lzc-video-player 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/.dockerignore +1 -0
  2. package/.eslintrc.cjs +18 -0
  3. package/.prettierrc.json +5 -0
  4. package/AGENTS.md +31 -0
  5. package/README.md +38 -0
  6. package/build.sh +10 -0
  7. package/demo/.vscode/extensions.json +3 -0
  8. package/demo/README.md +40 -0
  9. package/demo/env.d.ts +1 -0
  10. package/demo/index.html +13 -0
  11. package/demo/package-lock.json +2037 -0
  12. package/demo/package.json +25 -0
  13. package/demo/public/favicon.ico +0 -0
  14. package/demo/src/App.vue +25 -0
  15. package/demo/src/assets/base.css +70 -0
  16. package/demo/src/assets/logo.svg +1 -0
  17. package/demo/src/assets/main.css +33 -0
  18. package/demo/src/main.ts +8 -0
  19. package/demo/tsconfig.config.json +8 -0
  20. package/demo/tsconfig.json +16 -0
  21. package/demo/vite.config.ts +14 -0
  22. package/docs/progress-bar-style-analysis.md +87 -0
  23. package/env.d.ts +1 -0
  24. package/error_pages/502.html.tpl +13 -0
  25. package/i18next-parser.config.mjs +147 -0
  26. package/index.html +54 -0
  27. package/lazycat.png +0 -0
  28. package/lib/README.md +48 -0
  29. package/lib/package.json +22 -0
  30. package/lzc-build.local.yml +65 -0
  31. package/lzc-build.yml +65 -0
  32. package/lzc-manifest.yml +53 -0
  33. package/makefile +15 -0
  34. package/package.json +69 -0
  35. package/postcss.config.js +6 -0
  36. package/public/512x512.png +0 -0
  37. package/public/favicon.ico +0 -0
  38. package/public/languages/en/translation.json +125 -0
  39. package/public/languages/zh/translation.json +125 -0
  40. package/public/libass-wasm/4.1.0/default.woff2 +0 -0
  41. package/public/libass-wasm/4.1.0/subtitles-octopus-worker-legacy.js +40 -0
  42. package/public/libass-wasm/4.1.0/subtitles-octopus-worker.js +1 -0
  43. package/public/libass-wasm/4.1.0/subtitles-octopus-worker.wasm +0 -0
  44. package/public/libass-wasm/4.1.0/subtitles-octopus.js +1680 -0
  45. package/public/square-128x128.png +0 -0
  46. package/public/square-256x256.png +0 -0
  47. package/public/square-512x512.png +0 -0
  48. package/src/App.vue +18 -0
  49. package/src/assets/base.scss +104 -0
  50. package/src/assets/cloud.png +0 -0
  51. package/src/assets/logo.svg +1 -0
  52. package/src/components/Dialog/index.vue +96 -0
  53. package/src/components/MultipleEdit/choose.vue +39 -0
  54. package/src/components/PlayList/index.vue +521 -0
  55. package/src/components/Spectrum/index.vue +58 -0
  56. package/src/components/Video/NativeVideoPlayer.vue +748 -0
  57. package/src/components/Video/README.md +3 -0
  58. package/src/components/Video/clientPlayer.ts +348 -0
  59. package/src/components/Video/components/LzcModal/components/simpleList.vue +57 -0
  60. package/src/components/Video/components/LzcModal/list.vue +52 -0
  61. package/src/components/Video/components/LzcModal/playrate.vue +45 -0
  62. package/src/components/Video/components/LzcModal/resolution.vue +117 -0
  63. package/src/components/Video/components/LzcModal/subtitle.vue +499 -0
  64. package/src/components/Video/components/LzcModal/useModal.ts +18 -0
  65. package/src/components/Video/components/LzcOverlay/SubtitleLayer.vue +321 -0
  66. package/src/components/Video/components/LzcOverlay/cast.vue +253 -0
  67. package/src/components/Video/components/LzcOverlay/casting.vue +205 -0
  68. package/src/components/Video/components/LzcOverlay/error.vue +103 -0
  69. package/src/components/Video/components/LzcOverlay/helper.ts +81 -0
  70. package/src/components/Video/components/LzcOverlay/index.vue +99 -0
  71. package/src/components/Video/components/LzcOverlay/playing.vue +496 -0
  72. package/src/components/Video/components/LzcOverlay/playingButtons.vue +122 -0
  73. package/src/components/Video/components/LzcOverlay/playingLayout.vue +287 -0
  74. package/src/components/Video/components/LzcOverlay/useCast.ts +235 -0
  75. package/src/components/Video/components/LzcOverlay/useCommon.ts +41 -0
  76. package/src/components/Video/components/LzcOverlay/useOctopusRenderer.ts +230 -0
  77. package/src/components/Video/components/LzcOverlay/useSubtitleRenderEngine.ts +79 -0
  78. package/src/components/Video/components/LzcOverlay/useSubtitleTrack.ts +139 -0
  79. package/src/components/Video/components/useLzcCommon.ts +16 -0
  80. package/src/components/Video/directPlay.ts +345 -0
  81. package/src/components/Video/getSubtitleInfo.ts +42 -0
  82. package/src/components/Video/native/EventEmitter.ts +62 -0
  83. package/src/components/Video/native/NativeControls.vue +510 -0
  84. package/src/components/Video/native/NativeModal.vue +133 -0
  85. package/src/components/Video/native/NativePlayer.ts +913 -0
  86. package/src/components/Video/native/NativePlayer.vue +53 -0
  87. package/src/components/Video/native/index.ts +9 -0
  88. package/src/components/Video/native/native-player.css +183 -0
  89. package/src/components/Video/native/playerKey.ts +5 -0
  90. package/src/components/Video/native/useNativeCastMiddleware.ts +50 -0
  91. package/src/components/Video/native/useNativePlayer.ts +3 -0
  92. package/src/components/Video/native/useNativePlayerFullscreen.ts +44 -0
  93. package/src/components/Video/native/useNativePlayerHistory.ts +69 -0
  94. package/src/components/Video/native/useNativePlayerModal.ts +68 -0
  95. package/src/components/Video/native/useNativePlayerPlaylist.ts +67 -0
  96. package/src/components/Video/native/useNativePlayerState.ts +225 -0
  97. package/src/components/Video/player.ts +99 -0
  98. package/src/components/Video/theme/index.scss +291 -0
  99. package/src/components/Video/theme/videojs.css +1797 -0
  100. package/src/components/Video/useSource.ts +1431 -0
  101. package/src/components/Video/useSubtitlePreference.ts +66 -0
  102. package/src/components/Video/useWebview.ts +79 -0
  103. package/src/components/Video/videoFrame.ts +58 -0
  104. package/src/env.d.ts +3 -0
  105. package/src/i18n/README.md +392 -0
  106. package/src/i18n/index.ts +49 -0
  107. package/src/icons/Video_Player.svg +69 -0
  108. package/src/icons/box.svg +15 -0
  109. package/src/icons/client.svg +17 -0
  110. package/src/icons/logo.svg +28 -0
  111. package/src/icons//344/270/212/344/270/200/344/270/252.svg +6 -0
  112. package/src/icons//344/270/213/344/270/200/344/270/252.svg +4 -0
  113. package/src/icons//344/272/256/345/272/246.svg +13 -0
  114. package/src/icons//345/200/215/351/200/237.svg +14 -0
  115. package/src/icons//345/205/250/345/261/217.svg +16 -0
  116. package/src/icons//345/205/250/351/200/211_/345/267/262/351/200/211/344/270/255.svg +16 -0
  117. package/src/icons//345/205/250/351/200/211_/346/234/252/351/200/211/344/270/255.svg +15 -0
  118. package/src/icons//345/205/263/351/227/255/345/244/232/351/200/211.svg +14 -0
  119. package/src/icons//345/205/263/351/227/255/346/212/225/345/261/217.svg +11 -0
  120. package/src/icons//345/233/236/346/224/266/347/253/231.svg +15 -0
  121. package/src/icons//345/244/261/346/225/210.svg +17 -0
  122. package/src/icons//346/207/222/347/214/253/346/222/255/346/224/276/345/231/250-icon.png +0 -0
  123. package/src/icons//346/207/222/347/214/253/346/222/255/346/224/276/345/231/250.png +0 -0
  124. package/src/icons//346/212/225/345/261/217.svg +11 -0
  125. package/src/icons//346/212/225/351/200/201/344/270/255.jpg +0 -0
  126. package/src/icons//346/212/225/351/200/201/344/270/255.svg +21 -0
  127. package/src/icons//346/222/255/346/224/276.svg +3 -0
  128. package/src/icons//346/232/202/345/201/234.svg +4 -0
  129. package/src/icons//346/232/202/346/227/240.svg +21 -0
  130. package/src/icons//346/233/264/345/244/232/346/223/215/344/275/234.svg +11 -0
  131. package/src/icons//347/224/265/350/247/206.svg +18 -0
  132. package/src/icons//347/247/273/345/212/250/347/253/257_/350/203/214/346/231/257.webp +0 -0
  133. package/src/icons//350/203/214/346/231/257.png +0 -0
  134. package/src/icons//350/277/224/345/233/236.svg +13 -0
  135. package/src/icons//350/277/233/345/205/245/345/205/250/345/261/217.svg +13 -0
  136. package/src/icons//351/200/200/345/207/272/345/205/250/345/261/217.svg +15 -0
  137. package/src/icons//351/200/211/346/213/251.svg +15 -0
  138. package/src/icons//351/237/263/351/207/217.svg +13 -0
  139. package/src/index.d.ts +9 -0
  140. package/src/lzc-video-player.scss +7 -0
  141. package/src/lzc-video-player.ts +6 -0
  142. package/src/main.ts +62 -0
  143. package/src/model.ts +77 -0
  144. package/src/quasar-variables.sass +10 -0
  145. package/src/router/index.ts +74 -0
  146. package/src/stores/pinia.ts +3 -0
  147. package/src/stores/playlist.ts +146 -0
  148. package/src/use/useKeyBind.ts +61 -0
  149. package/src/use/useMultipleEdit.ts +60 -0
  150. package/src/use/useSdk.ts +5 -0
  151. package/src/use/useSubtitle.ts +39 -0
  152. package/src/use/useUtils.ts +22 -0
  153. package/src/use/useVideoFrame.ts +60 -0
  154. package/src/views/Home.ts +99 -0
  155. package/src/views/mobile/Home.vue +246 -0
  156. package/src/views/mobile/Player.vue +141 -0
  157. package/tailwind.config.js +15 -0
  158. package/tsconfig.config.json +8 -0
  159. package/tsconfig.json +20 -0
  160. package/vite.config.lib.ts +88 -0
  161. package/vite.config.ts +122 -0
  162. package/vue-shim.d.ts +4 -0
@@ -0,0 +1,1680 @@
1
+ // # The following lists all copyright notices and licenses for the
2
+ // # work contained in JavascriptSubtitlesOctopus per project.
3
+ //
4
+ // # Project: subtitlesoctopus
5
+ // License: Expat
6
+ // Copyright: 2017-2021 JavascriptSubtitlesOctopus contributors
7
+ //
8
+ // # Project: brotli
9
+ // License: Expat
10
+ // Copyright: 2014 Google Inc.
11
+ // 2015 The Chromium Authors.
12
+ // 2016 Google Inc.
13
+ // 2017 Google Inc.
14
+ // 2018 Google Inc.
15
+ // 2015 Google Inc.
16
+ // 2013 Google Inc.
17
+ // 2009, 2010, 2013-2016 by the Brotli Authors
18
+ // 2010 Google Inc.
19
+ //
20
+ // # Project: expat
21
+ // License: Expat
22
+ // Copyright: 2019 Zhongyuan Zhou <zhouzhongyuan@huawei.com>
23
+ // 2017-2022 Rhodri James <rhodri@wildebeest.org.uk>
24
+ // 2020 Joe Orton <jorton@redhat.com>
25
+ // 2016-2019 Sebastian Pipping <sebastian@pipping.org>
26
+ // 2021 Dong-hee Na <donghee.na@python.org>
27
+ // 2017 Joe Orton <jorton@redhat.com>
28
+ // 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
29
+ // 2004-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
30
+ // 2017 Sebastian Pipping <sebastian@pipping.org>
31
+ // 2004-2006 Karl Waclawek <karl@waclawek.net>
32
+ // 2006 Karl Waclawek <karl@waclawek.net>
33
+ // 2003-2006 Karl Waclawek <karl@waclawek.net>
34
+ // 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
35
+ // 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
36
+ // 2017 Franek Korta <fkorta@gmail.com>
37
+ // 2001-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
38
+ // 2006-2012 Karl Waclawek <karl@waclawek.net>
39
+ // 2017 Benbuck Nason <bnason@netflix.com>
40
+ // 2019 David Loffredo <loffredo@steptools.com>
41
+ // 2021 Tim Bray <tbray@textuality.com>
42
+ // 2018 Benjamin Peterson <benjamin@python.org>
43
+ // 2017 Rhodri James <rhodri@wildebeest.org.uk>
44
+ // 2002-2005 Karl Waclawek <karl@waclawek.net>
45
+ // 2016-2020 Sebastian Pipping <sebastian@pipping.org>
46
+ // 2016-2018 Sebastian Pipping <sebastian@pipping.org>
47
+ // 2016 Gilles Espinasse <g.esp@free.fr>
48
+ // 2007 Karl Waclawek <karl@waclawek.net>
49
+ // 2002-2016 Karl Waclawek <karl@waclawek.net>
50
+ // 2001-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
51
+ // 2016 Don Lewis <truckman@apache.org>
52
+ // 2000-2017 Expat development team
53
+ // 2002-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
54
+ // 2000 Clark Cooper <coopercc@users.sourceforge.net>
55
+ // 2002 Greg Stein <gstein@users.sourceforge.net>
56
+ // 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
57
+ // 2005-2012 Karl Waclawek <karl@waclawek.net>
58
+ // 2020 Boris Kolpackov <boris@codesynthesis.com>
59
+ // 2022 Thijs Schreijer <thijs@thijsschreijer.nl>
60
+ // 2017-2019 Sebastian Pipping <sebastian@pipping.org>
61
+ // 2016 Cristian Rodr\x{00c3}\x{00ad}guez <crrodriguez@opensuse.org>
62
+ // 2005 Karl Waclawek <karl@waclawek.net>
63
+ // 1999-2000 Thai Open Source Software Center Ltd
64
+ // 2000-2017 Expat development team / 1997-2000 Thai Open Source Software Center Ltd
65
+ // 2005-2007 Steven Solie <steven@solie.ca>
66
+ // 2016-2021 Sebastian Pipping <sebastian@pipping.org>
67
+ // 2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
68
+ // 2018 Anton Maklakov <antmak.pub@gmail.com>
69
+ // 2017 Alexander Bluhm <alexander.bluhm@gmx.net>
70
+ // 2016-2022 Sebastian Pipping <sebastian@pipping.org>
71
+ // 1997-2000 Thai Open Source Software Center Ltd
72
+ // 2017-2021 Sebastian Pipping <sebastian@pipping.org>
73
+ // 2002-2009 Karl Waclawek <karl@waclawek.net>
74
+ // 2002 Karl Waclawek <karl@waclawek.net>
75
+ // 2004-2009 Karl Waclawek <karl@waclawek.net>
76
+ // 2020 Tim Gates <tim.gates@iress.com>
77
+ // 2016 Pascal Cuoq <cuoq@trust-in-soft.com>
78
+ // 2017 Jos\x{00c3}\x{00a9} Guti\x{00c3}\x{00a9}rrez de la Concha <jose@zeroc.com>
79
+ // 2001-2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
80
+ // 2002-2006 Karl Waclawek <karl@waclawek.net>
81
+ // 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
82
+ // 2005-2009 Steven Solie <steven@solie.ca>
83
+ // 2018 Yury Gribov <tetra2005@gmail.com>
84
+ // 2022 Martin Ettl <ettl.martin78@googlemail.com>
85
+ // 2003 Greg Stein <gstein@users.sourceforge.net>
86
+ // 2016-2017 Sebastian Pipping <sebastian@pipping.org>
87
+ // 2020 Kleber Tarc\x{00c3}\x{00ad}sio <klebertarcisio@yahoo.com.br>
88
+ // 2001-2002 Greg Stein <gstein@users.sourceforge.net>
89
+ // 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
90
+ // 2005-2006 Karl Waclawek <karl@waclawek.net>
91
+ // 2016 Thomas Beutlich <tc@tbeu.de>
92
+ //
93
+ // # Project: freetype
94
+ // License: FTL
95
+ // Copyright: \x{00c5}\x{009d}\x{00c5}\x{00a5} \x{00c5}\x{009d}\x{00c5}\x{00a5}\x{00d1}\x{008f}\x{00c3}\x{00af}\x{00ef}\x{00ac}\x{00af}\x{00c4}\x{009f}")
96
+ // 2009-2013 Adobe Systems Incorporated.
97
+ // 2016-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
98
+ // 2013 Adobe Systems Incorporated.
99
+ // 2004-2022 David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.
100
+ // 2013-2022 Google, Inc.
101
+ // 2018-2022 Armin Hasitzka, David Turner, Robert Wilhelm, and Werner Lemberg.
102
+ // 2007-2014 Adobe Systems Incorporated.
103
+ // 2008-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
104
+ // 2005-2022 Werner Lemberg and Detlef W\x{00fc}rkner.
105
+ // 2006-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
106
+ // 2007-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
107
+ // 1996-2022 David Turner, Robert Wilhelm, Werner Lemberg and Detlef W\x{00fc}rkner.
108
+ // 2004-2022 Masatake YAMATO, Redhat K.K,
109
+ // 1996-2022 David Turner, Robert Wilhelm, Werner Lemberg, and Detlef Wuerkner.
110
+ // 1996-2022 David Turner, Robert Wilhelm, and Werner Lemberg
111
+ // 1995-2016 Jean-loup Gailly, Mark Adler
112
+ // 2021-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
113
+ // \x{00c5}\x{009d}\x{00c5}\x{00a5} \x{00c5}\x{009d}\x{00c5}\x{00a5}\x{00d1}\x{008f}\x{00c3}\x{00af}\x{00ef}\x{00ac}\x{00af}\x{00c4}\x{009f}"));
114
+ // 2004-2022 David Turner, Robert Wilhelm, Werner Lemberg and George Williams.
115
+ // 2009-2022 Oran Agra and Mickey Gabel.
116
+ // 2010-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
117
+ // 1995-2017 Jean-loup Gailly
118
+ // 2003 Huw D M Davies for Codeweavers
119
+ // 2013-2014 Adobe Systems Incorporated.
120
+ // 2005-2022 David Turner.
121
+ // 1995-2011, 2016 Mark Adler
122
+ // 2010-2022 Joel Klinghed.
123
+ // 2002-2022 Roberto Alameda.
124
+ // 1996-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
125
+ // 2011-2013 Adobe Systems Incorporated.
126
+ // 2007 Dmitry Timoshkov for Codeweavers
127
+ // 2002-2022 David Turner, Robert Wilhelm, and Werner Lemberg
128
+ // 2013-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
129
+ // 1996-2022 Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
130
+ // 1995-2017 Mark Adler
131
+ // 2000-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
132
+ // 2022 David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
133
+ // 2006-2013 Adobe Systems Incorporated.
134
+ // 1995-2003, 2010 Mark Adler
135
+ // 2012-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
136
+ // 2007-2022 Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
137
+ // 2007-2022 David Turner.
138
+ // 2017-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
139
+ // 2008-2022 David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
140
+ // 2018-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
141
+ // 1995-2005, 2010 Mark Adler
142
+ // 2005-2022 suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
143
+ // 2020-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
144
+ // 2007-2022 Derek Clegg and Michael Toftdal.
145
+ // \x{00e1}\x{00bb}\x{008b}...): %dn", "\x{00e1}\x{00ba}\x{0083}\x{00ce}\x{00ad}\x{00c5}\x{0082}\x{00c4}\x{00ba}", "all", 42);
146
+ // 2019-2022 Nikhil Ramakrishnan, David Turner, Robert Wilhelm, and Werner Lemberg.
147
+ // 2013 Google, Inc.
148
+ // 2004-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
149
+ // 2009-2014 Adobe Systems Incorporated.
150
+ // 2004-2022 Albert Chin-A-Young.
151
+ // 2003-2022 Masatake YAMATO, Redhat K.K.,
152
+ // 2002-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
153
+ // 2007-2013 Adobe Systems Incorporated.
154
+ // 2007-2022 Dereg Clegg and Michael Toftdal.
155
+ // 2003-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
156
+ // 2004-2022 Masatake YAMATO and Redhat K.K.
157
+ // 2004-2022 Masatake YAMATO, Red Hat K.K.,
158
+ // 2001-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
159
+ // 2001, 2012 David Turner, Robert Wilhelm, and Werner Lemberg.
160
+ // 1995-2022 Jean-loup Gailly, Mark Adler
161
+ // 1995-2022 Mark Adler
162
+ // 2004-2019 Mark Adler
163
+ // 1990, 1994, 1998 The Open Group
164
+ // 2005-2022 David Turner, Robert Wilhelm, and Werner Lemberg.
165
+ // 1995-2019 Mark Adler
166
+ // 2018-2022 David Turner, Robert Wilhelm, Dominik R\x{00c3}\x{00b6}ttsches, and Werner Lemberg.
167
+ // 2004-2022 suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
168
+ //
169
+ // License: public-domain
170
+ // Copyright: 2001 Alexander Peslyak and it is hereby released to the
171
+ //
172
+ // License: Zlib
173
+ // Copyright: 1995-2022 Jean-loup Gailly and Mark Adler
174
+ //
175
+ // License: Expat
176
+ // Copyright: 2000-2001, 2004 Francesco Zappa Nardelli
177
+ // 2001-2004 Francesco Zappa Nardelli
178
+ // 2003 Francesco Zappa Nardelli
179
+ // 2001-2015 Francesco Zappa Nardelli
180
+ // 2001-2004, 2011 Francesco Zappa Nardelli
181
+ // 2000-2002 Francesco Zappa Nardelli
182
+ // 2000 Computing Research Labs, New Mexico State University
183
+ // 2001-2014 Francesco Zappa Nardelli
184
+ // 2001-2002, 2012 Francesco Zappa Nardelli
185
+ // 2001-2002 Francesco Zappa Nardelli
186
+ // 2001-2008, 2011, 2013-2014 Francesco Zappa Nardelli
187
+ // 2000-2003, 2006, 2010 Francesco Zappa Nardelli
188
+ // 2000-2001, 2003 Francesco Zappa Nardelli
189
+ // 2000-2004, 2006-2011, 2013-2014 Francesco Zappa Nardelli
190
+ // 2000-2010, 2012-2014 Francesco Zappa Nardelli
191
+ //
192
+ // License: BSL-1.0
193
+ // Copyright: 2019 nyorain
194
+ //
195
+ // # Project: fribidi
196
+ // License: LGPL-2.1+
197
+ // Copyright: 1999-2000, 2017 Dov Grobgeld
198
+ // 1999-2000 Dov Grobgeld
199
+ // 2004 Behdad Esfahbod
200
+ // 2001-2002, 2004 Behdad Esfahbod
201
+ // 2009 Behdad Esfahbod
202
+ // 2017 Dov Grobgeld
203
+ // 2004-2005 Behdad Esfahbod
204
+ // 2004 Sharif FarsiWeb, Inc.
205
+ // 2015, 2017 Dov Grobgeld
206
+ // 2005 Behdad Esfahbod
207
+ // 2001 Behdad Esfahbod.
208
+ // 2001-2002 Behdad Esfahbod
209
+ // 2004 Sharif FarsiWeb, Inc
210
+ //
211
+ // # Project: fontconfig
212
+ // License: NTP~disclaimer
213
+ // Copyright: 2002 Keith Packard
214
+ // 2009 Roozbeh Pournader
215
+ // 2000 Tuomas J. Lukka
216
+ // 2006 Keith Packard
217
+ // 2008 Red Hat, Inc.
218
+ // 2000-2007 Keith Packard / 2005 Patrick Lam / 2009 Roozbeh Pournader / 2008,2009 Red Hat, Inc. / 2008 Danilo Šegan / 2012 Google, Inc.
219
+ // 2001 Keith Packard
220
+ // 2012 Google, Inc.
221
+ // 2012 Red Hat, Inc.
222
+ // 2013 Raimund Steger
223
+ // 2008,2009 Red Hat, Inc.
224
+ // 2000-2007 Keith Packard
225
+ // 2005 Patrick Lam
226
+ // 2003 Keith Packard
227
+ // 2020 Zoltan Vandrus
228
+ // \x{00e6}\x{0081}\x{00af} 2010 Behdad Esfahbod
229
+ // 2014 Red Hat, Inc.
230
+ // 2018 Akira TAGOH
231
+ // 2007 Keith Packard
232
+ // \x{00e6}\x{0081}\x{00af} 2006 Keith Packard
233
+ // 2008 Danilo Šegan
234
+ // 2015 Akira TAGOH
235
+ // 2016 Akira TAGOH
236
+ // 2008-2009 Red Hat, Inc.
237
+ // 2000 Keith Packard
238
+ // 2013 Akira TAGOH
239
+ // 2013 Google, Inc.
240
+ // 2010 Behdad Esfahbod
241
+ //
242
+ // License: MIT~old
243
+ // Copyright: 2009-2010 Red Hat, Inc.
244
+ // 2011-2013 Google, Inc.
245
+ // 2007 Chris Wilson
246
+ //
247
+ // License: public-domain
248
+ // Copyright: 2008,2009 Red Hat, Inc.
249
+ // 2009 Roozbeh Pournader
250
+ // 2012 Google, Inc.
251
+ // 2008 Danilo Šegan
252
+ // 2005 Patrick Lam
253
+ // 2000-2007 Keith Packard
254
+ //
255
+ // License: Expat
256
+ // Copyright: 2002-2003 Juliusz Chroboczek
257
+ //
258
+ // # Project: harfbuzz
259
+ // License: NTP~disclaimer
260
+ // Copyright: 2002 Keith Packard
261
+ // 2014 Google, Inc.
262
+ //
263
+ // License: MIT~old
264
+ // Copyright: 2012 Mozilla Foundation.
265
+ // 2004, 2007, 2009 Red Hat, Inc.
266
+ // 2009 Red Hat, Inc.
267
+ // 2015 Google, Inc.
268
+ // 2014 Google, Inc.
269
+ // 2018 Ebrahim Byagowi
270
+ // 2016 Igalia S.L.
271
+ // 2018 Ebrahim Byagowi.
272
+ // 2011 Martin Hosken
273
+ // 2019 Ebrahim Byagowi
274
+ // 1998-2004 David Turner and Werner Lemberg
275
+ // 2020 Ebrahim Byagowi
276
+ // 2013 Red Hat, Inc.
277
+ // 2011-2012 Google, Inc.
278
+ // 2011 SIL International
279
+ // 2018 Khaled Hosny
280
+ // 2018 Google, Inc.
281
+ // 2019-2020 Ebrahim Byagowi
282
+ // 2022 Google, Inc.
283
+ // 2012 Google, Inc.
284
+ // 2017 Google, Inc.
285
+ // 2007-2009 Red Hat, Inc.
286
+ // 2011 Codethink Limited
287
+ // 2013 Google, Inc.
288
+ // 2015-2019 Ebrahim Byagowi
289
+ // 2016 Google, Inc.
290
+ // 2011 Google, Inc.
291
+ //
292
+ // # Project: libass
293
+ // License: public-domain
294
+ // Copyright: 2006-2016 libass contributors
295
+ //
296
+ // License: NTP
297
+ // Copyright: 1994 Sun Microsystems, Inc.
298
+ // 2016 Oleg Oshmyan <chortos@inbox.lv>
299
+ // 1988-1993 The Regents of the University of California.
300
+ //
301
+ // License: ISC
302
+ // Copyright: 2015 Oleg Oshmyan <chortos@inbox.lv>
303
+ // 2011-2014 Yu Zhuohuang <yuzhuohuang@qq.com>
304
+ // 2013 rcombs <rcombs@rcombs.me>
305
+ // 2016 Vabishchevich Nikolay <vabnick@gmail.com>
306
+ // 2022 libass contributors
307
+ // 2015 Stephan Vedder <stephan.vedder@gmail.com>
308
+ // 2015 Vabishchevich Nikolay <vabnick@gmail.com>
309
+ // interest in the
310
+ // 2006-2016 libass contributors
311
+ // 2021 libass contributors
312
+ // 2017 Vabishchevich Nikolay <vabnick@gmail.com>
313
+ // 2011 Grigori Goronzy <greg@chown.ath.cx>
314
+ // 2010 Grigori Goronzy <greg@geekmind.org>
315
+ // 2014 Vabishchevich Nikolay <vabnick@gmail.com>
316
+ // 2015 Grigori Goronzy <greg@kinoho.net>
317
+ // 2013 Stefano Pigozzi <stefano.pigozzi@gmail.com>
318
+ // 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
319
+ // 2009 Grigori Goronzy <greg@geekmind.org>
320
+ //
321
+ // # The following section contains the full license text or
322
+ // # where permitted a shorter notice for all works contained
323
+ // # in JavascriptSubtitlesOctopus listed above
324
+ // #
325
+ // # Note that the shortnames used here are identical to those used by Debian
326
+ // # and will in some cases differ from SPDX identifiers. See below.
327
+ // #
328
+ // # Debian-name | SPDX-name
329
+ // # ---------------+-------------------
330
+ // # MIT~old | MIT-Modern-Variant
331
+ // # Expat | MIT
332
+ // # NTP~disclaimer | (None; it is NTP with a more verbose warranty disclaimer)
333
+ //
334
+ // License: Expat
335
+ // Permission is hereby granted, free of charge, to any person obtaining
336
+ // a copy of this software and associated documentation files (the
337
+ // "Software"), to deal in the Software without restriction, including
338
+ // without limitation the rights to use, copy, modify, merge, publish,
339
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
340
+ // persons to whom the Software is furnished to do so, subject to the
341
+ // following conditions:
342
+ // .
343
+ // The above copyright notice and this permission notice shall be included
344
+ // in all copies or substantial portions of the Software.
345
+ // .
346
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
347
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
348
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
349
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
350
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
351
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
352
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
353
+ //
354
+ // License: FTL
355
+ // Portions of this software are copyright © 2021 The FreeType
356
+ // Project (www.freetype.org). All rights reserved.
357
+ // A copy of the FreeType License can be obtained at
358
+ // https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/docs/FTL.TXT
359
+ //
360
+ // License: ISC
361
+ // Permission to use, copy, modify, and/or distribute this software for any
362
+ // purpose with or without fee is hereby granted, provided that the above
363
+ // copyright notice and this permission notice appear in all copies.
364
+ // .
365
+ // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
366
+ // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
367
+ // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
368
+ // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
369
+ // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
370
+ // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
371
+ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
372
+ //
373
+ // License: MIT~old
374
+ // Permission is hereby granted, without written agreement and without
375
+ // license or royalty fees, to use, copy, modify, and distribute this
376
+ // software and its documentation for any purpose, provided that the
377
+ // above copyright notice and the following two paragraphs appear in
378
+ // all copies of this software.
379
+ // .
380
+ // IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
381
+ // DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
382
+ // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
383
+ // IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
384
+ // DAMAGE.
385
+ // .
386
+ // THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
387
+ // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
388
+ // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
389
+ // ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
390
+ // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS
391
+ //
392
+ // License: NTP
393
+ // Permission to use, copy, modify, and distribute this
394
+ // software and its documentation for any purpose and without
395
+ // fee is hereby granted, provided that the above copyright
396
+ // notice appear in all copies. The University of California
397
+ // makes no representations about the suitability of this
398
+ // software for any purpose. It is provided "as is" without
399
+ // express or implied warranty.
400
+ //
401
+ // License: NTP~disclaimer
402
+ // Permission to use, copy, modify, distribute, and sell this software and its
403
+ // documentation for any purpose is hereby granted without fee, provided that
404
+ // the above copyright notice appear in all copies and that both that
405
+ // copyright notice and this permission notice appear in supporting
406
+ // documentation, and that the name of the author(s) not be used in
407
+ // advertising or publicity pertaining to distribution of the software without
408
+ // specific, written prior permission. The authors make no
409
+ // representations about the suitability of this software for any purpose. It
410
+ // is provided "as is" without express or implied warranty.
411
+ // .
412
+ // THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
413
+ // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
414
+ // EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
415
+ // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
416
+ // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
417
+ // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
418
+ // PERFORMANCE OF THIS SOFTWARE.
419
+ //
420
+ // License: Zlib
421
+ // This software is provided 'as-is', without any express or implied
422
+ // warranty. In no event will the authors be held liable for any damages
423
+ // arising from the use of this software.
424
+ // .
425
+ // Permission is granted to anyone to use this software for any purpose,
426
+ // including commercial applications, and to alter it and redistribute it
427
+ // freely, subject to the following restrictions:
428
+ // .
429
+ // 1. The origin of this software must not be misrepresented; you must not
430
+ // claim that you wrote the original software. If you use this software
431
+ // in a product, an acknowledgment in the product documentation would be
432
+ // appreciated but is not required.
433
+ // 2. Altered source versions must be plainly marked as such, and must not be
434
+ // misrepresented as being the original software.
435
+ // 3. This notice may not be removed or altered from any source distribution.
436
+ //
437
+ // License: BSL-1
438
+ // Boost Software License - Version 1.0 - August 17th, 2003
439
+ // .
440
+ // Permission is hereby granted, free of charge, to any person or organization
441
+ // obtaining a copy of the software and accompanying documentation covered by
442
+ // this license (the "Software") to use, reproduce, display, distribute,
443
+ // execute, and transmit the Software, and to prepare derivative works of the
444
+ // Software, and to permit third-parties to whom the Software is furnished to
445
+ // do so, all subject to the following:
446
+ // .
447
+ // The copyright notices in the Software and this entire statement, including
448
+ // the above license grant, this restriction and the following disclaimer,
449
+ // must be included in all copies of the Software, in whole or in part, and
450
+ // all derivative works of the Software, unless such copies or derivative
451
+ // works are solely in the form of machine-executable object code generated by
452
+ // a source language processor.
453
+ // .
454
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
455
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
456
+ // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
457
+ // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
458
+ // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
459
+ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
460
+ // DEALINGS IN THE SOFTWARE.
461
+ //
462
+ // License: LGPL-2.1
463
+ // GNU LESSER GENERAL PUBLIC LICENSE
464
+ // Version 2.1, February 1999
465
+ // .
466
+ // Copyright (C) 1991, 1999 Free Software Foundation, Inc.
467
+ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
468
+ // Everyone is permitted to copy and distribute verbatim copies
469
+ // of this license document, but changing it is not allowed.
470
+ // .
471
+ // [This is the first released version of the Lesser GPL. It also counts
472
+ // as the successor of the GNU Library Public License, version 2, hence
473
+ // the version number 2.1.]
474
+ // .
475
+ // Preamble
476
+ // .
477
+ // The licenses for most software are designed to take away your
478
+ // freedom to share and change it. By contrast, the GNU General Public
479
+ // Licenses are intended to guarantee your freedom to share and change
480
+ // free software--to make sure the software is free for all its users.
481
+ // .
482
+ // This license, the Lesser General Public License, applies to some
483
+ // specially designated software packages--typically libraries--of the
484
+ // Free Software Foundation and other authors who decide to use it. You
485
+ // can use it too, but we suggest you first think carefully about whether
486
+ // this license or the ordinary General Public License is the better
487
+ // strategy to use in any particular case, based on the explanations below.
488
+ // .
489
+ // When we speak of free software, we are referring to freedom of use,
490
+ // not price. Our General Public Licenses are designed to make sure that
491
+ // you have the freedom to distribute copies of free software (and charge
492
+ // for this service if you wish); that you receive source code or can get
493
+ // it if you want it; that you can change the software and use pieces of
494
+ // it in new free programs; and that you are informed that you can do
495
+ // these things.
496
+ // .
497
+ // To protect your rights, we need to make restrictions that forbid
498
+ // distributors to deny you these rights or to ask you to surrender these
499
+ // rights. These restrictions translate to certain responsibilities for
500
+ // you if you distribute copies of the library or if you modify it.
501
+ // .
502
+ // For example, if you distribute copies of the library, whether gratis
503
+ // or for a fee, you must give the recipients all the rights that we gave
504
+ // you. You must make sure that they, too, receive or can get the source
505
+ // code. If you link other code with the library, you must provide
506
+ // complete object files to the recipients, so that they can relink them
507
+ // with the library after making changes to the library and recompiling
508
+ // it. And you must show them these terms so they know their rights.
509
+ // .
510
+ // We protect your rights with a two-step method: (1) we copyright the
511
+ // library, and (2) we offer you this license, which gives you legal
512
+ // permission to copy, distribute and/or modify the library.
513
+ // .
514
+ // To protect each distributor, we want to make it very clear that
515
+ // there is no warranty for the free library. Also, if the library is
516
+ // modified by someone else and passed on, the recipients should know
517
+ // that what they have is not the original version, so that the original
518
+ // author's reputation will not be affected by problems that might be
519
+ // introduced by others.
520
+ // .
521
+ // Finally, software patents pose a constant threat to the existence of
522
+ // any free program. We wish to make sure that a company cannot
523
+ // effectively restrict the users of a free program by obtaining a
524
+ // restrictive license from a patent holder. Therefore, we insist that
525
+ // any patent license obtained for a version of the library must be
526
+ // consistent with the full freedom of use specified in this license.
527
+ // .
528
+ // Most GNU software, including some libraries, is covered by the
529
+ // ordinary GNU General Public License. This license, the GNU Lesser
530
+ // General Public License, applies to certain designated libraries, and
531
+ // is quite different from the ordinary General Public License. We use
532
+ // this license for certain libraries in order to permit linking those
533
+ // libraries into non-free programs.
534
+ // .
535
+ // When a program is linked with a library, whether statically or using
536
+ // a shared library, the combination of the two is legally speaking a
537
+ // combined work, a derivative of the original library. The ordinary
538
+ // General Public License therefore permits such linking only if the
539
+ // entire combination fits its criteria of freedom. The Lesser General
540
+ // Public License permits more lax criteria for linking other code with
541
+ // the library.
542
+ // .
543
+ // We call this license the "Lesser" General Public License because it
544
+ // does Less to protect the user's freedom than the ordinary General
545
+ // Public License. It also provides other free software developers Less
546
+ // of an advantage over competing non-free programs. These disadvantages
547
+ // are the reason we use the ordinary General Public License for many
548
+ // libraries. However, the Lesser license provides advantages in certain
549
+ // special circumstances.
550
+ // .
551
+ // For example, on rare occasions, there may be a special need to
552
+ // encourage the widest possible use of a certain library, so that it becomes
553
+ // a de-facto standard. To achieve this, non-free programs must be
554
+ // allowed to use the library. A more frequent case is that a free
555
+ // library does the same job as widely used non-free libraries. In this
556
+ // case, there is little to gain by limiting the free library to free
557
+ // software only, so we use the Lesser General Public License.
558
+ // .
559
+ // In other cases, permission to use a particular library in non-free
560
+ // programs enables a greater number of people to use a large body of
561
+ // free software. For example, permission to use the GNU C Library in
562
+ // non-free programs enables many more people to use the whole GNU
563
+ // operating system, as well as its variant, the GNU/Linux operating
564
+ // system.
565
+ // .
566
+ // Although the Lesser General Public License is Less protective of the
567
+ // users' freedom, it does ensure that the user of a program that is
568
+ // linked with the Library has the freedom and the wherewithal to run
569
+ // that program using a modified version of the Library.
570
+ // .
571
+ // The precise terms and conditions for copying, distribution and
572
+ // modification follow. Pay close attention to the difference between a
573
+ // "work based on the library" and a "work that uses the library". The
574
+ // former contains code derived from the library, whereas the latter must
575
+ // be combined with the library in order to run.
576
+ // .
577
+ // GNU LESSER GENERAL PUBLIC LICENSE
578
+ // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
579
+ // .
580
+ // 0. This License Agreement applies to any software library or other
581
+ // program which contains a notice placed by the copyright holder or
582
+ // other authorized party saying it may be distributed under the terms of
583
+ // this Lesser General Public License (also called "this License").
584
+ // Each licensee is addressed as "you".
585
+ // .
586
+ // A "library" means a collection of software functions and/or data
587
+ // prepared so as to be conveniently linked with application programs
588
+ // (which use some of those functions and data) to form executables.
589
+ // .
590
+ // The "Library", below, refers to any such software library or work
591
+ // which has been distributed under these terms. A "work based on the
592
+ // Library" means either the Library or any derivative work under
593
+ // copyright law: that is to say, a work containing the Library or a
594
+ // portion of it, either verbatim or with modifications and/or translated
595
+ // straightforwardly into another language. (Hereinafter, translation is
596
+ // included without limitation in the term "modification".)
597
+ // .
598
+ // "Source code" for a work means the preferred form of the work for
599
+ // making modifications to it. For a library, complete source code means
600
+ // all the source code for all modules it contains, plus any associated
601
+ // interface definition files, plus the scripts used to control compilation
602
+ // and installation of the library.
603
+ // .
604
+ // Activities other than copying, distribution and modification are not
605
+ // covered by this License; they are outside its scope. The act of
606
+ // running a program using the Library is not restricted, and output from
607
+ // such a program is covered only if its contents constitute a work based
608
+ // on the Library (independent of the use of the Library in a tool for
609
+ // writing it). Whether that is true depends on what the Library does
610
+ // and what the program that uses the Library does.
611
+ //
612
+ // 1. You may copy and distribute verbatim copies of the Library's
613
+ // complete source code as you receive it, in any medium, provided that
614
+ // you conspicuously and appropriately publish on each copy an
615
+ // appropriate copyright notice and disclaimer of warranty; keep intact
616
+ // all the notices that refer to this License and to the absence of any
617
+ // warranty; and distribute a copy of this License along with the
618
+ // Library.
619
+ // .
620
+ // You may charge a fee for the physical act of transferring a copy,
621
+ // and you may at your option offer warranty protection in exchange for a
622
+ // fee.
623
+ // .
624
+ // 2. You may modify your copy or copies of the Library or any portion
625
+ // of it, thus forming a work based on the Library, and copy and
626
+ // distribute such modifications or work under the terms of Section 1
627
+ // above, provided that you also meet all of these conditions:
628
+ // .
629
+ // a) The modified work must itself be a software library.
630
+ // .
631
+ // b) You must cause the files modified to carry prominent notices
632
+ // stating that you changed the files and the date of any change.
633
+ // .
634
+ // c) You must cause the whole of the work to be licensed at no
635
+ // charge to all third parties under the terms of this License.
636
+ // .
637
+ // d) If a facility in the modified Library refers to a function or a
638
+ // table of data to be supplied by an application program that uses
639
+ // the facility, other than as an argument passed when the facility
640
+ // is invoked, then you must make a good faith effort to ensure that,
641
+ // in the event an application does not supply such function or
642
+ // table, the facility still operates, and performs whatever part of
643
+ // its purpose remains meaningful.
644
+ // .
645
+ // (For example, a function in a library to compute square roots has
646
+ // a purpose that is entirely well-defined independent of the
647
+ // application. Therefore, Subsection 2d requires that any
648
+ // application-supplied function or table used by this function must
649
+ // be optional: if the application does not supply it, the square
650
+ // root function must still compute square roots.)
651
+ // .
652
+ // These requirements apply to the modified work as a whole. If
653
+ // identifiable sections of that work are not derived from the Library,
654
+ // and can be reasonably considered independent and separate works in
655
+ // themselves, then this License, and its terms, do not apply to those
656
+ // sections when you distribute them as separate works. But when you
657
+ // distribute the same sections as part of a whole which is a work based
658
+ // on the Library, the distribution of the whole must be on the terms of
659
+ // this License, whose permissions for other licensees extend to the
660
+ // entire whole, and thus to each and every part regardless of who wrote
661
+ // it.
662
+ // .
663
+ // Thus, it is not the intent of this section to claim rights or contest
664
+ // your rights to work written entirely by you; rather, the intent is to
665
+ // exercise the right to control the distribution of derivative or
666
+ // collective works based on the Library.
667
+ // .
668
+ // In addition, mere aggregation of another work not based on the Library
669
+ // with the Library (or with a work based on the Library) on a volume of
670
+ // a storage or distribution medium does not bring the other work under
671
+ // the scope of this License.
672
+ // .
673
+ // 3. You may opt to apply the terms of the ordinary GNU General Public
674
+ // License instead of this License to a given copy of the Library. To do
675
+ // this, you must alter all the notices that refer to this License, so
676
+ // that they refer to the ordinary GNU General Public License, version 2,
677
+ // instead of to this License. (If a newer version than version 2 of the
678
+ // ordinary GNU General Public License has appeared, then you can specify
679
+ // that version instead if you wish.) Do not make any other change in
680
+ // these notices.
681
+ // .
682
+ // Once this change is made in a given copy, it is irreversible for
683
+ // that copy, so the ordinary GNU General Public License applies to all
684
+ // subsequent copies and derivative works made from that copy.
685
+ // .
686
+ // This option is useful when you wish to copy part of the code of
687
+ // the Library into a program that is not a library.
688
+ // .
689
+ // 4. You may copy and distribute the Library (or a portion or
690
+ // derivative of it, under Section 2) in object code or executable form
691
+ // under the terms of Sections 1 and 2 above provided that you accompany
692
+ // it with the complete corresponding machine-readable source code, which
693
+ // must be distributed under the terms of Sections 1 and 2 above on a
694
+ // medium customarily used for software interchange.
695
+ // .
696
+ // If distribution of object code is made by offering access to copy
697
+ // from a designated place, then offering equivalent access to copy the
698
+ // source code from the same place satisfies the requirement to
699
+ // distribute the source code, even though third parties are not
700
+ // compelled to copy the source along with the object code.
701
+ // .
702
+ // 5. A program that contains no derivative of any portion of the
703
+ // Library, but is designed to work with the Library by being compiled or
704
+ // linked with it, is called a "work that uses the Library". Such a
705
+ // work, in isolation, is not a derivative work of the Library, and
706
+ // therefore falls outside the scope of this License.
707
+ // .
708
+ // However, linking a "work that uses the Library" with the Library
709
+ // creates an executable that is a derivative of the Library (because it
710
+ // contains portions of the Library), rather than a "work that uses the
711
+ // library". The executable is therefore covered by this License.
712
+ // Section 6 states terms for distribution of such executables.
713
+ // .
714
+ // When a "work that uses the Library" uses material from a header file
715
+ // that is part of the Library, the object code for the work may be a
716
+ // derivative work of the Library even though the source code is not.
717
+ // Whether this is true is especially significant if the work can be
718
+ // linked without the Library, or if the work is itself a library. The
719
+ // threshold for this to be true is not precisely defined by law.
720
+ // .
721
+ // If such an object file uses only numerical parameters, data
722
+ // structure layouts and accessors, and small macros and small inline
723
+ // functions (ten lines or less in length), then the use of the object
724
+ // file is unrestricted, regardless of whether it is legally a derivative
725
+ // work. (Executables containing this object code plus portions of the
726
+ // Library will still fall under Section 6.)
727
+ // .
728
+ // Otherwise, if the work is a derivative of the Library, you may
729
+ // distribute the object code for the work under the terms of Section 6.
730
+ // Any executables containing that work also fall under Section 6,
731
+ // whether or not they are linked directly with the Library itself.
732
+ // .
733
+ // 6. As an exception to the Sections above, you may also combine or
734
+ // link a "work that uses the Library" with the Library to produce a
735
+ // work containing portions of the Library, and distribute that work
736
+ // under terms of your choice, provided that the terms permit
737
+ // modification of the work for the customer's own use and reverse
738
+ // engineering for debugging such modifications.
739
+ // .
740
+ // You must give prominent notice with each copy of the work that the
741
+ // Library is used in it and that the Library and its use are covered by
742
+ // this License. You must supply a copy of this License. If the work
743
+ // during execution displays copyright notices, you must include the
744
+ // copyright notice for the Library among them, as well as a reference
745
+ // directing the user to the copy of this License. Also, you must do one
746
+ // of these things:
747
+ // .
748
+ // a) Accompany the work with the complete corresponding
749
+ // machine-readable source code for the Library including whatever
750
+ // changes were used in the work (which must be distributed under
751
+ // Sections 1 and 2 above); and, if the work is an executable linked
752
+ // with the Library, with the complete machine-readable "work that
753
+ // uses the Library", as object code and/or source code, so that the
754
+ // user can modify the Library and then relink to produce a modified
755
+ // executable containing the modified Library. (It is understood
756
+ // that the user who changes the contents of definitions files in the
757
+ // Library will not necessarily be able to recompile the application
758
+ // to use the modified definitions.)
759
+ // .
760
+ // b) Use a suitable shared library mechanism for linking with the
761
+ // Library. A suitable mechanism is one that (1) uses at run time a
762
+ // copy of the library already present on the user's computer system,
763
+ // rather than copying library functions into the executable, and (2)
764
+ // will operate properly with a modified version of the library, if
765
+ // the user installs one, as long as the modified version is
766
+ // interface-compatible with the version that the work was made with.
767
+ // .
768
+ // c) Accompany the work with a written offer, valid for at
769
+ // least three years, to give the same user the materials
770
+ // specified in Subsection 6a, above, for a charge no more
771
+ // than the cost of performing this distribution.
772
+ // .
773
+ // d) If distribution of the work is made by offering access to copy
774
+ // from a designated place, offer equivalent access to copy the above
775
+ // specified materials from the same place.
776
+ // .
777
+ // e) Verify that the user has already received a copy of these
778
+ // materials or that you have already sent this user a copy.
779
+ // .
780
+ // For an executable, the required form of the "work that uses the
781
+ // Library" must include any data and utility programs needed for
782
+ // reproducing the executable from it. However, as a special exception,
783
+ // the materials to be distributed need not include anything that is
784
+ // normally distributed (in either source or binary form) with the major
785
+ // components (compiler, kernel, and so on) of the operating system on
786
+ // which the executable runs, unless that component itself accompanies
787
+ // the executable.
788
+ // .
789
+ // It may happen that this requirement contradicts the license
790
+ // restrictions of other proprietary libraries that do not normally
791
+ // accompany the operating system. Such a contradiction means you cannot
792
+ // use both them and the Library together in an executable that you
793
+ // distribute.
794
+ // .
795
+ // 7. You may place library facilities that are a work based on the
796
+ // Library side-by-side in a single library together with other library
797
+ // facilities not covered by this License, and distribute such a combined
798
+ // library, provided that the separate distribution of the work based on
799
+ // the Library and of the other library facilities is otherwise
800
+ // permitted, and provided that you do these two things:
801
+ // .
802
+ // a) Accompany the combined library with a copy of the same work
803
+ // based on the Library, uncombined with any other library
804
+ // facilities. This must be distributed under the terms of the
805
+ // Sections above.
806
+ // .
807
+ // b) Give prominent notice with the combined library of the fact
808
+ // that part of it is a work based on the Library, and explaining
809
+ // where to find the accompanying uncombined form of the same work.
810
+ // .
811
+ // 8. You may not copy, modify, sublicense, link with, or distribute
812
+ // the Library except as expressly provided under this License. Any
813
+ // attempt otherwise to copy, modify, sublicense, link with, or
814
+ // distribute the Library is void, and will automatically terminate your
815
+ // rights under this License. However, parties who have received copies,
816
+ // or rights, from you under this License will not have their licenses
817
+ // terminated so long as such parties remain in full compliance.
818
+ // .
819
+ // 9. You are not required to accept this License, since you have not
820
+ // signed it. However, nothing else grants you permission to modify or
821
+ // distribute the Library or its derivative works. These actions are
822
+ // prohibited by law if you do not accept this License. Therefore, by
823
+ // modifying or distributing the Library (or any work based on the
824
+ // Library), you indicate your acceptance of this License to do so, and
825
+ // all its terms and conditions for copying, distributing or modifying
826
+ // the Library or works based on it.
827
+ // .
828
+ // 10. Each time you redistribute the Library (or any work based on the
829
+ // Library), the recipient automatically receives a license from the
830
+ // original licensor to copy, distribute, link with or modify the Library
831
+ // subject to these terms and conditions. You may not impose any further
832
+ // restrictions on the recipients' exercise of the rights granted herein.
833
+ // You are not responsible for enforcing compliance by third parties with
834
+ // this License.
835
+ // .
836
+ // 11. If, as a consequence of a court judgment or allegation of patent
837
+ // infringement or for any other reason (not limited to patent issues),
838
+ // conditions are imposed on you (whether by court order, agreement or
839
+ // otherwise) that contradict the conditions of this License, they do not
840
+ // excuse you from the conditions of this License. If you cannot
841
+ // distribute so as to satisfy simultaneously your obligations under this
842
+ // License and any other pertinent obligations, then as a consequence you
843
+ // may not distribute the Library at all. For example, if a patent
844
+ // license would not permit royalty-free redistribution of the Library by
845
+ // all those who receive copies directly or indirectly through you, then
846
+ // the only way you could satisfy both it and this License would be to
847
+ // refrain entirely from distribution of the Library.
848
+ // .
849
+ // If any portion of this section is held invalid or unenforceable under any
850
+ // particular circumstance, the balance of the section is intended to apply,
851
+ // and the section as a whole is intended to apply in other circumstances.
852
+ // .
853
+ // It is not the purpose of this section to induce you to infringe any
854
+ // patents or other property right claims or to contest validity of any
855
+ // such claims; this section has the sole purpose of protecting the
856
+ // integrity of the free software distribution system which is
857
+ // implemented by public license practices. Many people have made
858
+ // generous contributions to the wide range of software distributed
859
+ // through that system in reliance on consistent application of that
860
+ // system; it is up to the author/donor to decide if he or she is willing
861
+ // to distribute software through any other system and a licensee cannot
862
+ // impose that choice.
863
+ // .
864
+ // This section is intended to make thoroughly clear what is believed to
865
+ // be a consequence of the rest of this License.
866
+ // .
867
+ // 12. If the distribution and/or use of the Library is restricted in
868
+ // certain countries either by patents or by copyrighted interfaces, the
869
+ // original copyright holder who places the Library under this License may add
870
+ // an explicit geographical distribution limitation excluding those countries,
871
+ // so that distribution is permitted only in or among countries not thus
872
+ // excluded. In such case, this License incorporates the limitation as if
873
+ // written in the body of this License.
874
+ // .
875
+ // 13. The Free Software Foundation may publish revised and/or new
876
+ // versions of the Lesser General Public License from time to time.
877
+ // Such new versions will be similar in spirit to the present version,
878
+ // but may differ in detail to address new problems or concerns.
879
+ // .
880
+ // Each version is given a distinguishing version number. If the Library
881
+ // specifies a version number of this License which applies to it and
882
+ // "any later version", you have the option of following the terms and
883
+ // conditions either of that version or of any later version published by
884
+ // the Free Software Foundation. If the Library does not specify a
885
+ // license version number, you may choose any version ever published by
886
+ // the Free Software Foundation.
887
+ // .
888
+ // 14. If you wish to incorporate parts of the Library into other free
889
+ // programs whose distribution conditions are incompatible with these,
890
+ // write to the author to ask for permission. For software which is
891
+ // copyrighted by the Free Software Foundation, write to the Free
892
+ // Software Foundation; we sometimes make exceptions for this. Our
893
+ // decision will be guided by the two goals of preserving the free status
894
+ // of all derivatives of our free software and of promoting the sharing
895
+ // and reuse of software generally.
896
+ // .
897
+ // NO WARRANTY
898
+ // .
899
+ // 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
900
+ // WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
901
+ // EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
902
+ // OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
903
+ // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
904
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
905
+ // PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
906
+ // LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
907
+ // THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
908
+ // .
909
+ // 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
910
+ // WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
911
+ // AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
912
+ // FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
913
+ // CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
914
+ // LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
915
+ // RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
916
+ // FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
917
+ // SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
918
+ // DAMAGES.
919
+ // .
920
+ // END OF TERMS AND CONDITIONS
921
+ // .
922
+ // How to Apply These Terms to Your New Libraries
923
+ // .
924
+ // If you develop a new library, and you want it to be of the greatest
925
+ // possible use to the public, we recommend making it free software that
926
+ // everyone can redistribute and change. You can do so by permitting
927
+ // redistribution under these terms (or, alternatively, under the terms of the
928
+ // ordinary General Public License).
929
+ // .
930
+ // To apply these terms, attach the following notices to the library. It is
931
+ // safest to attach them to the start of each source file to most effectively
932
+ // convey the exclusion of warranty; and each file should have at least the
933
+ // "copyright" line and a pointer to where the full notice is found.
934
+ // .
935
+ // <one line to give the library's name and a brief idea of what it does.>
936
+ // Copyright (C) <year> <name of author>
937
+ // .
938
+ // This library is free software; you can redistribute it and/or
939
+ // modify it under the terms of the GNU Lesser General Public
940
+ // License as published by the Free Software Foundation; either
941
+ // version 2.1 of the License, or (at your option) any later version.
942
+ // .
943
+ // This library is distributed in the hope that it will be useful,
944
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
945
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
946
+ // Lesser General Public License for more details.
947
+ // .
948
+ // You should have received a copy of the GNU Lesser General Public
949
+ // License along with this library; if not, write to the Free Software
950
+ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
951
+ // .
952
+ // Also add information on how to contact you by electronic and paper mail.
953
+ // .
954
+ // You should also get your employer (if you work as a programmer) or your
955
+ // school, if any, to sign a "copyright disclaimer" for the library, if
956
+ // necessary. Here is a sample; alter the names:
957
+ // .
958
+ // Yoyodyne, Inc., hereby disclaims all copyright interest in the
959
+ // library `Frob' (a library for tweaking knobs) written by James Random Hacker.
960
+ // .
961
+ // <signature of Ty Coon>, 1 April 1990
962
+ // Ty Coon, President of Vice
963
+ // .
964
+ // That's all there is to it!
965
+ "use strict";
966
+ var SubtitlesOctopus = function (options) {
967
+ var supportsWebAssembly = false;
968
+ try {
969
+ if (typeof WebAssembly === "object"
970
+ && typeof WebAssembly.instantiate === "function") {
971
+ const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
972
+ if (module instanceof WebAssembly.Module)
973
+ supportsWebAssembly = (new WebAssembly.Instance(module) instanceof WebAssembly.Instance);
974
+ }
975
+ } catch (e) {
976
+ }
977
+ console.log("WebAssembly support detected: " + (supportsWebAssembly ? "yes" : "no"));
978
+
979
+ var self = this;
980
+ self.canvas = options.canvas; // HTML canvas element (optional if video specified)
981
+ self.renderMode = options.renderMode || (options.lossyRender ? 'lossy' : 'wasm-blend');
982
+ self.libassMemoryLimit = options.libassMemoryLimit || 0;
983
+ self.libassGlyphLimit = options.libassGlyphLimit || 0;
984
+ self.targetFps = options.targetFps || 24;
985
+ self.prescaleFactor = options.prescaleFactor || 1.0;
986
+ self.prescaleHeightLimit = options.prescaleHeightLimit || 1080;
987
+ self.maxRenderHeight = options.maxRenderHeight || 0; // 0 - no limit
988
+ self.dropAllAnimations = options.dropAllAnimations || false; // attempt to remove all animations as a last ditch effort for displaying on weak hardware; may severly mangle subtitles if enabled
989
+ self.isOurCanvas = false; // (internal) we created canvas and manage it
990
+ self.video = options.video; // HTML video element (optional if canvas specified)
991
+ self.canvasParent = null; // (internal) HTML canvas parent element
992
+ self.fonts = options.fonts || []; // Array with links to fonts used in sub (optional)
993
+ self.availableFonts = options.availableFonts || []; // Object with all available fonts (optional). Key is font name in lower case, value is link: {"arial": "/font1.ttf"}
994
+ self.fallbackFont = options.fallbackFont || 'default.woff2'; // URL to override fallback font, for example, with a CJK one. Default fallback font is Liberation Sans (Optional)
995
+ self.lazyFileLoading = options.lazyFileLoading || false; // Load fonts in a lazy way. Requires Access-Control-Expose-Headers for Accept-Ranges, Content-Length, and Content-Encoding. If Content-Encoding is compressed, file will be fully fetched instead of just a HEAD request.
996
+ self.onReadyEvent = options.onReady; // Function called when SubtitlesOctopus is ready (optional)
997
+ if (supportsWebAssembly) {
998
+ self.workerUrl = options.workerUrl || 'subtitles-octopus-worker.js'; // Link to WebAssembly worker
999
+ } else {
1000
+ self.workerUrl = options.legacyWorkerUrl || 'subtitles-octopus-worker-legacy.js'; // Link to legacy worker
1001
+ }
1002
+ self.subUrl = options.subUrl; // Link to sub file (optional if subContent specified)
1003
+ self.subContent = options.subContent || null; // Sub content (optional if subUrl specified)
1004
+ self.onErrorEvent = options.onError; // Function called in case of critical error meaning sub wouldn't be shown and you should use alternative method (for instance it occurs if browser doesn't support web workers).
1005
+ self.debug = options.debug || false; // When debug enabled, some performance info printed in console.
1006
+ self.lastRenderTime = 0; // (internal) Last time we got some frame from worker
1007
+ self.pixelRatio = window.devicePixelRatio || 1; // (internal) Device pixel ratio (for high dpi devices)
1008
+
1009
+ self.timeOffset = options.timeOffset || 0; // Time offset would be applied to currentTime from video (option)
1010
+
1011
+ self.hasAlphaBug = false;
1012
+
1013
+ (function() {
1014
+ if (typeof ImageData.prototype.constructor === 'function') {
1015
+ try {
1016
+ // try actually calling ImageData, as on some browsers it's reported
1017
+ // as existing but calling it errors out as "TypeError: Illegal constructor"
1018
+ new window.ImageData(new Uint8ClampedArray([0, 0, 0, 0]), 1, 1);
1019
+ return;
1020
+ } catch (e) {
1021
+ console.log("detected that ImageData is not constructable despite browser saying so");
1022
+ }
1023
+ }
1024
+
1025
+ var canvas = document.createElement('canvas');
1026
+ var ctx = canvas.getContext('2d');
1027
+
1028
+ window.ImageData = function () {
1029
+ var i = 0;
1030
+ if (arguments[0] instanceof Uint8ClampedArray) {
1031
+ var data = arguments[i++];
1032
+ }
1033
+ var width = arguments[i++];
1034
+ var height = arguments[i];
1035
+
1036
+ var imageData = ctx.createImageData(width, height);
1037
+ if (data) imageData.data.set(data);
1038
+ return imageData;
1039
+ }
1040
+ })();
1041
+
1042
+ self.workerError = function (error) {
1043
+ console.error('Worker error: ', error);
1044
+ if (self.onErrorEvent) {
1045
+ self.onErrorEvent(error);
1046
+ }
1047
+ if (!self.debug) {
1048
+ self.dispose();
1049
+ throw new Error('Worker error: ' + error);
1050
+ }
1051
+ };
1052
+
1053
+ // Not tested for repeated usage yet
1054
+ self.init = function () {
1055
+ if (!window.Worker) {
1056
+ self.workerError('worker not supported');
1057
+ return;
1058
+ }
1059
+ // Worker
1060
+ if (!self.worker) {
1061
+ self.worker = new Worker(self.workerUrl);
1062
+ self.worker.addEventListener('message', self.onWorkerMessage);
1063
+ self.worker.addEventListener('error', self.workerError);
1064
+ }
1065
+ self.workerActive = false;
1066
+ self.createCanvas();
1067
+ self.setVideo(options.video);
1068
+ self.setSubUrl(options.subUrl);
1069
+ self.worker.postMessage({
1070
+ target: 'worker-init',
1071
+ width: self.canvas.width,
1072
+ height: self.canvas.height,
1073
+ URL: document.URL,
1074
+ currentScript: self.workerUrl,
1075
+ preMain: true,
1076
+ renderMode: self.renderMode,
1077
+ subUrl: self.subUrl,
1078
+ subContent: self.subContent,
1079
+ fonts: self.fonts,
1080
+ availableFonts: self.availableFonts,
1081
+ fallbackFont: self.fallbackFont,
1082
+ lazyFileLoading: self.lazyFileLoading,
1083
+ debug: self.debug,
1084
+ targetFps: self.targetFps,
1085
+ libassMemoryLimit: self.libassMemoryLimit,
1086
+ libassGlyphLimit: self.libassGlyphLimit,
1087
+ dropAllAnimations: self.dropAllAnimations
1088
+ });
1089
+ };
1090
+
1091
+ self.createCanvas = function () {
1092
+ if (!self.canvas) {
1093
+ if (self.video) {
1094
+ self.isOurCanvas = true;
1095
+ self.canvas = document.createElement('canvas');
1096
+ self.canvas.className = 'libassjs-canvas';
1097
+ self.canvas.style.display = 'none';
1098
+
1099
+ self.canvasParent = document.createElement('div');
1100
+ self.canvasParent.className = 'libassjs-canvas-parent';
1101
+ self.canvasParent.appendChild(self.canvas);
1102
+
1103
+ if (self.video.nextSibling) {
1104
+ self.video.parentNode.insertBefore(self.canvasParent, self.video.nextSibling);
1105
+ }
1106
+ else {
1107
+ self.video.parentNode.appendChild(self.canvasParent);
1108
+ }
1109
+ }
1110
+ else {
1111
+ if (!self.canvas) {
1112
+ self.workerError('Don\'t know where to render: you should give video or canvas in options.');
1113
+ }
1114
+ }
1115
+ }
1116
+ self.ctx = self.canvas.getContext('2d');
1117
+ self.bufferCanvas = document.createElement('canvas');
1118
+ self.bufferCanvasCtx = self.bufferCanvas.getContext('2d');
1119
+
1120
+ // test for alpha bug, where e.g. WebKit can render a transparent pixel
1121
+ // (with alpha == 0) as non-black which then leads to visual artifacts
1122
+ self.bufferCanvas.width = 1;
1123
+ self.bufferCanvas.height = 1;
1124
+ var testBuf = new Uint8ClampedArray([0, 255, 0, 0]);
1125
+ var testImage = new ImageData(testBuf, 1, 1);
1126
+ self.bufferCanvasCtx.clearRect(0, 0, 1, 1);
1127
+ self.ctx.clearRect(0, 0, 1, 1);
1128
+ var prePut = self.ctx.getImageData(0, 0, 1, 1).data;
1129
+ self.bufferCanvasCtx.putImageData(testImage, 0, 0);
1130
+ self.ctx.drawImage(self.bufferCanvas, 0, 0);
1131
+ var postPut = self.ctx.getImageData(0, 0, 1, 1).data;
1132
+ self.hasAlphaBug = prePut[1] != postPut[1];
1133
+ if (self.hasAlphaBug) {
1134
+ console.log("Detected a browser having issue with transparent pixels, applying workaround");
1135
+ }
1136
+ };
1137
+
1138
+ function onTimeUpdate() {
1139
+ self.setCurrentTime(self.video.currentTime + self.timeOffset);
1140
+ };
1141
+
1142
+ function onPlaying() {
1143
+ self.setIsPaused(false, self.video.currentTime + self.timeOffset);
1144
+ }
1145
+
1146
+ function onPause() {
1147
+ self.setIsPaused(true, self.video.currentTime + self.timeOffset);
1148
+ }
1149
+
1150
+ function onSeeking() {
1151
+ self.video.removeEventListener('timeupdate', onTimeUpdate, false);
1152
+ }
1153
+
1154
+ function onSeeked() {
1155
+ self.video.addEventListener('timeupdate', onTimeUpdate, false);
1156
+
1157
+ var currentTime = self.video.currentTime + self.timeOffset;
1158
+
1159
+ self.setCurrentTime(currentTime);
1160
+ }
1161
+
1162
+ function onRateChange() {
1163
+ self.setRate(self.video.playbackRate);
1164
+ }
1165
+
1166
+ function onWaiting() {
1167
+ self.setIsPaused(true, self.video.currentTime + self.timeOffset);
1168
+ }
1169
+
1170
+ function onLoadedMetadata(e) {
1171
+ e.target.removeEventListener(e.type, onLoadedMetadata, false);
1172
+ self.resize();
1173
+ }
1174
+
1175
+ self.setVideo = function (video) {
1176
+ self.video = video;
1177
+ if (self.video) {
1178
+ self.video.addEventListener('timeupdate', onTimeUpdate, false);
1179
+ self.video.addEventListener('playing', onPlaying, false);
1180
+ self.video.addEventListener('pause', onPause, false);
1181
+ self.video.addEventListener('seeking', onSeeking, false);
1182
+ self.video.addEventListener('seeked', onSeeked, false);
1183
+ self.video.addEventListener('ratechange', onRateChange, false);
1184
+ self.video.addEventListener('waiting', onWaiting, false);
1185
+
1186
+ document.addEventListener("fullscreenchange", self.resizeWithTimeout, false);
1187
+ document.addEventListener("mozfullscreenchange", self.resizeWithTimeout, false);
1188
+ document.addEventListener("webkitfullscreenchange", self.resizeWithTimeout, false);
1189
+ document.addEventListener("msfullscreenchange", self.resizeWithTimeout, false);
1190
+ window.addEventListener("resize", self.resizeWithTimeout, false);
1191
+
1192
+ // Support Element Resize Observer
1193
+ if (typeof ResizeObserver !== "undefined") {
1194
+ self.ro = new ResizeObserver(self.resizeWithTimeout);
1195
+ self.ro.observe(self.video);
1196
+ }
1197
+
1198
+ if (self.video.videoWidth > 0) {
1199
+ self.resize();
1200
+ }
1201
+ else {
1202
+ self.video.addEventListener('loadedmetadata', onLoadedMetadata, false);
1203
+ }
1204
+ }
1205
+ };
1206
+
1207
+ self.getVideoPosition = function () {
1208
+ var videoRatio = self.video.videoWidth / self.video.videoHeight;
1209
+ var width = self.video.offsetWidth, height = self.video.offsetHeight;
1210
+ var elementRatio = width / height;
1211
+ var realWidth = width, realHeight = height;
1212
+ if (elementRatio > videoRatio) realWidth = Math.floor(height * videoRatio);
1213
+ else realHeight = Math.floor(width / videoRatio);
1214
+
1215
+ var x = (width - realWidth) / 2;
1216
+ var y = (height - realHeight) / 2;
1217
+
1218
+ return {
1219
+ width: realWidth,
1220
+ height: realHeight,
1221
+ x: x,
1222
+ y: y
1223
+ };
1224
+ };
1225
+
1226
+ self.setSubUrl = function (subUrl) {
1227
+ self.subUrl = subUrl;
1228
+ };
1229
+
1230
+ self.renderFrameData = null;
1231
+ function renderFrames() {
1232
+ var data = self.renderFramesData;
1233
+ var beforeDrawTime = performance.now();
1234
+ self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height);
1235
+ for (var i = 0; i < data.canvases.length; i++) {
1236
+ var image = data.canvases[i];
1237
+ self.bufferCanvas.width = image.w;
1238
+ self.bufferCanvas.height = image.h;
1239
+ var imageBuffer = new Uint8ClampedArray(image.buffer);
1240
+ if (self.hasAlphaBug) {
1241
+ for (var j = 3; j < imageBuffer.length; j = j + 4) {
1242
+ imageBuffer[j] = (imageBuffer[j] >= 1) ? imageBuffer[j] : 1;
1243
+ }
1244
+ }
1245
+ var imageData = new ImageData(imageBuffer, image.w, image.h);
1246
+ self.bufferCanvasCtx.putImageData(imageData, 0, 0);
1247
+ self.ctx.drawImage(self.bufferCanvas, image.x, image.y);
1248
+ }
1249
+ if (self.debug) {
1250
+ var drawTime = Math.round(performance.now() - beforeDrawTime);
1251
+ var blendTime = data.blendTime;
1252
+ if (typeof blendTime !== 'undefined') {
1253
+ console.log('render: ' + Math.round(data.spentTime - blendTime) + ' ms, blend: ' + Math.round(blendTime) + ' ms, draw: ' + drawTime + ' ms; TOTAL=' + Math.round(data.spentTime + drawTime) + ' ms');
1254
+ } else {
1255
+ console.log(Math.round(data.spentTime) + ' ms (+ ' + drawTime + ' ms draw)');
1256
+ }
1257
+ self.renderStart = performance.now();
1258
+ }
1259
+ }
1260
+
1261
+ /**
1262
+ * Lossy Render Mode
1263
+ *
1264
+ */
1265
+ function renderFastFrames() {
1266
+ var data = self.renderFramesData;
1267
+ var beforeDrawTime = performance.now();
1268
+ self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height);
1269
+ for (var i = 0; i < data.bitmaps.length; i++) {
1270
+ var image = data.bitmaps[i];
1271
+ self.ctx.drawImage(image.bitmap, image.x, image.y);
1272
+ }
1273
+ if (self.debug) {
1274
+ var drawTime = Math.round(performance.now() - beforeDrawTime);
1275
+ console.log(data.bitmaps.length + ' bitmaps, libass: ' + Math.round(data.libassTime) + 'ms, decode: ' + Math.round(data.decodeTime) + 'ms, draw: ' + drawTime + 'ms');
1276
+ self.renderStart = performance.now();
1277
+ }
1278
+ }
1279
+
1280
+ self.workerActive = false;
1281
+ self.frameId = 0;
1282
+ self.onWorkerMessage = function (event) {
1283
+ //dump('\nclient got ' + JSON.stringify(event.data).substr(0, 150) + '\n');
1284
+ if (!self.workerActive) {
1285
+ self.workerActive = true;
1286
+ if (self.onReadyEvent) {
1287
+ self.onReadyEvent();
1288
+ }
1289
+ }
1290
+ var data = event.data;
1291
+ switch (data.target) {
1292
+ case 'stdout': {
1293
+ console.log(data.content);
1294
+ break;
1295
+ }
1296
+ case 'console-log': {
1297
+ console.log.apply(console, JSON.parse(data.content));
1298
+ break;
1299
+ }
1300
+ case 'console-debug': {
1301
+ console.debug.apply(console, JSON.parse(data.content));
1302
+ break;
1303
+ }
1304
+ case 'console-info': {
1305
+ console.info.apply(console, JSON.parse(data.content));
1306
+ break;
1307
+ }
1308
+ case 'console-warn': {
1309
+ console.warn.apply(console, JSON.parse(data.content));
1310
+ break;
1311
+ }
1312
+ case 'console-error': {
1313
+ console.error.apply(console, JSON.parse(data.content));
1314
+ break;
1315
+ }
1316
+ case 'stderr': {
1317
+ console.error(data.content);
1318
+ break;
1319
+ }
1320
+ case 'window': {
1321
+ window[data.method]();
1322
+ break;
1323
+ }
1324
+ case 'canvas': {
1325
+ switch (data.op) {
1326
+ case 'getContext': {
1327
+ self.ctx = self.canvas.getContext(data.type, data.attributes);
1328
+ break;
1329
+ }
1330
+ case 'resize': {
1331
+ self.resize(data.width, data.height);
1332
+ break;
1333
+ }
1334
+ case 'renderCanvas': {
1335
+ if (self.lastRenderTime < data.time) {
1336
+ self.lastRenderTime = data.time;
1337
+ self.renderFramesData = data;
1338
+ window.requestAnimationFrame(renderFrames);
1339
+ }
1340
+ break;
1341
+ }
1342
+ case 'renderFastCanvas': {
1343
+ if (self.lastRenderTime < data.time) {
1344
+ self.lastRenderTime = data.time;
1345
+ self.renderFramesData = data;
1346
+ window.requestAnimationFrame(renderFastFrames);
1347
+ }
1348
+ break;
1349
+ }
1350
+ case 'setObjectProperty': {
1351
+ self.canvas[data.object][data.property] = data.value;
1352
+ break;
1353
+ }
1354
+ default:
1355
+ throw 'eh?';
1356
+ }
1357
+ break;
1358
+ }
1359
+ case 'tick': {
1360
+ self.frameId = data.id;
1361
+ self.worker.postMessage({
1362
+ target: 'tock',
1363
+ id: self.frameId
1364
+ });
1365
+ break;
1366
+ }
1367
+ case 'custom': {
1368
+ if (self['onCustomMessage']) {
1369
+ self['onCustomMessage'](event);
1370
+ } else {
1371
+ throw 'Custom message received but client onCustomMessage not implemented.';
1372
+ }
1373
+ break;
1374
+ }
1375
+ case 'setimmediate': {
1376
+ self.worker.postMessage({
1377
+ target: 'setimmediate'
1378
+ });
1379
+ break;
1380
+ }
1381
+ case 'get-events': {
1382
+ break;
1383
+ }
1384
+ case 'get-styles': {
1385
+ break;
1386
+ }
1387
+ case 'ready': {
1388
+ break;
1389
+ }
1390
+ default:
1391
+ throw 'what? ' + data.target;
1392
+ }
1393
+ };
1394
+
1395
+ function _computeCanvasSize(width, height) {
1396
+ var scalefactor = self.prescaleFactor <= 0 ? 1.0 : self.prescaleFactor;
1397
+
1398
+ if (height <= 0 || width <= 0) {
1399
+ width = 0;
1400
+ height = 0;
1401
+ } else {
1402
+ var sgn = scalefactor < 1 ? -1 : 1;
1403
+ var newH = height;
1404
+ if (sgn * newH * scalefactor <= sgn * self.prescaleHeightLimit)
1405
+ newH *= scalefactor;
1406
+ else if (sgn * newH < sgn * self.prescaleHeightLimit)
1407
+ newH = self.prescaleHeightLimit;
1408
+
1409
+ if (self.maxRenderHeight > 0 && newH > self.maxRenderHeight)
1410
+ newH = self.maxRenderHeight;
1411
+
1412
+ width *= newH / height;
1413
+ height = newH;
1414
+ }
1415
+
1416
+ return {'width': width, 'height': height};
1417
+ }
1418
+
1419
+ self.resize = function (width, height, top, left) {
1420
+ var videoSize = null;
1421
+ top = top || 0;
1422
+ left = left || 0;
1423
+ if ((!width || !height) && self.video) {
1424
+ videoSize = self.getVideoPosition();
1425
+ var newSize = _computeCanvasSize(videoSize.width * self.pixelRatio, videoSize.height * self.pixelRatio);
1426
+ width = newSize.width;
1427
+ height = newSize.height;
1428
+ var offset = self.canvasParent.getBoundingClientRect().top - self.video.getBoundingClientRect().top;
1429
+ top = videoSize.y - offset;
1430
+ left = videoSize.x;
1431
+ }
1432
+ if (!width || !height) {
1433
+ if (!self.video) {
1434
+ console.error('width or height is 0. You should specify width & height for resize.');
1435
+ }
1436
+ return;
1437
+ }
1438
+
1439
+
1440
+ if (
1441
+ self.canvas.width != width ||
1442
+ self.canvas.height != height ||
1443
+ self.canvas.style.top != top ||
1444
+ self.canvas.style.left != left
1445
+ ) {
1446
+ self.canvas.width = width;
1447
+ self.canvas.height = height;
1448
+
1449
+ if (videoSize != null) {
1450
+ self.canvasParent.style.position = 'relative';
1451
+ self.canvas.style.display = 'block';
1452
+ self.canvas.style.position = 'absolute';
1453
+ self.canvas.style.width = videoSize.width + 'px';
1454
+ self.canvas.style.height = videoSize.height + 'px';
1455
+ self.canvas.style.top = top + 'px';
1456
+ self.canvas.style.left = left + 'px';
1457
+ self.canvas.style.pointerEvents = 'none';
1458
+ }
1459
+
1460
+ self.worker.postMessage({
1461
+ target: 'canvas',
1462
+ width: self.canvas.width,
1463
+ height: self.canvas.height
1464
+ });
1465
+ }
1466
+ };
1467
+
1468
+ self.resizeWithTimeout = function () {
1469
+ self.resize();
1470
+ setTimeout(self.resize, 100);
1471
+ };
1472
+
1473
+ self.runBenchmark = function () {
1474
+ self.worker.postMessage({
1475
+ target: 'runBenchmark'
1476
+ });
1477
+ };
1478
+
1479
+ self.customMessage = function (data, options) {
1480
+ options = options || {};
1481
+ self.worker.postMessage({
1482
+ target: 'custom',
1483
+ userData: data,
1484
+ preMain: options.preMain
1485
+ });
1486
+ };
1487
+
1488
+ self.setCurrentTime = function (currentTime) {
1489
+ self.worker.postMessage({
1490
+ target: 'video',
1491
+ currentTime: currentTime
1492
+ });
1493
+ };
1494
+
1495
+ self.setTrackByUrl = function (url) {
1496
+ self.worker.postMessage({
1497
+ target: 'set-track-by-url',
1498
+ url: url
1499
+ });
1500
+ };
1501
+
1502
+ self.setTrack = function (content) {
1503
+ self.worker.postMessage({
1504
+ target: 'set-track',
1505
+ content: content
1506
+ });
1507
+ };
1508
+
1509
+ self.freeTrack = function (content) {
1510
+ self.worker.postMessage({
1511
+ target: 'free-track'
1512
+ });
1513
+ };
1514
+
1515
+
1516
+ self.render = self.setCurrentTime;
1517
+
1518
+ self.setIsPaused = function (isPaused, currentTime) {
1519
+ self.worker.postMessage({
1520
+ target: 'video',
1521
+ isPaused: isPaused,
1522
+ currentTime: currentTime
1523
+ });
1524
+ };
1525
+
1526
+ self.setRate = function (rate) {
1527
+ self.worker.postMessage({
1528
+ target: 'video',
1529
+ rate: rate
1530
+ });
1531
+ };
1532
+
1533
+ self.dispose = function () {
1534
+ self.worker.postMessage({
1535
+ target: 'destroy'
1536
+ });
1537
+
1538
+ self.worker.terminate();
1539
+ self.worker.removeEventListener('message', self.onWorkerMessage);
1540
+ self.worker.removeEventListener('error', self.workerError);
1541
+ self.workerActive = false;
1542
+ self.worker = null;
1543
+
1544
+ // Remove the canvas element to remove residual subtitles rendered on player
1545
+ if (self.video) {
1546
+ self.video.removeEventListener('timeupdate', onTimeUpdate, false);
1547
+ self.video.removeEventListener('playing', onPlaying, false);
1548
+ self.video.removeEventListener('pause', onPause, false);
1549
+ self.video.removeEventListener('seeking', onSeeking, false);
1550
+ self.video.removeEventListener('seeked', onSeeked, false);
1551
+ self.video.removeEventListener('ratechange', onRateChange, false);
1552
+ self.video.removeEventListener('waiting', onWaiting, false);
1553
+ self.video.removeEventListener('loadedmetadata', onLoadedMetadata, false);
1554
+
1555
+ document.removeEventListener('fullscreenchange', self.resizeWithTimeout, false);
1556
+ document.removeEventListener('mozfullscreenchange', self.resizeWithTimeout, false);
1557
+ document.removeEventListener('webkitfullscreenchange', self.resizeWithTimeout, false);
1558
+ document.removeEventListener('msfullscreenchange', self.resizeWithTimeout, false);
1559
+ window.removeEventListener('resize', self.resizeWithTimeout, false);
1560
+
1561
+ self.video.parentNode.removeChild(self.canvasParent);
1562
+
1563
+ self.video = null;
1564
+ }
1565
+
1566
+ if (self.ro) {
1567
+ self.ro.disconnect();
1568
+ self.ro = null;
1569
+ }
1570
+
1571
+ self.onCustomMessage = null;
1572
+ self.onErrorEvent = null;
1573
+ self.onReadyEvent = null;
1574
+ };
1575
+
1576
+ self.fetchFromWorker = function (workerOptions, onSuccess, onError) {
1577
+ try {
1578
+ var target = workerOptions['target']
1579
+
1580
+ var timeout = setTimeout(function() {
1581
+ reject(Error('Error: Timeout while try to fetch ' + target))
1582
+ }, 5000)
1583
+
1584
+ var resolve = function (event) {
1585
+ if (event.data.target == target) {
1586
+ onSuccess(event.data)
1587
+ self.worker.removeEventListener('message', resolve)
1588
+ self.worker.removeEventListener('error', reject)
1589
+ clearTimeout(timeout)
1590
+ }
1591
+ }
1592
+
1593
+ var reject = function (event) {
1594
+ onError(event)
1595
+ self.worker.removeEventListener('message', resolve)
1596
+ self.worker.removeEventListener('error', reject)
1597
+ clearTimeout(timeout)
1598
+ }
1599
+
1600
+ self.worker.addEventListener('message', resolve)
1601
+ self.worker.addEventListener('error', reject)
1602
+
1603
+ self.worker.postMessage(workerOptions)
1604
+ } catch (error) {
1605
+ onError(error)
1606
+ }
1607
+ }
1608
+
1609
+ self.createEvent = function (event) {
1610
+ self.worker.postMessage({
1611
+ target: 'create-event',
1612
+ event: event
1613
+ });
1614
+ };
1615
+
1616
+ self.getEvents = function (onSuccess, onError) {
1617
+ self.fetchFromWorker({
1618
+ target: 'get-events'
1619
+ }, function(data) {
1620
+ onSuccess(data.events)
1621
+ }, onError);
1622
+ };
1623
+
1624
+ self.setEvent = function (event, index) {
1625
+ self.worker.postMessage({
1626
+ target: 'set-event',
1627
+ event: event,
1628
+ index: index
1629
+ });
1630
+ };
1631
+
1632
+ self.removeEvent = function (index) {
1633
+ self.worker.postMessage({
1634
+ target: 'remove-event',
1635
+ index: index
1636
+ });
1637
+ };
1638
+
1639
+ self.createStyle = function (style) {
1640
+ self.worker.postMessage({
1641
+ target: 'create-style',
1642
+ style: style
1643
+ });
1644
+ };
1645
+
1646
+ self.getStyles = function (onSuccess, onError) {
1647
+ self.fetchFromWorker({
1648
+ target: 'get-styles'
1649
+ }, function(data) {
1650
+ onSuccess(data.styles)
1651
+ }, onError);
1652
+ };
1653
+
1654
+ self.setStyle = function (style, index) {
1655
+ self.worker.postMessage({
1656
+ target: 'set-style',
1657
+ style: style,
1658
+ index: index
1659
+ });
1660
+ };
1661
+
1662
+ self.removeStyle = function (index) {
1663
+ self.worker.postMessage({
1664
+ target: 'remove-style',
1665
+ index: index
1666
+ });
1667
+ };
1668
+
1669
+ self.init();
1670
+ };
1671
+
1672
+ if (typeof SubtitlesOctopusOnLoad == 'function') {
1673
+ SubtitlesOctopusOnLoad();
1674
+ }
1675
+
1676
+ if (typeof exports !== 'undefined') {
1677
+ if (typeof module !== 'undefined' && module.exports) {
1678
+ exports = module.exports = SubtitlesOctopus
1679
+ }
1680
+ }