Overview

Request 3720 (accepted)

- Update to version 18.0.1:
* CI: Fix true / false on stable builds
* CI: Add boolean arg parser to OSX
* CI: Deploy on tags and master branch
* CI: OSX - Deploy on all branches in the master repo.
* CI: OSX - Include branch in pkg
* enc-amf: Update to 1.4.3.11
* UI: Use correct string for systemTrayEnabled
* CI: OSX - Update to CEF 2987
* CI: Use correct folder for building browser
* CI: OSX - Use bash variable for CEF version
* UI: Don't exit on unknown command line arguments
* CI: OSX - export cef version so we can use it elsewhere
* CI: Fix cef version variable
* obs-outputs: Fix 100% CPU usage with new network code
* CI: OSX - Move CEF version to .travis
* VST: Fix save / load of plugin state. More interface options.
* UI: Fix audio monitoring dev. not being set on startup
* UI: Log audio monitoring dev. on start and when changed
* UI: Add logging of audio monitoring to sources
* VST: Fix crash when OBS is set to mono
* Revert "win-dshow: Add LGP timestamp fix"
* win-dshow: Actually fix LGP issue
* obs-outputs: Various fixes to new network code
* Update translations from Crowdin
* AUTHORS: Update with data from Git and Crowdin
* libobs: Apply sync offset to win32 audio monitoring
* UI: Disable network settings while outputs active
* Update translations from Crowdin
* AUTHORS: Update with data from Git and Crowdin

Submit package home:boombatow...es:Multimedia / obs-studio to package Multimedia / obs-studio

obs-studio.changes Changed
x
 
1
@@ -1,4 +1,48 @@
2
 -------------------------------------------------------------------
3
+Tue Mar 07 05:13:13 UTC 2017 - jimmy@boombatower.com
4
+
5
+- Update to version 18.0.1:
6
+  * CI: Fix true / false on stable builds
7
+  * CI: Add boolean arg parser to OSX
8
+  * CI: Deploy on tags and master branch
9
+  * CI: OSX - Deploy on all branches in the master repo.
10
+  * CI: OSX - Include branch in pkg
11
+  * enc-amf: Update to 1.4.3.11
12
+  * UI: Use correct string for systemTrayEnabled
13
+  * CI: OSX - Update to CEF 2987
14
+  * CI: Use correct folder for building browser
15
+  * CI: OSX - Use bash variable for CEF version
16
+  * UI: Don't exit on unknown command line arguments
17
+  * CI: OSX - export cef version so we can use it elsewhere
18
+  * CI: Fix cef version variable
19
+  * obs-outputs: Fix 100% CPU usage with new network code
20
+  * CI: OSX - Move CEF version to .travis
21
+  * VST: Fix save / load of plugin state. More interface options.
22
+  * UI: Fix audio monitoring dev. not being set on startup
23
+  * UI: Log audio monitoring dev. on start and when changed
24
+  * UI: Add logging of audio monitoring to sources
25
+  * VST: Fix crash when OBS is set to mono
26
+  * Revert "win-dshow: Add LGP timestamp fix"
27
+  * win-dshow: Actually fix LGP issue
28
+  * obs-outputs: Various fixes to new network code
29
+  * Update translations from Crowdin
30
+  * AUTHORS: Update with data from Git and Crowdin
31
+  * libobs: Apply sync offset to win32 audio monitoring
32
+  * UI: Disable network settings while outputs active
33
+  * Update translations from Crowdin
34
+  * AUTHORS: Update with data from Git and Crowdin
35
+  * CI: OSX - Brew install speexdsp
36
+  * CI: OSX - enable sparkle
37
+  * deps/blake2: Fix compiler warning
38
+  * UI: Fix game capture check when about to update
39
+  * deps: Add liblmza
40
+  * libobs: Update to 18.0.1
41
+  * updater: Add windows updater module
42
+  * UI/updater: Wait for OBS to close before updating
43
+  * obs-outputs: Improve shutdown behavior of new socket loop
44
+  * UI/updater: Use better function for getting process names
45
+
46
+-------------------------------------------------------------------
47
 Tue Feb 28 00:38:38 UTC 2017 - jimmy@boombatower.com
48
 
49
 - Update to version 18.0.0:
50
obs-studio.spec Changed
8
 
1
@@ -1,5 +1,5 @@
2
 Name:           obs-studio
3
-Version:        18.0.0
4
+Version:        18.0.1
5
 Release:        0
6
 Summary:        A recording/broadcasting program
7
 
8
_service Changed
10
 
1
@@ -1,7 +1,7 @@
2
 <services>
3
   <service name="tar_scm" mode="disabled">
4
     <param name="versionformat">@PARENT_TAG@</param>
5
-    <param name="revision">refs/tags/18.0.0</param>
6
+    <param name="revision">refs/tags/18.0.1</param>
7
     <param name="url">git://github.com/jp9000/obs-studio.git</param>
8
     <param name="scm">git</param>
9
     <param name="changesgenerate">enable</param>
10
_servicedata Changed
9
 
1
@@ -1,6 +1,6 @@
2
 <servicedata>
3
   <service name="tar_scm">
4
     <param name="url">git://github.com/jp9000/obs-studio.git</param>
5
-    <param name="changesrevision">5312ffa8157c4210cf57026f90eeb09e81a5a461</param>
6
+    <param name="changesrevision">bc9a58174b75c445dcb14259443a74746f0b3d43</param>
7
   </service>
8
 </servicedata>
9
obs-studio-18.0.0.tar.xz/.travis.yml -> obs-studio-18.0.1.tar.xz/.travis.yml Changed
20
 
1
@@ -11,7 +11,9 @@
2
 matrix:
3
   include:
4
     - os: osx
5
-      env: CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake
6
+      env:
7
+       - CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake
8
+       - CEF_BUILD_VERSION=3.2987.1588.g1952835
9
       before_install: "./CI/install-dependencies-osx.sh"
10
       before_script: "./CI/before-script-osx.sh"
11
       before_deploy: "./CI/before-deploy-osx.sh"
12
@@ -36,6 +38,7 @@
13
   on:
14
     repo: jp9000/obs-studio
15
     condition: "$TRAVIS_OS_NAME = osx"
16
+    all_branches: true
17
 
18
 # The channel name "azubu.il.us.quakenet.org#obs-dev" is encrypted against jp9000/obs-studio to prevent IRC spam of forks
19
 notifications:
20
obs-studio-18.0.0.tar.xz/AUTHORS -> obs-studio-18.0.1.tar.xz/AUTHORS Changed
80
 
1
@@ -1,4 +1,4 @@
2
-Contributors are sorted by their amount of commits / validated strings.
3
+Contributors are sorted by their amount of commits / translated strings.
4
 
5
 Contributors:
6
 Jim
7
@@ -7,15 +7,15 @@
8
 BtbN
9
 John Bradley
10
 Gol-D-Ace
11
-Zachary Lund
12
-Richard Stanway
13
 Colin Edwards
14
+Richard Stanway
15
+Zachary Lund
16
 Michael Fabian Dirks
17
 Martell Malone
18
 Christoph Hohmann
19
 HomeWorld
20
-dodgepong
21
 cg2121
22
+dodgepong
23
 derrod
24
 Ryan Foster
25
 Radzaquiel
26
@@ -154,6 +154,7 @@
27
 TotalCaesar659
28
 vic
29
 vividnightmare
30
+VodBox
31
 wayne wang
32
 Weikardzaena
33
 Will Jamieson
34
@@ -247,6 +248,7 @@
35
     Gol D. Ace (goldace)
36
     JorRy
37
 Estonian
38
+    MartinEwing
39
     AndresTraks
40
 Finnish
41
     ArkkisN (j)
42
@@ -258,12 +260,12 @@
43
 French
44
     radzaquiel
45
     Yberion
46
+    Nunzio Conte (nunzioconte54)
47
     Stéphane Lepin (Palakis)
48
     Léo (leeo97one)
49
     DoK_-
50
     BoboopTeam
51
     DarkInFire
52
-    Nunzio Conte (nunzioconte54)
53
     steve_fr
54
     Grisou2907
55
     McGuygnol
56
@@ -441,6 +443,7 @@
57
     Olle Dahström (odahlstrom)
58
     Gustav Ekner (ekner)
59
     Gol D. Ace (goldace)
60
+    Henrik Mattsson-Mårn (rchk)
61
     chaironeko
62
     Jonas Svensson (jonassanojj99)
63
 Tamil
64
@@ -451,8 +454,9 @@
65
     nongnoobjung (kitcharuk_4)
66
     dodgepong
67
 Turkish
68
-    omer.karagoz (mrkaragoz)
69
     Ali Kömesöğütlü (Mobile46) (byzlo685)
70
+    omer.karagoz (mrkaragoz)
71
+    monolifed
72
     Cemal Dursun (cmldrs)
73
     Savas Tokmak (Laserist)
74
     Murat Karagöz (anemon_1994)
75
@@ -470,3 +474,4 @@
76
     Hưng Nguyễn (hoyostudio)
77
     Hà Phi Hùng (haphihungcom)
78
     dodgepong
79
+    NCAA
80
obs-studio-18.0.0.tar.xz/CI/before-deploy-osx.sh -> obs-studio-18.0.1.tar.xz/CI/before-deploy-osx.sh Changed
26
 
1
@@ -10,7 +10,7 @@
2
 # Generate file name variables
3
 export GIT_HASH=$(git rev-parse --short HEAD)
4
 export FILE_DATE=$(date +%Y-%m-%d.%H:%M:%S)
5
-export FILENAME=$FILE_DATE-$GIT_HASH-osx.pkg
6
+export FILENAME=$FILE_DATE-$GIT_HASH-$TRAVIS_BRANCH-osx.pkg
7
 
8
 cd ./build
9
 
10
@@ -21,12 +21,12 @@
11
 
12
 # Package everything into a nice .app
13
 hr "Packaging .app"
14
-STABLE=False
15
+STABLE=false
16
 if [ -n "${TRAVIS_TAG}" ]; then
17
-  STABLE=TRUE
18
+  STABLE=true
19
 fi
20
 
21
-sudo python ../CI/install/osx/build_app.py --public-key ../CI/install/osx/OBSPublicDSAKey.pem --sparkle-framework ../../sparkle/Sparkle.framework --base-url "https://obsproject.com/osx_update" --stable $STABLE
22
+sudo python ../CI/install/osx/build_app.py --public-key ../CI/install/osx/OBSPublicDSAKey.pem --sparkle-framework ../../sparkle/Sparkle.framework --base-url "https://obsproject.com/osx_update" --stable=$STABLE
23
 
24
 # Move the CEF plugin back to where it belongs
25
 hr "Moving CEF back"
26
obs-studio-18.0.0.tar.xz/CI/before-script-osx.sh -> obs-studio-18.0.1.tar.xz/CI/before-script-osx.sh Changed
7
 
1
@@ -1,3 +1,3 @@
2
 mkdir build
3
 cd build
4
-cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 -DDepsPath=/tmp/obsdeps -DVLCPath=$PWD/../../vlc-master -DBUILD_BROWSER=ON -DCEF_ROOT_DIR=$PWD/../../cef_binary_3.2883.1540.gedbfb20_macosx64 ..
5
\ No newline at end of file
6
+cmake -DENABLE_SPARKLE_UPDATER=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 -DDepsPath=/tmp/obsdeps -DVLCPath=$PWD/../../vlc-master -DBUILD_BROWSER=ON -DCEF_ROOT_DIR=$PWD/../../cef_binary_${CEF_BUILD_VERSION}_macosx64 ..
7
obs-studio-18.0.0.tar.xz/CI/install-dependencies-osx.sh -> obs-studio-18.0.1.tar.xz/CI/install-dependencies-osx.sh Changed
26
 
1
@@ -14,7 +14,7 @@
2
 brew update
3
 
4
 #Base OBS Deps
5
-brew install qt5 jack
6
+brew install qt5 jack speexdsp
7
 
8
 # Fetch and untar prebuilt OBS deps that are compatible with older versions of OSX
9
 curl -L -O https://s3-us-west-2.amazonaws.com/obs-nightly/osx-deps.tar.gz -f --retry 5 -C -
10
@@ -28,11 +28,12 @@
11
 curl -L -o ./sparkle.tar.bz2 https://github.com/sparkle-project/Sparkle/releases/download/1.16.0/Sparkle-1.16.0.tar.bz2
12
 mkdir ./sparkle
13
 tar -xf ./sparkle.tar.bz2 -C ./sparkle
14
+sudo cp -R ./sparkle/Sparkle.framework /Library/Frameworks/Sparkle.framework
15
 
16
 # CEF Stuff
17
-curl -kLO http://opensource.spotify.com/cefbuilds/cef_binary_3.2883.1540.gedbfb20_macosx64.tar.bz2 -f --retry 5 -C -
18
-tar -xf ./cef_binary_3.2883.1540.gedbfb20_macosx64.tar.bz2
19
-cd ./cef_binary_3.2883.1540.gedbfb20_macosx64
20
+curl -kLO https://obs-nightly.s3-us-west-2.amazonaws.com/cef_binary_${CEF_BUILD_VERSION}_macosx64.tar.bz2 -f --retry 5 -C -
21
+tar -xf ./cef_binary_${CEF_BUILD_VERSION}_macosx64.tar.bz2
22
+cd ./cef_binary_${CEF_BUILD_VERSION}_macosx64
23
 mkdir build
24
 cd ./build
25
 cmake -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 ..
26
obs-studio-18.0.0.tar.xz/CI/install/osx/build_app.py -> obs-studio-18.0.1.tar.xz/CI/install/osx/build_app.py Changed
38
 
1
@@ -26,6 +26,20 @@
2
 import plistlib
3
 
4
 import argparse
5
+
6
+def _str_to_bool(s):
7
+    """Convert string to bool (in argparse context)."""
8
+    if s.lower() not in ['true', 'false']:
9
+        raise ValueError('Need bool; got %r' % s)
10
+    return {'true': True, 'false': False}[s.lower()]
11
+
12
+def add_boolean_argument(parser, name, default=False):                                                                                               
13
+    """Add a boolean argument to an ArgumentParser instance."""
14
+    group = parser.add_mutually_exclusive_group()
15
+    group.add_argument(
16
+        '--' + name, nargs='?', default=default, const=True, type=_str_to_bool)
17
+    group.add_argument('--no' + name, dest=name, action='store_false')
18
+
19
 parser = argparse.ArgumentParser(description='obs-studio package util')
20
 parser.add_argument('-d', '--base-dir', dest='dir', default='rundir/RelWithDebInfo')
21
 parser.add_argument('-n', '--build-number', dest='build_number', default='0')
22
@@ -34,7 +48,7 @@
23
 parser.add_argument('-b', '--base-url', dest='base_url', default='https://builds.catchexception.org/obs-studio')
24
 parser.add_argument('-u', '--user', dest='user', default='jp9000')
25
 parser.add_argument('-c', '--channel', dest='channel', default='master')
26
-parser.add_argument('-s', '--stable', dest='stable', required=False, action='store_true', default=False)
27
+add_boolean_argument(parser, 'stable', default=False)
28
 parser.add_argument('-p', '--prefix', dest='prefix', default='')
29
 args = parser.parse_args()
30
 
31
@@ -208,4 +222,4 @@
32
    rename("tmp", app_name)
33
 except:
34
    print("App already exists")
35
-   rmtree("tmp")
36
\ No newline at end of file
37
+   rmtree("tmp")
38
obs-studio-18.0.0.tar.xz/UI/CMakeLists.txt -> obs-studio-18.0.1.tar.xz/UI/CMakeLists.txt Changed
8
 
1
@@ -252,3 +252,6 @@
2
 endif()
3
 
4
 add_subdirectory(frontend-plugins)
5
+if(WIN32)
6
+   add_subdirectory(win-update/updater)
7
+endif()
8
obs-studio-18.0.0.tar.xz/UI/adv-audio-control.cpp -> obs-studio-18.0.1.tar.xz/UI/adv-audio-control.cpp Changed
25
 
1
@@ -297,6 +297,23 @@
2
 {
3
    int mt = monitoringType->itemData(index).toInt();
4
    obs_source_set_monitoring_type(source, (obs_monitoring_type)mt);
5
+
6
+   const char *type = nullptr;
7
+
8
+   switch (mt) {
9
+   case OBS_MONITORING_TYPE_NONE:
10
+       type = "none";
11
+       break;
12
+   case OBS_MONITORING_TYPE_MONITOR_ONLY:
13
+       type = "monitor only";
14
+       break;
15
+   case OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT:
16
+       type = "monitor and output";
17
+       break;
18
+   }
19
+
20
+   blog(LOG_INFO, "User changed audio monitoring for source '%s' to: %s",
21
+           obs_source_get_name(source), type);
22
 }
23
 
24
 static inline void setMixer(obs_source_t *source, const int mixerIdx,
25
obs-studio-18.0.0.tar.xz/UI/data/locale/da-DK.ini -> obs-studio-18.0.1.tar.xz/UI/data/locale/da-DK.ini Changed
65
 
1
@@ -4,11 +4,11 @@
2
 
3
 OK="OK"
4
 Apply="Anvend"
5
-Cancel="Annuller"
6
+Cancel="Annullér"
7
 Close="Luk"
8
 Save="Gem"
9
 Discard="Kassér"
10
-Disable="Deaktiver"
11
+Disable="Deaktivér"
12
 Yes="Ja"
13
 No="Nej"
14
 Add="Tilføj"
15
@@ -27,10 +27,10 @@
16
 Browse="Browse"
17
 Mono="Mono"
18
 Stereo="Stereo"
19
-DroppedFrames="Taber frames %1 (%2%)"
20
-PreviewProjector="Fuldskærms projektering (forhåndsvisning)"
21
-SceneProjector="Fuldskærms projektering (scene)"
22
-SourceProjector="Fuldskærms projektering (kilde)"
23
+DroppedFrames="Tabte frames %1 (%2%)"
24
+PreviewProjector="Fuldskærmsprojektering (forhåndsvisning)"
25
+SceneProjector="Fuldskærmsprojektering (scene)"
26
+SourceProjector="Fuldskærmsprojektering (kilde)"
27
 Clear="Ryd"
28
 Revert="Gendan"
29
 Show="Vis"
30
@@ -191,6 +191,10 @@
31
 Deinterlacing.TopFieldFirst="Øverste felt først"
32
 Deinterlacing.BottomFieldFirst="Nederste felt først"
33
 
34
+VolControl.SliderUnmuted="Lydstyrkeskyder for '%1': %2"
35
+VolControl.SliderMuted="Lydstyrkeskyder for '%1': %2 (lyd i øjeblikket slået fra)"
36
+VolControl.Mute="Gør '%1' tavs"
37
+VolControl.Properties="Egenskaber for '%1'"
38
 
39
 Basic.Main.AddSceneDlg.Title="Tilføje scene"
40
 Basic.Main.AddSceneDlg.Text="Angiv navnet på scene"
41
@@ -477,6 +481,8 @@
42
 Basic.Settings.Output.Adv.FFmpeg.AEncoder="Lyd encoder"
43
 Basic.Settings.Output.Adv.FFmpeg.AEncoderSettings="Lyd encoder indstillinger (hvis nogen)"
44
 Basic.Settings.Output.Adv.FFmpeg.MuxerSettings="Muxer indstillinger (hvis nogen)"
45
+Basic.Settings.Output.Adv.FFmpeg.GOPSize="Keyframe-Interval (billeder)"
46
+Basic.Settings.Output.Adv.FFmpeg.IgnoreCodecCompat="Vis alle codecs (selv potentielt inkompatible)"
47
 
48
 FilenameFormatting.completer="%CCYY-%MM-%DD %hh-%mm-%ss\n%YY-%MM-%DD %hh-%mm-%ss\n%Y-%m-%d %H-%M-%S\n%y-%m-%d %H-%M-%S\n%a %Y-%m-%d %H-%M-%S\n%A %Y-%m-%d %H-%M-%S\n%Y-%b-%d %H-%M-%S\n%Y-%B-%d %H-%M-%S\n%Y-%m-%d %I-%M-%S-%p\n%Y-%m-%d %H-%M-%S-%z\n%Y-%m-%d %H-%M-%S-%Z"
49
 
50
@@ -538,6 +544,8 @@
51
 Basic.Settings.Advanced.StreamDelay.MemoryUsage="Anslået hukommelsesbrug: %1 MB"
52
 Basic.Settings.Advanced.Network="Netværk"
53
 Basic.Settings.Advanced.Network.BindToIP="Bind til IP"
54
+Basic.Settings.Advanced.Network.EnableNewSocketLoop="Aktivér ny netværkskode"
55
+Basic.Settings.Advanced.Network.EnableLowLatencyMode="Lav forsinkelsestilstand"
56
 
57
 Basic.AdvAudio="Avancerede lydegenskaber"
58
 Basic.AdvAudio.Name="Navn"
59
@@ -607,4 +615,5 @@
60
 
61
 OutputWarnings.NoTracksSelected="Du skal vælge minimum ét spor"
62
 OutputWarnings.MultiTrackRecording="Advarsel: Visse formater (såsom FLV) understøtter ikke flere spor pr. optagelse"
63
+OutputWarnings.MP4Recording="Advarsel: MP4-optagelser vil ikke kunne genoprettes, hvis filen ikke kan færdiggøres (f.eks. som følge af BSODs, strømafbrydelse m.v.). Ønsker du at optage flere lydspor, overvej da at benytte MKV, og remuxe optagelsen til MP4, efter at den er færdiggjort (fil-> Remux optagelser)"
64
 
65
obs-studio-18.0.0.tar.xz/UI/data/locale/et-EE.ini -> obs-studio-18.0.1.tar.xz/UI/data/locale/et-EE.ini Changed
156
 
1
@@ -48,11 +48,31 @@
2
 Right="Paremalt"
3
 Top="Ülalt"
4
 Bottom="Alt"
5
-
6
+Reset="Lähtesta"
7
+Hours="Tundi"
8
+Minutes="Minutit"
9
+Seconds="Sekundit"
10
+Deprecated="Aegunud"
11
+ReplayBuffer="Taasesituse puhver"
12
+Import="Impordi"
13
+Export="Ekspordi"
14
+
15
+Updater.Title="Uus värskendus saadaval"
16
+Updater.Text="Uus värskendus on saadaval:"
17
+Updater.UpdateNow="Värskenda kohe"
18
+Updater.RemindMeLater="Tuleta mulle hiljem meelde"
19
+Updater.Skip="Jäta vahele versioon"
20
+Updater.Running.Title="Programm on hetkel aktiivne"
21
+Updater.Running.Text="Väljundid on hetkel aktiivsed, palun sulgege aktiivsed väljundid enne uuendamist"
22
+Updater.NoUpdatesAvailable.Title="Uusi värskendusi pole saadaval"
23
+Updater.NoUpdatesAvailable.Text="Värskendusi pole praegu saadaval"
24
+Updater.FailedToLaunch="Uuendaja käivitamine nurjus"
25
+Updater.GameCaptureActive.Title="Mängu hõive on aktiivne"
26
 
27
 QuickTransitions.SwapScenes="Vaheta üleminekul eelvaade ja väljund"
28
 QuickTransitions.SwapScenesTT="Vahetab pärast üleminekut eelvaate ja väljundi stseenid (kui väljundi esialgne stseen on veel olemas).\nEsialgsele stseenile tehtud muudatusi ei pöörata tagasi."
29
 QuickTransitions.DuplicateScene="Tee stseenist koopia"
30
+QuickTransitions.EditProperties="Dubleeritud allikad"
31
 QuickTransitions.HotkeyName="Valitud üleminek: %1"
32
 
33
 Basic.AddTransition="Lisa seadistatav üleminek"
34
@@ -86,14 +106,19 @@
35
 ConfirmRemove.Title="Ümbernimetamise kinnitamine"
36
 ConfirmRemove.Text="Kas soovid kindlasti eemaldada '$1'?"
37
 
38
+Output.StartStreamFailed="Voogedastuse alustamine nurjus"
39
+Output.StartRecordingFailed="Salvestamise alustamine nurjus"
40
 
41
 Output.ConnectFail.Title="Ühendamine ei õnnestunud"
42
 Output.ConnectFail.BadPath="Vigane rada või ühenduse URL. Palun veendu, et valitud sätted on õiged."
43
 Output.ConnectFail.ConnectFailed="Serveriga ühendamine ebaõnnestus"
44
 
45
+Output.RecordError.Title="Salvestamise tõrge"
46
 
47
 
48
+LogReturnDialog.CopyURL="Kopeeri aadress"
49
 
50
+LicenseAgreement.IAgree="Nõustun"
51
 LicenseAgreement.Exit="Välju"
52
 
53
 Remux.SourceFile="OBS-i salvestus"
54
@@ -120,15 +145,20 @@
55
 
56
 Basic.Main.PreviewConextMenu.Enable="Lülita eelvaade sisse"
57
 
58
+ScaleFiltering.Point="Punkt"
59
 
60
 
61
+VolControl.Properties="'%1' atribuudid"
62
 
63
 Basic.Main.AddSceneDlg.Title="Stseeni lisamine"
64
 Basic.Main.AddSceneDlg.Text="Sisesta stseeni nimi"
65
 
66
 Basic.Main.DefaultSceneName.Text="Stseen %1"
67
 
68
+Basic.Main.AddSceneCollection.Title="Lisada stseeni kogumik"
69
+Basic.Main.AddSceneCollection.Text="Palun sisestage stseeni kogumiku nimi"
70
 
71
+Basic.Main.RenameSceneCollection.Title="Nimeta ümber stseeni kogumik"
72
 
73
 AddProfile.Title="Profiili lisamine"
74
 AddProfile.Text="Sisesta uue profiili nimi"
75
@@ -143,6 +173,9 @@
76
 Basic.SourceSelect.AddVisible="Tee allikas nähtavaks"
77
 
78
 Basic.PropertiesWindow="'%1' omadused"
79
+Basic.PropertiesWindow.AddFiles="Lisa failid"
80
+Basic.PropertiesWindow.AddDir="Lisa kataloog"
81
+Basic.PropertiesWindow.AddURL="Lisa tee/URL"
82
 
83
 
84
 
85
@@ -151,6 +184,7 @@
86
 Basic.Filters.AudioFilters="Helifiltrid"
87
 Basic.Filters.AddFilter.Title="Filtri nimi"
88
 
89
+Basic.TransformWindow.Position="Asukoht"
90
 Basic.TransformWindow.Rotation="Pööramine"
91
 Basic.TransformWindow.Size="Suurus"
92
 Basic.TransformWindow.Alignment="Joondamine"
93
@@ -190,27 +224,51 @@
94
 
95
 Basic.MainMenu.Edit="Muuda (&E)"
96
 Basic.MainMenu.Edit.Undo="Võta tagasi (&U)"
97
-
98
-
99
+Basic.MainMenu.Edit.UndoAction="&Võta tagasi $1"
100
+Basic.MainMenu.Edit.Transform.Rotate90CW="Pööra 90 kraadi paremale"
101
+Basic.MainMenu.Edit.Transform.Rotate90CCW="Pööra 90 kraadi vasakule"
102
+Basic.MainMenu.Edit.Transform.Rotate180="Pööra 180 kraadi"
103
+Basic.MainMenu.Edit.Transform.FitToScreen="&Sobita ekraanile"
104
+Basic.MainMenu.Edit.Transform.StretchToScreen="&Venita ekraanile"
105
+Basic.MainMenu.Edit.Order="&Järjekord"
106
+Basic.MainMenu.Edit.Order.MoveUp="Liiguta &Üles"
107
+Basic.MainMenu.Edit.Order.MoveDown="Liiguta &Alla"
108
+Basic.MainMenu.Edit.Order.MoveToTop="Liiguta &Esimeseks"
109
+Basic.MainMenu.Edit.Order.MoveToBottom="Liiguta &Viimaseks"
110
+Basic.MainMenu.Edit.AdvAudio="&Täpsemad Heliatribuudid"
111
+
112
+Basic.MainMenu.View="&Vaade"
113
+Basic.MainMenu.View.Toolbars="&Tööriistaribad"
114
+Basic.MainMenu.View.SceneTransitions="S&tseeni üleminekud"
115
+Basic.MainMenu.View.StatusBar="&Olekuriba"
116
+
117
+Basic.MainMenu.SceneCollection="&Stseeni kogumik"
118
+Basic.MainMenu.Profile="&Profiil"
119
 
120
 
121
 Basic.MainMenu.Help.Logs="&Logifailid"
122
 Basic.MainMenu.Help.CheckForUpdates="Otsi värskendusi"
123
 
124
 
125
+Basic.Settings.General.Theme="Teema"
126
 Basic.Settings.General.Language="Keel"
127
+Basic.Settings.General.Projectors="Projektorid"
128
 
129
 Basic.Settings.Stream="Voogedastus"
130
 Basic.Settings.Stream.StreamType="Voogedastuse tüüp"
131
 
132
 Basic.Settings.Output="Väljund"
133
 Basic.Settings.Output.Format="Salvestusvorming"
134
+Basic.Settings.Output.Encoder="Kodeerija"
135
 Basic.Settings.Output.SelectDirectory="Vali salvestuskaust"
136
 Basic.Settings.Output.Mode="Väljundrežiim"
137
 Basic.Settings.Output.Mode.Simple="Lihtne"
138
 Basic.Settings.Output.Mode.Adv="Täpsemad seaded"
139
 Basic.Settings.Output.Simple.Encoder.Software="Tarkvara (x264)"
140
 Basic.Settings.Output.Simple.Encoder.Hardware.QSV="Riistvara (QSV)"
141
+Basic.Settings.Output.Simple.Encoder.Hardware.AMD="Riistvara (AMD)"
142
+Basic.Settings.Output.Simple.Encoder.Hardware.NVENC="Riistvara (NVENC)"
143
+Basic.Settings.Output.Simple.Encoder.SoftwareLowCPU="Tarkvara (x264 madal CPU kasutus, suurendab faili suurust)"
144
 
145
 Basic.Settings.Output.Adv.AudioTrack="Helirada"
146
 Basic.Settings.Output.Adv.Streaming="Voogedastus"
147
@@ -241,6 +299,8 @@
148
 Basic.Settings.Video.InvalidResolution="Eraldusvõime ei sobi. See peab olema kujul [width]x[height] (nt 1920x1080)"
149
 
150
 
151
+Basic.Settings.Audio.DesktopDevice="Töölaua heliseade"
152
+Basic.Settings.Audio.DesktopDevice2="Töölaua heliseade 2"
153
 
154
 Basic.Settings.Advanced.Video.ColorRange.Partial="Osaline"
155
 Basic.Settings.Advanced.Video.ColorRange.Full="Täielik"
156
obs-studio-18.0.0.tar.xz/UI/data/locale/fr-FR.ini -> obs-studio-18.0.1.tar.xz/UI/data/locale/fr-FR.ini Changed
7
 
1
@@ -615,4 +615,5 @@
2
 
3
 OutputWarnings.NoTracksSelected="Vous devez sélectionner au moins une piste"
4
 OutputWarnings.MultiTrackRecording="Attention : Certains formats (comme FLV) ne supportent pas les pistes multiples pour un même enregistrement"
5
+OutputWarnings.MP4Recording="Avertissement: Les enregistrements sauvegardés sur MP4 seront irrécupérables si le fichier ne peut pas être finalisé (par exemple, à cause des BSOD, des pertes de puissance, etc.). Si vous voulez enregistrer plusieurs pistes audio, pensez à utiliser MKV et remux l'enregistrement au mp4 après qu'il est terminé (File-> Remux Recordings)"
6
 
7
obs-studio-18.0.0.tar.xz/UI/data/locale/ko-KR.ini -> obs-studio-18.0.1.tar.xz/UI/data/locale/ko-KR.ini Changed
9
 
1
@@ -194,6 +194,7 @@
2
 VolControl.SliderUnmuted="'%1'의 음량 조절: %2"
3
 VolControl.SliderMuted="'%1'의 음량 조절: %2 (현재 음소거)"
4
 VolControl.Mute="음소거 '%1'"
5
+VolControl.Properties="'%1' 속성"
6
 
7
 Basic.Main.AddSceneDlg.Title="장면 추가"
8
 Basic.Main.AddSceneDlg.Text="장면의 이름을 입력하십시오"
9
obs-studio-18.0.0.tar.xz/UI/data/locale/sv-SE.ini -> obs-studio-18.0.1.tar.xz/UI/data/locale/sv-SE.ini Changed
34
 
1
@@ -304,7 +304,7 @@
2
 Basic.MainMenu.File.Export="&Exportera"
3
 Basic.MainMenu.File.Import="&Importera"
4
 Basic.MainMenu.File.ShowRecordings="Visa &inspelningar"
5
-Basic.MainMenu.File.Remux="Re&mux Inspelningar"
6
+Basic.MainMenu.File.Remux="Re&muxa inspelningar"
7
 Basic.MainMenu.File.Settings="&Inställningar"
8
 Basic.MainMenu.File.ShowSettingsFolder="Visa inställningsmapp"
9
 Basic.MainMenu.File.ShowProfileFolder="Visa profilmapp"
10
@@ -481,6 +481,8 @@
11
 Basic.Settings.Output.Adv.FFmpeg.AEncoder="Ljudkodare"
12
 Basic.Settings.Output.Adv.FFmpeg.AEncoderSettings="Ljudkodar-inställningar (om något)"
13
 Basic.Settings.Output.Adv.FFmpeg.MuxerSettings="Muxerinställningar (om det finns)"
14
+Basic.Settings.Output.Adv.FFmpeg.GOPSize="Intervall för keyframes (bildrutor)"
15
+Basic.Settings.Output.Adv.FFmpeg.IgnoreCodecCompat="Visa alla kodekar (även de som eventuellt inte är kompatibla)"
16
 
17
 FilenameFormatting.completer="%CCYY-%MM-%DD %hh-%mm-%ss\n%YY-%MM-%DD %hh-%mm-%ss\n%Y-%m-%d %H-%M-%S\n%y-%m-%d %H-%M-%S\n%a %Y-%m-%d %H-%M-%S\n%A %Y-%m-%d %H-%M-%S\n%Y-%b-%d %H-%M-%S\n%Y-%B-%d %H-%M-%S\n%Y-%m-%d %I-%M-%S-%p\n%Y-%m-%d %H-%M-%S-%z\n%Y-%m-%d %H-%M-%S-%Z"
18
 
19
@@ -552,6 +554,8 @@
20
 Basic.AdvAudio.Panning="Panorering"
21
 Basic.AdvAudio.SyncOffset="Sync Offset (ms)"
22
 Basic.AdvAudio.Monitoring="Ljuduppspelning"
23
+Basic.AdvAudio.Monitoring.None="Monitor av"
24
+Basic.AdvAudio.Monitoring.Both="Monitor och utgång"
25
 Basic.AdvAudio.AudioTracks="Spår"
26
 
27
 Basic.Settings.Hotkeys="Kortkommandon"
28
@@ -610,4 +614,5 @@
29
 
30
 OutputWarnings.NoTracksSelected="Du måste välja minst ett spår"
31
 OutputWarnings.MultiTrackRecording="Varning: En del format (t.ex. FLV) stöder inte flera spår för varje inspelning"
32
+OutputWarnings.MP4Recording="Varning: Inspelningar som sparas som MP4 kommer inte att kunna återställas om filen inte kan slutföras (d.v.s. om en datorkrasch, strömavbrott, etc. skulle inträffa). Om du vill spela in flera ljudspår, överväg att använda MKV och remuxa inspelningen till mp4 när den är färdig (Arkiv->Remuxa inspelningar)"
33
 
34
obs-studio-18.0.0.tar.xz/UI/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/UI/data/locale/tr-TR.ini Changed
179
 
1
@@ -8,7 +8,7 @@
2
 Close="Kapat"
3
 Save="Kaydet"
4
 Discard="Vazgeç"
5
-Disable="Devre dışı bırak"
6
+Disable="Devre Dışı Bırak"
7
 Yes="Evet"
8
 No="Hayır"
9
 Add="Ekle"
10
@@ -20,7 +20,7 @@
11
 MoveUp="Yukarı Taşı"
12
 MoveDown="Aşağı Taşı"
13
 Settings="Ayarlar"
14
-Display="Görüntüle"
15
+Display="Ekran"
16
 Name="İsim"
17
 Exit="Çık"
18
 Mixer="Karıştırıcı"
19
@@ -39,7 +39,7 @@
20
 New="Yeni"
21
 Duplicate="Çoğalt"
22
 Enable="Etkinleştir"
23
-DisableOSXVSync="OSX V-Sync Devre Dışı Bırakma"
24
+DisableOSXVSync="OSX V-Sync Devre Dışı Bırak"
25
 ResetOSXVSyncOnExit="OSX V-Sync'i Çıkışta Sıfırla"
26
 HighResourceUsage="Kodlama aşırı yüklendi!  Video ayarlarını kapatmayı veya daha hızlı bir kodlama ön ayarını kullanmayı düşünün."
27
 Transition="Geçiş"
28
@@ -63,13 +63,19 @@
29
 Updater.RemindMeLater="Daha sonra hatırlat"
30
 Updater.Skip="Sürümü Atla"
31
 Updater.Running.Title="Program şu anda etkin"
32
+Updater.Running.Text="Çıkışlar hala etkin, lütfen güncellemeye çalışmadan önce aktif çıkışları kapatın"
33
 Updater.NoUpdatesAvailable.Title="Güncelleme mevcut değil"
34
 Updater.NoUpdatesAvailable.Text="Şu anda mevcut hiçbir güncelleme yok"
35
 Updater.FailedToLaunch="Güncelleyici başlatılamadı"
36
 Updater.GameCaptureActive.Title="Oyun yakalama etkin"
37
+Updater.GameCaptureActive.Text="Oyun yakalama kanca kütüphanesi hala kullanımda. Lütfen yakalanmakta olan oyunları/programları kapatın (veya Windows'u yeniden başlatın) ve yeniden deneyin."
38
 
39
+QuickTransitions.SwapScenes="Geçişten Sonra Önizleme/Çıkış Sahnelerini Değiştir"
40
+QuickTransitions.SwapScenesTT="Geçişten sonra çıkış ve ön izleme sahnelerinin yerini değiştirir (çıkışın orijinal sahnesi hala mevcutsa).\n Bu çıkışın orijinal sahnesine yapılan değişiklikleri geri almayacaktır."
41
 QuickTransitions.DuplicateScene="Sahneyi Çoğalt"
42
+QuickTransitions.DuplicateSceneTT="Aynı sahneyi düzenlerken, çıkışı değiştirmeden kaynakların dönüşümünü veya görünülürlüğünü düzenlemeye izin verir.\nKaynakların özelliklerini çıkışı değiştirmeden düzenlemek için 'Kaynakları Çoğalt'ı etkinleştirin.\nBu değeri değiştirmek mevcut çıkış sahnesini sıfırlar (hala varsa)."
43
 QuickTransitions.EditProperties="Kaynakları Çoğalt"
44
+QuickTransitions.EditPropertiesTT="Aynı sahneyi düzenlerken, çıkışı değiştirmeden kaynakların özelliklerinin düzenlenmesine izin verir.\nSadece 'Sahneyi Çoğalt' etkinse kullanılabilir.\nBelli kaynaklar (yakalama ve medya kaynakları gibi) bunu desteklemez ve ayrı olarak düzenlenemez.\nBu değeri değiştirmek mevcut çıkış sahnesini sıfırlar (hala varsa).\n\nUyarı: Kaynaklar çoğaltılacağından, ek sistem ve video kaynağı gerektirebilir."
45
 QuickTransitions.HotkeyName="Hızlı Geçiş: %1"
46
 
47
 Basic.AddTransition="Yapılandırılabilir Geçiş Ekle"
48
@@ -85,11 +91,11 @@
49
 TitleBar.Profile="Profil"
50
 TitleBar.Scenes="Sahneler"
51
 
52
-NameExists.Title="Bu isim zaten mevcut"
53
+NameExists.Title="İsim zaten mevcut"
54
 NameExists.Text="Bu isim zaten kullanılıyor."
55
 
56
 NoNameEntered.Title="Lütfen geçerli bir isim girin"
57
-NoNameEntered.Text="İsmi boş kullanamazsınız."
58
+NoNameEntered.Text="İsim boş olamaz."
59
 
60
 ConfirmStart.Title="Yayın Başlatılsın Mı?"
61
 ConfirmStart.Text="Yayını gerçekten başlatmak istiyor musunuz?"
62
@@ -121,6 +127,7 @@
63
 Output.RecordError.Title="Kayıt Hatası"
64
 Output.RecordError.Msg="Kayıt anında bir hata oluştu."
65
 Output.ReplayBuffer.NoHotkey.Title="Kısayol tuşu ayarlanmadı!"
66
+Output.ReplayBuffer.NoHotkey.Msg="Yeniden oynatma arabelleği için ayarlı bir kısayol tuşu yok. Lütfen yeniden oynatma kayıtlarını kaydetmek için \"Kaydet\" kısayol tuşunu ayarlayın."
67
 
68
 Output.BadPath.Title="Dosya Yolu Geçersiz"
69
 Output.BadPath.Text="Ayarlanan dosya kayıt yolu geçersiz. Lütfen ayarlarınızı kontrol ederek geçerli bir dosya yolunun girilmiş olduğundan emin olunuz."
70
@@ -164,10 +171,10 @@
71
 
72
 Basic.Main.PreviewConextMenu.Enable="Önizlemeyi Etkinleştir"
73
 
74
-ScaleFiltering="Ölçek Filtreleme"
75
+ScaleFiltering="Boyut Filtreleme"
76
 ScaleFiltering.Point="Nokta"
77
 ScaleFiltering.Bilinear="Bilinear"
78
-ScaleFiltering.Bicubic="Bicubic"
79
+ScaleFiltering.Bicubic="Bikübik"
80
 ScaleFiltering.Lanczos="Lanczos"
81
 
82
 Deinterlacing="Deinterlacing"
83
@@ -183,6 +190,8 @@
84
 Deinterlacing.BottomFieldFirst="Önce Alt Alan"
85
 
86
 VolControl.SliderUnmuted="'%1' için ses kaydırıcı: %2"
87
+VolControl.SliderMuted="Повзунок гучності для '%1': %2 (şu anda sessiz)"
88
+VolControl.Mute="Sessiz '%1'"
89
 VolControl.Properties="'%1' için özellikler"
90
 
91
 Basic.Main.AddSceneDlg.Title="Sahne Ekle"
92
@@ -265,9 +274,9 @@
93
 Basic.TransformWindow.Alignment.BottomRight="Sağ alt"
94
 
95
 Basic.TransformWindow.BoundsType.None="Sınırsız"
96
-Basic.TransformWindow.BoundsType.MaxOnly="Yalnızca en büyük boyutu"
97
-Basic.TransformWindow.BoundsType.ScaleInner="İç sınırlara ölçekle"
98
-Basic.TransformWindow.BoundsType.ScaleOuter="Dış sınırlara göre boyutlandır"
99
+Basic.TransformWindow.BoundsType.MaxOnly="Yalnızca maksimum boyut"
100
+Basic.TransformWindow.BoundsType.ScaleInner="İç sınırlara boyutlandır"
101
+Basic.TransformWindow.BoundsType.ScaleOuter="Dış sınırlara boyutlandır"
102
 Basic.TransformWindow.BoundsType.ScaleToWidth="Sınır genişliğinde boyutlandır"
103
 Basic.TransformWindow.BoundsType.ScaleToHeight="Sınır yüksekliğinde boyutlandır"
104
 Basic.TransformWindow.BoundsType.Stretch="Sınırlara genişlet"
105
@@ -306,10 +315,10 @@
106
 Basic.MainMenu.Edit.UndoAction="&$1 Geri al"
107
 Basic.MainMenu.Edit.RedoAction="&$1 Yinele"
108
 Basic.MainMenu.Edit.LockPreview="&Önizlemeyi Kilitle"
109
-Basic.MainMenu.Edit.Scale="Ölçekleme &Önizleme"
110
-Basic.MainMenu.Edit.Scale.Window="Pencereye Ölçekle"
111
+Basic.MainMenu.Edit.Scale="Boyutlandırmayı &Önizle"
112
+Basic.MainMenu.Edit.Scale.Window="Pencereye Boyutlandır"
113
 Basic.MainMenu.Edit.Scale.Canvas="Tuval (%1x%2)"
114
-Basic.MainMenu.Edit.Scale.Output="Çıktı (%1x%2)"
115
+Basic.MainMenu.Edit.Scale.Output="Çıkış (%1x%2)"
116
 Basic.MainMenu.Edit.Transform="&Dönüştür"
117
 Basic.MainMenu.Edit.Transform.EditTransform="&Dönüştürmeyi Düzenle..."
118
 Basic.MainMenu.Edit.Transform.CopyTransform="Dönüştürmeyi Kopyala"
119
@@ -401,6 +410,7 @@
120
 Basic.Settings.Output.ReplayBuffer.MegabytesMax="Maksimum Bellek (Megabayt)"
121
 Basic.Settings.Output.ReplayBuffer.Estimate="Tahmini bellek kullanımı: %1 MB"
122
 Basic.Settings.Output.ReplayBuffer.EstimateUnknown="Bellek kullanımını tahmin edemezsin. Lütfen maksimum bellek sınırını ayarlayın."
123
+Basic.Settings.Output.ReplayBuffer.HotkeyMessage="(Not: kısayol tuşları bölümünde yeniden oynatma ara belleği için kısayol tuşu ayarladığınızdan emin olun)"
124
 Basic.Settings.Output.ReplayBuffer.Prefix="Tekrar Oynatma Arabelleği Dosya Adı Öneki"
125
 Basic.Settings.Output.ReplayBuffer.Suffix="Suffix"
126
 Basic.Settings.Output.Simple.SavePath="Kayıt Yolu"
127
@@ -420,14 +430,14 @@
128
 Basic.Settings.Output.AudioBitrate="Ses Bit Hızı"
129
 Basic.Settings.Output.Reconnect="Otomatik Yeniden Bağlan"
130
 Basic.Settings.Output.RetryDelay="Yeniden Deneme Gecikmesi (saniye)"
131
-Basic.Settings.Output.MaxRetries="En fazla yeniden deneme sayısı"
132
+Basic.Settings.Output.MaxRetries="Maksimum Deneme Sayısı"
133
 Basic.Settings.Output.Advanced="Gelişmiş Kodlayıcı Ayarlarını Etkinleştir"
134
 Basic.Settings.Output.EncoderPreset="Kodlayıcı Önayarı (yüksek = daha az İŞLEMCİ)"
135
 Basic.Settings.Output.CustomEncoderSettings="Özel Kodlayıcı Ayarları"
136
 Basic.Settings.Output.CustomMuxerSettings="Özel Muxer Ayarları"
137
 Basic.Settings.Output.NoSpaceFileName="Dosya ismini boşluk olmadan oluştur"
138
 
139
-Basic.Settings.Output.Adv.Rescale="Çıkışı Yeniden Ölçeklendir"
140
+Basic.Settings.Output.Adv.Rescale="Çıkışı Yeniden Boyutlandır"
141
 Basic.Settings.Output.Adv.AudioTrack="Ses Parçası"
142
 Basic.Settings.Output.Adv.Streaming="Yayın"
143
 Basic.Settings.Output.Adv.ApplyServiceSettings="Yayın hizmetini kodlayıcı ayarlarına zorla"
144
@@ -464,15 +474,18 @@
145
 Basic.Settings.Output.Adv.FFmpeg.AEncoder="Ses Kodlayıcı"
146
 Basic.Settings.Output.Adv.FFmpeg.AEncoderSettings="Ses Kodlayıcı Ayarları (var ise)"
147
 Basic.Settings.Output.Adv.FFmpeg.MuxerSettings="Muxer Ayarları (eğer varsa)"
148
+Basic.Settings.Output.Adv.FFmpeg.GOPSize="Anahtar Kare Aralığı (kare)"
149
+Basic.Settings.Output.Adv.FFmpeg.IgnoreCodecCompat="Tüm kodekleri göster (potansiyel olarak uyumsuz olsa bile)"
150
 
151
 FilenameFormatting.completer="%CCYY-%MM-%DD %hh-%mm-%ss\n%YY-%MM-%DD %hh-%mm-%ss\n%Y-%m-%d %H-%M-%S\n%y-%m-%d %H-%M-%S\n%a %Y-%m-%d %H-%M-%S\n%A %Y-%m-%d %H-%M-%S\n%Y-%b-%d %H-%M-%S\n%Y-%B-%d %H-%M-%S\n%Y-%m-%d %I-%M-%S-%p\n%Y-%m-%d %H-%M-%S-%z\n%Y-%m-%d %H-%M-%S-%Z"
152
 
153
+FilenameFormatting.TT="%CCYY   Yıl, dört hane\n%YY     Yıl, son iki hane (00-99)\n%MM      Ay rakamla (01-12)\n%DD     Ayın günü, önü-sıfırlı (01-31)\n%hh     Saat 24s formatlı (00-23)\n%mm      Dakika (00-59)\n%ss     Saniye (00-61)\n%%      A % sign\n%a        Kısaltılmış gün adı\n%A     Tam gün adı\n%b     Kısaltılmış ay adı\n%B      Tam ay adı\n%d      Ayın günü, önü-sıfırlı (01-31)\n%H      Saat 24s formatlı (00-23)\n%I       Saat 12s formatlı (01-12)\n%m       Ay rakamla (01-12)\n%M      Dakika (00-59)\n%p      AM veya PM belirteci\n%S        Saniye (00-61)\n%y      Yıl, son iki hane (00-99)\n%Y       Yıl\n%z     UTC'ye göre ISO 8601 farkı veya zaman dilimi\n      adı veya kısaltması\n%Z     Zaman dilimi adı veya kısaltması\n"
154
 
155
 Basic.Settings.Video="Video"
156
 Basic.Settings.Video.Adapter="Video Bağdaştırıcı:"
157
 Basic.Settings.Video.BaseResolution="Temel (Tuval) Çözünürlüğü:"
158
-Basic.Settings.Video.ScaledResolution="Çıkış (Ölçekli) Çözünürlüğü:"
159
-Basic.Settings.Video.DownscaleFilter="Filtreyi Azalt:"
160
+Basic.Settings.Video.ScaledResolution="Çıkış (Boyutlandırılmış) Çözünürlüğü:"
161
+Basic.Settings.Video.DownscaleFilter="Boyut Azaltma Filtresi:"
162
 Basic.Settings.Video.DisableAeroWindows="Aero'yu Devre Dışı Bırak (yalnızca Windows)"
163
 Basic.Settings.Video.FPS="FPS:"
164
 Basic.Settings.Video.FPSCommon="Ortak FPS Değerleri"
165
@@ -540,6 +553,7 @@
166
 Basic.AdvAudio.AudioTracks="Parçalar"
167
 
168
 Basic.Settings.Hotkeys="Kısayollar"
169
+Basic.Settings.Hotkeys.Pair="'%1' ile paylaşılan tuş kombinasyonu açma/kapama olarak çalışır"
170
 
171
 Basic.Hotkeys.SelectScene="Sahneye geçiş yap"
172
 
173
@@ -594,4 +608,5 @@
174
 
175
 OutputWarnings.NoTracksSelected="En az bir ses parçası seçmelisiniz"
176
 OutputWarnings.MultiTrackRecording="Uyarı: Bazı biçimler (FLV gibi) kayıt başına birden fazla parçayı desteklemez"
177
+OutputWarnings.MP4Recording="Uyarı: MP4'e kaydedilen kayıtlar eğer dosya sonlandırılamazsa kurtarılamaz (örneğin: Mavi Hata Ekranı, güç kesintisi v.b.). Eğer çoklu ses izi kaydetmek istiyorsanız MKV kullanmayı düşünün ve bittikten sonra sonra kayıtı mp4'e remuxlayabilirsiniz (Dosya->Remux Kayıtları)"
178
 
179
obs-studio-18.0.0.tar.xz/UI/forms/OBSBasicSettings.ui -> obs-studio-18.0.1.tar.xz/UI/forms/OBSBasicSettings.ui Changed
19
 
1
@@ -484,7 +484,7 @@
2
                    <item row="0" column="1">
3
                     <widget class="QCheckBox" name="systemTrayEnabled">
4
                      <property name="text">
5
-                      <string>Enabled</string>
6
+                      <string>Enable</string>
7
                      </property>
8
                     </widget>
9
                    </item>
10
@@ -4018,7 +4018,7 @@
11
                  </widget>
12
                 </item>
13
                 <item>
14
-                 <widget class="QGroupBox" name="groupBox_11">
15
+                 <widget class="QGroupBox" name="advNetworkGroupBox">
16
                   <property name="title">
17
                    <string>Basic.Settings.Advanced.Network</string>
18
                   </property>
19
obs-studio-18.0.1.tar.xz/UI/frontend-plugins/frontend-tools/data/locale/et-EE.ini Added
23
 
1
@@ -0,0 +1,21 @@
2
+SceneSwitcher="Automaatne stseeni vahetaja"
3
+SceneSwitcher.OnNoMatch="Kui üksi aken ei sobi:"
4
+SceneSwitcher.OnNoMatch.DontSwitch="Ära vaheta"
5
+SceneSwitcher.OnNoMatch.SwitchTo="Lülitu ümber:"
6
+SceneSwitcher.CheckInterval="Kontrollige aktiivse akna pealkiri iga:"
7
+SceneSwitcher.ActiveOrNotActive="Stseen vahetaja on:"
8
+Active="Aktiivne"
9
+Inactive="Inaktiivne"
10
+Start="Alusta"
11
+Stop="Lõpeta"
12
+
13
+Captions="Subtiitrid (eksperimentaalne)"
14
+Captions.AudioSource="Heli allikas"
15
+Captions.CurrentSystemLanguage="Praegune süsteemi keel (%1)"
16
+
17
+OutputTimer="Väljundi taimer"
18
+OutputTimer.Stream="Lõpeta voogedastus pärast:"
19
+OutputTimer.Record="Lõpeta voogedastus pärast:"
20
+OutputTimer.Stream.StoppingIn="Voogedastus lõppeb:"
21
+OutputTimer.Record.StoppingIn="Salvestamine lõppeb:"
22
+
23
obs-studio-18.0.0.tar.xz/UI/obs-app.cpp -> obs-studio-18.0.1.tar.xz/UI/obs-app.cpp Changed
14
 
1
@@ -1806,12 +1806,6 @@
2
            std::cout << "OBS Studio - " << 
3
                App()->GetVersionString() << "\n";
4
            exit(0);
5
-
6
-       } else {
7
-           std::cout << 
8
-               "Invalid arguments. Use --help or -h to get " << 
9
-               "a list of available command line arguments.\n";
10
-           exit(0);
11
        }
12
    }
13
 
14
obs-studio-18.0.1.tar.xz/UI/win-update/updater Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/UI/win-update/updater/CMakeLists.txt Added
53
 
1
@@ -0,0 +1,51 @@
2
+if(NOT ENABLE_WIN_UPDATER)
3
+   return()
4
+endif()
5
+
6
+if(NOT DEFINED STATIC_ZLIB_PATH OR "${STATIC_ZLIB_PATH}" STREQUAL "")
7
+   message(STATUS "STATIC_ZLIB_PATH not set, windows updater disabled")
8
+   return()
9
+endif()
10
+
11
+project(updater)
12
+
13
+include_directories(${OBS_JANSSON_INCLUDE_DIRS})
14
+include_directories(${LIBLZMA_INCLUDE_DIRS})
15
+include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
16
+include_directories(${BLAKE2_INCLUDE_DIR})
17
+
18
+find_package(ZLIB REQUIRED)
19
+
20
+set(updater_HEADERS
21
+   ../win-update-helpers.hpp
22
+   resource.h
23
+   updater.hpp
24
+   )
25
+set(updater_SOURCES
26
+   ../win-update-helpers.cpp
27
+   updater.cpp
28
+   patch.cpp
29
+   http.cpp
30
+   hash.cpp
31
+   updater.rc
32
+   )
33
+
34
+add_definitions(-DNOMINMAX -DUNICODE -D_UNICODE)
35
+if(MSVC)
36
+   add_compile_options("$<$<CONFIG:RelWithDebInfo>:/MT>")
37
+endif()
38
+
39
+add_executable(updater WIN32
40
+   ${updater_HEADERS}
41
+   ${updater_SOURCES}
42
+   )
43
+target_link_libraries(updater
44
+   ${OBS_JANSSON_IMPORT}
45
+   ${STATIC_ZLIB_PATH}
46
+   lzma
47
+   blake2
48
+   psapi
49
+   comctl32
50
+   shell32
51
+   winhttp
52
+   )
53
obs-studio-18.0.1.tar.xz/UI/win-update/updater/hash.cpp Added
63
 
1
@@ -0,0 +1,61 @@
2
+#include "updater.hpp"
3
+
4
+#include <util/windows/WinHandle.hpp>
5
+#include <vector>
6
+
7
+using namespace std;
8
+
9
+void HashToString(const uint8_t *in, wchar_t *out)
10
+{
11
+   const wchar_t alphabet[] = L"0123456789abcdef";
12
+
13
+   for (int i = 0; i != BLAKE2_HASH_LENGTH; ++i) {
14
+       out[2 * i]     = alphabet[in[i] / 16];
15
+       out[2 * i + 1] = alphabet[in[i] % 16];
16
+   }
17
+
18
+   out[BLAKE2_HASH_LENGTH * 2] = 0;
19
+}
20
+
21
+void StringToHash(const wchar_t *in, BYTE *out)
22
+{
23
+   int temp;
24
+
25
+   for (int i = 0; i < BLAKE2_HASH_LENGTH; i++) {
26
+       swscanf_s(in + i * 2, L"%02x", &temp);
27
+       out[i] = (BYTE)temp;
28
+   }
29
+}
30
+
31
+bool CalculateFileHash(const wchar_t *path, BYTE *hash)
32
+{
33
+   blake2b_state blake2;
34
+   if (blake2b_init(&blake2, BLAKE2_HASH_LENGTH) != 0)
35
+       return false;
36
+
37
+   WinHandle handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
38
+           nullptr, OPEN_EXISTING, 0, nullptr);
39
+   if (handle == INVALID_HANDLE_VALUE)
40
+       return false;
41
+
42
+   vector<BYTE> buf;
43
+   buf.resize(65536);
44
+
45
+   for (;;) {
46
+       DWORD read = 0;
47
+       if (!ReadFile(handle, buf.data(), (DWORD)buf.size(), &read,
48
+                   nullptr))
49
+           return false;
50
+
51
+       if (!read)
52
+           break;
53
+
54
+       if (blake2b_update(&blake2, buf.data(), read) != 0)
55
+           return false;
56
+   }
57
+
58
+   if (blake2b_final(&blake2, hash, BLAKE2_HASH_LENGTH) != 0)
59
+       return false;
60
+
61
+   return true;
62
+}
63
obs-studio-18.0.1.tar.xz/UI/win-update/updater/http.cpp Added
539
 
1
@@ -0,0 +1,537 @@
2
+#include "Updater.hpp"
3
+
4
+#include <algorithm>
5
+
6
+using namespace std;
7
+
8
+#define MAX_BUF_SIZE  262144
9
+#define READ_BUF_SIZE 32768
10
+
11
+/* ------------------------------------------------------------------------ */
12
+
13
+class ZipStream {
14
+   z_stream strm = {};
15
+   bool initialized = false;
16
+
17
+public:
18
+   inline ~ZipStream()
19
+   {
20
+       if (initialized)
21
+           inflateEnd(&strm);
22
+   }
23
+
24
+   inline operator z_stream*() {return &strm;}
25
+   inline z_stream *operator->() {return &strm;}
26
+
27
+   inline bool inflate()
28
+   {
29
+       int ret = inflateInit2(&strm, 16 + MAX_WBITS);
30
+       initialized = (ret == Z_OK);
31
+       return initialized;
32
+   }
33
+};
34
+
35
+/* ------------------------------------------------------------------------ */
36
+
37
+static bool ReadZippedHTTPData(string &responseBuf, z_stream *strm,
38
+       string &zipBuf, const uint8_t *buffer, DWORD outSize)
39
+{
40
+   do {
41
+       strm->avail_in = outSize;
42
+       strm->next_in  = buffer;
43
+
44
+       strm->avail_out = (uInt)zipBuf.size();
45
+       strm->next_out  = (Bytef *)zipBuf.data();
46
+
47
+       int zret = inflate(strm, Z_NO_FLUSH);
48
+       if (zret != Z_STREAM_END && zret != Z_OK)
49
+           return false;
50
+
51
+       try {
52
+           responseBuf.append(zipBuf.data(),
53
+                   zipBuf.size() - strm->avail_out);
54
+       } catch (...) {
55
+           return false;
56
+       }
57
+   } while (strm->avail_out == 0);
58
+
59
+   return true;
60
+}
61
+
62
+static bool ReadHTTPData(string &responseBuf, const uint8_t *buffer,
63
+       DWORD outSize)
64
+{
65
+   try {
66
+       responseBuf.append((const char *)buffer, outSize);
67
+   } catch (...) {
68
+       return false;
69
+   }
70
+   return true;
71
+}
72
+
73
+bool HTTPPostData(const wchar_t *url,
74
+                  const BYTE *   data,
75
+                  int            dataLen,
76
+                  const wchar_t *extraHeaders,
77
+                  int *          responseCode,
78
+                  string &       responseBuf)
79
+{
80
+   HttpHandle     hSession;
81
+   HttpHandle     hConnect;
82
+   HttpHandle     hRequest;
83
+   string         zipBuf;
84
+   URL_COMPONENTS urlComponents = {};
85
+   bool           secure        = false;
86
+
87
+   wchar_t hostName[256];
88
+   wchar_t path[1024];
89
+
90
+   const wchar_t *acceptTypes[] = {L"*/*", nullptr};
91
+
92
+   responseBuf.clear();
93
+
94
+   /* -------------------------------------- *
95
+    * get URL components                     */
96
+
97
+   urlComponents.dwStructSize = sizeof(urlComponents);
98
+
99
+   urlComponents.lpszHostName     = hostName;
100
+   urlComponents.dwHostNameLength = _countof(hostName);
101
+
102
+   urlComponents.lpszUrlPath     = path;
103
+   urlComponents.dwUrlPathLength = _countof(path);
104
+
105
+   WinHttpCrackUrl(url, 0, 0, &urlComponents);
106
+
107
+   if (urlComponents.nPort == 443)
108
+       secure = true;
109
+
110
+   /* -------------------------------------- *
111
+    * connect to server                      */
112
+
113
+   hSession = WinHttpOpen(L"OBS Updater/2.1",
114
+                          WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
115
+                          WINHTTP_NO_PROXY_NAME,
116
+                          WINHTTP_NO_PROXY_BYPASS,
117
+                          0);
118
+   if (!hSession) {
119
+       *responseCode = -1;
120
+       return false;
121
+   }
122
+
123
+   hConnect = WinHttpConnect(hSession, hostName,
124
+           secure
125
+           ? INTERNET_DEFAULT_HTTPS_PORT
126
+           : INTERNET_DEFAULT_HTTP_PORT, 0);
127
+   if (!hConnect) {
128
+       *responseCode = -2;
129
+       return false;
130
+   }
131
+
132
+   /* -------------------------------------- *
133
+    * request data                           */
134
+
135
+   hRequest = WinHttpOpenRequest(hConnect,
136
+                                 L"POST",
137
+                                 path,
138
+                                 nullptr,
139
+                                 WINHTTP_NO_REFERER,
140
+                                 acceptTypes,
141
+                                 secure
142
+                                 ? WINHTTP_FLAG_SECURE |
143
+                                   WINHTTP_FLAG_REFRESH
144
+                                 : WINHTTP_FLAG_REFRESH);
145
+   if (!hRequest) {
146
+       *responseCode = -3;
147
+       return false;
148
+   }
149
+
150
+   bool bResults = !!WinHttpSendRequest(hRequest, extraHeaders,
151
+           extraHeaders ? -1 : 0,
152
+           (void *)data, dataLen, dataLen, 0);
153
+
154
+   /* -------------------------------------- *
155
+    * end request                            */
156
+
157
+   if (bResults) {
158
+       bResults = !!WinHttpReceiveResponse(hRequest, nullptr);
159
+   } else {
160
+       *responseCode = GetLastError();
161
+       return false;
162
+   }
163
+
164
+   /* -------------------------------------- *
165
+    * get headers                            */
166
+
167
+   wchar_t encoding[64];
168
+   DWORD   encodingLen;
169
+
170
+   wchar_t statusCode[8];
171
+   DWORD   statusCodeLen;
172
+
173
+   statusCodeLen = sizeof(statusCode);
174
+   if (!WinHttpQueryHeaders(hRequest,
175
+                            WINHTTP_QUERY_STATUS_CODE,
176
+                            WINHTTP_HEADER_NAME_BY_INDEX,
177
+                            &statusCode,
178
+                            &statusCodeLen,
179
+                            WINHTTP_NO_HEADER_INDEX)) {
180
+       *responseCode = -4;
181
+       return false;
182
+   } else {
183
+       statusCode[_countof(statusCode) - 1] = 0;
184
+   }
185
+
186
+   encodingLen = sizeof(encoding);
187
+   if (!WinHttpQueryHeaders(hRequest,
188
+                            WINHTTP_QUERY_CONTENT_ENCODING,
189
+                            WINHTTP_HEADER_NAME_BY_INDEX,
190
+                            encoding,
191
+                            &encodingLen,
192
+                            WINHTTP_NO_HEADER_INDEX)) {
193
+       encoding[0] = 0;
194
+       if (GetLastError() != ERROR_WINHTTP_HEADER_NOT_FOUND) {
195
+           *responseCode = -5;
196
+           return false;
197
+       }
198
+   } else {
199
+       encoding[_countof(encoding) - 1] = 0;
200
+   }
201
+
202
+   /* -------------------------------------- *
203
+    * allocate response data                 */
204
+
205
+   DWORD responseBufSize = MAX_BUF_SIZE;
206
+
207
+   try {
208
+       responseBuf.reserve(responseBufSize);
209
+   } catch (...) {
210
+       *responseCode = -6;
211
+       return false;
212
+   }
213
+
214
+   /* -------------------------------------- *
215
+    * if zipped, initialize zip data         */
216
+
217
+   ZipStream strm;
218
+   bool gzip = wcscmp(encoding, L"gzip") == 0;
219
+
220
+   if (gzip) {
221
+       strm->zalloc   = Z_NULL;
222
+       strm->zfree    = Z_NULL;
223
+       strm->opaque   = Z_NULL;
224
+       strm->avail_in = 0;
225
+       strm->next_in  = Z_NULL;
226
+
227
+       if (!strm.inflate())
228
+           return false;
229
+
230
+       try {
231
+           zipBuf.resize(MAX_BUF_SIZE);
232
+       } catch (...) {
233
+           *responseCode = -6;
234
+           return false;
235
+       }
236
+   }
237
+
238
+   /* -------------------------------------- *
239
+    * read data                              */
240
+
241
+   *responseCode = wcstoul(statusCode, nullptr, 10);
242
+
243
+   /* are we supposed to return true here? */
244
+   if (!bResults || *responseCode != 200)
245
+       return true;
246
+
247
+   BYTE buffer[READ_BUF_SIZE];
248
+   DWORD dwSize, outSize;
249
+
250
+   do {
251
+       /* Check for available data. */
252
+       dwSize = 0;
253
+       if (!WinHttpQueryDataAvailable(hRequest, &dwSize)) {
254
+           *responseCode = -8;
255
+           return false;
256
+       }
257
+
258
+       dwSize = std::min(dwSize, (DWORD)sizeof(buffer));
259
+
260
+       if (!WinHttpReadData(hRequest, (void *)buffer, dwSize,
261
+                   &outSize)) {
262
+           *responseCode = -9;
263
+           return false;
264
+       }
265
+
266
+       if (!outSize)
267
+           break;
268
+
269
+       if (gzip) {
270
+           if (!ReadZippedHTTPData(responseBuf, strm, zipBuf,
271
+                       buffer, outSize)) {
272
+               *responseCode = -6;
273
+               return false;
274
+           }
275
+       } else {
276
+           if (!ReadHTTPData(responseBuf, buffer, outSize)) {
277
+               *responseCode = -6;
278
+               return false;
279
+           }
280
+       }
281
+
282
+       if (WaitForSingleObject(cancelRequested, 0) == WAIT_OBJECT_0) {
283
+           *responseCode = -14;
284
+           return false;
285
+       }
286
+   } while (dwSize > 0);
287
+
288
+   return true;
289
+}
290
+
291
+/* ------------------------------------------------------------------------ */
292
+
293
+static bool ReadHTTPZippedFile(z_stream *strm, HANDLE updateFile,
294
+       string &zipBuf, const uint8_t *buffer, DWORD outSize,
295
+       int *responseCode)
296
+{
297
+   do {
298
+       strm->avail_in = outSize;
299
+       strm->next_in  = buffer;
300
+
301
+       strm->avail_out = (uInt)zipBuf.size();
302
+       strm->next_out  = (Bytef *)zipBuf.data();
303
+
304
+       int zret = inflate(strm, Z_NO_FLUSH);
305
+       if (zret != Z_STREAM_END && zret != Z_OK)
306
+           return false;
307
+
308
+       DWORD written;
309
+       if (!WriteFile(updateFile,
310
+                  zipBuf.data(),
311
+                  MAX_BUF_SIZE - strm->avail_out,
312
+                  &written,
313
+                  nullptr)) {
314
+           *responseCode = -10;
315
+           return false;
316
+       }
317
+       if (written != MAX_BUF_SIZE - strm->avail_out) {
318
+           *responseCode = -11;
319
+           return false;
320
+       }
321
+
322
+       completedFileSize += written;
323
+   } while (strm->avail_out == 0);
324
+
325
+   return true;
326
+}
327
+
328
+static bool ReadHTTPFile(HANDLE updateFile, const uint8_t *buffer,
329
+       DWORD outSize, int *responseCode)
330
+{
331
+   DWORD written;
332
+   if (!WriteFile(updateFile, buffer, outSize, &written, nullptr)) {
333
+       *responseCode = -12;
334
+       return false;
335
+   }
336
+
337
+   if (written != outSize) {
338
+       *responseCode = -13;
339
+       return false;
340
+   }
341
+
342
+   completedFileSize += outSize;
343
+   return true;
344
+}
345
+
346
+bool HTTPGetFile(HINTERNET      hConnect,
347
+                 const wchar_t *url,
348
+                 const wchar_t *outputPath,
349
+                 const wchar_t *extraHeaders,
350
+                 int *          responseCode)
351
+{
352
+   HttpHandle hRequest;
353
+
354
+   const wchar_t *acceptTypes[] = {L"*/*", nullptr};
355
+
356
+   URL_COMPONENTS urlComponents = {};
357
+   bool           secure        = false;
358
+
359
+   string  zipBuf;
360
+   wchar_t hostName[256];
361
+   wchar_t path[1024];
362
+
363
+   /* -------------------------------------- *
364
+    * get URL components                     */
365
+
366
+   urlComponents.dwStructSize = sizeof(urlComponents);
367
+
368
+   urlComponents.lpszHostName     = hostName;
369
+   urlComponents.dwHostNameLength = _countof(hostName);
370
+
371
+   urlComponents.lpszUrlPath     = path;
372
+   urlComponents.dwUrlPathLength = _countof(path);
373
+
374
+   WinHttpCrackUrl(url, 0, 0, &urlComponents);
375
+
376
+   if (urlComponents.nPort == 443)
377
+       secure = true;
378
+
379
+   /* -------------------------------------- *
380
+    * request data                           */
381
+
382
+   hRequest = WinHttpOpenRequest(hConnect,
383
+                                 L"GET",
384
+                                 path,
385
+                                 nullptr,
386
+                                 WINHTTP_NO_REFERER,
387
+                                 acceptTypes,
388
+                                 secure
389
+                                 ? WINHTTP_FLAG_SECURE |
390
+                                   WINHTTP_FLAG_REFRESH
391
+                                 : WINHTTP_FLAG_REFRESH);
392
+   if (!hRequest) {
393
+       *responseCode = -3;
394
+       return false;
395
+   }
396
+
397
+   bool bResults = !!WinHttpSendRequest(hRequest, extraHeaders,
398
+           extraHeaders ? -1 : 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
399
+
400
+   /* -------------------------------------- *
401
+    * end request                            */
402
+
403
+   if (bResults) {
404
+       bResults = !!WinHttpReceiveResponse(hRequest, nullptr);
405
+   } else {
406
+       *responseCode = GetLastError();
407
+       return false;
408
+   }
409
+
410
+   /* -------------------------------------- *
411
+    * get headers                            */
412
+
413
+   wchar_t encoding[64];
414
+   DWORD   encodingLen;
415
+
416
+   wchar_t statusCode[8];
417
+   DWORD   statusCodeLen;
418
+
419
+   statusCodeLen = sizeof(statusCode);
420
+   if (!WinHttpQueryHeaders(hRequest,
421
+                            WINHTTP_QUERY_STATUS_CODE,
422
+                            WINHTTP_HEADER_NAME_BY_INDEX,
423
+                            &statusCode,
424
+                            &statusCodeLen,
425
+                            WINHTTP_NO_HEADER_INDEX)) {
426
+       *responseCode = -4;
427
+       return false;
428
+   } else {
429
+       statusCode[_countof(statusCode) - 1] = 0;
430
+   }
431
+
432
+   encodingLen = sizeof(encoding);
433
+   if (!WinHttpQueryHeaders(hRequest,
434
+                            WINHTTP_QUERY_CONTENT_ENCODING,
435
+                            WINHTTP_HEADER_NAME_BY_INDEX,
436
+                            encoding,
437
+                            &encodingLen,
438
+                            WINHTTP_NO_HEADER_INDEX)) {
439
+       encoding[0] = 0;
440
+       if (GetLastError() != ERROR_WINHTTP_HEADER_NOT_FOUND) {
441
+           *responseCode = -5;
442
+           return false;
443
+       }
444
+   } else {
445
+       encoding[_countof(encoding) - 1] = 0;
446
+   }
447
+
448
+   /* -------------------------------------- *
449
+    * allocate response data                 */
450
+
451
+   ZipStream strm;
452
+   bool gzip = wcscmp(encoding, L"gzip") == 0;
453
+
454
+   if (gzip) {
455
+       strm->zalloc   = Z_NULL;
456
+       strm->zfree    = Z_NULL;
457
+       strm->opaque   = Z_NULL;
458
+       strm->avail_in = 0;
459
+       strm->next_in  = Z_NULL;
460
+
461
+       if (!strm.inflate())
462
+           return false;
463
+
464
+       try {
465
+           zipBuf.resize(MAX_BUF_SIZE);
466
+       } catch (...) {
467
+           *responseCode = -6;
468
+           return false;
469
+       }
470
+   }
471
+
472
+   /* -------------------------------------- *
473
+    * read data                              */
474
+
475
+   *responseCode = wcstoul(statusCode, nullptr, 10);
476
+
477
+   /* are we supposed to return true here? */
478
+   if (!bResults || *responseCode != 200)
479
+       return true;
480
+
481
+   BYTE  buffer[READ_BUF_SIZE];
482
+   DWORD dwSize, outSize;
483
+   int   lastPosition = 0;
484
+
485
+   WinHandle updateFile = CreateFile(outputPath, GENERIC_WRITE, 0,
486
+           nullptr, CREATE_ALWAYS, 0, nullptr);
487
+   if (!updateFile.Valid()) {
488
+       *responseCode = -7;
489
+       return false;
490
+   }
491
+
492
+   do {
493
+       /* Check for available data. */
494
+       dwSize = 0;
495
+       if (!WinHttpQueryDataAvailable(hRequest, &dwSize)) {
496
+           *responseCode = -8;
497
+           return false;
498
+       }
499
+
500
+       dwSize = std::min(dwSize, (DWORD)sizeof(buffer));
501
+
502
+       if (!WinHttpReadData(hRequest, (void *)buffer, dwSize,
503
+                   &outSize)) {
504
+           *responseCode = -9;
505
+           return false;
506
+       } else {
507
+           if (!outSize)
508
+               break;
509
+
510
+           if (gzip) {
511
+               if (!ReadHTTPZippedFile(strm, updateFile,
512
+                           zipBuf, buffer,
513
+                           outSize, responseCode))
514
+                   return false;
515
+           } else {
516
+               if (!ReadHTTPFile(updateFile, buffer,
517
+                           outSize, responseCode))
518
+                   return false;
519
+           }
520
+
521
+           int position = (int)(((float)completedFileSize /
522
+                       (float)totalFileSize) * 100.0f);
523
+           if (position > lastPosition) {
524
+               lastPosition = position;
525
+               SendDlgItemMessage(hwndMain, IDC_PROGRESS,
526
+                       PBM_SETPOS, position, 0);
527
+           }
528
+       }
529
+
530
+       if (WaitForSingleObject(cancelRequested, 0) == WAIT_OBJECT_0) {
531
+           *responseCode = -14;
532
+           return false;
533
+       }
534
+
535
+   } while (dwSize > 0);
536
+
537
+   return true;
538
+}
539
obs-studio-18.0.1.tar.xz/UI/win-update/updater/patch.cpp Added
303
 
1
@@ -0,0 +1,301 @@
2
+#include "updater.hpp"
3
+
4
+#include <stdint.h>
5
+#include <vector>
6
+
7
+#include <lzma.h>
8
+
9
+using namespace std;
10
+
11
+#define MAX_BUF_SIZE  262144
12
+#define READ_BUF_SIZE 32768
13
+
14
+/* ------------------------------------------------------------------------ */
15
+
16
+class LZMAStream {
17
+   lzma_stream strm = {};
18
+   bool initialized = false;
19
+
20
+public:
21
+   inline ~LZMAStream()
22
+   {
23
+       if (initialized) {
24
+           lzma_end(&strm);
25
+       }
26
+   }
27
+
28
+   inline bool init_decoder()
29
+   {
30
+       lzma_ret ret = lzma_stream_decoder(
31
+               &strm,
32
+               200 * 1024 * 1024,
33
+               0);
34
+       initialized = (ret == LZMA_OK);
35
+       return initialized;
36
+   }
37
+
38
+   inline operator lzma_stream *() { return &strm; }
39
+   inline bool operator!() const { return !initialized; }
40
+
41
+   inline lzma_stream *get() { return &strm; }
42
+};
43
+
44
+class File {
45
+   FILE *f = nullptr;
46
+
47
+public:
48
+   inline ~File()
49
+   {
50
+       if (f)
51
+           fclose(f);
52
+   }
53
+
54
+   inline FILE **operator&() { return &f; }
55
+   inline operator FILE *() const { return f; }
56
+   inline bool operator!() const { return !f; }
57
+};
58
+
59
+/* ------------------------------------------------------------------------ */
60
+
61
+struct bspatch_stream {
62
+   void *opaque;
63
+   int (*read)(const struct bspatch_stream *stream, void *buffer,
64
+           int length);
65
+};
66
+
67
+/* ------------------------------------------------------------------------ */
68
+
69
+static int64_t offtin(const uint8_t *buf)
70
+{
71
+   int64_t y;
72
+
73
+   y = buf[7] & 0x7F;
74
+   y = y * 256;
75
+   y += buf[6];
76
+   y = y * 256;
77
+   y += buf[5];
78
+   y = y * 256;
79
+   y += buf[4];
80
+   y = y * 256;
81
+   y += buf[3];
82
+   y = y * 256;
83
+   y += buf[2];
84
+   y = y * 256;
85
+   y += buf[1];
86
+   y = y * 256;
87
+   y += buf[0];
88
+
89
+   if (buf[7] & 0x80)
90
+       y = -y;
91
+
92
+   return y;
93
+}
94
+
95
+/* ------------------------------------------------------------------------ */
96
+
97
+static int bspatch(const uint8_t *old, int64_t oldsize, uint8_t *newp,
98
+       int64_t newsize, struct bspatch_stream *stream)
99
+{
100
+   uint8_t buf[8];
101
+   int64_t oldpos, newpos;
102
+   int64_t ctrl[3];
103
+   int64_t i;
104
+
105
+   oldpos = 0;
106
+   newpos = 0;
107
+   while (newpos < newsize) {
108
+       /* Read control data */
109
+       for (i = 0; i <= 2; i++) {
110
+           if (stream->read(stream, buf, 8))
111
+               return -1;
112
+           ctrl[i] = offtin(buf);
113
+       };
114
+
115
+       /* Sanity-check */
116
+       if (newpos + ctrl[0] > newsize)
117
+           return -1;
118
+
119
+       /* Read diff string */
120
+       if (stream->read(stream, newp + newpos, (int)ctrl[0]))
121
+           return -1;
122
+
123
+       /* Add old data to diff string */
124
+       for (i = 0; i < ctrl[0]; i++)
125
+           if ((oldpos + i >= 0) && (oldpos + i < oldsize))
126
+               newp[newpos + i] += old[oldpos + i];
127
+
128
+       /* Adjust pointers */
129
+       newpos += ctrl[0];
130
+       oldpos += ctrl[0];
131
+
132
+       /* Sanity-check */
133
+       if (newpos + ctrl[1] > newsize)
134
+           return -1;
135
+
136
+       /* Read extra string */
137
+       if (stream->read(stream, newp + newpos, (int)ctrl[1]))
138
+           return -1;
139
+
140
+       /* Adjust pointers */
141
+       newpos += ctrl[1];
142
+       oldpos += ctrl[2];
143
+   };
144
+
145
+   return 0;
146
+}
147
+
148
+/* ------------------------------------------------------------------------ */
149
+
150
+struct patch_data {
151
+   HANDLE        h;
152
+   lzma_stream   *strm;
153
+   uint8_t       buf[READ_BUF_SIZE];
154
+};
155
+
156
+static int read_lzma(const struct bspatch_stream *stream, void *buffer, int len)
157
+{
158
+   if (!len)
159
+       return 0;
160
+
161
+   patch_data  *data    = (patch_data*)stream->opaque;
162
+   HANDLE      h        = data->h;
163
+   lzma_stream *strm    = data->strm;
164
+
165
+   strm->avail_out = (size_t)len;
166
+   strm->next_out  = (uint8_t *)buffer;
167
+
168
+   for (;;) {
169
+       if (strm->avail_in == 0) {
170
+           DWORD read_size;
171
+           if (!ReadFile(h, data->buf, READ_BUF_SIZE, &read_size,
172
+                       nullptr))
173
+               return -1;
174
+           if (read_size == 0)
175
+               return -1;
176
+
177
+           strm->avail_in = (size_t)read_size;
178
+           strm->next_in  = data->buf;
179
+       }
180
+
181
+       lzma_ret ret = lzma_code(strm, LZMA_RUN);
182
+       if (ret == LZMA_STREAM_END)
183
+           return 0;
184
+       if (ret != LZMA_OK)
185
+           return -1;
186
+       if (strm->avail_out == 0)
187
+           break;
188
+   }
189
+
190
+   return 0;
191
+}
192
+
193
+int ApplyPatch(const wchar_t *patchFile, const wchar_t *targetFile)
194
+try {
195
+   uint8_t               header[24];
196
+   int64_t               newsize;
197
+   struct bspatch_stream stream;
198
+   bool                  success;
199
+
200
+   WinHandle  hPatch;
201
+   WinHandle  hTarget;
202
+   LZMAStream strm;
203
+
204
+   /* --------------------------------- *
205
+    * open patch and file to patch      */
206
+
207
+   hPatch = CreateFile(patchFile, GENERIC_READ, 0, nullptr,
208
+           OPEN_EXISTING, 0, nullptr);
209
+   if (!hPatch.Valid())
210
+       throw int(GetLastError());
211
+
212
+   hTarget = CreateFile(targetFile, GENERIC_READ, 0, nullptr,
213
+           OPEN_EXISTING, 0, nullptr);
214
+   if (!hTarget.Valid())
215
+       throw int(GetLastError());
216
+
217
+   /* --------------------------------- *
218
+    * read patch header                 */
219
+
220
+   DWORD read;
221
+   success = !!ReadFile(hPatch, header, sizeof(header), &read, nullptr);
222
+   if (success && read == sizeof(header)) {
223
+       if (memcmp(header, "JIMSLEY/BSDIFF43", 16))
224
+           throw int(-4);
225
+   } else {
226
+       throw int(GetLastError());
227
+   }
228
+
229
+   /* --------------------------------- *
230
+    * allocate new file size data       */
231
+
232
+   newsize = offtin(header + 16);
233
+   if (newsize < 0 || newsize >= 0x7ffffffff)
234
+       throw int(-5);
235
+
236
+   vector<uint8_t> newData;
237
+   try {
238
+       newData.resize(newsize);
239
+   } catch (...) {
240
+       throw int(-1);
241
+   }
242
+
243
+   /* --------------------------------- *
244
+    * read old file                     */
245
+
246
+   DWORD targetFileSize;
247
+
248
+   targetFileSize = GetFileSize(hTarget, nullptr);
249
+   if (targetFileSize == INVALID_FILE_SIZE)
250
+       throw int(GetLastError());
251
+
252
+   vector<uint8_t> oldData;
253
+   try {
254
+       oldData.resize(targetFileSize);
255
+   } catch (...) {
256
+       throw int(-1);
257
+   }
258
+
259
+   if (!ReadFile(hTarget, &oldData[0], targetFileSize, &read, nullptr))
260
+       throw int(GetLastError());
261
+   if (read != targetFileSize)
262
+       throw int(-1);
263
+
264
+   /* --------------------------------- *
265
+    * patch to new file data            */
266
+
267
+   if (!strm.init_decoder())
268
+       throw int(-10);
269
+
270
+   patch_data data;
271
+   data.h    = hPatch;
272
+   data.strm = strm.get();
273
+
274
+   stream.read   = read_lzma;
275
+   stream.opaque = &data;
276
+
277
+   int ret = bspatch(oldData.data(), oldData.size(), newData.data(),
278
+           newData.size(), &stream);
279
+   if (ret != 0)
280
+       throw int(-9);
281
+
282
+   /* --------------------------------- *
283
+    * write new file                    */
284
+
285
+   hTarget = nullptr;
286
+   hTarget = CreateFile(targetFile, GENERIC_WRITE, 0, nullptr,
287
+           CREATE_ALWAYS, 0, nullptr);
288
+   if (!hTarget.Valid())
289
+       throw int(GetLastError());
290
+
291
+   DWORD written;
292
+
293
+   success = !!WriteFile(hTarget, newData.data(), (DWORD)newsize,
294
+           &written, nullptr);
295
+   if (!success || written != newsize)
296
+       throw int(GetLastError());
297
+
298
+   return 0;
299
+
300
+} catch (int code) {
301
+   return code;
302
+}
303
obs-studio-18.0.1.tar.xz/UI/win-update/updater/resource.h Added
23
 
1
@@ -0,0 +1,21 @@
2
+//{{NO_DEPENDENCIES}}
3
+// Microsoft Visual C++ generated include file.
4
+// Used by updater.rc
5
+//
6
+#define IDD_UPDATEDIALOG                101
7
+#define IDI_ICON1                       103
8
+#define IDC_PROGRESS                    1001
9
+#define IDC_STATUS                      1002
10
+#define IDCBUTTON                       1004
11
+#define IDC_BUTTON                      1004
12
+
13
+// Next default values for new objects
14
+//
15
+#ifdef APSTUDIO_INVOKED
16
+#ifndef APSTUDIO_READONLY_SYMBOLS
17
+#define _APS_NEXT_RESOURCE_VALUE        104
18
+#define _APS_NEXT_COMMAND_VALUE         40001
19
+#define _APS_NEXT_CONTROL_VALUE         1005
20
+#define _APS_NEXT_SYMED_VALUE           101
21
+#endif
22
+#endif
23
obs-studio-18.0.1.tar.xz/UI/win-update/updater/updater.cpp Added
1440
 
1
@@ -0,0 +1,1438 @@
2
+/******************************************************************************
3
+ Copyright (C) 2017 Hugh Bailey <obs.jim@gmail.com>
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation; either version 2 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18
+******************************************************************************/
19
+
20
+#include "updater.hpp"
21
+
22
+#include <psapi.h>
23
+
24
+#include <util/windows/CoTaskMemPtr.hpp>
25
+
26
+#include <future>
27
+#include <vector>
28
+#include <string>
29
+#include <mutex>
30
+
31
+using namespace std;
32
+
33
+/* ----------------------------------------------------------------------- */
34
+
35
+HANDLE     cancelRequested = nullptr;
36
+HANDLE     updateThread    = nullptr;
37
+HINSTANCE  hinstMain       = nullptr;
38
+HWND       hwndMain        = nullptr;
39
+HCRYPTPROV hProvider       = 0;
40
+
41
+static bool bExiting     = false;
42
+static bool updateFailed = false;
43
+static bool is32bit      = false;
44
+
45
+static bool downloadThreadFailure = false;
46
+
47
+int totalFileSize     = 0;
48
+int completedFileSize = 0;
49
+static int completedUpdates  = 0;
50
+
51
+struct LastError {
52
+   DWORD code;
53
+   inline LastError() { code = GetLastError(); }
54
+};
55
+
56
+void FreeWinHttpHandle(HINTERNET handle)
57
+{
58
+   WinHttpCloseHandle(handle);
59
+}
60
+
61
+/* ----------------------------------------------------------------------- */
62
+
63
+// http://www.codeproject.com/Articles/320748/Haephrati-Elevating-during-runtime
64
+static bool IsAppRunningAsAdminMode()
65
+{
66
+   BOOL  fIsRunAsAdmin        = FALSE;
67
+   DWORD dwError              = ERROR_SUCCESS;
68
+   PSID  pAdministratorsGroup = nullptr;
69
+
70
+   /* Allocate and initialize a SID of the administrators group. */
71
+   SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
72
+   if (!AllocateAndInitializeSid(&NtAuthority,
73
+                                 2,
74
+                                 SECURITY_BUILTIN_DOMAIN_RID,
75
+                                 DOMAIN_ALIAS_RID_ADMINS,
76
+                                 0,
77
+                                 0,
78
+                                 0,
79
+                                 0,
80
+                                 0,
81
+                                 0,
82
+                                 &pAdministratorsGroup)) {
83
+       dwError = GetLastError();
84
+       goto Cleanup;
85
+   }
86
+
87
+   /* Determine whether the SID of administrators group is enabled in the
88
+    * primary access token of the process. */
89
+   if (!CheckTokenMembership(nullptr, pAdministratorsGroup,
90
+               &fIsRunAsAdmin)) {
91
+       dwError = GetLastError();
92
+       goto Cleanup;
93
+   }
94
+
95
+Cleanup:
96
+   /* Centralized cleanup for all allocated resources. */
97
+   if (pAdministratorsGroup) {
98
+       FreeSid(pAdministratorsGroup);
99
+       pAdministratorsGroup = nullptr;
100
+   }
101
+
102
+   /* Throw the error if something failed in the function. */
103
+   if (ERROR_SUCCESS != dwError)
104
+       return false;
105
+
106
+   return !!fIsRunAsAdmin;
107
+}
108
+
109
+static void Status(const wchar_t *fmt, ...)
110
+{
111
+   wchar_t str[512];
112
+
113
+   va_list argptr;
114
+   va_start(argptr, fmt);
115
+
116
+   StringCbVPrintf(str, sizeof(str), fmt, argptr);
117
+
118
+   SetDlgItemText(hwndMain, IDC_STATUS, str);
119
+
120
+   va_end(argptr);
121
+}
122
+
123
+static void CreateFoldersForPath(const wchar_t *path)
124
+{
125
+   wchar_t *p = (wchar_t *)path;
126
+
127
+   while (*p) {
128
+       if (*p == '\\' || *p == '/') {
129
+           *p = 0;
130
+           CreateDirectory(path, nullptr);
131
+           *p = '\\';
132
+       }
133
+       p++;
134
+   }
135
+}
136
+
137
+static bool MyCopyFile(const wchar_t *src, const wchar_t *dest)
138
+try {
139
+   WinHandle hSrc;
140
+   WinHandle hDest;
141
+
142
+   hSrc = CreateFile(src, GENERIC_READ, 0, nullptr, OPEN_EXISTING,
143
+           FILE_FLAG_SEQUENTIAL_SCAN, nullptr);
144
+   if (!hSrc.Valid())
145
+       throw LastError();
146
+
147
+   hDest = CreateFile(dest, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS,
148
+           0, nullptr);
149
+   if (!hDest.Valid())
150
+       throw LastError();
151
+
152
+   BYTE  buf[65536];
153
+   DWORD read, wrote;
154
+
155
+   for (;;) {
156
+       if (!ReadFile(hSrc, buf, sizeof(buf), &read, nullptr))
157
+           throw LastError();
158
+
159
+       if (read == 0)
160
+           break;
161
+
162
+       if (!WriteFile(hDest, buf, read, &wrote, nullptr))
163
+           throw LastError();
164
+
165
+       if (wrote != read)
166
+           return false;
167
+   }
168
+
169
+   return true;
170
+
171
+} catch (LastError error) {
172
+   SetLastError(error.code);
173
+   return false;
174
+}
175
+
176
+static bool IsSafeFilename(const wchar_t *path)
177
+{
178
+   const wchar_t *p = path;
179
+
180
+   if (!*p)
181
+       return false;
182
+
183
+   if (wcsstr(path, L".."))
184
+       return false;
185
+
186
+   if (*p == '/')
187
+       return false;
188
+
189
+   while (*p) {
190
+       if (!isalnum(*p) &&
191
+           *p != '.' &&
192
+           *p != '/' &&
193
+           *p != '_' &&
194
+           *p != '-')
195
+           return false;
196
+       p++;
197
+   }
198
+
199
+   return true;
200
+}
201
+
202
+static string QuickReadFile(const wchar_t *path)
203
+{
204
+   string data;
205
+
206
+   WinHandle handle = CreateFileW(path, GENERIC_READ, 0, nullptr,
207
+           OPEN_EXISTING, 0, nullptr);
208
+   if (!handle.Valid()) {
209
+       return string();
210
+   }
211
+
212
+   LARGE_INTEGER size;
213
+
214
+   if (!GetFileSizeEx(handle, &size)) {
215
+       return string();
216
+   }
217
+
218
+   data.resize((size_t)size.QuadPart);
219
+
220
+   DWORD read;
221
+   if (!ReadFile(handle,
222
+                 &data[0],
223
+                 (DWORD)data.size(),
224
+                 &read,
225
+                 nullptr)) {
226
+       return string();
227
+   }
228
+   if (read != size.QuadPart) {
229
+       return string();
230
+   }
231
+
232
+   return data;
233
+}
234
+
235
+/* ----------------------------------------------------------------------- */
236
+
237
+enum state_t {
238
+   STATE_INVALID,
239
+   STATE_PENDING_DOWNLOAD,
240
+   STATE_DOWNLOADING,
241
+   STATE_DOWNLOADED,
242
+   STATE_INSTALLED,
243
+};
244
+
245
+struct update_t {
246
+   wstring sourceURL;
247
+   wstring outputPath;
248
+   wstring tempPath;
249
+   wstring previousFile;
250
+   wstring basename;
251
+   string  packageName;
252
+
253
+   DWORD   fileSize = 0;
254
+   BYTE    hash[BLAKE2_HASH_LENGTH];
255
+   BYTE    downloadhash[BLAKE2_HASH_LENGTH];
256
+   BYTE    my_hash[BLAKE2_HASH_LENGTH];
257
+   state_t state     = STATE_INVALID;
258
+   bool    has_hash  = false;
259
+   bool    patchable = false;
260
+
261
+   inline update_t() {}
262
+   inline update_t(const update_t &from)
263
+           : sourceURL(from.sourceURL),
264
+             outputPath(from.outputPath),
265
+             tempPath(from.tempPath),
266
+             previousFile(from.previousFile),
267
+             basename(from.basename),
268
+             packageName(from.packageName),
269
+             fileSize(from.fileSize),
270
+             state(from.state),
271
+             has_hash(from.has_hash),
272
+             patchable(from.patchable)
273
+   {
274
+       memcpy(hash, from.hash, sizeof(hash));
275
+       memcpy(downloadhash, from.downloadhash, sizeof(downloadhash));
276
+       memcpy(my_hash, from.my_hash, sizeof(my_hash));
277
+   }
278
+
279
+   inline update_t(update_t &&from)
280
+           : sourceURL(std::move(from.sourceURL)),
281
+             outputPath(std::move(from.outputPath)),
282
+             tempPath(std::move(from.tempPath)),
283
+             previousFile(std::move(from.previousFile)),
284
+             basename(std::move(from.basename)),
285
+             packageName(std::move(from.packageName)),
286
+             fileSize(from.fileSize),
287
+             state(from.state),
288
+             has_hash(from.has_hash),
289
+             patchable(from.patchable)
290
+   {
291
+       from.state = STATE_INVALID;
292
+
293
+       memcpy(hash, from.hash, sizeof(hash));
294
+       memcpy(downloadhash, from.downloadhash, sizeof(downloadhash));
295
+       memcpy(my_hash, from.my_hash, sizeof(my_hash));
296
+   }
297
+
298
+   void CleanPartialUpdate()
299
+   {
300
+       if (state == STATE_INSTALLED) {
301
+           if (!previousFile.empty()) {
302
+               DeleteFile(outputPath.c_str());
303
+               MyCopyFile(previousFile.c_str(),
304
+                       outputPath.c_str());
305
+               DeleteFile(previousFile.c_str());
306
+           } else {
307
+               DeleteFile(outputPath.c_str());
308
+           }
309
+       } else if (state == STATE_DOWNLOADED) {
310
+           DeleteFile(tempPath.c_str());
311
+       }
312
+   }
313
+
314
+   inline update_t &operator=(const update_t &from)
315
+   {
316
+           sourceURL = from.sourceURL;
317
+           outputPath = from.outputPath;
318
+           tempPath = from.tempPath;
319
+           previousFile = from.previousFile;
320
+           basename = from.basename;
321
+           packageName = from.packageName;
322
+           fileSize = from.fileSize;
323
+           state = from.state;
324
+           has_hash = from.has_hash;
325
+           patchable = from.patchable;
326
+
327
+       memcpy(hash, from.hash, sizeof(hash));
328
+       memcpy(downloadhash, from.downloadhash, sizeof(downloadhash));
329
+       memcpy(my_hash, from.my_hash, sizeof(my_hash));
330
+   }
331
+};
332
+
333
+static vector<update_t> updates;
334
+static mutex updateMutex;
335
+
336
+static inline void CleanupPartialUpdates()
337
+{
338
+   for (update_t &update : updates)
339
+       update.CleanPartialUpdate();
340
+}
341
+
342
+/* ----------------------------------------------------------------------- */
343
+
344
+bool DownloadWorkerThread()
345
+{
346
+   HttpHandle hSession = WinHttpOpen(L"OBS Studio Updater/2.1",
347
+                                     WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
348
+                                     WINHTTP_NO_PROXY_NAME,
349
+                                     WINHTTP_NO_PROXY_BYPASS,
350
+                                     0);
351
+   if (!hSession) {
352
+       downloadThreadFailure = true;
353
+       Status(L"Update failed: Couldn't open obsproject.com");
354
+       return false;
355
+   }
356
+
357
+   HttpHandle hConnect = WinHttpConnect(hSession, L"obsproject.com",
358
+           INTERNET_DEFAULT_HTTPS_PORT, 0);
359
+   if (!hConnect) {
360
+       downloadThreadFailure = true;
361
+       Status(L"Update failed: Couldn't connect to obsproject.com");
362
+       return false;
363
+   }
364
+
365
+   for (;;) {
366
+       bool foundWork = false;
367
+
368
+       unique_lock<mutex> ulock(updateMutex);
369
+
370
+       for (update_t &update : updates) {
371
+           int responseCode;
372
+
373
+           DWORD waitResult =
374
+               WaitForSingleObject(cancelRequested, 0);
375
+           if (waitResult == WAIT_OBJECT_0) {
376
+               return false;
377
+           }
378
+
379
+           if (update.state != STATE_PENDING_DOWNLOAD)
380
+               continue;
381
+
382
+           update.state = STATE_DOWNLOADING;
383
+
384
+           ulock.unlock();
385
+
386
+           foundWork = true;
387
+
388
+           if (downloadThreadFailure) {
389
+               return false;
390
+           }
391
+
392
+           Status(L"Downloading %s", update.outputPath.c_str());
393
+
394
+           if (!HTTPGetFile(hConnect,
395
+                            update.sourceURL.c_str(),
396
+                            update.tempPath.c_str(),
397
+                            L"Accept-Encoding: gzip",
398
+                            &responseCode)) {
399
+
400
+               downloadThreadFailure = true;
401
+               DeleteFile(update.tempPath.c_str());
402
+               Status(L"Update failed: Could not download "
403
+                      L"%s (error code %d)",
404
+                      update.outputPath.c_str(),
405
+                      responseCode);
406
+               return 1;
407
+           }
408
+
409
+           if (responseCode != 200) {
410
+               downloadThreadFailure = true;
411
+               DeleteFile(update.tempPath.c_str());
412
+               Status(L"Update failed: Could not download "
413
+                      L"%s (error code %d)",
414
+                      update.outputPath.c_str(),
415
+                      responseCode);
416
+               return 1;
417
+           }
418
+
419
+           BYTE downloadHash[BLAKE2_HASH_LENGTH];
420
+           if (!CalculateFileHash(update.tempPath.c_str(),
421
+                       downloadHash)) {
422
+               downloadThreadFailure = true;
423
+               DeleteFile(update.tempPath.c_str());
424
+               Status(L"Update failed: Couldn't verify "
425
+                       L"integrity of %s",
426
+                       update.outputPath.c_str());
427
+               return 1;
428
+           }
429
+
430
+           if (memcmp(update.downloadhash, downloadHash, 20)) {
431
+               downloadThreadFailure = true;
432
+               DeleteFile(update.tempPath.c_str());
433
+               Status(L"Update failed: Integrity check "
434
+                       L"failed on %s",
435
+                       update.outputPath.c_str());
436
+               return 1;
437
+           }
438
+
439
+           ulock.lock();
440
+
441
+           update.state = STATE_DOWNLOADED;
442
+           completedUpdates++;
443
+       }
444
+
445
+       if (!foundWork) {
446
+           break;
447
+       }
448
+       if (downloadThreadFailure) {
449
+           return false;
450
+       }
451
+   }
452
+
453
+   return true;
454
+}
455
+
456
+static bool RunDownloadWorkers(int num)
457
+try {
458
+   vector<future<bool>> thread_success_results;
459
+   thread_success_results.resize(num);
460
+
461
+   for (future<bool> &result : thread_success_results) {
462
+       result = async(DownloadWorkerThread);
463
+   }
464
+   for (future<bool> &result : thread_success_results) {
465
+       if (!result.get()) {
466
+           return false;
467
+       }
468
+   }
469
+
470
+   return true;
471
+
472
+} catch (...) {
473
+   return false;
474
+}
475
+
476
+/* ----------------------------------------------------------------------- */
477
+
478
+#define WAITIFOBS_SUCCESS       0
479
+#define WAITIFOBS_WRONG_PROCESS 1
480
+#define WAITIFOBS_CANCELLED     2
481
+
482
+static inline DWORD WaitIfOBS(DWORD id, const wchar_t *expected)
483
+{
484
+   wchar_t path[MAX_PATH];
485
+   wchar_t *name;
486
+   *path = 0;
487
+
488
+   WinHandle proc = OpenProcess(
489
+           PROCESS_QUERY_INFORMATION |
490
+           PROCESS_VM_READ |
491
+           SYNCHRONIZE,
492
+           false, id);
493
+   if (!proc.Valid())
494
+       return WAITIFOBS_WRONG_PROCESS;
495
+
496
+   if (!GetProcessImageFileName(proc, path, _countof(path)))
497
+       return WAITIFOBS_WRONG_PROCESS;
498
+
499
+   name = wcsrchr(path, L'\\');
500
+   if (name)
501
+       name += 1;
502
+   else
503
+       name = path;
504
+
505
+   if (_wcsnicmp(name, expected, 5) == 0) {
506
+       HANDLE hWait[2];
507
+       hWait[0] = proc;
508
+       hWait[1] = cancelRequested;
509
+
510
+       int i = WaitForMultipleObjects(2, hWait, false, INFINITE);
511
+       if (i == WAIT_OBJECT_0 + 1)
512
+           return WAITIFOBS_CANCELLED;
513
+
514
+       return WAITIFOBS_SUCCESS;
515
+   }
516
+
517
+   return WAITIFOBS_WRONG_PROCESS;
518
+}
519
+
520
+static bool WaitForOBS()
521
+{
522
+   DWORD proc_ids[1024], needed, count;
523
+   const wchar_t *name = is32bit ? L"obs32" : L"obs64";
524
+
525
+   if (!EnumProcesses(proc_ids, sizeof(proc_ids), &needed)) {
526
+       return true;
527
+   }
528
+
529
+   count = needed / sizeof(DWORD);
530
+
531
+   for (DWORD i = 0; i < count; i++) {
532
+       DWORD id = proc_ids[i];
533
+       if (id != 0) {
534
+           switch (WaitIfOBS(id, name)) {
535
+           case WAITIFOBS_SUCCESS:
536
+               return true;
537
+           case WAITIFOBS_WRONG_PROCESS:
538
+               break;
539
+           case WAITIFOBS_CANCELLED:
540
+               return false;
541
+           }
542
+       }
543
+   }
544
+
545
+   return true;
546
+}
547
+
548
+/* ----------------------------------------------------------------------- */
549
+
550
+static inline bool UTF8ToWide(wchar_t *wide, int wideSize, const char *utf8)
551
+{
552
+   return !!MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wide, wideSize);
553
+}
554
+
555
+static inline bool WideToUTF8(char *utf8, int utf8Size, const wchar_t *wide)
556
+{
557
+   return !!WideCharToMultiByte(CP_UTF8, 0, wide, -1, utf8, utf8Size,
558
+           nullptr, nullptr);
559
+}
560
+
561
+static inline bool FileExists(const wchar_t *path)
562
+{
563
+   WIN32_FIND_DATAW wfd;
564
+   HANDLE           hFind;
565
+
566
+   hFind = FindFirstFileW(path, &wfd);
567
+   if (hFind != INVALID_HANDLE_VALUE)
568
+       FindClose(hFind);
569
+
570
+   return hFind != INVALID_HANDLE_VALUE;
571
+}
572
+
573
+static bool NonCorePackageInstalled(const char *name)
574
+{
575
+   if (strcmp(name, "obs-browser") == 0) {
576
+       return FileExists(L"obs-plugins\\32bit\\obs-browser.dll");
577
+   } else if (strcmp(name, "realsense") == 0) {
578
+       return FileExists(L"obs-plugins\\32bit\\win-ivcam.dll");
579
+   }
580
+
581
+   return false;
582
+}
583
+
584
+#define UTF8ToWideBuf(wide, utf8) UTF8ToWide(wide, _countof(wide), utf8)
585
+#define WideToUTF8Buf(utf8, wide) WideToUTF8(utf8, _countof(utf8), wide)
586
+
587
+#define UPDATE_URL L"https://obsproject.com/update_studio"
588
+
589
+static bool AddPackageUpdateFiles(json_t *root, size_t idx,
590
+       const wchar_t *tempPath)
591
+{
592
+   json_t *package = json_array_get(root, idx);
593
+   json_t *name    = json_object_get(package, "name");
594
+   json_t *files   = json_object_get(package, "files");
595
+
596
+   if (!json_is_array(files))
597
+       return true;
598
+   if (!json_is_string(name))
599
+       return true;
600
+
601
+   wchar_t wPackageName[512];
602
+   const char *packageName = json_string_value(name);
603
+   size_t fileCount = json_array_size(files);
604
+
605
+   if (!UTF8ToWideBuf(wPackageName, packageName))
606
+       return false;
607
+
608
+   if (strcmp(packageName, "core") != 0 &&
609
+       !NonCorePackageInstalled(packageName))
610
+       return true;
611
+
612
+   for (size_t j = 0; j < fileCount; j++) {
613
+       json_t *file     = json_array_get(files, j);
614
+       json_t *fileName = json_object_get(file, "name");
615
+       json_t *hash     = json_object_get(file, "hash");
616
+       json_t *size     = json_object_get(file, "size");
617
+
618
+       if (!json_is_string(fileName))
619
+           continue;
620
+       if (!json_is_string(hash))
621
+           continue;
622
+       if (!json_is_integer(size))
623
+           continue;
624
+
625
+       const char *fileUTF8 = json_string_value(fileName);
626
+       const char *hashUTF8 = json_string_value(hash);
627
+       int fileSize         = (int)json_integer_value(size);
628
+
629
+       if (strlen(hashUTF8) != BLAKE2_HASH_LENGTH * 2)
630
+           continue;
631
+
632
+       /* convert strings to wide */
633
+
634
+       wchar_t sourceURL[1024];
635
+       wchar_t updateFileName[MAX_PATH];
636
+       wchar_t updateHashStr[BLAKE2_HASH_STR_LENGTH];
637
+       wchar_t tempFilePath[MAX_PATH];
638
+
639
+       if (!UTF8ToWideBuf(updateFileName, fileUTF8))
640
+           continue;
641
+       if (!UTF8ToWideBuf(updateHashStr, hashUTF8))
642
+           continue;
643
+
644
+       /* make sure paths are safe */
645
+
646
+       if (!IsSafeFilename(updateFileName)) {
647
+           Status(L"Update failed: Unsafe path '%s' found in "
648
+                   L"manifest", updateFileName);
649
+           return false;
650
+       }
651
+
652
+       StringCbPrintf(sourceURL, sizeof(sourceURL), L"%s/%s/%s",
653
+               UPDATE_URL, wPackageName, updateFileName);
654
+       StringCbPrintf(tempFilePath, sizeof(tempFilePath),
655
+               L"%s\\%s", tempPath, updateHashStr);
656
+
657
+       /* Check file hash */
658
+
659
+       BYTE    existingHash[BLAKE2_HASH_LENGTH];
660
+       wchar_t fileHashStr[BLAKE2_HASH_STR_LENGTH];
661
+       bool    has_hash;
662
+
663
+       /* We don't really care if this fails, it's just to avoid
664
+        * wasting bandwidth by downloading unmodified files */
665
+       if (CalculateFileHash(updateFileName, existingHash)) {
666
+
667
+           HashToString(existingHash, fileHashStr);
668
+           if (wcscmp(fileHashStr, updateHashStr) == 0)
669
+               continue;
670
+
671
+           has_hash = true;
672
+       } else {
673
+           has_hash = false;
674
+       }
675
+
676
+       /* Add update file */
677
+
678
+       update_t update;
679
+       update.fileSize     = fileSize;
680
+       update.basename     = updateFileName;
681
+       update.outputPath   = updateFileName;
682
+       update.tempPath     = tempFilePath;
683
+       update.sourceURL    = sourceURL;
684
+       update.packageName  = packageName;
685
+       update.state        = STATE_PENDING_DOWNLOAD;
686
+       update.patchable    = false;
687
+
688
+       StringToHash(updateHashStr, update.downloadhash);
689
+       memcpy(update.hash, update.downloadhash, sizeof(update.hash));
690
+
691
+       update.has_hash = has_hash;
692
+       if (has_hash)
693
+           StringToHash(fileHashStr, update.my_hash);
694
+
695
+       updates.push_back(move(update));
696
+
697
+       totalFileSize += fileSize;
698
+   }
699
+
700
+   return true;
701
+}
702
+
703
+static void UpdateWithPatchIfAvailable(const char *name, const char *hash,
704
+       const char *source,
705
+       int size)
706
+{
707
+   wchar_t widePatchableFilename[MAX_PATH];
708
+   wchar_t widePatchHash[MAX_PATH];
709
+   wchar_t sourceURL[1024];
710
+   wchar_t patchHashStr[BLAKE2_HASH_STR_LENGTH];
711
+
712
+   if (strncmp(source, "https://obsproject.com/", 23) != 0)
713
+       return;
714
+
715
+   string patchPackageName = name;
716
+
717
+   const char *slash = strchr(name, '/');
718
+   if (!slash)
719
+       return;
720
+
721
+   patchPackageName.resize(slash - name);
722
+   name = slash + 1;
723
+
724
+   if (!UTF8ToWideBuf(widePatchableFilename, name))
725
+       return;
726
+   if (!UTF8ToWideBuf(widePatchHash, hash))
727
+       return;
728
+   if (!UTF8ToWideBuf(sourceURL, source))
729
+       return;
730
+   if (!UTF8ToWideBuf(patchHashStr, hash))
731
+       return;
732
+
733
+   for (update_t &update : updates) {
734
+       if (update.packageName != patchPackageName)
735
+           continue;
736
+       if (update.basename != widePatchableFilename)
737
+           continue;
738
+
739
+       StringToHash(patchHashStr, update.downloadhash);
740
+
741
+       /* Replace the source URL with the patch file, mark it as
742
+        * patchable, and re-calculate download size */
743
+       totalFileSize -= (update.fileSize - size);
744
+       update.sourceURL = sourceURL;
745
+       update.fileSize  = size;
746
+       update.patchable = true;
747
+       break;
748
+   }
749
+}
750
+
751
+static bool UpdateFile(update_t &file)
752
+{
753
+   wchar_t oldFileRenamedPath[MAX_PATH];
754
+
755
+   if (file.patchable)
756
+       Status(L"Updating %s...", file.outputPath.c_str());
757
+   else
758
+       Status(L"Installing %s...", file.outputPath.c_str());
759
+
760
+   /* Check if we're replacing an existing file or just installing a new
761
+    * one */
762
+   DWORD attribs = GetFileAttributes(file.outputPath.c_str());
763
+
764
+   if (attribs != INVALID_FILE_ATTRIBUTES) {
765
+       wchar_t *curFileName = nullptr;
766
+       wchar_t  baseName[MAX_PATH];
767
+
768
+       StringCbCopy(baseName, sizeof(baseName),
769
+               file.outputPath.c_str());
770
+
771
+       curFileName = wcsrchr(baseName, '/');
772
+       if (curFileName) {
773
+           curFileName[0] = '\0';
774
+           curFileName++;
775
+       } else
776
+           curFileName = baseName;
777
+
778
+       /* Backup the existing file in case a rollback is needed */
779
+       StringCbCopy(oldFileRenamedPath,
780
+               sizeof(oldFileRenamedPath),
781
+               file.outputPath.c_str());
782
+       StringCbCat(oldFileRenamedPath,
783
+               sizeof(oldFileRenamedPath),
784
+               L".old");
785
+
786
+       if (!MyCopyFile(file.outputPath.c_str(), oldFileRenamedPath)) {
787
+           int is_sharing_violation =
788
+               (GetLastError() == ERROR_SHARING_VIOLATION);
789
+
790
+           if (is_sharing_violation)
791
+               Status(L"Update failed: %s is still in use.  "
792
+                      L"Close all programs and try again.",
793
+                      curFileName);
794
+           else
795
+               Status(L"Update failed: Couldn't backup %s "
796
+                      L"(error %d)",
797
+                      curFileName, GetLastError());
798
+           return false;
799
+       }
800
+
801
+       int  error_code;
802
+       bool installed_ok;
803
+
804
+       if (file.patchable) {
805
+           error_code = ApplyPatch(
806
+                   file.tempPath.c_str(),
807
+                   file.outputPath.c_str());
808
+           installed_ok = (error_code == 0);
809
+
810
+           if (installed_ok) {
811
+               BYTE patchedFileHash[BLAKE2_HASH_LENGTH];
812
+               if (!CalculateFileHash(file.outputPath.c_str(),
813
+                       patchedFileHash)) {
814
+                   Status(L"Update failed: Couldn't "
815
+                          L"verify integrity of patched %s",
816
+                          curFileName);
817
+                   return false;
818
+               }
819
+
820
+               if (memcmp(file.hash, patchedFileHash,
821
+                       BLAKE2_HASH_LENGTH) != 0) {
822
+                   Status(L"Update failed: Integrity "
823
+                          L"check of patched "
824
+                          L"%s failed",
825
+                          curFileName);
826
+                   return false;
827
+               }
828
+           }
829
+       } else {
830
+           installed_ok = MyCopyFile(
831
+                   file.tempPath.c_str(),
832
+                   file.outputPath.c_str());
833
+           error_code = GetLastError();
834
+       }
835
+
836
+       if (!installed_ok) {
837
+           int is_sharing_violation =
838
+               (error_code == ERROR_SHARING_VIOLATION);
839
+
840
+           if (is_sharing_violation)
841
+               Status(L"Update failed: %s is still in use.  "
842
+                      L"Close all "
843
+                      L"programs and try again.",
844
+                      curFileName);
845
+           else
846
+               Status(L"Update failed: Couldn't update %s "
847
+                      L"(error %d)",
848
+                      curFileName,
849
+                      GetLastError());
850
+           return false;
851
+       }
852
+
853
+       file.previousFile = oldFileRenamedPath;
854
+       file.state        = STATE_INSTALLED;
855
+   } else {
856
+       if (file.patchable) {
857
+           /* Uh oh, we thought we could patch something but it's
858
+            * no longer there! */
859
+           Status(L"Update failed: Source file %s not found",
860
+                   file.outputPath.c_str());
861
+           return false;
862
+       }
863
+
864
+       /* We may be installing into new folders,
865
+        * make sure they exist */
866
+       CreateFoldersForPath(file.outputPath.c_str());
867
+
868
+       bool success = !!MyCopyFile(
869
+               file.tempPath.c_str(),
870
+               file.outputPath.c_str());
871
+       if (!success) {
872
+           Status(L"Update failed: Couldn't install %s (error %d)",
873
+                   file.outputPath.c_str(),
874
+                   GetLastError());
875
+           return false;
876
+       }
877
+
878
+       file.previousFile = L"";
879
+       file.state        = STATE_INSTALLED;
880
+   }
881
+
882
+   return true;
883
+}
884
+
885
+static wchar_t tempPath[MAX_PATH] = {};
886
+
887
+#define PATCH_MANIFEST_URL \
888
+   L"https://obsproject.com/update_studio/getpatchmanifest"
889
+#define HASH_NULL \
890
+   L"0000000000000000000000000000000000000000"
891
+
892
+static bool Update(wchar_t *cmdLine)
893
+{
894
+   /* ------------------------------------- *
895
+    * Check to make sure OBS isn't running  */
896
+
897
+   HANDLE hObsUpdateMutex = OpenMutexW(SYNCHRONIZE, false,
898
+           L"OBSStudioUpdateMutex");
899
+   if (hObsUpdateMutex) {
900
+       HANDLE hWait[2];
901
+       hWait[0] = hObsUpdateMutex;
902
+       hWait[1] = cancelRequested;
903
+
904
+       int i = WaitForMultipleObjects(2, hWait, false, INFINITE);
905
+
906
+       if (i == WAIT_OBJECT_0)
907
+           ReleaseMutex(hObsUpdateMutex);
908
+
909
+       CloseHandle(hObsUpdateMutex);
910
+
911
+       if (i == WAIT_OBJECT_0 + 1)
912
+           return false;
913
+   }
914
+
915
+   if (!WaitForOBS())
916
+       return false;
917
+
918
+   /* ------------------------------------- *
919
+    * Init crypt stuff                      */
920
+
921
+   CryptProvider hProvider;
922
+   if (!CryptAcquireContext(&hProvider, nullptr, MS_ENH_RSA_AES_PROV,
923
+               PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
924
+       SetDlgItemTextW(hwndMain, IDC_STATUS,
925
+               L"Update failed: CryptAcquireContext failure");
926
+       return false;
927
+   }
928
+
929
+   ::hProvider = hProvider;
930
+
931
+   /* ------------------------------------- */
932
+
933
+   SetDlgItemTextW(hwndMain, IDC_STATUS,
934
+           L"Searching for available updates...");
935
+
936
+   /* ------------------------------------- *
937
+    * Check if updating portable build      */
938
+
939
+   bool bIsPortable = false;
940
+
941
+   if (cmdLine[0]) {
942
+       int argc;
943
+       LPWSTR *argv = CommandLineToArgvW(cmdLine, &argc);
944
+
945
+       if (argv) {
946
+           for (int i = 0; i < argc; i++) {
947
+               if (wcscmp(argv[i], L"Portable") == 0) {
948
+                   bIsPortable = true;
949
+               }
950
+           }
951
+
952
+           LocalFree((HLOCAL)argv);
953
+       }
954
+   }
955
+
956
+   /* ------------------------------------- *
957
+    * Get config path                       */
958
+
959
+   wchar_t lpAppDataPath[MAX_PATH];
960
+   lpAppDataPath[0] = 0;
961
+
962
+   if (bIsPortable) {
963
+       GetCurrentDirectory(_countof(lpAppDataPath), lpAppDataPath);
964
+       StringCbCat(lpAppDataPath, sizeof(lpAppDataPath), L"\\config");
965
+   } else {
966
+       CoTaskMemPtr<wchar_t> pOut;
967
+       HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData,
968
+               KF_FLAG_DEFAULT, nullptr, &pOut);
969
+       if (hr != S_OK) {
970
+           Status(L"Update failed: Could not determine AppData "
971
+                   L"location");
972
+           return false;
973
+       }
974
+
975
+       StringCbCopy(lpAppDataPath, sizeof(lpAppDataPath), pOut);
976
+       StringCbCat(lpAppDataPath, sizeof(lpAppDataPath),
977
+               L"\\obs-studio");
978
+   }
979
+
980
+   /* ------------------------------------- *
981
+    * Get download path                     */
982
+
983
+   wchar_t manifestPath[MAX_PATH];
984
+   wchar_t tempDirName[MAX_PATH];
985
+
986
+   manifestPath[0] = 0;
987
+   tempDirName[0]  = 0;
988
+
989
+   StringCbPrintf(manifestPath, sizeof(manifestPath),
990
+           L"%s\\updates\\manifest.json", lpAppDataPath);
991
+   if (!GetTempPathW(_countof(tempPath), tempPath)) {
992
+       Status(L"Update failed: Failed to get temp path: %ld",
993
+               GetLastError());
994
+       return false;
995
+   }
996
+   if (!GetTempFileNameW(tempDirName, L"obs-studio", 0, tempDirName)) {
997
+       Status(L"Update failed: Failed to create temp dir name: %ld",
998
+               GetLastError());
999
+       return false;
1000
+   }
1001
+
1002
+   StringCbCat(tempPath, sizeof(tempPath), tempDirName);
1003
+   CreateDirectory(tempPath, nullptr);
1004
+
1005
+   /* ------------------------------------- *
1006
+    * Load manifest file                    */
1007
+
1008
+   Json root;
1009
+   {
1010
+       string manifestFile = QuickReadFile(manifestPath);
1011
+       if (manifestFile.empty()) {
1012
+           Status(L"Update failed: Couldn't load manifest file");
1013
+           return false;
1014
+       }
1015
+
1016
+       json_error_t error;
1017
+       root = json_loads(manifestFile.c_str(), 0, &error);
1018
+
1019
+       if (!root) {
1020
+           Status(L"Update failed: Couldn't parse update "
1021
+                   L"manifest: %S", error.text);
1022
+           return false;
1023
+       }
1024
+   }
1025
+
1026
+   if (!json_is_object(root.get())) {
1027
+       Status(L"Update failed: Invalid update manifest");
1028
+       return false;
1029
+   }
1030
+
1031
+   /* ------------------------------------- *
1032
+    * Parse current manifest update files   */
1033
+
1034
+   json_t *packages = json_object_get(root, "packages");
1035
+   size_t packageCount = json_array_size(packages);
1036
+
1037
+   for (size_t i = 0; i < packageCount; i++) {
1038
+       if (!AddPackageUpdateFiles(packages, i, tempPath)) {
1039
+           Status(L"Failed to process update packages");
1040
+           return false;
1041
+       }
1042
+   }
1043
+
1044
+   /* ------------------------------------- *
1045
+    * Exit if updates already installed     */
1046
+
1047
+   if (!updates.size()) {
1048
+       Status(L"All available updates are already installed.");
1049
+       return true;
1050
+   }
1051
+
1052
+   /* ------------------------------------- *
1053
+    * Generate file hash json               */
1054
+
1055
+   Json files(json_array());
1056
+
1057
+   for (update_t &update : updates) {
1058
+       wchar_t whash_string[BLAKE2_HASH_STR_LENGTH];
1059
+       char    hash_string[BLAKE2_HASH_STR_LENGTH];
1060
+       char    outputPath[MAX_PATH];
1061
+
1062
+       if (!update.has_hash)
1063
+           continue;
1064
+
1065
+       /* check hash */
1066
+       HashToString(update.my_hash, whash_string);
1067
+       if (wcscmp(whash_string, HASH_NULL) == 0)
1068
+           continue;
1069
+
1070
+       if (!WideToUTF8Buf(hash_string, whash_string))
1071
+           continue;
1072
+       if (!WideToUTF8Buf(outputPath, update.basename.c_str()))
1073
+           continue;
1074
+
1075
+       string package_path;
1076
+       package_path = update.packageName;
1077
+       package_path += "/";
1078
+       package_path += outputPath;
1079
+
1080
+       json_t *obj = json_object();
1081
+       json_object_set(obj, "name", json_string(package_path.c_str()));
1082
+       json_object_set(obj, "hash", json_string(hash_string));
1083
+       json_array_append_new(files, obj);
1084
+   }
1085
+
1086
+   /* ------------------------------------- *
1087
+    * Send file hashes                      */
1088
+
1089
+   string newManifest;
1090
+   {
1091
+       char *post_body = json_dumps(files, JSON_COMPACT);
1092
+
1093
+       int    responseCode;
1094
+
1095
+       int len = (int)strlen(post_body);
1096
+       uLong compressSize = compressBound(len);
1097
+       string compressedJson;
1098
+
1099
+       compressedJson.resize(compressSize);
1100
+       compress2((Bytef*)&compressedJson[0], &compressSize,
1101
+               (const Bytef*)post_body, len,
1102
+               Z_BEST_COMPRESSION);
1103
+       compressedJson.resize(compressSize);
1104
+
1105
+       bool success = !!HTTPPostData(PATCH_MANIFEST_URL,
1106
+               (BYTE *)&compressedJson[0],
1107
+               (int)compressedJson.size(),
1108
+               L"Accept-Encoding: gzip", &responseCode,
1109
+               newManifest);
1110
+       free(post_body);
1111
+
1112
+       if (!success)
1113
+           return false;
1114
+
1115
+       if (responseCode != 200) {
1116
+           Status(L"Update failed: HTTP/%d while trying to "
1117
+                   L"download patch manifest",
1118
+                   responseCode);
1119
+           return false;
1120
+       }
1121
+   }
1122
+
1123
+   /* ------------------------------------- *
1124
+    * Parse new manifest                    */
1125
+
1126
+   json_error_t error;
1127
+   root = json_loads(newManifest.c_str(), 0, &error);
1128
+   if (!root) {
1129
+       Status(L"Update failed: Couldn't parse patch manifest: %S",
1130
+               error.text);
1131
+       return false;
1132
+   }
1133
+
1134
+   if (!json_is_array(root.get())) {
1135
+       Status(L"Update failed: Invalid patch manifest");
1136
+       return false;
1137
+   }
1138
+
1139
+   packageCount = json_array_size(root);
1140
+
1141
+   for (size_t i = 0; i < packageCount; i++) {
1142
+       json_t *patch = json_array_get(root, i);
1143
+
1144
+       if (!json_is_object(patch)) {
1145
+           Status(L"Update failed: Invalid patch manifest");
1146
+           return false;
1147
+       }
1148
+
1149
+       json_t *name_json   = json_object_get(patch, "name");
1150
+       json_t *hash_json   = json_object_get(patch, "hash");
1151
+       json_t *source_json = json_object_get(patch, "source");
1152
+       json_t *size_json   = json_object_get(patch, "size");
1153
+
1154
+       if (!json_is_string(name_json))
1155
+           continue;
1156
+       if (!json_is_string(hash_json))
1157
+           continue;
1158
+       if (!json_is_string(source_json))
1159
+           continue;
1160
+       if (!json_is_integer(size_json))
1161
+           continue;
1162
+
1163
+       const char *name   = json_string_value(name_json);
1164
+       const char *hash   = json_string_value(hash_json);
1165
+       const char *source = json_string_value(source_json);
1166
+       int         size   = (int)json_integer_value(size_json);
1167
+
1168
+       UpdateWithPatchIfAvailable(name, hash, source, size);
1169
+   }
1170
+
1171
+   /* ------------------------------------- *
1172
+    * Download Updates                      */
1173
+
1174
+   if (!RunDownloadWorkers(2))
1175
+       return false;
1176
+
1177
+   if (completedUpdates != updates.size()) {
1178
+       Status(L"Update failed to download all files.");
1179
+       return false;
1180
+   }
1181
+
1182
+   /* ------------------------------------- *
1183
+    * Install updates                       */
1184
+
1185
+   for (update_t &update : updates) {
1186
+       if (!UpdateFile(update))
1187
+           return false;
1188
+   }
1189
+
1190
+   /* If we get here, all updates installed successfully so we can purge
1191
+    * the old versions */
1192
+   for (update_t &update : updates) {
1193
+       if (!update.previousFile.empty())
1194
+           DeleteFile(update.previousFile.c_str());
1195
+
1196
+       /* We delete here not above in case of duplicate hashes */
1197
+       if (!update.tempPath.empty())
1198
+           DeleteFile(update.tempPath.c_str());
1199
+   }
1200
+
1201
+   Status(L"Update complete.");
1202
+   SetDlgItemText(hwndMain, IDC_BUTTON, L"Launch OBS");
1203
+   return true;
1204
+}
1205
+
1206
+static DWORD WINAPI UpdateThread(void *arg)
1207
+{
1208
+   wchar_t *cmdLine = (wchar_t *)arg;
1209
+
1210
+   bool success = Update(cmdLine);
1211
+
1212
+   if (!success) {
1213
+       /* This handles deleting temp files and rolling back and
1214
+        * partially installed updates */
1215
+       CleanupPartialUpdates();
1216
+
1217
+       if (tempPath[0])
1218
+           RemoveDirectory(tempPath);
1219
+
1220
+       if (WaitForSingleObject(cancelRequested, 0) == WAIT_OBJECT_0)
1221
+           Status(L"Update aborted.");
1222
+
1223
+       SendDlgItemMessage(hwndMain, IDC_PROGRESS, PBM_SETSTATE,
1224
+               PBST_ERROR, 0);
1225
+
1226
+       SetDlgItemText(hwndMain, IDC_BUTTON, L"Exit");
1227
+       EnableWindow(GetDlgItem(hwndMain, IDC_BUTTON), true);
1228
+
1229
+       updateFailed = true;
1230
+   } else {
1231
+       if (tempPath[0])
1232
+           RemoveDirectory(tempPath);
1233
+   }
1234
+
1235
+   if (bExiting)
1236
+       ExitProcess(success);
1237
+   return 0;
1238
+}
1239
+
1240
+static void CancelUpdate(bool quit)
1241
+{
1242
+   if (WaitForSingleObject(updateThread, 0) != WAIT_OBJECT_0) {
1243
+       bExiting = quit;
1244
+       SetEvent(cancelRequested);
1245
+   } else {
1246
+       PostQuitMessage(0);
1247
+   }
1248
+}
1249
+
1250
+static void LaunchOBS()
1251
+{
1252
+   wchar_t cwd[MAX_PATH];
1253
+   wchar_t newCwd[MAX_PATH];
1254
+   wchar_t obsPath[MAX_PATH];
1255
+
1256
+   GetCurrentDirectory(_countof(cwd) - 1, cwd);
1257
+
1258
+   StringCbCopy(obsPath, sizeof(obsPath), cwd);
1259
+   StringCbCat(obsPath, sizeof(obsPath), is32bit
1260
+           ? L"\\bin\\32bit"
1261
+           : L"\\bin\\64bit");
1262
+   SetCurrentDirectory(obsPath);
1263
+   StringCbCopy(newCwd, sizeof(newCwd), obsPath);
1264
+
1265
+   StringCbCat(obsPath, sizeof(obsPath), is32bit
1266
+           ? L"\\obs32.exe"
1267
+           : L"\\obs64.exe");
1268
+
1269
+   if (!FileExists(obsPath)) {
1270
+       StringCbCopy(obsPath, sizeof(obsPath), cwd);
1271
+       StringCbCat(obsPath, sizeof(obsPath), L"\\bin\\32bit");
1272
+       SetCurrentDirectory(obsPath);
1273
+       StringCbCopy(newCwd, sizeof(newCwd), obsPath);
1274
+
1275
+       StringCbCat(obsPath, sizeof(obsPath), L"\\obs32.exe");
1276
+
1277
+       if (!FileExists(obsPath)) {
1278
+           /* TODO: give user a message maybe? */
1279
+           return;
1280
+       }
1281
+   }
1282
+
1283
+   SHELLEXECUTEINFO execInfo;
1284
+
1285
+   ZeroMemory(&execInfo, sizeof(execInfo));
1286
+
1287
+   execInfo.cbSize      = sizeof(execInfo);
1288
+   execInfo.lpFile      = obsPath;
1289
+   execInfo.lpDirectory = newCwd;
1290
+   execInfo.nShow       = SW_SHOWNORMAL;
1291
+
1292
+   ShellExecuteEx(&execInfo);
1293
+}
1294
+
1295
+static INT_PTR CALLBACK UpdateDialogProc(HWND hwnd, UINT message,
1296
+       WPARAM wParam, LPARAM lParam)
1297
+{
1298
+   switch (message) {
1299
+   case WM_INITDIALOG: {
1300
+       static HICON hMainIcon = LoadIcon(hinstMain,
1301
+               MAKEINTRESOURCE(IDI_ICON1));
1302
+       SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hMainIcon);
1303
+       SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hMainIcon);
1304
+       return true;
1305
+   }
1306
+
1307
+   case WM_COMMAND:
1308
+       if (LOWORD(wParam) == IDC_BUTTON) {
1309
+           if (HIWORD(wParam) == BN_CLICKED) {
1310
+               DWORD result = WaitForSingleObject(
1311
+                       updateThread, 0);
1312
+               if (result == WAIT_OBJECT_0) {
1313
+                   if (updateFailed)
1314
+                       PostQuitMessage(0);
1315
+                   else
1316
+                       PostQuitMessage(1);
1317
+               } else {
1318
+                   EnableWindow((HWND)lParam, false);
1319
+                   CancelUpdate(false);
1320
+               }
1321
+           }
1322
+       }
1323
+       return true;
1324
+
1325
+   case WM_CLOSE:
1326
+       CancelUpdate(true);
1327
+       return true;
1328
+   }
1329
+
1330
+   return false;
1331
+}
1332
+
1333
+static void RestartAsAdmin(LPWSTR lpCmdLine)
1334
+{
1335
+   wchar_t myPath[MAX_PATH];
1336
+   if (!GetModuleFileNameW(nullptr, myPath, _countof(myPath) - 1)) {
1337
+       return;
1338
+   }
1339
+
1340
+   wchar_t cwd[MAX_PATH];
1341
+   GetCurrentDirectoryW(_countof(cwd) - 1, cwd);
1342
+
1343
+   SHELLEXECUTEINFO shExInfo = {0};
1344
+   shExInfo.cbSize           = sizeof(shExInfo);
1345
+   shExInfo.fMask            = SEE_MASK_NOCLOSEPROCESS;
1346
+   shExInfo.hwnd             = 0;
1347
+   shExInfo.lpVerb           = L"runas";  /* Operation to perform */
1348
+   shExInfo.lpFile           = myPath;    /* Application to start */
1349
+   shExInfo.lpParameters     = lpCmdLine; /* Additional parameters */
1350
+   shExInfo.lpDirectory      = cwd;
1351
+   shExInfo.nShow            = SW_NORMAL;
1352
+   shExInfo.hInstApp         = 0;
1353
+
1354
+   /* annoyingly the actual elevated updater will disappear behind other
1355
+    * windows :( */
1356
+   AllowSetForegroundWindow(ASFW_ANY);
1357
+
1358
+   if (ShellExecuteEx(&shExInfo)) {
1359
+       DWORD exitCode;
1360
+
1361
+       if (GetExitCodeProcess(shExInfo.hProcess, &exitCode)) {
1362
+           if (exitCode == 1) {
1363
+               LaunchOBS();
1364
+           }
1365
+       }
1366
+       CloseHandle(shExInfo.hProcess);
1367
+   }
1368
+}
1369
+
1370
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
1371
+{
1372
+   INITCOMMONCONTROLSEX icce;
1373
+
1374
+   if (!IsAppRunningAsAdminMode()) {
1375
+       HANDLE hLowMutex = CreateMutexW(nullptr, true,
1376
+               L"OBSUpdaterRunningAsNonAdminUser");
1377
+
1378
+       RestartAsAdmin(lpCmdLine);
1379
+
1380
+       if (hLowMutex) {
1381
+           ReleaseMutex(hLowMutex);
1382
+           CloseHandle(hLowMutex);
1383
+       }
1384
+
1385
+       return 0;
1386
+   } else {
1387
+       {
1388
+           wchar_t cwd[MAX_PATH];
1389
+           wchar_t newPath[MAX_PATH];
1390
+           GetCurrentDirectoryW(_countof(cwd) - 1, cwd);
1391
+
1392
+           is32bit = wcsstr(cwd, L"bin\\32bit") != nullptr;
1393
+           StringCbCat(cwd, sizeof(cwd), L"\\..\\..");
1394
+
1395
+           GetFullPathName(cwd, _countof(newPath), newPath,
1396
+                   nullptr);
1397
+           SetCurrentDirectory(newPath);
1398
+       }
1399
+
1400
+       hinstMain = hInstance;
1401
+
1402
+       icce.dwSize = sizeof(icce);
1403
+       icce.dwICC  = ICC_PROGRESS_CLASS;
1404
+
1405
+       InitCommonControlsEx(&icce);
1406
+
1407
+       hwndMain = CreateDialog(hInstance,
1408
+               MAKEINTRESOURCE(IDD_UPDATEDIALOG), nullptr,
1409
+               UpdateDialogProc);
1410
+       if (!hwndMain) {
1411
+           return -1;
1412
+       }
1413
+
1414
+       ShowWindow(hwndMain, SW_SHOWNORMAL);
1415
+       SetForegroundWindow(hwndMain);
1416
+
1417
+       cancelRequested = CreateEvent(nullptr, true, false, nullptr);
1418
+       updateThread = CreateThread(nullptr, 0, UpdateThread,
1419
+               lpCmdLine, 0, nullptr);
1420
+
1421
+       MSG msg;
1422
+       while (GetMessage(&msg, nullptr, 0, 0)) {
1423
+           if (!IsDialogMessage(hwndMain, &msg)) {
1424
+               TranslateMessage(&msg);
1425
+               DispatchMessage(&msg);
1426
+           }
1427
+       }
1428
+
1429
+       /* there is no non-elevated process waiting for us if UAC is
1430
+        * disabled */
1431
+       WinHandle hMutex = OpenMutex(SYNCHRONIZE, false,
1432
+               L"OBSUpdaterRunningAsNonAdminUser");
1433
+       if (msg.wParam == 1 && !hMutex) {
1434
+           LaunchOBS();
1435
+       }
1436
+
1437
+       return (int)msg.wParam;
1438
+   }
1439
+}
1440
obs-studio-18.0.1.tar.xz/UI/win-update/updater/updater.hpp Added
105
 
1
@@ -0,0 +1,103 @@
2
+#pragma once
3
+
4
+#define WINVER 0x0600
5
+#define _WIN32_WINDOWS 0x0600
6
+#define _WIN32_WINNT 0x0600
7
+#define WIN32_LEAN_AND_MEAN
8
+
9
+#define ZLIB_CONST
10
+
11
+#include <windows.h>
12
+#include <winhttp.h>
13
+#include <commctrl.h>
14
+#include <Wincrypt.h>
15
+#include <shlobj.h>
16
+#include <shellapi.h>
17
+#include <malloc.h>
18
+#include <stdlib.h>
19
+#include <tchar.h>
20
+#include <strsafe.h>
21
+#include <zlib.h>
22
+#include <ctype.h>
23
+#include <blake2.h>
24
+
25
+#include <string>
26
+
27
+#include "../win-update-helpers.hpp"
28
+
29
+#define BLAKE2_HASH_LENGTH 20
30
+#define BLAKE2_HASH_STR_LENGTH ((BLAKE2_HASH_LENGTH * 2) + 1)
31
+
32
+#if defined _M_IX86
33
+#pragma comment(linker, \
34
+                "/manifestdependency:\"type='win32' " \
35
+                "name='Microsoft.Windows.Common-Controls' " \
36
+                "version='6.0.0.0' " \
37
+                "processorArchitecture='x86' " \
38
+                "publicKeyToken='6595b64144ccf1df' " \
39
+                "language='*'\"")
40
+#elif defined _M_IA64
41
+#pragma comment(linker, \
42
+                "/manifestdependency:\"type='win32' " \
43
+                "name='Microsoft.Windows.Common-Controls' " \
44
+                "version='6.0.0.0' " \
45
+                "processorArchitecture='ia64' " \
46
+                "publicKeyToken='6595b64144ccf1df' " \
47
+                "language='*'\"")
48
+#elif defined _M_X64
49
+#pragma comment(linker, \
50
+                "/manifestdependency:\"type='win32' " \
51
+                "name='Microsoft.Windows.Common-Controls' " \
52
+                "version='6.0.0.0' " \
53
+                "processorArchitecture='amd64' " \
54
+                "publicKeyToken='6595b64144ccf1df' " \
55
+                "language='*'\"")
56
+#else
57
+#pragma comment(linker, \
58
+                "/manifestdependency:\"type='win32' " \
59
+                "name='Microsoft.Windows.Common-Controls' " \
60
+                "version='6.0.0.0' processorArchitecture='*' " \
61
+                "publicKeyToken='6595b64144ccf1df' " \
62
+                "language='*'\"")
63
+#endif
64
+
65
+#include <util/windows/WinHandle.hpp>
66
+#include <jansson.h>
67
+#include "resource.h"
68
+
69
+bool HTTPGetFile(HINTERNET      hConnect,
70
+                 const wchar_t *url,
71
+                 const wchar_t *outputPath,
72
+                 const wchar_t *extraHeaders,
73
+                 int *          responseCode);
74
+bool HTTPPostData(const wchar_t *url,
75
+                  const BYTE *   data,
76
+                  int            dataLen,
77
+                  const wchar_t *extraHeaders,
78
+                  int *          responseCode,
79
+                  std::string &  response);
80
+
81
+void HashToString(const BYTE *in, wchar_t *out);
82
+void StringToHash(const wchar_t *in, BYTE *out);
83
+
84
+bool CalculateFileHash(const wchar_t *path, BYTE *hash);
85
+
86
+int ApplyPatch(LPCTSTR patchFile, LPCTSTR targetFile);
87
+
88
+extern HWND       hwndMain;
89
+extern HCRYPTPROV hProvider;
90
+extern int        totalFileSize;
91
+extern int        completedFileSize;
92
+extern HANDLE     cancelRequested;
93
+
94
+#pragma pack(push, r1, 1)
95
+
96
+typedef struct {
97
+   BLOBHEADER blobheader;
98
+   RSAPUBKEY  rsapubkey;
99
+} PUBLICKEYHEADER;
100
+
101
+#pragma pack(pop, r1)
102
+
103
+void FreeWinHttpHandle(HINTERNET handle);
104
+using HttpHandle = CustomHandle<HINTERNET, FreeWinHttpHandle>;
105
obs-studio-18.0.1.tar.xz/UI/win-update/updater/updater.rc Added
147
 
1
@@ -0,0 +1,145 @@
2
+// Microsoft Visual C++ generated resource script.
3
+//
4
+#include "resource.h"
5
+
6
+#define APSTUDIO_READONLY_SYMBOLS
7
+/////////////////////////////////////////////////////////////////////////////
8
+//
9
+// Generated from the TEXTINCLUDE 2 resource.
10
+//
11
+#include "afxres.h"
12
+
13
+/////////////////////////////////////////////////////////////////////////////
14
+#undef APSTUDIO_READONLY_SYMBOLS
15
+
16
+/////////////////////////////////////////////////////////////////////////////
17
+// English (United States) resources
18
+
19
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21
+#pragma code_page(1252)
22
+
23
+#ifdef APSTUDIO_INVOKED
24
+/////////////////////////////////////////////////////////////////////////////
25
+//
26
+// TEXTINCLUDE
27
+//
28
+
29
+1 TEXTINCLUDE 
30
+BEGIN
31
+    "resource.h\0"
32
+END
33
+
34
+2 TEXTINCLUDE 
35
+BEGIN
36
+    "#include ""afxres.h""\r\n"
37
+    "\0"
38
+END
39
+
40
+3 TEXTINCLUDE 
41
+BEGIN
42
+    "\r\n"
43
+    "\0"
44
+END
45
+
46
+#endif    // APSTUDIO_INVOKED
47
+
48
+
49
+/////////////////////////////////////////////////////////////////////////////
50
+//
51
+// Dialog
52
+//
53
+
54
+IDD_UPDATEDIALOG DIALOGEX 0, 0, 316, 56
55
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
56
+EXSTYLE WS_EX_APPWINDOW
57
+CAPTION "OBS Studio Update"
58
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
59
+BEGIN
60
+    PUSHBUTTON      "Cancel",IDC_BUTTON,259,34,50,14
61
+    CONTROL         "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH,7,17,302,14
62
+    LTEXT           "Waiting for OBS to exit...",IDC_STATUS,7,7,302,8,SS_WORDELLIPSIS
63
+END
64
+
65
+
66
+/////////////////////////////////////////////////////////////////////////////
67
+//
68
+// DESIGNINFO
69
+//
70
+
71
+#ifdef APSTUDIO_INVOKED
72
+GUIDELINES DESIGNINFO
73
+BEGIN
74
+    IDD_UPDATEDIALOG, DIALOG
75
+    BEGIN
76
+        LEFTMARGIN, 7
77
+        RIGHTMARGIN, 309
78
+        TOPMARGIN, 7
79
+        BOTTOMMARGIN, 48
80
+    END
81
+END
82
+#endif    // APSTUDIO_INVOKED
83
+
84
+
85
+/////////////////////////////////////////////////////////////////////////////
86
+//
87
+// Version
88
+//
89
+
90
+VS_VERSION_INFO VERSIONINFO
91
+ FILEVERSION 1,0,0,1
92
+ PRODUCTVERSION 1,0,0,1
93
+ FILEFLAGSMASK 0x3fL
94
+#ifdef _DEBUG
95
+ FILEFLAGS 0x1L
96
+#else
97
+ FILEFLAGS 0x0L
98
+#endif
99
+ FILEOS 0x40004L
100
+ FILETYPE 0x1L
101
+ FILESUBTYPE 0x0L
102
+BEGIN
103
+    BLOCK "StringFileInfo"
104
+    BEGIN
105
+        BLOCK "040904b0"
106
+        BEGIN
107
+            VALUE "CompanyName", "obsproject.com"
108
+            VALUE "FileDescription", "OBS Updater"
109
+            VALUE "FileVersion", "1.0.0.1"
110
+            VALUE "InternalName", "updater.exe"
111
+            VALUE "LegalCopyright", "Copyright (C) 2013 Richard Stanway"
112
+            VALUE "OriginalFilename", "updater.exe"
113
+            VALUE "ProductName", "OBS Updater"
114
+            VALUE "ProductVersion", "1.0.0.1"
115
+        END
116
+    END
117
+    BLOCK "VarFileInfo"
118
+    BEGIN
119
+        VALUE "Translation", 0x409, 1200
120
+    END
121
+END
122
+
123
+
124
+/////////////////////////////////////////////////////////////////////////////
125
+//
126
+// Icon
127
+//
128
+
129
+// Icon with lowest ID value placed first to ensure application icon
130
+// remains consistent on all systems.
131
+IDI_ICON1               ICON                    "../../../cmake/winrc/obs-studio.ico"
132
+#endif    // English (United States) resources
133
+/////////////////////////////////////////////////////////////////////////////
134
+
135
+
136
+
137
+#ifndef APSTUDIO_INVOKED
138
+/////////////////////////////////////////////////////////////////////////////
139
+//
140
+// Generated from the TEXTINCLUDE 3 resource.
141
+//
142
+
143
+
144
+/////////////////////////////////////////////////////////////////////////////
145
+#endif    // not APSTUDIO_INVOKED
146
+
147
obs-studio-18.0.0.tar.xz/UI/win-update/win-update.cpp -> obs-studio-18.0.1.tar.xz/UI/win-update/win-update.cpp Changed
10
 
1
@@ -510,7 +510,7 @@
2
 
3
 static bool IsFileInUse(const wstring &file)
4
 {
5
-   WinHandle f = CreateFile(file.c_str(), GENERIC_READ, 0, nullptr,
6
+   WinHandle f = CreateFile(file.c_str(), GENERIC_WRITE, 0, nullptr,
7
            OPEN_EXISTING, 0, nullptr);
8
    if (!f.Valid()) {
9
        int err = GetLastError();
10
obs-studio-18.0.0.tar.xz/UI/window-basic-main.cpp -> obs-studio-18.0.1.tar.xz/UI/window-basic-main.cpp Changed
40
 
1
@@ -587,6 +587,18 @@
2
 
3
    blog(LOG_INFO, "    - source: '%s' (%s)", name, id);
4
 
5
+   obs_monitoring_type monitoring_type =
6
+       obs_source_get_monitoring_type(source);
7
+
8
+   if (monitoring_type != OBS_MONITORING_TYPE_NONE) {
9
+       const char *type =
10
+           (monitoring_type == OBS_MONITORING_TYPE_MONITOR_ONLY)
11
+           ? "monitor only"
12
+           : "monitor and output";
13
+
14
+       blog(LOG_INFO, "        - monitoring: %s", type);
15
+   }
16
+
17
    obs_source_enum_filters(source, LogFilter, (void*)(intptr_t)2);
18
    return true;
19
 }
20
@@ -1245,6 +1257,19 @@
21
            throw UNKNOWN_ERROR;
22
    }
23
 
24
+   /* load audio monitoring */
25
+#if defined(_WIN32) || defined(__APPLE__)
26
+   const char *device_name = config_get_string(basicConfig, "Audio",
27
+           "MonitoringDeviceName");
28
+   const char *device_id = config_get_string(basicConfig, "Audio",
29
+           "MonitoringDeviceId");
30
+
31
+   obs_set_audio_monitoring_device(device_name, device_id);
32
+
33
+   blog(LOG_INFO, "Audio monitoring device:\n\tname: %s\n\tid: %s",
34
+           device_name, device_id);
35
+#endif
36
+
37
    InitOBSCallbacks();
38
    InitHotkeys();
39
 
40
obs-studio-18.0.0.tar.xz/UI/window-basic-settings.cpp -> obs-studio-18.0.1.tar.xz/UI/window-basic-settings.cpp Changed
41
 
1
@@ -1704,6 +1704,7 @@
2
        ui->advOutRecTopContainer->setEnabled(false);
3
        ui->advOutRecTypeContainer->setEnabled(false);
4
        ui->advOutputAudioTracksTab->setEnabled(false);
5
+       ui->advNetworkGroupBox->setEnabled(false);
6
    }
7
 
8
    loading = false;
9
@@ -2543,6 +2544,9 @@
10
 
11
 void OBSBasicSettings::SaveAdvancedSettings()
12
 {
13
+   QString lastMonitoringDevice = config_get_string(main->Config(),
14
+           "Audio", "MonitoringDeviceId");
15
+
16
 #ifdef _WIN32
17
    if (WidgetChanged(ui->renderer))
18
        config_set_string(App()->GlobalConfig(), "Video", "Renderer",
19
@@ -2592,10 +2596,17 @@
20
    SaveComboData(ui->bindToIP, "Output", "BindIP");
21
 
22
 #if defined(_WIN32) || defined(__APPLE__)
23
-   obs_set_audio_monitoring_device(
24
-           QT_TO_UTF8(ui->monitoringDevice->currentText()),
25
-           QT_TO_UTF8(ui->monitoringDevice->currentData()
26
-               .toString()));
27
+   QString newDevice = ui->monitoringDevice->currentData().toString();
28
+
29
+   if (lastMonitoringDevice != newDevice) {
30
+       obs_set_audio_monitoring_device(
31
+               QT_TO_UTF8(ui->monitoringDevice->currentText()),
32
+               QT_TO_UTF8(newDevice));
33
+
34
+       blog(LOG_INFO, "Audio monitoring device:\n\tname: %s\n\tid: %s",
35
+               QT_TO_UTF8(ui->monitoringDevice->currentText()),
36
+               QT_TO_UTF8(newDevice));
37
+   }
38
 #endif
39
 }
40
 
41
obs-studio-18.0.0.tar.xz/deps/CMakeLists.txt -> obs-studio-18.0.1.tar.xz/deps/CMakeLists.txt Changed
9
 
1
@@ -10,6 +10,7 @@
2
 
3
 if(WIN32)
4
    add_subdirectory(blake2)
5
+   add_subdirectory(lzma)
6
 endif()
7
 
8
 if(BUILD_CAPTIONS)
9
obs-studio-18.0.0.tar.xz/deps/blake2/src/blake2.h -> obs-studio-18.0.1.tar.xz/deps/blake2/src/blake2.h Changed
12
 
1
@@ -137,8 +137,8 @@
2
 
3
   /* Padded structs result in a compile-time error */
4
   enum {
5
-    BLAKE2_DUMMY_1 = 1/(sizeof(blake2s_param) == BLAKE2S_OUTBYTES),
6
-    BLAKE2_DUMMY_2 = 1/(sizeof(blake2b_param) == BLAKE2B_OUTBYTES)
7
+    BLAKE2_DUMMY_1 = 1/(int)(sizeof(blake2s_param) == BLAKE2S_OUTBYTES),
8
+    BLAKE2_DUMMY_2 = 1/(int)(sizeof(blake2b_param) == BLAKE2B_OUTBYTES)
9
   };
10
 
11
   /* Streaming API */
12
obs-studio-18.0.1.tar.xz/deps/lzma Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/CMakeLists.txt Added
147
 
1
@@ -0,0 +1,145 @@
2
+cmake_minimum_required(VERSION 3.2)
3
+
4
+project(lzma)
5
+
6
+set(LIBLZMA_INCLUDE_DIRS 
7
+   "${CMAKE_CURRENT_SOURCE_DIR}"
8
+   "${CMAKE_CURRENT_SOURCE_DIR}/liblzma/api" 
9
+       CACHE PATH "lzma include path")
10
+
11
+set(LIBLZMA_CONFIG
12
+   "${CMAKE_CURRENT_SOURCE_DIR}/config.h"
13
+       CACHE PATH "lzma config.h path")
14
+
15
+include_directories(
16
+   ${LIBLZMA_INCLUDE_DIRS}
17
+   common
18
+   liblzma/api
19
+   liblzma/check
20
+   liblzma/common
21
+   liblzma/delta
22
+   liblzma/lz
23
+   liblzma/lzma
24
+   liblzma/rangecoder
25
+   liblzma/simple
26
+)
27
+
28
+add_definitions(
29
+   -DHAVE_CONFIG_H
30
+   -DTUKLIB_SYMBOL_PREFIX=lzma_)
31
+
32
+if(WIN32)
33
+   if(MSVC)
34
+       add_compile_options("$<$<CONFIG:RelWithDebInfo>:/MT>")
35
+   endif()
36
+   add_definitions(
37
+       -Dinline=_inline
38
+       -Drestrict=__restrict)
39
+endif()
40
+
41
+set(liblzma_check_SOURCES
42
+   liblzma/check/check.c)
43
+
44
+list(APPEND liblzma_check_SOURCES
45
+   liblzma/check/crc32_table.c
46
+   liblzma/check/crc32_fast.c
47
+   liblzma/check/crc64_table.c
48
+   liblzma/check/crc64_fast.c
49
+   liblzma/check/sha256.c)
50
+
51
+set(liblzma_common_SOURCES
52
+   liblzma/common/common.c
53
+   liblzma/common/block_util.c
54
+   liblzma/common/easy_preset.c
55
+   liblzma/common/filter_common.c
56
+   liblzma/common/hardware_physmem.c
57
+   liblzma/common/index.c
58
+   liblzma/common/stream_flags_common.c
59
+   liblzma/common/vli_size.c
60
+   liblzma/common/alone_encoder.c
61
+   liblzma/common/block_buffer_encoder.c
62
+   liblzma/common/block_encoder.c
63
+   liblzma/common/block_header_encoder.c
64
+   liblzma/common/easy_buffer_encoder.c
65
+   liblzma/common/easy_encoder.c
66
+   liblzma/common/easy_encoder_memusage.c
67
+   liblzma/common/filter_buffer_encoder.c
68
+   liblzma/common/filter_encoder.c
69
+   liblzma/common/filter_flags_encoder.c
70
+   liblzma/common/index_encoder.c
71
+   liblzma/common/stream_buffer_encoder.c
72
+   liblzma/common/stream_encoder.c
73
+   liblzma/common/stream_flags_encoder.c
74
+   liblzma/common/vli_encoder.c
75
+   liblzma/common/alone_decoder.c
76
+   liblzma/common/auto_decoder.c
77
+   liblzma/common/block_buffer_decoder.c
78
+   liblzma/common/block_decoder.c
79
+   liblzma/common/block_header_decoder.c
80
+   liblzma/common/easy_decoder_memusage.c
81
+   liblzma/common/filter_buffer_decoder.c
82
+   liblzma/common/filter_decoder.c
83
+   liblzma/common/filter_flags_decoder.c
84
+   liblzma/common/index_decoder.c
85
+   liblzma/common/index_hash.c
86
+   liblzma/common/stream_buffer_decoder.c
87
+   liblzma/common/stream_decoder.c
88
+   liblzma/common/stream_flags_decoder.c
89
+   liblzma/common/vli_decoder.c)
90
+
91
+set(liblzma_delta_SOURCES
92
+   liblzma/delta/delta_common.c
93
+   liblzma/delta/delta_encoder.c
94
+   liblzma/delta/delta_decoder.c)
95
+
96
+set(liblzma_lzma_SOURCES
97
+   liblzma/lzma/lzma_encoder.c
98
+   liblzma/lzma/lzma_encoder_presets.c
99
+   liblzma/lzma/lzma_encoder_optimum_fast.c
100
+   liblzma/lzma/lzma_encoder_optimum_normal.c
101
+   liblzma/lzma/fastpos_table.c
102
+   liblzma/lzma/lzma_decoder.c
103
+
104
+   liblzma/lzma/lzma2_encoder.c
105
+   liblzma/lzma/lzma2_decoder.c)
106
+
107
+set(liblzma_lz_SOURCES
108
+   liblzma/lz/lz_encoder.c
109
+   liblzma/lz/lz_encoder_mf.c
110
+   liblzma/lz/lz_decoder.c)
111
+
112
+set(liblzma_rangecoder_SOURCES
113
+   liblzma/rangecoder/price_table.c)
114
+
115
+set(liblzma_simple_SOURCES
116
+   liblzma/simple/simple_coder.c
117
+   liblzma/simple/simple_encoder.c
118
+   liblzma/simple/simple_decoder.c
119
+   
120
+   liblzma/simple/arm.c
121
+   liblzma/simple/armthumb.c
122
+   liblzma/simple/ia64.c
123
+   liblzma/simple/powerpc.c
124
+   liblzma/simple/sparc.c
125
+   liblzma/simple/x86.c)
126
+
127
+if (WIN32)
128
+   SET_SOURCE_FILES_PROPERTIES(
129
+       ${liblzma_check_SOURCES}
130
+       ${liblzma_common_SOURCES}
131
+       ${liblzma_delta_SOURCES}
132
+       ${liblzma_lz_SOURCES}
133
+       ${liblzma_lzma_SOURCES}
134
+       ${liblzma_rangecoder_SOURCES}
135
+       ${liblzma_simple_SOURCES}
136
+           PROPERTIES LANGUAGE C)
137
+endif()
138
+
139
+add_library(lzma STATIC
140
+   ${liblzma_check_SOURCES}
141
+   ${liblzma_common_SOURCES}
142
+   ${liblzma_delta_SOURCES}
143
+   ${liblzma_lz_SOURCES}
144
+   ${liblzma_lzma_SOURCES}
145
+   ${liblzma_rangecoder_SOURCES}
146
+   ${liblzma_simple_SOURCES})
147
obs-studio-18.0.1.tar.xz/deps/lzma/common Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/common/common_w32res.rc Added
52
 
1
@@ -0,0 +1,50 @@
2
+/*
3
+ * Author: Lasse Collin
4
+ *
5
+ * This file has been put into the public domain.
6
+ * You can do whatever you want with this file.
7
+ */
8
+
9
+#include <winresrc.h>
10
+#include "config.h"
11
+#define LZMA_H_INTERNAL
12
+#define LZMA_H_INTERNAL_RC
13
+#include "lzma/version.h"
14
+
15
+#ifndef MY_BUILD
16
+# define MY_BUILD 0
17
+#endif
18
+#define MY_VERSION LZMA_VERSION_MAJOR,LZMA_VERSION_MINOR,LZMA_VERSION_PATCH,MY_BUILD
19
+
20
+#define MY_FILENAME    MY_NAME MY_SUFFIX
21
+#define MY_COMPANY     "The Tukaani Project <http://tukaani.org/>"
22
+#define MY_PRODUCT     PACKAGE_NAME " <" PACKAGE_URL ">"
23
+
24
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
25
+VS_VERSION_INFO VERSIONINFO
26
+  FILEVERSION MY_VERSION
27
+  PRODUCTVERSION MY_VERSION
28
+  FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
29
+  FILEFLAGS 0
30
+  FILEOS VOS_NT_WINDOWS32
31
+  FILETYPE MY_TYPE
32
+  FILESUBTYPE 0x0L
33
+BEGIN
34
+    BLOCK "StringFileInfo"
35
+    BEGIN
36
+        BLOCK "040904b0"
37
+        BEGIN
38
+            VALUE "CompanyName", MY_COMPANY
39
+            VALUE "FileDescription", MY_DESC
40
+            VALUE "FileVersion", LZMA_VERSION_STRING
41
+            VALUE "InternalName", MY_NAME
42
+            VALUE "OriginalFilename", MY_FILENAME
43
+            VALUE "ProductName", MY_PRODUCT
44
+            VALUE "ProductVersion", LZMA_VERSION_STRING
45
+        END
46
+    END
47
+    BLOCK "VarFileInfo"
48
+    BEGIN
49
+        VALUE "Translation", 0x409, 1200
50
+    END
51
+END
52
obs-studio-18.0.1.tar.xz/deps/lzma/common/mythread.h Added
44
 
1
@@ -0,0 +1,42 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       mythread.h
5
+/// \brief      Wrappers for threads
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "sysdefs.h"
15
+
16
+
17
+#ifdef HAVE_PTHREAD
18
+#  include <pthread.h>
19
+
20
+#  define mythread_once(func) \
21
+   do { \
22
+       static pthread_once_t once_ = PTHREAD_ONCE_INIT; \
23
+       pthread_once(&once_, &func); \
24
+   } while (0)
25
+
26
+#  define mythread_sigmask(how, set, oset) \
27
+       pthread_sigmask(how, set, oset)
28
+
29
+#else
30
+
31
+#  define mythread_once(func) \
32
+   do { \
33
+       static bool once_ = false; \
34
+       if (!once_) { \
35
+           func(); \
36
+           once_ = true; \
37
+       } \
38
+   } while (0)
39
+
40
+#  define mythread_sigmask(how, set, oset) \
41
+       sigprocmask(how, set, oset)
42
+
43
+#endif
44
obs-studio-18.0.1.tar.xz/deps/lzma/common/sysdefs.h Added
201
 
1
@@ -0,0 +1,199 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       sysdefs.h
5
+/// \brief      Common includes, definitions, system-specific things etc.
6
+///
7
+/// This file is used also by the lzma command line tool, that's why this
8
+/// file is separate from common.h.
9
+//
10
+//  Author:     Lasse Collin
11
+//
12
+//  This file has been put into the public domain.
13
+//  You can do whatever you want with this file.
14
+//
15
+///////////////////////////////////////////////////////////////////////////////
16
+
17
+#ifndef LZMA_SYSDEFS_H
18
+#define LZMA_SYSDEFS_H
19
+
20
+//////////////
21
+// Includes //
22
+//////////////
23
+
24
+#ifdef HAVE_CONFIG_H
25
+#  include <config.h>
26
+#endif
27
+
28
+#if defined(_MSC_VER) && _MSC_VER >= 1400
29
+#  define VC_EXTRALEAN
30
+#  include <Windows.h>
31
+#  include <intrin.h>
32
+#  undef VC_EXTRALEAN
33
+#endif
34
+
35
+// Get standard-compliant stdio functions under MinGW and MinGW-w64.
36
+#ifdef __MINGW32__
37
+#  define __USE_MINGW_ANSI_STDIO 1
38
+#endif
39
+
40
+// size_t and NULL
41
+#include <stddef.h>
42
+
43
+#ifdef HAVE_INTTYPES_H
44
+#  include <inttypes.h>
45
+#endif
46
+
47
+// C99 says that inttypes.h always includes stdint.h, but some systems
48
+// don't do that, and require including stdint.h separately.
49
+#ifdef HAVE_STDINT_H
50
+#  include <stdint.h>
51
+#endif
52
+
53
+// Some pre-C99 systems have SIZE_MAX in limits.h instead of stdint.h. The
54
+// limits are also used to figure out some macros missing from pre-C99 systems.
55
+#ifdef HAVE_LIMITS_H
56
+#  include <limits.h>
57
+#endif
58
+
59
+// Be more compatible with systems that have non-conforming inttypes.h.
60
+// We assume that int is 32-bit and that long is either 32-bit or 64-bit.
61
+// Full Autoconf test could be more correct, but this should work well enough.
62
+// Note that this duplicates some code from lzma.h, but this is better since
63
+// we can work without inttypes.h thanks to Autoconf tests.
64
+#ifndef UINT32_C
65
+#  if UINT_MAX != 4294967295U
66
+#      error UINT32_C is not defined and unsigned int is not 32-bit.
67
+#  endif
68
+#  define UINT32_C(n) n ## U
69
+#endif
70
+#ifndef UINT32_MAX
71
+#  define UINT32_MAX UINT32_C(4294967295)
72
+#endif
73
+#ifndef PRIu32
74
+#  define PRIu32 "u"
75
+#endif
76
+#ifndef PRIx32
77
+#  define PRIx32 "x"
78
+#endif
79
+#ifndef PRIX32
80
+#  define PRIX32 "X"
81
+#endif
82
+
83
+#if ULONG_MAX == 4294967295UL
84
+#  ifndef UINT64_C
85
+#      define UINT64_C(n) n ## ULL
86
+#  endif
87
+#  ifndef PRIu64
88
+#      define PRIu64 "llu"
89
+#  endif
90
+#  ifndef PRIx64
91
+#      define PRIx64 "llx"
92
+#  endif
93
+#  ifndef PRIX64
94
+#      define PRIX64 "llX"
95
+#  endif
96
+#else
97
+#  ifndef UINT64_C
98
+#      define UINT64_C(n) n ## UL
99
+#  endif
100
+#  ifndef PRIu64
101
+#      define PRIu64 "lu"
102
+#  endif
103
+#  ifndef PRIx64
104
+#      define PRIx64 "lx"
105
+#  endif
106
+#  ifndef PRIX64
107
+#      define PRIX64 "lX"
108
+#  endif
109
+#endif
110
+#ifndef UINT64_MAX
111
+#  define UINT64_MAX UINT64_C(18446744073709551615)
112
+#endif
113
+
114
+// Incorrect(?) SIZE_MAX:
115
+//   - Interix headers typedef size_t to unsigned long,
116
+//     but a few lines later define SIZE_MAX to INT32_MAX.
117
+//   - SCO OpenServer (x86) headers typedef size_t to unsigned int
118
+//     but define SIZE_MAX to INT32_MAX.
119
+#if defined(__INTERIX) || defined(_SCO_DS)
120
+#  undef SIZE_MAX
121
+#endif
122
+
123
+// The code currently assumes that size_t is either 32-bit or 64-bit.
124
+#ifndef SIZE_MAX
125
+#  if SIZEOF_SIZE_T == 4
126
+#      define SIZE_MAX UINT32_MAX
127
+#  elif SIZEOF_SIZE_T == 8
128
+#      define SIZE_MAX UINT64_MAX
129
+#  else
130
+#      error size_t is not 32-bit or 64-bit
131
+#  endif
132
+#endif
133
+#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX
134
+#  error size_t is not 32-bit or 64-bit
135
+#endif
136
+
137
+#include <stdlib.h>
138
+#include <assert.h>
139
+
140
+// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written
141
+// so that it works with fake bool type, for example:
142
+//
143
+//    bool foo = (flags & 0x100) != 0;
144
+//    bool bar = !!(flags & 0x100);
145
+//
146
+// This works with the real C99 bool but breaks with fake bool:
147
+//
148
+//    bool baz = (flags & 0x100);
149
+//
150
+#ifdef HAVE_STDBOOL_H
151
+#  include <stdbool.h>
152
+#else
153
+#  if ! HAVE__BOOL
154
+typedef unsigned char _Bool;
155
+#  endif
156
+#  define bool _Bool
157
+#  define false 0
158
+#  define true 1
159
+#  define __bool_true_false_are_defined 1
160
+#endif
161
+
162
+// string.h should be enough but let's include strings.h and memory.h too if
163
+// they exists, since that shouldn't do any harm, but may improve portability.
164
+#ifdef HAVE_STRING_H
165
+#  include <string.h>
166
+#endif
167
+
168
+#ifdef HAVE_STRINGS_H
169
+#  include <strings.h>
170
+#endif
171
+
172
+#ifdef HAVE_MEMORY_H
173
+#  include <memory.h>
174
+#endif
175
+
176
+
177
+////////////
178
+// Macros //
179
+////////////
180
+
181
+#undef memzero
182
+#define memzero(s, n) memset(s, 0, n)
183
+
184
+// NOTE: Avoid using MIN() and MAX(), because even conditionally defining
185
+// those macros can cause some portability trouble, since on some systems
186
+// the system headers insist defining their own versions.
187
+#define my_min(x, y) ((x) < (y) ? (x) : (y))
188
+#define my_max(x, y) ((x) > (y) ? (x) : (y))
189
+
190
+#ifndef ARRAY_SIZE
191
+#  define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
192
+#endif
193
+
194
+#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
195
+#  define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x)))
196
+#else
197
+#  define lzma_attr_alloc_size(x)
198
+#endif
199
+
200
+#endif
201
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_common.h Added
73
 
1
@@ -0,0 +1,71 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_common.h
5
+/// \brief      Common definitions for tuklib modules
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef TUKLIB_COMMON_H
15
+#define TUKLIB_COMMON_H
16
+
17
+// The config file may be replaced by a package-specific file.
18
+// It should include at least stddef.h, inttypes.h, and limits.h.
19
+#include "tuklib_config.h"
20
+
21
+// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by
22
+// the tuklib modules. If you use a tuklib module in a library,
23
+// you should use TUKLIB_SYMBOL_PREFIX to make sure that there
24
+// are no symbol conflicts in case someone links your library
25
+// into application that also uses the same tuklib module.
26
+#ifndef TUKLIB_SYMBOL_PREFIX
27
+#  define TUKLIB_SYMBOL_PREFIX
28
+#endif
29
+
30
+#define TUKLIB_CAT_X(a, b) a ## b
31
+#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b)
32
+
33
+#ifndef TUKLIB_SYMBOL
34
+#  define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym)
35
+#endif
36
+
37
+#ifndef TUKLIB_DECLS_BEGIN
38
+#  ifdef __cplusplus
39
+#      define TUKLIB_DECLS_BEGIN extern "C" {
40
+#  else
41
+#      define TUKLIB_DECLS_BEGIN
42
+#  endif
43
+#endif
44
+
45
+#ifndef TUKLIB_DECLS_END
46
+#  ifdef __cplusplus
47
+#      define TUKLIB_DECLS_END }
48
+#  else
49
+#      define TUKLIB_DECLS_END
50
+#  endif
51
+#endif
52
+
53
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
54
+#  define TUKLIB_GNUC_REQ(major, minor) \
55
+       ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \
56
+           || __GNUC__ > (major))
57
+#else
58
+#  define TUKLIB_GNUC_REQ(major, minor) 0
59
+#endif
60
+
61
+#if TUKLIB_GNUC_REQ(2, 5)
62
+#  define tuklib_attr_noreturn __attribute__((__noreturn__))
63
+#else
64
+#  define tuklib_attr_noreturn
65
+#endif
66
+
67
+#if (defined(_WIN32) && !defined(__CYGWIN__)) \
68
+       || defined(__OS2__) || defined(__MSDOS__)
69
+#  define TUKLIB_DOSLIKE 1
70
+#endif
71
+
72
+#endif
73
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_config.h Added
9
 
1
@@ -0,0 +1,7 @@
2
+#ifdef HAVE_CONFIG_H
3
+#  include "sysdefs.h"
4
+#else
5
+#  include <stddef.h>
6
+#  include <inttypes.h>
7
+#  include <limits.h>
8
+#endif
9
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_cpucores.c Added
64
 
1
@@ -0,0 +1,62 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_cpucores.c
5
+/// \brief      Get the number of CPU cores online
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_cpucores.h"
15
+
16
+#if defined(TUKLIB_CPUCORES_SYSCTL)
17
+#  ifdef HAVE_SYS_PARAM_H
18
+#      include <sys/param.h>
19
+#  endif
20
+#  include <sys/sysctl.h>
21
+
22
+#elif defined(TUKLIB_CPUCORES_SYSCONF)
23
+#  include <unistd.h>
24
+
25
+// HP-UX
26
+#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
27
+#  include <sys/param.h>
28
+#  include <sys/pstat.h>
29
+#endif
30
+
31
+
32
+extern uint32_t
33
+tuklib_cpucores(void)
34
+{
35
+   uint32_t ret = 0;
36
+
37
+#if defined(TUKLIB_CPUCORES_SYSCTL)
38
+   int name[2] = { CTL_HW, HW_NCPU };
39
+   int cpus;
40
+   size_t cpus_size = sizeof(cpus);
41
+   if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1
42
+           && cpus_size == sizeof(cpus) && cpus > 0)
43
+       ret = cpus;
44
+
45
+#elif defined(TUKLIB_CPUCORES_SYSCONF)
46
+#  ifdef _SC_NPROCESSORS_ONLN
47
+   // Most systems
48
+   const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
49
+#  else
50
+   // IRIX
51
+   const long cpus = sysconf(_SC_NPROC_ONLN);
52
+#  endif
53
+   if (cpus > 0)
54
+       ret = cpus;
55
+
56
+#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
57
+   struct pst_dynamic pst;
58
+   if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1)
59
+       ret = pst.psd_proc_cnt;
60
+#endif
61
+
62
+   return ret;
63
+}
64
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_cpucores.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_cpucores.h
5
+/// \brief      Get the number of CPU cores online
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef TUKLIB_CPUCORES_H
15
+#define TUKLIB_CPUCORES_H
16
+
17
+#include "tuklib_common.h"
18
+TUKLIB_DECLS_BEGIN
19
+
20
+#define tuklib_cpucores TUKLIB_SYMBOL(tuklib_cpucores)
21
+extern uint32_t tuklib_cpucores(void);
22
+
23
+TUKLIB_DECLS_END
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_exit.c Added
59
 
1
@@ -0,0 +1,57 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_exit.c
5
+/// \brief      Close stdout and stderr, and exit
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_common.h"
15
+
16
+#include <stdlib.h>
17
+#include <stdio.h>
18
+
19
+#include "tuklib_gettext.h"
20
+#include "tuklib_progname.h"
21
+#include "tuklib_exit.h"
22
+
23
+
24
+extern void
25
+tuklib_exit(int status, int err_status, int show_error)
26
+{
27
+   if (status != err_status) {
28
+       // Close stdout. If something goes wrong,
29
+       // print an error message to stderr.
30
+       const int ferror_err = ferror(stdout);
31
+       const int fclose_err = fclose(stdout);
32
+       if (ferror_err || fclose_err) {
33
+           status = err_status;
34
+
35
+           // If it was fclose() that failed, we have the reason
36
+           // in errno. If only ferror() indicated an error,
37
+           // we have no idea what the reason was.
38
+           if (show_error)
39
+               fprintf(stderr, "%s: %s: %s\n", progname,
40
+                       _("Writing to standard "
41
+                           "output failed"),
42
+                       fclose_err ? strerror(errno)
43
+                           : _("Unknown error"));
44
+       }
45
+   }
46
+
47
+   if (status != err_status) {
48
+       // Close stderr. If something goes wrong, there's
49
+       // nothing where we could print an error message.
50
+       // Just set the exit status.
51
+       const int ferror_err = ferror(stderr);
52
+       const int fclose_err = fclose(stderr);
53
+       if (fclose_err || ferror_err)
54
+           status = err_status;
55
+   }
56
+
57
+   exit(status);
58
+}
59
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_exit.h Added
27
 
1
@@ -0,0 +1,25 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_exit.h
5
+/// \brief      Close stdout and stderr, and exit
6
+/// \note       Requires tuklib_progname and tuklib_gettext modules
7
+//
8
+//  Author:     Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef TUKLIB_EXIT_H
16
+#define TUKLIB_EXIT_H
17
+
18
+#include "tuklib_common.h"
19
+TUKLIB_DECLS_BEGIN
20
+
21
+#define tuklib_exit TUKLIB_SYMBOL(tuklib_exit)
22
+extern void tuklib_exit(int status, int err_status, int show_error)
23
+       tuklib_attr_noreturn;
24
+
25
+TUKLIB_DECLS_END
26
+#endif
27
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_gettext.h Added
46
 
1
@@ -0,0 +1,44 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_gettext.h
5
+/// \brief      Wrapper for gettext and friends
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef TUKLIB_GETTEXT_H
15
+#define TUKLIB_GETTEXT_H
16
+
17
+#include "tuklib_common.h"
18
+#include <locale.h>
19
+
20
+#ifndef TUKLIB_GETTEXT
21
+#  ifdef ENABLE_NLS
22
+#      define TUKLIB_GETTEXT 1
23
+#  else
24
+#      define TUKLIB_GETTEXT 0
25
+#  endif
26
+#endif
27
+
28
+#if TUKLIB_GETTEXT
29
+#  include <libintl.h>
30
+#  define tuklib_gettext_init(package, localedir) \
31
+       do { \
32
+           setlocale(LC_ALL, ""); \
33
+           bindtextdomain(package, localedir); \
34
+           textdomain(package); \
35
+       } while (0)
36
+#  define _(msgid) gettext(msgid)
37
+#else
38
+#  define tuklib_gettext_init(package, localedir) \
39
+       setlocale(LC_ALL, "")
40
+#  define _(msgid) (msgid)
41
+#  define ngettext(msgid1, msgid2, n) ((n) == 1 ? (msgid1) : (msgid2))
42
+#endif
43
+#define N_(msgid) msgid
44
+
45
+#endif
46
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_integer.h Added
525
 
1
@@ -0,0 +1,523 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_integer.h
5
+/// \brief      Various integer and bit operations
6
+///
7
+/// This file provides macros or functions to do some basic integer and bit
8
+/// operations.
9
+///
10
+/// Endianness related integer operations (XX = 16, 32, or 64; Y = b or l):
11
+///   - Byte swapping: bswapXX(num)
12
+///   - Byte order conversions to/from native: convXXYe(num)
13
+///   - Aligned reads: readXXYe(ptr)
14
+///   - Aligned writes: writeXXYe(ptr, num)
15
+///   - Unaligned reads (16/32-bit only): unaligned_readXXYe(ptr)
16
+///   - Unaligned writes (16/32-bit only): unaligned_writeXXYe(ptr, num)
17
+///
18
+/// Since they can macros, the arguments should have no side effects since
19
+/// they may be evaluated more than once.
20
+///
21
+/// \todo       PowerPC and possibly some other architectures support
22
+///             byte swapping load and store instructions. This file
23
+///             doesn't take advantage of those instructions.
24
+///
25
+/// Bit scan operations for non-zero 32-bit integers:
26
+///   - Bit scan reverse (find highest non-zero bit): bsr32(num)
27
+///   - Count leading zeros: clz32(num)
28
+///   - Count trailing zeros: ctz32(num)
29
+///   - Bit scan forward (simply an alias for ctz32()): bsf32(num)
30
+///
31
+/// The above bit scan operations return 0-31. If num is zero,
32
+/// the result is undefined.
33
+//
34
+//  Authors:    Lasse Collin
35
+//              Joachim Henke
36
+//
37
+//  This file has been put into the public domain.
38
+//  You can do whatever you want with this file.
39
+//
40
+///////////////////////////////////////////////////////////////////////////////
41
+
42
+#ifndef TUKLIB_INTEGER_H
43
+#define TUKLIB_INTEGER_H
44
+
45
+#include "tuklib_common.h"
46
+
47
+
48
+////////////////////////////////////////
49
+// Operating system specific features //
50
+////////////////////////////////////////
51
+
52
+#if defined(HAVE_BYTESWAP_H)
53
+   // glibc, uClibc, dietlibc
54
+#  include <byteswap.h>
55
+#  ifdef HAVE_BSWAP_16
56
+#      define bswap16(num) bswap_16(num)
57
+#  endif
58
+#  ifdef HAVE_BSWAP_32
59
+#      define bswap32(num) bswap_32(num)
60
+#  endif
61
+#  ifdef HAVE_BSWAP_64
62
+#      define bswap64(num) bswap_64(num)
63
+#  endif
64
+
65
+#elif defined(HAVE_SYS_ENDIAN_H)
66
+   // *BSDs and Darwin
67
+#  include <sys/endian.h>
68
+
69
+#elif defined(HAVE_SYS_BYTEORDER_H)
70
+   // Solaris
71
+#  include <sys/byteorder.h>
72
+#  ifdef BSWAP_16
73
+#      define bswap16(num) BSWAP_16(num)
74
+#  endif
75
+#  ifdef BSWAP_32
76
+#      define bswap32(num) BSWAP_32(num)
77
+#  endif
78
+#  ifdef BSWAP_64
79
+#      define bswap64(num) BSWAP_64(num)
80
+#  endif
81
+#  ifdef BE_16
82
+#      define conv16be(num) BE_16(num)
83
+#  endif
84
+#  ifdef BE_32
85
+#      define conv32be(num) BE_32(num)
86
+#  endif
87
+#  ifdef BE_64
88
+#      define conv64be(num) BE_64(num)
89
+#  endif
90
+#  ifdef LE_16
91
+#      define conv16le(num) LE_16(num)
92
+#  endif
93
+#  ifdef LE_32
94
+#      define conv32le(num) LE_32(num)
95
+#  endif
96
+#  ifdef LE_64
97
+#      define conv64le(num) LE_64(num)
98
+#  endif
99
+#endif
100
+
101
+
102
+///////////////////
103
+// Byte swapping //
104
+///////////////////
105
+
106
+#ifndef bswap16
107
+#  define bswap16(num) \
108
+       (((uint16_t)(num) << 8) | ((uint16_t)(num) >> 8))
109
+#endif
110
+
111
+#ifndef bswap32
112
+#  define bswap32(num) \
113
+       ( (((uint32_t)(num) << 24)                       ) \
114
+       | (((uint32_t)(num) <<  8) & UINT32_C(0x00FF0000)) \
115
+       | (((uint32_t)(num) >>  8) & UINT32_C(0x0000FF00)) \
116
+       | (((uint32_t)(num) >> 24)                       ) )
117
+#endif
118
+
119
+#ifndef bswap64
120
+#  define bswap64(num) \
121
+       ( (((uint64_t)(num) << 56)                               ) \
122
+       | (((uint64_t)(num) << 40) & UINT64_C(0x00FF000000000000)) \
123
+       | (((uint64_t)(num) << 24) & UINT64_C(0x0000FF0000000000)) \
124
+       | (((uint64_t)(num) <<  8) & UINT64_C(0x000000FF00000000)) \
125
+       | (((uint64_t)(num) >>  8) & UINT64_C(0x00000000FF000000)) \
126
+       | (((uint64_t)(num) >> 24) & UINT64_C(0x0000000000FF0000)) \
127
+       | (((uint64_t)(num) >> 40) & UINT64_C(0x000000000000FF00)) \
128
+       | (((uint64_t)(num) >> 56)                               ) )
129
+#endif
130
+
131
+// Define conversion macros using the basic byte swapping macros.
132
+#ifdef WORDS_BIGENDIAN
133
+#  ifndef conv16be
134
+#      define conv16be(num) ((uint16_t)(num))
135
+#  endif
136
+#  ifndef conv32be
137
+#      define conv32be(num) ((uint32_t)(num))
138
+#  endif
139
+#  ifndef conv64be
140
+#      define conv64be(num) ((uint64_t)(num))
141
+#  endif
142
+#  ifndef conv16le
143
+#      define conv16le(num) bswap16(num)
144
+#  endif
145
+#  ifndef conv32le
146
+#      define conv32le(num) bswap32(num)
147
+#  endif
148
+#  ifndef conv64le
149
+#      define conv64le(num) bswap64(num)
150
+#  endif
151
+#else
152
+#  ifndef conv16be
153
+#      define conv16be(num) bswap16(num)
154
+#  endif
155
+#  ifndef conv32be
156
+#      define conv32be(num) bswap32(num)
157
+#  endif
158
+#  ifndef conv64be
159
+#      define conv64be(num) bswap64(num)
160
+#  endif
161
+#  ifndef conv16le
162
+#      define conv16le(num) ((uint16_t)(num))
163
+#  endif
164
+#  ifndef conv32le
165
+#      define conv32le(num) ((uint32_t)(num))
166
+#  endif
167
+#  ifndef conv64le
168
+#      define conv64le(num) ((uint64_t)(num))
169
+#  endif
170
+#endif
171
+
172
+
173
+//////////////////////////////
174
+// Aligned reads and writes //
175
+//////////////////////////////
176
+
177
+static inline uint16_t
178
+read16be(const uint8_t *buf)
179
+{
180
+   uint16_t num = *(const uint16_t *)buf;
181
+   return conv16be(num);
182
+}
183
+
184
+
185
+static inline uint16_t
186
+read16le(const uint8_t *buf)
187
+{
188
+   uint16_t num = *(const uint16_t *)buf;
189
+   return conv16le(num);
190
+}
191
+
192
+
193
+static inline uint32_t
194
+read32be(const uint8_t *buf)
195
+{
196
+   uint32_t num = *(const uint32_t *)buf;
197
+   return conv32be(num);
198
+}
199
+
200
+
201
+static inline uint32_t
202
+read32le(const uint8_t *buf)
203
+{
204
+   uint32_t num = *(const uint32_t *)buf;
205
+   return conv32le(num);
206
+}
207
+
208
+
209
+static inline uint64_t
210
+read64be(const uint8_t *buf)
211
+{
212
+   uint64_t num = *(const uint64_t *)buf;
213
+   return conv64be(num);
214
+}
215
+
216
+
217
+static inline uint64_t
218
+read64le(const uint8_t *buf)
219
+{
220
+   uint64_t num = *(const uint64_t *)buf;
221
+   return conv64le(num);
222
+}
223
+
224
+
225
+// NOTE: Possible byte swapping must be done in a macro to allow GCC
226
+// to optimize byte swapping of constants when using glibc's or *BSD's
227
+// byte swapping macros. The actual write is done in an inline function
228
+// to make type checking of the buf pointer possible similarly to readXXYe()
229
+// functions.
230
+
231
+#define write16be(buf, num) write16ne((buf), conv16be(num))
232
+#define write16le(buf, num) write16ne((buf), conv16le(num))
233
+#define write32be(buf, num) write32ne((buf), conv32be(num))
234
+#define write32le(buf, num) write32ne((buf), conv32le(num))
235
+#define write64be(buf, num) write64ne((buf), conv64be(num))
236
+#define write64le(buf, num) write64ne((buf), conv64le(num))
237
+
238
+
239
+static inline void
240
+write16ne(uint8_t *buf, uint16_t num)
241
+{
242
+   *(uint16_t *)buf = num;
243
+   return;
244
+}
245
+
246
+
247
+static inline void
248
+write32ne(uint8_t *buf, uint32_t num)
249
+{
250
+   *(uint32_t *)buf = num;
251
+   return;
252
+}
253
+
254
+
255
+static inline void
256
+write64ne(uint8_t *buf, uint64_t num)
257
+{
258
+   *(uint64_t *)buf = num;
259
+   return;
260
+}
261
+
262
+
263
+////////////////////////////////
264
+// Unaligned reads and writes //
265
+////////////////////////////////
266
+
267
+// NOTE: TUKLIB_FAST_UNALIGNED_ACCESS indicates only support for 16-bit and
268
+// 32-bit unaligned integer loads and stores. It's possible that 64-bit
269
+// unaligned access doesn't work or is slower than byte-by-byte access.
270
+// Since unaligned 64-bit is probably not needed as often as 16-bit or
271
+// 32-bit, we simply don't support 64-bit unaligned access for now.
272
+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
273
+#  define unaligned_read16be read16be
274
+#  define unaligned_read16le read16le
275
+#  define unaligned_read32be read32be
276
+#  define unaligned_read32le read32le
277
+#  define unaligned_write16be write16be
278
+#  define unaligned_write16le write16le
279
+#  define unaligned_write32be write32be
280
+#  define unaligned_write32le write32le
281
+
282
+#else
283
+
284
+static inline uint16_t
285
+unaligned_read16be(const uint8_t *buf)
286
+{
287
+   uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1];
288
+   return num;
289
+}
290
+
291
+
292
+static inline uint16_t
293
+unaligned_read16le(const uint8_t *buf)
294
+{
295
+   uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8);
296
+   return num;
297
+}
298
+
299
+
300
+static inline uint32_t
301
+unaligned_read32be(const uint8_t *buf)
302
+{
303
+   uint32_t num = (uint32_t)buf[0] << 24;
304
+   num |= (uint32_t)buf[1] << 16;
305
+   num |= (uint32_t)buf[2] << 8;
306
+   num |= (uint32_t)buf[3];
307
+   return num;
308
+}
309
+
310
+
311
+static inline uint32_t
312
+unaligned_read32le(const uint8_t *buf)
313
+{
314
+   uint32_t num = (uint32_t)buf[0];
315
+   num |= (uint32_t)buf[1] << 8;
316
+   num |= (uint32_t)buf[2] << 16;
317
+   num |= (uint32_t)buf[3] << 24;
318
+   return num;
319
+}
320
+
321
+
322
+static inline void
323
+unaligned_write16be(uint8_t *buf, uint16_t num)
324
+{
325
+   buf[0] = num >> 8;
326
+   buf[1] = num;
327
+   return;
328
+}
329
+
330
+
331
+static inline void
332
+unaligned_write16le(uint8_t *buf, uint16_t num)
333
+{
334
+   buf[0] = num;
335
+   buf[1] = num >> 8;
336
+   return;
337
+}
338
+
339
+
340
+static inline void
341
+unaligned_write32be(uint8_t *buf, uint32_t num)
342
+{
343
+   buf[0] = num >> 24;
344
+   buf[1] = num >> 16;
345
+   buf[2] = num >> 8;
346
+   buf[3] = num;
347
+   return;
348
+}
349
+
350
+
351
+static inline void
352
+unaligned_write32le(uint8_t *buf, uint32_t num)
353
+{
354
+   buf[0] = num;
355
+   buf[1] = num >> 8;
356
+   buf[2] = num >> 16;
357
+   buf[3] = num >> 24;
358
+   return;
359
+}
360
+
361
+#endif
362
+
363
+
364
+static inline uint32_t
365
+bsr32(uint32_t n)
366
+{
367
+   // Check for ICC first, since it tends to define __GNUC__ too.
368
+#if defined(__INTEL_COMPILER)
369
+   return _bit_scan_reverse(n);
370
+
371
+#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX
372
+   // GCC >= 3.4 has __builtin_clz(), which gives good results on
373
+   // multiple architectures. On x86, __builtin_clz() ^ 31U becomes
374
+   // either plain BSR (so the XOR gets optimized away) or LZCNT and
375
+   // XOR (if -march indicates that SSE4a instructions are supported).
376
+   return __builtin_clz(n) ^ 31U;
377
+
378
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
379
+   uint32_t i;
380
+   __asm__("bsrl %1, %0" : "=r" (i) : "rm" (n));
381
+   return i;
382
+
383
+#elif defined(_MSC_VER) && _MSC_VER >= 1400
384
+   // MSVC isn't supported by tuklib, but since this code exists,
385
+   // it doesn't hurt to have it here anyway.
386
+   uint32_t i;
387
+   _BitScanReverse((DWORD *)&i, n);
388
+   return i;
389
+
390
+#else
391
+   uint32_t i = 31;
392
+
393
+   if ((n & UINT32_C(0xFFFF0000)) == 0) {
394
+       n <<= 16;
395
+       i = 15;
396
+   }
397
+
398
+   if ((n & UINT32_C(0xFF000000)) == 0) {
399
+       n <<= 8;
400
+       i -= 8;
401
+   }
402
+
403
+   if ((n & UINT32_C(0xF0000000)) == 0) {
404
+       n <<= 4;
405
+       i -= 4;
406
+   }
407
+
408
+   if ((n & UINT32_C(0xC0000000)) == 0) {
409
+       n <<= 2;
410
+       i -= 2;
411
+   }
412
+
413
+   if ((n & UINT32_C(0x80000000)) == 0)
414
+       --i;
415
+
416
+   return i;
417
+#endif
418
+}
419
+
420
+
421
+static inline uint32_t
422
+clz32(uint32_t n)
423
+{
424
+#if defined(__INTEL_COMPILER)
425
+   return _bit_scan_reverse(n) ^ 31U;
426
+
427
+#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX
428
+   return __builtin_clz(n);
429
+
430
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
431
+   uint32_t i;
432
+   __asm__("bsrl %1, %0\n\t"
433
+       "xorl $31, %0"
434
+       : "=r" (i) : "rm" (n));
435
+   return i;
436
+
437
+#elif defined(_MSC_VER) && _MSC_VER >= 1400
438
+   uint32_t i;
439
+   _BitScanReverse((DWORD *)&i, n);
440
+   return i ^ 31U;
441
+
442
+#else
443
+   uint32_t i = 0;
444
+
445
+   if ((n & UINT32_C(0xFFFF0000)) == 0) {
446
+       n <<= 16;
447
+       i = 16;
448
+   }
449
+
450
+   if ((n & UINT32_C(0xFF000000)) == 0) {
451
+       n <<= 8;
452
+       i += 8;
453
+   }
454
+
455
+   if ((n & UINT32_C(0xF0000000)) == 0) {
456
+       n <<= 4;
457
+       i += 4;
458
+   }
459
+
460
+   if ((n & UINT32_C(0xC0000000)) == 0) {
461
+       n <<= 2;
462
+       i += 2;
463
+   }
464
+
465
+   if ((n & UINT32_C(0x80000000)) == 0)
466
+       ++i;
467
+
468
+   return i;
469
+#endif
470
+}
471
+
472
+
473
+static inline uint32_t
474
+ctz32(uint32_t n)
475
+{
476
+#if defined(__INTEL_COMPILER)
477
+   return _bit_scan_forward(n);
478
+
479
+#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX >= UINT32_MAX
480
+   return __builtin_ctz(n);
481
+
482
+#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
483
+   uint32_t i;
484
+   __asm__("bsfl %1, %0" : "=r" (i) : "rm" (n));
485
+   return i;
486
+
487
+#elif defined(_MSC_VER) && _MSC_VER >= 1400
488
+   uint32_t i;
489
+   _BitScanForward((DWORD *)&i, n);
490
+   return i;
491
+
492
+#else
493
+   uint32_t i = 0;
494
+
495
+   if ((n & UINT32_C(0x0000FFFF)) == 0) {
496
+       n >>= 16;
497
+       i = 16;
498
+   }
499
+
500
+   if ((n & UINT32_C(0x000000FF)) == 0) {
501
+       n >>= 8;
502
+       i += 8;
503
+   }
504
+
505
+   if ((n & UINT32_C(0x0000000F)) == 0) {
506
+       n >>= 4;
507
+       i += 4;
508
+   }
509
+
510
+   if ((n & UINT32_C(0x00000003)) == 0) {
511
+       n >>= 2;
512
+       i += 2;
513
+   }
514
+
515
+   if ((n & UINT32_C(0x00000001)) == 0)
516
+       ++i;
517
+
518
+   return i;
519
+#endif
520
+}
521
+
522
+#define bsf32 ctz32
523
+
524
+#endif
525
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_mbstr.h Added
68
 
1
@@ -0,0 +1,66 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_mstr.h
5
+/// \brief      Utility functions for handling multibyte strings
6
+///
7
+/// If not enough multibyte string support is available in the C library,
8
+/// these functions keep working with the assumption that all strings
9
+/// are in a single-byte character set without combining characters, e.g.
10
+/// US-ASCII or ISO-8859-*.
11
+//
12
+//  Author:     Lasse Collin
13
+//
14
+//  This file has been put into the public domain.
15
+//  You can do whatever you want with this file.
16
+//
17
+///////////////////////////////////////////////////////////////////////////////
18
+
19
+#ifndef TUKLIB_MBSTR_H
20
+#define TUKLIB_MBSTR_H
21
+
22
+#include "tuklib_common.h"
23
+TUKLIB_DECLS_BEGIN
24
+
25
+#define tuklib_mbstr_width TUKLIB_SYMBOL(tuklib_mbstr_width)
26
+extern size_t tuklib_mbstr_width(const char *str, size_t *bytes);
27
+///<
28
+/// \brief      Get the number of columns needed for the multibyte string
29
+///
30
+/// This is somewhat similar to wcswidth() but works on multibyte strings.
31
+///
32
+/// \param      str         String whose width is to be calculated. If the
33
+///                         current locale uses a multibyte character set
34
+///                         that has shift states, the string must begin
35
+///                         and end in the initial shift state.
36
+/// \param      bytes       If this is not NULL, *bytes is set to the
37
+///                         value returned by strlen(str) (even if an
38
+///                         error occurs when calculating the width).
39
+///
40
+/// \return     On success, the number of columns needed to display the
41
+///             string e.g. in a terminal emulator is returned. On error,
42
+///             (size_t)-1 is returned. Possible errors include invalid,
43
+///             partial, or non-printable multibyte character in str, or
44
+///             that str doesn't end in the initial shift state.
45
+
46
+#define tuklib_mbstr_fw TUKLIB_SYMBOL(tuklib_mbstr_fw)
47
+extern int tuklib_mbstr_fw(const char *str, int columns_min);
48
+///<
49
+/// \brief      Get the field width for printf() e.g. to align table columns
50
+///
51
+/// Printing simple tables to a terminal can be done using the field field
52
+/// feature in the printf() format string, but it works only with single-byte
53
+/// character sets. To do the same with multibyte strings, tuklib_mbstr_fw()
54
+/// can be used to calculate appropriate field width.
55
+///
56
+/// The behavior of this function is undefined, if
57
+///   - str is NULL or not terminated with '\0';
58
+///   - columns_min <= 0; or
59
+///   - the calculated field width exceeds INT_MAX.
60
+///
61
+/// \return     If tuklib_mbstr_width(str, NULL) fails, -1 is returned.
62
+///             If str needs more columns than columns_min, zero is returned.
63
+///             Otherwise a positive integer is returned, which can be
64
+///             used as the field width, e.g. printf("%*s", fw, str).
65
+
66
+TUKLIB_DECLS_END
67
+#endif
68
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_mbstr_fw.c Added
33
 
1
@@ -0,0 +1,31 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_mstr_fw.c
5
+/// \brief      Get the field width for printf() e.g. to align table columns
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_mbstr.h"
15
+
16
+
17
+extern int
18
+tuklib_mbstr_fw(const char *str, int columns_min)
19
+{
20
+   size_t len;
21
+   const size_t width = tuklib_mbstr_width(str, &len);
22
+   if (width == (size_t)-1)
23
+       return -1;
24
+
25
+   if (width > (size_t)columns_min)
26
+       return 0;
27
+
28
+   if (width < (size_t)columns_min)
29
+       len += (size_t)columns_min - width;
30
+
31
+   return len;
32
+}
33
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_mbstr_width.c Added
66
 
1
@@ -0,0 +1,64 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_mstr_width.c
5
+/// \brief      Calculate width of a multibyte string
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_mbstr.h"
15
+
16
+#if defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
17
+#  include <wchar.h>
18
+#endif
19
+
20
+
21
+extern size_t
22
+tuklib_mbstr_width(const char *str, size_t *bytes)
23
+{
24
+   const size_t len = strlen(str);
25
+   if (bytes != NULL)
26
+       *bytes = len;
27
+
28
+#if !(defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH))
29
+   // In single-byte mode, the width of the string is the same
30
+   // as its length.
31
+   return len;
32
+
33
+#else
34
+   mbstate_t state;
35
+   memset(&state, 0, sizeof(state));
36
+
37
+   size_t width = 0;
38
+   size_t i = 0;
39
+
40
+   // Convert one multibyte character at a time to wchar_t
41
+   // and get its width using wcwidth().
42
+   while (i < len) {
43
+       wchar_t wc;
44
+       const size_t ret = mbrtowc(&wc, str + i, len - i, &state);
45
+       if (ret < 1 || ret > len)
46
+           return (size_t)-1;
47
+
48
+       i += ret;
49
+
50
+       const int wc_width = wcwidth(wc);
51
+       if (wc_width < 0)
52
+           return (size_t)-1;
53
+
54
+       width += wc_width;
55
+   }
56
+
57
+   // Require that the string ends in the initial shift state.
58
+   // This way the caller can be combine the string with other
59
+   // strings without needing to worry about the shift states.
60
+   if (!mbsinit(&state))
61
+       return (size_t)-1;
62
+
63
+   return width;
64
+#endif
65
+}
66
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_open_stdxxx.c Added
59
 
1
@@ -0,0 +1,57 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_open_stdxxx.c
5
+/// \brief      Make sure that file descriptors 0, 1, and 2 are open
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_open_stdxxx.h"
15
+
16
+#ifndef TUKLIB_DOSLIKE
17
+#  include <stdlib.h>
18
+#  include <errno.h>
19
+#  include <fcntl.h>
20
+#  include <unistd.h>
21
+#endif
22
+
23
+
24
+extern void
25
+tuklib_open_stdxxx(int err_status)
26
+{
27
+#ifdef TUKLIB_DOSLIKE
28
+   // Do nothing, just silence warnings.
29
+   (void)err_status;
30
+
31
+#else
32
+   for (int i = 0; i <= 2; ++i) {
33
+       // We use fcntl() to check if the file descriptor is open.
34
+       if (fcntl(i, F_GETFD) == -1 && errno == EBADF) {
35
+           // With stdin, we could use /dev/full so that
36
+           // writing to stdin would fail. However, /dev/full
37
+           // is Linux specific, and if the program tries to
38
+           // write to stdin, there's already a problem anyway.
39
+           const int fd = open("/dev/null", O_NOCTTY
40
+                   | (i == 0 ? O_WRONLY : O_RDONLY));
41
+
42
+           if (fd != i) {
43
+               if (fd != -1)
44
+                   (void)close(fd);
45
+
46
+               // Something went wrong. Exit with the
47
+               // exit status we were given. Don't try
48
+               // to print an error message, since stderr
49
+               // may very well be non-existent. This
50
+               // error should be extremely rare.
51
+               exit(err_status);
52
+           }
53
+       }
54
+   }
55
+#endif
56
+
57
+   return;
58
+}
59
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_open_stdxxx.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_open_stdxxx.h
5
+/// \brief      Make sure that file descriptors 0, 1, and 2 are open
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef TUKLIB_OPEN_STDXXX_H
15
+#define TUKLIB_OPEN_STDXXX_H
16
+
17
+#include "tuklib_common.h"
18
+TUKLIB_DECLS_BEGIN
19
+
20
+#define tuklib_open_stdxx TUKLIB_SYMBOL(tuklib_open_stdxxx)
21
+extern void tuklib_open_stdxxx(int err_status);
22
+
23
+TUKLIB_DECLS_END
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_physmem.c Added
198
 
1
@@ -0,0 +1,196 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_physmem.c
5
+/// \brief      Get the amount of physical memory
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_physmem.h"
15
+
16
+// We want to use Windows-specific code on Cygwin, which also has memory
17
+// information available via sysconf(), but on Cygwin 1.5 and older it
18
+// gives wrong results (from our point of view).
19
+#if defined(_WIN32) || defined(__CYGWIN__)
20
+#  ifndef _WIN32_WINNT
21
+#      define _WIN32_WINNT 0x0500
22
+#  endif
23
+#  include <windows.h>
24
+
25
+#elif defined(__OS2__)
26
+#  define INCL_DOSMISC
27
+#  include <os2.h>
28
+
29
+#elif defined(__DJGPP__)
30
+#  include <dpmi.h>
31
+
32
+#elif defined(__VMS)
33
+#  include <lib$routines.h>
34
+#  include <syidef.h>
35
+#  include <ssdef.h>
36
+
37
+// AIX
38
+#elif defined(TUKLIB_PHYSMEM_AIX)
39
+#  include <sys/systemcfg.h>
40
+
41
+#elif defined(TUKLIB_PHYSMEM_SYSCONF)
42
+#  include <unistd.h>
43
+
44
+#elif defined(TUKLIB_PHYSMEM_SYSCTL)
45
+#  ifdef HAVE_SYS_PARAM_H
46
+#      include <sys/param.h>
47
+#  endif
48
+#  include <sys/sysctl.h>
49
+
50
+// Tru64
51
+#elif defined(TUKLIB_PHYSMEM_GETSYSINFO)
52
+#  include <sys/sysinfo.h>
53
+#  include <machine/hal_sysinfo.h>
54
+
55
+// HP-UX
56
+#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)
57
+#  include <sys/param.h>
58
+#  include <sys/pstat.h>
59
+
60
+// IRIX
61
+#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)
62
+#  include <invent.h>
63
+
64
+// This sysinfo() is Linux-specific.
65
+#elif defined(TUKLIB_PHYSMEM_SYSINFO)
66
+#  include <sys/sysinfo.h>
67
+#endif
68
+
69
+
70
+extern uint64_t
71
+tuklib_physmem(void)
72
+{
73
+   uint64_t ret = 0;
74
+
75
+#if defined(_WIN32) || defined(__CYGWIN__)
76
+   if ((GetVersion() & 0xFF) >= 5) {
77
+       // Windows 2000 and later have GlobalMemoryStatusEx() which
78
+       // supports reporting values greater than 4 GiB. To keep the
79
+       // code working also on older Windows versions, use
80
+       // GlobalMemoryStatusEx() conditionally.
81
+       HMODULE kernel32 = GetModuleHandle("kernel32.dll");
82
+       if (kernel32 != NULL) {
83
+           BOOL (WINAPI *gmse)(LPMEMORYSTATUSEX) = GetProcAddress(
84
+                   kernel32, "GlobalMemoryStatusEx");
85
+           if (gmse != NULL) {
86
+               MEMORYSTATUSEX meminfo;
87
+               meminfo.dwLength = sizeof(meminfo);
88
+               if (gmse(&meminfo))
89
+                   ret = meminfo.ullTotalPhys;
90
+           }
91
+       }
92
+   }
93
+
94
+   if (ret == 0) {
95
+       // GlobalMemoryStatus() is supported by Windows 95 and later,
96
+       // so it is fine to link against it unconditionally. Note that
97
+       // GlobalMemoryStatus() has no return value.
98
+       MEMORYSTATUS meminfo;
99
+       meminfo.dwLength = sizeof(meminfo);
100
+       GlobalMemoryStatus(&meminfo);
101
+       ret = meminfo.dwTotalPhys;
102
+   }
103
+
104
+#elif defined(__OS2__)
105
+   unsigned long mem;
106
+   if (DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM,
107
+           &mem, sizeof(mem)) == 0)
108
+       ret = mem;
109
+
110
+#elif defined(__DJGPP__)
111
+   __dpmi_free_mem_info meminfo;
112
+   if (__dpmi_get_free_memory_information(&meminfo) == 0
113
+           && meminfo.total_number_of_physical_pages
114
+               != (unsigned long)-1)
115
+       ret = (uint64_t)meminfo.total_number_of_physical_pages * 4096;
116
+
117
+#elif defined(__VMS)
118
+   int vms_mem;
119
+   int val = SYI$_MEMSIZE;
120
+   if (LIB$GETSYI(&val, &vms_mem, 0, 0, 0, 0) == SS$_NORMAL)
121
+       ret = (uint64_t)vms_mem * 8192;
122
+
123
+#elif defined(TUKLIB_PHYSMEM_AIX)
124
+   ret = _system_configuration.physmem;
125
+
126
+#elif defined(TUKLIB_PHYSMEM_SYSCONF)
127
+   const long pagesize = sysconf(_SC_PAGESIZE);
128
+   const long pages = sysconf(_SC_PHYS_PAGES);
129
+   if (pagesize != -1 && pages != -1)
130
+       // According to docs, pagesize * pages can overflow.
131
+       // Simple case is 32-bit box with 4 GiB or more RAM,
132
+       // which may report exactly 4 GiB of RAM, and "long"
133
+       // being 32-bit will overflow. Casting to uint64_t
134
+       // hopefully avoids overflows in the near future.
135
+       ret = (uint64_t)pagesize * (uint64_t)pages;
136
+
137
+#elif defined(TUKLIB_PHYSMEM_SYSCTL)
138
+   int name[2] = {
139
+       CTL_HW,
140
+#ifdef HW_PHYSMEM64
141
+       HW_PHYSMEM64
142
+#else
143
+       HW_PHYSMEM
144
+#endif
145
+   };
146
+   union {
147
+       uint32_t u32;
148
+       uint64_t u64;
149
+   } mem;
150
+   size_t mem_ptr_size = sizeof(mem.u64);
151
+   if (sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, 0) != -1) {
152
+       // IIRC, 64-bit "return value" is possible on some 64-bit
153
+       // BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),
154
+       // so support both.
155
+       if (mem_ptr_size == sizeof(mem.u64))
156
+           ret = mem.u64;
157
+       else if (mem_ptr_size == sizeof(mem.u32))
158
+           ret = mem.u32;
159
+   }
160
+
161
+#elif defined(TUKLIB_PHYSMEM_GETSYSINFO)
162
+   // Docs are unclear if "start" is needed, but it doesn't hurt
163
+   // much to have it.
164
+   int memkb;
165
+   int start = 0;
166
+   if (getsysinfo(GSI_PHYSMEM, (caddr_t)&memkb, sizeof(memkb), &start)
167
+           != -1)
168
+       ret = (uint64_t)memkb * 1024;
169
+
170
+#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)
171
+   struct pst_static pst;
172
+   if (pstat_getstatic(&pst, sizeof(pst), 1, 0) != -1)
173
+       ret = (uint64_t)pst.physical_memory * (uint64_t)pst.page_size;
174
+
175
+#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)
176
+   inv_state_t *st = NULL;
177
+   if (setinvent_r(&st) != -1) {
178
+       inventory_t *i;
179
+       while ((i = getinvent_r(st)) != NULL) {
180
+           if (i->inv_class == INV_MEMORY
181
+                   && i->inv_type == INV_MAIN_MB) {
182
+               ret = (uint64_t)i->inv_state << 20;
183
+               break;
184
+           }
185
+       }
186
+
187
+       endinvent_r(st);
188
+   }
189
+
190
+#elif defined(TUKLIB_PHYSMEM_SYSINFO)
191
+   struct sysinfo si;
192
+   if (sysinfo(&si) == 0)
193
+       ret = (uint64_t)si.totalram * si.mem_unit;
194
+#endif
195
+
196
+   return ret;
197
+}
198
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_physmem.h Added
30
 
1
@@ -0,0 +1,28 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_physmem.h
5
+/// \brief      Get the amount of physical memory
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef TUKLIB_PHYSMEM_H
15
+#define TUKLIB_PHYSMEM_H
16
+
17
+#include "tuklib_common.h"
18
+TUKLIB_DECLS_BEGIN
19
+
20
+#define tuklib_physmem TUKLIB_SYMBOL(tuklib_physmem)
21
+extern uint64_t tuklib_physmem(void);
22
+///<
23
+/// \brief      Get the amount of physical memory in bytes
24
+///
25
+/// \return     Amount of physical memory in bytes. On error, zero is
26
+///             returned.
27
+
28
+TUKLIB_DECLS_END
29
+#endif
30
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_progname.c Added
52
 
1
@@ -0,0 +1,50 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_progname.c
5
+/// \brief      Program name to be displayed in messages
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "tuklib_progname.h"
15
+#include <string.h>
16
+
17
+
18
+#if !HAVE_DECL_PROGRAM_INVOCATION_NAME
19
+char *progname = NULL;
20
+#endif
21
+
22
+
23
+extern void
24
+tuklib_progname_init(char **argv)
25
+{
26
+#ifdef TUKLIB_DOSLIKE
27
+   // On these systems, argv[0] always has the full path and .exe
28
+   // suffix even if the user just types the plain program name.
29
+   // We modify argv[0] to make it nicer to read.
30
+
31
+   // Strip the leading path.
32
+   char *p = argv[0] + strlen(argv[0]);
33
+   while (argv[0] < p && p[-1] != '/' && p[-1] != '\\')
34
+       --p;
35
+
36
+   argv[0] = p;
37
+
38
+   // Strip the .exe suffix.
39
+   p = strrchr(p, '.');
40
+   if (p != NULL)
41
+       *p = '\0';
42
+
43
+   // Make it lowercase.
44
+   for (p = argv[0]; *p != '\0'; ++p)
45
+       if (*p >= 'A' && *p <= 'Z')
46
+           *p = *p - 'A' + 'a';
47
+#endif
48
+
49
+   progname = argv[0];
50
+   return;
51
+}
52
obs-studio-18.0.1.tar.xz/deps/lzma/common/tuklib_progname.h Added
34
 
1
@@ -0,0 +1,32 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       tuklib_progname.h
5
+/// \brief      Program name to be displayed in messages
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef TUKLIB_PROGNAME_H
15
+#define TUKLIB_PROGNAME_H
16
+
17
+#include "tuklib_common.h"
18
+#include <errno.h>
19
+
20
+TUKLIB_DECLS_BEGIN
21
+
22
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
23
+#  define progname program_invocation_name
24
+#else
25
+#  define progname TUKLIB_SYMBOL(tuklib_progname)
26
+   extern char *progname;
27
+#endif
28
+
29
+#define tuklib_progname_init TUKLIB_SYMBOL(tuklib_progname_init)
30
+extern void tuklib_progname_init(char **argv);
31
+
32
+TUKLIB_DECLS_END
33
+#endif
34
obs-studio-18.0.1.tar.xz/deps/lzma/config.h Added
418
 
1
@@ -0,0 +1,415 @@
2
+/* config.h.  Generated from config.h.in by configure.  */
3
+/* config.h.in.  Generated from configure.ac by autoheader.  */
4
+
5
+/* Define if building universal (internal helper macro) */
6
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
7
+
8
+/* How many MiB of RAM to assume if the real amount cannot be determined. */
9
+#define ASSUME_RAM 128
10
+
11
+/* Define to 1 if translation of program messages to the user's native
12
+language is requested. */
13
+/* #undef ENABLE_NLS */
14
+
15
+/* Define to 1 if bswap_16 is available. */
16
+/* #undef HAVE_BSWAP_16 */
17
+
18
+/* Define to 1 if bswap_32 is available. */
19
+/* #undef HAVE_BSWAP_32 */
20
+
21
+/* Define to 1 if bswap_64 is available. */
22
+/* #undef HAVE_BSWAP_64 */
23
+
24
+/* Define to 1 if you have the <byteswap.h> header file. */
25
+/* #undef HAVE_BYTESWAP_H */
26
+
27
+/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
28
+CoreFoundation framework. */
29
+/* #undef HAVE_CFLOCALECOPYCURRENT */
30
+
31
+/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
32
+the CoreFoundation framework. */
33
+/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
34
+
35
+/* Define to 1 if crc32 integrity check is enabled. */
36
+#define HAVE_CHECK_CRC32 1
37
+
38
+/* Define to 1 if crc64 integrity check is enabled. */
39
+#define HAVE_CHECK_CRC64 1
40
+
41
+/* Define to 1 if sha256 integrity check is enabled. */
42
+#define HAVE_CHECK_SHA256 1
43
+
44
+/* Define if the GNU dcgettext() function is already present or preinstalled.
45
+*/
46
+/* #undef HAVE_DCGETTEXT */
47
+
48
+/* Define to 1 if you have the declaration of `program_invocation_name', and
49
+to 0 if you don't. */
50
+#define HAVE_DECL_PROGRAM_INVOCATION_NAME 0
51
+
52
+/* Define to 1 if arm decoder is enabled. */
53
+#define HAVE_DECODER_ARM 1
54
+
55
+/* Define to 1 if armthumb decoder is enabled. */
56
+#define HAVE_DECODER_ARMTHUMB 1
57
+
58
+/* Define to 1 if delta decoder is enabled. */
59
+#define HAVE_DECODER_DELTA 1
60
+
61
+/* Define to 1 if ia64 decoder is enabled. */
62
+#define HAVE_DECODER_IA64 1
63
+
64
+/* Define to 1 if lzma1 decoder is enabled. */
65
+#define HAVE_DECODER_LZMA1 1
66
+
67
+/* Define to 1 if lzma2 decoder is enabled. */
68
+#define HAVE_DECODER_LZMA2 1
69
+
70
+/* Define to 1 if powerpc decoder is enabled. */
71
+#define HAVE_DECODER_POWERPC 1
72
+
73
+/* Define to 1 if sparc decoder is enabled. */
74
+#define HAVE_DECODER_SPARC 1
75
+
76
+/* Define to 1 if x86 decoder is enabled. */
77
+#define HAVE_DECODER_X86 1
78
+
79
+/* Define to 1 if you have the <dlfcn.h> header file. */
80
+/* #undef HAVE_DLFCN_H */
81
+
82
+/* Define to 1 if arm encoder is enabled. */
83
+#define HAVE_ENCODER_ARM 1
84
+
85
+/* Define to 1 if armthumb encoder is enabled. */
86
+#define HAVE_ENCODER_ARMTHUMB 1
87
+
88
+/* Define to 1 if delta encoder is enabled. */
89
+#define HAVE_ENCODER_DELTA 1
90
+
91
+/* Define to 1 if ia64 encoder is enabled. */
92
+#define HAVE_ENCODER_IA64 1
93
+
94
+/* Define to 1 if lzma1 encoder is enabled. */
95
+#define HAVE_ENCODER_LZMA1 1
96
+
97
+/* Define to 1 if lzma2 encoder is enabled. */
98
+#define HAVE_ENCODER_LZMA2 1
99
+
100
+/* Define to 1 if powerpc encoder is enabled. */
101
+#define HAVE_ENCODER_POWERPC 1
102
+
103
+/* Define to 1 if sparc encoder is enabled. */
104
+#define HAVE_ENCODER_SPARC 1
105
+
106
+/* Define to 1 if x86 encoder is enabled. */
107
+#define HAVE_ENCODER_X86 1
108
+
109
+/* Define to 1 if you have the <fcntl.h> header file. */
110
+#define HAVE_FCNTL_H 1
111
+
112
+/* Define to 1 if you have the `futimens' function. */
113
+/* #undef HAVE_FUTIMENS */
114
+
115
+/* Define to 1 if you have the `futimes' function. */
116
+/* #undef HAVE_FUTIMES */
117
+
118
+/* Define to 1 if you have the `futimesat' function. */
119
+/* #undef HAVE_FUTIMESAT */
120
+
121
+/* Define to 1 if you have the <getopt.h> header file. */
122
+/* #undef HAVE_GETOPT_H */
123
+
124
+/* Define to 1 if you have the `getopt_long' function. */
125
+/* #undef HAVE_GETOPT_LONG */
126
+
127
+/* Define if the GNU gettext() function is already present or preinstalled. */
128
+/* #undef HAVE_GETTEXT */
129
+
130
+/* Define if you have the iconv() function and it works. */
131
+#define HAVE_ICONV 1
132
+
133
+/* Define to 1 if you have the <inttypes.h> header file. */
134
+#define HAVE_INTTYPES_H 1
135
+
136
+/* Define to 1 if you have the <limits.h> header file. */
137
+#define HAVE_LIMITS_H 1
138
+
139
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
140
+#define HAVE_MBRTOWC 1
141
+
142
+/* Define to 1 if you have the <memory.h> header file. */
143
+#define HAVE_MEMORY_H 1
144
+
145
+/* Define to 1 to enable bt2 match finder. */
146
+#define HAVE_MF_BT2 1
147
+
148
+/* Define to 1 to enable bt3 match finder. */
149
+#define HAVE_MF_BT3 1
150
+
151
+/* Define to 1 to enable bt4 match finder. */
152
+#define HAVE_MF_BT4 1
153
+
154
+/* Define to 1 to enable hc3 match finder. */
155
+#define HAVE_MF_HC3 1
156
+
157
+/* Define to 1 to enable hc4 match finder. */
158
+#define HAVE_MF_HC4 1
159
+
160
+/* Define to 1 if getopt.h declares extern int optreset. */
161
+/* #undef HAVE_OPTRESET */
162
+
163
+/* Define if you have POSIX threads libraries and header files. */
164
+/* #undef HAVE_PTHREAD */
165
+
166
+/* Have PTHREAD_PRIO_INHERIT. */
167
+/* #undef HAVE_PTHREAD_PRIO_INHERIT */
168
+
169
+/* Define to 1 if optimizing for size. */
170
+/* #undef HAVE_SMALL */
171
+
172
+/* Define to 1 if stdbool.h conforms to C99. */
173
+#define HAVE_STDBOOL_H 1
174
+
175
+/* Define to 1 if you have the <stdint.h> header file. */
176
+#define HAVE_STDINT_H 1
177
+
178
+/* Define to 1 if you have the <stdlib.h> header file. */
179
+#define HAVE_STDLIB_H 1
180
+
181
+/* Define to 1 if you have the <strings.h> header file. */
182
+/* #undef HAVE_STRINGS_H */
183
+
184
+/* Define to 1 if you have the <string.h> header file. */
185
+#define HAVE_STRING_H 1
186
+
187
+/* Define to 1 if `st_atimensec' is a member of `struct stat'. */
188
+/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */
189
+
190
+/* Define to 1 if `st_atimespec.tv_nsec' is a member of `struct stat'. */
191
+/* #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC */
192
+
193
+/* Define to 1 if `st_atim.st__tim.tv_nsec' is a member of `struct stat'. */
194
+/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */
195
+
196
+/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */
197
+/* #undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC */
198
+
199
+/* Define to 1 if `st_uatime' is a member of `struct stat'. */
200
+/* #undef HAVE_STRUCT_STAT_ST_UATIME */
201
+
202
+/* Define to 1 if you have the <sys/byteorder.h> header file. */
203
+/* #undef HAVE_SYS_BYTEORDER_H */
204
+
205
+/* Define to 1 if you have the <sys/endian.h> header file. */
206
+/* #undef HAVE_SYS_ENDIAN_H */
207
+
208
+/* Define to 1 if you have the <sys/param.h> header file. */
209
+#define HAVE_SYS_PARAM_H 1
210
+
211
+/* Define to 1 if you have the <sys/stat.h> header file. */
212
+#define HAVE_SYS_STAT_H 1
213
+
214
+/* Define to 1 if you have the <sys/time.h> header file. */
215
+#define HAVE_SYS_TIME_H 1
216
+
217
+/* Define to 1 if you have the <sys/types.h> header file. */
218
+#define HAVE_SYS_TYPES_H 1
219
+
220
+/* Define to 1 if the system has the type `uintptr_t'. */
221
+#define HAVE_UINTPTR_T 1
222
+
223
+/* Define to 1 if you have the <unistd.h> header file. */
224
+#define HAVE_UNISTD_H 1
225
+
226
+/* Define to 1 if you have the `utime' function. */
227
+#define HAVE_UTIME 1
228
+
229
+/* Define to 1 if you have the `utimes' function. */
230
+/* #undef HAVE_UTIMES */
231
+
232
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
233
+declarations. */
234
+#define HAVE_VISIBILITY 1
235
+
236
+/* Define to 1 if you have the `wcwidth' function. */
237
+/* #undef HAVE_WCWIDTH */
238
+
239
+/* Define to 1 if the system has the type `_Bool'. */
240
+#define HAVE__BOOL 1
241
+
242
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
243
+*/
244
+#define LT_OBJDIR ".libs/"
245
+
246
+/* Name of package */
247
+#define PACKAGE "xz"
248
+
249
+/* Define to the address where bug reports for this package should be sent. */
250
+#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
251
+
252
+/* Define to the full name of this package. */
253
+#define PACKAGE_NAME "XZ Utils"
254
+
255
+/* Define to the one symbol short name of this package. */
256
+#define PACKAGE_TARNAME "xz"
257
+
258
+/* Define to the home page for this package. */
259
+#define PACKAGE_URL "http://tukaani.org/xz/"
260
+
261
+/* Define to necessary symbol if this constant uses a non-standard name on
262
+your system. */
263
+/* #undef PTHREAD_CREATE_JOINABLE */
264
+
265
+/* The size of `size_t', as computed by sizeof. */
266
+#define SIZEOF_SIZE_T 4
267
+
268
+/* Define to 1 if you have the ANSI C header files. */
269
+#define STDC_HEADERS 1
270
+
271
+/* Define to 1 if the number of available CPU cores can be detected with
272
+pstat_getdynamic(). */
273
+/* #undef TUKLIB_CPUCORES_PSTAT_GETDYNAMIC */
274
+
275
+/* Define to 1 if the number of available CPU cores can be detected with
276
+sysconf(_SC_NPROCESSORS_ONLN) or sysconf(_SC_NPROC_ONLN). */
277
+/* #undef TUKLIB_CPUCORES_SYSCONF */
278
+
279
+/* Define to 1 if the number of available CPU cores can be detected with
280
+sysctl(). */
281
+/* #undef TUKLIB_CPUCORES_SYSCTL */
282
+
283
+/* Define to 1 if the system supports fast unaligned access to 16-bit and
284
+32-bit integers. */
285
+#define TUKLIB_FAST_UNALIGNED_ACCESS 1
286
+
287
+/* Define to 1 if the amount of physical memory can be detected with
288
+_system_configuration.physmem. */
289
+/* #undef TUKLIB_PHYSMEM_AIX */
290
+
291
+/* Define to 1 if the amount of physical memory can be detected with
292
+getinvent_r(). */
293
+/* #undef TUKLIB_PHYSMEM_GETINVENT_R */
294
+
295
+/* Define to 1 if the amount of physical memory can be detected with
296
+getsysinfo(). */
297
+/* #undef TUKLIB_PHYSMEM_GETSYSINFO */
298
+
299
+/* Define to 1 if the amount of physical memory can be detected with
300
+pstat_getstatic(). */
301
+/* #undef TUKLIB_PHYSMEM_PSTAT_GETSTATIC */
302
+
303
+/* Define to 1 if the amount of physical memory can be detected with
304
+sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES). */
305
+/* #undef TUKLIB_PHYSMEM_SYSCONF */
306
+
307
+/* Define to 1 if the amount of physical memory can be detected with sysctl().
308
+*/
309
+/* #undef TUKLIB_PHYSMEM_SYSCTL */
310
+
311
+/* Define to 1 if the amount of physical memory can be detected with Linux
312
+sysinfo(). */
313
+/* #undef TUKLIB_PHYSMEM_SYSINFO */
314
+
315
+/* Enable extensions on AIX 3, Interix.  */
316
+#ifndef _ALL_SOURCE
317
+# define _ALL_SOURCE 1
318
+#endif
319
+/* Enable GNU extensions on systems that have them.  */
320
+#ifndef _GNU_SOURCE
321
+# define _GNU_SOURCE 1
322
+#endif
323
+/* Enable threading extensions on Solaris.  */
324
+#ifndef _POSIX_PTHREAD_SEMANTICS
325
+# define _POSIX_PTHREAD_SEMANTICS 1
326
+#endif
327
+/* Enable extensions on HP NonStop.  */
328
+#ifndef _TANDEM_SOURCE
329
+# define _TANDEM_SOURCE 1
330
+#endif
331
+/* Enable general extensions on Solaris.  */
332
+#ifndef __EXTENSIONS__
333
+# define __EXTENSIONS__ 1
334
+#endif
335
+
336
+#include "version.h"
337
+
338
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
339
+significant byte first (like Motorola and SPARC, unlike Intel). */
340
+#if defined AC_APPLE_UNIVERSAL_BUILD
341
+# if defined __BIG_ENDIAN__
342
+#  define WORDS_BIGENDIAN 1
343
+# endif
344
+#else
345
+# ifndef WORDS_BIGENDIAN
346
+/* #  undef WORDS_BIGENDIAN */
347
+# endif
348
+#endif
349
+
350
+/* Enable large inode numbers on Mac OS X 10.5.  */
351
+#ifndef _DARWIN_USE_64_BIT_INODE
352
+# define _DARWIN_USE_64_BIT_INODE 1
353
+#endif
354
+
355
+/* Number of bits in a file offset, on hosts where this is settable. */
356
+#define _FILE_OFFSET_BITS 64
357
+
358
+/* Define for large files, on AIX-style hosts. */
359
+/* #undef _LARGE_FILES */
360
+
361
+/* Define to 1 if on MINIX. */
362
+/* #undef _MINIX */
363
+
364
+/* Define to 2 if the system does not provide POSIX.1 features except with
365
+this defined. */
366
+/* #undef _POSIX_1_SOURCE */
367
+
368
+/* Define to 1 if you need to in order for `stat' and other things to work. */
369
+/* #undef _POSIX_SOURCE */
370
+
371
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
372
+<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
373
+#define below would cause a syntax error. */
374
+/* #undef _UINT32_T */
375
+
376
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
377
+<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
378
+#define below would cause a syntax error. */
379
+/* #undef _UINT64_T */
380
+
381
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
382
+<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
383
+#define below would cause a syntax error. */
384
+/* #undef _UINT8_T */
385
+
386
+/* Define to rpl_ if the getopt replacement functions and variables should be
387
+used. */
388
+/* #undef __GETOPT_PREFIX */
389
+
390
+/* Define to the type of a signed integer type of width exactly 32 bits if
391
+such a type exists and the standard includes do not define it. */
392
+/* #undef int32_t */
393
+
394
+/* Define to the type of a signed integer type of width exactly 64 bits if
395
+such a type exists and the standard includes do not define it. */
396
+/* #undef int64_t */
397
+
398
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
399
+such a type exists and the standard includes do not define it. */
400
+/* #undef uint16_t */
401
+
402
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
403
+such a type exists and the standard includes do not define it. */
404
+/* #undef uint32_t */
405
+
406
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
407
+such a type exists and the standard includes do not define it. */
408
+/* #undef uint64_t */
409
+
410
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
411
+such a type exists and the standard includes do not define it. */
412
+/* #undef uint8_t */
413
+
414
+/* Define to the type of an unsigned integer type wide enough to hold a
415
+pointer, if such a type exists, and if the system does not define it. */
416
+/* #undef uintptr_t */
417
\ No newline at end of file
418
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma.h Added
316
 
1
@@ -0,0 +1,314 @@
2
+/**
3
+ * \file        api/lzma.h
4
+ * \brief       The public API of liblzma data compression library
5
+ *
6
+ * liblzma is a public domain general-purpose data compression library with
7
+ * a zlib-like API. The native file format is .xz, but also the old .lzma
8
+ * format and raw (no headers) streams are supported. Multiple compression
9
+ * algorithms (filters) are supported. Currently LZMA2 is the primary filter.
10
+ *
11
+ * liblzma is part of XZ Utils <http://tukaani.org/xz/>. XZ Utils includes
12
+ * a gzip-like command line tool named xz and some other tools. XZ Utils
13
+ * is developed and maintained by Lasse Collin.
14
+ *
15
+ * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK
16
+ * <http://7-zip.org/sdk.html>.
17
+ *
18
+ * The SHA-256 implementation is based on the public domain code found from
19
+ * 7-Zip <http://7-zip.org/>, which has a modified version of the public
20
+ * domain SHA-256 code found from Crypto++ <http://www.cryptopp.com/>.
21
+ * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai.
22
+ */
23
+
24
+/*
25
+ * Author: Lasse Collin
26
+ *
27
+ * This file has been put into the public domain.
28
+ * You can do whatever you want with this file.
29
+ */
30
+
31
+#ifndef LZMA_H
32
+#define LZMA_H
33
+
34
+/*****************************
35
+ * Required standard headers *
36
+ *****************************/
37
+
38
+/*
39
+ * liblzma API headers need some standard types and macros. To allow
40
+ * including lzma.h without requiring the application to include other
41
+ * headers first, lzma.h includes the required standard headers unless
42
+ * they already seem to be included already or if LZMA_MANUAL_HEADERS
43
+ * has been defined.
44
+ *
45
+ * Here's what types and macros are needed and from which headers:
46
+ *  - stddef.h: size_t, NULL
47
+ *  - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n),
48
+ *    UINT32_MAX, UINT64_MAX
49
+ *
50
+ * However, inttypes.h is a little more portable than stdint.h, although
51
+ * inttypes.h declares some unneeded things compared to plain stdint.h.
52
+ *
53
+ * The hacks below aren't perfect, specifically they assume that inttypes.h
54
+ * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t,
55
+ * and that, in case of incomplete inttypes.h, unsigned int is 32-bit.
56
+ * If the application already takes care of setting up all the types and
57
+ * macros properly (for example by using gnulib's stdint.h or inttypes.h),
58
+ * we try to detect that the macros are already defined and don't include
59
+ * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to
60
+ * force this file to never include any system headers.
61
+ *
62
+ * Some could argue that liblzma API should provide all the required types,
63
+ * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was
64
+ * seen as an unnecessary mess, since most systems already provide all the
65
+ * necessary types and macros in the standard headers.
66
+ *
67
+ * Note that liblzma API still has lzma_bool, because using stdbool.h would
68
+ * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't
69
+ * necessarily the same as sizeof(bool) in C++.
70
+ */
71
+
72
+#ifndef LZMA_MANUAL_HEADERS
73
+   /*
74
+    * I suppose this works portably also in C++. Note that in C++,
75
+    * we need to get size_t into the global namespace.
76
+    */
77
+#  include <stddef.h>
78
+
79
+   /*
80
+    * Skip inttypes.h if we already have all the required macros. If we
81
+    * have the macros, we assume that we have the matching typedefs too.
82
+    */
83
+#  if !defined(UINT32_C) || !defined(UINT64_C) \
84
+           || !defined(UINT32_MAX) || !defined(UINT64_MAX)
85
+       /*
86
+        * MSVC has no C99 support, and thus it cannot be used to
87
+        * compile liblzma. The liblzma API has to still be usable
88
+        * from MSVC, so we need to define the required standard
89
+        * integer types here.
90
+        */
91
+#      if defined(_WIN32) && defined(_MSC_VER)
92
+           typedef unsigned __int8 uint8_t;
93
+           typedef unsigned __int32 uint32_t;
94
+           typedef unsigned __int64 uint64_t;
95
+#      else
96
+           /* Use the standard inttypes.h. */
97
+#          ifdef __cplusplus
98
+               /*
99
+                * C99 sections 7.18.2 and 7.18.4 specify
100
+                * that C++ implementations define the limit
101
+                * and constant macros only if specifically
102
+                * requested. Note that if you want the
103
+                * format macros (PRIu64 etc.) too, you need
104
+                * to define __STDC_FORMAT_MACROS before
105
+                * including lzma.h, since re-including
106
+                * inttypes.h with __STDC_FORMAT_MACROS
107
+                * defined doesn't necessarily work.
108
+                */
109
+#              ifndef __STDC_LIMIT_MACROS
110
+#                  define __STDC_LIMIT_MACROS 1
111
+#              endif
112
+#              ifndef __STDC_CONSTANT_MACROS
113
+#                  define __STDC_CONSTANT_MACROS 1
114
+#              endif
115
+#          endif
116
+
117
+#          include <inttypes.h>
118
+#      endif
119
+
120
+       /*
121
+        * Some old systems have only the typedefs in inttypes.h, and
122
+        * lack all the macros. For those systems, we need a few more
123
+        * hacks. We assume that unsigned int is 32-bit and unsigned
124
+        * long is either 32-bit or 64-bit. If these hacks aren't
125
+        * enough, the application has to setup the types manually
126
+        * before including lzma.h.
127
+        */
128
+#      ifndef UINT32_C
129
+#          if defined(_WIN32) && defined(_MSC_VER)
130
+#              define UINT32_C(n) n ## UI32
131
+#          else
132
+#              define UINT32_C(n) n ## U
133
+#          endif
134
+#      endif
135
+
136
+#      ifndef UINT64_C
137
+#          if defined(_WIN32) && defined(_MSC_VER)
138
+#              define UINT64_C(n) n ## UI64
139
+#          else
140
+               /* Get ULONG_MAX. */
141
+#              include <limits.h>
142
+#              if ULONG_MAX == 4294967295UL
143
+#                  define UINT64_C(n) n ## ULL
144
+#              else
145
+#                  define UINT64_C(n) n ## UL
146
+#              endif
147
+#          endif
148
+#      endif
149
+
150
+#      ifndef UINT32_MAX
151
+#          define UINT32_MAX (UINT32_C(4294967295))
152
+#      endif
153
+
154
+#      ifndef UINT64_MAX
155
+#          define UINT64_MAX (UINT64_C(18446744073709551615))
156
+#      endif
157
+#  endif
158
+#endif /* ifdef LZMA_MANUAL_HEADERS */
159
+
160
+
161
+/******************
162
+ * LZMA_API macro *
163
+ ******************/
164
+
165
+/*
166
+ * Some systems require that the functions and function pointers are
167
+ * declared specially in the headers. LZMA_API_IMPORT is for importing
168
+ * symbols and LZMA_API_CALL is to specify the calling convention.
169
+ *
170
+ * By default it is assumed that the application will link dynamically
171
+ * against liblzma. #define LZMA_API_STATIC in your application if you
172
+ * want to link against static liblzma. If you don't care about portability
173
+ * to operating systems like Windows, or at least don't care about linking
174
+ * against static liblzma on them, don't worry about LZMA_API_STATIC. That
175
+ * is, most developers will never need to use LZMA_API_STATIC.
176
+ *
177
+ * The GCC variants are a special case on Windows (Cygwin and MinGW).
178
+ * We rely on GCC doing the right thing with its auto-import feature,
179
+ * and thus don't use __declspec(dllimport). This way developers don't
180
+ * need to worry about LZMA_API_STATIC. Also the calling convention is
181
+ * omitted on Cygwin but not on MinGW.
182
+ */
183
+#ifndef LZMA_API_IMPORT
184
+#       define LZMA_API_STATIC
185
+#  if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__)
186
+#      define LZMA_API_IMPORT __declspec(dllimport)
187
+#  else
188
+#      define LZMA_API_IMPORT
189
+#  endif
190
+#endif
191
+
192
+#ifndef LZMA_API_CALL
193
+#  if defined(_WIN32) && !defined(__CYGWIN__)
194
+#      define LZMA_API_CALL __cdecl
195
+#  else
196
+#      define LZMA_API_CALL
197
+#  endif
198
+#endif
199
+
200
+#ifndef LZMA_API
201
+#  define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL
202
+#endif
203
+
204
+
205
+/***********
206
+ * nothrow *
207
+ ***********/
208
+
209
+/*
210
+ * None of the functions in liblzma may throw an exception. Even
211
+ * the functions that use callback functions won't throw exceptions,
212
+ * because liblzma would break if a callback function threw an exception.
213
+ */
214
+#ifndef lzma_nothrow
215
+#  if defined(__cplusplus)
216
+#      define lzma_nothrow throw()
217
+#  elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
218
+#      define lzma_nothrow __attribute__((__nothrow__))
219
+#  else
220
+#      define lzma_nothrow
221
+#  endif
222
+#endif
223
+
224
+
225
+/********************
226
+ * GNU C extensions *
227
+ ********************/
228
+
229
+/*
230
+ * GNU C extensions are used conditionally in the public API. It doesn't
231
+ * break anything if these are sometimes enabled and sometimes not, only
232
+ * affects warnings and optimizations.
233
+ */
234
+#if __GNUC__ >= 3
235
+#  ifndef lzma_attribute
236
+#      define lzma_attribute(attr) __attribute__(attr)
237
+#  endif
238
+
239
+   /* warn_unused_result was added in GCC 3.4. */
240
+#  ifndef lzma_attr_warn_unused_result
241
+#      if __GNUC__ == 3 && __GNUC_MINOR__ < 4
242
+#          define lzma_attr_warn_unused_result
243
+#      endif
244
+#  endif
245
+
246
+#else
247
+#  ifndef lzma_attribute
248
+#      define lzma_attribute(attr)
249
+#  endif
250
+#endif
251
+
252
+
253
+#ifndef lzma_attr_pure
254
+#  define lzma_attr_pure lzma_attribute((__pure__))
255
+#endif
256
+
257
+#ifndef lzma_attr_const
258
+#  define lzma_attr_const lzma_attribute((__const__))
259
+#endif
260
+
261
+#ifndef lzma_attr_warn_unused_result
262
+#  define lzma_attr_warn_unused_result \
263
+       lzma_attribute((__warn_unused_result__))
264
+#endif
265
+
266
+
267
+/**************
268
+ * Subheaders *
269
+ **************/
270
+
271
+#ifdef __cplusplus
272
+extern "C" {
273
+#endif
274
+
275
+/*
276
+ * Subheaders check that this is defined. It is to prevent including
277
+ * them directly from applications.
278
+ */
279
+#define LZMA_H_INTERNAL 1
280
+
281
+/* Basic features */
282
+#include "lzma/version.h"
283
+#include "lzma/base.h"
284
+#include "lzma/vli.h"
285
+#include "lzma/check.h"
286
+
287
+/* Filters */
288
+#include "lzma/filter.h"
289
+#include "lzma/bcj.h"
290
+#include "lzma/delta.h"
291
+#include "lzma/lzma.h"
292
+
293
+/* Container formats */
294
+#include "lzma/container.h"
295
+
296
+/* Advanced features */
297
+#include "lzma/stream_flags.h"
298
+#include "lzma/block.h"
299
+#include "lzma/index.h"
300
+#include "lzma/index_hash.h"
301
+
302
+/* Hardware information */
303
+#include "lzma/hardware.h"
304
+
305
+/*
306
+ * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
307
+ * re-including the subheaders.
308
+ */
309
+#undef LZMA_H_INTERNAL
310
+
311
+#ifdef __cplusplus
312
+}
313
+#endif
314
+
315
+#endif /* ifndef LZMA_H */
316
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/base.h Added
603
 
1
@@ -0,0 +1,601 @@
2
+/**
3
+ * \file        lzma/base.h
4
+ * \brief       Data types and functions used in many places in liblzma API
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Boolean
23
+ *
24
+ * This is here because C89 doesn't have stdbool.h. To set a value for
25
+ * variables having type lzma_bool, you can use
26
+ *   - C99's `true' and `false' from stdbool.h;
27
+ *   - C++'s internal `true' and `false'; or
28
+ *   - integers one (true) and zero (false).
29
+ */
30
+typedef unsigned char lzma_bool;
31
+
32
+
33
+/**
34
+ * \brief       Type of reserved enumeration variable in structures
35
+ *
36
+ * To avoid breaking library ABI when new features are added, several
37
+ * structures contain extra variables that may be used in future. Since
38
+ * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may
39
+ * even vary depending on the range of enumeration constants, we specify
40
+ * a separate type to be used for reserved enumeration variables. All
41
+ * enumeration constants in liblzma API will be non-negative and less
42
+ * than 128, which should guarantee that the ABI won't break even when
43
+ * new constants are added to existing enumerations.
44
+ */
45
+typedef enum {
46
+   LZMA_RESERVED_ENUM      = 0
47
+} lzma_reserved_enum;
48
+
49
+
50
+/**
51
+ * \brief       Return values used by several functions in liblzma
52
+ *
53
+ * Check the descriptions of specific functions to find out which return
54
+ * values they can return. With some functions the return values may have
55
+ * more specific meanings than described here; those differences are
56
+ * described per-function basis.
57
+ */
58
+typedef enum {
59
+   LZMA_OK                 = 0,
60
+       /**<
61
+        * \brief       Operation completed successfully
62
+        */
63
+
64
+   LZMA_STREAM_END         = 1,
65
+       /**<
66
+        * \brief       End of stream was reached
67
+        *
68
+        * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or
69
+        * LZMA_FINISH was finished. In decoder, this indicates
70
+        * that all the data was successfully decoded.
71
+        *
72
+        * In all cases, when LZMA_STREAM_END is returned, the last
73
+        * output bytes should be picked from strm->next_out.
74
+        */
75
+
76
+   LZMA_NO_CHECK           = 2,
77
+       /**<
78
+        * \brief       Input stream has no integrity check
79
+        *
80
+        * This return value can be returned only if the
81
+        * LZMA_TELL_NO_CHECK flag was used when initializing
82
+        * the decoder. LZMA_NO_CHECK is just a warning, and
83
+        * the decoding can be continued normally.
84
+        *
85
+        * It is possible to call lzma_get_check() immediately after
86
+        * lzma_code has returned LZMA_NO_CHECK. The result will
87
+        * naturally be LZMA_CHECK_NONE, but the possibility to call
88
+        * lzma_get_check() may be convenient in some applications.
89
+        */
90
+
91
+   LZMA_UNSUPPORTED_CHECK  = 3,
92
+       /**<
93
+        * \brief       Cannot calculate the integrity check
94
+        *
95
+        * The usage of this return value is different in encoders
96
+        * and decoders.
97
+        *
98
+        * Encoders can return this value only from the initialization
99
+        * function. If initialization fails with this value, the
100
+        * encoding cannot be done, because there's no way to produce
101
+        * output with the correct integrity check.
102
+        *
103
+        * Decoders can return this value only from lzma_code() and
104
+        * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when
105
+        * initializing the decoder. The decoding can still be
106
+        * continued normally even if the check type is unsupported,
107
+        * but naturally the check will not be validated, and possible
108
+        * errors may go undetected.
109
+        *
110
+        * With decoder, it is possible to call lzma_get_check()
111
+        * immediately after lzma_code() has returned
112
+        * LZMA_UNSUPPORTED_CHECK. This way it is possible to find
113
+        * out what the unsupported Check ID was.
114
+        */
115
+
116
+   LZMA_GET_CHECK          = 4,
117
+       /**<
118
+        * \brief       Integrity check type is now available
119
+        *
120
+        * This value can be returned only by the lzma_code() function
121
+        * and only if the decoder was initialized with the
122
+        * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the
123
+        * application that it may now call lzma_get_check() to find
124
+        * out the Check ID. This can be used, for example, to
125
+        * implement a decoder that accepts only files that have
126
+        * strong enough integrity check.
127
+        */
128
+
129
+   LZMA_MEM_ERROR          = 5,
130
+       /**<
131
+        * \brief       Cannot allocate memory
132
+        *
133
+        * Memory allocation failed, or the size of the allocation
134
+        * would be greater than SIZE_MAX.
135
+        *
136
+        * Due to internal implementation reasons, the coding cannot
137
+        * be continued even if more memory were made available after
138
+        * LZMA_MEM_ERROR.
139
+        */
140
+
141
+   LZMA_MEMLIMIT_ERROR     = 6,
142
+       /**
143
+        * \brief       Memory usage limit was reached
144
+        *
145
+        * Decoder would need more memory than allowed by the
146
+        * specified memory usage limit. To continue decoding,
147
+        * the memory usage limit has to be increased with
148
+        * lzma_memlimit_set().
149
+        */
150
+
151
+   LZMA_FORMAT_ERROR       = 7,
152
+       /**<
153
+        * \brief       File format not recognized
154
+        *
155
+        * The decoder did not recognize the input as supported file
156
+        * format. This error can occur, for example, when trying to
157
+        * decode .lzma format file with lzma_stream_decoder,
158
+        * because lzma_stream_decoder accepts only the .xz format.
159
+        */
160
+
161
+   LZMA_OPTIONS_ERROR      = 8,
162
+       /**<
163
+        * \brief       Invalid or unsupported options
164
+        *
165
+        * Invalid or unsupported options, for example
166
+        *  - unsupported filter(s) or filter options; or
167
+        *  - reserved bits set in headers (decoder only).
168
+        *
169
+        * Rebuilding liblzma with more features enabled, or
170
+        * upgrading to a newer version of liblzma may help.
171
+        */
172
+
173
+   LZMA_DATA_ERROR         = 9,
174
+       /**<
175
+        * \brief       Data is corrupt
176
+        *
177
+        * The usage of this return value is different in encoders
178
+        * and decoders. In both encoder and decoder, the coding
179
+        * cannot continue after this error.
180
+        *
181
+        * Encoders return this if size limits of the target file
182
+        * format would be exceeded. These limits are huge, thus
183
+        * getting this error from an encoder is mostly theoretical.
184
+        * For example, the maximum compressed and uncompressed
185
+        * size of a .xz Stream is roughly 8 EiB (2^63 bytes).
186
+        *
187
+        * Decoders return this error if the input data is corrupt.
188
+        * This can mean, for example, invalid CRC32 in headers
189
+        * or invalid check of uncompressed data.
190
+        */
191
+
192
+   LZMA_BUF_ERROR          = 10,
193
+       /**<
194
+        * \brief       No progress is possible
195
+        *
196
+        * This error code is returned when the coder cannot consume
197
+        * any new input and produce any new output. The most common
198
+        * reason for this error is that the input stream being
199
+        * decoded is truncated or corrupt.
200
+        *
201
+        * This error is not fatal. Coding can be continued normally
202
+        * by providing more input and/or more output space, if
203
+        * possible.
204
+        *
205
+        * Typically the first call to lzma_code() that can do no
206
+        * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only
207
+        * the second consecutive call doing no progress will return
208
+        * LZMA_BUF_ERROR. This is intentional.
209
+        *
210
+        * With zlib, Z_BUF_ERROR may be returned even if the
211
+        * application is doing nothing wrong, so apps will need
212
+        * to handle Z_BUF_ERROR specially. The above hack
213
+        * guarantees that liblzma never returns LZMA_BUF_ERROR
214
+        * to properly written applications unless the input file
215
+        * is truncated or corrupt. This should simplify the
216
+        * applications a little.
217
+        */
218
+
219
+   LZMA_PROG_ERROR         = 11,
220
+       /**<
221
+        * \brief       Programming error
222
+        *
223
+        * This indicates that the arguments given to the function are
224
+        * invalid or the internal state of the decoder is corrupt.
225
+        *   - Function arguments are invalid or the structures
226
+        *     pointed by the argument pointers are invalid
227
+        *     e.g. if strm->next_out has been set to NULL and
228
+        *     strm->avail_out > 0 when calling lzma_code().
229
+        *   - lzma_* functions have been called in wrong order
230
+        *     e.g. lzma_code() was called right after lzma_end().
231
+        *   - If errors occur randomly, the reason might be flaky
232
+        *     hardware.
233
+        *
234
+        * If you think that your code is correct, this error code
235
+        * can be a sign of a bug in liblzma. See the documentation
236
+        * how to report bugs.
237
+        */
238
+} lzma_ret;
239
+
240
+
241
+/**
242
+ * \brief       The `action' argument for lzma_code()
243
+ *
244
+ * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or LZMA_FINISH,
245
+ * the same `action' must is used until lzma_code() returns LZMA_STREAM_END.
246
+ * Also, the amount of input (that is, strm->avail_in) must not be modified
247
+ * by the application until lzma_code() returns LZMA_STREAM_END. Changing the
248
+ * `action' or modifying the amount of input will make lzma_code() return
249
+ * LZMA_PROG_ERROR.
250
+ */
251
+typedef enum {
252
+   LZMA_RUN = 0,
253
+       /**<
254
+        * \brief       Continue coding
255
+        *
256
+        * Encoder: Encode as much input as possible. Some internal
257
+        * buffering will probably be done (depends on the filter
258
+        * chain in use), which causes latency: the input used won't
259
+        * usually be decodeable from the output of the same
260
+        * lzma_code() call.
261
+        *
262
+        * Decoder: Decode as much input as possible and produce as
263
+        * much output as possible.
264
+        */
265
+
266
+   LZMA_SYNC_FLUSH = 1,
267
+       /**<
268
+        * \brief       Make all the input available at output
269
+        *
270
+        * Normally the encoder introduces some latency.
271
+        * LZMA_SYNC_FLUSH forces all the buffered data to be
272
+        * available at output without resetting the internal
273
+        * state of the encoder. This way it is possible to use
274
+        * compressed stream for example for communication over
275
+        * network.
276
+        *
277
+        * Only some filters support LZMA_SYNC_FLUSH. Trying to use
278
+        * LZMA_SYNC_FLUSH with filters that don't support it will
279
+        * make lzma_code() return LZMA_OPTIONS_ERROR. For example,
280
+        * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does.
281
+        *
282
+        * Using LZMA_SYNC_FLUSH very often can dramatically reduce
283
+        * the compression ratio. With some filters (for example,
284
+        * LZMA2), fine-tuning the compression options may help
285
+        * mitigate this problem significantly (for example,
286
+        * match finder with LZMA2).
287
+        *
288
+        * Decoders don't support LZMA_SYNC_FLUSH.
289
+        */
290
+
291
+   LZMA_FULL_FLUSH = 2,
292
+       /**<
293
+        * \brief       Finish encoding of the current Block
294
+        *
295
+        * All the input data going to the current Block must have
296
+        * been given to the encoder (the last bytes can still be
297
+        * pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH
298
+        * until it returns LZMA_STREAM_END. Then continue normally
299
+        * with LZMA_RUN or finish the Stream with LZMA_FINISH.
300
+        *
301
+        * This action is currently supported only by Stream encoder
302
+        * and easy encoder (which uses Stream encoder). If there is
303
+        * no unfinished Block, no empty Block is created.
304
+        */
305
+
306
+   LZMA_FINISH = 3
307
+       /**<
308
+        * \brief       Finish the coding operation
309
+        *
310
+        * All the input data must have been given to the encoder
311
+        * (the last bytes can still be pending in next_in).
312
+        * Call lzma_code() with LZMA_FINISH until it returns
313
+        * LZMA_STREAM_END. Once LZMA_FINISH has been used,
314
+        * the amount of input must no longer be changed by
315
+        * the application.
316
+        *
317
+        * When decoding, using LZMA_FINISH is optional unless the
318
+        * LZMA_CONCATENATED flag was used when the decoder was
319
+        * initialized. When LZMA_CONCATENATED was not used, the only
320
+        * effect of LZMA_FINISH is that the amount of input must not
321
+        * be changed just like in the encoder.
322
+        */
323
+} lzma_action;
324
+
325
+
326
+/**
327
+ * \brief       Custom functions for memory handling
328
+ *
329
+ * A pointer to lzma_allocator may be passed via lzma_stream structure
330
+ * to liblzma, and some advanced functions take a pointer to lzma_allocator
331
+ * as a separate function argument. The library will use the functions
332
+ * specified in lzma_allocator for memory handling instead of the default
333
+ * malloc() and free(). C++ users should note that the custom memory
334
+ * handling functions must not throw exceptions.
335
+ *
336
+ * liblzma doesn't make an internal copy of lzma_allocator. Thus, it is
337
+ * OK to change these function pointers in the middle of the coding
338
+ * process, but obviously it must be done carefully to make sure that the
339
+ * replacement `free' can deallocate memory allocated by the earlier
340
+ * `alloc' function(s).
341
+ */
342
+typedef struct {
343
+   /**
344
+    * \brief       Pointer to a custom memory allocation function
345
+    *
346
+    * If you don't want a custom allocator, but still want
347
+    * custom free(), set this to NULL and liblzma will use
348
+    * the standard malloc().
349
+    *
350
+    * \param       opaque  lzma_allocator.opaque (see below)
351
+    * \param       nmemb   Number of elements like in calloc(). liblzma
352
+    *                      will always set nmemb to 1, so it is safe to
353
+    *                      ignore nmemb in a custom allocator if you like.
354
+    *                      The nmemb argument exists only for
355
+    *                      compatibility with zlib and libbzip2.
356
+    * \param       size    Size of an element in bytes.
357
+    *                      liblzma never sets this to zero.
358
+    *
359
+    * \return      Pointer to the beginning of a memory block of
360
+    *              `size' bytes, or NULL if allocation fails
361
+    *              for some reason. When allocation fails, functions
362
+    *              of liblzma return LZMA_MEM_ERROR.
363
+    *
364
+    * The allocator should not waste time zeroing the allocated buffers.
365
+    * This is not only about speed, but also memory usage, since the
366
+    * operating system kernel doesn't necessarily allocate the requested
367
+    * memory in physical memory until it is actually used. With small
368
+    * input files, liblzma may actually need only a fraction of the
369
+    * memory that it requested for allocation.
370
+    *
371
+    * \note        LZMA_MEM_ERROR is also used when the size of the
372
+    *              allocation would be greater than SIZE_MAX. Thus,
373
+    *              don't assume that the custom allocator must have
374
+    *              returned NULL if some function from liblzma
375
+    *              returns LZMA_MEM_ERROR.
376
+    */
377
+   void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);
378
+
379
+   /**
380
+    * \brief       Pointer to a custom memory freeing function
381
+    *
382
+    * If you don't want a custom freeing function, but still
383
+    * want a custom allocator, set this to NULL and liblzma
384
+    * will use the standard free().
385
+    *
386
+    * \param       opaque  lzma_allocator.opaque (see below)
387
+    * \param       ptr     Pointer returned by lzma_allocator.alloc(),
388
+    *                      or when it is set to NULL, a pointer returned
389
+    *                      by the standard malloc().
390
+    */
391
+   void (LZMA_API_CALL *free)(void *opaque, void *ptr);
392
+
393
+   /**
394
+    * \brief       Pointer passed to .alloc() and .free()
395
+    *
396
+    * opaque is passed as the first argument to lzma_allocator.alloc()
397
+    * and lzma_allocator.free(). This intended to ease implementing
398
+    * custom memory allocation functions for use with liblzma.
399
+    *
400
+    * If you don't need this, you should set this to NULL.
401
+    */
402
+   void *opaque;
403
+
404
+} lzma_allocator;
405
+
406
+
407
+/**
408
+ * \brief       Internal data structure
409
+ *
410
+ * The contents of this structure is not visible outside the library.
411
+ */
412
+typedef struct lzma_internal_s lzma_internal;
413
+
414
+
415
+/**
416
+ * \brief       Passing data to and from liblzma
417
+ *
418
+ * The lzma_stream structure is used for
419
+ *  - passing pointers to input and output buffers to liblzma;
420
+ *  - defining custom memory hander functions; and
421
+ *  - holding a pointer to coder-specific internal data structures.
422
+ *
423
+ * Typical usage:
424
+ *
425
+ *  - After allocating lzma_stream (on stack or with malloc()), it must be
426
+ *    initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).
427
+ *
428
+ *  - Initialize a coder to the lzma_stream, for example by using
429
+ *    lzma_easy_encoder() or lzma_auto_decoder(). Some notes:
430
+ *      - In contrast to zlib, strm->next_in and strm->next_out are
431
+ *        ignored by all initialization functions, thus it is safe
432
+ *        to not initialize them yet.
433
+ *      - The initialization functions always set strm->total_in and
434
+ *        strm->total_out to zero.
435
+ *      - If the initialization function fails, no memory is left allocated
436
+ *        that would require freeing with lzma_end() even if some memory was
437
+ *        associated with the lzma_stream structure when the initialization
438
+ *        function was called.
439
+ *
440
+ *  - Use lzma_code() to do the actual work.
441
+ *
442
+ *  - Once the coding has been finished, the existing lzma_stream can be
443
+ *    reused. It is OK to reuse lzma_stream with different initialization
444
+ *    function without calling lzma_end() first. Old allocations are
445
+ *    automatically freed.
446
+ *
447
+ *  - Finally, use lzma_end() to free the allocated memory. lzma_end() never
448
+ *    frees the lzma_stream structure itself.
449
+ *
450
+ * Application may modify the values of total_in and total_out as it wants.
451
+ * They are updated by liblzma to match the amount of data read and
452
+ * written, but aren't used for anything else.
453
+ */
454
+typedef struct {
455
+   const uint8_t *next_in; /**< Pointer to the next input byte. */
456
+   size_t avail_in;    /**< Number of available input bytes in next_in. */
457
+   uint64_t total_in;  /**< Total number of bytes read by liblzma. */
458
+
459
+   uint8_t *next_out;  /**< Pointer to the next output position. */
460
+   size_t avail_out;   /**< Amount of free space in next_out. */
461
+   uint64_t total_out; /**< Total number of bytes written by liblzma. */
462
+
463
+   /**
464
+    * \brief       Custom memory allocation functions
465
+    *
466
+    * In most cases this is NULL which makes liblzma use
467
+    * the standard malloc() and free().
468
+    */
469
+   lzma_allocator *allocator;
470
+
471
+   /** Internal state is not visible to applications. */
472
+   lzma_internal *internal;
473
+
474
+   /*
475
+    * Reserved space to allow possible future extensions without
476
+    * breaking the ABI. Excluding the initialization of this structure,
477
+    * you should not touch these, because the names of these variables
478
+    * may change.
479
+    */
480
+   void *reserved_ptr1;
481
+   void *reserved_ptr2;
482
+   void *reserved_ptr3;
483
+   void *reserved_ptr4;
484
+   uint64_t reserved_int1;
485
+   uint64_t reserved_int2;
486
+   size_t reserved_int3;
487
+   size_t reserved_int4;
488
+   lzma_reserved_enum reserved_enum1;
489
+   lzma_reserved_enum reserved_enum2;
490
+
491
+} lzma_stream;
492
+
493
+
494
+/**
495
+ * \brief       Initialization for lzma_stream
496
+ *
497
+ * When you declare an instance of lzma_stream, you can immediately
498
+ * initialize it so that initialization functions know that no memory
499
+ * has been allocated yet:
500
+ *
501
+ *     lzma_stream strm = LZMA_STREAM_INIT;
502
+ *
503
+ * If you need to initialize a dynamically allocated lzma_stream, you can use
504
+ * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this
505
+ * violates the C standard since NULL may have different internal
506
+ * representation than zero, but it should be portable enough in practice.
507
+ * Anyway, for maximum portability, you can use something like this:
508
+ *
509
+ *     lzma_stream tmp = LZMA_STREAM_INIT;
510
+ *     *strm = tmp;
511
+ */
512
+#define LZMA_STREAM_INIT \
513
+   { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
514
+   NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
515
+   LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
516
+
517
+
518
+/**
519
+ * \brief       Encode or decode data
520
+ *
521
+ * Once the lzma_stream has been successfully initialized (e.g. with
522
+ * lzma_stream_encoder()), the actual encoding or decoding is done
523
+ * using this function. The application has to update strm->next_in,
524
+ * strm->avail_in, strm->next_out, and strm->avail_out to pass input
525
+ * to and get output from liblzma.
526
+ *
527
+ * See the description of the coder-specific initialization function to find
528
+ * out what `action' values are supported by the coder.
529
+ */
530
+extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action)
531
+       lzma_nothrow lzma_attr_warn_unused_result;
532
+
533
+
534
+/**
535
+ * \brief       Free memory allocated for the coder data structures
536
+ *
537
+ * \param       strm    Pointer to lzma_stream that is at least initialized
538
+ *                      with LZMA_STREAM_INIT.
539
+ *
540
+ * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other
541
+ * members of the lzma_stream structure are touched.
542
+ *
543
+ * \note        zlib indicates an error if application end()s unfinished
544
+ *              stream structure. liblzma doesn't do this, and assumes that
545
+ *              application knows what it is doing.
546
+ */
547
+extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;
548
+
549
+
550
+/**
551
+ * \brief       Get the memory usage of decoder filter chain
552
+ *
553
+ * This function is currently supported only when *strm has been initialized
554
+ * with a function that takes a memlimit argument. With other functions, you
555
+ * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage()
556
+ * to estimate the memory requirements.
557
+ *
558
+ * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big
559
+ * the memory usage limit should have been to decode the input. Note that
560
+ * this may give misleading information if decoding .xz Streams that have
561
+ * multiple Blocks, because each Block can have different memory requirements.
562
+ *
563
+ * \return      How much memory is currently allocated for the filter
564
+ *              decoders. If no filter chain is currently allocated,
565
+ *              some non-zero value is still returned, which is less than
566
+ *              or equal to what any filter chain would indicate as its
567
+ *              memory requirement.
568
+ *
569
+ *              If this function isn't supported by *strm or some other error
570
+ *              occurs, zero is returned.
571
+ */
572
+extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm)
573
+       lzma_nothrow lzma_attr_pure;
574
+
575
+
576
+/**
577
+ * \brief       Get the current memory usage limit
578
+ *
579
+ * This function is supported only when *strm has been initialized with
580
+ * a function that takes a memlimit argument.
581
+ *
582
+ * \return      On success, the current memory usage limit is returned
583
+ *              (always non-zero). On error, zero is returned.
584
+ */
585
+extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
586
+       lzma_nothrow lzma_attr_pure;
587
+
588
+
589
+/**
590
+ * \brief       Set the memory usage limit
591
+ *
592
+ * This function is supported only when *strm has been initialized with
593
+ * a function that takes a memlimit argument.
594
+ *
595
+ * \return      - LZMA_OK: New memory usage limit successfully set.
596
+ *              - LZMA_MEMLIMIT_ERROR: The new limit is too small.
597
+ *                The limit was not changed.
598
+ *              - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
599
+ *                support memory usage limit or memlimit was zero.
600
+ */
601
+extern LZMA_API(lzma_ret) lzma_memlimit_set(
602
+       lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
603
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/bcj.h Added
92
 
1
@@ -0,0 +1,90 @@
2
+/**
3
+ * \file        lzma/bcj.h
4
+ * \brief       Branch/Call/Jump conversion filters
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/* Filter IDs for lzma_filter.id */
22
+
23
+#define LZMA_FILTER_X86         LZMA_VLI_C(0x04)
24
+   /**<
25
+    * Filter for x86 binaries
26
+    */
27
+
28
+#define LZMA_FILTER_POWERPC     LZMA_VLI_C(0x05)
29
+   /**<
30
+    * Filter for Big endian PowerPC binaries
31
+    */
32
+
33
+#define LZMA_FILTER_IA64        LZMA_VLI_C(0x06)
34
+   /**<
35
+    * Filter for IA-64 (Itanium) binaries.
36
+    */
37
+
38
+#define LZMA_FILTER_ARM         LZMA_VLI_C(0x07)
39
+   /**<
40
+    * Filter for ARM binaries.
41
+    */
42
+
43
+#define LZMA_FILTER_ARMTHUMB    LZMA_VLI_C(0x08)
44
+   /**<
45
+    * Filter for ARM-Thumb binaries.
46
+    */
47
+
48
+#define LZMA_FILTER_SPARC       LZMA_VLI_C(0x09)
49
+   /**<
50
+    * Filter for SPARC binaries.
51
+    */
52
+
53
+
54
+/**
55
+ * \brief       Options for BCJ filters
56
+ *
57
+ * The BCJ filters never change the size of the data. Specifying options
58
+ * for them is optional: if pointer to options is NULL, default value is
59
+ * used. You probably never need to specify options to BCJ filters, so just
60
+ * set the options pointer to NULL and be happy.
61
+ *
62
+ * If options with non-default values have been specified when encoding,
63
+ * the same options must also be specified when decoding.
64
+ *
65
+ * \note        At the moment, none of the BCJ filters support
66
+ *              LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
67
+ *              LZMA_OPTIONS_ERROR will be returned. If there is need,
68
+ *              partial support for LZMA_SYNC_FLUSH can be added in future.
69
+ *              Partial means that flushing would be possible only at
70
+ *              offsets that are multiple of 2, 4, or 16 depending on
71
+ *              the filter, except x86 which cannot be made to support
72
+ *              LZMA_SYNC_FLUSH predictably.
73
+ */
74
+typedef struct {
75
+   /**
76
+    * \brief       Start offset for conversions
77
+    *
78
+    * This setting is useful only when the same filter is used
79
+    * _separately_ for multiple sections of the same executable file,
80
+    * and the sections contain cross-section branch/call/jump
81
+    * instructions. In that case it is beneficial to set the start
82
+    * offset of the non-first sections so that the relative addresses
83
+    * of the cross-section branch/call/jump instructions will use the
84
+    * same absolute addresses as in the first section.
85
+    *
86
+    * When the pointer to options is NULL, the default value (zero)
87
+    * is used.
88
+    */
89
+   uint32_t start_offset;
90
+
91
+} lzma_options_bcj;
92
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/block.h Added
535
 
1
@@ -0,0 +1,533 @@
2
+/**
3
+ * \file        lzma/block.h
4
+ * \brief       .xz Block handling
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Options for the Block and Block Header encoders and decoders
23
+ *
24
+ * Different Block handling functions use different parts of this structure.
25
+ * Some read some members, other functions write, and some do both. Only the
26
+ * members listed for reading need to be initialized when the specified
27
+ * functions are called. The members marked for writing will be assigned
28
+ * new values at some point either by calling the given function or by
29
+ * later calls to lzma_code().
30
+ */
31
+typedef struct {
32
+   /**
33
+    * \brief       Block format version
34
+    *
35
+    * To prevent API and ABI breakages if new features are needed in
36
+    * the Block field, a version number is used to indicate which
37
+    * fields in this structure are in use. For now, version must always
38
+    * be zero. With non-zero version, most Block related functions will
39
+    * return LZMA_OPTIONS_ERROR.
40
+    *
41
+    * Read by:
42
+    *  - All functions that take pointer to lzma_block as argument,
43
+    *    including lzma_block_header_decode().
44
+    *
45
+    * Written by:
46
+    *  - lzma_block_header_decode()
47
+    */
48
+   uint32_t version;
49
+
50
+   /**
51
+    * \brief       Size of the Block Header field
52
+    *
53
+    * This is always a multiple of four.
54
+    *
55
+    * Read by:
56
+    *  - lzma_block_header_encode()
57
+    *  - lzma_block_header_decode()
58
+    *  - lzma_block_compressed_size()
59
+    *  - lzma_block_unpadded_size()
60
+    *  - lzma_block_total_size()
61
+    *  - lzma_block_decoder()
62
+    *  - lzma_block_buffer_decode()
63
+    *
64
+    * Written by:
65
+    *  - lzma_block_header_size()
66
+    *  - lzma_block_buffer_encode()
67
+    */
68
+   uint32_t header_size;
69
+#  define LZMA_BLOCK_HEADER_SIZE_MIN 8
70
+#  define LZMA_BLOCK_HEADER_SIZE_MAX 1024
71
+
72
+   /**
73
+    * \brief       Type of integrity Check
74
+    *
75
+    * The Check ID is not stored into the Block Header, thus its value
76
+    * must be provided also when decoding.
77
+    *
78
+    * Read by:
79
+    *  - lzma_block_header_encode()
80
+    *  - lzma_block_header_decode()
81
+    *  - lzma_block_compressed_size()
82
+    *  - lzma_block_unpadded_size()
83
+    *  - lzma_block_total_size()
84
+    *  - lzma_block_encoder()
85
+    *  - lzma_block_decoder()
86
+    *  - lzma_block_buffer_encode()
87
+    *  - lzma_block_buffer_decode()
88
+    */
89
+   lzma_check check;
90
+
91
+   /**
92
+    * \brief       Size of the Compressed Data in bytes
93
+    *
94
+    * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder
95
+    * will store this value to the Block Header. Block encoder doesn't
96
+    * care about this value, but will set it once the encoding has been
97
+    * finished.
98
+    *
99
+    * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will
100
+    * verify that the size of the Compressed Data field matches
101
+    * compressed_size.
102
+    *
103
+    * Usually you don't know this value when encoding in streamed mode,
104
+    * and thus cannot write this field into the Block Header.
105
+    *
106
+    * In non-streamed mode you can reserve space for this field before
107
+    * encoding the actual Block. After encoding the data, finish the
108
+    * Block by encoding the Block Header. Steps in detail:
109
+    *
110
+    *  - Set compressed_size to some big enough value. If you don't know
111
+    *    better, use LZMA_VLI_MAX, but remember that bigger values take
112
+    *    more space in Block Header.
113
+    *
114
+    *  - Call lzma_block_header_size() to see how much space you need to
115
+    *    reserve for the Block Header.
116
+    *
117
+    *  - Encode the Block using lzma_block_encoder() and lzma_code().
118
+    *    It sets compressed_size to the correct value.
119
+    *
120
+    *  - Use lzma_block_header_encode() to encode the Block Header.
121
+    *    Because space was reserved in the first step, you don't need
122
+    *    to call lzma_block_header_size() anymore, because due to
123
+    *    reserving, header_size has to be big enough. If it is "too big",
124
+    *    lzma_block_header_encode() will add enough Header Padding to
125
+    *    make Block Header to match the size specified by header_size.
126
+    *
127
+    * Read by:
128
+    *  - lzma_block_header_size()
129
+    *  - lzma_block_header_encode()
130
+    *  - lzma_block_compressed_size()
131
+    *  - lzma_block_unpadded_size()
132
+    *  - lzma_block_total_size()
133
+    *  - lzma_block_decoder()
134
+    *  - lzma_block_buffer_decode()
135
+    *
136
+    * Written by:
137
+    *  - lzma_block_header_decode()
138
+    *  - lzma_block_compressed_size()
139
+    *  - lzma_block_encoder()
140
+    *  - lzma_block_decoder()
141
+    *  - lzma_block_buffer_encode()
142
+    *  - lzma_block_buffer_decode()
143
+    */
144
+   lzma_vli compressed_size;
145
+
146
+   /**
147
+    * \brief       Uncompressed Size in bytes
148
+    *
149
+    * This is handled very similarly to compressed_size above.
150
+    *
151
+    * uncompressed_size is needed by fewer functions than
152
+    * compressed_size. This is because uncompressed_size isn't
153
+    * needed to validate that Block stays within proper limits.
154
+    *
155
+    * Read by:
156
+    *  - lzma_block_header_size()
157
+    *  - lzma_block_header_encode()
158
+    *  - lzma_block_decoder()
159
+    *  - lzma_block_buffer_decode()
160
+    *
161
+    * Written by:
162
+    *  - lzma_block_header_decode()
163
+    *  - lzma_block_encoder()
164
+    *  - lzma_block_decoder()
165
+    *  - lzma_block_buffer_encode()
166
+    *  - lzma_block_buffer_decode()
167
+    */
168
+   lzma_vli uncompressed_size;
169
+
170
+   /**
171
+    * \brief       Array of filters
172
+    *
173
+    * There can be 1-4 filters. The end of the array is marked with
174
+    * .id = LZMA_VLI_UNKNOWN.
175
+    *
176
+    * Read by:
177
+    *  - lzma_block_header_size()
178
+    *  - lzma_block_header_encode()
179
+    *  - lzma_block_encoder()
180
+    *  - lzma_block_decoder()
181
+    *  - lzma_block_buffer_encode()
182
+    *  - lzma_block_buffer_decode()
183
+    *
184
+    * Written by:
185
+    *  - lzma_block_header_decode(): Note that this does NOT free()
186
+    *    the old filter options structures. All unused filters[] will
187
+    *    have .id == LZMA_VLI_UNKNOWN and .options == NULL. If
188
+    *    decoding fails, all filters[] are guaranteed to be
189
+    *    LZMA_VLI_UNKNOWN and NULL.
190
+    *
191
+    * \note        Because of the array is terminated with
192
+    *              .id = LZMA_VLI_UNKNOWN, the actual array must
193
+    *              have LZMA_FILTERS_MAX + 1 members or the Block
194
+    *              Header decoder will overflow the buffer.
195
+    */
196
+   lzma_filter *filters;
197
+
198
+   /**
199
+    * \brief       Raw value stored in the Check field
200
+    *
201
+    * After successful coding, the first lzma_check_size(check) bytes
202
+    * of this array contain the raw value stored in the Check field.
203
+    *
204
+    * Note that CRC32 and CRC64 are stored in little endian byte order.
205
+    * Take it into account if you display the Check values to the user.
206
+    *
207
+    * Written by:
208
+    *  - lzma_block_encoder()
209
+    *  - lzma_block_decoder()
210
+    *  - lzma_block_buffer_encode()
211
+    *  - lzma_block_buffer_decode()
212
+    */
213
+   uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
214
+
215
+   /*
216
+    * Reserved space to allow possible future extensions without
217
+    * breaking the ABI. You should not touch these, because the names
218
+    * of these variables may change. These are and will never be used
219
+    * with the currently supported options, so it is safe to leave these
220
+    * uninitialized.
221
+    */
222
+   void *reserved_ptr1;
223
+   void *reserved_ptr2;
224
+   void *reserved_ptr3;
225
+   uint32_t reserved_int1;
226
+   uint32_t reserved_int2;
227
+   lzma_vli reserved_int3;
228
+   lzma_vli reserved_int4;
229
+   lzma_vli reserved_int5;
230
+   lzma_vli reserved_int6;
231
+   lzma_vli reserved_int7;
232
+   lzma_vli reserved_int8;
233
+   lzma_reserved_enum reserved_enum1;
234
+   lzma_reserved_enum reserved_enum2;
235
+   lzma_reserved_enum reserved_enum3;
236
+   lzma_reserved_enum reserved_enum4;
237
+   lzma_bool reserved_bool1;
238
+   lzma_bool reserved_bool2;
239
+   lzma_bool reserved_bool3;
240
+   lzma_bool reserved_bool4;
241
+   lzma_bool reserved_bool5;
242
+   lzma_bool reserved_bool6;
243
+   lzma_bool reserved_bool7;
244
+   lzma_bool reserved_bool8;
245
+
246
+} lzma_block;
247
+
248
+
249
+/**
250
+ * \brief       Decode the Block Header Size field
251
+ *
252
+ * To decode Block Header using lzma_block_header_decode(), the size of the
253
+ * Block Header has to be known and stored into lzma_block.header_size.
254
+ * The size can be calculated from the first byte of a Block using this macro.
255
+ * Note that if the first byte is 0x00, it indicates beginning of Index; use
256
+ * this macro only when the byte is not 0x00.
257
+ *
258
+ * There is no encoding macro, because Block Header encoder is enough for that.
259
+ */
260
+#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
261
+
262
+
263
+/**
264
+ * \brief       Calculate Block Header Size
265
+ *
266
+ * Calculate the minimum size needed for the Block Header field using the
267
+ * settings specified in the lzma_block structure. Note that it is OK to
268
+ * increase the calculated header_size value as long as it is a multiple of
269
+ * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size
270
+ * just means that lzma_block_header_encode() will add Header Padding.
271
+ *
272
+ * \return      - LZMA_OK: Size calculated successfully and stored to
273
+ *                block->header_size.
274
+ *              - LZMA_OPTIONS_ERROR: Unsupported version, filters or
275
+ *                filter options.
276
+ *              - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.
277
+ *
278
+ * \note        This doesn't check that all the options are valid i.e. this
279
+ *              may return LZMA_OK even if lzma_block_header_encode() or
280
+ *              lzma_block_encoder() would fail. If you want to validate the
281
+ *              filter chain, consider using lzma_memlimit_encoder() which as
282
+ *              a side-effect validates the filter chain.
283
+ */
284
+extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)
285
+       lzma_nothrow lzma_attr_warn_unused_result;
286
+
287
+
288
+/**
289
+ * \brief       Encode Block Header
290
+ *
291
+ * The caller must have calculated the size of the Block Header already with
292
+ * lzma_block_header_size(). If a value larger than the one calculated by
293
+ * lzma_block_header_size() is used, the Block Header will be padded to the
294
+ * specified size.
295
+ *
296
+ * \param       out         Beginning of the output buffer. This must be
297
+ *                          at least block->header_size bytes.
298
+ * \param       block       Block options to be encoded.
299
+ *
300
+ * \return      - LZMA_OK: Encoding was successful. block->header_size
301
+ *                bytes were written to output buffer.
302
+ *              - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
303
+ *              - LZMA_PROG_ERROR: Invalid arguments, for example
304
+ *                block->header_size is invalid or block->filters is NULL.
305
+ */
306
+extern LZMA_API(lzma_ret) lzma_block_header_encode(
307
+       const lzma_block *block, uint8_t *out)
308
+       lzma_nothrow lzma_attr_warn_unused_result;
309
+
310
+
311
+/**
312
+ * \brief       Decode Block Header
313
+ *
314
+ * block->version should be set to the highest value supported by the
315
+ * application; currently the only possible version is zero. This function
316
+ * will set version to the lowest value that still supports all the features
317
+ * required by the Block Header.
318
+ *
319
+ * The size of the Block Header must have already been decoded with
320
+ * lzma_block_header_size_decode() macro and stored to block->header_size.
321
+ *
322
+ * The integrity check type from Stream Header must have been stored
323
+ * to block->check.
324
+ *
325
+ * block->filters must have been allocated, but they don't need to be
326
+ * initialized (possible existing filter options are not freed).
327
+ *
328
+ * \param       block       Destination for Block options.
329
+ * \param       allocator   lzma_allocator for custom allocator functions.
330
+ *                          Set to NULL to use malloc() (and also free()
331
+ *                          if an error occurs).
332
+ * \param       in          Beginning of the input buffer. This must be
333
+ *                          at least block->header_size bytes.
334
+ *
335
+ * \return      - LZMA_OK: Decoding was successful. block->header_size
336
+ *                bytes were read from the input buffer.
337
+ *              - LZMA_OPTIONS_ERROR: The Block Header specifies some
338
+ *                unsupported options such as unsupported filters. This can
339
+ *                happen also if block->version was set to a too low value
340
+ *                compared to what would be required to properly represent
341
+ *                the information stored in the Block Header.
342
+ *              - LZMA_DATA_ERROR: Block Header is corrupt, for example,
343
+ *                the CRC32 doesn't match.
344
+ *              - LZMA_PROG_ERROR: Invalid arguments, for example
345
+ *                block->header_size is invalid or block->filters is NULL.
346
+ */
347
+extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
348
+       lzma_allocator *allocator, const uint8_t *in)
349
+       lzma_nothrow lzma_attr_warn_unused_result;
350
+
351
+
352
+/**
353
+ * \brief       Validate and set Compressed Size according to Unpadded Size
354
+ *
355
+ * Block Header stores Compressed Size, but Index has Unpadded Size. If the
356
+ * application has already parsed the Index and is now decoding Blocks,
357
+ * it can calculate Compressed Size from Unpadded Size. This function does
358
+ * exactly that with error checking:
359
+ *
360
+ *  - Compressed Size calculated from Unpadded Size must be positive integer,
361
+ *    that is, Unpadded Size must be big enough that after Block Header and
362
+ *    Check fields there's still at least one byte for Compressed Size.
363
+ *
364
+ *  - If Compressed Size was present in Block Header, the new value
365
+ *    calculated from Unpadded Size is compared against the value
366
+ *    from Block Header.
367
+ *
368
+ * \note        This function must be called _after_ decoding the Block Header
369
+ *              field so that it can properly validate Compressed Size if it
370
+ *              was present in Block Header.
371
+ *
372
+ * \return      - LZMA_OK: block->compressed_size was set successfully.
373
+ *              - LZMA_DATA_ERROR: unpadded_size is too small compared to
374
+ *                block->header_size and lzma_check_size(block->check).
375
+ *              - LZMA_PROG_ERROR: Some values are invalid. For example,
376
+ *                block->header_size must be a multiple of four and
377
+ *                between 8 and 1024 inclusive.
378
+ */
379
+extern LZMA_API(lzma_ret) lzma_block_compressed_size(
380
+       lzma_block *block, lzma_vli unpadded_size)
381
+       lzma_nothrow lzma_attr_warn_unused_result;
382
+
383
+
384
+/**
385
+ * \brief       Calculate Unpadded Size
386
+ *
387
+ * The Index field stores Unpadded Size and Uncompressed Size. The latter
388
+ * can be taken directly from the lzma_block structure after coding a Block,
389
+ * but Unpadded Size needs to be calculated from Block Header Size,
390
+ * Compressed Size, and size of the Check field. This is where this function
391
+ * is needed.
392
+ *
393
+ * \return      Unpadded Size on success, or zero on error.
394
+ */
395
+extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)
396
+       lzma_nothrow lzma_attr_pure;
397
+
398
+
399
+/**
400
+ * \brief       Calculate the total encoded size of a Block
401
+ *
402
+ * This is equivalent to lzma_block_unpadded_size() except that the returned
403
+ * value includes the size of the Block Padding field.
404
+ *
405
+ * \return      On success, total encoded size of the Block. On error,
406
+ *              zero is returned.
407
+ */
408
+extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)
409
+       lzma_nothrow lzma_attr_pure;
410
+
411
+
412
+/**
413
+ * \brief       Initialize .xz Block encoder
414
+ *
415
+ * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the
416
+ * filter chain supports it), and LZMA_FINISH.
417
+ *
418
+ * \return      - LZMA_OK: All good, continue with lzma_code().
419
+ *              - LZMA_MEM_ERROR
420
+ *              - LZMA_OPTIONS_ERROR
421
+ *              - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID
422
+ *                that is not supported by this buid of liblzma. Initializing
423
+ *                the encoder failed.
424
+ *              - LZMA_PROG_ERROR
425
+ */
426
+extern LZMA_API(lzma_ret) lzma_block_encoder(
427
+       lzma_stream *strm, lzma_block *block)
428
+       lzma_nothrow lzma_attr_warn_unused_result;
429
+
430
+
431
+/**
432
+ * \brief       Initialize .xz Block decoder
433
+ *
434
+ * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using
435
+ * LZMA_FINISH is not required. It is supported only for convenience.
436
+ *
437
+ * \return      - LZMA_OK: All good, continue with lzma_code().
438
+ *              - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but
439
+ *                the given Check ID is not supported, thus Check will be
440
+ *                ignored.
441
+ *              - LZMA_PROG_ERROR
442
+ *              - LZMA_MEM_ERROR
443
+ */
444
+extern LZMA_API(lzma_ret) lzma_block_decoder(
445
+       lzma_stream *strm, lzma_block *block)
446
+       lzma_nothrow lzma_attr_warn_unused_result;
447
+
448
+
449
+/**
450
+ * \brief       Calculate maximum output size for single-call Block encoding
451
+ *
452
+ * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.
453
+ * See the documentation of lzma_stream_buffer_bound().
454
+ */
455
+extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
456
+       lzma_nothrow;
457
+
458
+
459
+/**
460
+ * \brief       Single-call .xz Block encoder
461
+ *
462
+ * In contrast to the multi-call encoder initialized with
463
+ * lzma_block_encoder(), this function encodes also the Block Header. This
464
+ * is required to make it possible to write appropriate Block Header also
465
+ * in case the data isn't compressible, and different filter chain has to be
466
+ * used to encode the data in uncompressed form using uncompressed chunks
467
+ * of the LZMA2 filter.
468
+ *
469
+ * When the data isn't compressible, header_size, compressed_size, and
470
+ * uncompressed_size are set just like when the data was compressible, but
471
+ * it is possible that header_size is too small to hold the filter chain
472
+ * specified in block->filters, because that isn't necessarily the filter
473
+ * chain that was actually used to encode the data. lzma_block_unpadded_size()
474
+ * still works normally, because it doesn't read the filters array.
475
+ *
476
+ * \param       block       Block options: block->version, block->check,
477
+ *                          and block->filters must have been initialized.
478
+ * \param       allocator   lzma_allocator for custom allocator functions.
479
+ *                          Set to NULL to use malloc() and free().
480
+ * \param       in          Beginning of the input buffer
481
+ * \param       in_size     Size of the input buffer
482
+ * \param       out         Beginning of the output buffer
483
+ * \param       out_pos     The next byte will be written to out[*out_pos].
484
+ *                          *out_pos is updated only if encoding succeeds.
485
+ * \param       out_size    Size of the out buffer; the first byte into
486
+ *                          which no data is written to is out[out_size].
487
+ *
488
+ * \return      - LZMA_OK: Encoding was successful.
489
+ *              - LZMA_BUF_ERROR: Not enough output buffer space.
490
+ *              - LZMA_UNSUPPORTED_CHECK
491
+ *              - LZMA_OPTIONS_ERROR
492
+ *              - LZMA_MEM_ERROR
493
+ *              - LZMA_DATA_ERROR
494
+ *              - LZMA_PROG_ERROR
495
+ */
496
+extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
497
+       lzma_block *block, lzma_allocator *allocator,
498
+       const uint8_t *in, size_t in_size,
499
+       uint8_t *out, size_t *out_pos, size_t out_size)
500
+       lzma_nothrow lzma_attr_warn_unused_result;
501
+
502
+
503
+/**
504
+ * \brief       Single-call .xz Block decoder
505
+ *
506
+ * This is single-call equivalent of lzma_block_decoder(), and requires that
507
+ * the caller has already decoded Block Header and checked its memory usage.
508
+ *
509
+ * \param       block       Block options just like with lzma_block_decoder().
510
+ * \param       allocator   lzma_allocator for custom allocator functions.
511
+ *                          Set to NULL to use malloc() and free().
512
+ * \param       in          Beginning of the input buffer
513
+ * \param       in_pos      The next byte will be read from in[*in_pos].
514
+ *                          *in_pos is updated only if decoding succeeds.
515
+ * \param       in_size     Size of the input buffer; the first byte that
516
+ *                          won't be read is in[in_size].
517
+ * \param       out         Beginning of the output buffer
518
+ * \param       out_pos     The next byte will be written to out[*out_pos].
519
+ *                          *out_pos is updated only if encoding succeeds.
520
+ * \param       out_size    Size of the out buffer; the first byte into
521
+ *                          which no data is written to is out[out_size].
522
+ *
523
+ * \return      - LZMA_OK: Decoding was successful.
524
+ *              - LZMA_OPTIONS_ERROR
525
+ *              - LZMA_DATA_ERROR
526
+ *              - LZMA_MEM_ERROR
527
+ *              - LZMA_BUF_ERROR: Output buffer was too small.
528
+ *              - LZMA_PROG_ERROR
529
+ */
530
+extern LZMA_API(lzma_ret) lzma_block_buffer_decode(
531
+       lzma_block *block, lzma_allocator *allocator,
532
+       const uint8_t *in, size_t *in_pos, size_t in_size,
533
+       uint8_t *out, size_t *out_pos, size_t out_size)
534
+       lzma_nothrow;
535
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/check.h Added
152
 
1
@@ -0,0 +1,150 @@
2
+/**
3
+ * \file        lzma/check.h
4
+ * \brief       Integrity checks
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Type of the integrity check (Check ID)
23
+ *
24
+ * The .xz format supports multiple types of checks that are calculated
25
+ * from the uncompressed data. They vary in both speed and ability to
26
+ * detect errors.
27
+ */
28
+typedef enum {
29
+   LZMA_CHECK_NONE     = 0,
30
+       /**<
31
+        * No Check is calculated.
32
+        *
33
+        * Size of the Check field: 0 bytes
34
+        */
35
+
36
+   LZMA_CHECK_CRC32    = 1,
37
+       /**<
38
+        * CRC32 using the polynomial from the IEEE 802.3 standard
39
+        *
40
+        * Size of the Check field: 4 bytes
41
+        */
42
+
43
+   LZMA_CHECK_CRC64    = 4,
44
+       /**<
45
+        * CRC64 using the polynomial from the ECMA-182 standard
46
+        *
47
+        * Size of the Check field: 8 bytes
48
+        */
49
+
50
+   LZMA_CHECK_SHA256   = 10
51
+       /**<
52
+        * SHA-256
53
+        *
54
+        * Size of the Check field: 32 bytes
55
+        */
56
+} lzma_check;
57
+
58
+
59
+/**
60
+ * \brief       Maximum valid Check ID
61
+ *
62
+ * The .xz file format specification specifies 16 Check IDs (0-15). Some
63
+ * of them are only reserved, that is, no actual Check algorithm has been
64
+ * assigned. When decoding, liblzma still accepts unknown Check IDs for
65
+ * future compatibility. If a valid but unsupported Check ID is detected,
66
+ * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
67
+ * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
68
+ */
69
+#define LZMA_CHECK_ID_MAX 15
70
+
71
+
72
+/**
73
+ * \brief       Test if the given Check ID is supported
74
+ *
75
+ * Return true if the given Check ID is supported by this liblzma build.
76
+ * Otherwise false is returned. It is safe to call this with a value that
77
+ * is not in the range [0, 15]; in that case the return value is always false.
78
+ *
79
+ * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always
80
+ * supported (even if liblzma is built with limited features).
81
+ */
82
+extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
83
+       lzma_nothrow lzma_attr_const;
84
+
85
+
86
+/**
87
+ * \brief       Get the size of the Check field with the given Check ID
88
+ *
89
+ * Although not all Check IDs have a check algorithm associated, the size of
90
+ * every Check is already frozen. This function returns the size (in bytes) of
91
+ * the Check field with the specified Check ID. The values are:
92
+ * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
93
+ *
94
+ * If the argument is not in the range [0, 15], UINT32_MAX is returned.
95
+ */
96
+extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
97
+       lzma_nothrow lzma_attr_const;
98
+
99
+
100
+/**
101
+ * \brief       Maximum size of a Check field
102
+ */
103
+#define LZMA_CHECK_SIZE_MAX 64
104
+
105
+
106
+/**
107
+ * \brief       Calculate CRC32
108
+ *
109
+ * Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
110
+ *
111
+ * \param       buf     Pointer to the input buffer
112
+ * \param       size    Size of the input buffer
113
+ * \param       crc     Previously returned CRC value. This is used to
114
+ *                      calculate the CRC of a big buffer in smaller chunks.
115
+ *                      Set to zero when starting a new calculation.
116
+ *
117
+ * \return      Updated CRC value, which can be passed to this function
118
+ *              again to continue CRC calculation.
119
+ */
120
+extern LZMA_API(uint32_t) lzma_crc32(
121
+       const uint8_t *buf, size_t size, uint32_t crc)
122
+       lzma_nothrow lzma_attr_pure;
123
+
124
+
125
+/**
126
+ * \brief       Calculate CRC64
127
+ *
128
+ * Calculate CRC64 using the polynomial from the ECMA-182 standard.
129
+ *
130
+ * This function is used similarly to lzma_crc32(). See its documentation.
131
+ */
132
+extern LZMA_API(uint64_t) lzma_crc64(
133
+       const uint8_t *buf, size_t size, uint64_t crc)
134
+       lzma_nothrow lzma_attr_pure;
135
+
136
+
137
+/*
138
+ * SHA-256 functions are currently not exported to public API.
139
+ * Contact Lasse Collin if you think it should be.
140
+ */
141
+
142
+
143
+/**
144
+ * \brief       Get the type of the integrity check
145
+ *
146
+ * This function can be called only immediately after lzma_code() has
147
+ * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
148
+ * Calling this function in any other situation has undefined behavior.
149
+ */
150
+extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)
151
+       lzma_nothrow;
152
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/container.h Added
426
 
1
@@ -0,0 +1,424 @@
2
+/**
3
+ * \file        lzma/container.h
4
+ * \brief       File formats
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/************
22
+ * Encoding *
23
+ ************/
24
+
25
+/**
26
+ * \brief       Default compression preset
27
+ *
28
+ * It's not straightforward to recommend a default preset, because in some
29
+ * cases keeping the resource usage relatively low is more important that
30
+ * getting the maximum compression ratio.
31
+ */
32
+#define LZMA_PRESET_DEFAULT     UINT32_C(6)
33
+
34
+
35
+/**
36
+ * \brief       Mask for preset level
37
+ *
38
+ * This is useful only if you need to extract the level from the preset
39
+ * variable. That should be rare.
40
+ */
41
+#define LZMA_PRESET_LEVEL_MASK  UINT32_C(0x1F)
42
+
43
+
44
+/*
45
+ * Preset flags
46
+ *
47
+ * Currently only one flag is defined.
48
+ */
49
+
50
+/**
51
+ * \brief       Extreme compression preset
52
+ *
53
+ * This flag modifies the preset to make the encoding significantly slower
54
+ * while improving the compression ratio only marginally. This is useful
55
+ * when you don't mind wasting time to get as small result as possible.
56
+ *
57
+ * This flag doesn't affect the memory usage requirements of the decoder (at
58
+ * least not significantly). The memory usage of the encoder may be increased
59
+ * a little but only at the lowest preset levels (0-3).
60
+ */
61
+#define LZMA_PRESET_EXTREME       (UINT32_C(1) << 31)
62
+
63
+
64
+/**
65
+ * \brief       Calculate approximate memory usage of easy encoder
66
+ *
67
+ * This function is a wrapper for lzma_raw_encoder_memusage().
68
+ *
69
+ * \param       preset  Compression preset (level and possible flags)
70
+ *
71
+ * \return      Number of bytes of memory required for the given
72
+ *              preset when encoding. If an error occurs, for example
73
+ *              due to unsupported preset, UINT64_MAX is returned.
74
+ */
75
+extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
76
+       lzma_nothrow lzma_attr_pure;
77
+
78
+
79
+/**
80
+ * \brief       Calculate approximate decoder memory usage of a preset
81
+ *
82
+ * This function is a wrapper for lzma_raw_decoder_memusage().
83
+ *
84
+ * \param       preset  Compression preset (level and possible flags)
85
+ *
86
+ * \return      Number of bytes of memory required to decompress a file
87
+ *              that was compressed using the given preset. If an error
88
+ *              occurs, for example due to unsupported preset, UINT64_MAX
89
+ *              is returned.
90
+ */
91
+extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)
92
+       lzma_nothrow lzma_attr_pure;
93
+
94
+
95
+/**
96
+ * \brief       Initialize .xz Stream encoder using a preset number
97
+ *
98
+ * This function is intended for those who just want to use the basic features
99
+ * if liblzma (that is, most developers out there).
100
+ *
101
+ * \param       strm    Pointer to lzma_stream that is at least initialized
102
+ *                      with LZMA_STREAM_INIT.
103
+ * \param       preset  Compression preset to use. A preset consist of level
104
+ *                      number and zero or more flags. Usually flags aren't
105
+ *                      used, so preset is simply a number [0, 9] which match
106
+ *                      the options -0 ... -9 of the xz command line tool.
107
+ *                      Additional flags can be be set using bitwise-or with
108
+ *                      the preset level number, e.g. 6 | LZMA_PRESET_EXTREME.
109
+ * \param       check   Integrity check type to use. See check.h for available
110
+ *                      checks. The xz command line tool defaults to
111
+ *                      LZMA_CHECK_CRC64, which is a good choice if you are
112
+ *                      unsure. LZMA_CHECK_CRC32 is good too as long as the
113
+ *                      uncompressed file is not many gigabytes.
114
+ *
115
+ * \return      - LZMA_OK: Initialization succeeded. Use lzma_code() to
116
+ *                encode your data.
117
+ *              - LZMA_MEM_ERROR: Memory allocation failed.
118
+ *              - LZMA_OPTIONS_ERROR: The given compression preset is not
119
+ *                supported by this build of liblzma.
120
+ *              - LZMA_UNSUPPORTED_CHECK: The given check type is not
121
+ *                supported by this liblzma build.
122
+ *              - LZMA_PROG_ERROR: One or more of the parameters have values
123
+ *                that will never be valid. For example, strm == NULL.
124
+ *
125
+ * If initialization fails (return value is not LZMA_OK), all the memory
126
+ * allocated for *strm by liblzma is always freed. Thus, there is no need
127
+ * to call lzma_end() after failed initialization.
128
+ *
129
+ * If initialization succeeds, use lzma_code() to do the actual encoding.
130
+ * Valid values for `action' (the second argument of lzma_code()) are
131
+ * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
132
+ * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.
133
+ */
134
+extern LZMA_API(lzma_ret) lzma_easy_encoder(
135
+       lzma_stream *strm, uint32_t preset, lzma_check check)
136
+       lzma_nothrow lzma_attr_warn_unused_result;
137
+
138
+
139
+/**
140
+ * \brief       Single-call .xz Stream encoding using a preset number
141
+ *
142
+ * The maximum required output buffer size can be calculated with
143
+ * lzma_stream_buffer_bound().
144
+ *
145
+ * \param       preset      Compression preset to use. See the description
146
+ *                          in lzma_easy_encoder().
147
+ * \param       check       Type of the integrity check to calculate from
148
+ *                          uncompressed data.
149
+ * \param       allocator   lzma_allocator for custom allocator functions.
150
+ *                          Set to NULL to use malloc() and free().
151
+ * \param       in          Beginning of the input buffer
152
+ * \param       in_size     Size of the input buffer
153
+ * \param       out         Beginning of the output buffer
154
+ * \param       out_pos     The next byte will be written to out[*out_pos].
155
+ *                          *out_pos is updated only if encoding succeeds.
156
+ * \param       out_size    Size of the out buffer; the first byte into
157
+ *                          which no data is written to is out[out_size].
158
+ *
159
+ * \return      - LZMA_OK: Encoding was successful.
160
+ *              - LZMA_BUF_ERROR: Not enough output buffer space.
161
+ *              - LZMA_UNSUPPORTED_CHECK
162
+ *              - LZMA_OPTIONS_ERROR
163
+ *              - LZMA_MEM_ERROR
164
+ *              - LZMA_DATA_ERROR
165
+ *              - LZMA_PROG_ERROR
166
+ */
167
+extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
168
+       uint32_t preset, lzma_check check,
169
+       lzma_allocator *allocator, const uint8_t *in, size_t in_size,
170
+       uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
171
+
172
+
173
+/**
174
+ * \brief       Initialize .xz Stream encoder using a custom filter chain
175
+ *
176
+ * \param       strm    Pointer to properly prepared lzma_stream
177
+ * \param       filters Array of filters. This must be terminated with
178
+ *                      filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for
179
+ *                      more information.
180
+ * \param       check   Type of the integrity check to calculate from
181
+ *                      uncompressed data.
182
+ *
183
+ * \return      - LZMA_OK: Initialization was successful.
184
+ *              - LZMA_MEM_ERROR
185
+ *              - LZMA_UNSUPPORTED_CHECK
186
+ *              - LZMA_OPTIONS_ERROR
187
+ *              - LZMA_PROG_ERROR
188
+ */
189
+extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,
190
+       const lzma_filter *filters, lzma_check check)
191
+       lzma_nothrow lzma_attr_warn_unused_result;
192
+
193
+
194
+/**
195
+ * \brief       Initialize .lzma encoder (legacy file format)
196
+ *
197
+ * The .lzma format is sometimes called the LZMA_Alone format, which is the
198
+ * reason for the name of this function. The .lzma format supports only the
199
+ * LZMA1 filter. There is no support for integrity checks like CRC32.
200
+ *
201
+ * Use this function if and only if you need to create files readable by
202
+ * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format
203
+ * is strongly recommended.
204
+ *
205
+ * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH.
206
+ * No kind of flushing is supported, because the file format doesn't make
207
+ * it possible.
208
+ *
209
+ * \return      - LZMA_OK
210
+ *              - LZMA_MEM_ERROR
211
+ *              - LZMA_OPTIONS_ERROR
212
+ *              - LZMA_PROG_ERROR
213
+ */
214
+extern LZMA_API(lzma_ret) lzma_alone_encoder(
215
+       lzma_stream *strm, const lzma_options_lzma *options)
216
+       lzma_nothrow lzma_attr_warn_unused_result;
217
+
218
+
219
+/**
220
+ * \brief       Calculate output buffer size for single-call Stream encoder
221
+ *
222
+ * When trying to compress uncompressible data, the encoded size will be
223
+ * slightly bigger than the input data. This function calculates how much
224
+ * output buffer space is required to be sure that lzma_stream_buffer_encode()
225
+ * doesn't return LZMA_BUF_ERROR.
226
+ *
227
+ * The calculated value is not exact, but it is guaranteed to be big enough.
228
+ * The actual maximum output space required may be slightly smaller (up to
229
+ * about 100 bytes). This should not be a problem in practice.
230
+ *
231
+ * If the calculated maximum size doesn't fit into size_t or would make the
232
+ * Stream grow past LZMA_VLI_MAX (which should never happen in practice),
233
+ * zero is returned to indicate the error.
234
+ *
235
+ * \note        The limit calculated by this function applies only to
236
+ *              single-call encoding. Multi-call encoding may (and probably
237
+ *              will) have larger maximum expansion when encoding
238
+ *              uncompressible data. Currently there is no function to
239
+ *              calculate the maximum expansion of multi-call encoding.
240
+ */
241
+extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
242
+       lzma_nothrow;
243
+
244
+
245
+/**
246
+ * \brief       Single-call .xz Stream encoder
247
+ *
248
+ * \param       filters     Array of filters. This must be terminated with
249
+ *                          filters[n].id = LZMA_VLI_UNKNOWN. See filter.h
250
+ *                          for more information.
251
+ * \param       check       Type of the integrity check to calculate from
252
+ *                          uncompressed data.
253
+ * \param       allocator   lzma_allocator for custom allocator functions.
254
+ *                          Set to NULL to use malloc() and free().
255
+ * \param       in          Beginning of the input buffer
256
+ * \param       in_size     Size of the input buffer
257
+ * \param       out         Beginning of the output buffer
258
+ * \param       out_pos     The next byte will be written to out[*out_pos].
259
+ *                          *out_pos is updated only if encoding succeeds.
260
+ * \param       out_size    Size of the out buffer; the first byte into
261
+ *                          which no data is written to is out[out_size].
262
+ *
263
+ * \return      - LZMA_OK: Encoding was successful.
264
+ *              - LZMA_BUF_ERROR: Not enough output buffer space.
265
+ *              - LZMA_UNSUPPORTED_CHECK
266
+ *              - LZMA_OPTIONS_ERROR
267
+ *              - LZMA_MEM_ERROR
268
+ *              - LZMA_DATA_ERROR
269
+ *              - LZMA_PROG_ERROR
270
+ */
271
+extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
272
+       lzma_filter *filters, lzma_check check,
273
+       lzma_allocator *allocator, const uint8_t *in, size_t in_size,
274
+       uint8_t *out, size_t *out_pos, size_t out_size)
275
+       lzma_nothrow lzma_attr_warn_unused_result;
276
+
277
+
278
+/************
279
+ * Decoding *
280
+ ************/
281
+
282
+/**
283
+ * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream
284
+ * being decoded has no integrity check. Note that when used with
285
+ * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK
286
+ * if LZMA_TELL_NO_CHECK is used.
287
+ */
288
+#define LZMA_TELL_NO_CHECK              UINT32_C(0x01)
289
+
290
+
291
+/**
292
+ * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input
293
+ * stream has an integrity check, but the type of the integrity check is not
294
+ * supported by this liblzma version or build. Such files can still be
295
+ * decoded, but the integrity check cannot be verified.
296
+ */
297
+#define LZMA_TELL_UNSUPPORTED_CHECK     UINT32_C(0x02)
298
+
299
+
300
+/**
301
+ * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type
302
+ * of the integrity check is known. The type can then be got with
303
+ * lzma_get_check().
304
+ */
305
+#define LZMA_TELL_ANY_CHECK             UINT32_C(0x04)
306
+
307
+
308
+/**
309
+ * This flag enables decoding of concatenated files with file formats that
310
+ * allow concatenating compressed files as is. From the formats currently
311
+ * supported by liblzma, only the .xz format allows concatenated files.
312
+ * Concatenated files are not allowed with the legacy .lzma format.
313
+ *
314
+ * This flag also affects the usage of the `action' argument for lzma_code().
315
+ * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END
316
+ * unless LZMA_FINISH is used as `action'. Thus, the application has to set
317
+ * LZMA_FINISH in the same way as it does when encoding.
318
+ *
319
+ * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH
320
+ * as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required.
321
+ */
322
+#define LZMA_CONCATENATED               UINT32_C(0x08)
323
+
324
+
325
+/**
326
+ * \brief       Initialize .xz Stream decoder
327
+ *
328
+ * \param       strm        Pointer to properly prepared lzma_stream
329
+ * \param       memlimit    Memory usage limit as bytes. Use UINT64_MAX
330
+ *                          to effectively disable the limiter.
331
+ * \param       flags       Bitwise-or of zero or more of the decoder flags:
332
+ *                          LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
333
+ *                          LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED
334
+ *
335
+ * \return      - LZMA_OK: Initialization was successful.
336
+ *              - LZMA_MEM_ERROR: Cannot allocate memory.
337
+ *              - LZMA_OPTIONS_ERROR: Unsupported flags
338
+ *              - LZMA_PROG_ERROR
339
+ */
340
+extern LZMA_API(lzma_ret) lzma_stream_decoder(
341
+       lzma_stream *strm, uint64_t memlimit, uint32_t flags)
342
+       lzma_nothrow lzma_attr_warn_unused_result;
343
+
344
+
345
+/**
346
+ * \brief       Decode .xz Streams and .lzma files with autodetection
347
+ *
348
+ * This decoder autodetects between the .xz and .lzma file formats, and
349
+ * calls lzma_stream_decoder() or lzma_alone_decoder() once the type
350
+ * of the input file has been detected.
351
+ *
352
+ * \param       strm        Pointer to properly prepared lzma_stream
353
+ * \param       memlimit    Memory usage limit as bytes. Use UINT64_MAX
354
+ *                          to effectively disable the limiter.
355
+ * \param       flags       Bitwise-or of flags, or zero for no flags.
356
+ *
357
+ * \return      - LZMA_OK: Initialization was successful.
358
+ *              - LZMA_MEM_ERROR: Cannot allocate memory.
359
+ *              - LZMA_OPTIONS_ERROR: Unsupported flags
360
+ *              - LZMA_PROG_ERROR
361
+ */
362
+extern LZMA_API(lzma_ret) lzma_auto_decoder(
363
+       lzma_stream *strm, uint64_t memlimit, uint32_t flags)
364
+       lzma_nothrow lzma_attr_warn_unused_result;
365
+
366
+
367
+/**
368
+ * \brief       Initialize .lzma decoder (legacy file format)
369
+ *
370
+ * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
371
+ * There is no need to use LZMA_FINISH, but allowing it may simplify
372
+ * certain types of applications.
373
+ *
374
+ * \return      - LZMA_OK
375
+ *              - LZMA_MEM_ERROR
376
+ *              - LZMA_PROG_ERROR
377
+ */
378
+extern LZMA_API(lzma_ret) lzma_alone_decoder(
379
+       lzma_stream *strm, uint64_t memlimit)
380
+       lzma_nothrow lzma_attr_warn_unused_result;
381
+
382
+
383
+/**
384
+ * \brief       Single-call .xz Stream decoder
385
+ *
386
+ * \param       memlimit    Pointer to how much memory the decoder is allowed
387
+ *                          to allocate. The value pointed by this pointer is
388
+ *                          modified if and only if LZMA_MEMLIMIT_ERROR is
389
+ *                          returned.
390
+ * \param       flags       Bitwise-or of zero or more of the decoder flags:
391
+ *                          LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
392
+ *                          LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK
393
+ *                          is not allowed and will return LZMA_PROG_ERROR.
394
+ * \param       allocator   lzma_allocator for custom allocator functions.
395
+ *                          Set to NULL to use malloc() and free().
396
+ * \param       in          Beginning of the input buffer
397
+ * \param       in_pos      The next byte will be read from in[*in_pos].
398
+ *                          *in_pos is updated only if decoding succeeds.
399
+ * \param       in_size     Size of the input buffer; the first byte that
400
+ *                          won't be read is in[in_size].
401
+ * \param       out         Beginning of the output buffer
402
+ * \param       out_pos     The next byte will be written to out[*out_pos].
403
+ *                          *out_pos is updated only if decoding succeeds.
404
+ * \param       out_size    Size of the out buffer; the first byte into
405
+ *                          which no data is written to is out[out_size].
406
+ *
407
+ * \return      - LZMA_OK: Decoding was successful.
408
+ *              - LZMA_FORMAT_ERROR
409
+ *              - LZMA_OPTIONS_ERROR
410
+ *              - LZMA_DATA_ERROR
411
+ *              - LZMA_NO_CHECK: This can be returned only if using
412
+ *                the LZMA_TELL_NO_CHECK flag.
413
+ *              - LZMA_UNSUPPORTED_CHECK: This can be returned only if using
414
+ *                the LZMA_TELL_UNSUPPORTED_CHECK flag.
415
+ *              - LZMA_MEM_ERROR
416
+ *              - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
417
+ *                The minimum required memlimit value was stored to *memlimit.
418
+ *              - LZMA_BUF_ERROR: Output buffer was too small.
419
+ *              - LZMA_PROG_ERROR
420
+ */
421
+extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(
422
+       uint64_t *memlimit, uint32_t flags, lzma_allocator *allocator,
423
+       const uint8_t *in, size_t *in_pos, size_t in_size,
424
+       uint8_t *out, size_t *out_pos, size_t out_size)
425
+       lzma_nothrow lzma_attr_warn_unused_result;
426
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/delta.h Added
79
 
1
@@ -0,0 +1,77 @@
2
+/**
3
+ * \file        lzma/delta.h
4
+ * \brief       Delta filter
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Filter ID
23
+ *
24
+ * Filter ID of the Delta filter. This is used as lzma_filter.id.
25
+ */
26
+#define LZMA_FILTER_DELTA       LZMA_VLI_C(0x03)
27
+
28
+
29
+/**
30
+ * \brief       Type of the delta calculation
31
+ *
32
+ * Currently only byte-wise delta is supported. Other possible types could
33
+ * be, for example, delta of 16/32/64-bit little/big endian integers, but
34
+ * these are not currently planned since byte-wise delta is almost as good.
35
+ */
36
+typedef enum {
37
+   LZMA_DELTA_TYPE_BYTE
38
+} lzma_delta_type;
39
+
40
+
41
+/**
42
+ * \brief       Options for the Delta filter
43
+ *
44
+ * These options are needed by both encoder and decoder.
45
+ */
46
+typedef struct {
47
+   /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */
48
+   lzma_delta_type type;
49
+
50
+   /**
51
+    * \brief       Delta distance
52
+    *
53
+    * With the only currently supported type, LZMA_DELTA_TYPE_BYTE,
54
+    * the distance is as bytes.
55
+    *
56
+    * Examples:
57
+    *  - 16-bit stereo audio: distance = 4 bytes
58
+    *  - 24-bit RGB image data: distance = 3 bytes
59
+    */
60
+   uint32_t dist;
61
+#  define LZMA_DELTA_DIST_MIN 1
62
+#  define LZMA_DELTA_DIST_MAX 256
63
+
64
+   /*
65
+    * Reserved space to allow possible future extensions without
66
+    * breaking the ABI. You should not touch these, because the names
67
+    * of these variables may change. These are and will never be used
68
+    * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these
69
+    * uninitialized.
70
+    */
71
+   uint32_t reserved_int1;
72
+   uint32_t reserved_int2;
73
+   uint32_t reserved_int3;
74
+   uint32_t reserved_int4;
75
+   void *reserved_ptr1;
76
+   void *reserved_ptr2;
77
+
78
+} lzma_options_delta;
79
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/filter.h Added
426
 
1
@@ -0,0 +1,424 @@
2
+/**
3
+ * \file        lzma/filter.h
4
+ * \brief       Common filter related types and functions
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Maximum number of filters in a chain
23
+ *
24
+ * A filter chain can have 1-4 filters, of which three are allowed to change
25
+ * the size of the data. Usually only one or two filters are needed.
26
+ */
27
+#define LZMA_FILTERS_MAX 4
28
+
29
+
30
+/**
31
+ * \brief       Filter options
32
+ *
33
+ * This structure is used to pass Filter ID and a pointer filter's
34
+ * options to liblzma. A few functions work with a single lzma_filter
35
+ * structure, while most functions expect a filter chain.
36
+ *
37
+ * A filter chain is indicated with an array of lzma_filter structures.
38
+ * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter
39
+ * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to
40
+ * be able to hold any arbitrary filter chain. This is important when
41
+ * using lzma_block_header_decode() from block.h, because too small
42
+ * array would make liblzma write past the end of the filters array.
43
+ */
44
+typedef struct {
45
+   /**
46
+    * \brief       Filter ID
47
+    *
48
+    * Use constants whose name begin with `LZMA_FILTER_' to specify
49
+    * different filters. In an array of lzma_filter structures, use
50
+    * LZMA_VLI_UNKNOWN to indicate end of filters.
51
+    *
52
+    * \note        This is not an enum, because on some systems enums
53
+    *              cannot be 64-bit.
54
+    */
55
+   lzma_vli id;
56
+
57
+   /**
58
+    * \brief       Pointer to filter-specific options structure
59
+    *
60
+    * If the filter doesn't need options, set this to NULL. If id is
61
+    * set to LZMA_VLI_UNKNOWN, options is ignored, and thus
62
+    * doesn't need be initialized.
63
+    */
64
+   void *options;
65
+
66
+} lzma_filter;
67
+
68
+
69
+/**
70
+ * \brief       Test if the given Filter ID is supported for encoding
71
+ *
72
+ * Return true if the give Filter ID is supported for encoding by this
73
+ * liblzma build. Otherwise false is returned.
74
+ *
75
+ * There is no way to list which filters are available in this particular
76
+ * liblzma version and build. It would be useless, because the application
77
+ * couldn't know what kind of options the filter would need.
78
+ */
79
+extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id)
80
+       lzma_nothrow lzma_attr_const;
81
+
82
+
83
+/**
84
+ * \brief       Test if the given Filter ID is supported for decoding
85
+ *
86
+ * Return true if the give Filter ID is supported for decoding by this
87
+ * liblzma build. Otherwise false is returned.
88
+ */
89
+extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
90
+       lzma_nothrow lzma_attr_const;
91
+
92
+
93
+/**
94
+ * \brief       Copy the filters array
95
+ *
96
+ * Copy the Filter IDs and filter-specific options from src to dest.
97
+ * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating
98
+ * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least
99
+ * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that
100
+ * src is smaller than that.
101
+ *
102
+ * Unless the filter-specific options is NULL, the Filter ID has to be
103
+ * supported by liblzma, because liblzma needs to know the size of every
104
+ * filter-specific options structure. The filter-specific options are not
105
+ * validated. If options is NULL, any unsupported Filter IDs are copied
106
+ * without returning an error.
107
+ *
108
+ * Old filter-specific options in dest are not freed, so dest doesn't
109
+ * need to be initialized by the caller in any way.
110
+ *
111
+ * If an error occurs, memory possibly already allocated by this function
112
+ * is always freed.
113
+ *
114
+ * \return      - LZMA_OK
115
+ *              - LZMA_MEM_ERROR
116
+ *              - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options
117
+ *                is not NULL.
118
+ *              - LZMA_PROG_ERROR: src or dest is NULL.
119
+ */
120
+extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src,
121
+       lzma_filter *dest, lzma_allocator *allocator) lzma_nothrow;
122
+
123
+
124
+/**
125
+ * \brief       Calculate approximate memory requirements for raw encoder
126
+ *
127
+ * This function can be used to calculate the memory requirements for
128
+ * Block and Stream encoders too because Block and Stream encoders don't
129
+ * need significantly more memory than raw encoder.
130
+ *
131
+ * \param       filters     Array of filters terminated with
132
+ *                          .id == LZMA_VLI_UNKNOWN.
133
+ *
134
+ * \return      Number of bytes of memory required for the given
135
+ *              filter chain when encoding. If an error occurs,
136
+ *              for example due to unsupported filter chain,
137
+ *              UINT64_MAX is returned.
138
+ */
139
+extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
140
+       lzma_nothrow lzma_attr_pure;
141
+
142
+
143
+/**
144
+ * \brief       Calculate approximate memory requirements for raw decoder
145
+ *
146
+ * This function can be used to calculate the memory requirements for
147
+ * Block and Stream decoders too because Block and Stream decoders don't
148
+ * need significantly more memory than raw decoder.
149
+ *
150
+ * \param       filters     Array of filters terminated with
151
+ *                          .id == LZMA_VLI_UNKNOWN.
152
+ *
153
+ * \return      Number of bytes of memory required for the given
154
+ *              filter chain when decoding. If an error occurs,
155
+ *              for example due to unsupported filter chain,
156
+ *              UINT64_MAX is returned.
157
+ */
158
+extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)
159
+       lzma_nothrow lzma_attr_pure;
160
+
161
+
162
+/**
163
+ * \brief       Initialize raw encoder
164
+ *
165
+ * This function may be useful when implementing custom file formats.
166
+ *
167
+ * \param       strm    Pointer to properly prepared lzma_stream
168
+ * \param       filters Array of lzma_filter structures. The end of the
169
+ *                      array must be marked with .id = LZMA_VLI_UNKNOWN.
170
+ *
171
+ * The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the
172
+ * filter chain supports it), or LZMA_FINISH.
173
+ *
174
+ * \return      - LZMA_OK
175
+ *              - LZMA_MEM_ERROR
176
+ *              - LZMA_OPTIONS_ERROR
177
+ *              - LZMA_PROG_ERROR
178
+ */
179
+extern LZMA_API(lzma_ret) lzma_raw_encoder(
180
+       lzma_stream *strm, const lzma_filter *filters)
181
+       lzma_nothrow lzma_attr_warn_unused_result;
182
+
183
+
184
+/**
185
+ * \brief       Initialize raw decoder
186
+ *
187
+ * The initialization of raw decoder goes similarly to raw encoder.
188
+ *
189
+ * The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using
190
+ * LZMA_FINISH is not required, it is supported just for convenience.
191
+ *
192
+ * \return      - LZMA_OK
193
+ *              - LZMA_MEM_ERROR
194
+ *              - LZMA_OPTIONS_ERROR
195
+ *              - LZMA_PROG_ERROR
196
+ */
197
+extern LZMA_API(lzma_ret) lzma_raw_decoder(
198
+       lzma_stream *strm, const lzma_filter *filters)
199
+       lzma_nothrow lzma_attr_warn_unused_result;
200
+
201
+
202
+/**
203
+ * \brief       Update the filter chain in the encoder
204
+ *
205
+ * This function is for advanced users only. This function has two slightly
206
+ * different purposes:
207
+ *
208
+ *  - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter
209
+ *    chain, which will be used starting from the next Block.
210
+ *
211
+ *  - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change
212
+ *    the filter-specific options in the middle of encoding. The actual
213
+ *    filters in the chain (Filter IDs) cannot be changed. In the future,
214
+ *    it might become possible to change the filter options without
215
+ *    using LZMA_SYNC_FLUSH.
216
+ *
217
+ * While rarely useful, this function may be called also when no data has
218
+ * been compressed yet. In that case, this function will behave as if
219
+ * LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block
220
+ * encoder) had been used right before calling this function.
221
+ *
222
+ * \return      - LZMA_OK
223
+ *              - LZMA_MEM_ERROR
224
+ *              - LZMA_MEMLIMIT_ERROR
225
+ *              - LZMA_OPTIONS_ERROR
226
+ *              - LZMA_PROG_ERROR
227
+ */
228
+extern LZMA_API(lzma_ret) lzma_filters_update(
229
+       lzma_stream *strm, const lzma_filter *filters) lzma_nothrow;
230
+
231
+
232
+/**
233
+ * \brief       Single-call raw encoder
234
+ *
235
+ * \param       filters     Array of lzma_filter structures. The end of the
236
+ *                          array must be marked with .id = LZMA_VLI_UNKNOWN.
237
+ * \param       allocator   lzma_allocator for custom allocator functions.
238
+ *                          Set to NULL to use malloc() and free().
239
+ * \param       in          Beginning of the input buffer
240
+ * \param       in_size     Size of the input buffer
241
+ * \param       out         Beginning of the output buffer
242
+ * \param       out_pos     The next byte will be written to out[*out_pos].
243
+ *                          *out_pos is updated only if encoding succeeds.
244
+ * \param       out_size    Size of the out buffer; the first byte into
245
+ *                          which no data is written to is out[out_size].
246
+ *
247
+ * \return      - LZMA_OK: Encoding was successful.
248
+ *              - LZMA_BUF_ERROR: Not enough output buffer space.
249
+ *              - LZMA_OPTIONS_ERROR
250
+ *              - LZMA_MEM_ERROR
251
+ *              - LZMA_DATA_ERROR
252
+ *              - LZMA_PROG_ERROR
253
+ *
254
+ * \note        There is no function to calculate how big output buffer
255
+ *              would surely be big enough. (lzma_stream_buffer_bound()
256
+ *              works only for lzma_stream_buffer_encode(); raw encoder
257
+ *              won't necessarily meet that bound.)
258
+ */
259
+extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
260
+       const lzma_filter *filters, lzma_allocator *allocator,
261
+       const uint8_t *in, size_t in_size, uint8_t *out,
262
+       size_t *out_pos, size_t out_size) lzma_nothrow;
263
+
264
+
265
+/**
266
+ * \brief       Single-call raw decoder
267
+ *
268
+ * \param       filters     Array of lzma_filter structures. The end of the
269
+ *                          array must be marked with .id = LZMA_VLI_UNKNOWN.
270
+ * \param       allocator   lzma_allocator for custom allocator functions.
271
+ *                          Set to NULL to use malloc() and free().
272
+ * \param       in          Beginning of the input buffer
273
+ * \param       in_pos      The next byte will be read from in[*in_pos].
274
+ *                          *in_pos is updated only if decoding succeeds.
275
+ * \param       in_size     Size of the input buffer; the first byte that
276
+ *                          won't be read is in[in_size].
277
+ * \param       out         Beginning of the output buffer
278
+ * \param       out_pos     The next byte will be written to out[*out_pos].
279
+ *                          *out_pos is updated only if encoding succeeds.
280
+ * \param       out_size    Size of the out buffer; the first byte into
281
+ *                          which no data is written to is out[out_size].
282
+ */
283
+extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(
284
+       const lzma_filter *filters, lzma_allocator *allocator,
285
+       const uint8_t *in, size_t *in_pos, size_t in_size,
286
+       uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
287
+
288
+
289
+/**
290
+ * \brief       Get the size of the Filter Properties field
291
+ *
292
+ * This function may be useful when implementing custom file formats
293
+ * using the raw encoder and decoder.
294
+ *
295
+ * \param       size    Pointer to uint32_t to hold the size of the properties
296
+ * \param       filter  Filter ID and options (the size of the properties may
297
+ *                      vary depending on the options)
298
+ *
299
+ * \return      - LZMA_OK
300
+ *              - LZMA_OPTIONS_ERROR
301
+ *              - LZMA_PROG_ERROR
302
+ *
303
+ * \note        This function validates the Filter ID, but does not
304
+ *              necessarily validate the options. Thus, it is possible
305
+ *              that this returns LZMA_OK while the following call to
306
+ *              lzma_properties_encode() returns LZMA_OPTIONS_ERROR.
307
+ */
308
+extern LZMA_API(lzma_ret) lzma_properties_size(
309
+       uint32_t *size, const lzma_filter *filter) lzma_nothrow;
310
+
311
+
312
+/**
313
+ * \brief       Encode the Filter Properties field
314
+ *
315
+ * \param       filter  Filter ID and options
316
+ * \param       props   Buffer to hold the encoded options. The size of
317
+ *                      buffer must have been already determined with
318
+ *                      lzma_properties_size().
319
+ *
320
+ * \return      - LZMA_OK
321
+ *              - LZMA_OPTIONS_ERROR
322
+ *              - LZMA_PROG_ERROR
323
+ *
324
+ * \note        Even this function won't validate more options than actually
325
+ *              necessary. Thus, it is possible that encoding the properties
326
+ *              succeeds but using the same options to initialize the encoder
327
+ *              will fail.
328
+ *
329
+ * \note        If lzma_properties_size() indicated that the size
330
+ *              of the Filter Properties field is zero, calling
331
+ *              lzma_properties_encode() is not required, but it
332
+ *              won't do any harm either.
333
+ */
334
+extern LZMA_API(lzma_ret) lzma_properties_encode(
335
+       const lzma_filter *filter, uint8_t *props) lzma_nothrow;
336
+
337
+
338
+/**
339
+ * \brief       Decode the Filter Properties field
340
+ *
341
+ * \param       filter      filter->id must have been set to the correct
342
+ *                          Filter ID. filter->options doesn't need to be
343
+ *                          initialized (it's not freed by this function). The
344
+ *                          decoded options will be stored to filter->options.
345
+ *                          filter->options is set to NULL if there are no
346
+ *                          properties or if an error occurs.
347
+ * \param       allocator   Custom memory allocator used to allocate the
348
+ *                          options. Set to NULL to use the default malloc(),
349
+ *                          and in case of an error, also free().
350
+ * \param       props       Input buffer containing the properties.
351
+ * \param       props_size  Size of the properties. This must be the exact
352
+ *                          size; giving too much or too little input will
353
+ *                          return LZMA_OPTIONS_ERROR.
354
+ *
355
+ * \return      - LZMA_OK
356
+ *              - LZMA_OPTIONS_ERROR
357
+ *              - LZMA_MEM_ERROR
358
+ */
359
+extern LZMA_API(lzma_ret) lzma_properties_decode(
360
+       lzma_filter *filter, lzma_allocator *allocator,
361
+       const uint8_t *props, size_t props_size) lzma_nothrow;
362
+
363
+
364
+/**
365
+ * \brief       Calculate encoded size of a Filter Flags field
366
+ *
367
+ * Knowing the size of Filter Flags is useful to know when allocating
368
+ * memory to hold the encoded Filter Flags.
369
+ *
370
+ * \param       size    Pointer to integer to hold the calculated size
371
+ * \param       filter  Filter ID and associated options whose encoded
372
+ *                      size is to be calculated
373
+ *
374
+ * \return      - LZMA_OK: *size set successfully. Note that this doesn't
375
+ *                guarantee that filter->options is valid, thus
376
+ *                lzma_filter_flags_encode() may still fail.
377
+ *              - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.
378
+ *              - LZMA_PROG_ERROR: Invalid options
379
+ *
380
+ * \note        If you need to calculate size of List of Filter Flags,
381
+ *              you need to loop over every lzma_filter entry.
382
+ */
383
+extern LZMA_API(lzma_ret) lzma_filter_flags_size(
384
+       uint32_t *size, const lzma_filter *filter)
385
+       lzma_nothrow lzma_attr_warn_unused_result;
386
+
387
+
388
+/**
389
+ * \brief       Encode Filter Flags into given buffer
390
+ *
391
+ * In contrast to some functions, this doesn't allocate the needed buffer.
392
+ * This is due to how this function is used internally by liblzma.
393
+ *
394
+ * \param       filter      Filter ID and options to be encoded
395
+ * \param       out         Beginning of the output buffer
396
+ * \param       out_pos     out[*out_pos] is the next write position. This
397
+ *                          is updated by the encoder.
398
+ * \param       out_size    out[out_size] is the first byte to not write.
399
+ *
400
+ * \return      - LZMA_OK: Encoding was successful.
401
+ *              - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
402
+ *              - LZMA_PROG_ERROR: Invalid options or not enough output
403
+ *                buffer space (you should have checked it with
404
+ *                lzma_filter_flags_size()).
405
+ */
406
+extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,
407
+       uint8_t *out, size_t *out_pos, size_t out_size)
408
+       lzma_nothrow lzma_attr_warn_unused_result;
409
+
410
+
411
+/**
412
+ * \brief       Decode Filter Flags from given buffer
413
+ *
414
+ * The decoded result is stored into *filter. The old value of
415
+ * filter->options is not free()d.
416
+ *
417
+ * \return      - LZMA_OK
418
+ *              - LZMA_OPTIONS_ERROR
419
+ *              - LZMA_MEM_ERROR
420
+ *              - LZMA_PROG_ERROR
421
+ */
422
+extern LZMA_API(lzma_ret) lzma_filter_flags_decode(
423
+       lzma_filter *filter, lzma_allocator *allocator,
424
+       const uint8_t *in, size_t *in_pos, size_t in_size)
425
+       lzma_nothrow lzma_attr_warn_unused_result;
426
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/hardware.h Added
52
 
1
@@ -0,0 +1,50 @@
2
+/**
3
+ * \file        lzma/hardware.h
4
+ * \brief       Hardware information
5
+ *
6
+ * Since liblzma can consume a lot of system resources, it also provides
7
+ * ways to limit the resource usage. Applications linking against liblzma
8
+ * need to do the actual decisions how much resources to let liblzma to use.
9
+ * To ease making these decisions, liblzma provides functions to find out
10
+ * the relevant capabilities of the underlaying hardware. Currently there
11
+ * is only a function to find out the amount of RAM, but in the future there
12
+ * will be also a function to detect how many concurrent threads the system
13
+ * can run.
14
+ *
15
+ * \note        On some operating systems, these function may temporarily
16
+ *              load a shared library or open file descriptor(s) to find out
17
+ *              the requested hardware information. Unless the application
18
+ *              assumes that specific file descriptors are not touched by
19
+ *              other threads, this should have no effect on thread safety.
20
+ *              Possible operations involving file descriptors will restart
21
+ *              the syscalls if they return EINTR.
22
+ */
23
+
24
+/*
25
+ * Author: Lasse Collin
26
+ *
27
+ * This file has been put into the public domain.
28
+ * You can do whatever you want with this file.
29
+ *
30
+ * See ../lzma.h for information about liblzma as a whole.
31
+ */
32
+
33
+#ifndef LZMA_H_INTERNAL
34
+#  error Never include this file directly. Use <lzma.h> instead.
35
+#endif
36
+
37
+
38
+/**
39
+ * \brief       Get the total amount of physical memory (RAM) in bytes
40
+ *
41
+ * This function may be useful when determining a reasonable memory
42
+ * usage limit for decompressing or how much memory it is OK to use
43
+ * for compressing.
44
+ *
45
+ * \return      On success, the total amount of physical memory in bytes
46
+ *              is returned. If the amount of RAM cannot be determined,
47
+ *              zero is returned. This can happen if an error occurs
48
+ *              or if there is no code in liblzma to detect the amount
49
+ *              of RAM on the specific operating system.
50
+ */
51
+extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
52
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/index.h Added
684
 
1
@@ -0,0 +1,682 @@
2
+/**
3
+ * \file        lzma/index.h
4
+ * \brief       Handling of .xz Index and related information
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Opaque data type to hold the Index(es) and other information
23
+ *
24
+ * lzma_index often holds just one .xz Index and possibly the Stream Flags
25
+ * of the same Stream and size of the Stream Padding field. However,
26
+ * multiple lzma_indexes can be concatenated with lzma_index_cat() and then
27
+ * there may be information about multiple Streams in the same lzma_index.
28
+ *
29
+ * Notes about thread safety: Only one thread may modify lzma_index at
30
+ * a time. All functions that take non-const pointer to lzma_index
31
+ * modify it. As long as no thread is modifying the lzma_index, getting
32
+ * information from the same lzma_index can be done from multiple threads
33
+ * at the same time with functions that take a const pointer to
34
+ * lzma_index or use lzma_index_iter. The same iterator must be used
35
+ * only by one thread at a time, of course, but there can be as many
36
+ * iterators for the same lzma_index as needed.
37
+ */
38
+typedef struct lzma_index_s lzma_index;
39
+
40
+
41
+/**
42
+ * \brief       Iterator to get information about Blocks and Streams
43
+ */
44
+typedef struct {
45
+   struct {
46
+       /**
47
+        * \brief       Pointer to Stream Flags
48
+        *
49
+        * This is NULL if Stream Flags have not been set for
50
+        * this Stream with lzma_index_stream_flags().
51
+        */
52
+       const lzma_stream_flags *flags;
53
+
54
+       const void *reserved_ptr1;
55
+       const void *reserved_ptr2;
56
+       const void *reserved_ptr3;
57
+
58
+       /**
59
+        * \brief       Stream number in the lzma_index
60
+        *
61
+        * The first Stream is 1.
62
+        */
63
+       lzma_vli number;
64
+
65
+       /**
66
+        * \brief       Number of Blocks in the Stream
67
+        *
68
+        * If this is zero, the block structure below has
69
+        * undefined values.
70
+        */
71
+       lzma_vli block_count;
72
+
73
+       /**
74
+        * \brief       Compressed start offset of this Stream
75
+        *
76
+        * The offset is relative to the beginning of the lzma_index
77
+        * (i.e. usually the beginning of the .xz file).
78
+        */
79
+       lzma_vli compressed_offset;
80
+
81
+       /**
82
+        * \brief       Uncompressed start offset of this Stream
83
+        *
84
+        * The offset is relative to the beginning of the lzma_index
85
+        * (i.e. usually the beginning of the .xz file).
86
+        */
87
+       lzma_vli uncompressed_offset;
88
+
89
+       /**
90
+        * \brief       Compressed size of this Stream
91
+        *
92
+        * This includes all headers except the possible
93
+        * Stream Padding after this Stream.
94
+        */
95
+       lzma_vli compressed_size;
96
+
97
+       /**
98
+        * \brief       Uncompressed size of this Stream
99
+        */
100
+       lzma_vli uncompressed_size;
101
+
102
+       /**
103
+        * \brief       Size of Stream Padding after this Stream
104
+        *
105
+        * If it hasn't been set with lzma_index_stream_padding(),
106
+        * this defaults to zero. Stream Padding is always
107
+        * a multiple of four bytes.
108
+        */
109
+       lzma_vli padding;
110
+
111
+       lzma_vli reserved_vli1;
112
+       lzma_vli reserved_vli2;
113
+       lzma_vli reserved_vli3;
114
+       lzma_vli reserved_vli4;
115
+   } stream;
116
+
117
+   struct {
118
+       /**
119
+        * \brief       Block number in the file
120
+        *
121
+        * The first Block is 1.
122
+        */
123
+       lzma_vli number_in_file;
124
+
125
+       /**
126
+        * \brief       Compressed start offset of this Block
127
+        *
128
+        * This offset is relative to the beginning of the
129
+        * lzma_index (i.e. usually the beginning of the .xz file).
130
+        * Normally this is where you should seek in the .xz file
131
+        * to start decompressing this Block.
132
+        */
133
+       lzma_vli compressed_file_offset;
134
+
135
+       /**
136
+        * \brief       Uncompressed start offset of this Block
137
+        *
138
+        * This offset is relative to the beginning of the lzma_index
139
+        * (i.e. usually the beginning of the .xz file).
140
+        *
141
+        * When doing random-access reading, it is possible that
142
+        * the target offset is not exactly at Block boundary. One
143
+        * will need to compare the target offset against
144
+        * uncompressed_file_offset or uncompressed_stream_offset,
145
+        * and possibly decode and throw away some amount of data
146
+        * before reaching the target offset.
147
+        */
148
+       lzma_vli uncompressed_file_offset;
149
+
150
+       /**
151
+        * \brief       Block number in this Stream
152
+        *
153
+        * The first Block is 1.
154
+        */
155
+       lzma_vli number_in_stream;
156
+
157
+       /**
158
+        * \brief       Compressed start offset of this Block
159
+        *
160
+        * This offset is relative to the beginning of the Stream
161
+        * containing this Block.
162
+        */
163
+       lzma_vli compressed_stream_offset;
164
+
165
+       /**
166
+        * \brief       Uncompressed start offset of this Block
167
+        *
168
+        * This offset is relative to the beginning of the Stream
169
+        * containing this Block.
170
+        */
171
+       lzma_vli uncompressed_stream_offset;
172
+
173
+       /**
174
+        * \brief       Uncompressed size of this Block
175
+        *
176
+        * You should pass this to the Block decoder if you will
177
+        * decode this Block. It will allow the Block decoder to
178
+        * validate the uncompressed size.
179
+        */
180
+       lzma_vli uncompressed_size;
181
+
182
+       /**
183
+        * \brief       Unpadded size of this Block
184
+        *
185
+        * You should pass this to the Block decoder if you will
186
+        * decode this Block. It will allow the Block decoder to
187
+        * validate the unpadded size.
188
+        */
189
+       lzma_vli unpadded_size;
190
+
191
+       /**
192
+        * \brief       Total compressed size
193
+        *
194
+        * This includes all headers and padding in this Block.
195
+        * This is useful if you need to know how many bytes
196
+        * the Block decoder will actually read.
197
+        */
198
+       lzma_vli total_size;
199
+
200
+       lzma_vli reserved_vli1;
201
+       lzma_vli reserved_vli2;
202
+       lzma_vli reserved_vli3;
203
+       lzma_vli reserved_vli4;
204
+
205
+       const void *reserved_ptr1;
206
+       const void *reserved_ptr2;
207
+       const void *reserved_ptr3;
208
+       const void *reserved_ptr4;
209
+   } block;
210
+
211
+   /*
212
+    * Internal data which is used to store the state of the iterator.
213
+    * The exact format may vary between liblzma versions, so don't
214
+    * touch these in any way.
215
+    */
216
+   union {
217
+       const void *p;
218
+       size_t s;
219
+       lzma_vli v;
220
+   } internal[6];
221
+} lzma_index_iter;
222
+
223
+
224
+/**
225
+ * \brief       Operation mode for lzma_index_iter_next()
226
+ */
227
+typedef enum {
228
+   LZMA_INDEX_ITER_ANY             = 0,
229
+       /**<
230
+        * \brief       Get the next Block or Stream
231
+        *
232
+        * Go to the next Block if the current Stream has at least
233
+        * one Block left. Otherwise go to the next Stream even if
234
+        * it has no Blocks. If the Stream has no Blocks
235
+        * (lzma_index_iter.stream.block_count == 0),
236
+        * lzma_index_iter.block will have undefined values.
237
+        */
238
+
239
+   LZMA_INDEX_ITER_STREAM          = 1,
240
+       /**<
241
+        * \brief       Get the next Stream
242
+        *
243
+        * Go to the next Stream even if the current Stream has
244
+        * unread Blocks left. If the next Stream has at least one
245
+        * Block, the iterator will point to the first Block.
246
+        * If there are no Blocks, lzma_index_iter.block will have
247
+        * undefined values.
248
+        */
249
+
250
+   LZMA_INDEX_ITER_BLOCK           = 2,
251
+       /**<
252
+        * \brief       Get the next Block
253
+        *
254
+        * Go to the next Block if the current Stream has at least
255
+        * one Block left. If the current Stream has no Blocks left,
256
+        * the next Stream with at least one Block is located and
257
+        * the iterator will be made to point to the first Block of
258
+        * that Stream.
259
+        */
260
+
261
+   LZMA_INDEX_ITER_NONEMPTY_BLOCK  = 3
262
+       /**<
263
+        * \brief       Get the next non-empty Block
264
+        *
265
+        * This is like LZMA_INDEX_ITER_BLOCK except that it will
266
+        * skip Blocks whose Uncompressed Size is zero.
267
+        */
268
+
269
+} lzma_index_iter_mode;
270
+
271
+
272
+/**
273
+ * \brief       Calculate memory usage of lzma_index
274
+ *
275
+ * On disk, the size of the Index field depends on both the number of Records
276
+ * stored and how big values the Records store (due to variable-length integer
277
+ * encoding). When the Index is kept in lzma_index structure, the memory usage
278
+ * depends only on the number of Records/Blocks stored in the Index(es), and
279
+ * in case of concatenated lzma_indexes, the number of Streams. The size in
280
+ * RAM is almost always significantly bigger than in the encoded form on disk.
281
+ *
282
+ * This function calculates an approximate amount of memory needed hold
283
+ * the given number of Streams and Blocks in lzma_index structure. This
284
+ * value may vary between CPU architectures and also between liblzma versions
285
+ * if the internal implementation is modified.
286
+ */
287
+extern LZMA_API(uint64_t) lzma_index_memusage(
288
+       lzma_vli streams, lzma_vli blocks) lzma_nothrow;
289
+
290
+
291
+/**
292
+ * \brief       Calculate the memory usage of an existing lzma_index
293
+ *
294
+ * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),
295
+ * lzma_index_block_count(i)).
296
+ */
297
+extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)
298
+       lzma_nothrow;
299
+
300
+
301
+/**
302
+ * \brief       Allocate and initialize a new lzma_index structure
303
+ *
304
+ * \return      On success, a pointer to an empty initialized lzma_index is
305
+ *              returned. If allocation fails, NULL is returned.
306
+ */
307
+extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator)
308
+       lzma_nothrow;
309
+
310
+
311
+/**
312
+ * \brief       Deallocate lzma_index
313
+ *
314
+ * If i is NULL, this does nothing.
315
+ */
316
+extern LZMA_API(void) lzma_index_end(lzma_index *i, lzma_allocator *allocator)
317
+       lzma_nothrow;
318
+
319
+
320
+/**
321
+ * \brief       Add a new Block to lzma_index
322
+ *
323
+ * \param       i                 Pointer to a lzma_index structure
324
+ * \param       allocator         Pointer to lzma_allocator, or NULL to
325
+ *                                use malloc()
326
+ * \param       unpadded_size     Unpadded Size of a Block. This can be
327
+ *                                calculated with lzma_block_unpadded_size()
328
+ *                                after encoding or decoding the Block.
329
+ * \param       uncompressed_size Uncompressed Size of a Block. This can be
330
+ *                                taken directly from lzma_block structure
331
+ *                                after encoding or decoding the Block.
332
+ *
333
+ * Appending a new Block does not invalidate iterators. For example,
334
+ * if an iterator was pointing to the end of the lzma_index, after
335
+ * lzma_index_append() it is possible to read the next Block with
336
+ * an existing iterator.
337
+ *
338
+ * \return      - LZMA_OK
339
+ *              - LZMA_MEM_ERROR
340
+ *              - LZMA_DATA_ERROR: Compressed or uncompressed size of the
341
+ *                Stream or size of the Index field would grow too big.
342
+ *              - LZMA_PROG_ERROR
343
+ */
344
+extern LZMA_API(lzma_ret) lzma_index_append(
345
+       lzma_index *i, lzma_allocator *allocator,
346
+       lzma_vli unpadded_size, lzma_vli uncompressed_size)
347
+       lzma_nothrow lzma_attr_warn_unused_result;
348
+
349
+
350
+/**
351
+ * \brief       Set the Stream Flags
352
+ *
353
+ * Set the Stream Flags of the last (and typically the only) Stream
354
+ * in lzma_index. This can be useful when reading information from the
355
+ * lzma_index, because to decode Blocks, knowing the integrity check type
356
+ * is needed.
357
+ *
358
+ * The given Stream Flags are copied into internal preallocated structure
359
+ * in the lzma_index, thus the caller doesn't need to keep the *stream_flags
360
+ * available after calling this function.
361
+ *
362
+ * \return      - LZMA_OK
363
+ *              - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.
364
+ *              - LZMA_PROG_ERROR
365
+ */
366
+extern LZMA_API(lzma_ret) lzma_index_stream_flags(
367
+       lzma_index *i, const lzma_stream_flags *stream_flags)
368
+       lzma_nothrow lzma_attr_warn_unused_result;
369
+
370
+
371
+/**
372
+ * \brief       Get the types of integrity Checks
373
+ *
374
+ * If lzma_index_stream_flags() is used to set the Stream Flags for
375
+ * every Stream, lzma_index_checks() can be used to get a bitmask to
376
+ * indicate which Check types have been used. It can be useful e.g. if
377
+ * showing the Check types to the user.
378
+ *
379
+ * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.
380
+ */
381
+extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)
382
+       lzma_nothrow lzma_attr_pure;
383
+
384
+
385
+/**
386
+ * \brief       Set the amount of Stream Padding
387
+ *
388
+ * Set the amount of Stream Padding of the last (and typically the only)
389
+ * Stream in the lzma_index. This is needed when planning to do random-access
390
+ * reading within multiple concatenated Streams.
391
+ *
392
+ * By default, the amount of Stream Padding is assumed to be zero bytes.
393
+ *
394
+ * \return      - LZMA_OK
395
+ *              - LZMA_DATA_ERROR: The file size would grow too big.
396
+ *              - LZMA_PROG_ERROR
397
+ */
398
+extern LZMA_API(lzma_ret) lzma_index_stream_padding(
399
+       lzma_index *i, lzma_vli stream_padding)
400
+       lzma_nothrow lzma_attr_warn_unused_result;
401
+
402
+
403
+/**
404
+ * \brief       Get the number of Streams
405
+ */
406
+extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)
407
+       lzma_nothrow lzma_attr_pure;
408
+
409
+
410
+/**
411
+ * \brief       Get the number of Blocks
412
+ *
413
+ * This returns the total number of Blocks in lzma_index. To get number
414
+ * of Blocks in individual Streams, use lzma_index_iter.
415
+ */
416
+extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)
417
+       lzma_nothrow lzma_attr_pure;
418
+
419
+
420
+/**
421
+ * \brief       Get the size of the Index field as bytes
422
+ *
423
+ * This is needed to verify the Backward Size field in the Stream Footer.
424
+ */
425
+extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)
426
+       lzma_nothrow lzma_attr_pure;
427
+
428
+
429
+/**
430
+ * \brief       Get the total size of the Stream
431
+ *
432
+ * If multiple lzma_indexes have been combined, this works as if the Blocks
433
+ * were in a single Stream. This is useful if you are going to combine
434
+ * Blocks from multiple Streams into a single new Stream.
435
+ */
436
+extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)
437
+       lzma_nothrow lzma_attr_pure;
438
+
439
+
440
+/**
441
+ * \brief       Get the total size of the Blocks
442
+ *
443
+ * This doesn't include the Stream Header, Stream Footer, Stream Padding,
444
+ * or Index fields.
445
+ */
446
+extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)
447
+       lzma_nothrow lzma_attr_pure;
448
+
449
+
450
+/**
451
+ * \brief       Get the total size of the file
452
+ *
453
+ * When no lzma_indexes have been combined with lzma_index_cat() and there is
454
+ * no Stream Padding, this function is identical to lzma_index_stream_size().
455
+ * If multiple lzma_indexes have been combined, this includes also the headers
456
+ * of each separate Stream and the possible Stream Padding fields.
457
+ */
458
+extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)
459
+       lzma_nothrow lzma_attr_pure;
460
+
461
+
462
+/**
463
+ * \brief       Get the uncompressed size of the file
464
+ */
465
+extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)
466
+       lzma_nothrow lzma_attr_pure;
467
+
468
+
469
+/**
470
+ * \brief       Initialize an iterator
471
+ *
472
+ * \param       iter    Pointer to a lzma_index_iter structure
473
+ * \param       i       lzma_index to which the iterator will be associated
474
+ *
475
+ * This function associates the iterator with the given lzma_index, and calls
476
+ * lzma_index_iter_rewind() on the iterator.
477
+ *
478
+ * This function doesn't allocate any memory, thus there is no
479
+ * lzma_index_iter_end(). The iterator is valid as long as the
480
+ * associated lzma_index is valid, that is, until lzma_index_end() or
481
+ * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't
482
+ * become invalid if new Blocks are added to it with lzma_index_append() or
483
+ * if it is used as the destination in lzma_index_cat().
484
+ *
485
+ * It is safe to make copies of an initialized lzma_index_iter, for example,
486
+ * to easily restart reading at some particular position.
487
+ */
488
+extern LZMA_API(void) lzma_index_iter_init(
489
+       lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;
490
+
491
+
492
+/**
493
+ * \brief       Rewind the iterator
494
+ *
495
+ * Rewind the iterator so that next call to lzma_index_iter_next() will
496
+ * return the first Block or Stream.
497
+ */
498
+extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)
499
+       lzma_nothrow;
500
+
501
+
502
+/**
503
+ * \brief       Get the next Block or Stream
504
+ *
505
+ * \param       iter    Iterator initialized with lzma_index_iter_init()
506
+ * \param       mode    Specify what kind of information the caller wants
507
+ *                      to get. See lzma_index_iter_mode for details.
508
+ *
509
+ * \return      If next Block or Stream matching the mode was found, *iter
510
+ *              is updated and this function returns false. If no Block or
511
+ *              Stream matching the mode is found, *iter is not modified
512
+ *              and this function returns true. If mode is set to an unknown
513
+ *              value, *iter is not modified and this function returns true.
514
+ */
515
+extern LZMA_API(lzma_bool) lzma_index_iter_next(
516
+       lzma_index_iter *iter, lzma_index_iter_mode mode)
517
+       lzma_nothrow lzma_attr_warn_unused_result;
518
+
519
+
520
+/**
521
+ * \brief       Locate a Block
522
+ *
523
+ * If it is possible to seek in the .xz file, it is possible to parse
524
+ * the Index field(s) and use lzma_index_iter_locate() to do random-access
525
+ * reading with granularity of Block size.
526
+ *
527
+ * \param       iter    Iterator that was earlier initialized with
528
+ *                      lzma_index_iter_init().
529
+ * \param       target  Uncompressed target offset which the caller would
530
+ *                      like to locate from the Stream
531
+ *
532
+ * If the target is smaller than the uncompressed size of the Stream (can be
533
+ * checked with lzma_index_uncompressed_size()):
534
+ *  - Information about the Stream and Block containing the requested
535
+ *    uncompressed offset is stored into *iter.
536
+ *  - Internal state of the iterator is adjusted so that
537
+ *    lzma_index_iter_next() can be used to read subsequent Blocks or Streams.
538
+ *  - This function returns false.
539
+ *
540
+ * If target is greater than the uncompressed size of the Stream, *iter
541
+ * is not modified, and this function returns true.
542
+ */
543
+extern LZMA_API(lzma_bool) lzma_index_iter_locate(
544
+       lzma_index_iter *iter, lzma_vli target) lzma_nothrow;
545
+
546
+
547
+/**
548
+ * \brief       Concatenate lzma_indexes
549
+ *
550
+ * Concatenating lzma_indexes is useful when doing random-access reading in
551
+ * multi-Stream .xz file, or when combining multiple Streams into single
552
+ * Stream.
553
+ *
554
+ * \param       dest      lzma_index after which src is appended
555
+ * \param       src       lzma_index to be appended after dest. If this
556
+ *                        function succeeds, the memory allocated for src
557
+ *                        is freed or moved to be part of dest, and all
558
+ *                        iterators pointing to src will become invalid.
559
+ * \param       allocator Custom memory allocator; can be NULL to use
560
+ *                        malloc() and free().
561
+ *
562
+ * \return      - LZMA_OK: lzma_indexes were concatenated successfully.
563
+ *                src is now a dangling pointer.
564
+ *              - LZMA_DATA_ERROR: *dest would grow too big.
565
+ *              - LZMA_MEM_ERROR
566
+ *              - LZMA_PROG_ERROR
567
+ */
568
+extern LZMA_API(lzma_ret) lzma_index_cat(
569
+       lzma_index *dest, lzma_index *src, lzma_allocator *allocator)
570
+       lzma_nothrow lzma_attr_warn_unused_result;
571
+
572
+
573
+/**
574
+ * \brief       Duplicate lzma_index
575
+ *
576
+ * \return      A copy of the lzma_index, or NULL if memory allocation failed.
577
+ */
578
+extern LZMA_API(lzma_index *) lzma_index_dup(
579
+       const lzma_index *i, lzma_allocator *allocator)
580
+       lzma_nothrow lzma_attr_warn_unused_result;
581
+
582
+
583
+/**
584
+ * \brief       Initialize .xz Index encoder
585
+ *
586
+ * \param       strm        Pointer to properly prepared lzma_stream
587
+ * \param       i           Pointer to lzma_index which should be encoded.
588
+ *
589
+ * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
590
+ * It is enough to use only one of them (you can choose freely; use LZMA_RUN
591
+ * to support liblzma versions older than 5.0.0).
592
+ *
593
+ * \return      - LZMA_OK: Initialization succeeded, continue with lzma_code().
594
+ *              - LZMA_MEM_ERROR
595
+ *              - LZMA_PROG_ERROR
596
+ */
597
+extern LZMA_API(lzma_ret) lzma_index_encoder(
598
+       lzma_stream *strm, const lzma_index *i)
599
+       lzma_nothrow lzma_attr_warn_unused_result;
600
+
601
+
602
+/**
603
+ * \brief       Initialize .xz Index decoder
604
+ *
605
+ * \param       strm        Pointer to properly prepared lzma_stream
606
+ * \param       i           The decoded Index will be made available via
607
+ *                          this pointer. Initially this function will
608
+ *                          set *i to NULL (the old value is ignored). If
609
+ *                          decoding succeeds (lzma_code() returns
610
+ *                          LZMA_STREAM_END), *i will be set to point
611
+ *                          to a new lzma_index, which the application
612
+ *                          has to later free with lzma_index_end().
613
+ * \param       memlimit    How much memory the resulting lzma_index is
614
+ *                          allowed to require.
615
+ *
616
+ * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
617
+ * It is enough to use only one of them (you can choose freely; use LZMA_RUN
618
+ * to support liblzma versions older than 5.0.0).
619
+ *
620
+ * \return      - LZMA_OK: Initialization succeeded, continue with lzma_code().
621
+ *              - LZMA_MEM_ERROR
622
+ *              - LZMA_MEMLIMIT_ERROR
623
+ *              - LZMA_PROG_ERROR
624
+ */
625
+extern LZMA_API(lzma_ret) lzma_index_decoder(
626
+       lzma_stream *strm, lzma_index **i, uint64_t memlimit)
627
+       lzma_nothrow lzma_attr_warn_unused_result;
628
+
629
+
630
+/**
631
+ * \brief       Single-call .xz Index encoder
632
+ *
633
+ * \param       i         lzma_index to be encoded
634
+ * \param       out       Beginning of the output buffer
635
+ * \param       out_pos   The next byte will be written to out[*out_pos].
636
+ *                        *out_pos is updated only if encoding succeeds.
637
+ * \param       out_size  Size of the out buffer; the first byte into
638
+ *                        which no data is written to is out[out_size].
639
+ *
640
+ * \return      - LZMA_OK: Encoding was successful.
641
+ *              - LZMA_BUF_ERROR: Output buffer is too small. Use
642
+ *                lzma_index_size() to find out how much output
643
+ *                space is needed.
644
+ *              - LZMA_PROG_ERROR
645
+ *
646
+ * \note        This function doesn't take allocator argument since all
647
+ *              the internal data is allocated on stack.
648
+ */
649
+extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,
650
+       uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
651
+
652
+
653
+/**
654
+ * \brief       Single-call .xz Index decoder
655
+ *
656
+ * \param       i           If decoding succeeds, *i will point to a new
657
+ *                          lzma_index, which the application has to
658
+ *                          later free with lzma_index_end(). If an error
659
+ *                          occurs, *i will be NULL. The old value of *i
660
+ *                          is always ignored and thus doesn't need to be
661
+ *                          initialized by the caller.
662
+ * \param       memlimit    Pointer to how much memory the resulting
663
+ *                          lzma_index is allowed to require. The value
664
+ *                          pointed by this pointer is modified if and only
665
+ *                          if LZMA_MEMLIMIT_ERROR is returned.
666
+ * \param       allocator   Pointer to lzma_allocator, or NULL to use malloc()
667
+ * \param       in          Beginning of the input buffer
668
+ * \param       in_pos      The next byte will be read from in[*in_pos].
669
+ *                          *in_pos is updated only if decoding succeeds.
670
+ * \param       in_size     Size of the input buffer; the first byte that
671
+ *                          won't be read is in[in_size].
672
+ *
673
+ * \return      - LZMA_OK: Decoding was successful.
674
+ *              - LZMA_MEM_ERROR
675
+ *              - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
676
+ *                The minimum required memlimit value was stored to *memlimit.
677
+ *              - LZMA_DATA_ERROR
678
+ *              - LZMA_PROG_ERROR
679
+ */
680
+extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,
681
+       uint64_t *memlimit, lzma_allocator *allocator,
682
+       const uint8_t *in, size_t *in_pos, size_t in_size)
683
+       lzma_nothrow;
684
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/index_hash.h Added
109
 
1
@@ -0,0 +1,107 @@
2
+/**
3
+ * \file        lzma/index_hash.h
4
+ * \brief       Validate Index by using a hash function
5
+ *
6
+ * Hashing makes it possible to use constant amount of memory to validate
7
+ * Index of arbitrary size.
8
+ */
9
+
10
+/*
11
+ * Author: Lasse Collin
12
+ *
13
+ * This file has been put into the public domain.
14
+ * You can do whatever you want with this file.
15
+ *
16
+ * See ../lzma.h for information about liblzma as a whole.
17
+ */
18
+
19
+#ifndef LZMA_H_INTERNAL
20
+#  error Never include this file directly. Use <lzma.h> instead.
21
+#endif
22
+
23
+/**
24
+ * \brief       Opaque data type to hold the Index hash
25
+ */
26
+typedef struct lzma_index_hash_s lzma_index_hash;
27
+
28
+
29
+/**
30
+ * \brief       Allocate and initialize a new lzma_index_hash structure
31
+ *
32
+ * If index_hash is NULL, a new lzma_index_hash structure is allocated,
33
+ * initialized, and a pointer to it returned. If allocation fails, NULL
34
+ * is returned.
35
+ *
36
+ * If index_hash is non-NULL, it is reinitialized and the same pointer
37
+ * returned. In this case, return value cannot be NULL or a different
38
+ * pointer than the index_hash that was given as an argument.
39
+ */
40
+extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
41
+       lzma_index_hash *index_hash, lzma_allocator *allocator)
42
+       lzma_nothrow lzma_attr_warn_unused_result;
43
+
44
+
45
+/**
46
+ * \brief       Deallocate lzma_index_hash structure
47
+ */
48
+extern LZMA_API(void) lzma_index_hash_end(
49
+       lzma_index_hash *index_hash, lzma_allocator *allocator)
50
+       lzma_nothrow;
51
+
52
+
53
+/**
54
+ * \brief       Add a new Record to an Index hash
55
+ *
56
+ * \param       index             Pointer to a lzma_index_hash structure
57
+ * \param       unpadded_size     Unpadded Size of a Block
58
+ * \param       uncompressed_size Uncompressed Size of a Block
59
+ *
60
+ * \return      - LZMA_OK
61
+ *              - LZMA_DATA_ERROR: Compressed or uncompressed size of the
62
+ *                Stream or size of the Index field would grow too big.
63
+ *              - LZMA_PROG_ERROR: Invalid arguments or this function is being
64
+ *                used when lzma_index_hash_decode() has already been used.
65
+ */
66
+extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
67
+       lzma_vli unpadded_size, lzma_vli uncompressed_size)
68
+       lzma_nothrow lzma_attr_warn_unused_result;
69
+
70
+
71
+/**
72
+ * \brief       Decode and validate the Index field
73
+ *
74
+ * After telling the sizes of all Blocks with lzma_index_hash_append(),
75
+ * the actual Index field is decoded with this function. Specifically,
76
+ * once decoding of the Index field has been started, no more Records
77
+ * can be added using lzma_index_hash_append().
78
+ *
79
+ * This function doesn't use lzma_stream structure to pass the input data.
80
+ * Instead, the input buffer is specified using three arguments. This is
81
+ * because it matches better the internal APIs of liblzma.
82
+ *
83
+ * \param       index_hash      Pointer to a lzma_index_hash structure
84
+ * \param       in              Pointer to the beginning of the input buffer
85
+ * \param       in_pos          in[*in_pos] is the next byte to process
86
+ * \param       in_size         in[in_size] is the first byte not to process
87
+ *
88
+ * \return      - LZMA_OK: So far good, but more input is needed.
89
+ *              - LZMA_STREAM_END: Index decoded successfully and it matches
90
+ *                the Records given with lzma_index_hash_append().
91
+ *              - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
92
+ *                information given with lzma_index_hash_append().
93
+ *              - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
94
+ *              - LZMA_PROG_ERROR
95
+ */
96
+extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
97
+       const uint8_t *in, size_t *in_pos, size_t in_size)
98
+       lzma_nothrow lzma_attr_warn_unused_result;
99
+
100
+
101
+/**
102
+ * \brief       Get the size of the Index field as bytes
103
+ *
104
+ * This is needed to verify the Backward Size field in the Stream Footer.
105
+ */
106
+extern LZMA_API(lzma_vli) lzma_index_hash_size(
107
+       const lzma_index_hash *index_hash)
108
+       lzma_nothrow lzma_attr_pure;
109
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/lzma.h Added
422
 
1
@@ -0,0 +1,420 @@
2
+/**
3
+ * \file        lzma/lzma.h
4
+ * \brief       LZMA1 and LZMA2 filters
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       LZMA1 Filter ID
23
+ *
24
+ * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
25
+ * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
26
+ * accidentally using LZMA when they actually want LZMA2.
27
+ *
28
+ * LZMA1 shouldn't be used for new applications unless you _really_ know
29
+ * what you are doing. LZMA2 is almost always a better choice.
30
+ */
31
+#define LZMA_FILTER_LZMA1       LZMA_VLI_C(0x4000000000000001)
32
+
33
+/**
34
+ * \brief       LZMA2 Filter ID
35
+ *
36
+ * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
37
+ * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
38
+ * when trying to compress uncompressible data), possibility to change
39
+ * lc/lp/pb in the middle of encoding, and some other internal improvements.
40
+ */
41
+#define LZMA_FILTER_LZMA2       LZMA_VLI_C(0x21)
42
+
43
+
44
+/**
45
+ * \brief       Match finders
46
+ *
47
+ * Match finder has major effect on both speed and compression ratio.
48
+ * Usually hash chains are faster than binary trees.
49
+ *
50
+ * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
51
+ * choice, because binary trees get much higher compression ratio penalty
52
+ * with LZMA_SYNC_FLUSH.
53
+ *
54
+ * The memory usage formulas are only rough estimates, which are closest to
55
+ * reality when dict_size is a power of two. The formulas are  more complex
56
+ * in reality, and can also change a little between liblzma versions. Use
57
+ * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
58
+ */
59
+typedef enum {
60
+   LZMA_MF_HC3     = 0x03,
61
+       /**<
62
+        * \brief       Hash Chain with 2- and 3-byte hashing
63
+        *
64
+        * Minimum nice_len: 3
65
+        *
66
+        * Memory usage:
67
+        *  - dict_size <= 16 MiB: dict_size * 7.5
68
+        *  - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
69
+        */
70
+
71
+   LZMA_MF_HC4     = 0x04,
72
+       /**<
73
+        * \brief       Hash Chain with 2-, 3-, and 4-byte hashing
74
+        *
75
+        * Minimum nice_len: 4
76
+        *
77
+        * Memory usage:
78
+        *  - dict_size <= 32 MiB: dict_size * 7.5
79
+        *  - dict_size > 32 MiB: dict_size * 6.5
80
+        */
81
+
82
+   LZMA_MF_BT2     = 0x12,
83
+       /**<
84
+        * \brief       Binary Tree with 2-byte hashing
85
+        *
86
+        * Minimum nice_len: 2
87
+        *
88
+        * Memory usage: dict_size * 9.5
89
+        */
90
+
91
+   LZMA_MF_BT3     = 0x13,
92
+       /**<
93
+        * \brief       Binary Tree with 2- and 3-byte hashing
94
+        *
95
+        * Minimum nice_len: 3
96
+        *
97
+        * Memory usage:
98
+        *  - dict_size <= 16 MiB: dict_size * 11.5
99
+        *  - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
100
+        */
101
+
102
+   LZMA_MF_BT4     = 0x14
103
+       /**<
104
+        * \brief       Binary Tree with 2-, 3-, and 4-byte hashing
105
+        *
106
+        * Minimum nice_len: 4
107
+        *
108
+        * Memory usage:
109
+        *  - dict_size <= 32 MiB: dict_size * 11.5
110
+        *  - dict_size > 32 MiB: dict_size * 10.5
111
+        */
112
+} lzma_match_finder;
113
+
114
+
115
+/**
116
+ * \brief       Test if given match finder is supported
117
+ *
118
+ * Return true if the given match finder is supported by this liblzma build.
119
+ * Otherwise false is returned. It is safe to call this with a value that
120
+ * isn't listed in lzma_match_finder enumeration; the return value will be
121
+ * false.
122
+ *
123
+ * There is no way to list which match finders are available in this
124
+ * particular liblzma version and build. It would be useless, because
125
+ * a new match finder, which the application developer wasn't aware,
126
+ * could require giving additional options to the encoder that the older
127
+ * match finders don't need.
128
+ */
129
+extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
130
+       lzma_nothrow lzma_attr_const;
131
+
132
+
133
+/**
134
+ * \brief       Compression modes
135
+ *
136
+ * This selects the function used to analyze the data produced by the match
137
+ * finder.
138
+ */
139
+typedef enum {
140
+   LZMA_MODE_FAST = 1,
141
+       /**<
142
+        * \brief       Fast compression
143
+        *
144
+        * Fast mode is usually at its best when combined with
145
+        * a hash chain match finder.
146
+        */
147
+
148
+   LZMA_MODE_NORMAL = 2
149
+       /**<
150
+        * \brief       Normal compression
151
+        *
152
+        * This is usually notably slower than fast mode. Use this
153
+        * together with binary tree match finders to expose the
154
+        * full potential of the LZMA1 or LZMA2 encoder.
155
+        */
156
+} lzma_mode;
157
+
158
+
159
+/**
160
+ * \brief       Test if given compression mode is supported
161
+ *
162
+ * Return true if the given compression mode is supported by this liblzma
163
+ * build. Otherwise false is returned. It is safe to call this with a value
164
+ * that isn't listed in lzma_mode enumeration; the return value will be false.
165
+ *
166
+ * There is no way to list which modes are available in this particular
167
+ * liblzma version and build. It would be useless, because a new compression
168
+ * mode, which the application developer wasn't aware, could require giving
169
+ * additional options to the encoder that the older modes don't need.
170
+ */
171
+extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
172
+       lzma_nothrow lzma_attr_const;
173
+
174
+
175
+/**
176
+ * \brief       Options specific to the LZMA1 and LZMA2 filters
177
+ *
178
+ * Since LZMA1 and LZMA2 share most of the code, it's simplest to share
179
+ * the options structure too. For encoding, all but the reserved variables
180
+ * need to be initialized unless specifically mentioned otherwise.
181
+ * lzma_lzma_preset() can be used to get a good starting point.
182
+ *
183
+ * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
184
+ * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
185
+ */
186
+typedef struct {
187
+   /**
188
+    * \brief       Dictionary size in bytes
189
+    *
190
+    * Dictionary size indicates how many bytes of the recently processed
191
+    * uncompressed data is kept in memory. One method to reduce size of
192
+    * the uncompressed data is to store distance-length pairs, which
193
+    * indicate what data to repeat from the dictionary buffer. Thus,
194
+    * the bigger the dictionary, the better the compression ratio
195
+    * usually is.
196
+    *
197
+    * Maximum size of the dictionary depends on multiple things:
198
+    *  - Memory usage limit
199
+    *  - Available address space (not a problem on 64-bit systems)
200
+    *  - Selected match finder (encoder only)
201
+    *
202
+    * Currently the maximum dictionary size for encoding is 1.5 GiB
203
+    * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
204
+    * systems for certain match finder implementation reasons. In the
205
+    * future, there may be match finders that support bigger
206
+    * dictionaries.
207
+    *
208
+    * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
209
+    * UINT32_MAX), so increasing the maximum dictionary size of the
210
+    * encoder won't cause problems for old decoders.
211
+    *
212
+    * Because extremely small dictionaries sizes would have unneeded
213
+    * overhead in the decoder, the minimum dictionary size is 4096 bytes.
214
+    *
215
+    * \note        When decoding, too big dictionary does no other harm
216
+    *              than wasting memory.
217
+    */
218
+   uint32_t dict_size;
219
+#  define LZMA_DICT_SIZE_MIN       UINT32_C(4096)
220
+#  define LZMA_DICT_SIZE_DEFAULT   (UINT32_C(1) << 23)
221
+
222
+   /**
223
+    * \brief       Pointer to an initial dictionary
224
+    *
225
+    * It is possible to initialize the LZ77 history window using
226
+    * a preset dictionary. It is useful when compressing many
227
+    * similar, relatively small chunks of data independently from
228
+    * each other. The preset dictionary should contain typical
229
+    * strings that occur in the files being compressed. The most
230
+    * probable strings should be near the end of the preset dictionary.
231
+    *
232
+    * This feature should be used only in special situations. For
233
+    * now, it works correctly only with raw encoding and decoding.
234
+    * Currently none of the container formats supported by
235
+    * liblzma allow preset dictionary when decoding, thus if
236
+    * you create a .xz or .lzma file with preset dictionary, it
237
+    * cannot be decoded with the regular decoder functions. In the
238
+    * future, the .xz format will likely get support for preset
239
+    * dictionary though.
240
+    */
241
+   const uint8_t *preset_dict;
242
+
243
+   /**
244
+    * \brief       Size of the preset dictionary
245
+    *
246
+    * Specifies the size of the preset dictionary. If the size is
247
+    * bigger than dict_size, only the last dict_size bytes are
248
+    * processed.
249
+    *
250
+    * This variable is read only when preset_dict is not NULL.
251
+    * If preset_dict is not NULL but preset_dict_size is zero,
252
+    * no preset dictionary is used (identical to only setting
253
+    * preset_dict to NULL).
254
+    */
255
+   uint32_t preset_dict_size;
256
+
257
+   /**
258
+    * \brief       Number of literal context bits
259
+    *
260
+    * How many of the highest bits of the previous uncompressed
261
+    * eight-bit byte (also known as `literal') are taken into
262
+    * account when predicting the bits of the next literal.
263
+    *
264
+    * E.g. in typical English text, an upper-case letter is
265
+    * often followed by a lower-case letter, and a lower-case
266
+    * letter is usually followed by another lower-case letter.
267
+    * In the US-ASCII character set, the highest three bits are 010
268
+    * for upper-case letters and 011 for lower-case letters.
269
+    * When lc is at least 3, the literal coding can take advantage of
270
+    * this property in the uncompressed data.
271
+    *
272
+    * There is a limit that applies to literal context bits and literal
273
+    * position bits together: lc + lp <= 4. Without this limit the
274
+    * decoding could become very slow, which could have security related
275
+    * results in some cases like email servers doing virus scanning.
276
+    * This limit also simplifies the internal implementation in liblzma.
277
+    *
278
+    * There may be LZMA1 streams that have lc + lp > 4 (maximum possible
279
+    * lc would be 8). It is not possible to decode such streams with
280
+    * liblzma.
281
+    */
282
+   uint32_t lc;
283
+#  define LZMA_LCLP_MIN    0
284
+#  define LZMA_LCLP_MAX    4
285
+#  define LZMA_LC_DEFAULT  3
286
+
287
+   /**
288
+    * \brief       Number of literal position bits
289
+    *
290
+    * lp affects what kind of alignment in the uncompressed data is
291
+    * assumed when encoding literals. A literal is a single 8-bit byte.
292
+    * See pb below for more information about alignment.
293
+    */
294
+   uint32_t lp;
295
+#  define LZMA_LP_DEFAULT  0
296
+
297
+   /**
298
+    * \brief       Number of position bits
299
+    *
300
+    * pb affects what kind of alignment in the uncompressed data is
301
+    * assumed in general. The default means four-byte alignment
302
+    * (2^ pb =2^2=4), which is often a good choice when there's
303
+    * no better guess.
304
+    *
305
+    * When the aligment is known, setting pb accordingly may reduce
306
+    * the file size a little. E.g. with text files having one-byte
307
+    * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
308
+    * improve compression slightly. For UTF-16 text, pb=1 is a good
309
+    * choice. If the alignment is an odd number like 3 bytes, pb=0
310
+    * might be the best choice.
311
+    *
312
+    * Even though the assumed alignment can be adjusted with pb and
313
+    * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
314
+    * It might be worth taking into account when designing file formats
315
+    * that are likely to be often compressed with LZMA1 or LZMA2.
316
+    */
317
+   uint32_t pb;
318
+#  define LZMA_PB_MIN      0
319
+#  define LZMA_PB_MAX      4
320
+#  define LZMA_PB_DEFAULT  2
321
+
322
+   /** Compression mode */
323
+   lzma_mode mode;
324
+
325
+   /**
326
+    * \brief       Nice length of a match
327
+    *
328
+    * This determines how many bytes the encoder compares from the match
329
+    * candidates when looking for the best match. Once a match of at
330
+    * least nice_len bytes long is found, the encoder stops looking for
331
+    * better candidates and encodes the match. (Naturally, if the found
332
+    * match is actually longer than nice_len, the actual length is
333
+    * encoded; it's not truncated to nice_len.)
334
+    *
335
+    * Bigger values usually increase the compression ratio and
336
+    * compression time. For most files, 32 to 128 is a good value,
337
+    * which gives very good compression ratio at good speed.
338
+    *
339
+    * The exact minimum value depends on the match finder. The maximum
340
+    * is 273, which is the maximum length of a match that LZMA1 and
341
+    * LZMA2 can encode.
342
+    */
343
+   uint32_t nice_len;
344
+
345
+   /** Match finder ID */
346
+   lzma_match_finder mf;
347
+
348
+   /**
349
+    * \brief       Maximum search depth in the match finder
350
+    *
351
+    * For every input byte, match finder searches through the hash chain
352
+    * or binary tree in a loop, each iteration going one step deeper in
353
+    * the chain or tree. The searching stops if
354
+    *  - a match of at least nice_len bytes long is found;
355
+    *  - all match candidates from the hash chain or binary tree have
356
+    *    been checked; or
357
+    *  - maximum search depth is reached.
358
+    *
359
+    * Maximum search depth is needed to prevent the match finder from
360
+    * wasting too much time in case there are lots of short match
361
+    * candidates. On the other hand, stopping the search before all
362
+    * candidates have been checked can reduce compression ratio.
363
+    *
364
+    * Setting depth to zero tells liblzma to use an automatic default
365
+    * value, that depends on the selected match finder and nice_len.
366
+    * The default is in the range [4, 200] or so (it may vary between
367
+    * liblzma versions).
368
+    *
369
+    * Using a bigger depth value than the default can increase
370
+    * compression ratio in some cases. There is no strict maximum value,
371
+    * but high values (thousands or millions) should be used with care:
372
+    * the encoder could remain fast enough with typical input, but
373
+    * malicious input could cause the match finder to slow down
374
+    * dramatically, possibly creating a denial of service attack.
375
+    */
376
+   uint32_t depth;
377
+
378
+   /*
379
+    * Reserved space to allow possible future extensions without
380
+    * breaking the ABI. You should not touch these, because the names
381
+    * of these variables may change. These are and will never be used
382
+    * with the currently supported options, so it is safe to leave these
383
+    * uninitialized.
384
+    */
385
+   uint32_t reserved_int1;
386
+   uint32_t reserved_int2;
387
+   uint32_t reserved_int3;
388
+   uint32_t reserved_int4;
389
+   uint32_t reserved_int5;
390
+   uint32_t reserved_int6;
391
+   uint32_t reserved_int7;
392
+   uint32_t reserved_int8;
393
+   lzma_reserved_enum reserved_enum1;
394
+   lzma_reserved_enum reserved_enum2;
395
+   lzma_reserved_enum reserved_enum3;
396
+   lzma_reserved_enum reserved_enum4;
397
+   void *reserved_ptr1;
398
+   void *reserved_ptr2;
399
+
400
+} lzma_options_lzma;
401
+
402
+
403
+/**
404
+ * \brief       Set a compression preset to lzma_options_lzma structure
405
+ *
406
+ * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
407
+ * of the xz command line tool. In addition, it is possible to bitwise-or
408
+ * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
409
+ * The flags are defined in container.h, because the flags are used also
410
+ * with lzma_easy_encoder().
411
+ *
412
+ * The preset values are subject to changes between liblzma versions.
413
+ *
414
+ * This function is available only if LZMA1 or LZMA2 encoder has been enabled
415
+ * when building liblzma.
416
+ *
417
+ * \return      On success, false is returned. If the preset is not
418
+ *              supported, true is returned.
419
+ */
420
+extern LZMA_API(lzma_bool) lzma_lzma_preset(
421
+       lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
422
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/stream_flags.h Added
225
 
1
@@ -0,0 +1,223 @@
2
+/**
3
+ * \file        lzma/stream_flags.h
4
+ * \brief       .xz Stream Header and Stream Footer encoder and decoder
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/**
22
+ * \brief       Size of Stream Header and Stream Footer
23
+ *
24
+ * Stream Header and Stream Footer have the same size and they are not
25
+ * going to change even if a newer version of the .xz file format is
26
+ * developed in future.
27
+ */
28
+#define LZMA_STREAM_HEADER_SIZE 12
29
+
30
+
31
+/**
32
+ * \brief       Options for encoding/decoding Stream Header and Stream Footer
33
+ */
34
+typedef struct {
35
+   /**
36
+    * \brief       Stream Flags format version
37
+    *
38
+    * To prevent API and ABI breakages if new features are needed in
39
+    * Stream Header or Stream Footer, a version number is used to
40
+    * indicate which fields in this structure are in use. For now,
41
+    * version must always be zero. With non-zero version, the
42
+    * lzma_stream_header_encode() and lzma_stream_footer_encode()
43
+    * will return LZMA_OPTIONS_ERROR.
44
+    *
45
+    * lzma_stream_header_decode() and lzma_stream_footer_decode()
46
+    * will always set this to the lowest value that supports all the
47
+    * features indicated by the Stream Flags field. The application
48
+    * must check that the version number set by the decoding functions
49
+    * is supported by the application. Otherwise it is possible that
50
+    * the application will decode the Stream incorrectly.
51
+    */
52
+   uint32_t version;
53
+
54
+   /**
55
+    * \brief       Backward Size
56
+    *
57
+    * Backward Size must be a multiple of four bytes. In this Stream
58
+    * format version, Backward Size is the size of the Index field.
59
+    *
60
+    * Backward Size isn't actually part of the Stream Flags field, but
61
+    * it is convenient to include in this structure anyway. Backward
62
+    * Size is present only in the Stream Footer. There is no need to
63
+    * initialize backward_size when encoding Stream Header.
64
+    *
65
+    * lzma_stream_header_decode() always sets backward_size to
66
+    * LZMA_VLI_UNKNOWN so that it is convenient to use
67
+    * lzma_stream_flags_compare() when both Stream Header and Stream
68
+    * Footer have been decoded.
69
+    */
70
+   lzma_vli backward_size;
71
+#  define LZMA_BACKWARD_SIZE_MIN 4
72
+#  define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
73
+
74
+   /**
75
+    * \brief       Check ID
76
+    *
77
+    * This indicates the type of the integrity check calculated from
78
+    * uncompressed data.
79
+    */
80
+   lzma_check check;
81
+
82
+   /*
83
+    * Reserved space to allow possible future extensions without
84
+    * breaking the ABI. You should not touch these, because the
85
+    * names of these variables may change.
86
+    *
87
+    * (We will never be able to use all of these since Stream Flags
88
+    * is just two bytes plus Backward Size of four bytes. But it's
89
+    * nice to have the proper types when they are needed.)
90
+    */
91
+   lzma_reserved_enum reserved_enum1;
92
+   lzma_reserved_enum reserved_enum2;
93
+   lzma_reserved_enum reserved_enum3;
94
+   lzma_reserved_enum reserved_enum4;
95
+   lzma_bool reserved_bool1;
96
+   lzma_bool reserved_bool2;
97
+   lzma_bool reserved_bool3;
98
+   lzma_bool reserved_bool4;
99
+   lzma_bool reserved_bool5;
100
+   lzma_bool reserved_bool6;
101
+   lzma_bool reserved_bool7;
102
+   lzma_bool reserved_bool8;
103
+   uint32_t reserved_int1;
104
+   uint32_t reserved_int2;
105
+
106
+} lzma_stream_flags;
107
+
108
+
109
+/**
110
+ * \brief       Encode Stream Header
111
+ *
112
+ * \param       options     Stream Header options to be encoded.
113
+ *                          options->backward_size is ignored and doesn't
114
+ *                          need to be initialized.
115
+ * \param       out         Beginning of the output buffer of
116
+ *                          LZMA_STREAM_HEADER_SIZE bytes.
117
+ *
118
+ * \return      - LZMA_OK: Encoding was successful.
119
+ *              - LZMA_OPTIONS_ERROR: options->version is not supported by
120
+ *                this liblzma version.
121
+ *              - LZMA_PROG_ERROR: Invalid options.
122
+ */
123
+extern LZMA_API(lzma_ret) lzma_stream_header_encode(
124
+       const lzma_stream_flags *options, uint8_t *out)
125
+       lzma_nothrow lzma_attr_warn_unused_result;
126
+
127
+
128
+/**
129
+ * \brief       Encode Stream Footer
130
+ *
131
+ * \param       options     Stream Footer options to be encoded.
132
+ * \param       out         Beginning of the output buffer of
133
+ *                          LZMA_STREAM_HEADER_SIZE bytes.
134
+ *
135
+ * \return      - LZMA_OK: Encoding was successful.
136
+ *              - LZMA_OPTIONS_ERROR: options->version is not supported by
137
+ *                this liblzma version.
138
+ *              - LZMA_PROG_ERROR: Invalid options.
139
+ */
140
+extern LZMA_API(lzma_ret) lzma_stream_footer_encode(
141
+       const lzma_stream_flags *options, uint8_t *out)
142
+       lzma_nothrow lzma_attr_warn_unused_result;
143
+
144
+
145
+/**
146
+ * \brief       Decode Stream Header
147
+ *
148
+ * \param       options     Target for the decoded Stream Header options.
149
+ * \param       in          Beginning of the input buffer of
150
+ *                          LZMA_STREAM_HEADER_SIZE bytes.
151
+ *
152
+ * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to
153
+ * help comparing Stream Flags from Stream Header and Stream Footer with
154
+ * lzma_stream_flags_compare().
155
+ *
156
+ * \return      - LZMA_OK: Decoding was successful.
157
+ *              - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
158
+ *                buffer cannot be Stream Header.
159
+ *              - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header
160
+ *                is corrupt.
161
+ *              - LZMA_OPTIONS_ERROR: Unsupported options are present
162
+ *                in the header.
163
+ *
164
+ * \note        When decoding .xz files that contain multiple Streams, it may
165
+ *              make sense to print "file format not recognized" only if
166
+ *              decoding of the Stream Header of the _first_ Stream gives
167
+ *              LZMA_FORMAT_ERROR. If non-first Stream Header gives
168
+ *              LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is
169
+ *              probably more appropriate.
170
+ *
171
+ *              For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if
172
+ *              LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode()
173
+ *              when decoding non-first Stream.
174
+ */
175
+extern LZMA_API(lzma_ret) lzma_stream_header_decode(
176
+       lzma_stream_flags *options, const uint8_t *in)
177
+       lzma_nothrow lzma_attr_warn_unused_result;
178
+
179
+
180
+/**
181
+ * \brief       Decode Stream Footer
182
+ *
183
+ * \param       options     Target for the decoded Stream Header options.
184
+ * \param       in          Beginning of the input buffer of
185
+ *                          LZMA_STREAM_HEADER_SIZE bytes.
186
+ *
187
+ * \return      - LZMA_OK: Decoding was successful.
188
+ *              - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
189
+ *                buffer cannot be Stream Footer.
190
+ *              - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer
191
+ *                is corrupt.
192
+ *              - LZMA_OPTIONS_ERROR: Unsupported options are present
193
+ *                in Stream Footer.
194
+ *
195
+ * \note        If Stream Header was already decoded successfully, but
196
+ *              decoding Stream Footer returns LZMA_FORMAT_ERROR, the
197
+ *              application should probably report some other error message
198
+ *              than "file format not recognized", since the file more likely
199
+ *              is corrupt (possibly truncated). Stream decoder in liblzma
200
+ *              uses LZMA_DATA_ERROR in this situation.
201
+ */
202
+extern LZMA_API(lzma_ret) lzma_stream_footer_decode(
203
+       lzma_stream_flags *options, const uint8_t *in)
204
+       lzma_nothrow lzma_attr_warn_unused_result;
205
+
206
+
207
+/**
208
+ * \brief       Compare two lzma_stream_flags structures
209
+ *
210
+ * backward_size values are compared only if both are not
211
+ * LZMA_VLI_UNKNOWN.
212
+ *
213
+ * \return      - LZMA_OK: Both are equal. If either had backward_size set
214
+ *                to LZMA_VLI_UNKNOWN, backward_size values were not
215
+ *                compared or validated.
216
+ *              - LZMA_DATA_ERROR: The structures differ.
217
+ *              - LZMA_OPTIONS_ERROR: version in either structure is greater
218
+ *                than the maximum supported version (currently zero).
219
+ *              - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or
220
+ *                backward_size.
221
+ */
222
+extern LZMA_API(lzma_ret) lzma_stream_flags_compare(
223
+       const lzma_stream_flags *a, const lzma_stream_flags *b)
224
+       lzma_nothrow lzma_attr_pure;
225
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/version.h Added
123
 
1
@@ -0,0 +1,121 @@
2
+/**
3
+ * \file        lzma/version.h
4
+ * \brief       Version number
5
+ */
6
+
7
+/*
8
+ * Author: Lasse Collin
9
+ *
10
+ * This file has been put into the public domain.
11
+ * You can do whatever you want with this file.
12
+ *
13
+ * See ../lzma.h for information about liblzma as a whole.
14
+ */
15
+
16
+#ifndef LZMA_H_INTERNAL
17
+#  error Never include this file directly. Use <lzma.h> instead.
18
+#endif
19
+
20
+
21
+/*
22
+ * Version number split into components
23
+ */
24
+#define LZMA_VERSION_MAJOR 5
25
+#define LZMA_VERSION_MINOR 0
26
+#define LZMA_VERSION_PATCH 7
27
+#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
28
+
29
+#ifndef LZMA_VERSION_COMMIT
30
+#  define LZMA_VERSION_COMMIT ""
31
+#endif
32
+
33
+
34
+/*
35
+ * Map symbolic stability levels to integers.
36
+ */
37
+#define LZMA_VERSION_STABILITY_ALPHA 0
38
+#define LZMA_VERSION_STABILITY_BETA 1
39
+#define LZMA_VERSION_STABILITY_STABLE 2
40
+
41
+
42
+/**
43
+ * \brief       Compile-time version number
44
+ *
45
+ * The version number is of format xyyyzzzs where
46
+ *  - x = major
47
+ *  - yyy = minor
48
+ *  - zzz = revision
49
+ *  - s indicates stability: 0 = alpha, 1 = beta, 2 = stable
50
+ *
51
+ * The same xyyyzzz triplet is never reused with different stability levels.
52
+ * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta
53
+ * or 5.1.0 stable.
54
+ *
55
+ * \note        The version number of liblzma has nothing to with
56
+ *              the version number of Igor Pavlov's LZMA SDK.
57
+ */
58
+#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \
59
+       + LZMA_VERSION_MINOR * UINT32_C(10000) \
60
+       + LZMA_VERSION_PATCH * UINT32_C(10) \
61
+       + LZMA_VERSION_STABILITY)
62
+
63
+
64
+/*
65
+ * Macros to construct the compile-time version string
66
+ */
67
+#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA
68
+#  define LZMA_VERSION_STABILITY_STRING "alpha"
69
+#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA
70
+#  define LZMA_VERSION_STABILITY_STRING "beta"
71
+#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE
72
+#  define LZMA_VERSION_STABILITY_STRING ""
73
+#else
74
+#  error Incorrect LZMA_VERSION_STABILITY
75
+#endif
76
+
77
+#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \
78
+       #major "." #minor "." #patch stability commit
79
+
80
+#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \
81
+       LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit)
82
+
83
+
84
+/**
85
+ * \brief       Compile-time version as a string
86
+ *
87
+ * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable
88
+ * versions don't have any "stable" suffix). In future, a snapshot built
89
+ * from source code repository may include an additional suffix, for example
90
+ * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form
91
+ * in LZMA_VERSION macro.
92
+ */
93
+#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \
94
+       LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \
95
+       LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \
96
+       LZMA_VERSION_COMMIT)
97
+
98
+
99
+/* #ifndef is needed for use with windres (MinGW or Cygwin). */
100
+#ifndef LZMA_H_INTERNAL_RC
101
+
102
+/**
103
+ * \brief       Run-time version number as an integer
104
+ *
105
+ * Return the value of LZMA_VERSION macro at the compile time of liblzma.
106
+ * This allows the application to compare if it was built against the same,
107
+ * older, or newer version of liblzma that is currently running.
108
+ */
109
+extern LZMA_API(uint32_t) lzma_version_number(void)
110
+       lzma_nothrow lzma_attr_const;
111
+
112
+
113
+/**
114
+ * \brief       Run-time version as a string
115
+ *
116
+ * This function may be useful if you want to display which version of
117
+ * liblzma your application is currently using.
118
+ */
119
+extern LZMA_API(const char *) lzma_version_string(void)
120
+       lzma_nothrow lzma_attr_const;
121
+
122
+#endif
123
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/api/lzma/vli.h Added
168
 
1
@@ -0,0 +1,166 @@
2
+/**
3
+ * \file        lzma/vli.h
4
+ * \brief       Variable-length integer handling
5
+ *
6
+ * In the .xz format, most integers are encoded in a variable-length
7
+ * representation, which is sometimes called little endian base-128 encoding.
8
+ * This saves space when smaller values are more likely than bigger values.
9
+ *
10
+ * The encoding scheme encodes seven bits to every byte, using minimum
11
+ * number of bytes required to represent the given value. Encodings that use
12
+ * non-minimum number of bytes are invalid, thus every integer has exactly
13
+ * one encoded representation. The maximum number of bits in a VLI is 63,
14
+ * thus the vli argument must be less than or equal to UINT64_MAX / 2. You
15
+ * should use LZMA_VLI_MAX for clarity.
16
+ */
17
+
18
+/*
19
+ * Author: Lasse Collin
20
+ *
21
+ * This file has been put into the public domain.
22
+ * You can do whatever you want with this file.
23
+ *
24
+ * See ../lzma.h for information about liblzma as a whole.
25
+ */
26
+
27
+#ifndef LZMA_H_INTERNAL
28
+#  error Never include this file directly. Use <lzma.h> instead.
29
+#endif
30
+
31
+
32
+/**
33
+ * \brief       Maximum supported value of a variable-length integer
34
+ */
35
+#define LZMA_VLI_MAX (UINT64_MAX / 2)
36
+
37
+/**
38
+ * \brief       VLI value to denote that the value is unknown
39
+ */
40
+#define LZMA_VLI_UNKNOWN UINT64_MAX
41
+
42
+/**
43
+ * \brief       Maximum supported encoded length of variable length integers
44
+ */
45
+#define LZMA_VLI_BYTES_MAX 9
46
+
47
+/**
48
+ * \brief       VLI constant suffix
49
+ */
50
+#define LZMA_VLI_C(n) UINT64_C(n)
51
+
52
+
53
+/**
54
+ * \brief       Variable-length integer type
55
+ *
56
+ * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is
57
+ * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the
58
+ * underlaying integer type.
59
+ *
60
+ * lzma_vli will be uint64_t for the foreseeable future. If a bigger size
61
+ * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will
62
+ * not overflow lzma_vli. This simplifies integer overflow detection.
63
+ */
64
+typedef uint64_t lzma_vli;
65
+
66
+
67
+/**
68
+ * \brief       Validate a variable-length integer
69
+ *
70
+ * This is useful to test that application has given acceptable values
71
+ * for example in the uncompressed_size and compressed_size variables.
72
+ *
73
+ * \return      True if the integer is representable as VLI or if it
74
+ *              indicates unknown value.
75
+ */
76
+#define lzma_vli_is_valid(vli) \
77
+   ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN)
78
+
79
+
80
+/**
81
+ * \brief       Encode a variable-length integer
82
+ *
83
+ * This function has two modes: single-call and multi-call. Single-call mode
84
+ * encodes the whole integer at once; it is an error if the output buffer is
85
+ * too small. Multi-call mode saves the position in *vli_pos, and thus it is
86
+ * possible to continue encoding if the buffer becomes full before the whole
87
+ * integer has been encoded.
88
+ *
89
+ * \param       vli       Integer to be encoded
90
+ * \param       vli_pos   How many VLI-encoded bytes have already been written
91
+ *                        out. When starting to encode a new integer in
92
+ *                        multi-call mode, *vli_pos must be set to zero.
93
+ *                        To use single-call encoding, set vli_pos to NULL.
94
+ * \param       out       Beginning of the output buffer
95
+ * \param       out_pos   The next byte will be written to out[*out_pos].
96
+ * \param       out_size  Size of the out buffer; the first byte into
97
+ *                        which no data is written to is out[out_size].
98
+ *
99
+ * \return      Slightly different return values are used in multi-call and
100
+ *              single-call modes.
101
+ *
102
+ *              Single-call (vli_pos == NULL):
103
+ *              - LZMA_OK: Integer successfully encoded.
104
+ *              - LZMA_PROG_ERROR: Arguments are not sane. This can be due
105
+ *                to too little output space; single-call mode doesn't use
106
+ *                LZMA_BUF_ERROR, since the application should have checked
107
+ *                the encoded size with lzma_vli_size().
108
+ *
109
+ *              Multi-call (vli_pos != NULL):
110
+ *              - LZMA_OK: So far all OK, but the integer is not
111
+ *                completely written out yet.
112
+ *              - LZMA_STREAM_END: Integer successfully encoded.
113
+ *              - LZMA_BUF_ERROR: No output space was provided.
114
+ *              - LZMA_PROG_ERROR: Arguments are not sane.
115
+ */
116
+extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
117
+       uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
118
+
119
+
120
+/**
121
+ * \brief       Decode a variable-length integer
122
+ *
123
+ * Like lzma_vli_encode(), this function has single-call and multi-call modes.
124
+ *
125
+ * \param       vli       Pointer to decoded integer. The decoder will
126
+ *                        initialize it to zero when *vli_pos == 0, so
127
+ *                        application isn't required to initialize *vli.
128
+ * \param       vli_pos   How many bytes have already been decoded. When
129
+ *                        starting to decode a new integer in multi-call
130
+ *                        mode, *vli_pos must be initialized to zero. To
131
+ *                        use single-call decoding, set vli_pos to NULL.
132
+ * \param       in        Beginning of the input buffer
133
+ * \param       in_pos    The next byte will be read from in[*in_pos].
134
+ * \param       in_size   Size of the input buffer; the first byte that
135
+ *                        won't be read is in[in_size].
136
+ *
137
+ * \return      Slightly different return values are used in multi-call and
138
+ *              single-call modes.
139
+ *
140
+ *              Single-call (vli_pos == NULL):
141
+ *              - LZMA_OK: Integer successfully decoded.
142
+ *              - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting
143
+ *                the end of the input buffer before the whole integer was
144
+ *                decoded; providing no input at all will use LZMA_DATA_ERROR.
145
+ *              - LZMA_PROG_ERROR: Arguments are not sane.
146
+ *
147
+ *              Multi-call (vli_pos != NULL):
148
+ *              - LZMA_OK: So far all OK, but the integer is not
149
+ *                completely decoded yet.
150
+ *              - LZMA_STREAM_END: Integer successfully decoded.
151
+ *              - LZMA_DATA_ERROR: Integer is corrupt.
152
+ *              - LZMA_BUF_ERROR: No input was provided.
153
+ *              - LZMA_PROG_ERROR: Arguments are not sane.
154
+ */
155
+extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,
156
+       const uint8_t *in, size_t *in_pos, size_t in_size)
157
+       lzma_nothrow;
158
+
159
+
160
+/**
161
+ * \brief       Get the number of bytes required to encode a VLI
162
+ *
163
+ * \return      Number of bytes on success (1-9). If vli isn't valid,
164
+ *              zero is returned.
165
+ */
166
+extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli)
167
+       lzma_nothrow lzma_attr_pure;
168
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/Makefile.inc Added
53
 
1
@@ -0,0 +1,51 @@
2
+##
3
+## Author: Lasse Collin
4
+##
5
+## This file has been put into the public domain.
6
+## You can do whatever you want with this file.
7
+##
8
+
9
+EXTRA_DIST += \
10
+   check/crc32_tablegen.c \
11
+   check/crc64_tablegen.c
12
+
13
+liblzma_la_SOURCES += \
14
+   check/check.c \
15
+   check/check.h \
16
+   check/crc_macros.h
17
+
18
+if COND_CHECK_CRC32
19
+if COND_SMALL
20
+liblzma_la_SOURCES += check/crc32_small.c
21
+else
22
+liblzma_la_SOURCES += \
23
+   check/crc32_table.c \
24
+   check/crc32_table_le.h \
25
+   check/crc32_table_be.h
26
+if COND_ASM_X86
27
+liblzma_la_SOURCES += check/crc32_x86.S
28
+else
29
+liblzma_la_SOURCES += check/crc32_fast.c
30
+endif
31
+endif
32
+endif
33
+
34
+if COND_CHECK_CRC64
35
+if COND_SMALL
36
+liblzma_la_SOURCES += check/crc64_small.c
37
+else
38
+liblzma_la_SOURCES += \
39
+   check/crc64_table.c \
40
+   check/crc64_table_le.h \
41
+   check/crc64_table_be.h
42
+if COND_ASM_X86
43
+liblzma_la_SOURCES += check/crc64_x86.S
44
+else
45
+liblzma_la_SOURCES += check/crc64_fast.c
46
+endif
47
+endif
48
+endif
49
+
50
+if COND_CHECK_SHA256
51
+liblzma_la_SOURCES += check/sha256.c
52
+endif
53
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/check.c Added
176
 
1
@@ -0,0 +1,174 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       check.c
5
+/// \brief      Single API to access different integrity checks
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "check.h"
15
+
16
+
17
+extern LZMA_API(lzma_bool)
18
+lzma_check_is_supported(lzma_check type)
19
+{
20
+   if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
21
+       return false;
22
+
23
+   static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = {
24
+       true,   // LZMA_CHECK_NONE
25
+
26
+#ifdef HAVE_CHECK_CRC32
27
+       true,
28
+#else
29
+       false,
30
+#endif
31
+
32
+       false,  // Reserved
33
+       false,  // Reserved
34
+
35
+#ifdef HAVE_CHECK_CRC64
36
+       true,
37
+#else
38
+       false,
39
+#endif
40
+
41
+       false,  // Reserved
42
+       false,  // Reserved
43
+       false,  // Reserved
44
+       false,  // Reserved
45
+       false,  // Reserved
46
+
47
+#ifdef HAVE_CHECK_SHA256
48
+       true,
49
+#else
50
+       false,
51
+#endif
52
+
53
+       false,  // Reserved
54
+       false,  // Reserved
55
+       false,  // Reserved
56
+       false,  // Reserved
57
+       false,  // Reserved
58
+   };
59
+
60
+   return available_checks[(unsigned int)(type)];
61
+}
62
+
63
+
64
+extern LZMA_API(uint32_t)
65
+lzma_check_size(lzma_check type)
66
+{
67
+   if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
68
+       return UINT32_MAX;
69
+
70
+   // See file-format.txt section 2.1.1.2.
71
+   static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = {
72
+       0,
73
+       4, 4, 4,
74
+       8, 8, 8,
75
+       16, 16, 16,
76
+       32, 32, 32,
77
+       64, 64, 64
78
+   };
79
+
80
+   return check_sizes[(unsigned int)(type)];
81
+}
82
+
83
+
84
+extern void
85
+lzma_check_init(lzma_check_state *check, lzma_check type)
86
+{
87
+   switch (type) {
88
+   case LZMA_CHECK_NONE:
89
+       break;
90
+
91
+#ifdef HAVE_CHECK_CRC32
92
+   case LZMA_CHECK_CRC32:
93
+       check->state.crc32 = 0;
94
+       break;
95
+#endif
96
+
97
+#ifdef HAVE_CHECK_CRC64
98
+   case LZMA_CHECK_CRC64:
99
+       check->state.crc64 = 0;
100
+       break;
101
+#endif
102
+
103
+#ifdef HAVE_CHECK_SHA256
104
+   case LZMA_CHECK_SHA256:
105
+       lzma_sha256_init(check);
106
+       break;
107
+#endif
108
+
109
+   default:
110
+       break;
111
+   }
112
+
113
+   return;
114
+}
115
+
116
+
117
+extern void
118
+lzma_check_update(lzma_check_state *check, lzma_check type,
119
+       const uint8_t *buf, size_t size)
120
+{
121
+   switch (type) {
122
+#ifdef HAVE_CHECK_CRC32
123
+   case LZMA_CHECK_CRC32:
124
+       check->state.crc32 = lzma_crc32(buf, size, check->state.crc32);
125
+       break;
126
+#endif
127
+
128
+#ifdef HAVE_CHECK_CRC64
129
+   case LZMA_CHECK_CRC64:
130
+       check->state.crc64 = lzma_crc64(buf, size, check->state.crc64);
131
+       break;
132
+#endif
133
+
134
+#ifdef HAVE_CHECK_SHA256
135
+   case LZMA_CHECK_SHA256:
136
+       lzma_sha256_update(buf, size, check);
137
+       break;
138
+#endif
139
+
140
+   default:
141
+       break;
142
+   }
143
+
144
+   return;
145
+}
146
+
147
+
148
+extern void
149
+lzma_check_finish(lzma_check_state *check, lzma_check type)
150
+{
151
+   switch (type) {
152
+#ifdef HAVE_CHECK_CRC32
153
+   case LZMA_CHECK_CRC32:
154
+       check->buffer.u32[0] = conv32le(check->state.crc32);
155
+       break;
156
+#endif
157
+
158
+#ifdef HAVE_CHECK_CRC64
159
+   case LZMA_CHECK_CRC64:
160
+       check->buffer.u64[0] = conv64le(check->state.crc64);
161
+       break;
162
+#endif
163
+
164
+#ifdef HAVE_CHECK_SHA256
165
+   case LZMA_CHECK_SHA256:
166
+       lzma_sha256_finish(check);
167
+       break;
168
+#endif
169
+
170
+   default:
171
+       break;
172
+   }
173
+
174
+   return;
175
+}
176
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/check.h Added
97
 
1
@@ -0,0 +1,95 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       check.h
5
+/// \brief      Internal API to different integrity check functions
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_CHECK_H
15
+#define LZMA_CHECK_H
16
+
17
+#include "common.h"
18
+
19
+
20
+// Index hashing needs the best possible hash function (preferably
21
+// a cryptographic hash) for maximum reliability.
22
+#if defined(HAVE_CHECK_SHA256)
23
+#  define LZMA_CHECK_BEST LZMA_CHECK_SHA256
24
+#elif defined(HAVE_CHECK_CRC64)
25
+#  define LZMA_CHECK_BEST LZMA_CHECK_CRC64
26
+#else
27
+#  define LZMA_CHECK_BEST LZMA_CHECK_CRC32
28
+#endif
29
+
30
+
31
+/// \brief      Structure to hold internal state of the check being calculated
32
+///
33
+/// \note       This is not in the public API because this structure may
34
+///             change in future if new integrity check algorithms are added.
35
+typedef struct {
36
+   /// Buffer to hold the final result and a temporary buffer for SHA256.
37
+   union {
38
+       uint8_t u8[64];
39
+       uint32_t u32[16];
40
+       uint64_t u64[8];
41
+   } buffer;
42
+
43
+   /// Check-specific data
44
+   union {
45
+       uint32_t crc32;
46
+       uint64_t crc64;
47
+
48
+       struct {
49
+           /// Internal state
50
+           uint32_t state[8];
51
+
52
+           /// Size of the message excluding padding
53
+           uint64_t size;
54
+       } sha256;
55
+   } state;
56
+
57
+} lzma_check_state;
58
+
59
+
60
+/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep
61
+/// the array two-dimensional.
62
+#ifdef HAVE_SMALL
63
+extern uint32_t lzma_crc32_table[1][256];
64
+extern void lzma_crc32_init(void);
65
+#else
66
+extern const uint32_t lzma_crc32_table[8][256];
67
+extern const uint64_t lzma_crc64_table[4][256];
68
+#endif
69
+
70
+
71
+/// \brief      Initialize *check depending on type
72
+///
73
+/// \return     LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not
74
+///             supported by the current version or build of liblzma.
75
+///             LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX.
76
+extern void lzma_check_init(lzma_check_state *check, lzma_check type);
77
+
78
+/// Update the check state
79
+extern void lzma_check_update(lzma_check_state *check, lzma_check type,
80
+       const uint8_t *buf, size_t size);
81
+
82
+/// Finish the check calculation and store the result to check->buffer.u8.
83
+extern void lzma_check_finish(lzma_check_state *check, lzma_check type);
84
+
85
+
86
+/// Prepare SHA-256 state for new input.
87
+extern void lzma_sha256_init(lzma_check_state *check);
88
+
89
+/// Update the SHA-256 hash state
90
+extern void lzma_sha256_update(
91
+       const uint8_t *buf, size_t size, lzma_check_state *check);
92
+
93
+/// Finish the SHA-256 calculation and store the result to check->buffer.u8.
94
+extern void lzma_sha256_finish(lzma_check_state *check);
95
+
96
+#endif
97
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_fast.c Added
84
 
1
@@ -0,0 +1,82 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc32.c
5
+/// \brief      CRC32 calculation
6
+///
7
+/// Calculate the CRC32 using the slice-by-eight algorithm.
8
+/// It is explained in this document:
9
+/// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf
10
+/// The code in this file is not the same as in Intel's paper, but
11
+/// the basic principle is identical.
12
+//
13
+//  Author:     Lasse Collin
14
+//
15
+//  This file has been put into the public domain.
16
+//  You can do whatever you want with this file.
17
+//
18
+///////////////////////////////////////////////////////////////////////////////
19
+
20
+#include "check.h"
21
+#include "crc_macros.h"
22
+
23
+
24
+// If you make any changes, do some benchmarking! Seemingly unrelated
25
+// changes can very easily ruin the performance (and very probably is
26
+// very compiler dependent).
27
+extern LZMA_API(uint32_t)
28
+lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
29
+{
30
+   crc = ~crc;
31
+
32
+#ifdef WORDS_BIGENDIAN
33
+   crc = bswap32(crc);
34
+#endif
35
+
36
+   if (size > 8) {
37
+       // Fix the alignment, if needed. The if statement above
38
+       // ensures that this won't read past the end of buf[].
39
+       while ((uintptr_t)(buf) & 7) {
40
+           crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
41
+           --size;
42
+       }
43
+
44
+       // Calculate the position where to stop.
45
+       const uint8_t *const limit = buf + (size & ~(size_t)(7));
46
+
47
+       // Calculate how many bytes must be calculated separately
48
+       // before returning the result.
49
+       size &= (size_t)(7);
50
+
51
+       // Calculate the CRC32 using the slice-by-eight algorithm.
52
+       while (buf < limit) {
53
+           crc ^= *(const uint32_t *)(buf);
54
+           buf += 4;
55
+
56
+           crc = lzma_crc32_table[7][A(crc)]
57
+               ^ lzma_crc32_table[6][B(crc)]
58
+               ^ lzma_crc32_table[5][C(crc)]
59
+               ^ lzma_crc32_table[4][D(crc)];
60
+
61
+           const uint32_t tmp = *(const uint32_t *)(buf);
62
+           buf += 4;
63
+
64
+           // At least with some compilers, it is critical for
65
+           // performance, that the crc variable is XORed
66
+           // between the two table-lookup pairs.
67
+           crc = lzma_crc32_table[3][A(tmp)]
68
+               ^ lzma_crc32_table[2][B(tmp)]
69
+               ^ crc
70
+               ^ lzma_crc32_table[1][C(tmp)]
71
+               ^ lzma_crc32_table[0][D(tmp)];
72
+       }
73
+   }
74
+
75
+   while (size-- != 0)
76
+       crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
77
+
78
+#ifdef WORDS_BIGENDIAN
79
+   crc = bswap32(crc);
80
+#endif
81
+
82
+   return ~crc;
83
+}
84
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_small.c Added
63
 
1
@@ -0,0 +1,61 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc32_small.c
5
+/// \brief      CRC32 calculation (size-optimized)
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "check.h"
15
+
16
+
17
+uint32_t lzma_crc32_table[1][256];
18
+
19
+
20
+static void
21
+crc32_init(void)
22
+{
23
+   static const uint32_t poly32 = UINT32_C(0xEDB88320);
24
+
25
+   for (size_t b = 0; b < 256; ++b) {
26
+       uint32_t r = b;
27
+       for (size_t i = 0; i < 8; ++i) {
28
+           if (r & 1)
29
+               r = (r >> 1) ^ poly32;
30
+           else
31
+               r >>= 1;
32
+       }
33
+
34
+       lzma_crc32_table[0][b] = r;
35
+   }
36
+
37
+   return;
38
+}
39
+
40
+
41
+extern void
42
+lzma_crc32_init(void)
43
+{
44
+   mythread_once(crc32_init);
45
+   return;
46
+}
47
+
48
+
49
+extern LZMA_API(uint32_t)
50
+lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
51
+{
52
+   lzma_crc32_init();
53
+
54
+   crc = ~crc;
55
+
56
+   while (size != 0) {
57
+       crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
58
+       --size;
59
+   }
60
+
61
+   return ~crc;
62
+}
63
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_table.c Added
21
 
1
@@ -0,0 +1,19 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc32_table.c
5
+/// \brief      Precalculated CRC32 table with correct endianness
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+#ifdef WORDS_BIGENDIAN
17
+#  include "crc32_table_be.h"
18
+#else
19
+#  include "crc32_table_le.h"
20
+#endif
21
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_table_be.h Added
527
 
1
@@ -0,0 +1,525 @@
2
+/* This file has been automatically generated by crc32_tablegen.c. */
3
+
4
+const uint32_t lzma_crc32_table[8][256] = {
5
+   {
6
+       0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999,
7
+       0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E,
8
+       0x3288DB0E, 0xA4B8DC79, 0x1EE9D5E0, 0x88D9D297,
9
+       0x2B4CB609, 0xBD7CB17E, 0x072DB8E7, 0x911DBF90,
10
+       0x6410B71D, 0xF220B06A, 0x4871B9F3, 0xDE41BE84,
11
+       0x7DD4DA1A, 0xEBE4DD6D, 0x51B5D4F4, 0xC785D383,
12
+       0x56986C13, 0xC0A86B64, 0x7AF962FD, 0xECC9658A,
13
+       0x4F5C0114, 0xD96C0663, 0x633D0FFA, 0xF50D088D,
14
+       0xC8206E3B, 0x5E10694C, 0xE44160D5, 0x727167A2,
15
+       0xD1E4033C, 0x47D4044B, 0xFD850DD2, 0x6BB50AA5,
16
+       0xFAA8B535, 0x6C98B242, 0xD6C9BBDB, 0x40F9BCAC,
17
+       0xE36CD832, 0x755CDF45, 0xCF0DD6DC, 0x593DD1AB,
18
+       0xAC30D926, 0x3A00DE51, 0x8051D7C8, 0x1661D0BF,
19
+       0xB5F4B421, 0x23C4B356, 0x9995BACF, 0x0FA5BDB8,
20
+       0x9EB80228, 0x0888055F, 0xB2D90CC6, 0x24E90BB1,
21
+       0x877C6F2F, 0x114C6858, 0xAB1D61C1, 0x3D2D66B6,
22
+       0x9041DC76, 0x0671DB01, 0xBC20D298, 0x2A10D5EF,
23
+       0x8985B171, 0x1FB5B606, 0xA5E4BF9F, 0x33D4B8E8,
24
+       0xA2C90778, 0x34F9000F, 0x8EA80996, 0x18980EE1,
25
+       0xBB0D6A7F, 0x2D3D6D08, 0x976C6491, 0x015C63E6,
26
+       0xF4516B6B, 0x62616C1C, 0xD8306585, 0x4E0062F2,
27
+       0xED95066C, 0x7BA5011B, 0xC1F40882, 0x57C40FF5,
28
+       0xC6D9B065, 0x50E9B712, 0xEAB8BE8B, 0x7C88B9FC,
29
+       0xDF1DDD62, 0x492DDA15, 0xF37CD38C, 0x654CD4FB,
30
+       0x5861B24D, 0xCE51B53A, 0x7400BCA3, 0xE230BBD4,
31
+       0x41A5DF4A, 0xD795D83D, 0x6DC4D1A4, 0xFBF4D6D3,
32
+       0x6AE96943, 0xFCD96E34, 0x468867AD, 0xD0B860DA,
33
+       0x732D0444, 0xE51D0333, 0x5F4C0AAA, 0xC97C0DDD,
34
+       0x3C710550, 0xAA410227, 0x10100BBE, 0x86200CC9,
35
+       0x25B56857, 0xB3856F20, 0x09D466B9, 0x9FE461CE,
36
+       0x0EF9DE5E, 0x98C9D929, 0x2298D0B0, 0xB4A8D7C7,
37
+       0x173DB359, 0x810DB42E, 0x3B5CBDB7, 0xAD6CBAC0,
38
+       0x2083B8ED, 0xB6B3BF9A, 0x0CE2B603, 0x9AD2B174,
39
+       0x3947D5EA, 0xAF77D29D, 0x1526DB04, 0x8316DC73,
40
+       0x120B63E3, 0x843B6494, 0x3E6A6D0D, 0xA85A6A7A,
41
+       0x0BCF0EE4, 0x9DFF0993, 0x27AE000A, 0xB19E077D,
42
+       0x44930FF0, 0xD2A30887, 0x68F2011E, 0xFEC20669,
43
+       0x5D5762F7, 0xCB676580, 0x71366C19, 0xE7066B6E,
44
+       0x761BD4FE, 0xE02BD389, 0x5A7ADA10, 0xCC4ADD67,
45
+       0x6FDFB9F9, 0xF9EFBE8E, 0x43BEB717, 0xD58EB060,
46
+       0xE8A3D6D6, 0x7E93D1A1, 0xC4C2D838, 0x52F2DF4F,
47
+       0xF167BBD1, 0x6757BCA6, 0xDD06B53F, 0x4B36B248,
48
+       0xDA2B0DD8, 0x4C1B0AAF, 0xF64A0336, 0x607A0441,
49
+       0xC3EF60DF, 0x55DF67A8, 0xEF8E6E31, 0x79BE6946,
50
+       0x8CB361CB, 0x1A8366BC, 0xA0D26F25, 0x36E26852,
51
+       0x95770CCC, 0x03470BBB, 0xB9160222, 0x2F260555,
52
+       0xBE3BBAC5, 0x280BBDB2, 0x925AB42B, 0x046AB35C,
53
+       0xA7FFD7C2, 0x31CFD0B5, 0x8B9ED92C, 0x1DAEDE5B,
54
+       0xB0C2649B, 0x26F263EC, 0x9CA36A75, 0x0A936D02,
55
+       0xA906099C, 0x3F360EEB, 0x85670772, 0x13570005,
56
+       0x824ABF95, 0x147AB8E2, 0xAE2BB17B, 0x381BB60C,
57
+       0x9B8ED292, 0x0DBED5E5, 0xB7EFDC7C, 0x21DFDB0B,
58
+       0xD4D2D386, 0x42E2D4F1, 0xF8B3DD68, 0x6E83DA1F,
59
+       0xCD16BE81, 0x5B26B9F6, 0xE177B06F, 0x7747B718,
60
+       0xE65A0888, 0x706A0FFF, 0xCA3B0666, 0x5C0B0111,
61
+       0xFF9E658F, 0x69AE62F8, 0xD3FF6B61, 0x45CF6C16,
62
+       0x78E20AA0, 0xEED20DD7, 0x5483044E, 0xC2B30339,
63
+       0x612667A7, 0xF71660D0, 0x4D476949, 0xDB776E3E,
64
+       0x4A6AD1AE, 0xDC5AD6D9, 0x660BDF40, 0xF03BD837,
65
+       0x53AEBCA9, 0xC59EBBDE, 0x7FCFB247, 0xE9FFB530,
66
+       0x1CF2BDBD, 0x8AC2BACA, 0x3093B353, 0xA6A3B424,
67
+       0x0536D0BA, 0x9306D7CD, 0x2957DE54, 0xBF67D923,
68
+       0x2E7A66B3, 0xB84A61C4, 0x021B685D, 0x942B6F2A,
69
+       0x37BE0BB4, 0xA18E0CC3, 0x1BDF055A, 0x8DEF022D
70
+   }, {
71
+       0x00000000, 0x41311B19, 0x82623632, 0xC3532D2B,
72
+       0x04C56C64, 0x45F4777D, 0x86A75A56, 0xC796414F,
73
+       0x088AD9C8, 0x49BBC2D1, 0x8AE8EFFA, 0xCBD9F4E3,
74
+       0x0C4FB5AC, 0x4D7EAEB5, 0x8E2D839E, 0xCF1C9887,
75
+       0x5112C24A, 0x1023D953, 0xD370F478, 0x9241EF61,
76
+       0x55D7AE2E, 0x14E6B537, 0xD7B5981C, 0x96848305,
77
+       0x59981B82, 0x18A9009B, 0xDBFA2DB0, 0x9ACB36A9,
78
+       0x5D5D77E6, 0x1C6C6CFF, 0xDF3F41D4, 0x9E0E5ACD,
79
+       0xA2248495, 0xE3159F8C, 0x2046B2A7, 0x6177A9BE,
80
+       0xA6E1E8F1, 0xE7D0F3E8, 0x2483DEC3, 0x65B2C5DA,
81
+       0xAAAE5D5D, 0xEB9F4644, 0x28CC6B6F, 0x69FD7076,
82
+       0xAE6B3139, 0xEF5A2A20, 0x2C09070B, 0x6D381C12,
83
+       0xF33646DF, 0xB2075DC6, 0x715470ED, 0x30656BF4,
84
+       0xF7F32ABB, 0xB6C231A2, 0x75911C89, 0x34A00790,
85
+       0xFBBC9F17, 0xBA8D840E, 0x79DEA925, 0x38EFB23C,
86
+       0xFF79F373, 0xBE48E86A, 0x7D1BC541, 0x3C2ADE58,
87
+       0x054F79F0, 0x447E62E9, 0x872D4FC2, 0xC61C54DB,
88
+       0x018A1594, 0x40BB0E8D, 0x83E823A6, 0xC2D938BF,
89
+       0x0DC5A038, 0x4CF4BB21, 0x8FA7960A, 0xCE968D13,
90
+       0x0900CC5C, 0x4831D745, 0x8B62FA6E, 0xCA53E177,
91
+       0x545DBBBA, 0x156CA0A3, 0xD63F8D88, 0x970E9691,
92
+       0x5098D7DE, 0x11A9CCC7, 0xD2FAE1EC, 0x93CBFAF5,
93
+       0x5CD76272, 0x1DE6796B, 0xDEB55440, 0x9F844F59,
94
+       0x58120E16, 0x1923150F, 0xDA703824, 0x9B41233D,
95
+       0xA76BFD65, 0xE65AE67C, 0x2509CB57, 0x6438D04E,
96
+       0xA3AE9101, 0xE29F8A18, 0x21CCA733, 0x60FDBC2A,
97
+       0xAFE124AD, 0xEED03FB4, 0x2D83129F, 0x6CB20986,
98
+       0xAB2448C9, 0xEA1553D0, 0x29467EFB, 0x687765E2,
99
+       0xF6793F2F, 0xB7482436, 0x741B091D, 0x352A1204,
100
+       0xF2BC534B, 0xB38D4852, 0x70DE6579, 0x31EF7E60,
101
+       0xFEF3E6E7, 0xBFC2FDFE, 0x7C91D0D5, 0x3DA0CBCC,
102
+       0xFA368A83, 0xBB07919A, 0x7854BCB1, 0x3965A7A8,
103
+       0x4B98833B, 0x0AA99822, 0xC9FAB509, 0x88CBAE10,
104
+       0x4F5DEF5F, 0x0E6CF446, 0xCD3FD96D, 0x8C0EC274,
105
+       0x43125AF3, 0x022341EA, 0xC1706CC1, 0x804177D8,
106
+       0x47D73697, 0x06E62D8E, 0xC5B500A5, 0x84841BBC,
107
+       0x1A8A4171, 0x5BBB5A68, 0x98E87743, 0xD9D96C5A,
108
+       0x1E4F2D15, 0x5F7E360C, 0x9C2D1B27, 0xDD1C003E,
109
+       0x120098B9, 0x533183A0, 0x9062AE8B, 0xD153B592,
110
+       0x16C5F4DD, 0x57F4EFC4, 0x94A7C2EF, 0xD596D9F6,
111
+       0xE9BC07AE, 0xA88D1CB7, 0x6BDE319C, 0x2AEF2A85,
112
+       0xED796BCA, 0xAC4870D3, 0x6F1B5DF8, 0x2E2A46E1,
113
+       0xE136DE66, 0xA007C57F, 0x6354E854, 0x2265F34D,
114
+       0xE5F3B202, 0xA4C2A91B, 0x67918430, 0x26A09F29,
115
+       0xB8AEC5E4, 0xF99FDEFD, 0x3ACCF3D6, 0x7BFDE8CF,
116
+       0xBC6BA980, 0xFD5AB299, 0x3E099FB2, 0x7F3884AB,
117
+       0xB0241C2C, 0xF1150735, 0x32462A1E, 0x73773107,
118
+       0xB4E17048, 0xF5D06B51, 0x3683467A, 0x77B25D63,
119
+       0x4ED7FACB, 0x0FE6E1D2, 0xCCB5CCF9, 0x8D84D7E0,
120
+       0x4A1296AF, 0x0B238DB6, 0xC870A09D, 0x8941BB84,
121
+       0x465D2303, 0x076C381A, 0xC43F1531, 0x850E0E28,
122
+       0x42984F67, 0x03A9547E, 0xC0FA7955, 0x81CB624C,
123
+       0x1FC53881, 0x5EF42398, 0x9DA70EB3, 0xDC9615AA,
124
+       0x1B0054E5, 0x5A314FFC, 0x996262D7, 0xD85379CE,
125
+       0x174FE149, 0x567EFA50, 0x952DD77B, 0xD41CCC62,
126
+       0x138A8D2D, 0x52BB9634, 0x91E8BB1F, 0xD0D9A006,
127
+       0xECF37E5E, 0xADC26547, 0x6E91486C, 0x2FA05375,
128
+       0xE836123A, 0xA9070923, 0x6A542408, 0x2B653F11,
129
+       0xE479A796, 0xA548BC8F, 0x661B91A4, 0x272A8ABD,
130
+       0xE0BCCBF2, 0xA18DD0EB, 0x62DEFDC0, 0x23EFE6D9,
131
+       0xBDE1BC14, 0xFCD0A70D, 0x3F838A26, 0x7EB2913F,
132
+       0xB924D070, 0xF815CB69, 0x3B46E642, 0x7A77FD5B,
133
+       0xB56B65DC, 0xF45A7EC5, 0x370953EE, 0x763848F7,
134
+       0xB1AE09B8, 0xF09F12A1, 0x33CC3F8A, 0x72FD2493
135
+   }, {
136
+       0x00000000, 0x376AC201, 0x6ED48403, 0x59BE4602,
137
+       0xDCA80907, 0xEBC2CB06, 0xB27C8D04, 0x85164F05,
138
+       0xB851130E, 0x8F3BD10F, 0xD685970D, 0xE1EF550C,
139
+       0x64F91A09, 0x5393D808, 0x0A2D9E0A, 0x3D475C0B,
140
+       0x70A3261C, 0x47C9E41D, 0x1E77A21F, 0x291D601E,
141
+       0xAC0B2F1B, 0x9B61ED1A, 0xC2DFAB18, 0xF5B56919,
142
+       0xC8F23512, 0xFF98F713, 0xA626B111, 0x914C7310,
143
+       0x145A3C15, 0x2330FE14, 0x7A8EB816, 0x4DE47A17,
144
+       0xE0464D38, 0xD72C8F39, 0x8E92C93B, 0xB9F80B3A,
145
+       0x3CEE443F, 0x0B84863E, 0x523AC03C, 0x6550023D,
146
+       0x58175E36, 0x6F7D9C37, 0x36C3DA35, 0x01A91834,
147
+       0x84BF5731, 0xB3D59530, 0xEA6BD332, 0xDD011133,
148
+       0x90E56B24, 0xA78FA925, 0xFE31EF27, 0xC95B2D26,
149
+       0x4C4D6223, 0x7B27A022, 0x2299E620, 0x15F32421,
150
+       0x28B4782A, 0x1FDEBA2B, 0x4660FC29, 0x710A3E28,
151
+       0xF41C712D, 0xC376B32C, 0x9AC8F52E, 0xADA2372F,
152
+       0xC08D9A70, 0xF7E75871, 0xAE591E73, 0x9933DC72,
153
+       0x1C259377, 0x2B4F5176, 0x72F11774, 0x459BD575,
154
+       0x78DC897E, 0x4FB64B7F, 0x16080D7D, 0x2162CF7C,
155
+       0xA4748079, 0x931E4278, 0xCAA0047A, 0xFDCAC67B,
156
+       0xB02EBC6C, 0x87447E6D, 0xDEFA386F, 0xE990FA6E,
157
+       0x6C86B56B, 0x5BEC776A, 0x02523168, 0x3538F369,
158
+       0x087FAF62, 0x3F156D63, 0x66AB2B61, 0x51C1E960,
159
+       0xD4D7A665, 0xE3BD6464, 0xBA032266, 0x8D69E067,
160
+       0x20CBD748, 0x17A11549, 0x4E1F534B, 0x7975914A,
161
+       0xFC63DE4F, 0xCB091C4E, 0x92B75A4C, 0xA5DD984D,
162
+       0x989AC446, 0xAFF00647, 0xF64E4045, 0xC1248244,
163
+       0x4432CD41, 0x73580F40, 0x2AE64942, 0x1D8C8B43,
164
+       0x5068F154, 0x67023355, 0x3EBC7557, 0x09D6B756,
165
+       0x8CC0F853, 0xBBAA3A52, 0xE2147C50, 0xD57EBE51,
166
+       0xE839E25A, 0xDF53205B, 0x86ED6659, 0xB187A458,
167
+       0x3491EB5D, 0x03FB295C, 0x5A456F5E, 0x6D2FAD5F,
168
+       0x801B35E1, 0xB771F7E0, 0xEECFB1E2, 0xD9A573E3,
169
+       0x5CB33CE6, 0x6BD9FEE7, 0x3267B8E5, 0x050D7AE4,
170
+       0x384A26EF, 0x0F20E4EE, 0x569EA2EC, 0x61F460ED,
171
+       0xE4E22FE8, 0xD388EDE9, 0x8A36ABEB, 0xBD5C69EA,
172
+       0xF0B813FD, 0xC7D2D1FC, 0x9E6C97FE, 0xA90655FF,
173
+       0x2C101AFA, 0x1B7AD8FB, 0x42C49EF9, 0x75AE5CF8,
174
+       0x48E900F3, 0x7F83C2F2, 0x263D84F0, 0x115746F1,
175
+       0x944109F4, 0xA32BCBF5, 0xFA958DF7, 0xCDFF4FF6,
176
+       0x605D78D9, 0x5737BAD8, 0x0E89FCDA, 0x39E33EDB,
177
+       0xBCF571DE, 0x8B9FB3DF, 0xD221F5DD, 0xE54B37DC,
178
+       0xD80C6BD7, 0xEF66A9D6, 0xB6D8EFD4, 0x81B22DD5,
179
+       0x04A462D0, 0x33CEA0D1, 0x6A70E6D3, 0x5D1A24D2,
180
+       0x10FE5EC5, 0x27949CC4, 0x7E2ADAC6, 0x494018C7,
181
+       0xCC5657C2, 0xFB3C95C3, 0xA282D3C1, 0x95E811C0,
182
+       0xA8AF4DCB, 0x9FC58FCA, 0xC67BC9C8, 0xF1110BC9,
183
+       0x740744CC, 0x436D86CD, 0x1AD3C0CF, 0x2DB902CE,
184
+       0x4096AF91, 0x77FC6D90, 0x2E422B92, 0x1928E993,
185
+       0x9C3EA696, 0xAB546497, 0xF2EA2295, 0xC580E094,
186
+       0xF8C7BC9F, 0xCFAD7E9E, 0x9613389C, 0xA179FA9D,
187
+       0x246FB598, 0x13057799, 0x4ABB319B, 0x7DD1F39A,
188
+       0x3035898D, 0x075F4B8C, 0x5EE10D8E, 0x698BCF8F,
189
+       0xEC9D808A, 0xDBF7428B, 0x82490489, 0xB523C688,
190
+       0x88649A83, 0xBF0E5882, 0xE6B01E80, 0xD1DADC81,
191
+       0x54CC9384, 0x63A65185, 0x3A181787, 0x0D72D586,
192
+       0xA0D0E2A9, 0x97BA20A8, 0xCE0466AA, 0xF96EA4AB,
193
+       0x7C78EBAE, 0x4B1229AF, 0x12AC6FAD, 0x25C6ADAC,
194
+       0x1881F1A7, 0x2FEB33A6, 0x765575A4, 0x413FB7A5,
195
+       0xC429F8A0, 0xF3433AA1, 0xAAFD7CA3, 0x9D97BEA2,
196
+       0xD073C4B5, 0xE71906B4, 0xBEA740B6, 0x89CD82B7,
197
+       0x0CDBCDB2, 0x3BB10FB3, 0x620F49B1, 0x55658BB0,
198
+       0x6822D7BB, 0x5F4815BA, 0x06F653B8, 0x319C91B9,
199
+       0xB48ADEBC, 0x83E01CBD, 0xDA5E5ABF, 0xED3498BE
200
+   }, {
201
+       0x00000000, 0x6567BCB8, 0x8BC809AA, 0xEEAFB512,
202
+       0x5797628F, 0x32F0DE37, 0xDC5F6B25, 0xB938D79D,
203
+       0xEF28B4C5, 0x8A4F087D, 0x64E0BD6F, 0x018701D7,
204
+       0xB8BFD64A, 0xDDD86AF2, 0x3377DFE0, 0x56106358,
205
+       0x9F571950, 0xFA30A5E8, 0x149F10FA, 0x71F8AC42,
206
+       0xC8C07BDF, 0xADA7C767, 0x43087275, 0x266FCECD,
207
+       0x707FAD95, 0x1518112D, 0xFBB7A43F, 0x9ED01887,
208
+       0x27E8CF1A, 0x428F73A2, 0xAC20C6B0, 0xC9477A08,
209
+       0x3EAF32A0, 0x5BC88E18, 0xB5673B0A, 0xD00087B2,
210
+       0x6938502F, 0x0C5FEC97, 0xE2F05985, 0x8797E53D,
211
+       0xD1878665, 0xB4E03ADD, 0x5A4F8FCF, 0x3F283377,
212
+       0x8610E4EA, 0xE3775852, 0x0DD8ED40, 0x68BF51F8,
213
+       0xA1F82BF0, 0xC49F9748, 0x2A30225A, 0x4F579EE2,
214
+       0xF66F497F, 0x9308F5C7, 0x7DA740D5, 0x18C0FC6D,
215
+       0x4ED09F35, 0x2BB7238D, 0xC518969F, 0xA07F2A27,
216
+       0x1947FDBA, 0x7C204102, 0x928FF410, 0xF7E848A8,
217
+       0x3D58149B, 0x583FA823, 0xB6901D31, 0xD3F7A189,
218
+       0x6ACF7614, 0x0FA8CAAC, 0xE1077FBE, 0x8460C306,
219
+       0xD270A05E, 0xB7171CE6, 0x59B8A9F4, 0x3CDF154C,
220
+       0x85E7C2D1, 0xE0807E69, 0x0E2FCB7B, 0x6B4877C3,
221
+       0xA20F0DCB, 0xC768B173, 0x29C70461, 0x4CA0B8D9,
222
+       0xF5986F44, 0x90FFD3FC, 0x7E5066EE, 0x1B37DA56,
223
+       0x4D27B90E, 0x284005B6, 0xC6EFB0A4, 0xA3880C1C,
224
+       0x1AB0DB81, 0x7FD76739, 0x9178D22B, 0xF41F6E93,
225
+       0x03F7263B, 0x66909A83, 0x883F2F91, 0xED589329,
226
+       0x546044B4, 0x3107F80C, 0xDFA84D1E, 0xBACFF1A6,
227
+       0xECDF92FE, 0x89B82E46, 0x67179B54, 0x027027EC,
228
+       0xBB48F071, 0xDE2F4CC9, 0x3080F9DB, 0x55E74563,
229
+       0x9CA03F6B, 0xF9C783D3, 0x176836C1, 0x720F8A79,
230
+       0xCB375DE4, 0xAE50E15C, 0x40FF544E, 0x2598E8F6,
231
+       0x73888BAE, 0x16EF3716, 0xF8408204, 0x9D273EBC,
232
+       0x241FE921, 0x41785599, 0xAFD7E08B, 0xCAB05C33,
233
+       0x3BB659ED, 0x5ED1E555, 0xB07E5047, 0xD519ECFF,
234
+       0x6C213B62, 0x094687DA, 0xE7E932C8, 0x828E8E70,
235
+       0xD49EED28, 0xB1F95190, 0x5F56E482, 0x3A31583A,
236
+       0x83098FA7, 0xE66E331F, 0x08C1860D, 0x6DA63AB5,
237
+       0xA4E140BD, 0xC186FC05, 0x2F294917, 0x4A4EF5AF,
238
+       0xF3762232, 0x96119E8A, 0x78BE2B98, 0x1DD99720,
239
+       0x4BC9F478, 0x2EAE48C0, 0xC001FDD2, 0xA566416A,
240
+       0x1C5E96F7, 0x79392A4F, 0x97969F5D, 0xF2F123E5,
241
+       0x05196B4D, 0x607ED7F5, 0x8ED162E7, 0xEBB6DE5F,
242
+       0x528E09C2, 0x37E9B57A, 0xD9460068, 0xBC21BCD0,
243
+       0xEA31DF88, 0x8F566330, 0x61F9D622, 0x049E6A9A,
244
+       0xBDA6BD07, 0xD8C101BF, 0x366EB4AD, 0x53090815,
245
+       0x9A4E721D, 0xFF29CEA5, 0x11867BB7, 0x74E1C70F,
246
+       0xCDD91092, 0xA8BEAC2A, 0x46111938, 0x2376A580,
247
+       0x7566C6D8, 0x10017A60, 0xFEAECF72, 0x9BC973CA,
248
+       0x22F1A457, 0x479618EF, 0xA939ADFD, 0xCC5E1145,
249
+       0x06EE4D76, 0x6389F1CE, 0x8D2644DC, 0xE841F864,
250
+       0x51792FF9, 0x341E9341, 0xDAB12653, 0xBFD69AEB,
251
+       0xE9C6F9B3, 0x8CA1450B, 0x620EF019, 0x07694CA1,
252
+       0xBE519B3C, 0xDB362784, 0x35999296, 0x50FE2E2E,
253
+       0x99B95426, 0xFCDEE89E, 0x12715D8C, 0x7716E134,
254
+       0xCE2E36A9, 0xAB498A11, 0x45E63F03, 0x208183BB,
255
+       0x7691E0E3, 0x13F65C5B, 0xFD59E949, 0x983E55F1,
256
+       0x2106826C, 0x44613ED4, 0xAACE8BC6, 0xCFA9377E,
257
+       0x38417FD6, 0x5D26C36E, 0xB389767C, 0xD6EECAC4,
258
+       0x6FD61D59, 0x0AB1A1E1, 0xE41E14F3, 0x8179A84B,
259
+       0xD769CB13, 0xB20E77AB, 0x5CA1C2B9, 0x39C67E01,
260
+       0x80FEA99C, 0xE5991524, 0x0B36A036, 0x6E511C8E,
261
+       0xA7166686, 0xC271DA3E, 0x2CDE6F2C, 0x49B9D394,
262
+       0xF0810409, 0x95E6B8B1, 0x7B490DA3, 0x1E2EB11B,
263
+       0x483ED243, 0x2D596EFB, 0xC3F6DBE9, 0xA6916751,
264
+       0x1FA9B0CC, 0x7ACE0C74, 0x9461B966, 0xF10605DE
265
+   }, {
266
+       0x00000000, 0xB029603D, 0x6053C07A, 0xD07AA047,
267
+       0xC0A680F5, 0x708FE0C8, 0xA0F5408F, 0x10DC20B2,
268
+       0xC14B7030, 0x7162100D, 0xA118B04A, 0x1131D077,
269
+       0x01EDF0C5, 0xB1C490F8, 0x61BE30BF, 0xD1975082,
270
+       0x8297E060, 0x32BE805D, 0xE2C4201A, 0x52ED4027,
271
+       0x42316095, 0xF21800A8, 0x2262A0EF, 0x924BC0D2,
272
+       0x43DC9050, 0xF3F5F06D, 0x238F502A, 0x93A63017,
273
+       0x837A10A5, 0x33537098, 0xE329D0DF, 0x5300B0E2,
274
+       0x042FC1C1, 0xB406A1FC, 0x647C01BB, 0xD4556186,
275
+       0xC4894134, 0x74A02109, 0xA4DA814E, 0x14F3E173,
276
+       0xC564B1F1, 0x754DD1CC, 0xA537718B, 0x151E11B6,
277
+       0x05C23104, 0xB5EB5139, 0x6591F17E, 0xD5B89143,
278
+       0x86B821A1, 0x3691419C, 0xE6EBE1DB, 0x56C281E6,
279
+       0x461EA154, 0xF637C169, 0x264D612E, 0x96640113,
280
+       0x47F35191, 0xF7DA31AC, 0x27A091EB, 0x9789F1D6,
281
+       0x8755D164, 0x377CB159, 0xE706111E, 0x572F7123,
282
+       0x4958F358, 0xF9719365, 0x290B3322, 0x9922531F,
283
+       0x89FE73AD, 0x39D71390, 0xE9ADB3D7, 0x5984D3EA,
284
+       0x88138368, 0x383AE355, 0xE8404312, 0x5869232F,
285
+       0x48B5039D, 0xF89C63A0, 0x28E6C3E7, 0x98CFA3DA,
286
+       0xCBCF1338, 0x7BE67305, 0xAB9CD342, 0x1BB5B37F,
287
+       0x0B6993CD, 0xBB40F3F0, 0x6B3A53B7, 0xDB13338A,
288
+       0x0A846308, 0xBAAD0335, 0x6AD7A372, 0xDAFEC34F,
289
+       0xCA22E3FD, 0x7A0B83C0, 0xAA712387, 0x1A5843BA,
290
+       0x4D773299, 0xFD5E52A4, 0x2D24F2E3, 0x9D0D92DE,
291
+       0x8DD1B26C, 0x3DF8D251, 0xED827216, 0x5DAB122B,
292
+       0x8C3C42A9, 0x3C152294, 0xEC6F82D3, 0x5C46E2EE,
293
+       0x4C9AC25C, 0xFCB3A261, 0x2CC90226, 0x9CE0621B,
294
+       0xCFE0D2F9, 0x7FC9B2C4, 0xAFB31283, 0x1F9A72BE,
295
+       0x0F46520C, 0xBF6F3231, 0x6F159276, 0xDF3CF24B,
296
+       0x0EABA2C9, 0xBE82C2F4, 0x6EF862B3, 0xDED1028E,
297
+       0xCE0D223C, 0x7E244201, 0xAE5EE246, 0x1E77827B,
298
+       0x92B0E6B1, 0x2299868C, 0xF2E326CB, 0x42CA46F6,
299
+       0x52166644, 0xE23F0679, 0x3245A63E, 0x826CC603,
300
+       0x53FB9681, 0xE3D2F6BC, 0x33A856FB, 0x838136C6,
301
+       0x935D1674, 0x23747649, 0xF30ED60E, 0x4327B633,
302
+       0x102706D1, 0xA00E66EC, 0x7074C6AB, 0xC05DA696,
303
+       0xD0818624, 0x60A8E619, 0xB0D2465E, 0x00FB2663,
304
+       0xD16C76E1, 0x614516DC, 0xB13FB69B, 0x0116D6A6,
305
+       0x11CAF614, 0xA1E39629, 0x7199366E, 0xC1B05653,
306
+       0x969F2770, 0x26B6474D, 0xF6CCE70A, 0x46E58737,
307
+       0x5639A785, 0xE610C7B8, 0x366A67FF, 0x864307C2,
308
+       0x57D45740, 0xE7FD377D, 0x3787973A, 0x87AEF707,
309
+       0x9772D7B5, 0x275BB788, 0xF72117CF, 0x470877F2,
310
+       0x1408C710, 0xA421A72D, 0x745B076A, 0xC4726757,
311
+       0xD4AE47E5, 0x648727D8, 0xB4FD879F, 0x04D4E7A2,
312
+       0xD543B720, 0x656AD71D, 0xB510775A, 0x05391767,
313
+       0x15E537D5, 0xA5CC57E8, 0x75B6F7AF, 0xC59F9792,
314
+       0xDBE815E9, 0x6BC175D4, 0xBBBBD593, 0x0B92B5AE,
315
+       0x1B4E951C, 0xAB67F521, 0x7B1D5566, 0xCB34355B,
316
+       0x1AA365D9, 0xAA8A05E4, 0x7AF0A5A3, 0xCAD9C59E,
317
+       0xDA05E52C, 0x6A2C8511, 0xBA562556, 0x0A7F456B,
318
+       0x597FF589, 0xE95695B4, 0x392C35F3, 0x890555CE,
319
+       0x99D9757C, 0x29F01541, 0xF98AB506, 0x49A3D53B,
320
+       0x983485B9, 0x281DE584, 0xF86745C3, 0x484E25FE,
321
+       0x5892054C, 0xE8BB6571, 0x38C1C536, 0x88E8A50B,
322
+       0xDFC7D428, 0x6FEEB415, 0xBF941452, 0x0FBD746F,
323
+       0x1F6154DD, 0xAF4834E0, 0x7F3294A7, 0xCF1BF49A,
324
+       0x1E8CA418, 0xAEA5C425, 0x7EDF6462, 0xCEF6045F,
325
+       0xDE2A24ED, 0x6E0344D0, 0xBE79E497, 0x0E5084AA,
326
+       0x5D503448, 0xED795475, 0x3D03F432, 0x8D2A940F,
327
+       0x9DF6B4BD, 0x2DDFD480, 0xFDA574C7, 0x4D8C14FA,
328
+       0x9C1B4478, 0x2C322445, 0xFC488402, 0x4C61E43F,
329
+       0x5CBDC48D, 0xEC94A4B0, 0x3CEE04F7, 0x8CC764CA
330
+   }, {
331
+       0x00000000, 0xA5D35CCB, 0x0BA1C84D, 0xAE729486,
332
+       0x1642919B, 0xB391CD50, 0x1DE359D6, 0xB830051D,
333
+       0x6D8253EC, 0xC8510F27, 0x66239BA1, 0xC3F0C76A,
334
+       0x7BC0C277, 0xDE139EBC, 0x70610A3A, 0xD5B256F1,
335
+       0x9B02D603, 0x3ED18AC8, 0x90A31E4E, 0x35704285,
336
+       0x8D404798, 0x28931B53, 0x86E18FD5, 0x2332D31E,
337
+       0xF68085EF, 0x5353D924, 0xFD214DA2, 0x58F21169,
338
+       0xE0C21474, 0x451148BF, 0xEB63DC39, 0x4EB080F2,
339
+       0x3605AC07, 0x93D6F0CC, 0x3DA4644A, 0x98773881,
340
+       0x20473D9C, 0x85946157, 0x2BE6F5D1, 0x8E35A91A,
341
+       0x5B87FFEB, 0xFE54A320, 0x502637A6, 0xF5F56B6D,
342
+       0x4DC56E70, 0xE81632BB, 0x4664A63D, 0xE3B7FAF6,
343
+       0xAD077A04, 0x08D426CF, 0xA6A6B249, 0x0375EE82,
344
+       0xBB45EB9F, 0x1E96B754, 0xB0E423D2, 0x15377F19,
345
+       0xC08529E8, 0x65567523, 0xCB24E1A5, 0x6EF7BD6E,
346
+       0xD6C7B873, 0x7314E4B8, 0xDD66703E, 0x78B52CF5,
347
+       0x6C0A580F, 0xC9D904C4, 0x67AB9042, 0xC278CC89,
348
+       0x7A48C994, 0xDF9B955F, 0x71E901D9, 0xD43A5D12,
349
+       0x01880BE3, 0xA45B5728, 0x0A29C3AE, 0xAFFA9F65,
350
+       0x17CA9A78, 0xB219C6B3, 0x1C6B5235, 0xB9B80EFE,
351
+       0xF7088E0C, 0x52DBD2C7, 0xFCA94641, 0x597A1A8A,
352
+       0xE14A1F97, 0x4499435C, 0xEAEBD7DA, 0x4F388B11,
353
+       0x9A8ADDE0, 0x3F59812B, 0x912B15AD, 0x34F84966,
354
+       0x8CC84C7B, 0x291B10B0, 0x87698436, 0x22BAD8FD,
355
+       0x5A0FF408, 0xFFDCA8C3, 0x51AE3C45, 0xF47D608E,
356
+       0x4C4D6593, 0xE99E3958, 0x47ECADDE, 0xE23FF115,
357
+       0x378DA7E4, 0x925EFB2F, 0x3C2C6FA9, 0x99FF3362,
358
+       0x21CF367F, 0x841C6AB4, 0x2A6EFE32, 0x8FBDA2F9,
359
+       0xC10D220B, 0x64DE7EC0, 0xCAACEA46, 0x6F7FB68D,
360
+       0xD74FB390, 0x729CEF5B, 0xDCEE7BDD, 0x793D2716,
361
+       0xAC8F71E7, 0x095C2D2C, 0xA72EB9AA, 0x02FDE561,
362
+       0xBACDE07C, 0x1F1EBCB7, 0xB16C2831, 0x14BF74FA,
363
+       0xD814B01E, 0x7DC7ECD5, 0xD3B57853, 0x76662498,
364
+       0xCE562185, 0x6B857D4E, 0xC5F7E9C8, 0x6024B503,
365
+       0xB596E3F2, 0x1045BF39, 0xBE372BBF, 0x1BE47774,
366
+       0xA3D47269, 0x06072EA2, 0xA875BA24, 0x0DA6E6EF,
367
+       0x4316661D, 0xE6C53AD6, 0x48B7AE50, 0xED64F29B,
368
+       0x5554F786, 0xF087AB4D, 0x5EF53FCB, 0xFB266300,
369
+       0x2E9435F1, 0x8B47693A, 0x2535FDBC, 0x80E6A177,
370
+       0x38D6A46A, 0x9D05F8A1, 0x33776C27, 0x96A430EC,
371
+       0xEE111C19, 0x4BC240D2, 0xE5B0D454, 0x4063889F,
372
+       0xF8538D82, 0x5D80D149, 0xF3F245CF, 0x56211904,
373
+       0x83934FF5, 0x2640133E, 0x883287B8, 0x2DE1DB73,
374
+       0x95D1DE6E, 0x300282A5, 0x9E701623, 0x3BA34AE8,
375
+       0x7513CA1A, 0xD0C096D1, 0x7EB20257, 0xDB615E9C,
376
+       0x63515B81, 0xC682074A, 0x68F093CC, 0xCD23CF07,
377
+       0x189199F6, 0xBD42C53D, 0x133051BB, 0xB6E30D70,
378
+       0x0ED3086D, 0xAB0054A6, 0x0572C020, 0xA0A19CEB,
379
+       0xB41EE811, 0x11CDB4DA, 0xBFBF205C, 0x1A6C7C97,
380
+       0xA25C798A, 0x078F2541, 0xA9FDB1C7, 0x0C2EED0C,
381
+       0xD99CBBFD, 0x7C4FE736, 0xD23D73B0, 0x77EE2F7B,
382
+       0xCFDE2A66, 0x6A0D76AD, 0xC47FE22B, 0x61ACBEE0,
383
+       0x2F1C3E12, 0x8ACF62D9, 0x24BDF65F, 0x816EAA94,
384
+       0x395EAF89, 0x9C8DF342, 0x32FF67C4, 0x972C3B0F,
385
+       0x429E6DFE, 0xE74D3135, 0x493FA5B3, 0xECECF978,
386
+       0x54DCFC65, 0xF10FA0AE, 0x5F7D3428, 0xFAAE68E3,
387
+       0x821B4416, 0x27C818DD, 0x89BA8C5B, 0x2C69D090,
388
+       0x9459D58D, 0x318A8946, 0x9FF81DC0, 0x3A2B410B,
389
+       0xEF9917FA, 0x4A4A4B31, 0xE438DFB7, 0x41EB837C,
390
+       0xF9DB8661, 0x5C08DAAA, 0xF27A4E2C, 0x57A912E7,
391
+       0x19199215, 0xBCCACEDE, 0x12B85A58, 0xB76B0693,
392
+       0x0F5B038E, 0xAA885F45, 0x04FACBC3, 0xA1299708,
393
+       0x749BC1F9, 0xD1489D32, 0x7F3A09B4, 0xDAE9557F,
394
+       0x62D95062, 0xC70A0CA9, 0x6978982F, 0xCCABC4E4
395
+   }, {
396
+       0x00000000, 0xB40B77A6, 0x29119F97, 0x9D1AE831,
397
+       0x13244FF4, 0xA72F3852, 0x3A35D063, 0x8E3EA7C5,
398
+       0x674EEF33, 0xD3459895, 0x4E5F70A4, 0xFA540702,
399
+       0x746AA0C7, 0xC061D761, 0x5D7B3F50, 0xE97048F6,
400
+       0xCE9CDE67, 0x7A97A9C1, 0xE78D41F0, 0x53863656,
401
+       0xDDB89193, 0x69B3E635, 0xF4A90E04, 0x40A279A2,
402
+       0xA9D23154, 0x1DD946F2, 0x80C3AEC3, 0x34C8D965,
403
+       0xBAF67EA0, 0x0EFD0906, 0x93E7E137, 0x27EC9691,
404
+       0x9C39BDCF, 0x2832CA69, 0xB5282258, 0x012355FE,
405
+       0x8F1DF23B, 0x3B16859D, 0xA60C6DAC, 0x12071A0A,
406
+       0xFB7752FC, 0x4F7C255A, 0xD266CD6B, 0x666DBACD,
407
+       0xE8531D08, 0x5C586AAE, 0xC142829F, 0x7549F539,
408
+       0x52A563A8, 0xE6AE140E, 0x7BB4FC3F, 0xCFBF8B99,
409
+       0x41812C5C, 0xF58A5BFA, 0x6890B3CB, 0xDC9BC46D,
410
+       0x35EB8C9B, 0x81E0FB3D, 0x1CFA130C, 0xA8F164AA,
411
+       0x26CFC36F, 0x92C4B4C9, 0x0FDE5CF8, 0xBBD52B5E,
412
+       0x79750B44, 0xCD7E7CE2, 0x506494D3, 0xE46FE375,
413
+       0x6A5144B0, 0xDE5A3316, 0x4340DB27, 0xF74BAC81,
414
+       0x1E3BE477, 0xAA3093D1, 0x372A7BE0, 0x83210C46,
415
+       0x0D1FAB83, 0xB914DC25, 0x240E3414, 0x900543B2,
416
+       0xB7E9D523, 0x03E2A285, 0x9EF84AB4, 0x2AF33D12,
417
+       0xA4CD9AD7, 0x10C6ED71, 0x8DDC0540, 0x39D772E6,
418
+       0xD0A73A10, 0x64AC4DB6, 0xF9B6A587, 0x4DBDD221,
419
+       0xC38375E4, 0x77880242, 0xEA92EA73, 0x5E999DD5,
420
+       0xE54CB68B, 0x5147C12D, 0xCC5D291C, 0x78565EBA,
421
+       0xF668F97F, 0x42638ED9, 0xDF7966E8, 0x6B72114E,
422
+       0x820259B8, 0x36092E1E, 0xAB13C62F, 0x1F18B189,
423
+       0x9126164C, 0x252D61EA, 0xB83789DB, 0x0C3CFE7D,
424
+       0x2BD068EC, 0x9FDB1F4A, 0x02C1F77B, 0xB6CA80DD,
425
+       0x38F42718, 0x8CFF50BE, 0x11E5B88F, 0xA5EECF29,
426
+       0x4C9E87DF, 0xF895F079, 0x658F1848, 0xD1846FEE,
427
+       0x5FBAC82B, 0xEBB1BF8D, 0x76AB57BC, 0xC2A0201A,
428
+       0xF2EA1688, 0x46E1612E, 0xDBFB891F, 0x6FF0FEB9,
429
+       0xE1CE597C, 0x55C52EDA, 0xC8DFC6EB, 0x7CD4B14D,
430
+       0x95A4F9BB, 0x21AF8E1D, 0xBCB5662C, 0x08BE118A,
431
+       0x8680B64F, 0x328BC1E9, 0xAF9129D8, 0x1B9A5E7E,
432
+       0x3C76C8EF, 0x887DBF49, 0x15675778, 0xA16C20DE,
433
+       0x2F52871B, 0x9B59F0BD, 0x0643188C, 0xB2486F2A,
434
+       0x5B3827DC, 0xEF33507A, 0x7229B84B, 0xC622CFED,
435
+       0x481C6828, 0xFC171F8E, 0x610DF7BF, 0xD5068019,
436
+       0x6ED3AB47, 0xDAD8DCE1, 0x47C234D0, 0xF3C94376,
437
+       0x7DF7E4B3, 0xC9FC9315, 0x54E67B24, 0xE0ED0C82,
438
+       0x099D4474, 0xBD9633D2, 0x208CDBE3, 0x9487AC45,
439
+       0x1AB90B80, 0xAEB27C26, 0x33A89417, 0x87A3E3B1,
440
+       0xA04F7520, 0x14440286, 0x895EEAB7, 0x3D559D11,
441
+       0xB36B3AD4, 0x07604D72, 0x9A7AA543, 0x2E71D2E5,
442
+       0xC7019A13, 0x730AEDB5, 0xEE100584, 0x5A1B7222,
443
+       0xD425D5E7, 0x602EA241, 0xFD344A70, 0x493F3DD6,
444
+       0x8B9F1DCC, 0x3F946A6A, 0xA28E825B, 0x1685F5FD,
445
+       0x98BB5238, 0x2CB0259E, 0xB1AACDAF, 0x05A1BA09,
446
+       0xECD1F2FF, 0x58DA8559, 0xC5C06D68, 0x71CB1ACE,
447
+       0xFFF5BD0B, 0x4BFECAAD, 0xD6E4229C, 0x62EF553A,
448
+       0x4503C3AB, 0xF108B40D, 0x6C125C3C, 0xD8192B9A,
449
+       0x56278C5F, 0xE22CFBF9, 0x7F3613C8, 0xCB3D646E,
450
+       0x224D2C98, 0x96465B3E, 0x0B5CB30F, 0xBF57C4A9,
451
+       0x3169636C, 0x856214CA, 0x1878FCFB, 0xAC738B5D,
452
+       0x17A6A003, 0xA3ADD7A5, 0x3EB73F94, 0x8ABC4832,
453
+       0x0482EFF7, 0xB0899851, 0x2D937060, 0x999807C6,
454
+       0x70E84F30, 0xC4E33896, 0x59F9D0A7, 0xEDF2A701,
455
+       0x63CC00C4, 0xD7C77762, 0x4ADD9F53, 0xFED6E8F5,
456
+       0xD93A7E64, 0x6D3109C2, 0xF02BE1F3, 0x44209655,
457
+       0xCA1E3190, 0x7E154636, 0xE30FAE07, 0x5704D9A1,
458
+       0xBE749157, 0x0A7FE6F1, 0x97650EC0, 0x236E7966,
459
+       0xAD50DEA3, 0x195BA905, 0x84414134, 0x304A3692
460
+   }, {
461
+       0x00000000, 0x9E00AACC, 0x7D072542, 0xE3078F8E,
462
+       0xFA0E4A84, 0x640EE048, 0x87096FC6, 0x1909C50A,
463
+       0xB51BE5D3, 0x2B1B4F1F, 0xC81CC091, 0x561C6A5D,
464
+       0x4F15AF57, 0xD115059B, 0x32128A15, 0xAC1220D9,
465
+       0x2B31BB7C, 0xB53111B0, 0x56369E3E, 0xC83634F2,
466
+       0xD13FF1F8, 0x4F3F5B34, 0xAC38D4BA, 0x32387E76,
467
+       0x9E2A5EAF, 0x002AF463, 0xE32D7BED, 0x7D2DD121,
468
+       0x6424142B, 0xFA24BEE7, 0x19233169, 0x87239BA5,
469
+       0x566276F9, 0xC862DC35, 0x2B6553BB, 0xB565F977,
470
+       0xAC6C3C7D, 0x326C96B1, 0xD16B193F, 0x4F6BB3F3,
471
+       0xE379932A, 0x7D7939E6, 0x9E7EB668, 0x007E1CA4,
472
+       0x1977D9AE, 0x87777362, 0x6470FCEC, 0xFA705620,
473
+       0x7D53CD85, 0xE3536749, 0x0054E8C7, 0x9E54420B,
474
+       0x875D8701, 0x195D2DCD, 0xFA5AA243, 0x645A088F,
475
+       0xC8482856, 0x5648829A, 0xB54F0D14, 0x2B4FA7D8,
476
+       0x324662D2, 0xAC46C81E, 0x4F414790, 0xD141ED5C,
477
+       0xEDC29D29, 0x73C237E5, 0x90C5B86B, 0x0EC512A7,
478
+       0x17CCD7AD, 0x89CC7D61, 0x6ACBF2EF, 0xF4CB5823,
479
+       0x58D978FA, 0xC6D9D236, 0x25DE5DB8, 0xBBDEF774,
480
+       0xA2D7327E, 0x3CD798B2, 0xDFD0173C, 0x41D0BDF0,
481
+       0xC6F32655, 0x58F38C99, 0xBBF40317, 0x25F4A9DB,
482
+       0x3CFD6CD1, 0xA2FDC61D, 0x41FA4993, 0xDFFAE35F,
483
+       0x73E8C386, 0xEDE8694A, 0x0EEFE6C4, 0x90EF4C08,
484
+       0x89E68902, 0x17E623CE, 0xF4E1AC40, 0x6AE1068C,
485
+       0xBBA0EBD0, 0x25A0411C, 0xC6A7CE92, 0x58A7645E,
486
+       0x41AEA154, 0xDFAE0B98, 0x3CA98416, 0xA2A92EDA,
487
+       0x0EBB0E03, 0x90BBA4CF, 0x73BC2B41, 0xEDBC818D,
488
+       0xF4B54487, 0x6AB5EE4B, 0x89B261C5, 0x17B2CB09,
489
+       0x909150AC, 0x0E91FA60, 0xED9675EE, 0x7396DF22,
490
+       0x6A9F1A28, 0xF49FB0E4, 0x17983F6A, 0x899895A6,
491
+       0x258AB57F, 0xBB8A1FB3, 0x588D903D, 0xC68D3AF1,
492
+       0xDF84FFFB, 0x41845537, 0xA283DAB9, 0x3C837075,
493
+       0xDA853B53, 0x4485919F, 0xA7821E11, 0x3982B4DD,
494
+       0x208B71D7, 0xBE8BDB1B, 0x5D8C5495, 0xC38CFE59,
495
+       0x6F9EDE80, 0xF19E744C, 0x1299FBC2, 0x8C99510E,
496
+       0x95909404, 0x0B903EC8, 0xE897B146, 0x76971B8A,
497
+       0xF1B4802F, 0x6FB42AE3, 0x8CB3A56D, 0x12B30FA1,
498
+       0x0BBACAAB, 0x95BA6067, 0x76BDEFE9, 0xE8BD4525,
499
+       0x44AF65FC, 0xDAAFCF30, 0x39A840BE, 0xA7A8EA72,
500
+       0xBEA12F78, 0x20A185B4, 0xC3A60A3A, 0x5DA6A0F6,
501
+       0x8CE74DAA, 0x12E7E766, 0xF1E068E8, 0x6FE0C224,
502
+       0x76E9072E, 0xE8E9ADE2, 0x0BEE226C, 0x95EE88A0,
503
+       0x39FCA879, 0xA7FC02B5, 0x44FB8D3B, 0xDAFB27F7,
504
+       0xC3F2E2FD, 0x5DF24831, 0xBEF5C7BF, 0x20F56D73,
505
+       0xA7D6F6D6, 0x39D65C1A, 0xDAD1D394, 0x44D17958,
506
+       0x5DD8BC52, 0xC3D8169E, 0x20DF9910, 0xBEDF33DC,
507
+       0x12CD1305, 0x8CCDB9C9, 0x6FCA3647, 0xF1CA9C8B,
508
+       0xE8C35981, 0x76C3F34D, 0x95C47CC3, 0x0BC4D60F,
509
+       0x3747A67A, 0xA9470CB6, 0x4A408338, 0xD44029F4,
510
+       0xCD49ECFE, 0x53494632, 0xB04EC9BC, 0x2E4E6370,
511
+       0x825C43A9, 0x1C5CE965, 0xFF5B66EB, 0x615BCC27,
512
+       0x7852092D, 0xE652A3E1, 0x05552C6F, 0x9B5586A3,
513
+       0x1C761D06, 0x8276B7CA, 0x61713844, 0xFF719288,
514
+       0xE6785782, 0x7878FD4E, 0x9B7F72C0, 0x057FD80C,
515
+       0xA96DF8D5, 0x376D5219, 0xD46ADD97, 0x4A6A775B,
516
+       0x5363B251, 0xCD63189D, 0x2E649713, 0xB0643DDF,
517
+       0x6125D083, 0xFF257A4F, 0x1C22F5C1, 0x82225F0D,
518
+       0x9B2B9A07, 0x052B30CB, 0xE62CBF45, 0x782C1589,
519
+       0xD43E3550, 0x4A3E9F9C, 0xA9391012, 0x3739BADE,
520
+       0x2E307FD4, 0xB030D518, 0x53375A96, 0xCD37F05A,
521
+       0x4A146BFF, 0xD414C133, 0x37134EBD, 0xA913E471,
522
+       0xB01A217B, 0x2E1A8BB7, 0xCD1D0439, 0x531DAEF5,
523
+       0xFF0F8E2C, 0x610F24E0, 0x8208AB6E, 0x1C0801A2,
524
+       0x0501C4A8, 0x9B016E64, 0x7806E1EA, 0xE6064B26
525
+   }
526
+};
527
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_table_le.h Added
527
 
1
@@ -0,0 +1,525 @@
2
+/* This file has been automatically generated by crc32_tablegen.c. */
3
+
4
+const uint32_t lzma_crc32_table[8][256] = {
5
+   {
6
+       0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
7
+       0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
8
+       0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
9
+       0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
10
+       0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
11
+       0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
12
+       0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
13
+       0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
14
+       0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
15
+       0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
16
+       0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
17
+       0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
18
+       0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
19
+       0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
20
+       0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
21
+       0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
22
+       0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
23
+       0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
24
+       0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
25
+       0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
26
+       0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
27
+       0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
28
+       0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
29
+       0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
30
+       0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
31
+       0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
32
+       0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
33
+       0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
34
+       0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
35
+       0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
36
+       0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
37
+       0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
38
+       0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
39
+       0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
40
+       0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
41
+       0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
42
+       0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
43
+       0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
44
+       0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
45
+       0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
46
+       0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
47
+       0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
48
+       0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
49
+       0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
50
+       0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
51
+       0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
52
+       0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
53
+       0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
54
+       0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
55
+       0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
56
+       0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
57
+       0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
58
+       0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
59
+       0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
60
+       0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
61
+       0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
62
+       0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
63
+       0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
64
+       0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
65
+       0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
66
+       0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
67
+       0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
68
+       0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
69
+       0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
70
+   }, {
71
+       0x00000000, 0x191B3141, 0x32366282, 0x2B2D53C3,
72
+       0x646CC504, 0x7D77F445, 0x565AA786, 0x4F4196C7,
73
+       0xC8D98A08, 0xD1C2BB49, 0xFAEFE88A, 0xE3F4D9CB,
74
+       0xACB54F0C, 0xB5AE7E4D, 0x9E832D8E, 0x87981CCF,
75
+       0x4AC21251, 0x53D92310, 0x78F470D3, 0x61EF4192,
76
+       0x2EAED755, 0x37B5E614, 0x1C98B5D7, 0x05838496,
77
+       0x821B9859, 0x9B00A918, 0xB02DFADB, 0xA936CB9A,
78
+       0xE6775D5D, 0xFF6C6C1C, 0xD4413FDF, 0xCD5A0E9E,
79
+       0x958424A2, 0x8C9F15E3, 0xA7B24620, 0xBEA97761,
80
+       0xF1E8E1A6, 0xE8F3D0E7, 0xC3DE8324, 0xDAC5B265,
81
+       0x5D5DAEAA, 0x44469FEB, 0x6F6BCC28, 0x7670FD69,
82
+       0x39316BAE, 0x202A5AEF, 0x0B07092C, 0x121C386D,
83
+       0xDF4636F3, 0xC65D07B2, 0xED705471, 0xF46B6530,
84
+       0xBB2AF3F7, 0xA231C2B6, 0x891C9175, 0x9007A034,
85
+       0x179FBCFB, 0x0E848DBA, 0x25A9DE79, 0x3CB2EF38,
86
+       0x73F379FF, 0x6AE848BE, 0x41C51B7D, 0x58DE2A3C,
87
+       0xF0794F05, 0xE9627E44, 0xC24F2D87, 0xDB541CC6,
88
+       0x94158A01, 0x8D0EBB40, 0xA623E883, 0xBF38D9C2,
89
+       0x38A0C50D, 0x21BBF44C, 0x0A96A78F, 0x138D96CE,
90
+       0x5CCC0009, 0x45D73148, 0x6EFA628B, 0x77E153CA,
91
+       0xBABB5D54, 0xA3A06C15, 0x888D3FD6, 0x91960E97,
92
+       0xDED79850, 0xC7CCA911, 0xECE1FAD2, 0xF5FACB93,
93
+       0x7262D75C, 0x6B79E61D, 0x4054B5DE, 0x594F849F,
94
+       0x160E1258, 0x0F152319, 0x243870DA, 0x3D23419B,
95
+       0x65FD6BA7, 0x7CE65AE6, 0x57CB0925, 0x4ED03864,
96
+       0x0191AEA3, 0x188A9FE2, 0x33A7CC21, 0x2ABCFD60,
97
+       0xAD24E1AF, 0xB43FD0EE, 0x9F12832D, 0x8609B26C,
98
+       0xC94824AB, 0xD05315EA, 0xFB7E4629, 0xE2657768,
99
+       0x2F3F79F6, 0x362448B7, 0x1D091B74, 0x04122A35,
100
+       0x4B53BCF2, 0x52488DB3, 0x7965DE70, 0x607EEF31,
101
+       0xE7E6F3FE, 0xFEFDC2BF, 0xD5D0917C, 0xCCCBA03D,
102
+       0x838A36FA, 0x9A9107BB, 0xB1BC5478, 0xA8A76539,
103
+       0x3B83984B, 0x2298A90A, 0x09B5FAC9, 0x10AECB88,
104
+       0x5FEF5D4F, 0x46F46C0E, 0x6DD93FCD, 0x74C20E8C,
105
+       0xF35A1243, 0xEA412302, 0xC16C70C1, 0xD8774180,
106
+       0x9736D747, 0x8E2DE606, 0xA500B5C5, 0xBC1B8484,
107
+       0x71418A1A, 0x685ABB5B, 0x4377E898, 0x5A6CD9D9,
108
+       0x152D4F1E, 0x0C367E5F, 0x271B2D9C, 0x3E001CDD,
109
+       0xB9980012, 0xA0833153, 0x8BAE6290, 0x92B553D1,
110
+       0xDDF4C516, 0xC4EFF457, 0xEFC2A794, 0xF6D996D5,
111
+       0xAE07BCE9, 0xB71C8DA8, 0x9C31DE6B, 0x852AEF2A,
112
+       0xCA6B79ED, 0xD37048AC, 0xF85D1B6F, 0xE1462A2E,
113
+       0x66DE36E1, 0x7FC507A0, 0x54E85463, 0x4DF36522,
114
+       0x02B2F3E5, 0x1BA9C2A4, 0x30849167, 0x299FA026,
115
+       0xE4C5AEB8, 0xFDDE9FF9, 0xD6F3CC3A, 0xCFE8FD7B,
116
+       0x80A96BBC, 0x99B25AFD, 0xB29F093E, 0xAB84387F,
117
+       0x2C1C24B0, 0x350715F1, 0x1E2A4632, 0x07317773,
118
+       0x4870E1B4, 0x516BD0F5, 0x7A468336, 0x635DB277,
119
+       0xCBFAD74E, 0xD2E1E60F, 0xF9CCB5CC, 0xE0D7848D,
120
+       0xAF96124A, 0xB68D230B, 0x9DA070C8, 0x84BB4189,
121
+       0x03235D46, 0x1A386C07, 0x31153FC4, 0x280E0E85,
122
+       0x674F9842, 0x7E54A903, 0x5579FAC0, 0x4C62CB81,
123
+       0x8138C51F, 0x9823F45E, 0xB30EA79D, 0xAA1596DC,
124
+       0xE554001B, 0xFC4F315A, 0xD7626299, 0xCE7953D8,
125
+       0x49E14F17, 0x50FA7E56, 0x7BD72D95, 0x62CC1CD4,
126
+       0x2D8D8A13, 0x3496BB52, 0x1FBBE891, 0x06A0D9D0,
127
+       0x5E7EF3EC, 0x4765C2AD, 0x6C48916E, 0x7553A02F,
128
+       0x3A1236E8, 0x230907A9, 0x0824546A, 0x113F652B,
129
+       0x96A779E4, 0x8FBC48A5, 0xA4911B66, 0xBD8A2A27,
130
+       0xF2CBBCE0, 0xEBD08DA1, 0xC0FDDE62, 0xD9E6EF23,
131
+       0x14BCE1BD, 0x0DA7D0FC, 0x268A833F, 0x3F91B27E,
132
+       0x70D024B9, 0x69CB15F8, 0x42E6463B, 0x5BFD777A,
133
+       0xDC656BB5, 0xC57E5AF4, 0xEE530937, 0xF7483876,
134
+       0xB809AEB1, 0xA1129FF0, 0x8A3FCC33, 0x9324FD72
135
+   }, {
136
+       0x00000000, 0x01C26A37, 0x0384D46E, 0x0246BE59,
137
+       0x0709A8DC, 0x06CBC2EB, 0x048D7CB2, 0x054F1685,
138
+       0x0E1351B8, 0x0FD13B8F, 0x0D9785D6, 0x0C55EFE1,
139
+       0x091AF964, 0x08D89353, 0x0A9E2D0A, 0x0B5C473D,
140
+       0x1C26A370, 0x1DE4C947, 0x1FA2771E, 0x1E601D29,
141
+       0x1B2F0BAC, 0x1AED619B, 0x18ABDFC2, 0x1969B5F5,
142
+       0x1235F2C8, 0x13F798FF, 0x11B126A6, 0x10734C91,
143
+       0x153C5A14, 0x14FE3023, 0x16B88E7A, 0x177AE44D,
144
+       0x384D46E0, 0x398F2CD7, 0x3BC9928E, 0x3A0BF8B9,
145
+       0x3F44EE3C, 0x3E86840B, 0x3CC03A52, 0x3D025065,
146
+       0x365E1758, 0x379C7D6F, 0x35DAC336, 0x3418A901,
147
+       0x3157BF84, 0x3095D5B3, 0x32D36BEA, 0x331101DD,
148
+       0x246BE590, 0x25A98FA7, 0x27EF31FE, 0x262D5BC9,
149
+       0x23624D4C, 0x22A0277B, 0x20E69922, 0x2124F315,
150
+       0x2A78B428, 0x2BBADE1F, 0x29FC6046, 0x283E0A71,
151
+       0x2D711CF4, 0x2CB376C3, 0x2EF5C89A, 0x2F37A2AD,
152
+       0x709A8DC0, 0x7158E7F7, 0x731E59AE, 0x72DC3399,
153
+       0x7793251C, 0x76514F2B, 0x7417F172, 0x75D59B45,
154
+       0x7E89DC78, 0x7F4BB64F, 0x7D0D0816, 0x7CCF6221,
155
+       0x798074A4, 0x78421E93, 0x7A04A0CA, 0x7BC6CAFD,
156
+       0x6CBC2EB0, 0x6D7E4487, 0x6F38FADE, 0x6EFA90E9,
157
+       0x6BB5866C, 0x6A77EC5B, 0x68315202, 0x69F33835,
158
+       0x62AF7F08, 0x636D153F, 0x612BAB66, 0x60E9C151,
159
+       0x65A6D7D4, 0x6464BDE3, 0x662203BA, 0x67E0698D,
160
+       0x48D7CB20, 0x4915A117, 0x4B531F4E, 0x4A917579,
161
+       0x4FDE63FC, 0x4E1C09CB, 0x4C5AB792, 0x4D98DDA5,
162
+       0x46C49A98, 0x4706F0AF, 0x45404EF6, 0x448224C1,
163
+       0x41CD3244, 0x400F5873, 0x4249E62A, 0x438B8C1D,
164
+       0x54F16850, 0x55330267, 0x5775BC3E, 0x56B7D609,
165
+       0x53F8C08C, 0x523AAABB, 0x507C14E2, 0x51BE7ED5,
166
+       0x5AE239E8, 0x5B2053DF, 0x5966ED86, 0x58A487B1,
167
+       0x5DEB9134, 0x5C29FB03, 0x5E6F455A, 0x5FAD2F6D,
168
+       0xE1351B80, 0xE0F771B7, 0xE2B1CFEE, 0xE373A5D9,
169
+       0xE63CB35C, 0xE7FED96B, 0xE5B86732, 0xE47A0D05,
170
+       0xEF264A38, 0xEEE4200F, 0xECA29E56, 0xED60F461,
171
+       0xE82FE2E4, 0xE9ED88D3, 0xEBAB368A, 0xEA695CBD,
172
+       0xFD13B8F0, 0xFCD1D2C7, 0xFE976C9E, 0xFF5506A9,
173
+       0xFA1A102C, 0xFBD87A1B, 0xF99EC442, 0xF85CAE75,
174
+       0xF300E948, 0xF2C2837F, 0xF0843D26, 0xF1465711,
175
+       0xF4094194, 0xF5CB2BA3, 0xF78D95FA, 0xF64FFFCD,
176
+       0xD9785D60, 0xD8BA3757, 0xDAFC890E, 0xDB3EE339,
177
+       0xDE71F5BC, 0xDFB39F8B, 0xDDF521D2, 0xDC374BE5,
178
+       0xD76B0CD8, 0xD6A966EF, 0xD4EFD8B6, 0xD52DB281,
179
+       0xD062A404, 0xD1A0CE33, 0xD3E6706A, 0xD2241A5D,
180
+       0xC55EFE10, 0xC49C9427, 0xC6DA2A7E, 0xC7184049,
181
+       0xC25756CC, 0xC3953CFB, 0xC1D382A2, 0xC011E895,
182
+       0xCB4DAFA8, 0xCA8FC59F, 0xC8C97BC6, 0xC90B11F1,
183
+       0xCC440774, 0xCD866D43, 0xCFC0D31A, 0xCE02B92D,
184
+       0x91AF9640, 0x906DFC77, 0x922B422E, 0x93E92819,
185
+       0x96A63E9C, 0x976454AB, 0x9522EAF2, 0x94E080C5,
186
+       0x9FBCC7F8, 0x9E7EADCF, 0x9C381396, 0x9DFA79A1,
187
+       0x98B56F24, 0x99770513, 0x9B31BB4A, 0x9AF3D17D,
188
+       0x8D893530, 0x8C4B5F07, 0x8E0DE15E, 0x8FCF8B69,
189
+       0x8A809DEC, 0x8B42F7DB, 0x89044982, 0x88C623B5,
190
+       0x839A6488, 0x82580EBF, 0x801EB0E6, 0x81DCDAD1,
191
+       0x8493CC54, 0x8551A663, 0x8717183A, 0x86D5720D,
192
+       0xA9E2D0A0, 0xA820BA97, 0xAA6604CE, 0xABA46EF9,
193
+       0xAEEB787C, 0xAF29124B, 0xAD6FAC12, 0xACADC625,
194
+       0xA7F18118, 0xA633EB2F, 0xA4755576, 0xA5B73F41,
195
+       0xA0F829C4, 0xA13A43F3, 0xA37CFDAA, 0xA2BE979D,
196
+       0xB5C473D0, 0xB40619E7, 0xB640A7BE, 0xB782CD89,
197
+       0xB2CDDB0C, 0xB30FB13B, 0xB1490F62, 0xB08B6555,
198
+       0xBBD72268, 0xBA15485F, 0xB853F606, 0xB9919C31,
199
+       0xBCDE8AB4, 0xBD1CE083, 0xBF5A5EDA, 0xBE9834ED
200
+   }, {
201
+       0x00000000, 0xB8BC6765, 0xAA09C88B, 0x12B5AFEE,
202
+       0x8F629757, 0x37DEF032, 0x256B5FDC, 0x9DD738B9,
203
+       0xC5B428EF, 0x7D084F8A, 0x6FBDE064, 0xD7018701,
204
+       0x4AD6BFB8, 0xF26AD8DD, 0xE0DF7733, 0x58631056,
205
+       0x5019579F, 0xE8A530FA, 0xFA109F14, 0x42ACF871,
206
+       0xDF7BC0C8, 0x67C7A7AD, 0x75720843, 0xCDCE6F26,
207
+       0x95AD7F70, 0x2D111815, 0x3FA4B7FB, 0x8718D09E,
208
+       0x1ACFE827, 0xA2738F42, 0xB0C620AC, 0x087A47C9,
209
+       0xA032AF3E, 0x188EC85B, 0x0A3B67B5, 0xB28700D0,
210
+       0x2F503869, 0x97EC5F0C, 0x8559F0E2, 0x3DE59787,
211
+       0x658687D1, 0xDD3AE0B4, 0xCF8F4F5A, 0x7733283F,
212
+       0xEAE41086, 0x525877E3, 0x40EDD80D, 0xF851BF68,
213
+       0xF02BF8A1, 0x48979FC4, 0x5A22302A, 0xE29E574F,
214
+       0x7F496FF6, 0xC7F50893, 0xD540A77D, 0x6DFCC018,
215
+       0x359FD04E, 0x8D23B72B, 0x9F9618C5, 0x272A7FA0,
216
+       0xBAFD4719, 0x0241207C, 0x10F48F92, 0xA848E8F7,
217
+       0x9B14583D, 0x23A83F58, 0x311D90B6, 0x89A1F7D3,
218
+       0x1476CF6A, 0xACCAA80F, 0xBE7F07E1, 0x06C36084,
219
+       0x5EA070D2, 0xE61C17B7, 0xF4A9B859, 0x4C15DF3C,
220
+       0xD1C2E785, 0x697E80E0, 0x7BCB2F0E, 0xC377486B,
221
+       0xCB0D0FA2, 0x73B168C7, 0x6104C729, 0xD9B8A04C,
222
+       0x446F98F5, 0xFCD3FF90, 0xEE66507E, 0x56DA371B,
223
+       0x0EB9274D, 0xB6054028, 0xA4B0EFC6, 0x1C0C88A3,
224
+       0x81DBB01A, 0x3967D77F, 0x2BD27891, 0x936E1FF4,
225
+       0x3B26F703, 0x839A9066, 0x912F3F88, 0x299358ED,
226
+       0xB4446054, 0x0CF80731, 0x1E4DA8DF, 0xA6F1CFBA,
227
+       0xFE92DFEC, 0x462EB889, 0x549B1767, 0xEC277002,
228
+       0x71F048BB, 0xC94C2FDE, 0xDBF98030, 0x6345E755,
229
+       0x6B3FA09C, 0xD383C7F9, 0xC1366817, 0x798A0F72,
230
+       0xE45D37CB, 0x5CE150AE, 0x4E54FF40, 0xF6E89825,
231
+       0xAE8B8873, 0x1637EF16, 0x048240F8, 0xBC3E279D,
232
+       0x21E91F24, 0x99557841, 0x8BE0D7AF, 0x335CB0CA,
233
+       0xED59B63B, 0x55E5D15E, 0x47507EB0, 0xFFEC19D5,
234
+       0x623B216C, 0xDA874609, 0xC832E9E7, 0x708E8E82,
235
+       0x28ED9ED4, 0x9051F9B1, 0x82E4565F, 0x3A58313A,
236
+       0xA78F0983, 0x1F336EE6, 0x0D86C108, 0xB53AA66D,
237
+       0xBD40E1A4, 0x05FC86C1, 0x1749292F, 0xAFF54E4A,
238
+       0x322276F3, 0x8A9E1196, 0x982BBE78, 0x2097D91D,
239
+       0x78F4C94B, 0xC048AE2E, 0xD2FD01C0, 0x6A4166A5,
240
+       0xF7965E1C, 0x4F2A3979, 0x5D9F9697, 0xE523F1F2,
241
+       0x4D6B1905, 0xF5D77E60, 0xE762D18E, 0x5FDEB6EB,
242
+       0xC2098E52, 0x7AB5E937, 0x680046D9, 0xD0BC21BC,
243
+       0x88DF31EA, 0x3063568F, 0x22D6F961, 0x9A6A9E04,
244
+       0x07BDA6BD, 0xBF01C1D8, 0xADB46E36, 0x15080953,
245
+       0x1D724E9A, 0xA5CE29FF, 0xB77B8611, 0x0FC7E174,
246
+       0x9210D9CD, 0x2AACBEA8, 0x38191146, 0x80A57623,
247
+       0xD8C66675, 0x607A0110, 0x72CFAEFE, 0xCA73C99B,
248
+       0x57A4F122, 0xEF189647, 0xFDAD39A9, 0x45115ECC,
249
+       0x764DEE06, 0xCEF18963, 0xDC44268D, 0x64F841E8,
250
+       0xF92F7951, 0x41931E34, 0x5326B1DA, 0xEB9AD6BF,
251
+       0xB3F9C6E9, 0x0B45A18C, 0x19F00E62, 0xA14C6907,
252
+       0x3C9B51BE, 0x842736DB, 0x96929935, 0x2E2EFE50,
253
+       0x2654B999, 0x9EE8DEFC, 0x8C5D7112, 0x34E11677,
254
+       0xA9362ECE, 0x118A49AB, 0x033FE645, 0xBB838120,
255
+       0xE3E09176, 0x5B5CF613, 0x49E959FD, 0xF1553E98,
256
+       0x6C820621, 0xD43E6144, 0xC68BCEAA, 0x7E37A9CF,
257
+       0xD67F4138, 0x6EC3265D, 0x7C7689B3, 0xC4CAEED6,
258
+       0x591DD66F, 0xE1A1B10A, 0xF3141EE4, 0x4BA87981,
259
+       0x13CB69D7, 0xAB770EB2, 0xB9C2A15C, 0x017EC639,
260
+       0x9CA9FE80, 0x241599E5, 0x36A0360B, 0x8E1C516E,
261
+       0x866616A7, 0x3EDA71C2, 0x2C6FDE2C, 0x94D3B949,
262
+       0x090481F0, 0xB1B8E695, 0xA30D497B, 0x1BB12E1E,
263
+       0x43D23E48, 0xFB6E592D, 0xE9DBF6C3, 0x516791A6,
264
+       0xCCB0A91F, 0x740CCE7A, 0x66B96194, 0xDE0506F1
265
+   }, {
266
+       0x00000000, 0x3D6029B0, 0x7AC05360, 0x47A07AD0,
267
+       0xF580A6C0, 0xC8E08F70, 0x8F40F5A0, 0xB220DC10,
268
+       0x30704BC1, 0x0D106271, 0x4AB018A1, 0x77D03111,
269
+       0xC5F0ED01, 0xF890C4B1, 0xBF30BE61, 0x825097D1,
270
+       0x60E09782, 0x5D80BE32, 0x1A20C4E2, 0x2740ED52,
271
+       0x95603142, 0xA80018F2, 0xEFA06222, 0xD2C04B92,
272
+       0x5090DC43, 0x6DF0F5F3, 0x2A508F23, 0x1730A693,
273
+       0xA5107A83, 0x98705333, 0xDFD029E3, 0xE2B00053,
274
+       0xC1C12F04, 0xFCA106B4, 0xBB017C64, 0x866155D4,
275
+       0x344189C4, 0x0921A074, 0x4E81DAA4, 0x73E1F314,
276
+       0xF1B164C5, 0xCCD14D75, 0x8B7137A5, 0xB6111E15,
277
+       0x0431C205, 0x3951EBB5, 0x7EF19165, 0x4391B8D5,
278
+       0xA121B886, 0x9C419136, 0xDBE1EBE6, 0xE681C256,
279
+       0x54A11E46, 0x69C137F6, 0x2E614D26, 0x13016496,
280
+       0x9151F347, 0xAC31DAF7, 0xEB91A027, 0xD6F18997,
281
+       0x64D15587, 0x59B17C37, 0x1E1106E7, 0x23712F57,
282
+       0x58F35849, 0x659371F9, 0x22330B29, 0x1F532299,
283
+       0xAD73FE89, 0x9013D739, 0xD7B3ADE9, 0xEAD38459,
284
+       0x68831388, 0x55E33A38, 0x124340E8, 0x2F236958,
285
+       0x9D03B548, 0xA0639CF8, 0xE7C3E628, 0xDAA3CF98,
286
+       0x3813CFCB, 0x0573E67B, 0x42D39CAB, 0x7FB3B51B,
287
+       0xCD93690B, 0xF0F340BB, 0xB7533A6B, 0x8A3313DB,
288
+       0x0863840A, 0x3503ADBA, 0x72A3D76A, 0x4FC3FEDA,
289
+       0xFDE322CA, 0xC0830B7A, 0x872371AA, 0xBA43581A,
290
+       0x9932774D, 0xA4525EFD, 0xE3F2242D, 0xDE920D9D,
291
+       0x6CB2D18D, 0x51D2F83D, 0x167282ED, 0x2B12AB5D,
292
+       0xA9423C8C, 0x9422153C, 0xD3826FEC, 0xEEE2465C,
293
+       0x5CC29A4C, 0x61A2B3FC, 0x2602C92C, 0x1B62E09C,
294
+       0xF9D2E0CF, 0xC4B2C97F, 0x8312B3AF, 0xBE729A1F,
295
+       0x0C52460F, 0x31326FBF, 0x7692156F, 0x4BF23CDF,
296
+       0xC9A2AB0E, 0xF4C282BE, 0xB362F86E, 0x8E02D1DE,
297
+       0x3C220DCE, 0x0142247E, 0x46E25EAE, 0x7B82771E,
298
+       0xB1E6B092, 0x8C869922, 0xCB26E3F2, 0xF646CA42,
299
+       0x44661652, 0x79063FE2, 0x3EA64532, 0x03C66C82,
300
+       0x8196FB53, 0xBCF6D2E3, 0xFB56A833, 0xC6368183,
301
+       0x74165D93, 0x49767423, 0x0ED60EF3, 0x33B62743,
302
+       0xD1062710, 0xEC660EA0, 0xABC67470, 0x96A65DC0,
303
+       0x248681D0, 0x19E6A860, 0x5E46D2B0, 0x6326FB00,
304
+       0xE1766CD1, 0xDC164561, 0x9BB63FB1, 0xA6D61601,
305
+       0x14F6CA11, 0x2996E3A1, 0x6E369971, 0x5356B0C1,
306
+       0x70279F96, 0x4D47B626, 0x0AE7CCF6, 0x3787E546,
307
+       0x85A73956, 0xB8C710E6, 0xFF676A36, 0xC2074386,
308
+       0x4057D457, 0x7D37FDE7, 0x3A978737, 0x07F7AE87,
309
+       0xB5D77297, 0x88B75B27, 0xCF1721F7, 0xF2770847,
310
+       0x10C70814, 0x2DA721A4, 0x6A075B74, 0x576772C4,
311
+       0xE547AED4, 0xD8278764, 0x9F87FDB4, 0xA2E7D404,
312
+       0x20B743D5, 0x1DD76A65, 0x5A7710B5, 0x67173905,
313
+       0xD537E515, 0xE857CCA5, 0xAFF7B675, 0x92979FC5,
314
+       0xE915E8DB, 0xD475C16B, 0x93D5BBBB, 0xAEB5920B,
315
+       0x1C954E1B, 0x21F567AB, 0x66551D7B, 0x5B3534CB,
316
+       0xD965A31A, 0xE4058AAA, 0xA3A5F07A, 0x9EC5D9CA,
317
+       0x2CE505DA, 0x11852C6A, 0x562556BA, 0x6B457F0A,
318
+       0x89F57F59, 0xB49556E9, 0xF3352C39, 0xCE550589,
319
+       0x7C75D999, 0x4115F029, 0x06B58AF9, 0x3BD5A349,
320
+       0xB9853498, 0x84E51D28, 0xC34567F8, 0xFE254E48,
321
+       0x4C059258, 0x7165BBE8, 0x36C5C138, 0x0BA5E888,
322
+       0x28D4C7DF, 0x15B4EE6F, 0x521494BF, 0x6F74BD0F,
323
+       0xDD54611F, 0xE03448AF, 0xA794327F, 0x9AF41BCF,
324
+       0x18A48C1E, 0x25C4A5AE, 0x6264DF7E, 0x5F04F6CE,
325
+       0xED242ADE, 0xD044036E, 0x97E479BE, 0xAA84500E,
326
+       0x4834505D, 0x755479ED, 0x32F4033D, 0x0F942A8D,
327
+       0xBDB4F69D, 0x80D4DF2D, 0xC774A5FD, 0xFA148C4D,
328
+       0x78441B9C, 0x4524322C, 0x028448FC, 0x3FE4614C,
329
+       0x8DC4BD5C, 0xB0A494EC, 0xF704EE3C, 0xCA64C78C
330
+   }, {
331
+       0x00000000, 0xCB5CD3A5, 0x4DC8A10B, 0x869472AE,
332
+       0x9B914216, 0x50CD91B3, 0xD659E31D, 0x1D0530B8,
333
+       0xEC53826D, 0x270F51C8, 0xA19B2366, 0x6AC7F0C3,
334
+       0x77C2C07B, 0xBC9E13DE, 0x3A0A6170, 0xF156B2D5,
335
+       0x03D6029B, 0xC88AD13E, 0x4E1EA390, 0x85427035,
336
+       0x9847408D, 0x531B9328, 0xD58FE186, 0x1ED33223,
337
+       0xEF8580F6, 0x24D95353, 0xA24D21FD, 0x6911F258,
338
+       0x7414C2E0, 0xBF481145, 0x39DC63EB, 0xF280B04E,
339
+       0x07AC0536, 0xCCF0D693, 0x4A64A43D, 0x81387798,
340
+       0x9C3D4720, 0x57619485, 0xD1F5E62B, 0x1AA9358E,
341
+       0xEBFF875B, 0x20A354FE, 0xA6372650, 0x6D6BF5F5,
342
+       0x706EC54D, 0xBB3216E8, 0x3DA66446, 0xF6FAB7E3,
343
+       0x047A07AD, 0xCF26D408, 0x49B2A6A6, 0x82EE7503,
344
+       0x9FEB45BB, 0x54B7961E, 0xD223E4B0, 0x197F3715,
345
+       0xE82985C0, 0x23755665, 0xA5E124CB, 0x6EBDF76E,
346
+       0x73B8C7D6, 0xB8E41473, 0x3E7066DD, 0xF52CB578,
347
+       0x0F580A6C, 0xC404D9C9, 0x4290AB67, 0x89CC78C2,
348
+       0x94C9487A, 0x5F959BDF, 0xD901E971, 0x125D3AD4,
349
+       0xE30B8801, 0x28575BA4, 0xAEC3290A, 0x659FFAAF,
350
+       0x789ACA17, 0xB3C619B2, 0x35526B1C, 0xFE0EB8B9,
351
+       0x0C8E08F7, 0xC7D2DB52, 0x4146A9FC, 0x8A1A7A59,
352
+       0x971F4AE1, 0x5C439944, 0xDAD7EBEA, 0x118B384F,
353
+       0xE0DD8A9A, 0x2B81593F, 0xAD152B91, 0x6649F834,
354
+       0x7B4CC88C, 0xB0101B29, 0x36846987, 0xFDD8BA22,
355
+       0x08F40F5A, 0xC3A8DCFF, 0x453CAE51, 0x8E607DF4,
356
+       0x93654D4C, 0x58399EE9, 0xDEADEC47, 0x15F13FE2,
357
+       0xE4A78D37, 0x2FFB5E92, 0xA96F2C3C, 0x6233FF99,
358
+       0x7F36CF21, 0xB46A1C84, 0x32FE6E2A, 0xF9A2BD8F,
359
+       0x0B220DC1, 0xC07EDE64, 0x46EAACCA, 0x8DB67F6F,
360
+       0x90B34FD7, 0x5BEF9C72, 0xDD7BEEDC, 0x16273D79,
361
+       0xE7718FAC, 0x2C2D5C09, 0xAAB92EA7, 0x61E5FD02,
362
+       0x7CE0CDBA, 0xB7BC1E1F, 0x31286CB1, 0xFA74BF14,
363
+       0x1EB014D8, 0xD5ECC77D, 0x5378B5D3, 0x98246676,
364
+       0x852156CE, 0x4E7D856B, 0xC8E9F7C5, 0x03B52460,
365
+       0xF2E396B5, 0x39BF4510, 0xBF2B37BE, 0x7477E41B,
366
+       0x6972D4A3, 0xA22E0706, 0x24BA75A8, 0xEFE6A60D,
367
+       0x1D661643, 0xD63AC5E6, 0x50AEB748, 0x9BF264ED,
368
+       0x86F75455, 0x4DAB87F0, 0xCB3FF55E, 0x006326FB,
369
+       0xF135942E, 0x3A69478B, 0xBCFD3525, 0x77A1E680,
370
+       0x6AA4D638, 0xA1F8059D, 0x276C7733, 0xEC30A496,
371
+       0x191C11EE, 0xD240C24B, 0x54D4B0E5, 0x9F886340,
372
+       0x828D53F8, 0x49D1805D, 0xCF45F2F3, 0x04192156,
373
+       0xF54F9383, 0x3E134026, 0xB8873288, 0x73DBE12D,
374
+       0x6EDED195, 0xA5820230, 0x2316709E, 0xE84AA33B,
375
+       0x1ACA1375, 0xD196C0D0, 0x5702B27E, 0x9C5E61DB,
376
+       0x815B5163, 0x4A0782C6, 0xCC93F068, 0x07CF23CD,
377
+       0xF6999118, 0x3DC542BD, 0xBB513013, 0x700DE3B6,
378
+       0x6D08D30E, 0xA65400AB, 0x20C07205, 0xEB9CA1A0,
379
+       0x11E81EB4, 0xDAB4CD11, 0x5C20BFBF, 0x977C6C1A,
380
+       0x8A795CA2, 0x41258F07, 0xC7B1FDA9, 0x0CED2E0C,
381
+       0xFDBB9CD9, 0x36E74F7C, 0xB0733DD2, 0x7B2FEE77,
382
+       0x662ADECF, 0xAD760D6A, 0x2BE27FC4, 0xE0BEAC61,
383
+       0x123E1C2F, 0xD962CF8A, 0x5FF6BD24, 0x94AA6E81,
384
+       0x89AF5E39, 0x42F38D9C, 0xC467FF32, 0x0F3B2C97,
385
+       0xFE6D9E42, 0x35314DE7, 0xB3A53F49, 0x78F9ECEC,
386
+       0x65FCDC54, 0xAEA00FF1, 0x28347D5F, 0xE368AEFA,
387
+       0x16441B82, 0xDD18C827, 0x5B8CBA89, 0x90D0692C,
388
+       0x8DD55994, 0x46898A31, 0xC01DF89F, 0x0B412B3A,
389
+       0xFA1799EF, 0x314B4A4A, 0xB7DF38E4, 0x7C83EB41,
390
+       0x6186DBF9, 0xAADA085C, 0x2C4E7AF2, 0xE712A957,
391
+       0x15921919, 0xDECECABC, 0x585AB812, 0x93066BB7,
392
+       0x8E035B0F, 0x455F88AA, 0xC3CBFA04, 0x089729A1,
393
+       0xF9C19B74, 0x329D48D1, 0xB4093A7F, 0x7F55E9DA,
394
+       0x6250D962, 0xA90C0AC7, 0x2F987869, 0xE4C4ABCC
395
+   }, {
396
+       0x00000000, 0xA6770BB4, 0x979F1129, 0x31E81A9D,
397
+       0xF44F2413, 0x52382FA7, 0x63D0353A, 0xC5A73E8E,
398
+       0x33EF4E67, 0x959845D3, 0xA4705F4E, 0x020754FA,
399
+       0xC7A06A74, 0x61D761C0, 0x503F7B5D, 0xF64870E9,
400
+       0x67DE9CCE, 0xC1A9977A, 0xF0418DE7, 0x56368653,
401
+       0x9391B8DD, 0x35E6B369, 0x040EA9F4, 0xA279A240,
402
+       0x5431D2A9, 0xF246D91D, 0xC3AEC380, 0x65D9C834,
403
+       0xA07EF6BA, 0x0609FD0E, 0x37E1E793, 0x9196EC27,
404
+       0xCFBD399C, 0x69CA3228, 0x582228B5, 0xFE552301,
405
+       0x3BF21D8F, 0x9D85163B, 0xAC6D0CA6, 0x0A1A0712,
406
+       0xFC5277FB, 0x5A257C4F, 0x6BCD66D2, 0xCDBA6D66,
407
+       0x081D53E8, 0xAE6A585C, 0x9F8242C1, 0x39F54975,
408
+       0xA863A552, 0x0E14AEE6, 0x3FFCB47B, 0x998BBFCF,
409
+       0x5C2C8141, 0xFA5B8AF5, 0xCBB39068, 0x6DC49BDC,
410
+       0x9B8CEB35, 0x3DFBE081, 0x0C13FA1C, 0xAA64F1A8,
411
+       0x6FC3CF26, 0xC9B4C492, 0xF85CDE0F, 0x5E2BD5BB,
412
+       0x440B7579, 0xE27C7ECD, 0xD3946450, 0x75E36FE4,
413
+       0xB044516A, 0x16335ADE, 0x27DB4043, 0x81AC4BF7,
414
+       0x77E43B1E, 0xD19330AA, 0xE07B2A37, 0x460C2183,
415
+       0x83AB1F0D, 0x25DC14B9, 0x14340E24, 0xB2430590,
416
+       0x23D5E9B7, 0x85A2E203, 0xB44AF89E, 0x123DF32A,
417
+       0xD79ACDA4, 0x71EDC610, 0x4005DC8D, 0xE672D739,
418
+       0x103AA7D0, 0xB64DAC64, 0x87A5B6F9, 0x21D2BD4D,
419
+       0xE47583C3, 0x42028877, 0x73EA92EA, 0xD59D995E,
420
+       0x8BB64CE5, 0x2DC14751, 0x1C295DCC, 0xBA5E5678,
421
+       0x7FF968F6, 0xD98E6342, 0xE86679DF, 0x4E11726B,
422
+       0xB8590282, 0x1E2E0936, 0x2FC613AB, 0x89B1181F,
423
+       0x4C162691, 0xEA612D25, 0xDB8937B8, 0x7DFE3C0C,
424
+       0xEC68D02B, 0x4A1FDB9F, 0x7BF7C102, 0xDD80CAB6,
425
+       0x1827F438, 0xBE50FF8C, 0x8FB8E511, 0x29CFEEA5,
426
+       0xDF879E4C, 0x79F095F8, 0x48188F65, 0xEE6F84D1,
427
+       0x2BC8BA5F, 0x8DBFB1EB, 0xBC57AB76, 0x1A20A0C2,
428
+       0x8816EAF2, 0x2E61E146, 0x1F89FBDB, 0xB9FEF06F,
429
+       0x7C59CEE1, 0xDA2EC555, 0xEBC6DFC8, 0x4DB1D47C,
430
+       0xBBF9A495, 0x1D8EAF21, 0x2C66B5BC, 0x8A11BE08,
431
+       0x4FB68086, 0xE9C18B32, 0xD82991AF, 0x7E5E9A1B,
432
+       0xEFC8763C, 0x49BF7D88, 0x78576715, 0xDE206CA1,
433
+       0x1B87522F, 0xBDF0599B, 0x8C184306, 0x2A6F48B2,
434
+       0xDC27385B, 0x7A5033EF, 0x4BB82972, 0xEDCF22C6,
435
+       0x28681C48, 0x8E1F17FC, 0xBFF70D61, 0x198006D5,
436
+       0x47ABD36E, 0xE1DCD8DA, 0xD034C247, 0x7643C9F3,
437
+       0xB3E4F77D, 0x1593FCC9, 0x247BE654, 0x820CEDE0,
438
+       0x74449D09, 0xD23396BD, 0xE3DB8C20, 0x45AC8794,
439
+       0x800BB91A, 0x267CB2AE, 0x1794A833, 0xB1E3A387,
440
+       0x20754FA0, 0x86024414, 0xB7EA5E89, 0x119D553D,
441
+       0xD43A6BB3, 0x724D6007, 0x43A57A9A, 0xE5D2712E,
442
+       0x139A01C7, 0xB5ED0A73, 0x840510EE, 0x22721B5A,
443
+       0xE7D525D4, 0x41A22E60, 0x704A34FD, 0xD63D3F49,
444
+       0xCC1D9F8B, 0x6A6A943F, 0x5B828EA2, 0xFDF58516,
445
+       0x3852BB98, 0x9E25B02C, 0xAFCDAAB1, 0x09BAA105,
446
+       0xFFF2D1EC, 0x5985DA58, 0x686DC0C5, 0xCE1ACB71,
447
+       0x0BBDF5FF, 0xADCAFE4B, 0x9C22E4D6, 0x3A55EF62,
448
+       0xABC30345, 0x0DB408F1, 0x3C5C126C, 0x9A2B19D8,
449
+       0x5F8C2756, 0xF9FB2CE2, 0xC813367F, 0x6E643DCB,
450
+       0x982C4D22, 0x3E5B4696, 0x0FB35C0B, 0xA9C457BF,
451
+       0x6C636931, 0xCA146285, 0xFBFC7818, 0x5D8B73AC,
452
+       0x03A0A617, 0xA5D7ADA3, 0x943FB73E, 0x3248BC8A,
453
+       0xF7EF8204, 0x519889B0, 0x6070932D, 0xC6079899,
454
+       0x304FE870, 0x9638E3C4, 0xA7D0F959, 0x01A7F2ED,
455
+       0xC400CC63, 0x6277C7D7, 0x539FDD4A, 0xF5E8D6FE,
456
+       0x647E3AD9, 0xC209316D, 0xF3E12BF0, 0x55962044,
457
+       0x90311ECA, 0x3646157E, 0x07AE0FE3, 0xA1D90457,
458
+       0x579174BE, 0xF1E67F0A, 0xC00E6597, 0x66796E23,
459
+       0xA3DE50AD, 0x05A95B19, 0x34414184, 0x92364A30
460
+   }, {
461
+       0x00000000, 0xCCAA009E, 0x4225077D, 0x8E8F07E3,
462
+       0x844A0EFA, 0x48E00E64, 0xC66F0987, 0x0AC50919,
463
+       0xD3E51BB5, 0x1F4F1B2B, 0x91C01CC8, 0x5D6A1C56,
464
+       0x57AF154F, 0x9B0515D1, 0x158A1232, 0xD92012AC,
465
+       0x7CBB312B, 0xB01131B5, 0x3E9E3656, 0xF23436C8,
466
+       0xF8F13FD1, 0x345B3F4F, 0xBAD438AC, 0x767E3832,
467
+       0xAF5E2A9E, 0x63F42A00, 0xED7B2DE3, 0x21D12D7D,
468
+       0x2B142464, 0xE7BE24FA, 0x69312319, 0xA59B2387,
469
+       0xF9766256, 0x35DC62C8, 0xBB53652B, 0x77F965B5,
470
+       0x7D3C6CAC, 0xB1966C32, 0x3F196BD1, 0xF3B36B4F,
471
+       0x2A9379E3, 0xE639797D, 0x68B67E9E, 0xA41C7E00,
472
+       0xAED97719, 0x62737787, 0xECFC7064, 0x205670FA,
473
+       0x85CD537D, 0x496753E3, 0xC7E85400, 0x0B42549E,
474
+       0x01875D87, 0xCD2D5D19, 0x43A25AFA, 0x8F085A64,
475
+       0x562848C8, 0x9A824856, 0x140D4FB5, 0xD8A74F2B,
476
+       0xD2624632, 0x1EC846AC, 0x9047414F, 0x5CED41D1,
477
+       0x299DC2ED, 0xE537C273, 0x6BB8C590, 0xA712C50E,
478
+       0xADD7CC17, 0x617DCC89, 0xEFF2CB6A, 0x2358CBF4,
479
+       0xFA78D958, 0x36D2D9C6, 0xB85DDE25, 0x74F7DEBB,
480
+       0x7E32D7A2, 0xB298D73C, 0x3C17D0DF, 0xF0BDD041,
481
+       0x5526F3C6, 0x998CF358, 0x1703F4BB, 0xDBA9F425,
482
+       0xD16CFD3C, 0x1DC6FDA2, 0x9349FA41, 0x5FE3FADF,
483
+       0x86C3E873, 0x4A69E8ED, 0xC4E6EF0E, 0x084CEF90,
484
+       0x0289E689, 0xCE23E617, 0x40ACE1F4, 0x8C06E16A,
485
+       0xD0EBA0BB, 0x1C41A025, 0x92CEA7C6, 0x5E64A758,
486
+       0x54A1AE41, 0x980BAEDF, 0x1684A93C, 0xDA2EA9A2,
487
+       0x030EBB0E, 0xCFA4BB90, 0x412BBC73, 0x8D81BCED,
488
+       0x8744B5F4, 0x4BEEB56A, 0xC561B289, 0x09CBB217,
489
+       0xAC509190, 0x60FA910E, 0xEE7596ED, 0x22DF9673,
490
+       0x281A9F6A, 0xE4B09FF4, 0x6A3F9817, 0xA6959889,
491
+       0x7FB58A25, 0xB31F8ABB, 0x3D908D58, 0xF13A8DC6,
492
+       0xFBFF84DF, 0x37558441, 0xB9DA83A2, 0x7570833C,
493
+       0x533B85DA, 0x9F918544, 0x111E82A7, 0xDDB48239,
494
+       0xD7718B20, 0x1BDB8BBE, 0x95548C5D, 0x59FE8CC3,
495
+       0x80DE9E6F, 0x4C749EF1, 0xC2FB9912, 0x0E51998C,
496
+       0x04949095, 0xC83E900B, 0x46B197E8, 0x8A1B9776,
497
+       0x2F80B4F1, 0xE32AB46F, 0x6DA5B38C, 0xA10FB312,
498
+       0xABCABA0B, 0x6760BA95, 0xE9EFBD76, 0x2545BDE8,
499
+       0xFC65AF44, 0x30CFAFDA, 0xBE40A839, 0x72EAA8A7,
500
+       0x782FA1BE, 0xB485A120, 0x3A0AA6C3, 0xF6A0A65D,
501
+       0xAA4DE78C, 0x66E7E712, 0xE868E0F1, 0x24C2E06F,
502
+       0x2E07E976, 0xE2ADE9E8, 0x6C22EE0B, 0xA088EE95,
503
+       0x79A8FC39, 0xB502FCA7, 0x3B8DFB44, 0xF727FBDA,
504
+       0xFDE2F2C3, 0x3148F25D, 0xBFC7F5BE, 0x736DF520,
505
+       0xD6F6D6A7, 0x1A5CD639, 0x94D3D1DA, 0x5879D144,
506
+       0x52BCD85D, 0x9E16D8C3, 0x1099DF20, 0xDC33DFBE,
507
+       0x0513CD12, 0xC9B9CD8C, 0x4736CA6F, 0x8B9CCAF1,
508
+       0x8159C3E8, 0x4DF3C376, 0xC37CC495, 0x0FD6C40B,
509
+       0x7AA64737, 0xB60C47A9, 0x3883404A, 0xF42940D4,
510
+       0xFEEC49CD, 0x32464953, 0xBCC94EB0, 0x70634E2E,
511
+       0xA9435C82, 0x65E95C1C, 0xEB665BFF, 0x27CC5B61,
512
+       0x2D095278, 0xE1A352E6, 0x6F2C5505, 0xA386559B,
513
+       0x061D761C, 0xCAB77682, 0x44387161, 0x889271FF,
514
+       0x825778E6, 0x4EFD7878, 0xC0727F9B, 0x0CD87F05,
515
+       0xD5F86DA9, 0x19526D37, 0x97DD6AD4, 0x5B776A4A,
516
+       0x51B26353, 0x9D1863CD, 0x1397642E, 0xDF3D64B0,
517
+       0x83D02561, 0x4F7A25FF, 0xC1F5221C, 0x0D5F2282,
518
+       0x079A2B9B, 0xCB302B05, 0x45BF2CE6, 0x89152C78,
519
+       0x50353ED4, 0x9C9F3E4A, 0x121039A9, 0xDEBA3937,
520
+       0xD47F302E, 0x18D530B0, 0x965A3753, 0x5AF037CD,
521
+       0xFF6B144A, 0x33C114D4, 0xBD4E1337, 0x71E413A9,
522
+       0x7B211AB0, 0xB78B1A2E, 0x39041DCD, 0xF5AE1D53,
523
+       0x2C8E0FFF, 0xE0240F61, 0x6EAB0882, 0xA201081C,
524
+       0xA8C40105, 0x646E019B, 0xEAE10678, 0x264B06E6
525
+   }
526
+};
527
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_tablegen.c Added
119
 
1
@@ -0,0 +1,117 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc32_tablegen.c
5
+/// \brief      Generate crc32_table_le.h and crc32_table_be.h
6
+///
7
+/// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c
8
+/// Add -DWORDS_BIGENDIAN to generate big endian table.
9
+/// Add -DLZ_HASH_TABLE to generate lz_encoder_hash_table.h (little endian).
10
+//
11
+//  Author:     Lasse Collin
12
+//
13
+//  This file has been put into the public domain.
14
+//  You can do whatever you want with this file.
15
+//
16
+///////////////////////////////////////////////////////////////////////////////
17
+
18
+#include <stdio.h>
19
+#include "../../common/tuklib_integer.h"
20
+
21
+
22
+static uint32_t crc32_table[8][256];
23
+
24
+
25
+static void
26
+init_crc32_table(void)
27
+{
28
+   static const uint32_t poly32 = UINT32_C(0xEDB88320);
29
+
30
+   for (size_t s = 0; s < 8; ++s) {
31
+       for (size_t b = 0; b < 256; ++b) {
32
+           uint32_t r = s == 0 ? b : crc32_table[s - 1][b];
33
+
34
+           for (size_t i = 0; i < 8; ++i) {
35
+               if (r & 1)
36
+                   r = (r >> 1) ^ poly32;
37
+               else
38
+                   r >>= 1;
39
+           }
40
+
41
+           crc32_table[s][b] = r;
42
+       }
43
+   }
44
+
45
+#ifdef WORDS_BIGENDIAN
46
+   for (size_t s = 0; s < 8; ++s)
47
+       for (size_t b = 0; b < 256; ++b)
48
+           crc32_table[s][b] = bswap32(crc32_table[s][b]);
49
+#endif
50
+
51
+   return;
52
+}
53
+
54
+
55
+static void
56
+print_crc32_table(void)
57
+{
58
+   printf("/* This file has been automatically generated by "
59
+           "crc32_tablegen.c. */\n\n"
60
+           "const uint32_t lzma_crc32_table[8][256] = {\n\t{");
61
+
62
+   for (size_t s = 0; s < 8; ++s) {
63
+       for (size_t b = 0; b < 256; ++b) {
64
+           if ((b % 4) == 0)
65
+               printf("\n\t\t");
66
+
67
+           printf("0x%08" PRIX32, crc32_table[s][b]);
68
+
69
+           if (b != 255)
70
+               printf(",%s", (b+1) % 4 == 0 ? "" : " ");
71
+       }
72
+
73
+       if (s == 7)
74
+           printf("\n\t}\n};\n");
75
+       else
76
+           printf("\n\t}, {");
77
+   }
78
+
79
+   return;
80
+}
81
+
82
+
83
+static void
84
+print_lz_table(void)
85
+{
86
+   printf("/* This file has been automatically generated by "
87
+           "crc32_tablegen.c. */\n\n"
88
+           "const uint32_t lzma_lz_hash_table[256] = {");
89
+
90
+   for (size_t b = 0; b < 256; ++b) {
91
+       if ((b % 4) == 0)
92
+           printf("\n\t");
93
+
94
+       printf("0x%08" PRIX32, crc32_table[0][b]);
95
+
96
+       if (b != 255)
97
+           printf(",%s", (b+1) % 4 == 0 ? "" : " ");
98
+   }
99
+
100
+   printf("\n};\n");
101
+
102
+   return;
103
+}
104
+
105
+
106
+int
107
+main(void)
108
+{
109
+   init_crc32_table();
110
+
111
+#ifdef LZ_HASH_TABLE
112
+   print_lz_table();
113
+#else
114
+   print_crc32_table();
115
+#endif
116
+
117
+   return 0;
118
+}
119
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc32_x86.S Added
306
 
1
@@ -0,0 +1,304 @@
2
+/*
3
+ * Speed-optimized CRC32 using slicing-by-eight algorithm
4
+ *
5
+ * This uses only i386 instructions, but it is optimized for i686 and later
6
+ * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2). For i586
7
+ * (e.g. Pentium), slicing-by-four would be better, and even the C version
8
+ * of slicing-by-eight built with gcc -march=i586 tends to be a little bit
9
+ * better than this. Very few probably run this code on i586 or older x86
10
+ * so this shouldn't be a problem in practice.
11
+ *
12
+ * Authors: Igor Pavlov (original version)
13
+ *          Lasse Collin (AT&T syntax, PIC support, better portability)
14
+ *
15
+ * This file has been put into the public domain.
16
+ * You can do whatever you want with this file.
17
+ *
18
+ * This code needs lzma_crc32_table, which can be created using the
19
+ * following C code:
20
+
21
+uint32_t lzma_crc32_table[8][256];
22
+
23
+void
24
+init_table(void)
25
+{
26
+   // IEEE-802.3
27
+   static const uint32_t poly32 = UINT32_C(0xEDB88320);
28
+
29
+   // Castagnoli
30
+   // static const uint32_t poly32 = UINT32_C(0x82F63B78);
31
+
32
+   // Koopman
33
+   // static const uint32_t poly32 = UINT32_C(0xEB31D82E);
34
+
35
+   for (size_t s = 0; s < 8; ++s) {
36
+       for (size_t b = 0; b < 256; ++b) {
37
+           uint32_t r = s == 0 ? b : lzma_crc32_table[s - 1][b];
38
+
39
+           for (size_t i = 0; i < 8; ++i) {
40
+               if (r & 1)
41
+                   r = (r >> 1) ^ poly32;
42
+               else
43
+                   r >>= 1;
44
+           }
45
+
46
+           lzma_crc32_table[s][b] = r;
47
+       }
48
+   }
49
+}
50
+
51
+ * The prototype of the CRC32 function:
52
+ * extern uint32_t lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc);
53
+ */
54
+
55
+/*
56
+ * On some systems, the functions need to be prefixed. The prefix is
57
+ * usually an underscore.
58
+ */
59
+#ifndef __USER_LABEL_PREFIX__
60
+#  define __USER_LABEL_PREFIX__
61
+#endif
62
+#define MAKE_SYM_CAT(prefix, sym) prefix ## sym
63
+#define MAKE_SYM(prefix, sym) MAKE_SYM_CAT(prefix, sym)
64
+#define LZMA_CRC32 MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc32)
65
+#define LZMA_CRC32_TABLE MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc32_table)
66
+
67
+/*
68
+ * Solaris assembler doesn't have .p2align, and Darwin uses .align
69
+ * differently than GNU/Linux and Solaris.
70
+ */
71
+#if defined(__APPLE__) || defined(__MSDOS__)
72
+#  define ALIGN(pow2, abs) .align pow2
73
+#else
74
+#  define ALIGN(pow2, abs) .align abs
75
+#endif
76
+
77
+   .text
78
+   .globl  LZMA_CRC32
79
+
80
+#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) \
81
+       && !defined(__MSDOS__)
82
+   .type   LZMA_CRC32, @function
83
+#endif
84
+
85
+   ALIGN(4, 16)
86
+LZMA_CRC32:
87
+   /*
88
+    * Register usage:
89
+    * %eax crc
90
+    * %esi buf
91
+    * %edi size or buf + size
92
+    * %ebx lzma_crc32_table
93
+    * %ebp Table index
94
+    * %ecx Temporary
95
+    * %edx Temporary
96
+    */
97
+   pushl   %ebx
98
+   pushl   %esi
99
+   pushl   %edi
100
+   pushl   %ebp
101
+   movl    0x14(%esp), %esi /* buf */
102
+   movl    0x18(%esp), %edi /* size */
103
+   movl    0x1C(%esp), %eax /* crc */
104
+
105
+   /*
106
+    * Store the address of lzma_crc32_table to %ebx. This is needed to
107
+    * get position-independent code (PIC).
108
+    *
109
+    * The PIC macro is defined by libtool, while __PIC__ is defined
110
+    * by GCC but only on some systems. Testing for both makes it simpler
111
+    * to test this code without libtool, and keeps the code working also
112
+    * when built with libtool but using something else than GCC.
113
+    *
114
+    * I understood that libtool may define PIC on Windows even though
115
+    * the code in Windows DLLs is not PIC in sense that it is in ELF
116
+    * binaries, so we need a separate check to always use the non-PIC
117
+    * code on Windows.
118
+    */
119
+#if (!defined(PIC) && !defined(__PIC__)) \
120
+       || (defined(_WIN32) || defined(__CYGWIN__))
121
+   /* Not PIC */
122
+   movl    $ LZMA_CRC32_TABLE, %ebx
123
+#elif defined(__APPLE__)
124
+   /* Mach-O */
125
+   call    .L_get_pc
126
+.L_pic:
127
+   leal    .L_lzma_crc32_table$non_lazy_ptr-.L_pic(%ebx), %ebx
128
+   movl    (%ebx), %ebx
129
+#else
130
+   /* ELF */
131
+   call    .L_get_pc
132
+   addl    $_GLOBAL_OFFSET_TABLE_, %ebx
133
+   movl    LZMA_CRC32_TABLE@GOT(%ebx), %ebx
134
+#endif
135
+
136
+   /* Complement the initial value. */
137
+   notl    %eax
138
+
139
+   ALIGN(4, 16)
140
+.L_align:
141
+   /*
142
+    * Check if there is enough input to use slicing-by-eight.
143
+    * We need 16 bytes, because the loop pre-reads eight bytes.
144
+    */
145
+   cmpl    $16, %edi
146
+   jb  .L_rest
147
+
148
+   /* Check if we have reached alignment of eight bytes. */
149
+   testl   $7, %esi
150
+   jz  .L_slice
151
+
152
+   /* Calculate CRC of the next input byte. */
153
+   movzbl  (%esi), %ebp
154
+   incl    %esi
155
+   movzbl  %al, %ecx
156
+   xorl    %ecx, %ebp
157
+   shrl    $8, %eax
158
+   xorl    (%ebx, %ebp, 4), %eax
159
+   decl    %edi
160
+   jmp .L_align
161
+
162
+   ALIGN(2, 4)
163
+.L_slice:
164
+   /*
165
+    * If we get here, there's at least 16 bytes of aligned input
166
+    * available. Make %edi multiple of eight bytes. Store the possible
167
+    * remainder over the "size" variable in the argument stack.
168
+    */
169
+   movl    %edi, 0x18(%esp)
170
+   andl    $-8, %edi
171
+   subl    %edi, 0x18(%esp)
172
+
173
+   /*
174
+    * Let %edi be buf + size - 8 while running the main loop. This way
175
+    * we can compare for equality to determine when exit the loop.
176
+    */
177
+   addl    %esi, %edi
178
+   subl    $8, %edi
179
+
180
+   /* Read in the first eight aligned bytes. */
181
+   xorl    (%esi), %eax
182
+   movl    4(%esi), %ecx
183
+   movzbl  %cl, %ebp
184
+
185
+.L_loop:
186
+   movl    0x0C00(%ebx, %ebp, 4), %edx
187
+   movzbl  %ch, %ebp
188
+   xorl    0x0800(%ebx, %ebp, 4), %edx
189
+   shrl    $16, %ecx
190
+   xorl    8(%esi), %edx
191
+   movzbl  %cl, %ebp
192
+   xorl    0x0400(%ebx, %ebp, 4), %edx
193
+   movzbl  %ch, %ebp
194
+   xorl    (%ebx, %ebp, 4), %edx
195
+   movzbl  %al, %ebp
196
+
197
+   /*
198
+    * Read the next four bytes, for which the CRC is calculated
199
+    * on the next interation of the loop.
200
+    */
201
+   movl    12(%esi), %ecx
202
+
203
+   xorl    0x1C00(%ebx, %ebp, 4), %edx
204
+   movzbl  %ah, %ebp
205
+   shrl    $16, %eax
206
+   xorl    0x1800(%ebx, %ebp, 4), %edx
207
+   movzbl  %ah, %ebp
208
+   movzbl  %al, %eax
209
+   movl    0x1400(%ebx, %eax, 4), %eax
210
+   addl    $8, %esi
211
+   xorl    %edx, %eax
212
+   xorl    0x1000(%ebx, %ebp, 4), %eax
213
+
214
+   /* Check for end of aligned input. */
215
+   cmpl    %edi, %esi
216
+   movzbl  %cl, %ebp
217
+   jne .L_loop
218
+
219
+   /*
220
+    * Process the remaining eight bytes, which we have already
221
+    * copied to %ecx and %edx.
222
+    */
223
+   movl    0x0C00(%ebx, %ebp, 4), %edx
224
+   movzbl  %ch, %ebp
225
+   xorl    0x0800(%ebx, %ebp, 4), %edx
226
+   shrl    $16, %ecx
227
+   movzbl  %cl, %ebp
228
+   xorl    0x0400(%ebx, %ebp, 4), %edx
229
+   movzbl  %ch, %ebp
230
+   xorl    (%ebx, %ebp, 4), %edx
231
+   movzbl  %al, %ebp
232
+
233
+   xorl    0x1C00(%ebx, %ebp, 4), %edx
234
+   movzbl  %ah, %ebp
235
+   shrl    $16, %eax
236
+   xorl    0x1800(%ebx, %ebp, 4), %edx
237
+   movzbl  %ah, %ebp
238
+   movzbl  %al, %eax
239
+   movl    0x1400(%ebx, %eax, 4), %eax
240
+   addl    $8, %esi
241
+   xorl    %edx, %eax
242
+   xorl    0x1000(%ebx, %ebp, 4), %eax
243
+
244
+   /* Copy the number of remaining bytes to %edi. */
245
+   movl    0x18(%esp), %edi
246
+
247
+.L_rest:
248
+   /* Check for end of input. */
249
+   testl   %edi, %edi
250
+   jz  .L_return
251
+
252
+   /* Calculate CRC of the next input byte. */
253
+   movzbl  (%esi), %ebp
254
+   incl    %esi
255
+   movzbl  %al, %ecx
256
+   xorl    %ecx, %ebp
257
+   shrl    $8, %eax
258
+   xorl    (%ebx, %ebp, 4), %eax
259
+   decl    %edi
260
+   jmp .L_rest
261
+
262
+.L_return:
263
+   /* Complement the final value. */
264
+   notl    %eax
265
+
266
+   popl    %ebp
267
+   popl    %edi
268
+   popl    %esi
269
+   popl    %ebx
270
+   ret
271
+
272
+#if defined(PIC) || defined(__PIC__)
273
+   ALIGN(4, 16)
274
+.L_get_pc:
275
+   movl    (%esp), %ebx
276
+   ret
277
+#endif
278
+
279
+#if defined(__APPLE__) && (defined(PIC) || defined(__PIC__))
280
+   /* Mach-O PIC */
281
+   .section __IMPORT,__pointers,non_lazy_symbol_pointers
282
+.L_lzma_crc32_table$non_lazy_ptr:
283
+   .indirect_symbol LZMA_CRC32_TABLE
284
+   .long 0
285
+
286
+#elif defined(_WIN32) || defined(__CYGWIN__)
287
+#  ifdef DLL_EXPORT
288
+   /* This is equivalent of __declspec(dllexport). */
289
+   .section .drectve
290
+   .ascii " -export:lzma_crc32"
291
+#  endif
292
+
293
+#elif !defined(__MSDOS__)
294
+   /* ELF */
295
+   .size   LZMA_CRC32, .-LZMA_CRC32
296
+#endif
297
+
298
+/*
299
+ * This is needed to support non-executable stack. It's ugly to
300
+ * use __linux__ here, but I don't know a way to detect when
301
+ * we are using GNU assembler.
302
+ */
303
+#if defined(__ELF__) && defined(__linux__)
304
+   .section    .note.GNU-stack,"",@progbits
305
+#endif
306
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_fast.c Added
74
 
1
@@ -0,0 +1,72 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc64.c
5
+/// \brief      CRC64 calculation
6
+///
7
+/// Calculate the CRC64 using the slice-by-four algorithm. This is the same
8
+/// idea that is used in crc32_fast.c, but for CRC64 we use only four tables
9
+/// instead of eight to avoid increasing CPU cache usage.
10
+//
11
+//  Author:     Lasse Collin
12
+//
13
+//  This file has been put into the public domain.
14
+//  You can do whatever you want with this file.
15
+//
16
+///////////////////////////////////////////////////////////////////////////////
17
+
18
+#include "check.h"
19
+#include "crc_macros.h"
20
+
21
+
22
+#ifdef WORDS_BIGENDIAN
23
+#  define A1(x) ((x) >> 56)
24
+#else
25
+#  define A1 A
26
+#endif
27
+
28
+
29
+// See the comments in crc32_fast.c. They aren't duplicated here.
30
+extern LZMA_API(uint64_t)
31
+lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
32
+{
33
+   crc = ~crc;
34
+
35
+#ifdef WORDS_BIGENDIAN
36
+   crc = bswap64(crc);
37
+#endif
38
+
39
+   if (size > 4) {
40
+       while ((uintptr_t)(buf) & 3) {
41
+           crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
42
+           --size;
43
+       }
44
+
45
+       const uint8_t *const limit = buf + (size & ~(size_t)(3));
46
+       size &= (size_t)(3);
47
+
48
+       while (buf < limit) {
49
+#ifdef WORDS_BIGENDIAN
50
+           const uint32_t tmp = (crc >> 32)
51
+                   ^ *(const uint32_t *)(buf);
52
+#else
53
+           const uint32_t tmp = crc ^ *(const uint32_t *)(buf);
54
+#endif
55
+           buf += 4;
56
+
57
+           crc = lzma_crc64_table[3][A(tmp)]
58
+               ^ lzma_crc64_table[2][B(tmp)]
59
+               ^ S32(crc)
60
+               ^ lzma_crc64_table[1][C(tmp)]
61
+               ^ lzma_crc64_table[0][D(tmp)];
62
+       }
63
+   }
64
+
65
+   while (size-- != 0)
66
+       crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
67
+
68
+#ifdef WORDS_BIGENDIAN
69
+   crc = bswap64(crc);
70
+#endif
71
+
72
+   return ~crc;
73
+}
74
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_small.c Added
55
 
1
@@ -0,0 +1,53 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc64_small.c
5
+/// \brief      CRC64 calculation (size-optimized)
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "check.h"
15
+
16
+
17
+static uint64_t crc64_table[256];
18
+
19
+
20
+static void
21
+crc64_init(void)
22
+{
23
+   static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
24
+
25
+   for (size_t b = 0; b < 256; ++b) {
26
+       uint64_t r = b;
27
+       for (size_t i = 0; i < 8; ++i) {
28
+           if (r & 1)
29
+               r = (r >> 1) ^ poly64;
30
+           else
31
+               r >>= 1;
32
+       }
33
+
34
+       crc64_table[b] = r;
35
+   }
36
+
37
+   return;
38
+}
39
+
40
+
41
+extern LZMA_API(uint64_t)
42
+lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
43
+{
44
+   mythread_once(crc64_init);
45
+
46
+   crc = ~crc;
47
+
48
+   while (size != 0) {
49
+       crc = crc64_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
50
+       --size;
51
+   }
52
+
53
+   return ~crc;
54
+}
55
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_table.c Added
21
 
1
@@ -0,0 +1,19 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc64_table.c
5
+/// \brief      Precalculated CRC64 table with correct endianness
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+#ifdef WORDS_BIGENDIAN
17
+#  include "crc64_table_be.h"
18
+#else
19
+#  include "crc64_table_le.h"
20
+#endif
21
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_table_be.h Added
523
 
1
@@ -0,0 +1,521 @@
2
+/* This file has been automatically generated by crc64_tablegen.c. */
3
+
4
+const uint64_t lzma_crc64_table[4][256] = {
5
+   {
6
+       UINT64_C(0x0000000000000000), UINT64_C(0x6F5FA703BE4C2EB3),
7
+       UINT64_C(0x5BA040A8573684F4), UINT64_C(0x34FFE7ABE97AAA47),
8
+       UINT64_C(0x335E8FFF84C3D07B), UINT64_C(0x5C0128FC3A8FFEC8),
9
+       UINT64_C(0x68FECF57D3F5548F), UINT64_C(0x07A168546DB97A3C),
10
+       UINT64_C(0x66BC1EFF0987A1F7), UINT64_C(0x09E3B9FCB7CB8F44),
11
+       UINT64_C(0x3D1C5E575EB12503), UINT64_C(0x5243F954E0FD0BB0),
12
+       UINT64_C(0x55E291008D44718C), UINT64_C(0x3ABD360333085F3F),
13
+       UINT64_C(0x0E42D1A8DA72F578), UINT64_C(0x611D76AB643EDBCB),
14
+       UINT64_C(0x4966335138A19B7D), UINT64_C(0x2639945286EDB5CE),
15
+       UINT64_C(0x12C673F96F971F89), UINT64_C(0x7D99D4FAD1DB313A),
16
+       UINT64_C(0x7A38BCAEBC624B06), UINT64_C(0x15671BAD022E65B5),
17
+       UINT64_C(0x2198FC06EB54CFF2), UINT64_C(0x4EC75B055518E141),
18
+       UINT64_C(0x2FDA2DAE31263A8A), UINT64_C(0x40858AAD8F6A1439),
19
+       UINT64_C(0x747A6D066610BE7E), UINT64_C(0x1B25CA05D85C90CD),
20
+       UINT64_C(0x1C84A251B5E5EAF1), UINT64_C(0x73DB05520BA9C442),
21
+       UINT64_C(0x4724E2F9E2D36E05), UINT64_C(0x287B45FA5C9F40B6),
22
+       UINT64_C(0x92CC66A2704237FB), UINT64_C(0xFD93C1A1CE0E1948),
23
+       UINT64_C(0xC96C260A2774B30F), UINT64_C(0xA633810999389DBC),
24
+       UINT64_C(0xA192E95DF481E780), UINT64_C(0xCECD4E5E4ACDC933),
25
+       UINT64_C(0xFA32A9F5A3B76374), UINT64_C(0x956D0EF61DFB4DC7),
26
+       UINT64_C(0xF470785D79C5960C), UINT64_C(0x9B2FDF5EC789B8BF),
27
+       UINT64_C(0xAFD038F52EF312F8), UINT64_C(0xC08F9FF690BF3C4B),
28
+       UINT64_C(0xC72EF7A2FD064677), UINT64_C(0xA87150A1434A68C4),
29
+       UINT64_C(0x9C8EB70AAA30C283), UINT64_C(0xF3D11009147CEC30),
30
+       UINT64_C(0xDBAA55F348E3AC86), UINT64_C(0xB4F5F2F0F6AF8235),
31
+       UINT64_C(0x800A155B1FD52872), UINT64_C(0xEF55B258A19906C1),
32
+       UINT64_C(0xE8F4DA0CCC207CFD), UINT64_C(0x87AB7D0F726C524E),
33
+       UINT64_C(0xB3549AA49B16F809), UINT64_C(0xDC0B3DA7255AD6BA),
34
+       UINT64_C(0xBD164B0C41640D71), UINT64_C(0xD249EC0FFF2823C2),
35
+       UINT64_C(0xE6B60BA416528985), UINT64_C(0x89E9ACA7A81EA736),
36
+       UINT64_C(0x8E48C4F3C5A7DD0A), UINT64_C(0xE11763F07BEBF3B9),
37
+       UINT64_C(0xD5E8845B929159FE), UINT64_C(0xBAB723582CDD774D),
38
+       UINT64_C(0xA187C3EBCA2BB664), UINT64_C(0xCED864E8746798D7),
39
+       UINT64_C(0xFA2783439D1D3290), UINT64_C(0x9578244023511C23),
40
+       UINT64_C(0x92D94C144EE8661F), UINT64_C(0xFD86EB17F0A448AC),
41
+       UINT64_C(0xC9790CBC19DEE2EB), UINT64_C(0xA626ABBFA792CC58),
42
+       UINT64_C(0xC73BDD14C3AC1793), UINT64_C(0xA8647A177DE03920),
43
+       UINT64_C(0x9C9B9DBC949A9367), UINT64_C(0xF3C43ABF2AD6BDD4),
44
+       UINT64_C(0xF46552EB476FC7E8), UINT64_C(0x9B3AF5E8F923E95B),
45
+       UINT64_C(0xAFC512431059431C), UINT64_C(0xC09AB540AE156DAF),
46
+       UINT64_C(0xE8E1F0BAF28A2D19), UINT64_C(0x87BE57B94CC603AA),
47
+       UINT64_C(0xB341B012A5BCA9ED), UINT64_C(0xDC1E17111BF0875E),
48
+       UINT64_C(0xDBBF7F457649FD62), UINT64_C(0xB4E0D846C805D3D1),
49
+       UINT64_C(0x801F3FED217F7996), UINT64_C(0xEF4098EE9F335725),
50
+       UINT64_C(0x8E5DEE45FB0D8CEE), UINT64_C(0xE10249464541A25D),
51
+       UINT64_C(0xD5FDAEEDAC3B081A), UINT64_C(0xBAA209EE127726A9),
52
+       UINT64_C(0xBD0361BA7FCE5C95), UINT64_C(0xD25CC6B9C1827226),
53
+       UINT64_C(0xE6A3211228F8D861), UINT64_C(0x89FC861196B4F6D2),
54
+       UINT64_C(0x334BA549BA69819F), UINT64_C(0x5C14024A0425AF2C),
55
+       UINT64_C(0x68EBE5E1ED5F056B), UINT64_C(0x07B442E253132BD8),
56
+       UINT64_C(0x00152AB63EAA51E4), UINT64_C(0x6F4A8DB580E67F57),
57
+       UINT64_C(0x5BB56A1E699CD510), UINT64_C(0x34EACD1DD7D0FBA3),
58
+       UINT64_C(0x55F7BBB6B3EE2068), UINT64_C(0x3AA81CB50DA20EDB),
59
+       UINT64_C(0x0E57FB1EE4D8A49C), UINT64_C(0x61085C1D5A948A2F),
60
+       UINT64_C(0x66A93449372DF013), UINT64_C(0x09F6934A8961DEA0),
61
+       UINT64_C(0x3D0974E1601B74E7), UINT64_C(0x5256D3E2DE575A54),
62
+       UINT64_C(0x7A2D961882C81AE2), UINT64_C(0x1572311B3C843451),
63
+       UINT64_C(0x218DD6B0D5FE9E16), UINT64_C(0x4ED271B36BB2B0A5),
64
+       UINT64_C(0x497319E7060BCA99), UINT64_C(0x262CBEE4B847E42A),
65
+       UINT64_C(0x12D3594F513D4E6D), UINT64_C(0x7D8CFE4CEF7160DE),
66
+       UINT64_C(0x1C9188E78B4FBB15), UINT64_C(0x73CE2FE4350395A6),
67
+       UINT64_C(0x4731C84FDC793FE1), UINT64_C(0x286E6F4C62351152),
68
+       UINT64_C(0x2FCF07180F8C6B6E), UINT64_C(0x4090A01BB1C045DD),
69
+       UINT64_C(0x746F47B058BAEF9A), UINT64_C(0x1B30E0B3E6F6C129),
70
+       UINT64_C(0x420F87D795576CC9), UINT64_C(0x2D5020D42B1B427A),
71
+       UINT64_C(0x19AFC77FC261E83D), UINT64_C(0x76F0607C7C2DC68E),
72
+       UINT64_C(0x715108281194BCB2), UINT64_C(0x1E0EAF2BAFD89201),
73
+       UINT64_C(0x2AF1488046A23846), UINT64_C(0x45AEEF83F8EE16F5),
74
+       UINT64_C(0x24B399289CD0CD3E), UINT64_C(0x4BEC3E2B229CE38D),
75
+       UINT64_C(0x7F13D980CBE649CA), UINT64_C(0x104C7E8375AA6779),
76
+       UINT64_C(0x17ED16D718131D45), UINT64_C(0x78B2B1D4A65F33F6),
77
+       UINT64_C(0x4C4D567F4F2599B1), UINT64_C(0x2312F17CF169B702),
78
+       UINT64_C(0x0B69B486ADF6F7B4), UINT64_C(0x6436138513BAD907),
79
+       UINT64_C(0x50C9F42EFAC07340), UINT64_C(0x3F96532D448C5DF3),
80
+       UINT64_C(0x38373B79293527CF), UINT64_C(0x57689C7A9779097C),
81
+       UINT64_C(0x63977BD17E03A33B), UINT64_C(0x0CC8DCD2C04F8D88),
82
+       UINT64_C(0x6DD5AA79A4715643), UINT64_C(0x028A0D7A1A3D78F0),
83
+       UINT64_C(0x3675EAD1F347D2B7), UINT64_C(0x592A4DD24D0BFC04),
84
+       UINT64_C(0x5E8B258620B28638), UINT64_C(0x31D482859EFEA88B),
85
+       UINT64_C(0x052B652E778402CC), UINT64_C(0x6A74C22DC9C82C7F),
86
+       UINT64_C(0xD0C3E175E5155B32), UINT64_C(0xBF9C46765B597581),
87
+       UINT64_C(0x8B63A1DDB223DFC6), UINT64_C(0xE43C06DE0C6FF175),
88
+       UINT64_C(0xE39D6E8A61D68B49), UINT64_C(0x8CC2C989DF9AA5FA),
89
+       UINT64_C(0xB83D2E2236E00FBD), UINT64_C(0xD762892188AC210E),
90
+       UINT64_C(0xB67FFF8AEC92FAC5), UINT64_C(0xD920588952DED476),
91
+       UINT64_C(0xEDDFBF22BBA47E31), UINT64_C(0x8280182105E85082),
92
+       UINT64_C(0x8521707568512ABE), UINT64_C(0xEA7ED776D61D040D),
93
+       UINT64_C(0xDE8130DD3F67AE4A), UINT64_C(0xB1DE97DE812B80F9),
94
+       UINT64_C(0x99A5D224DDB4C04F), UINT64_C(0xF6FA752763F8EEFC),
95
+       UINT64_C(0xC205928C8A8244BB), UINT64_C(0xAD5A358F34CE6A08),
96
+       UINT64_C(0xAAFB5DDB59771034), UINT64_C(0xC5A4FAD8E73B3E87),
97
+       UINT64_C(0xF15B1D730E4194C0), UINT64_C(0x9E04BA70B00DBA73),
98
+       UINT64_C(0xFF19CCDBD43361B8), UINT64_C(0x90466BD86A7F4F0B),
99
+       UINT64_C(0xA4B98C738305E54C), UINT64_C(0xCBE62B703D49CBFF),
100
+       UINT64_C(0xCC47432450F0B1C3), UINT64_C(0xA318E427EEBC9F70),
101
+       UINT64_C(0x97E7038C07C63537), UINT64_C(0xF8B8A48FB98A1B84),
102
+       UINT64_C(0xE388443C5F7CDAAD), UINT64_C(0x8CD7E33FE130F41E),
103
+       UINT64_C(0xB8280494084A5E59), UINT64_C(0xD777A397B60670EA),
104
+       UINT64_C(0xD0D6CBC3DBBF0AD6), UINT64_C(0xBF896CC065F32465),
105
+       UINT64_C(0x8B768B6B8C898E22), UINT64_C(0xE4292C6832C5A091),
106
+       UINT64_C(0x85345AC356FB7B5A), UINT64_C(0xEA6BFDC0E8B755E9),
107
+       UINT64_C(0xDE941A6B01CDFFAE), UINT64_C(0xB1CBBD68BF81D11D),
108
+       UINT64_C(0xB66AD53CD238AB21), UINT64_C(0xD935723F6C748592),
109
+       UINT64_C(0xEDCA9594850E2FD5), UINT64_C(0x829532973B420166),
110
+       UINT64_C(0xAAEE776D67DD41D0), UINT64_C(0xC5B1D06ED9916F63),
111
+       UINT64_C(0xF14E37C530EBC524), UINT64_C(0x9E1190C68EA7EB97),
112
+       UINT64_C(0x99B0F892E31E91AB), UINT64_C(0xF6EF5F915D52BF18),
113
+       UINT64_C(0xC210B83AB428155F), UINT64_C(0xAD4F1F390A643BEC),
114
+       UINT64_C(0xCC5269926E5AE027), UINT64_C(0xA30DCE91D016CE94),
115
+       UINT64_C(0x97F2293A396C64D3), UINT64_C(0xF8AD8E3987204A60),
116
+       UINT64_C(0xFF0CE66DEA99305C), UINT64_C(0x9053416E54D51EEF),
117
+       UINT64_C(0xA4ACA6C5BDAFB4A8), UINT64_C(0xCBF301C603E39A1B),
118
+       UINT64_C(0x7144229E2F3EED56), UINT64_C(0x1E1B859D9172C3E5),
119
+       UINT64_C(0x2AE46236780869A2), UINT64_C(0x45BBC535C6444711),
120
+       UINT64_C(0x421AAD61ABFD3D2D), UINT64_C(0x2D450A6215B1139E),
121
+       UINT64_C(0x19BAEDC9FCCBB9D9), UINT64_C(0x76E54ACA4287976A),
122
+       UINT64_C(0x17F83C6126B94CA1), UINT64_C(0x78A79B6298F56212),
123
+       UINT64_C(0x4C587CC9718FC855), UINT64_C(0x2307DBCACFC3E6E6),
124
+       UINT64_C(0x24A6B39EA27A9CDA), UINT64_C(0x4BF9149D1C36B269),
125
+       UINT64_C(0x7F06F336F54C182E), UINT64_C(0x105954354B00369D),
126
+       UINT64_C(0x382211CF179F762B), UINT64_C(0x577DB6CCA9D35898),
127
+       UINT64_C(0x6382516740A9F2DF), UINT64_C(0x0CDDF664FEE5DC6C),
128
+       UINT64_C(0x0B7C9E30935CA650), UINT64_C(0x642339332D1088E3),
129
+       UINT64_C(0x50DCDE98C46A22A4), UINT64_C(0x3F83799B7A260C17),
130
+       UINT64_C(0x5E9E0F301E18D7DC), UINT64_C(0x31C1A833A054F96F),
131
+       UINT64_C(0x053E4F98492E5328), UINT64_C(0x6A61E89BF7627D9B),
132
+       UINT64_C(0x6DC080CF9ADB07A7), UINT64_C(0x029F27CC24972914),
133
+       UINT64_C(0x3660C067CDED8353), UINT64_C(0x593F676473A1ADE0)
134
+   }, {
135
+       UINT64_C(0x0000000000000000), UINT64_C(0x0DF1D05C9279E954),
136
+       UINT64_C(0x1AE2A1B924F3D2A9), UINT64_C(0x171371E5B68A3BFD),
137
+       UINT64_C(0xB1DA4DDC62497DC1), UINT64_C(0xBC2B9D80F0309495),
138
+       UINT64_C(0xAB38EC6546BAAF68), UINT64_C(0xA6C93C39D4C3463C),
139
+       UINT64_C(0xE7AB9517EE3D2210), UINT64_C(0xEA5A454B7C44CB44),
140
+       UINT64_C(0xFD4934AECACEF0B9), UINT64_C(0xF0B8E4F258B719ED),
141
+       UINT64_C(0x5671D8CB8C745FD1), UINT64_C(0x5B8008971E0DB685),
142
+       UINT64_C(0x4C937972A8878D78), UINT64_C(0x4162A92E3AFE642C),
143
+       UINT64_C(0xCE572B2FDC7B4420), UINT64_C(0xC3A6FB734E02AD74),
144
+       UINT64_C(0xD4B58A96F8889689), UINT64_C(0xD9445ACA6AF17FDD),
145
+       UINT64_C(0x7F8D66F3BE3239E1), UINT64_C(0x727CB6AF2C4BD0B5),
146
+       UINT64_C(0x656FC74A9AC1EB48), UINT64_C(0x689E171608B8021C),
147
+       UINT64_C(0x29FCBE3832466630), UINT64_C(0x240D6E64A03F8F64),
148
+       UINT64_C(0x331E1F8116B5B499), UINT64_C(0x3EEFCFDD84CC5DCD),
149
+       UINT64_C(0x9826F3E4500F1BF1), UINT64_C(0x95D723B8C276F2A5),
150
+       UINT64_C(0x82C4525D74FCC958), UINT64_C(0x8F358201E685200C),
151
+       UINT64_C(0x9CAF565EB8F78840), UINT64_C(0x915E86022A8E6114),
152
+       UINT64_C(0x864DF7E79C045AE9), UINT64_C(0x8BBC27BB0E7DB3BD),
153
+       UINT64_C(0x2D751B82DABEF581), UINT64_C(0x2084CBDE48C71CD5),
154
+       UINT64_C(0x3797BA3BFE4D2728), UINT64_C(0x3A666A676C34CE7C),
155
+       UINT64_C(0x7B04C34956CAAA50), UINT64_C(0x76F51315C4B34304),
156
+       UINT64_C(0x61E662F0723978F9), UINT64_C(0x6C17B2ACE04091AD),
157
+       UINT64_C(0xCADE8E953483D791), UINT64_C(0xC72F5EC9A6FA3EC5),
158
+       UINT64_C(0xD03C2F2C10700538), UINT64_C(0xDDCDFF708209EC6C),
159
+       UINT64_C(0x52F87D71648CCC60), UINT64_C(0x5F09AD2DF6F52534),
160
+       UINT64_C(0x481ADCC8407F1EC9), UINT64_C(0x45EB0C94D206F79D),
161
+       UINT64_C(0xE32230AD06C5B1A1), UINT64_C(0xEED3E0F194BC58F5),
162
+       UINT64_C(0xF9C0911422366308), UINT64_C(0xF4314148B04F8A5C),
163
+       UINT64_C(0xB553E8668AB1EE70), UINT64_C(0xB8A2383A18C80724),
164
+       UINT64_C(0xAFB149DFAE423CD9), UINT64_C(0xA24099833C3BD58D),
165
+       UINT64_C(0x0489A5BAE8F893B1), UINT64_C(0x097875E67A817AE5),
166
+       UINT64_C(0x1E6B0403CC0B4118), UINT64_C(0x139AD45F5E72A84C),
167
+       UINT64_C(0x385FADBC70EF1181), UINT64_C(0x35AE7DE0E296F8D5),
168
+       UINT64_C(0x22BD0C05541CC328), UINT64_C(0x2F4CDC59C6652A7C),
169
+       UINT64_C(0x8985E06012A66C40), UINT64_C(0x8474303C80DF8514),
170
+       UINT64_C(0x936741D93655BEE9), UINT64_C(0x9E969185A42C57BD),
171
+       UINT64_C(0xDFF438AB9ED23391), UINT64_C(0xD205E8F70CABDAC5),
172
+       UINT64_C(0xC5169912BA21E138), UINT64_C(0xC8E7494E2858086C),
173
+       UINT64_C(0x6E2E7577FC9B4E50), UINT64_C(0x63DFA52B6EE2A704),
174
+       UINT64_C(0x74CCD4CED8689CF9), UINT64_C(0x793D04924A1175AD),
175
+       UINT64_C(0xF6088693AC9455A1), UINT64_C(0xFBF956CF3EEDBCF5),
176
+       UINT64_C(0xECEA272A88678708), UINT64_C(0xE11BF7761A1E6E5C),
177
+       UINT64_C(0x47D2CB4FCEDD2860), UINT64_C(0x4A231B135CA4C134),
178
+       UINT64_C(0x5D306AF6EA2EFAC9), UINT64_C(0x50C1BAAA7857139D),
179
+       UINT64_C(0x11A3138442A977B1), UINT64_C(0x1C52C3D8D0D09EE5),
180
+       UINT64_C(0x0B41B23D665AA518), UINT64_C(0x06B06261F4234C4C),
181
+       UINT64_C(0xA0795E5820E00A70), UINT64_C(0xAD888E04B299E324),
182
+       UINT64_C(0xBA9BFFE10413D8D9), UINT64_C(0xB76A2FBD966A318D),
183
+       UINT64_C(0xA4F0FBE2C81899C1), UINT64_C(0xA9012BBE5A617095),
184
+       UINT64_C(0xBE125A5BECEB4B68), UINT64_C(0xB3E38A077E92A23C),
185
+       UINT64_C(0x152AB63EAA51E400), UINT64_C(0x18DB666238280D54),
186
+       UINT64_C(0x0FC817878EA236A9), UINT64_C(0x0239C7DB1CDBDFFD),
187
+       UINT64_C(0x435B6EF52625BBD1), UINT64_C(0x4EAABEA9B45C5285),
188
+       UINT64_C(0x59B9CF4C02D66978), UINT64_C(0x54481F1090AF802C),
189
+       UINT64_C(0xF2812329446CC610), UINT64_C(0xFF70F375D6152F44),
190
+       UINT64_C(0xE8638290609F14B9), UINT64_C(0xE59252CCF2E6FDED),
191
+       UINT64_C(0x6AA7D0CD1463DDE1), UINT64_C(0x67560091861A34B5),
192
+       UINT64_C(0x7045717430900F48), UINT64_C(0x7DB4A128A2E9E61C),
193
+       UINT64_C(0xDB7D9D11762AA020), UINT64_C(0xD68C4D4DE4534974),
194
+       UINT64_C(0xC19F3CA852D97289), UINT64_C(0xCC6EECF4C0A09BDD),
195
+       UINT64_C(0x8D0C45DAFA5EFFF1), UINT64_C(0x80FD9586682716A5),
196
+       UINT64_C(0x97EEE463DEAD2D58), UINT64_C(0x9A1F343F4CD4C40C),
197
+       UINT64_C(0x3CD6080698178230), UINT64_C(0x3127D85A0A6E6B64),
198
+       UINT64_C(0x2634A9BFBCE45099), UINT64_C(0x2BC579E32E9DB9CD),
199
+       UINT64_C(0xF5A054D6CA71FB90), UINT64_C(0xF851848A580812C4),
200
+       UINT64_C(0xEF42F56FEE822939), UINT64_C(0xE2B325337CFBC06D),
201
+       UINT64_C(0x447A190AA8388651), UINT64_C(0x498BC9563A416F05),
202
+       UINT64_C(0x5E98B8B38CCB54F8), UINT64_C(0x536968EF1EB2BDAC),
203
+       UINT64_C(0x120BC1C1244CD980), UINT64_C(0x1FFA119DB63530D4),
204
+       UINT64_C(0x08E9607800BF0B29), UINT64_C(0x0518B02492C6E27D),
205
+       UINT64_C(0xA3D18C1D4605A441), UINT64_C(0xAE205C41D47C4D15),
206
+       UINT64_C(0xB9332DA462F676E8), UINT64_C(0xB4C2FDF8F08F9FBC),
207
+       UINT64_C(0x3BF77FF9160ABFB0), UINT64_C(0x3606AFA5847356E4),
208
+       UINT64_C(0x2115DE4032F96D19), UINT64_C(0x2CE40E1CA080844D),
209
+       UINT64_C(0x8A2D32257443C271), UINT64_C(0x87DCE279E63A2B25),
210
+       UINT64_C(0x90CF939C50B010D8), UINT64_C(0x9D3E43C0C2C9F98C),
211
+       UINT64_C(0xDC5CEAEEF8379DA0), UINT64_C(0xD1AD3AB26A4E74F4),
212
+       UINT64_C(0xC6BE4B57DCC44F09), UINT64_C(0xCB4F9B0B4EBDA65D),
213
+       UINT64_C(0x6D86A7329A7EE061), UINT64_C(0x6077776E08070935),
214
+       UINT64_C(0x7764068BBE8D32C8), UINT64_C(0x7A95D6D72CF4DB9C),
215
+       UINT64_C(0x690F0288728673D0), UINT64_C(0x64FED2D4E0FF9A84),
216
+       UINT64_C(0x73EDA3315675A179), UINT64_C(0x7E1C736DC40C482D),
217
+       UINT64_C(0xD8D54F5410CF0E11), UINT64_C(0xD5249F0882B6E745),
218
+       UINT64_C(0xC237EEED343CDCB8), UINT64_C(0xCFC63EB1A64535EC),
219
+       UINT64_C(0x8EA4979F9CBB51C0), UINT64_C(0x835547C30EC2B894),
220
+       UINT64_C(0x94463626B8488369), UINT64_C(0x99B7E67A2A316A3D),
221
+       UINT64_C(0x3F7EDA43FEF22C01), UINT64_C(0x328F0A1F6C8BC555),
222
+       UINT64_C(0x259C7BFADA01FEA8), UINT64_C(0x286DABA6487817FC),
223
+       UINT64_C(0xA75829A7AEFD37F0), UINT64_C(0xAAA9F9FB3C84DEA4),
224
+       UINT64_C(0xBDBA881E8A0EE559), UINT64_C(0xB04B584218770C0D),
225
+       UINT64_C(0x1682647BCCB44A31), UINT64_C(0x1B73B4275ECDA365),
226
+       UINT64_C(0x0C60C5C2E8479898), UINT64_C(0x0191159E7A3E71CC),
227
+       UINT64_C(0x40F3BCB040C015E0), UINT64_C(0x4D026CECD2B9FCB4),
228
+       UINT64_C(0x5A111D096433C749), UINT64_C(0x57E0CD55F64A2E1D),
229
+       UINT64_C(0xF129F16C22896821), UINT64_C(0xFCD82130B0F08175),
230
+       UINT64_C(0xEBCB50D5067ABA88), UINT64_C(0xE63A8089940353DC),
231
+       UINT64_C(0xCDFFF96ABA9EEA11), UINT64_C(0xC00E293628E70345),
232
+       UINT64_C(0xD71D58D39E6D38B8), UINT64_C(0xDAEC888F0C14D1EC),
233
+       UINT64_C(0x7C25B4B6D8D797D0), UINT64_C(0x71D464EA4AAE7E84),
234
+       UINT64_C(0x66C7150FFC244579), UINT64_C(0x6B36C5536E5DAC2D),
235
+       UINT64_C(0x2A546C7D54A3C801), UINT64_C(0x27A5BC21C6DA2155),
236
+       UINT64_C(0x30B6CDC470501AA8), UINT64_C(0x3D471D98E229F3FC),
237
+       UINT64_C(0x9B8E21A136EAB5C0), UINT64_C(0x967FF1FDA4935C94),
238
+       UINT64_C(0x816C801812196769), UINT64_C(0x8C9D504480608E3D),
239
+       UINT64_C(0x03A8D24566E5AE31), UINT64_C(0x0E590219F49C4765),
240
+       UINT64_C(0x194A73FC42167C98), UINT64_C(0x14BBA3A0D06F95CC),
241
+       UINT64_C(0xB2729F9904ACD3F0), UINT64_C(0xBF834FC596D53AA4),
242
+       UINT64_C(0xA8903E20205F0159), UINT64_C(0xA561EE7CB226E80D),
243
+       UINT64_C(0xE403475288D88C21), UINT64_C(0xE9F2970E1AA16575),
244
+       UINT64_C(0xFEE1E6EBAC2B5E88), UINT64_C(0xF31036B73E52B7DC),
245
+       UINT64_C(0x55D90A8EEA91F1E0), UINT64_C(0x5828DAD278E818B4),
246
+       UINT64_C(0x4F3BAB37CE622349), UINT64_C(0x42CA7B6B5C1BCA1D),
247
+       UINT64_C(0x5150AF3402696251), UINT64_C(0x5CA17F6890108B05),
248
+       UINT64_C(0x4BB20E8D269AB0F8), UINT64_C(0x4643DED1B4E359AC),
249
+       UINT64_C(0xE08AE2E860201F90), UINT64_C(0xED7B32B4F259F6C4),
250
+       UINT64_C(0xFA68435144D3CD39), UINT64_C(0xF799930DD6AA246D),
251
+       UINT64_C(0xB6FB3A23EC544041), UINT64_C(0xBB0AEA7F7E2DA915),
252
+       UINT64_C(0xAC199B9AC8A792E8), UINT64_C(0xA1E84BC65ADE7BBC),
253
+       UINT64_C(0x072177FF8E1D3D80), UINT64_C(0x0AD0A7A31C64D4D4),
254
+       UINT64_C(0x1DC3D646AAEEEF29), UINT64_C(0x1032061A3897067D),
255
+       UINT64_C(0x9F07841BDE122671), UINT64_C(0x92F654474C6BCF25),
256
+       UINT64_C(0x85E525A2FAE1F4D8), UINT64_C(0x8814F5FE68981D8C),
257
+       UINT64_C(0x2EDDC9C7BC5B5BB0), UINT64_C(0x232C199B2E22B2E4),
258
+       UINT64_C(0x343F687E98A88919), UINT64_C(0x39CEB8220AD1604D),
259
+       UINT64_C(0x78AC110C302F0461), UINT64_C(0x755DC150A256ED35),
260
+       UINT64_C(0x624EB0B514DCD6C8), UINT64_C(0x6FBF60E986A53F9C),
261
+       UINT64_C(0xC9765CD0526679A0), UINT64_C(0xC4878C8CC01F90F4),
262
+       UINT64_C(0xD394FD697695AB09), UINT64_C(0xDE652D35E4EC425D)
263
+   }, {
264
+       UINT64_C(0x0000000000000000), UINT64_C(0xCB6D6A914AE10B3F),
265
+       UINT64_C(0x96DBD42295C2177E), UINT64_C(0x5DB6BEB3DF231C41),
266
+       UINT64_C(0x2CB7A9452A852FFC), UINT64_C(0xE7DAC3D4606424C3),
267
+       UINT64_C(0xBA6C7D67BF473882), UINT64_C(0x710117F6F5A633BD),
268
+       UINT64_C(0xDD705D247FA5876A), UINT64_C(0x161D37B535448C55),
269
+       UINT64_C(0x4BAB8906EA679014), UINT64_C(0x80C6E397A0869B2B),
270
+       UINT64_C(0xF1C7F4615520A896), UINT64_C(0x3AAA9EF01FC1A3A9),
271
+       UINT64_C(0x671C2043C0E2BFE8), UINT64_C(0xAC714AD28A03B4D7),
272
+       UINT64_C(0xBAE1BA48FE4A0FD5), UINT64_C(0x718CD0D9B4AB04EA),
273
+       UINT64_C(0x2C3A6E6A6B8818AB), UINT64_C(0xE75704FB21691394),
274
+       UINT64_C(0x9656130DD4CF2029), UINT64_C(0x5D3B799C9E2E2B16),
275
+       UINT64_C(0x008DC72F410D3757), UINT64_C(0xCBE0ADBE0BEC3C68),
276
+       UINT64_C(0x6791E76C81EF88BF), UINT64_C(0xACFC8DFDCB0E8380),
277
+       UINT64_C(0xF14A334E142D9FC1), UINT64_C(0x3A2759DF5ECC94FE),
278
+       UINT64_C(0x4B264E29AB6AA743), UINT64_C(0x804B24B8E18BAC7C),
279
+       UINT64_C(0xDDFD9A0B3EA8B03D), UINT64_C(0x1690F09A7449BB02),
280
+       UINT64_C(0xF1DD7B3ED73AC638), UINT64_C(0x3AB011AF9DDBCD07),
281
+       UINT64_C(0x6706AF1C42F8D146), UINT64_C(0xAC6BC58D0819DA79),
282
+       UINT64_C(0xDD6AD27BFDBFE9C4), UINT64_C(0x1607B8EAB75EE2FB),
283
+       UINT64_C(0x4BB10659687DFEBA), UINT64_C(0x80DC6CC8229CF585),
284
+       UINT64_C(0x2CAD261AA89F4152), UINT64_C(0xE7C04C8BE27E4A6D),
285
+       UINT64_C(0xBA76F2383D5D562C), UINT64_C(0x711B98A977BC5D13),
286
+       UINT64_C(0x001A8F5F821A6EAE), UINT64_C(0xCB77E5CEC8FB6591),
287
+       UINT64_C(0x96C15B7D17D879D0), UINT64_C(0x5DAC31EC5D3972EF),
288
+       UINT64_C(0x4B3CC1762970C9ED), UINT64_C(0x8051ABE76391C2D2),
289
+       UINT64_C(0xDDE71554BCB2DE93), UINT64_C(0x168A7FC5F653D5AC),
290
+       UINT64_C(0x678B683303F5E611), UINT64_C(0xACE602A24914ED2E),
291
+       UINT64_C(0xF150BC119637F16F), UINT64_C(0x3A3DD680DCD6FA50),
292
+       UINT64_C(0x964C9C5256D54E87), UINT64_C(0x5D21F6C31C3445B8),
293
+       UINT64_C(0x00974870C31759F9), UINT64_C(0xCBFA22E189F652C6),
294
+       UINT64_C(0xBAFB35177C50617B), UINT64_C(0x71965F8636B16A44),
295
+       UINT64_C(0x2C20E135E9927605), UINT64_C(0xE74D8BA4A3737D3A),
296
+       UINT64_C(0xE2BBF77CAE758C71), UINT64_C(0x29D69DEDE494874E),
297
+       UINT64_C(0x7460235E3BB79B0F), UINT64_C(0xBF0D49CF71569030),
298
+       UINT64_C(0xCE0C5E3984F0A38D), UINT64_C(0x056134A8CE11A8B2),
299
+       UINT64_C(0x58D78A1B1132B4F3), UINT64_C(0x93BAE08A5BD3BFCC),
300
+       UINT64_C(0x3FCBAA58D1D00B1B), UINT64_C(0xF4A6C0C99B310024),
301
+       UINT64_C(0xA9107E7A44121C65), UINT64_C(0x627D14EB0EF3175A),
302
+       UINT64_C(0x137C031DFB5524E7), UINT64_C(0xD811698CB1B42FD8),
303
+       UINT64_C(0x85A7D73F6E973399), UINT64_C(0x4ECABDAE247638A6),
304
+       UINT64_C(0x585A4D34503F83A4), UINT64_C(0x933727A51ADE889B),
305
+       UINT64_C(0xCE819916C5FD94DA), UINT64_C(0x05ECF3878F1C9FE5),
306
+       UINT64_C(0x74EDE4717ABAAC58), UINT64_C(0xBF808EE0305BA767),
307
+       UINT64_C(0xE2363053EF78BB26), UINT64_C(0x295B5AC2A599B019),
308
+       UINT64_C(0x852A10102F9A04CE), UINT64_C(0x4E477A81657B0FF1),
309
+       UINT64_C(0x13F1C432BA5813B0), UINT64_C(0xD89CAEA3F0B9188F),
310
+       UINT64_C(0xA99DB955051F2B32), UINT64_C(0x62F0D3C44FFE200D),
311
+       UINT64_C(0x3F466D7790DD3C4C), UINT64_C(0xF42B07E6DA3C3773),
312
+       UINT64_C(0x13668C42794F4A49), UINT64_C(0xD80BE6D333AE4176),
313
+       UINT64_C(0x85BD5860EC8D5D37), UINT64_C(0x4ED032F1A66C5608),
314
+       UINT64_C(0x3FD1250753CA65B5), UINT64_C(0xF4BC4F96192B6E8A),
315
+       UINT64_C(0xA90AF125C60872CB), UINT64_C(0x62679BB48CE979F4),
316
+       UINT64_C(0xCE16D16606EACD23), UINT64_C(0x057BBBF74C0BC61C),
317
+       UINT64_C(0x58CD05449328DA5D), UINT64_C(0x93A06FD5D9C9D162),
318
+       UINT64_C(0xE2A178232C6FE2DF), UINT64_C(0x29CC12B2668EE9E0),
319
+       UINT64_C(0x747AAC01B9ADF5A1), UINT64_C(0xBF17C690F34CFE9E),
320
+       UINT64_C(0xA987360A8705459C), UINT64_C(0x62EA5C9BCDE44EA3),
321
+       UINT64_C(0x3F5CE22812C752E2), UINT64_C(0xF43188B9582659DD),
322
+       UINT64_C(0x85309F4FAD806A60), UINT64_C(0x4E5DF5DEE761615F),
323
+       UINT64_C(0x13EB4B6D38427D1E), UINT64_C(0xD88621FC72A37621),
324
+       UINT64_C(0x74F76B2EF8A0C2F6), UINT64_C(0xBF9A01BFB241C9C9),
325
+       UINT64_C(0xE22CBF0C6D62D588), UINT64_C(0x2941D59D2783DEB7),
326
+       UINT64_C(0x5840C26BD225ED0A), UINT64_C(0x932DA8FA98C4E635),
327
+       UINT64_C(0xCE9B164947E7FA74), UINT64_C(0x05F67CD80D06F14B),
328
+       UINT64_C(0xC477EFF95CEB18E3), UINT64_C(0x0F1A8568160A13DC),
329
+       UINT64_C(0x52AC3BDBC9290F9D), UINT64_C(0x99C1514A83C804A2),
330
+       UINT64_C(0xE8C046BC766E371F), UINT64_C(0x23AD2C2D3C8F3C20),
331
+       UINT64_C(0x7E1B929EE3AC2061), UINT64_C(0xB576F80FA94D2B5E),
332
+       UINT64_C(0x1907B2DD234E9F89), UINT64_C(0xD26AD84C69AF94B6),
333
+       UINT64_C(0x8FDC66FFB68C88F7), UINT64_C(0x44B10C6EFC6D83C8),
334
+       UINT64_C(0x35B01B9809CBB075), UINT64_C(0xFEDD7109432ABB4A),
335
+       UINT64_C(0xA36BCFBA9C09A70B), UINT64_C(0x6806A52BD6E8AC34),
336
+       UINT64_C(0x7E9655B1A2A11736), UINT64_C(0xB5FB3F20E8401C09),
337
+       UINT64_C(0xE84D819337630048), UINT64_C(0x2320EB027D820B77),
338
+       UINT64_C(0x5221FCF4882438CA), UINT64_C(0x994C9665C2C533F5),
339
+       UINT64_C(0xC4FA28D61DE62FB4), UINT64_C(0x0F9742475707248B),
340
+       UINT64_C(0xA3E60895DD04905C), UINT64_C(0x688B620497E59B63),
341
+       UINT64_C(0x353DDCB748C68722), UINT64_C(0xFE50B62602278C1D),
342
+       UINT64_C(0x8F51A1D0F781BFA0), UINT64_C(0x443CCB41BD60B49F),
343
+       UINT64_C(0x198A75F26243A8DE), UINT64_C(0xD2E71F6328A2A3E1),
344
+       UINT64_C(0x35AA94C78BD1DEDB), UINT64_C(0xFEC7FE56C130D5E4),
345
+       UINT64_C(0xA37140E51E13C9A5), UINT64_C(0x681C2A7454F2C29A),
346
+       UINT64_C(0x191D3D82A154F127), UINT64_C(0xD2705713EBB5FA18),
347
+       UINT64_C(0x8FC6E9A03496E659), UINT64_C(0x44AB83317E77ED66),
348
+       UINT64_C(0xE8DAC9E3F47459B1), UINT64_C(0x23B7A372BE95528E),
349
+       UINT64_C(0x7E011DC161B64ECF), UINT64_C(0xB56C77502B5745F0),
350
+       UINT64_C(0xC46D60A6DEF1764D), UINT64_C(0x0F000A3794107D72),
351
+       UINT64_C(0x52B6B4844B336133), UINT64_C(0x99DBDE1501D26A0C),
352
+       UINT64_C(0x8F4B2E8F759BD10E), UINT64_C(0x4426441E3F7ADA31),
353
+       UINT64_C(0x1990FAADE059C670), UINT64_C(0xD2FD903CAAB8CD4F),
354
+       UINT64_C(0xA3FC87CA5F1EFEF2), UINT64_C(0x6891ED5B15FFF5CD),
355
+       UINT64_C(0x352753E8CADCE98C), UINT64_C(0xFE4A3979803DE2B3),
356
+       UINT64_C(0x523B73AB0A3E5664), UINT64_C(0x9956193A40DF5D5B),
357
+       UINT64_C(0xC4E0A7899FFC411A), UINT64_C(0x0F8DCD18D51D4A25),
358
+       UINT64_C(0x7E8CDAEE20BB7998), UINT64_C(0xB5E1B07F6A5A72A7),
359
+       UINT64_C(0xE8570ECCB5796EE6), UINT64_C(0x233A645DFF9865D9),
360
+       UINT64_C(0x26CC1885F29E9492), UINT64_C(0xEDA17214B87F9FAD),
361
+       UINT64_C(0xB017CCA7675C83EC), UINT64_C(0x7B7AA6362DBD88D3),
362
+       UINT64_C(0x0A7BB1C0D81BBB6E), UINT64_C(0xC116DB5192FAB051),
363
+       UINT64_C(0x9CA065E24DD9AC10), UINT64_C(0x57CD0F730738A72F),
364
+       UINT64_C(0xFBBC45A18D3B13F8), UINT64_C(0x30D12F30C7DA18C7),
365
+       UINT64_C(0x6D67918318F90486), UINT64_C(0xA60AFB1252180FB9),
366
+       UINT64_C(0xD70BECE4A7BE3C04), UINT64_C(0x1C668675ED5F373B),
367
+       UINT64_C(0x41D038C6327C2B7A), UINT64_C(0x8ABD5257789D2045),
368
+       UINT64_C(0x9C2DA2CD0CD49B47), UINT64_C(0x5740C85C46359078),
369
+       UINT64_C(0x0AF676EF99168C39), UINT64_C(0xC19B1C7ED3F78706),
370
+       UINT64_C(0xB09A0B882651B4BB), UINT64_C(0x7BF761196CB0BF84),
371
+       UINT64_C(0x2641DFAAB393A3C5), UINT64_C(0xED2CB53BF972A8FA),
372
+       UINT64_C(0x415DFFE973711C2D), UINT64_C(0x8A30957839901712),
373
+       UINT64_C(0xD7862BCBE6B30B53), UINT64_C(0x1CEB415AAC52006C),
374
+       UINT64_C(0x6DEA56AC59F433D1), UINT64_C(0xA6873C3D131538EE),
375
+       UINT64_C(0xFB31828ECC3624AF), UINT64_C(0x305CE81F86D72F90),
376
+       UINT64_C(0xD71163BB25A452AA), UINT64_C(0x1C7C092A6F455995),
377
+       UINT64_C(0x41CAB799B06645D4), UINT64_C(0x8AA7DD08FA874EEB),
378
+       UINT64_C(0xFBA6CAFE0F217D56), UINT64_C(0x30CBA06F45C07669),
379
+       UINT64_C(0x6D7D1EDC9AE36A28), UINT64_C(0xA610744DD0026117),
380
+       UINT64_C(0x0A613E9F5A01D5C0), UINT64_C(0xC10C540E10E0DEFF),
381
+       UINT64_C(0x9CBAEABDCFC3C2BE), UINT64_C(0x57D7802C8522C981),
382
+       UINT64_C(0x26D697DA7084FA3C), UINT64_C(0xEDBBFD4B3A65F103),
383
+       UINT64_C(0xB00D43F8E546ED42), UINT64_C(0x7B602969AFA7E67D),
384
+       UINT64_C(0x6DF0D9F3DBEE5D7F), UINT64_C(0xA69DB362910F5640),
385
+       UINT64_C(0xFB2B0DD14E2C4A01), UINT64_C(0x3046674004CD413E),
386
+       UINT64_C(0x414770B6F16B7283), UINT64_C(0x8A2A1A27BB8A79BC),
387
+       UINT64_C(0xD79CA49464A965FD), UINT64_C(0x1CF1CE052E486EC2),
388
+       UINT64_C(0xB08084D7A44BDA15), UINT64_C(0x7BEDEE46EEAAD12A),
389
+       UINT64_C(0x265B50F53189CD6B), UINT64_C(0xED363A647B68C654),
390
+       UINT64_C(0x9C372D928ECEF5E9), UINT64_C(0x575A4703C42FFED6),
391
+       UINT64_C(0x0AECF9B01B0CE297), UINT64_C(0xC181932151EDE9A8)
392
+   }, {
393
+       UINT64_C(0x0000000000000000), UINT64_C(0xDCA12C225E8AEE1D),
394
+       UINT64_C(0xB8435944BC14DD3B), UINT64_C(0x64E27566E29E3326),
395
+       UINT64_C(0x7087B2887829BA77), UINT64_C(0xAC269EAA26A3546A),
396
+       UINT64_C(0xC8C4EBCCC43D674C), UINT64_C(0x1465C7EE9AB78951),
397
+       UINT64_C(0xE00E6511F15274EF), UINT64_C(0x3CAF4933AFD89AF2),
398
+       UINT64_C(0x584D3C554D46A9D4), UINT64_C(0x84EC107713CC47C9),
399
+       UINT64_C(0x9089D799897BCE98), UINT64_C(0x4C28FBBBD7F12085),
400
+       UINT64_C(0x28CA8EDD356F13A3), UINT64_C(0xF46BA2FF6BE5FDBE),
401
+       UINT64_C(0x4503C48DC90A304C), UINT64_C(0x99A2E8AF9780DE51),
402
+       UINT64_C(0xFD409DC9751EED77), UINT64_C(0x21E1B1EB2B94036A),
403
+       UINT64_C(0x35847605B1238A3B), UINT64_C(0xE9255A27EFA96426),
404
+       UINT64_C(0x8DC72F410D375700), UINT64_C(0x5166036353BDB91D),
405
+       UINT64_C(0xA50DA19C385844A3), UINT64_C(0x79AC8DBE66D2AABE),
406
+       UINT64_C(0x1D4EF8D8844C9998), UINT64_C(0xC1EFD4FADAC67785),
407
+       UINT64_C(0xD58A13144071FED4), UINT64_C(0x092B3F361EFB10C9),
408
+       UINT64_C(0x6DC94A50FC6523EF), UINT64_C(0xB1686672A2EFCDF2),
409
+       UINT64_C(0x8A06881B93156098), UINT64_C(0x56A7A439CD9F8E85),
410
+       UINT64_C(0x3245D15F2F01BDA3), UINT64_C(0xEEE4FD7D718B53BE),
411
+       UINT64_C(0xFA813A93EB3CDAEF), UINT64_C(0x262016B1B5B634F2),
412
+       UINT64_C(0x42C263D7572807D4), UINT64_C(0x9E634FF509A2E9C9),
413
+       UINT64_C(0x6A08ED0A62471477), UINT64_C(0xB6A9C1283CCDFA6A),
414
+       UINT64_C(0xD24BB44EDE53C94C), UINT64_C(0x0EEA986C80D92751),
415
+       UINT64_C(0x1A8F5F821A6EAE00), UINT64_C(0xC62E73A044E4401D),
416
+       UINT64_C(0xA2CC06C6A67A733B), UINT64_C(0x7E6D2AE4F8F09D26),
417
+       UINT64_C(0xCF054C965A1F50D4), UINT64_C(0x13A460B40495BEC9),
418
+       UINT64_C(0x774615D2E60B8DEF), UINT64_C(0xABE739F0B88163F2),
419
+       UINT64_C(0xBF82FE1E2236EAA3), UINT64_C(0x6323D23C7CBC04BE),
420
+       UINT64_C(0x07C1A75A9E223798), UINT64_C(0xDB608B78C0A8D985),
421
+       UINT64_C(0x2F0B2987AB4D243B), UINT64_C(0xF3AA05A5F5C7CA26),
422
+       UINT64_C(0x974870C31759F900), UINT64_C(0x4BE95CE149D3171D),
423
+       UINT64_C(0x5F8C9B0FD3649E4C), UINT64_C(0x832DB72D8DEE7051),
424
+       UINT64_C(0xE7CFC24B6F704377), UINT64_C(0x3B6EEE6931FAAD6A),
425
+       UINT64_C(0x91131E980D8418A2), UINT64_C(0x4DB232BA530EF6BF),
426
+       UINT64_C(0x295047DCB190C599), UINT64_C(0xF5F16BFEEF1A2B84),
427
+       UINT64_C(0xE194AC1075ADA2D5), UINT64_C(0x3D3580322B274CC8),
428
+       UINT64_C(0x59D7F554C9B97FEE), UINT64_C(0x8576D976973391F3),
429
+       UINT64_C(0x711D7B89FCD66C4D), UINT64_C(0xADBC57ABA25C8250),
430
+       UINT64_C(0xC95E22CD40C2B176), UINT64_C(0x15FF0EEF1E485F6B),
431
+       UINT64_C(0x019AC90184FFD63A), UINT64_C(0xDD3BE523DA753827),
432
+       UINT64_C(0xB9D9904538EB0B01), UINT64_C(0x6578BC676661E51C),
433
+       UINT64_C(0xD410DA15C48E28EE), UINT64_C(0x08B1F6379A04C6F3),
434
+       UINT64_C(0x6C538351789AF5D5), UINT64_C(0xB0F2AF7326101BC8),
435
+       UINT64_C(0xA497689DBCA79299), UINT64_C(0x783644BFE22D7C84),
436
+       UINT64_C(0x1CD431D900B34FA2), UINT64_C(0xC0751DFB5E39A1BF),
437
+       UINT64_C(0x341EBF0435DC5C01), UINT64_C(0xE8BF93266B56B21C),
438
+       UINT64_C(0x8C5DE64089C8813A), UINT64_C(0x50FCCA62D7426F27),
439
+       UINT64_C(0x44990D8C4DF5E676), UINT64_C(0x983821AE137F086B),
440
+       UINT64_C(0xFCDA54C8F1E13B4D), UINT64_C(0x207B78EAAF6BD550),
441
+       UINT64_C(0x1B1596839E91783A), UINT64_C(0xC7B4BAA1C01B9627),
442
+       UINT64_C(0xA356CFC72285A501), UINT64_C(0x7FF7E3E57C0F4B1C),
443
+       UINT64_C(0x6B92240BE6B8C24D), UINT64_C(0xB7330829B8322C50),
444
+       UINT64_C(0xD3D17D4F5AAC1F76), UINT64_C(0x0F70516D0426F16B),
445
+       UINT64_C(0xFB1BF3926FC30CD5), UINT64_C(0x27BADFB03149E2C8),
446
+       UINT64_C(0x4358AAD6D3D7D1EE), UINT64_C(0x9FF986F48D5D3FF3),
447
+       UINT64_C(0x8B9C411A17EAB6A2), UINT64_C(0x573D6D38496058BF),
448
+       UINT64_C(0x33DF185EABFE6B99), UINT64_C(0xEF7E347CF5748584),
449
+       UINT64_C(0x5E16520E579B4876), UINT64_C(0x82B77E2C0911A66B),
450
+       UINT64_C(0xE6550B4AEB8F954D), UINT64_C(0x3AF42768B5057B50),
451
+       UINT64_C(0x2E91E0862FB2F201), UINT64_C(0xF230CCA471381C1C),
452
+       UINT64_C(0x96D2B9C293A62F3A), UINT64_C(0x4A7395E0CD2CC127),
453
+       UINT64_C(0xBE18371FA6C93C99), UINT64_C(0x62B91B3DF843D284),
454
+       UINT64_C(0x065B6E5B1ADDE1A2), UINT64_C(0xDAFA427944570FBF),
455
+       UINT64_C(0xCE9F8597DEE086EE), UINT64_C(0x123EA9B5806A68F3),
456
+       UINT64_C(0x76DCDCD362F45BD5), UINT64_C(0xAA7DF0F13C7EB5C8),
457
+       UINT64_C(0xA739329F30A7E9D6), UINT64_C(0x7B981EBD6E2D07CB),
458
+       UINT64_C(0x1F7A6BDB8CB334ED), UINT64_C(0xC3DB47F9D239DAF0),
459
+       UINT64_C(0xD7BE8017488E53A1), UINT64_C(0x0B1FAC351604BDBC),
460
+       UINT64_C(0x6FFDD953F49A8E9A), UINT64_C(0xB35CF571AA106087),
461
+       UINT64_C(0x4737578EC1F59D39), UINT64_C(0x9B967BAC9F7F7324),
462
+       UINT64_C(0xFF740ECA7DE14002), UINT64_C(0x23D522E8236BAE1F),
463
+       UINT64_C(0x37B0E506B9DC274E), UINT64_C(0xEB11C924E756C953),
464
+       UINT64_C(0x8FF3BC4205C8FA75), UINT64_C(0x535290605B421468),
465
+       UINT64_C(0xE23AF612F9ADD99A), UINT64_C(0x3E9BDA30A7273787),
466
+       UINT64_C(0x5A79AF5645B904A1), UINT64_C(0x86D883741B33EABC),
467
+       UINT64_C(0x92BD449A818463ED), UINT64_C(0x4E1C68B8DF0E8DF0),
468
+       UINT64_C(0x2AFE1DDE3D90BED6), UINT64_C(0xF65F31FC631A50CB),
469
+       UINT64_C(0x0234930308FFAD75), UINT64_C(0xDE95BF2156754368),
470
+       UINT64_C(0xBA77CA47B4EB704E), UINT64_C(0x66D6E665EA619E53),
471
+       UINT64_C(0x72B3218B70D61702), UINT64_C(0xAE120DA92E5CF91F),
472
+       UINT64_C(0xCAF078CFCCC2CA39), UINT64_C(0x165154ED92482424),
473
+       UINT64_C(0x2D3FBA84A3B2894E), UINT64_C(0xF19E96A6FD386753),
474
+       UINT64_C(0x957CE3C01FA65475), UINT64_C(0x49DDCFE2412CBA68),
475
+       UINT64_C(0x5DB8080CDB9B3339), UINT64_C(0x8119242E8511DD24),
476
+       UINT64_C(0xE5FB5148678FEE02), UINT64_C(0x395A7D6A3905001F),
477
+       UINT64_C(0xCD31DF9552E0FDA1), UINT64_C(0x1190F3B70C6A13BC),
478
+       UINT64_C(0x757286D1EEF4209A), UINT64_C(0xA9D3AAF3B07ECE87),
479
+       UINT64_C(0xBDB66D1D2AC947D6), UINT64_C(0x6117413F7443A9CB),
480
+       UINT64_C(0x05F5345996DD9AED), UINT64_C(0xD954187BC85774F0),
481
+       UINT64_C(0x683C7E096AB8B902), UINT64_C(0xB49D522B3432571F),
482
+       UINT64_C(0xD07F274DD6AC6439), UINT64_C(0x0CDE0B6F88268A24),
483
+       UINT64_C(0x18BBCC8112910375), UINT64_C(0xC41AE0A34C1BED68),
484
+       UINT64_C(0xA0F895C5AE85DE4E), UINT64_C(0x7C59B9E7F00F3053),
485
+       UINT64_C(0x88321B189BEACDED), UINT64_C(0x5493373AC56023F0),
486
+       UINT64_C(0x3071425C27FE10D6), UINT64_C(0xECD06E7E7974FECB),
487
+       UINT64_C(0xF8B5A990E3C3779A), UINT64_C(0x241485B2BD499987),
488
+       UINT64_C(0x40F6F0D45FD7AAA1), UINT64_C(0x9C57DCF6015D44BC),
489
+       UINT64_C(0x362A2C073D23F174), UINT64_C(0xEA8B002563A91F69),
490
+       UINT64_C(0x8E69754381372C4F), UINT64_C(0x52C85961DFBDC252),
491
+       UINT64_C(0x46AD9E8F450A4B03), UINT64_C(0x9A0CB2AD1B80A51E),
492
+       UINT64_C(0xFEEEC7CBF91E9638), UINT64_C(0x224FEBE9A7947825),
493
+       UINT64_C(0xD6244916CC71859B), UINT64_C(0x0A85653492FB6B86),
494
+       UINT64_C(0x6E671052706558A0), UINT64_C(0xB2C63C702EEFB6BD),
495
+       UINT64_C(0xA6A3FB9EB4583FEC), UINT64_C(0x7A02D7BCEAD2D1F1),
496
+       UINT64_C(0x1EE0A2DA084CE2D7), UINT64_C(0xC2418EF856C60CCA),
497
+       UINT64_C(0x7329E88AF429C138), UINT64_C(0xAF88C4A8AAA32F25),
498
+       UINT64_C(0xCB6AB1CE483D1C03), UINT64_C(0x17CB9DEC16B7F21E),
499
+       UINT64_C(0x03AE5A028C007B4F), UINT64_C(0xDF0F7620D28A9552),
500
+       UINT64_C(0xBBED03463014A674), UINT64_C(0x674C2F646E9E4869),
501
+       UINT64_C(0x93278D9B057BB5D7), UINT64_C(0x4F86A1B95BF15BCA),
502
+       UINT64_C(0x2B64D4DFB96F68EC), UINT64_C(0xF7C5F8FDE7E586F1),
503
+       UINT64_C(0xE3A03F137D520FA0), UINT64_C(0x3F01133123D8E1BD),
504
+       UINT64_C(0x5BE36657C146D29B), UINT64_C(0x87424A759FCC3C86),
505
+       UINT64_C(0xBC2CA41CAE3691EC), UINT64_C(0x608D883EF0BC7FF1),
506
+       UINT64_C(0x046FFD5812224CD7), UINT64_C(0xD8CED17A4CA8A2CA),
507
+       UINT64_C(0xCCAB1694D61F2B9B), UINT64_C(0x100A3AB68895C586),
508
+       UINT64_C(0x74E84FD06A0BF6A0), UINT64_C(0xA84963F2348118BD),
509
+       UINT64_C(0x5C22C10D5F64E503), UINT64_C(0x8083ED2F01EE0B1E),
510
+       UINT64_C(0xE4619849E3703838), UINT64_C(0x38C0B46BBDFAD625),
511
+       UINT64_C(0x2CA57385274D5F74), UINT64_C(0xF0045FA779C7B169),
512
+       UINT64_C(0x94E62AC19B59824F), UINT64_C(0x484706E3C5D36C52),
513
+       UINT64_C(0xF92F6091673CA1A0), UINT64_C(0x258E4CB339B64FBD),
514
+       UINT64_C(0x416C39D5DB287C9B), UINT64_C(0x9DCD15F785A29286),
515
+       UINT64_C(0x89A8D2191F151BD7), UINT64_C(0x5509FE3B419FF5CA),
516
+       UINT64_C(0x31EB8B5DA301C6EC), UINT64_C(0xED4AA77FFD8B28F1),
517
+       UINT64_C(0x19210580966ED54F), UINT64_C(0xC58029A2C8E43B52),
518
+       UINT64_C(0xA1625CC42A7A0874), UINT64_C(0x7DC370E674F0E669),
519
+       UINT64_C(0x69A6B708EE476F38), UINT64_C(0xB5079B2AB0CD8125),
520
+       UINT64_C(0xD1E5EE4C5253B203), UINT64_C(0x0D44C26E0CD95C1E)
521
+   }
522
+};
523
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_table_le.h Added
523
 
1
@@ -0,0 +1,521 @@
2
+/* This file has been automatically generated by crc64_tablegen.c. */
3
+
4
+const uint64_t lzma_crc64_table[4][256] = {
5
+   {
6
+       UINT64_C(0x0000000000000000), UINT64_C(0xB32E4CBE03A75F6F),
7
+       UINT64_C(0xF4843657A840A05B), UINT64_C(0x47AA7AE9ABE7FF34),
8
+       UINT64_C(0x7BD0C384FF8F5E33), UINT64_C(0xC8FE8F3AFC28015C),
9
+       UINT64_C(0x8F54F5D357CFFE68), UINT64_C(0x3C7AB96D5468A107),
10
+       UINT64_C(0xF7A18709FF1EBC66), UINT64_C(0x448FCBB7FCB9E309),
11
+       UINT64_C(0x0325B15E575E1C3D), UINT64_C(0xB00BFDE054F94352),
12
+       UINT64_C(0x8C71448D0091E255), UINT64_C(0x3F5F08330336BD3A),
13
+       UINT64_C(0x78F572DAA8D1420E), UINT64_C(0xCBDB3E64AB761D61),
14
+       UINT64_C(0x7D9BA13851336649), UINT64_C(0xCEB5ED8652943926),
15
+       UINT64_C(0x891F976FF973C612), UINT64_C(0x3A31DBD1FAD4997D),
16
+       UINT64_C(0x064B62BCAEBC387A), UINT64_C(0xB5652E02AD1B6715),
17
+       UINT64_C(0xF2CF54EB06FC9821), UINT64_C(0x41E11855055BC74E),
18
+       UINT64_C(0x8A3A2631AE2DDA2F), UINT64_C(0x39146A8FAD8A8540),
19
+       UINT64_C(0x7EBE1066066D7A74), UINT64_C(0xCD905CD805CA251B),
20
+       UINT64_C(0xF1EAE5B551A2841C), UINT64_C(0x42C4A90B5205DB73),
21
+       UINT64_C(0x056ED3E2F9E22447), UINT64_C(0xB6409F5CFA457B28),
22
+       UINT64_C(0xFB374270A266CC92), UINT64_C(0x48190ECEA1C193FD),
23
+       UINT64_C(0x0FB374270A266CC9), UINT64_C(0xBC9D3899098133A6),
24
+       UINT64_C(0x80E781F45DE992A1), UINT64_C(0x33C9CD4A5E4ECDCE),
25
+       UINT64_C(0x7463B7A3F5A932FA), UINT64_C(0xC74DFB1DF60E6D95),
26
+       UINT64_C(0x0C96C5795D7870F4), UINT64_C(0xBFB889C75EDF2F9B),
27
+       UINT64_C(0xF812F32EF538D0AF), UINT64_C(0x4B3CBF90F69F8FC0),
28
+       UINT64_C(0x774606FDA2F72EC7), UINT64_C(0xC4684A43A15071A8),
29
+       UINT64_C(0x83C230AA0AB78E9C), UINT64_C(0x30EC7C140910D1F3),
30
+       UINT64_C(0x86ACE348F355AADB), UINT64_C(0x3582AFF6F0F2F5B4),
31
+       UINT64_C(0x7228D51F5B150A80), UINT64_C(0xC10699A158B255EF),
32
+       UINT64_C(0xFD7C20CC0CDAF4E8), UINT64_C(0x4E526C720F7DAB87),
33
+       UINT64_C(0x09F8169BA49A54B3), UINT64_C(0xBAD65A25A73D0BDC),
34
+       UINT64_C(0x710D64410C4B16BD), UINT64_C(0xC22328FF0FEC49D2),
35
+       UINT64_C(0x85895216A40BB6E6), UINT64_C(0x36A71EA8A7ACE989),
36
+       UINT64_C(0x0ADDA7C5F3C4488E), UINT64_C(0xB9F3EB7BF06317E1),
37
+       UINT64_C(0xFE5991925B84E8D5), UINT64_C(0x4D77DD2C5823B7BA),
38
+       UINT64_C(0x64B62BCAEBC387A1), UINT64_C(0xD7986774E864D8CE),
39
+       UINT64_C(0x90321D9D438327FA), UINT64_C(0x231C512340247895),
40
+       UINT64_C(0x1F66E84E144CD992), UINT64_C(0xAC48A4F017EB86FD),
41
+       UINT64_C(0xEBE2DE19BC0C79C9), UINT64_C(0x58CC92A7BFAB26A6),
42
+       UINT64_C(0x9317ACC314DD3BC7), UINT64_C(0x2039E07D177A64A8),
43
+       UINT64_C(0x67939A94BC9D9B9C), UINT64_C(0xD4BDD62ABF3AC4F3),
44
+       UINT64_C(0xE8C76F47EB5265F4), UINT64_C(0x5BE923F9E8F53A9B),
45
+       UINT64_C(0x1C4359104312C5AF), UINT64_C(0xAF6D15AE40B59AC0),
46
+       UINT64_C(0x192D8AF2BAF0E1E8), UINT64_C(0xAA03C64CB957BE87),
47
+       UINT64_C(0xEDA9BCA512B041B3), UINT64_C(0x5E87F01B11171EDC),
48
+       UINT64_C(0x62FD4976457FBFDB), UINT64_C(0xD1D305C846D8E0B4),
49
+       UINT64_C(0x96797F21ED3F1F80), UINT64_C(0x2557339FEE9840EF),
50
+       UINT64_C(0xEE8C0DFB45EE5D8E), UINT64_C(0x5DA24145464902E1),
51
+       UINT64_C(0x1A083BACEDAEFDD5), UINT64_C(0xA9267712EE09A2BA),
52
+       UINT64_C(0x955CCE7FBA6103BD), UINT64_C(0x267282C1B9C65CD2),
53
+       UINT64_C(0x61D8F8281221A3E6), UINT64_C(0xD2F6B4961186FC89),
54
+       UINT64_C(0x9F8169BA49A54B33), UINT64_C(0x2CAF25044A02145C),
55
+       UINT64_C(0x6B055FEDE1E5EB68), UINT64_C(0xD82B1353E242B407),
56
+       UINT64_C(0xE451AA3EB62A1500), UINT64_C(0x577FE680B58D4A6F),
57
+       UINT64_C(0x10D59C691E6AB55B), UINT64_C(0xA3FBD0D71DCDEA34),
58
+       UINT64_C(0x6820EEB3B6BBF755), UINT64_C(0xDB0EA20DB51CA83A),
59
+       UINT64_C(0x9CA4D8E41EFB570E), UINT64_C(0x2F8A945A1D5C0861),
60
+       UINT64_C(0x13F02D374934A966), UINT64_C(0xA0DE61894A93F609),
61
+       UINT64_C(0xE7741B60E174093D), UINT64_C(0x545A57DEE2D35652),
62
+       UINT64_C(0xE21AC88218962D7A), UINT64_C(0x5134843C1B317215),
63
+       UINT64_C(0x169EFED5B0D68D21), UINT64_C(0xA5B0B26BB371D24E),
64
+       UINT64_C(0x99CA0B06E7197349), UINT64_C(0x2AE447B8E4BE2C26),
65
+       UINT64_C(0x6D4E3D514F59D312), UINT64_C(0xDE6071EF4CFE8C7D),
66
+       UINT64_C(0x15BB4F8BE788911C), UINT64_C(0xA6950335E42FCE73),
67
+       UINT64_C(0xE13F79DC4FC83147), UINT64_C(0x521135624C6F6E28),
68
+       UINT64_C(0x6E6B8C0F1807CF2F), UINT64_C(0xDD45C0B11BA09040),
69
+       UINT64_C(0x9AEFBA58B0476F74), UINT64_C(0x29C1F6E6B3E0301B),
70
+       UINT64_C(0xC96C5795D7870F42), UINT64_C(0x7A421B2BD420502D),
71
+       UINT64_C(0x3DE861C27FC7AF19), UINT64_C(0x8EC62D7C7C60F076),
72
+       UINT64_C(0xB2BC941128085171), UINT64_C(0x0192D8AF2BAF0E1E),
73
+       UINT64_C(0x4638A2468048F12A), UINT64_C(0xF516EEF883EFAE45),
74
+       UINT64_C(0x3ECDD09C2899B324), UINT64_C(0x8DE39C222B3EEC4B),
75
+       UINT64_C(0xCA49E6CB80D9137F), UINT64_C(0x7967AA75837E4C10),
76
+       UINT64_C(0x451D1318D716ED17), UINT64_C(0xF6335FA6D4B1B278),
77
+       UINT64_C(0xB199254F7F564D4C), UINT64_C(0x02B769F17CF11223),
78
+       UINT64_C(0xB4F7F6AD86B4690B), UINT64_C(0x07D9BA1385133664),
79
+       UINT64_C(0x4073C0FA2EF4C950), UINT64_C(0xF35D8C442D53963F),
80
+       UINT64_C(0xCF273529793B3738), UINT64_C(0x7C0979977A9C6857),
81
+       UINT64_C(0x3BA3037ED17B9763), UINT64_C(0x888D4FC0D2DCC80C),
82
+       UINT64_C(0x435671A479AAD56D), UINT64_C(0xF0783D1A7A0D8A02),
83
+       UINT64_C(0xB7D247F3D1EA7536), UINT64_C(0x04FC0B4DD24D2A59),
84
+       UINT64_C(0x3886B22086258B5E), UINT64_C(0x8BA8FE9E8582D431),
85
+       UINT64_C(0xCC0284772E652B05), UINT64_C(0x7F2CC8C92DC2746A),
86
+       UINT64_C(0x325B15E575E1C3D0), UINT64_C(0x8175595B76469CBF),
87
+       UINT64_C(0xC6DF23B2DDA1638B), UINT64_C(0x75F16F0CDE063CE4),
88
+       UINT64_C(0x498BD6618A6E9DE3), UINT64_C(0xFAA59ADF89C9C28C),
89
+       UINT64_C(0xBD0FE036222E3DB8), UINT64_C(0x0E21AC88218962D7),
90
+       UINT64_C(0xC5FA92EC8AFF7FB6), UINT64_C(0x76D4DE52895820D9),
91
+       UINT64_C(0x317EA4BB22BFDFED), UINT64_C(0x8250E80521188082),
92
+       UINT64_C(0xBE2A516875702185), UINT64_C(0x0D041DD676D77EEA),
93
+       UINT64_C(0x4AAE673FDD3081DE), UINT64_C(0xF9802B81DE97DEB1),
94
+       UINT64_C(0x4FC0B4DD24D2A599), UINT64_C(0xFCEEF8632775FAF6),
95
+       UINT64_C(0xBB44828A8C9205C2), UINT64_C(0x086ACE348F355AAD),
96
+       UINT64_C(0x34107759DB5DFBAA), UINT64_C(0x873E3BE7D8FAA4C5),
97
+       UINT64_C(0xC094410E731D5BF1), UINT64_C(0x73BA0DB070BA049E),
98
+       UINT64_C(0xB86133D4DBCC19FF), UINT64_C(0x0B4F7F6AD86B4690),
99
+       UINT64_C(0x4CE50583738CB9A4), UINT64_C(0xFFCB493D702BE6CB),
100
+       UINT64_C(0xC3B1F050244347CC), UINT64_C(0x709FBCEE27E418A3),
101
+       UINT64_C(0x3735C6078C03E797), UINT64_C(0x841B8AB98FA4B8F8),
102
+       UINT64_C(0xADDA7C5F3C4488E3), UINT64_C(0x1EF430E13FE3D78C),
103
+       UINT64_C(0x595E4A08940428B8), UINT64_C(0xEA7006B697A377D7),
104
+       UINT64_C(0xD60ABFDBC3CBD6D0), UINT64_C(0x6524F365C06C89BF),
105
+       UINT64_C(0x228E898C6B8B768B), UINT64_C(0x91A0C532682C29E4),
106
+       UINT64_C(0x5A7BFB56C35A3485), UINT64_C(0xE955B7E8C0FD6BEA),
107
+       UINT64_C(0xAEFFCD016B1A94DE), UINT64_C(0x1DD181BF68BDCBB1),
108
+       UINT64_C(0x21AB38D23CD56AB6), UINT64_C(0x9285746C3F7235D9),
109
+       UINT64_C(0xD52F0E859495CAED), UINT64_C(0x6601423B97329582),
110
+       UINT64_C(0xD041DD676D77EEAA), UINT64_C(0x636F91D96ED0B1C5),
111
+       UINT64_C(0x24C5EB30C5374EF1), UINT64_C(0x97EBA78EC690119E),
112
+       UINT64_C(0xAB911EE392F8B099), UINT64_C(0x18BF525D915FEFF6),
113
+       UINT64_C(0x5F1528B43AB810C2), UINT64_C(0xEC3B640A391F4FAD),
114
+       UINT64_C(0x27E05A6E926952CC), UINT64_C(0x94CE16D091CE0DA3),
115
+       UINT64_C(0xD3646C393A29F297), UINT64_C(0x604A2087398EADF8),
116
+       UINT64_C(0x5C3099EA6DE60CFF), UINT64_C(0xEF1ED5546E415390),
117
+       UINT64_C(0xA8B4AFBDC5A6ACA4), UINT64_C(0x1B9AE303C601F3CB),
118
+       UINT64_C(0x56ED3E2F9E224471), UINT64_C(0xE5C372919D851B1E),
119
+       UINT64_C(0xA26908783662E42A), UINT64_C(0x114744C635C5BB45),
120
+       UINT64_C(0x2D3DFDAB61AD1A42), UINT64_C(0x9E13B115620A452D),
121
+       UINT64_C(0xD9B9CBFCC9EDBA19), UINT64_C(0x6A978742CA4AE576),
122
+       UINT64_C(0xA14CB926613CF817), UINT64_C(0x1262F598629BA778),
123
+       UINT64_C(0x55C88F71C97C584C), UINT64_C(0xE6E6C3CFCADB0723),
124
+       UINT64_C(0xDA9C7AA29EB3A624), UINT64_C(0x69B2361C9D14F94B),
125
+       UINT64_C(0x2E184CF536F3067F), UINT64_C(0x9D36004B35545910),
126
+       UINT64_C(0x2B769F17CF112238), UINT64_C(0x9858D3A9CCB67D57),
127
+       UINT64_C(0xDFF2A94067518263), UINT64_C(0x6CDCE5FE64F6DD0C),
128
+       UINT64_C(0x50A65C93309E7C0B), UINT64_C(0xE388102D33392364),
129
+       UINT64_C(0xA4226AC498DEDC50), UINT64_C(0x170C267A9B79833F),
130
+       UINT64_C(0xDCD7181E300F9E5E), UINT64_C(0x6FF954A033A8C131),
131
+       UINT64_C(0x28532E49984F3E05), UINT64_C(0x9B7D62F79BE8616A),
132
+       UINT64_C(0xA707DB9ACF80C06D), UINT64_C(0x14299724CC279F02),
133
+       UINT64_C(0x5383EDCD67C06036), UINT64_C(0xE0ADA17364673F59)
134
+   }, {
135
+       UINT64_C(0x0000000000000000), UINT64_C(0x54E979925CD0F10D),
136
+       UINT64_C(0xA9D2F324B9A1E21A), UINT64_C(0xFD3B8AB6E5711317),
137
+       UINT64_C(0xC17D4962DC4DDAB1), UINT64_C(0x959430F0809D2BBC),
138
+       UINT64_C(0x68AFBA4665EC38AB), UINT64_C(0x3C46C3D4393CC9A6),
139
+       UINT64_C(0x10223DEE1795ABE7), UINT64_C(0x44CB447C4B455AEA),
140
+       UINT64_C(0xB9F0CECAAE3449FD), UINT64_C(0xED19B758F2E4B8F0),
141
+       UINT64_C(0xD15F748CCBD87156), UINT64_C(0x85B60D1E9708805B),
142
+       UINT64_C(0x788D87A87279934C), UINT64_C(0x2C64FE3A2EA96241),
143
+       UINT64_C(0x20447BDC2F2B57CE), UINT64_C(0x74AD024E73FBA6C3),
144
+       UINT64_C(0x899688F8968AB5D4), UINT64_C(0xDD7FF16ACA5A44D9),
145
+       UINT64_C(0xE13932BEF3668D7F), UINT64_C(0xB5D04B2CAFB67C72),
146
+       UINT64_C(0x48EBC19A4AC76F65), UINT64_C(0x1C02B80816179E68),
147
+       UINT64_C(0x3066463238BEFC29), UINT64_C(0x648F3FA0646E0D24),
148
+       UINT64_C(0x99B4B516811F1E33), UINT64_C(0xCD5DCC84DDCFEF3E),
149
+       UINT64_C(0xF11B0F50E4F32698), UINT64_C(0xA5F276C2B823D795),
150
+       UINT64_C(0x58C9FC745D52C482), UINT64_C(0x0C2085E60182358F),
151
+       UINT64_C(0x4088F7B85E56AF9C), UINT64_C(0x14618E2A02865E91),
152
+       UINT64_C(0xE95A049CE7F74D86), UINT64_C(0xBDB37D0EBB27BC8B),
153
+       UINT64_C(0x81F5BEDA821B752D), UINT64_C(0xD51CC748DECB8420),
154
+       UINT64_C(0x28274DFE3BBA9737), UINT64_C(0x7CCE346C676A663A),
155
+       UINT64_C(0x50AACA5649C3047B), UINT64_C(0x0443B3C41513F576),
156
+       UINT64_C(0xF9783972F062E661), UINT64_C(0xAD9140E0ACB2176C),
157
+       UINT64_C(0x91D78334958EDECA), UINT64_C(0xC53EFAA6C95E2FC7),
158
+       UINT64_C(0x380570102C2F3CD0), UINT64_C(0x6CEC098270FFCDDD),
159
+       UINT64_C(0x60CC8C64717DF852), UINT64_C(0x3425F5F62DAD095F),
160
+       UINT64_C(0xC91E7F40C8DC1A48), UINT64_C(0x9DF706D2940CEB45),
161
+       UINT64_C(0xA1B1C506AD3022E3), UINT64_C(0xF558BC94F1E0D3EE),
162
+       UINT64_C(0x086336221491C0F9), UINT64_C(0x5C8A4FB0484131F4),
163
+       UINT64_C(0x70EEB18A66E853B5), UINT64_C(0x2407C8183A38A2B8),
164
+       UINT64_C(0xD93C42AEDF49B1AF), UINT64_C(0x8DD53B3C839940A2),
165
+       UINT64_C(0xB193F8E8BAA58904), UINT64_C(0xE57A817AE6757809),
166
+       UINT64_C(0x18410BCC03046B1E), UINT64_C(0x4CA8725E5FD49A13),
167
+       UINT64_C(0x8111EF70BCAD5F38), UINT64_C(0xD5F896E2E07DAE35),
168
+       UINT64_C(0x28C31C54050CBD22), UINT64_C(0x7C2A65C659DC4C2F),
169
+       UINT64_C(0x406CA61260E08589), UINT64_C(0x1485DF803C307484),
170
+       UINT64_C(0xE9BE5536D9416793), UINT64_C(0xBD572CA48591969E),
171
+       UINT64_C(0x9133D29EAB38F4DF), UINT64_C(0xC5DAAB0CF7E805D2),
172
+       UINT64_C(0x38E121BA129916C5), UINT64_C(0x6C0858284E49E7C8),
173
+       UINT64_C(0x504E9BFC77752E6E), UINT64_C(0x04A7E26E2BA5DF63),
174
+       UINT64_C(0xF99C68D8CED4CC74), UINT64_C(0xAD75114A92043D79),
175
+       UINT64_C(0xA15594AC938608F6), UINT64_C(0xF5BCED3ECF56F9FB),
176
+       UINT64_C(0x088767882A27EAEC), UINT64_C(0x5C6E1E1A76F71BE1),
177
+       UINT64_C(0x6028DDCE4FCBD247), UINT64_C(0x34C1A45C131B234A),
178
+       UINT64_C(0xC9FA2EEAF66A305D), UINT64_C(0x9D135778AABAC150),
179
+       UINT64_C(0xB177A9428413A311), UINT64_C(0xE59ED0D0D8C3521C),
180
+       UINT64_C(0x18A55A663DB2410B), UINT64_C(0x4C4C23F46162B006),
181
+       UINT64_C(0x700AE020585E79A0), UINT64_C(0x24E399B2048E88AD),
182
+       UINT64_C(0xD9D81304E1FF9BBA), UINT64_C(0x8D316A96BD2F6AB7),
183
+       UINT64_C(0xC19918C8E2FBF0A4), UINT64_C(0x9570615ABE2B01A9),
184
+       UINT64_C(0x684BEBEC5B5A12BE), UINT64_C(0x3CA2927E078AE3B3),
185
+       UINT64_C(0x00E451AA3EB62A15), UINT64_C(0x540D28386266DB18),
186
+       UINT64_C(0xA936A28E8717C80F), UINT64_C(0xFDDFDB1CDBC73902),
187
+       UINT64_C(0xD1BB2526F56E5B43), UINT64_C(0x85525CB4A9BEAA4E),
188
+       UINT64_C(0x7869D6024CCFB959), UINT64_C(0x2C80AF90101F4854),
189
+       UINT64_C(0x10C66C44292381F2), UINT64_C(0x442F15D675F370FF),
190
+       UINT64_C(0xB9149F60908263E8), UINT64_C(0xEDFDE6F2CC5292E5),
191
+       UINT64_C(0xE1DD6314CDD0A76A), UINT64_C(0xB5341A8691005667),
192
+       UINT64_C(0x480F903074714570), UINT64_C(0x1CE6E9A228A1B47D),
193
+       UINT64_C(0x20A02A76119D7DDB), UINT64_C(0x744953E44D4D8CD6),
194
+       UINT64_C(0x8972D952A83C9FC1), UINT64_C(0xDD9BA0C0F4EC6ECC),
195
+       UINT64_C(0xF1FF5EFADA450C8D), UINT64_C(0xA51627688695FD80),
196
+       UINT64_C(0x582DADDE63E4EE97), UINT64_C(0x0CC4D44C3F341F9A),
197
+       UINT64_C(0x308217980608D63C), UINT64_C(0x646B6E0A5AD82731),
198
+       UINT64_C(0x9950E4BCBFA93426), UINT64_C(0xCDB99D2EE379C52B),
199
+       UINT64_C(0x90FB71CAD654A0F5), UINT64_C(0xC41208588A8451F8),
200
+       UINT64_C(0x392982EE6FF542EF), UINT64_C(0x6DC0FB7C3325B3E2),
201
+       UINT64_C(0x518638A80A197A44), UINT64_C(0x056F413A56C98B49),
202
+       UINT64_C(0xF854CB8CB3B8985E), UINT64_C(0xACBDB21EEF686953),
203
+       UINT64_C(0x80D94C24C1C10B12), UINT64_C(0xD43035B69D11FA1F),
204
+       UINT64_C(0x290BBF007860E908), UINT64_C(0x7DE2C69224B01805),
205
+       UINT64_C(0x41A405461D8CD1A3), UINT64_C(0x154D7CD4415C20AE),
206
+       UINT64_C(0xE876F662A42D33B9), UINT64_C(0xBC9F8FF0F8FDC2B4),
207
+       UINT64_C(0xB0BF0A16F97FF73B), UINT64_C(0xE4567384A5AF0636),
208
+       UINT64_C(0x196DF93240DE1521), UINT64_C(0x4D8480A01C0EE42C),
209
+       UINT64_C(0x71C2437425322D8A), UINT64_C(0x252B3AE679E2DC87),
210
+       UINT64_C(0xD810B0509C93CF90), UINT64_C(0x8CF9C9C2C0433E9D),
211
+       UINT64_C(0xA09D37F8EEEA5CDC), UINT64_C(0xF4744E6AB23AADD1),
212
+       UINT64_C(0x094FC4DC574BBEC6), UINT64_C(0x5DA6BD4E0B9B4FCB),
213
+       UINT64_C(0x61E07E9A32A7866D), UINT64_C(0x350907086E777760),
214
+       UINT64_C(0xC8328DBE8B066477), UINT64_C(0x9CDBF42CD7D6957A),
215
+       UINT64_C(0xD073867288020F69), UINT64_C(0x849AFFE0D4D2FE64),
216
+       UINT64_C(0x79A1755631A3ED73), UINT64_C(0x2D480CC46D731C7E),
217
+       UINT64_C(0x110ECF10544FD5D8), UINT64_C(0x45E7B682089F24D5),
218
+       UINT64_C(0xB8DC3C34EDEE37C2), UINT64_C(0xEC3545A6B13EC6CF),
219
+       UINT64_C(0xC051BB9C9F97A48E), UINT64_C(0x94B8C20EC3475583),
220
+       UINT64_C(0x698348B826364694), UINT64_C(0x3D6A312A7AE6B799),
221
+       UINT64_C(0x012CF2FE43DA7E3F), UINT64_C(0x55C58B6C1F0A8F32),
222
+       UINT64_C(0xA8FE01DAFA7B9C25), UINT64_C(0xFC177848A6AB6D28),
223
+       UINT64_C(0xF037FDAEA72958A7), UINT64_C(0xA4DE843CFBF9A9AA),
224
+       UINT64_C(0x59E50E8A1E88BABD), UINT64_C(0x0D0C771842584BB0),
225
+       UINT64_C(0x314AB4CC7B648216), UINT64_C(0x65A3CD5E27B4731B),
226
+       UINT64_C(0x989847E8C2C5600C), UINT64_C(0xCC713E7A9E159101),
227
+       UINT64_C(0xE015C040B0BCF340), UINT64_C(0xB4FCB9D2EC6C024D),
228
+       UINT64_C(0x49C73364091D115A), UINT64_C(0x1D2E4AF655CDE057),
229
+       UINT64_C(0x216889226CF129F1), UINT64_C(0x7581F0B03021D8FC),
230
+       UINT64_C(0x88BA7A06D550CBEB), UINT64_C(0xDC53039489803AE6),
231
+       UINT64_C(0x11EA9EBA6AF9FFCD), UINT64_C(0x4503E72836290EC0),
232
+       UINT64_C(0xB8386D9ED3581DD7), UINT64_C(0xECD1140C8F88ECDA),
233
+       UINT64_C(0xD097D7D8B6B4257C), UINT64_C(0x847EAE4AEA64D471),
234
+       UINT64_C(0x794524FC0F15C766), UINT64_C(0x2DAC5D6E53C5366B),
235
+       UINT64_C(0x01C8A3547D6C542A), UINT64_C(0x5521DAC621BCA527),
236
+       UINT64_C(0xA81A5070C4CDB630), UINT64_C(0xFCF329E2981D473D),
237
+       UINT64_C(0xC0B5EA36A1218E9B), UINT64_C(0x945C93A4FDF17F96),
238
+       UINT64_C(0x6967191218806C81), UINT64_C(0x3D8E608044509D8C),
239
+       UINT64_C(0x31AEE56645D2A803), UINT64_C(0x65479CF41902590E),
240
+       UINT64_C(0x987C1642FC734A19), UINT64_C(0xCC956FD0A0A3BB14),
241
+       UINT64_C(0xF0D3AC04999F72B2), UINT64_C(0xA43AD596C54F83BF),
242
+       UINT64_C(0x59015F20203E90A8), UINT64_C(0x0DE826B27CEE61A5),
243
+       UINT64_C(0x218CD888524703E4), UINT64_C(0x7565A11A0E97F2E9),
244
+       UINT64_C(0x885E2BACEBE6E1FE), UINT64_C(0xDCB7523EB73610F3),
245
+       UINT64_C(0xE0F191EA8E0AD955), UINT64_C(0xB418E878D2DA2858),
246
+       UINT64_C(0x492362CE37AB3B4F), UINT64_C(0x1DCA1B5C6B7BCA42),
247
+       UINT64_C(0x5162690234AF5051), UINT64_C(0x058B1090687FA15C),
248
+       UINT64_C(0xF8B09A268D0EB24B), UINT64_C(0xAC59E3B4D1DE4346),
249
+       UINT64_C(0x901F2060E8E28AE0), UINT64_C(0xC4F659F2B4327BED),
250
+       UINT64_C(0x39CDD344514368FA), UINT64_C(0x6D24AAD60D9399F7),
251
+       UINT64_C(0x414054EC233AFBB6), UINT64_C(0x15A92D7E7FEA0ABB),
252
+       UINT64_C(0xE892A7C89A9B19AC), UINT64_C(0xBC7BDE5AC64BE8A1),
253
+       UINT64_C(0x803D1D8EFF772107), UINT64_C(0xD4D4641CA3A7D00A),
254
+       UINT64_C(0x29EFEEAA46D6C31D), UINT64_C(0x7D0697381A063210),
255
+       UINT64_C(0x712612DE1B84079F), UINT64_C(0x25CF6B4C4754F692),
256
+       UINT64_C(0xD8F4E1FAA225E585), UINT64_C(0x8C1D9868FEF51488),
257
+       UINT64_C(0xB05B5BBCC7C9DD2E), UINT64_C(0xE4B2222E9B192C23),
258
+       UINT64_C(0x1989A8987E683F34), UINT64_C(0x4D60D10A22B8CE39),
259
+       UINT64_C(0x61042F300C11AC78), UINT64_C(0x35ED56A250C15D75),
260
+       UINT64_C(0xC8D6DC14B5B04E62), UINT64_C(0x9C3FA586E960BF6F),
261
+       UINT64_C(0xA0796652D05C76C9), UINT64_C(0xF4901FC08C8C87C4),
262
+       UINT64_C(0x09AB957669FD94D3), UINT64_C(0x5D42ECE4352D65DE)
263
+   }, {
264
+       UINT64_C(0x0000000000000000), UINT64_C(0x3F0BE14A916A6DCB),
265
+       UINT64_C(0x7E17C29522D4DB96), UINT64_C(0x411C23DFB3BEB65D),
266
+       UINT64_C(0xFC2F852A45A9B72C), UINT64_C(0xC3246460D4C3DAE7),
267
+       UINT64_C(0x823847BF677D6CBA), UINT64_C(0xBD33A6F5F6170171),
268
+       UINT64_C(0x6A87A57F245D70DD), UINT64_C(0x558C4435B5371D16),
269
+       UINT64_C(0x149067EA0689AB4B), UINT64_C(0x2B9B86A097E3C680),
270
+       UINT64_C(0x96A8205561F4C7F1), UINT64_C(0xA9A3C11FF09EAA3A),
271
+       UINT64_C(0xE8BFE2C043201C67), UINT64_C(0xD7B4038AD24A71AC),
272
+       UINT64_C(0xD50F4AFE48BAE1BA), UINT64_C(0xEA04ABB4D9D08C71),
273
+       UINT64_C(0xAB18886B6A6E3A2C), UINT64_C(0x94136921FB0457E7),
274
+       UINT64_C(0x2920CFD40D135696), UINT64_C(0x162B2E9E9C793B5D),
275
+       UINT64_C(0x57370D412FC78D00), UINT64_C(0x683CEC0BBEADE0CB),
276
+       UINT64_C(0xBF88EF816CE79167), UINT64_C(0x80830ECBFD8DFCAC),
277
+       UINT64_C(0xC19F2D144E334AF1), UINT64_C(0xFE94CC5EDF59273A),
278
+       UINT64_C(0x43A76AAB294E264B), UINT64_C(0x7CAC8BE1B8244B80),
279
+       UINT64_C(0x3DB0A83E0B9AFDDD), UINT64_C(0x02BB49749AF09016),
280
+       UINT64_C(0x38C63AD73E7BDDF1), UINT64_C(0x07CDDB9DAF11B03A),
281
+       UINT64_C(0x46D1F8421CAF0667), UINT64_C(0x79DA19088DC56BAC),
282
+       UINT64_C(0xC4E9BFFD7BD26ADD), UINT64_C(0xFBE25EB7EAB80716),
283
+       UINT64_C(0xBAFE7D685906B14B), UINT64_C(0x85F59C22C86CDC80),
284
+       UINT64_C(0x52419FA81A26AD2C), UINT64_C(0x6D4A7EE28B4CC0E7),
285
+       UINT64_C(0x2C565D3D38F276BA), UINT64_C(0x135DBC77A9981B71),
286
+       UINT64_C(0xAE6E1A825F8F1A00), UINT64_C(0x9165FBC8CEE577CB),
287
+       UINT64_C(0xD079D8177D5BC196), UINT64_C(0xEF72395DEC31AC5D),
288
+       UINT64_C(0xEDC9702976C13C4B), UINT64_C(0xD2C29163E7AB5180),
289
+       UINT64_C(0x93DEB2BC5415E7DD), UINT64_C(0xACD553F6C57F8A16),
290
+       UINT64_C(0x11E6F50333688B67), UINT64_C(0x2EED1449A202E6AC),
291
+       UINT64_C(0x6FF1379611BC50F1), UINT64_C(0x50FAD6DC80D63D3A),
292
+       UINT64_C(0x874ED556529C4C96), UINT64_C(0xB845341CC3F6215D),
293
+       UINT64_C(0xF95917C370489700), UINT64_C(0xC652F689E122FACB),
294
+       UINT64_C(0x7B61507C1735FBBA), UINT64_C(0x446AB136865F9671),
295
+       UINT64_C(0x057692E935E1202C), UINT64_C(0x3A7D73A3A48B4DE7),
296
+       UINT64_C(0x718C75AE7CF7BBE2), UINT64_C(0x4E8794E4ED9DD629),
297
+       UINT64_C(0x0F9BB73B5E236074), UINT64_C(0x30905671CF490DBF),
298
+       UINT64_C(0x8DA3F084395E0CCE), UINT64_C(0xB2A811CEA8346105),
299
+       UINT64_C(0xF3B432111B8AD758), UINT64_C(0xCCBFD35B8AE0BA93),
300
+       UINT64_C(0x1B0BD0D158AACB3F), UINT64_C(0x2400319BC9C0A6F4),
301
+       UINT64_C(0x651C12447A7E10A9), UINT64_C(0x5A17F30EEB147D62),
302
+       UINT64_C(0xE72455FB1D037C13), UINT64_C(0xD82FB4B18C6911D8),
303
+       UINT64_C(0x9933976E3FD7A785), UINT64_C(0xA6387624AEBDCA4E),
304
+       UINT64_C(0xA4833F50344D5A58), UINT64_C(0x9B88DE1AA5273793),
305
+       UINT64_C(0xDA94FDC5169981CE), UINT64_C(0xE59F1C8F87F3EC05),
306
+       UINT64_C(0x58ACBA7A71E4ED74), UINT64_C(0x67A75B30E08E80BF),
307
+       UINT64_C(0x26BB78EF533036E2), UINT64_C(0x19B099A5C25A5B29),
308
+       UINT64_C(0xCE049A2F10102A85), UINT64_C(0xF10F7B65817A474E),
309
+       UINT64_C(0xB01358BA32C4F113), UINT64_C(0x8F18B9F0A3AE9CD8),
310
+       UINT64_C(0x322B1F0555B99DA9), UINT64_C(0x0D20FE4FC4D3F062),
311
+       UINT64_C(0x4C3CDD90776D463F), UINT64_C(0x73373CDAE6072BF4),
312
+       UINT64_C(0x494A4F79428C6613), UINT64_C(0x7641AE33D3E60BD8),
313
+       UINT64_C(0x375D8DEC6058BD85), UINT64_C(0x08566CA6F132D04E),
314
+       UINT64_C(0xB565CA530725D13F), UINT64_C(0x8A6E2B19964FBCF4),
315
+       UINT64_C(0xCB7208C625F10AA9), UINT64_C(0xF479E98CB49B6762),
316
+       UINT64_C(0x23CDEA0666D116CE), UINT64_C(0x1CC60B4CF7BB7B05),
317
+       UINT64_C(0x5DDA28934405CD58), UINT64_C(0x62D1C9D9D56FA093),
318
+       UINT64_C(0xDFE26F2C2378A1E2), UINT64_C(0xE0E98E66B212CC29),
319
+       UINT64_C(0xA1F5ADB901AC7A74), UINT64_C(0x9EFE4CF390C617BF),
320
+       UINT64_C(0x9C4505870A3687A9), UINT64_C(0xA34EE4CD9B5CEA62),
321
+       UINT64_C(0xE252C71228E25C3F), UINT64_C(0xDD592658B98831F4),
322
+       UINT64_C(0x606A80AD4F9F3085), UINT64_C(0x5F6161E7DEF55D4E),
323
+       UINT64_C(0x1E7D42386D4BEB13), UINT64_C(0x2176A372FC2186D8),
324
+       UINT64_C(0xF6C2A0F82E6BF774), UINT64_C(0xC9C941B2BF019ABF),
325
+       UINT64_C(0x88D5626D0CBF2CE2), UINT64_C(0xB7DE83279DD54129),
326
+       UINT64_C(0x0AED25D26BC24058), UINT64_C(0x35E6C498FAA82D93),
327
+       UINT64_C(0x74FAE74749169BCE), UINT64_C(0x4BF1060DD87CF605),
328
+       UINT64_C(0xE318EB5CF9EF77C4), UINT64_C(0xDC130A1668851A0F),
329
+       UINT64_C(0x9D0F29C9DB3BAC52), UINT64_C(0xA204C8834A51C199),
330
+       UINT64_C(0x1F376E76BC46C0E8), UINT64_C(0x203C8F3C2D2CAD23),
331
+       UINT64_C(0x6120ACE39E921B7E), UINT64_C(0x5E2B4DA90FF876B5),
332
+       UINT64_C(0x899F4E23DDB20719), UINT64_C(0xB694AF694CD86AD2),
333
+       UINT64_C(0xF7888CB6FF66DC8F), UINT64_C(0xC8836DFC6E0CB144),
334
+       UINT64_C(0x75B0CB09981BB035), UINT64_C(0x4ABB2A430971DDFE),
335
+       UINT64_C(0x0BA7099CBACF6BA3), UINT64_C(0x34ACE8D62BA50668),
336
+       UINT64_C(0x3617A1A2B155967E), UINT64_C(0x091C40E8203FFBB5),
337
+       UINT64_C(0x4800633793814DE8), UINT64_C(0x770B827D02EB2023),
338
+       UINT64_C(0xCA382488F4FC2152), UINT64_C(0xF533C5C265964C99),
339
+       UINT64_C(0xB42FE61DD628FAC4), UINT64_C(0x8B2407574742970F),
340
+       UINT64_C(0x5C9004DD9508E6A3), UINT64_C(0x639BE59704628B68),
341
+       UINT64_C(0x2287C648B7DC3D35), UINT64_C(0x1D8C270226B650FE),
342
+       UINT64_C(0xA0BF81F7D0A1518F), UINT64_C(0x9FB460BD41CB3C44),
343
+       UINT64_C(0xDEA84362F2758A19), UINT64_C(0xE1A3A228631FE7D2),
344
+       UINT64_C(0xDBDED18BC794AA35), UINT64_C(0xE4D530C156FEC7FE),
345
+       UINT64_C(0xA5C9131EE54071A3), UINT64_C(0x9AC2F254742A1C68),
346
+       UINT64_C(0x27F154A1823D1D19), UINT64_C(0x18FAB5EB135770D2),
347
+       UINT64_C(0x59E69634A0E9C68F), UINT64_C(0x66ED777E3183AB44),
348
+       UINT64_C(0xB15974F4E3C9DAE8), UINT64_C(0x8E5295BE72A3B723),
349
+       UINT64_C(0xCF4EB661C11D017E), UINT64_C(0xF045572B50776CB5),
350
+       UINT64_C(0x4D76F1DEA6606DC4), UINT64_C(0x727D1094370A000F),
351
+       UINT64_C(0x3361334B84B4B652), UINT64_C(0x0C6AD20115DEDB99),
352
+       UINT64_C(0x0ED19B758F2E4B8F), UINT64_C(0x31DA7A3F1E442644),
353
+       UINT64_C(0x70C659E0ADFA9019), UINT64_C(0x4FCDB8AA3C90FDD2),
354
+       UINT64_C(0xF2FE1E5FCA87FCA3), UINT64_C(0xCDF5FF155BED9168),
355
+       UINT64_C(0x8CE9DCCAE8532735), UINT64_C(0xB3E23D8079394AFE),
356
+       UINT64_C(0x64563E0AAB733B52), UINT64_C(0x5B5DDF403A195699),
357
+       UINT64_C(0x1A41FC9F89A7E0C4), UINT64_C(0x254A1DD518CD8D0F),
358
+       UINT64_C(0x9879BB20EEDA8C7E), UINT64_C(0xA7725A6A7FB0E1B5),
359
+       UINT64_C(0xE66E79B5CC0E57E8), UINT64_C(0xD96598FF5D643A23),
360
+       UINT64_C(0x92949EF28518CC26), UINT64_C(0xAD9F7FB81472A1ED),
361
+       UINT64_C(0xEC835C67A7CC17B0), UINT64_C(0xD388BD2D36A67A7B),
362
+       UINT64_C(0x6EBB1BD8C0B17B0A), UINT64_C(0x51B0FA9251DB16C1),
363
+       UINT64_C(0x10ACD94DE265A09C), UINT64_C(0x2FA73807730FCD57),
364
+       UINT64_C(0xF8133B8DA145BCFB), UINT64_C(0xC718DAC7302FD130),
365
+       UINT64_C(0x8604F9188391676D), UINT64_C(0xB90F185212FB0AA6),
366
+       UINT64_C(0x043CBEA7E4EC0BD7), UINT64_C(0x3B375FED7586661C),
367
+       UINT64_C(0x7A2B7C32C638D041), UINT64_C(0x45209D785752BD8A),
368
+       UINT64_C(0x479BD40CCDA22D9C), UINT64_C(0x789035465CC84057),
369
+       UINT64_C(0x398C1699EF76F60A), UINT64_C(0x0687F7D37E1C9BC1),
370
+       UINT64_C(0xBBB45126880B9AB0), UINT64_C(0x84BFB06C1961F77B),
371
+       UINT64_C(0xC5A393B3AADF4126), UINT64_C(0xFAA872F93BB52CED),
372
+       UINT64_C(0x2D1C7173E9FF5D41), UINT64_C(0x121790397895308A),
373
+       UINT64_C(0x530BB3E6CB2B86D7), UINT64_C(0x6C0052AC5A41EB1C),
374
+       UINT64_C(0xD133F459AC56EA6D), UINT64_C(0xEE3815133D3C87A6),
375
+       UINT64_C(0xAF2436CC8E8231FB), UINT64_C(0x902FD7861FE85C30),
376
+       UINT64_C(0xAA52A425BB6311D7), UINT64_C(0x9559456F2A097C1C),
377
+       UINT64_C(0xD44566B099B7CA41), UINT64_C(0xEB4E87FA08DDA78A),
378
+       UINT64_C(0x567D210FFECAA6FB), UINT64_C(0x6976C0456FA0CB30),
379
+       UINT64_C(0x286AE39ADC1E7D6D), UINT64_C(0x176102D04D7410A6),
380
+       UINT64_C(0xC0D5015A9F3E610A), UINT64_C(0xFFDEE0100E540CC1),
381
+       UINT64_C(0xBEC2C3CFBDEABA9C), UINT64_C(0x81C922852C80D757),
382
+       UINT64_C(0x3CFA8470DA97D626), UINT64_C(0x03F1653A4BFDBBED),
383
+       UINT64_C(0x42ED46E5F8430DB0), UINT64_C(0x7DE6A7AF6929607B),
384
+       UINT64_C(0x7F5DEEDBF3D9F06D), UINT64_C(0x40560F9162B39DA6),
385
+       UINT64_C(0x014A2C4ED10D2BFB), UINT64_C(0x3E41CD0440674630),
386
+       UINT64_C(0x83726BF1B6704741), UINT64_C(0xBC798ABB271A2A8A),
387
+       UINT64_C(0xFD65A96494A49CD7), UINT64_C(0xC26E482E05CEF11C),
388
+       UINT64_C(0x15DA4BA4D78480B0), UINT64_C(0x2AD1AAEE46EEED7B),
389
+       UINT64_C(0x6BCD8931F5505B26), UINT64_C(0x54C6687B643A36ED),
390
+       UINT64_C(0xE9F5CE8E922D379C), UINT64_C(0xD6FE2FC403475A57),
391
+       UINT64_C(0x97E20C1BB0F9EC0A), UINT64_C(0xA8E9ED51219381C1)
392
+   }, {
393
+       UINT64_C(0x0000000000000000), UINT64_C(0x1DEE8A5E222CA1DC),
394
+       UINT64_C(0x3BDD14BC445943B8), UINT64_C(0x26339EE26675E264),
395
+       UINT64_C(0x77BA297888B28770), UINT64_C(0x6A54A326AA9E26AC),
396
+       UINT64_C(0x4C673DC4CCEBC4C8), UINT64_C(0x5189B79AEEC76514),
397
+       UINT64_C(0xEF7452F111650EE0), UINT64_C(0xF29AD8AF3349AF3C),
398
+       UINT64_C(0xD4A9464D553C4D58), UINT64_C(0xC947CC137710EC84),
399
+       UINT64_C(0x98CE7B8999D78990), UINT64_C(0x8520F1D7BBFB284C),
400
+       UINT64_C(0xA3136F35DD8ECA28), UINT64_C(0xBEFDE56BFFA26BF4),
401
+       UINT64_C(0x4C300AC98DC40345), UINT64_C(0x51DE8097AFE8A299),
402
+       UINT64_C(0x77ED1E75C99D40FD), UINT64_C(0x6A03942BEBB1E121),
403
+       UINT64_C(0x3B8A23B105768435), UINT64_C(0x2664A9EF275A25E9),
404
+       UINT64_C(0x0057370D412FC78D), UINT64_C(0x1DB9BD5363036651),
405
+       UINT64_C(0xA34458389CA10DA5), UINT64_C(0xBEAAD266BE8DAC79),
406
+       UINT64_C(0x98994C84D8F84E1D), UINT64_C(0x8577C6DAFAD4EFC1),
407
+       UINT64_C(0xD4FE714014138AD5), UINT64_C(0xC910FB1E363F2B09),
408
+       UINT64_C(0xEF2365FC504AC96D), UINT64_C(0xF2CDEFA2726668B1),
409
+       UINT64_C(0x986015931B88068A), UINT64_C(0x858E9FCD39A4A756),
410
+       UINT64_C(0xA3BD012F5FD14532), UINT64_C(0xBE538B717DFDE4EE),
411
+       UINT64_C(0xEFDA3CEB933A81FA), UINT64_C(0xF234B6B5B1162026),
412
+       UINT64_C(0xD4072857D763C242), UINT64_C(0xC9E9A209F54F639E),
413
+       UINT64_C(0x771447620AED086A), UINT64_C(0x6AFACD3C28C1A9B6),
414
+       UINT64_C(0x4CC953DE4EB44BD2), UINT64_C(0x5127D9806C98EA0E),
415
+       UINT64_C(0x00AE6E1A825F8F1A), UINT64_C(0x1D40E444A0732EC6),
416
+       UINT64_C(0x3B737AA6C606CCA2), UINT64_C(0x269DF0F8E42A6D7E),
417
+       UINT64_C(0xD4501F5A964C05CF), UINT64_C(0xC9BE9504B460A413),
418
+       UINT64_C(0xEF8D0BE6D2154677), UINT64_C(0xF26381B8F039E7AB),
419
+       UINT64_C(0xA3EA36221EFE82BF), UINT64_C(0xBE04BC7C3CD22363),
420
+       UINT64_C(0x9837229E5AA7C107), UINT64_C(0x85D9A8C0788B60DB),
421
+       UINT64_C(0x3B244DAB87290B2F), UINT64_C(0x26CAC7F5A505AAF3),
422
+       UINT64_C(0x00F95917C3704897), UINT64_C(0x1D17D349E15CE94B),
423
+       UINT64_C(0x4C9E64D30F9B8C5F), UINT64_C(0x5170EE8D2DB72D83),
424
+       UINT64_C(0x7743706F4BC2CFE7), UINT64_C(0x6AADFA3169EE6E3B),
425
+       UINT64_C(0xA218840D981E1391), UINT64_C(0xBFF60E53BA32B24D),
426
+       UINT64_C(0x99C590B1DC475029), UINT64_C(0x842B1AEFFE6BF1F5),
427
+       UINT64_C(0xD5A2AD7510AC94E1), UINT64_C(0xC84C272B3280353D),
428
+       UINT64_C(0xEE7FB9C954F5D759), UINT64_C(0xF391339776D97685),
429
+       UINT64_C(0x4D6CD6FC897B1D71), UINT64_C(0x50825CA2AB57BCAD),
430
+       UINT64_C(0x76B1C240CD225EC9), UINT64_C(0x6B5F481EEF0EFF15),
431
+       UINT64_C(0x3AD6FF8401C99A01), UINT64_C(0x273875DA23E53BDD),
432
+       UINT64_C(0x010BEB384590D9B9), UINT64_C(0x1CE5616667BC7865),
433
+       UINT64_C(0xEE288EC415DA10D4), UINT64_C(0xF3C6049A37F6B108),
434
+       UINT64_C(0xD5F59A785183536C), UINT64_C(0xC81B102673AFF2B0),
435
+       UINT64_C(0x9992A7BC9D6897A4), UINT64_C(0x847C2DE2BF443678),
436
+       UINT64_C(0xA24FB300D931D41C), UINT64_C(0xBFA1395EFB1D75C0),
437
+       UINT64_C(0x015CDC3504BF1E34), UINT64_C(0x1CB2566B2693BFE8),
438
+       UINT64_C(0x3A81C88940E65D8C), UINT64_C(0x276F42D762CAFC50),
439
+       UINT64_C(0x76E6F54D8C0D9944), UINT64_C(0x6B087F13AE213898),
440
+       UINT64_C(0x4D3BE1F1C854DAFC), UINT64_C(0x50D56BAFEA787B20),
441
+       UINT64_C(0x3A78919E8396151B), UINT64_C(0x27961BC0A1BAB4C7),
442
+       UINT64_C(0x01A58522C7CF56A3), UINT64_C(0x1C4B0F7CE5E3F77F),
443
+       UINT64_C(0x4DC2B8E60B24926B), UINT64_C(0x502C32B8290833B7),
444
+       UINT64_C(0x761FAC5A4F7DD1D3), UINT64_C(0x6BF126046D51700F),
445
+       UINT64_C(0xD50CC36F92F31BFB), UINT64_C(0xC8E24931B0DFBA27),
446
+       UINT64_C(0xEED1D7D3D6AA5843), UINT64_C(0xF33F5D8DF486F99F),
447
+       UINT64_C(0xA2B6EA171A419C8B), UINT64_C(0xBF586049386D3D57),
448
+       UINT64_C(0x996BFEAB5E18DF33), UINT64_C(0x848574F57C347EEF),
449
+       UINT64_C(0x76489B570E52165E), UINT64_C(0x6BA611092C7EB782),
450
+       UINT64_C(0x4D958FEB4A0B55E6), UINT64_C(0x507B05B56827F43A),
451
+       UINT64_C(0x01F2B22F86E0912E), UINT64_C(0x1C1C3871A4CC30F2),
452
+       UINT64_C(0x3A2FA693C2B9D296), UINT64_C(0x27C12CCDE095734A),
453
+       UINT64_C(0x993CC9A61F3718BE), UINT64_C(0x84D243F83D1BB962),
454
+       UINT64_C(0xA2E1DD1A5B6E5B06), UINT64_C(0xBF0F57447942FADA),
455
+       UINT64_C(0xEE86E0DE97859FCE), UINT64_C(0xF3686A80B5A93E12),
456
+       UINT64_C(0xD55BF462D3DCDC76), UINT64_C(0xC8B57E3CF1F07DAA),
457
+       UINT64_C(0xD6E9A7309F3239A7), UINT64_C(0xCB072D6EBD1E987B),
458
+       UINT64_C(0xED34B38CDB6B7A1F), UINT64_C(0xF0DA39D2F947DBC3),
459
+       UINT64_C(0xA1538E481780BED7), UINT64_C(0xBCBD041635AC1F0B),
460
+       UINT64_C(0x9A8E9AF453D9FD6F), UINT64_C(0x876010AA71F55CB3),
461
+       UINT64_C(0x399DF5C18E573747), UINT64_C(0x24737F9FAC7B969B),
462
+       UINT64_C(0x0240E17DCA0E74FF), UINT64_C(0x1FAE6B23E822D523),
463
+       UINT64_C(0x4E27DCB906E5B037), UINT64_C(0x53C956E724C911EB),
464
+       UINT64_C(0x75FAC80542BCF38F), UINT64_C(0x6814425B60905253),
465
+       UINT64_C(0x9AD9ADF912F63AE2), UINT64_C(0x873727A730DA9B3E),
466
+       UINT64_C(0xA104B94556AF795A), UINT64_C(0xBCEA331B7483D886),
467
+       UINT64_C(0xED6384819A44BD92), UINT64_C(0xF08D0EDFB8681C4E),
468
+       UINT64_C(0xD6BE903DDE1DFE2A), UINT64_C(0xCB501A63FC315FF6),
469
+       UINT64_C(0x75ADFF0803933402), UINT64_C(0x6843755621BF95DE),
470
+       UINT64_C(0x4E70EBB447CA77BA), UINT64_C(0x539E61EA65E6D666),
471
+       UINT64_C(0x0217D6708B21B372), UINT64_C(0x1FF95C2EA90D12AE),
472
+       UINT64_C(0x39CAC2CCCF78F0CA), UINT64_C(0x24244892ED545116),
473
+       UINT64_C(0x4E89B2A384BA3F2D), UINT64_C(0x536738FDA6969EF1),
474
+       UINT64_C(0x7554A61FC0E37C95), UINT64_C(0x68BA2C41E2CFDD49),
475
+       UINT64_C(0x39339BDB0C08B85D), UINT64_C(0x24DD11852E241981),
476
+       UINT64_C(0x02EE8F674851FBE5), UINT64_C(0x1F0005396A7D5A39),
477
+       UINT64_C(0xA1FDE05295DF31CD), UINT64_C(0xBC136A0CB7F39011),
478
+       UINT64_C(0x9A20F4EED1867275), UINT64_C(0x87CE7EB0F3AAD3A9),
479
+       UINT64_C(0xD647C92A1D6DB6BD), UINT64_C(0xCBA943743F411761),
480
+       UINT64_C(0xED9ADD965934F505), UINT64_C(0xF07457C87B1854D9),
481
+       UINT64_C(0x02B9B86A097E3C68), UINT64_C(0x1F5732342B529DB4),
482
+       UINT64_C(0x3964ACD64D277FD0), UINT64_C(0x248A26886F0BDE0C),
483
+       UINT64_C(0x7503911281CCBB18), UINT64_C(0x68ED1B4CA3E01AC4),
484
+       UINT64_C(0x4EDE85AEC595F8A0), UINT64_C(0x53300FF0E7B9597C),
485
+       UINT64_C(0xEDCDEA9B181B3288), UINT64_C(0xF02360C53A379354),
486
+       UINT64_C(0xD610FE275C427130), UINT64_C(0xCBFE74797E6ED0EC),
487
+       UINT64_C(0x9A77C3E390A9B5F8), UINT64_C(0x879949BDB2851424),
488
+       UINT64_C(0xA1AAD75FD4F0F640), UINT64_C(0xBC445D01F6DC579C),
489
+       UINT64_C(0x74F1233D072C2A36), UINT64_C(0x691FA96325008BEA),
490
+       UINT64_C(0x4F2C37814375698E), UINT64_C(0x52C2BDDF6159C852),
491
+       UINT64_C(0x034B0A458F9EAD46), UINT64_C(0x1EA5801BADB20C9A),
492
+       UINT64_C(0x38961EF9CBC7EEFE), UINT64_C(0x257894A7E9EB4F22),
493
+       UINT64_C(0x9B8571CC164924D6), UINT64_C(0x866BFB923465850A),
494
+       UINT64_C(0xA05865705210676E), UINT64_C(0xBDB6EF2E703CC6B2),
495
+       UINT64_C(0xEC3F58B49EFBA3A6), UINT64_C(0xF1D1D2EABCD7027A),
496
+       UINT64_C(0xD7E24C08DAA2E01E), UINT64_C(0xCA0CC656F88E41C2),
497
+       UINT64_C(0x38C129F48AE82973), UINT64_C(0x252FA3AAA8C488AF),
498
+       UINT64_C(0x031C3D48CEB16ACB), UINT64_C(0x1EF2B716EC9DCB17),
499
+       UINT64_C(0x4F7B008C025AAE03), UINT64_C(0x52958AD220760FDF),
500
+       UINT64_C(0x74A614304603EDBB), UINT64_C(0x69489E6E642F4C67),
501
+       UINT64_C(0xD7B57B059B8D2793), UINT64_C(0xCA5BF15BB9A1864F),
502
+       UINT64_C(0xEC686FB9DFD4642B), UINT64_C(0xF186E5E7FDF8C5F7),
503
+       UINT64_C(0xA00F527D133FA0E3), UINT64_C(0xBDE1D8233113013F),
504
+       UINT64_C(0x9BD246C15766E35B), UINT64_C(0x863CCC9F754A4287),
505
+       UINT64_C(0xEC9136AE1CA42CBC), UINT64_C(0xF17FBCF03E888D60),
506
+       UINT64_C(0xD74C221258FD6F04), UINT64_C(0xCAA2A84C7AD1CED8),
507
+       UINT64_C(0x9B2B1FD69416ABCC), UINT64_C(0x86C59588B63A0A10),
508
+       UINT64_C(0xA0F60B6AD04FE874), UINT64_C(0xBD188134F26349A8),
509
+       UINT64_C(0x03E5645F0DC1225C), UINT64_C(0x1E0BEE012FED8380),
510
+       UINT64_C(0x383870E3499861E4), UINT64_C(0x25D6FABD6BB4C038),
511
+       UINT64_C(0x745F4D278573A52C), UINT64_C(0x69B1C779A75F04F0),
512
+       UINT64_C(0x4F82599BC12AE694), UINT64_C(0x526CD3C5E3064748),
513
+       UINT64_C(0xA0A13C6791602FF9), UINT64_C(0xBD4FB639B34C8E25),
514
+       UINT64_C(0x9B7C28DBD5396C41), UINT64_C(0x8692A285F715CD9D),
515
+       UINT64_C(0xD71B151F19D2A889), UINT64_C(0xCAF59F413BFE0955),
516
+       UINT64_C(0xECC601A35D8BEB31), UINT64_C(0xF1288BFD7FA74AED),
517
+       UINT64_C(0x4FD56E9680052119), UINT64_C(0x523BE4C8A22980C5),
518
+       UINT64_C(0x74087A2AC45C62A1), UINT64_C(0x69E6F074E670C37D),
519
+       UINT64_C(0x386F47EE08B7A669), UINT64_C(0x2581CDB02A9B07B5),
520
+       UINT64_C(0x03B253524CEEE5D1), UINT64_C(0x1E5CD90C6EC2440D)
521
+   }
522
+};
523
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_tablegen.c Added
90
 
1
@@ -0,0 +1,88 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc64_tablegen.c
5
+/// \brief      Generate crc64_table_le.h and crc64_table_be.h
6
+///
7
+/// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c
8
+/// Add -DWORDS_BIGENDIAN to generate big endian table.
9
+//
10
+//  Author:     Lasse Collin
11
+//
12
+//  This file has been put into the public domain.
13
+//  You can do whatever you want with this file.
14
+//
15
+///////////////////////////////////////////////////////////////////////////////
16
+
17
+#include <stdio.h>
18
+#include "../../common/tuklib_integer.h"
19
+
20
+
21
+static uint64_t crc64_table[4][256];
22
+
23
+
24
+extern void
25
+init_crc64_table(void)
26
+{
27
+   static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
28
+
29
+   for (size_t s = 0; s < 4; ++s) {
30
+       for (size_t b = 0; b < 256; ++b) {
31
+           uint64_t r = s == 0 ? b : crc64_table[s - 1][b];
32
+
33
+           for (size_t i = 0; i < 8; ++i) {
34
+               if (r & 1)
35
+                   r = (r >> 1) ^ poly64;
36
+               else
37
+                   r >>= 1;
38
+           }
39
+
40
+           crc64_table[s][b] = r;
41
+       }
42
+   }
43
+
44
+#ifdef WORDS_BIGENDIAN
45
+   for (size_t s = 0; s < 4; ++s)
46
+       for (size_t b = 0; b < 256; ++b)
47
+           crc64_table[s][b] = bswap64(crc64_table[s][b]);
48
+#endif
49
+
50
+   return;
51
+}
52
+
53
+
54
+static void
55
+print_crc64_table(void)
56
+{
57
+   printf("/* This file has been automatically generated by "
58
+           "crc64_tablegen.c. */\n\n"
59
+           "const uint64_t lzma_crc64_table[4][256] = {\n\t{");
60
+
61
+   for (size_t s = 0; s < 4; ++s) {
62
+       for (size_t b = 0; b < 256; ++b) {
63
+           if ((b % 2) == 0)
64
+               printf("\n\t\t");
65
+
66
+           printf("UINT64_C(0x%016" PRIX64 ")",
67
+                   crc64_table[s][b]);
68
+
69
+           if (b != 255)
70
+               printf(",%s", (b+1) % 2 == 0 ? "" : " ");
71
+       }
72
+
73
+       if (s == 3)
74
+           printf("\n\t}\n};\n");
75
+       else
76
+           printf("\n\t}, {");
77
+   }
78
+
79
+   return;
80
+}
81
+
82
+
83
+int
84
+main(void)
85
+{
86
+   init_crc64_table();
87
+   print_crc64_table();
88
+   return 0;
89
+}
90
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc64_x86.S Added
289
 
1
@@ -0,0 +1,287 @@
2
+/*
3
+ * Speed-optimized CRC64 using slicing-by-four algorithm
4
+ *
5
+ * This uses only i386 instructions, but it is optimized for i686 and later
6
+ * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2).
7
+ *
8
+ * Authors: Igor Pavlov (original CRC32 assembly code)
9
+ *          Lasse Collin (CRC64 adaptation of the modified CRC32 code)
10
+ *
11
+ * This file has been put into the public domain.
12
+ * You can do whatever you want with this file.
13
+ *
14
+ * This code needs lzma_crc64_table, which can be created using the
15
+ * following C code:
16
+
17
+uint64_t lzma_crc64_table[4][256];
18
+
19
+void
20
+init_table(void)
21
+{
22
+   // ECMA-182
23
+   static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
24
+
25
+   for (size_t s = 0; s < 4; ++s) {
26
+       for (size_t b = 0; b < 256; ++b) {
27
+           uint64_t r = s == 0 ? b : lzma_crc64_table[s - 1][b];
28
+
29
+           for (size_t i = 0; i < 8; ++i) {
30
+               if (r & 1)
31
+                   r = (r >> 1) ^ poly64;
32
+               else
33
+                   r >>= 1;
34
+           }
35
+
36
+           lzma_crc64_table[s][b] = r;
37
+       }
38
+   }
39
+}
40
+
41
+ * The prototype of the CRC64 function:
42
+ * extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
43
+ */
44
+
45
+/*
46
+ * On some systems, the functions need to be prefixed. The prefix is
47
+ * usually an underscore.
48
+ */
49
+#ifndef __USER_LABEL_PREFIX__
50
+#  define __USER_LABEL_PREFIX__
51
+#endif
52
+#define MAKE_SYM_CAT(prefix, sym) prefix ## sym
53
+#define MAKE_SYM(prefix, sym) MAKE_SYM_CAT(prefix, sym)
54
+#define LZMA_CRC64 MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc64)
55
+#define LZMA_CRC64_TABLE MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc64_table)
56
+
57
+/*
58
+ * Solaris assembler doesn't have .p2align, and Darwin uses .align
59
+ * differently than GNU/Linux and Solaris.
60
+ */
61
+#if defined(__APPLE__) || defined(__MSDOS__)
62
+#  define ALIGN(pow2, abs) .align pow2
63
+#else
64
+#  define ALIGN(pow2, abs) .align abs
65
+#endif
66
+
67
+   .text
68
+   .globl  LZMA_CRC64
69
+
70
+#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) \
71
+       && !defined(__MSDOS__)
72
+   .type   LZMA_CRC64, @function
73
+#endif
74
+
75
+   ALIGN(4, 16)
76
+LZMA_CRC64:
77
+   /*
78
+    * Register usage:
79
+    * %eax crc LSB
80
+    * %edx crc MSB
81
+    * %esi buf
82
+    * %edi size or buf + size
83
+    * %ebx lzma_crc64_table
84
+    * %ebp Table index
85
+    * %ecx Temporary
86
+    */
87
+   pushl   %ebx
88
+   pushl   %esi
89
+   pushl   %edi
90
+   pushl   %ebp
91
+   movl    0x14(%esp), %esi /* buf */
92
+   movl    0x18(%esp), %edi /* size */
93
+   movl    0x1C(%esp), %eax /* crc LSB */
94
+   movl    0x20(%esp), %edx /* crc MSB */
95
+
96
+   /*
97
+    * Store the address of lzma_crc64_table to %ebx. This is needed to
98
+    * get position-independent code (PIC).
99
+    *
100
+    * The PIC macro is defined by libtool, while __PIC__ is defined
101
+    * by GCC but only on some systems. Testing for both makes it simpler
102
+    * to test this code without libtool, and keeps the code working also
103
+    * when built with libtool but using something else than GCC.
104
+    *
105
+    * I understood that libtool may define PIC on Windows even though
106
+    * the code in Windows DLLs is not PIC in sense that it is in ELF
107
+    * binaries, so we need a separate check to always use the non-PIC
108
+    * code on Windows.
109
+    */
110
+#if (!defined(PIC) && !defined(__PIC__)) \
111
+       || (defined(_WIN32) || defined(__CYGWIN__))
112
+   /* Not PIC */
113
+   movl    $ LZMA_CRC64_TABLE, %ebx
114
+#elif defined(__APPLE__)
115
+   /* Mach-O */
116
+   call    .L_get_pc
117
+.L_pic:
118
+   leal    .L_lzma_crc64_table$non_lazy_ptr-.L_pic(%ebx), %ebx
119
+   movl    (%ebx), %ebx
120
+#else
121
+   /* ELF */
122
+   call    .L_get_pc
123
+   addl    $_GLOBAL_OFFSET_TABLE_, %ebx
124
+   movl    LZMA_CRC64_TABLE@GOT(%ebx), %ebx
125
+#endif
126
+
127
+   /* Complement the initial value. */
128
+   notl    %eax
129
+   notl    %edx
130
+
131
+.L_align:
132
+   /*
133
+    * Check if there is enough input to use slicing-by-four.
134
+    * We need eight bytes, because the loop pre-reads four bytes.
135
+    */
136
+   cmpl    $8, %edi
137
+   jb  .L_rest
138
+
139
+   /* Check if we have reached alignment of four bytes. */
140
+   testl   $3, %esi
141
+   jz  .L_slice
142
+
143
+   /* Calculate CRC of the next input byte. */
144
+   movzbl  (%esi), %ebp
145
+   incl    %esi
146
+   movzbl  %al, %ecx
147
+   xorl    %ecx, %ebp
148
+   shrdl   $8, %edx, %eax
149
+   xorl    (%ebx, %ebp, 8), %eax
150
+   shrl    $8, %edx
151
+   xorl    4(%ebx, %ebp, 8), %edx
152
+   decl    %edi
153
+   jmp .L_align
154
+
155
+.L_slice:
156
+   /*
157
+    * If we get here, there's at least eight bytes of aligned input
158
+    * available. Make %edi multiple of four bytes. Store the possible
159
+    * remainder over the "size" variable in the argument stack.
160
+    */
161
+   movl    %edi, 0x18(%esp)
162
+   andl    $-4, %edi
163
+   subl    %edi, 0x18(%esp)
164
+
165
+   /*
166
+    * Let %edi be buf + size - 4 while running the main loop. This way
167
+    * we can compare for equality to determine when exit the loop.
168
+    */
169
+   addl    %esi, %edi
170
+   subl    $4, %edi
171
+
172
+   /* Read in the first four aligned bytes. */
173
+   movl    (%esi), %ecx
174
+
175
+.L_loop:
176
+   xorl    %eax, %ecx
177
+   movzbl  %cl, %ebp
178
+   movl    0x1800(%ebx, %ebp, 8), %eax
179
+   xorl    %edx, %eax
180
+   movl    0x1804(%ebx, %ebp, 8), %edx
181
+   movzbl  %ch, %ebp
182
+   xorl    0x1000(%ebx, %ebp, 8), %eax
183
+   xorl    0x1004(%ebx, %ebp, 8), %edx
184
+   shrl    $16, %ecx
185
+   movzbl  %cl, %ebp
186
+   xorl    0x0800(%ebx, %ebp, 8), %eax
187
+   xorl    0x0804(%ebx, %ebp, 8), %edx
188
+   movzbl  %ch, %ebp
189
+   addl    $4, %esi
190
+   xorl    (%ebx, %ebp, 8), %eax
191
+   xorl    4(%ebx, %ebp, 8), %edx
192
+
193
+   /* Check for end of aligned input. */
194
+   cmpl    %edi, %esi
195
+
196
+   /*
197
+    * Copy the next input byte to %ecx. It is slightly faster to
198
+    * read it here than at the top of the loop.
199
+    */
200
+   movl    (%esi), %ecx
201
+   jb  .L_loop
202
+
203
+   /*
204
+    * Process the remaining four bytes, which we have already
205
+    * copied to %ecx.
206
+    */
207
+   xorl    %eax, %ecx
208
+   movzbl  %cl, %ebp
209
+   movl    0x1800(%ebx, %ebp, 8), %eax
210
+   xorl    %edx, %eax
211
+   movl    0x1804(%ebx, %ebp, 8), %edx
212
+   movzbl  %ch, %ebp
213
+   xorl    0x1000(%ebx, %ebp, 8), %eax
214
+   xorl    0x1004(%ebx, %ebp, 8), %edx
215
+   shrl    $16, %ecx
216
+   movzbl  %cl, %ebp
217
+   xorl    0x0800(%ebx, %ebp, 8), %eax
218
+   xorl    0x0804(%ebx, %ebp, 8), %edx
219
+   movzbl  %ch, %ebp
220
+   addl    $4, %esi
221
+   xorl    (%ebx, %ebp, 8), %eax
222
+   xorl    4(%ebx, %ebp, 8), %edx
223
+
224
+   /* Copy the number of remaining bytes to %edi. */
225
+   movl    0x18(%esp), %edi
226
+
227
+.L_rest:
228
+   /* Check for end of input. */
229
+   testl   %edi, %edi
230
+   jz  .L_return
231
+
232
+   /* Calculate CRC of the next input byte. */
233
+   movzbl  (%esi), %ebp
234
+   incl    %esi
235
+   movzbl  %al, %ecx
236
+   xorl    %ecx, %ebp
237
+   shrdl   $8, %edx, %eax
238
+   xorl    (%ebx, %ebp, 8), %eax
239
+   shrl    $8, %edx
240
+   xorl    4(%ebx, %ebp, 8), %edx
241
+   decl    %edi
242
+   jmp .L_rest
243
+
244
+.L_return:
245
+   /* Complement the final value. */
246
+   notl    %eax
247
+   notl    %edx
248
+
249
+   popl    %ebp
250
+   popl    %edi
251
+   popl    %esi
252
+   popl    %ebx
253
+   ret
254
+
255
+#if defined(PIC) || defined(__PIC__)
256
+   ALIGN(4, 16)
257
+.L_get_pc:
258
+   movl    (%esp), %ebx
259
+   ret
260
+#endif
261
+
262
+#if defined(__APPLE__) && (defined(PIC) || defined(__PIC__))
263
+   /* Mach-O PIC */
264
+   .section __IMPORT,__pointers,non_lazy_symbol_pointers
265
+.L_lzma_crc64_table$non_lazy_ptr:
266
+   .indirect_symbol LZMA_CRC64_TABLE
267
+   .long 0
268
+
269
+#elif defined(_WIN32) || defined(__CYGWIN__)
270
+#  ifdef DLL_EXPORT
271
+   /* This is equivalent of __declspec(dllexport). */
272
+   .section .drectve
273
+   .ascii " -export:lzma_crc64"
274
+#  endif
275
+
276
+#elif !defined(__MSDOS__)
277
+   /* ELF */
278
+   .size   LZMA_CRC64, .-LZMA_CRC64
279
+#endif
280
+
281
+/*
282
+ * This is needed to support non-executable stack. It's ugly to
283
+ * use __linux__ here, but I don't know a way to detect when
284
+ * we are using GNU assembler.
285
+ */
286
+#if defined(__ELF__) && defined(__linux__)
287
+   .section    .note.GNU-stack,"",@progbits
288
+#endif
289
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/crc_macros.h Added
32
 
1
@@ -0,0 +1,30 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       crc_macros.h
5
+/// \brief      Some endian-dependent macros for CRC32 and CRC64
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifdef WORDS_BIGENDIAN
15
+#  define A(x) ((x) >> 24)
16
+#  define B(x) (((x) >> 16) & 0xFF)
17
+#  define C(x) (((x) >> 8) & 0xFF)
18
+#  define D(x) ((x) & 0xFF)
19
+
20
+#  define S8(x) ((x) << 8)
21
+#  define S32(x) ((x) << 32)
22
+
23
+#else
24
+#  define A(x) ((x) & 0xFF)
25
+#  define B(x) (((x) >> 8) & 0xFF)
26
+#  define C(x) (((x) >> 16) & 0xFF)
27
+#  define D(x) ((x) >> 24)
28
+
29
+#  define S8(x) ((x) >> 8)
30
+#  define S32(x) ((x) >> 32)
31
+#endif
32
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/check/sha256.c Added
202
 
1
@@ -0,0 +1,200 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       sha256.c
5
+/// \brief      SHA-256
6
+///
7
+/// \todo       Crypto++ has x86 ASM optimizations. They use SSE so if they
8
+///             are imported to liblzma, SSE instructions need to be used
9
+///             conditionally to keep the code working on older boxes.
10
+//
11
+//  This code is based on the code found from 7-Zip, which has a modified
12
+//  version of the SHA-256 found from Crypto++ <http://www.cryptopp.com/>.
13
+//  The code was modified a little to fit into liblzma.
14
+//
15
+//  Authors:    Kevin Springle
16
+//              Wei Dai
17
+//              Igor Pavlov
18
+//              Lasse Collin
19
+//
20
+//  This file has been put into the public domain.
21
+//  You can do whatever you want with this file.
22
+//
23
+///////////////////////////////////////////////////////////////////////////////
24
+
25
+// Avoid bogus warnings in transform().
26
+#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4
27
+#  pragma GCC diagnostic ignored "-Wuninitialized"
28
+#endif
29
+
30
+#include "check.h"
31
+
32
+// At least on x86, GCC is able to optimize this to a rotate instruction.
33
+#define rotr_32(num, amount) ((num) >> (amount) | (num) << (32 - (amount)))
34
+
35
+#define blk0(i) (W[i] = data[i])
36
+#define blk2(i) (W[i & 15] += s1(W[(i - 2) & 15]) + W[(i - 7) & 15] \
37
+       + s0(W[(i - 15) & 15]))
38
+
39
+#define Ch(x, y, z) (z ^ (x & (y ^ z)))
40
+#define Maj(x, y, z) ((x & y) | (z & (x | y)))
41
+
42
+#define a(i) T[(0 - i) & 7]
43
+#define b(i) T[(1 - i) & 7]
44
+#define c(i) T[(2 - i) & 7]
45
+#define d(i) T[(3 - i) & 7]
46
+#define e(i) T[(4 - i) & 7]
47
+#define f(i) T[(5 - i) & 7]
48
+#define g(i) T[(6 - i) & 7]
49
+#define h(i) T[(7 - i) & 7]
50
+
51
+#define R(i) \
52
+   h(i) += S1(e(i)) + Ch(e(i), f(i), g(i)) + SHA256_K[i + j] \
53
+       + (j ? blk2(i) : blk0(i)); \
54
+   d(i) += h(i); \
55
+   h(i) += S0(a(i)) + Maj(a(i), b(i), c(i))
56
+
57
+#define S0(x) (rotr_32(x, 2) ^ rotr_32(x, 13) ^ rotr_32(x, 22))
58
+#define S1(x) (rotr_32(x, 6) ^ rotr_32(x, 11) ^ rotr_32(x, 25))
59
+#define s0(x) (rotr_32(x, 7) ^ rotr_32(x, 18) ^ (x >> 3))
60
+#define s1(x) (rotr_32(x, 17) ^ rotr_32(x, 19) ^ (x >> 10))
61
+
62
+
63
+static const uint32_t SHA256_K[64] = {
64
+   0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
65
+   0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
66
+   0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
67
+   0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
68
+   0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
69
+   0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
70
+   0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
71
+   0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
72
+   0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
73
+   0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
74
+   0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
75
+   0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
76
+   0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
77
+   0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
78
+   0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
79
+   0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,
80
+};
81
+
82
+
83
+static void
84
+transform(uint32_t state[8], const uint32_t data[16])
85
+{
86
+   uint32_t W[16];
87
+   uint32_t T[8];
88
+
89
+   // Copy state[] to working vars.
90
+   memcpy(T, state, sizeof(T));
91
+
92
+   // 64 operations, partially loop unrolled
93
+   for (unsigned int j = 0; j < 64; j += 16) {
94
+       R( 0); R( 1); R( 2); R( 3);
95
+       R( 4); R( 5); R( 6); R( 7);
96
+       R( 8); R( 9); R(10); R(11);
97
+       R(12); R(13); R(14); R(15);
98
+   }
99
+
100
+   // Add the working vars back into state[].
101
+   state[0] += a(0);
102
+   state[1] += b(0);
103
+   state[2] += c(0);
104
+   state[3] += d(0);
105
+   state[4] += e(0);
106
+   state[5] += f(0);
107
+   state[6] += g(0);
108
+   state[7] += h(0);
109
+}
110
+
111
+
112
+static void
113
+process(lzma_check_state *check)
114
+{
115
+#ifdef WORDS_BIGENDIAN
116
+   transform(check->state.sha256.state, check->buffer.u32);
117
+
118
+#else
119
+   uint32_t data[16];
120
+
121
+   for (size_t i = 0; i < 16; ++i)
122
+       data[i] = bswap32(check->buffer.u32[i]);
123
+
124
+   transform(check->state.sha256.state, data);
125
+#endif
126
+
127
+   return;
128
+}
129
+
130
+
131
+extern void
132
+lzma_sha256_init(lzma_check_state *check)
133
+{
134
+   static const uint32_t s[8] = {
135
+       0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
136
+       0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19,
137
+   };
138
+
139
+   memcpy(check->state.sha256.state, s, sizeof(s));
140
+   check->state.sha256.size = 0;
141
+
142
+   return;
143
+}
144
+
145
+
146
+extern void
147
+lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)
148
+{
149
+   // Copy the input data into a properly aligned temporary buffer.
150
+   // This way we can be called with arbitrarily sized buffers
151
+   // (no need to be multiple of 64 bytes), and the code works also
152
+   // on architectures that don't allow unaligned memory access.
153
+   while (size > 0) {
154
+       const size_t copy_start = check->state.sha256.size & 0x3F;
155
+       size_t copy_size = 64 - copy_start;
156
+       if (copy_size > size)
157
+           copy_size = size;
158
+
159
+       memcpy(check->buffer.u8 + copy_start, buf, copy_size);
160
+
161
+       buf += copy_size;
162
+       size -= copy_size;
163
+       check->state.sha256.size += copy_size;
164
+
165
+       if ((check->state.sha256.size & 0x3F) == 0)
166
+           process(check);
167
+   }
168
+
169
+   return;
170
+}
171
+
172
+
173
+extern void
174
+lzma_sha256_finish(lzma_check_state *check)
175
+{
176
+   // Add padding as described in RFC 3174 (it describes SHA-1 but
177
+   // the same padding style is used for SHA-256 too).
178
+   size_t pos = check->state.sha256.size & 0x3F;
179
+   check->buffer.u8[pos++] = 0x80;
180
+
181
+   while (pos != 64 - 8) {
182
+       if (pos == 64) {
183
+           process(check);
184
+           pos = 0;
185
+       }
186
+
187
+       check->buffer.u8[pos++] = 0x00;
188
+   }
189
+
190
+   // Convert the message size from bytes to bits.
191
+   check->state.sha256.size *= 8;
192
+
193
+   check->buffer.u64[(64 - 8) / 8] = conv64be(check->state.sha256.size);
194
+
195
+   process(check);
196
+
197
+   for (size_t i = 0; i < 8; ++i)
198
+       check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);
199
+
200
+   return;
201
+}
202
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/alone_decoder.c Added
240
 
1
@@ -0,0 +1,238 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       alone_decoder.c
5
+/// \brief      Decoder for LZMA_Alone files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "alone_decoder.h"
15
+#include "lzma_decoder.h"
16
+#include "lz_decoder.h"
17
+
18
+
19
+struct lzma_coder_s {
20
+   lzma_next_coder next;
21
+
22
+   enum {
23
+       SEQ_PROPERTIES,
24
+       SEQ_DICTIONARY_SIZE,
25
+       SEQ_UNCOMPRESSED_SIZE,
26
+       SEQ_CODER_INIT,
27
+       SEQ_CODE,
28
+   } sequence;
29
+
30
+   /// If true, reject files that are unlikely to be .lzma files.
31
+   /// If false, more non-.lzma files get accepted and will give
32
+   /// LZMA_DATA_ERROR either immediately or after a few output bytes.
33
+   bool picky;
34
+
35
+   /// Position in the header fields
36
+   size_t pos;
37
+
38
+   /// Uncompressed size decoded from the header
39
+   lzma_vli uncompressed_size;
40
+
41
+   /// Memory usage limit
42
+   uint64_t memlimit;
43
+
44
+   /// Amount of memory actually needed (only an estimate)
45
+   uint64_t memusage;
46
+
47
+   /// Options decoded from the header needed to initialize
48
+   /// the LZMA decoder
49
+   lzma_options_lzma options;
50
+};
51
+
52
+
53
+static lzma_ret
54
+alone_decode(lzma_coder *coder,
55
+       lzma_allocator *allocator lzma_attribute((__unused__)),
56
+       const uint8_t *restrict in, size_t *restrict in_pos,
57
+       size_t in_size, uint8_t *restrict out,
58
+       size_t *restrict out_pos, size_t out_size,
59
+       lzma_action action)
60
+{
61
+   while (*out_pos < out_size
62
+           && (coder->sequence == SEQ_CODE || *in_pos < in_size))
63
+   switch (coder->sequence) {
64
+   case SEQ_PROPERTIES:
65
+       if (lzma_lzma_lclppb_decode(&coder->options, in[*in_pos]))
66
+           return LZMA_FORMAT_ERROR;
67
+
68
+       coder->sequence = SEQ_DICTIONARY_SIZE;
69
+       ++*in_pos;
70
+       break;
71
+
72
+   case SEQ_DICTIONARY_SIZE:
73
+       coder->options.dict_size
74
+               |= (size_t)(in[*in_pos]) << (coder->pos * 8);
75
+
76
+       if (++coder->pos == 4) {
77
+           if (coder->picky && coder->options.dict_size
78
+                   != UINT32_MAX) {
79
+               // A hack to ditch tons of false positives:
80
+               // We allow only dictionary sizes that are
81
+               // 2^n or 2^n + 2^(n-1). LZMA_Alone created
82
+               // only files with 2^n, but accepts any
83
+               // dictionary size.
84
+               uint32_t d = coder->options.dict_size - 1;
85
+               d |= d >> 2;
86
+               d |= d >> 3;
87
+               d |= d >> 4;
88
+               d |= d >> 8;
89
+               d |= d >> 16;
90
+               ++d;
91
+
92
+               if (d != coder->options.dict_size)
93
+                   return LZMA_FORMAT_ERROR;
94
+           }
95
+
96
+           coder->pos = 0;
97
+           coder->sequence = SEQ_UNCOMPRESSED_SIZE;
98
+       }
99
+
100
+       ++*in_pos;
101
+       break;
102
+
103
+   case SEQ_UNCOMPRESSED_SIZE:
104
+       coder->uncompressed_size
105
+               |= (lzma_vli)(in[*in_pos]) << (coder->pos * 8);
106
+       ++*in_pos;
107
+       if (++coder->pos < 8)
108
+           break;
109
+
110
+       // Another hack to ditch false positives: Assume that
111
+       // if the uncompressed size is known, it must be less
112
+       // than 256 GiB.
113
+       if (coder->picky
114
+               && coder->uncompressed_size != LZMA_VLI_UNKNOWN
115
+               && coder->uncompressed_size
116
+                   >= (LZMA_VLI_C(1) << 38))
117
+           return LZMA_FORMAT_ERROR;
118
+
119
+       // Calculate the memory usage so that it is ready
120
+       // for SEQ_CODER_INIT.
121
+       coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
122
+               + LZMA_MEMUSAGE_BASE;
123
+
124
+       coder->pos = 0;
125
+       coder->sequence = SEQ_CODER_INIT;
126
+
127
+   // Fall through
128
+
129
+   case SEQ_CODER_INIT: {
130
+       if (coder->memusage > coder->memlimit)
131
+           return LZMA_MEMLIMIT_ERROR;
132
+
133
+       lzma_filter_info filters[2] = {
134
+           {
135
+               .init = &lzma_lzma_decoder_init,
136
+               .options = &coder->options,
137
+           }, {
138
+               .init = NULL,
139
+           }
140
+       };
141
+
142
+       const lzma_ret ret = lzma_next_filter_init(&coder->next,
143
+               allocator, filters);
144
+       if (ret != LZMA_OK)
145
+           return ret;
146
+
147
+       // Use a hack to set the uncompressed size.
148
+       lzma_lz_decoder_uncompressed(coder->next.coder,
149
+               coder->uncompressed_size);
150
+
151
+       coder->sequence = SEQ_CODE;
152
+       break;
153
+   }
154
+
155
+   case SEQ_CODE: {
156
+       return coder->next.code(coder->next.coder,
157
+               allocator, in, in_pos, in_size,
158
+               out, out_pos, out_size, action);
159
+   }
160
+
161
+   default:
162
+       return LZMA_PROG_ERROR;
163
+   }
164
+
165
+   return LZMA_OK;
166
+}
167
+
168
+
169
+static void
170
+alone_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
171
+{
172
+   lzma_next_end(&coder->next, allocator);
173
+   lzma_free(coder, allocator);
174
+   return;
175
+}
176
+
177
+
178
+static lzma_ret
179
+alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
180
+       uint64_t *old_memlimit, uint64_t new_memlimit)
181
+{
182
+   *memusage = coder->memusage;
183
+   *old_memlimit = coder->memlimit;
184
+
185
+   if (new_memlimit != 0) {
186
+       if (new_memlimit < coder->memusage)
187
+           return LZMA_MEMLIMIT_ERROR;
188
+
189
+       coder->memlimit = new_memlimit;
190
+   }
191
+
192
+   return LZMA_OK;
193
+}
194
+
195
+
196
+extern lzma_ret
197
+lzma_alone_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
198
+       uint64_t memlimit, bool picky)
199
+{
200
+   lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator);
201
+
202
+   if (memlimit == 0)
203
+       return LZMA_PROG_ERROR;
204
+
205
+   if (next->coder == NULL) {
206
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
207
+       if (next->coder == NULL)
208
+           return LZMA_MEM_ERROR;
209
+
210
+       next->code = &alone_decode;
211
+       next->end = &alone_decoder_end;
212
+       next->memconfig = &alone_decoder_memconfig;
213
+       next->coder->next = LZMA_NEXT_CODER_INIT;
214
+   }
215
+
216
+   next->coder->sequence = SEQ_PROPERTIES;
217
+   next->coder->picky = picky;
218
+   next->coder->pos = 0;
219
+   next->coder->options.dict_size = 0;
220
+   next->coder->options.preset_dict = NULL;
221
+   next->coder->options.preset_dict_size = 0;
222
+   next->coder->uncompressed_size = 0;
223
+   next->coder->memlimit = memlimit;
224
+   next->coder->memusage = LZMA_MEMUSAGE_BASE;
225
+
226
+   return LZMA_OK;
227
+}
228
+
229
+
230
+extern LZMA_API(lzma_ret)
231
+lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit)
232
+{
233
+   lzma_next_strm_init(lzma_alone_decoder_init, strm, memlimit, false);
234
+
235
+   strm->internal->supported_actions[LZMA_RUN] = true;
236
+   strm->internal->supported_actions[LZMA_FINISH] = true;
237
+
238
+   return LZMA_OK;
239
+}
240
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/alone_decoder.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       alone_decoder.h
5
+/// \brief      Decoder for LZMA_Alone files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_ALONE_DECODER_H
15
+#define LZMA_ALONE_DECODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+extern lzma_ret lzma_alone_decoder_init(
21
+       lzma_next_coder *next, lzma_allocator *allocator,
22
+       uint64_t memlimit, bool picky);
23
+
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/alone_encoder.c Added
159
 
1
@@ -0,0 +1,157 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       alone_decoder.c
5
+/// \brief      Decoder for LZMA_Alone files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+#include "lzma_encoder.h"
16
+
17
+
18
+#define ALONE_HEADER_SIZE (1 + 4 + 8)
19
+
20
+
21
+struct lzma_coder_s {
22
+   lzma_next_coder next;
23
+
24
+   enum {
25
+       SEQ_HEADER,
26
+       SEQ_CODE,
27
+   } sequence;
28
+
29
+   size_t header_pos;
30
+   uint8_t header[ALONE_HEADER_SIZE];
31
+};
32
+
33
+
34
+static lzma_ret
35
+alone_encode(lzma_coder *coder,
36
+       lzma_allocator *allocator lzma_attribute((__unused__)),
37
+       const uint8_t *restrict in, size_t *restrict in_pos,
38
+       size_t in_size, uint8_t *restrict out,
39
+       size_t *restrict out_pos, size_t out_size,
40
+       lzma_action action)
41
+{
42
+   while (*out_pos < out_size)
43
+   switch (coder->sequence) {
44
+   case SEQ_HEADER:
45
+       lzma_bufcpy(coder->header, &coder->header_pos,
46
+               ALONE_HEADER_SIZE,
47
+               out, out_pos, out_size);
48
+       if (coder->header_pos < ALONE_HEADER_SIZE)
49
+           return LZMA_OK;
50
+
51
+       coder->sequence = SEQ_CODE;
52
+       break;
53
+
54
+   case SEQ_CODE:
55
+       return coder->next.code(coder->next.coder,
56
+               allocator, in, in_pos, in_size,
57
+               out, out_pos, out_size, action);
58
+
59
+   default:
60
+       assert(0);
61
+       return LZMA_PROG_ERROR;
62
+   }
63
+
64
+   return LZMA_OK;
65
+}
66
+
67
+
68
+static void
69
+alone_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
70
+{
71
+   lzma_next_end(&coder->next, allocator);
72
+   lzma_free(coder, allocator);
73
+   return;
74
+}
75
+
76
+
77
+// At least for now, this is not used by any internal function.
78
+static lzma_ret
79
+alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
80
+       const lzma_options_lzma *options)
81
+{
82
+   lzma_next_coder_init(&alone_encoder_init, next, allocator);
83
+
84
+   if (next->coder == NULL) {
85
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
86
+       if (next->coder == NULL)
87
+           return LZMA_MEM_ERROR;
88
+
89
+       next->code = &alone_encode;
90
+       next->end = &alone_encoder_end;
91
+       next->coder->next = LZMA_NEXT_CODER_INIT;
92
+   }
93
+
94
+   // Basic initializations
95
+   next->coder->sequence = SEQ_HEADER;
96
+   next->coder->header_pos = 0;
97
+
98
+   // Encode the header:
99
+   // - Properties (1 byte)
100
+   if (lzma_lzma_lclppb_encode(options, next->coder->header))
101
+       return LZMA_OPTIONS_ERROR;
102
+
103
+   // - Dictionary size (4 bytes)
104
+   if (options->dict_size < LZMA_DICT_SIZE_MIN)
105
+       return LZMA_OPTIONS_ERROR;
106
+
107
+   // Round up to the next 2^n or 2^n + 2^(n - 1) depending on which
108
+   // one is the next unless it is UINT32_MAX. While the header would
109
+   // allow any 32-bit integer, we do this to keep the decoder of liblzma
110
+   // accepting the resulting files.
111
+   uint32_t d = options->dict_size - 1;
112
+   d |= d >> 2;
113
+   d |= d >> 3;
114
+   d |= d >> 4;
115
+   d |= d >> 8;
116
+   d |= d >> 16;
117
+   if (d != UINT32_MAX)
118
+       ++d;
119
+
120
+   unaligned_write32le(next->coder->header + 1, d);
121
+
122
+   // - Uncompressed size (always unknown and using EOPM)
123
+   memset(next->coder->header + 1 + 4, 0xFF, 8);
124
+
125
+   // Initialize the LZMA encoder.
126
+   const lzma_filter_info filters[2] = {
127
+       {
128
+           .init = &lzma_lzma_encoder_init,
129
+           .options = (void *)(options),
130
+       }, {
131
+           .init = NULL,
132
+       }
133
+   };
134
+
135
+   return lzma_next_filter_init(&next->coder->next, allocator, filters);
136
+}
137
+
138
+
139
+/*
140
+extern lzma_ret
141
+lzma_alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
142
+       const lzma_options_alone *options)
143
+{
144
+   lzma_next_coder_init(&alone_encoder_init, next, allocator, options);
145
+}
146
+*/
147
+
148
+
149
+extern LZMA_API(lzma_ret)
150
+lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options)
151
+{
152
+   lzma_next_strm_init(alone_encoder_init, strm, options);
153
+
154
+   strm->internal->supported_actions[LZMA_RUN] = true;
155
+   strm->internal->supported_actions[LZMA_FINISH] = true;
156
+
157
+   return LZMA_OK;
158
+}
159
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/auto_decoder.c Added
188
 
1
@@ -0,0 +1,186 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       auto_decoder.c
5
+/// \brief      Autodetect between .xz Stream and .lzma (LZMA_Alone) formats
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_decoder.h"
15
+#include "alone_decoder.h"
16
+
17
+
18
+struct lzma_coder_s {
19
+   /// Stream decoder or LZMA_Alone decoder
20
+   lzma_next_coder next;
21
+
22
+   uint64_t memlimit;
23
+   uint32_t flags;
24
+
25
+   enum {
26
+       SEQ_INIT,
27
+       SEQ_CODE,
28
+       SEQ_FINISH,
29
+   } sequence;
30
+};
31
+
32
+
33
+static lzma_ret
34
+auto_decode(lzma_coder *coder, lzma_allocator *allocator,
35
+       const uint8_t *restrict in, size_t *restrict in_pos,
36
+       size_t in_size, uint8_t *restrict out,
37
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
38
+{
39
+   switch (coder->sequence) {
40
+   case SEQ_INIT:
41
+       if (*in_pos >= in_size)
42
+           return LZMA_OK;
43
+
44
+       // Update the sequence now, because we want to continue from
45
+       // SEQ_CODE even if we return some LZMA_*_CHECK.
46
+       coder->sequence = SEQ_CODE;
47
+
48
+       // Detect the file format. For now this is simple, since if
49
+       // it doesn't start with 0xFD (the first magic byte of the
50
+       // new format), it has to be LZMA_Alone, or something that
51
+       // we don't support at all.
52
+       if (in[*in_pos] == 0xFD) {
53
+           return_if_error(lzma_stream_decoder_init(
54
+                   &coder->next, allocator,
55
+                   coder->memlimit, coder->flags));
56
+       } else {
57
+           return_if_error(lzma_alone_decoder_init(&coder->next,
58
+                   allocator, coder->memlimit, true));
59
+
60
+           // If the application wants to know about missing
61
+           // integrity check or about the check in general, we
62
+           // need to handle it here, because LZMA_Alone decoder
63
+           // doesn't accept any flags.
64
+           if (coder->flags & LZMA_TELL_NO_CHECK)
65
+               return LZMA_NO_CHECK;
66
+
67
+           if (coder->flags & LZMA_TELL_ANY_CHECK)
68
+               return LZMA_GET_CHECK;
69
+       }
70
+
71
+   // Fall through
72
+
73
+   case SEQ_CODE: {
74
+       const lzma_ret ret = coder->next.code(
75
+               coder->next.coder, allocator,
76
+               in, in_pos, in_size,
77
+               out, out_pos, out_size, action);
78
+       if (ret != LZMA_STREAM_END
79
+               || (coder->flags & LZMA_CONCATENATED) == 0)
80
+           return ret;
81
+
82
+       coder->sequence = SEQ_FINISH;
83
+   }
84
+
85
+   // Fall through
86
+
87
+   case SEQ_FINISH:
88
+       // When LZMA_DECODE_CONCATENATED was used and we were decoding
89
+       // LZMA_Alone file, we need to check check that there is no
90
+       // trailing garbage and wait for LZMA_FINISH.
91
+       if (*in_pos < in_size)
92
+           return LZMA_DATA_ERROR;
93
+
94
+       return action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK;
95
+
96
+   default:
97
+       assert(0);
98
+       return LZMA_PROG_ERROR;
99
+   }
100
+}
101
+
102
+
103
+static void
104
+auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
105
+{
106
+   lzma_next_end(&coder->next, allocator);
107
+   lzma_free(coder, allocator);
108
+   return;
109
+}
110
+
111
+
112
+static lzma_check
113
+auto_decoder_get_check(const lzma_coder *coder)
114
+{
115
+   // It is LZMA_Alone if get_check is NULL.
116
+   return coder->next.get_check == NULL ? LZMA_CHECK_NONE
117
+           : coder->next.get_check(coder->next.coder);
118
+}
119
+
120
+
121
+static lzma_ret
122
+auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
123
+       uint64_t *old_memlimit, uint64_t new_memlimit)
124
+{
125
+   lzma_ret ret;
126
+
127
+   if (coder->next.memconfig != NULL) {
128
+       ret = coder->next.memconfig(coder->next.coder,
129
+               memusage, old_memlimit, new_memlimit);
130
+       assert(*old_memlimit == coder->memlimit);
131
+   } else {
132
+       // No coder is configured yet. Use the base value as
133
+       // the current memory usage.
134
+       *memusage = LZMA_MEMUSAGE_BASE;
135
+       *old_memlimit = coder->memlimit;
136
+       ret = LZMA_OK;
137
+   }
138
+
139
+   if (ret == LZMA_OK && new_memlimit != 0)
140
+       coder->memlimit = new_memlimit;
141
+
142
+   return ret;
143
+}
144
+
145
+
146
+static lzma_ret
147
+auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
148
+       uint64_t memlimit, uint32_t flags)
149
+{
150
+   lzma_next_coder_init(&auto_decoder_init, next, allocator);
151
+
152
+   if (memlimit == 0)
153
+       return LZMA_PROG_ERROR;
154
+
155
+   if (flags & ~LZMA_SUPPORTED_FLAGS)
156
+       return LZMA_OPTIONS_ERROR;
157
+
158
+   if (next->coder == NULL) {
159
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
160
+       if (next->coder == NULL)
161
+           return LZMA_MEM_ERROR;
162
+
163
+       next->code = &auto_decode;
164
+       next->end = &auto_decoder_end;
165
+       next->get_check = &auto_decoder_get_check;
166
+       next->memconfig = &auto_decoder_memconfig;
167
+       next->coder->next = LZMA_NEXT_CODER_INIT;
168
+   }
169
+
170
+   next->coder->memlimit = memlimit;
171
+   next->coder->flags = flags;
172
+   next->coder->sequence = SEQ_INIT;
173
+
174
+   return LZMA_OK;
175
+}
176
+
177
+
178
+extern LZMA_API(lzma_ret)
179
+lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
180
+{
181
+   lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags);
182
+
183
+   strm->internal->supported_actions[LZMA_RUN] = true;
184
+   strm->internal->supported_actions[LZMA_FINISH] = true;
185
+
186
+   return LZMA_OK;
187
+}
188
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_buffer_decoder.c Added
82
 
1
@@ -0,0 +1,80 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_buffer_decoder.c
5
+/// \brief      Single-call .xz Block decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "block_decoder.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator,
19
+       const uint8_t *in, size_t *in_pos, size_t in_size,
20
+       uint8_t *out, size_t *out_pos, size_t out_size)
21
+{
22
+   if (in_pos == NULL || (in == NULL && *in_pos != in_size)
23
+           || *in_pos > in_size || out_pos == NULL
24
+           || (out == NULL && *out_pos != out_size)
25
+           || *out_pos > out_size)
26
+       return LZMA_PROG_ERROR;
27
+
28
+   // Initialize the Block decoder.
29
+   lzma_next_coder block_decoder = LZMA_NEXT_CODER_INIT;
30
+   lzma_ret ret = lzma_block_decoder_init(
31
+           &block_decoder, allocator, block);
32
+
33
+   if (ret == LZMA_OK) {
34
+       // Save the positions so that we can restore them in case
35
+       // an error occurs.
36
+       const size_t in_start = *in_pos;
37
+       const size_t out_start = *out_pos;
38
+
39
+       // Do the actual decoding.
40
+       ret = block_decoder.code(block_decoder.coder, allocator,
41
+               in, in_pos, in_size, out, out_pos, out_size,
42
+               LZMA_FINISH);
43
+
44
+       if (ret == LZMA_STREAM_END) {
45
+           ret = LZMA_OK;
46
+       } else {
47
+           if (ret == LZMA_OK) {
48
+               // Either the input was truncated or the
49
+               // output buffer was too small.
50
+               assert(*in_pos == in_size
51
+                       || *out_pos == out_size);
52
+
53
+               // If all the input was consumed, then the
54
+               // input is truncated, even if the output
55
+               // buffer is also full. This is because
56
+               // processing the last byte of the Block
57
+               // never produces output.
58
+               //
59
+               // NOTE: This assumption may break when new
60
+               // filters are added, if the end marker of
61
+               // the filter doesn't consume at least one
62
+               // complete byte.
63
+               if (*in_pos == in_size)
64
+                   ret = LZMA_DATA_ERROR;
65
+               else
66
+                   ret = LZMA_BUF_ERROR;
67
+           }
68
+
69
+           // Restore the positions.
70
+           *in_pos = in_start;
71
+           *out_pos = out_start;
72
+       }
73
+   }
74
+
75
+   // Free the decoder memory. This needs to be done even if
76
+   // initialization fails, because the internal API doesn't
77
+   // require the initialization function to free its memory on error.
78
+   lzma_next_end(&block_decoder, allocator);
79
+
80
+   return ret;
81
+}
82
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_buffer_encoder.c Added
307
 
1
@@ -0,0 +1,305 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_buffer_encoder.c
5
+/// \brief      Single-call .xz Block encoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "block_encoder.h"
15
+#include "filter_encoder.h"
16
+#include "lzma2_encoder.h"
17
+#include "check.h"
18
+
19
+
20
+/// Estimate the maximum size of the Block Header and Check fields for
21
+/// a Block that uses LZMA2 uncompressed chunks. We could use
22
+/// lzma_block_header_size() but this is simpler.
23
+///
24
+/// Block Header Size + Block Flags + Compressed Size
25
+/// + Uncompressed Size + Filter Flags for LZMA2 + CRC32 + Check
26
+/// and round up to the next multiple of four to take Header Padding
27
+/// into account.
28
+#define HEADERS_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 \
29
+       + LZMA_CHECK_SIZE_MAX + 3) & ~3)
30
+
31
+
32
+static lzma_vli
33
+lzma2_bound(lzma_vli uncompressed_size)
34
+{
35
+   // Prevent integer overflow in overhead calculation.
36
+   if (uncompressed_size > COMPRESSED_SIZE_MAX)
37
+       return 0;
38
+
39
+   // Calculate the exact overhead of the LZMA2 headers: Round
40
+   // uncompressed_size up to the next multiple of LZMA2_CHUNK_MAX,
41
+   // multiply by the size of per-chunk header, and add one byte for
42
+   // the end marker.
43
+   const lzma_vli overhead = ((uncompressed_size + LZMA2_CHUNK_MAX - 1)
44
+               / LZMA2_CHUNK_MAX)
45
+           * LZMA2_HEADER_UNCOMPRESSED + 1;
46
+
47
+   // Catch the possible integer overflow.
48
+   if (COMPRESSED_SIZE_MAX - overhead < uncompressed_size)
49
+       return 0;
50
+
51
+   return uncompressed_size + overhead;
52
+}
53
+
54
+
55
+extern LZMA_API(size_t)
56
+lzma_block_buffer_bound(size_t uncompressed_size)
57
+{
58
+   // For now, if the data doesn't compress, we always use uncompressed
59
+   // chunks of LZMA2. In future we may use Subblock filter too, but
60
+   // but for simplicity we probably will still use the same bound
61
+   // calculation even though Subblock filter would have slightly less
62
+   // overhead.
63
+   lzma_vli lzma2_size = lzma2_bound(uncompressed_size);
64
+   if (lzma2_size == 0)
65
+       return 0;
66
+
67
+   // Take Block Padding into account.
68
+   lzma2_size = (lzma2_size + 3) & ~LZMA_VLI_C(3);
69
+
70
+#if SIZE_MAX < LZMA_VLI_MAX
71
+   // Catch the possible integer overflow on 32-bit systems. There's no
72
+   // overflow on 64-bit systems, because lzma2_bound() already takes
73
+   // into account the size of the headers in the Block.
74
+   if (SIZE_MAX - HEADERS_BOUND < lzma2_size)
75
+       return 0;
76
+#endif
77
+
78
+   return HEADERS_BOUND + lzma2_size;
79
+}
80
+
81
+
82
+static lzma_ret
83
+block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,
84
+       uint8_t *out, size_t *out_pos, size_t out_size)
85
+{
86
+   // TODO: Figure out if the last filter is LZMA2 or Subblock and use
87
+   // that filter to encode the uncompressed chunks.
88
+
89
+   // Use LZMA2 uncompressed chunks. We wouldn't need a dictionary at
90
+   // all, but LZMA2 always requires a dictionary, so use the minimum
91
+   // value to minimize memory usage of the decoder.
92
+   lzma_options_lzma lzma2 = {
93
+       .dict_size = LZMA_DICT_SIZE_MIN,
94
+   };
95
+
96
+   lzma_filter filters[2];
97
+   filters[0].id = LZMA_FILTER_LZMA2;
98
+   filters[0].options = &lzma2;
99
+   filters[1].id = LZMA_VLI_UNKNOWN;
100
+
101
+   // Set the above filter options to *block temporarily so that we can
102
+   // encode the Block Header.
103
+   lzma_filter *filters_orig = block->filters;
104
+   block->filters = filters;
105
+
106
+   if (lzma_block_header_size(block) != LZMA_OK) {
107
+       block->filters = filters_orig;
108
+       return LZMA_PROG_ERROR;
109
+   }
110
+
111
+   // Check that there's enough output space. The caller has already
112
+   // set block->compressed_size to what lzma2_bound() has returned,
113
+   // so we can reuse that value. We know that compressed_size is a
114
+   // known valid VLI and header_size is a small value so their sum
115
+   // will never overflow.
116
+   assert(block->compressed_size == lzma2_bound(in_size));
117
+   if (out_size - *out_pos
118
+           < block->header_size + block->compressed_size) {
119
+       block->filters = filters_orig;
120
+       return LZMA_BUF_ERROR;
121
+   }
122
+
123
+   if (lzma_block_header_encode(block, out + *out_pos) != LZMA_OK) {
124
+       block->filters = filters_orig;
125
+       return LZMA_PROG_ERROR;
126
+   }
127
+
128
+   block->filters = filters_orig;
129
+   *out_pos += block->header_size;
130
+
131
+   // Encode the data using LZMA2 uncompressed chunks.
132
+   size_t in_pos = 0;
133
+   uint8_t control = 0x01; // Dictionary reset
134
+
135
+   while (in_pos < in_size) {
136
+       // Control byte: Indicate uncompressed chunk, of which
137
+       // the first resets the dictionary.
138
+       out[(*out_pos)++] = control;
139
+       control = 0x02; // No dictionary reset
140
+
141
+       // Size of the uncompressed chunk
142
+       const size_t copy_size
143
+               = my_min(in_size - in_pos, LZMA2_CHUNK_MAX);
144
+       out[(*out_pos)++] = (copy_size - 1) >> 8;
145
+       out[(*out_pos)++] = (copy_size - 1) & 0xFF;
146
+
147
+       // The actual data
148
+       assert(*out_pos + copy_size <= out_size);
149
+       memcpy(out + *out_pos, in + in_pos, copy_size);
150
+
151
+       in_pos += copy_size;
152
+       *out_pos += copy_size;
153
+   }
154
+
155
+   // End marker
156
+   out[(*out_pos)++] = 0x00;
157
+   assert(*out_pos <= out_size);
158
+
159
+   return LZMA_OK;
160
+}
161
+
162
+
163
+static lzma_ret
164
+block_encode_normal(lzma_block *block, lzma_allocator *allocator,
165
+       const uint8_t *in, size_t in_size,
166
+       uint8_t *out, size_t *out_pos, size_t out_size)
167
+{
168
+   // Find out the size of the Block Header.
169
+   block->compressed_size = lzma2_bound(in_size);
170
+   if (block->compressed_size == 0)
171
+       return LZMA_DATA_ERROR;
172
+
173
+   block->uncompressed_size = in_size;
174
+   return_if_error(lzma_block_header_size(block));
175
+
176
+   // Reserve space for the Block Header and skip it for now.
177
+   if (out_size - *out_pos <= block->header_size)
178
+       return LZMA_BUF_ERROR;
179
+
180
+   const size_t out_start = *out_pos;
181
+   *out_pos += block->header_size;
182
+
183
+   // Limit out_size so that we stop encoding if the output would grow
184
+   // bigger than what uncompressed Block would be.
185
+   if (out_size - *out_pos > block->compressed_size)
186
+       out_size = *out_pos + block->compressed_size;
187
+
188
+   // TODO: In many common cases this could be optimized to use
189
+   // significantly less memory.
190
+   lzma_next_coder raw_encoder = LZMA_NEXT_CODER_INIT;
191
+   lzma_ret ret = lzma_raw_encoder_init(
192
+           &raw_encoder, allocator, block->filters);
193
+
194
+   if (ret == LZMA_OK) {
195
+       size_t in_pos = 0;
196
+       ret = raw_encoder.code(raw_encoder.coder, allocator,
197
+               in, &in_pos, in_size, out, out_pos, out_size,
198
+               LZMA_FINISH);
199
+   }
200
+
201
+   // NOTE: This needs to be run even if lzma_raw_encoder_init() failed.
202
+   lzma_next_end(&raw_encoder, allocator);
203
+
204
+   if (ret == LZMA_STREAM_END) {
205
+       // Compression was successful. Write the Block Header.
206
+       block->compressed_size
207
+               = *out_pos - (out_start + block->header_size);
208
+       ret = lzma_block_header_encode(block, out + out_start);
209
+       if (ret != LZMA_OK)
210
+           ret = LZMA_PROG_ERROR;
211
+
212
+   } else if (ret == LZMA_OK) {
213
+       // Output buffer became full.
214
+       ret = LZMA_BUF_ERROR;
215
+   }
216
+
217
+   // Reset *out_pos if something went wrong.
218
+   if (ret != LZMA_OK)
219
+       *out_pos = out_start;
220
+
221
+   return ret;
222
+}
223
+
224
+
225
+extern LZMA_API(lzma_ret)
226
+lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
227
+       const uint8_t *in, size_t in_size,
228
+       uint8_t *out, size_t *out_pos, size_t out_size)
229
+{
230
+   // Validate the arguments.
231
+   if (block == NULL || (in == NULL && in_size != 0) || out == NULL
232
+           || out_pos == NULL || *out_pos > out_size)
233
+       return LZMA_PROG_ERROR;
234
+
235
+   // The contents of the structure may depend on the version so
236
+   // check the version before validating the contents of *block.
237
+   if (block->version != 0)
238
+       return LZMA_OPTIONS_ERROR;
239
+
240
+   if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX
241
+           || block->filters == NULL)
242
+       return LZMA_PROG_ERROR;
243
+
244
+   if (!lzma_check_is_supported(block->check))
245
+       return LZMA_UNSUPPORTED_CHECK;
246
+
247
+   // Size of a Block has to be a multiple of four, so limit the size
248
+   // here already. This way we don't need to check it again when adding
249
+   // Block Padding.
250
+   out_size -= (out_size - *out_pos) & 3;
251
+
252
+   // Get the size of the Check field.
253
+   const size_t check_size = lzma_check_size(block->check);
254
+   assert(check_size != UINT32_MAX);
255
+
256
+   // Reserve space for the Check field.
257
+   if (out_size - *out_pos <= check_size)
258
+       return LZMA_BUF_ERROR;
259
+
260
+   out_size -= check_size;
261
+
262
+   // Do the actual compression.
263
+   const lzma_ret ret = block_encode_normal(block, allocator,
264
+           in, in_size, out, out_pos, out_size);
265
+   if (ret != LZMA_OK) {
266
+       // If the error was something else than output buffer
267
+       // becoming full, return the error now.
268
+       if (ret != LZMA_BUF_ERROR)
269
+           return ret;
270
+
271
+       // The data was uncompressible (at least with the options
272
+       // given to us) or the output buffer was too small. Use the
273
+       // uncompressed chunks of LZMA2 to wrap the data into a valid
274
+       // Block. If we haven't been given enough output space, even
275
+       // this may fail.
276
+       return_if_error(block_encode_uncompressed(block, in, in_size,
277
+               out, out_pos, out_size));
278
+   }
279
+
280
+   assert(*out_pos <= out_size);
281
+
282
+   // Block Padding. No buffer overflow here, because we already adjusted
283
+   // out_size so that (out_size - out_start) is a multiple of four.
284
+   // Thus, if the buffer is full, the loop body can never run.
285
+   for (size_t i = (size_t)(block->compressed_size); i & 3; ++i) {
286
+       assert(*out_pos < out_size);
287
+       out[(*out_pos)++] = 0x00;
288
+   }
289
+
290
+   // If there's no Check field, we are done now.
291
+   if (check_size > 0) {
292
+       // Calculate the integrity check. We reserved space for
293
+       // the Check field earlier so we don't need to check for
294
+       // available output space here.
295
+       lzma_check_state check;
296
+       lzma_check_init(&check, block->check);
297
+       lzma_check_update(&check, block->check, in, in_size);
298
+       lzma_check_finish(&check, block->check);
299
+
300
+       memcpy(block->raw_check, check.buffer.u8, check_size);
301
+       memcpy(out + *out_pos, check.buffer.u8, check_size);
302
+       *out_pos += check_size;
303
+   }
304
+
305
+   return LZMA_OK;
306
+}
307
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_decoder.c Added
244
 
1
@@ -0,0 +1,242 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_decoder.c
5
+/// \brief      Decodes .xz Blocks
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "block_decoder.h"
15
+#include "filter_decoder.h"
16
+#include "check.h"
17
+
18
+
19
+struct lzma_coder_s {
20
+   enum {
21
+       SEQ_CODE,
22
+       SEQ_PADDING,
23
+       SEQ_CHECK,
24
+   } sequence;
25
+
26
+   /// The filters in the chain; initialized with lzma_raw_decoder_init().
27
+   lzma_next_coder next;
28
+
29
+   /// Decoding options; we also write Compressed Size and Uncompressed
30
+   /// Size back to this structure when the decoding has been finished.
31
+   lzma_block *block;
32
+
33
+   /// Compressed Size calculated while decoding
34
+   lzma_vli compressed_size;
35
+
36
+   /// Uncompressed Size calculated while decoding
37
+   lzma_vli uncompressed_size;
38
+
39
+   /// Maximum allowed Compressed Size; this takes into account the
40
+   /// size of the Block Header and Check fields when Compressed Size
41
+   /// is unknown.
42
+   lzma_vli compressed_limit;
43
+
44
+   /// Position when reading the Check field
45
+   size_t check_pos;
46
+
47
+   /// Check of the uncompressed data
48
+   lzma_check_state check;
49
+};
50
+
51
+
52
+static inline bool
53
+update_size(lzma_vli *size, lzma_vli add, lzma_vli limit)
54
+{
55
+   if (limit > LZMA_VLI_MAX)
56
+       limit = LZMA_VLI_MAX;
57
+
58
+   if (limit < *size || limit - *size < add)
59
+       return true;
60
+
61
+   *size += add;
62
+
63
+   return false;
64
+}
65
+
66
+
67
+static inline bool
68
+is_size_valid(lzma_vli size, lzma_vli reference)
69
+{
70
+   return reference == LZMA_VLI_UNKNOWN || reference == size;
71
+}
72
+
73
+
74
+static lzma_ret
75
+block_decode(lzma_coder *coder, lzma_allocator *allocator,
76
+       const uint8_t *restrict in, size_t *restrict in_pos,
77
+       size_t in_size, uint8_t *restrict out,
78
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
79
+{
80
+   switch (coder->sequence) {
81
+   case SEQ_CODE: {
82
+       const size_t in_start = *in_pos;
83
+       const size_t out_start = *out_pos;
84
+
85
+       const lzma_ret ret = coder->next.code(coder->next.coder,
86
+               allocator, in, in_pos, in_size,
87
+               out, out_pos, out_size, action);
88
+
89
+       const size_t in_used = *in_pos - in_start;
90
+       const size_t out_used = *out_pos - out_start;
91
+
92
+       // NOTE: We compare to compressed_limit here, which prevents
93
+       // the total size of the Block growing past LZMA_VLI_MAX.
94
+       if (update_size(&coder->compressed_size, in_used,
95
+                   coder->compressed_limit)
96
+               || update_size(&coder->uncompressed_size,
97
+                   out_used,
98
+                   coder->block->uncompressed_size))
99
+           return LZMA_DATA_ERROR;
100
+
101
+       lzma_check_update(&coder->check, coder->block->check,
102
+               out + out_start, out_used);
103
+
104
+       if (ret != LZMA_STREAM_END)
105
+           return ret;
106
+
107
+       // Compressed and Uncompressed Sizes are now at their final
108
+       // values. Verify that they match the values given to us.
109
+       if (!is_size_valid(coder->compressed_size,
110
+                   coder->block->compressed_size)
111
+               || !is_size_valid(coder->uncompressed_size,
112
+                   coder->block->uncompressed_size))
113
+           return LZMA_DATA_ERROR;
114
+
115
+       // Copy the values into coder->block. The caller
116
+       // may use this information to construct Index.
117
+       coder->block->compressed_size = coder->compressed_size;
118
+       coder->block->uncompressed_size = coder->uncompressed_size;
119
+
120
+       coder->sequence = SEQ_PADDING;
121
+   }
122
+
123
+   // Fall through
124
+
125
+   case SEQ_PADDING:
126
+       // Compressed Data is padded to a multiple of four bytes.
127
+       while (coder->compressed_size & 3) {
128
+           if (*in_pos >= in_size)
129
+               return LZMA_OK;
130
+
131
+           // We use compressed_size here just get the Padding
132
+           // right. The actual Compressed Size was stored to
133
+           // coder->block already, and won't be modified by
134
+           // us anymore.
135
+           ++coder->compressed_size;
136
+
137
+           if (in[(*in_pos)++] != 0x00)
138
+               return LZMA_DATA_ERROR;
139
+       }
140
+
141
+       if (coder->block->check == LZMA_CHECK_NONE)
142
+           return LZMA_STREAM_END;
143
+
144
+       lzma_check_finish(&coder->check, coder->block->check);
145
+       coder->sequence = SEQ_CHECK;
146
+
147
+   // Fall through
148
+
149
+   case SEQ_CHECK: {
150
+       const size_t check_size = lzma_check_size(coder->block->check);
151
+       lzma_bufcpy(in, in_pos, in_size, coder->block->raw_check,
152
+               &coder->check_pos, check_size);
153
+       if (coder->check_pos < check_size)
154
+           return LZMA_OK;
155
+
156
+       // Validate the Check only if we support it.
157
+       // coder->check.buffer may be uninitialized
158
+       // when the Check ID is not supported.
159
+       if (lzma_check_is_supported(coder->block->check)
160
+               && memcmp(coder->block->raw_check,
161
+                   coder->check.buffer.u8,
162
+                   check_size) != 0)
163
+           return LZMA_DATA_ERROR;
164
+
165
+       return LZMA_STREAM_END;
166
+   }
167
+   }
168
+
169
+   return LZMA_PROG_ERROR;
170
+}
171
+
172
+
173
+static void
174
+block_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
175
+{
176
+   lzma_next_end(&coder->next, allocator);
177
+   lzma_free(coder, allocator);
178
+   return;
179
+}
180
+
181
+
182
+extern lzma_ret
183
+lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
184
+       lzma_block *block)
185
+{
186
+   lzma_next_coder_init(&lzma_block_decoder_init, next, allocator);
187
+
188
+   // Validate the options. lzma_block_unpadded_size() does that for us
189
+   // except for Uncompressed Size and filters. Filters are validated
190
+   // by the raw decoder.
191
+   if (lzma_block_unpadded_size(block) == 0
192
+           || !lzma_vli_is_valid(block->uncompressed_size))
193
+       return LZMA_PROG_ERROR;
194
+
195
+   // Allocate and initialize *next->coder if needed.
196
+   if (next->coder == NULL) {
197
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
198
+       if (next->coder == NULL)
199
+           return LZMA_MEM_ERROR;
200
+
201
+       next->code = &block_decode;
202
+       next->end = &block_decoder_end;
203
+       next->coder->next = LZMA_NEXT_CODER_INIT;
204
+   }
205
+
206
+   // Basic initializations
207
+   next->coder->sequence = SEQ_CODE;
208
+   next->coder->block = block;
209
+   next->coder->compressed_size = 0;
210
+   next->coder->uncompressed_size = 0;
211
+
212
+   // If Compressed Size is not known, we calculate the maximum allowed
213
+   // value so that encoded size of the Block (including Block Padding)
214
+   // is still a valid VLI and a multiple of four.
215
+   next->coder->compressed_limit
216
+           = block->compressed_size == LZMA_VLI_UNKNOWN
217
+               ? (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
218
+                   - block->header_size
219
+                   - lzma_check_size(block->check)
220
+               : block->compressed_size;
221
+
222
+   // Initialize the check. It's caller's problem if the Check ID is not
223
+   // supported, and the Block decoder cannot verify the Check field.
224
+   // Caller can test lzma_check_is_supported(block->check).
225
+   next->coder->check_pos = 0;
226
+   lzma_check_init(&next->coder->check, block->check);
227
+
228
+   // Initialize the filter chain.
229
+   return lzma_raw_decoder_init(&next->coder->next, allocator,
230
+           block->filters);
231
+}
232
+
233
+
234
+extern LZMA_API(lzma_ret)
235
+lzma_block_decoder(lzma_stream *strm, lzma_block *block)
236
+{
237
+   lzma_next_strm_init(lzma_block_decoder_init, strm, block);
238
+
239
+   strm->internal->supported_actions[LZMA_RUN] = true;
240
+   strm->internal->supported_actions[LZMA_FINISH] = true;
241
+
242
+   return LZMA_OK;
243
+}
244
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_decoder.h Added
24
 
1
@@ -0,0 +1,22 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_decoder.h
5
+/// \brief      Decodes .xz Blocks
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_BLOCK_DECODER_H
15
+#define LZMA_BLOCK_DECODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+extern lzma_ret lzma_block_decoder_init(lzma_next_coder *next,
21
+       lzma_allocator *allocator, lzma_block *block);
22
+
23
+#endif
24
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_encoder.c Added
219
 
1
@@ -0,0 +1,217 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_encoder.c
5
+/// \brief      Encodes .xz Blocks
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "block_encoder.h"
15
+#include "filter_encoder.h"
16
+#include "check.h"
17
+
18
+
19
+struct lzma_coder_s {
20
+   /// The filters in the chain; initialized with lzma_raw_decoder_init().
21
+   lzma_next_coder next;
22
+
23
+   /// Encoding options; we also write Unpadded Size, Compressed Size,
24
+   /// and Uncompressed Size back to this structure when the encoding
25
+   /// has been finished.
26
+   lzma_block *block;
27
+
28
+   enum {
29
+       SEQ_CODE,
30
+       SEQ_PADDING,
31
+       SEQ_CHECK,
32
+   } sequence;
33
+
34
+   /// Compressed Size calculated while encoding
35
+   lzma_vli compressed_size;
36
+
37
+   /// Uncompressed Size calculated while encoding
38
+   lzma_vli uncompressed_size;
39
+
40
+   /// Position in the Check field
41
+   size_t pos;
42
+
43
+   /// Check of the uncompressed data
44
+   lzma_check_state check;
45
+};
46
+
47
+
48
+static lzma_ret
49
+block_encode(lzma_coder *coder, lzma_allocator *allocator,
50
+       const uint8_t *restrict in, size_t *restrict in_pos,
51
+       size_t in_size, uint8_t *restrict out,
52
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
53
+{
54
+   // Check that our amount of input stays in proper limits.
55
+   if (LZMA_VLI_MAX - coder->uncompressed_size < in_size - *in_pos)
56
+       return LZMA_DATA_ERROR;
57
+
58
+   switch (coder->sequence) {
59
+   case SEQ_CODE: {
60
+       const size_t in_start = *in_pos;
61
+       const size_t out_start = *out_pos;
62
+
63
+       const lzma_ret ret = coder->next.code(coder->next.coder,
64
+               allocator, in, in_pos, in_size,
65
+               out, out_pos, out_size, action);
66
+
67
+       const size_t in_used = *in_pos - in_start;
68
+       const size_t out_used = *out_pos - out_start;
69
+
70
+       if (COMPRESSED_SIZE_MAX - coder->compressed_size < out_used)
71
+           return LZMA_DATA_ERROR;
72
+
73
+       coder->compressed_size += out_used;
74
+
75
+       // No need to check for overflow because we have already
76
+       // checked it at the beginning of this function.
77
+       coder->uncompressed_size += in_used;
78
+
79
+       lzma_check_update(&coder->check, coder->block->check,
80
+               in + in_start, in_used);
81
+
82
+       if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH)
83
+           return ret;
84
+
85
+       assert(*in_pos == in_size);
86
+       assert(action == LZMA_FINISH);
87
+
88
+       // Copy the values into coder->block. The caller
89
+       // may use this information to construct Index.
90
+       coder->block->compressed_size = coder->compressed_size;
91
+       coder->block->uncompressed_size = coder->uncompressed_size;
92
+
93
+       coder->sequence = SEQ_PADDING;
94
+   }
95
+
96
+   // Fall through
97
+
98
+   case SEQ_PADDING:
99
+       // Pad Compressed Data to a multiple of four bytes. We can
100
+       // use coder->compressed_size for this since we don't need
101
+       // it for anything else anymore.
102
+       while (coder->compressed_size & 3) {
103
+           if (*out_pos >= out_size)
104
+               return LZMA_OK;
105
+
106
+           out[*out_pos] = 0x00;
107
+           ++*out_pos;
108
+           ++coder->compressed_size;
109
+       }
110
+
111
+       if (coder->block->check == LZMA_CHECK_NONE)
112
+           return LZMA_STREAM_END;
113
+
114
+       lzma_check_finish(&coder->check, coder->block->check);
115
+
116
+       coder->sequence = SEQ_CHECK;
117
+
118
+   // Fall through
119
+
120
+   case SEQ_CHECK: {
121
+       const size_t check_size = lzma_check_size(coder->block->check);
122
+       lzma_bufcpy(coder->check.buffer.u8, &coder->pos, check_size,
123
+               out, out_pos, out_size);
124
+       if (coder->pos < check_size)
125
+           return LZMA_OK;
126
+
127
+       memcpy(coder->block->raw_check, coder->check.buffer.u8,
128
+               check_size);
129
+       return LZMA_STREAM_END;
130
+   }
131
+   }
132
+
133
+   return LZMA_PROG_ERROR;
134
+}
135
+
136
+
137
+static void
138
+block_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
139
+{
140
+   lzma_next_end(&coder->next, allocator);
141
+   lzma_free(coder, allocator);
142
+   return;
143
+}
144
+
145
+
146
+static lzma_ret
147
+block_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
148
+       const lzma_filter *filters lzma_attribute((__unused__)),
149
+       const lzma_filter *reversed_filters)
150
+{
151
+   if (coder->sequence != SEQ_CODE)
152
+       return LZMA_PROG_ERROR;
153
+
154
+   return lzma_next_filter_update(
155
+           &coder->next, allocator, reversed_filters);
156
+}
157
+
158
+
159
+extern lzma_ret
160
+lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
161
+       lzma_block *block)
162
+{
163
+   lzma_next_coder_init(&lzma_block_encoder_init, next, allocator);
164
+
165
+   if (block == NULL)
166
+       return LZMA_PROG_ERROR;
167
+
168
+   // The contents of the structure may depend on the version so
169
+   // check the version first.
170
+   if (block->version != 0)
171
+       return LZMA_OPTIONS_ERROR;
172
+
173
+   // If the Check ID is not supported, we cannot calculate the check and
174
+   // thus not create a proper Block.
175
+   if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX)
176
+       return LZMA_PROG_ERROR;
177
+
178
+   if (!lzma_check_is_supported(block->check))
179
+       return LZMA_UNSUPPORTED_CHECK;
180
+
181
+   // Allocate and initialize *next->coder if needed.
182
+   if (next->coder == NULL) {
183
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
184
+       if (next->coder == NULL)
185
+           return LZMA_MEM_ERROR;
186
+
187
+       next->code = &block_encode;
188
+       next->end = &block_encoder_end;
189
+       next->update = &block_encoder_update;
190
+       next->coder->next = LZMA_NEXT_CODER_INIT;
191
+   }
192
+
193
+   // Basic initializations
194
+   next->coder->sequence = SEQ_CODE;
195
+   next->coder->block = block;
196
+   next->coder->compressed_size = 0;
197
+   next->coder->uncompressed_size = 0;
198
+   next->coder->pos = 0;
199
+
200
+   // Initialize the check
201
+   lzma_check_init(&next->coder->check, block->check);
202
+
203
+   // Initialize the requested filters.
204
+   return lzma_raw_encoder_init(&next->coder->next, allocator,
205
+           block->filters);
206
+}
207
+
208
+
209
+extern LZMA_API(lzma_ret)
210
+lzma_block_encoder(lzma_stream *strm, lzma_block *block)
211
+{
212
+   lzma_next_strm_init(lzma_block_encoder_init, strm, block);
213
+
214
+   strm->internal->supported_actions[LZMA_RUN] = true;
215
+   strm->internal->supported_actions[LZMA_FINISH] = true;
216
+
217
+   return LZMA_OK;
218
+}
219
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_encoder.h Added
49
 
1
@@ -0,0 +1,47 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_encoder.h
5
+/// \brief      Encodes .xz Blocks
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_BLOCK_ENCODER_H
15
+#define LZMA_BLOCK_ENCODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+/// \brief      Biggest Compressed Size value that the Block encoder supports
21
+///
22
+/// The maximum size of a single Block is limited by the maximum size of
23
+/// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3).
24
+/// While the size is really big and no one should hit it in practice, we
25
+/// take it into account in some places anyway to catch some errors e.g. if
26
+/// application passes insanely big value to some function.
27
+///
28
+/// We could take into account the headers etc. to determine the exact
29
+/// maximum size of the Compressed Data field, but the complexity would give
30
+/// us nothing useful. Instead, limit the size of Compressed Data so that
31
+/// even with biggest possible Block Header and Check fields the total
32
+/// encoded size of the Block stays as a valid VLI. This doesn't guarantee
33
+/// that the size of the Stream doesn't grow too big, but that problem is
34
+/// taken care outside the Block handling code.
35
+///
36
+/// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of
37
+/// the Compressed Data field, it will still stay in the proper limit.
38
+///
39
+/// This constant is in this file because it is needed in both
40
+/// block_encoder.c and block_buffer_encoder.c.
41
+#define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \
42
+       - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3))
43
+
44
+
45
+extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,
46
+       lzma_allocator *allocator, lzma_block *block);
47
+
48
+#endif
49
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_header_decoder.c Added
118
 
1
@@ -0,0 +1,116 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_header_decoder.c
5
+/// \brief      Decodes Block Header from .xz files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+#include "check.h"
16
+
17
+
18
+static void
19
+free_properties(lzma_block *block, lzma_allocator *allocator)
20
+{
21
+   // Free allocated filter options. The last array member is not
22
+   // touched after the initialization in the beginning of
23
+   // lzma_block_header_decode(), so we don't need to touch that here.
24
+   for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) {
25
+       lzma_free(block->filters[i].options, allocator);
26
+       block->filters[i].id = LZMA_VLI_UNKNOWN;
27
+       block->filters[i].options = NULL;
28
+   }
29
+
30
+   return;
31
+}
32
+
33
+
34
+extern LZMA_API(lzma_ret)
35
+lzma_block_header_decode(lzma_block *block,
36
+       lzma_allocator *allocator, const uint8_t *in)
37
+{
38
+   // NOTE: We consider the header to be corrupt not only when the
39
+   // CRC32 doesn't match, but also when variable-length integers
40
+   // are invalid or over 63 bits, or if the header is too small
41
+   // to contain the claimed information.
42
+
43
+   // Initialize the filter options array. This way the caller can
44
+   // safely free() the options even if an error occurs in this function.
45
+   for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) {
46
+       block->filters[i].id = LZMA_VLI_UNKNOWN;
47
+       block->filters[i].options = NULL;
48
+   }
49
+
50
+   // Always zero for now.
51
+   block->version = 0;
52
+
53
+   // Validate Block Header Size and Check type. The caller must have
54
+   // already set these, so it is a programming error if this test fails.
55
+   if (lzma_block_header_size_decode(in[0]) != block->header_size
56
+           || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX)
57
+       return LZMA_PROG_ERROR;
58
+
59
+   // Exclude the CRC32 field.
60
+   const size_t in_size = block->header_size - 4;
61
+
62
+   // Verify CRC32
63
+   if (lzma_crc32(in, in_size, 0) != unaligned_read32le(in + in_size))
64
+       return LZMA_DATA_ERROR;
65
+
66
+   // Check for unsupported flags.
67
+   if (in[1] & 0x3C)
68
+       return LZMA_OPTIONS_ERROR;
69
+
70
+   // Start after the Block Header Size and Block Flags fields.
71
+   size_t in_pos = 2;
72
+
73
+   // Compressed Size
74
+   if (in[1] & 0x40) {
75
+       return_if_error(lzma_vli_decode(&block->compressed_size,
76
+               NULL, in, &in_pos, in_size));
77
+
78
+       // Validate Compressed Size. This checks that it isn't zero
79
+       // and that the total size of the Block is a valid VLI.
80
+       if (lzma_block_unpadded_size(block) == 0)
81
+           return LZMA_DATA_ERROR;
82
+   } else {
83
+       block->compressed_size = LZMA_VLI_UNKNOWN;
84
+   }
85
+
86
+   // Uncompressed Size
87
+   if (in[1] & 0x80)
88
+       return_if_error(lzma_vli_decode(&block->uncompressed_size,
89
+               NULL, in, &in_pos, in_size));
90
+   else
91
+       block->uncompressed_size = LZMA_VLI_UNKNOWN;
92
+
93
+   // Filter Flags
94
+   const size_t filter_count = (in[1] & 3) + 1;
95
+   for (size_t i = 0; i < filter_count; ++i) {
96
+       const lzma_ret ret = lzma_filter_flags_decode(
97
+               &block->filters[i], allocator,
98
+               in, &in_pos, in_size);
99
+       if (ret != LZMA_OK) {
100
+           free_properties(block, allocator);
101
+           return ret;
102
+       }
103
+   }
104
+
105
+   // Padding
106
+   while (in_pos < in_size) {
107
+       if (in[in_pos++] != 0x00) {
108
+           free_properties(block, allocator);
109
+
110
+           // Possibly some new field present so use
111
+           // LZMA_OPTIONS_ERROR instead of LZMA_DATA_ERROR.
112
+           return LZMA_OPTIONS_ERROR;
113
+       }
114
+   }
115
+
116
+   return LZMA_OK;
117
+}
118
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_header_encoder.c Added
134
 
1
@@ -0,0 +1,132 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_header_encoder.c
5
+/// \brief      Encodes Block Header for .xz files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+#include "check.h"
16
+
17
+
18
+extern LZMA_API(lzma_ret)
19
+lzma_block_header_size(lzma_block *block)
20
+{
21
+   if (block->version != 0)
22
+       return LZMA_OPTIONS_ERROR;
23
+
24
+   // Block Header Size + Block Flags + CRC32.
25
+   uint32_t size = 1 + 1 + 4;
26
+
27
+   // Compressed Size
28
+   if (block->compressed_size != LZMA_VLI_UNKNOWN) {
29
+       const uint32_t add = lzma_vli_size(block->compressed_size);
30
+       if (add == 0 || block->compressed_size == 0)
31
+           return LZMA_PROG_ERROR;
32
+
33
+       size += add;
34
+   }
35
+
36
+   // Uncompressed Size
37
+   if (block->uncompressed_size != LZMA_VLI_UNKNOWN) {
38
+       const uint32_t add = lzma_vli_size(block->uncompressed_size);
39
+       if (add == 0)
40
+           return LZMA_PROG_ERROR;
41
+
42
+       size += add;
43
+   }
44
+
45
+   // List of Filter Flags
46
+   if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
47
+       return LZMA_PROG_ERROR;
48
+
49
+   for (size_t i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
50
+       // Don't allow too many filters.
51
+       if (i == LZMA_FILTERS_MAX)
52
+           return LZMA_PROG_ERROR;
53
+
54
+       uint32_t add;
55
+       return_if_error(lzma_filter_flags_size(&add,
56
+               block->filters + i));
57
+
58
+       size += add;
59
+   }
60
+
61
+   // Pad to a multiple of four bytes.
62
+   block->header_size = (size + 3) & ~UINT32_C(3);
63
+
64
+   // NOTE: We don't verify that the encoded size of the Block stays
65
+   // within limits. This is because it is possible that we are called
66
+   // with exaggerated Compressed Size (e.g. LZMA_VLI_MAX) to reserve
67
+   // space for Block Header, and later called again with lower,
68
+   // real values.
69
+
70
+   return LZMA_OK;
71
+}
72
+
73
+
74
+extern LZMA_API(lzma_ret)
75
+lzma_block_header_encode(const lzma_block *block, uint8_t *out)
76
+{
77
+   // Validate everything but filters.
78
+   if (lzma_block_unpadded_size(block) == 0
79
+           || !lzma_vli_is_valid(block->uncompressed_size))
80
+       return LZMA_PROG_ERROR;
81
+
82
+   // Indicate the size of the buffer _excluding_ the CRC32 field.
83
+   const size_t out_size = block->header_size - 4;
84
+
85
+   // Store the Block Header Size.
86
+   out[0] = out_size / 4;
87
+
88
+   // We write Block Flags in pieces.
89
+   out[1] = 0x00;
90
+   size_t out_pos = 2;
91
+
92
+   // Compressed Size
93
+   if (block->compressed_size != LZMA_VLI_UNKNOWN) {
94
+       return_if_error(lzma_vli_encode(block->compressed_size, NULL,
95
+               out, &out_pos, out_size));
96
+
97
+       out[1] |= 0x40;
98
+   }
99
+
100
+   // Uncompressed Size
101
+   if (block->uncompressed_size != LZMA_VLI_UNKNOWN) {
102
+       return_if_error(lzma_vli_encode(block->uncompressed_size, NULL,
103
+               out, &out_pos, out_size));
104
+
105
+       out[1] |= 0x80;
106
+   }
107
+
108
+   // Filter Flags
109
+   if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
110
+       return LZMA_PROG_ERROR;
111
+
112
+   size_t filter_count = 0;
113
+   do {
114
+       // There can be a maximum of four filters.
115
+       if (filter_count == LZMA_FILTERS_MAX)
116
+           return LZMA_PROG_ERROR;
117
+
118
+       return_if_error(lzma_filter_flags_encode(
119
+               block->filters + filter_count,
120
+               out, &out_pos, out_size));
121
+
122
+   } while (block->filters[++filter_count].id != LZMA_VLI_UNKNOWN);
123
+
124
+   out[1] |= filter_count - 1;
125
+
126
+   // Padding
127
+   memzero(out + out_pos, out_size - out_pos);
128
+
129
+   // CRC32
130
+   unaligned_write32le(out + out_size, lzma_crc32(out, out_size, 0));
131
+
132
+   return LZMA_OK;
133
+}
134
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/block_util.c Added
92
 
1
@@ -0,0 +1,90 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       block_header.c
5
+/// \brief      Utility functions to handle lzma_block
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+#include "index.h"
16
+
17
+
18
+extern LZMA_API(lzma_ret)
19
+lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size)
20
+{
21
+   // Validate everything but Uncompressed Size and filters.
22
+   if (lzma_block_unpadded_size(block) == 0)
23
+       return LZMA_PROG_ERROR;
24
+
25
+   const uint32_t container_size = block->header_size
26
+           + lzma_check_size(block->check);
27
+
28
+   // Validate that Compressed Size will be greater than zero.
29
+   if (unpadded_size <= container_size)
30
+       return LZMA_DATA_ERROR;
31
+
32
+   // Calculate what Compressed Size is supposed to be.
33
+   // If Compressed Size was present in Block Header,
34
+   // compare that the new value matches it.
35
+   const lzma_vli compressed_size = unpadded_size - container_size;
36
+   if (block->compressed_size != LZMA_VLI_UNKNOWN
37
+           && block->compressed_size != compressed_size)
38
+       return LZMA_DATA_ERROR;
39
+
40
+   block->compressed_size = compressed_size;
41
+
42
+   return LZMA_OK;
43
+}
44
+
45
+
46
+extern LZMA_API(lzma_vli)
47
+lzma_block_unpadded_size(const lzma_block *block)
48
+{
49
+   // Validate the values that we are interested in i.e. all but
50
+   // Uncompressed Size and the filters.
51
+   //
52
+   // NOTE: This function is used for validation too, so it is
53
+   // essential that these checks are always done even if
54
+   // Compressed Size is unknown.
55
+   if (block == NULL || block->version != 0
56
+           || block->header_size < LZMA_BLOCK_HEADER_SIZE_MIN
57
+           || block->header_size > LZMA_BLOCK_HEADER_SIZE_MAX
58
+           || (block->header_size & 3)
59
+           || !lzma_vli_is_valid(block->compressed_size)
60
+           || block->compressed_size == 0
61
+           || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX)
62
+       return 0;
63
+
64
+   // If Compressed Size is unknown, return that we cannot know
65
+   // size of the Block either.
66
+   if (block->compressed_size == LZMA_VLI_UNKNOWN)
67
+       return LZMA_VLI_UNKNOWN;
68
+
69
+   // Calculate Unpadded Size and validate it.
70
+   const lzma_vli unpadded_size = block->compressed_size
71
+               + block->header_size
72
+               + lzma_check_size(block->check);
73
+
74
+   assert(unpadded_size >= UNPADDED_SIZE_MIN);
75
+   if (unpadded_size > UNPADDED_SIZE_MAX)
76
+       return 0;
77
+
78
+   return unpadded_size;
79
+}
80
+
81
+
82
+extern LZMA_API(lzma_vli)
83
+lzma_block_total_size(const lzma_block *block)
84
+{
85
+   lzma_vli unpadded_size = lzma_block_unpadded_size(block);
86
+
87
+   if (unpadded_size != LZMA_VLI_UNKNOWN)
88
+       unpadded_size = vli_ceil4(unpadded_size);
89
+
90
+   return unpadded_size;
91
+}
92
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/common.c Added
390
 
1
@@ -0,0 +1,388 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       common.h
5
+/// \brief      Common functions needed in many places in liblzma
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+
17
+/////////////
18
+// Version //
19
+/////////////
20
+
21
+extern LZMA_API(uint32_t)
22
+lzma_version_number(void)
23
+{
24
+   return LZMA_VERSION;
25
+}
26
+
27
+
28
+extern LZMA_API(const char *)
29
+lzma_version_string(void)
30
+{
31
+   return LZMA_VERSION_STRING;
32
+}
33
+
34
+
35
+///////////////////////
36
+// Memory allocation //
37
+///////////////////////
38
+
39
+extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
40
+lzma_alloc(size_t size, lzma_allocator *allocator)
41
+{
42
+   // Some malloc() variants return NULL if called with size == 0.
43
+   if (size == 0)
44
+       size = 1;
45
+
46
+   void *ptr;
47
+
48
+   if (allocator != NULL && allocator->alloc != NULL)
49
+       ptr = allocator->alloc(allocator->opaque, 1, size);
50
+   else
51
+       ptr = malloc(size);
52
+
53
+   return ptr;
54
+}
55
+
56
+
57
+extern void
58
+lzma_free(void *ptr, lzma_allocator *allocator)
59
+{
60
+   if (allocator != NULL && allocator->free != NULL)
61
+       allocator->free(allocator->opaque, ptr);
62
+   else
63
+       free(ptr);
64
+
65
+   return;
66
+}
67
+
68
+
69
+//////////
70
+// Misc //
71
+//////////
72
+
73
+extern size_t
74
+lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
75
+       size_t in_size, uint8_t *restrict out,
76
+       size_t *restrict out_pos, size_t out_size)
77
+{
78
+   const size_t in_avail = in_size - *in_pos;
79
+   const size_t out_avail = out_size - *out_pos;
80
+   const size_t copy_size = my_min(in_avail, out_avail);
81
+
82
+   memcpy(out + *out_pos, in + *in_pos, copy_size);
83
+
84
+   *in_pos += copy_size;
85
+   *out_pos += copy_size;
86
+
87
+   return copy_size;
88
+}
89
+
90
+
91
+extern lzma_ret
92
+lzma_next_filter_init(lzma_next_coder *next, lzma_allocator *allocator,
93
+       const lzma_filter_info *filters)
94
+{
95
+   lzma_next_coder_init(filters[0].init, next, allocator);
96
+   next->id = filters[0].id;
97
+   return filters[0].init == NULL
98
+           ? LZMA_OK : filters[0].init(next, allocator, filters);
99
+}
100
+
101
+
102
+extern lzma_ret
103
+lzma_next_filter_update(lzma_next_coder *next, lzma_allocator *allocator,
104
+       const lzma_filter *reversed_filters)
105
+{
106
+   // Check that the application isn't trying to change the Filter ID.
107
+   // End of filters is indicated with LZMA_VLI_UNKNOWN in both
108
+   // reversed_filters[0].id and next->id.
109
+   if (reversed_filters[0].id != next->id)
110
+       return LZMA_PROG_ERROR;
111
+
112
+   if (reversed_filters[0].id == LZMA_VLI_UNKNOWN)
113
+       return LZMA_OK;
114
+
115
+   assert(next->update != NULL);
116
+   return next->update(next->coder, allocator, NULL, reversed_filters);
117
+}
118
+
119
+
120
+extern void
121
+lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator)
122
+{
123
+   if (next->init != (uintptr_t)(NULL)) {
124
+       // To avoid tiny end functions that simply call
125
+       // lzma_free(coder, allocator), we allow leaving next->end
126
+       // NULL and call lzma_free() here.
127
+       if (next->end != NULL)
128
+           next->end(next->coder, allocator);
129
+       else
130
+           lzma_free(next->coder, allocator);
131
+
132
+       // Reset the variables so the we don't accidentally think
133
+       // that it is an already initialized coder.
134
+       *next = LZMA_NEXT_CODER_INIT;
135
+   }
136
+
137
+   return;
138
+}
139
+
140
+
141
+//////////////////////////////////////
142
+// External to internal API wrapper //
143
+//////////////////////////////////////
144
+
145
+extern lzma_ret
146
+lzma_strm_init(lzma_stream *strm)
147
+{
148
+   if (strm == NULL)
149
+       return LZMA_PROG_ERROR;
150
+
151
+   if (strm->internal == NULL) {
152
+       strm->internal = lzma_alloc(sizeof(lzma_internal),
153
+               strm->allocator);
154
+       if (strm->internal == NULL)
155
+           return LZMA_MEM_ERROR;
156
+
157
+       strm->internal->next = LZMA_NEXT_CODER_INIT;
158
+   }
159
+
160
+   strm->internal->supported_actions[LZMA_RUN] = false;
161
+   strm->internal->supported_actions[LZMA_SYNC_FLUSH] = false;
162
+   strm->internal->supported_actions[LZMA_FULL_FLUSH] = false;
163
+   strm->internal->supported_actions[LZMA_FINISH] = false;
164
+   strm->internal->sequence = ISEQ_RUN;
165
+   strm->internal->allow_buf_error = false;
166
+
167
+   strm->total_in = 0;
168
+   strm->total_out = 0;
169
+
170
+   return LZMA_OK;
171
+}
172
+
173
+
174
+extern LZMA_API(lzma_ret)
175
+lzma_code(lzma_stream *strm, lzma_action action)
176
+{
177
+   // Sanity checks
178
+   if ((strm->next_in == NULL && strm->avail_in != 0)
179
+           || (strm->next_out == NULL && strm->avail_out != 0)
180
+           || strm->internal == NULL
181
+           || strm->internal->next.code == NULL
182
+           || (unsigned int)(action) > LZMA_FINISH
183
+           || !strm->internal->supported_actions[action])
184
+       return LZMA_PROG_ERROR;
185
+
186
+   // Check if unsupported members have been set to non-zero or non-NULL,
187
+   // which would indicate that some new feature is wanted.
188
+   if (strm->reserved_ptr1 != NULL
189
+           || strm->reserved_ptr2 != NULL
190
+           || strm->reserved_ptr3 != NULL
191
+           || strm->reserved_ptr4 != NULL
192
+           || strm->reserved_int1 != 0
193
+           || strm->reserved_int2 != 0
194
+           || strm->reserved_int3 != 0
195
+           || strm->reserved_int4 != 0
196
+           || strm->reserved_enum1 != LZMA_RESERVED_ENUM
197
+           || strm->reserved_enum2 != LZMA_RESERVED_ENUM)
198
+       return LZMA_OPTIONS_ERROR;
199
+
200
+   switch (strm->internal->sequence) {
201
+   case ISEQ_RUN:
202
+       switch (action) {
203
+       case LZMA_RUN:
204
+           break;
205
+
206
+       case LZMA_SYNC_FLUSH:
207
+           strm->internal->sequence = ISEQ_SYNC_FLUSH;
208
+           break;
209
+
210
+       case LZMA_FULL_FLUSH:
211
+           strm->internal->sequence = ISEQ_FULL_FLUSH;
212
+           break;
213
+
214
+       case LZMA_FINISH:
215
+           strm->internal->sequence = ISEQ_FINISH;
216
+           break;
217
+       }
218
+
219
+       break;
220
+
221
+   case ISEQ_SYNC_FLUSH:
222
+       // The same action must be used until we return
223
+       // LZMA_STREAM_END, and the amount of input must not change.
224
+       if (action != LZMA_SYNC_FLUSH
225
+               || strm->internal->avail_in != strm->avail_in)
226
+           return LZMA_PROG_ERROR;
227
+
228
+       break;
229
+
230
+   case ISEQ_FULL_FLUSH:
231
+       if (action != LZMA_FULL_FLUSH
232
+               || strm->internal->avail_in != strm->avail_in)
233
+           return LZMA_PROG_ERROR;
234
+
235
+       break;
236
+
237
+   case ISEQ_FINISH:
238
+       if (action != LZMA_FINISH
239
+               || strm->internal->avail_in != strm->avail_in)
240
+           return LZMA_PROG_ERROR;
241
+
242
+       break;
243
+
244
+   case ISEQ_END:
245
+       return LZMA_STREAM_END;
246
+
247
+   case ISEQ_ERROR:
248
+   default:
249
+       return LZMA_PROG_ERROR;
250
+   }
251
+
252
+   size_t in_pos = 0;
253
+   size_t out_pos = 0;
254
+   lzma_ret ret = strm->internal->next.code(
255
+           strm->internal->next.coder, strm->allocator,
256
+           strm->next_in, &in_pos, strm->avail_in,
257
+           strm->next_out, &out_pos, strm->avail_out, action);
258
+
259
+   strm->next_in += in_pos;
260
+   strm->avail_in -= in_pos;
261
+   strm->total_in += in_pos;
262
+
263
+   strm->next_out += out_pos;
264
+   strm->avail_out -= out_pos;
265
+   strm->total_out += out_pos;
266
+
267
+   strm->internal->avail_in = strm->avail_in;
268
+
269
+   switch (ret) {
270
+   case LZMA_OK:
271
+       // Don't return LZMA_BUF_ERROR when it happens the first time.
272
+       // This is to avoid returning LZMA_BUF_ERROR when avail_out
273
+       // was zero but still there was no more data left to written
274
+       // to next_out.
275
+       if (out_pos == 0 && in_pos == 0) {
276
+           if (strm->internal->allow_buf_error)
277
+               ret = LZMA_BUF_ERROR;
278
+           else
279
+               strm->internal->allow_buf_error = true;
280
+       } else {
281
+           strm->internal->allow_buf_error = false;
282
+       }
283
+       break;
284
+
285
+   case LZMA_STREAM_END:
286
+       if (strm->internal->sequence == ISEQ_SYNC_FLUSH
287
+               || strm->internal->sequence == ISEQ_FULL_FLUSH)
288
+           strm->internal->sequence = ISEQ_RUN;
289
+       else
290
+           strm->internal->sequence = ISEQ_END;
291
+
292
+   // Fall through
293
+
294
+   case LZMA_NO_CHECK:
295
+   case LZMA_UNSUPPORTED_CHECK:
296
+   case LZMA_GET_CHECK:
297
+   case LZMA_MEMLIMIT_ERROR:
298
+       // Something else than LZMA_OK, but not a fatal error,
299
+       // that is, coding may be continued (except if ISEQ_END).
300
+       strm->internal->allow_buf_error = false;
301
+       break;
302
+
303
+   default:
304
+       // All the other errors are fatal; coding cannot be continued.
305
+       assert(ret != LZMA_BUF_ERROR);
306
+       strm->internal->sequence = ISEQ_ERROR;
307
+       break;
308
+   }
309
+
310
+   return ret;
311
+}
312
+
313
+
314
+extern LZMA_API(void)
315
+lzma_end(lzma_stream *strm)
316
+{
317
+   if (strm != NULL && strm->internal != NULL) {
318
+       lzma_next_end(&strm->internal->next, strm->allocator);
319
+       lzma_free(strm->internal, strm->allocator);
320
+       strm->internal = NULL;
321
+   }
322
+
323
+   return;
324
+}
325
+
326
+
327
+extern LZMA_API(lzma_check)
328
+lzma_get_check(const lzma_stream *strm)
329
+{
330
+   // Return LZMA_CHECK_NONE if we cannot know the check type.
331
+   // It's a bug in the application if this happens.
332
+   if (strm->internal->next.get_check == NULL)
333
+       return LZMA_CHECK_NONE;
334
+
335
+   return strm->internal->next.get_check(strm->internal->next.coder);
336
+}
337
+
338
+
339
+extern LZMA_API(uint64_t)
340
+lzma_memusage(const lzma_stream *strm)
341
+{
342
+   uint64_t memusage;
343
+   uint64_t old_memlimit;
344
+
345
+   if (strm == NULL || strm->internal == NULL
346
+           || strm->internal->next.memconfig == NULL
347
+           || strm->internal->next.memconfig(
348
+               strm->internal->next.coder,
349
+               &memusage, &old_memlimit, 0) != LZMA_OK)
350
+       return 0;
351
+
352
+   return memusage;
353
+}
354
+
355
+
356
+extern LZMA_API(uint64_t)
357
+lzma_memlimit_get(const lzma_stream *strm)
358
+{
359
+   uint64_t old_memlimit;
360
+   uint64_t memusage;
361
+
362
+   if (strm == NULL || strm->internal == NULL
363
+           || strm->internal->next.memconfig == NULL
364
+           || strm->internal->next.memconfig(
365
+               strm->internal->next.coder,
366
+               &memusage, &old_memlimit, 0) != LZMA_OK)
367
+       return 0;
368
+
369
+   return old_memlimit;
370
+}
371
+
372
+
373
+extern LZMA_API(lzma_ret)
374
+lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit)
375
+{
376
+   // Dummy variables to simplify memconfig functions
377
+   uint64_t old_memlimit;
378
+   uint64_t memusage;
379
+
380
+   if (strm == NULL || strm->internal == NULL
381
+           || strm->internal->next.memconfig == NULL)
382
+       return LZMA_PROG_ERROR;
383
+
384
+   if (new_memlimit != 0 && new_memlimit < LZMA_MEMUSAGE_BASE)
385
+       return LZMA_MEMLIMIT_ERROR;
386
+
387
+   return strm->internal->next.memconfig(strm->internal->next.coder,
388
+           &memusage, &old_memlimit, new_memlimit);
389
+}
390
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/common.h Added
286
 
1
@@ -0,0 +1,284 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       common.h
5
+/// \brief      Definitions common to the whole liblzma library
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_COMMON_H
15
+#define LZMA_COMMON_H
16
+
17
+#include "sysdefs.h"
18
+#include "mythread.h"
19
+#include "tuklib_integer.h"
20
+
21
+#if defined(_WIN32) || defined(__CYGWIN__)
22
+#  ifdef DLL_EXPORT
23
+#      define LZMA_API_EXPORT __declspec(dllexport)
24
+#  else
25
+#      define LZMA_API_EXPORT
26
+#  endif
27
+// Don't use ifdef or defined() below.
28
+#elif HAVE_VISIBILITY
29
+#  define LZMA_API_EXPORT __attribute__((__visibility__("default")))
30
+#else
31
+#  define LZMA_API_EXPORT
32
+#endif
33
+
34
+#define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL
35
+
36
+#include "lzma.h"
37
+
38
+// These allow helping the compiler in some often-executed branches, whose
39
+// result is almost always the same.
40
+#ifdef __GNUC__
41
+#  define likely(expr) __builtin_expect(expr, true)
42
+#  define unlikely(expr) __builtin_expect(expr, false)
43
+#else
44
+#  define likely(expr) (expr)
45
+#  define unlikely(expr) (expr)
46
+#endif
47
+
48
+
49
+/// Size of temporary buffers needed in some filters
50
+#define LZMA_BUFFER_SIZE 4096
51
+
52
+
53
+/// Starting value for memory usage estimates. Instead of calculating size
54
+/// of _every_ structure and taking into account malloc() overhead etc., we
55
+/// add a base size to all memory usage estimates. It's not very accurate
56
+/// but should be easily good enough.
57
+#define LZMA_MEMUSAGE_BASE (UINT64_C(1) << 15)
58
+
59
+/// Start of internal Filter ID space. These IDs must never be used
60
+/// in Streams.
61
+#define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62)
62
+
63
+
64
+/// Supported flags that can be passed to lzma_stream_decoder()
65
+/// or lzma_auto_decoder().
66
+#define LZMA_SUPPORTED_FLAGS \
67
+   ( LZMA_TELL_NO_CHECK \
68
+   | LZMA_TELL_UNSUPPORTED_CHECK \
69
+   | LZMA_TELL_ANY_CHECK \
70
+   | LZMA_CONCATENATED )
71
+
72
+
73
+/// Type of encoder/decoder specific data; the actual structure is defined
74
+/// differently in different coders.
75
+typedef struct lzma_coder_s lzma_coder;
76
+
77
+typedef struct lzma_next_coder_s lzma_next_coder;
78
+
79
+typedef struct lzma_filter_info_s lzma_filter_info;
80
+
81
+
82
+/// Type of a function used to initialize a filter encoder or decoder
83
+typedef lzma_ret (*lzma_init_function)(
84
+       lzma_next_coder *next, lzma_allocator *allocator,
85
+       const lzma_filter_info *filters);
86
+
87
+/// Type of a function to do some kind of coding work (filters, Stream,
88
+/// Block encoders/decoders etc.). Some special coders use don't use both
89
+/// input and output buffers, but for simplicity they still use this same
90
+/// function prototype.
91
+typedef lzma_ret (*lzma_code_function)(
92
+       lzma_coder *coder, lzma_allocator *allocator,
93
+       const uint8_t *restrict in, size_t *restrict in_pos,
94
+       size_t in_size, uint8_t *restrict out,
95
+       size_t *restrict out_pos, size_t out_size,
96
+       lzma_action action);
97
+
98
+/// Type of a function to free the memory allocated for the coder
99
+typedef void (*lzma_end_function)(
100
+       lzma_coder *coder, lzma_allocator *allocator);
101
+
102
+
103
+/// Raw coder validates and converts an array of lzma_filter structures to
104
+/// an array of lzma_filter_info structures. This array is used with
105
+/// lzma_next_filter_init to initialize the filter chain.
106
+struct lzma_filter_info_s {
107
+   /// Filter ID. This is used only by the encoder
108
+   /// with lzma_filters_update().
109
+   lzma_vli id;
110
+
111
+   /// Pointer to function used to initialize the filter.
112
+   /// This is NULL to indicate end of array.
113
+   lzma_init_function init;
114
+
115
+   /// Pointer to filter's options structure
116
+   void *options;
117
+};
118
+
119
+
120
+/// Hold data and function pointers of the next filter in the chain.
121
+struct lzma_next_coder_s {
122
+   /// Pointer to coder-specific data
123
+   lzma_coder *coder;
124
+
125
+   /// Filter ID. This is LZMA_VLI_UNKNOWN when this structure doesn't
126
+   /// point to a filter coder.
127
+   lzma_vli id;
128
+
129
+   /// "Pointer" to init function. This is never called here.
130
+   /// We need only to detect if we are initializing a coder
131
+   /// that was allocated earlier. See lzma_next_coder_init and
132
+   /// lzma_next_strm_init macros in this file.
133
+   uintptr_t init;
134
+
135
+   /// Pointer to function to do the actual coding
136
+   lzma_code_function code;
137
+
138
+   /// Pointer to function to free lzma_next_coder.coder. This can
139
+   /// be NULL; in that case, lzma_free is called to free
140
+   /// lzma_next_coder.coder.
141
+   lzma_end_function end;
142
+
143
+   /// Pointer to function to return the type of the integrity check.
144
+   /// Most coders won't support this.
145
+   lzma_check (*get_check)(const lzma_coder *coder);
146
+
147
+   /// Pointer to function to get and/or change the memory usage limit.
148
+   /// If new_memlimit == 0, the limit is not changed.
149
+   lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage,
150
+           uint64_t *old_memlimit, uint64_t new_memlimit);
151
+
152
+   /// Update the filter-specific options or the whole filter chain
153
+   /// in the encoder.
154
+   lzma_ret (*update)(lzma_coder *coder, lzma_allocator *allocator,
155
+           const lzma_filter *filters,
156
+           const lzma_filter *reversed_filters);
157
+};
158
+
159
+
160
+/// Macro to initialize lzma_next_coder structure
161
+#define LZMA_NEXT_CODER_INIT \
162
+   (lzma_next_coder){ \
163
+       .coder = NULL, \
164
+       .init = (uintptr_t)(NULL), \
165
+       .id = LZMA_VLI_UNKNOWN, \
166
+       .code = NULL, \
167
+       .end = NULL, \
168
+       .get_check = NULL, \
169
+       .memconfig = NULL, \
170
+       .update = NULL, \
171
+   }
172
+
173
+
174
+/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to
175
+/// this is stored in lzma_stream.
176
+struct lzma_internal_s {
177
+   /// The actual coder that should do something useful
178
+   lzma_next_coder next;
179
+
180
+   /// Track the state of the coder. This is used to validate arguments
181
+   /// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH
182
+   /// is used on every call to lzma_code until next.code has returned
183
+   /// LZMA_STREAM_END.
184
+   enum {
185
+       ISEQ_RUN,
186
+       ISEQ_SYNC_FLUSH,
187
+       ISEQ_FULL_FLUSH,
188
+       ISEQ_FINISH,
189
+       ISEQ_END,
190
+       ISEQ_ERROR,
191
+   } sequence;
192
+
193
+   /// A copy of lzma_stream avail_in. This is used to verify that the
194
+   /// amount of input doesn't change once e.g. LZMA_FINISH has been
195
+   /// used.
196
+   size_t avail_in;
197
+
198
+   /// Indicates which lzma_action values are allowed by next.code.
199
+   bool supported_actions[4];
200
+
201
+   /// If true, lzma_code will return LZMA_BUF_ERROR if no progress was
202
+   /// made (no input consumed and no output produced by next.code).
203
+   bool allow_buf_error;
204
+};
205
+
206
+
207
+/// Allocates memory
208
+extern void *lzma_alloc(size_t size, lzma_allocator *allocator)
209
+       lzma_attribute((__malloc__)) lzma_attr_alloc_size(1);
210
+
211
+/// Frees memory
212
+extern void lzma_free(void *ptr, lzma_allocator *allocator);
213
+
214
+
215
+/// Allocates strm->internal if it is NULL, and initializes *strm and
216
+/// strm->internal. This function is only called via lzma_next_strm_init macro.
217
+extern lzma_ret lzma_strm_init(lzma_stream *strm);
218
+
219
+/// Initializes the next filter in the chain, if any. This takes care of
220
+/// freeing the memory of previously initialized filter if it is different
221
+/// than the filter being initialized now. This way the actual filter
222
+/// initialization functions don't need to use lzma_next_coder_init macro.
223
+extern lzma_ret lzma_next_filter_init(lzma_next_coder *next,
224
+       lzma_allocator *allocator, const lzma_filter_info *filters);
225
+
226
+/// Update the next filter in the chain, if any. This checks that
227
+/// the application is not trying to change the Filter IDs.
228
+extern lzma_ret lzma_next_filter_update(
229
+       lzma_next_coder *next, lzma_allocator *allocator,
230
+       const lzma_filter *reversed_filters);
231
+
232
+/// Frees the memory allocated for next->coder either using next->end or,
233
+/// if next->end is NULL, using lzma_free.
234
+extern void lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator);
235
+
236
+
237
+/// Copy as much data as possible from in[] to out[] and update *in_pos
238
+/// and *out_pos accordingly. Returns the number of bytes copied.
239
+extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
240
+       size_t in_size, uint8_t *restrict out,
241
+       size_t *restrict out_pos, size_t out_size);
242
+
243
+
244
+/// \brief      Return if expression doesn't evaluate to LZMA_OK
245
+///
246
+/// There are several situations where we want to return immediately
247
+/// with the value of expr if it isn't LZMA_OK. This macro shortens
248
+/// the code a little.
249
+#define return_if_error(expr) \
250
+do { \
251
+   const lzma_ret ret_ = (expr); \
252
+   if (ret_ != LZMA_OK) \
253
+       return ret_; \
254
+} while (0)
255
+
256
+
257
+/// If next isn't already initialized, free the previous coder. Then mark
258
+/// that next is _possibly_ initialized for the coder using this macro.
259
+/// "Possibly" means that if e.g. allocation of next->coder fails, the
260
+/// structure isn't actually initialized for this coder, but leaving
261
+/// next->init to func is still OK.
262
+#define lzma_next_coder_init(func, next, allocator) \
263
+do { \
264
+   if ((uintptr_t)(func) != (next)->init) \
265
+       lzma_next_end(next, allocator); \
266
+   (next)->init = (uintptr_t)(func); \
267
+} while (0)
268
+
269
+
270
+/// Initializes lzma_strm and calls func() to initialize strm->internal->next.
271
+/// (The function being called will use lzma_next_coder_init()). If
272
+/// initialization fails, memory that wasn't freed by func() is freed
273
+/// along strm->internal.
274
+#define lzma_next_strm_init(func, strm, ...) \
275
+do { \
276
+   return_if_error(lzma_strm_init(strm)); \
277
+   const lzma_ret ret_ = func(&(strm)->internal->next, \
278
+           (strm)->allocator, __VA_ARGS__); \
279
+   if (ret_ != LZMA_OK) { \
280
+       lzma_end(strm); \
281
+       return ret_; \
282
+   } \
283
+} while (0)
284
+
285
+#endif
286
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/easy_buffer_encoder.c Added
29
 
1
@@ -0,0 +1,27 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       easy_buffer_encoder.c
5
+/// \brief      Easy single-call .xz Stream encoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "easy_preset.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_easy_buffer_encode(uint32_t preset, lzma_check check,
19
+       lzma_allocator *allocator, const uint8_t *in, size_t in_size,
20
+       uint8_t *out, size_t *out_pos, size_t out_size)
21
+{
22
+   lzma_options_easy opt_easy;
23
+   if (lzma_easy_preset(&opt_easy, preset))
24
+       return LZMA_OPTIONS_ERROR;
25
+
26
+   return lzma_stream_buffer_encode(opt_easy.filters, check,
27
+           allocator, in, in_size, out, out_pos, out_size);
28
+}
29
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/easy_decoder_memusage.c Added
26
 
1
@@ -0,0 +1,24 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       easy_decoder_memusage.c
5
+/// \brief      Decoder memory usage calculation to match easy encoder presets
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "easy_preset.h"
15
+
16
+
17
+extern LZMA_API(uint64_t)
18
+lzma_easy_decoder_memusage(uint32_t preset)
19
+{
20
+   lzma_options_easy opt_easy;
21
+   if (lzma_easy_preset(&opt_easy, preset))
22
+       return UINT32_MAX;
23
+
24
+   return lzma_raw_decoder_memusage(opt_easy.filters);
25
+}
26
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/easy_encoder.c Added
27
 
1
@@ -0,0 +1,25 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       easy_encoder.c
5
+/// \brief      Easy .xz Stream encoder initialization
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "easy_preset.h"
15
+#include "stream_encoder.h"
16
+
17
+
18
+extern LZMA_API(lzma_ret)
19
+lzma_easy_encoder(lzma_stream *strm, uint32_t preset, lzma_check check)
20
+{
21
+   lzma_options_easy opt_easy;
22
+   if (lzma_easy_preset(&opt_easy, preset))
23
+       return LZMA_OPTIONS_ERROR;
24
+
25
+   return lzma_stream_encoder(strm, opt_easy.filters, check);
26
+}
27
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/easy_encoder_memusage.c Added
26
 
1
@@ -0,0 +1,24 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       easy_encoder_memusage.c
5
+/// \brief      Easy .xz Stream encoder memory usage calculation
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "easy_preset.h"
15
+
16
+
17
+extern LZMA_API(uint64_t)
18
+lzma_easy_encoder_memusage(uint32_t preset)
19
+{
20
+   lzma_options_easy opt_easy;
21
+   if (lzma_easy_preset(&opt_easy, preset))
22
+       return UINT32_MAX;
23
+
24
+   return lzma_raw_encoder_memusage(opt_easy.filters);
25
+}
26
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/easy_preset.c Added
29
 
1
@@ -0,0 +1,27 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       easy_preset.c
5
+/// \brief      Preset handling for easy encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "easy_preset.h"
15
+
16
+
17
+extern bool
18
+lzma_easy_preset(lzma_options_easy *opt_easy, uint32_t preset)
19
+{
20
+   if (lzma_lzma_preset(&opt_easy->opt_lzma, preset))
21
+       return true;
22
+
23
+   opt_easy->filters[0].id = LZMA_FILTER_LZMA2;
24
+   opt_easy->filters[0].options = &opt_easy->opt_lzma;
25
+   opt_easy->filters[1].id = LZMA_VLI_UNKNOWN;
26
+
27
+   return false;
28
+}
29
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/easy_preset.h Added
34
 
1
@@ -0,0 +1,32 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       easy_preset.h
5
+/// \brief      Preset handling for easy encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+
17
+typedef struct {
18
+   /// We need to keep the filters array available in case
19
+   /// LZMA_FULL_FLUSH is used.
20
+   lzma_filter filters[LZMA_FILTERS_MAX + 1];
21
+
22
+   /// Options for LZMA2
23
+   lzma_options_lzma opt_lzma;
24
+
25
+   // Options for more filters can be added later, so this struct
26
+   // is not ready to be put into the public API.
27
+
28
+} lzma_options_easy;
29
+
30
+
31
+/// Set *easy to the settings given by the preset. Returns true on error,
32
+/// false on success.
33
+extern bool lzma_easy_preset(lzma_options_easy *easy, uint32_t preset);
34
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_buffer_decoder.c Added
89
 
1
@@ -0,0 +1,87 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_buffer_decoder.c
5
+/// \brief      Single-call raw decoding
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_decoder.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_raw_buffer_decode(const lzma_filter *filters, lzma_allocator *allocator,
19
+       const uint8_t *in, size_t *in_pos, size_t in_size,
20
+       uint8_t *out, size_t *out_pos, size_t out_size)
21
+{
22
+   // Validate what isn't validated later in filter_common.c.
23
+   if (in == NULL || in_pos == NULL || *in_pos > in_size || out == NULL
24
+           || out_pos == NULL || *out_pos > out_size)
25
+       return LZMA_PROG_ERROR;
26
+
27
+   // Initialize the decoer.
28
+   lzma_next_coder next = LZMA_NEXT_CODER_INIT;
29
+   return_if_error(lzma_raw_decoder_init(&next, allocator, filters));
30
+
31
+   // Store the positions so that we can restore them if something
32
+   // goes wrong.
33
+   const size_t in_start = *in_pos;
34
+   const size_t out_start = *out_pos;
35
+
36
+   // Do the actual decoding and free decoder's memory.
37
+   lzma_ret ret = next.code(next.coder, allocator, in, in_pos, in_size,
38
+           out, out_pos, out_size, LZMA_FINISH);
39
+
40
+   if (ret == LZMA_STREAM_END) {
41
+       ret = LZMA_OK;
42
+   } else {
43
+       if (ret == LZMA_OK) {
44
+           // Either the input was truncated or the
45
+           // output buffer was too small.
46
+           assert(*in_pos == in_size || *out_pos == out_size);
47
+
48
+           if (*in_pos != in_size) {
49
+               // Since input wasn't consumed completely,
50
+               // the output buffer became full and is
51
+               // too small.
52
+               ret = LZMA_BUF_ERROR;
53
+
54
+           } else if (*out_pos != out_size) {
55
+               // Since output didn't became full, the input
56
+               // has to be truncated.
57
+               ret = LZMA_DATA_ERROR;
58
+
59
+           } else {
60
+               // All the input was consumed and output
61
+               // buffer is full. Now we don't immediately
62
+               // know the reason for the error. Try
63
+               // decoding one more byte. If it succeeds,
64
+               // then the output buffer was too small. If
65
+               // we cannot get a new output byte, the input
66
+               // is truncated.
67
+               uint8_t tmp[1];
68
+               size_t tmp_pos = 0;
69
+               (void)next.code(next.coder, allocator,
70
+                       in, in_pos, in_size,
71
+                       tmp, &tmp_pos, 1, LZMA_FINISH);
72
+
73
+               if (tmp_pos == 1)
74
+                   ret = LZMA_BUF_ERROR;
75
+               else
76
+                   ret = LZMA_DATA_ERROR;
77
+           }
78
+       }
79
+
80
+       // Restore the positions.
81
+       *in_pos = in_start;
82
+       *out_pos = out_start;
83
+   }
84
+
85
+   lzma_next_end(&next, allocator);
86
+
87
+   return ret;
88
+}
89
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_buffer_encoder.c Added
56
 
1
@@ -0,0 +1,54 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_buffer_encoder.c
5
+/// \brief      Single-call raw encoding
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_encoder.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_raw_buffer_encode(const lzma_filter *filters, lzma_allocator *allocator,
19
+       const uint8_t *in, size_t in_size, uint8_t *out,
20
+       size_t *out_pos, size_t out_size)
21
+{
22
+   // Validate what isn't validated later in filter_common.c.
23
+   if ((in == NULL && in_size != 0) || out == NULL
24
+           || out_pos == NULL || *out_pos > out_size)
25
+       return LZMA_PROG_ERROR;
26
+
27
+   // Initialize the encoder
28
+   lzma_next_coder next = LZMA_NEXT_CODER_INIT;
29
+   return_if_error(lzma_raw_encoder_init(&next, allocator, filters));
30
+
31
+   // Store the output position so that we can restore it if
32
+   // something goes wrong.
33
+   const size_t out_start = *out_pos;
34
+
35
+   // Do the actual encoding and free coder's memory.
36
+   size_t in_pos = 0;
37
+   lzma_ret ret = next.code(next.coder, allocator, in, &in_pos, in_size,
38
+           out, out_pos, out_size, LZMA_FINISH);
39
+   lzma_next_end(&next, allocator);
40
+
41
+   if (ret == LZMA_STREAM_END) {
42
+       ret = LZMA_OK;
43
+   } else {
44
+       if (ret == LZMA_OK) {
45
+           // Output buffer was too small.
46
+           assert(*out_pos == out_size);
47
+           ret = LZMA_BUF_ERROR;
48
+       }
49
+
50
+       // Restore the output position.
51
+       *out_pos = out_start;
52
+   }
53
+
54
+   return ret;
55
+}
56
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_common.c Added
339
 
1
@@ -0,0 +1,337 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_common.c
5
+/// \brief      Filter-specific stuff common for both encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_common.h"
15
+
16
+
17
+static const struct {
18
+   /// Filter ID
19
+   lzma_vli id;
20
+
21
+   /// Size of the filter-specific options structure
22
+   size_t options_size;
23
+
24
+   /// True if it is OK to use this filter as non-last filter in
25
+   /// the chain.
26
+   bool non_last_ok;
27
+
28
+   /// True if it is OK to use this filter as the last filter in
29
+   /// the chain.
30
+   bool last_ok;
31
+
32
+   /// True if the filter may change the size of the data (that is, the
33
+   /// amount of encoded output can be different than the amount of
34
+   /// uncompressed input).
35
+   bool changes_size;
36
+
37
+} features[] = {
38
+#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1)
39
+   {
40
+       .id = LZMA_FILTER_LZMA1,
41
+       .options_size = sizeof(lzma_options_lzma),
42
+       .non_last_ok = false,
43
+       .last_ok = true,
44
+       .changes_size = true,
45
+   },
46
+#endif
47
+#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)
48
+   {
49
+       .id = LZMA_FILTER_LZMA2,
50
+       .options_size = sizeof(lzma_options_lzma),
51
+       .non_last_ok = false,
52
+       .last_ok = true,
53
+       .changes_size = true,
54
+   },
55
+#endif
56
+#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)
57
+   {
58
+       .id = LZMA_FILTER_X86,
59
+       .options_size = sizeof(lzma_options_bcj),
60
+       .non_last_ok = true,
61
+       .last_ok = false,
62
+       .changes_size = false,
63
+   },
64
+#endif
65
+#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC)
66
+   {
67
+       .id = LZMA_FILTER_POWERPC,
68
+       .options_size = sizeof(lzma_options_bcj),
69
+       .non_last_ok = true,
70
+       .last_ok = false,
71
+       .changes_size = false,
72
+   },
73
+#endif
74
+#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)
75
+   {
76
+       .id = LZMA_FILTER_IA64,
77
+       .options_size = sizeof(lzma_options_bcj),
78
+       .non_last_ok = true,
79
+       .last_ok = false,
80
+       .changes_size = false,
81
+   },
82
+#endif
83
+#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM)
84
+   {
85
+       .id = LZMA_FILTER_ARM,
86
+       .options_size = sizeof(lzma_options_bcj),
87
+       .non_last_ok = true,
88
+       .last_ok = false,
89
+       .changes_size = false,
90
+   },
91
+#endif
92
+#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB)
93
+   {
94
+       .id = LZMA_FILTER_ARMTHUMB,
95
+       .options_size = sizeof(lzma_options_bcj),
96
+       .non_last_ok = true,
97
+       .last_ok = false,
98
+       .changes_size = false,
99
+   },
100
+#endif
101
+#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC)
102
+   {
103
+       .id = LZMA_FILTER_SPARC,
104
+       .options_size = sizeof(lzma_options_bcj),
105
+       .non_last_ok = true,
106
+       .last_ok = false,
107
+       .changes_size = false,
108
+   },
109
+#endif
110
+#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)
111
+   {
112
+       .id = LZMA_FILTER_DELTA,
113
+       .options_size = sizeof(lzma_options_delta),
114
+       .non_last_ok = true,
115
+       .last_ok = false,
116
+       .changes_size = false,
117
+   },
118
+#endif
119
+   {
120
+       .id = LZMA_VLI_UNKNOWN
121
+   }
122
+};
123
+
124
+
125
+extern LZMA_API(lzma_ret)
126
+lzma_filters_copy(const lzma_filter *src, lzma_filter *dest,
127
+       lzma_allocator *allocator)
128
+{
129
+   if (src == NULL || dest == NULL)
130
+       return LZMA_PROG_ERROR;
131
+
132
+   lzma_ret ret;
133
+   size_t i;
134
+   for (i = 0; src[i].id != LZMA_VLI_UNKNOWN; ++i) {
135
+       // There must be a maximum of four filters plus
136
+       // the array terminator.
137
+       if (i == LZMA_FILTERS_MAX) {
138
+           ret = LZMA_OPTIONS_ERROR;
139
+           goto error;
140
+       }
141
+
142
+       dest[i].id = src[i].id;
143
+
144
+       if (src[i].options == NULL) {
145
+           dest[i].options = NULL;
146
+       } else {
147
+           // See if the filter is supported only when the
148
+           // options is not NULL. This might be convenient
149
+           // sometimes if the app is actually copying only
150
+           // a partial filter chain with a place holder ID.
151
+           //
152
+           // When options is not NULL, the Filter ID must be
153
+           // supported by us, because otherwise we don't know
154
+           // how big the options are.
155
+           size_t j;
156
+           for (j = 0; src[i].id != features[j].id; ++j) {
157
+               if (features[j].id == LZMA_VLI_UNKNOWN) {
158
+                   ret = LZMA_OPTIONS_ERROR;
159
+                   goto error;
160
+               }
161
+           }
162
+
163
+           // Allocate and copy the options.
164
+           dest[i].options = lzma_alloc(features[j].options_size,
165
+                   allocator);
166
+           if (dest[i].options == NULL) {
167
+               ret = LZMA_MEM_ERROR;
168
+               goto error;
169
+           }
170
+
171
+           memcpy(dest[i].options, src[i].options,
172
+                   features[j].options_size);
173
+       }
174
+   }
175
+
176
+   // Terminate the filter array.
177
+   assert(i <= LZMA_FILTERS_MAX + 1);
178
+   dest[i].id = LZMA_VLI_UNKNOWN;
179
+   dest[i].options = NULL;
180
+
181
+   return LZMA_OK;
182
+
183
+error:
184
+   // Free the options which we have already allocated.
185
+   while (i-- > 0) {
186
+       lzma_free(dest[i].options, allocator);
187
+       dest[i].options = NULL;
188
+   }
189
+
190
+   return ret;
191
+}
192
+
193
+
194
+static lzma_ret
195
+validate_chain(const lzma_filter *filters, size_t *count)
196
+{
197
+   // There must be at least one filter.
198
+   if (filters == NULL || filters[0].id == LZMA_VLI_UNKNOWN)
199
+       return LZMA_PROG_ERROR;
200
+
201
+   // Number of non-last filters that may change the size of the data
202
+   // significantly (that is, more than 1-2 % or so).
203
+   size_t changes_size_count = 0;
204
+
205
+   // True if it is OK to add a new filter after the current filter.
206
+   bool non_last_ok = true;
207
+
208
+   // True if the last filter in the given chain is actually usable as
209
+   // the last filter. Only filters that support embedding End of Payload
210
+   // Marker can be used as the last filter in the chain.
211
+   bool last_ok = false;
212
+
213
+   size_t i = 0;
214
+   do {
215
+       size_t j;
216
+       for (j = 0; filters[i].id != features[j].id; ++j)
217
+           if (features[j].id == LZMA_VLI_UNKNOWN)
218
+               return LZMA_OPTIONS_ERROR;
219
+
220
+       // If the previous filter in the chain cannot be a non-last
221
+       // filter, the chain is invalid.
222
+       if (!non_last_ok)
223
+           return LZMA_OPTIONS_ERROR;
224
+
225
+       non_last_ok = features[j].non_last_ok;
226
+       last_ok = features[j].last_ok;
227
+       changes_size_count += features[j].changes_size;
228
+
229
+   } while (filters[++i].id != LZMA_VLI_UNKNOWN);
230
+
231
+   // There must be 1-4 filters. The last filter must be usable as
232
+   // the last filter in the chain. A maximum of three filters are
233
+   // allowed to change the size of the data.
234
+   if (i > LZMA_FILTERS_MAX || !last_ok || changes_size_count > 3)
235
+       return LZMA_OPTIONS_ERROR;
236
+
237
+   *count = i;
238
+   return LZMA_OK;
239
+}
240
+
241
+
242
+extern lzma_ret
243
+lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
244
+       const lzma_filter *options,
245
+       lzma_filter_find coder_find, bool is_encoder)
246
+{
247
+   // Do some basic validation and get the number of filters.
248
+   size_t count;
249
+   return_if_error(validate_chain(options, &count));
250
+
251
+   // Set the filter functions and copy the options pointer.
252
+   lzma_filter_info filters[LZMA_FILTERS_MAX + 1];
253
+   if (is_encoder) {
254
+       for (size_t i = 0; i < count; ++i) {
255
+           // The order of the filters is reversed in the
256
+           // encoder. It allows more efficient handling
257
+           // of the uncompressed data.
258
+           const size_t j = count - i - 1;
259
+
260
+           const lzma_filter_coder *const fc
261
+                   = coder_find(options[i].id);
262
+           if (fc == NULL || fc->init == NULL)
263
+               return LZMA_OPTIONS_ERROR;
264
+
265
+           filters[j].id = options[i].id;
266
+           filters[j].init = fc->init;
267
+           filters[j].options = options[i].options;
268
+       }
269
+   } else {
270
+       for (size_t i = 0; i < count; ++i) {
271
+           const lzma_filter_coder *const fc
272
+                   = coder_find(options[i].id);
273
+           if (fc == NULL || fc->init == NULL)
274
+               return LZMA_OPTIONS_ERROR;
275
+
276
+           filters[i].id = options[i].id;
277
+           filters[i].init = fc->init;
278
+           filters[i].options = options[i].options;
279
+       }
280
+   }
281
+
282
+   // Terminate the array.
283
+   filters[count].id = LZMA_VLI_UNKNOWN;
284
+   filters[count].init = NULL;
285
+
286
+   // Initialize the filters.
287
+   const lzma_ret ret = lzma_next_filter_init(next, allocator, filters);
288
+   if (ret != LZMA_OK)
289
+       lzma_next_end(next, allocator);
290
+
291
+   return ret;
292
+}
293
+
294
+
295
+extern uint64_t
296
+lzma_raw_coder_memusage(lzma_filter_find coder_find,
297
+       const lzma_filter *filters)
298
+{
299
+   // The chain has to have at least one filter.
300
+   {
301
+       size_t tmp;
302
+       if (validate_chain(filters, &tmp) != LZMA_OK)
303
+           return UINT64_MAX;
304
+   }
305
+
306
+   uint64_t total = 0;
307
+   size_t i = 0;
308
+
309
+   do {
310
+       const lzma_filter_coder *const fc
311
+                = coder_find(filters[i].id);
312
+       if (fc == NULL)
313
+           return UINT64_MAX; // Unsupported Filter ID
314
+
315
+       if (fc->memusage == NULL) {
316
+           // This filter doesn't have a function to calculate
317
+           // the memory usage and validate the options. Such
318
+           // filters need only little memory, so we use 1 KiB
319
+           // as a good estimate. They also accept all possible
320
+           // options, so there's no need to worry about lack
321
+           // of validation.
322
+           total += 1024;
323
+       } else {
324
+           // Call the filter-specific memory usage calculation
325
+           // function.
326
+           const uint64_t usage
327
+                   = fc->memusage(filters[i].options);
328
+           if (usage == UINT64_MAX)
329
+               return UINT64_MAX; // Invalid options
330
+
331
+           total += usage;
332
+       }
333
+   } while (filters[++i].id != LZMA_VLI_UNKNOWN);
334
+
335
+   // Add some fixed amount of extra. It's to compensate memory usage
336
+   // of Stream, Block etc. coders, malloc() overhead, stack etc.
337
+   return total + LZMA_MEMUSAGE_BASE;
338
+}
339
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_common.h Added
50
 
1
@@ -0,0 +1,48 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_common.c
5
+/// \brief      Filter-specific stuff common for both encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_FILTER_COMMON_H
15
+#define LZMA_FILTER_COMMON_H
16
+
17
+#include "common.h"
18
+
19
+
20
+/// Both lzma_filter_encoder and lzma_filter_decoder begin with these members.
21
+typedef struct {
22
+   /// Filter ID
23
+   lzma_vli id;
24
+
25
+   /// Initializes the filter encoder and calls lzma_next_filter_init()
26
+   /// for filters + 1.
27
+   lzma_init_function init;
28
+
29
+   /// Calculates memory usage of the encoder. If the options are
30
+   /// invalid, UINT64_MAX is returned.
31
+   uint64_t (*memusage)(const void *options);
32
+
33
+} lzma_filter_coder;
34
+
35
+
36
+typedef const lzma_filter_coder *(*lzma_filter_find)(lzma_vli id);
37
+
38
+
39
+extern lzma_ret lzma_raw_coder_init(
40
+       lzma_next_coder *next, lzma_allocator *allocator,
41
+       const lzma_filter *filters,
42
+       lzma_filter_find coder_find, bool is_encoder);
43
+
44
+
45
+extern uint64_t lzma_raw_coder_memusage(lzma_filter_find coder_find,
46
+       const lzma_filter *filters);
47
+
48
+
49
+#endif
50
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_decoder.c Added
185
 
1
@@ -0,0 +1,183 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_decoder.c
5
+/// \brief      Filter ID mapping to filter-specific functions
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_decoder.h"
15
+#include "filter_common.h"
16
+#include "lzma_decoder.h"
17
+#include "lzma2_decoder.h"
18
+#include "simple_decoder.h"
19
+#include "delta_decoder.h"
20
+
21
+
22
+typedef struct {
23
+   /// Filter ID
24
+   lzma_vli id;
25
+
26
+   /// Initializes the filter encoder and calls lzma_next_filter_init()
27
+   /// for filters + 1.
28
+   lzma_init_function init;
29
+
30
+   /// Calculates memory usage of the encoder. If the options are
31
+   /// invalid, UINT64_MAX is returned.
32
+   uint64_t (*memusage)(const void *options);
33
+
34
+   /// Decodes Filter Properties.
35
+   ///
36
+   /// \return     - LZMA_OK: Properties decoded successfully.
37
+   ///             - LZMA_OPTIONS_ERROR: Unsupported properties
38
+   ///             - LZMA_MEM_ERROR: Memory allocation failed.
39
+   lzma_ret (*props_decode)(void **options, lzma_allocator *allocator,
40
+           const uint8_t *props, size_t props_size);
41
+
42
+} lzma_filter_decoder;
43
+
44
+
45
+static const lzma_filter_decoder decoders[] = {
46
+#ifdef HAVE_DECODER_LZMA1
47
+   {
48
+       .id = LZMA_FILTER_LZMA1,
49
+       .init = &lzma_lzma_decoder_init,
50
+       .memusage = &lzma_lzma_decoder_memusage,
51
+       .props_decode = &lzma_lzma_props_decode,
52
+   },
53
+#endif
54
+#ifdef HAVE_DECODER_LZMA2
55
+   {
56
+       .id = LZMA_FILTER_LZMA2,
57
+       .init = &lzma_lzma2_decoder_init,
58
+       .memusage = &lzma_lzma2_decoder_memusage,
59
+       .props_decode = &lzma_lzma2_props_decode,
60
+   },
61
+#endif
62
+#ifdef HAVE_DECODER_X86
63
+   {
64
+       .id = LZMA_FILTER_X86,
65
+       .init = &lzma_simple_x86_decoder_init,
66
+       .memusage = NULL,
67
+       .props_decode = &lzma_simple_props_decode,
68
+   },
69
+#endif
70
+#ifdef HAVE_DECODER_POWERPC
71
+   {
72
+       .id = LZMA_FILTER_POWERPC,
73
+       .init = &lzma_simple_powerpc_decoder_init,
74
+       .memusage = NULL,
75
+       .props_decode = &lzma_simple_props_decode,
76
+   },
77
+#endif
78
+#ifdef HAVE_DECODER_IA64
79
+   {
80
+       .id = LZMA_FILTER_IA64,
81
+       .init = &lzma_simple_ia64_decoder_init,
82
+       .memusage = NULL,
83
+       .props_decode = &lzma_simple_props_decode,
84
+   },
85
+#endif
86
+#ifdef HAVE_DECODER_ARM
87
+   {
88
+       .id = LZMA_FILTER_ARM,
89
+       .init = &lzma_simple_arm_decoder_init,
90
+       .memusage = NULL,
91
+       .props_decode = &lzma_simple_props_decode,
92
+   },
93
+#endif
94
+#ifdef HAVE_DECODER_ARMTHUMB
95
+   {
96
+       .id = LZMA_FILTER_ARMTHUMB,
97
+       .init = &lzma_simple_armthumb_decoder_init,
98
+       .memusage = NULL,
99
+       .props_decode = &lzma_simple_props_decode,
100
+   },
101
+#endif
102
+#ifdef HAVE_DECODER_SPARC
103
+   {
104
+       .id = LZMA_FILTER_SPARC,
105
+       .init = &lzma_simple_sparc_decoder_init,
106
+       .memusage = NULL,
107
+       .props_decode = &lzma_simple_props_decode,
108
+   },
109
+#endif
110
+#ifdef HAVE_DECODER_DELTA
111
+   {
112
+       .id = LZMA_FILTER_DELTA,
113
+       .init = &lzma_delta_decoder_init,
114
+       .memusage = &lzma_delta_coder_memusage,
115
+       .props_decode = &lzma_delta_props_decode,
116
+   },
117
+#endif
118
+};
119
+
120
+
121
+static const lzma_filter_decoder *
122
+decoder_find(lzma_vli id)
123
+{
124
+   for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i)
125
+       if (decoders[i].id == id)
126
+           return decoders + i;
127
+
128
+   return NULL;
129
+}
130
+
131
+
132
+extern LZMA_API(lzma_bool)
133
+lzma_filter_decoder_is_supported(lzma_vli id)
134
+{
135
+   return decoder_find(id) != NULL;
136
+}
137
+
138
+
139
+extern lzma_ret
140
+lzma_raw_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
141
+       const lzma_filter *options)
142
+{
143
+   return lzma_raw_coder_init(next, allocator,
144
+           options, (lzma_filter_find)(&decoder_find), false);
145
+}
146
+
147
+
148
+extern LZMA_API(lzma_ret)
149
+lzma_raw_decoder(lzma_stream *strm, const lzma_filter *options)
150
+{
151
+   lzma_next_strm_init(lzma_raw_decoder_init, strm, options);
152
+
153
+   strm->internal->supported_actions[LZMA_RUN] = true;
154
+   strm->internal->supported_actions[LZMA_FINISH] = true;
155
+
156
+   return LZMA_OK;
157
+}
158
+
159
+
160
+extern LZMA_API(uint64_t)
161
+lzma_raw_decoder_memusage(const lzma_filter *filters)
162
+{
163
+   return lzma_raw_coder_memusage(
164
+           (lzma_filter_find)(&decoder_find), filters);
165
+}
166
+
167
+
168
+extern LZMA_API(lzma_ret)
169
+lzma_properties_decode(lzma_filter *filter, lzma_allocator *allocator,
170
+       const uint8_t *props, size_t props_size)
171
+{
172
+   // Make it always NULL so that the caller can always safely free() it.
173
+   filter->options = NULL;
174
+
175
+   const lzma_filter_decoder *const fd = decoder_find(filter->id);
176
+   if (fd == NULL)
177
+       return LZMA_OPTIONS_ERROR;
178
+
179
+   if (fd->props_decode == NULL)
180
+       return props_size == 0 ? LZMA_OK : LZMA_OPTIONS_ERROR;
181
+
182
+   return fd->props_decode(
183
+           &filter->options, allocator, props, props_size);
184
+}
185
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_decoder.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_decoder.c
5
+/// \brief      Filter ID mapping to filter-specific functions
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_FILTER_DECODER_H
15
+#define LZMA_FILTER_DECODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+extern lzma_ret lzma_raw_decoder_init(
21
+       lzma_next_coder *next, lzma_allocator *allocator,
22
+       const lzma_filter *options);
23
+
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_encoder.c Added
290
 
1
@@ -0,0 +1,288 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_decoder.c
5
+/// \brief      Filter ID mapping to filter-specific functions
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_encoder.h"
15
+#include "filter_common.h"
16
+#include "lzma_encoder.h"
17
+#include "lzma2_encoder.h"
18
+#include "simple_encoder.h"
19
+#include "delta_encoder.h"
20
+
21
+
22
+typedef struct {
23
+   /// Filter ID
24
+   lzma_vli id;
25
+
26
+   /// Initializes the filter encoder and calls lzma_next_filter_init()
27
+   /// for filters + 1.
28
+   lzma_init_function init;
29
+
30
+   /// Calculates memory usage of the encoder. If the options are
31
+   /// invalid, UINT64_MAX is returned.
32
+   uint64_t (*memusage)(const void *options);
33
+
34
+   /// Calculates the minimum sane size for Blocks (or other types of
35
+   /// chunks) to which the input data can be split to make
36
+   /// multithreaded encoding possible. If this is NULL, it is assumed
37
+   /// that the encoder is fast enough with single thread.
38
+   lzma_vli (*chunk_size)(const void *options);
39
+
40
+   /// Tells the size of the Filter Properties field. If options are
41
+   /// invalid, UINT32_MAX is returned. If this is NULL, props_size_fixed
42
+   /// is used.
43
+   lzma_ret (*props_size_get)(uint32_t *size, const void *options);
44
+   uint32_t props_size_fixed;
45
+
46
+   /// Encodes Filter Properties.
47
+   ///
48
+   /// \return     - LZMA_OK: Properties encoded successfully.
49
+   ///             - LZMA_OPTIONS_ERROR: Unsupported options
50
+   ///             - LZMA_PROG_ERROR: Invalid options or not enough
51
+   ///               output space
52
+   lzma_ret (*props_encode)(const void *options, uint8_t *out);
53
+
54
+} lzma_filter_encoder;
55
+
56
+
57
+static const lzma_filter_encoder encoders[] = {
58
+#ifdef HAVE_ENCODER_LZMA1
59
+   {
60
+       .id = LZMA_FILTER_LZMA1,
61
+       .init = &lzma_lzma_encoder_init,
62
+       .memusage = &lzma_lzma_encoder_memusage,
63
+       .chunk_size = NULL, // FIXME
64
+       .props_size_get = NULL,
65
+       .props_size_fixed = 5,
66
+       .props_encode = &lzma_lzma_props_encode,
67
+   },
68
+#endif
69
+#ifdef HAVE_ENCODER_LZMA2
70
+   {
71
+       .id = LZMA_FILTER_LZMA2,
72
+       .init = &lzma_lzma2_encoder_init,
73
+       .memusage = &lzma_lzma2_encoder_memusage,
74
+       .chunk_size = NULL, // FIXME
75
+       .props_size_get = NULL,
76
+       .props_size_fixed = 1,
77
+       .props_encode = &lzma_lzma2_props_encode,
78
+   },
79
+#endif
80
+#ifdef HAVE_ENCODER_X86
81
+   {
82
+       .id = LZMA_FILTER_X86,
83
+       .init = &lzma_simple_x86_encoder_init,
84
+       .memusage = NULL,
85
+       .chunk_size = NULL,
86
+       .props_size_get = &lzma_simple_props_size,
87
+       .props_encode = &lzma_simple_props_encode,
88
+   },
89
+#endif
90
+#ifdef HAVE_ENCODER_POWERPC
91
+   {
92
+       .id = LZMA_FILTER_POWERPC,
93
+       .init = &lzma_simple_powerpc_encoder_init,
94
+       .memusage = NULL,
95
+       .chunk_size = NULL,
96
+       .props_size_get = &lzma_simple_props_size,
97
+       .props_encode = &lzma_simple_props_encode,
98
+   },
99
+#endif
100
+#ifdef HAVE_ENCODER_IA64
101
+   {
102
+       .id = LZMA_FILTER_IA64,
103
+       .init = &lzma_simple_ia64_encoder_init,
104
+       .memusage = NULL,
105
+       .chunk_size = NULL,
106
+       .props_size_get = &lzma_simple_props_size,
107
+       .props_encode = &lzma_simple_props_encode,
108
+   },
109
+#endif
110
+#ifdef HAVE_ENCODER_ARM
111
+   {
112
+       .id = LZMA_FILTER_ARM,
113
+       .init = &lzma_simple_arm_encoder_init,
114
+       .memusage = NULL,
115
+       .chunk_size = NULL,
116
+       .props_size_get = &lzma_simple_props_size,
117
+       .props_encode = &lzma_simple_props_encode,
118
+   },
119
+#endif
120
+#ifdef HAVE_ENCODER_ARMTHUMB
121
+   {
122
+       .id = LZMA_FILTER_ARMTHUMB,
123
+       .init = &lzma_simple_armthumb_encoder_init,
124
+       .memusage = NULL,
125
+       .chunk_size = NULL,
126
+       .props_size_get = &lzma_simple_props_size,
127
+       .props_encode = &lzma_simple_props_encode,
128
+   },
129
+#endif
130
+#ifdef HAVE_ENCODER_SPARC
131
+   {
132
+       .id = LZMA_FILTER_SPARC,
133
+       .init = &lzma_simple_sparc_encoder_init,
134
+       .memusage = NULL,
135
+       .chunk_size = NULL,
136
+       .props_size_get = &lzma_simple_props_size,
137
+       .props_encode = &lzma_simple_props_encode,
138
+   },
139
+#endif
140
+#ifdef HAVE_ENCODER_DELTA
141
+   {
142
+       .id = LZMA_FILTER_DELTA,
143
+       .init = &lzma_delta_encoder_init,
144
+       .memusage = &lzma_delta_coder_memusage,
145
+       .chunk_size = NULL,
146
+       .props_size_get = NULL,
147
+       .props_size_fixed = 1,
148
+       .props_encode = &lzma_delta_props_encode,
149
+   },
150
+#endif
151
+};
152
+
153
+
154
+static const lzma_filter_encoder *
155
+encoder_find(lzma_vli id)
156
+{
157
+   for (size_t i = 0; i < ARRAY_SIZE(encoders); ++i)
158
+       if (encoders[i].id == id)
159
+           return encoders + i;
160
+
161
+   return NULL;
162
+}
163
+
164
+
165
+extern LZMA_API(lzma_bool)
166
+lzma_filter_encoder_is_supported(lzma_vli id)
167
+{
168
+   return encoder_find(id) != NULL;
169
+}
170
+
171
+
172
+extern LZMA_API(lzma_ret)
173
+lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)
174
+{
175
+   if (strm->internal->next.update == NULL)
176
+       return LZMA_PROG_ERROR;
177
+
178
+   // Validate the filter chain.
179
+   if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)
180
+       return LZMA_OPTIONS_ERROR;
181
+
182
+   // The actual filter chain in the encoder is reversed. Some things
183
+   // still want the normal order chain, so we provide both.
184
+   size_t count = 1;
185
+   while (filters[count].id != LZMA_VLI_UNKNOWN)
186
+       ++count;
187
+
188
+   lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1];
189
+   for (size_t i = 0; i < count; ++i)
190
+       reversed_filters[count - i - 1] = filters[i];
191
+
192
+   reversed_filters[count].id = LZMA_VLI_UNKNOWN;
193
+
194
+   return strm->internal->next.update(strm->internal->next.coder,
195
+           strm->allocator, filters, reversed_filters);
196
+}
197
+
198
+
199
+extern lzma_ret
200
+lzma_raw_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
201
+       const lzma_filter *options)
202
+{
203
+   return lzma_raw_coder_init(next, allocator,
204
+           options, (lzma_filter_find)(&encoder_find), true);
205
+}
206
+
207
+
208
+extern LZMA_API(lzma_ret)
209
+lzma_raw_encoder(lzma_stream *strm, const lzma_filter *options)
210
+{
211
+   lzma_next_strm_init(lzma_raw_coder_init, strm, options,
212
+           (lzma_filter_find)(&encoder_find), true);
213
+
214
+   strm->internal->supported_actions[LZMA_RUN] = true;
215
+   strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
216
+   strm->internal->supported_actions[LZMA_FINISH] = true;
217
+
218
+   return LZMA_OK;
219
+}
220
+
221
+
222
+extern LZMA_API(uint64_t)
223
+lzma_raw_encoder_memusage(const lzma_filter *filters)
224
+{
225
+   return lzma_raw_coder_memusage(
226
+           (lzma_filter_find)(&encoder_find), filters);
227
+}
228
+
229
+
230
+/*
231
+extern LZMA_API(lzma_vli)
232
+lzma_chunk_size(const lzma_filter *filters)
233
+{
234
+   lzma_vli max = 0;
235
+
236
+   for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
237
+       const lzma_filter_encoder *const fe
238
+               = encoder_find(filters[i].id);
239
+       if (fe->chunk_size != NULL) {
240
+           const lzma_vli size
241
+                   = fe->chunk_size(filters[i].options);
242
+           if (size == LZMA_VLI_UNKNOWN)
243
+               return LZMA_VLI_UNKNOWN;
244
+
245
+           if (size > max)
246
+               max = size;
247
+       }
248
+   }
249
+
250
+   return max;
251
+}
252
+*/
253
+
254
+
255
+extern LZMA_API(lzma_ret)
256
+lzma_properties_size(uint32_t *size, const lzma_filter *filter)
257
+{
258
+   const lzma_filter_encoder *const fe = encoder_find(filter->id);
259
+   if (fe == NULL) {
260
+       // Unknown filter - if the Filter ID is a proper VLI,
261
+       // return LZMA_OPTIONS_ERROR instead of LZMA_PROG_ERROR,
262
+       // because it's possible that we just don't have support
263
+       // compiled in for the requested filter.
264
+       return filter->id <= LZMA_VLI_MAX
265
+               ? LZMA_OPTIONS_ERROR : LZMA_PROG_ERROR;
266
+   }
267
+
268
+   if (fe->props_size_get == NULL) {
269
+       // No props_size_get() function, use props_size_fixed.
270
+       *size = fe->props_size_fixed;
271
+       return LZMA_OK;
272
+   }
273
+
274
+   return fe->props_size_get(size, filter->options);
275
+}
276
+
277
+
278
+extern LZMA_API(lzma_ret)
279
+lzma_properties_encode(const lzma_filter *filter, uint8_t *props)
280
+{
281
+   const lzma_filter_encoder *const fe = encoder_find(filter->id);
282
+   if (fe == NULL)
283
+       return LZMA_PROG_ERROR;
284
+
285
+   if (fe->props_encode == NULL)
286
+       return LZMA_OK;
287
+
288
+   return fe->props_encode(filter->options, props);
289
+}
290
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_encoder.h Added
29
 
1
@@ -0,0 +1,27 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_encoder.c
5
+/// \brief      Filter ID mapping to filter-specific functions
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_FILTER_ENCODER_H
15
+#define LZMA_FILTER_ENCODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+// FIXME: Might become a part of the public API once finished.
21
+// extern lzma_vli lzma_chunk_size(const lzma_filter *filters);
22
+
23
+
24
+extern lzma_ret lzma_raw_encoder_init(
25
+       lzma_next_coder *next, lzma_allocator *allocator,
26
+       const lzma_filter *filters);
27
+
28
+#endif
29
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_flags_decoder.c Added
48
 
1
@@ -0,0 +1,46 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_flags_decoder.c
5
+/// \brief      Decodes a Filter Flags field
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_decoder.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_filter_flags_decode(
19
+       lzma_filter *filter, lzma_allocator *allocator,
20
+       const uint8_t *in, size_t *in_pos, size_t in_size)
21
+{
22
+   // Set the pointer to NULL so the caller can always safely free it.
23
+   filter->options = NULL;
24
+
25
+   // Filter ID
26
+   return_if_error(lzma_vli_decode(&filter->id, NULL,
27
+           in, in_pos, in_size));
28
+
29
+   if (filter->id >= LZMA_FILTER_RESERVED_START)
30
+       return LZMA_DATA_ERROR;
31
+
32
+   // Size of Properties
33
+   lzma_vli props_size;
34
+   return_if_error(lzma_vli_decode(&props_size, NULL,
35
+           in, in_pos, in_size));
36
+
37
+   // Filter Properties
38
+   if (in_size - *in_pos < props_size)
39
+       return LZMA_DATA_ERROR;
40
+
41
+   const lzma_ret ret = lzma_properties_decode(
42
+           filter, allocator, in + *in_pos, props_size);
43
+
44
+   *in_pos += props_size;
45
+
46
+   return ret;
47
+}
48
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/filter_flags_encoder.c Added
58
 
1
@@ -0,0 +1,56 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       filter_flags_encoder.c
5
+/// \brief      Decodes a Filter Flags field
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "filter_encoder.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_filter_flags_size(uint32_t *size, const lzma_filter *filter)
19
+{
20
+   if (filter->id >= LZMA_FILTER_RESERVED_START)
21
+       return LZMA_PROG_ERROR;
22
+
23
+   return_if_error(lzma_properties_size(size, filter));
24
+
25
+   *size += lzma_vli_size(filter->id) + lzma_vli_size(*size);
26
+
27
+   return LZMA_OK;
28
+}
29
+
30
+
31
+extern LZMA_API(lzma_ret)
32
+lzma_filter_flags_encode(const lzma_filter *filter,
33
+       uint8_t *out, size_t *out_pos, size_t out_size)
34
+{
35
+   // Filter ID
36
+   if (filter->id >= LZMA_FILTER_RESERVED_START)
37
+       return LZMA_PROG_ERROR;
38
+
39
+   return_if_error(lzma_vli_encode(filter->id, NULL,
40
+           out, out_pos, out_size));
41
+
42
+   // Size of Properties
43
+   uint32_t props_size;
44
+   return_if_error(lzma_properties_size(&props_size, filter));
45
+   return_if_error(lzma_vli_encode(props_size, NULL,
46
+           out, out_pos, out_size));
47
+
48
+   // Filter Properties
49
+   if (out_size - *out_pos < props_size)
50
+       return LZMA_PROG_ERROR;
51
+
52
+   return_if_error(lzma_properties_encode(filter, out + *out_pos));
53
+
54
+   *out_pos += props_size;
55
+
56
+   return LZMA_OK;
57
+}
58
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/hardware_physmem.c Added
27
 
1
@@ -0,0 +1,25 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       hardware_physmem.c
5
+/// \brief      Get the total amount of physical memory (RAM)
6
+//
7
+//  Author:     Jonathan Nieder
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+#include "tuklib_physmem.h"
17
+
18
+
19
+extern LZMA_API(uint64_t)
20
+lzma_physmem(void)
21
+{
22
+   // It is simpler to make lzma_physmem() a wrapper for
23
+   // tuklib_physmem() than to hack appropriate symbol visiblity
24
+   // support for the tuklib modules.
25
+   return tuklib_physmem();
26
+}
27
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/index.c Added
1246
 
1
@@ -0,0 +1,1244 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       index.c
5
+/// \brief      Handling of .xz Indexes and some other Stream information
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "index.h"
15
+#include "stream_flags_common.h"
16
+
17
+
18
+/// \brief      How many Records to allocate at once
19
+///
20
+/// This should be big enough to avoid making lots of tiny allocations
21
+/// but small enough to avoid too much unused memory at once.
22
+#define INDEX_GROUP_SIZE 512
23
+
24
+
25
+/// \brief      How many Records can be allocated at once at maximum
26
+#define PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record))
27
+
28
+
29
+/// \brief      Base structure for index_stream and index_group structures
30
+typedef struct index_tree_node_s index_tree_node;
31
+struct index_tree_node_s {
32
+   /// Uncompressed start offset of this Stream (relative to the
33
+   /// beginning of the file) or Block (relative to the beginning
34
+   /// of the Stream)
35
+   lzma_vli uncompressed_base;
36
+
37
+   /// Compressed start offset of this Stream or Block
38
+   lzma_vli compressed_base;
39
+
40
+   index_tree_node *parent;
41
+   index_tree_node *left;
42
+   index_tree_node *right;
43
+};
44
+
45
+
46
+/// \brief      AVL tree to hold index_stream or index_group structures
47
+typedef struct {
48
+   /// Root node
49
+   index_tree_node *root;
50
+
51
+   /// Leftmost node. Since the tree will be filled sequentially,
52
+   /// this won't change after the first node has been added to
53
+   /// the tree.
54
+   index_tree_node *leftmost;
55
+
56
+   /// The rightmost node in the tree. Since the tree is filled
57
+   /// sequentially, this is always the node where to add the new data.
58
+   index_tree_node *rightmost;
59
+
60
+   /// Number of nodes in the tree
61
+   uint32_t count;
62
+
63
+} index_tree;
64
+
65
+
66
+typedef struct {
67
+   lzma_vli uncompressed_sum;
68
+   lzma_vli unpadded_sum;
69
+} index_record;
70
+
71
+
72
+typedef struct {
73
+   /// Every Record group is part of index_stream.groups tree.
74
+   index_tree_node node;
75
+
76
+   /// Number of Blocks in this Stream before this group.
77
+   lzma_vli number_base;
78
+
79
+   /// Number of Records that can be put in records[].
80
+   size_t allocated;
81
+
82
+   /// Index of the last Record in use.
83
+   size_t last;
84
+
85
+   /// The sizes in this array are stored as cumulative sums relative
86
+   /// to the beginning of the Stream. This makes it possible to
87
+   /// use binary search in lzma_index_locate().
88
+   ///
89
+   /// Note that the cumulative summing is done specially for
90
+   /// unpadded_sum: The previous value is rounded up to the next
91
+   /// multiple of four before adding the Unpadded Size of the new
92
+   /// Block. The total encoded size of the Blocks in the Stream
93
+   /// is records[last].unpadded_sum in the last Record group of
94
+   /// the Stream.
95
+   ///
96
+   /// For example, if the Unpadded Sizes are 39, 57, and 81, the
97
+   /// stored values are 39, 97 (40 + 57), and 181 (100 + 181).
98
+   /// The total encoded size of these Blocks is 184.
99
+   ///
100
+   /// This is a flexible array, because it makes easy to optimize
101
+   /// memory usage in case someone concatenates many Streams that
102
+   /// have only one or few Blocks.
103
+   index_record records[];
104
+
105
+} index_group;
106
+
107
+
108
+typedef struct {
109
+   /// Every index_stream is a node in the tree of Sreams.
110
+   index_tree_node node;
111
+
112
+   /// Number of this Stream (first one is 1)
113
+   uint32_t number;
114
+
115
+   /// Total number of Blocks before this Stream
116
+   lzma_vli block_number_base;
117
+
118
+   /// Record groups of this Stream are stored in a tree.
119
+   /// It's a T-tree with AVL-tree balancing. There are
120
+   /// INDEX_GROUP_SIZE Records per node by default.
121
+   /// This keeps the number of memory allocations reasonable
122
+   /// and finding a Record is fast.
123
+   index_tree groups;
124
+
125
+   /// Number of Records in this Stream
126
+   lzma_vli record_count;
127
+
128
+   /// Size of the List of Records field in this Stream. This is used
129
+   /// together with record_count to calculate the size of the Index
130
+   /// field and thus the total size of the Stream.
131
+   lzma_vli index_list_size;
132
+
133
+   /// Stream Flags of this Stream. This is meaningful only if
134
+   /// the Stream Flags have been told us with lzma_index_stream_flags().
135
+   /// Initially stream_flags.version is set to UINT32_MAX to indicate
136
+   /// that the Stream Flags are unknown.
137
+   lzma_stream_flags stream_flags;
138
+
139
+   /// Amount of Stream Padding after this Stream. This defaults to
140
+   /// zero and can be set with lzma_index_stream_padding().
141
+   lzma_vli stream_padding;
142
+
143
+} index_stream;
144
+
145
+
146
+struct lzma_index_s {
147
+   /// AVL-tree containing the Stream(s). Often there is just one
148
+   /// Stream, but using a tree keeps lookups fast even when there
149
+   /// are many concatenated Streams.
150
+   index_tree streams;
151
+
152
+   /// Uncompressed size of all the Blocks in the Stream(s)
153
+   lzma_vli uncompressed_size;
154
+
155
+   /// Total size of all the Blocks in the Stream(s)
156
+   lzma_vli total_size;
157
+
158
+   /// Total number of Records in all Streams in this lzma_index
159
+   lzma_vli record_count;
160
+
161
+   /// Size of the List of Records field if all the Streams in this
162
+   /// lzma_index were packed into a single Stream (makes it simpler to
163
+   /// take many .xz files and combine them into a single Stream).
164
+   ///
165
+   /// This value together with record_count is needed to calculate
166
+   /// Backward Size that is stored into Stream Footer.
167
+   lzma_vli index_list_size;
168
+
169
+   /// How many Records to allocate at once in lzma_index_append().
170
+   /// This defaults to INDEX_GROUP_SIZE but can be overriden with
171
+   /// lzma_index_prealloc().
172
+   size_t prealloc;
173
+
174
+   /// Bitmask indicating what integrity check types have been used
175
+   /// as set by lzma_index_stream_flags(). The bit of the last Stream
176
+   /// is not included here, since it is possible to change it by
177
+   /// calling lzma_index_stream_flags() again.
178
+   uint32_t checks;
179
+};
180
+
181
+
182
+static void
183
+index_tree_init(index_tree *tree)
184
+{
185
+   tree->root = NULL;
186
+   tree->leftmost = NULL;
187
+   tree->rightmost = NULL;
188
+   tree->count = 0;
189
+   return;
190
+}
191
+
192
+
193
+/// Helper for index_tree_end()
194
+static void
195
+index_tree_node_end(index_tree_node *node, lzma_allocator *allocator,
196
+       void (*free_func)(void *node, lzma_allocator *allocator))
197
+{
198
+   // The tree won't ever be very huge, so recursion should be fine.
199
+   // 20 levels in the tree is likely quite a lot already in practice.
200
+   if (node->left != NULL)
201
+       index_tree_node_end(node->left, allocator, free_func);
202
+
203
+   if (node->right != NULL)
204
+       index_tree_node_end(node->right, allocator, free_func);
205
+
206
+   if (free_func != NULL)
207
+       free_func(node, allocator);
208
+
209
+   lzma_free(node, allocator);
210
+   return;
211
+}
212
+
213
+
214
+/// Free the meory allocated for a tree. If free_func is not NULL,
215
+/// it is called on each node before freeing the node. This is used
216
+/// to free the Record groups from each index_stream before freeing
217
+/// the index_stream itself.
218
+static void
219
+index_tree_end(index_tree *tree, lzma_allocator *allocator,
220
+       void (*free_func)(void *node, lzma_allocator *allocator))
221
+{
222
+   if (tree->root != NULL)
223
+       index_tree_node_end(tree->root, allocator, free_func);
224
+
225
+   return;
226
+}
227
+
228
+
229
+/// Add a new node to the tree. node->uncompressed_base and
230
+/// node->compressed_base must have been set by the caller already.
231
+static void
232
+index_tree_append(index_tree *tree, index_tree_node *node)
233
+{
234
+   node->parent = tree->rightmost;
235
+   node->left = NULL;
236
+   node->right = NULL;
237
+
238
+   ++tree->count;
239
+
240
+   // Handle the special case of adding the first node.
241
+   if (tree->root == NULL) {
242
+       tree->root = node;
243
+       tree->leftmost = node;
244
+       tree->rightmost = node;
245
+       return;
246
+   }
247
+
248
+   // The tree is always filled sequentially.
249
+   assert(tree->rightmost->uncompressed_base <= node->uncompressed_base);
250
+   assert(tree->rightmost->compressed_base < node->compressed_base);
251
+
252
+   // Add the new node after the rightmost node. It's the correct
253
+   // place due to the reason above.
254
+   tree->rightmost->right = node;
255
+   tree->rightmost = node;
256
+
257
+   // Balance the AVL-tree if needed. We don't need to keep the balance
258
+   // factors in nodes, because we always fill the tree sequentially,
259
+   // and thus know the state of the tree just by looking at the node
260
+   // count. From the node count we can calculate how many steps to go
261
+   // up in the tree to find the rotation root.
262
+   uint32_t up = tree->count ^ (UINT32_C(1) << bsr32(tree->count));
263
+   if (up != 0) {
264
+       // Locate the root node for the rotation.
265
+       up = ctz32(tree->count) + 2;
266
+       do {
267
+           node = node->parent;
268
+       } while (--up > 0);
269
+
270
+       // Rotate left using node as the rotation root.
271
+       index_tree_node *pivot = node->right;
272
+
273
+       if (node->parent == NULL) {
274
+           tree->root = pivot;
275
+       } else {
276
+           assert(node->parent->right == node);
277
+           node->parent->right = pivot;
278
+       }
279
+
280
+       pivot->parent = node->parent;
281
+
282
+       node->right = pivot->left;
283
+       if (node->right != NULL)
284
+           node->right->parent = node;
285
+
286
+       pivot->left = node;
287
+       node->parent = pivot;
288
+   }
289
+
290
+   return;
291
+}
292
+
293
+
294
+/// Get the next node in the tree. Return NULL if there are no more nodes.
295
+static void *
296
+index_tree_next(const index_tree_node *node)
297
+{
298
+   if (node->right != NULL) {
299
+       node = node->right;
300
+       while (node->left != NULL)
301
+           node = node->left;
302
+
303
+       return (void *)(node);
304
+   }
305
+
306
+   while (node->parent != NULL && node->parent->right == node)
307
+       node = node->parent;
308
+
309
+   return (void *)(node->parent);
310
+}
311
+
312
+
313
+/// Locate a node that contains the given uncompressed offset. It is
314
+/// caller's job to check that target is not bigger than the uncompressed
315
+/// size of the tree (the last node would be returned in that case still).
316
+static void *
317
+index_tree_locate(const index_tree *tree, lzma_vli target)
318
+{
319
+   const index_tree_node *result = NULL;
320
+   const index_tree_node *node = tree->root;
321
+
322
+   assert(tree->leftmost == NULL
323
+           || tree->leftmost->uncompressed_base == 0);
324
+
325
+   // Consecutive nodes may have the same uncompressed_base.
326
+   // We must pick the rightmost one.
327
+   while (node != NULL) {
328
+       if (node->uncompressed_base > target) {
329
+           node = node->left;
330
+       } else {
331
+           result = node;
332
+           node = node->right;
333
+       }
334
+   }
335
+
336
+   return (void *)(result);
337
+}
338
+
339
+
340
+/// Allocate and initialize a new Stream using the given base offsets.
341
+static index_stream *
342
+index_stream_init(lzma_vli compressed_base, lzma_vli uncompressed_base,
343
+       lzma_vli stream_number, lzma_vli block_number_base,
344
+       lzma_allocator *allocator)
345
+{
346
+   index_stream *s = lzma_alloc(sizeof(index_stream), allocator);
347
+   if (s == NULL)
348
+       return NULL;
349
+
350
+   s->node.uncompressed_base = uncompressed_base;
351
+   s->node.compressed_base = compressed_base;
352
+   s->node.parent = NULL;
353
+   s->node.left = NULL;
354
+   s->node.right = NULL;
355
+
356
+   s->number = stream_number;
357
+   s->block_number_base = block_number_base;
358
+
359
+   index_tree_init(&s->groups);
360
+
361
+   s->record_count = 0;
362
+   s->index_list_size = 0;
363
+   s->stream_flags.version = UINT32_MAX;
364
+   s->stream_padding = 0;
365
+
366
+   return s;
367
+}
368
+
369
+
370
+/// Free the memory allocated for a Stream and its Record groups.
371
+static void
372
+index_stream_end(void *node, lzma_allocator *allocator)
373
+{
374
+   index_stream *s = node;
375
+   index_tree_end(&s->groups, allocator, NULL);
376
+   return;
377
+}
378
+
379
+
380
+static lzma_index *
381
+index_init_plain(lzma_allocator *allocator)
382
+{
383
+   lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator);
384
+   if (i != NULL) {
385
+       index_tree_init(&i->streams);
386
+       i->uncompressed_size = 0;
387
+       i->total_size = 0;
388
+       i->record_count = 0;
389
+       i->index_list_size = 0;
390
+       i->prealloc = INDEX_GROUP_SIZE;
391
+       i->checks = 0;
392
+   }
393
+
394
+   return i;
395
+}
396
+
397
+
398
+extern LZMA_API(lzma_index *)
399
+lzma_index_init(lzma_allocator *allocator)
400
+{
401
+   lzma_index *i = index_init_plain(allocator);
402
+   if (i == NULL)
403
+       return NULL;
404
+
405
+   index_stream *s = index_stream_init(0, 0, 1, 0, allocator);
406
+   if (s == NULL) {
407
+       lzma_free(i, allocator);
408
+       return NULL;
409
+   }
410
+
411
+   index_tree_append(&i->streams, &s->node);
412
+
413
+   return i;
414
+}
415
+
416
+
417
+extern LZMA_API(void)
418
+lzma_index_end(lzma_index *i, lzma_allocator *allocator)
419
+{
420
+   // NOTE: If you modify this function, check also the bottom
421
+   // of lzma_index_cat().
422
+   if (i != NULL) {
423
+       index_tree_end(&i->streams, allocator, &index_stream_end);
424
+       lzma_free(i, allocator);
425
+   }
426
+
427
+   return;
428
+}
429
+
430
+
431
+extern void
432
+lzma_index_prealloc(lzma_index *i, lzma_vli records)
433
+{
434
+   if (records > PREALLOC_MAX)
435
+       records = PREALLOC_MAX;
436
+
437
+   i->prealloc = (size_t)(records);
438
+   return;
439
+}
440
+
441
+
442
+extern LZMA_API(uint64_t)
443
+lzma_index_memusage(lzma_vli streams, lzma_vli blocks)
444
+{
445
+   // This calculates an upper bound that is only a little bit
446
+   // bigger than the exact maximum memory usage with the given
447
+   // parameters.
448
+
449
+   // Typical malloc() overhead is 2 * sizeof(void *) but we take
450
+   // a little bit extra just in case. Using LZMA_MEMUSAGE_BASE
451
+   // instead would give too inaccurate estimate.
452
+   const size_t alloc_overhead = 4 * sizeof(void *);
453
+
454
+   // Amount of memory needed for each Stream base structures.
455
+   // We assume that every Stream has at least one Block and
456
+   // thus at least one group.
457
+   const size_t stream_base = sizeof(index_stream)
458
+           + sizeof(index_group) + 2 * alloc_overhead;
459
+
460
+   // Amount of memory needed per group.
461
+   const size_t group_base = sizeof(index_group)
462
+           + INDEX_GROUP_SIZE * sizeof(index_record)
463
+           + alloc_overhead;
464
+
465
+   // Number of groups. There may actually be more, but that overhead
466
+   // has been taken into account in stream_base already.
467
+   const lzma_vli groups
468
+           = (blocks + INDEX_GROUP_SIZE - 1) / INDEX_GROUP_SIZE;
469
+
470
+   // Memory used by index_stream and index_group structures.
471
+   const uint64_t streams_mem = streams * stream_base;
472
+   const uint64_t groups_mem = groups * group_base;
473
+
474
+   // Memory used by the base structure.
475
+   const uint64_t index_base = sizeof(lzma_index) + alloc_overhead;
476
+
477
+   // Validate the arguments and catch integer overflows.
478
+   // Maximum number of Streams is "only" UINT32_MAX, because
479
+   // that limit is used by the tree containing the Streams.
480
+   const uint64_t limit = UINT64_MAX - index_base;
481
+   if (streams == 0 || streams > UINT32_MAX || blocks > LZMA_VLI_MAX
482
+           || streams > limit / stream_base
483
+           || groups > limit / group_base
484
+           || limit - streams_mem < groups_mem)
485
+       return UINT64_MAX;
486
+
487
+   return index_base + streams_mem + groups_mem;
488
+}
489
+
490
+
491
+extern LZMA_API(uint64_t)
492
+lzma_index_memused(const lzma_index *i)
493
+{
494
+   return lzma_index_memusage(i->streams.count, i->record_count);
495
+}
496
+
497
+
498
+extern LZMA_API(lzma_vli)
499
+lzma_index_block_count(const lzma_index *i)
500
+{
501
+   return i->record_count;
502
+}
503
+
504
+
505
+extern LZMA_API(lzma_vli)
506
+lzma_index_stream_count(const lzma_index *i)
507
+{
508
+   return i->streams.count;
509
+}
510
+
511
+
512
+extern LZMA_API(lzma_vli)
513
+lzma_index_size(const lzma_index *i)
514
+{
515
+   return index_size(i->record_count, i->index_list_size);
516
+}
517
+
518
+
519
+extern LZMA_API(lzma_vli)
520
+lzma_index_total_size(const lzma_index *i)
521
+{
522
+   return i->total_size;
523
+}
524
+
525
+
526
+extern LZMA_API(lzma_vli)
527
+lzma_index_stream_size(const lzma_index *i)
528
+{
529
+   // Stream Header + Blocks + Index + Stream Footer
530
+   return LZMA_STREAM_HEADER_SIZE + i->total_size
531
+           + index_size(i->record_count, i->index_list_size)
532
+           + LZMA_STREAM_HEADER_SIZE;
533
+}
534
+
535
+
536
+static lzma_vli
537
+index_file_size(lzma_vli compressed_base, lzma_vli unpadded_sum,
538
+       lzma_vli record_count, lzma_vli index_list_size,
539
+       lzma_vli stream_padding)
540
+{
541
+   // Earlier Streams and Stream Paddings + Stream Header
542
+   // + Blocks + Index + Stream Footer + Stream Padding
543
+   //
544
+   // This might go over LZMA_VLI_MAX due to too big unpadded_sum
545
+   // when this function is used in lzma_index_append().
546
+   lzma_vli file_size = compressed_base + 2 * LZMA_STREAM_HEADER_SIZE
547
+           + stream_padding + vli_ceil4(unpadded_sum);
548
+   if (file_size > LZMA_VLI_MAX)
549
+       return LZMA_VLI_UNKNOWN;
550
+
551
+   // The same applies here.
552
+   file_size += index_size(record_count, index_list_size);
553
+   if (file_size > LZMA_VLI_MAX)
554
+       return LZMA_VLI_UNKNOWN;
555
+
556
+   return file_size;
557
+}
558
+
559
+
560
+extern LZMA_API(lzma_vli)
561
+lzma_index_file_size(const lzma_index *i)
562
+{
563
+   const index_stream *s = (const index_stream *)(i->streams.rightmost);
564
+   const index_group *g = (const index_group *)(s->groups.rightmost);
565
+   return index_file_size(s->node.compressed_base,
566
+           g == NULL ? 0 : g->records[g->last].unpadded_sum,
567
+           s->record_count, s->index_list_size,
568
+           s->stream_padding);
569
+}
570
+
571
+
572
+extern LZMA_API(lzma_vli)
573
+lzma_index_uncompressed_size(const lzma_index *i)
574
+{
575
+   return i->uncompressed_size;
576
+}
577
+
578
+
579
+extern LZMA_API(uint32_t)
580
+lzma_index_checks(const lzma_index *i)
581
+{
582
+   uint32_t checks = i->checks;
583
+
584
+   // Get the type of the Check of the last Stream too.
585
+   const index_stream *s = (const index_stream *)(i->streams.rightmost);
586
+   if (s->stream_flags.version != UINT32_MAX)
587
+       checks |= UINT32_C(1) << s->stream_flags.check;
588
+
589
+   return checks;
590
+}
591
+
592
+
593
+extern uint32_t
594
+lzma_index_padding_size(const lzma_index *i)
595
+{
596
+   return (LZMA_VLI_C(4) - index_size_unpadded(
597
+           i->record_count, i->index_list_size)) & 3;
598
+}
599
+
600
+
601
+extern LZMA_API(lzma_ret)
602
+lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags)
603
+{
604
+   if (i == NULL || stream_flags == NULL)
605
+       return LZMA_PROG_ERROR;
606
+
607
+   // Validate the Stream Flags.
608
+   return_if_error(lzma_stream_flags_compare(
609
+           stream_flags, stream_flags));
610
+
611
+   index_stream *s = (index_stream *)(i->streams.rightmost);
612
+   s->stream_flags = *stream_flags;
613
+
614
+   return LZMA_OK;
615
+}
616
+
617
+
618
+extern LZMA_API(lzma_ret)
619
+lzma_index_stream_padding(lzma_index *i, lzma_vli stream_padding)
620
+{
621
+   if (i == NULL || stream_padding > LZMA_VLI_MAX
622
+           || (stream_padding & 3) != 0)
623
+       return LZMA_PROG_ERROR;
624
+
625
+   index_stream *s = (index_stream *)(i->streams.rightmost);
626
+
627
+   // Check that the new value won't make the file grow too big.
628
+   const lzma_vli old_stream_padding = s->stream_padding;
629
+   s->stream_padding = 0;
630
+   if (lzma_index_file_size(i) + stream_padding > LZMA_VLI_MAX) {
631
+       s->stream_padding = old_stream_padding;
632
+       return LZMA_DATA_ERROR;
633
+   }
634
+
635
+   s->stream_padding = stream_padding;
636
+   return LZMA_OK;
637
+}
638
+
639
+
640
+extern LZMA_API(lzma_ret)
641
+lzma_index_append(lzma_index *i, lzma_allocator *allocator,
642
+       lzma_vli unpadded_size, lzma_vli uncompressed_size)
643
+{
644
+   // Validate.
645
+   if (i == NULL || unpadded_size < UNPADDED_SIZE_MIN
646
+           || unpadded_size > UNPADDED_SIZE_MAX
647
+           || uncompressed_size > LZMA_VLI_MAX)
648
+       return LZMA_PROG_ERROR;
649
+
650
+   index_stream *s = (index_stream *)(i->streams.rightmost);
651
+   index_group *g = (index_group *)(s->groups.rightmost);
652
+
653
+   const lzma_vli compressed_base = g == NULL ? 0
654
+           : vli_ceil4(g->records[g->last].unpadded_sum);
655
+   const lzma_vli uncompressed_base = g == NULL ? 0
656
+           : g->records[g->last].uncompressed_sum;
657
+   const uint32_t index_list_size_add = lzma_vli_size(unpadded_size)
658
+           + lzma_vli_size(uncompressed_size);
659
+
660
+   // Check that the file size will stay within limits.
661
+   if (index_file_size(s->node.compressed_base,
662
+           compressed_base + unpadded_size, s->record_count + 1,
663
+           s->index_list_size + index_list_size_add,
664
+           s->stream_padding) == LZMA_VLI_UNKNOWN)
665
+       return LZMA_DATA_ERROR;
666
+
667
+   // The size of the Index field must not exceed the maximum value
668
+   // that can be stored in the Backward Size field.
669
+   if (index_size(i->record_count + 1,
670
+           i->index_list_size + index_list_size_add)
671
+           > LZMA_BACKWARD_SIZE_MAX)
672
+       return LZMA_DATA_ERROR;
673
+
674
+   if (g != NULL && g->last + 1 < g->allocated) {
675
+       // There is space in the last group at least for one Record.
676
+       ++g->last;
677
+   } else {
678
+       // We need to allocate a new group.
679
+       g = lzma_alloc(sizeof(index_group)
680
+               + i->prealloc * sizeof(index_record),
681
+               allocator);
682
+       if (g == NULL)
683
+           return LZMA_MEM_ERROR;
684
+
685
+       g->last = 0;
686
+       g->allocated = i->prealloc;
687
+
688
+       // Reset prealloc so that if the application happens to
689
+       // add new Records, the allocation size will be sane.
690
+       i->prealloc = INDEX_GROUP_SIZE;
691
+
692
+       // Set the start offsets of this group.
693
+       g->node.uncompressed_base = uncompressed_base;
694
+       g->node.compressed_base = compressed_base;
695
+       g->number_base = s->record_count + 1;
696
+
697
+       // Add the new group to the Stream.
698
+       index_tree_append(&s->groups, &g->node);
699
+   }
700
+
701
+   // Add the new Record to the group.
702
+   g->records[g->last].uncompressed_sum
703
+           = uncompressed_base + uncompressed_size;
704
+   g->records[g->last].unpadded_sum
705
+           = compressed_base + unpadded_size;
706
+
707
+   // Update the totals.
708
+   ++s->record_count;
709
+   s->index_list_size += index_list_size_add;
710
+
711
+   i->total_size += vli_ceil4(unpadded_size);
712
+   i->uncompressed_size += uncompressed_size;
713
+   ++i->record_count;
714
+   i->index_list_size += index_list_size_add;
715
+
716
+   return LZMA_OK;
717
+}
718
+
719
+
720
+/// Structure to pass info to index_cat_helper()
721
+typedef struct {
722
+   /// Uncompressed size of the destination
723
+   lzma_vli uncompressed_size;
724
+
725
+   /// Compressed file size of the destination
726
+   lzma_vli file_size;
727
+
728
+   /// Same as above but for Block numbers
729
+   lzma_vli block_number_add;
730
+
731
+   /// Number of Streams that were in the destination index before we
732
+   /// started appending new Streams from the source index. This is
733
+   /// used to fix the Stream numbering.
734
+   uint32_t stream_number_add;
735
+
736
+   /// Destination index' Stream tree
737
+   index_tree *streams;
738
+
739
+} index_cat_info;
740
+
741
+
742
+/// Add the Stream nodes from the source index to dest using recursion.
743
+/// Simplest iterative traversal of the source tree wouldn't work, because
744
+/// we update the pointers in nodes when moving them to the destination tree.
745
+static void
746
+index_cat_helper(const index_cat_info *info, index_stream *this)
747
+{
748
+   index_stream *left = (index_stream *)(this->node.left);
749
+   index_stream *right = (index_stream *)(this->node.right);
750
+
751
+   if (left != NULL)
752
+       index_cat_helper(info, left);
753
+
754
+   this->node.uncompressed_base += info->uncompressed_size;
755
+   this->node.compressed_base += info->file_size;
756
+   this->number += info->stream_number_add;
757
+   this->block_number_base += info->block_number_add;
758
+   index_tree_append(info->streams, &this->node);
759
+
760
+   if (right != NULL)
761
+       index_cat_helper(info, right);
762
+
763
+   return;
764
+}
765
+
766
+
767
+extern LZMA_API(lzma_ret)
768
+lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src,
769
+       lzma_allocator *allocator)
770
+{
771
+   const lzma_vli dest_file_size = lzma_index_file_size(dest);
772
+
773
+   // Check that we don't exceed the file size limits.
774
+   if (dest_file_size + lzma_index_file_size(src) > LZMA_VLI_MAX
775
+           || dest->uncompressed_size + src->uncompressed_size
776
+               > LZMA_VLI_MAX)
777
+       return LZMA_DATA_ERROR;
778
+
779
+   // Check that the encoded size of the combined lzma_indexes stays
780
+   // within limits. In theory, this should be done only if we know
781
+   // that the user plans to actually combine the Streams and thus
782
+   // construct a single Index (probably rare). However, exceeding
783
+   // this limit is quite theoretical, so we do this check always
784
+   // to simplify things elsewhere.
785
+   {
786
+       const lzma_vli dest_size = index_size_unpadded(
787
+               dest->record_count, dest->index_list_size);
788
+       const lzma_vli src_size = index_size_unpadded(
789
+               src->record_count, src->index_list_size);
790
+       if (vli_ceil4(dest_size + src_size) > LZMA_BACKWARD_SIZE_MAX)
791
+           return LZMA_DATA_ERROR;
792
+   }
793
+
794
+   // Optimize the last group to minimize memory usage. Allocation has
795
+   // to be done before modifying dest or src.
796
+   {
797
+       index_stream *s = (index_stream *)(dest->streams.rightmost);
798
+       index_group *g = (index_group *)(s->groups.rightmost);
799
+       if (g != NULL && g->last + 1 < g->allocated) {
800
+           assert(g->node.left == NULL);
801
+           assert(g->node.right == NULL);
802
+
803
+           index_group *newg = lzma_alloc(sizeof(index_group)
804
+                   + (g->last + 1)
805
+                   * sizeof(index_record),
806
+                   allocator);
807
+           if (newg == NULL)
808
+               return LZMA_MEM_ERROR;
809
+
810
+           newg->node = g->node;
811
+           newg->allocated = g->last + 1;
812
+           newg->last = g->last;
813
+           newg->number_base = g->number_base;
814
+
815
+           memcpy(newg->records, g->records, newg->allocated
816
+                   * sizeof(index_record));
817
+
818
+           if (g->node.parent != NULL) {
819
+               assert(g->node.parent->right == &g->node);
820
+               g->node.parent->right = &newg->node;
821
+           }
822
+
823
+           if (s->groups.leftmost == &g->node) {
824
+               assert(s->groups.root == &g->node);
825
+               s->groups.leftmost = &newg->node;
826
+               s->groups.root = &newg->node;
827
+           }
828
+
829
+           if (s->groups.rightmost == &g->node)
830
+               s->groups.rightmost = &newg->node;
831
+
832
+           lzma_free(g, allocator);
833
+       }
834
+   }
835
+
836
+   // Add all the Streams from src to dest. Update the base offsets
837
+   // of each Stream from src.
838
+   const index_cat_info info = {
839
+       .uncompressed_size = dest->uncompressed_size,
840
+       .file_size = dest_file_size,
841
+       .stream_number_add = dest->streams.count,
842
+       .block_number_add = dest->record_count,
843
+       .streams = &dest->streams,
844
+   };
845
+   index_cat_helper(&info, (index_stream *)(src->streams.root));
846
+
847
+   // Update info about all the combined Streams.
848
+   dest->uncompressed_size += src->uncompressed_size;
849
+   dest->total_size += src->total_size;
850
+   dest->record_count += src->record_count;
851
+   dest->index_list_size += src->index_list_size;
852
+   dest->checks = lzma_index_checks(dest) | src->checks;
853
+
854
+   // There's nothing else left in src than the base structure.
855
+   lzma_free(src, allocator);
856
+
857
+   return LZMA_OK;
858
+}
859
+
860
+
861
+/// Duplicate an index_stream.
862
+static index_stream *
863
+index_dup_stream(const index_stream *src, lzma_allocator *allocator)
864
+{
865
+   // Catch a somewhat theoretical integer overflow.
866
+   if (src->record_count > PREALLOC_MAX)
867
+       return NULL;
868
+
869
+   // Allocate and initialize a new Stream.
870
+   index_stream *dest = index_stream_init(src->node.compressed_base,
871
+           src->node.uncompressed_base, src->number,
872
+           src->block_number_base, allocator);
873
+
874
+   // Return immediately if allocation failed or if there are
875
+   // no groups to duplicate.
876
+   if (dest == NULL || src->groups.leftmost == NULL)
877
+       return dest;
878
+
879
+   // Copy the overall information.
880
+   dest->record_count = src->record_count;
881
+   dest->index_list_size = src->index_list_size;
882
+   dest->stream_flags = src->stream_flags;
883
+   dest->stream_padding = src->stream_padding;
884
+
885
+   // Allocate memory for the Records. We put all the Records into
886
+   // a single group. It's simplest and also tends to make
887
+   // lzma_index_locate() a little bit faster with very big Indexes.
888
+   index_group *destg = lzma_alloc(sizeof(index_group)
889
+           + src->record_count * sizeof(index_record),
890
+           allocator);
891
+   if (destg == NULL) {
892
+       index_stream_end(dest, allocator);
893
+       return NULL;
894
+   }
895
+
896
+   // Initialize destg.
897
+   destg->node.uncompressed_base = 0;
898
+   destg->node.compressed_base = 0;
899
+   destg->number_base = 1;
900
+   destg->allocated = src->record_count;
901
+   destg->last = src->record_count - 1;
902
+
903
+   // Go through all the groups in src and copy the Records into destg.
904
+   const index_group *srcg = (const index_group *)(src->groups.leftmost);
905
+   size_t i = 0;
906
+   do {
907
+       memcpy(destg->records + i, srcg->records,
908
+               (srcg->last + 1) * sizeof(index_record));
909
+       i += srcg->last + 1;
910
+       srcg = index_tree_next(&srcg->node);
911
+   } while (srcg != NULL);
912
+
913
+   assert(i == destg->allocated);
914
+
915
+   // Add the group to the new Stream.
916
+   index_tree_append(&dest->groups, &destg->node);
917
+
918
+   return dest;
919
+}
920
+
921
+
922
+extern LZMA_API(lzma_index *)
923
+lzma_index_dup(const lzma_index *src, lzma_allocator *allocator)
924
+{
925
+   // Allocate the base structure (no initial Stream).
926
+   lzma_index *dest = index_init_plain(allocator);
927
+   if (dest == NULL)
928
+       return NULL;
929
+
930
+   // Copy the totals.
931
+   dest->uncompressed_size = src->uncompressed_size;
932
+   dest->total_size = src->total_size;
933
+   dest->record_count = src->record_count;
934
+   dest->index_list_size = src->index_list_size;
935
+
936
+   // Copy the Streams and the groups in them.
937
+   const index_stream *srcstream
938
+           = (const index_stream *)(src->streams.leftmost);
939
+   do {
940
+       index_stream *deststream = index_dup_stream(
941
+               srcstream, allocator);
942
+       if (deststream == NULL) {
943
+           lzma_index_end(dest, allocator);
944
+           return NULL;
945
+       }
946
+
947
+       index_tree_append(&dest->streams, &deststream->node);
948
+
949
+       srcstream = index_tree_next(&srcstream->node);
950
+   } while (srcstream != NULL);
951
+
952
+   return dest;
953
+}
954
+
955
+
956
+/// Indexing for lzma_index_iter.internal[]
957
+enum {
958
+   ITER_INDEX,
959
+   ITER_STREAM,
960
+   ITER_GROUP,
961
+   ITER_RECORD,
962
+   ITER_METHOD,
963
+};
964
+
965
+
966
+/// Values for lzma_index_iter.internal[ITER_METHOD].s
967
+enum {
968
+   ITER_METHOD_NORMAL,
969
+   ITER_METHOD_NEXT,
970
+   ITER_METHOD_LEFTMOST,
971
+};
972
+
973
+
974
+static void
975
+iter_set_info(lzma_index_iter *iter)
976
+{
977
+   const lzma_index *i = iter->internal[ITER_INDEX].p;
978
+   const index_stream *stream = iter->internal[ITER_STREAM].p;
979
+   const index_group *group = iter->internal[ITER_GROUP].p;
980
+   const size_t record = iter->internal[ITER_RECORD].s;
981
+
982
+   // lzma_index_iter.internal must not contain a pointer to the last
983
+   // group in the index, because that may be reallocated by
984
+   // lzma_index_cat().
985
+   if (group == NULL) {
986
+       // There are no groups.
987
+       assert(stream->groups.root == NULL);
988
+       iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST;
989
+
990
+   } else if (i->streams.rightmost != &stream->node
991
+           || stream->groups.rightmost != &group->node) {
992
+       // The group is not not the last group in the index.
993
+       iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL;
994
+
995
+   } else if (stream->groups.leftmost != &group->node) {
996
+       // The group isn't the only group in the Stream, thus we
997
+       // know that it must have a parent group i.e. it's not
998
+       // the root node.
999
+       assert(stream->groups.root != &group->node);
1000
+       assert(group->node.parent->right == &group->node);
1001
+       iter->internal[ITER_METHOD].s = ITER_METHOD_NEXT;
1002
+       iter->internal[ITER_GROUP].p = group->node.parent;
1003
+
1004
+   } else {
1005
+       // The Stream has only one group.
1006
+       assert(stream->groups.root == &group->node);
1007
+       assert(group->node.parent == NULL);
1008
+       iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST;
1009
+       iter->internal[ITER_GROUP].p = NULL;
1010
+   }
1011
+
1012
+   iter->stream.number = stream->number;
1013
+   iter->stream.block_count = stream->record_count;
1014
+   iter->stream.compressed_offset = stream->node.compressed_base;
1015
+   iter->stream.uncompressed_offset = stream->node.uncompressed_base;
1016
+
1017
+   // iter->stream.flags will be NULL if the Stream Flags haven't been
1018
+   // set with lzma_index_stream_flags().
1019
+   iter->stream.flags = stream->stream_flags.version == UINT32_MAX
1020
+           ? NULL : &stream->stream_flags;
1021
+   iter->stream.padding = stream->stream_padding;
1022
+
1023
+   if (stream->groups.rightmost == NULL) {
1024
+       // Stream has no Blocks.
1025
+       iter->stream.compressed_size = index_size(0, 0)
1026
+               + 2 * LZMA_STREAM_HEADER_SIZE;
1027
+       iter->stream.uncompressed_size = 0;
1028
+   } else {
1029
+       const index_group *g = (const index_group *)(
1030
+               stream->groups.rightmost);
1031
+
1032
+       // Stream Header + Stream Footer + Index + Blocks
1033
+       iter->stream.compressed_size = 2 * LZMA_STREAM_HEADER_SIZE
1034
+               + index_size(stream->record_count,
1035
+                   stream->index_list_size)
1036
+               + vli_ceil4(g->records[g->last].unpadded_sum);
1037
+       iter->stream.uncompressed_size
1038
+               = g->records[g->last].uncompressed_sum;
1039
+   }
1040
+
1041
+   if (group != NULL) {
1042
+       iter->block.number_in_stream = group->number_base + record;
1043
+       iter->block.number_in_file = iter->block.number_in_stream
1044
+               + stream->block_number_base;
1045
+
1046
+       iter->block.compressed_stream_offset
1047
+               = record == 0 ? group->node.compressed_base
1048
+               : vli_ceil4(group->records[
1049
+                   record - 1].unpadded_sum);
1050
+       iter->block.uncompressed_stream_offset
1051
+               = record == 0 ? group->node.uncompressed_base
1052
+               : group->records[record - 1].uncompressed_sum;
1053
+
1054
+       iter->block.uncompressed_size
1055
+               = group->records[record].uncompressed_sum
1056
+               - iter->block.uncompressed_stream_offset;
1057
+       iter->block.unpadded_size
1058
+               = group->records[record].unpadded_sum
1059
+               - iter->block.compressed_stream_offset;
1060
+       iter->block.total_size = vli_ceil4(iter->block.unpadded_size);
1061
+
1062
+       iter->block.compressed_stream_offset
1063
+               += LZMA_STREAM_HEADER_SIZE;
1064
+
1065
+       iter->block.compressed_file_offset
1066
+               = iter->block.compressed_stream_offset
1067
+               + iter->stream.compressed_offset;
1068
+       iter->block.uncompressed_file_offset
1069
+               = iter->block.uncompressed_stream_offset
1070
+               + iter->stream.uncompressed_offset;
1071
+   }
1072
+
1073
+   return;
1074
+}
1075
+
1076
+
1077
+extern LZMA_API(void)
1078
+lzma_index_iter_init(lzma_index_iter *iter, const lzma_index *i)
1079
+{
1080
+   iter->internal[ITER_INDEX].p = i;
1081
+   lzma_index_iter_rewind(iter);
1082
+   return;
1083
+}
1084
+
1085
+
1086
+extern LZMA_API(void)
1087
+lzma_index_iter_rewind(lzma_index_iter *iter)
1088
+{
1089
+   iter->internal[ITER_STREAM].p = NULL;
1090
+   iter->internal[ITER_GROUP].p = NULL;
1091
+   iter->internal[ITER_RECORD].s = 0;
1092
+   iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL;
1093
+   return;
1094
+}
1095
+
1096
+
1097
+extern LZMA_API(lzma_bool)
1098
+lzma_index_iter_next(lzma_index_iter *iter, lzma_index_iter_mode mode)
1099
+{
1100
+   // Catch unsupported mode values.
1101
+   if ((unsigned int)(mode) > LZMA_INDEX_ITER_NONEMPTY_BLOCK)
1102
+       return true;
1103
+
1104
+   const lzma_index *i = iter->internal[ITER_INDEX].p;
1105
+   const index_stream *stream = iter->internal[ITER_STREAM].p;
1106
+   const index_group *group = NULL;
1107
+   size_t record = iter->internal[ITER_RECORD].s;
1108
+
1109
+   // If we are being asked for the next Stream, leave group to NULL
1110
+   // so that the rest of the this function thinks that this Stream
1111
+   // has no groups and will thus go to the next Stream.
1112
+   if (mode != LZMA_INDEX_ITER_STREAM) {
1113
+       // Get the pointer to the current group. See iter_set_inf()
1114
+       // for explanation.
1115
+       switch (iter->internal[ITER_METHOD].s) {
1116
+       case ITER_METHOD_NORMAL:
1117
+           group = iter->internal[ITER_GROUP].p;
1118
+           break;
1119
+
1120
+       case ITER_METHOD_NEXT:
1121
+           group = index_tree_next(iter->internal[ITER_GROUP].p);
1122
+           break;
1123
+
1124
+       case ITER_METHOD_LEFTMOST:
1125
+           group = (const index_group *)(
1126
+                   stream->groups.leftmost);
1127
+           break;
1128
+       }
1129
+   }
1130
+
1131
+again:
1132
+   if (stream == NULL) {
1133
+       // We at the beginning of the lzma_index.
1134
+       // Locate the first Stream.
1135
+       stream = (const index_stream *)(i->streams.leftmost);
1136
+       if (mode >= LZMA_INDEX_ITER_BLOCK) {
1137
+           // Since we are being asked to return information
1138
+           // about the first a Block, skip Streams that have
1139
+           // no Blocks.
1140
+           while (stream->groups.leftmost == NULL) {
1141
+               stream = index_tree_next(&stream->node);
1142
+               if (stream == NULL)
1143
+                   return true;
1144
+           }
1145
+       }
1146
+
1147
+       // Start from the first Record in the Stream.
1148
+       group = (const index_group *)(stream->groups.leftmost);
1149
+       record = 0;
1150
+
1151
+   } else if (group != NULL && record < group->last) {
1152
+       // The next Record is in the same group.
1153
+       ++record;
1154
+
1155
+   } else {
1156
+       // This group has no more Records or this Stream has
1157
+       // no Blocks at all.
1158
+       record = 0;
1159
+
1160
+       // If group is not NULL, this Stream has at least one Block
1161
+       // and thus at least one group. Find the next group.
1162
+       if (group != NULL)
1163
+           group = index_tree_next(&group->node);
1164
+
1165
+       if (group == NULL) {
1166
+           // This Stream has no more Records. Find the next
1167
+           // Stream. If we are being asked to return information
1168
+           // about a Block, we skip empty Streams.
1169
+           do {
1170
+               stream = index_tree_next(&stream->node);
1171
+               if (stream == NULL)
1172
+                   return true;
1173
+           } while (mode >= LZMA_INDEX_ITER_BLOCK
1174
+                   && stream->groups.leftmost == NULL);
1175
+
1176
+           group = (const index_group *)(
1177
+                   stream->groups.leftmost);
1178
+       }
1179
+   }
1180
+
1181
+   if (mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) {
1182
+       // We need to look for the next Block again if this Block
1183
+       // is empty.
1184
+       if (record == 0) {
1185
+           if (group->node.uncompressed_base
1186
+                   == group->records[0].uncompressed_sum)
1187
+               goto again;
1188
+       } else if (group->records[record - 1].uncompressed_sum
1189
+               == group->records[record].uncompressed_sum) {
1190
+           goto again;
1191
+       }
1192
+   }
1193
+
1194
+   iter->internal[ITER_STREAM].p = stream;
1195
+   iter->internal[ITER_GROUP].p = group;
1196
+   iter->internal[ITER_RECORD].s = record;
1197
+
1198
+   iter_set_info(iter);
1199
+
1200
+   return false;
1201
+}
1202
+
1203
+
1204
+extern LZMA_API(lzma_bool)
1205
+lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)
1206
+{
1207
+   const lzma_index *i = iter->internal[ITER_INDEX].p;
1208
+
1209
+   // If the target is past the end of the file, return immediately.
1210
+   if (i->uncompressed_size <= target)
1211
+       return true;
1212
+
1213
+   // Locate the Stream containing the target offset.
1214
+   const index_stream *stream = index_tree_locate(&i->streams, target);
1215
+   assert(stream != NULL);
1216
+   target -= stream->node.uncompressed_base;
1217
+
1218
+   // Locate the group containing the target offset.
1219
+   const index_group *group = index_tree_locate(&stream->groups, target);
1220
+   assert(group != NULL);
1221
+
1222
+   // Use binary search to locate the exact Record. It is the first
1223
+   // Record whose uncompressed_sum is greater than target.
1224
+   // This is because we want the rightmost Record that fullfills the
1225
+   // search criterion. It is possible that there are empty Blocks;
1226
+   // we don't want to return them.
1227
+   size_t left = 0;
1228
+   size_t right = group->last;
1229
+
1230
+   while (left < right) {
1231
+       const size_t pos = left + (right - left) / 2;
1232
+       if (group->records[pos].uncompressed_sum <= target)
1233
+           left = pos + 1;
1234
+       else
1235
+           right = pos;
1236
+   }
1237
+
1238
+   iter->internal[ITER_STREAM].p = stream;
1239
+   iter->internal[ITER_GROUP].p = group;
1240
+   iter->internal[ITER_RECORD].s = left;
1241
+
1242
+   iter_set_info(iter);
1243
+
1244
+   return false;
1245
+}
1246
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/index.h Added
75
 
1
@@ -0,0 +1,73 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       index.h
5
+/// \brief      Handling of Index
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_INDEX_H
15
+#define LZMA_INDEX_H
16
+
17
+#include "common.h"
18
+
19
+
20
+/// Minimum Unpadded Size
21
+#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
22
+
23
+/// Maximum Unpadded Size
24
+#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
25
+
26
+
27
+/// Get the size of the Index Padding field. This is needed by Index encoder
28
+/// and decoder, but applications should have no use for this.
29
+extern uint32_t lzma_index_padding_size(const lzma_index *i);
30
+
31
+
32
+/// Set for how many Records to allocate memory the next time
33
+/// lzma_index_append() needs to allocate space for a new Record.
34
+/// This is used only by the Index decoder.
35
+extern void lzma_index_prealloc(lzma_index *i, lzma_vli records);
36
+
37
+
38
+/// Round the variable-length integer to the next multiple of four.
39
+static inline lzma_vli
40
+vli_ceil4(lzma_vli vli)
41
+{
42
+   assert(vli <= LZMA_VLI_MAX);
43
+   return (vli + 3) & ~LZMA_VLI_C(3);
44
+}
45
+
46
+
47
+/// Calculate the size of the Index field excluding Index Padding
48
+static inline lzma_vli
49
+index_size_unpadded(lzma_vli count, lzma_vli index_list_size)
50
+{
51
+   // Index Indicator + Number of Records + List of Records + CRC32
52
+   return 1 + lzma_vli_size(count) + index_list_size + 4;
53
+}
54
+
55
+
56
+/// Calculate the size of the Index field including Index Padding
57
+static inline lzma_vli
58
+index_size(lzma_vli count, lzma_vli index_list_size)
59
+{
60
+   return vli_ceil4(index_size_unpadded(count, index_list_size));
61
+}
62
+
63
+
64
+/// Calculate the total size of the Stream
65
+static inline lzma_vli
66
+index_stream_size(lzma_vli blocks_size,
67
+       lzma_vli count, lzma_vli index_list_size)
68
+{
69
+   return LZMA_STREAM_HEADER_SIZE + blocks_size
70
+           + index_size(count, index_list_size)
71
+           + LZMA_STREAM_HEADER_SIZE;
72
+}
73
+
74
+#endif
75
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/index_decoder.c Added
347
 
1
@@ -0,0 +1,345 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       index_decoder.c
5
+/// \brief      Decodes the Index field
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "index.h"
15
+#include "check.h"
16
+
17
+
18
+struct lzma_coder_s {
19
+   enum {
20
+       SEQ_INDICATOR,
21
+       SEQ_COUNT,
22
+       SEQ_MEMUSAGE,
23
+       SEQ_UNPADDED,
24
+       SEQ_UNCOMPRESSED,
25
+       SEQ_PADDING_INIT,
26
+       SEQ_PADDING,
27
+       SEQ_CRC32,
28
+   } sequence;
29
+
30
+   /// Memory usage limit
31
+   uint64_t memlimit;
32
+
33
+   /// Target Index
34
+   lzma_index *index;
35
+
36
+   /// Pointer give by the application, which is set after
37
+   /// successful decoding.
38
+   lzma_index **index_ptr;
39
+
40
+   /// Number of Records left to decode.
41
+   lzma_vli count;
42
+
43
+   /// The most recent Unpadded Size field
44
+   lzma_vli unpadded_size;
45
+
46
+   /// The most recent Uncompressed Size field
47
+   lzma_vli uncompressed_size;
48
+
49
+   /// Position in integers
50
+   size_t pos;
51
+
52
+   /// CRC32 of the List of Records field
53
+   uint32_t crc32;
54
+};
55
+
56
+
57
+static lzma_ret
58
+index_decode(lzma_coder *coder, lzma_allocator *allocator,
59
+       const uint8_t *restrict in, size_t *restrict in_pos,
60
+       size_t in_size,
61
+       uint8_t *restrict out lzma_attribute((__unused__)),
62
+       size_t *restrict out_pos lzma_attribute((__unused__)),
63
+       size_t out_size lzma_attribute((__unused__)),
64
+       lzma_action action lzma_attribute((__unused__)))
65
+{
66
+   // Similar optimization as in index_encoder.c
67
+   const size_t in_start = *in_pos;
68
+   lzma_ret ret = LZMA_OK;
69
+
70
+   while (*in_pos < in_size)
71
+   switch (coder->sequence) {
72
+   case SEQ_INDICATOR:
73
+       // Return LZMA_DATA_ERROR instead of e.g. LZMA_PROG_ERROR or
74
+       // LZMA_FORMAT_ERROR, because a typical usage case for Index
75
+       // decoder is when parsing the Stream backwards. If seeking
76
+       // backward from the Stream Footer gives us something that
77
+       // doesn't begin with Index Indicator, the file is considered
78
+       // corrupt, not "programming error" or "unrecognized file
79
+       // format". One could argue that the application should
80
+       // verify the Index Indicator before trying to decode the
81
+       // Index, but well, I suppose it is simpler this way.
82
+       if (in[(*in_pos)++] != 0x00)
83
+           return LZMA_DATA_ERROR;
84
+
85
+       coder->sequence = SEQ_COUNT;
86
+       break;
87
+
88
+   case SEQ_COUNT:
89
+       ret = lzma_vli_decode(&coder->count, &coder->pos,
90
+               in, in_pos, in_size);
91
+       if (ret != LZMA_STREAM_END)
92
+           goto out;
93
+
94
+       coder->pos = 0;
95
+       coder->sequence = SEQ_MEMUSAGE;
96
+
97
+   // Fall through
98
+
99
+   case SEQ_MEMUSAGE:
100
+       if (lzma_index_memusage(1, coder->count) > coder->memlimit) {
101
+           ret = LZMA_MEMLIMIT_ERROR;
102
+           goto out;
103
+       }
104
+
105
+       // Tell the Index handling code how many Records this
106
+       // Index has to allow it to allocate memory more efficiently.
107
+       lzma_index_prealloc(coder->index, coder->count);
108
+
109
+       ret = LZMA_OK;
110
+       coder->sequence = coder->count == 0
111
+               ? SEQ_PADDING_INIT : SEQ_UNPADDED;
112
+       break;
113
+
114
+   case SEQ_UNPADDED:
115
+   case SEQ_UNCOMPRESSED: {
116
+       lzma_vli *size = coder->sequence == SEQ_UNPADDED
117
+               ? &coder->unpadded_size
118
+               : &coder->uncompressed_size;
119
+
120
+       ret = lzma_vli_decode(size, &coder->pos,
121
+               in, in_pos, in_size);
122
+       if (ret != LZMA_STREAM_END)
123
+           goto out;
124
+
125
+       ret = LZMA_OK;
126
+       coder->pos = 0;
127
+
128
+       if (coder->sequence == SEQ_UNPADDED) {
129
+           // Validate that encoded Unpadded Size isn't too small
130
+           // or too big.
131
+           if (coder->unpadded_size < UNPADDED_SIZE_MIN
132
+                   || coder->unpadded_size
133
+                       > UNPADDED_SIZE_MAX)
134
+               return LZMA_DATA_ERROR;
135
+
136
+           coder->sequence = SEQ_UNCOMPRESSED;
137
+       } else {
138
+           // Add the decoded Record to the Index.
139
+           return_if_error(lzma_index_append(
140
+                   coder->index, allocator,
141
+                   coder->unpadded_size,
142
+                   coder->uncompressed_size));
143
+
144
+           // Check if this was the last Record.
145
+           coder->sequence = --coder->count == 0
146
+                   ? SEQ_PADDING_INIT
147
+                   : SEQ_UNPADDED;
148
+       }
149
+
150
+       break;
151
+   }
152
+
153
+   case SEQ_PADDING_INIT:
154
+       coder->pos = lzma_index_padding_size(coder->index);
155
+       coder->sequence = SEQ_PADDING;
156
+
157
+   // Fall through
158
+
159
+   case SEQ_PADDING:
160
+       if (coder->pos > 0) {
161
+           --coder->pos;
162
+           if (in[(*in_pos)++] != 0x00)
163
+               return LZMA_DATA_ERROR;
164
+
165
+           break;
166
+       }
167
+
168
+       // Finish the CRC32 calculation.
169
+       coder->crc32 = lzma_crc32(in + in_start,
170
+               *in_pos - in_start, coder->crc32);
171
+
172
+       coder->sequence = SEQ_CRC32;
173
+
174
+   // Fall through
175
+
176
+   case SEQ_CRC32:
177
+       do {
178
+           if (*in_pos == in_size)
179
+               return LZMA_OK;
180
+
181
+           if (((coder->crc32 >> (coder->pos * 8)) & 0xFF)
182
+                   != in[(*in_pos)++])
183
+               return LZMA_DATA_ERROR;
184
+
185
+       } while (++coder->pos < 4);
186
+
187
+       // Decoding was successful, now we can let the application
188
+       // see the decoded Index.
189
+       *coder->index_ptr = coder->index;
190
+
191
+       // Make index NULL so we don't free it unintentionally.
192
+       coder->index = NULL;
193
+
194
+       return LZMA_STREAM_END;
195
+
196
+   default:
197
+       assert(0);
198
+       return LZMA_PROG_ERROR;
199
+   }
200
+
201
+out:
202
+   // Update the CRC32,
203
+   coder->crc32 = lzma_crc32(in + in_start,
204
+           *in_pos - in_start, coder->crc32);
205
+
206
+   return ret;
207
+}
208
+
209
+
210
+static void
211
+index_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
212
+{
213
+   lzma_index_end(coder->index, allocator);
214
+   lzma_free(coder, allocator);
215
+   return;
216
+}
217
+
218
+
219
+static lzma_ret
220
+index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
221
+       uint64_t *old_memlimit, uint64_t new_memlimit)
222
+{
223
+   *memusage = lzma_index_memusage(1, coder->count);
224
+   *old_memlimit = coder->memlimit;
225
+
226
+   if (new_memlimit != 0) {
227
+       if (new_memlimit < *memusage)
228
+           return LZMA_MEMLIMIT_ERROR;
229
+
230
+       coder->memlimit = new_memlimit;
231
+   }
232
+
233
+   return LZMA_OK;
234
+}
235
+
236
+
237
+static lzma_ret
238
+index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator,
239
+       lzma_index **i, uint64_t memlimit)
240
+{
241
+   // Remember the pointer given by the application. We will set it
242
+   // to point to the decoded Index only if decoding is successful.
243
+   // Before that, keep it NULL so that applications can always safely
244
+   // pass it to lzma_index_end() no matter did decoding succeed or not.
245
+   coder->index_ptr = i;
246
+   *i = NULL;
247
+
248
+   // We always allocate a new lzma_index.
249
+   coder->index = lzma_index_init(allocator);
250
+   if (coder->index == NULL)
251
+       return LZMA_MEM_ERROR;
252
+
253
+   // Initialize the rest.
254
+   coder->sequence = SEQ_INDICATOR;
255
+   coder->memlimit = memlimit;
256
+   coder->count = 0; // Needs to be initialized due to _memconfig().
257
+   coder->pos = 0;
258
+   coder->crc32 = 0;
259
+
260
+   return LZMA_OK;
261
+}
262
+
263
+
264
+static lzma_ret
265
+index_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
266
+       lzma_index **i, uint64_t memlimit)
267
+{
268
+   lzma_next_coder_init(&index_decoder_init, next, allocator);
269
+
270
+   if (i == NULL || memlimit == 0)
271
+       return LZMA_PROG_ERROR;
272
+
273
+   if (next->coder == NULL) {
274
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
275
+       if (next->coder == NULL)
276
+           return LZMA_MEM_ERROR;
277
+
278
+       next->code = &index_decode;
279
+       next->end = &index_decoder_end;
280
+       next->memconfig = &index_decoder_memconfig;
281
+       next->coder->index = NULL;
282
+   } else {
283
+       lzma_index_end(next->coder->index, allocator);
284
+   }
285
+
286
+   return index_decoder_reset(next->coder, allocator, i, memlimit);
287
+}
288
+
289
+
290
+extern LZMA_API(lzma_ret)
291
+lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit)
292
+{
293
+   lzma_next_strm_init(index_decoder_init, strm, i, memlimit);
294
+
295
+   strm->internal->supported_actions[LZMA_RUN] = true;
296
+   strm->internal->supported_actions[LZMA_FINISH] = true;
297
+
298
+   return LZMA_OK;
299
+}
300
+
301
+
302
+extern LZMA_API(lzma_ret)
303
+lzma_index_buffer_decode(
304
+       lzma_index **i, uint64_t *memlimit, lzma_allocator *allocator,
305
+       const uint8_t *in, size_t *in_pos, size_t in_size)
306
+{
307
+   // Sanity checks
308
+   if (i == NULL || memlimit == NULL
309
+           || in == NULL || in_pos == NULL || *in_pos > in_size)
310
+       return LZMA_PROG_ERROR;
311
+
312
+   // Initialize the decoder.
313
+   lzma_coder coder;
314
+   return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit));
315
+
316
+   // Store the input start position so that we can restore it in case
317
+   // of an error.
318
+   const size_t in_start = *in_pos;
319
+
320
+   // Do the actual decoding.
321
+   lzma_ret ret = index_decode(&coder, allocator, in, in_pos, in_size,
322
+           NULL, NULL, 0, LZMA_RUN);
323
+
324
+   if (ret == LZMA_STREAM_END) {
325
+       ret = LZMA_OK;
326
+   } else {
327
+       // Something went wrong, free the Index structure and restore
328
+       // the input position.
329
+       lzma_index_end(coder.index, allocator);
330
+       *in_pos = in_start;
331
+
332
+       if (ret == LZMA_OK) {
333
+           // The input is truncated or otherwise corrupt.
334
+           // Use LZMA_DATA_ERROR instead of LZMA_BUF_ERROR
335
+           // like lzma_vli_decode() does in single-call mode.
336
+           ret = LZMA_DATA_ERROR;
337
+
338
+       } else if (ret == LZMA_MEMLIMIT_ERROR) {
339
+           // Tell the caller how much memory would have
340
+           // been needed.
341
+           *memlimit = lzma_index_memusage(1, coder.count);
342
+       }
343
+   }
344
+
345
+   return ret;
346
+}
347
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/index_encoder.c Added
256
 
1
@@ -0,0 +1,254 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       index_encoder.c
5
+/// \brief      Encodes the Index field
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "index_encoder.h"
15
+#include "index.h"
16
+#include "check.h"
17
+
18
+
19
+struct lzma_coder_s {
20
+   enum {
21
+       SEQ_INDICATOR,
22
+       SEQ_COUNT,
23
+       SEQ_UNPADDED,
24
+       SEQ_UNCOMPRESSED,
25
+       SEQ_NEXT,
26
+       SEQ_PADDING,
27
+       SEQ_CRC32,
28
+   } sequence;
29
+
30
+   /// Index being encoded
31
+   const lzma_index *index;
32
+
33
+   /// Iterator for the Index being encoded
34
+   lzma_index_iter iter;
35
+
36
+   /// Position in integers
37
+   size_t pos;
38
+
39
+   /// CRC32 of the List of Records field
40
+   uint32_t crc32;
41
+};
42
+
43
+
44
+static lzma_ret
45
+index_encode(lzma_coder *coder,
46
+       lzma_allocator *allocator lzma_attribute((__unused__)),
47
+       const uint8_t *restrict in lzma_attribute((__unused__)),
48
+       size_t *restrict in_pos lzma_attribute((__unused__)),
49
+       size_t in_size lzma_attribute((__unused__)),
50
+       uint8_t *restrict out, size_t *restrict out_pos,
51
+       size_t out_size,
52
+       lzma_action action lzma_attribute((__unused__)))
53
+{
54
+   // Position where to start calculating CRC32. The idea is that we
55
+   // need to call lzma_crc32() only once per call to index_encode().
56
+   const size_t out_start = *out_pos;
57
+
58
+   // Return value to use if we return at the end of this function.
59
+   // We use "goto out" to jump out of the while-switch construct
60
+   // instead of returning directly, because that way we don't need
61
+   // to copypaste the lzma_crc32() call to many places.
62
+   lzma_ret ret = LZMA_OK;
63
+
64
+   while (*out_pos < out_size)
65
+   switch (coder->sequence) {
66
+   case SEQ_INDICATOR:
67
+       out[*out_pos] = 0x00;
68
+       ++*out_pos;
69
+       coder->sequence = SEQ_COUNT;
70
+       break;
71
+
72
+   case SEQ_COUNT: {
73
+       const lzma_vli count = lzma_index_block_count(coder->index);
74
+       ret = lzma_vli_encode(count, &coder->pos,
75
+               out, out_pos, out_size);
76
+       if (ret != LZMA_STREAM_END)
77
+           goto out;
78
+
79
+       ret = LZMA_OK;
80
+       coder->pos = 0;
81
+       coder->sequence = SEQ_NEXT;
82
+       break;
83
+   }
84
+
85
+   case SEQ_NEXT:
86
+       if (lzma_index_iter_next(
87
+               &coder->iter, LZMA_INDEX_ITER_BLOCK)) {
88
+           // Get the size of the Index Padding field.
89
+           coder->pos = lzma_index_padding_size(coder->index);
90
+           assert(coder->pos <= 3);
91
+           coder->sequence = SEQ_PADDING;
92
+           break;
93
+       }
94
+
95
+       coder->sequence = SEQ_UNPADDED;
96
+
97
+   // Fall through
98
+
99
+   case SEQ_UNPADDED:
100
+   case SEQ_UNCOMPRESSED: {
101
+       const lzma_vli size = coder->sequence == SEQ_UNPADDED
102
+               ? coder->iter.block.unpadded_size
103
+               : coder->iter.block.uncompressed_size;
104
+
105
+       ret = lzma_vli_encode(size, &coder->pos,
106
+               out, out_pos, out_size);
107
+       if (ret != LZMA_STREAM_END)
108
+           goto out;
109
+
110
+       ret = LZMA_OK;
111
+       coder->pos = 0;
112
+
113
+       // Advance to SEQ_UNCOMPRESSED or SEQ_NEXT.
114
+       ++coder->sequence;
115
+       break;
116
+   }
117
+
118
+   case SEQ_PADDING:
119
+       if (coder->pos > 0) {
120
+           --coder->pos;
121
+           out[(*out_pos)++] = 0x00;
122
+           break;
123
+       }
124
+
125
+       // Finish the CRC32 calculation.
126
+       coder->crc32 = lzma_crc32(out + out_start,
127
+               *out_pos - out_start, coder->crc32);
128
+
129
+       coder->sequence = SEQ_CRC32;
130
+
131
+   // Fall through
132
+
133
+   case SEQ_CRC32:
134
+       // We don't use the main loop, because we don't want
135
+       // coder->crc32 to be touched anymore.
136
+       do {
137
+           if (*out_pos == out_size)
138
+               return LZMA_OK;
139
+
140
+           out[*out_pos] = (coder->crc32 >> (coder->pos * 8))
141
+                   & 0xFF;
142
+           ++*out_pos;
143
+
144
+       } while (++coder->pos < 4);
145
+
146
+       return LZMA_STREAM_END;
147
+
148
+   default:
149
+       assert(0);
150
+       return LZMA_PROG_ERROR;
151
+   }
152
+
153
+out:
154
+   // Update the CRC32.
155
+   coder->crc32 = lzma_crc32(out + out_start,
156
+           *out_pos - out_start, coder->crc32);
157
+
158
+   return ret;
159
+}
160
+
161
+
162
+static void
163
+index_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
164
+{
165
+   lzma_free(coder, allocator);
166
+   return;
167
+}
168
+
169
+
170
+static void
171
+index_encoder_reset(lzma_coder *coder, const lzma_index *i)
172
+{
173
+   lzma_index_iter_init(&coder->iter, i);
174
+
175
+   coder->sequence = SEQ_INDICATOR;
176
+   coder->index = i;
177
+   coder->pos = 0;
178
+   coder->crc32 = 0;
179
+
180
+   return;
181
+}
182
+
183
+
184
+extern lzma_ret
185
+lzma_index_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
186
+       const lzma_index *i)
187
+{
188
+   lzma_next_coder_init(&lzma_index_encoder_init, next, allocator);
189
+
190
+   if (i == NULL)
191
+       return LZMA_PROG_ERROR;
192
+
193
+   if (next->coder == NULL) {
194
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
195
+       if (next->coder == NULL)
196
+           return LZMA_MEM_ERROR;
197
+
198
+       next->code = &index_encode;
199
+       next->end = &index_encoder_end;
200
+   }
201
+
202
+   index_encoder_reset(next->coder, i);
203
+
204
+   return LZMA_OK;
205
+}
206
+
207
+
208
+extern LZMA_API(lzma_ret)
209
+lzma_index_encoder(lzma_stream *strm, const lzma_index *i)
210
+{
211
+   lzma_next_strm_init(lzma_index_encoder_init, strm, i);
212
+
213
+   strm->internal->supported_actions[LZMA_RUN] = true;
214
+   strm->internal->supported_actions[LZMA_FINISH] = true;
215
+
216
+   return LZMA_OK;
217
+}
218
+
219
+
220
+extern LZMA_API(lzma_ret)
221
+lzma_index_buffer_encode(const lzma_index *i,
222
+       uint8_t *out, size_t *out_pos, size_t out_size)
223
+{
224
+   // Validate the arguments.
225
+   if (i == NULL || out == NULL || out_pos == NULL || *out_pos > out_size)
226
+       return LZMA_PROG_ERROR;
227
+
228
+   // Don't try to encode if there's not enough output space.
229
+   if (out_size - *out_pos < lzma_index_size(i))
230
+       return LZMA_BUF_ERROR;
231
+
232
+   // The Index encoder needs just one small data structure so we can
233
+   // allocate it on stack.
234
+   lzma_coder coder;
235
+   index_encoder_reset(&coder, i);
236
+
237
+   // Do the actual encoding. This should never fail, but store
238
+   // the original *out_pos just in case.
239
+   const size_t out_start = *out_pos;
240
+   lzma_ret ret = index_encode(&coder, NULL, NULL, NULL, 0,
241
+           out, out_pos, out_size, LZMA_RUN);
242
+
243
+   if (ret == LZMA_STREAM_END) {
244
+       ret = LZMA_OK;
245
+   } else {
246
+       // We should never get here, but just in case, restore the
247
+       // output position and set the error accordingly if something
248
+       // goes wrong and debugging isn't enabled.
249
+       assert(0);
250
+       *out_pos = out_start;
251
+       ret = LZMA_PROG_ERROR;
252
+   }
253
+
254
+   return ret;
255
+}
256
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/index_encoder.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       index_encoder.h
5
+/// \brief      Encodes the Index field
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_INDEX_ENCODER_H
15
+#define LZMA_INDEX_ENCODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+extern lzma_ret lzma_index_encoder_init(lzma_next_coder *next,
21
+       lzma_allocator *allocator, const lzma_index *i);
22
+
23
+
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/index_hash.c Added
334
 
1
@@ -0,0 +1,332 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       index_hash.c
5
+/// \brief      Validates Index by using a hash function
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+#include "index.h"
16
+#include "check.h"
17
+
18
+
19
+typedef struct {
20
+   /// Sum of the Block sizes (including Block Padding)
21
+   lzma_vli blocks_size;
22
+
23
+   /// Sum of the Uncompressed Size fields
24
+   lzma_vli uncompressed_size;
25
+
26
+   /// Number of Records
27
+   lzma_vli count;
28
+
29
+   /// Size of the List of Index Records as bytes
30
+   lzma_vli index_list_size;
31
+
32
+   /// Check calculated from Unpadded Sizes and Uncompressed Sizes.
33
+   lzma_check_state check;
34
+
35
+} lzma_index_hash_info;
36
+
37
+
38
+struct lzma_index_hash_s {
39
+   enum {
40
+       SEQ_BLOCK,
41
+       SEQ_COUNT,
42
+       SEQ_UNPADDED,
43
+       SEQ_UNCOMPRESSED,
44
+       SEQ_PADDING_INIT,
45
+       SEQ_PADDING,
46
+       SEQ_CRC32,
47
+   } sequence;
48
+
49
+   /// Information collected while decoding the actual Blocks.
50
+   lzma_index_hash_info blocks;
51
+
52
+   /// Information collected from the Index field.
53
+   lzma_index_hash_info records;
54
+
55
+   /// Number of Records not fully decoded
56
+   lzma_vli remaining;
57
+
58
+   /// Unpadded Size currently being read from an Index Record.
59
+   lzma_vli unpadded_size;
60
+
61
+   /// Uncompressed Size currently being read from an Index Record.
62
+   lzma_vli uncompressed_size;
63
+
64
+   /// Position in variable-length integers when decoding them from
65
+   /// the List of Records.
66
+   size_t pos;
67
+
68
+   /// CRC32 of the Index
69
+   uint32_t crc32;
70
+};
71
+
72
+
73
+extern LZMA_API(lzma_index_hash *)
74
+lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator)
75
+{
76
+   if (index_hash == NULL) {
77
+       index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator);
78
+       if (index_hash == NULL)
79
+           return NULL;
80
+   }
81
+
82
+   index_hash->sequence = SEQ_BLOCK;
83
+   index_hash->blocks.blocks_size = 0;
84
+   index_hash->blocks.uncompressed_size = 0;
85
+   index_hash->blocks.count = 0;
86
+   index_hash->blocks.index_list_size = 0;
87
+   index_hash->records.blocks_size = 0;
88
+   index_hash->records.uncompressed_size = 0;
89
+   index_hash->records.count = 0;
90
+   index_hash->records.index_list_size = 0;
91
+   index_hash->unpadded_size = 0;
92
+   index_hash->uncompressed_size = 0;
93
+   index_hash->pos = 0;
94
+   index_hash->crc32 = 0;
95
+
96
+   // These cannot fail because LZMA_CHECK_BEST is known to be supported.
97
+   (void)lzma_check_init(&index_hash->blocks.check, LZMA_CHECK_BEST);
98
+   (void)lzma_check_init(&index_hash->records.check, LZMA_CHECK_BEST);
99
+
100
+   return index_hash;
101
+}
102
+
103
+
104
+extern LZMA_API(void)
105
+lzma_index_hash_end(lzma_index_hash *index_hash, lzma_allocator *allocator)
106
+{
107
+   lzma_free(index_hash, allocator);
108
+   return;
109
+}
110
+
111
+
112
+extern LZMA_API(lzma_vli)
113
+lzma_index_hash_size(const lzma_index_hash *index_hash)
114
+{
115
+   // Get the size of the Index from ->blocks instead of ->records for
116
+   // cases where application wants to know the Index Size before
117
+   // decoding the Index.
118
+   return index_size(index_hash->blocks.count,
119
+           index_hash->blocks.index_list_size);
120
+}
121
+
122
+
123
+/// Updates the sizes and the hash without any validation.
124
+static lzma_ret
125
+hash_append(lzma_index_hash_info *info, lzma_vli unpadded_size,
126
+       lzma_vli uncompressed_size)
127
+{
128
+   info->blocks_size += vli_ceil4(unpadded_size);
129
+   info->uncompressed_size += uncompressed_size;
130
+   info->index_list_size += lzma_vli_size(unpadded_size)
131
+           + lzma_vli_size(uncompressed_size);
132
+   ++info->count;
133
+
134
+   const lzma_vli sizes[2] = { unpadded_size, uncompressed_size };
135
+   lzma_check_update(&info->check, LZMA_CHECK_BEST,
136
+           (const uint8_t *)(sizes), sizeof(sizes));
137
+
138
+   return LZMA_OK;
139
+}
140
+
141
+
142
+extern LZMA_API(lzma_ret)
143
+lzma_index_hash_append(lzma_index_hash *index_hash, lzma_vli unpadded_size,
144
+       lzma_vli uncompressed_size)
145
+{
146
+   // Validate the arguments.
147
+   if (index_hash->sequence != SEQ_BLOCK
148
+           || unpadded_size < UNPADDED_SIZE_MIN
149
+           || unpadded_size > UNPADDED_SIZE_MAX
150
+           || uncompressed_size > LZMA_VLI_MAX)
151
+       return LZMA_PROG_ERROR;
152
+
153
+   // Update the hash.
154
+   return_if_error(hash_append(&index_hash->blocks,
155
+           unpadded_size, uncompressed_size));
156
+
157
+   // Validate the properties of *info are still in allowed limits.
158
+   if (index_hash->blocks.blocks_size > LZMA_VLI_MAX
159
+           || index_hash->blocks.uncompressed_size > LZMA_VLI_MAX
160
+           || index_size(index_hash->blocks.count,
161
+                   index_hash->blocks.index_list_size)
162
+               > LZMA_BACKWARD_SIZE_MAX
163
+           || index_stream_size(index_hash->blocks.blocks_size,
164
+                   index_hash->blocks.count,
165
+                   index_hash->blocks.index_list_size)
166
+               > LZMA_VLI_MAX)
167
+       return LZMA_DATA_ERROR;
168
+
169
+   return LZMA_OK;
170
+}
171
+
172
+
173
+extern LZMA_API(lzma_ret)
174
+lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,
175
+       size_t *in_pos, size_t in_size)
176
+{
177
+   // Catch zero input buffer here, because in contrast to Index encoder
178
+   // and decoder functions, applications call this function directly
179
+   // instead of via lzma_code(), which does the buffer checking.
180
+   if (*in_pos >= in_size)
181
+       return LZMA_BUF_ERROR;
182
+
183
+   // NOTE: This function has many similarities to index_encode() and
184
+   // index_decode() functions found from index_encoder.c and
185
+   // index_decoder.c. See the comments especially in index_encoder.c.
186
+   const size_t in_start = *in_pos;
187
+   lzma_ret ret = LZMA_OK;
188
+
189
+   while (*in_pos < in_size)
190
+   switch (index_hash->sequence) {
191
+   case SEQ_BLOCK:
192
+       // Check the Index Indicator is present.
193
+       if (in[(*in_pos)++] != 0x00)
194
+           return LZMA_DATA_ERROR;
195
+
196
+       index_hash->sequence = SEQ_COUNT;
197
+       break;
198
+
199
+   case SEQ_COUNT: {
200
+       ret = lzma_vli_decode(&index_hash->remaining,
201
+               &index_hash->pos, in, in_pos, in_size);
202
+       if (ret != LZMA_STREAM_END)
203
+           goto out;
204
+
205
+       // The count must match the count of the Blocks decoded.
206
+       if (index_hash->remaining != index_hash->blocks.count)
207
+           return LZMA_DATA_ERROR;
208
+
209
+       ret = LZMA_OK;
210
+       index_hash->pos = 0;
211
+
212
+       // Handle the special case when there are no Blocks.
213
+       index_hash->sequence = index_hash->remaining == 0
214
+               ? SEQ_PADDING_INIT : SEQ_UNPADDED;
215
+       break;
216
+   }
217
+
218
+   case SEQ_UNPADDED:
219
+   case SEQ_UNCOMPRESSED: {
220
+       lzma_vli *size = index_hash->sequence == SEQ_UNPADDED
221
+               ? &index_hash->unpadded_size
222
+               : &index_hash->uncompressed_size;
223
+
224
+       ret = lzma_vli_decode(size, &index_hash->pos,
225
+               in, in_pos, in_size);
226
+       if (ret != LZMA_STREAM_END)
227
+           goto out;
228
+
229
+       ret = LZMA_OK;
230
+       index_hash->pos = 0;
231
+
232
+       if (index_hash->sequence == SEQ_UNPADDED) {
233
+           if (index_hash->unpadded_size < UNPADDED_SIZE_MIN
234
+                   || index_hash->unpadded_size
235
+                       > UNPADDED_SIZE_MAX)
236
+               return LZMA_DATA_ERROR;
237
+
238
+           index_hash->sequence = SEQ_UNCOMPRESSED;
239
+       } else {
240
+           // Update the hash.
241
+           return_if_error(hash_append(&index_hash->records,
242
+                   index_hash->unpadded_size,
243
+                   index_hash->uncompressed_size));
244
+
245
+           // Verify that we don't go over the known sizes. Note
246
+           // that this validation is simpler than the one used
247
+           // in lzma_index_hash_append(), because here we know
248
+           // that values in index_hash->blocks are already
249
+           // validated and we are fine as long as we don't
250
+           // exceed them in index_hash->records.
251
+           if (index_hash->blocks.blocks_size
252
+                   < index_hash->records.blocks_size
253
+                   || index_hash->blocks.uncompressed_size
254
+                   < index_hash->records.uncompressed_size
255
+                   || index_hash->blocks.index_list_size
256
+                   < index_hash->records.index_list_size)
257
+               return LZMA_DATA_ERROR;
258
+
259
+           // Check if this was the last Record.
260
+           index_hash->sequence = --index_hash->remaining == 0
261
+                   ? SEQ_PADDING_INIT : SEQ_UNPADDED;
262
+       }
263
+
264
+       break;
265
+   }
266
+
267
+   case SEQ_PADDING_INIT:
268
+       index_hash->pos = (LZMA_VLI_C(4) - index_size_unpadded(
269
+               index_hash->records.count,
270
+               index_hash->records.index_list_size)) & 3;
271
+       index_hash->sequence = SEQ_PADDING;
272
+
273
+   // Fall through
274
+
275
+   case SEQ_PADDING:
276
+       if (index_hash->pos > 0) {
277
+           --index_hash->pos;
278
+           if (in[(*in_pos)++] != 0x00)
279
+               return LZMA_DATA_ERROR;
280
+
281
+           break;
282
+       }
283
+
284
+       // Compare the sizes.
285
+       if (index_hash->blocks.blocks_size
286
+               != index_hash->records.blocks_size
287
+               || index_hash->blocks.uncompressed_size
288
+               != index_hash->records.uncompressed_size
289
+               || index_hash->blocks.index_list_size
290
+               != index_hash->records.index_list_size)
291
+           return LZMA_DATA_ERROR;
292
+
293
+       // Finish the hashes and compare them.
294
+       lzma_check_finish(&index_hash->blocks.check, LZMA_CHECK_BEST);
295
+       lzma_check_finish(&index_hash->records.check, LZMA_CHECK_BEST);
296
+       if (memcmp(index_hash->blocks.check.buffer.u8,
297
+               index_hash->records.check.buffer.u8,
298
+               lzma_check_size(LZMA_CHECK_BEST)) != 0)
299
+           return LZMA_DATA_ERROR;
300
+
301
+       // Finish the CRC32 calculation.
302
+       index_hash->crc32 = lzma_crc32(in + in_start,
303
+               *in_pos - in_start, index_hash->crc32);
304
+
305
+       index_hash->sequence = SEQ_CRC32;
306
+
307
+   // Fall through
308
+
309
+   case SEQ_CRC32:
310
+       do {
311
+           if (*in_pos == in_size)
312
+               return LZMA_OK;
313
+
314
+           if (((index_hash->crc32 >> (index_hash->pos * 8))
315
+                   & 0xFF) != in[(*in_pos)++])
316
+               return LZMA_DATA_ERROR;
317
+
318
+       } while (++index_hash->pos < 4);
319
+
320
+       return LZMA_STREAM_END;
321
+
322
+   default:
323
+       assert(0);
324
+       return LZMA_PROG_ERROR;
325
+   }
326
+
327
+out:
328
+   // Update the CRC32,
329
+   index_hash->crc32 = lzma_crc32(in + in_start,
330
+           *in_pos - in_start, index_hash->crc32);
331
+
332
+   return ret;
333
+}
334
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_buffer_decoder.c Added
93
 
1
@@ -0,0 +1,91 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_buffer_decoder.c
5
+/// \brief      Single-call .xz Stream decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_decoder.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
19
+       lzma_allocator *allocator,
20
+       const uint8_t *in, size_t *in_pos, size_t in_size,
21
+       uint8_t *out, size_t *out_pos, size_t out_size)
22
+{
23
+   // Sanity checks
24
+   if (in_pos == NULL || (in == NULL && *in_pos != in_size)
25
+           || *in_pos > in_size || out_pos == NULL
26
+           || (out == NULL && *out_pos != out_size)
27
+           || *out_pos > out_size)
28
+       return LZMA_PROG_ERROR;
29
+
30
+   // Catch flags that are not allowed in buffer-to-buffer decoding.
31
+   if (flags & LZMA_TELL_ANY_CHECK)
32
+       return LZMA_PROG_ERROR;
33
+
34
+   // Initialize the Stream decoder.
35
+   // TODO: We need something to tell the decoder that it can use the
36
+   // output buffer as workspace, and thus save significant amount of RAM.
37
+   lzma_next_coder stream_decoder = LZMA_NEXT_CODER_INIT;
38
+   lzma_ret ret = lzma_stream_decoder_init(
39
+           &stream_decoder, allocator, *memlimit, flags);
40
+
41
+   if (ret == LZMA_OK) {
42
+       // Save the positions so that we can restore them in case
43
+       // an error occurs.
44
+       const size_t in_start = *in_pos;
45
+       const size_t out_start = *out_pos;
46
+
47
+       // Do the actual decoding.
48
+       ret = stream_decoder.code(stream_decoder.coder, allocator,
49
+               in, in_pos, in_size, out, out_pos, out_size,
50
+               LZMA_FINISH);
51
+
52
+       if (ret == LZMA_STREAM_END) {
53
+           ret = LZMA_OK;
54
+       } else {
55
+           // Something went wrong, restore the positions.
56
+           *in_pos = in_start;
57
+           *out_pos = out_start;
58
+
59
+           if (ret == LZMA_OK) {
60
+               // Either the input was truncated or the
61
+               // output buffer was too small.
62
+               assert(*in_pos == in_size
63
+                       || *out_pos == out_size);
64
+
65
+               // If all the input was consumed, then the
66
+               // input is truncated, even if the output
67
+               // buffer is also full. This is because
68
+               // processing the last byte of the Stream
69
+               // never produces output.
70
+               if (*in_pos == in_size)
71
+                   ret = LZMA_DATA_ERROR;
72
+               else
73
+                   ret = LZMA_BUF_ERROR;
74
+
75
+           } else if (ret == LZMA_MEMLIMIT_ERROR) {
76
+               // Let the caller know how much memory would
77
+               // have been needed.
78
+               uint64_t memusage;
79
+               (void)stream_decoder.memconfig(
80
+                       stream_decoder.coder,
81
+                       memlimit, &memusage, 0);
82
+           }
83
+       }
84
+   }
85
+
86
+   // Free the decoder memory. This needs to be done even if
87
+   // initialization fails, because the internal API doesn't
88
+   // require the initialization function to free its memory on error.
89
+   lzma_next_end(&stream_decoder, allocator);
90
+
91
+   return ret;
92
+}
93
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_buffer_encoder.c Added
142
 
1
@@ -0,0 +1,140 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_buffer_encoder.c
5
+/// \brief      Single-call .xz Stream encoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "index.h"
15
+
16
+
17
+/// Maximum size of Index that has exactly one Record.
18
+/// Index Indicator + Number of Records + Record + CRC32 rounded up to
19
+/// the next multiple of four.
20
+#define INDEX_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3) & ~3)
21
+
22
+/// Stream Header, Stream Footer, and Index
23
+#define HEADERS_BOUND (2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND)
24
+
25
+
26
+extern LZMA_API(size_t)
27
+lzma_stream_buffer_bound(size_t uncompressed_size)
28
+{
29
+   // Get the maximum possible size of a Block.
30
+   const size_t block_bound = lzma_block_buffer_bound(uncompressed_size);
31
+   if (block_bound == 0)
32
+       return 0;
33
+
34
+   // Catch the possible integer overflow and also prevent the size of
35
+   // the Stream exceeding LZMA_VLI_MAX (theoretically possible on
36
+   // 64-bit systems).
37
+   if (my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND)
38
+       return 0;
39
+
40
+   return block_bound + HEADERS_BOUND;
41
+}
42
+
43
+
44
+extern LZMA_API(lzma_ret)
45
+lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
46
+       lzma_allocator *allocator, const uint8_t *in, size_t in_size,
47
+       uint8_t *out, size_t *out_pos_ptr, size_t out_size)
48
+{
49
+   // Sanity checks
50
+   if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX
51
+           || (in == NULL && in_size != 0) || out == NULL
52
+           || out_pos_ptr == NULL || *out_pos_ptr > out_size)
53
+       return LZMA_PROG_ERROR;
54
+
55
+   if (!lzma_check_is_supported(check))
56
+       return LZMA_UNSUPPORTED_CHECK;
57
+
58
+   // Note for the paranoids: Index encoder prevents the Stream from
59
+   // getting too big and still being accepted with LZMA_OK, and Block
60
+   // encoder catches if the input is too big. So we don't need to
61
+   // separately check if the buffers are too big.
62
+
63
+   // Use a local copy. We update *out_pos_ptr only if everything
64
+   // succeeds.
65
+   size_t out_pos = *out_pos_ptr;
66
+
67
+   // Check that there's enough space for both Stream Header and
68
+   // Stream Footer.
69
+   if (out_size - out_pos <= 2 * LZMA_STREAM_HEADER_SIZE)
70
+       return LZMA_BUF_ERROR;
71
+
72
+   // Reserve space for Stream Footer so we don't need to check for
73
+   // available space again before encoding Stream Footer.
74
+   out_size -= LZMA_STREAM_HEADER_SIZE;
75
+
76
+   // Encode the Stream Header.
77
+   lzma_stream_flags stream_flags = {
78
+       .version = 0,
79
+       .check = check,
80
+   };
81
+
82
+   if (lzma_stream_header_encode(&stream_flags, out + out_pos)
83
+           != LZMA_OK)
84
+       return LZMA_PROG_ERROR;
85
+
86
+   out_pos += LZMA_STREAM_HEADER_SIZE;
87
+
88
+   // Encode a Block but only if there is at least one byte of input.
89
+   lzma_block block = {
90
+       .version = 0,
91
+       .check = check,
92
+       .filters = filters,
93
+   };
94
+
95
+   if (in_size > 0)
96
+       return_if_error(lzma_block_buffer_encode(&block, allocator,
97
+               in, in_size, out, &out_pos, out_size));
98
+
99
+   // Index
100
+   {
101
+       // Create an Index. It will have one Record if there was
102
+       // at least one byte of input to encode. Otherwise the
103
+       // Index will be empty.
104
+       lzma_index *i = lzma_index_init(allocator);
105
+       if (i == NULL)
106
+           return LZMA_MEM_ERROR;
107
+
108
+       lzma_ret ret = LZMA_OK;
109
+
110
+       if (in_size > 0)
111
+           ret = lzma_index_append(i, allocator,
112
+                   lzma_block_unpadded_size(&block),
113
+                   block.uncompressed_size);
114
+
115
+       // If adding the Record was successful, encode the Index
116
+       // and get its size which will be stored into Stream Footer.
117
+       if (ret == LZMA_OK) {
118
+           ret = lzma_index_buffer_encode(
119
+                   i, out, &out_pos, out_size);
120
+
121
+           stream_flags.backward_size = lzma_index_size(i);
122
+       }
123
+
124
+       lzma_index_end(i, allocator);
125
+
126
+       if (ret != LZMA_OK)
127
+           return ret;
128
+   }
129
+
130
+   // Stream Footer. We have already reserved space for this.
131
+   if (lzma_stream_footer_encode(&stream_flags, out + out_pos)
132
+           != LZMA_OK)
133
+       return LZMA_PROG_ERROR;
134
+
135
+   out_pos += LZMA_STREAM_HEADER_SIZE;
136
+
137
+   // Everything went fine, make the new output position available
138
+   // to the application.
139
+   *out_pos_ptr = out_pos;
140
+   return LZMA_OK;
141
+}
142
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_decoder.c Added
453
 
1
@@ -0,0 +1,451 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_decoder.c
5
+/// \brief      Decodes .xz Streams
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_decoder.h"
15
+#include "block_decoder.h"
16
+
17
+
18
+struct lzma_coder_s {
19
+   enum {
20
+       SEQ_STREAM_HEADER,
21
+       SEQ_BLOCK_HEADER,
22
+       SEQ_BLOCK,
23
+       SEQ_INDEX,
24
+       SEQ_STREAM_FOOTER,
25
+       SEQ_STREAM_PADDING,
26
+   } sequence;
27
+
28
+   /// Block or Metadata decoder. This takes little memory and the same
29
+   /// data structure can be used to decode every Block Header, so it's
30
+   /// a good idea to have a separate lzma_next_coder structure for it.
31
+   lzma_next_coder block_decoder;
32
+
33
+   /// Block options decoded by the Block Header decoder and used by
34
+   /// the Block decoder.
35
+   lzma_block block_options;
36
+
37
+   /// Stream Flags from Stream Header
38
+   lzma_stream_flags stream_flags;
39
+
40
+   /// Index is hashed so that it can be compared to the sizes of Blocks
41
+   /// with O(1) memory usage.
42
+   lzma_index_hash *index_hash;
43
+
44
+   /// Memory usage limit
45
+   uint64_t memlimit;
46
+
47
+   /// Amount of memory actually needed (only an estimate)
48
+   uint64_t memusage;
49
+
50
+   /// If true, LZMA_NO_CHECK is returned if the Stream has
51
+   /// no integrity check.
52
+   bool tell_no_check;
53
+
54
+   /// If true, LZMA_UNSUPPORTED_CHECK is returned if the Stream has
55
+   /// an integrity check that isn't supported by this liblzma build.
56
+   bool tell_unsupported_check;
57
+
58
+   /// If true, LZMA_GET_CHECK is returned after decoding Stream Header.
59
+   bool tell_any_check;
60
+
61
+   /// If true, we will decode concatenated Streams that possibly have
62
+   /// Stream Padding between or after them. LZMA_STREAM_END is returned
63
+   /// once the application isn't giving us any new input, and we aren't
64
+   /// in the middle of a Stream, and possible Stream Padding is a
65
+   /// multiple of four bytes.
66
+   bool concatenated;
67
+
68
+   /// When decoding concatenated Streams, this is true as long as we
69
+   /// are decoding the first Stream. This is needed to avoid misleading
70
+   /// LZMA_FORMAT_ERROR in case the later Streams don't have valid magic
71
+   /// bytes.
72
+   bool first_stream;
73
+
74
+   /// Write position in buffer[] and position in Stream Padding
75
+   size_t pos;
76
+
77
+   /// Buffer to hold Stream Header, Block Header, and Stream Footer.
78
+   /// Block Header has biggest maximum size.
79
+   uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];
80
+};
81
+
82
+
83
+static lzma_ret
84
+stream_decoder_reset(lzma_coder *coder, lzma_allocator *allocator)
85
+{
86
+   // Initialize the Index hash used to verify the Index.
87
+   coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator);
88
+   if (coder->index_hash == NULL)
89
+       return LZMA_MEM_ERROR;
90
+
91
+   // Reset the rest of the variables.
92
+   coder->sequence = SEQ_STREAM_HEADER;
93
+   coder->pos = 0;
94
+
95
+   return LZMA_OK;
96
+}
97
+
98
+
99
+static lzma_ret
100
+stream_decode(lzma_coder *coder, lzma_allocator *allocator,
101
+       const uint8_t *restrict in, size_t *restrict in_pos,
102
+       size_t in_size, uint8_t *restrict out,
103
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
104
+{
105
+   // When decoding the actual Block, it may be able to produce more
106
+   // output even if we don't give it any new input.
107
+   while (true)
108
+   switch (coder->sequence) {
109
+   case SEQ_STREAM_HEADER: {
110
+       // Copy the Stream Header to the internal buffer.
111
+       lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
112
+               LZMA_STREAM_HEADER_SIZE);
113
+
114
+       // Return if we didn't get the whole Stream Header yet.
115
+       if (coder->pos < LZMA_STREAM_HEADER_SIZE)
116
+           return LZMA_OK;
117
+
118
+       coder->pos = 0;
119
+
120
+       // Decode the Stream Header.
121
+       const lzma_ret ret = lzma_stream_header_decode(
122
+               &coder->stream_flags, coder->buffer);
123
+       if (ret != LZMA_OK)
124
+           return ret == LZMA_FORMAT_ERROR && !coder->first_stream
125
+                   ? LZMA_DATA_ERROR : ret;
126
+
127
+       // If we are decoding concatenated Streams, and the later
128
+       // Streams have invalid Header Magic Bytes, we give
129
+       // LZMA_DATA_ERROR instead of LZMA_FORMAT_ERROR.
130
+       coder->first_stream = false;
131
+
132
+       // Copy the type of the Check so that Block Header and Block
133
+       // decoders see it.
134
+       coder->block_options.check = coder->stream_flags.check;
135
+
136
+       // Even if we return LZMA_*_CHECK below, we want
137
+       // to continue from Block Header decoding.
138
+       coder->sequence = SEQ_BLOCK_HEADER;
139
+
140
+       // Detect if there's no integrity check or if it is
141
+       // unsupported if those were requested by the application.
142
+       if (coder->tell_no_check && coder->stream_flags.check
143
+               == LZMA_CHECK_NONE)
144
+           return LZMA_NO_CHECK;
145
+
146
+       if (coder->tell_unsupported_check
147
+               && !lzma_check_is_supported(
148
+                   coder->stream_flags.check))
149
+           return LZMA_UNSUPPORTED_CHECK;
150
+
151
+       if (coder->tell_any_check)
152
+           return LZMA_GET_CHECK;
153
+   }
154
+
155
+   // Fall through
156
+
157
+   case SEQ_BLOCK_HEADER: {
158
+       if (*in_pos >= in_size)
159
+           return LZMA_OK;
160
+
161
+       if (coder->pos == 0) {
162
+           // Detect if it's Index.
163
+           if (in[*in_pos] == 0x00) {
164
+               coder->sequence = SEQ_INDEX;
165
+               break;
166
+           }
167
+
168
+           // Calculate the size of the Block Header. Note that
169
+           // Block Header decoder wants to see this byte too
170
+           // so don't advance *in_pos.
171
+           coder->block_options.header_size
172
+                   = lzma_block_header_size_decode(
173
+                       in[*in_pos]);
174
+       }
175
+
176
+       // Copy the Block Header to the internal buffer.
177
+       lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
178
+               coder->block_options.header_size);
179
+
180
+       // Return if we didn't get the whole Block Header yet.
181
+       if (coder->pos < coder->block_options.header_size)
182
+           return LZMA_OK;
183
+
184
+       coder->pos = 0;
185
+
186
+       // Version 0 is currently the only possible version.
187
+       coder->block_options.version = 0;
188
+
189
+       // Set up a buffer to hold the filter chain. Block Header
190
+       // decoder will initialize all members of this array so
191
+       // we don't need to do it here.
192
+       lzma_filter filters[LZMA_FILTERS_MAX + 1];
193
+       coder->block_options.filters = filters;
194
+
195
+       // Decode the Block Header.
196
+       return_if_error(lzma_block_header_decode(&coder->block_options,
197
+               allocator, coder->buffer));
198
+
199
+       // Check the memory usage limit.
200
+       const uint64_t memusage = lzma_raw_decoder_memusage(filters);
201
+       lzma_ret ret;
202
+
203
+       if (memusage == UINT64_MAX) {
204
+           // One or more unknown Filter IDs.
205
+           ret = LZMA_OPTIONS_ERROR;
206
+       } else {
207
+           // Now we can set coder->memusage since we know that
208
+           // the filter chain is valid. We don't want
209
+           // lzma_memusage() to return UINT64_MAX in case of
210
+           // invalid filter chain.
211
+           coder->memusage = memusage;
212
+
213
+           if (memusage > coder->memlimit) {
214
+               // The chain would need too much memory.
215
+               ret = LZMA_MEMLIMIT_ERROR;
216
+           } else {
217
+               // Memory usage is OK.
218
+               // Initialize the Block decoder.
219
+               ret = lzma_block_decoder_init(
220
+                       &coder->block_decoder,
221
+                       allocator,
222
+                       &coder->block_options);
223
+           }
224
+       }
225
+
226
+       // Free the allocated filter options since they are needed
227
+       // only to initialize the Block decoder.
228
+       for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i)
229
+           lzma_free(filters[i].options, allocator);
230
+
231
+       coder->block_options.filters = NULL;
232
+
233
+       // Check if memory usage calculation and Block enocoder
234
+       // initialization succeeded.
235
+       if (ret != LZMA_OK)
236
+           return ret;
237
+
238
+       coder->sequence = SEQ_BLOCK;
239
+   }
240
+
241
+   // Fall through
242
+
243
+   case SEQ_BLOCK: {
244
+       const lzma_ret ret = coder->block_decoder.code(
245
+               coder->block_decoder.coder, allocator,
246
+               in, in_pos, in_size, out, out_pos, out_size,
247
+               action);
248
+
249
+       if (ret != LZMA_STREAM_END)
250
+           return ret;
251
+
252
+       // Block decoded successfully. Add the new size pair to
253
+       // the Index hash.
254
+       return_if_error(lzma_index_hash_append(coder->index_hash,
255
+               lzma_block_unpadded_size(
256
+                   &coder->block_options),
257
+               coder->block_options.uncompressed_size));
258
+
259
+       coder->sequence = SEQ_BLOCK_HEADER;
260
+       break;
261
+   }
262
+
263
+   case SEQ_INDEX: {
264
+       // If we don't have any input, don't call
265
+       // lzma_index_hash_decode() since it would return
266
+       // LZMA_BUF_ERROR, which we must not do here.
267
+       if (*in_pos >= in_size)
268
+           return LZMA_OK;
269
+
270
+       // Decode the Index and compare it to the hash calculated
271
+       // from the sizes of the Blocks (if any).
272
+       const lzma_ret ret = lzma_index_hash_decode(coder->index_hash,
273
+               in, in_pos, in_size);
274
+       if (ret != LZMA_STREAM_END)
275
+           return ret;
276
+
277
+       coder->sequence = SEQ_STREAM_FOOTER;
278
+   }
279
+
280
+   // Fall through
281
+
282
+   case SEQ_STREAM_FOOTER: {
283
+       // Copy the Stream Footer to the internal buffer.
284
+       lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
285
+               LZMA_STREAM_HEADER_SIZE);
286
+
287
+       // Return if we didn't get the whole Stream Footer yet.
288
+       if (coder->pos < LZMA_STREAM_HEADER_SIZE)
289
+           return LZMA_OK;
290
+
291
+       coder->pos = 0;
292
+
293
+       // Decode the Stream Footer. The decoder gives
294
+       // LZMA_FORMAT_ERROR if the magic bytes don't match,
295
+       // so convert that return code to LZMA_DATA_ERROR.
296
+       lzma_stream_flags footer_flags;
297
+       const lzma_ret ret = lzma_stream_footer_decode(
298
+               &footer_flags, coder->buffer);
299
+       if (ret != LZMA_OK)
300
+           return ret == LZMA_FORMAT_ERROR
301
+                   ? LZMA_DATA_ERROR : ret;
302
+
303
+       // Check that Index Size stored in the Stream Footer matches
304
+       // the real size of the Index field.
305
+       if (lzma_index_hash_size(coder->index_hash)
306
+               != footer_flags.backward_size)
307
+           return LZMA_DATA_ERROR;
308
+
309
+       // Compare that the Stream Flags fields are identical in
310
+       // both Stream Header and Stream Footer.
311
+       return_if_error(lzma_stream_flags_compare(
312
+               &coder->stream_flags, &footer_flags));
313
+
314
+       if (!coder->concatenated)
315
+           return LZMA_STREAM_END;
316
+
317
+       coder->sequence = SEQ_STREAM_PADDING;
318
+   }
319
+
320
+   // Fall through
321
+
322
+   case SEQ_STREAM_PADDING:
323
+       assert(coder->concatenated);
324
+
325
+       // Skip over possible Stream Padding.
326
+       while (true) {
327
+           if (*in_pos >= in_size) {
328
+               // Unless LZMA_FINISH was used, we cannot
329
+               // know if there's more input coming later.
330
+               if (action != LZMA_FINISH)
331
+                   return LZMA_OK;
332
+
333
+               // Stream Padding must be a multiple of
334
+               // four bytes.
335
+               return coder->pos == 0
336
+                       ? LZMA_STREAM_END
337
+                       : LZMA_DATA_ERROR;
338
+           }
339
+
340
+           // If the byte is not zero, it probably indicates
341
+           // beginning of a new Stream (or the file is corrupt).
342
+           if (in[*in_pos] != 0x00)
343
+               break;
344
+
345
+           ++*in_pos;
346
+           coder->pos = (coder->pos + 1) & 3;
347
+       }
348
+
349
+       // Stream Padding must be a multiple of four bytes (empty
350
+       // Stream Padding is OK).
351
+       if (coder->pos != 0) {
352
+           ++*in_pos;
353
+           return LZMA_DATA_ERROR;
354
+       }
355
+
356
+       // Prepare to decode the next Stream.
357
+       return_if_error(stream_decoder_reset(coder, allocator));
358
+       break;
359
+
360
+   default:
361
+       assert(0);
362
+       return LZMA_PROG_ERROR;
363
+   }
364
+
365
+   // Never reached
366
+}
367
+
368
+
369
+static void
370
+stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
371
+{
372
+   lzma_next_end(&coder->block_decoder, allocator);
373
+   lzma_index_hash_end(coder->index_hash, allocator);
374
+   lzma_free(coder, allocator);
375
+   return;
376
+}
377
+
378
+
379
+static lzma_check
380
+stream_decoder_get_check(const lzma_coder *coder)
381
+{
382
+   return coder->stream_flags.check;
383
+}
384
+
385
+
386
+static lzma_ret
387
+stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
388
+       uint64_t *old_memlimit, uint64_t new_memlimit)
389
+{
390
+   *memusage = coder->memusage;
391
+   *old_memlimit = coder->memlimit;
392
+
393
+   if (new_memlimit != 0) {
394
+       if (new_memlimit < coder->memusage)
395
+           return LZMA_MEMLIMIT_ERROR;
396
+
397
+       coder->memlimit = new_memlimit;
398
+   }
399
+
400
+   return LZMA_OK;
401
+}
402
+
403
+
404
+extern lzma_ret
405
+lzma_stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
406
+       uint64_t memlimit, uint32_t flags)
407
+{
408
+   lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator);
409
+
410
+   if (memlimit == 0)
411
+       return LZMA_PROG_ERROR;
412
+
413
+   if (flags & ~LZMA_SUPPORTED_FLAGS)
414
+       return LZMA_OPTIONS_ERROR;
415
+
416
+   if (next->coder == NULL) {
417
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
418
+       if (next->coder == NULL)
419
+           return LZMA_MEM_ERROR;
420
+
421
+       next->code = &stream_decode;
422
+       next->end = &stream_decoder_end;
423
+       next->get_check = &stream_decoder_get_check;
424
+       next->memconfig = &stream_decoder_memconfig;
425
+
426
+       next->coder->block_decoder = LZMA_NEXT_CODER_INIT;
427
+       next->coder->index_hash = NULL;
428
+   }
429
+
430
+   next->coder->memlimit = memlimit;
431
+   next->coder->memusage = LZMA_MEMUSAGE_BASE;
432
+   next->coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
433
+   next->coder->tell_unsupported_check
434
+           = (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0;
435
+   next->coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;
436
+   next->coder->concatenated = (flags & LZMA_CONCATENATED) != 0;
437
+   next->coder->first_stream = true;
438
+
439
+   return stream_decoder_reset(next->coder, allocator);
440
+}
441
+
442
+
443
+extern LZMA_API(lzma_ret)
444
+lzma_stream_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
445
+{
446
+   lzma_next_strm_init(lzma_stream_decoder_init, strm, memlimit, flags);
447
+
448
+   strm->internal->supported_actions[LZMA_RUN] = true;
449
+   strm->internal->supported_actions[LZMA_FINISH] = true;
450
+
451
+   return LZMA_OK;
452
+}
453
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_decoder.h Added
23
 
1
@@ -0,0 +1,21 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_decoder.h
5
+/// \brief      Decodes .xz Streams
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_STREAM_DECODER_H
15
+#define LZMA_STREAM_DECODER_H
16
+
17
+#include "common.h"
18
+
19
+extern lzma_ret lzma_stream_decoder_init(lzma_next_coder *next,
20
+       lzma_allocator *allocator, uint64_t memlimit, uint32_t flags);
21
+
22
+#endif
23
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_encoder.c Added
333
 
1
@@ -0,0 +1,331 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_encoder.c
5
+/// \brief      Encodes .xz Streams
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_encoder.h"
15
+#include "block_encoder.h"
16
+#include "index_encoder.h"
17
+
18
+
19
+struct lzma_coder_s {
20
+   enum {
21
+       SEQ_STREAM_HEADER,
22
+       SEQ_BLOCK_INIT,
23
+       SEQ_BLOCK_HEADER,
24
+       SEQ_BLOCK_ENCODE,
25
+       SEQ_INDEX_ENCODE,
26
+       SEQ_STREAM_FOOTER,
27
+   } sequence;
28
+
29
+   /// True if Block encoder has been initialized by
30
+   /// lzma_stream_encoder_init() or stream_encoder_update()
31
+   /// and thus doesn't need to be initialized in stream_encode().
32
+   bool block_encoder_is_initialized;
33
+
34
+   /// Block
35
+   lzma_next_coder block_encoder;
36
+
37
+   /// Options for the Block encoder
38
+   lzma_block block_options;
39
+
40
+   /// The filter chain currently in use
41
+   lzma_filter filters[LZMA_FILTERS_MAX + 1];
42
+
43
+   /// Index encoder. This is separate from Block encoder, because this
44
+   /// doesn't take much memory, and when encoding multiple Streams
45
+   /// with the same encoding options we avoid reallocating memory.
46
+   lzma_next_coder index_encoder;
47
+
48
+   /// Index to hold sizes of the Blocks
49
+   lzma_index *index;
50
+
51
+   /// Read position in buffer[]
52
+   size_t buffer_pos;
53
+
54
+   /// Total number of bytes in buffer[]
55
+   size_t buffer_size;
56
+
57
+   /// Buffer to hold Stream Header, Block Header, and Stream Footer.
58
+   /// Block Header has biggest maximum size.
59
+   uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];
60
+};
61
+
62
+
63
+static lzma_ret
64
+block_encoder_init(lzma_coder *coder, lzma_allocator *allocator)
65
+{
66
+   // Prepare the Block options. Even though Block encoder doesn't need
67
+   // compressed_size, uncompressed_size, and header_size to be
68
+   // initialized, it is a good idea to do it here, because this way
69
+   // we catch if someone gave us Filter ID that cannot be used in
70
+   // Blocks/Streams.
71
+   coder->block_options.compressed_size = LZMA_VLI_UNKNOWN;
72
+   coder->block_options.uncompressed_size = LZMA_VLI_UNKNOWN;
73
+
74
+   return_if_error(lzma_block_header_size(&coder->block_options));
75
+
76
+   // Initialize the actual Block encoder.
77
+   return lzma_block_encoder_init(&coder->block_encoder, allocator,
78
+           &coder->block_options);
79
+}
80
+
81
+
82
+static lzma_ret
83
+stream_encode(lzma_coder *coder, lzma_allocator *allocator,
84
+       const uint8_t *restrict in, size_t *restrict in_pos,
85
+       size_t in_size, uint8_t *restrict out,
86
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
87
+{
88
+   // Main loop
89
+   while (*out_pos < out_size)
90
+   switch (coder->sequence) {
91
+   case SEQ_STREAM_HEADER:
92
+   case SEQ_BLOCK_HEADER:
93
+   case SEQ_STREAM_FOOTER:
94
+       lzma_bufcpy(coder->buffer, &coder->buffer_pos,
95
+               coder->buffer_size, out, out_pos, out_size);
96
+       if (coder->buffer_pos < coder->buffer_size)
97
+           return LZMA_OK;
98
+
99
+       if (coder->sequence == SEQ_STREAM_FOOTER)
100
+           return LZMA_STREAM_END;
101
+
102
+       coder->buffer_pos = 0;
103
+       ++coder->sequence;
104
+       break;
105
+
106
+   case SEQ_BLOCK_INIT: {
107
+       if (*in_pos == in_size) {
108
+           // If we are requested to flush or finish the current
109
+           // Block, return LZMA_STREAM_END immediately since
110
+           // there's nothing to do.
111
+           if (action != LZMA_FINISH)
112
+               return action == LZMA_RUN
113
+                       ? LZMA_OK : LZMA_STREAM_END;
114
+
115
+           // The application had used LZMA_FULL_FLUSH to finish
116
+           // the previous Block, but now wants to finish without
117
+           // encoding new data, or it is simply creating an
118
+           // empty Stream with no Blocks.
119
+           //
120
+           // Initialize the Index encoder, and continue to
121
+           // actually encoding the Index.
122
+           return_if_error(lzma_index_encoder_init(
123
+                   &coder->index_encoder, allocator,
124
+                   coder->index));
125
+           coder->sequence = SEQ_INDEX_ENCODE;
126
+           break;
127
+       }
128
+
129
+       // Initialize the Block encoder unless it was already
130
+       // initialized by lzma_stream_encoder_init() or
131
+       // stream_encoder_update().
132
+       if (!coder->block_encoder_is_initialized)
133
+           return_if_error(block_encoder_init(coder, allocator));
134
+
135
+       // Make it false so that we don't skip the initialization
136
+       // with the next Block.
137
+       coder->block_encoder_is_initialized = false;
138
+
139
+       // Encode the Block Header. This shouldn't fail since we have
140
+       // already initialized the Block encoder.
141
+       if (lzma_block_header_encode(&coder->block_options,
142
+               coder->buffer) != LZMA_OK)
143
+           return LZMA_PROG_ERROR;
144
+
145
+       coder->buffer_size = coder->block_options.header_size;
146
+       coder->sequence = SEQ_BLOCK_HEADER;
147
+       break;
148
+   }
149
+
150
+   case SEQ_BLOCK_ENCODE: {
151
+       static const lzma_action convert[4] = {
152
+           LZMA_RUN,
153
+           LZMA_SYNC_FLUSH,
154
+           LZMA_FINISH,
155
+           LZMA_FINISH,
156
+       };
157
+
158
+       const lzma_ret ret = coder->block_encoder.code(
159
+               coder->block_encoder.coder, allocator,
160
+               in, in_pos, in_size,
161
+               out, out_pos, out_size, convert[action]);
162
+       if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH)
163
+           return ret;
164
+
165
+       // Add a new Index Record.
166
+       const lzma_vli unpadded_size = lzma_block_unpadded_size(
167
+               &coder->block_options);
168
+       assert(unpadded_size != 0);
169
+       return_if_error(lzma_index_append(coder->index, allocator,
170
+               unpadded_size,
171
+               coder->block_options.uncompressed_size));
172
+
173
+       coder->sequence = SEQ_BLOCK_INIT;
174
+       break;
175
+   }
176
+
177
+   case SEQ_INDEX_ENCODE: {
178
+       // Call the Index encoder. It doesn't take any input, so
179
+       // those pointers can be NULL.
180
+       const lzma_ret ret = coder->index_encoder.code(
181
+               coder->index_encoder.coder, allocator,
182
+               NULL, NULL, 0,
183
+               out, out_pos, out_size, LZMA_RUN);
184
+       if (ret != LZMA_STREAM_END)
185
+           return ret;
186
+
187
+       // Encode the Stream Footer into coder->buffer.
188
+       const lzma_stream_flags stream_flags = {
189
+           .version = 0,
190
+           .backward_size = lzma_index_size(coder->index),
191
+           .check = coder->block_options.check,
192
+       };
193
+
194
+       if (lzma_stream_footer_encode(&stream_flags, coder->buffer)
195
+               != LZMA_OK)
196
+           return LZMA_PROG_ERROR;
197
+
198
+       coder->buffer_size = LZMA_STREAM_HEADER_SIZE;
199
+       coder->sequence = SEQ_STREAM_FOOTER;
200
+       break;
201
+   }
202
+
203
+   default:
204
+       assert(0);
205
+       return LZMA_PROG_ERROR;
206
+   }
207
+
208
+   return LZMA_OK;
209
+}
210
+
211
+
212
+static void
213
+stream_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
214
+{
215
+   lzma_next_end(&coder->block_encoder, allocator);
216
+   lzma_next_end(&coder->index_encoder, allocator);
217
+   lzma_index_end(coder->index, allocator);
218
+
219
+   for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
220
+       lzma_free(coder->filters[i].options, allocator);
221
+
222
+   lzma_free(coder, allocator);
223
+   return;
224
+}
225
+
226
+
227
+static lzma_ret
228
+stream_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
229
+       const lzma_filter *filters,
230
+       const lzma_filter *reversed_filters)
231
+{
232
+   if (coder->sequence <= SEQ_BLOCK_INIT) {
233
+       // There is no incomplete Block waiting to be finished,
234
+       // thus we can change the whole filter chain. Start by
235
+       // trying to initialize the Block encoder with the new
236
+       // chain. This way we detect if the chain is valid.
237
+       coder->block_encoder_is_initialized = false;
238
+       coder->block_options.filters = (lzma_filter *)(filters);
239
+       const lzma_ret ret = block_encoder_init(coder, allocator);
240
+       coder->block_options.filters = coder->filters;
241
+       if (ret != LZMA_OK)
242
+           return ret;
243
+
244
+       coder->block_encoder_is_initialized = true;
245
+
246
+   } else if (coder->sequence <= SEQ_BLOCK_ENCODE) {
247
+       // We are in the middle of a Block. Try to update only
248
+       // the filter-specific options.
249
+       return_if_error(coder->block_encoder.update(
250
+               coder->block_encoder.coder, allocator,
251
+               filters, reversed_filters));
252
+   } else {
253
+       // Trying to update the filter chain when we are already
254
+       // encoding Index or Stream Footer.
255
+       return LZMA_PROG_ERROR;
256
+   }
257
+
258
+   // Free the copy of the old chain and make a copy of the new chain.
259
+   for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
260
+       lzma_free(coder->filters[i].options, allocator);
261
+
262
+   return lzma_filters_copy(filters, coder->filters, allocator);
263
+}
264
+
265
+
266
+extern lzma_ret
267
+lzma_stream_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
268
+       const lzma_filter *filters, lzma_check check)
269
+{
270
+   lzma_next_coder_init(&lzma_stream_encoder_init, next, allocator);
271
+
272
+   if (filters == NULL)
273
+       return LZMA_PROG_ERROR;
274
+
275
+   if (next->coder == NULL) {
276
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
277
+       if (next->coder == NULL)
278
+           return LZMA_MEM_ERROR;
279
+
280
+       next->code = &stream_encode;
281
+       next->end = &stream_encoder_end;
282
+       next->update = &stream_encoder_update;
283
+
284
+       next->coder->filters[0].id = LZMA_VLI_UNKNOWN;
285
+       next->coder->block_encoder = LZMA_NEXT_CODER_INIT;
286
+       next->coder->index_encoder = LZMA_NEXT_CODER_INIT;
287
+       next->coder->index = NULL;
288
+   }
289
+
290
+   // Basic initializations
291
+   next->coder->sequence = SEQ_STREAM_HEADER;
292
+   next->coder->block_options.version = 0;
293
+   next->coder->block_options.check = check;
294
+
295
+   // Initialize the Index
296
+   lzma_index_end(next->coder->index, allocator);
297
+   next->coder->index = lzma_index_init(allocator);
298
+   if (next->coder->index == NULL)
299
+       return LZMA_MEM_ERROR;
300
+
301
+   // Encode the Stream Header
302
+   lzma_stream_flags stream_flags = {
303
+       .version = 0,
304
+       .check = check,
305
+   };
306
+   return_if_error(lzma_stream_header_encode(
307
+           &stream_flags, next->coder->buffer));
308
+
309
+   next->coder->buffer_pos = 0;
310
+   next->coder->buffer_size = LZMA_STREAM_HEADER_SIZE;
311
+
312
+   // Initialize the Block encoder. This way we detect unsupported
313
+   // filter chains when initializing the Stream encoder instead of
314
+   // giving an error after Stream Header has already written out.
315
+   return stream_encoder_update(
316
+           next->coder, allocator, filters, NULL);
317
+}
318
+
319
+
320
+extern LZMA_API(lzma_ret)
321
+lzma_stream_encoder(lzma_stream *strm,
322
+       const lzma_filter *filters, lzma_check check)
323
+{
324
+   lzma_next_strm_init(lzma_stream_encoder_init, strm, filters, check);
325
+
326
+   strm->internal->supported_actions[LZMA_RUN] = true;
327
+   strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
328
+   strm->internal->supported_actions[LZMA_FULL_FLUSH] = true;
329
+   strm->internal->supported_actions[LZMA_FINISH] = true;
330
+
331
+   return LZMA_OK;
332
+}
333
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_encoder.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_encoder.h
5
+/// \brief      Encodes .xz Streams
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_STREAM_ENCODER_H
15
+#define LZMA_STREAM_ENCODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+extern lzma_ret lzma_stream_encoder_init(
21
+       lzma_next_coder *next, lzma_allocator *allocator,
22
+       const lzma_filter *filters, lzma_check check);
23
+
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_flags_common.c Added
49
 
1
@@ -0,0 +1,47 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_flags_common.c
5
+/// \brief      Common stuff for Stream flags coders
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_flags_common.h"
15
+
16
+
17
+const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 };
18
+const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A };
19
+
20
+
21
+extern LZMA_API(lzma_ret)
22
+lzma_stream_flags_compare(
23
+       const lzma_stream_flags *a, const lzma_stream_flags *b)
24
+{
25
+   // We can compare only version 0 structures.
26
+   if (a->version != 0 || b->version != 0)
27
+       return LZMA_OPTIONS_ERROR;
28
+
29
+   // Check type
30
+   if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX
31
+           || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX)
32
+       return LZMA_PROG_ERROR;
33
+
34
+   if (a->check != b->check)
35
+       return LZMA_DATA_ERROR;
36
+
37
+   // Backward Sizes are compared only if they are known in both.
38
+   if (a->backward_size != LZMA_VLI_UNKNOWN
39
+           && b->backward_size != LZMA_VLI_UNKNOWN) {
40
+       if (!is_backward_size_valid(a) || !is_backward_size_valid(b))
41
+           return LZMA_PROG_ERROR;
42
+
43
+       if (a->backward_size != b->backward_size)
44
+           return LZMA_DATA_ERROR;
45
+   }
46
+
47
+   return LZMA_OK;
48
+}
49
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_flags_common.h Added
35
 
1
@@ -0,0 +1,33 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_flags_common.h
5
+/// \brief      Common stuff for Stream flags coders
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_STREAM_FLAGS_COMMON_H
15
+#define LZMA_STREAM_FLAGS_COMMON_H
16
+
17
+#include "common.h"
18
+
19
+/// Size of the Stream Flags field
20
+#define LZMA_STREAM_FLAGS_SIZE 2
21
+
22
+extern const uint8_t lzma_header_magic[6];
23
+extern const uint8_t lzma_footer_magic[2];
24
+
25
+
26
+static inline bool
27
+is_backward_size_valid(const lzma_stream_flags *options)
28
+{
29
+   return options->backward_size >= LZMA_BACKWARD_SIZE_MIN
30
+           && options->backward_size <= LZMA_BACKWARD_SIZE_MAX
31
+           && (options->backward_size & 3) == 0;
32
+}
33
+
34
+#endif
35
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_flags_decoder.c Added
84
 
1
@@ -0,0 +1,82 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_flags_decoder.c
5
+/// \brief      Decodes Stream Header and Stream Footer from .xz files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_flags_common.h"
15
+
16
+
17
+static bool
18
+stream_flags_decode(lzma_stream_flags *options, const uint8_t *in)
19
+{
20
+   // Reserved bits must be unset.
21
+   if (in[0] != 0x00 || (in[1] & 0xF0))
22
+       return true;
23
+
24
+   options->version = 0;
25
+   options->check = in[1] & 0x0F;
26
+
27
+   return false;
28
+}
29
+
30
+
31
+extern LZMA_API(lzma_ret)
32
+lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in)
33
+{
34
+   // Magic
35
+   if (memcmp(in, lzma_header_magic, sizeof(lzma_header_magic)) != 0)
36
+       return LZMA_FORMAT_ERROR;
37
+
38
+   // Verify the CRC32 so we can distinguish between corrupt
39
+   // and unsupported files.
40
+   const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic),
41
+           LZMA_STREAM_FLAGS_SIZE, 0);
42
+   if (crc != unaligned_read32le(in + sizeof(lzma_header_magic)
43
+           + LZMA_STREAM_FLAGS_SIZE))
44
+       return LZMA_DATA_ERROR;
45
+
46
+   // Stream Flags
47
+   if (stream_flags_decode(options, in + sizeof(lzma_header_magic)))
48
+       return LZMA_OPTIONS_ERROR;
49
+
50
+   // Set Backward Size to indicate unknown value. That way
51
+   // lzma_stream_flags_compare() can be used to compare Stream Header
52
+   // and Stream Footer while keeping it useful also for comparing
53
+   // two Stream Footers.
54
+   options->backward_size = LZMA_VLI_UNKNOWN;
55
+
56
+   return LZMA_OK;
57
+}
58
+
59
+
60
+extern LZMA_API(lzma_ret)
61
+lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in)
62
+{
63
+   // Magic
64
+   if (memcmp(in + sizeof(uint32_t) * 2 + LZMA_STREAM_FLAGS_SIZE,
65
+           lzma_footer_magic, sizeof(lzma_footer_magic)) != 0)
66
+       return LZMA_FORMAT_ERROR;
67
+
68
+   // CRC32
69
+   const uint32_t crc = lzma_crc32(in + sizeof(uint32_t),
70
+           sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0);
71
+   if (crc != unaligned_read32le(in))
72
+       return LZMA_DATA_ERROR;
73
+
74
+   // Stream Flags
75
+   if (stream_flags_decode(options, in + sizeof(uint32_t) * 2))
76
+       return LZMA_OPTIONS_ERROR;
77
+
78
+   // Backward Size
79
+   options->backward_size = unaligned_read32le(in + sizeof(uint32_t));
80
+   options->backward_size = (options->backward_size + 1) * 4;
81
+
82
+   return LZMA_OK;
83
+}
84
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/stream_flags_encoder.c Added
88
 
1
@@ -0,0 +1,86 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       stream_flags_encoder.c
5
+/// \brief      Encodes Stream Header and Stream Footer for .xz files
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "stream_flags_common.h"
15
+
16
+
17
+static bool
18
+stream_flags_encode(const lzma_stream_flags *options, uint8_t *out)
19
+{
20
+   if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)
21
+       return true;
22
+
23
+   out[0] = 0x00;
24
+   out[1] = options->check;
25
+
26
+   return false;
27
+}
28
+
29
+
30
+extern LZMA_API(lzma_ret)
31
+lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)
32
+{
33
+   assert(sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE
34
+           + 4 == LZMA_STREAM_HEADER_SIZE);
35
+
36
+   if (options->version != 0)
37
+       return LZMA_OPTIONS_ERROR;
38
+
39
+   // Magic
40
+   memcpy(out, lzma_header_magic, sizeof(lzma_header_magic));
41
+
42
+   // Stream Flags
43
+   if (stream_flags_encode(options, out + sizeof(lzma_header_magic)))
44
+       return LZMA_PROG_ERROR;
45
+
46
+   // CRC32 of the Stream Header
47
+   const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic),
48
+           LZMA_STREAM_FLAGS_SIZE, 0);
49
+
50
+   unaligned_write32le(out + sizeof(lzma_header_magic)
51
+           + LZMA_STREAM_FLAGS_SIZE, crc);
52
+
53
+   return LZMA_OK;
54
+}
55
+
56
+
57
+extern LZMA_API(lzma_ret)
58
+lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)
59
+{
60
+   assert(2 * 4 + LZMA_STREAM_FLAGS_SIZE + sizeof(lzma_footer_magic)
61
+           == LZMA_STREAM_HEADER_SIZE);
62
+
63
+   if (options->version != 0)
64
+       return LZMA_OPTIONS_ERROR;
65
+
66
+   // Backward Size
67
+   if (!is_backward_size_valid(options))
68
+       return LZMA_PROG_ERROR;
69
+
70
+   unaligned_write32le(out + 4, options->backward_size / 4 - 1);
71
+
72
+   // Stream Flags
73
+   if (stream_flags_encode(options, out + 2 * 4))
74
+       return LZMA_PROG_ERROR;
75
+
76
+   // CRC32
77
+   const uint32_t crc = lzma_crc32(
78
+           out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0);
79
+
80
+   unaligned_write32le(out, crc);
81
+
82
+   // Magic
83
+   memcpy(out + 2 * 4 + LZMA_STREAM_FLAGS_SIZE,
84
+           lzma_footer_magic, sizeof(lzma_footer_magic));
85
+
86
+   return LZMA_OK;
87
+}
88
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/vli_decoder.c Added
88
 
1
@@ -0,0 +1,86 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       vli_decoder.c
5
+/// \brief      Decodes variable-length integers
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos,
19
+       const uint8_t *restrict in, size_t *restrict in_pos,
20
+       size_t in_size)
21
+{
22
+   // If we haven't been given vli_pos, work in single-call mode.
23
+   size_t vli_pos_internal = 0;
24
+   if (vli_pos == NULL) {
25
+       vli_pos = &vli_pos_internal;
26
+       *vli = 0;
27
+
28
+       // If there's no input, use LZMA_DATA_ERROR. This way it is
29
+       // easy to decode VLIs from buffers that have known size,
30
+       // and get the correct error code in case the buffer is
31
+       // too short.
32
+       if (*in_pos >= in_size)
33
+           return LZMA_DATA_ERROR;
34
+
35
+   } else {
36
+       // Initialize *vli when starting to decode a new integer.
37
+       if (*vli_pos == 0)
38
+           *vli = 0;
39
+
40
+       // Validate the arguments.
41
+       if (*vli_pos >= LZMA_VLI_BYTES_MAX
42
+               || (*vli >> (*vli_pos * 7)) != 0)
43
+           return LZMA_PROG_ERROR;;
44
+
45
+       if (*in_pos >= in_size)
46
+           return LZMA_BUF_ERROR;
47
+   }
48
+
49
+   do {
50
+       // Read the next byte. Use a temporary variable so that we
51
+       // can update *in_pos immediately.
52
+       const uint8_t byte = in[*in_pos];
53
+       ++*in_pos;
54
+
55
+       // Add the newly read byte to *vli.
56
+       *vli += (lzma_vli)(byte & 0x7F) << (*vli_pos * 7);
57
+       ++*vli_pos;
58
+
59
+       // Check if this is the last byte of a multibyte integer.
60
+       if ((byte & 0x80) == 0) {
61
+           // We don't allow using variable-length integers as
62
+           // padding i.e. the encoding must use the most the
63
+           // compact form.
64
+           if (byte == 0x00 && *vli_pos > 1)
65
+               return LZMA_DATA_ERROR;
66
+
67
+           return vli_pos == &vli_pos_internal
68
+                   ? LZMA_OK : LZMA_STREAM_END;
69
+       }
70
+
71
+       // There is at least one more byte coming. If we have already
72
+       // read maximum number of bytes, the integer is considered
73
+       // corrupt.
74
+       //
75
+       // If we need bigger integers in future, old versions liblzma
76
+       // will confusingly indicate the file being corrupt istead of
77
+       // unsupported. I suppose it's still better this way, because
78
+       // in the foreseeable future (writing this in 2008) the only
79
+       // reason why files would appear having over 63-bit integers
80
+       // is that the files are simply corrupt.
81
+       if (*vli_pos == LZMA_VLI_BYTES_MAX)
82
+           return LZMA_DATA_ERROR;
83
+
84
+   } while (*in_pos < in_size);
85
+
86
+   return vli_pos == &vli_pos_internal ? LZMA_DATA_ERROR : LZMA_OK;
87
+}
88
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/vli_encoder.c Added
71
 
1
@@ -0,0 +1,69 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       vli_encoder.c
5
+/// \brief      Encodes variable-length integers
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+
17
+extern LZMA_API(lzma_ret)
18
+lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
19
+       uint8_t *restrict out, size_t *restrict out_pos,
20
+       size_t out_size)
21
+{
22
+   // If we haven't been given vli_pos, work in single-call mode.
23
+   size_t vli_pos_internal = 0;
24
+   if (vli_pos == NULL) {
25
+       vli_pos = &vli_pos_internal;
26
+
27
+       // In single-call mode, we expect that the caller has
28
+       // reserved enough output space.
29
+       if (*out_pos >= out_size)
30
+           return LZMA_PROG_ERROR;
31
+   } else {
32
+       // This never happens when we are called by liblzma, but
33
+       // may happen if called directly from an application.
34
+       if (*out_pos >= out_size)
35
+           return LZMA_BUF_ERROR;
36
+   }
37
+
38
+   // Validate the arguments.
39
+   if (*vli_pos >= LZMA_VLI_BYTES_MAX || vli > LZMA_VLI_MAX)
40
+       return LZMA_PROG_ERROR;
41
+
42
+   // Shift vli so that the next bits to encode are the lowest. In
43
+   // single-call mode this never changes vli since *vli_pos is zero.
44
+   vli >>= *vli_pos * 7;
45
+
46
+   // Write the non-last bytes in a loop.
47
+   while (vli >= 0x80) {
48
+       // We don't need *vli_pos during this function call anymore,
49
+       // but update it here so that it is ready if we need to
50
+       // return before the whole integer has been decoded.
51
+       ++*vli_pos;
52
+       assert(*vli_pos < LZMA_VLI_BYTES_MAX);
53
+
54
+       // Write the next byte.
55
+       out[*out_pos] = (uint8_t)(vli) | 0x80;
56
+       vli >>= 7;
57
+
58
+       if (++*out_pos == out_size)
59
+           return vli_pos == &vli_pos_internal
60
+                   ? LZMA_PROG_ERROR : LZMA_OK;
61
+   }
62
+
63
+   // Write the last byte.
64
+   out[*out_pos] = (uint8_t)(vli);
65
+   ++*out_pos;
66
+   ++*vli_pos;
67
+
68
+   return vli_pos == &vli_pos_internal ? LZMA_OK : LZMA_STREAM_END;
69
+
70
+}
71
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/common/vli_size.c Added
32
 
1
@@ -0,0 +1,30 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       vli_size.c
5
+/// \brief      Calculates the encoded size of a variable-length integer
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+
17
+extern LZMA_API(uint32_t)
18
+lzma_vli_size(lzma_vli vli)
19
+{
20
+   if (vli > LZMA_VLI_MAX)
21
+       return 0;
22
+
23
+   uint32_t i = 0;
24
+   do {
25
+       vli >>= 7;
26
+       ++i;
27
+   } while (vli != 0);
28
+
29
+   assert(i <= LZMA_VLI_BYTES_MAX);
30
+   return i;
31
+}
32
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/Makefile.inc Added
25
 
1
@@ -0,0 +1,23 @@
2
+##
3
+## Author: Lasse Collin
4
+##
5
+## This file has been put into the public domain.
6
+## You can do whatever you want with this file.
7
+##
8
+
9
+liblzma_la_SOURCES += \
10
+   delta/delta_common.c \
11
+   delta/delta_common.h \
12
+   delta/delta_private.h
13
+
14
+if COND_ENCODER_DELTA
15
+liblzma_la_SOURCES += \
16
+   delta/delta_encoder.c \
17
+   delta/delta_encoder.h
18
+endif
19
+
20
+if COND_DECODER_DELTA
21
+liblzma_la_SOURCES += \
22
+   delta/delta_decoder.c \
23
+   delta/delta_decoder.h
24
+endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_common.c Added
72
 
1
@@ -0,0 +1,70 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_common.c
5
+/// \brief      Common stuff for Delta encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "delta_common.h"
15
+#include "delta_private.h"
16
+
17
+
18
+static void
19
+delta_coder_end(lzma_coder *coder, lzma_allocator *allocator)
20
+{
21
+   lzma_next_end(&coder->next, allocator);
22
+   lzma_free(coder, allocator);
23
+   return;
24
+}
25
+
26
+
27
+extern lzma_ret
28
+lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
29
+       const lzma_filter_info *filters)
30
+{
31
+   // Allocate memory for the decoder if needed.
32
+   if (next->coder == NULL) {
33
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
34
+       if (next->coder == NULL)
35
+           return LZMA_MEM_ERROR;
36
+
37
+       // End function is the same for encoder and decoder.
38
+       next->end = &delta_coder_end;
39
+       next->coder->next = LZMA_NEXT_CODER_INIT;
40
+   }
41
+
42
+   // Validate the options.
43
+   if (lzma_delta_coder_memusage(filters[0].options) == UINT64_MAX)
44
+       return LZMA_OPTIONS_ERROR;
45
+
46
+   // Set the delta distance.
47
+   const lzma_options_delta *opt = filters[0].options;
48
+   next->coder->distance = opt->dist;
49
+
50
+   // Initialize the rest of the variables.
51
+   next->coder->pos = 0;
52
+   memzero(next->coder->history, LZMA_DELTA_DIST_MAX);
53
+
54
+   // Initialize the next decoder in the chain, if any.
55
+   return lzma_next_filter_init(&next->coder->next,
56
+           allocator, filters + 1);
57
+}
58
+
59
+
60
+extern uint64_t
61
+lzma_delta_coder_memusage(const void *options)
62
+{
63
+   const lzma_options_delta *opt = options;
64
+
65
+   if (opt == NULL || opt->type != LZMA_DELTA_TYPE_BYTE
66
+           || opt->dist < LZMA_DELTA_DIST_MIN
67
+           || opt->dist > LZMA_DELTA_DIST_MAX)
68
+       return UINT64_MAX;
69
+
70
+   return sizeof(lzma_coder);
71
+}
72
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_common.h Added
22
 
1
@@ -0,0 +1,20 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_common.h
5
+/// \brief      Common stuff for Delta encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_DELTA_COMMON_H
15
+#define LZMA_DELTA_COMMON_H
16
+
17
+#include "common.h"
18
+
19
+extern uint64_t lzma_delta_coder_memusage(const void *options);
20
+
21
+#endif
22
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_decoder.c Added
78
 
1
@@ -0,0 +1,76 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_decoder.c
5
+/// \brief      Delta filter decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "delta_decoder.h"
15
+#include "delta_private.h"
16
+
17
+
18
+static void
19
+decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size)
20
+{
21
+   const size_t distance = coder->distance;
22
+
23
+   for (size_t i = 0; i < size; ++i) {
24
+       buffer[i] += coder->history[(distance + coder->pos) & 0xFF];
25
+       coder->history[coder->pos-- & 0xFF] = buffer[i];
26
+   }
27
+}
28
+
29
+
30
+static lzma_ret
31
+delta_decode(lzma_coder *coder, lzma_allocator *allocator,
32
+       const uint8_t *restrict in, size_t *restrict in_pos,
33
+       size_t in_size, uint8_t *restrict out,
34
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
35
+{
36
+   assert(coder->next.code != NULL);
37
+
38
+   const size_t out_start = *out_pos;
39
+
40
+   const lzma_ret ret = coder->next.code(coder->next.coder, allocator,
41
+           in, in_pos, in_size, out, out_pos, out_size,
42
+           action);
43
+
44
+   decode_buffer(coder, out + out_start, *out_pos - out_start);
45
+
46
+   return ret;
47
+}
48
+
49
+
50
+extern lzma_ret
51
+lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
52
+       const lzma_filter_info *filters)
53
+{
54
+   next->code = &delta_decode;
55
+   return lzma_delta_coder_init(next, allocator, filters);
56
+}
57
+
58
+
59
+extern lzma_ret
60
+lzma_delta_props_decode(void **options, lzma_allocator *allocator,
61
+       const uint8_t *props, size_t props_size)
62
+{
63
+   if (props_size != 1)
64
+       return LZMA_OPTIONS_ERROR;
65
+
66
+   lzma_options_delta *opt
67
+           = lzma_alloc(sizeof(lzma_options_delta), allocator);
68
+   if (opt == NULL)
69
+       return LZMA_MEM_ERROR;
70
+
71
+   opt->type = LZMA_DELTA_TYPE_BYTE;
72
+   opt->dist = props[0] + 1;
73
+
74
+   *options = opt;
75
+
76
+   return LZMA_OK;
77
+}
78
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_decoder.h Added
27
 
1
@@ -0,0 +1,25 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_decoder.h
5
+/// \brief      Delta filter decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_DELTA_DECODER_H
15
+#define LZMA_DELTA_DECODER_H
16
+
17
+#include "delta_common.h"
18
+
19
+extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next,
20
+       lzma_allocator *allocator, const lzma_filter_info *filters);
21
+
22
+extern lzma_ret lzma_delta_props_decode(
23
+       void **options, lzma_allocator *allocator,
24
+       const uint8_t *props, size_t props_size);
25
+
26
+#endif
27
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_encoder.c Added
123
 
1
@@ -0,0 +1,121 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_encoder.c
5
+/// \brief      Delta filter encoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "delta_encoder.h"
15
+#include "delta_private.h"
16
+
17
+
18
+/// Copies and encodes the data at the same time. This is used when Delta
19
+/// is the first filter in the chain (and thus the last filter in the
20
+/// encoder's filter stack).
21
+static void
22
+copy_and_encode(lzma_coder *coder,
23
+       const uint8_t *restrict in, uint8_t *restrict out, size_t size)
24
+{
25
+   const size_t distance = coder->distance;
26
+
27
+   for (size_t i = 0; i < size; ++i) {
28
+       const uint8_t tmp = coder->history[
29
+               (distance + coder->pos) & 0xFF];
30
+       coder->history[coder->pos-- & 0xFF] = in[i];
31
+       out[i] = in[i] - tmp;
32
+   }
33
+}
34
+
35
+
36
+/// Encodes the data in place. This is used when we are the last filter
37
+/// in the chain (and thus non-last filter in the encoder's filter stack).
38
+static void
39
+encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size)
40
+{
41
+   const size_t distance = coder->distance;
42
+
43
+   for (size_t i = 0; i < size; ++i) {
44
+       const uint8_t tmp = coder->history[
45
+               (distance + coder->pos) & 0xFF];
46
+       coder->history[coder->pos-- & 0xFF] = buffer[i];
47
+       buffer[i] -= tmp;
48
+   }
49
+}
50
+
51
+
52
+static lzma_ret
53
+delta_encode(lzma_coder *coder, lzma_allocator *allocator,
54
+       const uint8_t *restrict in, size_t *restrict in_pos,
55
+       size_t in_size, uint8_t *restrict out,
56
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
57
+{
58
+   lzma_ret ret;
59
+
60
+   if (coder->next.code == NULL) {
61
+       const size_t in_avail = in_size - *in_pos;
62
+       const size_t out_avail = out_size - *out_pos;
63
+       const size_t size = my_min(in_avail, out_avail);
64
+
65
+       copy_and_encode(coder, in + *in_pos, out + *out_pos, size);
66
+
67
+       *in_pos += size;
68
+       *out_pos += size;
69
+
70
+       ret = action != LZMA_RUN && *in_pos == in_size
71
+               ? LZMA_STREAM_END : LZMA_OK;
72
+
73
+   } else {
74
+       const size_t out_start = *out_pos;
75
+
76
+       ret = coder->next.code(coder->next.coder, allocator,
77
+               in, in_pos, in_size, out, out_pos, out_size,
78
+               action);
79
+
80
+       encode_in_place(coder, out + out_start, *out_pos - out_start);
81
+   }
82
+
83
+   return ret;
84
+}
85
+
86
+
87
+static lzma_ret
88
+delta_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
89
+       const lzma_filter *filters_null lzma_attribute((__unused__)),
90
+       const lzma_filter *reversed_filters)
91
+{
92
+   // Delta doesn't and will never support changing the options in
93
+   // the middle of encoding. If the app tries to change them, we
94
+   // simply ignore them.
95
+   return lzma_next_filter_update(
96
+           &coder->next, allocator, reversed_filters + 1);
97
+}
98
+
99
+
100
+extern lzma_ret
101
+lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
102
+       const lzma_filter_info *filters)
103
+{
104
+   next->code = &delta_encode;
105
+   next->update = &delta_encoder_update;
106
+   return lzma_delta_coder_init(next, allocator, filters);
107
+}
108
+
109
+
110
+extern lzma_ret
111
+lzma_delta_props_encode(const void *options, uint8_t *out)
112
+{
113
+   // The caller must have already validated the options, so it's
114
+   // LZMA_PROG_ERROR if they are invalid.
115
+   if (lzma_delta_coder_memusage(options) == UINT64_MAX)
116
+       return LZMA_PROG_ERROR;
117
+
118
+   const lzma_options_delta *opt = options;
119
+   out[0] = opt->dist - LZMA_DELTA_DIST_MIN;
120
+
121
+   return LZMA_OK;
122
+}
123
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_encoder.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_encoder.h
5
+/// \brief      Delta filter encoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_DELTA_ENCODER_H
15
+#define LZMA_DELTA_ENCODER_H
16
+
17
+#include "delta_common.h"
18
+
19
+extern lzma_ret lzma_delta_encoder_init(lzma_next_coder *next,
20
+       lzma_allocator *allocator, const lzma_filter_info *filters);
21
+
22
+extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out);
23
+
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/delta/delta_private.h Added
39
 
1
@@ -0,0 +1,37 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       delta_private.h
5
+/// \brief      Private common stuff for Delta encoder and decoder
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_DELTA_PRIVATE_H
15
+#define LZMA_DELTA_PRIVATE_H
16
+
17
+#include "delta_common.h"
18
+
19
+struct lzma_coder_s {
20
+   /// Next coder in the chain
21
+   lzma_next_coder next;
22
+
23
+   /// Delta distance
24
+   size_t distance;
25
+
26
+   /// Position in history[]
27
+   uint8_t pos;
28
+
29
+   /// Buffer to hold history of the original data
30
+   uint8_t history[LZMA_DELTA_DIST_MAX];
31
+};
32
+
33
+
34
+extern lzma_ret lzma_delta_coder_init(
35
+       lzma_next_coder *next, lzma_allocator *allocator,
36
+       const lzma_filter_info *filters);
37
+
38
+#endif
39
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/Makefile.inc Added
24
 
1
@@ -0,0 +1,22 @@
2
+##
3
+## Author: Lasse Collin
4
+##
5
+## This file has been put into the public domain.
6
+## You can do whatever you want with this file.
7
+##
8
+
9
+if COND_ENCODER_LZ
10
+liblzma_la_SOURCES += \
11
+   lz/lz_encoder.c \
12
+   lz/lz_encoder.h \
13
+   lz/lz_encoder_hash.h \
14
+   lz/lz_encoder_hash_table.h \
15
+   lz/lz_encoder_mf.c
16
+endif
17
+
18
+
19
+if COND_DECODER_LZ
20
+liblzma_la_SOURCES += \
21
+   lz/lz_decoder.c \
22
+   lz/lz_decoder.h
23
+endif
24
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_decoder.c Added
302
 
1
@@ -0,0 +1,300 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lz_decoder.c
5
+/// \brief      LZ out window
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+// liblzma supports multiple LZ77-based filters. The LZ part is shared
16
+// between these filters. The LZ code takes care of dictionary handling
17
+// and passing the data between filters in the chain. The filter-specific
18
+// part decodes from the input buffer to the dictionary.
19
+
20
+
21
+#include "lz_decoder.h"
22
+
23
+
24
+struct lzma_coder_s {
25
+   /// Dictionary (history buffer)
26
+   lzma_dict dict;
27
+
28
+   /// The actual LZ-based decoder e.g. LZMA
29
+   lzma_lz_decoder lz;
30
+
31
+   /// Next filter in the chain, if any. Note that LZMA and LZMA2 are
32
+   /// only allowed as the last filter, but the long-range filter in
33
+   /// future can be in the middle of the chain.
34
+   lzma_next_coder next;
35
+
36
+   /// True if the next filter in the chain has returned LZMA_STREAM_END.
37
+   bool next_finished;
38
+
39
+   /// True if the LZ decoder (e.g. LZMA) has detected end of payload
40
+   /// marker. This may become true before next_finished becomes true.
41
+   bool this_finished;
42
+
43
+   /// Temporary buffer needed when the LZ-based filter is not the last
44
+   /// filter in the chain. The output of the next filter is first
45
+   /// decoded into buffer[], which is then used as input for the actual
46
+   /// LZ-based decoder.
47
+   struct {
48
+       size_t pos;
49
+       size_t size;
50
+       uint8_t buffer[LZMA_BUFFER_SIZE];
51
+   } temp;
52
+};
53
+
54
+
55
+static void
56
+lz_decoder_reset(lzma_coder *coder)
57
+{
58
+   coder->dict.pos = 0;
59
+   coder->dict.full = 0;
60
+   coder->dict.buf[coder->dict.size - 1] = '\0';
61
+   coder->dict.need_reset = false;
62
+   return;
63
+}
64
+
65
+
66
+static lzma_ret
67
+decode_buffer(lzma_coder *coder,
68
+       const uint8_t *restrict in, size_t *restrict in_pos,
69
+       size_t in_size, uint8_t *restrict out,
70
+       size_t *restrict out_pos, size_t out_size)
71
+{
72
+   while (true) {
73
+       // Wrap the dictionary if needed.
74
+       if (coder->dict.pos == coder->dict.size)
75
+           coder->dict.pos = 0;
76
+
77
+       // Store the current dictionary position. It is needed to know
78
+       // where to start copying to the out[] buffer.
79
+       const size_t dict_start = coder->dict.pos;
80
+
81
+       // Calculate how much we allow coder->lz.code() to decode.
82
+       // It must not decode past the end of the dictionary
83
+       // buffer, and we don't want it to decode more than is
84
+       // actually needed to fill the out[] buffer.
85
+       coder->dict.limit = coder->dict.pos
86
+               + my_min(out_size - *out_pos,
87
+                   coder->dict.size - coder->dict.pos);
88
+
89
+       // Call the coder->lz.code() to do the actual decoding.
90
+       const lzma_ret ret = coder->lz.code(
91
+               coder->lz.coder, &coder->dict,
92
+               in, in_pos, in_size);
93
+
94
+       // Copy the decoded data from the dictionary to the out[]
95
+       // buffer.
96
+       const size_t copy_size = coder->dict.pos - dict_start;
97
+       assert(copy_size <= out_size - *out_pos);
98
+       memcpy(out + *out_pos, coder->dict.buf + dict_start,
99
+               copy_size);
100
+       *out_pos += copy_size;
101
+
102
+       // Reset the dictionary if so requested by coder->lz.code().
103
+       if (coder->dict.need_reset) {
104
+           lz_decoder_reset(coder);
105
+
106
+           // Since we reset dictionary, we don't check if
107
+           // dictionary became full.
108
+           if (ret != LZMA_OK || *out_pos == out_size)
109
+               return ret;
110
+       } else {
111
+           // Return if everything got decoded or an error
112
+           // occurred, or if there's no more data to decode.
113
+           //
114
+           // Note that detecting if there's something to decode
115
+           // is done by looking if dictionary become full
116
+           // instead of looking if *in_pos == in_size. This
117
+           // is because it is possible that all the input was
118
+           // consumed already but some data is pending to be
119
+           // written to the dictionary.
120
+           if (ret != LZMA_OK || *out_pos == out_size
121
+                   || coder->dict.pos < coder->dict.size)
122
+               return ret;
123
+       }
124
+   }
125
+}
126
+
127
+
128
+static lzma_ret
129
+lz_decode(lzma_coder *coder,
130
+       lzma_allocator *allocator lzma_attribute((__unused__)),
131
+       const uint8_t *restrict in, size_t *restrict in_pos,
132
+       size_t in_size, uint8_t *restrict out,
133
+       size_t *restrict out_pos, size_t out_size,
134
+       lzma_action action)
135
+{
136
+   if (coder->next.code == NULL)
137
+       return decode_buffer(coder, in, in_pos, in_size,
138
+               out, out_pos, out_size);
139
+
140
+   // We aren't the last coder in the chain, we need to decode
141
+   // our input to a temporary buffer.
142
+   while (*out_pos < out_size) {
143
+       // Fill the temporary buffer if it is empty.
144
+       if (!coder->next_finished
145
+               && coder->temp.pos == coder->temp.size) {
146
+           coder->temp.pos = 0;
147
+           coder->temp.size = 0;
148
+
149
+           const lzma_ret ret = coder->next.code(
150
+                   coder->next.coder,
151
+                   allocator, in, in_pos, in_size,
152
+                   coder->temp.buffer, &coder->temp.size,
153
+                   LZMA_BUFFER_SIZE, action);
154
+
155
+           if (ret == LZMA_STREAM_END)
156
+               coder->next_finished = true;
157
+           else if (ret != LZMA_OK || coder->temp.size == 0)
158
+               return ret;
159
+       }
160
+
161
+       if (coder->this_finished) {
162
+           if (coder->temp.size != 0)
163
+               return LZMA_DATA_ERROR;
164
+
165
+           if (coder->next_finished)
166
+               return LZMA_STREAM_END;
167
+
168
+           return LZMA_OK;
169
+       }
170
+
171
+       const lzma_ret ret = decode_buffer(coder, coder->temp.buffer,
172
+               &coder->temp.pos, coder->temp.size,
173
+               out, out_pos, out_size);
174
+
175
+       if (ret == LZMA_STREAM_END)
176
+           coder->this_finished = true;
177
+       else if (ret != LZMA_OK)
178
+           return ret;
179
+       else if (coder->next_finished && *out_pos < out_size)
180
+           return LZMA_DATA_ERROR;
181
+   }
182
+
183
+   return LZMA_OK;
184
+}
185
+
186
+
187
+static void
188
+lz_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
189
+{
190
+   lzma_next_end(&coder->next, allocator);
191
+   lzma_free(coder->dict.buf, allocator);
192
+
193
+   if (coder->lz.end != NULL)
194
+       coder->lz.end(coder->lz.coder, allocator);
195
+   else
196
+       lzma_free(coder->lz.coder, allocator);
197
+
198
+   lzma_free(coder, allocator);
199
+   return;
200
+}
201
+
202
+
203
+extern lzma_ret
204
+lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
205
+       const lzma_filter_info *filters,
206
+       lzma_ret (*lz_init)(lzma_lz_decoder *lz,
207
+           lzma_allocator *allocator, const void *options,
208
+           lzma_lz_options *lz_options))
209
+{
210
+   // Allocate the base structure if it isn't already allocated.
211
+   if (next->coder == NULL) {
212
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
213
+       if (next->coder == NULL)
214
+           return LZMA_MEM_ERROR;
215
+
216
+       next->code = &lz_decode;
217
+       next->end = &lz_decoder_end;
218
+
219
+       next->coder->dict.buf = NULL;
220
+       next->coder->dict.size = 0;
221
+       next->coder->lz = LZMA_LZ_DECODER_INIT;
222
+       next->coder->next = LZMA_NEXT_CODER_INIT;
223
+   }
224
+
225
+   // Allocate and initialize the LZ-based decoder. It will also give
226
+   // us the dictionary size.
227
+   lzma_lz_options lz_options;
228
+   return_if_error(lz_init(&next->coder->lz, allocator,
229
+           filters[0].options, &lz_options));
230
+
231
+   // If the dictionary size is very small, increase it to 4096 bytes.
232
+   // This is to prevent constant wrapping of the dictionary, which
233
+   // would slow things down. The downside is that since we don't check
234
+   // separately for the real dictionary size, we may happily accept
235
+   // corrupt files.
236
+   if (lz_options.dict_size < 4096)
237
+       lz_options.dict_size = 4096;
238
+
239
+   // Make dictionary size a multipe of 16. Some LZ-based decoders like
240
+   // LZMA use the lowest bits lzma_dict.pos to know the alignment of the
241
+   // data. Aligned buffer is also good when memcpying from the
242
+   // dictionary to the output buffer, since applications are
243
+   // recommended to give aligned buffers to liblzma.
244
+   //
245
+   // Avoid integer overflow.
246
+   if (lz_options.dict_size > SIZE_MAX - 15)
247
+       return LZMA_MEM_ERROR;
248
+
249
+   lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15));
250
+
251
+   // Allocate and initialize the dictionary.
252
+   if (next->coder->dict.size != lz_options.dict_size) {
253
+       lzma_free(next->coder->dict.buf, allocator);
254
+       next->coder->dict.buf
255
+               = lzma_alloc(lz_options.dict_size, allocator);
256
+       if (next->coder->dict.buf == NULL)
257
+           return LZMA_MEM_ERROR;
258
+
259
+       next->coder->dict.size = lz_options.dict_size;
260
+   }
261
+
262
+   lz_decoder_reset(next->coder);
263
+
264
+   // Use the preset dictionary if it was given to us.
265
+   if (lz_options.preset_dict != NULL
266
+           && lz_options.preset_dict_size > 0) {
267
+       // If the preset dictionary is bigger than the actual
268
+       // dictionary, copy only the tail.
269
+       const size_t copy_size = my_min(lz_options.preset_dict_size,
270
+               lz_options.dict_size);
271
+       const size_t offset = lz_options.preset_dict_size - copy_size;
272
+       memcpy(next->coder->dict.buf, lz_options.preset_dict + offset,
273
+               copy_size);
274
+       next->coder->dict.pos = copy_size;
275
+       next->coder->dict.full = copy_size;
276
+   }
277
+
278
+   // Miscellaneous initializations
279
+   next->coder->next_finished = false;
280
+   next->coder->this_finished = false;
281
+   next->coder->temp.pos = 0;
282
+   next->coder->temp.size = 0;
283
+
284
+   // Initialize the next filter in the chain, if any.
285
+   return lzma_next_filter_init(&next->coder->next, allocator,
286
+           filters + 1);
287
+}
288
+
289
+
290
+extern uint64_t
291
+lzma_lz_decoder_memusage(size_t dictionary_size)
292
+{
293
+   return sizeof(lzma_coder) + (uint64_t)(dictionary_size);
294
+}
295
+
296
+
297
+extern void
298
+lzma_lz_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size)
299
+{
300
+   coder->lz.set_uncompressed(coder->lz.coder, uncompressed_size);
301
+}
302
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_decoder.h Added
236
 
1
@@ -0,0 +1,234 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lz_decoder.h
5
+/// \brief      LZ out window
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZ_DECODER_H
16
+#define LZMA_LZ_DECODER_H
17
+
18
+#include "common.h"
19
+
20
+
21
+typedef struct {
22
+   /// Pointer to the dictionary buffer. It can be an allocated buffer
23
+   /// internal to liblzma, or it can a be a buffer given by the
24
+   /// application when in single-call mode (not implemented yet).
25
+   uint8_t *buf;
26
+
27
+   /// Write position in dictionary. The next byte will be written to
28
+   /// buf[pos].
29
+   size_t pos;
30
+
31
+   /// Indicates how full the dictionary is. This is used by
32
+   /// dict_is_distance_valid() to detect corrupt files that would
33
+   /// read beyond the beginning of the dictionary.
34
+   size_t full;
35
+
36
+   /// Write limit
37
+   size_t limit;
38
+
39
+   /// Size of the dictionary
40
+   size_t size;
41
+
42
+   /// True when dictionary should be reset before decoding more data.
43
+   bool need_reset;
44
+
45
+} lzma_dict;
46
+
47
+
48
+typedef struct {
49
+   size_t dict_size;
50
+   const uint8_t *preset_dict;
51
+   size_t preset_dict_size;
52
+} lzma_lz_options;
53
+
54
+
55
+typedef struct {
56
+   /// Data specific to the LZ-based decoder
57
+   lzma_coder *coder;
58
+
59
+   /// Function to decode from in[] to *dict
60
+   lzma_ret (*code)(lzma_coder *restrict coder,
61
+           lzma_dict *restrict dict, const uint8_t *restrict in,
62
+           size_t *restrict in_pos, size_t in_size);
63
+
64
+   void (*reset)(lzma_coder *coder, const void *options);
65
+
66
+   /// Set the uncompressed size
67
+   void (*set_uncompressed)(lzma_coder *coder,
68
+           lzma_vli uncompressed_size);
69
+
70
+   /// Free allocated resources
71
+   void (*end)(lzma_coder *coder, lzma_allocator *allocator);
72
+
73
+} lzma_lz_decoder;
74
+
75
+
76
+#define LZMA_LZ_DECODER_INIT \
77
+   (lzma_lz_decoder){ \
78
+       .coder = NULL, \
79
+       .code = NULL, \
80
+       .reset = NULL, \
81
+       .set_uncompressed = NULL, \
82
+       .end = NULL, \
83
+   }
84
+
85
+
86
+extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next,
87
+       lzma_allocator *allocator, const lzma_filter_info *filters,
88
+       lzma_ret (*lz_init)(lzma_lz_decoder *lz,
89
+           lzma_allocator *allocator, const void *options,
90
+           lzma_lz_options *lz_options));
91
+
92
+extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size);
93
+
94
+extern void lzma_lz_decoder_uncompressed(
95
+       lzma_coder *coder, lzma_vli uncompressed_size);
96
+
97
+
98
+//////////////////////
99
+// Inline functions //
100
+//////////////////////
101
+
102
+/// Get a byte from the history buffer.
103
+static inline uint8_t
104
+dict_get(const lzma_dict *const dict, const uint32_t distance)
105
+{
106
+   return dict->buf[dict->pos - distance - 1
107
+           + (distance < dict->pos ? 0 : dict->size)];
108
+}
109
+
110
+
111
+/// Test if dictionary is empty.
112
+static inline bool
113
+dict_is_empty(const lzma_dict *const dict)
114
+{
115
+   return dict->full == 0;
116
+}
117
+
118
+
119
+/// Validate the match distance
120
+static inline bool
121
+dict_is_distance_valid(const lzma_dict *const dict, const size_t distance)
122
+{
123
+   return dict->full > distance;
124
+}
125
+
126
+
127
+/// Repeat *len bytes at distance.
128
+static inline bool
129
+dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len)
130
+{
131
+   // Don't write past the end of the dictionary.
132
+   const size_t dict_avail = dict->limit - dict->pos;
133
+   uint32_t left = my_min(dict_avail, *len);
134
+   *len -= left;
135
+
136
+   // Repeat a block of data from the history. Because memcpy() is faster
137
+   // than copying byte by byte in a loop, the copying process gets split
138
+   // into three cases.
139
+   if (distance < left) {
140
+       // Source and target areas overlap, thus we can't use
141
+       // memcpy() nor even memmove() safely.
142
+       do {
143
+           dict->buf[dict->pos] = dict_get(dict, distance);
144
+           ++dict->pos;
145
+       } while (--left > 0);
146
+
147
+   } else if (distance < dict->pos) {
148
+       // The easiest and fastest case
149
+       memcpy(dict->buf + dict->pos,
150
+               dict->buf + dict->pos - distance - 1,
151
+               left);
152
+       dict->pos += left;
153
+
154
+   } else {
155
+       // The bigger the dictionary, the more rare this
156
+       // case occurs. We need to "wrap" the dict, thus
157
+       // we might need two memcpy() to copy all the data.
158
+       assert(dict->full == dict->size);
159
+       const uint32_t copy_pos
160
+               = dict->pos - distance - 1 + dict->size;
161
+       uint32_t copy_size = dict->size - copy_pos;
162
+
163
+       if (copy_size < left) {
164
+           memmove(dict->buf + dict->pos, dict->buf + copy_pos,
165
+                   copy_size);
166
+           dict->pos += copy_size;
167
+           copy_size = left - copy_size;
168
+           memcpy(dict->buf + dict->pos, dict->buf, copy_size);
169
+           dict->pos += copy_size;
170
+       } else {
171
+           memmove(dict->buf + dict->pos, dict->buf + copy_pos,
172
+                   left);
173
+           dict->pos += left;
174
+       }
175
+   }
176
+
177
+   // Update how full the dictionary is.
178
+   if (dict->full < dict->pos)
179
+       dict->full = dict->pos;
180
+
181
+   return unlikely(*len != 0);
182
+}
183
+
184
+
185
+/// Puts one byte into the dictionary. Returns true if the dictionary was
186
+/// already full and the byte couldn't be added.
187
+static inline bool
188
+dict_put(lzma_dict *dict, uint8_t byte)
189
+{
190
+   if (unlikely(dict->pos == dict->limit))
191
+       return true;
192
+
193
+   dict->buf[dict->pos++] = byte;
194
+
195
+   if (dict->pos > dict->full)
196
+       dict->full = dict->pos;
197
+
198
+   return false;
199
+}
200
+
201
+
202
+/// Copies arbitrary amount of data into the dictionary.
203
+static inline void
204
+dict_write(lzma_dict *restrict dict, const uint8_t *restrict in,
205
+       size_t *restrict in_pos, size_t in_size,
206
+       size_t *restrict left)
207
+{
208
+   // NOTE: If we are being given more data than the size of the
209
+   // dictionary, it could be possible to optimize the LZ decoder
210
+   // so that not everything needs to go through the dictionary.
211
+   // This shouldn't be very common thing in practice though, and
212
+   // the slowdown of one extra memcpy() isn't bad compared to how
213
+   // much time it would have taken if the data were compressed.
214
+
215
+   if (in_size - *in_pos > *left)
216
+       in_size = *in_pos + *left;
217
+
218
+   *left -= lzma_bufcpy(in, in_pos, in_size,
219
+           dict->buf, &dict->pos, dict->limit);
220
+
221
+   if (dict->pos > dict->full)
222
+       dict->full = dict->pos;
223
+
224
+   return;
225
+}
226
+
227
+
228
+static inline void
229
+dict_reset(lzma_dict *dict)
230
+{
231
+   dict->need_reset = true;
232
+   return;
233
+}
234
+
235
+#endif
236
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_encoder.c Added
585
 
1
@@ -0,0 +1,583 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lz_encoder.c
5
+/// \brief      LZ in window
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "lz_encoder.h"
16
+#include "lz_encoder_hash.h"
17
+
18
+// See lz_encoder_hash.h. This is a bit hackish but avoids making
19
+// endianness a conditional in makefiles.
20
+#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL)
21
+#  include "lz_encoder_hash_table.h"
22
+#endif
23
+
24
+
25
+struct lzma_coder_s {
26
+   /// LZ-based encoder e.g. LZMA
27
+   lzma_lz_encoder lz;
28
+
29
+   /// History buffer and match finder
30
+   lzma_mf mf;
31
+
32
+   /// Next coder in the chain
33
+   lzma_next_coder next;
34
+};
35
+
36
+
37
+/// \brief      Moves the data in the input window to free space for new data
38
+///
39
+/// mf->buffer is a sliding input window, which keeps mf->keep_size_before
40
+/// bytes of input history available all the time. Now and then we need to
41
+/// "slide" the buffer to make space for the new data to the end of the
42
+/// buffer. At the same time, data older than keep_size_before is dropped.
43
+///
44
+static void
45
+move_window(lzma_mf *mf)
46
+{
47
+   // Align the move to a multiple of 16 bytes. Some LZ-based encoders
48
+   // like LZMA use the lowest bits of mf->read_pos to know the
49
+   // alignment of the uncompressed data. We also get better speed
50
+   // for memmove() with aligned buffers.
51
+   assert(mf->read_pos > mf->keep_size_before);
52
+   const uint32_t move_offset
53
+       = (mf->read_pos - mf->keep_size_before) & ~UINT32_C(15);
54
+
55
+   assert(mf->write_pos > move_offset);
56
+   const size_t move_size = mf->write_pos - move_offset;
57
+
58
+   assert(move_offset + move_size <= mf->size);
59
+
60
+   memmove(mf->buffer, mf->buffer + move_offset, move_size);
61
+
62
+   mf->offset += move_offset;
63
+   mf->read_pos -= move_offset;
64
+   mf->read_limit -= move_offset;
65
+   mf->write_pos -= move_offset;
66
+
67
+   return;
68
+}
69
+
70
+
71
+/// \brief      Tries to fill the input window (mf->buffer)
72
+///
73
+/// If we are the last encoder in the chain, our input data is in in[].
74
+/// Otherwise we call the next filter in the chain to process in[] and
75
+/// write its output to mf->buffer.
76
+///
77
+/// This function must not be called once it has returned LZMA_STREAM_END.
78
+///
79
+static lzma_ret
80
+fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
81
+       size_t *in_pos, size_t in_size, lzma_action action)
82
+{
83
+   assert(coder->mf.read_pos <= coder->mf.write_pos);
84
+
85
+   // Move the sliding window if needed.
86
+   if (coder->mf.read_pos >= coder->mf.size - coder->mf.keep_size_after)
87
+       move_window(&coder->mf);
88
+
89
+   // Maybe this is ugly, but lzma_mf uses uint32_t for most things
90
+   // (which I find cleanest), but we need size_t here when filling
91
+   // the history window.
92
+   size_t write_pos = coder->mf.write_pos;
93
+   lzma_ret ret;
94
+   if (coder->next.code == NULL) {
95
+       // Not using a filter, simply memcpy() as much as possible.
96
+       lzma_bufcpy(in, in_pos, in_size, coder->mf.buffer,
97
+               &write_pos, coder->mf.size);
98
+
99
+       ret = action != LZMA_RUN && *in_pos == in_size
100
+               ? LZMA_STREAM_END : LZMA_OK;
101
+
102
+   } else {
103
+       ret = coder->next.code(coder->next.coder, allocator,
104
+               in, in_pos, in_size,
105
+               coder->mf.buffer, &write_pos,
106
+               coder->mf.size, action);
107
+   }
108
+
109
+   coder->mf.write_pos = write_pos;
110
+
111
+   // If end of stream has been reached or flushing completed, we allow
112
+   // the encoder to process all the input (that is, read_pos is allowed
113
+   // to reach write_pos). Otherwise we keep keep_size_after bytes
114
+   // available as prebuffer.
115
+   if (ret == LZMA_STREAM_END) {
116
+       assert(*in_pos == in_size);
117
+       ret = LZMA_OK;
118
+       coder->mf.action = action;
119
+       coder->mf.read_limit = coder->mf.write_pos;
120
+
121
+   } else if (coder->mf.write_pos > coder->mf.keep_size_after) {
122
+       // This needs to be done conditionally, because if we got
123
+       // only little new input, there may be too little input
124
+       // to do any encoding yet.
125
+       coder->mf.read_limit = coder->mf.write_pos
126
+               - coder->mf.keep_size_after;
127
+   }
128
+
129
+   // Restart the match finder after finished LZMA_SYNC_FLUSH.
130
+   if (coder->mf.pending > 0
131
+           && coder->mf.read_pos < coder->mf.read_limit) {
132
+       // Match finder may update coder->pending and expects it to
133
+       // start from zero, so use a temporary variable.
134
+       const size_t pending = coder->mf.pending;
135
+       coder->mf.pending = 0;
136
+
137
+       // Rewind read_pos so that the match finder can hash
138
+       // the pending bytes.
139
+       assert(coder->mf.read_pos >= pending);
140
+       coder->mf.read_pos -= pending;
141
+
142
+       // Call the skip function directly instead of using
143
+       // mf_skip(), since we don't want to touch mf->read_ahead.
144
+       coder->mf.skip(&coder->mf, pending);
145
+   }
146
+
147
+   return ret;
148
+}
149
+
150
+
151
+static lzma_ret
152
+lz_encode(lzma_coder *coder, lzma_allocator *allocator,
153
+       const uint8_t *restrict in, size_t *restrict in_pos,
154
+       size_t in_size,
155
+       uint8_t *restrict out, size_t *restrict out_pos,
156
+       size_t out_size, lzma_action action)
157
+{
158
+   while (*out_pos < out_size
159
+           && (*in_pos < in_size || action != LZMA_RUN)) {
160
+       // Read more data to coder->mf.buffer if needed.
161
+       if (coder->mf.action == LZMA_RUN && coder->mf.read_pos
162
+               >= coder->mf.read_limit)
163
+           return_if_error(fill_window(coder, allocator,
164
+                   in, in_pos, in_size, action));
165
+
166
+       // Encode
167
+       const lzma_ret ret = coder->lz.code(coder->lz.coder,
168
+               &coder->mf, out, out_pos, out_size);
169
+       if (ret != LZMA_OK) {
170
+           // Setting this to LZMA_RUN for cases when we are
171
+           // flushing. It doesn't matter when finishing or if
172
+           // an error occurred.
173
+           coder->mf.action = LZMA_RUN;
174
+           return ret;
175
+       }
176
+   }
177
+
178
+   return LZMA_OK;
179
+}
180
+
181
+
182
+static bool
183
+lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
184
+       const lzma_lz_options *lz_options)
185
+{
186
+   // For now, the dictionary size is limited to 1.5 GiB. This may grow
187
+   // in the future if needed, but it needs a little more work than just
188
+   // changing this check.
189
+   if (lz_options->dict_size < LZMA_DICT_SIZE_MIN
190
+           || lz_options->dict_size
191
+               > (UINT32_C(1) << 30) + (UINT32_C(1) << 29)
192
+           || lz_options->nice_len > lz_options->match_len_max)
193
+       return true;
194
+
195
+   mf->keep_size_before = lz_options->before_size + lz_options->dict_size;
196
+
197
+   mf->keep_size_after = lz_options->after_size
198
+           + lz_options->match_len_max;
199
+
200
+   // To avoid constant memmove()s, allocate some extra space. Since
201
+   // memmove()s become more expensive when the size of the buffer
202
+   // increases, we reserve more space when a large dictionary is
203
+   // used to make the memmove() calls rarer.
204
+   //
205
+   // This works with dictionaries up to about 3 GiB. If bigger
206
+   // dictionary is wanted, some extra work is needed:
207
+   //   - Several variables in lzma_mf have to be changed from uint32_t
208
+   //     to size_t.
209
+   //   - Memory usage calculation needs something too, e.g. use uint64_t
210
+   //     for mf->size.
211
+   uint32_t reserve = lz_options->dict_size / 2;
212
+   if (reserve > (UINT32_C(1) << 30))
213
+       reserve /= 2;
214
+
215
+   reserve += (lz_options->before_size + lz_options->match_len_max
216
+           + lz_options->after_size) / 2 + (UINT32_C(1) << 19);
217
+
218
+   const uint32_t old_size = mf->size;
219
+   mf->size = mf->keep_size_before + reserve + mf->keep_size_after;
220
+
221
+   // Deallocate the old history buffer if it exists but has different
222
+   // size than what is needed now.
223
+   if (mf->buffer != NULL && old_size != mf->size) {
224
+       lzma_free(mf->buffer, allocator);
225
+       mf->buffer = NULL;
226
+   }
227
+
228
+   // Match finder options
229
+   mf->match_len_max = lz_options->match_len_max;
230
+   mf->nice_len = lz_options->nice_len;
231
+
232
+   // cyclic_size has to stay smaller than 2 Gi. Note that this doesn't
233
+   // mean limiting dictionary size to less than 2 GiB. With a match
234
+   // finder that uses multibyte resolution (hashes start at e.g. every
235
+   // fourth byte), cyclic_size would stay below 2 Gi even when
236
+   // dictionary size is greater than 2 GiB.
237
+   //
238
+   // It would be possible to allow cyclic_size >= 2 Gi, but then we
239
+   // would need to be careful to use 64-bit types in various places
240
+   // (size_t could do since we would need bigger than 32-bit address
241
+   // space anyway). It would also require either zeroing a multigigabyte
242
+   // buffer at initialization (waste of time and RAM) or allow
243
+   // normalization in lz_encoder_mf.c to access uninitialized
244
+   // memory to keep the code simpler. The current way is simple and
245
+   // still allows pretty big dictionaries, so I don't expect these
246
+   // limits to change.
247
+   mf->cyclic_size = lz_options->dict_size + 1;
248
+
249
+   // Validate the match finder ID and setup the function pointers.
250
+   switch (lz_options->match_finder) {
251
+#ifdef HAVE_MF_HC3
252
+   case LZMA_MF_HC3:
253
+       mf->find = &lzma_mf_hc3_find;
254
+       mf->skip = &lzma_mf_hc3_skip;
255
+       break;
256
+#endif
257
+#ifdef HAVE_MF_HC4
258
+   case LZMA_MF_HC4:
259
+       mf->find = &lzma_mf_hc4_find;
260
+       mf->skip = &lzma_mf_hc4_skip;
261
+       break;
262
+#endif
263
+#ifdef HAVE_MF_BT2
264
+   case LZMA_MF_BT2:
265
+       mf->find = &lzma_mf_bt2_find;
266
+       mf->skip = &lzma_mf_bt2_skip;
267
+       break;
268
+#endif
269
+#ifdef HAVE_MF_BT3
270
+   case LZMA_MF_BT3:
271
+       mf->find = &lzma_mf_bt3_find;
272
+       mf->skip = &lzma_mf_bt3_skip;
273
+       break;
274
+#endif
275
+#ifdef HAVE_MF_BT4
276
+   case LZMA_MF_BT4:
277
+       mf->find = &lzma_mf_bt4_find;
278
+       mf->skip = &lzma_mf_bt4_skip;
279
+       break;
280
+#endif
281
+
282
+   default:
283
+       return true;
284
+   }
285
+
286
+   // Calculate the sizes of mf->hash and mf->son and check that
287
+   // nice_len is big enough for the selected match finder.
288
+   const uint32_t hash_bytes = lz_options->match_finder & 0x0F;
289
+   if (hash_bytes > mf->nice_len)
290
+       return true;
291
+
292
+   const bool is_bt = (lz_options->match_finder & 0x10) != 0;
293
+   uint32_t hs;
294
+
295
+   if (hash_bytes == 2) {
296
+       hs = 0xFFFF;
297
+   } else {
298
+       // Round dictionary size up to the next 2^n - 1 so it can
299
+       // be used as a hash mask.
300
+       hs = lz_options->dict_size - 1;
301
+       hs |= hs >> 1;
302
+       hs |= hs >> 2;
303
+       hs |= hs >> 4;
304
+       hs |= hs >> 8;
305
+       hs >>= 1;
306
+       hs |= 0xFFFF;
307
+
308
+       if (hs > (UINT32_C(1) << 24)) {
309
+           if (hash_bytes == 3)
310
+               hs = (UINT32_C(1) << 24) - 1;
311
+           else
312
+               hs >>= 1;
313
+       }
314
+   }
315
+
316
+   mf->hash_mask = hs;
317
+
318
+   ++hs;
319
+   if (hash_bytes > 2)
320
+       hs += HASH_2_SIZE;
321
+   if (hash_bytes > 3)
322
+       hs += HASH_3_SIZE;
323
+/*
324
+   No match finder uses this at the moment.
325
+   if (mf->hash_bytes > 4)
326
+       hs += HASH_4_SIZE;
327
+*/
328
+
329
+   // If the above code calculating hs is modified, make sure that
330
+   // this assertion stays valid (UINT32_MAX / 5 is not strictly the
331
+   // exact limit). If it doesn't, you need to calculate that
332
+   // hash_size_sum + sons_count cannot overflow.
333
+   assert(hs < UINT32_MAX / 5);
334
+
335
+   const uint32_t old_count = mf->hash_size_sum + mf->sons_count;
336
+   mf->hash_size_sum = hs;
337
+   mf->sons_count = mf->cyclic_size;
338
+   if (is_bt)
339
+       mf->sons_count *= 2;
340
+
341
+   const uint32_t new_count = mf->hash_size_sum + mf->sons_count;
342
+
343
+   // Deallocate the old hash array if it exists and has different size
344
+   // than what is needed now.
345
+   if (old_count != new_count) {
346
+       lzma_free(mf->hash, allocator);
347
+       mf->hash = NULL;
348
+   }
349
+
350
+   // Maximum number of match finder cycles
351
+   mf->depth = lz_options->depth;
352
+   if (mf->depth == 0) {
353
+       if (is_bt)
354
+           mf->depth = 16 + mf->nice_len / 2;
355
+       else
356
+           mf->depth = 4 + mf->nice_len / 4;
357
+   }
358
+
359
+   return false;
360
+}
361
+
362
+
363
+static bool
364
+lz_encoder_init(lzma_mf *mf, lzma_allocator *allocator,
365
+       const lzma_lz_options *lz_options)
366
+{
367
+   // Allocate the history buffer.
368
+   if (mf->buffer == NULL) {
369
+       mf->buffer = lzma_alloc(mf->size, allocator);
370
+       if (mf->buffer == NULL)
371
+           return true;
372
+   }
373
+
374
+   // Use cyclic_size as initial mf->offset. This allows
375
+   // avoiding a few branches in the match finders. The downside is
376
+   // that match finder needs to be normalized more often, which may
377
+   // hurt performance with huge dictionaries.
378
+   mf->offset = mf->cyclic_size;
379
+   mf->read_pos = 0;
380
+   mf->read_ahead = 0;
381
+   mf->read_limit = 0;
382
+   mf->write_pos = 0;
383
+   mf->pending = 0;
384
+
385
+   // Allocate match finder's hash array.
386
+   const size_t alloc_count = mf->hash_size_sum + mf->sons_count;
387
+
388
+#if UINT32_MAX >= SIZE_MAX / 4
389
+   // Check for integer overflow. (Huge dictionaries are not
390
+   // possible on 32-bit CPU.)
391
+   if (alloc_count > SIZE_MAX / sizeof(uint32_t))
392
+       return true;
393
+#endif
394
+
395
+   if (mf->hash == NULL) {
396
+       mf->hash = lzma_alloc(alloc_count * sizeof(uint32_t),
397
+               allocator);
398
+       if (mf->hash == NULL)
399
+           return true;
400
+   }
401
+
402
+   mf->son = mf->hash + mf->hash_size_sum;
403
+   mf->cyclic_pos = 0;
404
+
405
+   // Initialize the hash table. Since EMPTY_HASH_VALUE is zero, we
406
+   // can use memset().
407
+/*
408
+   for (uint32_t i = 0; i < hash_size_sum; ++i)
409
+       mf->hash[i] = EMPTY_HASH_VALUE;
410
+*/
411
+   memzero(mf->hash, (size_t)(mf->hash_size_sum) * sizeof(uint32_t));
412
+
413
+   // We don't need to initialize mf->son, but not doing that will
414
+   // make Valgrind complain in normalization (see normalize() in
415
+   // lz_encoder_mf.c).
416
+   //
417
+   // Skipping this initialization is *very* good when big dictionary is
418
+   // used but only small amount of data gets actually compressed: most
419
+   // of the mf->hash won't get actually allocated by the kernel, so
420
+   // we avoid wasting RAM and improve initialization speed a lot.
421
+   //memzero(mf->son, (size_t)(mf->sons_count) * sizeof(uint32_t));
422
+
423
+   // Handle preset dictionary.
424
+   if (lz_options->preset_dict != NULL
425
+           && lz_options->preset_dict_size > 0) {
426
+       // If the preset dictionary is bigger than the actual
427
+       // dictionary, use only the tail.
428
+       mf->write_pos = my_min(lz_options->preset_dict_size, mf->size);
429
+       memcpy(mf->buffer, lz_options->preset_dict
430
+               + lz_options->preset_dict_size - mf->write_pos,
431
+               mf->write_pos);
432
+       mf->action = LZMA_SYNC_FLUSH;
433
+       mf->skip(mf, mf->write_pos);
434
+   }
435
+
436
+   mf->action = LZMA_RUN;
437
+
438
+   return false;
439
+}
440
+
441
+
442
+extern uint64_t
443
+lzma_lz_encoder_memusage(const lzma_lz_options *lz_options)
444
+{
445
+   // Old buffers must not exist when calling lz_encoder_prepare().
446
+   lzma_mf mf = {
447
+       .buffer = NULL,
448
+       .hash = NULL,
449
+       .hash_size_sum = 0,
450
+       .sons_count = 0,
451
+   };
452
+
453
+   // Setup the size information into mf.
454
+   if (lz_encoder_prepare(&mf, NULL, lz_options))
455
+       return UINT64_MAX;
456
+
457
+   // Calculate the memory usage.
458
+   return (uint64_t)(mf.hash_size_sum + mf.sons_count)
459
+               * sizeof(uint32_t)
460
+           + (uint64_t)(mf.size) + sizeof(lzma_coder);
461
+}
462
+
463
+
464
+static void
465
+lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
466
+{
467
+   lzma_next_end(&coder->next, allocator);
468
+
469
+   lzma_free(coder->mf.hash, allocator);
470
+   lzma_free(coder->mf.buffer, allocator);
471
+
472
+   if (coder->lz.end != NULL)
473
+       coder->lz.end(coder->lz.coder, allocator);
474
+   else
475
+       lzma_free(coder->lz.coder, allocator);
476
+
477
+   lzma_free(coder, allocator);
478
+   return;
479
+}
480
+
481
+
482
+static lzma_ret
483
+lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
484
+       const lzma_filter *filters_null lzma_attribute((__unused__)),
485
+       const lzma_filter *reversed_filters)
486
+{
487
+   if (coder->lz.options_update == NULL)
488
+       return LZMA_PROG_ERROR;
489
+
490
+   return_if_error(coder->lz.options_update(
491
+           coder->lz.coder, reversed_filters));
492
+
493
+   return lzma_next_filter_update(
494
+           &coder->next, allocator, reversed_filters + 1);
495
+}
496
+
497
+
498
+extern lzma_ret
499
+lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
500
+       const lzma_filter_info *filters,
501
+       lzma_ret (*lz_init)(lzma_lz_encoder *lz,
502
+           lzma_allocator *allocator, const void *options,
503
+           lzma_lz_options *lz_options))
504
+{
505
+#ifdef HAVE_SMALL
506
+   // We need that the CRC32 table has been initialized.
507
+   lzma_crc32_init();
508
+#endif
509
+
510
+   // Allocate and initialize the base data structure.
511
+   if (next->coder == NULL) {
512
+       next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
513
+       if (next->coder == NULL)
514
+           return LZMA_MEM_ERROR;
515
+
516
+       next->code = &lz_encode;
517
+       next->end = &lz_encoder_end;
518
+       next->update = &lz_encoder_update;
519
+
520
+       next->coder->lz.coder = NULL;
521
+       next->coder->lz.code = NULL;
522
+       next->coder->lz.end = NULL;
523
+
524
+       next->coder->mf.buffer = NULL;
525
+       next->coder->mf.hash = NULL;
526
+       next->coder->mf.hash_size_sum = 0;
527
+       next->coder->mf.sons_count = 0;
528
+
529
+       next->coder->next = LZMA_NEXT_CODER_INIT;
530
+   }
531
+
532
+   // Initialize the LZ-based encoder.
533
+   lzma_lz_options lz_options;
534
+   return_if_error(lz_init(&next->coder->lz, allocator,
535
+           filters[0].options, &lz_options));
536
+
537
+   // Setup the size information into next->coder->mf and deallocate
538
+   // old buffers if they have wrong size.
539
+   if (lz_encoder_prepare(&next->coder->mf, allocator, &lz_options))
540
+       return LZMA_OPTIONS_ERROR;
541
+
542
+   // Allocate new buffers if needed, and do the rest of
543
+   // the initialization.
544
+   if (lz_encoder_init(&next->coder->mf, allocator, &lz_options))
545
+       return LZMA_MEM_ERROR;
546
+
547
+   // Initialize the next filter in the chain, if any.
548
+   return lzma_next_filter_init(&next->coder->next, allocator,
549
+           filters + 1);
550
+}
551
+
552
+
553
+extern LZMA_API(lzma_bool)
554
+lzma_mf_is_supported(lzma_match_finder mf)
555
+{
556
+   bool ret = false;
557
+
558
+#ifdef HAVE_MF_HC3
559
+   if (mf == LZMA_MF_HC3)
560
+       ret = true;
561
+#endif
562
+
563
+#ifdef HAVE_MF_HC4
564
+   if (mf == LZMA_MF_HC4)
565
+       ret = true;
566
+#endif
567
+
568
+#ifdef HAVE_MF_BT2
569
+   if (mf == LZMA_MF_BT2)
570
+       ret = true;
571
+#endif
572
+
573
+#ifdef HAVE_MF_BT3
574
+   if (mf == LZMA_MF_BT3)
575
+       ret = true;
576
+#endif
577
+
578
+#ifdef HAVE_MF_BT4
579
+   if (mf == LZMA_MF_BT4)
580
+       ret = true;
581
+#endif
582
+
583
+   return ret;
584
+}
585
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_encoder.h Added
330
 
1
@@ -0,0 +1,328 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lz_encoder.h
5
+/// \brief      LZ in window and match finder API
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZ_ENCODER_H
16
+#define LZMA_LZ_ENCODER_H
17
+
18
+#include "common.h"
19
+
20
+
21
+/// A table of these is used by the LZ-based encoder to hold
22
+/// the length-distance pairs found by the match finder.
23
+typedef struct {
24
+   uint32_t len;
25
+   uint32_t dist;
26
+} lzma_match;
27
+
28
+
29
+typedef struct lzma_mf_s lzma_mf;
30
+struct lzma_mf_s {
31
+   ///////////////
32
+   // In Window //
33
+   ///////////////
34
+
35
+   /// Pointer to buffer with data to be compressed
36
+   uint8_t *buffer;
37
+
38
+   /// Total size of the allocated buffer (that is, including all
39
+   /// the extra space)
40
+   uint32_t size;
41
+
42
+   /// Number of bytes that must be kept available in our input history.
43
+   /// That is, once keep_size_before bytes have been processed,
44
+   /// buffer[read_pos - keep_size_before] is the oldest byte that
45
+   /// must be available for reading.
46
+   uint32_t keep_size_before;
47
+
48
+   /// Number of bytes that must be kept in buffer after read_pos.
49
+   /// That is, read_pos <= write_pos - keep_size_after as long as
50
+   /// action is LZMA_RUN; when action != LZMA_RUN, read_pos is allowed
51
+   /// to reach write_pos so that the last bytes get encoded too.
52
+   uint32_t keep_size_after;
53
+
54
+   /// Match finders store locations of matches using 32-bit integers.
55
+   /// To avoid adjusting several megabytes of integers every time the
56
+   /// input window is moved with move_window, we only adjust the
57
+   /// offset of the buffer. Thus, buffer[value_in_hash_table - offset]
58
+   /// is the byte pointed by value_in_hash_table.
59
+   uint32_t offset;
60
+
61
+   /// buffer[read_pos] is the next byte to run through the match
62
+   /// finder. This is incremented in the match finder once the byte
63
+   /// has been processed.
64
+   uint32_t read_pos;
65
+
66
+   /// Number of bytes that have been ran through the match finder, but
67
+   /// which haven't been encoded by the LZ-based encoder yet.
68
+   uint32_t read_ahead;
69
+
70
+   /// As long as read_pos is less than read_limit, there is enough
71
+   /// input available in buffer for at least one encoding loop.
72
+   ///
73
+   /// Because of the stateful API, read_limit may and will get greater
74
+   /// than read_pos quite often. This is taken into account when
75
+   /// calculating the value for keep_size_after.
76
+   uint32_t read_limit;
77
+
78
+   /// buffer[write_pos] is the first byte that doesn't contain valid
79
+   /// uncompressed data; that is, the next input byte will be copied
80
+   /// to buffer[write_pos].
81
+   uint32_t write_pos;
82
+
83
+   /// Number of bytes not hashed before read_pos. This is needed to
84
+   /// restart the match finder after LZMA_SYNC_FLUSH.
85
+   uint32_t pending;
86
+
87
+   //////////////////
88
+   // Match Finder //
89
+   //////////////////
90
+
91
+   /// Find matches. Returns the number of distance-length pairs written
92
+   /// to the matches array. This is called only via lzma_mf_find().
93
+   uint32_t (*find)(lzma_mf *mf, lzma_match *matches);
94
+
95
+   /// Skips num bytes. This is like find() but doesn't make the
96
+   /// distance-length pairs available, thus being a little faster.
97
+   /// This is called only via mf_skip().
98
+   void (*skip)(lzma_mf *mf, uint32_t num);
99
+
100
+   uint32_t *hash;
101
+   uint32_t *son;
102
+   uint32_t cyclic_pos;
103
+   uint32_t cyclic_size; // Must be dictionary size + 1.
104
+   uint32_t hash_mask;
105
+
106
+   /// Maximum number of loops in the match finder
107
+   uint32_t depth;
108
+
109
+   /// Maximum length of a match that the match finder will try to find.
110
+   uint32_t nice_len;
111
+
112
+   /// Maximum length of a match supported by the LZ-based encoder.
113
+   /// If the longest match found by the match finder is nice_len,
114
+   /// mf_find() tries to expand it up to match_len_max bytes.
115
+   uint32_t match_len_max;
116
+
117
+   /// When running out of input, binary tree match finders need to know
118
+   /// if it is due to flushing or finishing. The action is used also
119
+   /// by the LZ-based encoders themselves.
120
+   lzma_action action;
121
+
122
+   /// Number of elements in hash[]
123
+   uint32_t hash_size_sum;
124
+
125
+   /// Number of elements in son[]
126
+   uint32_t sons_count;
127
+};
128
+
129
+
130
+typedef struct {
131
+   /// Extra amount of data to keep available before the "actual"
132
+   /// dictionary.
133
+   size_t before_size;
134
+
135
+   /// Size of the history buffer
136
+   size_t dict_size;
137
+
138
+   /// Extra amount of data to keep available after the "actual"
139
+   /// dictionary.
140
+   size_t after_size;
141
+
142
+   /// Maximum length of a match that the LZ-based encoder can accept.
143
+   /// This is used to extend matches of length nice_len to the
144
+   /// maximum possible length.
145
+   size_t match_len_max;
146
+
147
+   /// Match finder will search matches up to this length.
148
+   /// This must be less than or equal to match_len_max.
149
+   size_t nice_len;
150
+
151
+   /// Type of the match finder to use
152
+   lzma_match_finder match_finder;
153
+
154
+   /// Maximum search depth
155
+   uint32_t depth;
156
+
157
+   /// TODO: Comment
158
+   const uint8_t *preset_dict;
159
+
160
+   uint32_t preset_dict_size;
161
+
162
+} lzma_lz_options;
163
+
164
+
165
+// The total usable buffer space at any moment outside the match finder:
166
+// before_size + dict_size + after_size + match_len_max
167
+//
168
+// In reality, there's some extra space allocated to prevent the number of
169
+// memmove() calls reasonable. The bigger the dict_size is, the bigger
170
+// this extra buffer will be since with bigger dictionaries memmove() would
171
+// also take longer.
172
+//
173
+// A single encoder loop in the LZ-based encoder may call the match finder
174
+// (mf_find() or mf_skip()) at most after_size times. In other words,
175
+// a single encoder loop may increment lzma_mf.read_pos at most after_size
176
+// times. Since matches are looked up to
177
+// lzma_mf.buffer[lzma_mf.read_pos + match_len_max - 1], the total
178
+// amount of extra buffer needed after dict_size becomes
179
+// after_size + match_len_max.
180
+//
181
+// before_size has two uses. The first one is to keep literals available
182
+// in cases when the LZ-based encoder has made some read ahead.
183
+// TODO: Maybe this could be changed by making the LZ-based encoders to
184
+// store the actual literals as they do with length-distance pairs.
185
+//
186
+// Algorithms such as LZMA2 first try to compress a chunk, and then check
187
+// if the encoded result is smaller than the uncompressed one. If the chunk
188
+// was uncompressible, it is better to store it in uncompressed form in
189
+// the output stream. To do this, the whole uncompressed chunk has to be
190
+// still available in the history buffer. before_size achieves that.
191
+
192
+
193
+typedef struct {
194
+   /// Data specific to the LZ-based encoder
195
+   lzma_coder *coder;
196
+
197
+   /// Function to encode from *dict to out[]
198
+   lzma_ret (*code)(lzma_coder *restrict coder,
199
+           lzma_mf *restrict mf, uint8_t *restrict out,
200
+           size_t *restrict out_pos, size_t out_size);
201
+
202
+   /// Free allocated resources
203
+   void (*end)(lzma_coder *coder, lzma_allocator *allocator);
204
+
205
+   /// Update the options in the middle of the encoding.
206
+   lzma_ret (*options_update)(lzma_coder *coder,
207
+           const lzma_filter *filter);
208
+
209
+} lzma_lz_encoder;
210
+
211
+
212
+// Basic steps:
213
+//  1. Input gets copied into the dictionary.
214
+//  2. Data in dictionary gets run through the match finder byte by byte.
215
+//  3. The literals and matches are encoded using e.g. LZMA.
216
+//
217
+// The bytes that have been ran through the match finder, but not encoded yet,
218
+// are called `read ahead'.
219
+
220
+
221
+/// Get pointer to the first byte not ran through the match finder
222
+static inline const uint8_t *
223
+mf_ptr(const lzma_mf *mf)
224
+{
225
+   return mf->buffer + mf->read_pos;
226
+}
227
+
228
+
229
+/// Get the number of bytes that haven't been ran through the match finder yet.
230
+static inline uint32_t
231
+mf_avail(const lzma_mf *mf)
232
+{
233
+   return mf->write_pos - mf->read_pos;
234
+}
235
+
236
+
237
+/// Get the number of bytes that haven't been encoded yet (some of these
238
+/// bytes may have been ran through the match finder though).
239
+static inline uint32_t
240
+mf_unencoded(const lzma_mf *mf)
241
+{
242
+   return mf->write_pos - mf->read_pos + mf->read_ahead;
243
+}
244
+
245
+
246
+/// Calculate the absolute offset from the beginning of the most recent
247
+/// dictionary reset. Only the lowest four bits are important, so there's no
248
+/// problem that we don't know the 64-bit size of the data encoded so far.
249
+///
250
+/// NOTE: When moving the input window, we need to do it so that the lowest
251
+/// bits of dict->read_pos are not modified to keep this macro working
252
+/// as intended.
253
+static inline uint32_t
254
+mf_position(const lzma_mf *mf)
255
+{
256
+   return mf->read_pos - mf->read_ahead;
257
+}
258
+
259
+
260
+/// Since everything else begins with mf_, use it also for lzma_mf_find().
261
+#define mf_find lzma_mf_find
262
+
263
+
264
+/// Skip the given number of bytes. This is used when a good match was found.
265
+/// For example, if mf_find() finds a match of 200 bytes long, the first byte
266
+/// of that match was already consumed by mf_find(), and the rest 199 bytes
267
+/// have to be skipped with mf_skip(mf, 199).
268
+static inline void
269
+mf_skip(lzma_mf *mf, uint32_t amount)
270
+{
271
+   if (amount != 0) {
272
+       mf->skip(mf, amount);
273
+       mf->read_ahead += amount;
274
+   }
275
+}
276
+
277
+
278
+/// Copies at most *left number of bytes from the history buffer
279
+/// to out[]. This is needed by LZMA2 to encode uncompressed chunks.
280
+static inline void
281
+mf_read(lzma_mf *mf, uint8_t *out, size_t *out_pos, size_t out_size,
282
+       size_t *left)
283
+{
284
+   const size_t out_avail = out_size - *out_pos;
285
+   const size_t copy_size = my_min(out_avail, *left);
286
+
287
+   assert(mf->read_ahead == 0);
288
+   assert(mf->read_pos >= *left);
289
+
290
+   memcpy(out + *out_pos, mf->buffer + mf->read_pos - *left,
291
+           copy_size);
292
+
293
+   *out_pos += copy_size;
294
+   *left -= copy_size;
295
+   return;
296
+}
297
+
298
+
299
+extern lzma_ret lzma_lz_encoder_init(
300
+       lzma_next_coder *next, lzma_allocator *allocator,
301
+       const lzma_filter_info *filters,
302
+       lzma_ret (*lz_init)(lzma_lz_encoder *lz,
303
+           lzma_allocator *allocator, const void *options,
304
+           lzma_lz_options *lz_options));
305
+
306
+
307
+extern uint64_t lzma_lz_encoder_memusage(const lzma_lz_options *lz_options);
308
+
309
+
310
+// These are only for LZ encoder's internal use.
311
+extern uint32_t lzma_mf_find(
312
+       lzma_mf *mf, uint32_t *count, lzma_match *matches);
313
+
314
+extern uint32_t lzma_mf_hc3_find(lzma_mf *dict, lzma_match *matches);
315
+extern void lzma_mf_hc3_skip(lzma_mf *dict, uint32_t amount);
316
+
317
+extern uint32_t lzma_mf_hc4_find(lzma_mf *dict, lzma_match *matches);
318
+extern void lzma_mf_hc4_skip(lzma_mf *dict, uint32_t amount);
319
+
320
+extern uint32_t lzma_mf_bt2_find(lzma_mf *dict, lzma_match *matches);
321
+extern void lzma_mf_bt2_skip(lzma_mf *dict, uint32_t amount);
322
+
323
+extern uint32_t lzma_mf_bt3_find(lzma_mf *dict, lzma_match *matches);
324
+extern void lzma_mf_bt3_skip(lzma_mf *dict, uint32_t amount);
325
+
326
+extern uint32_t lzma_mf_bt4_find(lzma_mf *dict, lzma_match *matches);
327
+extern void lzma_mf_bt4_skip(lzma_mf *dict, uint32_t amount);
328
+
329
+#endif
330
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_encoder_hash.h Added
110
 
1
@@ -0,0 +1,108 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lz_encoder_hash.h
5
+/// \brief      Hash macros for match finders
6
+//
7
+//  Author:     Igor Pavlov
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_LZ_ENCODER_HASH_H
15
+#define LZMA_LZ_ENCODER_HASH_H
16
+
17
+#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL)
18
+   // This is to make liblzma produce the same output on big endian
19
+   // systems that it does on little endian systems. lz_encoder.c
20
+   // takes care of including the actual table.
21
+   extern const uint32_t lzma_lz_hash_table[256];
22
+#  define hash_table lzma_lz_hash_table
23
+#else
24
+#  include "check.h"
25
+#  define hash_table lzma_crc32_table[0]
26
+#endif
27
+
28
+#define HASH_2_SIZE (UINT32_C(1) << 10)
29
+#define HASH_3_SIZE (UINT32_C(1) << 16)
30
+#define HASH_4_SIZE (UINT32_C(1) << 20)
31
+
32
+#define HASH_2_MASK (HASH_2_SIZE - 1)
33
+#define HASH_3_MASK (HASH_3_SIZE - 1)
34
+#define HASH_4_MASK (HASH_4_SIZE - 1)
35
+
36
+#define FIX_3_HASH_SIZE (HASH_2_SIZE)
37
+#define FIX_4_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE)
38
+#define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE)
39
+
40
+// Endianness doesn't matter in hash_2_calc() (no effect on the output).
41
+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
42
+#  define hash_2_calc() \
43
+       const uint32_t hash_value = *(const uint16_t *)(cur)
44
+#else
45
+#  define hash_2_calc() \
46
+       const uint32_t hash_value \
47
+           = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)
48
+#endif
49
+
50
+#define hash_3_calc() \
51
+   const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
52
+   const uint32_t hash_2_value = temp & HASH_2_MASK; \
53
+   const uint32_t hash_value \
54
+           = (temp ^ ((uint32_t)(cur[2]) << 8)) & mf->hash_mask
55
+
56
+#define hash_4_calc() \
57
+   const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
58
+   const uint32_t hash_2_value = temp & HASH_2_MASK; \
59
+   const uint32_t hash_3_value \
60
+           = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
61
+   const uint32_t hash_value = (temp ^ ((uint32_t)(cur[2]) << 8) \
62
+           ^ (hash_table[cur[3]] << 5)) & mf->hash_mask
63
+
64
+
65
+// The following are not currently used.
66
+
67
+#define hash_5_calc() \
68
+   const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
69
+   const uint32_t hash_2_value = temp & HASH_2_MASK; \
70
+   const uint32_t hash_3_value \
71
+           = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
72
+   uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \
73
+           ^ hash_table[cur[3]] << 5); \
74
+   const uint32_t hash_value \
75
+           = (hash_4_value ^ (hash_table[cur[4]] << 3)) \
76
+               & mf->hash_mask; \
77
+   hash_4_value &= HASH_4_MASK
78
+
79
+/*
80
+#define hash_zip_calc() \
81
+   const uint32_t hash_value \
82
+           = (((uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)) \
83
+               ^ hash_table[cur[2]]) & 0xFFFF
84
+*/
85
+
86
+#define hash_zip_calc() \
87
+   const uint32_t hash_value \
88
+           = (((uint32_t)(cur[2]) | ((uint32_t)(cur[0]) << 8)) \
89
+               ^ hash_table[cur[1]]) & 0xFFFF
90
+
91
+#define mt_hash_2_calc() \
92
+   const uint32_t hash_2_value \
93
+           = (hash_table[cur[0]] ^ cur[1]) & HASH_2_MASK
94
+
95
+#define mt_hash_3_calc() \
96
+   const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
97
+   const uint32_t hash_2_value = temp & HASH_2_MASK; \
98
+   const uint32_t hash_3_value \
99
+           = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK
100
+
101
+#define mt_hash_4_calc() \
102
+   const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
103
+   const uint32_t hash_2_value = temp & HASH_2_MASK; \
104
+   const uint32_t hash_3_value \
105
+           = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
106
+   const uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \
107
+           (hash_table[cur[3]] << 5)) & HASH_4_MASK
108
+
109
+#endif
110
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_encoder_hash_table.h Added
70
 
1
@@ -0,0 +1,68 @@
2
+/* This file has been automatically generated by crc32_tablegen.c. */
3
+
4
+const uint32_t lzma_lz_hash_table[256] = {
5
+   0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
6
+   0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
7
+   0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
8
+   0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
9
+   0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
10
+   0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
11
+   0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
12
+   0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
13
+   0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
14
+   0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
15
+   0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
16
+   0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
17
+   0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
18
+   0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
19
+   0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
20
+   0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
21
+   0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
22
+   0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
23
+   0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
24
+   0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
25
+   0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
26
+   0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
27
+   0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
28
+   0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
29
+   0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
30
+   0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
31
+   0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
32
+   0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
33
+   0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
34
+   0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
35
+   0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
36
+   0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
37
+   0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
38
+   0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
39
+   0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
40
+   0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
41
+   0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
42
+   0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
43
+   0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
44
+   0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
45
+   0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
46
+   0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
47
+   0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
48
+   0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
49
+   0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
50
+   0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
51
+   0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
52
+   0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
53
+   0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
54
+   0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
55
+   0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
56
+   0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
57
+   0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
58
+   0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
59
+   0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
60
+   0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
61
+   0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
62
+   0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
63
+   0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
64
+   0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
65
+   0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
66
+   0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
67
+   0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
68
+   0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
69
+};
70
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lz/lz_encoder_mf.c Added
755
 
1
@@ -0,0 +1,753 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lz_encoder_mf.c
5
+/// \brief      Match finders
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "lz_encoder.h"
16
+#include "lz_encoder_hash.h"
17
+
18
+
19
+/// \brief      Find matches starting from the current byte
20
+///
21
+/// \return     The length of the longest match found
22
+extern uint32_t
23
+lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
24
+{
25
+   // Call the match finder. It returns the number of length-distance
26
+   // pairs found.
27
+   // FIXME: Minimum count is zero, what _exactly_ is the maximum?
28
+   const uint32_t count = mf->find(mf, matches);
29
+
30
+   // Length of the longest match; assume that no matches were found
31
+   // and thus the maximum length is zero.
32
+   uint32_t len_best = 0;
33
+
34
+   if (count > 0) {
35
+#ifndef NDEBUG
36
+       // Validate the matches.
37
+       for (uint32_t i = 0; i < count; ++i) {
38
+           assert(matches[i].len <= mf->nice_len);
39
+           assert(matches[i].dist < mf->read_pos);
40
+           assert(memcmp(mf_ptr(mf) - 1,
41
+               mf_ptr(mf) - matches[i].dist - 2,
42
+               matches[i].len) == 0);
43
+       }
44
+#endif
45
+
46
+       // The last used element in the array contains
47
+       // the longest match.
48
+       len_best = matches[count - 1].len;
49
+
50
+       // If a match of maximum search length was found, try to
51
+       // extend the match to maximum possible length.
52
+       if (len_best == mf->nice_len) {
53
+           // The limit for the match length is either the
54
+           // maximum match length supported by the LZ-based
55
+           // encoder or the number of bytes left in the
56
+           // dictionary, whichever is smaller.
57
+           uint32_t limit = mf_avail(mf) + 1;
58
+           if (limit > mf->match_len_max)
59
+               limit = mf->match_len_max;
60
+
61
+           // Pointer to the byte we just ran through
62
+           // the match finder.
63
+           const uint8_t *p1 = mf_ptr(mf) - 1;
64
+
65
+           // Pointer to the beginning of the match. We need -1
66
+           // here because the match distances are zero based.
67
+           const uint8_t *p2 = p1 - matches[count - 1].dist - 1;
68
+
69
+           while (len_best < limit
70
+                   && p1[len_best] == p2[len_best])
71
+               ++len_best;
72
+       }
73
+   }
74
+
75
+   *count_ptr = count;
76
+
77
+   // Finally update the read position to indicate that match finder was
78
+   // run for this dictionary offset.
79
+   ++mf->read_ahead;
80
+
81
+   return len_best;
82
+}
83
+
84
+
85
+/// Hash value to indicate unused element in the hash. Since we start the
86
+/// positions from dict_size + 1, zero is always too far to qualify
87
+/// as usable match position.
88
+#define EMPTY_HASH_VALUE 0
89
+
90
+
91
+/// Normalization must be done when lzma_mf.offset + lzma_mf.read_pos
92
+/// reaches MUST_NORMALIZE_POS.
93
+#define MUST_NORMALIZE_POS UINT32_MAX
94
+
95
+
96
+/// \brief      Normalizes hash values
97
+///
98
+/// The hash arrays store positions of match candidates. The positions are
99
+/// relative to an arbitrary offset that is not the same as the absolute
100
+/// offset in the input stream. The relative position of the current byte
101
+/// is lzma_mf.offset + lzma_mf.read_pos. The distances of the matches are
102
+/// the differences of the current read position and the position found from
103
+/// the hash.
104
+///
105
+/// To prevent integer overflows of the offsets stored in the hash arrays,
106
+/// we need to "normalize" the stored values now and then. During the
107
+/// normalization, we drop values that indicate distance greater than the
108
+/// dictionary size, thus making space for new values.
109
+static void
110
+normalize(lzma_mf *mf)
111
+{
112
+   assert(mf->read_pos + mf->offset == MUST_NORMALIZE_POS);
113
+
114
+   // In future we may not want to touch the lowest bits, because there
115
+   // may be match finders that use larger resolution than one byte.
116
+   const uint32_t subvalue
117
+           = (MUST_NORMALIZE_POS - mf->cyclic_size);
118
+               // & (~(UINT32_C(1) << 10) - 1);
119
+
120
+   const uint32_t count = mf->hash_size_sum + mf->sons_count;
121
+   uint32_t *hash = mf->hash;
122
+
123
+   for (uint32_t i = 0; i < count; ++i) {
124
+       // If the distance is greater than the dictionary size,
125
+       // we can simply mark the hash element as empty.
126
+       //
127
+       // NOTE: Only the first mf->hash_size_sum elements are
128
+       // initialized for sure. There may be uninitialized elements
129
+       // in mf->son. Since we go through both mf->hash and
130
+       // mf->son here in normalization, Valgrind may complain
131
+       // that the "if" below depends on uninitialized value. In
132
+       // this case it is safe to ignore the warning. See also the
133
+       // comments in lz_encoder_init() in lz_encoder.c.
134
+       if (hash[i] <= subvalue)
135
+           hash[i] = EMPTY_HASH_VALUE;
136
+       else
137
+           hash[i] -= subvalue;
138
+   }
139
+
140
+   // Update offset to match the new locations.
141
+   mf->offset -= subvalue;
142
+
143
+   return;
144
+}
145
+
146
+
147
+/// Mark the current byte as processed from point of view of the match finder.
148
+static void
149
+move_pos(lzma_mf *mf)
150
+{
151
+   if (++mf->cyclic_pos == mf->cyclic_size)
152
+       mf->cyclic_pos = 0;
153
+
154
+   ++mf->read_pos;
155
+   assert(mf->read_pos <= mf->write_pos);
156
+
157
+   if (unlikely(mf->read_pos + mf->offset == UINT32_MAX))
158
+       normalize(mf);
159
+}
160
+
161
+
162
+/// When flushing, we cannot run the match finder unless there is nice_len
163
+/// bytes available in the dictionary. Instead, we skip running the match
164
+/// finder (indicating that no match was found), and count how many bytes we
165
+/// have ignored this way.
166
+///
167
+/// When new data is given after the flushing was completed, the match finder
168
+/// is restarted by rewinding mf->read_pos backwards by mf->pending. Then
169
+/// the missed bytes are added to the hash using the match finder's skip
170
+/// function (with small amount of input, it may start using mf->pending
171
+/// again if flushing).
172
+///
173
+/// Due to this rewinding, we don't touch cyclic_pos or test for
174
+/// normalization. It will be done when the match finder's skip function
175
+/// catches up after a flush.
176
+static void
177
+move_pending(lzma_mf *mf)
178
+{
179
+   ++mf->read_pos;
180
+   assert(mf->read_pos <= mf->write_pos);
181
+   ++mf->pending;
182
+}
183
+
184
+
185
+/// Calculate len_limit and determine if there is enough input to run
186
+/// the actual match finder code. Sets up "cur" and "pos". This macro
187
+/// is used by all find functions and binary tree skip functions. Hash
188
+/// chain skip function doesn't need len_limit so a simpler code is used
189
+/// in them.
190
+#define header(is_bt, len_min, ret_op) \
191
+   uint32_t len_limit = mf_avail(mf); \
192
+   if (mf->nice_len <= len_limit) { \
193
+       len_limit = mf->nice_len; \
194
+   } else if (len_limit < (len_min) \
195
+           || (is_bt && mf->action == LZMA_SYNC_FLUSH)) { \
196
+       assert(mf->action != LZMA_RUN); \
197
+       move_pending(mf); \
198
+       ret_op; \
199
+   } \
200
+   const uint8_t *cur = mf_ptr(mf); \
201
+   const uint32_t pos = mf->read_pos + mf->offset
202
+
203
+
204
+/// Header for find functions. "return 0" indicates that zero matches
205
+/// were found.
206
+#define header_find(is_bt, len_min) \
207
+   header(is_bt, len_min, return 0); \
208
+   uint32_t matches_count = 0
209
+
210
+
211
+/// Header for a loop in a skip function. "continue" tells to skip the rest
212
+/// of the code in the loop.
213
+#define header_skip(is_bt, len_min) \
214
+   header(is_bt, len_min, continue)
215
+
216
+
217
+/// Calls hc_find_func() or bt_find_func() and calculates the total number
218
+/// of matches found. Updates the dictionary position and returns the number
219
+/// of matches found.
220
+#define call_find(func, len_best) \
221
+do { \
222
+   matches_count = func(len_limit, pos, cur, cur_match, mf->depth, \
223
+               mf->son, mf->cyclic_pos, mf->cyclic_size, \
224
+               matches + matches_count, len_best) \
225
+           - matches; \
226
+   move_pos(mf); \
227
+   return matches_count; \
228
+} while (0)
229
+
230
+
231
+////////////////
232
+// Hash Chain //
233
+////////////////
234
+
235
+#if defined(HAVE_MF_HC3) || defined(HAVE_MF_HC4)
236
+///
237
+///
238
+/// \param      len_limit       Don't look for matches longer than len_limit.
239
+/// \param      pos             lzma_mf.read_pos + lzma_mf.offset
240
+/// \param      cur             Pointer to current byte (mf_ptr(mf))
241
+/// \param      cur_match       Start position of the current match candidate
242
+/// \param      depth           Maximum length of the hash chain
243
+/// \param      son             lzma_mf.son (contains the hash chain)
244
+/// \param      cyclic_pos
245
+/// \param      cyclic_size
246
+/// \param      matches         Array to hold the matches.
247
+/// \param      len_best        The length of the longest match found so far.
248
+static lzma_match *
249
+hc_find_func(
250
+       const uint32_t len_limit,
251
+       const uint32_t pos,
252
+       const uint8_t *const cur,
253
+       uint32_t cur_match,
254
+       uint32_t depth,
255
+       uint32_t *const son,
256
+       const uint32_t cyclic_pos,
257
+       const uint32_t cyclic_size,
258
+       lzma_match *matches,
259
+       uint32_t len_best)
260
+{
261
+   son[cyclic_pos] = cur_match;
262
+
263
+   while (true) {
264
+       const uint32_t delta = pos - cur_match;
265
+       if (depth-- == 0 || delta >= cyclic_size)
266
+           return matches;
267
+
268
+       const uint8_t *const pb = cur - delta;
269
+       cur_match = son[cyclic_pos - delta
270
+               + (delta > cyclic_pos ? cyclic_size : 0)];
271
+
272
+       if (pb[len_best] == cur[len_best] && pb[0] == cur[0]) {
273
+           uint32_t len = 0;
274
+           while (++len != len_limit)
275
+               if (pb[len] != cur[len])
276
+                   break;
277
+
278
+           if (len_best < len) {
279
+               len_best = len;
280
+               matches->len = len;
281
+               matches->dist = delta - 1;
282
+               ++matches;
283
+
284
+               if (len == len_limit)
285
+                   return matches;
286
+           }
287
+       }
288
+   }
289
+}
290
+
291
+
292
+#define hc_find(len_best) \
293
+   call_find(hc_find_func, len_best)
294
+
295
+
296
+#define hc_skip() \
297
+do { \
298
+   mf->son[mf->cyclic_pos] = cur_match; \
299
+   move_pos(mf); \
300
+} while (0)
301
+
302
+#endif
303
+
304
+
305
+#ifdef HAVE_MF_HC3
306
+extern uint32_t
307
+lzma_mf_hc3_find(lzma_mf *mf, lzma_match *matches)
308
+{
309
+   header_find(false, 3);
310
+
311
+   hash_3_calc();
312
+
313
+   const uint32_t delta2 = pos - mf->hash[hash_2_value];
314
+   const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
315
+
316
+   mf->hash[hash_2_value] = pos;
317
+   mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
318
+
319
+   uint32_t len_best = 2;
320
+
321
+   if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
322
+       for ( ; len_best != len_limit; ++len_best)
323
+           if (*(cur + len_best - delta2) != cur[len_best])
324
+               break;
325
+
326
+       matches[0].len = len_best;
327
+       matches[0].dist = delta2 - 1;
328
+       matches_count = 1;
329
+
330
+       if (len_best == len_limit) {
331
+           hc_skip();
332
+           return 1; // matches_count
333
+       }
334
+   }
335
+
336
+   hc_find(len_best);
337
+}
338
+
339
+
340
+extern void
341
+lzma_mf_hc3_skip(lzma_mf *mf, uint32_t amount)
342
+{
343
+   do {
344
+       if (mf_avail(mf) < 3) {
345
+           move_pending(mf);
346
+           continue;
347
+       }
348
+
349
+       const uint8_t *cur = mf_ptr(mf);
350
+       const uint32_t pos = mf->read_pos + mf->offset;
351
+
352
+       hash_3_calc();
353
+
354
+       const uint32_t cur_match
355
+               = mf->hash[FIX_3_HASH_SIZE + hash_value];
356
+
357
+       mf->hash[hash_2_value] = pos;
358
+       mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
359
+
360
+       hc_skip();
361
+
362
+   } while (--amount != 0);
363
+}
364
+#endif
365
+
366
+
367
+#ifdef HAVE_MF_HC4
368
+extern uint32_t
369
+lzma_mf_hc4_find(lzma_mf *mf, lzma_match *matches)
370
+{
371
+   header_find(false, 4);
372
+
373
+   hash_4_calc();
374
+
375
+   uint32_t delta2 = pos - mf->hash[hash_2_value];
376
+   const uint32_t delta3
377
+           = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
378
+   const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
379
+
380
+   mf->hash[hash_2_value ] = pos;
381
+   mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
382
+   mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
383
+
384
+   uint32_t len_best = 1;
385
+
386
+   if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
387
+       len_best = 2;
388
+       matches[0].len = 2;
389
+       matches[0].dist = delta2 - 1;
390
+       matches_count = 1;
391
+   }
392
+
393
+   if (delta2 != delta3 && delta3 < mf->cyclic_size
394
+           && *(cur - delta3) == *cur) {
395
+       len_best = 3;
396
+       matches[matches_count++].dist = delta3 - 1;
397
+       delta2 = delta3;
398
+   }
399
+
400
+   if (matches_count != 0) {
401
+       for ( ; len_best != len_limit; ++len_best)
402
+           if (*(cur + len_best - delta2) != cur[len_best])
403
+               break;
404
+
405
+       matches[matches_count - 1].len = len_best;
406
+
407
+       if (len_best == len_limit) {
408
+           hc_skip();
409
+           return matches_count;
410
+       }
411
+   }
412
+
413
+   if (len_best < 3)
414
+       len_best = 3;
415
+
416
+   hc_find(len_best);
417
+}
418
+
419
+
420
+extern void
421
+lzma_mf_hc4_skip(lzma_mf *mf, uint32_t amount)
422
+{
423
+   do {
424
+       if (mf_avail(mf) < 4) {
425
+           move_pending(mf);
426
+           continue;
427
+       }
428
+
429
+       const uint8_t *cur = mf_ptr(mf);
430
+       const uint32_t pos = mf->read_pos + mf->offset;
431
+
432
+       hash_4_calc();
433
+
434
+       const uint32_t cur_match
435
+               = mf->hash[FIX_4_HASH_SIZE + hash_value];
436
+
437
+       mf->hash[hash_2_value] = pos;
438
+       mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
439
+       mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
440
+
441
+       hc_skip();
442
+
443
+   } while (--amount != 0);
444
+}
445
+#endif
446
+
447
+
448
+/////////////////
449
+// Binary Tree //
450
+/////////////////
451
+
452
+#if defined(HAVE_MF_BT2) || defined(HAVE_MF_BT3) || defined(HAVE_MF_BT4)
453
+static lzma_match *
454
+bt_find_func(
455
+       const uint32_t len_limit,
456
+       const uint32_t pos,
457
+       const uint8_t *const cur,
458
+       uint32_t cur_match,
459
+       uint32_t depth,
460
+       uint32_t *const son,
461
+       const uint32_t cyclic_pos,
462
+       const uint32_t cyclic_size,
463
+       lzma_match *matches,
464
+       uint32_t len_best)
465
+{
466
+   uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;
467
+   uint32_t *ptr1 = son + (cyclic_pos << 1);
468
+
469
+   uint32_t len0 = 0;
470
+   uint32_t len1 = 0;
471
+
472
+   while (true) {
473
+       const uint32_t delta = pos - cur_match;
474
+       if (depth-- == 0 || delta >= cyclic_size) {
475
+           *ptr0 = EMPTY_HASH_VALUE;
476
+           *ptr1 = EMPTY_HASH_VALUE;
477
+           return matches;
478
+       }
479
+
480
+       uint32_t *const pair = son + ((cyclic_pos - delta
481
+               + (delta > cyclic_pos ? cyclic_size : 0))
482
+               << 1);
483
+
484
+       const uint8_t *const pb = cur - delta;
485
+       uint32_t len = my_min(len0, len1);
486
+
487
+       if (pb[len] == cur[len]) {
488
+           while (++len != len_limit)
489
+               if (pb[len] != cur[len])
490
+                   break;
491
+
492
+           if (len_best < len) {
493
+               len_best = len;
494
+               matches->len = len;
495
+               matches->dist = delta - 1;
496
+               ++matches;
497
+
498
+               if (len == len_limit) {
499
+                   *ptr1 = pair[0];
500
+                   *ptr0 = pair[1];
501
+                   return matches;
502
+               }
503
+           }
504
+       }
505
+
506
+       if (pb[len] < cur[len]) {
507
+           *ptr1 = cur_match;
508
+           ptr1 = pair + 1;
509
+           cur_match = *ptr1;
510
+           len1 = len;
511
+       } else {
512
+           *ptr0 = cur_match;
513
+           ptr0 = pair;
514
+           cur_match = *ptr0;
515
+           len0 = len;
516
+       }
517
+   }
518
+}
519
+
520
+
521
+static void
522
+bt_skip_func(
523
+       const uint32_t len_limit,
524
+       const uint32_t pos,
525
+       const uint8_t *const cur,
526
+       uint32_t cur_match,
527
+       uint32_t depth,
528
+       uint32_t *const son,
529
+       const uint32_t cyclic_pos,
530
+       const uint32_t cyclic_size)
531
+{
532
+   uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;
533
+   uint32_t *ptr1 = son + (cyclic_pos << 1);
534
+
535
+   uint32_t len0 = 0;
536
+   uint32_t len1 = 0;
537
+
538
+   while (true) {
539
+       const uint32_t delta = pos - cur_match;
540
+       if (depth-- == 0 || delta >= cyclic_size) {
541
+           *ptr0 = EMPTY_HASH_VALUE;
542
+           *ptr1 = EMPTY_HASH_VALUE;
543
+           return;
544
+       }
545
+
546
+       uint32_t *pair = son + ((cyclic_pos - delta
547
+               + (delta > cyclic_pos ? cyclic_size : 0))
548
+               << 1);
549
+       const uint8_t *pb = cur - delta;
550
+       uint32_t len = my_min(len0, len1);
551
+
552
+       if (pb[len] == cur[len]) {
553
+           while (++len != len_limit)
554
+               if (pb[len] != cur[len])
555
+                   break;
556
+
557
+           if (len == len_limit) {
558
+               *ptr1 = pair[0];
559
+               *ptr0 = pair[1];
560
+               return;
561
+           }
562
+       }
563
+
564
+       if (pb[len] < cur[len]) {
565
+           *ptr1 = cur_match;
566
+           ptr1 = pair + 1;
567
+           cur_match = *ptr1;
568
+           len1 = len;
569
+       } else {
570
+           *ptr0 = cur_match;
571
+           ptr0 = pair;
572
+           cur_match = *ptr0;
573
+           len0 = len;
574
+       }
575
+   }
576
+}
577
+
578
+
579
+#define bt_find(len_best) \
580
+   call_find(bt_find_func, len_best)
581
+
582
+#define bt_skip() \
583
+do { \
584
+   bt_skip_func(len_limit, pos, cur, cur_match, mf->depth, \
585
+           mf->son, mf->cyclic_pos, \
586
+           mf->cyclic_size); \
587
+   move_pos(mf); \
588
+} while (0)
589
+
590
+#endif
591
+
592
+
593
+#ifdef HAVE_MF_BT2
594
+extern uint32_t
595
+lzma_mf_bt2_find(lzma_mf *mf, lzma_match *matches)
596
+{
597
+   header_find(true, 2);
598
+
599
+   hash_2_calc();
600
+
601
+   const uint32_t cur_match = mf->hash[hash_value];
602
+   mf->hash[hash_value] = pos;
603
+
604
+   bt_find(1);
605
+}
606
+
607
+
608
+extern void
609
+lzma_mf_bt2_skip(lzma_mf *mf, uint32_t amount)
610
+{
611
+   do {
612
+       header_skip(true, 2);
613
+
614
+       hash_2_calc();
615
+
616
+       const uint32_t cur_match = mf->hash[hash_value];
617
+       mf->hash[hash_value] = pos;
618
+
619
+       bt_skip();
620
+
621
+   } while (--amount != 0);
622
+}
623
+#endif
624
+
625
+
626
+#ifdef HAVE_MF_BT3
627
+extern uint32_t
628
+lzma_mf_bt3_find(lzma_mf *mf, lzma_match *matches)
629
+{
630
+   header_find(true, 3);
631
+
632
+   hash_3_calc();
633
+
634
+   const uint32_t delta2 = pos - mf->hash[hash_2_value];
635
+   const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
636
+
637
+   mf->hash[hash_2_value] = pos;
638
+   mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
639
+
640
+   uint32_t len_best = 2;
641
+
642
+   if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
643
+       for ( ; len_best != len_limit; ++len_best)
644
+           if (*(cur + len_best - delta2) != cur[len_best])
645
+               break;
646
+
647
+       matches[0].len = len_best;
648
+       matches[0].dist = delta2 - 1;
649
+       matches_count = 1;
650
+
651
+       if (len_best == len_limit) {
652
+           bt_skip();
653
+           return 1; // matches_count
654
+       }
655
+   }
656
+
657
+   bt_find(len_best);
658
+}
659
+
660
+
661
+extern void
662
+lzma_mf_bt3_skip(lzma_mf *mf, uint32_t amount)
663
+{
664
+   do {
665
+       header_skip(true, 3);
666
+
667
+       hash_3_calc();
668
+
669
+       const uint32_t cur_match
670
+               = mf->hash[FIX_3_HASH_SIZE + hash_value];
671
+
672
+       mf->hash[hash_2_value] = pos;
673
+       mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
674
+
675
+       bt_skip();
676
+
677
+   } while (--amount != 0);
678
+}
679
+#endif
680
+
681
+
682
+#ifdef HAVE_MF_BT4
683
+extern uint32_t
684
+lzma_mf_bt4_find(lzma_mf *mf, lzma_match *matches)
685
+{
686
+   header_find(true, 4);
687
+
688
+   hash_4_calc();
689
+
690
+   uint32_t delta2 = pos - mf->hash[hash_2_value];
691
+   const uint32_t delta3
692
+           = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
693
+   const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
694
+
695
+   mf->hash[hash_2_value] = pos;
696
+   mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
697
+   mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
698
+
699
+   uint32_t len_best = 1;
700
+
701
+   if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
702
+       len_best = 2;
703
+       matches[0].len = 2;
704
+       matches[0].dist = delta2 - 1;
705
+       matches_count = 1;
706
+   }
707
+
708
+   if (delta2 != delta3 && delta3 < mf->cyclic_size
709
+           && *(cur - delta3) == *cur) {
710
+       len_best = 3;
711
+       matches[matches_count++].dist = delta3 - 1;
712
+       delta2 = delta3;
713
+   }
714
+
715
+   if (matches_count != 0) {
716
+       for ( ; len_best != len_limit; ++len_best)
717
+           if (*(cur + len_best - delta2) != cur[len_best])
718
+               break;
719
+
720
+       matches[matches_count - 1].len = len_best;
721
+
722
+       if (len_best == len_limit) {
723
+           bt_skip();
724
+           return matches_count;
725
+       }
726
+   }
727
+
728
+   if (len_best < 3)
729
+       len_best = 3;
730
+
731
+   bt_find(len_best);
732
+}
733
+
734
+
735
+extern void
736
+lzma_mf_bt4_skip(lzma_mf *mf, uint32_t amount)
737
+{
738
+   do {
739
+       header_skip(true, 4);
740
+
741
+       hash_4_calc();
742
+
743
+       const uint32_t cur_match
744
+               = mf->hash[FIX_4_HASH_SIZE + hash_value];
745
+
746
+       mf->hash[hash_2_value] = pos;
747
+       mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
748
+       mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
749
+
750
+       bt_skip();
751
+
752
+   } while (--amount != 0);
753
+}
754
+#endif
755
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/fastpos.h Added
142
 
1
@@ -0,0 +1,140 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       fastpos.h
5
+/// \brief      Kind of two-bit version of bit scan reverse
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_FASTPOS_H
16
+#define LZMA_FASTPOS_H
17
+
18
+// LZMA encodes match distances (positions) by storing the highest two
19
+// bits using a six-bit value [0, 63], and then the missing lower bits.
20
+// Dictionary size is also stored using this encoding in the new .lzma
21
+// file format header.
22
+//
23
+// fastpos.h provides a way to quickly find out the correct six-bit
24
+// values. The following table gives some examples of this encoding:
25
+//
26
+//      pos   return
27
+//       0       0
28
+//       1       1
29
+//       2       2
30
+//       3       3
31
+//       4       4
32
+//       5       4
33
+//       6       5
34
+//       7       5
35
+//       8       6
36
+//      11       6
37
+//      12       7
38
+//     ...      ...
39
+//      15       7
40
+//      16       8
41
+//      17       8
42
+//     ...      ...
43
+//      23       8
44
+//      24       9
45
+//      25       9
46
+//     ...      ...
47
+//
48
+//
49
+// Provided functions or macros
50
+// ----------------------------
51
+//
52
+// get_pos_slot(pos) is the basic version. get_pos_slot_2(pos)
53
+// assumes that pos >= FULL_DISTANCES, thus the result is at least
54
+// FULL_DISTANCES_BITS * 2. Using get_pos_slot(pos) instead of
55
+// get_pos_slot_2(pos) would give the same result, but get_pos_slot_2(pos)
56
+// should be tiny bit faster due to the assumption being made.
57
+//
58
+//
59
+// Size vs. speed
60
+// --------------
61
+//
62
+// With some CPUs that have fast BSR (bit scan reverse) instruction, the
63
+// size optimized version is slightly faster than the bigger table based
64
+// approach. Such CPUs include Intel Pentium Pro, Pentium II, Pentium III
65
+// and Core 2 (possibly others). AMD K7 seems to have slower BSR, but that
66
+// would still have speed roughly comparable to the table version. Older
67
+// x86 CPUs like the original Pentium have very slow BSR; on those systems
68
+// the table version is a lot faster.
69
+//
70
+// On some CPUs, the table version is a lot faster when using position
71
+// dependent code, but with position independent code the size optimized
72
+// version is slightly faster. This occurs at least on 32-bit SPARC (no
73
+// ASM optimizations).
74
+//
75
+// I'm making the table version the default, because that has good speed
76
+// on all systems I have tried. The size optimized version is sometimes
77
+// slightly faster, but sometimes it is a lot slower.
78
+
79
+#ifdef HAVE_SMALL
80
+#  define get_pos_slot(pos) ((pos) <= 4 ? (pos) : get_pos_slot_2(pos))
81
+
82
+static inline uint32_t
83
+get_pos_slot_2(uint32_t pos)
84
+{
85
+   const uint32_t i = bsr32(pos);
86
+   return (i + i) + ((pos >> (i - 1)) & 1);
87
+}
88
+
89
+
90
+#else
91
+
92
+#define FASTPOS_BITS 13
93
+
94
+extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS];
95
+
96
+
97
+#define fastpos_shift(extra, n) \
98
+   ((extra) + (n) * (FASTPOS_BITS - 1))
99
+
100
+#define fastpos_limit(extra, n) \
101
+   (UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n)))
102
+
103
+#define fastpos_result(pos, extra, n) \
104
+   lzma_fastpos[(pos) >> fastpos_shift(extra, n)] \
105
+           + 2 * fastpos_shift(extra, n)
106
+
107
+
108
+static inline uint32_t
109
+get_pos_slot(uint32_t pos)
110
+{
111
+   // If it is small enough, we can pick the result directly from
112
+   // the precalculated table.
113
+   if (pos < fastpos_limit(0, 0))
114
+       return lzma_fastpos[pos];
115
+
116
+   if (pos < fastpos_limit(0, 1))
117
+       return fastpos_result(pos, 0, 1);
118
+
119
+   return fastpos_result(pos, 0, 2);
120
+}
121
+
122
+
123
+#ifdef FULL_DISTANCES_BITS
124
+static inline uint32_t
125
+get_pos_slot_2(uint32_t pos)
126
+{
127
+   assert(pos >= FULL_DISTANCES);
128
+
129
+   if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 0))
130
+       return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 0);
131
+
132
+   if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 1))
133
+       return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 1);
134
+
135
+   return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 2);
136
+}
137
+#endif
138
+
139
+#endif
140
+
141
+#endif
142
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/fastpos_table.c Added
521
 
1
@@ -0,0 +1,519 @@
2
+/* This file has been automatically generated by fastpos_tablegen.c. */
3
+
4
+#include "common.h"
5
+#include "fastpos.h"
6
+
7
+const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {
8
+     0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,
9
+     8,  8,  8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9,
10
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
11
+    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
12
+    12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
13
+    12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
14
+    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
15
+    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
16
+    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
17
+    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
18
+    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
19
+    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
20
+    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
21
+    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
22
+    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
23
+    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
24
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
25
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
26
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
27
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
28
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
29
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
30
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
31
+    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
32
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
33
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
34
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
35
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
36
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
37
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
38
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
39
+    17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
40
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
41
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
42
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
43
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
44
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
45
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
46
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
47
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
48
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
49
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
50
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
51
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
52
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
53
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
54
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
55
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
56
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
57
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
58
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
59
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
60
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
61
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
62
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
63
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
64
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
65
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
66
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
67
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
68
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
69
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
70
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
71
+    19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
72
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
73
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
74
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
75
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
76
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
77
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
78
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
79
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
80
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
81
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
82
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
83
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
84
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
85
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
86
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
87
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
88
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
89
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
90
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
91
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
92
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
93
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
94
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
95
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
96
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
97
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
98
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
99
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
100
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
101
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
102
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
103
+    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
104
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
105
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
106
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
107
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
108
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
109
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
110
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
111
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
112
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
113
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
114
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
115
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
116
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
117
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
118
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
119
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
120
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
121
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
122
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
123
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
124
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
125
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
126
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
127
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
128
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
129
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
130
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
131
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
132
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
133
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
134
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
135
+    21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
136
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
137
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
138
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
139
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
140
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
141
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
142
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
143
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
144
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
145
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
146
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
147
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
148
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
149
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
150
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
151
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
152
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
153
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
154
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
155
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
156
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
157
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
158
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
159
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
160
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
161
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
162
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
163
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
164
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
165
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
166
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
167
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
168
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
169
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
170
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
171
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
172
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
173
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
174
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
175
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
176
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
177
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
178
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
179
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
180
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
181
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
182
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
183
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
184
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
185
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
186
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
187
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
188
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
189
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
190
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
191
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
192
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
193
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
194
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
195
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
196
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
197
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
198
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
199
+    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
200
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
201
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
202
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
203
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
204
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
205
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
206
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
207
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
208
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
209
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
210
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
211
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
212
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
213
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
214
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
215
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
216
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
217
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
218
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
219
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
220
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
221
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
222
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
223
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
224
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
225
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
226
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
227
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
228
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
229
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
230
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
231
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
232
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
233
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
234
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
235
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
236
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
237
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
238
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
239
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
240
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
241
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
242
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
243
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
244
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
245
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
246
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
247
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
248
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
249
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
250
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
251
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
252
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
253
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
254
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
255
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
256
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
257
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
258
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
259
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
260
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
261
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
262
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
263
+    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
264
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
265
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
266
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
267
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
268
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
269
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
270
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
271
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
272
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
273
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
274
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
275
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
276
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
277
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
278
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
279
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
280
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
281
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
282
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
283
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
284
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
285
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
286
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
287
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
288
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
289
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
290
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
291
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
292
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
293
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
294
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
295
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
296
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
297
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
298
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
299
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
300
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
301
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
302
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
303
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
304
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
305
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
306
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
307
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
308
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
309
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
310
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
311
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
312
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
313
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
314
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
315
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
316
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
317
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
318
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
319
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
320
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
321
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
322
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
323
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
324
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
325
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
326
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
327
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
328
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
329
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
330
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
331
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
332
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
333
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
334
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
335
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
336
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
337
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
338
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
339
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
340
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
341
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
342
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
343
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
344
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
345
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
346
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
347
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
348
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
349
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
350
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
351
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
352
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
353
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
354
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
355
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
356
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
357
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
358
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
359
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
360
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
361
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
362
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
363
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
364
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
365
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
366
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
367
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
368
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
369
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
370
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
371
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
372
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
373
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
374
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
375
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
376
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
377
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
378
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
379
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
380
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
381
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
382
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
383
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
384
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
385
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
386
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
387
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
388
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
389
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
390
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
391
+    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
392
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
393
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
394
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
395
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
396
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
397
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
398
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
399
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
400
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
401
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
402
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
403
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
404
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
405
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
406
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
407
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
408
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
409
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
410
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
411
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
412
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
413
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
414
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
415
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
416
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
417
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
418
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
419
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
420
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
421
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
422
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
423
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
424
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
425
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
426
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
427
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
428
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
429
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
430
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
431
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
432
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
433
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
434
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
435
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
436
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
437
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
438
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
439
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
440
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
441
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
442
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
443
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
444
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
445
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
446
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
447
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
448
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
449
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
450
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
451
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
452
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
453
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
454
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
455
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
456
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
457
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
458
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
459
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
460
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
461
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
462
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
463
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
464
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
465
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
466
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
467
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
468
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
469
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
470
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
471
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
472
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
473
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
474
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
475
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
476
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
477
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
478
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
479
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
480
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
481
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
482
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
483
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
484
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
485
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
486
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
487
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
488
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
489
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
490
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
491
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
492
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
493
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
494
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
495
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
496
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
497
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
498
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
499
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
500
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
501
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
502
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
503
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
504
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
505
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
506
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
507
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
508
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
509
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
510
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
511
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
512
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
513
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
514
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
515
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
516
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
517
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
518
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
519
+    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
520
+};
521
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/fastpos_tablegen.c Added
58
 
1
@@ -0,0 +1,56 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       fastpos_tablegen.c
5
+/// \brief      Generates the lzma_fastpos[] lookup table
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include <sys/types.h>
16
+#include <inttypes.h>
17
+#include <stdio.h>
18
+#include "fastpos.h"
19
+
20
+
21
+int
22
+main(void)
23
+{
24
+   uint8_t fastpos[1 << FASTPOS_BITS];
25
+
26
+   const uint8_t fast_slots = 2 * FASTPOS_BITS;
27
+   uint32_t c = 2;
28
+
29
+   fastpos[0] = 0;
30
+   fastpos[1] = 1;
31
+
32
+   for (uint8_t slot_fast = 2; slot_fast < fast_slots; ++slot_fast) {
33
+       const uint32_t k = 1 << ((slot_fast >> 1) - 1);
34
+       for (uint32_t j = 0; j < k; ++j, ++c)
35
+           fastpos[c] = slot_fast;
36
+   }
37
+
38
+   printf("/* This file has been automatically generated "
39
+           "by fastpos_tablegen.c. */\n\n"
40
+           "#include \"common.h\"\n"
41
+           "#include \"fastpos.h\"\n\n"
42
+           "const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {");
43
+
44
+   for (size_t i = 0; i < (1 << FASTPOS_BITS); ++i) {
45
+       if (i % 16 == 0)
46
+           printf("\n\t");
47
+
48
+       printf("%3u", (unsigned int)(fastpos[i]));
49
+
50
+       if (i != (1 << FASTPOS_BITS) - 1)
51
+           printf(",");
52
+   }
53
+
54
+   printf("\n};\n");
55
+
56
+   return 0;
57
+}
58
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma2_decoder.c Added
306
 
1
@@ -0,0 +1,304 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma2_decoder.c
5
+/// \brief      LZMA2 decoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "lzma2_decoder.h"
16
+#include "lz_decoder.h"
17
+#include "lzma_decoder.h"
18
+
19
+
20
+struct lzma_coder_s {
21
+   enum sequence {
22
+       SEQ_CONTROL,
23
+       SEQ_UNCOMPRESSED_1,
24
+       SEQ_UNCOMPRESSED_2,
25
+       SEQ_COMPRESSED_0,
26
+       SEQ_COMPRESSED_1,
27
+       SEQ_PROPERTIES,
28
+       SEQ_LZMA,
29
+       SEQ_COPY,
30
+   } sequence;
31
+
32
+   /// Sequence after the size fields have been decoded.
33
+   enum sequence next_sequence;
34
+
35
+   /// LZMA decoder
36
+   lzma_lz_decoder lzma;
37
+
38
+   /// Uncompressed size of LZMA chunk
39
+   size_t uncompressed_size;
40
+
41
+   /// Compressed size of the chunk (naturally equals to uncompressed
42
+   /// size of uncompressed chunk)
43
+   size_t compressed_size;
44
+
45
+   /// True if properties are needed. This is false before the
46
+   /// first LZMA chunk.
47
+   bool need_properties;
48
+
49
+   /// True if dictionary reset is needed. This is false before the
50
+   /// first chunk (LZMA or uncompressed).
51
+   bool need_dictionary_reset;
52
+
53
+   lzma_options_lzma options;
54
+};
55
+
56
+
57
+static lzma_ret
58
+lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict,
59
+       const uint8_t *restrict in, size_t *restrict in_pos,
60
+       size_t in_size)
61
+{
62
+   // With SEQ_LZMA it is possible that no new input is needed to do
63
+   // some progress. The rest of the sequences assume that there is
64
+   // at least one byte of input.
65
+   while (*in_pos < in_size || coder->sequence == SEQ_LZMA)
66
+   switch (coder->sequence) {
67
+   case SEQ_CONTROL: {
68
+       const uint32_t control = in[*in_pos];
69
+       ++*in_pos;
70
+
71
+       // End marker
72
+       if (control == 0x00)
73
+           return LZMA_STREAM_END;
74
+
75
+       if (control >= 0xE0 || control == 1) {
76
+           // Dictionary reset implies that next LZMA chunk has
77
+           // to set new properties.
78
+           coder->need_properties = true;
79
+           coder->need_dictionary_reset = true;
80
+       } else if (coder->need_dictionary_reset) {
81
+           return LZMA_DATA_ERROR;
82
+       }
83
+
84
+       if (control >= 0x80) {
85
+           // LZMA chunk. The highest five bits of the
86
+           // uncompressed size are taken from the control byte.
87
+           coder->uncompressed_size = (control & 0x1F) << 16;
88
+           coder->sequence = SEQ_UNCOMPRESSED_1;
89
+
90
+           // See if there are new properties or if we need to
91
+           // reset the state.
92
+           if (control >= 0xC0) {
93
+               // When there are new properties, state reset
94
+               // is done at SEQ_PROPERTIES.
95
+               coder->need_properties = false;
96
+               coder->next_sequence = SEQ_PROPERTIES;
97
+
98
+           } else if (coder->need_properties) {
99
+               return LZMA_DATA_ERROR;
100
+
101
+           } else {
102
+               coder->next_sequence = SEQ_LZMA;
103
+
104
+               // If only state reset is wanted with old
105
+               // properties, do the resetting here for
106
+               // simplicity.
107
+               if (control >= 0xA0)
108
+                   coder->lzma.reset(coder->lzma.coder,
109
+                           &coder->options);
110
+           }
111
+       } else {
112
+           // Invalid control values
113
+           if (control > 2)
114
+               return LZMA_DATA_ERROR;
115
+
116
+           // It's uncompressed chunk
117
+           coder->sequence = SEQ_COMPRESSED_0;
118
+           coder->next_sequence = SEQ_COPY;
119
+       }
120
+
121
+       if (coder->need_dictionary_reset) {
122
+           // Finish the dictionary reset and let the caller
123
+           // flush the dictionary to the actual output buffer.
124
+           coder->need_dictionary_reset = false;
125
+           dict_reset(dict);
126
+           return LZMA_OK;
127
+       }
128
+
129
+       break;
130
+   }
131
+
132
+   case SEQ_UNCOMPRESSED_1:
133
+       coder->uncompressed_size += (uint32_t)(in[(*in_pos)++]) << 8;
134
+       coder->sequence = SEQ_UNCOMPRESSED_2;
135
+       break;
136
+
137
+   case SEQ_UNCOMPRESSED_2:
138
+       coder->uncompressed_size += in[(*in_pos)++] + 1;
139
+       coder->sequence = SEQ_COMPRESSED_0;
140
+       coder->lzma.set_uncompressed(coder->lzma.coder,
141
+               coder->uncompressed_size);
142
+       break;
143
+
144
+   case SEQ_COMPRESSED_0:
145
+       coder->compressed_size = (uint32_t)(in[(*in_pos)++]) << 8;
146
+       coder->sequence = SEQ_COMPRESSED_1;
147
+       break;
148
+
149
+   case SEQ_COMPRESSED_1:
150
+       coder->compressed_size += in[(*in_pos)++] + 1;
151
+       coder->sequence = coder->next_sequence;
152
+       break;
153
+
154
+   case SEQ_PROPERTIES:
155
+       if (lzma_lzma_lclppb_decode(&coder->options, in[(*in_pos)++]))
156
+           return LZMA_DATA_ERROR;
157
+
158
+       coder->lzma.reset(coder->lzma.coder, &coder->options);
159
+
160
+       coder->sequence = SEQ_LZMA;
161
+       break;
162
+
163
+   case SEQ_LZMA: {
164
+       // Store the start offset so that we can update
165
+       // coder->compressed_size later.
166
+       const size_t in_start = *in_pos;
167
+
168
+       // Decode from in[] to *dict.
169
+       const lzma_ret ret = coder->lzma.code(coder->lzma.coder,
170
+               dict, in, in_pos, in_size);
171
+
172
+       // Validate and update coder->compressed_size.
173
+       const size_t in_used = *in_pos - in_start;
174
+       if (in_used > coder->compressed_size)
175
+           return LZMA_DATA_ERROR;
176
+
177
+       coder->compressed_size -= in_used;
178
+
179
+       // Return if we didn't finish the chunk, or an error occurred.
180
+       if (ret != LZMA_STREAM_END)
181
+           return ret;
182
+
183
+       // The LZMA decoder must have consumed the whole chunk now.
184
+       // We don't need to worry about uncompressed size since it
185
+       // is checked by the LZMA decoder.
186
+       if (coder->compressed_size != 0)
187
+           return LZMA_DATA_ERROR;
188
+
189
+       coder->sequence = SEQ_CONTROL;
190
+       break;
191
+   }
192
+
193
+   case SEQ_COPY: {
194
+       // Copy from input to the dictionary as is.
195
+       dict_write(dict, in, in_pos, in_size, &coder->compressed_size);
196
+       if (coder->compressed_size != 0)
197
+           return LZMA_OK;
198
+
199
+       coder->sequence = SEQ_CONTROL;
200
+       break;
201
+   }
202
+
203
+   default:
204
+       assert(0);
205
+       return LZMA_PROG_ERROR;
206
+   }
207
+
208
+   return LZMA_OK;
209
+}
210
+
211
+
212
+static void
213
+lzma2_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
214
+{
215
+   assert(coder->lzma.end == NULL);
216
+   lzma_free(coder->lzma.coder, allocator);
217
+
218
+   lzma_free(coder, allocator);
219
+
220
+   return;
221
+}
222
+
223
+
224
+static lzma_ret
225
+lzma2_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
226
+       const void *opt, lzma_lz_options *lz_options)
227
+{
228
+   if (lz->coder == NULL) {
229
+       lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
230
+       if (lz->coder == NULL)
231
+           return LZMA_MEM_ERROR;
232
+
233
+       lz->code = &lzma2_decode;
234
+       lz->end = &lzma2_decoder_end;
235
+
236
+       lz->coder->lzma = LZMA_LZ_DECODER_INIT;
237
+   }
238
+
239
+   const lzma_options_lzma *options = opt;
240
+
241
+   lz->coder->sequence = SEQ_CONTROL;
242
+   lz->coder->need_properties = true;
243
+   lz->coder->need_dictionary_reset = options->preset_dict == NULL
244
+           || options->preset_dict_size == 0;
245
+
246
+   return lzma_lzma_decoder_create(&lz->coder->lzma,
247
+           allocator, options, lz_options);
248
+}
249
+
250
+
251
+extern lzma_ret
252
+lzma_lzma2_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
253
+       const lzma_filter_info *filters)
254
+{
255
+   // LZMA2 can only be the last filter in the chain. This is enforced
256
+   // by the raw_decoder initialization.
257
+   assert(filters[1].init == NULL);
258
+
259
+   return lzma_lz_decoder_init(next, allocator, filters,
260
+           &lzma2_decoder_init);
261
+}
262
+
263
+
264
+extern uint64_t
265
+lzma_lzma2_decoder_memusage(const void *options)
266
+{
267
+   return sizeof(lzma_coder)
268
+           + lzma_lzma_decoder_memusage_nocheck(options);
269
+}
270
+
271
+
272
+extern lzma_ret
273
+lzma_lzma2_props_decode(void **options, lzma_allocator *allocator,
274
+       const uint8_t *props, size_t props_size)
275
+{
276
+   if (props_size != 1)
277
+       return LZMA_OPTIONS_ERROR;
278
+
279
+   // Check that reserved bits are unset.
280
+   if (props[0] & 0xC0)
281
+       return LZMA_OPTIONS_ERROR;
282
+
283
+   // Decode the dictionary size.
284
+   if (props[0] > 40)
285
+       return LZMA_OPTIONS_ERROR;
286
+
287
+   lzma_options_lzma *opt = lzma_alloc(
288
+           sizeof(lzma_options_lzma), allocator);
289
+   if (opt == NULL)
290
+       return LZMA_MEM_ERROR;
291
+
292
+   if (props[0] == 40) {
293
+       opt->dict_size = UINT32_MAX;
294
+   } else {
295
+       opt->dict_size = 2 | (props[0] & 1);
296
+       opt->dict_size <<= props[0] / 2 + 11;
297
+   }
298
+
299
+   opt->preset_dict = NULL;
300
+   opt->preset_dict_size = 0;
301
+
302
+   *options = opt;
303
+
304
+   return LZMA_OK;
305
+}
306
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma2_decoder.h Added
30
 
1
@@ -0,0 +1,28 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma2_decoder.h
5
+/// \brief      LZMA2 decoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZMA2_DECODER_H
16
+#define LZMA_LZMA2_DECODER_H
17
+
18
+#include "common.h"
19
+
20
+extern lzma_ret lzma_lzma2_decoder_init(lzma_next_coder *next,
21
+       lzma_allocator *allocator, const lzma_filter_info *filters);
22
+
23
+extern uint64_t lzma_lzma2_decoder_memusage(const void *options);
24
+
25
+extern lzma_ret lzma_lzma2_props_decode(
26
+       void **options, lzma_allocator *allocator,
27
+       const uint8_t *props, size_t props_size);
28
+
29
+#endif
30
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma2_encoder.c Added
395
 
1
@@ -0,0 +1,393 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma2_encoder.c
5
+/// \brief      LZMA2 encoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "lz_encoder.h"
16
+#include "lzma_encoder.h"
17
+#include "fastpos.h"
18
+#include "lzma2_encoder.h"
19
+
20
+
21
+struct lzma_coder_s {
22
+   enum {
23
+       SEQ_INIT,
24
+       SEQ_LZMA_ENCODE,
25
+       SEQ_LZMA_COPY,
26
+       SEQ_UNCOMPRESSED_HEADER,
27
+       SEQ_UNCOMPRESSED_COPY,
28
+   } sequence;
29
+
30
+   /// LZMA encoder
31
+   lzma_coder *lzma;
32
+
33
+   /// LZMA options currently in use.
34
+   lzma_options_lzma opt_cur;
35
+
36
+   bool need_properties;
37
+   bool need_state_reset;
38
+   bool need_dictionary_reset;
39
+
40
+   /// Uncompressed size of a chunk
41
+   size_t uncompressed_size;
42
+
43
+   /// Compressed size of a chunk (excluding headers); this is also used
44
+   /// to indicate the end of buf[] in SEQ_LZMA_COPY.
45
+   size_t compressed_size;
46
+
47
+   /// Read position in buf[]
48
+   size_t buf_pos;
49
+
50
+   /// Buffer to hold the chunk header and LZMA compressed data
51
+   uint8_t buf[LZMA2_HEADER_MAX + LZMA2_CHUNK_MAX];
52
+};
53
+
54
+
55
+static void
56
+lzma2_header_lzma(lzma_coder *coder)
57
+{
58
+   assert(coder->uncompressed_size > 0);
59
+   assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);
60
+   assert(coder->compressed_size > 0);
61
+   assert(coder->compressed_size <= LZMA2_CHUNK_MAX);
62
+
63
+   size_t pos;
64
+
65
+   if (coder->need_properties) {
66
+       pos = 0;
67
+
68
+       if (coder->need_dictionary_reset)
69
+           coder->buf[pos] = 0x80 + (3 << 5);
70
+       else
71
+           coder->buf[pos] = 0x80 + (2 << 5);
72
+   } else {
73
+       pos = 1;
74
+
75
+       if (coder->need_state_reset)
76
+           coder->buf[pos] = 0x80 + (1 << 5);
77
+       else
78
+           coder->buf[pos] = 0x80;
79
+   }
80
+
81
+   // Set the start position for copying.
82
+   coder->buf_pos = pos;
83
+
84
+   // Uncompressed size
85
+   size_t size = coder->uncompressed_size - 1;
86
+   coder->buf[pos++] += size >> 16;
87
+   coder->buf[pos++] = (size >> 8) & 0xFF;
88
+   coder->buf[pos++] = size & 0xFF;
89
+
90
+   // Compressed size
91
+   size = coder->compressed_size - 1;
92
+   coder->buf[pos++] = size >> 8;
93
+   coder->buf[pos++] = size & 0xFF;
94
+
95
+   // Properties, if needed
96
+   if (coder->need_properties)
97
+       lzma_lzma_lclppb_encode(&coder->opt_cur, coder->buf + pos);
98
+
99
+   coder->need_properties = false;
100
+   coder->need_state_reset = false;
101
+   coder->need_dictionary_reset = false;
102
+
103
+   // The copying code uses coder->compressed_size to indicate the end
104
+   // of coder->buf[], so we need add the maximum size of the header here.
105
+   coder->compressed_size += LZMA2_HEADER_MAX;
106
+
107
+   return;
108
+}
109
+
110
+
111
+static void
112
+lzma2_header_uncompressed(lzma_coder *coder)
113
+{
114
+   assert(coder->uncompressed_size > 0);
115
+   assert(coder->uncompressed_size <= LZMA2_CHUNK_MAX);
116
+
117
+   // If this is the first chunk, we need to include dictionary
118
+   // reset indicator.
119
+   if (coder->need_dictionary_reset)
120
+       coder->buf[0] = 1;
121
+   else
122
+       coder->buf[0] = 2;
123
+
124
+   coder->need_dictionary_reset = false;
125
+
126
+   // "Compressed" size
127
+   coder->buf[1] = (coder->uncompressed_size - 1) >> 8;
128
+   coder->buf[2] = (coder->uncompressed_size - 1) & 0xFF;
129
+
130
+   // Set the start position for copying.
131
+   coder->buf_pos = 0;
132
+   return;
133
+}
134
+
135
+
136
+static lzma_ret
137
+lzma2_encode(lzma_coder *restrict coder, lzma_mf *restrict mf,
138
+       uint8_t *restrict out, size_t *restrict out_pos,
139
+       size_t out_size)
140
+{
141
+   while (*out_pos < out_size)
142
+   switch (coder->sequence) {
143
+   case SEQ_INIT:
144
+       // If there's no input left and we are flushing or finishing,
145
+       // don't start a new chunk.
146
+       if (mf_unencoded(mf) == 0) {
147
+           // Write end of payload marker if finishing.
148
+           if (mf->action == LZMA_FINISH)
149
+               out[(*out_pos)++] = 0;
150
+
151
+           return mf->action == LZMA_RUN
152
+                   ? LZMA_OK : LZMA_STREAM_END;
153
+       }
154
+
155
+       if (coder->need_state_reset)
156
+           return_if_error(lzma_lzma_encoder_reset(
157
+                   coder->lzma, &coder->opt_cur));
158
+
159
+       coder->uncompressed_size = 0;
160
+       coder->compressed_size = 0;
161
+       coder->sequence = SEQ_LZMA_ENCODE;
162
+
163
+   // Fall through
164
+
165
+   case SEQ_LZMA_ENCODE: {
166
+       // Calculate how much more uncompressed data this chunk
167
+       // could accept.
168
+       const uint32_t left = LZMA2_UNCOMPRESSED_MAX
169
+               - coder->uncompressed_size;
170
+       uint32_t limit;
171
+
172
+       if (left < mf->match_len_max) {
173
+           // Must flush immediately since the next LZMA symbol
174
+           // could make the uncompressed size of the chunk too
175
+           // big.
176
+           limit = 0;
177
+       } else {
178
+           // Calculate maximum read_limit that is OK from point
179
+           // of view of LZMA2 chunk size.
180
+           limit = mf->read_pos - mf->read_ahead
181
+                   + left - mf->match_len_max;
182
+       }
183
+
184
+       // Save the start position so that we can update
185
+       // coder->uncompressed_size.
186
+       const uint32_t read_start = mf->read_pos - mf->read_ahead;
187
+
188
+       // Call the LZMA encoder until the chunk is finished.
189
+       const lzma_ret ret = lzma_lzma_encode(coder->lzma, mf,
190
+               coder->buf + LZMA2_HEADER_MAX,
191
+               &coder->compressed_size,
192
+               LZMA2_CHUNK_MAX, limit);
193
+
194
+       coder->uncompressed_size += mf->read_pos - mf->read_ahead
195
+               - read_start;
196
+
197
+       assert(coder->compressed_size <= LZMA2_CHUNK_MAX);
198
+       assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);
199
+
200
+       if (ret != LZMA_STREAM_END)
201
+           return LZMA_OK;
202
+
203
+       // See if the chunk compressed. If it didn't, we encode it
204
+       // as uncompressed chunk. This saves a few bytes of space
205
+       // and makes decoding faster.
206
+       if (coder->compressed_size >= coder->uncompressed_size) {
207
+           coder->uncompressed_size += mf->read_ahead;
208
+           assert(coder->uncompressed_size
209
+                   <= LZMA2_UNCOMPRESSED_MAX);
210
+           mf->read_ahead = 0;
211
+           lzma2_header_uncompressed(coder);
212
+           coder->need_state_reset = true;
213
+           coder->sequence = SEQ_UNCOMPRESSED_HEADER;
214
+           break;
215
+       }
216
+
217
+       // The chunk did compress at least by one byte, so we store
218
+       // the chunk as LZMA.
219
+       lzma2_header_lzma(coder);
220
+
221
+       coder->sequence = SEQ_LZMA_COPY;
222
+   }
223
+
224
+   // Fall through
225
+
226
+   case SEQ_LZMA_COPY:
227
+       // Copy the compressed chunk along its headers to the
228
+       // output buffer.
229
+       lzma_bufcpy(coder->buf, &coder->buf_pos,
230
+               coder->compressed_size,
231
+               out, out_pos, out_size);
232
+       if (coder->buf_pos != coder->compressed_size)
233
+           return LZMA_OK;
234
+
235
+       coder->sequence = SEQ_INIT;
236
+       break;
237
+
238
+   case SEQ_UNCOMPRESSED_HEADER:
239
+       // Copy the three-byte header to indicate uncompressed chunk.
240
+       lzma_bufcpy(coder->buf, &coder->buf_pos,
241
+               LZMA2_HEADER_UNCOMPRESSED,
242
+               out, out_pos, out_size);
243
+       if (coder->buf_pos != LZMA2_HEADER_UNCOMPRESSED)
244
+           return LZMA_OK;
245
+
246
+       coder->sequence = SEQ_UNCOMPRESSED_COPY;
247
+
248
+   // Fall through
249
+
250
+   case SEQ_UNCOMPRESSED_COPY:
251
+       // Copy the uncompressed data as is from the dictionary
252
+       // to the output buffer.
253
+       mf_read(mf, out, out_pos, out_size, &coder->uncompressed_size);
254
+       if (coder->uncompressed_size != 0)
255
+           return LZMA_OK;
256
+
257
+       coder->sequence = SEQ_INIT;
258
+       break;
259
+   }
260
+
261
+   return LZMA_OK;
262
+}
263
+
264
+
265
+static void
266
+lzma2_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
267
+{
268
+   lzma_free(coder->lzma, allocator);
269
+   lzma_free(coder, allocator);
270
+   return;
271
+}
272
+
273
+
274
+static lzma_ret
275
+lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter)
276
+{
277
+   // New options can be set only when there is no incomplete chunk.
278
+   // This is the case at the beginning of the raw stream and right
279
+   // after LZMA_SYNC_FLUSH.
280
+   if (filter->options == NULL || coder->sequence != SEQ_INIT)
281
+       return LZMA_PROG_ERROR;
282
+
283
+   // Look if there are new options. At least for now,
284
+   // only lc/lp/pb can be changed.
285
+   const lzma_options_lzma *opt = filter->options;
286
+   if (coder->opt_cur.lc != opt->lc || coder->opt_cur.lp != opt->lp
287
+           || coder->opt_cur.pb != opt->pb) {
288
+       // Validate the options.
289
+       if (opt->lc > LZMA_LCLP_MAX || opt->lp > LZMA_LCLP_MAX
290
+               || opt->lc + opt->lp > LZMA_LCLP_MAX
291
+               || opt->pb > LZMA_PB_MAX)
292
+           return LZMA_OPTIONS_ERROR;
293
+
294
+       // The new options will be used when the encoder starts
295
+       // a new LZMA2 chunk.
296
+       coder->opt_cur.lc = opt->lc;
297
+       coder->opt_cur.lp = opt->lp;
298
+       coder->opt_cur.pb = opt->pb;
299
+       coder->need_properties = true;
300
+       coder->need_state_reset = true;
301
+   }
302
+
303
+   return LZMA_OK;
304
+}
305
+
306
+
307
+static lzma_ret
308
+lzma2_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
309
+       const void *options, lzma_lz_options *lz_options)
310
+{
311
+   if (options == NULL)
312
+       return LZMA_PROG_ERROR;
313
+
314
+   if (lz->coder == NULL) {
315
+       lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
316
+       if (lz->coder == NULL)
317
+           return LZMA_MEM_ERROR;
318
+
319
+       lz->code = &lzma2_encode;
320
+       lz->end = &lzma2_encoder_end;
321
+       lz->options_update = &lzma2_encoder_options_update;
322
+
323
+       lz->coder->lzma = NULL;
324
+   }
325
+
326
+   lz->coder->opt_cur = *(const lzma_options_lzma *)(options);
327
+
328
+   lz->coder->sequence = SEQ_INIT;
329
+   lz->coder->need_properties = true;
330
+   lz->coder->need_state_reset = false;
331
+   lz->coder->need_dictionary_reset
332
+           = lz->coder->opt_cur.preset_dict == NULL
333
+           || lz->coder->opt_cur.preset_dict_size == 0;
334
+
335
+   // Initialize LZMA encoder
336
+   return_if_error(lzma_lzma_encoder_create(&lz->coder->lzma, allocator,
337
+           &lz->coder->opt_cur, lz_options));
338
+
339
+   // Make sure that we will always have enough history available in
340
+   // case we need to use uncompressed chunks. They are used when the
341
+   // compressed size of a chunk is not smaller than the uncompressed
342
+   // size, so we need to have at least LZMA2_COMPRESSED_MAX bytes
343
+   // history available.
344
+   if (lz_options->before_size + lz_options->dict_size < LZMA2_CHUNK_MAX)
345
+       lz_options->before_size
346
+               = LZMA2_CHUNK_MAX - lz_options->dict_size;
347
+
348
+   return LZMA_OK;
349
+}
350
+
351
+
352
+extern lzma_ret
353
+lzma_lzma2_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
354
+       const lzma_filter_info *filters)
355
+{
356
+   return lzma_lz_encoder_init(
357
+           next, allocator, filters, &lzma2_encoder_init);
358
+}
359
+
360
+
361
+extern uint64_t
362
+lzma_lzma2_encoder_memusage(const void *options)
363
+{
364
+   const uint64_t lzma_mem = lzma_lzma_encoder_memusage(options);
365
+   if (lzma_mem == UINT64_MAX)
366
+       return UINT64_MAX;
367
+
368
+   return sizeof(lzma_coder) + lzma_mem;
369
+}
370
+
371
+
372
+extern lzma_ret
373
+lzma_lzma2_props_encode(const void *options, uint8_t *out)
374
+{
375
+   const lzma_options_lzma *const opt = options;
376
+   uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);
377
+
378
+   // Round up to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending
379
+   // on which one is the next:
380
+   --d;
381
+   d |= d >> 2;
382
+   d |= d >> 3;
383
+   d |= d >> 4;
384
+   d |= d >> 8;
385
+   d |= d >> 16;
386
+
387
+   // Get the highest two bits using the proper encoding:
388
+   if (d == UINT32_MAX)
389
+       out[0] = 40;
390
+   else
391
+       out[0] = get_pos_slot(d + 1) - 24;
392
+
393
+   return LZMA_OK;
394
+}
395
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma2_encoder.h Added
43
 
1
@@ -0,0 +1,41 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma2_encoder.h
5
+/// \brief      LZMA2 encoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZMA2_ENCODER_H
16
+#define LZMA_LZMA2_ENCODER_H
17
+
18
+#include "common.h"
19
+
20
+
21
+/// Maximum number of bytes of actual data per chunk (no headers)
22
+#define LZMA2_CHUNK_MAX (UINT32_C(1) << 16)
23
+
24
+/// Maximum uncompressed size of LZMA chunk (no headers)
25
+#define LZMA2_UNCOMPRESSED_MAX (UINT32_C(1) << 21)
26
+
27
+/// Maximum size of LZMA2 headers
28
+#define LZMA2_HEADER_MAX 6
29
+
30
+/// Size of a header for uncompressed chunk
31
+#define LZMA2_HEADER_UNCOMPRESSED 3
32
+
33
+
34
+extern lzma_ret lzma_lzma2_encoder_init(
35
+       lzma_next_coder *next, lzma_allocator *allocator,
36
+       const lzma_filter_info *filters);
37
+
38
+extern uint64_t lzma_lzma2_encoder_memusage(const void *options);
39
+
40
+extern lzma_ret lzma_lzma2_props_encode(const void *options, uint8_t *out);
41
+
42
+#endif
43
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_common.h Added
225
 
1
@@ -0,0 +1,223 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_common.h
5
+/// \brief      Private definitions common to LZMA encoder and decoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZMA_COMMON_H
16
+#define LZMA_LZMA_COMMON_H
17
+
18
+#include "common.h"
19
+#include "range_common.h"
20
+
21
+
22
+///////////////////
23
+// Miscellaneous //
24
+///////////////////
25
+
26
+/// Maximum number of position states. A position state is the lowest pos bits
27
+/// number of bits of the current uncompressed offset. In some places there
28
+/// are different sets of probabilities for different pos states.
29
+#define POS_STATES_MAX (1 << LZMA_PB_MAX)
30
+
31
+
32
+/// Validates lc, lp, and pb.
33
+static inline bool
34
+is_lclppb_valid(const lzma_options_lzma *options)
35
+{
36
+   return options->lc <= LZMA_LCLP_MAX && options->lp <= LZMA_LCLP_MAX
37
+           && options->lc + options->lp <= LZMA_LCLP_MAX
38
+           && options->pb <= LZMA_PB_MAX;
39
+}
40
+
41
+
42
+///////////
43
+// State //
44
+///////////
45
+
46
+/// This enum is used to track which events have occurred most recently and
47
+/// in which order. This information is used to predict the next event.
48
+///
49
+/// Events:
50
+///  - Literal: One 8-bit byte
51
+///  - Match: Repeat a chunk of data at some distance
52
+///  - Long repeat: Multi-byte match at a recently seen distance
53
+///  - Short repeat: One-byte repeat at a recently seen distance
54
+///
55
+/// The event names are in from STATE_oldest_older_previous. REP means
56
+/// either short or long repeated match, and NONLIT means any non-literal.
57
+typedef enum {
58
+   STATE_LIT_LIT,
59
+   STATE_MATCH_LIT_LIT,
60
+   STATE_REP_LIT_LIT,
61
+   STATE_SHORTREP_LIT_LIT,
62
+   STATE_MATCH_LIT,
63
+   STATE_REP_LIT,
64
+   STATE_SHORTREP_LIT,
65
+   STATE_LIT_MATCH,
66
+   STATE_LIT_LONGREP,
67
+   STATE_LIT_SHORTREP,
68
+   STATE_NONLIT_MATCH,
69
+   STATE_NONLIT_REP,
70
+} lzma_lzma_state;
71
+
72
+
73
+/// Total number of states
74
+#define STATES 12
75
+
76
+/// The lowest 7 states indicate that the previous state was a literal.
77
+#define LIT_STATES 7
78
+
79
+
80
+/// Indicate that the latest state was a literal.
81
+#define update_literal(state) \
82
+   state = ((state) <= STATE_SHORTREP_LIT_LIT \
83
+           ? STATE_LIT_LIT \
84
+           : ((state) <= STATE_LIT_SHORTREP \
85
+               ? (state) - 3 \
86
+               : (state) - 6))
87
+
88
+/// Indicate that the latest state was a match.
89
+#define update_match(state) \
90
+   state = ((state) < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH)
91
+
92
+/// Indicate that the latest state was a long repeated match.
93
+#define update_long_rep(state) \
94
+   state = ((state) < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP)
95
+
96
+/// Indicate that the latest state was a short match.
97
+#define update_short_rep(state) \
98
+   state = ((state) < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP)
99
+
100
+/// Test if the previous state was a literal.
101
+#define is_literal_state(state) \
102
+   ((state) < LIT_STATES)
103
+
104
+
105
+/////////////
106
+// Literal //
107
+/////////////
108
+
109
+/// Each literal coder is divided in three sections:
110
+///   - 0x001-0x0FF: Without match byte
111
+///   - 0x101-0x1FF: With match byte; match bit is 0
112
+///   - 0x201-0x2FF: With match byte; match bit is 1
113
+///
114
+/// Match byte is used when the previous LZMA symbol was something else than
115
+/// a literal (that is, it was some kind of match).
116
+#define LITERAL_CODER_SIZE 0x300
117
+
118
+/// Maximum number of literal coders
119
+#define LITERAL_CODERS_MAX (1 << LZMA_LCLP_MAX)
120
+
121
+/// Locate the literal coder for the next literal byte. The choice depends on
122
+///   - the lowest literal_pos_bits bits of the position of the current
123
+///     byte; and
124
+///   - the highest literal_context_bits bits of the previous byte.
125
+#define literal_subcoder(probs, lc, lp_mask, pos, prev_byte) \
126
+   ((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))])
127
+
128
+
129
+static inline void
130
+literal_init(probability (*probs)[LITERAL_CODER_SIZE],
131
+       uint32_t lc, uint32_t lp)
132
+{
133
+   assert(lc + lp <= LZMA_LCLP_MAX);
134
+
135
+   const uint32_t coders = 1U << (lc + lp);
136
+
137
+   for (uint32_t i = 0; i < coders; ++i)
138
+       for (uint32_t j = 0; j < LITERAL_CODER_SIZE; ++j)
139
+           bit_reset(probs[i][j]);
140
+
141
+   return;
142
+}
143
+
144
+
145
+//////////////////
146
+// Match length //
147
+//////////////////
148
+
149
+// Minimum length of a match is two bytes.
150
+#define MATCH_LEN_MIN 2
151
+
152
+// Match length is encoded with 4, 5, or 10 bits.
153
+//
154
+// Length   Bits
155
+//  2-9      4 = Choice=0 + 3 bits
156
+// 10-17     5 = Choice=1 + Choice2=0 + 3 bits
157
+// 18-273   10 = Choice=1 + Choice2=1 + 8 bits
158
+#define LEN_LOW_BITS 3
159
+#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS)
160
+#define LEN_MID_BITS 3
161
+#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS)
162
+#define LEN_HIGH_BITS 8
163
+#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS)
164
+#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)
165
+
166
+// Maximum length of a match is 273 which is a result of the encoding
167
+// described above.
168
+#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1)
169
+
170
+
171
+////////////////////
172
+// Match distance //
173
+////////////////////
174
+
175
+// Different set of probabilities is used for match distances that have very
176
+// short match length: Lengths of 2, 3, and 4 bytes have a separate set of
177
+// probabilities for each length. The matches with longer length use a shared
178
+// set of probabilities.
179
+#define LEN_TO_POS_STATES 4
180
+
181
+// Macro to get the index of the appropriate probability array.
182
+#define get_len_to_pos_state(len) \
183
+   ((len) < LEN_TO_POS_STATES + MATCH_LEN_MIN \
184
+       ? (len) - MATCH_LEN_MIN \
185
+       : LEN_TO_POS_STATES - 1)
186
+
187
+// The highest two bits of a match distance (pos slot) are encoded using six
188
+// bits. See fastpos.h for more explanation.
189
+#define POS_SLOT_BITS 6
190
+#define POS_SLOTS (1 << POS_SLOT_BITS)
191
+
192
+// Match distances up to 127 are fully encoded using probabilities. Since
193
+// the highest two bits (pos slot) are always encoded using six bits, the
194
+// distances 0-3 don't need any additional bits to encode, since the pos
195
+// slot itself is the same as the actual distance. START_POS_MODEL_INDEX
196
+// indicates the first pos slot where at least one additional bit is needed.
197
+#define START_POS_MODEL_INDEX 4
198
+
199
+// Match distances greater than 127 are encoded in three pieces:
200
+//   - pos slot: the highest two bits
201
+//   - direct bits: 2-26 bits below the highest two bits
202
+//   - alignment bits: four lowest bits
203
+//
204
+// Direct bits don't use any probabilities.
205
+//
206
+// The pos slot value of 14 is for distances 128-191 (see the table in
207
+// fastpos.h to understand why).
208
+#define END_POS_MODEL_INDEX 14
209
+
210
+// Pos slots that indicate a distance <= 127.
211
+#define FULL_DISTANCES_BITS (END_POS_MODEL_INDEX / 2)
212
+#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)
213
+
214
+// For match distances greater than 127, only the highest two bits and the
215
+// lowest four bits (alignment) is encoded using probabilities.
216
+#define ALIGN_BITS 4
217
+#define ALIGN_TABLE_SIZE (1 << ALIGN_BITS)
218
+#define ALIGN_MASK (ALIGN_TABLE_SIZE - 1)
219
+
220
+// LZMA remembers the four most recent match distances. Reusing these distances
221
+// tends to take less space than re-encoding the actual distance value.
222
+#define REP_DISTANCES 4
223
+
224
+#endif
225
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_decoder.c Added
1059
 
1
@@ -0,0 +1,1057 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_decoder.c
5
+/// \brief      LZMA decoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "lz_decoder.h"
16
+#include "lzma_common.h"
17
+#include "lzma_decoder.h"
18
+#include "range_decoder.h"
19
+
20
+
21
+#ifdef HAVE_SMALL
22
+
23
+// Macros for (somewhat) size-optimized code.
24
+#define seq_4(seq) seq
25
+
26
+#define seq_6(seq) seq
27
+
28
+#define seq_8(seq) seq
29
+
30
+#define seq_len(seq) \
31
+   seq ## _CHOICE, \
32
+   seq ## _CHOICE2, \
33
+   seq ## _BITTREE
34
+
35
+#define len_decode(target, ld, pos_state, seq) \
36
+do { \
37
+case seq ## _CHOICE: \
38
+   rc_if_0(ld.choice, seq ## _CHOICE) { \
39
+       rc_update_0(ld.choice); \
40
+       probs = ld.low[pos_state];\
41
+       limit = LEN_LOW_SYMBOLS; \
42
+       target = MATCH_LEN_MIN; \
43
+   } else { \
44
+       rc_update_1(ld.choice); \
45
+case seq ## _CHOICE2: \
46
+       rc_if_0(ld.choice2, seq ## _CHOICE2) { \
47
+           rc_update_0(ld.choice2); \
48
+           probs = ld.mid[pos_state]; \
49
+           limit = LEN_MID_SYMBOLS; \
50
+           target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \
51
+       } else { \
52
+           rc_update_1(ld.choice2); \
53
+           probs = ld.high; \
54
+           limit = LEN_HIGH_SYMBOLS; \
55
+           target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS \
56
+                   + LEN_MID_SYMBOLS; \
57
+       } \
58
+   } \
59
+   symbol = 1; \
60
+case seq ## _BITTREE: \
61
+   do { \
62
+       rc_bit(probs[symbol], , , seq ## _BITTREE); \
63
+   } while (symbol < limit); \
64
+   target += symbol - limit; \
65
+} while (0)
66
+
67
+#else // HAVE_SMALL
68
+
69
+// Unrolled versions
70
+#define seq_4(seq) \
71
+   seq ## 0, \
72
+   seq ## 1, \
73
+   seq ## 2, \
74
+   seq ## 3
75
+
76
+#define seq_6(seq) \
77
+   seq ## 0, \
78
+   seq ## 1, \
79
+   seq ## 2, \
80
+   seq ## 3, \
81
+   seq ## 4, \
82
+   seq ## 5
83
+
84
+#define seq_8(seq) \
85
+   seq ## 0, \
86
+   seq ## 1, \
87
+   seq ## 2, \
88
+   seq ## 3, \
89
+   seq ## 4, \
90
+   seq ## 5, \
91
+   seq ## 6, \
92
+   seq ## 7
93
+
94
+#define seq_len(seq) \
95
+   seq ## _CHOICE, \
96
+   seq ## _LOW0, \
97
+   seq ## _LOW1, \
98
+   seq ## _LOW2, \
99
+   seq ## _CHOICE2, \
100
+   seq ## _MID0, \
101
+   seq ## _MID1, \
102
+   seq ## _MID2, \
103
+   seq ## _HIGH0, \
104
+   seq ## _HIGH1, \
105
+   seq ## _HIGH2, \
106
+   seq ## _HIGH3, \
107
+   seq ## _HIGH4, \
108
+   seq ## _HIGH5, \
109
+   seq ## _HIGH6, \
110
+   seq ## _HIGH7
111
+
112
+#define len_decode(target, ld, pos_state, seq) \
113
+do { \
114
+   symbol = 1; \
115
+case seq ## _CHOICE: \
116
+   rc_if_0(ld.choice, seq ## _CHOICE) { \
117
+       rc_update_0(ld.choice); \
118
+       rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW0); \
119
+       rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW1); \
120
+       rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW2); \
121
+       target = symbol - LEN_LOW_SYMBOLS + MATCH_LEN_MIN; \
122
+   } else { \
123
+       rc_update_1(ld.choice); \
124
+case seq ## _CHOICE2: \
125
+       rc_if_0(ld.choice2, seq ## _CHOICE2) { \
126
+           rc_update_0(ld.choice2); \
127
+           rc_bit_case(ld.mid[pos_state][symbol], , , \
128
+                   seq ## _MID0); \
129
+           rc_bit_case(ld.mid[pos_state][symbol], , , \
130
+                   seq ## _MID1); \
131
+           rc_bit_case(ld.mid[pos_state][symbol], , , \
132
+                   seq ## _MID2); \
133
+           target = symbol - LEN_MID_SYMBOLS \
134
+                   + MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \
135
+       } else { \
136
+           rc_update_1(ld.choice2); \
137
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH0); \
138
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH1); \
139
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH2); \
140
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH3); \
141
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH4); \
142
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH5); \
143
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH6); \
144
+           rc_bit_case(ld.high[symbol], , , seq ## _HIGH7); \
145
+           target = symbol - LEN_HIGH_SYMBOLS \
146
+                   + MATCH_LEN_MIN \
147
+                   + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; \
148
+       } \
149
+   } \
150
+} while (0)
151
+
152
+#endif // HAVE_SMALL
153
+
154
+
155
+/// Length decoder probabilities; see comments in lzma_common.h.
156
+typedef struct {
157
+   probability choice;
158
+   probability choice2;
159
+   probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS];
160
+   probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS];
161
+   probability high[LEN_HIGH_SYMBOLS];
162
+} lzma_length_decoder;
163
+
164
+
165
+struct lzma_coder_s {
166
+   ///////////////////
167
+   // Probabilities //
168
+   ///////////////////
169
+
170
+   /// Literals; see comments in lzma_common.h.
171
+   probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
172
+
173
+   /// If 1, it's a match. Otherwise it's a single 8-bit literal.
174
+   probability is_match[STATES][POS_STATES_MAX];
175
+
176
+   /// If 1, it's a repeated match. The distance is one of rep0 .. rep3.
177
+   probability is_rep[STATES];
178
+
179
+   /// If 0, distance of a repeated match is rep0.
180
+   /// Otherwise check is_rep1.
181
+   probability is_rep0[STATES];
182
+
183
+   /// If 0, distance of a repeated match is rep1.
184
+   /// Otherwise check is_rep2.
185
+   probability is_rep1[STATES];
186
+
187
+   /// If 0, distance of a repeated match is rep2. Otherwise it is rep3.
188
+   probability is_rep2[STATES];
189
+
190
+   /// If 1, the repeated match has length of one byte. Otherwise
191
+   /// the length is decoded from rep_len_decoder.
192
+   probability is_rep0_long[STATES][POS_STATES_MAX];
193
+
194
+   /// Probability tree for the highest two bits of the match distance.
195
+   /// There is a separate probability tree for match lengths of
196
+   /// 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273].
197
+   probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS];
198
+
199
+   /// Probability trees for additional bits for match distance when the
200
+   /// distance is in the range [4, 127].
201
+   probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX];
202
+
203
+   /// Probability tree for the lowest four bits of a match distance
204
+   /// that is equal to or greater than 128.
205
+   probability pos_align[ALIGN_TABLE_SIZE];
206
+
207
+   /// Length of a normal match
208
+   lzma_length_decoder match_len_decoder;
209
+
210
+   /// Length of a repeated match
211
+   lzma_length_decoder rep_len_decoder;
212
+
213
+   ///////////////////
214
+   // Decoder state //
215
+   ///////////////////
216
+
217
+   // Range coder
218
+   lzma_range_decoder rc;
219
+
220
+   // Types of the most recently seen LZMA symbols
221
+   lzma_lzma_state state;
222
+
223
+   uint32_t rep0;      ///< Distance of the latest match
224
+   uint32_t rep1;      ///< Distance of second latest match
225
+   uint32_t rep2;      ///< Distance of third latest match
226
+   uint32_t rep3;      ///< Distance of fourth latest match
227
+
228
+   uint32_t pos_mask; // (1U << pb) - 1
229
+   uint32_t literal_context_bits;
230
+   uint32_t literal_pos_mask;
231
+
232
+   /// Uncompressed size as bytes, or LZMA_VLI_UNKNOWN if end of
233
+   /// payload marker is expected.
234
+   lzma_vli uncompressed_size;
235
+
236
+   ////////////////////////////////
237
+   // State of incomplete symbol //
238
+   ////////////////////////////////
239
+
240
+   /// Position where to continue the decoder loop
241
+   enum {
242
+       SEQ_NORMALIZE,
243
+       SEQ_IS_MATCH,
244
+       seq_8(SEQ_LITERAL),
245
+       seq_8(SEQ_LITERAL_MATCHED),
246
+       SEQ_LITERAL_WRITE,
247
+       SEQ_IS_REP,
248
+       seq_len(SEQ_MATCH_LEN),
249
+       seq_6(SEQ_POS_SLOT),
250
+       SEQ_POS_MODEL,
251
+       SEQ_DIRECT,
252
+       seq_4(SEQ_ALIGN),
253
+       SEQ_EOPM,
254
+       SEQ_IS_REP0,
255
+       SEQ_SHORTREP,
256
+       SEQ_IS_REP0_LONG,
257
+       SEQ_IS_REP1,
258
+       SEQ_IS_REP2,
259
+       seq_len(SEQ_REP_LEN),
260
+       SEQ_COPY,
261
+   } sequence;
262
+
263
+   /// Base of the current probability tree
264
+   probability *probs;
265
+
266
+   /// Symbol being decoded. This is also used as an index variable in
267
+   /// bittree decoders: probs[symbol]
268
+   uint32_t symbol;
269
+
270
+   /// Used as a loop termination condition on bittree decoders and
271
+   /// direct bits decoder.
272
+   uint32_t limit;
273
+
274
+   /// Matched literal decoder: 0x100 or 0 to help avoiding branches.
275
+   /// Bittree reverse decoders: Offset of the next bit: 1 << offset
276
+   uint32_t offset;
277
+
278
+   /// If decoding a literal: match byte.
279
+   /// If decoding a match: length of the match.
280
+   uint32_t len;
281
+};
282
+
283
+
284
+static lzma_ret
285
+lzma_decode(lzma_coder *restrict coder, lzma_dict *restrict dictptr,
286
+       const uint8_t *restrict in,
287
+       size_t *restrict in_pos, size_t in_size)
288
+{
289
+   ////////////////////
290
+   // Initialization //
291
+   ////////////////////
292
+
293
+   if (!rc_read_init(&coder->rc, in, in_pos, in_size))
294
+       return LZMA_OK;
295
+
296
+   ///////////////
297
+   // Variables //
298
+   ///////////////
299
+
300
+   // Making local copies of often-used variables improves both
301
+   // speed and readability.
302
+
303
+   lzma_dict dict = *dictptr;
304
+
305
+   const size_t dict_start = dict.pos;
306
+
307
+   // Range decoder
308
+   rc_to_local(coder->rc, *in_pos);
309
+
310
+   // State
311
+   uint32_t state = coder->state;
312
+   uint32_t rep0 = coder->rep0;
313
+   uint32_t rep1 = coder->rep1;
314
+   uint32_t rep2 = coder->rep2;
315
+   uint32_t rep3 = coder->rep3;
316
+
317
+   const uint32_t pos_mask = coder->pos_mask;
318
+
319
+   // These variables are actually needed only if we last time ran
320
+   // out of input in the middle of the decoder loop.
321
+   probability *probs = coder->probs;
322
+   uint32_t symbol = coder->symbol;
323
+   uint32_t limit = coder->limit;
324
+   uint32_t offset = coder->offset;
325
+   uint32_t len = coder->len;
326
+
327
+   const uint32_t literal_pos_mask = coder->literal_pos_mask;
328
+   const uint32_t literal_context_bits = coder->literal_context_bits;
329
+
330
+   // Temporary variables
331
+   uint32_t pos_state = dict.pos & pos_mask;
332
+
333
+   lzma_ret ret = LZMA_OK;
334
+
335
+   // If uncompressed size is known, there must be no end of payload
336
+   // marker.
337
+   const bool no_eopm = coder->uncompressed_size
338
+           != LZMA_VLI_UNKNOWN;
339
+   if (no_eopm && coder->uncompressed_size < dict.limit - dict.pos)
340
+       dict.limit = dict.pos + (size_t)(coder->uncompressed_size);
341
+
342
+   // The main decoder loop. The "switch" is used to restart the decoder at
343
+   // correct location. Once restarted, the "switch" is no longer used.
344
+   switch (coder->sequence)
345
+   while (true) {
346
+       // Calculate new pos_state. This is skipped on the first loop
347
+       // since we already calculated it when setting up the local
348
+       // variables.
349
+       pos_state = dict.pos & pos_mask;
350
+
351
+   case SEQ_NORMALIZE:
352
+   case SEQ_IS_MATCH:
353
+       if (unlikely(no_eopm && dict.pos == dict.limit))
354
+           break;
355
+
356
+       rc_if_0(coder->is_match[state][pos_state], SEQ_IS_MATCH) {
357
+           rc_update_0(coder->is_match[state][pos_state]);
358
+
359
+           // It's a literal i.e. a single 8-bit byte.
360
+
361
+           probs = literal_subcoder(coder->literal,
362
+                   literal_context_bits, literal_pos_mask,
363
+                   dict.pos, dict_get(&dict, 0));
364
+           symbol = 1;
365
+
366
+           if (is_literal_state(state)) {
367
+               // Decode literal without match byte.
368
+#ifdef HAVE_SMALL
369
+   case SEQ_LITERAL:
370
+               do {
371
+                   rc_bit(probs[symbol], , , SEQ_LITERAL);
372
+               } while (symbol < (1 << 8));
373
+#else
374
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL0);
375
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL1);
376
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL2);
377
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL3);
378
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL4);
379
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL5);
380
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL6);
381
+               rc_bit_case(probs[symbol], , , SEQ_LITERAL7);
382
+#endif
383
+           } else {
384
+               // Decode literal with match byte.
385
+               //
386
+               // We store the byte we compare against
387
+               // ("match byte") to "len" to minimize the
388
+               // number of variables we need to store
389
+               // between decoder calls.
390
+               len = dict_get(&dict, rep0) << 1;
391
+
392
+               // The usage of "offset" allows omitting some
393
+               // branches, which should give tiny speed
394
+               // improvement on some CPUs. "offset" gets
395
+               // set to zero if match_bit didn't match.
396
+               offset = 0x100;
397
+
398
+#ifdef HAVE_SMALL
399
+   case SEQ_LITERAL_MATCHED:
400
+               do {
401
+                   const uint32_t match_bit
402
+                           = len & offset;
403
+                   const uint32_t subcoder_index
404
+                           = offset + match_bit
405
+                           + symbol;
406
+
407
+                   rc_bit(probs[subcoder_index],
408
+                           offset &= ~match_bit,
409
+                           offset &= match_bit,
410
+                           SEQ_LITERAL_MATCHED);
411
+
412
+                   // It seems to be faster to do this
413
+                   // here instead of putting it to the
414
+                   // beginning of the loop and then
415
+                   // putting the "case" in the middle
416
+                   // of the loop.
417
+                   len <<= 1;
418
+
419
+               } while (symbol < (1 << 8));
420
+#else
421
+               // Unroll the loop.
422
+               uint32_t match_bit;
423
+               uint32_t subcoder_index;
424
+
425
+#  define d(seq) \
426
+       case seq: \
427
+           match_bit = len & offset; \
428
+           subcoder_index = offset + match_bit + symbol; \
429
+           rc_bit(probs[subcoder_index], \
430
+                   offset &= ~match_bit, \
431
+                   offset &= match_bit, \
432
+                   seq)
433
+
434
+               d(SEQ_LITERAL_MATCHED0);
435
+               len <<= 1;
436
+               d(SEQ_LITERAL_MATCHED1);
437
+               len <<= 1;
438
+               d(SEQ_LITERAL_MATCHED2);
439
+               len <<= 1;
440
+               d(SEQ_LITERAL_MATCHED3);
441
+               len <<= 1;
442
+               d(SEQ_LITERAL_MATCHED4);
443
+               len <<= 1;
444
+               d(SEQ_LITERAL_MATCHED5);
445
+               len <<= 1;
446
+               d(SEQ_LITERAL_MATCHED6);
447
+               len <<= 1;
448
+               d(SEQ_LITERAL_MATCHED7);
449
+#  undef d
450
+#endif
451
+           }
452
+
453
+           //update_literal(state);
454
+           // Use a lookup table to update to literal state,
455
+           // since compared to other state updates, this would
456
+           // need two branches.
457
+           static const lzma_lzma_state next_state[] = {
458
+               STATE_LIT_LIT,
459
+               STATE_LIT_LIT,
460
+               STATE_LIT_LIT,
461
+               STATE_LIT_LIT,
462
+               STATE_MATCH_LIT_LIT,
463
+               STATE_REP_LIT_LIT,
464
+               STATE_SHORTREP_LIT_LIT,
465
+               STATE_MATCH_LIT,
466
+               STATE_REP_LIT,
467
+               STATE_SHORTREP_LIT,
468
+               STATE_MATCH_LIT,
469
+               STATE_REP_LIT
470
+           };
471
+           state = next_state[state];
472
+
473
+   case SEQ_LITERAL_WRITE:
474
+           if (unlikely(dict_put(&dict, symbol))) {
475
+               coder->sequence = SEQ_LITERAL_WRITE;
476
+               goto out;
477
+           }
478
+
479
+           continue;
480
+       }
481
+
482
+       // Instead of a new byte we are going to get a byte range
483
+       // (distance and length) which will be repeated from our
484
+       // output history.
485
+
486
+       rc_update_1(coder->is_match[state][pos_state]);
487
+
488
+   case SEQ_IS_REP:
489
+       rc_if_0(coder->is_rep[state], SEQ_IS_REP) {
490
+           // Not a repeated match
491
+           rc_update_0(coder->is_rep[state]);
492
+           update_match(state);
493
+
494
+           // The latest three match distances are kept in
495
+           // memory in case there are repeated matches.
496
+           rep3 = rep2;
497
+           rep2 = rep1;
498
+           rep1 = rep0;
499
+
500
+           // Decode the length of the match.
501
+           len_decode(len, coder->match_len_decoder,
502
+                   pos_state, SEQ_MATCH_LEN);
503
+
504
+           // Prepare to decode the highest two bits of the
505
+           // match distance.
506
+           probs = coder->pos_slot[get_len_to_pos_state(len)];
507
+           symbol = 1;
508
+
509
+#ifdef HAVE_SMALL
510
+   case SEQ_POS_SLOT:
511
+           do {
512
+               rc_bit(probs[symbol], , , SEQ_POS_SLOT);
513
+           } while (symbol < POS_SLOTS);
514
+#else
515
+           rc_bit_case(probs[symbol], , , SEQ_POS_SLOT0);
516
+           rc_bit_case(probs[symbol], , , SEQ_POS_SLOT1);
517
+           rc_bit_case(probs[symbol], , , SEQ_POS_SLOT2);
518
+           rc_bit_case(probs[symbol], , , SEQ_POS_SLOT3);
519
+           rc_bit_case(probs[symbol], , , SEQ_POS_SLOT4);
520
+           rc_bit_case(probs[symbol], , , SEQ_POS_SLOT5);
521
+#endif
522
+           // Get rid of the highest bit that was needed for
523
+           // indexing of the probability array.
524
+           symbol -= POS_SLOTS;
525
+           assert(symbol <= 63);
526
+
527
+           if (symbol < START_POS_MODEL_INDEX) {
528
+               // Match distances [0, 3] have only two bits.
529
+               rep0 = symbol;
530
+           } else {
531
+               // Decode the lowest [1, 29] bits of
532
+               // the match distance.
533
+               limit = (symbol >> 1) - 1;
534
+               assert(limit >= 1 && limit <= 30);
535
+               rep0 = 2 + (symbol & 1);
536
+
537
+               if (symbol < END_POS_MODEL_INDEX) {
538
+                   // Prepare to decode the low bits for
539
+                   // a distance of [4, 127].
540
+                   assert(limit <= 5);
541
+                   rep0 <<= limit;
542
+                   assert(rep0 <= 96);
543
+                   // -1 is fine, because we start
544
+                   // decoding at probs[1], not probs[0].
545
+                   // NOTE: This violates the C standard,
546
+                   // since we are doing pointer
547
+                   // arithmetic past the beginning of
548
+                   // the array.
549
+                   assert((int32_t)(rep0 - symbol - 1)
550
+                           >= -1);
551
+                   assert((int32_t)(rep0 - symbol - 1)
552
+                           <= 82);
553
+                   probs = coder->pos_special + rep0
554
+                           - symbol - 1;
555
+                   symbol = 1;
556
+                   offset = 0;
557
+   case SEQ_POS_MODEL:
558
+#ifdef HAVE_SMALL
559
+                   do {
560
+                       rc_bit(probs[symbol], ,
561
+                           rep0 += 1 << offset,
562
+                           SEQ_POS_MODEL);
563
+                   } while (++offset < limit);
564
+#else
565
+                   switch (limit) {
566
+                   case 5:
567
+                       assert(offset == 0);
568
+                       rc_bit(probs[symbol], ,
569
+                           rep0 += 1,
570
+                           SEQ_POS_MODEL);
571
+                       ++offset;
572
+                       --limit;
573
+                   case 4:
574
+                       rc_bit(probs[symbol], ,
575
+                           rep0 += 1 << offset,
576
+                           SEQ_POS_MODEL);
577
+                       ++offset;
578
+                       --limit;
579
+                   case 3:
580
+                       rc_bit(probs[symbol], ,
581
+                           rep0 += 1 << offset,
582
+                           SEQ_POS_MODEL);
583
+                       ++offset;
584
+                       --limit;
585
+                   case 2:
586
+                       rc_bit(probs[symbol], ,
587
+                           rep0 += 1 << offset,
588
+                           SEQ_POS_MODEL);
589
+                       ++offset;
590
+                       --limit;
591
+                   case 1:
592
+                       // We need "symbol" only for
593
+                       // indexing the probability
594
+                       // array, thus we can use
595
+                       // rc_bit_last() here to omit
596
+                       // the unneeded updating of
597
+                       // "symbol".
598
+                       rc_bit_last(probs[symbol], ,
599
+                           rep0 += 1 << offset,
600
+                           SEQ_POS_MODEL);
601
+                   }
602
+#endif
603
+               } else {
604
+                   // The distance is >= 128. Decode the
605
+                   // lower bits without probabilities
606
+                   // except the lowest four bits.
607
+                   assert(symbol >= 14);
608
+                   assert(limit >= 6);
609
+                   limit -= ALIGN_BITS;
610
+                   assert(limit >= 2);
611
+   case SEQ_DIRECT:
612
+                   // Not worth manual unrolling
613
+                   do {
614
+                       rc_direct(rep0, SEQ_DIRECT);
615
+                   } while (--limit > 0);
616
+
617
+                   // Decode the lowest four bits using
618
+                   // probabilities.
619
+                   rep0 <<= ALIGN_BITS;
620
+                   symbol = 1;
621
+#ifdef HAVE_SMALL
622
+                   offset = 0;
623
+   case SEQ_ALIGN:
624
+                   do {
625
+                       rc_bit(coder->pos_align[
626
+                               symbol], ,
627
+                           rep0 += 1 << offset,
628
+                           SEQ_ALIGN);
629
+                   } while (++offset < ALIGN_BITS);
630
+#else
631
+   case SEQ_ALIGN0:
632
+                   rc_bit(coder->pos_align[symbol], ,
633
+                           rep0 += 1, SEQ_ALIGN0);
634
+   case SEQ_ALIGN1:
635
+                   rc_bit(coder->pos_align[symbol], ,
636
+                           rep0 += 2, SEQ_ALIGN1);
637
+   case SEQ_ALIGN2:
638
+                   rc_bit(coder->pos_align[symbol], ,
639
+                           rep0 += 4, SEQ_ALIGN2);
640
+   case SEQ_ALIGN3:
641
+                   // Like in SEQ_POS_MODEL, we don't
642
+                   // need "symbol" for anything else
643
+                   // than indexing the probability array.
644
+                   rc_bit_last(coder->pos_align[symbol], ,
645
+                           rep0 += 8, SEQ_ALIGN3);
646
+#endif
647
+
648
+                   if (rep0 == UINT32_MAX) {
649
+                       // End of payload marker was
650
+                       // found. It must not be
651
+                       // present if uncompressed
652
+                       // size is known.
653
+                       if (coder->uncompressed_size
654
+                       != LZMA_VLI_UNKNOWN) {
655
+                           ret = LZMA_DATA_ERROR;
656
+                           goto out;
657
+                       }
658
+
659
+   case SEQ_EOPM:
660
+                       // LZMA1 stream with
661
+                       // end-of-payload marker.
662
+                       rc_normalize(SEQ_EOPM);
663
+                       ret = LZMA_STREAM_END;
664
+                       goto out;
665
+                   }
666
+               }
667
+           }
668
+
669
+           // Validate the distance we just decoded.
670
+           if (unlikely(!dict_is_distance_valid(&dict, rep0))) {
671
+               ret = LZMA_DATA_ERROR;
672
+               goto out;
673
+           }
674
+
675
+       } else {
676
+           rc_update_1(coder->is_rep[state]);
677
+
678
+           // Repeated match
679
+           //
680
+           // The match distance is a value that we have had
681
+           // earlier. The latest four match distances are
682
+           // available as rep0, rep1, rep2 and rep3. We will
683
+           // now decode which of them is the new distance.
684
+           //
685
+           // There cannot be a match if we haven't produced
686
+           // any output, so check that first.
687
+           if (unlikely(!dict_is_distance_valid(&dict, 0))) {
688
+               ret = LZMA_DATA_ERROR;
689
+               goto out;
690
+           }
691
+
692
+   case SEQ_IS_REP0:
693
+           rc_if_0(coder->is_rep0[state], SEQ_IS_REP0) {
694
+               rc_update_0(coder->is_rep0[state]);
695
+               // The distance is rep0.
696
+
697
+   case SEQ_IS_REP0_LONG:
698
+               rc_if_0(coder->is_rep0_long[state][pos_state],
699
+                       SEQ_IS_REP0_LONG) {
700
+                   rc_update_0(coder->is_rep0_long[
701
+                           state][pos_state]);
702
+
703
+                   update_short_rep(state);
704
+
705
+   case SEQ_SHORTREP:
706
+                   if (unlikely(dict_put(&dict, dict_get(
707
+                           &dict, rep0)))) {
708
+                       coder->sequence = SEQ_SHORTREP;
709
+                       goto out;
710
+                   }
711
+
712
+                   continue;
713
+               }
714
+
715
+               // Repeating more than one byte at
716
+               // distance of rep0.
717
+               rc_update_1(coder->is_rep0_long[
718
+                       state][pos_state]);
719
+
720
+           } else {
721
+               rc_update_1(coder->is_rep0[state]);
722
+
723
+   case SEQ_IS_REP1:
724
+               // The distance is rep1, rep2 or rep3. Once
725
+               // we find out which one of these three, it
726
+               // is stored to rep0 and rep1, rep2 and rep3
727
+               // are updated accordingly.
728
+               rc_if_0(coder->is_rep1[state], SEQ_IS_REP1) {
729
+                   rc_update_0(coder->is_rep1[state]);
730
+
731
+                   const uint32_t distance = rep1;
732
+                   rep1 = rep0;
733
+                   rep0 = distance;
734
+
735
+               } else {
736
+                   rc_update_1(coder->is_rep1[state]);
737
+   case SEQ_IS_REP2:
738
+                   rc_if_0(coder->is_rep2[state],
739
+                           SEQ_IS_REP2) {
740
+                       rc_update_0(coder->is_rep2[
741
+                               state]);
742
+
743
+                       const uint32_t distance = rep2;
744
+                       rep2 = rep1;
745
+                       rep1 = rep0;
746
+                       rep0 = distance;
747
+
748
+                   } else {
749
+                       rc_update_1(coder->is_rep2[
750
+                               state]);
751
+
752
+                       const uint32_t distance = rep3;
753
+                       rep3 = rep2;
754
+                       rep2 = rep1;
755
+                       rep1 = rep0;
756
+                       rep0 = distance;
757
+                   }
758
+               }
759
+           }
760
+
761
+           update_long_rep(state);
762
+
763
+           // Decode the length of the repeated match.
764
+           len_decode(len, coder->rep_len_decoder,
765
+                   pos_state, SEQ_REP_LEN);
766
+       }
767
+
768
+       /////////////////////////////////
769
+       // Repeat from history buffer. //
770
+       /////////////////////////////////
771
+
772
+       // The length is always between these limits. There is no way
773
+       // to trigger the algorithm to set len outside this range.
774
+       assert(len >= MATCH_LEN_MIN);
775
+       assert(len <= MATCH_LEN_MAX);
776
+
777
+   case SEQ_COPY:
778
+       // Repeat len bytes from distance of rep0.
779
+       if (unlikely(dict_repeat(&dict, rep0, &len))) {
780
+           coder->sequence = SEQ_COPY;
781
+           goto out;
782
+       }
783
+   }
784
+
785
+   rc_normalize(SEQ_NORMALIZE);
786
+   coder->sequence = SEQ_IS_MATCH;
787
+
788
+out:
789
+   // Save state
790
+
791
+   // NOTE: Must not copy dict.limit.
792
+   dictptr->pos = dict.pos;
793
+   dictptr->full = dict.full;
794
+
795
+   rc_from_local(coder->rc, *in_pos);
796
+
797
+   coder->state = state;
798
+   coder->rep0 = rep0;
799
+   coder->rep1 = rep1;
800
+   coder->rep2 = rep2;
801
+   coder->rep3 = rep3;
802
+
803
+   coder->probs = probs;
804
+   coder->symbol = symbol;
805
+   coder->limit = limit;
806
+   coder->offset = offset;
807
+   coder->len = len;
808
+
809
+   // Update the remaining amount of uncompressed data if uncompressed
810
+   // size was known.
811
+   if (coder->uncompressed_size != LZMA_VLI_UNKNOWN) {
812
+       coder->uncompressed_size -= dict.pos - dict_start;
813
+
814
+       // Since there cannot be end of payload marker if the
815
+       // uncompressed size was known, we check here if we
816
+       // finished decoding.
817
+       if (coder->uncompressed_size == 0 && ret == LZMA_OK
818
+               && coder->sequence != SEQ_NORMALIZE)
819
+           ret = coder->sequence == SEQ_IS_MATCH
820
+                   ? LZMA_STREAM_END : LZMA_DATA_ERROR;
821
+   }
822
+
823
+   // We can do an additional check in the range decoder to catch some
824
+   // corrupted files.
825
+   if (ret == LZMA_STREAM_END) {
826
+       if (!rc_is_finished(coder->rc))
827
+           ret = LZMA_DATA_ERROR;
828
+
829
+       // Reset the range decoder so that it is ready to reinitialize
830
+       // for a new LZMA2 chunk.
831
+       rc_reset(coder->rc);
832
+   }
833
+
834
+   return ret;
835
+}
836
+
837
+
838
+
839
+static void
840
+lzma_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size)
841
+{
842
+   coder->uncompressed_size = uncompressed_size;
843
+}
844
+
845
+/*
846
+extern void
847
+lzma_lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size)
848
+{
849
+   // This is hack.
850
+   (*(lzma_coder **)(coder))->uncompressed_size = uncompressed_size;
851
+}
852
+*/
853
+
854
+static void
855
+lzma_decoder_reset(lzma_coder *coder, const void *opt)
856
+{
857
+   const lzma_options_lzma *options = opt;
858
+
859
+   // NOTE: We assume that lc/lp/pb are valid since they were
860
+   // successfully decoded with lzma_lzma_decode_properties().
861
+
862
+   // Calculate pos_mask. We don't need pos_bits as is for anything.
863
+   coder->pos_mask = (1U << options->pb) - 1;
864
+
865
+   // Initialize the literal decoder.
866
+   literal_init(coder->literal, options->lc, options->lp);
867
+
868
+   coder->literal_context_bits = options->lc;
869
+   coder->literal_pos_mask = (1U << options->lp) - 1;
870
+
871
+   // State
872
+   coder->state = STATE_LIT_LIT;
873
+   coder->rep0 = 0;
874
+   coder->rep1 = 0;
875
+   coder->rep2 = 0;
876
+   coder->rep3 = 0;
877
+   coder->pos_mask = (1U << options->pb) - 1;
878
+
879
+   // Range decoder
880
+   rc_reset(coder->rc);
881
+
882
+   // Bit and bittree decoders
883
+   for (uint32_t i = 0; i < STATES; ++i) {
884
+       for (uint32_t j = 0; j <= coder->pos_mask; ++j) {
885
+           bit_reset(coder->is_match[i][j]);
886
+           bit_reset(coder->is_rep0_long[i][j]);
887
+       }
888
+
889
+       bit_reset(coder->is_rep[i]);
890
+       bit_reset(coder->is_rep0[i]);
891
+       bit_reset(coder->is_rep1[i]);
892
+       bit_reset(coder->is_rep2[i]);
893
+   }
894
+
895
+   for (uint32_t i = 0; i < LEN_TO_POS_STATES; ++i)
896
+       bittree_reset(coder->pos_slot[i], POS_SLOT_BITS);
897
+
898
+   for (uint32_t i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i)
899
+       bit_reset(coder->pos_special[i]);
900
+
901
+   bittree_reset(coder->pos_align, ALIGN_BITS);
902
+
903
+   // Len decoders (also bit/bittree)
904
+   const uint32_t num_pos_states = 1U << options->pb;
905
+   bit_reset(coder->match_len_decoder.choice);
906
+   bit_reset(coder->match_len_decoder.choice2);
907
+   bit_reset(coder->rep_len_decoder.choice);
908
+   bit_reset(coder->rep_len_decoder.choice2);
909
+
910
+   for (uint32_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
911
+       bittree_reset(coder->match_len_decoder.low[pos_state],
912
+               LEN_LOW_BITS);
913
+       bittree_reset(coder->match_len_decoder.mid[pos_state],
914
+               LEN_MID_BITS);
915
+
916
+       bittree_reset(coder->rep_len_decoder.low[pos_state],
917
+               LEN_LOW_BITS);
918
+       bittree_reset(coder->rep_len_decoder.mid[pos_state],
919
+               LEN_MID_BITS);
920
+   }
921
+
922
+   bittree_reset(coder->match_len_decoder.high, LEN_HIGH_BITS);
923
+   bittree_reset(coder->rep_len_decoder.high, LEN_HIGH_BITS);
924
+
925
+   coder->sequence = SEQ_IS_MATCH;
926
+   coder->probs = NULL;
927
+   coder->symbol = 0;
928
+   coder->limit = 0;
929
+   coder->offset = 0;
930
+   coder->len = 0;
931
+
932
+   return;
933
+}
934
+
935
+
936
+extern lzma_ret
937
+lzma_lzma_decoder_create(lzma_lz_decoder *lz, lzma_allocator *allocator,
938
+       const void *opt, lzma_lz_options *lz_options)
939
+{
940
+   if (lz->coder == NULL) {
941
+       lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
942
+       if (lz->coder == NULL)
943
+           return LZMA_MEM_ERROR;
944
+
945
+       lz->code = &lzma_decode;
946
+       lz->reset = &lzma_decoder_reset;
947
+       lz->set_uncompressed = &lzma_decoder_uncompressed;
948
+   }
949
+
950
+   // All dictionary sizes are OK here. LZ decoder will take care of
951
+   // the special cases.
952
+   const lzma_options_lzma *options = opt;
953
+   lz_options->dict_size = options->dict_size;
954
+   lz_options->preset_dict = options->preset_dict;
955
+   lz_options->preset_dict_size = options->preset_dict_size;
956
+
957
+   return LZMA_OK;
958
+}
959
+
960
+
961
+/// Allocate and initialize LZMA decoder. This is used only via LZ
962
+/// initialization (lzma_lzma_decoder_init() passes function pointer to
963
+/// the LZ initialization).
964
+static lzma_ret
965
+lzma_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
966
+       const void *options, lzma_lz_options *lz_options)
967
+{
968
+   if (!is_lclppb_valid(options))
969
+       return LZMA_PROG_ERROR;
970
+
971
+   return_if_error(lzma_lzma_decoder_create(
972
+           lz, allocator, options, lz_options));
973
+
974
+   lzma_decoder_reset(lz->coder, options);
975
+   lzma_decoder_uncompressed(lz->coder, LZMA_VLI_UNKNOWN);
976
+
977
+   return LZMA_OK;
978
+}
979
+
980
+
981
+extern lzma_ret
982
+lzma_lzma_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
983
+       const lzma_filter_info *filters)
984
+{
985
+   // LZMA can only be the last filter in the chain. This is enforced
986
+   // by the raw_decoder initialization.
987
+   assert(filters[1].init == NULL);
988
+
989
+   return lzma_lz_decoder_init(next, allocator, filters,
990
+           &lzma_decoder_init);
991
+}
992
+
993
+
994
+extern bool
995
+lzma_lzma_lclppb_decode(lzma_options_lzma *options, uint8_t byte)
996
+{
997
+   if (byte > (4 * 5 + 4) * 9 + 8)
998
+       return true;
999
+
1000
+   // See the file format specification to understand this.
1001
+   options->pb = byte / (9 * 5);
1002
+   byte -= options->pb * 9 * 5;
1003
+   options->lp = byte / 9;
1004
+   options->lc = byte - options->lp * 9;
1005
+
1006
+   return options->lc + options->lp > LZMA_LCLP_MAX;
1007
+}
1008
+
1009
+
1010
+extern uint64_t
1011
+lzma_lzma_decoder_memusage_nocheck(const void *options)
1012
+{
1013
+   const lzma_options_lzma *const opt = options;
1014
+   return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size);
1015
+}
1016
+
1017
+
1018
+extern uint64_t
1019
+lzma_lzma_decoder_memusage(const void *options)
1020
+{
1021
+   if (!is_lclppb_valid(options))
1022
+       return UINT64_MAX;
1023
+
1024
+   return lzma_lzma_decoder_memusage_nocheck(options);
1025
+}
1026
+
1027
+
1028
+extern lzma_ret
1029
+lzma_lzma_props_decode(void **options, lzma_allocator *allocator,
1030
+       const uint8_t *props, size_t props_size)
1031
+{
1032
+   if (props_size != 5)
1033
+       return LZMA_OPTIONS_ERROR;
1034
+
1035
+   lzma_options_lzma *opt
1036
+           = lzma_alloc(sizeof(lzma_options_lzma), allocator);
1037
+   if (opt == NULL)
1038
+       return LZMA_MEM_ERROR;
1039
+
1040
+   if (lzma_lzma_lclppb_decode(opt, props[0]))
1041
+       goto error;
1042
+
1043
+   // All dictionary sizes are accepted, including zero. LZ decoder
1044
+   // will automatically use a dictionary at least a few KiB even if
1045
+   // a smaller dictionary is requested.
1046
+   opt->dict_size = unaligned_read32le(props + 1);
1047
+
1048
+   opt->preset_dict = NULL;
1049
+   opt->preset_dict_size = 0;
1050
+
1051
+   *options = opt;
1052
+
1053
+   return LZMA_OK;
1054
+
1055
+error:
1056
+   lzma_free(opt, allocator);
1057
+   return LZMA_OPTIONS_ERROR;
1058
+}
1059
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_decoder.h Added
54
 
1
@@ -0,0 +1,52 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_decoder.h
5
+/// \brief      LZMA decoder API
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZMA_DECODER_H
16
+#define LZMA_LZMA_DECODER_H
17
+
18
+#include "common.h"
19
+
20
+
21
+/// Allocates and initializes LZMA decoder
22
+extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next,
23
+       lzma_allocator *allocator, const lzma_filter_info *filters);
24
+
25
+extern uint64_t lzma_lzma_decoder_memusage(const void *options);
26
+
27
+extern lzma_ret lzma_lzma_props_decode(
28
+       void **options, lzma_allocator *allocator,
29
+       const uint8_t *props, size_t props_size);
30
+
31
+
32
+/// \brief      Decodes the LZMA Properties byte (lc/lp/pb)
33
+///
34
+/// \return     true if error occurred, false on success
35
+///
36
+extern bool lzma_lzma_lclppb_decode(
37
+       lzma_options_lzma *options, uint8_t byte);
38
+
39
+
40
+#ifdef LZMA_LZ_DECODER_H
41
+/// Allocate and setup function pointers only. This is used by LZMA1 and
42
+/// LZMA2 decoders.
43
+extern lzma_ret lzma_lzma_decoder_create(
44
+       lzma_lz_decoder *lz, lzma_allocator *allocator,
45
+       const void *opt, lzma_lz_options *lz_options);
46
+
47
+/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2
48
+/// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb.
49
+extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options);
50
+
51
+#endif
52
+
53
+#endif
54
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_encoder.c Added
677
 
1
@@ -0,0 +1,675 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_encoder.c
5
+/// \brief      LZMA encoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "lzma2_encoder.h"
16
+#include "lzma_encoder_private.h"
17
+#include "fastpos.h"
18
+
19
+
20
+/////////////
21
+// Literal //
22
+/////////////
23
+
24
+static inline void
25
+literal_matched(lzma_range_encoder *rc, probability *subcoder,
26
+       uint32_t match_byte, uint32_t symbol)
27
+{
28
+   uint32_t offset = 0x100;
29
+   symbol += UINT32_C(1) << 8;
30
+
31
+   do {
32
+       match_byte <<= 1;
33
+       const uint32_t match_bit = match_byte & offset;
34
+       const uint32_t subcoder_index
35
+               = offset + match_bit + (symbol >> 8);
36
+       const uint32_t bit = (symbol >> 7) & 1;
37
+       rc_bit(rc, &subcoder[subcoder_index], bit);
38
+
39
+       symbol <<= 1;
40
+       offset &= ~(match_byte ^ symbol);
41
+
42
+   } while (symbol < (UINT32_C(1) << 16));
43
+}
44
+
45
+
46
+static inline void
47
+literal(lzma_coder *coder, lzma_mf *mf, uint32_t position)
48
+{
49
+   // Locate the literal byte to be encoded and the subcoder.
50
+   const uint8_t cur_byte = mf->buffer[
51
+           mf->read_pos - mf->read_ahead];
52
+   probability *subcoder = literal_subcoder(coder->literal,
53
+           coder->literal_context_bits, coder->literal_pos_mask,
54
+           position, mf->buffer[mf->read_pos - mf->read_ahead - 1]);
55
+
56
+   if (is_literal_state(coder->state)) {
57
+       // Previous LZMA-symbol was a literal. Encode a normal
58
+       // literal without a match byte.
59
+       rc_bittree(&coder->rc, subcoder, 8, cur_byte);
60
+   } else {
61
+       // Previous LZMA-symbol was a match. Use the last byte of
62
+       // the match as a "match byte". That is, compare the bits
63
+       // of the current literal and the match byte.
64
+       const uint8_t match_byte = mf->buffer[
65
+               mf->read_pos - coder->reps[0] - 1
66
+               - mf->read_ahead];
67
+       literal_matched(&coder->rc, subcoder, match_byte, cur_byte);
68
+   }
69
+
70
+   update_literal(coder->state);
71
+}
72
+
73
+
74
+//////////////////
75
+// Match length //
76
+//////////////////
77
+
78
+static void
79
+length_update_prices(lzma_length_encoder *lc, const uint32_t pos_state)
80
+{
81
+   const uint32_t table_size = lc->table_size;
82
+   lc->counters[pos_state] = table_size;
83
+
84
+   const uint32_t a0 = rc_bit_0_price(lc->choice);
85
+   const uint32_t a1 = rc_bit_1_price(lc->choice);
86
+   const uint32_t b0 = a1 + rc_bit_0_price(lc->choice2);
87
+   const uint32_t b1 = a1 + rc_bit_1_price(lc->choice2);
88
+   uint32_t *const prices = lc->prices[pos_state];
89
+
90
+   uint32_t i;
91
+   for (i = 0; i < table_size && i < LEN_LOW_SYMBOLS; ++i)
92
+       prices[i] = a0 + rc_bittree_price(lc->low[pos_state],
93
+               LEN_LOW_BITS, i);
94
+
95
+   for (; i < table_size && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; ++i)
96
+       prices[i] = b0 + rc_bittree_price(lc->mid[pos_state],
97
+               LEN_MID_BITS, i - LEN_LOW_SYMBOLS);
98
+
99
+   for (; i < table_size; ++i)
100
+       prices[i] = b1 + rc_bittree_price(lc->high, LEN_HIGH_BITS,
101
+               i - LEN_LOW_SYMBOLS - LEN_MID_SYMBOLS);
102
+
103
+   return;
104
+}
105
+
106
+
107
+static inline void
108
+length(lzma_range_encoder *rc, lzma_length_encoder *lc,
109
+       const uint32_t pos_state, uint32_t len, const bool fast_mode)
110
+{
111
+   assert(len <= MATCH_LEN_MAX);
112
+   len -= MATCH_LEN_MIN;
113
+
114
+   if (len < LEN_LOW_SYMBOLS) {
115
+       rc_bit(rc, &lc->choice, 0);
116
+       rc_bittree(rc, lc->low[pos_state], LEN_LOW_BITS, len);
117
+   } else {
118
+       rc_bit(rc, &lc->choice, 1);
119
+       len -= LEN_LOW_SYMBOLS;
120
+
121
+       if (len < LEN_MID_SYMBOLS) {
122
+           rc_bit(rc, &lc->choice2, 0);
123
+           rc_bittree(rc, lc->mid[pos_state], LEN_MID_BITS, len);
124
+       } else {
125
+           rc_bit(rc, &lc->choice2, 1);
126
+           len -= LEN_MID_SYMBOLS;
127
+           rc_bittree(rc, lc->high, LEN_HIGH_BITS, len);
128
+       }
129
+   }
130
+
131
+   // Only getoptimum uses the prices so don't update the table when
132
+   // in fast mode.
133
+   if (!fast_mode)
134
+       if (--lc->counters[pos_state] == 0)
135
+           length_update_prices(lc, pos_state);
136
+}
137
+
138
+
139
+///////////
140
+// Match //
141
+///////////
142
+
143
+static inline void
144
+match(lzma_coder *coder, const uint32_t pos_state,
145
+       const uint32_t distance, const uint32_t len)
146
+{
147
+   update_match(coder->state);
148
+
149
+   length(&coder->rc, &coder->match_len_encoder, pos_state, len,
150
+           coder->fast_mode);
151
+
152
+   const uint32_t pos_slot = get_pos_slot(distance);
153
+   const uint32_t len_to_pos_state = get_len_to_pos_state(len);
154
+   rc_bittree(&coder->rc, coder->pos_slot[len_to_pos_state],
155
+           POS_SLOT_BITS, pos_slot);
156
+
157
+   if (pos_slot >= START_POS_MODEL_INDEX) {
158
+       const uint32_t footer_bits = (pos_slot >> 1) - 1;
159
+       const uint32_t base = (2 | (pos_slot & 1)) << footer_bits;
160
+       const uint32_t pos_reduced = distance - base;
161
+
162
+       if (pos_slot < END_POS_MODEL_INDEX) {
163
+           // Careful here: base - pos_slot - 1 can be -1, but
164
+           // rc_bittree_reverse starts at probs[1], not probs[0].
165
+           rc_bittree_reverse(&coder->rc,
166
+               coder->pos_special + base - pos_slot - 1,
167
+               footer_bits, pos_reduced);
168
+       } else {
169
+           rc_direct(&coder->rc, pos_reduced >> ALIGN_BITS,
170
+                   footer_bits - ALIGN_BITS);
171
+           rc_bittree_reverse(
172
+                   &coder->rc, coder->pos_align,
173
+                   ALIGN_BITS, pos_reduced & ALIGN_MASK);
174
+           ++coder->align_price_count;
175
+       }
176
+   }
177
+
178
+   coder->reps[3] = coder->reps[2];
179
+   coder->reps[2] = coder->reps[1];
180
+   coder->reps[1] = coder->reps[0];
181
+   coder->reps[0] = distance;
182
+   ++coder->match_price_count;
183
+}
184
+
185
+
186
+////////////////////
187
+// Repeated match //
188
+////////////////////
189
+
190
+static inline void
191
+rep_match(lzma_coder *coder, const uint32_t pos_state,
192
+       const uint32_t rep, const uint32_t len)
193
+{
194
+   if (rep == 0) {
195
+       rc_bit(&coder->rc, &coder->is_rep0[coder->state], 0);
196
+       rc_bit(&coder->rc,
197
+               &coder->is_rep0_long[coder->state][pos_state],
198
+               len != 1);
199
+   } else {
200
+       const uint32_t distance = coder->reps[rep];
201
+       rc_bit(&coder->rc, &coder->is_rep0[coder->state], 1);
202
+
203
+       if (rep == 1) {
204
+           rc_bit(&coder->rc, &coder->is_rep1[coder->state], 0);
205
+       } else {
206
+           rc_bit(&coder->rc, &coder->is_rep1[coder->state], 1);
207
+           rc_bit(&coder->rc, &coder->is_rep2[coder->state],
208
+                   rep - 2);
209
+
210
+           if (rep == 3)
211
+               coder->reps[3] = coder->reps[2];
212
+
213
+           coder->reps[2] = coder->reps[1];
214
+       }
215
+
216
+       coder->reps[1] = coder->reps[0];
217
+       coder->reps[0] = distance;
218
+   }
219
+
220
+   if (len == 1) {
221
+       update_short_rep(coder->state);
222
+   } else {
223
+       length(&coder->rc, &coder->rep_len_encoder, pos_state, len,
224
+               coder->fast_mode);
225
+       update_long_rep(coder->state);
226
+   }
227
+}
228
+
229
+
230
+//////////
231
+// Main //
232
+//////////
233
+
234
+static void
235
+encode_symbol(lzma_coder *coder, lzma_mf *mf,
236
+       uint32_t back, uint32_t len, uint32_t position)
237
+{
238
+   const uint32_t pos_state = position & coder->pos_mask;
239
+
240
+   if (back == UINT32_MAX) {
241
+       // Literal i.e. eight-bit byte
242
+       assert(len == 1);
243
+       rc_bit(&coder->rc,
244
+               &coder->is_match[coder->state][pos_state], 0);
245
+       literal(coder, mf, position);
246
+   } else {
247
+       // Some type of match
248
+       rc_bit(&coder->rc,
249
+           &coder->is_match[coder->state][pos_state], 1);
250
+
251
+       if (back < REP_DISTANCES) {
252
+           // It's a repeated match i.e. the same distance
253
+           // has been used earlier.
254
+           rc_bit(&coder->rc, &coder->is_rep[coder->state], 1);
255
+           rep_match(coder, pos_state, back, len);
256
+       } else {
257
+           // Normal match
258
+           rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);
259
+           match(coder, pos_state, back - REP_DISTANCES, len);
260
+       }
261
+   }
262
+
263
+   assert(mf->read_ahead >= len);
264
+   mf->read_ahead -= len;
265
+}
266
+
267
+
268
+static bool
269
+encode_init(lzma_coder *coder, lzma_mf *mf)
270
+{
271
+   assert(mf_position(mf) == 0);
272
+
273
+   if (mf->read_pos == mf->read_limit) {
274
+       if (mf->action == LZMA_RUN)
275
+           return false; // We cannot do anything.
276
+
277
+       // We are finishing (we cannot get here when flushing).
278
+       assert(mf->write_pos == mf->read_pos);
279
+       assert(mf->action == LZMA_FINISH);
280
+   } else {
281
+       // Do the actual initialization. The first LZMA symbol must
282
+       // always be a literal.
283
+       mf_skip(mf, 1);
284
+       mf->read_ahead = 0;
285
+       rc_bit(&coder->rc, &coder->is_match[0][0], 0);
286
+       rc_bittree(&coder->rc, coder->literal[0], 8, mf->buffer[0]);
287
+   }
288
+
289
+   // Initialization is done (except if empty file).
290
+   coder->is_initialized = true;
291
+
292
+   return true;
293
+}
294
+
295
+
296
+static void
297
+encode_eopm(lzma_coder *coder, uint32_t position)
298
+{
299
+   const uint32_t pos_state = position & coder->pos_mask;
300
+   rc_bit(&coder->rc, &coder->is_match[coder->state][pos_state], 1);
301
+   rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);
302
+   match(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN);
303
+}
304
+
305
+
306
+/// Number of bytes that a single encoding loop in lzma_lzma_encode() can
307
+/// consume from the dictionary. This limit comes from lzma_lzma_optimum()
308
+/// and may need to be updated if that function is significantly modified.
309
+#define LOOP_INPUT_MAX (OPTS + 1)
310
+
311
+
312
+extern lzma_ret
313
+lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf,
314
+       uint8_t *restrict out, size_t *restrict out_pos,
315
+       size_t out_size, uint32_t limit)
316
+{
317
+   // Initialize the stream if no data has been encoded yet.
318
+   if (!coder->is_initialized && !encode_init(coder, mf))
319
+       return LZMA_OK;
320
+
321
+   // Get the lowest bits of the uncompressed offset from the LZ layer.
322
+   uint32_t position = mf_position(mf);
323
+
324
+   while (true) {
325
+       // Encode pending bits, if any. Calling this before encoding
326
+       // the next symbol is needed only with plain LZMA, since
327
+       // LZMA2 always provides big enough buffer to flush
328
+       // everything out from the range encoder. For the same reason,
329
+       // rc_encode() never returns true when this function is used
330
+       // as part of LZMA2 encoder.
331
+       if (rc_encode(&coder->rc, out, out_pos, out_size)) {
332
+           assert(limit == UINT32_MAX);
333
+           return LZMA_OK;
334
+       }
335
+
336
+       // With LZMA2 we need to take care that compressed size of
337
+       // a chunk doesn't get too big.
338
+       // FIXME? Check if this could be improved.
339
+       if (limit != UINT32_MAX
340
+               && (mf->read_pos - mf->read_ahead >= limit
341
+                   || *out_pos + rc_pending(&coder->rc)
342
+                       >= LZMA2_CHUNK_MAX
343
+                           - LOOP_INPUT_MAX))
344
+           break;
345
+
346
+       // Check that there is some input to process.
347
+       if (mf->read_pos >= mf->read_limit) {
348
+           if (mf->action == LZMA_RUN)
349
+               return LZMA_OK;
350
+
351
+           if (mf->read_ahead == 0)
352
+               break;
353
+       }
354
+
355
+       // Get optimal match (repeat position and length).
356
+       // Value ranges for pos:
357
+       //   - [0, REP_DISTANCES): repeated match
358
+       //   - [REP_DISTANCES, UINT32_MAX):
359
+       //     match at (pos - REP_DISTANCES)
360
+       //   - UINT32_MAX: not a match but a literal
361
+       // Value ranges for len:
362
+       //   - [MATCH_LEN_MIN, MATCH_LEN_MAX]
363
+       uint32_t len;
364
+       uint32_t back;
365
+
366
+       if (coder->fast_mode)
367
+           lzma_lzma_optimum_fast(coder, mf, &back, &len);
368
+       else
369
+           lzma_lzma_optimum_normal(
370
+                   coder, mf, &back, &len, position);
371
+
372
+       encode_symbol(coder, mf, back, len, position);
373
+
374
+       position += len;
375
+   }
376
+
377
+   if (!coder->is_flushed) {
378
+       coder->is_flushed = true;
379
+
380
+       // We don't support encoding plain LZMA streams without EOPM,
381
+       // and LZMA2 doesn't use EOPM at LZMA level.
382
+       if (limit == UINT32_MAX)
383
+           encode_eopm(coder, position);
384
+
385
+       // Flush the remaining bytes from the range encoder.
386
+       rc_flush(&coder->rc);
387
+
388
+       // Copy the remaining bytes to the output buffer. If there
389
+       // isn't enough output space, we will copy out the remaining
390
+       // bytes on the next call to this function by using
391
+       // the rc_encode() call in the encoding loop above.
392
+       if (rc_encode(&coder->rc, out, out_pos, out_size)) {
393
+           assert(limit == UINT32_MAX);
394
+           return LZMA_OK;
395
+       }
396
+   }
397
+
398
+   // Make it ready for the next LZMA2 chunk.
399
+   coder->is_flushed = false;
400
+
401
+   return LZMA_STREAM_END;
402
+}
403
+
404
+
405
+static lzma_ret
406
+lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf,
407
+       uint8_t *restrict out, size_t *restrict out_pos,
408
+       size_t out_size)
409
+{
410
+   // Plain LZMA has no support for sync-flushing.
411
+   if (unlikely(mf->action == LZMA_SYNC_FLUSH))
412
+       return LZMA_OPTIONS_ERROR;
413
+
414
+   return lzma_lzma_encode(coder, mf, out, out_pos, out_size, UINT32_MAX);
415
+}
416
+
417
+
418
+////////////////////
419
+// Initialization //
420
+////////////////////
421
+
422
+static bool
423
+is_options_valid(const lzma_options_lzma *options)
424
+{
425
+   // Validate some of the options. LZ encoder validates nice_len too
426
+   // but we need a valid value here earlier.
427
+   return is_lclppb_valid(options)
428
+           && options->nice_len >= MATCH_LEN_MIN
429
+           && options->nice_len <= MATCH_LEN_MAX
430
+           && (options->mode == LZMA_MODE_FAST
431
+               || options->mode == LZMA_MODE_NORMAL);
432
+}
433
+
434
+
435
+static void
436
+set_lz_options(lzma_lz_options *lz_options, const lzma_options_lzma *options)
437
+{
438
+   // LZ encoder initialization does the validation for these so we
439
+   // don't need to validate here.
440
+   lz_options->before_size = OPTS;
441
+   lz_options->dict_size = options->dict_size;
442
+   lz_options->after_size = LOOP_INPUT_MAX;
443
+   lz_options->match_len_max = MATCH_LEN_MAX;
444
+   lz_options->nice_len = options->nice_len;
445
+   lz_options->match_finder = options->mf;
446
+   lz_options->depth = options->depth;
447
+   lz_options->preset_dict = options->preset_dict;
448
+   lz_options->preset_dict_size = options->preset_dict_size;
449
+   return;
450
+}
451
+
452
+
453
+static void
454
+length_encoder_reset(lzma_length_encoder *lencoder,
455
+       const uint32_t num_pos_states, const bool fast_mode)
456
+{
457
+   bit_reset(lencoder->choice);
458
+   bit_reset(lencoder->choice2);
459
+
460
+   for (size_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
461
+       bittree_reset(lencoder->low[pos_state], LEN_LOW_BITS);
462
+       bittree_reset(lencoder->mid[pos_state], LEN_MID_BITS);
463
+   }
464
+
465
+   bittree_reset(lencoder->high, LEN_HIGH_BITS);
466
+
467
+   if (!fast_mode)
468
+       for (size_t pos_state = 0; pos_state < num_pos_states;
469
+               ++pos_state)
470
+           length_update_prices(lencoder, pos_state);
471
+
472
+   return;
473
+}
474
+
475
+
476
+extern lzma_ret
477
+lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
478
+{
479
+   if (!is_options_valid(options))
480
+       return LZMA_OPTIONS_ERROR;
481
+
482
+   coder->pos_mask = (1U << options->pb) - 1;
483
+   coder->literal_context_bits = options->lc;
484
+   coder->literal_pos_mask = (1U << options->lp) - 1;
485
+
486
+   // Range coder
487
+   rc_reset(&coder->rc);
488
+
489
+   // State
490
+   coder->state = STATE_LIT_LIT;
491
+   for (size_t i = 0; i < REP_DISTANCES; ++i)
492
+       coder->reps[i] = 0;
493
+
494
+   literal_init(coder->literal, options->lc, options->lp);
495
+
496
+   // Bit encoders
497
+   for (size_t i = 0; i < STATES; ++i) {
498
+       for (size_t j = 0; j <= coder->pos_mask; ++j) {
499
+           bit_reset(coder->is_match[i][j]);
500
+           bit_reset(coder->is_rep0_long[i][j]);
501
+       }
502
+
503
+       bit_reset(coder->is_rep[i]);
504
+       bit_reset(coder->is_rep0[i]);
505
+       bit_reset(coder->is_rep1[i]);
506
+       bit_reset(coder->is_rep2[i]);
507
+   }
508
+
509
+   for (size_t i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i)
510
+       bit_reset(coder->pos_special[i]);
511
+
512
+   // Bit tree encoders
513
+   for (size_t i = 0; i < LEN_TO_POS_STATES; ++i)
514
+       bittree_reset(coder->pos_slot[i], POS_SLOT_BITS);
515
+
516
+   bittree_reset(coder->pos_align, ALIGN_BITS);
517
+
518
+   // Length encoders
519
+   length_encoder_reset(&coder->match_len_encoder,
520
+           1U << options->pb, coder->fast_mode);
521
+
522
+   length_encoder_reset(&coder->rep_len_encoder,
523
+           1U << options->pb, coder->fast_mode);
524
+
525
+   // Price counts are incremented every time appropriate probabilities
526
+   // are changed. price counts are set to zero when the price tables
527
+   // are updated, which is done when the appropriate price counts have
528
+   // big enough value, and lzma_mf.read_ahead == 0 which happens at
529
+   // least every OPTS (a few thousand) possible price count increments.
530
+   //
531
+   // By resetting price counts to UINT32_MAX / 2, we make sure that the
532
+   // price tables will be initialized before they will be used (since
533
+   // the value is definitely big enough), and that it is OK to increment
534
+   // price counts without risk of integer overflow (since UINT32_MAX / 2
535
+   // is small enough). The current code doesn't increment price counts
536
+   // before initializing price tables, but it maybe done in future if
537
+   // we add support for saving the state between LZMA2 chunks.
538
+   coder->match_price_count = UINT32_MAX / 2;
539
+   coder->align_price_count = UINT32_MAX / 2;
540
+
541
+   coder->opts_end_index = 0;
542
+   coder->opts_current_index = 0;
543
+
544
+   return LZMA_OK;
545
+}
546
+
547
+
548
+extern lzma_ret
549
+lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator,
550
+       const lzma_options_lzma *options, lzma_lz_options *lz_options)
551
+{
552
+   // Allocate lzma_coder if it wasn't already allocated.
553
+   if (*coder_ptr == NULL) {
554
+       *coder_ptr = lzma_alloc(sizeof(lzma_coder), allocator);
555
+       if (*coder_ptr == NULL)
556
+           return LZMA_MEM_ERROR;
557
+   }
558
+
559
+   lzma_coder *coder = *coder_ptr;
560
+
561
+   // Set compression mode. We haven't validates the options yet,
562
+   // but it's OK here, since nothing bad happens with invalid
563
+   // options in the code below, and they will get rejected by
564
+   // lzma_lzma_encoder_reset() call at the end of this function.
565
+   switch (options->mode) {
566
+       case LZMA_MODE_FAST:
567
+           coder->fast_mode = true;
568
+           break;
569
+
570
+       case LZMA_MODE_NORMAL: {
571
+           coder->fast_mode = false;
572
+
573
+           // Set dist_table_size.
574
+           // Round the dictionary size up to next 2^n.
575
+           uint32_t log_size = 0;
576
+           while ((UINT32_C(1) << log_size) < options->dict_size)
577
+               ++log_size;
578
+
579
+           coder->dist_table_size = log_size * 2;
580
+
581
+           // Length encoders' price table size
582
+           coder->match_len_encoder.table_size
583
+               = options->nice_len + 1 - MATCH_LEN_MIN;
584
+           coder->rep_len_encoder.table_size
585
+               = options->nice_len + 1 - MATCH_LEN_MIN;
586
+           break;
587
+       }
588
+
589
+       default:
590
+           return LZMA_OPTIONS_ERROR;
591
+   }
592
+
593
+   // We don't need to write the first byte as literal if there is
594
+   // a non-empty preset dictionary. encode_init() wouldn't even work
595
+   // if there is a non-empty preset dictionary, because encode_init()
596
+   // assumes that position is zero and previous byte is also zero.
597
+   coder->is_initialized = options->preset_dict != NULL
598
+           && options->preset_dict_size > 0;
599
+   coder->is_flushed = false;
600
+
601
+   set_lz_options(lz_options, options);
602
+
603
+   return lzma_lzma_encoder_reset(coder, options);
604
+}
605
+
606
+
607
+static lzma_ret
608
+lzma_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
609
+       const void *options, lzma_lz_options *lz_options)
610
+{
611
+   lz->code = &lzma_encode;
612
+   return lzma_lzma_encoder_create(
613
+           &lz->coder, allocator, options, lz_options);
614
+}
615
+
616
+
617
+extern lzma_ret
618
+lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
619
+       const lzma_filter_info *filters)
620
+{
621
+   return lzma_lz_encoder_init(
622
+           next, allocator, filters, &lzma_encoder_init);
623
+}
624
+
625
+
626
+extern uint64_t
627
+lzma_lzma_encoder_memusage(const void *options)
628
+{
629
+   if (!is_options_valid(options))
630
+       return UINT64_MAX;
631
+
632
+   lzma_lz_options lz_options;
633
+   set_lz_options(&lz_options, options);
634
+
635
+   const uint64_t lz_memusage = lzma_lz_encoder_memusage(&lz_options);
636
+   if (lz_memusage == UINT64_MAX)
637
+       return UINT64_MAX;
638
+
639
+   return (uint64_t)(sizeof(lzma_coder)) + lz_memusage;
640
+}
641
+
642
+
643
+extern bool
644
+lzma_lzma_lclppb_encode(const lzma_options_lzma *options, uint8_t *byte)
645
+{
646
+   if (!is_lclppb_valid(options))
647
+       return true;
648
+
649
+   *byte = (options->pb * 5 + options->lp) * 9 + options->lc;
650
+   assert(*byte <= (4 * 5 + 4) * 9 + 8);
651
+
652
+   return false;
653
+}
654
+
655
+
656
+#ifdef HAVE_ENCODER_LZMA1
657
+extern lzma_ret
658
+lzma_lzma_props_encode(const void *options, uint8_t *out)
659
+{
660
+   const lzma_options_lzma *const opt = options;
661
+
662
+   if (lzma_lzma_lclppb_encode(opt, out))
663
+       return LZMA_PROG_ERROR;
664
+
665
+   unaligned_write32le(out + 1, opt->dict_size);
666
+
667
+   return LZMA_OK;
668
+}
669
+#endif
670
+
671
+
672
+extern LZMA_API(lzma_bool)
673
+lzma_mode_is_supported(lzma_mode mode)
674
+{
675
+   return mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL;
676
+}
677
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_encoder.h Added
56
 
1
@@ -0,0 +1,54 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_encoder.h
5
+/// \brief      LZMA encoder API
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZMA_ENCODER_H
16
+#define LZMA_LZMA_ENCODER_H
17
+
18
+#include "common.h"
19
+
20
+
21
+extern lzma_ret lzma_lzma_encoder_init(lzma_next_coder *next,
22
+       lzma_allocator *allocator, const lzma_filter_info *filters);
23
+
24
+
25
+extern uint64_t lzma_lzma_encoder_memusage(const void *options);
26
+
27
+extern lzma_ret lzma_lzma_props_encode(const void *options, uint8_t *out);
28
+
29
+
30
+/// Encodes lc/lp/pb into one byte. Returns false on success and true on error.
31
+extern bool lzma_lzma_lclppb_encode(
32
+       const lzma_options_lzma *options, uint8_t *byte);
33
+
34
+
35
+#ifdef LZMA_LZ_ENCODER_H
36
+
37
+/// Initializes raw LZMA encoder; this is used by LZMA2.
38
+extern lzma_ret lzma_lzma_encoder_create(
39
+       lzma_coder **coder_ptr, lzma_allocator *allocator,
40
+       const lzma_options_lzma *options, lzma_lz_options *lz_options);
41
+
42
+
43
+/// Resets an already initialized LZMA encoder; this is used by LZMA2.
44
+extern lzma_ret lzma_lzma_encoder_reset(
45
+       lzma_coder *coder, const lzma_options_lzma *options);
46
+
47
+
48
+extern lzma_ret lzma_lzma_encode(lzma_coder *restrict coder,
49
+       lzma_mf *restrict mf, uint8_t *restrict out,
50
+       size_t *restrict out_pos, size_t out_size,
51
+       uint32_t read_limit);
52
+
53
+#endif
54
+
55
+#endif
56
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_encoder_optimum_fast.c Added
181
 
1
@@ -0,0 +1,179 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_encoder_optimum_fast.c
5
+//
6
+//  Author:     Igor Pavlov
7
+//
8
+//  This file has been put into the public domain.
9
+//  You can do whatever you want with this file.
10
+//
11
+///////////////////////////////////////////////////////////////////////////////
12
+
13
+#include "lzma_encoder_private.h"
14
+
15
+
16
+#define change_pair(small_dist, big_dist) \
17
+   (((big_dist) >> 7) > (small_dist))
18
+
19
+
20
+extern void
21
+lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf,
22
+       uint32_t *restrict back_res, uint32_t *restrict len_res)
23
+{
24
+   const uint32_t nice_len = mf->nice_len;
25
+
26
+   uint32_t len_main;
27
+   uint32_t matches_count;
28
+   if (mf->read_ahead == 0) {
29
+       len_main = mf_find(mf, &matches_count, coder->matches);
30
+   } else {
31
+       assert(mf->read_ahead == 1);
32
+       len_main = coder->longest_match_length;
33
+       matches_count = coder->matches_count;
34
+   }
35
+
36
+   const uint8_t *buf = mf_ptr(mf) - 1;
37
+   const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
38
+
39
+   if (buf_avail < 2) {
40
+       // There's not enough input left to encode a match.
41
+       *back_res = UINT32_MAX;
42
+       *len_res = 1;
43
+       return;
44
+   }
45
+
46
+   // Look for repeated matches; scan the previous four match distances
47
+   uint32_t rep_len = 0;
48
+   uint32_t rep_index = 0;
49
+
50
+   for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
51
+       // Pointer to the beginning of the match candidate
52
+       const uint8_t *const buf_back = buf - coder->reps[i] - 1;
53
+
54
+       // If the first two bytes (2 == MATCH_LEN_MIN) do not match,
55
+       // this rep is not useful.
56
+       if (not_equal_16(buf, buf_back))
57
+           continue;
58
+
59
+       // The first two bytes matched.
60
+       // Calculate the length of the match.
61
+       uint32_t len;
62
+       for (len = 2; len < buf_avail
63
+               && buf[len] == buf_back[len]; ++len) ;
64
+
65
+       // If we have found a repeated match that is at least
66
+       // nice_len long, return it immediately.
67
+       if (len >= nice_len) {
68
+           *back_res = i;
69
+           *len_res = len;
70
+           mf_skip(mf, len - 1);
71
+           return;
72
+       }
73
+
74
+       if (len > rep_len) {
75
+           rep_index = i;
76
+           rep_len = len;
77
+       }
78
+   }
79
+
80
+   // We didn't find a long enough repeated match. Encode it as a normal
81
+   // match if the match length is at least nice_len.
82
+   if (len_main >= nice_len) {
83
+       *back_res = coder->matches[matches_count - 1].dist
84
+               + REP_DISTANCES;
85
+       *len_res = len_main;
86
+       mf_skip(mf, len_main - 1);
87
+       return;
88
+   }
89
+
90
+   uint32_t back_main = 0;
91
+   if (len_main >= 2) {
92
+       back_main = coder->matches[matches_count - 1].dist;
93
+
94
+       while (matches_count > 1 && len_main ==
95
+               coder->matches[matches_count - 2].len + 1) {
96
+           if (!change_pair(coder->matches[
97
+                       matches_count - 2].dist,
98
+                   back_main))
99
+               break;
100
+
101
+           --matches_count;
102
+           len_main = coder->matches[matches_count - 1].len;
103
+           back_main = coder->matches[matches_count - 1].dist;
104
+       }
105
+
106
+       if (len_main == 2 && back_main >= 0x80)
107
+           len_main = 1;
108
+   }
109
+
110
+   if (rep_len >= 2) {
111
+       if (rep_len + 1 >= len_main
112
+               || (rep_len + 2 >= len_main
113
+                   && back_main > (UINT32_C(1) << 9))
114
+               || (rep_len + 3 >= len_main
115
+                   && back_main > (UINT32_C(1) << 15))) {
116
+           *back_res = rep_index;
117
+           *len_res = rep_len;
118
+           mf_skip(mf, rep_len - 1);
119
+           return;
120
+       }
121
+   }
122
+
123
+   if (len_main < 2 || buf_avail <= 2) {
124
+       *back_res = UINT32_MAX;
125
+       *len_res = 1;
126
+       return;
127
+   }
128
+
129
+   // Get the matches for the next byte. If we find a better match,
130
+   // the current byte is encoded as a literal.
131
+   coder->longest_match_length = mf_find(mf,
132
+           &coder->matches_count, coder->matches);
133
+
134
+   if (coder->longest_match_length >= 2) {
135
+       const uint32_t new_dist = coder->matches[
136
+               coder->matches_count - 1].dist;
137
+
138
+       if ((coder->longest_match_length >= len_main
139
+                   && new_dist < back_main)
140
+               || (coder->longest_match_length == len_main + 1
141
+                   && !change_pair(back_main, new_dist))
142
+               || (coder->longest_match_length > len_main + 1)
143
+               || (coder->longest_match_length + 1 >= len_main
144
+                   && len_main >= 3
145
+                   && change_pair(new_dist, back_main))) {
146
+           *back_res = UINT32_MAX;
147
+           *len_res = 1;
148
+           return;
149
+       }
150
+   }
151
+
152
+   // In contrast to LZMA SDK, dictionary could not have been moved
153
+   // between mf_find() calls, thus it is safe to just increment
154
+   // the old buf pointer instead of recalculating it with mf_ptr().
155
+   ++buf;
156
+
157
+   const uint32_t limit = len_main - 1;
158
+
159
+   for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
160
+       const uint8_t *const buf_back = buf - coder->reps[i] - 1;
161
+
162
+       if (not_equal_16(buf, buf_back))
163
+           continue;
164
+
165
+       uint32_t len;
166
+       for (len = 2; len < limit
167
+               && buf[len] == buf_back[len]; ++len) ;
168
+
169
+       if (len >= limit) {
170
+           *back_res = UINT32_MAX;
171
+           *len_res = 1;
172
+           return;
173
+       }
174
+   }
175
+
176
+   *back_res = back_main + REP_DISTANCES;
177
+   *len_res = len_main;
178
+   mf_skip(mf, len_main - 2);
179
+   return;
180
+}
181
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_encoder_optimum_normal.c Added
870
 
1
@@ -0,0 +1,868 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_encoder_optimum_normal.c
5
+//
6
+//  Author:     Igor Pavlov
7
+//
8
+//  This file has been put into the public domain.
9
+//  You can do whatever you want with this file.
10
+//
11
+///////////////////////////////////////////////////////////////////////////////
12
+
13
+#include "lzma_encoder_private.h"
14
+#include "fastpos.h"
15
+
16
+
17
+////////////
18
+// Prices //
19
+////////////
20
+
21
+static uint32_t
22
+get_literal_price(const lzma_coder *const coder, const uint32_t pos,
23
+       const uint32_t prev_byte, const bool match_mode,
24
+       uint32_t match_byte, uint32_t symbol)
25
+{
26
+   const probability *const subcoder = literal_subcoder(coder->literal,
27
+           coder->literal_context_bits, coder->literal_pos_mask,
28
+           pos, prev_byte);
29
+
30
+   uint32_t price = 0;
31
+
32
+   if (!match_mode) {
33
+       price = rc_bittree_price(subcoder, 8, symbol);
34
+   } else {
35
+       uint32_t offset = 0x100;
36
+       symbol += UINT32_C(1) << 8;
37
+
38
+       do {
39
+           match_byte <<= 1;
40
+
41
+           const uint32_t match_bit = match_byte & offset;
42
+           const uint32_t subcoder_index
43
+                   = offset + match_bit + (symbol >> 8);
44
+           const uint32_t bit = (symbol >> 7) & 1;
45
+           price += rc_bit_price(subcoder[subcoder_index], bit);
46
+
47
+           symbol <<= 1;
48
+           offset &= ~(match_byte ^ symbol);
49
+
50
+       } while (symbol < (UINT32_C(1) << 16));
51
+   }
52
+
53
+   return price;
54
+}
55
+
56
+
57
+static inline uint32_t
58
+get_len_price(const lzma_length_encoder *const lencoder,
59
+       const uint32_t len, const uint32_t pos_state)
60
+{
61
+   // NOTE: Unlike the other price tables, length prices are updated
62
+   // in lzma_encoder.c
63
+   return lencoder->prices[pos_state][len - MATCH_LEN_MIN];
64
+}
65
+
66
+
67
+static inline uint32_t
68
+get_short_rep_price(const lzma_coder *const coder,
69
+       const lzma_lzma_state state, const uint32_t pos_state)
70
+{
71
+   return rc_bit_0_price(coder->is_rep0[state])
72
+       + rc_bit_0_price(coder->is_rep0_long[state][pos_state]);
73
+}
74
+
75
+
76
+static inline uint32_t
77
+get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
78
+       const lzma_lzma_state state, uint32_t pos_state)
79
+{
80
+   uint32_t price;
81
+
82
+   if (rep_index == 0) {
83
+       price = rc_bit_0_price(coder->is_rep0[state]);
84
+       price += rc_bit_1_price(coder->is_rep0_long[state][pos_state]);
85
+   } else {
86
+       price = rc_bit_1_price(coder->is_rep0[state]);
87
+
88
+       if (rep_index == 1) {
89
+           price += rc_bit_0_price(coder->is_rep1[state]);
90
+       } else {
91
+           price += rc_bit_1_price(coder->is_rep1[state]);
92
+           price += rc_bit_price(coder->is_rep2[state],
93
+                   rep_index - 2);
94
+       }
95
+   }
96
+
97
+   return price;
98
+}
99
+
100
+
101
+static inline uint32_t
102
+get_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
103
+       const uint32_t len, const lzma_lzma_state state,
104
+       const uint32_t pos_state)
105
+{
106
+   return get_len_price(&coder->rep_len_encoder, len, pos_state)
107
+       + get_pure_rep_price(coder, rep_index, state, pos_state);
108
+}
109
+
110
+
111
+static inline uint32_t
112
+get_pos_len_price(const lzma_coder *const coder, const uint32_t pos,
113
+       const uint32_t len, const uint32_t pos_state)
114
+{
115
+   const uint32_t len_to_pos_state = get_len_to_pos_state(len);
116
+   uint32_t price;
117
+
118
+   if (pos < FULL_DISTANCES) {
119
+       price = coder->distances_prices[len_to_pos_state][pos];
120
+   } else {
121
+       const uint32_t pos_slot = get_pos_slot_2(pos);
122
+       price = coder->pos_slot_prices[len_to_pos_state][pos_slot]
123
+               + coder->align_prices[pos & ALIGN_MASK];
124
+   }
125
+
126
+   price += get_len_price(&coder->match_len_encoder, len, pos_state);
127
+
128
+   return price;
129
+}
130
+
131
+
132
+static void
133
+fill_distances_prices(lzma_coder *coder)
134
+{
135
+   for (uint32_t len_to_pos_state = 0;
136
+           len_to_pos_state < LEN_TO_POS_STATES;
137
+           ++len_to_pos_state) {
138
+
139
+       uint32_t *const pos_slot_prices
140
+               = coder->pos_slot_prices[len_to_pos_state];
141
+
142
+       // Price to encode the pos_slot.
143
+       for (uint32_t pos_slot = 0;
144
+               pos_slot < coder->dist_table_size; ++pos_slot)
145
+           pos_slot_prices[pos_slot] = rc_bittree_price(
146
+                   coder->pos_slot[len_to_pos_state],
147
+                   POS_SLOT_BITS, pos_slot);
148
+
149
+       // For matches with distance >= FULL_DISTANCES, add the price
150
+       // of the direct bits part of the match distance. (Align bits
151
+       // are handled by fill_align_prices()).
152
+       for (uint32_t pos_slot = END_POS_MODEL_INDEX;
153
+               pos_slot < coder->dist_table_size; ++pos_slot)
154
+           pos_slot_prices[pos_slot] += rc_direct_price(
155
+                   ((pos_slot >> 1) - 1) - ALIGN_BITS);
156
+
157
+       // Distances in the range [0, 3] are fully encoded with
158
+       // pos_slot, so they are used for coder->distances_prices
159
+       // as is.
160
+       for (uint32_t i = 0; i < START_POS_MODEL_INDEX; ++i)
161
+           coder->distances_prices[len_to_pos_state][i]
162
+                   = pos_slot_prices[i];
163
+   }
164
+
165
+   // Distances in the range [4, 127] depend on pos_slot and pos_special.
166
+   // We do this in a loop separate from the above loop to avoid
167
+   // redundant calls to get_pos_slot().
168
+   for (uint32_t i = START_POS_MODEL_INDEX; i < FULL_DISTANCES; ++i) {
169
+       const uint32_t pos_slot = get_pos_slot(i);
170
+       const uint32_t footer_bits = ((pos_slot >> 1) - 1);
171
+       const uint32_t base = (2 | (pos_slot & 1)) << footer_bits;
172
+       const uint32_t price = rc_bittree_reverse_price(
173
+               coder->pos_special + base - pos_slot - 1,
174
+               footer_bits, i - base);
175
+
176
+       for (uint32_t len_to_pos_state = 0;
177
+               len_to_pos_state < LEN_TO_POS_STATES;
178
+               ++len_to_pos_state)
179
+           coder->distances_prices[len_to_pos_state][i]
180
+                   = price + coder->pos_slot_prices[
181
+                       len_to_pos_state][pos_slot];
182
+   }
183
+
184
+   coder->match_price_count = 0;
185
+   return;
186
+}
187
+
188
+
189
+static void
190
+fill_align_prices(lzma_coder *coder)
191
+{
192
+   for (uint32_t i = 0; i < ALIGN_TABLE_SIZE; ++i)
193
+       coder->align_prices[i] = rc_bittree_reverse_price(
194
+               coder->pos_align, ALIGN_BITS, i);
195
+
196
+   coder->align_price_count = 0;
197
+   return;
198
+}
199
+
200
+
201
+/////////////
202
+// Optimal //
203
+/////////////
204
+
205
+static inline void
206
+make_literal(lzma_optimal *optimal)
207
+{
208
+   optimal->back_prev = UINT32_MAX;
209
+   optimal->prev_1_is_literal = false;
210
+}
211
+
212
+
213
+static inline void
214
+make_short_rep(lzma_optimal *optimal)
215
+{
216
+   optimal->back_prev = 0;
217
+   optimal->prev_1_is_literal = false;
218
+}
219
+
220
+
221
+#define is_short_rep(optimal) \
222
+   ((optimal).back_prev == 0)
223
+
224
+
225
+static void
226
+backward(lzma_coder *restrict coder, uint32_t *restrict len_res,
227
+       uint32_t *restrict back_res, uint32_t cur)
228
+{
229
+   coder->opts_end_index = cur;
230
+
231
+   uint32_t pos_mem = coder->opts[cur].pos_prev;
232
+   uint32_t back_mem = coder->opts[cur].back_prev;
233
+
234
+   do {
235
+       if (coder->opts[cur].prev_1_is_literal) {
236
+           make_literal(&coder->opts[pos_mem]);
237
+           coder->opts[pos_mem].pos_prev = pos_mem - 1;
238
+
239
+           if (coder->opts[cur].prev_2) {
240
+               coder->opts[pos_mem - 1].prev_1_is_literal
241
+                       = false;
242
+               coder->opts[pos_mem - 1].pos_prev
243
+                       = coder->opts[cur].pos_prev_2;
244
+               coder->opts[pos_mem - 1].back_prev
245
+                       = coder->opts[cur].back_prev_2;
246
+           }
247
+       }
248
+
249
+       const uint32_t pos_prev = pos_mem;
250
+       const uint32_t back_cur = back_mem;
251
+
252
+       back_mem = coder->opts[pos_prev].back_prev;
253
+       pos_mem = coder->opts[pos_prev].pos_prev;
254
+
255
+       coder->opts[pos_prev].back_prev = back_cur;
256
+       coder->opts[pos_prev].pos_prev = cur;
257
+       cur = pos_prev;
258
+
259
+   } while (cur != 0);
260
+
261
+   coder->opts_current_index = coder->opts[0].pos_prev;
262
+   *len_res = coder->opts[0].pos_prev;
263
+   *back_res = coder->opts[0].back_prev;
264
+
265
+   return;
266
+}
267
+
268
+
269
+//////////
270
+// Main //
271
+//////////
272
+
273
+static inline uint32_t
274
+helper1(lzma_coder *restrict coder, lzma_mf *restrict mf,
275
+       uint32_t *restrict back_res, uint32_t *restrict len_res,
276
+       uint32_t position)
277
+{
278
+   const uint32_t nice_len = mf->nice_len;
279
+
280
+   uint32_t len_main;
281
+   uint32_t matches_count;
282
+
283
+   if (mf->read_ahead == 0) {
284
+       len_main = mf_find(mf, &matches_count, coder->matches);
285
+   } else {
286
+       assert(mf->read_ahead == 1);
287
+       len_main = coder->longest_match_length;
288
+       matches_count = coder->matches_count;
289
+   }
290
+
291
+   const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
292
+   if (buf_avail < 2) {
293
+       *back_res = UINT32_MAX;
294
+       *len_res = 1;
295
+       return UINT32_MAX;
296
+   }
297
+
298
+   const uint8_t *const buf = mf_ptr(mf) - 1;
299
+
300
+   uint32_t rep_lens[REP_DISTANCES];
301
+   uint32_t rep_max_index = 0;
302
+
303
+   for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
304
+       const uint8_t *const buf_back = buf - coder->reps[i] - 1;
305
+
306
+       if (not_equal_16(buf, buf_back)) {
307
+           rep_lens[i] = 0;
308
+           continue;
309
+       }
310
+
311
+       uint32_t len_test;
312
+       for (len_test = 2; len_test < buf_avail
313
+               && buf[len_test] == buf_back[len_test];
314
+               ++len_test) ;
315
+
316
+       rep_lens[i] = len_test;
317
+       if (len_test > rep_lens[rep_max_index])
318
+           rep_max_index = i;
319
+   }
320
+
321
+   if (rep_lens[rep_max_index] >= nice_len) {
322
+       *back_res = rep_max_index;
323
+       *len_res = rep_lens[rep_max_index];
324
+       mf_skip(mf, *len_res - 1);
325
+       return UINT32_MAX;
326
+   }
327
+
328
+
329
+   if (len_main >= nice_len) {
330
+       *back_res = coder->matches[matches_count - 1].dist
331
+               + REP_DISTANCES;
332
+       *len_res = len_main;
333
+       mf_skip(mf, len_main - 1);
334
+       return UINT32_MAX;
335
+   }
336
+
337
+   const uint8_t current_byte = *buf;
338
+   const uint8_t match_byte = *(buf - coder->reps[0] - 1);
339
+
340
+   if (len_main < 2 && current_byte != match_byte
341
+           && rep_lens[rep_max_index] < 2) {
342
+       *back_res = UINT32_MAX;
343
+       *len_res = 1;
344
+       return UINT32_MAX;
345
+   }
346
+
347
+   coder->opts[0].state = coder->state;
348
+
349
+   const uint32_t pos_state = position & coder->pos_mask;
350
+
351
+   coder->opts[1].price = rc_bit_0_price(
352
+               coder->is_match[coder->state][pos_state])
353
+           + get_literal_price(coder, position, buf[-1],
354
+               !is_literal_state(coder->state),
355
+               match_byte, current_byte);
356
+
357
+   make_literal(&coder->opts[1]);
358
+
359
+   const uint32_t match_price = rc_bit_1_price(
360
+           coder->is_match[coder->state][pos_state]);
361
+   const uint32_t rep_match_price = match_price
362
+           + rc_bit_1_price(coder->is_rep[coder->state]);
363
+
364
+   if (match_byte == current_byte) {
365
+       const uint32_t short_rep_price = rep_match_price
366
+               + get_short_rep_price(
367
+                   coder, coder->state, pos_state);
368
+
369
+       if (short_rep_price < coder->opts[1].price) {
370
+           coder->opts[1].price = short_rep_price;
371
+           make_short_rep(&coder->opts[1]);
372
+       }
373
+   }
374
+
375
+   const uint32_t len_end = my_max(len_main, rep_lens[rep_max_index]);
376
+
377
+   if (len_end < 2) {
378
+       *back_res = coder->opts[1].back_prev;
379
+       *len_res = 1;
380
+       return UINT32_MAX;
381
+   }
382
+
383
+   coder->opts[1].pos_prev = 0;
384
+
385
+   for (uint32_t i = 0; i < REP_DISTANCES; ++i)
386
+       coder->opts[0].backs[i] = coder->reps[i];
387
+
388
+   uint32_t len = len_end;
389
+   do {
390
+       coder->opts[len].price = RC_INFINITY_PRICE;
391
+   } while (--len >= 2);
392
+
393
+
394
+   for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
395
+       uint32_t rep_len = rep_lens[i];
396
+       if (rep_len < 2)
397
+           continue;
398
+
399
+       const uint32_t price = rep_match_price + get_pure_rep_price(
400
+               coder, i, coder->state, pos_state);
401
+
402
+       do {
403
+           const uint32_t cur_and_len_price = price
404
+                   + get_len_price(
405
+                       &coder->rep_len_encoder,
406
+                       rep_len, pos_state);
407
+
408
+           if (cur_and_len_price < coder->opts[rep_len].price) {
409
+               coder->opts[rep_len].price = cur_and_len_price;
410
+               coder->opts[rep_len].pos_prev = 0;
411
+               coder->opts[rep_len].back_prev = i;
412
+               coder->opts[rep_len].prev_1_is_literal = false;
413
+           }
414
+       } while (--rep_len >= 2);
415
+   }
416
+
417
+
418
+   const uint32_t normal_match_price = match_price
419
+           + rc_bit_0_price(coder->is_rep[coder->state]);
420
+
421
+   len = rep_lens[0] >= 2 ? rep_lens[0] + 1 : 2;
422
+   if (len <= len_main) {
423
+       uint32_t i = 0;
424
+       while (len > coder->matches[i].len)
425
+           ++i;
426
+
427
+       for(; ; ++len) {
428
+           const uint32_t dist = coder->matches[i].dist;
429
+           const uint32_t cur_and_len_price = normal_match_price
430
+                   + get_pos_len_price(coder,
431
+                       dist, len, pos_state);
432
+
433
+           if (cur_and_len_price < coder->opts[len].price) {
434
+               coder->opts[len].price = cur_and_len_price;
435
+               coder->opts[len].pos_prev = 0;
436
+               coder->opts[len].back_prev
437
+                       = dist + REP_DISTANCES;
438
+               coder->opts[len].prev_1_is_literal = false;
439
+           }
440
+
441
+           if (len == coder->matches[i].len)
442
+               if (++i == matches_count)
443
+                   break;
444
+       }
445
+   }
446
+
447
+   return len_end;
448
+}
449
+
450
+
451
+static inline uint32_t
452
+helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
453
+       uint32_t len_end, uint32_t position, const uint32_t cur,
454
+       const uint32_t nice_len, const uint32_t buf_avail_full)
455
+{
456
+   uint32_t matches_count = coder->matches_count;
457
+   uint32_t new_len = coder->longest_match_length;
458
+   uint32_t pos_prev = coder->opts[cur].pos_prev;
459
+   lzma_lzma_state state;
460
+
461
+   if (coder->opts[cur].prev_1_is_literal) {
462
+       --pos_prev;
463
+
464
+       if (coder->opts[cur].prev_2) {
465
+           state = coder->opts[coder->opts[cur].pos_prev_2].state;
466
+
467
+           if (coder->opts[cur].back_prev_2 < REP_DISTANCES)
468
+               update_long_rep(state);
469
+           else
470
+               update_match(state);
471
+
472
+       } else {
473
+           state = coder->opts[pos_prev].state;
474
+       }
475
+
476
+       update_literal(state);
477
+
478
+   } else {
479
+       state = coder->opts[pos_prev].state;
480
+   }
481
+
482
+   if (pos_prev == cur - 1) {
483
+       if (is_short_rep(coder->opts[cur]))
484
+           update_short_rep(state);
485
+       else
486
+           update_literal(state);
487
+   } else {
488
+       uint32_t pos;
489
+       if (coder->opts[cur].prev_1_is_literal
490
+               && coder->opts[cur].prev_2) {
491
+           pos_prev = coder->opts[cur].pos_prev_2;
492
+           pos = coder->opts[cur].back_prev_2;
493
+           update_long_rep(state);
494
+       } else {
495
+           pos = coder->opts[cur].back_prev;
496
+           if (pos < REP_DISTANCES)
497
+               update_long_rep(state);
498
+           else
499
+               update_match(state);
500
+       }
501
+
502
+       if (pos < REP_DISTANCES) {
503
+           reps[0] = coder->opts[pos_prev].backs[pos];
504
+
505
+           uint32_t i;
506
+           for (i = 1; i <= pos; ++i)
507
+               reps[i] = coder->opts[pos_prev].backs[i - 1];
508
+
509
+           for (; i < REP_DISTANCES; ++i)
510
+               reps[i] = coder->opts[pos_prev].backs[i];
511
+
512
+       } else {
513
+           reps[0] = pos - REP_DISTANCES;
514
+
515
+           for (uint32_t i = 1; i < REP_DISTANCES; ++i)
516
+               reps[i] = coder->opts[pos_prev].backs[i - 1];
517
+       }
518
+   }
519
+
520
+   coder->opts[cur].state = state;
521
+
522
+   for (uint32_t i = 0; i < REP_DISTANCES; ++i)
523
+       coder->opts[cur].backs[i] = reps[i];
524
+
525
+   const uint32_t cur_price = coder->opts[cur].price;
526
+
527
+   const uint8_t current_byte = *buf;
528
+   const uint8_t match_byte = *(buf - reps[0] - 1);
529
+
530
+   const uint32_t pos_state = position & coder->pos_mask;
531
+
532
+   const uint32_t cur_and_1_price = cur_price
533
+           + rc_bit_0_price(coder->is_match[state][pos_state])
534
+           + get_literal_price(coder, position, buf[-1],
535
+           !is_literal_state(state), match_byte, current_byte);
536
+
537
+   bool next_is_literal = false;
538
+
539
+   if (cur_and_1_price < coder->opts[cur + 1].price) {
540
+       coder->opts[cur + 1].price = cur_and_1_price;
541
+       coder->opts[cur + 1].pos_prev = cur;
542
+       make_literal(&coder->opts[cur + 1]);
543
+       next_is_literal = true;
544
+   }
545
+
546
+   const uint32_t match_price = cur_price
547
+           + rc_bit_1_price(coder->is_match[state][pos_state]);
548
+   const uint32_t rep_match_price = match_price
549
+           + rc_bit_1_price(coder->is_rep[state]);
550
+
551
+   if (match_byte == current_byte
552
+           && !(coder->opts[cur + 1].pos_prev < cur
553
+               && coder->opts[cur + 1].back_prev == 0)) {
554
+
555
+       const uint32_t short_rep_price = rep_match_price
556
+               + get_short_rep_price(coder, state, pos_state);
557
+
558
+       if (short_rep_price <= coder->opts[cur + 1].price) {
559
+           coder->opts[cur + 1].price = short_rep_price;
560
+           coder->opts[cur + 1].pos_prev = cur;
561
+           make_short_rep(&coder->opts[cur + 1]);
562
+           next_is_literal = true;
563
+       }
564
+   }
565
+
566
+   if (buf_avail_full < 2)
567
+       return len_end;
568
+
569
+   const uint32_t buf_avail = my_min(buf_avail_full, nice_len);
570
+
571
+   if (!next_is_literal && match_byte != current_byte) { // speed optimization
572
+       // try literal + rep0
573
+       const uint8_t *const buf_back = buf - reps[0] - 1;
574
+       const uint32_t limit = my_min(buf_avail_full, nice_len + 1);
575
+
576
+       uint32_t len_test = 1;
577
+       while (len_test < limit && buf[len_test] == buf_back[len_test])
578
+           ++len_test;
579
+
580
+       --len_test;
581
+
582
+       if (len_test >= 2) {
583
+           lzma_lzma_state state_2 = state;
584
+           update_literal(state_2);
585
+
586
+           const uint32_t pos_state_next = (position + 1) & coder->pos_mask;
587
+           const uint32_t next_rep_match_price = cur_and_1_price
588
+                   + rc_bit_1_price(coder->is_match[state_2][pos_state_next])
589
+                   + rc_bit_1_price(coder->is_rep[state_2]);
590
+
591
+           //for (; len_test >= 2; --len_test) {
592
+           const uint32_t offset = cur + 1 + len_test;
593
+
594
+           while (len_end < offset)
595
+               coder->opts[++len_end].price = RC_INFINITY_PRICE;
596
+
597
+           const uint32_t cur_and_len_price = next_rep_match_price
598
+                   + get_rep_price(coder, 0, len_test,
599
+                       state_2, pos_state_next);
600
+
601
+           if (cur_and_len_price < coder->opts[offset].price) {
602
+               coder->opts[offset].price = cur_and_len_price;
603
+               coder->opts[offset].pos_prev = cur + 1;
604
+               coder->opts[offset].back_prev = 0;
605
+               coder->opts[offset].prev_1_is_literal = true;
606
+               coder->opts[offset].prev_2 = false;
607
+           }
608
+           //}
609
+       }
610
+   }
611
+
612
+
613
+   uint32_t start_len = 2; // speed optimization
614
+
615
+   for (uint32_t rep_index = 0; rep_index < REP_DISTANCES; ++rep_index) {
616
+       const uint8_t *const buf_back = buf - reps[rep_index] - 1;
617
+       if (not_equal_16(buf, buf_back))
618
+           continue;
619
+
620
+       uint32_t len_test;
621
+       for (len_test = 2; len_test < buf_avail
622
+               && buf[len_test] == buf_back[len_test];
623
+               ++len_test) ;
624
+
625
+       while (len_end < cur + len_test)
626
+           coder->opts[++len_end].price = RC_INFINITY_PRICE;
627
+
628
+       const uint32_t len_test_temp = len_test;
629
+       const uint32_t price = rep_match_price + get_pure_rep_price(
630
+               coder, rep_index, state, pos_state);
631
+
632
+       do {
633
+           const uint32_t cur_and_len_price = price
634
+                   + get_len_price(&coder->rep_len_encoder,
635
+                           len_test, pos_state);
636
+
637
+           if (cur_and_len_price < coder->opts[cur + len_test].price) {
638
+               coder->opts[cur + len_test].price = cur_and_len_price;
639
+               coder->opts[cur + len_test].pos_prev = cur;
640
+               coder->opts[cur + len_test].back_prev = rep_index;
641
+               coder->opts[cur + len_test].prev_1_is_literal = false;
642
+           }
643
+       } while (--len_test >= 2);
644
+
645
+       len_test = len_test_temp;
646
+
647
+       if (rep_index == 0)
648
+           start_len = len_test + 1;
649
+
650
+
651
+       uint32_t len_test_2 = len_test + 1;
652
+       const uint32_t limit = my_min(buf_avail_full,
653
+               len_test_2 + nice_len);
654
+       for (; len_test_2 < limit
655
+               && buf[len_test_2] == buf_back[len_test_2];
656
+               ++len_test_2) ;
657
+
658
+       len_test_2 -= len_test + 1;
659
+
660
+       if (len_test_2 >= 2) {
661
+           lzma_lzma_state state_2 = state;
662
+           update_long_rep(state_2);
663
+
664
+           uint32_t pos_state_next = (position + len_test) & coder->pos_mask;
665
+
666
+           const uint32_t cur_and_len_literal_price = price
667
+                   + get_len_price(&coder->rep_len_encoder,
668
+                       len_test, pos_state)
669
+                   + rc_bit_0_price(coder->is_match[state_2][pos_state_next])
670
+                   + get_literal_price(coder, position + len_test,
671
+                       buf[len_test - 1], true,
672
+                       buf_back[len_test], buf[len_test]);
673
+
674
+           update_literal(state_2);
675
+
676
+           pos_state_next = (position + len_test + 1) & coder->pos_mask;
677
+
678
+           const uint32_t next_rep_match_price = cur_and_len_literal_price
679
+                   + rc_bit_1_price(coder->is_match[state_2][pos_state_next])
680
+                   + rc_bit_1_price(coder->is_rep[state_2]);
681
+
682
+           //for(; len_test_2 >= 2; len_test_2--) {
683
+           const uint32_t offset = cur + len_test + 1 + len_test_2;
684
+
685
+           while (len_end < offset)
686
+               coder->opts[++len_end].price = RC_INFINITY_PRICE;
687
+
688
+           const uint32_t cur_and_len_price = next_rep_match_price
689
+                   + get_rep_price(coder, 0, len_test_2,
690
+                       state_2, pos_state_next);
691
+
692
+           if (cur_and_len_price < coder->opts[offset].price) {
693
+               coder->opts[offset].price = cur_and_len_price;
694
+               coder->opts[offset].pos_prev = cur + len_test + 1;
695
+               coder->opts[offset].back_prev = 0;
696
+               coder->opts[offset].prev_1_is_literal = true;
697
+               coder->opts[offset].prev_2 = true;
698
+               coder->opts[offset].pos_prev_2 = cur;
699
+               coder->opts[offset].back_prev_2 = rep_index;
700
+           }
701
+           //}
702
+       }
703
+   }
704
+
705
+
706
+   //for (uint32_t len_test = 2; len_test <= new_len; ++len_test)
707
+   if (new_len > buf_avail) {
708
+       new_len = buf_avail;
709
+
710
+       matches_count = 0;
711
+       while (new_len > coder->matches[matches_count].len)
712
+           ++matches_count;
713
+
714
+       coder->matches[matches_count++].len = new_len;
715
+   }
716
+
717
+
718
+   if (new_len >= start_len) {
719
+       const uint32_t normal_match_price = match_price
720
+               + rc_bit_0_price(coder->is_rep[state]);
721
+
722
+       while (len_end < cur + new_len)
723
+           coder->opts[++len_end].price = RC_INFINITY_PRICE;
724
+
725
+       uint32_t i = 0;
726
+       while (start_len > coder->matches[i].len)
727
+           ++i;
728
+
729
+       for (uint32_t len_test = start_len; ; ++len_test) {
730
+           const uint32_t cur_back = coder->matches[i].dist;
731
+           uint32_t cur_and_len_price = normal_match_price
732
+                   + get_pos_len_price(coder,
733
+                       cur_back, len_test, pos_state);
734
+
735
+           if (cur_and_len_price < coder->opts[cur + len_test].price) {
736
+               coder->opts[cur + len_test].price = cur_and_len_price;
737
+               coder->opts[cur + len_test].pos_prev = cur;
738
+               coder->opts[cur + len_test].back_prev
739
+                       = cur_back + REP_DISTANCES;
740
+               coder->opts[cur + len_test].prev_1_is_literal = false;
741
+           }
742
+
743
+           if (len_test == coder->matches[i].len) {
744
+               // Try Match + Literal + Rep0
745
+               const uint8_t *const buf_back = buf - cur_back - 1;
746
+               uint32_t len_test_2 = len_test + 1;
747
+               const uint32_t limit = my_min(buf_avail_full,
748
+                       len_test_2 + nice_len);
749
+
750
+               for (; len_test_2 < limit &&
751
+                       buf[len_test_2] == buf_back[len_test_2];
752
+                       ++len_test_2) ;
753
+
754
+               len_test_2 -= len_test + 1;
755
+
756
+               if (len_test_2 >= 2) {
757
+                   lzma_lzma_state state_2 = state;
758
+                   update_match(state_2);
759
+                   uint32_t pos_state_next
760
+                           = (position + len_test) & coder->pos_mask;
761
+
762
+                   const uint32_t cur_and_len_literal_price = cur_and_len_price
763
+                           + rc_bit_0_price(
764
+                               coder->is_match[state_2][pos_state_next])
765
+                           + get_literal_price(coder,
766
+                               position + len_test,
767
+                               buf[len_test - 1],
768
+                               true,
769
+                               buf_back[len_test],
770
+                               buf[len_test]);
771
+
772
+                   update_literal(state_2);
773
+                   pos_state_next = (pos_state_next + 1) & coder->pos_mask;
774
+
775
+                   const uint32_t next_rep_match_price
776
+                           = cur_and_len_literal_price
777
+                           + rc_bit_1_price(
778
+                               coder->is_match[state_2][pos_state_next])
779
+                           + rc_bit_1_price(coder->is_rep[state_2]);
780
+
781
+                   // for(; len_test_2 >= 2; --len_test_2) {
782
+                   const uint32_t offset = cur + len_test + 1 + len_test_2;
783
+
784
+                   while (len_end < offset)
785
+                       coder->opts[++len_end].price = RC_INFINITY_PRICE;
786
+
787
+                   cur_and_len_price = next_rep_match_price
788
+                           + get_rep_price(coder, 0, len_test_2,
789
+                               state_2, pos_state_next);
790
+
791
+                   if (cur_and_len_price < coder->opts[offset].price) {
792
+                       coder->opts[offset].price = cur_and_len_price;
793
+                       coder->opts[offset].pos_prev = cur + len_test + 1;
794
+                       coder->opts[offset].back_prev = 0;
795
+                       coder->opts[offset].prev_1_is_literal = true;
796
+                       coder->opts[offset].prev_2 = true;
797
+                       coder->opts[offset].pos_prev_2 = cur;
798
+                       coder->opts[offset].back_prev_2
799
+                               = cur_back + REP_DISTANCES;
800
+                   }
801
+                   //}
802
+               }
803
+
804
+               if (++i == matches_count)
805
+                   break;
806
+           }
807
+       }
808
+   }
809
+
810
+   return len_end;
811
+}
812
+
813
+
814
+extern void
815
+lzma_lzma_optimum_normal(lzma_coder *restrict coder, lzma_mf *restrict mf,
816
+       uint32_t *restrict back_res, uint32_t *restrict len_res,
817
+       uint32_t position)
818
+{
819
+   // If we have symbols pending, return the next pending symbol.
820
+   if (coder->opts_end_index != coder->opts_current_index) {
821
+       assert(mf->read_ahead > 0);
822
+       *len_res = coder->opts[coder->opts_current_index].pos_prev
823
+               - coder->opts_current_index;
824
+       *back_res = coder->opts[coder->opts_current_index].back_prev;
825
+       coder->opts_current_index = coder->opts[
826
+               coder->opts_current_index].pos_prev;
827
+       return;
828
+   }
829
+
830
+   // Update the price tables. In LZMA SDK <= 4.60 (and possibly later)
831
+   // this was done in both initialization function and in the main loop.
832
+   // In liblzma they were moved into this single place.
833
+   if (mf->read_ahead == 0) {
834
+       if (coder->match_price_count >= (1 << 7))
835
+           fill_distances_prices(coder);
836
+
837
+       if (coder->align_price_count >= ALIGN_TABLE_SIZE)
838
+           fill_align_prices(coder);
839
+   }
840
+
841
+   // TODO: This needs quite a bit of cleaning still. But splitting
842
+   // the original function into two pieces makes it at least a little
843
+   // more readable, since those two parts don't share many variables.
844
+
845
+   uint32_t len_end = helper1(coder, mf, back_res, len_res, position);
846
+   if (len_end == UINT32_MAX)
847
+       return;
848
+
849
+   uint32_t reps[REP_DISTANCES];
850
+   memcpy(reps, coder->reps, sizeof(reps));
851
+
852
+   uint32_t cur;
853
+   for (cur = 1; cur < len_end; ++cur) {
854
+       assert(cur < OPTS);
855
+
856
+       coder->longest_match_length = mf_find(
857
+               mf, &coder->matches_count, coder->matches);
858
+
859
+       if (coder->longest_match_length >= mf->nice_len)
860
+           break;
861
+
862
+       len_end = helper2(coder, reps, mf_ptr(mf) - 1, len_end,
863
+               position + cur, cur, mf->nice_len,
864
+               my_min(mf_avail(mf) + 1, OPTS - 1 - cur));
865
+   }
866
+
867
+   backward(coder, len_res, back_res, cur);
868
+   return;
869
+}
870
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_encoder_presets.c Added
65
 
1
@@ -0,0 +1,63 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_encoder_presets.c
5
+/// \brief      Encoder presets
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "common.h"
15
+
16
+
17
+extern LZMA_API(lzma_bool)
18
+lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)
19
+{
20
+   const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK;
21
+   const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK;
22
+   const uint32_t supported_flags = LZMA_PRESET_EXTREME;
23
+
24
+   if (level > 9 || (flags & ~supported_flags))
25
+       return true;
26
+
27
+   options->preset_dict = NULL;
28
+   options->preset_dict_size = 0;
29
+
30
+   options->lc = LZMA_LC_DEFAULT;
31
+   options->lp = LZMA_LP_DEFAULT;
32
+   options->pb = LZMA_PB_DEFAULT;
33
+
34
+   static const uint8_t dict_pow2[]
35
+           = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };
36
+   options->dict_size = UINT32_C(1) << dict_pow2[level];
37
+
38
+   if (level <= 3) {
39
+       options->mode = LZMA_MODE_FAST;
40
+       options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;
41
+       options->nice_len = level <= 1 ? 128 : 273;
42
+       static const uint8_t depths[] = { 4, 8, 24, 48 };
43
+       options->depth = depths[level];
44
+   } else {
45
+       options->mode = LZMA_MODE_NORMAL;
46
+       options->mf = LZMA_MF_BT4;
47
+       options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64;
48
+       options->depth = 0;
49
+   }
50
+
51
+   if (flags & LZMA_PRESET_EXTREME) {
52
+       options->mode = LZMA_MODE_NORMAL;
53
+       options->mf = LZMA_MF_BT4;
54
+       if (level == 3 || level == 5) {
55
+           options->nice_len = 192;
56
+           options->depth = 0;
57
+       } else {
58
+           options->nice_len = 273;
59
+           options->depth = 512;
60
+       }
61
+   }
62
+
63
+   return false;
64
+}
65
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/lzma/lzma_encoder_private.h Added
150
 
1
@@ -0,0 +1,148 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       lzma_encoder_private.h
5
+/// \brief      Private definitions for LZMA encoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_LZMA_ENCODER_PRIVATE_H
16
+#define LZMA_LZMA_ENCODER_PRIVATE_H
17
+
18
+#include "lz_encoder.h"
19
+#include "range_encoder.h"
20
+#include "lzma_common.h"
21
+#include "lzma_encoder.h"
22
+
23
+
24
+// Macro to compare if the first two bytes in two buffers differ. This is
25
+// needed in lzma_lzma_optimum_*() to test if the match is at least
26
+// MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no
27
+// reason to not use it when it is supported.
28
+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
29
+#  define not_equal_16(a, b) \
30
+       (*(const uint16_t *)(a) != *(const uint16_t *)(b))
31
+#else
32
+#  define not_equal_16(a, b) \
33
+       ((a)[0] != (b)[0] || (a)[1] != (b)[1])
34
+#endif
35
+
36
+
37
+// Optimal - Number of entries in the optimum array.
38
+#define OPTS (1 << 12)
39
+
40
+
41
+typedef struct {
42
+   probability choice;
43
+   probability choice2;
44
+   probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS];
45
+   probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS];
46
+   probability high[LEN_HIGH_SYMBOLS];
47
+
48
+   uint32_t prices[POS_STATES_MAX][LEN_SYMBOLS];
49
+   uint32_t table_size;
50
+   uint32_t counters[POS_STATES_MAX];
51
+
52
+} lzma_length_encoder;
53
+
54
+
55
+typedef struct {
56
+   lzma_lzma_state state;
57
+
58
+   bool prev_1_is_literal;
59
+   bool prev_2;
60
+
61
+   uint32_t pos_prev_2;
62
+   uint32_t back_prev_2;
63
+
64
+   uint32_t price;
65
+   uint32_t pos_prev;  // pos_next;
66
+   uint32_t back_prev;
67
+
68
+   uint32_t backs[REP_DISTANCES];
69
+
70
+} lzma_optimal;
71
+
72
+
73
+struct lzma_coder_s {
74
+   /// Range encoder
75
+   lzma_range_encoder rc;
76
+
77
+   /// State
78
+   lzma_lzma_state state;
79
+
80
+   /// The four most recent match distances
81
+   uint32_t reps[REP_DISTANCES];
82
+
83
+   /// Array of match candidates
84
+   lzma_match matches[MATCH_LEN_MAX + 1];
85
+
86
+   /// Number of match candidates in matches[]
87
+   uint32_t matches_count;
88
+
89
+   /// Variable to hold the length of the longest match between calls
90
+   /// to lzma_lzma_optimum_*().
91
+   uint32_t longest_match_length;
92
+
93
+   /// True if using getoptimumfast
94
+   bool fast_mode;
95
+
96
+   /// True if the encoder has been initialized by encoding the first
97
+   /// byte as a literal.
98
+   bool is_initialized;
99
+
100
+   /// True if the range encoder has been flushed, but not all bytes
101
+   /// have been written to the output buffer yet.
102
+   bool is_flushed;
103
+
104
+   uint32_t pos_mask;         ///< (1 << pos_bits) - 1
105
+   uint32_t literal_context_bits;
106
+   uint32_t literal_pos_mask;
107
+
108
+   // These are the same as in lzma_decoder.c. See comments there.
109
+   probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
110
+   probability is_match[STATES][POS_STATES_MAX];
111
+   probability is_rep[STATES];
112
+   probability is_rep0[STATES];
113
+   probability is_rep1[STATES];
114
+   probability is_rep2[STATES];
115
+   probability is_rep0_long[STATES][POS_STATES_MAX];
116
+   probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS];
117
+   probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX];
118
+   probability pos_align[ALIGN_TABLE_SIZE];
119
+
120
+   // These are the same as in lzma_decoder.c except that the encoders
121
+   // include also price tables.
122
+   lzma_length_encoder match_len_encoder;
123
+   lzma_length_encoder rep_len_encoder;
124
+
125
+   // Price tables
126
+   uint32_t pos_slot_prices[LEN_TO_POS_STATES][POS_SLOTS];
127
+   uint32_t distances_prices[LEN_TO_POS_STATES][FULL_DISTANCES];
128
+   uint32_t dist_table_size;
129
+   uint32_t match_price_count;
130
+
131
+   uint32_t align_prices[ALIGN_TABLE_SIZE];
132
+   uint32_t align_price_count;
133
+
134
+   // Optimal
135
+   uint32_t opts_end_index;
136
+   uint32_t opts_current_index;
137
+   lzma_optimal opts[OPTS];
138
+};
139
+
140
+
141
+extern void lzma_lzma_optimum_fast(
142
+       lzma_coder *restrict coder, lzma_mf *restrict mf,
143
+       uint32_t *restrict back_res, uint32_t *restrict len_res);
144
+
145
+extern void lzma_lzma_optimum_normal(lzma_coder *restrict coder,
146
+       lzma_mf *restrict mf, uint32_t *restrict back_res,
147
+       uint32_t *restrict len_res, uint32_t position);
148
+
149
+#endif
150
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/Makefile.inc Added
23
 
1
@@ -0,0 +1,21 @@
2
+##
3
+## Author: Lasse Collin
4
+##
5
+## This file has been put into the public domain.
6
+## You can do whatever you want with this file.
7
+##
8
+
9
+EXTRA_DIST += rangecoder/price_tablegen.c
10
+
11
+liblzma_la_SOURCES += rangecoder/range_common.h
12
+
13
+if COND_ENCODER_LZMA1
14
+liblzma_la_SOURCES += \
15
+   rangecoder/range_encoder.h \
16
+   rangecoder/price.h \
17
+   rangecoder/price_table.c
18
+endif
19
+
20
+if COND_DECODER_LZMA1
21
+liblzma_la_SOURCES += rangecoder/range_decoder.h
22
+endif
23
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/price.h Added
94
 
1
@@ -0,0 +1,92 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       price.h
5
+/// \brief      Probability price calculation
6
+//
7
+//  Author:     Igor Pavlov
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_PRICE_H
15
+#define LZMA_PRICE_H
16
+
17
+
18
+#define RC_MOVE_REDUCING_BITS 4
19
+#define RC_BIT_PRICE_SHIFT_BITS 4
20
+#define RC_PRICE_TABLE_SIZE (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS)
21
+
22
+#define RC_INFINITY_PRICE (UINT32_C(1) << 30)
23
+
24
+
25
+/// Lookup table for the inline functions defined in this file.
26
+extern const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE];
27
+
28
+
29
+static inline uint32_t
30
+rc_bit_price(const probability prob, const uint32_t bit)
31
+{
32
+   return lzma_rc_prices[(prob ^ ((UINT32_C(0) - bit)
33
+           & (RC_BIT_MODEL_TOTAL - 1))) >> RC_MOVE_REDUCING_BITS];
34
+}
35
+
36
+
37
+static inline uint32_t
38
+rc_bit_0_price(const probability prob)
39
+{
40
+   return lzma_rc_prices[prob >> RC_MOVE_REDUCING_BITS];
41
+}
42
+
43
+
44
+static inline uint32_t
45
+rc_bit_1_price(const probability prob)
46
+{
47
+   return lzma_rc_prices[(prob ^ (RC_BIT_MODEL_TOTAL - 1))
48
+           >> RC_MOVE_REDUCING_BITS];
49
+}
50
+
51
+
52
+static inline uint32_t
53
+rc_bittree_price(const probability *const probs,
54
+       const uint32_t bit_levels, uint32_t symbol)
55
+{
56
+   uint32_t price = 0;
57
+   symbol += UINT32_C(1) << bit_levels;
58
+
59
+   do {
60
+       const uint32_t bit = symbol & 1;
61
+       symbol >>= 1;
62
+       price += rc_bit_price(probs[symbol], bit);
63
+   } while (symbol != 1);
64
+
65
+   return price;
66
+}
67
+
68
+
69
+static inline uint32_t
70
+rc_bittree_reverse_price(const probability *const probs,
71
+       uint32_t bit_levels, uint32_t symbol)
72
+{
73
+   uint32_t price = 0;
74
+   uint32_t model_index = 1;
75
+
76
+   do {
77
+       const uint32_t bit = symbol & 1;
78
+       symbol >>= 1;
79
+       price += rc_bit_price(probs[model_index], bit);
80
+       model_index = (model_index << 1) + bit;
81
+   } while (--bit_levels != 0);
82
+
83
+   return price;
84
+}
85
+
86
+
87
+static inline uint32_t
88
+rc_direct_price(const uint32_t bits)
89
+{
90
+    return bits << RC_BIT_PRICE_SHIFT_BITS;
91
+}
92
+
93
+#endif
94
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/price_table.c Added
24
 
1
@@ -0,0 +1,22 @@
2
+/* This file has been automatically generated by price_tablegen.c. */
3
+
4
+#include "range_encoder.h"
5
+
6
+const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE] = {
7
+    128, 103,  91,  84,  78,  73,  69,  66,
8
+     63,  61,  58,  56,  54,  52,  51,  49,
9
+     48,  46,  45,  44,  43,  42,  41,  40,
10
+     39,  38,  37,  36,  35,  34,  34,  33,
11
+     32,  31,  31,  30,  29,  29,  28,  28,
12
+     27,  26,  26,  25,  25,  24,  24,  23,
13
+     23,  22,  22,  22,  21,  21,  20,  20,
14
+     19,  19,  19,  18,  18,  17,  17,  17,
15
+     16,  16,  16,  15,  15,  15,  14,  14,
16
+     14,  13,  13,  13,  12,  12,  12,  11,
17
+     11,  11,  11,  10,  10,  10,  10,   9,
18
+      9,   9,   9,   8,   8,   8,   8,   7,
19
+      7,   7,   7,   6,   6,   6,   6,   5,
20
+      5,   5,   5,   5,   4,   4,   4,   4,
21
+      3,   3,   3,   3,   3,   2,   2,   2,
22
+      2,   2,   2,   1,   1,   1,   1,   1
23
+};
24
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/price_tablegen.c Added
89
 
1
@@ -0,0 +1,87 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       price_tablegen.c
5
+/// \brief      Probability price table generator
6
+///
7
+/// Compiling: gcc -std=c99 -o price_tablegen price_tablegen.c
8
+///
9
+//  Authors:    Igor Pavlov
10
+//              Lasse Collin
11
+//
12
+//  This file has been put into the public domain.
13
+//  You can do whatever you want with this file.
14
+//
15
+///////////////////////////////////////////////////////////////////////////////
16
+
17
+#include <inttypes.h>
18
+#include <stdio.h>
19
+#include "range_common.h"
20
+#include "price.h"
21
+
22
+
23
+static uint32_t rc_prices[RC_PRICE_TABLE_SIZE];
24
+
25
+
26
+static void
27
+init_price_table(void)
28
+{
29
+   for (uint32_t i = (UINT32_C(1) << RC_MOVE_REDUCING_BITS) / 2;
30
+           i < RC_BIT_MODEL_TOTAL;
31
+           i += (UINT32_C(1) << RC_MOVE_REDUCING_BITS)) {
32
+       const uint32_t cycles_bits = RC_BIT_PRICE_SHIFT_BITS;
33
+       uint32_t w = i;
34
+       uint32_t bit_count = 0;
35
+
36
+       for (uint32_t j = 0; j < cycles_bits; ++j) {
37
+           w *= w;
38
+           bit_count <<= 1;
39
+
40
+           while (w >= (UINT32_C(1) << 16)) {
41
+               w >>= 1;
42
+               ++bit_count;
43
+           }
44
+       }
45
+
46
+       rc_prices[i >> RC_MOVE_REDUCING_BITS]
47
+               = (RC_BIT_MODEL_TOTAL_BITS << cycles_bits)
48
+               - 15 - bit_count;
49
+   }
50
+
51
+   return;
52
+}
53
+
54
+
55
+static void
56
+print_price_table(void)
57
+{
58
+   printf("/* This file has been automatically generated by "
59
+           "price_tablegen.c. */\n\n"
60
+           "#include \"range_encoder.h\"\n\n"
61
+           "const uint8_t lzma_rc_prices["
62
+           "RC_PRICE_TABLE_SIZE] = {");
63
+
64
+   const size_t array_size = sizeof(lzma_rc_prices)
65
+           / sizeof(lzma_rc_prices[0]);
66
+   for (size_t i = 0; i < array_size; ++i) {
67
+       if (i % 8 == 0)
68
+           printf("\n\t");
69
+
70
+       printf("%4" PRIu32, rc_prices[i]);
71
+
72
+       if (i != array_size - 1)
73
+           printf(",");
74
+   }
75
+
76
+   printf("\n};\n");
77
+
78
+   return;
79
+}
80
+
81
+
82
+int
83
+main(void)
84
+{
85
+   init_price_table();
86
+   print_price_table();
87
+   return 0;
88
+}
89
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/range_common.h Added
75
 
1
@@ -0,0 +1,73 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       range_common.h
5
+/// \brief      Common things for range encoder and decoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_RANGE_COMMON_H
16
+#define LZMA_RANGE_COMMON_H
17
+
18
+#ifdef HAVE_CONFIG_H
19
+#  include "common.h"
20
+#endif
21
+
22
+
23
+///////////////
24
+// Constants //
25
+///////////////
26
+
27
+#define RC_SHIFT_BITS 8
28
+#define RC_TOP_BITS 24
29
+#define RC_TOP_VALUE (UINT32_C(1) << RC_TOP_BITS)
30
+#define RC_BIT_MODEL_TOTAL_BITS 11
31
+#define RC_BIT_MODEL_TOTAL (UINT32_C(1) << RC_BIT_MODEL_TOTAL_BITS)
32
+#define RC_MOVE_BITS 5
33
+
34
+
35
+////////////
36
+// Macros //
37
+////////////
38
+
39
+// Resets the probability so that both 0 and 1 have probability of 50 %
40
+#define bit_reset(prob) \
41
+   prob = RC_BIT_MODEL_TOTAL >> 1
42
+
43
+// This does the same for a complete bit tree.
44
+// (A tree represented as an array.)
45
+#define bittree_reset(probs, bit_levels) \
46
+   for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \
47
+       bit_reset((probs)[bt_i])
48
+
49
+
50
+//////////////////////
51
+// Type definitions //
52
+//////////////////////
53
+
54
+/// \brief      Type of probabilities used with range coder
55
+///
56
+/// This needs to be at least 12-bit integer, so uint16_t is a logical choice.
57
+/// However, on some architecture and compiler combinations, a bigger type
58
+/// may give better speed, because the probability variables are accessed
59
+/// a lot. On the other hand, bigger probability type increases cache
60
+/// footprint, since there are 2 to 14 thousand probability variables in
61
+/// LZMA (assuming the limit of lc + lp <= 4; with lc + lp <= 12 there
62
+/// would be about 1.5 million variables).
63
+///
64
+/// With malicious files, the initialization speed of the LZMA decoder can
65
+/// become important. In that case, smaller probability variables mean that
66
+/// there is less bytes to write to RAM, which makes initialization faster.
67
+/// With big probability type, the initialization can become so slow that it
68
+/// can be a problem e.g. for email servers doing virus scanning.
69
+///
70
+/// I will be sticking to uint16_t unless some specific architectures
71
+/// are *much* faster (20-50 %) with uint32_t.
72
+typedef uint16_t probability;
73
+
74
+#endif
75
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/range_decoder.h Added
181
 
1
@@ -0,0 +1,179 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       range_decoder.h
5
+/// \brief      Range Decoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_RANGE_DECODER_H
16
+#define LZMA_RANGE_DECODER_H
17
+
18
+#include "range_common.h"
19
+
20
+
21
+typedef struct {
22
+   uint32_t range;
23
+   uint32_t code;
24
+   uint32_t init_bytes_left;
25
+} lzma_range_decoder;
26
+
27
+
28
+/// Reads the first five bytes to initialize the range decoder.
29
+static inline bool
30
+rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in,
31
+       size_t *restrict in_pos, size_t in_size)
32
+{
33
+   while (rc->init_bytes_left > 0) {
34
+       if (*in_pos == in_size)
35
+           return false;
36
+
37
+       rc->code = (rc->code << 8) | in[*in_pos];
38
+       ++*in_pos;
39
+       --rc->init_bytes_left;
40
+   }
41
+
42
+   return true;
43
+}
44
+
45
+
46
+/// Makes local copies of range decoder and *in_pos variables. Doing this
47
+/// improves speed significantly. The range decoder macros expect also
48
+/// variables `in' and `in_size' to be defined.
49
+#define rc_to_local(range_decoder, in_pos) \
50
+   lzma_range_decoder rc = range_decoder; \
51
+   size_t rc_in_pos = (in_pos); \
52
+   uint32_t rc_bound
53
+
54
+
55
+/// Stores the local copes back to the range decoder structure.
56
+#define rc_from_local(range_decoder, in_pos) \
57
+do { \
58
+   range_decoder = rc; \
59
+   in_pos = rc_in_pos; \
60
+} while (0)
61
+
62
+
63
+/// Resets the range decoder structure.
64
+#define rc_reset(range_decoder) \
65
+do { \
66
+   (range_decoder).range = UINT32_MAX; \
67
+   (range_decoder).code = 0; \
68
+   (range_decoder).init_bytes_left = 5; \
69
+} while (0)
70
+
71
+
72
+/// When decoding has been properly finished, rc.code is always zero unless
73
+/// the input stream is corrupt. So checking this can catch some corrupt
74
+/// files especially if they don't have any other integrity check.
75
+#define rc_is_finished(range_decoder) \
76
+   ((range_decoder).code == 0)
77
+
78
+
79
+/// Read the next input byte if needed. If more input is needed but there is
80
+/// no more input available, "goto out" is used to jump out of the main
81
+/// decoder loop.
82
+#define rc_normalize(seq) \
83
+do { \
84
+   if (rc.range < RC_TOP_VALUE) { \
85
+       if (unlikely(rc_in_pos == in_size)) { \
86
+           coder->sequence = seq; \
87
+           goto out; \
88
+       } \
89
+       rc.range <<= RC_SHIFT_BITS; \
90
+       rc.code = (rc.code << RC_SHIFT_BITS) | in[rc_in_pos++]; \
91
+   } \
92
+} while (0)
93
+
94
+
95
+/// Start decoding a bit. This must be used together with rc_update_0()
96
+/// and rc_update_1():
97
+///
98
+///     rc_if_0(prob, seq) {
99
+///         rc_update_0(prob);
100
+///         // Do something
101
+///     } else {
102
+///         rc_update_1(prob);
103
+///         // Do something else
104
+///     }
105
+///
106
+#define rc_if_0(prob, seq) \
107
+   rc_normalize(seq); \
108
+   rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * (prob); \
109
+   if (rc.code < rc_bound)
110
+
111
+
112
+/// Update the range decoder state and the used probability variable to
113
+/// match a decoded bit of 0.
114
+#define rc_update_0(prob) \
115
+do { \
116
+   rc.range = rc_bound; \
117
+   prob += (RC_BIT_MODEL_TOTAL - (prob)) >> RC_MOVE_BITS; \
118
+} while (0)
119
+
120
+
121
+/// Update the range decoder state and the used probability variable to
122
+/// match a decoded bit of 1.
123
+#define rc_update_1(prob) \
124
+do { \
125
+   rc.range -= rc_bound; \
126
+   rc.code -= rc_bound; \
127
+   prob -= (prob) >> RC_MOVE_BITS; \
128
+} while (0)
129
+
130
+
131
+/// Decodes one bit and runs action0 or action1 depending on the decoded bit.
132
+/// This macro is used as the last step in bittree reverse decoders since
133
+/// those don't use "symbol" for anything else than indexing the probability
134
+/// arrays.
135
+#define rc_bit_last(prob, action0, action1, seq) \
136
+do { \
137
+   rc_if_0(prob, seq) { \
138
+       rc_update_0(prob); \
139
+       action0; \
140
+   } else { \
141
+       rc_update_1(prob); \
142
+       action1; \
143
+   } \
144
+} while (0)
145
+
146
+
147
+/// Decodes one bit, updates "symbol", and runs action0 or action1 depending
148
+/// on the decoded bit.
149
+#define rc_bit(prob, action0, action1, seq) \
150
+   rc_bit_last(prob, \
151
+       symbol <<= 1; action0, \
152
+       symbol = (symbol << 1) + 1; action1, \
153
+       seq);
154
+
155
+
156
+/// Like rc_bit() but add "case seq:" as a prefix. This makes the unrolled
157
+/// loops more readable because the code isn't littered with "case"
158
+/// statements. On the other hand this also makes it less readable, since
159
+/// spotting the places where the decoder loop may be restarted is less
160
+/// obvious.
161
+#define rc_bit_case(prob, action0, action1, seq) \
162
+   case seq: rc_bit(prob, action0, action1, seq)
163
+
164
+
165
+/// Decode a bit without using a probability.
166
+#define rc_direct(dest, seq) \
167
+do { \
168
+   rc_normalize(seq); \
169
+   rc.range >>= 1; \
170
+   rc.code -= rc.range; \
171
+   rc_bound = UINT32_C(0) - (rc.code >> 31); \
172
+   rc.code += rc.range & rc_bound; \
173
+   dest = (dest << 1) + (rc_bound + 1); \
174
+} while (0)
175
+
176
+
177
+// NOTE: No macros are provided for bittree decoding. It seems to be simpler
178
+// to just write them open in the code.
179
+
180
+#endif
181
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/rangecoder/range_encoder.h Added
233
 
1
@@ -0,0 +1,231 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       range_encoder.h
5
+/// \brief      Range Encoder
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#ifndef LZMA_RANGE_ENCODER_H
16
+#define LZMA_RANGE_ENCODER_H
17
+
18
+#include "range_common.h"
19
+#include "price.h"
20
+
21
+
22
+/// Maximum number of symbols that can be put pending into lzma_range_encoder
23
+/// structure between calls to lzma_rc_encode(). For LZMA, 52+5 is enough
24
+/// (match with big distance and length followed by range encoder flush).
25
+#define RC_SYMBOLS_MAX 58
26
+
27
+
28
+typedef struct {
29
+   uint64_t low;
30
+   uint64_t cache_size;
31
+   uint32_t range;
32
+   uint8_t cache;
33
+
34
+   /// Number of symbols in the tables
35
+   size_t count;
36
+
37
+   /// rc_encode()'s position in the tables
38
+   size_t pos;
39
+
40
+   /// Symbols to encode
41
+   enum {
42
+       RC_BIT_0,
43
+       RC_BIT_1,
44
+       RC_DIRECT_0,
45
+       RC_DIRECT_1,
46
+       RC_FLUSH,
47
+   } symbols[RC_SYMBOLS_MAX];
48
+
49
+   /// Probabilities associated with RC_BIT_0 or RC_BIT_1
50
+   probability *probs[RC_SYMBOLS_MAX];
51
+
52
+} lzma_range_encoder;
53
+
54
+
55
+static inline void
56
+rc_reset(lzma_range_encoder *rc)
57
+{
58
+   rc->low = 0;
59
+   rc->cache_size = 1;
60
+   rc->range = UINT32_MAX;
61
+   rc->cache = 0;
62
+   rc->count = 0;
63
+   rc->pos = 0;
64
+}
65
+
66
+
67
+static inline void
68
+rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit)
69
+{
70
+   rc->symbols[rc->count] = bit;
71
+   rc->probs[rc->count] = prob;
72
+   ++rc->count;
73
+}
74
+
75
+
76
+static inline void
77
+rc_bittree(lzma_range_encoder *rc, probability *probs,
78
+       uint32_t bit_count, uint32_t symbol)
79
+{
80
+   uint32_t model_index = 1;
81
+
82
+   do {
83
+       const uint32_t bit = (symbol >> --bit_count) & 1;
84
+       rc_bit(rc, &probs[model_index], bit);
85
+       model_index = (model_index << 1) + bit;
86
+   } while (bit_count != 0);
87
+}
88
+
89
+
90
+static inline void
91
+rc_bittree_reverse(lzma_range_encoder *rc, probability *probs,
92
+       uint32_t bit_count, uint32_t symbol)
93
+{
94
+   uint32_t model_index = 1;
95
+
96
+   do {
97
+       const uint32_t bit = symbol & 1;
98
+       symbol >>= 1;
99
+       rc_bit(rc, &probs[model_index], bit);
100
+       model_index = (model_index << 1) + bit;
101
+   } while (--bit_count != 0);
102
+}
103
+
104
+
105
+static inline void
106
+rc_direct(lzma_range_encoder *rc,
107
+       uint32_t value, uint32_t bit_count)
108
+{
109
+   do {
110
+       rc->symbols[rc->count++]
111
+               = RC_DIRECT_0 + ((value >> --bit_count) & 1);
112
+   } while (bit_count != 0);
113
+}
114
+
115
+
116
+static inline void
117
+rc_flush(lzma_range_encoder *rc)
118
+{
119
+   for (size_t i = 0; i < 5; ++i)
120
+       rc->symbols[rc->count++] = RC_FLUSH;
121
+}
122
+
123
+
124
+static inline bool
125
+rc_shift_low(lzma_range_encoder *rc,
126
+       uint8_t *out, size_t *out_pos, size_t out_size)
127
+{
128
+   if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000)
129
+           || (uint32_t)(rc->low >> 32) != 0) {
130
+       do {
131
+           if (*out_pos == out_size)
132
+               return true;
133
+
134
+           out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32);
135
+           ++*out_pos;
136
+           rc->cache = 0xFF;
137
+
138
+       } while (--rc->cache_size != 0);
139
+
140
+       rc->cache = (rc->low >> 24) & 0xFF;
141
+   }
142
+
143
+   ++rc->cache_size;
144
+   rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS;
145
+
146
+   return false;
147
+}
148
+
149
+
150
+static inline bool
151
+rc_encode(lzma_range_encoder *rc,
152
+       uint8_t *out, size_t *out_pos, size_t out_size)
153
+{
154
+   assert(rc->count <= RC_SYMBOLS_MAX);
155
+
156
+   while (rc->pos < rc->count) {
157
+       // Normalize
158
+       if (rc->range < RC_TOP_VALUE) {
159
+           if (rc_shift_low(rc, out, out_pos, out_size))
160
+               return true;
161
+
162
+           rc->range <<= RC_SHIFT_BITS;
163
+       }
164
+
165
+       // Encode a bit
166
+       switch (rc->symbols[rc->pos]) {
167
+       case RC_BIT_0: {
168
+           probability prob = *rc->probs[rc->pos];
169
+           rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS)
170
+                   * prob;
171
+           prob += (RC_BIT_MODEL_TOTAL - prob) >> RC_MOVE_BITS;
172
+           *rc->probs[rc->pos] = prob;
173
+           break;
174
+       }
175
+
176
+       case RC_BIT_1: {
177
+           probability prob = *rc->probs[rc->pos];
178
+           const uint32_t bound = prob * (rc->range
179
+                   >> RC_BIT_MODEL_TOTAL_BITS);
180
+           rc->low += bound;
181
+           rc->range -= bound;
182
+           prob -= prob >> RC_MOVE_BITS;
183
+           *rc->probs[rc->pos] = prob;
184
+           break;
185
+       }
186
+
187
+       case RC_DIRECT_0:
188
+           rc->range >>= 1;
189
+           break;
190
+
191
+       case RC_DIRECT_1:
192
+           rc->range >>= 1;
193
+           rc->low += rc->range;
194
+           break;
195
+
196
+       case RC_FLUSH:
197
+           // Prevent further normalizations.
198
+           rc->range = UINT32_MAX;
199
+
200
+           // Flush the last five bytes (see rc_flush()).
201
+           do {
202
+               if (rc_shift_low(rc, out, out_pos, out_size))
203
+                   return true;
204
+           } while (++rc->pos < rc->count);
205
+
206
+           // Reset the range encoder so we are ready to continue
207
+           // encoding if we weren't finishing the stream.
208
+           rc_reset(rc);
209
+           return false;
210
+
211
+       default:
212
+           assert(0);
213
+           break;
214
+       }
215
+
216
+       ++rc->pos;
217
+   }
218
+
219
+   rc->count = 0;
220
+   rc->pos = 0;
221
+
222
+   return false;
223
+}
224
+
225
+
226
+static inline uint64_t
227
+rc_pending(const lzma_range_encoder *rc)
228
+{
229
+   return rc->cache_size + 5 - 1;
230
+}
231
+
232
+#endif
233
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple Added
2
 
1
+(directory)
2
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/Makefile.inc Added
49
 
1
@@ -0,0 +1,47 @@
2
+##
3
+## Author: Lasse Collin
4
+##
5
+## This file has been put into the public domain.
6
+## You can do whatever you want with this file.
7
+##
8
+
9
+liblzma_la_SOURCES += \
10
+   simple/simple_coder.c \
11
+   simple/simple_coder.h \
12
+   simple/simple_private.h
13
+
14
+if COND_ENCODER_SIMPLE
15
+liblzma_la_SOURCES += \
16
+   simple/simple_encoder.c \
17
+   simple/simple_encoder.h
18
+endif
19
+
20
+if COND_DECODER_SIMPLE
21
+liblzma_la_SOURCES += \
22
+   simple/simple_decoder.c \
23
+   simple/simple_decoder.h
24
+endif
25
+
26
+if COND_FILTER_X86
27
+liblzma_la_SOURCES += simple/x86.c
28
+endif
29
+
30
+if COND_FILTER_POWERPC
31
+liblzma_la_SOURCES += simple/powerpc.c
32
+endif
33
+
34
+if COND_FILTER_IA64
35
+liblzma_la_SOURCES += simple/ia64.c
36
+endif
37
+
38
+if COND_FILTER_ARM
39
+liblzma_la_SOURCES += simple/arm.c
40
+endif
41
+
42
+if COND_FILTER_ARMTHUMB
43
+liblzma_la_SOURCES += simple/armthumb.c
44
+endif
45
+
46
+if COND_FILTER_SPARC
47
+liblzma_la_SOURCES += simple/sparc.c
48
+endif
49
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/arm.c Added
71
 
1
@@ -0,0 +1,69 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       arm.c
5
+/// \brief      Filter for ARM binaries
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "simple_private.h"
16
+
17
+
18
+static size_t
19
+arm_code(lzma_simple *simple lzma_attribute((__unused__)),
20
+       uint32_t now_pos, bool is_encoder,
21
+       uint8_t *buffer, size_t size)
22
+{
23
+   size_t i;
24
+   for (i = 0; i + 4 <= size; i += 4) {
25
+       if (buffer[i + 3] == 0xEB) {
26
+           uint32_t src = (buffer[i + 2] << 16)
27
+                   | (buffer[i + 1] << 8)
28
+                   | (buffer[i + 0]);
29
+           src <<= 2;
30
+
31
+           uint32_t dest;
32
+           if (is_encoder)
33
+               dest = now_pos + (uint32_t)(i) + 8 + src;
34
+           else
35
+               dest = src - (now_pos + (uint32_t)(i) + 8);
36
+
37
+           dest >>= 2;
38
+           buffer[i + 2] = (dest >> 16);
39
+           buffer[i + 1] = (dest >> 8);
40
+           buffer[i + 0] = dest;
41
+       }
42
+   }
43
+
44
+   return i;
45
+}
46
+
47
+
48
+static lzma_ret
49
+arm_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
50
+       const lzma_filter_info *filters, bool is_encoder)
51
+{
52
+   return lzma_simple_coder_init(next, allocator, filters,
53
+           &arm_code, 0, 4, 4, is_encoder);
54
+}
55
+
56
+
57
+extern lzma_ret
58
+lzma_simple_arm_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
59
+       const lzma_filter_info *filters)
60
+{
61
+   return arm_coder_init(next, allocator, filters, true);
62
+}
63
+
64
+
65
+extern lzma_ret
66
+lzma_simple_arm_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
67
+       const lzma_filter_info *filters)
68
+{
69
+   return arm_coder_init(next, allocator, filters, false);
70
+}
71
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/armthumb.c Added
76
 
1
@@ -0,0 +1,74 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       armthumb.c
5
+/// \brief      Filter for ARM-Thumb binaries
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "simple_private.h"
16
+
17
+
18
+static size_t
19
+armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
20
+       uint32_t now_pos, bool is_encoder,
21
+       uint8_t *buffer, size_t size)
22
+{
23
+   size_t i;
24
+   for (i = 0; i + 4 <= size; i += 2) {
25
+       if ((buffer[i + 1] & 0xF8) == 0xF0
26
+               && (buffer[i + 3] & 0xF8) == 0xF8) {
27
+           uint32_t src = ((buffer[i + 1] & 0x7) << 19)
28
+                   | (buffer[i + 0] << 11)
29
+                   | ((buffer[i + 3] & 0x7) << 8)
30
+                   | (buffer[i + 2]);
31
+
32
+           src <<= 1;
33
+
34
+           uint32_t dest;
35
+           if (is_encoder)
36
+               dest = now_pos + (uint32_t)(i) + 4 + src;
37
+           else
38
+               dest = src - (now_pos + (uint32_t)(i) + 4);
39
+
40
+           dest >>= 1;
41
+           buffer[i + 1] = 0xF0 | ((dest >> 19) & 0x7);
42
+           buffer[i + 0] = (dest >> 11);
43
+           buffer[i + 3] = 0xF8 | ((dest >> 8) & 0x7);
44
+           buffer[i + 2] = (dest);
45
+           i += 2;
46
+       }
47
+   }
48
+
49
+   return i;
50
+}
51
+
52
+
53
+static lzma_ret
54
+armthumb_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
55
+       const lzma_filter_info *filters, bool is_encoder)
56
+{
57
+   return lzma_simple_coder_init(next, allocator, filters,
58
+           &armthumb_code, 0, 4, 2, is_encoder);
59
+}
60
+
61
+
62
+extern lzma_ret
63
+lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
64
+       lzma_allocator *allocator, const lzma_filter_info *filters)
65
+{
66
+   return armthumb_coder_init(next, allocator, filters, true);
67
+}
68
+
69
+
70
+extern lzma_ret
71
+lzma_simple_armthumb_decoder_init(lzma_next_coder *next,
72
+       lzma_allocator *allocator, const lzma_filter_info *filters)
73
+{
74
+   return armthumb_coder_init(next, allocator, filters, false);
75
+}
76
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/ia64.c Added
112
 
1
@@ -0,0 +1,110 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       ia64.c
5
+/// \brief      Filter for IA64 (Itanium) binaries
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "simple_private.h"
16
+
17
+
18
+static size_t
19
+ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
20
+       uint32_t now_pos, bool is_encoder,
21
+       uint8_t *buffer, size_t size)
22
+{
23
+   static const uint32_t BRANCH_TABLE[32] = {
24
+       0, 0, 0, 0, 0, 0, 0, 0,
25
+       0, 0, 0, 0, 0, 0, 0, 0,
26
+       4, 4, 6, 6, 0, 0, 7, 7,
27
+       4, 4, 0, 0, 4, 4, 0, 0
28
+   };
29
+
30
+   size_t i;
31
+   for (i = 0; i + 16 <= size; i += 16) {
32
+       const uint32_t instr_template = buffer[i] & 0x1F;
33
+       const uint32_t mask = BRANCH_TABLE[instr_template];
34
+       uint32_t bit_pos = 5;
35
+
36
+       for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) {
37
+           if (((mask >> slot) & 1) == 0)
38
+               continue;
39
+
40
+           const size_t byte_pos = (bit_pos >> 3);
41
+           const uint32_t bit_res = bit_pos & 0x7;
42
+           uint64_t instruction = 0;
43
+
44
+           for (size_t j = 0; j < 6; ++j)
45
+               instruction += (uint64_t)(
46
+                       buffer[i + j + byte_pos])
47
+                       << (8 * j);
48
+
49
+           uint64_t inst_norm = instruction >> bit_res;
50
+
51
+           if (((inst_norm >> 37) & 0xF) == 0x5
52
+                   && ((inst_norm >> 9) & 0x7) == 0
53
+                   /* &&  (inst_norm & 0x3F)== 0 */
54
+                   ) {
55
+               uint32_t src = (uint32_t)(
56
+                       (inst_norm >> 13) & 0xFFFFF);
57
+               src |= ((inst_norm >> 36) & 1) << 20;
58
+
59
+               src <<= 4;
60
+
61
+               uint32_t dest;
62
+               if (is_encoder)
63
+                   dest = now_pos + (uint32_t)(i) + src;
64
+               else
65
+                   dest = src - (now_pos + (uint32_t)(i));
66
+
67
+               dest >>= 4;
68
+
69
+               inst_norm &= ~((uint64_t)(0x8FFFFF) << 13);
70
+               inst_norm |= (uint64_t)(dest & 0xFFFFF) << 13;
71
+               inst_norm |= (uint64_t)(dest & 0x100000)
72
+                       << (36 - 20);
73
+
74
+               instruction &= (1 << bit_res) - 1;
75
+               instruction |= (inst_norm << bit_res);
76
+
77
+               for (size_t j = 0; j < 6; j++)
78
+                   buffer[i + j + byte_pos] = (uint8_t)(
79
+                           instruction
80
+                           >> (8 * j));
81
+           }
82
+       }
83
+   }
84
+
85
+   return i;
86
+}
87
+
88
+
89
+static lzma_ret
90
+ia64_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
91
+       const lzma_filter_info *filters, bool is_encoder)
92
+{
93
+   return lzma_simple_coder_init(next, allocator, filters,
94
+           &ia64_code, 0, 16, 16, is_encoder);
95
+}
96
+
97
+
98
+extern lzma_ret
99
+lzma_simple_ia64_encoder_init(lzma_next_coder *next,
100
+       lzma_allocator *allocator, const lzma_filter_info *filters)
101
+{
102
+   return ia64_coder_init(next, allocator, filters, true);
103
+}
104
+
105
+
106
+extern lzma_ret
107
+lzma_simple_ia64_decoder_init(lzma_next_coder *next,
108
+       lzma_allocator *allocator, const lzma_filter_info *filters)
109
+{
110
+   return ia64_coder_init(next, allocator, filters, false);
111
+}
112
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/powerpc.c Added
75
 
1
@@ -0,0 +1,73 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       powerpc.c
5
+/// \brief      Filter for PowerPC (big endian) binaries
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "simple_private.h"
16
+
17
+
18
+static size_t
19
+powerpc_code(lzma_simple *simple lzma_attribute((__unused__)),
20
+       uint32_t now_pos, bool is_encoder,
21
+       uint8_t *buffer, size_t size)
22
+{
23
+   size_t i;
24
+   for (i = 0; i + 4 <= size; i += 4) {
25
+       // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link)
26
+       if ((buffer[i] >> 2) == 0x12
27
+               && ((buffer[i + 3] & 3) == 1)) {
28
+
29
+           const uint32_t src = ((buffer[i + 0] & 3) << 24)
30
+                   | (buffer[i + 1] << 16)
31
+                   | (buffer[i + 2] << 8)
32
+                   | (buffer[i + 3] & (~3));
33
+
34
+           uint32_t dest;
35
+           if (is_encoder)
36
+               dest = now_pos + (uint32_t)(i) + src;
37
+           else
38
+               dest = src - (now_pos + (uint32_t)(i));
39
+
40
+           buffer[i + 0] = 0x48 | ((dest >> 24) &  0x03);
41
+           buffer[i + 1] = (dest >> 16);
42
+           buffer[i + 2] = (dest >> 8);
43
+           buffer[i + 3] &= 0x03;
44
+           buffer[i + 3] |= dest;
45
+       }
46
+   }
47
+
48
+   return i;
49
+}
50
+
51
+
52
+static lzma_ret
53
+powerpc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
54
+       const lzma_filter_info *filters, bool is_encoder)
55
+{
56
+   return lzma_simple_coder_init(next, allocator, filters,
57
+           &powerpc_code, 0, 4, 4, is_encoder);
58
+}
59
+
60
+
61
+extern lzma_ret
62
+lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
63
+       lzma_allocator *allocator, const lzma_filter_info *filters)
64
+{
65
+   return powerpc_coder_init(next, allocator, filters, true);
66
+}
67
+
68
+
69
+extern lzma_ret
70
+lzma_simple_powerpc_decoder_init(lzma_next_coder *next,
71
+       lzma_allocator *allocator, const lzma_filter_info *filters)
72
+{
73
+   return powerpc_coder_init(next, allocator, filters, false);
74
+}
75
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_coder.c Added
279
 
1
@@ -0,0 +1,277 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_coder.c
5
+/// \brief      Wrapper for simple filters
6
+///
7
+/// Simple filters don't change the size of the data i.e. number of bytes
8
+/// in equals the number of bytes out.
9
+//
10
+//  Author:     Lasse Collin
11
+//
12
+//  This file has been put into the public domain.
13
+//  You can do whatever you want with this file.
14
+//
15
+///////////////////////////////////////////////////////////////////////////////
16
+
17
+#include "simple_private.h"
18
+
19
+
20
+/// Copied or encodes/decodes more data to out[].
21
+static lzma_ret
22
+copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
23
+       const uint8_t *restrict in, size_t *restrict in_pos,
24
+       size_t in_size, uint8_t *restrict out,
25
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
26
+{
27
+   assert(!coder->end_was_reached);
28
+
29
+   if (coder->next.code == NULL) {
30
+       lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size);
31
+
32
+       // Check if end of stream was reached.
33
+       if (coder->is_encoder && action == LZMA_FINISH
34
+               && *in_pos == in_size)
35
+           coder->end_was_reached = true;
36
+
37
+   } else {
38
+       // Call the next coder in the chain to provide us some data.
39
+       const lzma_ret ret = coder->next.code(
40
+               coder->next.coder, allocator,
41
+               in, in_pos, in_size,
42
+               out, out_pos, out_size, action);
43
+
44
+       if (ret == LZMA_STREAM_END) {
45
+           assert(!coder->is_encoder
46
+                   || action == LZMA_FINISH);
47
+           coder->end_was_reached = true;
48
+
49
+       } else if (ret != LZMA_OK) {
50
+           return ret;
51
+       }
52
+   }
53
+
54
+   return LZMA_OK;
55
+}
56
+
57
+
58
+static size_t
59
+call_filter(lzma_coder *coder, uint8_t *buffer, size_t size)
60
+{
61
+   const size_t filtered = coder->filter(coder->simple,
62
+           coder->now_pos, coder->is_encoder,
63
+           buffer, size);
64
+   coder->now_pos += filtered;
65
+   return filtered;
66
+}
67
+
68
+
69
+static lzma_ret
70
+simple_code(lzma_coder *coder, lzma_allocator *allocator,
71
+       const uint8_t *restrict in, size_t *restrict in_pos,
72
+       size_t in_size, uint8_t *restrict out,
73
+       size_t *restrict out_pos, size_t out_size, lzma_action action)
74
+{
75
+   // TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it
76
+   // in cases when the filter is able to filter everything. With most
77
+   // simple filters it can be done at offset that is a multiple of 2,
78
+   // 4, or 16. With x86 filter, it needs good luck, and thus cannot
79
+   // be made to work predictably.
80
+   if (action == LZMA_SYNC_FLUSH)
81
+       return LZMA_OPTIONS_ERROR;
82
+
83
+   // Flush already filtered data from coder->buffer[] to out[].
84
+   if (coder->pos < coder->filtered) {
85
+       lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered,
86
+               out, out_pos, out_size);
87
+
88
+       // If we couldn't flush all the filtered data, return to
89
+       // application immediately.
90
+       if (coder->pos < coder->filtered)
91
+           return LZMA_OK;
92
+
93
+       if (coder->end_was_reached) {
94
+           assert(coder->filtered == coder->size);
95
+           return LZMA_STREAM_END;
96
+       }
97
+   }
98
+
99
+   // If we get here, there is no filtered data left in the buffer.
100
+   coder->filtered = 0;
101
+
102
+   assert(!coder->end_was_reached);
103
+
104
+   // If there is more output space left than there is unfiltered data
105
+   // in coder->buffer[], flush coder->buffer[] to out[], and copy/code
106
+   // more data to out[] hopefully filling it completely. Then filter
107
+   // the data in out[]. This step is where most of the data gets
108
+   // filtered if the buffer sizes used by the application are reasonable.
109
+   const size_t out_avail = out_size - *out_pos;
110
+   const size_t buf_avail = coder->size - coder->pos;
111
+   if (out_avail > buf_avail || buf_avail == 0) {
112
+       // Store the old position so that we know from which byte
113
+       // to start filtering.
114
+       const size_t out_start = *out_pos;
115
+
116
+       // Flush data from coder->buffer[] to out[], but don't reset
117
+       // coder->pos and coder->size yet. This way the coder can be
118
+       // restarted if the next filter in the chain returns e.g.
119
+       // LZMA_MEM_ERROR.
120
+       memcpy(out + *out_pos, coder->buffer + coder->pos, buf_avail);
121
+       *out_pos += buf_avail;
122
+
123
+       // Copy/Encode/Decode more data to out[].
124
+       {
125
+           const lzma_ret ret = copy_or_code(coder, allocator,
126
+                   in, in_pos, in_size,
127
+                   out, out_pos, out_size, action);
128
+           assert(ret != LZMA_STREAM_END);
129
+           if (ret != LZMA_OK)
130
+               return ret;
131
+       }
132
+
133
+       // Filter out[].
134
+       const size_t size = *out_pos - out_start;
135
+       const size_t filtered = call_filter(
136
+               coder, out + out_start, size);
137
+
138
+       const size_t unfiltered = size - filtered;
139
+       assert(unfiltered <= coder->allocated / 2);
140
+
141
+       // Now we can update coder->pos and coder->size, because
142
+       // the next coder in the chain (if any) was successful.
143
+       coder->pos = 0;
144
+       coder->size = unfiltered;
145
+
146
+       if (coder->end_was_reached) {
147
+           // The last byte has been copied to out[] already.
148
+           // They are left as is.
149
+           coder->size = 0;
150
+
151
+       } else if (unfiltered > 0) {
152
+           // There is unfiltered data left in out[]. Copy it to
153
+           // coder->buffer[] and rewind *out_pos appropriately.
154
+           *out_pos -= unfiltered;
155
+           memcpy(coder->buffer, out + *out_pos, unfiltered);
156
+       }
157
+   } else if (coder->pos > 0) {
158
+       memmove(coder->buffer, coder->buffer + coder->pos, buf_avail);
159
+       coder->size -= coder->pos;
160
+       coder->pos = 0;
161
+   }
162
+
163
+   assert(coder->pos == 0);
164
+
165
+   // If coder->buffer[] isn't empty, try to fill it by copying/decoding
166
+   // more data. Then filter coder->buffer[] and copy the successfully
167
+   // filtered data to out[]. It is probable, that some filtered and
168
+   // unfiltered data will be left to coder->buffer[].
169
+   if (coder->size > 0) {
170
+       {
171
+           const lzma_ret ret = copy_or_code(coder, allocator,
172
+                   in, in_pos, in_size,
173
+                   coder->buffer, &coder->size,
174
+                   coder->allocated, action);
175
+           assert(ret != LZMA_STREAM_END);
176
+           if (ret != LZMA_OK)
177
+               return ret;
178
+       }
179
+
180
+       coder->filtered = call_filter(
181
+               coder, coder->buffer, coder->size);
182
+
183
+       // Everything is considered to be filtered if coder->buffer[]
184
+       // contains the last bytes of the data.
185
+       if (coder->end_was_reached)
186
+           coder->filtered = coder->size;
187
+
188
+       // Flush as much as possible.
189
+       lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered,
190
+               out, out_pos, out_size);
191
+   }
192
+
193
+   // Check if we got everything done.
194
+   if (coder->end_was_reached && coder->pos == coder->size)
195
+       return LZMA_STREAM_END;
196
+
197
+   return LZMA_OK;
198
+}
199
+
200
+
201
+static void
202
+simple_coder_end(lzma_coder *coder, lzma_allocator *allocator)
203
+{
204
+   lzma_next_end(&coder->next, allocator);
205
+   lzma_free(coder->simple, allocator);
206
+   lzma_free(coder, allocator);
207
+   return;
208
+}
209
+
210
+
211
+static lzma_ret
212
+simple_coder_update(lzma_coder *coder, lzma_allocator *allocator,
213
+       const lzma_filter *filters_null lzma_attribute((__unused__)),
214
+       const lzma_filter *reversed_filters)
215
+{
216
+   // No update support, just call the next filter in the chain.
217
+   return lzma_next_filter_update(
218
+           &coder->next, allocator, reversed_filters + 1);
219
+}
220
+
221
+
222
+extern lzma_ret
223
+lzma_simple_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
224
+       const lzma_filter_info *filters,
225
+       size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
226
+           bool is_encoder, uint8_t *buffer, size_t size),
227
+       size_t simple_size, size_t unfiltered_max,
228
+       uint32_t alignment, bool is_encoder)
229
+{
230
+   // Allocate memory for the lzma_coder structure if needed.
231
+   if (next->coder == NULL) {
232
+       // Here we allocate space also for the temporary buffer. We
233
+       // need twice the size of unfiltered_max, because then it
234
+       // is always possible to filter at least unfiltered_max bytes
235
+       // more data in coder->buffer[] if it can be filled completely.
236
+       next->coder = lzma_alloc(sizeof(lzma_coder)
237
+               + 2 * unfiltered_max, allocator);
238
+       if (next->coder == NULL)
239
+           return LZMA_MEM_ERROR;
240
+
241
+       next->code = &simple_code;
242
+       next->end = &simple_coder_end;
243
+       next->update = &simple_coder_update;
244
+
245
+       next->coder->next = LZMA_NEXT_CODER_INIT;
246
+       next->coder->filter = filter;
247
+       next->coder->allocated = 2 * unfiltered_max;
248
+
249
+       // Allocate memory for filter-specific data structure.
250
+       if (simple_size > 0) {
251
+           next->coder->simple = lzma_alloc(
252
+                   simple_size, allocator);
253
+           if (next->coder->simple == NULL)
254
+               return LZMA_MEM_ERROR;
255
+       } else {
256
+           next->coder->simple = NULL;
257
+       }
258
+   }
259
+
260
+   if (filters[0].options != NULL) {
261
+       const lzma_options_bcj *simple = filters[0].options;
262
+       next->coder->now_pos = simple->start_offset;
263
+       if (next->coder->now_pos & (alignment - 1))
264
+           return LZMA_OPTIONS_ERROR;
265
+   } else {
266
+       next->coder->now_pos = 0;
267
+   }
268
+
269
+   // Reset variables.
270
+   next->coder->is_encoder = is_encoder;
271
+   next->coder->end_was_reached = false;
272
+   next->coder->pos = 0;
273
+   next->coder->filtered = 0;
274
+   next->coder->size = 0;
275
+
276
+   return lzma_next_filter_init(
277
+           &next->coder->next, allocator, filters + 1);
278
+}
279
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_coder.h Added
62
 
1
@@ -0,0 +1,60 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_coder.h
5
+/// \brief      Wrapper for simple filters
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_SIMPLE_CODER_H
15
+#define LZMA_SIMPLE_CODER_H
16
+
17
+#include "common.h"
18
+
19
+
20
+extern lzma_ret lzma_simple_x86_encoder_init(lzma_next_coder *next,
21
+       lzma_allocator *allocator, const lzma_filter_info *filters);
22
+
23
+extern lzma_ret lzma_simple_x86_decoder_init(lzma_next_coder *next,
24
+       lzma_allocator *allocator, const lzma_filter_info *filters);
25
+
26
+
27
+extern lzma_ret lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
28
+       lzma_allocator *allocator, const lzma_filter_info *filters);
29
+
30
+extern lzma_ret lzma_simple_powerpc_decoder_init(lzma_next_coder *next,
31
+       lzma_allocator *allocator, const lzma_filter_info *filters);
32
+
33
+
34
+extern lzma_ret lzma_simple_ia64_encoder_init(lzma_next_coder *next,
35
+       lzma_allocator *allocator, const lzma_filter_info *filters);
36
+
37
+extern lzma_ret lzma_simple_ia64_decoder_init(lzma_next_coder *next,
38
+       lzma_allocator *allocator, const lzma_filter_info *filters);
39
+
40
+
41
+extern lzma_ret lzma_simple_arm_encoder_init(lzma_next_coder *next,
42
+       lzma_allocator *allocator, const lzma_filter_info *filters);
43
+
44
+extern lzma_ret lzma_simple_arm_decoder_init(lzma_next_coder *next,
45
+       lzma_allocator *allocator, const lzma_filter_info *filters);
46
+
47
+
48
+extern lzma_ret lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
49
+       lzma_allocator *allocator, const lzma_filter_info *filters);
50
+
51
+extern lzma_ret lzma_simple_armthumb_decoder_init(lzma_next_coder *next,
52
+       lzma_allocator *allocator, const lzma_filter_info *filters);
53
+
54
+
55
+extern lzma_ret lzma_simple_sparc_encoder_init(lzma_next_coder *next,
56
+       lzma_allocator *allocator, const lzma_filter_info *filters);
57
+
58
+extern lzma_ret lzma_simple_sparc_decoder_init(lzma_next_coder *next,
59
+       lzma_allocator *allocator, const lzma_filter_info *filters);
60
+
61
+#endif
62
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_decoder.c Added
42
 
1
@@ -0,0 +1,40 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_decoder.c
5
+/// \brief      Properties decoder for simple filters
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "simple_decoder.h"
15
+
16
+
17
+extern lzma_ret
18
+lzma_simple_props_decode(void **options, lzma_allocator *allocator,
19
+       const uint8_t *props, size_t props_size)
20
+{
21
+   if (props_size == 0)
22
+       return LZMA_OK;
23
+
24
+   if (props_size != 4)
25
+       return LZMA_OPTIONS_ERROR;
26
+
27
+   lzma_options_bcj *opt = lzma_alloc(
28
+           sizeof(lzma_options_bcj), allocator);
29
+   if (opt == NULL)
30
+       return LZMA_MEM_ERROR;
31
+
32
+   opt->start_offset = unaligned_read32le(props);
33
+
34
+   // Don't leave an options structure allocated if start_offset is zero.
35
+   if (opt->start_offset == 0)
36
+       lzma_free(opt, allocator);
37
+   else
38
+       *options = opt;
39
+
40
+   return LZMA_OK;
41
+}
42
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_decoder.h Added
24
 
1
@@ -0,0 +1,22 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_decoder.h
5
+/// \brief      Properties decoder for simple filters
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_SIMPLE_DECODER_H
15
+#define LZMA_SIMPLE_DECODER_H
16
+
17
+#include "simple_coder.h"
18
+
19
+extern lzma_ret lzma_simple_props_decode(
20
+       void **options, lzma_allocator *allocator,
21
+       const uint8_t *props, size_t props_size);
22
+
23
+#endif
24
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_encoder.c Added
40
 
1
@@ -0,0 +1,38 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_encoder.c
5
+/// \brief      Properties encoder for simple filters
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#include "simple_encoder.h"
15
+
16
+
17
+extern lzma_ret
18
+lzma_simple_props_size(uint32_t *size, const void *options)
19
+{
20
+   const lzma_options_bcj *const opt = options;
21
+   *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
22
+   return LZMA_OK;
23
+}
24
+
25
+
26
+extern lzma_ret
27
+lzma_simple_props_encode(const void *options, uint8_t *out)
28
+{
29
+   const lzma_options_bcj *const opt = options;
30
+
31
+   // The default start offset is zero, so we don't need to store any
32
+   // options unless the start offset is non-zero.
33
+   if (opt == NULL || opt->start_offset == 0)
34
+       return LZMA_OK;
35
+
36
+   unaligned_write32le(out, opt->start_offset);
37
+
38
+   return LZMA_OK;
39
+}
40
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_encoder.h Added
25
 
1
@@ -0,0 +1,23 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_encoder.c
5
+/// \brief      Properties encoder for simple filters
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_SIMPLE_ENCODER_H
15
+#define LZMA_SIMPLE_ENCODER_H
16
+
17
+#include "simple_coder.h"
18
+
19
+
20
+extern lzma_ret lzma_simple_props_size(uint32_t *size, const void *options);
21
+
22
+extern lzma_ret lzma_simple_props_encode(const void *options, uint8_t *out);
23
+
24
+#endif
25
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/simple_private.h Added
77
 
1
@@ -0,0 +1,75 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       simple_private.h
5
+/// \brief      Private definitions for so called simple filters
6
+//
7
+//  Author:     Lasse Collin
8
+//
9
+//  This file has been put into the public domain.
10
+//  You can do whatever you want with this file.
11
+//
12
+///////////////////////////////////////////////////////////////////////////////
13
+
14
+#ifndef LZMA_SIMPLE_PRIVATE_H
15
+#define LZMA_SIMPLE_PRIVATE_H
16
+
17
+#include "simple_coder.h"
18
+
19
+
20
+typedef struct lzma_simple_s lzma_simple;
21
+
22
+struct lzma_coder_s {
23
+   /// Next filter in the chain
24
+   lzma_next_coder next;
25
+
26
+   /// True if the next coder in the chain has returned LZMA_STREAM_END.
27
+   bool end_was_reached;
28
+
29
+   /// True if filter() should encode the data; false to decode.
30
+   /// Currently all simple filters use the same function for encoding
31
+   /// and decoding, because the difference between encoders and decoders
32
+   /// is very small.
33
+   bool is_encoder;
34
+
35
+   /// Pointer to filter-specific function, which does
36
+   /// the actual filtering.
37
+   size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
38
+           bool is_encoder, uint8_t *buffer, size_t size);
39
+
40
+   /// Pointer to filter-specific data, or NULL if filter doesn't need
41
+   /// any extra data.
42
+   lzma_simple *simple;
43
+
44
+   /// The lowest 32 bits of the current position in the data. Most
45
+   /// filters need this to do conversions between absolute and relative
46
+   /// addresses.
47
+   uint32_t now_pos;
48
+
49
+   /// Size of the memory allocated for the buffer.
50
+   size_t allocated;
51
+
52
+   /// Flushing position in the temporary buffer. buffer[pos] is the
53
+   /// next byte to be copied to out[].
54
+   size_t pos;
55
+
56
+   /// buffer[filtered] is the first unfiltered byte. When pos is smaller
57
+   /// than filtered, there is unflushed filtered data in the buffer.
58
+   size_t filtered;
59
+
60
+   /// Total number of bytes (both filtered and unfiltered) currently
61
+   /// in the temporary buffer.
62
+   size_t size;
63
+
64
+   /// Temporary buffer
65
+   uint8_t buffer[];
66
+};
67
+
68
+
69
+extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
70
+       lzma_allocator *allocator, const lzma_filter_info *filters,
71
+       size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
72
+           bool is_encoder, uint8_t *buffer, size_t size),
73
+       size_t simple_size, size_t unfiltered_max,
74
+       uint32_t alignment, bool is_encoder);
75
+
76
+#endif
77
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/sparc.c Added
83
 
1
@@ -0,0 +1,81 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       sparc.c
5
+/// \brief      Filter for SPARC binaries
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "simple_private.h"
16
+
17
+
18
+static size_t
19
+sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
20
+       uint32_t now_pos, bool is_encoder,
21
+       uint8_t *buffer, size_t size)
22
+{
23
+   size_t i;
24
+   for (i = 0; i + 4 <= size; i += 4) {
25
+
26
+       if ((buffer[i] == 0x40 && (buffer[i + 1] & 0xC0) == 0x00)
27
+               || (buffer[i] == 0x7F
28
+               && (buffer[i + 1] & 0xC0) == 0xC0)) {
29
+
30
+           uint32_t src = ((uint32_t)buffer[i + 0] << 24)
31
+                   | ((uint32_t)buffer[i + 1] << 16)
32
+                   | ((uint32_t)buffer[i + 2] << 8)
33
+                   | ((uint32_t)buffer[i + 3]);
34
+
35
+           src <<= 2;
36
+
37
+           uint32_t dest;
38
+           if (is_encoder)
39
+               dest = now_pos + (uint32_t)(i) + src;
40
+           else
41
+               dest = src - (now_pos + (uint32_t)(i));
42
+
43
+           dest >>= 2;
44
+
45
+           dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF)
46
+                   | (dest & 0x3FFFFF)
47
+                   | 0x40000000;
48
+
49
+           buffer[i + 0] = (uint8_t)(dest >> 24);
50
+           buffer[i + 1] = (uint8_t)(dest >> 16);
51
+           buffer[i + 2] = (uint8_t)(dest >> 8);
52
+           buffer[i + 3] = (uint8_t)(dest);
53
+       }
54
+   }
55
+
56
+   return i;
57
+}
58
+
59
+
60
+static lzma_ret
61
+sparc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
62
+       const lzma_filter_info *filters, bool is_encoder)
63
+{
64
+   return lzma_simple_coder_init(next, allocator, filters,
65
+           &sparc_code, 0, 4, 4, is_encoder);
66
+}
67
+
68
+
69
+extern lzma_ret
70
+lzma_simple_sparc_encoder_init(lzma_next_coder *next,
71
+       lzma_allocator *allocator, const lzma_filter_info *filters)
72
+{
73
+   return sparc_coder_init(next, allocator, filters, true);
74
+}
75
+
76
+
77
+extern lzma_ret
78
+lzma_simple_sparc_decoder_init(lzma_next_coder *next,
79
+       lzma_allocator *allocator, const lzma_filter_info *filters)
80
+{
81
+   return sparc_coder_init(next, allocator, filters, false);
82
+}
83
obs-studio-18.0.1.tar.xz/deps/lzma/liblzma/simple/x86.c Added
156
 
1
@@ -0,0 +1,154 @@
2
+///////////////////////////////////////////////////////////////////////////////
3
+//
4
+/// \file       x86.c
5
+/// \brief      Filter for x86 binaries (BCJ filter)
6
+///
7
+//  Authors:    Igor Pavlov
8
+//              Lasse Collin
9
+//
10
+//  This file has been put into the public domain.
11
+//  You can do whatever you want with this file.
12
+//
13
+///////////////////////////////////////////////////////////////////////////////
14
+
15
+#include "simple_private.h"
16
+
17
+
18
+#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
19
+
20
+
21
+struct lzma_simple_s {
22
+   uint32_t prev_mask;
23
+   uint32_t prev_pos;
24
+};
25
+
26
+
27
+static size_t
28
+x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
29
+       uint8_t *buffer, size_t size)
30
+{
31
+   static const bool MASK_TO_ALLOWED_STATUS[8]
32
+       = { true, true, true, false, true, false, false, false };
33
+
34
+   static const uint32_t MASK_TO_BIT_NUMBER[8]
35
+           = { 0, 1, 2, 2, 3, 3, 3, 3 };
36
+
37
+   uint32_t prev_mask = simple->prev_mask;
38
+   uint32_t prev_pos = simple->prev_pos;
39
+
40
+   if (size < 5)
41
+       return 0;
42
+
43
+   if (now_pos - prev_pos > 5)
44
+       prev_pos = now_pos - 5;
45
+
46
+   const size_t limit = size - 5;
47
+   size_t buffer_pos = 0;
48
+
49
+   while (buffer_pos <= limit) {
50
+       uint8_t b = buffer[buffer_pos];
51
+       if (b != 0xE8 && b != 0xE9) {
52
+           ++buffer_pos;
53
+           continue;
54
+       }
55
+
56
+       const uint32_t offset = now_pos + (uint32_t)(buffer_pos)
57
+               - prev_pos;
58
+       prev_pos = now_pos + (uint32_t)(buffer_pos);
59
+
60
+       if (offset > 5) {
61
+           prev_mask = 0;
62
+       } else {
63
+           for (uint32_t i = 0; i < offset; ++i) {
64
+               prev_mask &= 0x77;
65
+               prev_mask <<= 1;
66
+           }
67
+       }
68
+
69
+       b = buffer[buffer_pos + 4];
70
+
71
+       if (Test86MSByte(b)
72
+           && MASK_TO_ALLOWED_STATUS[(prev_mask >> 1) & 0x7]
73
+               && (prev_mask >> 1) < 0x10) {
74
+
75
+           uint32_t src = ((uint32_t)(b) << 24)
76
+               | ((uint32_t)(buffer[buffer_pos + 3]) << 16)
77
+               | ((uint32_t)(buffer[buffer_pos + 2]) << 8)
78
+               | (buffer[buffer_pos + 1]);
79
+
80
+           uint32_t dest;
81
+           while (true) {
82
+               if (is_encoder)
83
+                   dest = src + (now_pos + (uint32_t)(
84
+                           buffer_pos) + 5);
85
+               else
86
+                   dest = src - (now_pos + (uint32_t)(
87
+                           buffer_pos) + 5);
88
+
89
+               if (prev_mask == 0)
90
+                   break;
91
+
92
+               const uint32_t i = MASK_TO_BIT_NUMBER[
93
+                       prev_mask >> 1];
94
+
95
+               b = (uint8_t)(dest >> (24 - i * 8));
96
+
97
+               if (!Test86MSByte(b))
98
+                   break;
99
+
100
+               src = dest ^ ((1 << (32 - i * 8)) - 1);
101
+           }
102
+
103
+           buffer[buffer_pos + 4]
104
+                   = (uint8_t)(~(((dest >> 24) & 1) - 1));
105
+           buffer[buffer_pos + 3] = (uint8_t)(dest >> 16);
106
+           buffer[buffer_pos + 2] = (uint8_t)(dest >> 8);
107
+           buffer[buffer_pos + 1] = (uint8_t)(dest);
108
+           buffer_pos += 5;
109
+           prev_mask = 0;
110
+
111
+       } else {
112
+           ++buffer_pos;
113
+           prev_mask |= 1;
114
+           if (Test86MSByte(b))
115
+               prev_mask |= 0x10;
116
+       }
117
+   }
118
+
119
+   simple->prev_mask = prev_mask;
120
+   simple->prev_pos = prev_pos;
121
+
122
+   return buffer_pos;
123
+}
124
+
125
+
126
+static lzma_ret
127
+x86_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
128
+       const lzma_filter_info *filters, bool is_encoder)
129
+{
130
+   const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters,
131
+           &x86_code, sizeof(lzma_simple), 5, 1, is_encoder);
132
+
133
+   if (ret == LZMA_OK) {
134
+       next->coder->simple->prev_mask = 0;
135
+       next->coder->simple->prev_pos = (uint32_t)(-5);
136
+   }
137
+
138
+   return ret;
139
+}
140
+
141
+
142
+extern lzma_ret
143
+lzma_simple_x86_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
144
+       const lzma_filter_info *filters)
145
+{
146
+   return x86_coder_init(next, allocator, filters, true);
147
+}
148
+
149
+
150
+extern lzma_ret
151
+lzma_simple_x86_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
152
+       const lzma_filter_info *filters)
153
+{
154
+   return x86_coder_init(next, allocator, filters, false);
155
+}
156
obs-studio-18.0.1.tar.xz/deps/lzma/version.h Added
11
 
1
@@ -0,0 +1,8 @@
2
+/* Define to the full name and version of this package. */
3
+#define PACKAGE_STRING "XZ Utils 5.0.7"
4
+
5
+/* Define to the version of this package. */
6
+#define PACKAGE_VERSION "5.0.7"
7
+
8
+/* Version number of package */
9
+#define VERSION "5.0.7"
10
\ No newline at end of file
11
obs-studio-18.0.0.tar.xz/libobs/audio-monitoring/win32/wasapi-output.c -> obs-studio-18.0.1.tar.xz/libobs/audio-monitoring/win32/wasapi-output.c Changed
10
 
1
@@ -63,6 +63,8 @@
2
        circlebuf_free(&monitor->delay_buffer);
3
    monitor->last_recv_time = cur_time;
4
 
5
+   ts += monitor->source->sync_offset;
6
+
7
    circlebuf_push_back(&monitor->delay_buffer, &ts, sizeof(ts));
8
    circlebuf_push_back(&monitor->delay_buffer, frames, sizeof(*frames));
9
    circlebuf_push_back(&monitor->delay_buffer, *data,
10
obs-studio-18.0.0.tar.xz/libobs/obs-config.h -> obs-studio-18.0.1.tar.xz/libobs/obs-config.h Changed
10
 
1
@@ -41,7 +41,7 @@
2
  *
3
  * Reset to zero each major or minor version
4
  */
5
-#define LIBOBS_API_PATCH_VER  0
6
+#define LIBOBS_API_PATCH_VER  1
7
 
8
 #define MAKE_SEMANTIC_VERSION(major, minor, patch) \
9
                              ((major << 24) | \
10
obs-studio-18.0.1.tar.xz/plugins/coreaudio-encoder/data/locale/et-EE.ini Added
8
 
1
@@ -0,0 +1,6 @@
2
+CoreAudioAAC="CoreAudio AAC kodeerija"
3
+Bitrate="Bitikiirus"
4
+AllowHEAAC="Luba HE-AAC"
5
+OutputSamplerate="Väljundi diskreetimissagedus"
6
+UseInputSampleRate="Kasuta sisendi (OBS) diskreetimissagedust (võib loetleda toeta bitikiirusi)"
7
+
8
obs-studio-18.0.1.tar.xz/plugins/decklink/data/locale/et-EE.ini Added
8
 
1
@@ -0,0 +1,6 @@
2
+BlackmagicDevice="Blackmagic seade"
3
+Device="Seade"
4
+Mode="Režiim"
5
+Buffering="Kasutada puhverdamist"
6
+PixelFormat="Piksli formaat"
7
+
8
obs-studio-18.0.0.tar.xz/plugins/enc-amf/CMakeLists.txt -> obs-studio-18.0.1.tar.xz/plugins/enc-amf/CMakeLists.txt Changed
10
 
1
@@ -37,7 +37,7 @@
2
 SET(enc-amf_VERSION_MAJOR 1)
3
 SET(enc-amf_VERSION_MINOR 4)
4
 SET(enc-amf_VERSION_PATCH 3)
5
-SET(enc-amf_VERSION_BUILD 10)
6
+SET(enc-amf_VERSION_BUILD 11)
7
 configure_file(
8
    "${PROJECT_SOURCE_DIR}/#Resources/package.in.bat"
9
    "${PROJECT_SOURCE_DIR}/#Resources/package.bat"
10
obs-studio-18.0.0.tar.xz/plugins/enc-amf/Source/amf-capabilities.cpp -> obs-studio-18.0.1.tar.xz/plugins/enc-amf/Source/amf-capabilities.cpp Changed
109
 
1
@@ -230,12 +230,12 @@
2
            adapters = api->EnumerateAdapters();
3
        } catch (std::exception e) {
4
            AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Exception while enumerating %s adapters: %s.",
5
-               api->GetName(),
6
+               api->GetName().c_str(),
7
                e.what());
8
            continue;
9
        } catch (...) {
10
            AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Critical exception while enumerating %s adapters.",
11
-               api->GetName());
12
+               api->GetName().c_str());
13
            throw;
14
        }
15
 
16
@@ -244,7 +244,7 @@
17
            amf::AMFContextPtr amfContext;
18
            res = amfFactory->CreateContext(&amfContext);
19
            if (res != AMF_OK) {
20
-               AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to create context on %s adapter '%s', error %ls (code %lld).",
21
+               AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to create context on %s adapter '%s', error %ls (code %d).",
22
                    api->GetName().c_str(),
23
                    adapter.Name.c_str(),
24
                    amfInstance->GetTrace()->GetResultText(res),
25
@@ -257,13 +257,13 @@
26
                apiInst = api->CreateInstanceOnAdapter(adapter);
27
            } catch (std::exception e) {
28
                AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Exception while intializing %s adapter '%s': %s.",
29
-                   api->GetName(),
30
+                   api->GetName().c_str(),
31
                    adapter.Name,
32
                    e.what());
33
                continue;
34
            } catch (...) {
35
                AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Critical exception while intializing %s adapter '%s'.",
36
-                   api->GetName(),
37
+                   api->GetName().c_str(),
38
                    adapter.Name);
39
                throw;
40
            }
41
@@ -282,8 +282,8 @@
42
                    break;
43
            }
44
            if (res != AMF_OK) {
45
-               AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Initialization failed for %s adapter '%s', error %ls (code %lld).",
46
-                   api->GetName(),
47
+               AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Initialization failed for %s adapter '%s', error %ls (code %d).",
48
+                   api->GetName().c_str(),
49
                    adapter.Name.c_str(),
50
                    amfInstance->GetTrace()->GetResultText(res),
51
                    res);
52
@@ -302,8 +302,8 @@
53
                    Plugin::Utility::VCEEncoderTypeAsAMF(type),
54
                    &amfComponent);
55
                if (res != AMF_OK) {
56
-                   AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to create component for %s adapter '%s' with codec '%s', error %ls (code %lld).",
57
-                       api->GetName(),
58
+                   AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to create component for %s adapter '%s' with codec '%s', error %ls (code %d).",
59
+                       api->GetName().c_str(),
60
                        adapter.Name.c_str(),
61
                        Plugin::Utility::VCEEncoderTypeAsString(type),
62
                        amfInstance->GetTrace()->GetResultText(res), res);
63
@@ -313,8 +313,8 @@
64
                amf::AMFCapsPtr amfCaps;
65
                res = amfComponent->GetCaps(&amfCaps);
66
                if (res != AMF_OK) {
67
-                   AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to query capabilities for %s adapter '%s' with codec '%s', error %ls (code %lld).",
68
-                       api->GetName(),
69
+                   AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to query capabilities for %s adapter '%s' with codec '%s', error %ls (code %d).",
70
+                       api->GetName().c_str(),
71
                        adapter.Name.c_str(),
72
                        Plugin::Utility::VCEEncoderTypeAsString(type),
73
                        amfInstance->GetTrace()->GetResultText(res), res);
74
@@ -337,16 +337,16 @@
75
 
76
                    res = GetIOCapability(false, amfCaps, &(devCaps.input));
77
                    if (res != AMF_OK)
78
-                       AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to query input capabilities for %s adapter '%s' with codec '%s', error %ls (code %lld).",
79
-                           api->GetName(),
80
+                       AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to query input capabilities for %s adapter '%s' with codec '%s', error %ls (code %d).",
81
+                           api->GetName().c_str(),
82
                            adapter.Name.c_str(),
83
                            Plugin::Utility::VCEEncoderTypeAsString(type),
84
                            amfInstance->GetTrace()->GetResultText(res), res);
85
 
86
                    res = GetIOCapability(true, amfCaps, &(devCaps.output));
87
                    if (res != AMF_OK)
88
-                       AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to query output capabilities for %s adapter '%s' with codec '%s', error %ls (code %lld).",
89
-                           api->GetName(),
90
+                       AMF_LOG_ERROR("<" __FUNCTION_NAME__ "> Unable to query output capabilities for %s adapter '%s' with codec '%s', error %ls (code %d).",
91
+                           api->GetName().c_str(),
92
                            adapter.Name.c_str(),
93
                            Plugin::Utility::VCEEncoderTypeAsString(type),
94
                            amfInstance->GetTrace()->GetResultText(res), res);
95
@@ -371,11 +371,11 @@
96
    std::vector<std::pair<H264EncoderType, VCEDeviceCapabilities>> caps;
97
    for (auto kv : capabilityMap) {
98
        auto apiName = std::get<0>(kv.first);
99
-       auto adapter = std::get<1>(kv.first);
100
+       auto curAdapter = std::get<1>(kv.first);
101
 
102
        if (apiName != api->GetName())
103
            continue;
104
-       if (adapter != adapter)
105
+       if (curAdapter != adapter)
106
            continue;
107
 
108
        auto type = std::get<2>(kv.first);
109
obs-studio-18.0.0.tar.xz/plugins/enc-amf/Source/amf-h264.cpp -> obs-studio-18.0.1.tar.xz/plugins/enc-amf/Source/amf-h264.cpp Changed
44
 
1
@@ -137,7 +137,7 @@
2
        AMF_RESULT res = m_AMFEncoder->GetPropertyInfo(propIndex, (const amf::AMFPropertyInfo**) &pInfo);
3
        if (res != AMF_OK)
4
            continue;
5
-       AMF_LOG_INFO(" [%ls] %ls (Type: %s, Index %d)",
6
+       AMF_LOG_INFO(" [%ls] %ls (Type: %s, Index %Iu)",
7
            pInfo->name, pInfo->desc, typeToString[pInfo->type], propIndex);
8
        AMF_LOG_INFO("  Content Type: %d",
9
            pInfo->contentType);
10
@@ -449,13 +449,13 @@
11
            int32_t queueSizeDelta = ((int32_t)m_InputQueueLastSize - (int32_t)queueSize);
12
 
13
            if (queueSizeDelta >= 5) {
14
-               AMF_LOG_INFO("GPU Encoder is catching up, queue is shrinking... (%ld,%+ld,%ld)",
15
+               AMF_LOG_INFO("GPU Encoder is catching up, queue is shrinking... (%Iu,%+ld,%Iu)",
16
                    m_InputQueueLastSize,
17
                    queueSizeDelta,
18
                    queueSize);
19
                m_InputQueueLastSize = queueSize;
20
            } else if (queueSizeDelta <= -5) {
21
-               AMF_LOG_WARNING("GPU Encoder overloaded, queue is growing... (%ld,%+ld,%ld)",
22
+               AMF_LOG_WARNING("GPU Encoder overloaded, queue is growing... (%Iu,%+ld,%Iu)",
23
                    m_InputQueueLastSize, queueSizeDelta, queueSize);
24
                m_InputQueueLastSize = queueSize;
25
            }
26
@@ -480,7 +480,7 @@
27
            throw std::exception("Unable to submit first frame, terminating...");
28
        else {
29
            uint64_t dtime = (uint64_t)diff.count();
30
-           AMF_LOG_INFO("First submission took %ld.%ld seconds.", dtime / 1000000000, dtime % 1000000000);
31
+           AMF_LOG_INFO("First submission took %" PRIu64 ".%" PRIu64 " seconds.", dtime / 1000000000, dtime % 1000000000);
32
        }
33
    }
34
 
35
@@ -531,7 +531,7 @@
36
        packet->size = pAMFBuffer->GetSize();
37
        if (m_PacketDataBuffer.size() < packet->size) {
38
            size_t newBufferSize = (size_t)exp2(ceil(log2(packet->size)));
39
-           AMF_LOG_DEBUG("Packet Buffer was resized to %d byte from %d byte.", newBufferSize, m_PacketDataBuffer.size());
40
+           AMF_LOG_DEBUG("Packet Buffer was resized to %Iu byte from %Iu byte.", newBufferSize, m_PacketDataBuffer.size());
41
            m_PacketDataBuffer.resize(newBufferSize);
42
        }
43
        packet->data = m_PacketDataBuffer.data();
44
obs-studio-18.0.0.tar.xz/plugins/enc-amf/Source/amf.cpp -> obs-studio-18.0.1.tar.xz/plugins/enc-amf/Source/amf.cpp Changed
77
 
1
@@ -46,7 +46,7 @@
2
 
3
    virtual void Write(const wchar_t* scope, const wchar_t* message) override {
4
        const wchar_t* realmsg = &(message[(33 + wcslen(scope) + 2)]); // Skip Time & Scope
5
-       size_t msgLen = wcslen(realmsg) - (sizeof(wchar_t));
6
+       int msgLen = (int)wcslen(realmsg) - (sizeof(wchar_t));
7
 
8
        blog(LOG_INFO, "[AMF Encoder] [%.*ls][%ls] %.*ls",
9
            12, &(message[11]),
10
@@ -94,31 +94,33 @@
11
    }
12
    AMF_LOG_DEBUG("<" __FUNCTION_NAME__ "> Loaded '%ls'.", AMF_DLL_NAME);
13
    #ifdef _WIN32 // Windows: Get Product Version
14
+   void* pProductVersion = "unknown";
15
+   uint32_t lProductVersionSize = 7;
16
    std::vector<char> verbuf(GetFileVersionInfoSizeW(AMF_DLL_NAME, nullptr));
17
-   GetFileVersionInfoW(AMF_DLL_NAME, 0, (DWORD)verbuf.size(), verbuf.data());
18
-
19
-   void* pBlock = verbuf.data();
20
-
21
-   // Read the list of languages and code pages.
22
-   struct LANGANDCODEPAGE {
23
-       WORD wLanguage;
24
-       WORD wCodePage;
25
-   } *lpTranslate;
26
-   UINT cbTranslate = sizeof(LANGANDCODEPAGE);
27
-
28
-   VerQueryValueA(pBlock, "\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &cbTranslate);
29
-
30
-   std::vector<char> buf(1024);
31
-   sprintf(buf.data(), "%s%04x%04x%s",
32
-       "\\StringFileInfo\\",
33
-       lpTranslate[0].wLanguage,
34
-       lpTranslate[0].wCodePage,
35
-       "\\ProductVersion");
36
-
37
-   // Retrieve file description for language and code page "i". 
38
-   void* pProductVersion;
39
-   uint32_t lProductVersionSize;
40
-   VerQueryValueA(pBlock, buf.data(), &pProductVersion, &lProductVersionSize);
41
+   if (GetFileVersionInfoW(AMF_DLL_NAME, 0, (DWORD)verbuf.size(), verbuf.data())) {
42
+
43
+       void* pBlock = verbuf.data();
44
+
45
+       // Read the list of languages and code pages.
46
+       struct LANGANDCODEPAGE {
47
+           WORD wLanguage;
48
+           WORD wCodePage;
49
+       } *lpTranslate;
50
+       UINT cbTranslate = sizeof(LANGANDCODEPAGE);
51
+
52
+       if (VerQueryValueA(pBlock, "\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &cbTranslate)) {
53
+
54
+           std::vector<char> buf(1024);
55
+           sprintf(buf.data(), "%s%04x%04x%s",
56
+               "\\StringFileInfo\\",
57
+               lpTranslate[0].wLanguage,
58
+               lpTranslate[0].wCodePage,
59
+               "\\ProductVersion");
60
+
61
+           // Retrieve file description for language and code page "i". 
62
+           VerQueryValueA(pBlock, buf.data(), &pProductVersion, &lProductVersionSize);
63
+       }
64
+   }
65
    #endif _WIN32 // Windows: Get Product Version
66
 
67
    /// Find Function for Querying AMF Version.
68
@@ -178,7 +180,7 @@
69
        (uint16_t)((m_AMFVersion_Runtime >> 32ull) & 0xFFFF),
70
        (uint16_t)((m_AMFVersion_Runtime >> 16ull) & 0xFFFF),
71
        (uint16_t)((m_AMFVersion_Runtime & 0xFFFF)),
72
-       lProductVersionSize, pProductVersion
73
+       lProductVersionSize, (char *)pProductVersion
74
    );
75
 
76
    AMF_LOG_DEBUG("<" __FUNCTION_NAME__ "> Initialized.");
77
obs-studio-18.0.0.tar.xz/plugins/enc-amf/Source/api-d3d11.cpp -> obs-studio-18.0.1.tar.xz/plugins/enc-amf/Source/api-d3d11.cpp Changed
10
 
1
@@ -278,7 +278,7 @@
2
        if (SUCCEEDED(hr)) {
3
            break;
4
        } else {
5
-           AMF_LOG_WARNING("<" __FUNCTION_NAME__ "> Unable to create D3D11 device, error code %X (mode %d).", hr, c);
6
+           AMF_LOG_WARNING("<" __FUNCTION_NAME__ "> Unable to create D3D11 device, error code %X (mode %Iu).", hr, c);
7
        }
8
    }
9
    if (FAILED(hr)) {
10
obs-studio-18.0.0.tar.xz/plugins/image-source/data/locale/cs-CZ.ini -> obs-studio-18.0.1.tar.xz/plugins/image-source/data/locale/cs-CZ.ini Changed
10
 
1
@@ -13,4 +13,8 @@
2
 SlideShow.Transition.Swipe="Tažení"
3
 SlideShow.Transition.Slide="Sklouznutí"
4
 
5
+ColorSource="Zdroj barvy"
6
+ColorSource.Color="Barva"
7
+ColorSource.Width="Šířka"
8
+ColorSource.Height="Výška"
9
 
10
obs-studio-18.0.1.tar.xz/plugins/image-source/data/locale/et-EE.ini Added
22
 
1
@@ -0,0 +1,20 @@
2
+ImageInput="Pilt"
3
+File="Pildifail"
4
+UnloadWhenNotShowing="Laadi maha pilt kui ei ole nähtav"
5
+
6
+SlideShow="Piltide slaidiesitus"
7
+SlideShow.TransitionSpeed="Ülemineku kiirus (millisekundites)"
8
+SlideShow.SlideTime="Aeg slaidide vahel (millisekundites)"
9
+SlideShow.Files="Pildifailid"
10
+SlideShow.Randomize="Juhuslik taasesitus"
11
+SlideShow.Transition="Üleminek"
12
+SlideShow.Transition.Cut="Ilmuv"
13
+SlideShow.Transition.Fade="Hajuv"
14
+SlideShow.Transition.Swipe="Pühkiv"
15
+SlideShow.Transition.Slide="Sisselendav"
16
+
17
+ColorSource="Värvi allikas"
18
+ColorSource.Color="Värv"
19
+ColorSource.Width="Laius"
20
+ColorSource.Height="Kõrgus"
21
+
22
obs-studio-18.0.0.tar.xz/plugins/image-source/data/locale/fr-FR.ini -> obs-studio-18.0.1.tar.xz/plugins/image-source/data/locale/fr-FR.ini Changed
10
 
1
@@ -13,4 +13,8 @@
2
 SlideShow.Transition.Swipe="Balayage"
3
 SlideShow.Transition.Slide="Glissement"
4
 
5
+ColorSource="Source de couleur"
6
+ColorSource.Color="Couleur"
7
+ColorSource.Width="Largeur"
8
+ColorSource.Height="Hauteur"
9
 
10
obs-studio-18.0.0.tar.xz/plugins/image-source/data/locale/it-IT.ini -> obs-studio-18.0.1.tar.xz/plugins/image-source/data/locale/it-IT.ini Changed
10
 
1
@@ -13,4 +13,8 @@
2
 SlideShow.Transition.Swipe="Scorri"
3
 SlideShow.Transition.Slide="Scivola"
4
 
5
+ColorSource="Origine del colore"
6
+ColorSource.Color="Colore"
7
+ColorSource.Width="Larghezza"
8
+ColorSource.Height="Altezza"
9
 
10
obs-studio-18.0.0.tar.xz/plugins/image-source/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/image-source/data/locale/tr-TR.ini Changed
10
 
1
@@ -13,4 +13,8 @@
2
 SlideShow.Transition.Swipe="Swipe"
3
 SlideShow.Transition.Slide="Slide"
4
 
5
+ColorSource="Renk Kaynağı"
6
+ColorSource.Color="Renk"
7
+ColorSource.Width="Genişlik"
8
+ColorSource.Height="Yükseklik"
9
 
10
obs-studio-18.0.1.tar.xz/plugins/linux-alsa/data/locale/et-EE.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+AlsaInput="Helihõive seade (ALSA)"
3
+Device="Seade"
4
+
5
obs-studio-18.0.1.tar.xz/plugins/linux-capture/data/locale/et-EE.ini Added
17
 
1
@@ -0,0 +1,15 @@
2
+X11SharedMemoryScreenInput="Ekraani hõive (XSHM)"
3
+Screen="Ekraan"
4
+CaptureCursor="Jäädvusta kursor"
5
+AdvancedSettings="Täpsemad sätted"
6
+XServer="X Server"
7
+XCCapture="Akna hõive (Xcomposite)"
8
+Window="Aken"
9
+CropTop="Kärbi ülevalt (pikslit)"
10
+CropLeft="Kärbi vasakult (pikslit)"
11
+CropRight="Kärbi paremalt (pikslit)"
12
+CropBottom="Kärbi alt (pikslit)"
13
+SwapRedBlue="Vaheta punane ja sinine"
14
+LockX="Lukusta X server salvestamise ajal"
15
+IncludeXBorder="Kaasa X piirjoon"
16
+
17
obs-studio-18.0.1.tar.xz/plugins/linux-jack/data/locale/et-EE.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+StartJACKServer="Käivita JACK server"
3
+Channels="Kanalite arv"
4
+JACKInput="JACK sisend klient"
5
+
6
obs-studio-18.0.1.tar.xz/plugins/linux-pulseaudio/data/locale/et-EE.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+PulseInput="Helisisendi hõive (PulseAudio)"
3
+PulseOutput="Heliväljundi hõive (PulseAudio)"
4
+Device="Seade"
5
+
6
obs-studio-18.0.1.tar.xz/plugins/linux-v4l2/data/locale/et-EE.ini Added
13
 
1
@@ -0,0 +1,11 @@
2
+V4L2Input="Videohõive seade (V4L2)"
3
+Device="Seade"
4
+Input="Sisend"
5
+VideoFormat="Video formaat"
6
+VideoStandard="Video standard"
7
+DVTiming="DV ajastus"
8
+Resolution="Resolutsioon"
9
+FrameRate="Kaadrisagedus"
10
+LeaveUnchanged="Jäta muutmata"
11
+UseBuffering="Kasuta puhverdamist"
12
+
13
obs-studio-18.0.1.tar.xz/plugins/mac-avcapture/data/locale/et-EE.ini Added
16
 
1
@@ -0,0 +1,14 @@
2
+AVCapture="Videohõive seade"
3
+Device="Seade"
4
+UsePreset="Kasuta eelseadistust"
5
+Preset="Eelseadistus"
6
+Buffering="Kasuta puhverdamist"
7
+FrameRate="Kaadrisagedus"
8
+InputFormat="Sisestus formaat"
9
+ColorSpace="Värviruum"
10
+VideoRange="Video vahemik"
11
+VideoRange.Partial="Osaliselt"
12
+VideoRange.Full="Täielik"
13
+Auto="Automaatne"
14
+Unknown="Teadmata ($1)"
15
+
16
obs-studio-18.0.1.tar.xz/plugins/mac-capture/data/locale/et-EE.ini Added
21
 
1
@@ -0,0 +1,19 @@
2
+CoreAudio.InputCapture="Helisisendi hõive"
3
+CoreAudio.OutputCapture="Heliväljundi hõive"
4
+CoreAudio.Device="Seade"
5
+CoreAudio.Device.Default="Vaikeseade"
6
+DisplayCapture="Kuvari hõive"
7
+DisplayCapture.Display="Kuvar"
8
+DisplayCapture.ShowCursor="Näita kursorit"
9
+WindowCapture="Akna hõive"
10
+WindowCapture.ShowShadow="Näita akna varju"
11
+WindowUtils.Window="Aken"
12
+WindowUtils.ShowEmptyNames="Kuva nimetuid aknaid"
13
+CropMode="Kärbi"
14
+CropMode.None="Pole"
15
+CropMode.Manual="Manuaalne"
16
+Crop.origin.x="Kärbi vasakult"
17
+Crop.origin.y="Kärbi ülevalt"
18
+Crop.size.width="Kärbi paremalt"
19
+Crop.size.height="Kärbi alt"
20
+
21
obs-studio-18.0.1.tar.xz/plugins/mac-syphon/data/locale/et-EE.ini Added
15
 
1
@@ -0,0 +1,13 @@
2
+Syphon="Mängu hõive (Syphon)"
3
+Source="Allikas"
4
+LaunchSyphonInject="Käivita SyphonInject"
5
+Inject="Sisesta"
6
+Application="Rakendus"
7
+SyphonLicense="Syphon litsentsi"
8
+Crop="Kärbi"
9
+Crop.origin.x="Kärbi vasakult"
10
+Crop.origin.y="Kärbi ülevalt"
11
+Crop.size.width="Kärbi paremalt"
12
+Crop.size.height="Kärbi alt"
13
+AllowTransparency="Luba läbipaistvus"
14
+
15
obs-studio-18.0.1.tar.xz/plugins/mac-vth264/data/locale/et-EE.ini Added
14
 
1
@@ -0,0 +1,12 @@
2
+VTH264EncHW="Apple VT H264 riistvara kodeerija"
3
+VTH264EncSW="Apple VT H264 tarkvara kodeerija"
4
+VTEncoder="VideoToolbox kodeerija"
5
+Bitrate="Bitikiirus"
6
+UseMaxBitrate="Piira bitikiirust"
7
+MaxBitrate="Maksimaalne bitikiirus"
8
+Profile="Profiil"
9
+None="(Määramata)"
10
+DefaultEncoder="(Vaikekodeering)"
11
+UseBFrames="Kasuta B-raame"
12
+
13
+
14
obs-studio-18.0.0.tar.xz/plugins/mac-vth264/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/mac-vth264/data/locale/tr-TR.ini Changed
19
 
1
@@ -1,13 +1,13 @@
2
 VTH264EncHW="Apple VT H264 Donanım Kodlayıcı"
3
 VTH264EncSW="Apple VT H264 Yazılım Kodlayıcı"
4
 VTEncoder="VideoToolbox Kodlayıcı"
5
-Bitrate="Bithızı"
6
+Bitrate="Bit hızı"
7
 UseMaxBitrate="Bit hızını sınırla"
8
-MaxBitrate="Maks bit hızı"
9
-KeyframeIntervalSec="Anahtarkare Aralığı (saniye, 0=otomatik)"
10
+MaxBitrate="Maksimum bit hızı"
11
+KeyframeIntervalSec="Anahtar Kare Aralığı (saniye, 0=otomatik)"
12
 Profile="Profil"
13
 None="(Yok)"
14
 DefaultEncoder="(Varsayılan Kodlayıcı)"
15
-UseBFrames="B-Frame kullan"
16
+UseBFrames="B-Karelerini kullan"
17
 
18
 
19
obs-studio-18.0.1.tar.xz/plugins/mac-vth264/data/locale/vi-VN.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+None="(Ingen)"
3
+
4
+
5
obs-studio-18.0.0.tar.xz/plugins/obs-browser/README.md -> obs-studio-18.0.1.tar.xz/plugins/obs-browser/README.md Changed
19
 
1
@@ -51,7 +51,7 @@
2
 ### Building CEF
3
 #### Getting
4
 *  Download CEF Mac 64 from [https://cefbuilds.com/](https://cefbuilds.com/)
5
-  *  At the time of writing this I used build 2883
6
+  *  Use CEF branch 2987
7
 *  Extract and cd into the folder
8
 
9
 #### Setting Up Project
10
@@ -92,7 +92,7 @@
11
 ### Building CEF
12
 #### Getting
13
 *  Download CEF Windows 64bit from [https://cefbuilds.com/](https://cefbuilds.com/)
14
-  *  At the time of writing this I used build 2704
15
+  *  Use CEF branch 2987
16
 *  Extract and cd into the folder
17
 
18
 #### Setting Up Project
19
obs-studio-18.0.0.tar.xz/plugins/obs-browser/shared/browser-app.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-browser/shared/browser-app.cpp Changed
13
 
1
@@ -36,9 +36,9 @@
2
 }
3
 
4
 void BrowserApp::OnRegisterCustomSchemes(
5
-       CefRefPtr<CefSchemeRegistrar> registrar)
6
+       CefRawPtr<CefSchemeRegistrar> registrar)
7
 {
8
-   registrar->AddCustomScheme("http", true, true, false);
9
+   registrar->AddCustomScheme("http", true, false, false, false, true);
10
 }
11
 
12
 void BrowserApp::OnBeforeCommandLineProcessing(
13
obs-studio-18.0.0.tar.xz/plugins/obs-browser/shared/browser-app.hpp -> obs-studio-18.0.1.tar.xz/plugins/obs-browser/shared/browser-app.hpp Changed
10
 
1
@@ -31,7 +31,7 @@
2
 public:
3
    virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;
4
    virtual void OnRegisterCustomSchemes(
5
-           CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
6
+           CefRawPtr<CefSchemeRegistrar> registrar) OVERRIDE;
7
    virtual void OnBeforeCommandLineProcessing(
8
        const CefString& process_type,
9
        CefRefPtr<CefCommandLine> command_line) OVERRIDE;
10
obs-studio-18.0.0.tar.xz/plugins/obs-browser/shared/browser-version.h -> obs-studio-18.0.1.tar.xz/plugins/obs-browser/shared/browser-version.h Changed
8
 
1
@@ -1,3 +1,3 @@
2
 #pragma once
3
 
4
-#define OBS_BROWSER_VERSION "1.28.0"
5
\ No newline at end of file
6
+#define OBS_BROWSER_VERSION "1.29.0"
7
\ No newline at end of file
8
obs-studio-18.0.1.tar.xz/plugins/obs-ffmpeg/data/locale/et-EE.ini Added
36
 
1
@@ -0,0 +1,34 @@
2
+FFmpegOutput="FFmpeg väljund"
3
+Bitrate="Bitikiirus"
4
+
5
+
6
+NVENC.Preset.default="Vaikimisi"
7
+NVENC.Preset.hq="Kõrge kvaliteet"
8
+NVENC.Preset.hp="Suur jõudlus"
9
+NVENC.Preset.bd="Bluray"
10
+NVENC.Preset.ll="Madal-viivitus"
11
+NVENC.Preset.llhq="Madal-viivitus Kõrge kvaliteediga"
12
+NVENC.Preset.llhp="Madal-viivitus suure jõudlusega"
13
+NVENC.Level="Tase"
14
+
15
+FFmpegSource="Meedia allikas"
16
+LocalFile="Kohalik fail"
17
+Looping="Korda"
18
+Input="Sisend"
19
+InputFormat="Sisestus formaat"
20
+ClearOnMediaEnd="Peida allikas kui taasesitus lõppeb"
21
+AudioBufferSize="Audio puhvri suurus (kaadrit)"
22
+ColorRange="YUV värviruumi vahemik"
23
+ColorRange.Auto="Automaatne"
24
+ColorRange.Partial="Osaline"
25
+ColorRange.Full="Täielik"
26
+
27
+
28
+MediaFileFilter.AllMediaFiles="Kõik meediumifailid"
29
+MediaFileFilter.VideoFiles="Videofailid"
30
+MediaFileFilter.AudioFiles="Helifailid"
31
+MediaFileFilter.AllFiles="Kõik failid"
32
+
33
+ReplayBuffer="Taasesituse puhver"
34
+ReplayBuffer.Save="Salvesta Taasesitus"
35
+
36
obs-studio-18.0.0.tar.xz/plugins/obs-ffmpeg/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-ffmpeg/data/locale/tr-TR.ini Changed
14
 
1
@@ -3,10 +3,10 @@
2
 Bitrate="Bit hızı"
3
 Preset="Ön Tanımlı"
4
 RateControl="Oran Kontrolü"
5
-KeyframeIntervalSec="Anahtarkare Aralığı (saniye, 0=otomatik)"
6
+KeyframeIntervalSec="Anahtar Kare Aralığı (saniye, 0=otomatik)"
7
 Lossless="Kayıpsız"
8
 
9
-BFrames="B-frame'leri"
10
+BFrames="B-Kareleri"
11
 
12
 NVENC.Use2Pass="İki Taramalı Kodlama Kullan"
13
 NVENC.Preset.default="Varsayılan"
14
obs-studio-18.0.1.tar.xz/plugins/obs-filters/data/locale/et-EE.ini Added
18
 
1
@@ -0,0 +1,16 @@
2
+ColorFilter="Värvi korrektsioon"
3
+ColorGradeFilter="Lisa LUT"
4
+Gain="Võimendus"
5
+Contrast="Kontrast"
6
+Brightness="Heledus"
7
+Gamma="Gamma"
8
+BrowsePath.Images="Kõik pildifailid"
9
+Crop.Left="Vasakult"
10
+Crop.Right="Paremalt"
11
+Crop.Top="Ülevalt"
12
+Crop.Bottom="Alt"
13
+Crop.Width="Laius"
14
+Crop.Height="Kõrgus"
15
+Crop.Relative="Suhteline"
16
+Amount="Kogus"
17
+
18
obs-studio-18.0.0.tar.xz/plugins/obs-filters/data/locale/fr-FR.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-filters/data/locale/fr-FR.ini Changed
12
 
1
@@ -66,4 +66,10 @@
2
 Saturation="Saturation"
3
 HueShift="Décalage de teinte"
4
 Amount="Quantité"
5
+Compressor="Compresseur"
6
+Compressor.Ratio="Ratio (X:1)"
7
+Compressor.Threshold="Seuil (dB)"
8
+Compressor.AttackTime="Attaque (ms)"
9
+Compressor.ReleaseTime="Libération (ms)"
10
+Compressor.OutputGain="Sortie Gain (dB)"
11
 
12
obs-studio-18.0.0.tar.xz/plugins/obs-filters/data/locale/it-IT.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-filters/data/locale/it-IT.ini Changed
7
 
1
@@ -1,4 +1,5 @@
2
 ColorFilter="Correzione colore"
3
+ColorGradeFilter="Applica LUT"
4
 MaskFilter="Immagine maschera/miscela"
5
 AsyncDelayFilter="Ritardo video (Asincrono)"
6
 CropFilter="Crop/Pad"
7
obs-studio-18.0.0.tar.xz/plugins/obs-filters/data/locale/sv-SE.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-filters/data/locale/sv-SE.ini Changed
8
 
1
@@ -69,4 +69,6 @@
2
 Compressor.Ratio="Förhållande (X:1)"
3
 Compressor.Threshold="Tröskel (dB)"
4
 Compressor.AttackTime="Attack (ms)"
5
+Compressor.ReleaseTime="Frigör (ms)"
6
+Compressor.OutputGain="Utmatningsförstärkning (dB)"
7
 
8
obs-studio-18.0.0.tar.xz/plugins/obs-filters/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-filters/data/locale/tr-TR.ini Changed
27
 
1
@@ -1,4 +1,5 @@
2
 ColorFilter="Renk Düzeltme"
3
+ColorGradeFilter="LUT Uygula"
4
 MaskFilter="Görüntü Maskesi/Blend"
5
 AsyncDelayFilter="Görüntü Gecikmesi (Async)"
6
 CropFilter="Kes/Kaydır"
7
@@ -7,6 +8,7 @@
8
 ColorKeyFilter="Renk Anahtarı"
9
 SharpnessFilter="Keskinleştirme"
10
 ScaleFilter="Ölçeklendirme/Boy Oranı"
11
+UndistortCenter="Ultra genişten boyutlandırırken görüntü merkezindeki bozulmayı düzelt"
12
 NoiseGate="Gürültü Filtresi"
13
 NoiseSuppress="Gürültü Bastırma"
14
 Gain="Kazanç"
15
@@ -63,4 +65,11 @@
16
 NoiseSuppress.SuppressLevel="Bastırma Düzeyi (dB)"
17
 Saturation="Renk Doygunluğu"
18
 HueShift="Ton Kayması"
19
+Amount="Miktar"
20
+Compressor="Sıkıştırma"
21
+Compressor.Ratio="Oran (X:1)"
22
+Compressor.Threshold="Eşik (dB)"
23
+Compressor.AttackTime="Atak (ms)"
24
+Compressor.ReleaseTime="Bırakma (ms)"
25
+Compressor.OutputGain="Çıkış Kazancı (dB)"
26
 
27
obs-studio-18.0.1.tar.xz/plugins/obs-libfdk/data/locale/et-EE.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+LibFDK="libfdk AAC kodeerija"
3
+Bitrate="Bitikiirus"
4
+
5
obs-studio-18.0.1.tar.xz/plugins/obs-outputs/data/locale/et-EE.ini Added
4
 
1
@@ -0,0 +1,2 @@
2
+RTMPStream="RTMP voogedastus"
3
+
4
obs-studio-18.0.0.tar.xz/plugins/obs-outputs/rtmp-stream.c -> obs-studio-18.0.1.tar.xz/plugins/obs-outputs/rtmp-stream.c Changed
153
 
1
@@ -92,9 +92,6 @@
2
        }
3
    }
4
 
5
-   if (stream->socket_thread_active)
6
-       pthread_join(stream->socket_thread, NULL);
7
-
8
    free_packets(stream);
9
    dstr_free(&stream->path);
10
    dstr_free(&stream->key);
11
@@ -109,6 +106,13 @@
12
 #ifdef TEST_FRAMEDROPS
13
    circlebuf_free(&stream->droptest_info);
14
 #endif
15
+
16
+   os_event_destroy(stream->buffer_space_available_event);
17
+   os_event_destroy(stream->buffer_has_data_event);
18
+   os_event_destroy(stream->socket_available_event);
19
+   os_event_destroy(stream->send_thread_signaled_exit);
20
+   pthread_mutex_destroy(&stream->write_buf_mutex);
21
+
22
    if (stream->write_buf)
23
        bfree(stream->write_buf);
24
    bfree(stream);
25
@@ -129,6 +133,32 @@
26
    if (os_event_init(&stream->stop_event, OS_EVENT_TYPE_MANUAL) != 0)
27
        goto fail;
28
 
29
+   if (pthread_mutex_init(&stream->write_buf_mutex, NULL) != 0) {
30
+       warn("Failed to initialize write buffer mutex");
31
+       goto fail;
32
+   }
33
+
34
+   if (os_event_init(&stream->buffer_space_available_event,
35
+       OS_EVENT_TYPE_AUTO) != 0) {
36
+       warn("Failed to initialize write buffer event");
37
+       goto fail;
38
+   }
39
+   if (os_event_init(&stream->buffer_has_data_event,
40
+       OS_EVENT_TYPE_AUTO) != 0) {
41
+       warn("Failed to initialize data buffer event");
42
+       goto fail;
43
+   }
44
+   if (os_event_init(&stream->socket_available_event,
45
+       OS_EVENT_TYPE_AUTO) != 0) {
46
+       warn("Failed to initialize socket buffer event");
47
+       goto fail;
48
+   }
49
+   if (os_event_init(&stream->send_thread_signaled_exit,
50
+       OS_EVENT_TYPE_MANUAL) != 0) {
51
+       warn("Failed to initialize socket exit event");
52
+       goto fail;
53
+   }
54
+
55
    UNUSED_PARAMETER(settings);
56
    return stream;
57
 
58
@@ -390,6 +420,14 @@
59
        info("User stopped the stream");
60
    }
61
 
62
+   if (stream->new_socket_loop) {
63
+       os_event_signal(stream->send_thread_signaled_exit);
64
+       os_event_signal(stream->buffer_has_data_event);
65
+       pthread_join(stream->socket_thread, NULL);
66
+       stream->socket_thread_active = false;
67
+       stream->rtmp.m_bCustomSend = false;
68
+   }
69
+
70
    RTMP_Close(&stream->rtmp);
71
 
72
    if (!stopping(stream)) {
73
@@ -540,26 +578,7 @@
74
            return OBS_OUTPUT_ERROR;
75
        }
76
 
77
-       if (pthread_mutex_init(&stream->write_buf_mutex, NULL) != 0) {
78
-           warn("Failed to initialize write buffer mutex");
79
-           return OBS_OUTPUT_ERROR;
80
-       }
81
-
82
-       if (os_event_init(&stream->buffer_space_available_event,
83
-                   OS_EVENT_TYPE_MANUAL) != 0) {
84
-           warn("Failed to initialize write buffer event");
85
-           return OBS_OUTPUT_ERROR;
86
-       }
87
-       if (os_event_init(&stream->buffer_has_data_event,
88
-                   OS_EVENT_TYPE_MANUAL) != 0) {
89
-           warn("Failed to initialize data buffer event");
90
-           return OBS_OUTPUT_ERROR;
91
-       }
92
-       if (os_event_init(&stream->socket_available_event,
93
-                   OS_EVENT_TYPE_MANUAL) != 0) {
94
-           warn("Failed to initialize socket buffer event");
95
-           return OBS_OUTPUT_ERROR;
96
-       }
97
+       os_event_reset(stream->send_thread_signaled_exit);
98
 
99
        info("New socket loop enabled by user");
100
        if (stream->low_latency_mode)
101
@@ -568,8 +587,37 @@
102
        if (stream->write_buf)
103
            bfree(stream->write_buf);
104
 
105
-       stream->write_buf_size = STREAM_WRITE_BUFFER_SIZE;
106
-       stream->write_buf = bmalloc(STREAM_WRITE_BUFFER_SIZE);
107
+       int total_bitrate = 0;
108
+       obs_output_t  *context  = stream->output;
109
+
110
+       obs_encoder_t *vencoder = obs_output_get_video_encoder(context);
111
+       if (vencoder) {
112
+           obs_data_t *params = obs_encoder_get_settings(vencoder);
113
+           if (params) {
114
+               int bitrate = obs_data_get_int(params, "bitrate");
115
+               total_bitrate += bitrate;
116
+               obs_data_release(params);
117
+           }
118
+       }
119
+
120
+       obs_encoder_t *aencoder = obs_output_get_audio_encoder(context, 0);
121
+       if (aencoder) {
122
+           obs_data_t *params = obs_encoder_get_settings(aencoder);
123
+           if (params) {
124
+               int bitrate = obs_data_get_int(params, "bitrate");
125
+               total_bitrate += bitrate;
126
+               obs_data_release(params);
127
+           }
128
+       }
129
+
130
+       // to bytes/sec
131
+       int ideal_buffer_size = total_bitrate * 128;
132
+
133
+       if (ideal_buffer_size < 131072)
134
+           ideal_buffer_size = 131072;
135
+
136
+       stream->write_buf_size = ideal_buffer_size;
137
+       stream->write_buf = bmalloc(ideal_buffer_size);
138
 
139
 #ifdef _WIN32
140
        ret = pthread_create(&stream->socket_thread, NULL,
141
@@ -741,11 +789,6 @@
142
        pthread_join(stream->send_thread, NULL);
143
    }
144
 
145
-   if (stream->socket_thread_active) {
146
-       pthread_join(stream->socket_thread, NULL);
147
-       stream->socket_thread_active = false;
148
-   }
149
-
150
    free_packets(stream);
151
 
152
    service = obs_output_get_service(stream->output);
153
obs-studio-18.0.0.tar.xz/plugins/obs-outputs/rtmp-stream.h -> obs-studio-18.0.1.tar.xz/plugins/obs-outputs/rtmp-stream.h Changed
18
 
1
@@ -31,8 +31,6 @@
2
 #define OPT_NEWSOCKETLOOP_ENABLED "new_socket_loop_enabled"
3
 #define OPT_LOWLATENCY_ENABLED "low_latency_mode_enabled"
4
 
5
-#define STREAM_WRITE_BUFFER_SIZE 524288
6
-
7
 //#define TEST_FRAMEDROPS
8
 
9
 #ifdef TEST_FRAMEDROPS
10
@@ -104,6 +102,7 @@
11
    os_event_t       *buffer_space_available_event;
12
    os_event_t       *buffer_has_data_event;
13
    os_event_t       *socket_available_event;
14
+   os_event_t       *send_thread_signaled_exit;
15
 };
16
 
17
 #ifdef _WIN32
18
obs-studio-18.0.0.tar.xz/plugins/obs-outputs/rtmp-windows.c -> obs-studio-18.0.1.tar.xz/plugins/obs-outputs/rtmp-windows.c Changed
77
 
1
@@ -7,6 +7,7 @@
2
    closesocket(stream->rtmp.m_sb.sb_socket);
3
    stream->rtmp.m_sb.sb_socket = -1;
4
    stream->write_buf_len = 0;
5
+   os_event_signal(stream->buffer_space_available_event);
6
 }
7
 
8
 static bool socket_event(struct rtmp_stream *stream, bool *can_write,
9
@@ -15,9 +16,9 @@
10
    WSANETWORKEVENTS net_events;
11
    bool success;
12
 
13
-   success = !!WSAEnumNetworkEvents(stream->rtmp.m_sb.sb_socket, NULL,
14
+   success = !WSAEnumNetworkEvents(stream->rtmp.m_sb.sb_socket, NULL,
15
            &net_events);
16
-   if (success) {
17
+   if (!success) {
18
        blog(LOG_ERROR, "socket_thread_windows: Aborting due to "
19
                "WSAEnumNetworkEvents failure, %d",
20
                WSAGetLastError());
21
@@ -231,6 +232,8 @@
22
    return exit_loop ? RET_BREAK : RET_CONTINUE;
23
 }
24
 
25
+#define LATENCY_FACTOR 20
26
+
27
 static inline void socket_thread_windows_internal(struct rtmp_stream *stream)
28
 {
29
    bool can_write = false;
30
@@ -251,8 +254,8 @@
31
    send_backlog_event = CreateEvent(NULL, true, false, NULL);
32
 
33
    if (stream->low_latency_mode) {
34
-       delay_time = 1400.0f / (stream->write_buf_size / 1000.0f);
35
-       latency_packet_size = 1460;
36
+       delay_time = 1000 / LATENCY_FACTOR;
37
+       latency_packet_size = stream->write_buf_size / (LATENCY_FACTOR - 2);
38
    } else {
39
        latency_packet_size = stream->write_buf_size;
40
        delay_time = 0;
41
@@ -276,11 +279,12 @@
42
    objs[2] = send_backlog_event;
43
 
44
    for (;;) {
45
-       if (os_event_try(stream->stop_event) != EAGAIN) {
46
+       if (os_event_try(stream->send_thread_signaled_exit) != EAGAIN) {
47
            pthread_mutex_lock(&stream->write_buf_mutex);
48
            if (stream->write_buf_len == 0) {
49
                //blog(LOG_DEBUG, "Exiting on empty buffer");
50
                pthread_mutex_unlock(&stream->write_buf_mutex);
51
+               os_event_reset(stream->send_thread_signaled_exit);
52
                break;
53
            }
54
 
55
@@ -321,15 +325,20 @@
56
 
57
                switch (ret) {
58
                case RET_BREAK:
59
-                   break;
60
+                   goto exit_write_loop;
61
                case RET_FATAL:
62
                    return;
63
                case RET_CONTINUE:;
64
                }
65
            }
66
        }
67
+       exit_write_loop:;
68
    }
69
 
70
+   if (stream->rtmp.m_sb.sb_socket != INVALID_SOCKET)
71
+       WSAEventSelect(stream->rtmp.m_sb.sb_socket,
72
+           stream->socket_available_event, 0);
73
+
74
    blog(LOG_INFO, "socket_thread_windows: Normal exit");
75
 }
76
 
77
obs-studio-18.0.1.tar.xz/plugins/obs-qsv11/data/locale/et-EE.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+Bitrate="Bitikiirus"
3
+MaxBitrate="Maksimaalne bitikiirus"
4
+
5
obs-studio-18.0.0.tar.xz/plugins/obs-qsv11/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-qsv11/data/locale/tr-TR.ini Changed
12
 
1
@@ -1,8 +1,8 @@
2
 TargetUsage="Hedef Kullanımı"
3
 Bitrate="Bit hızı"
4
-MaxBitrate="Maks Bit hızı"
5
+MaxBitrate="Maksimum Bit Hızı"
6
 RateControl="Oran Kontrolü"
7
-KeyframeIntervalSec="Anahtarkare Aralığı (saniye, 0=otomatik)"
8
+KeyframeIntervalSec="Anahtar Kare Aralığı (saniye, 0=otomatik)"
9
 Profile="Profil"
10
 AsyncDepth="Eşzamansız Derinlik"
11
 Accuracy="Doğruluk"
12
obs-studio-18.0.1.tar.xz/plugins/obs-text/data/locale/et-EE.ini Added
15
 
1
@@ -0,0 +1,13 @@
2
+TextGDIPlus="Tekst (GDI +)"
3
+Font="Font"
4
+Text="Tekst"
5
+ReadFromFile="Loe failist"
6
+Color="Värv"
7
+Opacity="Läbipaistvus"
8
+Alignment.Center="Keskele"
9
+Outline="Kontuur"
10
+Outline.Size="Kontuuri suurus"
11
+Outline.Color="Kontuuri värv"
12
+Width="Laius"
13
+Height="Kõrgus"
14
+
15
obs-studio-18.0.0.tar.xz/plugins/obs-text/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-text/data/locale/tr-TR.ini Changed
10
 
1
@@ -25,6 +25,8 @@
2
 Outline.Size="Anahat Boyutu"
3
 Outline.Color="Anahat Rengi"
4
 Outline.Opacity="Anahat Saydamlığı"
5
+ChatlogMode="Sohbet Günlük Modu"
6
+ChatlogMode.Lines="Sohbet Günlük Satır Sınırı"
7
 UseCustomExtents="İsteğe Bağlı Metin Boyutu Kullan"
8
 UseCustomExtents.Wrap="Metni Kaydır"
9
 Width="Genişlik"
10
obs-studio-18.0.1.tar.xz/plugins/obs-transitions/data/locale/et-EE.ini Added
25
 
1
@@ -0,0 +1,23 @@
2
+FadeTransition="Hajuv"
3
+CutTransition="Lõika"
4
+SwipeTransition="Pühkiv"
5
+SlideTransition="Lenda sisse"
6
+FadeToColorTransition="Haju värvi"
7
+Direction="Suunas"
8
+Direction.Left="Vasakule"
9
+Direction.Right="Paremale"
10
+Direction.Up="Üles"
11
+Direction.Down="Alla"
12
+SwipeIn="Pühi sisse"
13
+Color="Värv"
14
+LumaWipe.Image="Pilt"
15
+LumaWipe.Invert="Teistpidi"
16
+LumaWipe.Softness="Pehmus"
17
+LumaWipe.Type.BoxTopLeft="Kast üleval vasakul"
18
+LumaWipe.Type.BoxTopRight="Kast üleval paremal"
19
+LumaWipe.Type.Burst="Plahvatuse"
20
+LumaWipe.Type.Clock="Kell"
21
+LumaWipe.Type.Cloud="Pilv"
22
+LumaWipe.Type.Curtain="Kardin"
23
+LumaWipe.Type.Fan="Ventilaator"
24
+
25
obs-studio-18.0.0.tar.xz/plugins/obs-transitions/data/locale/sv-SE.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-transitions/data/locale/sv-SE.ini Changed
9
 
1
@@ -10,6 +10,7 @@
2
 Direction.Down="Ned"
3
 SwipeIn="Svep in"
4
 Color="Färg"
5
+SwitchPoint="Maxpunkt för färg (procent)"
6
 LumaWipeTransition="Luma Wipe"
7
 LumaWipe.Image="Bild"
8
 LumaWipe.Invert="Invertera"
9
obs-studio-18.0.0.tar.xz/plugins/obs-vst/VSTPlugin.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/VSTPlugin.cpp Changed
118
 
1
@@ -22,7 +22,7 @@
2
        sourceContext{sourceContext} {
3
 
4
    int numChannels = VST_MAX_CHANNELS;
5
-   int blocksize = 512;
6
+   int blocksize = BLOCK_SIZE;
7
 
8
    inputs = (float **) malloc(sizeof(float **) * numChannels);
9
    outputs = (float **) malloc(sizeof(float **) * numChannels);
10
@@ -50,12 +50,14 @@
11
        if (!effect)
12
        {
13
            //TODO: alert user of error
14
+           blog(LOG_WARNING, "VST Plug-in: Can't load "
15
+                   "effect!");
16
            return;
17
        }
18
 
19
        // Check plug-in's magic number
20
-       // If incorrect, then the file either was not loaded properly, is not a
21
-       // real VST plug-in, or is otherwise corrupt.
22
+       // If incorrect, then the file either was not loaded properly,
23
+       // is not a real VST plug-in, or is otherwise corrupt.
24
        if (effect->magic != kEffectMagic)
25
        {
26
            blog(LOG_WARNING, "VST Plug-in's magic number is bad");
27
@@ -69,13 +71,17 @@
28
                obs_get_audio());
29
        effect->dispatcher(effect, effSetSampleRate, 0, 0, nullptr,
30
                sampleRate);
31
-       int blocksize = 512;
32
+       int blocksize = BLOCK_SIZE;
33
        effect->dispatcher(effect, effSetBlockSize, 0, blocksize,
34
                nullptr, 0.0f);
35
 
36
        effect->dispatcher(effect, effMainsChanged, 0, 1, nullptr, 0);
37
 
38
        effectReady = true;
39
+
40
+       if (openInterfaceWhenActive) {
41
+           openEditor();
42
+       }
43
    }
44
 }
45
 
46
@@ -95,7 +101,12 @@
47
 
48
        float *adata[VST_MAX_CHANNELS];
49
        for (size_t d = 0; d < VST_MAX_CHANNELS; d++) {
50
-           adata[d] = (float *) audio->data[d];
51
+            if (audio->data[d] != NULL) {
52
+                adata[d] = (float *) audio->data[d];
53
+            }
54
+            else {
55
+                adata[d] = inputs[d];
56
+            }
57
        };
58
 
59
        effect->processReplacing(effect, adata, outputs, audio->frames);
60
@@ -166,7 +177,8 @@
61
            filtered = true;
62
        else
63
        {
64
-           blog(LOG_WARNING, "VST Plug-in: Future idle calls will not be displayed!");
65
+           blog(LOG_WARNING, "VST Plug-in: Future idle calls "
66
+           "will not be displayed!");
67
            wasIdle = true;
68
        }
69
    }
70
@@ -195,7 +207,8 @@
71
    {
72
        void *buf = nullptr;
73
 
74
-       intptr_t chunkSize = effect->dispatcher(effect, effGetChunk, 1, 0, &buf, 0.0);
75
+       intptr_t chunkSize = effect->dispatcher(effect, effGetChunk, 1,
76
+               0, &buf, 0.0);
77
 
78
        QByteArray data = QByteArray((char *) buf, chunkSize);
79
        return QString(data.toBase64()).toStdString();
80
@@ -207,7 +220,8 @@
81
        }
82
 
83
        const char *bytes = reinterpret_cast<const char *>(&params[0]);
84
-       QByteArray data = QByteArray(bytes, sizeof(float) * params.size());
85
+       QByteArray data = QByteArray(bytes, sizeof(float) *
86
+               params.size());
87
        std::string encoded = QString(data.toBase64()).toStdString();
88
        return encoded;
89
    }
90
@@ -226,7 +240,8 @@
91
        QByteArray chunkData = QByteArray::fromBase64(base64Data);
92
        void *buf = nullptr;
93
        buf = chunkData.data();
94
-       effect->dispatcher(effect, effSetChunk, 0, chunkData.length(), buf, 0);
95
+       effect->dispatcher(effect, effSetChunk, 1, chunkData.length(),
96
+               buf, 0);
97
    } else {
98
        QByteArray base64Data = QByteArray(data.c_str(),
99
                data.length());
100
@@ -250,3 +265,16 @@
101
        }
102
    }
103
 }
104
+
105
+void VSTPlugin::setProgram(const int programNumber) {
106
+   if (programNumber < effect->numPrograms) {
107
+       effect->dispatcher(effect, effSetProgram, 0, programNumber, NULL, 0.0f);
108
+   }
109
+   else {
110
+       blog(LOG_ERROR, "Failed to load program, number was outside possible program range.");
111
+   }
112
+}
113
+
114
+int VSTPlugin::getProgram() {
115
+   return effect->dispatcher(effect, effGetProgram, 0, 0, NULL, 0.0f);
116
+}
117
\ No newline at end of file
118
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/ca-ES.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Obre l'interfície de l'extensió"
3
+ClosePluginInterface="Tanca la interfície de l'extensió"
4
+VstPlugin="Extensió VST 2.x"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/cs-CZ.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Otevřít rozhraní Plug-inu"
3
+ClosePluginInterface="Zavřít rozhraní Plug-inu"
4
+VstPlugin="VST 2.x Plug-in"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/da-DK.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Åbn plug-in grænseflade"
3
+ClosePluginInterface="Luk plug-in grænseflade"
4
+VstPlugin="VST 2.x plug-in"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/de-DE.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+OpenPluginInterface="Öffne Plug-in-Schnittstelle"
3
+ClosePluginInterface="Schließe Plug-in-Schnittstelle"
4
+VstPlugin="VST 2.x Plug-in"
5
+OpenInterfaceWhenActive="Öffne Schnittstelle, wenn aktiv"
6
obs-studio-18.0.0.tar.xz/plugins/obs-vst/data/locale/en-US.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/en-US.ini Changed
7
 
1
@@ -1,3 +1,4 @@
2
 OpenPluginInterface="Open Plug-in Interface"
3
 ClosePluginInterface="Close Plug-in Interface"
4
 VstPlugin="VST 2.x Plug-in"
5
+OpenInterfaceWhenActive="Open interface when active"
6
\ No newline at end of file
7
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/es-ES.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Abrir la interfaz de la extensión"
3
+ClosePluginInterface="Cerrar la interfaz de la extensión"
4
+VstPlugin="Extensión VST 2.x"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/eu-ES.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Ireki pluginaren interfazea"
3
+ClosePluginInterface="Itxi pluginaren interfazea"
4
+VstPlugin="VST 2.x Plugina"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/fi-FI.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+OpenPluginInterface="Avaa liitännäisen käyttöliittymä"
3
+ClosePluginInterface="Sulje liitännäisen käyttöliittymä"
4
+VstPlugin="VST 2.x Plug-in"
5
+OpenInterfaceWhenActive="Avaa käyttöliittymä kun aktiivinen"
6
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/fr-FR.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Afficher l'interface graphique du plug-in"
3
+ClosePluginInterface="Fermer l'interface graphique du plug-in"
4
+VstPlugin="Plug-in VST 2.x"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/hu-HU.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+OpenPluginInterface="Bővítmény interfész megnyitása"
3
+ClosePluginInterface="Bővítmény interfész bezárása"
4
+VstPlugin="VST 2.x Bővítmény"
5
+OpenInterfaceWhenActive="Interfész megnyitása, amikor aktív"
6
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/ja-JP.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+OpenPluginInterface="プラグインインターフェイスを開く"
3
+ClosePluginInterface="プラグインインターフェイスを閉じる"
4
+VstPlugin="VST 2.x プラグイン"
5
+OpenInterfaceWhenActive="アクティブな時にインターフェイスを開く"
6
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/ko-KR.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="플러그인 설정 열기"
3
+ClosePluginInterface="플러그인 설정 닫기"
4
+VstPlugin="VST 2.x 플러그인"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/nl-NL.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Open Plugin Interface"
3
+ClosePluginInterface="Sluit Plugin Interface"
4
+VstPlugin="VST 2.x Plugin"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/pl-PL.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+OpenPluginInterface="Otwórz panel wtyczki"
3
+ClosePluginInterface="Zamknij panel wtyczki"
4
+VstPlugin="Wtyczka VST 2.x"
5
+OpenInterfaceWhenActive="Otwórz panel, gdy wtyczka aktywna"
6
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/pt-BR.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Abrir Interface do Plugin"
3
+ClosePluginInterface="Fechar Interface do Plugin"
4
+VstPlugin="Plugin VST 2.x"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/ru-RU.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Открыть интерфейс плагина"
3
+ClosePluginInterface="Закрыть интерфейс плагина"
4
+VstPlugin="Плагин VST 2.x"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/sv-SE.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Öppna tilläggets gränssnitt"
3
+ClosePluginInterface="Stäng tilläggets gränssnitt"
4
+VstPlugin="VST 2.x-tillägg"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/tr-TR.ini Added
3
 
1
@@ -0,0 +1,1 @@
2
+VstPlugin="VST 2.x Eklentisi"
3
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/uk-UA.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="Відкрити інтерфейс плагіна"
3
+ClosePluginInterface="Закрити інтерфейс плагіна"
4
+VstPlugin="VST 2.x Плагін"
5
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/zh-CN.ini Added
6
 
1
@@ -0,0 +1,4 @@
2
+OpenPluginInterface="打开插件界面"
3
+ClosePluginInterface="关闭插件界面"
4
+VstPlugin="VST 2.x 插件"
5
+OpenInterfaceWhenActive="活跃时打开界面"
6
obs-studio-18.0.1.tar.xz/plugins/obs-vst/data/locale/zh-TW.ini Added
5
 
1
@@ -0,0 +1,3 @@
2
+OpenPluginInterface="開啟外掛程式界面"
3
+ClosePluginInterface="關閉外掛程式介面"
4
+VstPlugin="VST 2.x 外掛程式"
5
obs-studio-18.0.0.tar.xz/plugins/obs-vst/headers/EditorWidget.h -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/headers/EditorWidget.h Changed
39
 
1
@@ -1,5 +1,6 @@
2
 /*****************************************************************************
3
 Copyright (C) 2016-2017 by Colin Edwards.
4
+Additional Code Copyright (C) 2016-2017 by c3r1c3 <c3r1c3@nevermindonline.com>
5
 
6
 This program is free software: you can redistribute it and/or modify
7
 it under the terms of the GNU General Public License as published by
8
@@ -21,6 +22,12 @@
9
 #include <QWidget>
10
 #ifdef __APPLE__
11
    #include <QMacCocoaViewContainer>
12
+#elif WIN32
13
+   #include <QWindow>
14
+   #include <Windows.h>
15
+#elif __linux__
16
+   #include <QWindow>
17
+   #include <xcb/xcb.h>
18
 #endif
19
 
20
 #include "aeffectx.h"
21
@@ -28,8 +35,8 @@
22
 
23
 class VSTPlugin;
24
 
25
-class VstRect
26
-{
27
+class VstRect {
28
+
29
    public:
30
        short top;
31
        short left;
32
@@ -56,4 +63,4 @@
33
        void handleResizeRequest(int width, int height);
34
 };
35
 
36
-#endif //OBS_STUDIO_EDITORDIALOG_H
37
\ No newline at end of file
38
+#endif //OBS_STUDIO_EDITORDIALOG_H
39
obs-studio-18.0.0.tar.xz/plugins/obs-vst/headers/VSTPlugin.h -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/headers/VSTPlugin.h Changed
39
 
1
@@ -20,13 +20,16 @@
2
 #define OBS_STUDIO_VSTPLUGIN_H
3
 
4
 #define VST_MAX_CHANNELS    8
5
+#define BLOCK_SIZE          512
6
 
7
 #include <string>
8
-#include "aeffectx.h"
9
+#include <QDirIterator>
10
 #include <obs-module.h>
11
+#include "aeffectx.h"
12
 #include "vst-plugin-callbacks.hpp"
13
 #include "EditorWidget.h"
14
 
15
+
16
 #ifdef __APPLE__
17
    #include <CoreFoundation/CoreFoundation.h>
18
 #endif
19
@@ -47,7 +50,7 @@
20
 
21
    bool effectReady = false;
22
 
23
-   #ifdef __APPLE__
24
+#ifdef __APPLE__
25
        CFBundleRef bundle = NULL;
26
    #elif WIN32
27
        HINSTANCE dllHandle = nullptr;
28
@@ -88,7 +91,10 @@
29
        void closeEditor();
30
        std::string getChunk();
31
        void setChunk(std::string data);
32
+       void setProgram(const int programNumber);
33
+       int getProgram();
34
        obs_audio_data* process(struct obs_audio_data *audio);
35
+       bool openInterfaceWhenActive = false;
36
 };
37
 
38
 #endif //OBS_STUDIO_VSTPLUGIN_H
39
obs-studio-18.0.0.tar.xz/plugins/obs-vst/linux/EditorWidget-linux.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/linux/EditorWidget-linux.cpp Changed
141
 
1
@@ -2,10 +2,6 @@
2
 Copyright (C) 2016-2017 by Colin Edwards.
3
 Additional Code Copyright (C) 2016-2017 by c3r1c3 <c3r1c3@nevermindonline.com>
4
 
5
-Special thanks to Nik Reiman for sharing his awesome code with the world.
6
-Some of the original code can be found here:
7
-https://github.com/teragonaudio/MrsWatson/blob/master/source/plugin/PluginVst2xLinux.cpp
8
-
9
 This program is free software: you can redistribute it and/or modify
10
 it under the terms of the GNU General Public License as published by
11
 the Free Software Foundation, either version 2 of the License, or
12
@@ -22,87 +18,67 @@
13
 
14
 #include "../headers/EditorWidget.h"
15
 
16
-#include <X11/Xlib.h>
17
-#include <QWindow>
18
-
19
-
20
 void EditorWidget::buildEffectContainer(AEffect *effect) {
21
-   Display *display;
22
-   Window window;
23
-   XEvent event;
24
 
25
-   int screenNumber;
26
-
27
-   blog(LOG_WARNING, "Opening X display");
28
-   display = XOpenDisplay(NULL);
29
-   if (display == NULL)
30
+   /* First we open a connection to the X Server. */
31
+   xcb_connection_t *connection = xcb_connect(NULL, NULL);
32
+   if (xcb_connection_has_error(connection) >= 1)
33
    {
34
-       blog(LOG_WARNING, "Can't open default display");
35
+       blog(LOG_ERROR, "VST: Couldn't connect to XCB.");
36
        return;
37
    }
38
 
39
-   blog(LOG_WARNING, "Acquiring default screen for X display");
40
-   screenNumber = DefaultScreen(display);
41
-   Screen *screen = DefaultScreenOfDisplay(display);
42
-
43
-   int screenWidth = WidthOfScreen(screen);
44
-   int screenHeight = HeightOfScreen(screen);
45
-   blog(LOG_WARNING, "Screen dimensions: %dx%d", screenWidth, screenHeight);
46
-
47
-   // Default size is 300x300 pixels
48
-   int windowX = (screenWidth - 300) / 2;
49
-   int windowY = (screenHeight - 300) / 2;
50
-
51
-   blog(LOG_WARNING, "Creating window at %dx%d", windowX, windowY);
52
-   window = XCreateSimpleWindow(display, RootWindow(display, screenNumber),
53
-           0, 0, 300, 300, 1, BlackPixel(display, screenNumber),
54
-           BlackPixel(display, screenNumber));
55
-
56
-   //XStoreName(display, window, pluginName->data);
57
-/*
58
-   XSelectInput(display, window, ExposureMask | KeyPressMask);
59
-   XMapWindow(display, window);
60
-   XMoveWindow(display, window, windowX, windowY);
61
-
62
-
63
-   blog(LOG_WARNING, "Opening plugin editor window");
64
-   effect->dispatcher(effect, effEditOpen, 0, 0, (void *) window, 0);
65
-
66
-   while (true) {
67
-       XNextEvent(display, &event);
68
-
69
-       if (event.type == Expose) {
70
-       }
71
-
72
-       if (event.type == KeyPress) {
73
-           break;
74
-       }
75
+   /* Now get the default/first screen. */
76
+   const xcb_setup_t      *setup  = xcb_get_setup (connection);
77
+   xcb_screen_iterator_t   iter   = xcb_setup_roots_iterator (setup);
78
+   xcb_screen_t           *screen = iter.data;
79
+   if (!screen)
80
+   {
81
+       blog(LOG_WARNING, "VST: Couldn't setup screen.");
82
+       return;
83
    }
84
 
85
-   blog(LOG_WARNING, "Closing plugin editor window");
86
-   effect->dispatcher(effect, effEditClose, 0, 0, 0, 0);
87
-   XDestroyWindow(display, window);
88
-   XCloseDisplay(display);
89
-*/
90
-   /*
91
-   QWidget *widget = QWidget::createWindowContainer(QWindow::window);
92
+   /* Create the window */
93
+   xcb_window_t window = xcb_generate_id (connection);
94
+   xcb_create_window (
95
+       connection,                    /* Connection          */
96
+       XCB_COPY_FROM_PARENT,          /* depth (same as root)*/
97
+       window,                        /* window Id           */
98
+       screen->root,                  /* parent window       */
99
+       0, 0,                          /* x, y                */
100
+       150, 150,                      /* width, height       */
101
+       10,                            /* border_width        */
102
+       XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
103
+       screen->root_visual,           /* visual              */
104
+       0, NULL                        /* masks, not used yet */
105
+   );
106
+
107
+   /* Map the window on the screen */
108
+   xcb_map_window (connection, window);
109
+
110
+   /* Make sure to flush so the Window shows. */
111
+   xcb_flush (connection);
112
+
113
+   /* Now we re-parent the Window to QT so we can better control it. */
114
+   QWidget *widget = QWidget::createWindowContainer(
115
+           QWindow::fromWinId(window), this);
116
    widget->move(0, 0);
117
    widget->resize(300, 300);
118
 
119
-   effect->dispatcher(effect, effEditOpen, 0, 0, window, 0);
120
+   effect->dispatcher(effect, effEditOpen, 0, 0, (void *)window, 0);
121
 
122
    VstRect* vstRect = nullptr;
123
    effect->dispatcher(effect, effEditGetRect, 0, 0, &vstRect, 0);
124
+
125
    if (vstRect)
126
    {
127
        widget->resize(vstRect->right - vstRect->left,
128
-                  vstRect->bottom - vstRect->top);
129
+               vstRect->bottom - vstRect->top);
130
    }
131
-    */
132
 }
133
 
134
 void EditorWidget::handleResizeRequest(int width, int height) {
135
    // We don't have to do anything here as far as I can tell.
136
    // The widget will resize the HWIND itself and then
137
    // this widget will automatically size depending on that.
138
-}
139
\ No newline at end of file
140
+}
141
obs-studio-18.0.0.tar.xz/plugins/obs-vst/linux/VSTPlugin-linux.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/linux/VSTPlugin-linux.cpp Changed
38
 
1
@@ -18,23 +18,21 @@
2
 #include "../headers/VSTPlugin.h"
3
 
4
 #include <util/platform.h>
5
-#include <X11/Xlib.h>
6
 
7
 AEffect* VSTPlugin::loadEffect() {
8
    AEffect *plugin = nullptr;
9
 
10
-   soHandle = dlopen(pluginPath.c_str(), RTLD_LAZY);
11
-   bfree(wpath);
12
-   bfree(charPath);
13
+   soHandle = os_dlopen(pluginPath.c_str());
14
    if(soHandle == nullptr)
15
    {
16
-       blog(LOG_WARNING, "Failed trying to load VST from '%s', error %d\n",
17
-               pluginPath.c_str(), errno);
18
+       blog(LOG_WARNING, "Failed trying to load VST from '%s',"
19
+               "error %d\n", pluginPath.c_str(), errno);
20
        return nullptr;
21
    }
22
 
23
-   vstPluginMain mainEntryPoint =
24
-           (vstPluginMain)(soHandle, "VSTPluginMain");
25
+   vstPluginMain mainEntryPoint;
26
+
27
+   mainEntryPoint = (vstPluginMain)os_dlsym(soHandle, "VSTPluginMain");
28
 
29
    if (mainEntryPoint == nullptr) {
30
        mainEntryPoint =
31
@@ -62,4 +60,4 @@
32
        os_dlclose(soHandle);
33
        soHandle = nullptr;
34
    }
35
-}
36
\ No newline at end of file
37
+}
38
obs-studio-18.0.0.tar.xz/plugins/obs-vst/obs-vst.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/obs-vst.cpp Changed
51
 
1
@@ -17,15 +17,15 @@
2
 *****************************************************************************/
3
 
4
 #include "headers/VSTPlugin.h"
5
-#include <QDir>
6
-#include <QDirIterator>
7
 
8
-#define OPEN_VST_SETTINGS      "open_vst_settings"
9
-#define CLOSE_VST_SETTINGS     "close_vst_settings"
10
+#define OPEN_VST_SETTINGS             "open_vst_settings"
11
+#define CLOSE_VST_SETTINGS            "close_vst_settings"
12
+#define OPEN_WHEN_ACTIVE_VST_SETTINGS "open_when_active_vst_settings"
13
 
14
-#define PLUG_IN_NAME            obs_module_text("VstPlugin")
15
-#define OPEN_VST_TEXT           obs_module_text("OpenPluginInterface")
16
-#define CLOSE_VST_TEXT          obs_module_text("ClosePluginInterface")
17
+#define PLUG_IN_NAME              obs_module_text("VstPlugin")
18
+#define OPEN_VST_TEXT             obs_module_text("OpenPluginInterface")
19
+#define CLOSE_VST_TEXT            obs_module_text("ClosePluginInterface")
20
+#define OPEN_WHEN_ACTIVE_VST_TEXT obs_module_text("OpenInterfaceWhenActive")
21
 
22
 OBS_DECLARE_MODULE()
23
 OBS_MODULE_USE_DEFAULT_LOCALE("obs-vst", "en-US")
24
@@ -83,6 +83,8 @@
25
 {
26
    VSTPlugin *vstPlugin = (VSTPlugin *)data;
27
 
28
+   vstPlugin->openInterfaceWhenActive = obs_data_get_bool(settings, OPEN_WHEN_ACTIVE_VST_SETTINGS);
29
+
30
    const char *path = obs_data_get_string(settings, "plugin_path");
31
 
32
    if (strcmp(path, "") == 0)
33
@@ -94,8 +96,6 @@
34
    const char *chunkData = obs_data_get_string(settings, "chunk_data");
35
    if (chunkData && strlen(chunkData) > 0) {
36
        vstPlugin->setChunk(std::string(chunkData));
37
-       obs_data_set_string(settings, "chunk_data",
38
-               vstPlugin->getChunk().c_str());
39
    }
40
 }
41
 
42
@@ -235,6 +235,8 @@
43
    obs_property_set_visible(obs_properties_get(props,
44
            CLOSE_VST_SETTINGS), false);
45
 
46
+   obs_properties_add_bool(props, OPEN_WHEN_ACTIVE_VST_SETTINGS, OPEN_WHEN_ACTIVE_VST_TEXT);
47
+
48
    UNUSED_PARAMETER(data);
49
 
50
    return props;
51
obs-studio-18.0.0.tar.xz/plugins/obs-vst/win/EditorWidget-win.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/win/EditorWidget-win.cpp Changed
26
 
1
@@ -17,12 +17,8 @@
2
 
3
 #include "../headers/EditorWidget.h"
4
 
5
-#include <QWindow>
6
-#include <Windows.h>
7
-
8
 void EditorWidget::buildEffectContainer(AEffect *effect) {
9
-   WNDCLASSEX wcex{ sizeof(wcex)
10
-   };
11
+   WNDCLASSEX wcex{ sizeof(wcex)};
12
 
13
    wcex.lpfnWndProc = DefWindowProc;
14
    wcex.hInstance = GetModuleHandle(0);
15
@@ -52,5 +48,7 @@
16
 }
17
 
18
 void EditorWidget::handleResizeRequest(int width, int height) {
19
-   // We don't have to do anything here as far as I can tell. The widget will resize the HWIND itself and then this widget will automatically size depending on that.
20
-}
21
\ No newline at end of file
22
+   // We don't have to do anything here as far as I can tell.
23
+   // The widget will resize the HWIND itself and then this
24
+   // widget will automatically size depending on that.
25
+}
26
obs-studio-18.0.0.tar.xz/plugins/obs-vst/win/VSTPlugin-win.cpp -> obs-studio-18.0.1.tar.xz/plugins/obs-vst/win/VSTPlugin-win.cpp Changed
17
 
1
@@ -34,10 +34,12 @@
2
 
3
        // Display the error message and exit the process
4
        if (errorCode == ERROR_BAD_EXE_FORMAT) {
5
-           blog(LOG_WARNING, "Could not open library, wrong architecture.");
6
+           blog(LOG_WARNING, "Could not open library, "
7
+                   "wrong architecture.");
8
        } else {
9
-           blog(LOG_WARNING, "Failed trying to load VST from '%s', error %d\n",
10
-           pluginPath, GetLastError());
11
+           blog(LOG_WARNING, "Failed trying to load VST from '%s'"
12
+                   ", error %d\n", pluginPath,
13
+                   GetLastError());
14
        }
15
        return nullptr;
16
    }
17
obs-studio-18.0.0.tar.xz/plugins/obs-x264/data/locale/et-EE.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-x264/data/locale/et-EE.ini Changed
9
 
1
@@ -1,4 +1,7 @@
2
 Bitrate="Bitikiirus"
3
 CustomBufsize="Kasuta kohandatud puhvri suurust"
4
 BufferSize="Puhvri suurus"
5
+Profile="Profiil"
6
+None="(Määramata)"
7
+EncoderOptions="x264 suvandid (eraldatud tühikutega)"
8
 
9
obs-studio-18.0.0.tar.xz/plugins/obs-x264/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/obs-x264/data/locale/tr-TR.ini Changed
10
 
1
@@ -3,7 +3,7 @@
2
 BufferSize="Arabellek Boyutu"
3
 RateControl="Oran Kontrolü"
4
 CRF="CRF"
5
-KeyframeIntervalSec="Anahtarkare Aralığı (saniye, 0=otomatik)"
6
+KeyframeIntervalSec="Anahtar Kare Aralığı (saniye, 0=otomatik)"
7
 CPUPreset="CPU Kullanım Önayarı (yüksek = az CPU kullanımı)"
8
 Profile="Profil"
9
 Tune="Ayarla"
10
obs-studio-18.0.1.tar.xz/plugins/rtmp-services/data/locale/et-EE.ini Added
12
 
1
@@ -0,0 +1,10 @@
2
+StreamingServices="Voogedastuse teenus"
3
+CustomStreamingServer="Kohandatud voogedastuse Server"
4
+Service="Teenus"
5
+Server="Server"
6
+StreamKey="Voogedastuse võti"
7
+UseAuth="Kasuta autentimist"
8
+Username="Kasutajanimi"
9
+Password="Salasõna"
10
+ShowAll="Näita kõiki teenuseid"
11
+
12
obs-studio-18.0.1.tar.xz/plugins/text-freetype2/data/locale/et-EE.ini Added
16
 
1
@@ -0,0 +1,14 @@
2
+TextFreetype2="Tekst (FreeType 2)"
3
+Font="Font"
4
+Text="Tekst"
5
+TextFile="Tekstifail (UTF-8 või UTF-16)"
6
+TextFileFilter="Tekstifailid (*.txt);;"
7
+ChatLogMode="Vestlus logi režiim (Viimased 6 rida)"
8
+Color1="Värv 1"
9
+Color2="Värv 2"
10
+Outline="Kontuur"
11
+DropShadow="Langev vari"
12
+ReadFromFile="Loe failist"
13
+CustomWidth="Kohandatud teksti laius"
14
+WordWrap="Eraldi reale"
15
+
16
obs-studio-18.0.1.tar.xz/plugins/vlc-video/data/locale/et-EE.ini Added
10
 
1
@@ -0,0 +1,8 @@
2
+VLCSource="VLC Video allikas"
3
+Playlist="Esitusloend"
4
+LoopPlaylist="Korda esitusloendit"
5
+PlaybackBehavior="Käitumine"
6
+PlaybackBehavior.StopRestart="Lõpeta kui nähtamatu, alusta uuesti kui nähtav"
7
+PlaybackBehavior.PauseUnpause="Peata kui nähtamatu, jätka kui nähtav"
8
+PlaybackBehavior.AlwaysPlay="Mängi alati, isegi siis kui pole nähtav"
9
+
10
obs-studio-18.0.1.tar.xz/plugins/win-capture/data/locale/et-EE.ini Added
21
 
1
@@ -0,0 +1,19 @@
2
+MonitorCapture="Kuvari hõive"
3
+WindowCapture="Akna hõive"
4
+WindowCapture.Window="Aken"
5
+WindowCapture.Priority.Title="Akna pealkiri"
6
+WindowCapture.Priority.Class="Akna klass"
7
+WindowCapture.Priority.Exe="Käivitatava faili nimi"
8
+CaptureCursor="Jäädvusta kursor"
9
+AllowTransparency="Luba läbipaistvus"
10
+Monitor="Kuvar"
11
+PrimaryMonitor="Esmane kuvar"
12
+GameCapture="Mängu hõive"
13
+GameCapture.AnyFullscreen="Jäädvusta kõiki täisekraanil olevaid aplikatsiooni"
14
+GameCapture.CaptureWindow="Jäädvusta kindel aken"
15
+GameCapture.UseHotkey="Jäädvusta tagaplaani akent kiirklahviga"
16
+GameCapture.LimitFramerate="Limiteeri hõive kaadrisagedust"
17
+GameCapture.HotkeyStart="Jäädvusta esiplaani akent"
18
+GameCapture.HotkeyStop="Deaktiveeri hõive"
19
+Mode="Režiim"
20
+
21
obs-studio-18.0.1.tar.xz/plugins/win-dshow/data/locale/et-EE.ini Added
33
 
1
@@ -0,0 +1,31 @@
2
+VideoCaptureDevice="Videohõive seade"
3
+Device="Seade"
4
+ColorSpace="YUV värviruumi"
5
+ColorSpace.Default="Vaikimisi"
6
+ColorRange.Partial="Osaliselt"
7
+ColorRange.Full="Täielik"
8
+ConfigureAudio="Konfigureerige heli"
9
+ConfigureVideo="Konfigureerige Video"
10
+ResFPSType.Custom="Kohandatud"
11
+ResFPSType.DevPreferred="Seadme vaikesätte"
12
+FPS.Highest="Kõrgeim FPS"
13
+Resolution="Resolutsioon"
14
+VideoFormat="Video formaat"
15
+VideoFormat.Any="Ükskõik milline"
16
+AudioOutputMode="Heliväljundi režiim"
17
+AudioOutputMode.Capture="Salvesta ainult heli"
18
+UseCustomAudioDevice="Kasuta kohandatud heliseadet"
19
+AudioDevice="Heliseade"
20
+Buffering="Puhverdamine"
21
+Buffering.AutoDetect="Automaatne tuvastamine"
22
+Buffering.Enable="Sisse lülitatud"
23
+Buffering.Disable="Välja lülitatud"
24
+Activate="Aktiveeri"
25
+Deactivate="Deaktiveeri"
26
+FlipVertically="Pööra vertikaalselt"
27
+DeactivateWhenNotShowing="Laadi maha kui ei ole nähtav"
28
+
29
+Bitrate="Bitikiirus"
30
+Encoder.C985="AVerMedia H.264 kodeerija (c985)"
31
+Encoder.C353="AVerMedia H.264 kodeerija"
32
+
33
obs-studio-18.0.0.tar.xz/plugins/win-dshow/ffmpeg-decode.c -> obs-studio-18.0.1.tar.xz/plugins/win-dshow/ffmpeg-decode.c Changed
55
 
1
@@ -16,8 +16,6 @@
2
 ******************************************************************************/
3
 
4
 #include "ffmpeg-decode.h"
5
-#include <util/util_uint128.h>
6
-#include <util/base.h>
7
 #include <obs-avc.h>
8
 
9
 int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id)
10
@@ -109,33 +107,8 @@
11
    memcpy(decode->packet_buffer, data, size);
12
 }
13
 
14
-static void do_idiotic_lgp_audio_packet_realignment(
15
-       struct ffmpeg_decode *decode, long long *ts)
16
-{
17
-   uint64_t new_ts = (uint64_t)*ts;
18
-   util_uint128_t u128;
19
-
20
-   if (!decode->lgp_started) {
21
-       decode->lgp_start_ts = new_ts;
22
-       decode->lgp_next_expected_ts = new_ts;
23
-       decode->lgp_started = true;
24
-   }
25
-
26
-   if (llabs(decode->lgp_next_expected_ts - new_ts) < 3000000ULL) {
27
-       *ts = (long long)decode->lgp_next_expected_ts;
28
-   } else {
29
-       decode->lgp_start_ts = new_ts;
30
-       decode->lgp_frames_since_start = 0;
31
-   }
32
-
33
-   decode->lgp_frames_since_start += (uint64_t)decode->frame->nb_samples;
34
-   u128 = util_mul64_64(decode->lgp_frames_since_start, 10000000ULL);
35
-   decode->lgp_next_expected_ts = decode->lgp_start_ts +
36
-       util_div128_32(u128, (uint32_t)decode->frame->sample_rate).low;
37
-}
38
-
39
 int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
40
-       uint8_t *data, size_t size, long long *ts,
41
+       uint8_t *data, size_t size,
42
        struct obs_source_audio *audio,
43
        bool *got_output)
44
 {
45
@@ -175,9 +148,6 @@
46
    if (audio->format == AUDIO_FORMAT_UNKNOWN)
47
        return 0;
48
 
49
-   if (decode->fix_braindead_lgp_audio_packet_stupidity)
50
-       do_idiotic_lgp_audio_packet_realignment(decode, ts);
51
-
52
    *got_output = true;
53
    return len;
54
 }
55
obs-studio-18.0.0.tar.xz/plugins/win-dshow/ffmpeg-decode.h -> obs-studio-18.0.1.tar.xz/plugins/win-dshow/ffmpeg-decode.h Changed
22
 
1
@@ -44,19 +44,13 @@
2
 
3
    uint8_t        *packet_buffer;
4
    size_t         packet_size;
5
-
6
-   uint64_t       lgp_start_ts;
7
-   uint64_t       lgp_frames_since_start;
8
-   uint64_t       lgp_next_expected_ts;
9
-   bool           lgp_started;
10
-   bool           fix_braindead_lgp_audio_packet_stupidity;
11
 };
12
 
13
 extern int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id);
14
 extern void ffmpeg_decode_free(struct ffmpeg_decode *decode);
15
 
16
 extern int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
17
-       uint8_t *data, size_t size, long long *ts,
18
+       uint8_t *data, size_t size,
19
        struct obs_source_audio *audio,
20
        bool *got_output);
21
 
22
obs-studio-18.0.0.tar.xz/plugins/win-dshow/win-dshow.cpp -> obs-studio-18.0.1.tar.xz/plugins/win-dshow/win-dshow.cpp Changed
54
 
1
@@ -508,31 +508,32 @@
2
            blog(LOG_WARNING, "Could not initialize audio decoder");
3
            return;
4
        }
5
-
6
-       if (videoConfig.name.find(L"C875") != std::string::npos ||
7
-           videoConfig.name.find(L"C835") != std::string::npos) {
8
-           audio_decoder->fix_braindead_lgp_audio_packet_stupidity
9
-               = true;
10
-           blog(LOG_INFO, "Oh great, an LGP was detected.  "
11
-                   "How wonderful.  I'm just ecstatic.");
12
-       }
13
    }
14
 
15
-   bool got_output;
16
-   int len = ffmpeg_decode_audio(audio_decoder, data, size, &ts,
17
-           &audio, &got_output);
18
-   if (len < 0) {
19
-       blog(LOG_WARNING, "Error decoding audio");
20
-       return;
21
-   }
22
+   do {
23
+       bool got_output;
24
+       int len = ffmpeg_decode_audio(audio_decoder, data, size,
25
+               &audio, &got_output);
26
+       if (len < 0) {
27
+           blog(LOG_WARNING, "Error decoding audio");
28
+           return;
29
+       }
30
 
31
-   if (got_output) {
32
-       audio.timestamp = (uint64_t)ts * 100;
33
+       if (got_output) {
34
+           audio.timestamp = (uint64_t)ts * 100;
35
 #if LOG_ENCODED_AUDIO_TS
36
-       blog(LOG_DEBUG, "audio ts: %llu", audio.timestamp);
37
+           blog(LOG_DEBUG, "audio ts: %llu", audio.timestamp);
38
 #endif
39
-       obs_source_output_audio(source, &audio);
40
-   }
41
+           obs_source_output_audio(source, &audio);
42
+       } else {
43
+           break;
44
+       }
45
+
46
+       ts += int64_t(audio_decoder->frame->nb_samples) * 10000000LL /
47
+           int64_t(audio_decoder->frame->sample_rate);
48
+       size -= (size_t)len;
49
+       data += len;
50
+   } while (size > 0);
51
 }
52
 
53
 void DShowInput::OnAudioData(const AudioConfig &config,
54
obs-studio-18.0.1.tar.xz/plugins/win-mf/data/locale/et-EE.ini Added
12
 
1
@@ -0,0 +1,10 @@
2
+MFAACEnc="Media Foundation AAC kodeerija"
3
+Bitrate="Bitikiirus"
4
+
5
+MF.H264.Encoder="Kodeerija nimi"
6
+MF.H264.BufferSize="Puhvri suurus"
7
+MF.H264.Bitrate="Bitikiirus"
8
+MF.H264.MaxBitrate="Maksimaalne bitikiirus"
9
+MF.H264.Profile="Profiil"
10
+
11
+
12
obs-studio-18.0.0.tar.xz/plugins/win-mf/data/locale/tr-TR.ini -> obs-studio-18.0.1.tar.xz/plugins/win-mf/data/locale/tr-TR.ini Changed
35
 
1
@@ -3,23 +3,23 @@
2
 
3
 MF.H264.EncoderName="Medya Vakfı H264 Kodlayıcısı"
4
 MF.H264.Encoder="Kodlayıcı Adı"
5
-MF.H264.LowLatency="Düşük Gecikme Süresi (Çerçeve yeniden sıralamasını devre dışı bırak)"
6
-MF.H264.BFrames="Ardışık B-Frame sayısı"
7
+MF.H264.LowLatency="Düşük Gecikme (Kare yeniden sıralamasını devre dışı bırak)"
8
+MF.H264.BFrames="Ardışık B-Kare sayısı"
9
 MF.H264.CustomBufsize="İsteğe Bağlı Arabellek Boyutu Kullan"
10
 MF.H264.BufferSize="Arabellek Boyutu"
11
-MF.H264.CustomMaxBitrate="Özel En Yüksek Bit Hızı Kullan"
12
-MF.H264.Bitrate="Bithızı"
13
-MF.H264.MaxBitrate="En Yüksek Bit Hızı"
14
-MF.H264.KeyframeIntervalSec="Anahtarkare Aralığı (saniye, 0=otomatik)"
15
+MF.H264.CustomMaxBitrate="Özel Maksimum Bit Hızı Kullan"
16
+MF.H264.Bitrate="Bit hızı"
17
+MF.H264.MaxBitrate="Maksimum Bit Hızı"
18
+MF.H264.KeyframeIntervalSec="Anahtar Kare Aralığı (saniye, 0=otomatik)"
19
 MF.H264.RateControl="Oran Kontrolü"
20
-MF.H264.CBR="CBR (Sabit bit hızı)"
21
+MF.H264.CBR="CBR (Sabit Bit Hızı)"
22
 MF.H264.VBR="VBR (Değişken Bit Hızı)"
23
 MF.H264.CQP="CQP (Sabit Kalite)"
24
 MF.H264.MinQP="Minimum QP"
25
 MF.H264.MaxQP="Maksimum QP"
26
-MF.H264.QPI="QP I-Frame"
27
-MF.H264.QPP="QP P-Frame"
28
-MF.H264.QPB="QP B-Frame"
29
+MF.H264.QPI="QP I-Kare"
30
+MF.H264.QPP="QP P-Kare"
31
+MF.H264.QPB="QP B-Kare"
32
 MF.H264.Profile="Profil"
33
 MF.H264.Advanced="Gelişmiş"
34
 
35
Refresh

No build results available

Refresh

No rpmlint results available

Request History
boombatower's avatar

boombatower created request about 8 years ago

- Update to version 18.0.1:
* CI: Fix true / false on stable builds
* CI: Add boolean arg parser to OSX
* CI: Deploy on tags and master branch
* CI: OSX - Deploy on all branches in the master repo.
* CI: OSX - Include branch in pkg
* enc-amf: Update to 1.4.3.11
* UI: Use correct string for systemTrayEnabled
* CI: OSX - Update to CEF 2987
* CI: Use correct folder for building browser
* CI: OSX - Use bash variable for CEF version
* UI: Don't exit on unknown command line arguments
* CI: OSX - export cef version so we can use it elsewhere
* CI: Fix cef version variable
* obs-outputs: Fix 100% CPU usage with new network code
* CI: OSX - Move CEF version to .travis
* VST: Fix save / load of plugin state. More interface options.
* UI: Fix audio monitoring dev. not being set on startup
* UI: Log audio monitoring dev. on start and when changed
* UI: Add logging of audio monitoring to sources
* VST: Fix crash when OBS is set to mono
* Revert "win-dshow: Add LGP timestamp fix"
* win-dshow: Actually fix LGP issue
* obs-outputs: Various fixes to new network code
* Update translations from Crowdin
* AUTHORS: Update with data from Git and Crowdin
* libobs: Apply sync offset to win32 audio monitoring
* UI: Disable network settings while outputs active
* Update translations from Crowdin
* AUTHORS: Update with data from Git and Crowdin


boombatower's avatar

boombatower accepted request about 8 years ago

ok