1
0
mirror of https://github.com/odrling/Aegisub synced 2025-04-11 22:56:02 +02:00

63 Commits

Author SHA1 Message Date
arch1t3cht
9b5a41e8a8
Stop shifting timecodes to start at 0ms
This reverts commit 1dedfb18cd62f006c39f76ce298f4a3157607271.
Such files exist in the wild (one example being a large set of old CR
rips, see https://redvice.org/2018/crunchyroll-83ms-delay/) and players
like mpv also respect this video delay (at least they do now, they might
not have when the linked commit was made).

Fixes TypesettingTools/Aegisub#21.
Fixes TypesettingTools/Aegisub#169.
2024-12-19 16:51:54 +01:00
arch1t3cht
374ea92210 Add missing include in tests/tests/fs.cpp 2024-12-17 10:11:35 -08:00
arch1t3cht
c7e703f169 Fix FrameAtTime computation for CFR
To see how the previous implementation was faulty, see either the added
tests, or
- In Aegisub, open a dummy video with a frame rate of 23.976
- Make a subtitle event with start time 04:44.41
- Double-click the line to (supposedly) seek to its first frame
- This will seek one frame earlier than it should, and the event will
  not be displayed on the resulting frame.

The new formula is the mathematical inverse of the TimeAtFrame formula
(for the EXACT case). The derivation is the following:

FrameAtTime(ms, EXACT) should be the largest possible integer `frame`
such that:

ms >= floor(((frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2)) / numerator)

where `/` denotes division of real numbers (i.e. without rounding down).
The expression on the right is the formula used in TimeAtFrame.
This inequality can be transformed as follows:

ms >= floor(((frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2)) / numerator)

((frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2)) / numerator < ms + 1

(frame - timecodes.size() + 1) * 1000 * denominator + last + floor(numerator / 2) < (ms + 1) * numerator

(frame - timecodes.size() + 1) * 1000 * denominator < (ms + 1) * numerator - last - floor(numerator / 2)

frame - timecodes.size() + 1 < ((ms + 1) * numerator - last - floor(numerator / 2)) / (1000 * denominator)

frame - timecodes.size() + 1 < ceil(((ms + 1) * numerator - last - floor(numerator / 2)) / (1000 * denominator))

frame - timecodes.size() + 1 < floor(((ms + 1) * numerator - last - floor(numerator / 2) + (1000 * denominator - 1)) / (1000 * denominator))

frame < floor(((ms + 1) * numerator - last - floor(numerator / 2) + (1000 * denominator - 1)) / (1000 * denominator)) + timecodes.size() - 1

frame <= floor(((ms + 1) * numerator - last - floor(numerator / 2) + (1000 * denominator - 1)) / (1000 * denominator)) + timecodes.size() - 2

Since we are looking for the largest integer `frame` satisfying this
inequality, FrameAtTime(ms, EXACT) must be equal to the right-hand side
in the last inequality.
2024-12-17 10:11:35 -08:00
arch1t3cht
0b40de8bea
C++ modernization and boost removal (#182)
* Bump boost to 1.83

* Switch to building as C++20

Co-authored-by: Ryan Lucia <ryan@luciaonline.net>

* Fix many warnings

* Rip out boost::locale and just use ICU directly

* Fix

* Replace boost::filesystem with std::filesystem

* Fix

* Addditional c++ modernization

* Use string_view all over the place and rip out more boost stuff

* Simply BOM handling in charset conversions

* libaegisub: fix dispatch types

* Fix

* Bump subprojects

* Reorganize tests build file

* Fix remaining compilation errors on Linux

* Rip out the last bits of boost::filesystem

* Remove remaining uses of boost string joins

* Fix some errors introduced with refactors

* Revert "Simply BOM handling in charset conversions"

This reverts commit 2e6b26d5ffe69d7fb280bb1d18c6758112244b64.
Taking out the BOM handling broke tests, so it'll probably break more
stuff.

* Bring back IconvWrapper::RequiredBufferSize

This partially reverts 62befa996126659d139e9ad53e631780b6ed6122 .
This function is actually used in charset_conv_win.cpp

* Fix ifind after moving to ICU

The previous logic didn't check if the match was on parts of
decomposed characters, so it also failed the corresponding test.

* Remove incorrect karaoke_matcher test

This was clearly incorrect and probably just unfinished.

* Remove leftover boost::locale code

* Move iconv include to charset_conv.h

On newer mac sdks iconv_t is defined differently, so it's harder to
just have a typedef for it.

* Fix compilation on arm64 mac

wx uses a different string implementation here, and utf8_string()
doesn't exist there.

* Fix luajit dependency in luabins project

Since luajit always first tried using dependency(), further calls
of dependency() will also always return system luajit.
meson.override_dependency() won't work.
This makes luabins link system luajit where it's available while aegisub
itself uses the subproject's luajit, which causes all kinds of fun
issues and definitely didn't baffle me four hours...

The added solution for this is horribly ugly (and also has problems when
reconfiguring...) but it's the only one I found that works. Maybe it's
better to always require interal luajit after all, or make the user
choose with a meson option?

* Fix locale initialization

Previously this would fail on startup because the automation menu
uses boost::locale::comparator.
... Or maybe the locale init change should just be reverted entirely?
Or it should be something different? I don't really know.

* Revert "Fix luajit dependency in luabins project"

This reverts commit 340fb9c6125412d18f23c08c00f2bc8f46774b6d.

* Fix luajit dependency in luabins project, take 2

Thinking about it some more, just copying the detection logic is
probably the lesser evil here.

* Fix agi::split_iterator after refactor

is_end being removed caused it to not output an empty segment at the
end if the input ends with a delimiter, but existing usages relied
on it doing that.

* Fix style parsing after refactor

* Fix tons of implicit this captures

* Enable CI to test

* Update deprecated hunspell usage

* Fix tests compilation on mac

* Make sure wx subproject builds with c++14

* Fix compilation on Windows

* Revert "Bring back IconvWrapper::RequiredBufferSize"

This reverts commit 04f4b260a08de6497c583f025090ca4f9fe1ef6d.

* Pin libass wrap for now

Apparently dependency('iconv') breaks when iconv is overridden??

* Fix compilation with wx 3.0

* Fix startup crash on Windows

windows.h was defining the ERROR macro, which shadowed the
DialogueTokenType enum variant, which broke the lexer construction.

* Fix SplitText ICU logic

Include UBRK_WORD_IDEO and check the entire rules vec. This now matches
the logic of boost::locale.

* Add test for character_count with \N and friends

* Fix ass_dialogue parsing after refactor

* Revert "Pin libass wrap for now"

This reverts commit 3802bb7272a8bf4861c09b020c9eee9e643804fc.

* Remove iconv's stdbool.h

This was breaking things (libass) and doesn't seem to be
needed any more.

* Revert changes to to_wx

These broke some things, in particular FromUTF8Unchecked seems to not
like empty strings. Probably safer to just revert.

* Fix kara replacer after refactor

* Fix karaoke timing mode after refactor

* Revert "Enable CI to test"

This reverts commit 256cbebbfc9cf4eb5c497898670ac28ce24ce2fd.

---------

Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Co-authored-by: Thomas Goyne <plorkyeran@gmail.com>
2023-12-03 10:59:50 -08:00
woclass
7e9c7d7aa0
Run tests (#125)
* [git] ignore IDE setting, Meson subprojects

* [win_installer] rename *.mo -> *.gmo

* [win_installer] only add aeg translations

* [win_installer] split aeg/wx translations

* [win_installer] gen & pack translations

* [git] ignore hunspell source dir

* [git] ignore uchardet source dir

* [test] Generate the test executable

run with `meson test`

* [test] add tools to remove test data files

`unset.bat FULL_PATH`

* [test] set to correct Error type

* [test] Set Source character sets to UTF-8 for MSVC

* [test] move test data files to build_root

* [git] remove IDE dir

* [git] ignore gtest subprojects

* [ci] run test in ci

* [meson/test] use more meaningful name

* [test] Add more comments and help msg
2021-05-23 23:33:33 -04:00
Ryan
d583744b69 Merge in work from TypesettingTools fork 2021-01-16 02:12:31 -05:00
Ryan Lucia
c965171663 Remove autotools build system 2021-01-10 03:14:12 -05:00
wangqr
57ee580c0f Fix lagi_thes unit tests on Windows
The thes file was using \r\n line ends, and \r was not stripped, causing the encoding string has a \r at its end.
Use binary mode and always use \n as line ends.
2019-09-22 17:41:05 -07:00
wangqr
10f7458b5f Fix PCM provider bugs 2019-09-22 17:41:02 -07:00
wangqr
1122c0880a Fix failing unit tests on Windows 2019-09-22 17:41:02 -07:00
wangqr
dd59fc988a Fix gtest setup.bat on Windows 2019-09-22 17:41:02 -07:00
wangqr
7a1756a26f In tagless_find_helper only tag before start should be ignored
The search result is irrelevant to which tag we should ignore

Fix wangqr/Aegisub#17
2019-09-22 17:41:02 -07:00
wangqr
6732179a8a Fix wrong memset usage 2019-09-22 17:41:02 -07:00
wangqr
5d4973a5f6 Fix millisecond to centisecond convertion
Fix Aegisub/Aegisub#94
2019-09-22 17:12:05 -07:00
therealfun
f6a2ac08a6 Makefiles: replace the use of subst macro with patsubst (#56)
$(subst .c,.o,...) replaces '.c' with '.o' everywhere in pathnames. For
example, renaming the "Aegisub" folder to "Aegisub.cool" will make the
build system generate "Aegisub.oool/.../.o" objects.

https://www.gnu.org/software/make/manual/make.html#Text-Functions
2018-03-05 09:28:29 -08:00
Thomas Goyne
893b08a19c Add CFLAGS_PTHREAD/LIBS_PTHREAD to everything needing them
Closes #1903.
2016-03-05 11:23:46 -08:00
Thomas Goyne
45315476bd Switch to a maintained fork of universalchardet 2016-02-09 20:29:29 -08:00
Thomas Goyne
fefa31eb47 Improve code coverage of tests 2015-07-28 14:30:03 -07:00
Thomas Goyne
3c55d4fde4 Fix incorrect results for non-regex skip tags searches
Closes #1865.
2015-07-27 10:29:22 -07:00
Thomas Goyne
3554bdc29a Fix failing tests 2015-02-15 12:37:34 -08:00
Thomas Goyne
427037a552 Reimplement boost::split_iterator to make it less slow
boost::split_iterator type-erases the predicate, which makes it require
a virtual call per character (!) along with a heap allocation. As it
turns out we only ever need one predicate (comparing to a single
character), so replace it with a split_iterator that just does that.
2015-02-07 14:56:27 -08:00
Thomas Goyne
a6b1639320 Extract some bits that don't need to be templated from templates
Cuts compile time by about 10% and shrinks the final binary a little.
2014-12-28 16:46:38 -08:00
Thomas Goyne
cf252fa91a Add simple type -> type name string compile time reflection stuff
This is needed for passing types to the LuaJIT ffi.
2014-07-28 12:30:44 -07:00
Thomas Goyne
584284aa79 Reject vfr timecodes which are all identical 2014-07-15 09:11:40 -07:00
Thomas Goyne
a5c2ef273f Add tests for floating point sample conversion 2014-07-10 11:44:56 -07:00
Thomas Goyne
63de3232f7 Add test for channel downmixing 2014-07-10 11:44:56 -07:00
Thomas Goyne
f32bdff84a Add tests for the sample doubling converter and make it work correctly 2014-07-10 11:44:56 -07:00
Thomas Goyne
b9c75d8706 Add tests for the audio bitdepth conversions
And fix some bugs in it, and make it not rely on undefined behavior.
2014-07-10 11:44:56 -07:00
Thomas Goyne
585e9489d9 Move some of the audio provider machinery to libaegisub
And add tests.
2014-07-10 11:44:56 -07:00
Thomas Goyne
a11da3350c Save a backup copy of the old hotkey file if migrating from the old format 2014-07-07 09:42:02 -07:00
Thomas Goyne
5a14b36389 Remove unused test util functions 2014-07-06 19:25:49 -07:00
Thomas Goyne
935c6bc3a7 Store hotkeys in a less dumb format 2014-07-06 19:25:49 -07:00
Thomas Goyne
033baed930 Add simple tests for agi::Split 2014-07-06 19:25:49 -07:00
Thomas Goyne
2757ebd94f Add character counter tests 2014-07-06 19:25:49 -07:00
Thomas Goyne
3b34ed9a77 Move AssTime to libaegisub and add tests 2014-07-06 19:25:49 -07:00
Thomas Goyne
f0f836c47b Eliminate a pointless std::map in charset_conv 2014-07-06 19:25:48 -07:00
Thomas Goyne
d9016cc8ea Debloat and slightly speed up the MRU code 2014-07-06 19:25:48 -07:00
Thomas Goyne
518342b919 Make the hotkey code a bit less bloated 2014-07-06 19:25:48 -07:00
Thomas Goyne
c0c05e982a Support passing a test filter to make test 2014-07-04 21:14:29 -07:00
Thomas Goyne
df8ad34838 Eliminate pointless runtime datastructures for CalltipProvider
And add some tests and make it actually work correctly.
2014-07-04 20:37:36 -07:00
Thomas Goyne
2f0ddb4f32 Improve the line_iterator tests 2014-07-03 10:57:53 -07:00
Thomas Goyne
3832f700c5 Eliminate race condition in fs::Touch test 2014-07-02 18:20:11 -07:00
Thomas Goyne
3ddafcd34a Disable iconv tests that require on libiconv functionality when not using libiconv 2014-07-02 18:20:10 -07:00
Thomas Goyne
c804042978 Fix test compilation with gcc 2014-07-02 18:20:10 -07:00
Thomas Goyne
c5bffa9352 Fix failing path test on Linux 2014-07-02 18:20:10 -07:00
Thomas Goyne
1c94439909 Support running setup.sh out-of-tree 2014-07-02 10:55:19 -07:00
Thomas Goyne
dbf144812b Fix failing path tests on OS X 2014-06-29 10:45:26 -07:00
Thomas Goyne
4c88449e4c Make UnknownElement moveable and not copyable
And remove the unused comparison functionality.
2014-06-29 10:45:26 -07:00
Thomas Goyne
4c0e578eda Rewrite the remaining bits of json::Writer 2014-06-29 10:45:26 -07:00
Thomas Goyne
bc410a99f6 Change the in-memory storage of options to a sorted vector 2014-06-29 10:01:00 -07:00