Commit Graph

97 Commits

Author SHA1 Message Date
Moritz Bunkus
78a46ac215
bit_reader_c: add function for reading bits into a std::string 2019-01-22 18:01:09 +01:00
Moritz Bunkus
66effd98c2
math: add function for clamping parts of a rational to max value 2018-10-11 16:34:43 +02:00
Moritz Bunkus
88dfeae3f5
memory_c: new function for prepending memory; add test cases 2018-10-08 10:53:59 +02:00
Moritz Bunkus
8bcc286dfc
refactoring: no 'using namespace …' in header files
It is dangerous insofar as it pollutes an immense number of source
files. For example, utf8cpp's stuff uses relative namespace
names (e.g. `utf8::some_type`). If `using namespace libebml` is in
effect, then this clashes with `libebml::utf8` which is a typedef for
`unsigned char`, causing compiler errors.
2018-06-15 17:45:22 +02:00
Moritz Bunkus
c8cb86b8fb
bit_reader_c: fix get_bit_position/get_remaining_bits for empty buffers
One side affect of the fixed bug was that trying to identify/mux an
empty file (file with a size of 0) resulted in the following error
message:

> Error: buffer_c: num > m_filled. Should not have happened. Please
> file a bug report.
2018-06-14 21:23:42 +02:00
Moritz Bunkus
e3f54fdbcb bit_writer_c: change put_bit() back to taking a bool
Taking an `int` was done due to clang-tidy's modernize checks
bemoaning the use of integers 0 and 1 instead of `true` and `false`
for Boolean parameters. However, that had the unintended consequence
of truncating values if the values given to the parameter is e.g. a
`uint64_t` for which a bit was tested with "value & (1 << shift)" —
which relied on implicit conversion to bool.
2018-04-27 14:42:14 +02:00
Moritz Bunkus
b49a370c57 use C++14 std::string literals 2018-04-20 16:32:54 +02:00
Moritz Bunkus
589809a170 tests: avoid memory leaks 2018-04-17 16:35:41 +02:00
Moritz Bunkus
33b36d66c9 mtx::bits::writer_c: allow usage with provided buffer
Such a buffer cannot be extended, though.
2018-03-06 20:52:46 +01:00
Moritz Bunkus
3f83660b4d memory_c: add splice function for removing/inserting sections 2017-12-17 22:50:54 +01:00
Moritz Bunkus
68272764e1 mm_proxy_io_c, kax_analyzer_c: take & store I/O instances as shared pointers 2017-12-17 15:40:26 +01:00
Moritz Bunkus
25536c6b6c split mm_io.{h,cpp} into one file for each class 2017-12-17 12:54:59 +01:00
Moritz Bunkus
0f1514dab5 tests: add tests for reading text files with BOMs 2017-12-01 14:22:03 +01:00
Moritz Bunkus
45fd90b9c1 bit reader: add support for RBSP (transform 0x00 00 03 to 0x00 00) 2017-11-17 15:10:16 +01:00
Moritz Bunkus
f3ea2937ad byte_buffer_c: move to namespace mtx::bytes 2017-10-03 11:26:03 +02:00
Moritz Bunkus
56adacc202 bit_reader_c, bit_writer_c: move to namespace mtx::bits 2017-10-03 10:41:52 +02:00
Moritz Bunkus
3b2ff9b6ae memory_c: add comparison operators with strings constants 2017-07-21 17:16:18 +02:00
Moritz Bunkus
9baa010848 bit_writer_c: let writer manage memory on its own 2017-07-19 23:07:27 +02:00
Moritz Bunkus
319c8009e0 bit_writer_c: tests, eof(), get_remaining_bits() 2017-07-19 16:45:27 +02:00
Moritz Bunkus
f01afa73fb bit_cursor.h: split into bit_reader.h and bit_writer.h 2017-07-19 15:49:06 +02:00
Moritz Bunkus
4047a54a35 all: rename parse_timecode functions to parse_timestamp
Part of an ongoing effort to replace the use of the term `timecode`
with `timestamp`. Timecodes have a very specific meaning in the
audio/video world, and it's not what MKVToolNix has been using the
term for.
2017-07-14 11:44:40 +02:00
Moritz Bunkus
c008f20864 tests: cosmetics (alignment) 2017-04-22 15:19:14 +02:00
Moritz Bunkus
ebcda7f4eb version_number_t: add support for fewer than three digit groups 2017-04-22 15:17:53 +02:00
Moritz Bunkus
71094d135f tests: add unit test for version number parsing & formatting 2017-04-22 15:01:48 +02:00
Moritz Bunkus
e6149128a4 math: add function for converting unsigned integers to signed ones
This should be used for reading signed integers from files where
they're stored in 2's complements (as all modern processors use). In
cases where the unsigned integer is bigger than the maximum signed
integer, static_cast<>ing is an implementation-defined behavior.

The code was adopted from the following answer on Stack Overflow where
they discuss an implementation that avoids such implementation-defined
behavior: https://stackoverflow.com/a/13208789/507077
2017-02-18 19:23:13 +01:00
Moritz Bunkus
0a2be6fdce common: functions for formatting numbers with thousands separators 2017-01-27 13:46:38 +01:00
Moritz Bunkus
8739d1a999 timestamp_c: add value_or_zero returning value if valid or 0 2016-12-06 23:00:13 +01:00
Moritz Bunkus
a213cba968 mkvmerge, mkvextract: add support for HDMV TextST subtitles 2016-11-28 16:41:43 +01:00
Moritz Bunkus
4f46785336 number parsing: recognize new units "h" for hours and "m/min" for minutes
Implemented as requested in #1813.
2016-11-21 20:15:52 +01:00
Moritz Bunkus
ecab1d9675 number parsing: accept "nsec" as a unit for nanoseconds 2016-11-21 19:54:50 +01:00
Moritz Bunkus
ddc54b4a2b number parsing: accept "µs" as a unit for microseconds 2016-11-21 19:37:51 +01:00
Moritz Bunkus
85c8ea6518 timecode parsing: use parse_duration_number_with_unit
Removes code duplication.
2016-11-21 16:04:46 +01:00
Moritz Bunkus
3d49184a2a timecode parsing: add unit tests 2016-11-21 15:47:22 +01:00
Moritz Bunkus
ac769467c6 number parsing: accept "msec" as a unit for milliseconds 2016-11-21 15:19:03 +01:00
Moritz Bunkus
36505d6eb1 byte_buffer_c: re-factor API slightly & function for adding data at front 2016-10-09 17:57:07 +02:00
Moritz Bunkus
efa42bd7cc parse_number_with_unit: don't use double; fix "i" unit for fraction syntax
This re-writes the "parse_number_with_unit" not to use the "double" data
type internally but int64_t-based fractions. This fixes issues with
"double" precision on certain 32bit platforms and test cases failing.
This is a fix for #1705.

Due to this change the handling of the syntax "1234/56i" with "i" as the
unit was fixed as well. Before the value was wrongfully multiplied
instead of divided by 2 leading to quadruple the expected value being
returned. This was mentioned in and fixes part of #1673.
2016-06-04 13:22:46 +02:00
Moritz Bunkus
5cce934976 common: add string floating point number parsing to rational objects 2016-06-04 12:11:24 +02:00
Moritz Bunkus
884a627622 mkvmerge: move parse_number_with_unit to common 2016-04-27 22:00:16 +02:00
Moritz Bunkus
680dff7a3f timestamp_c: add function for negation 2016-04-11 21:58:12 +02:00
Moritz Bunkus
38ce7f9d8c functions for normalizing line endings/removing them from end of string 2016-04-09 17:27:25 +02:00
Moritz Bunkus
675ee7c48a tests: add case for construct with EbmlString and std::string 2016-03-01 19:09:06 +01:00
Moritz Bunkus
a8d7074def bit_cursor: allow setting bit position to exactly the end
For one it makes for easier-to-use interfaces such as
bc.set_bit_position(bc.get_bits…)) without having to check if the
position is at the end and the get_bits returns 0. It's also consistent
with containers in the standard C++ library.

In this particular case it fixes the AAC handling of program config
elements with an empty comment field that are located at the end of the
GA specific config where the aforementioned pattern of
set_bit_position(get_bits(…)) is used.

Fixes #1578.
2016-01-24 12:08:36 +01:00
Moritz Bunkus
c51bb7cfe9 re-factor mtx::any from propedit.cpp to list_utils.h 2015-12-19 15:55:01 +01:00
Moritz Bunkus
d5a02a8bda Revert "all: don't write BOMs for UTF-* encoded text files"
This reverts commits 2c11d3f3bd and
9436271a04.

The reason is that users have chimed in with legitimate use cases,
especially extracting text subtitles on Windows, modifying them and
re-muxing them later. This worked out of the box before but requires
setting the subtitle character set to UTF-8 upon re-muxing now.
2015-12-16 10:27:20 +01:00
Moritz Bunkus
9436271a04 tests: adjust for UTF-BOM changes in 2c11d3f 2015-11-28 15:22:06 +01:00
Moritz Bunkus
745da353b6 Translations: intentional update due to c63e0b0
c63e0b0 all: don't use Guillemets in English text
2015-10-15 14:39:02 +02:00
Moritz Bunkus
b1c4f7f47f all: rename format_timecode to format_timestamp
Part of an ongoing effort to replace the use of the term 'timecode' with
'timestamp'. Timecodes have a very specific meaning in the audio/video
world, and it's not what MKVToolNix has been using the term for.
2015-10-07 20:21:59 +02:00
Moritz Bunkus
e476208bdd all: rename (basic_)timecode_c to (basic_)timestamp_c
Part of an ongoing effort to replace the use of the term 'timecode' with
'timestamp'. Timecodes have a very specific meaning in the audio/video
world, and it's not what MKVToolNix has been using the term for.
2015-10-07 09:59:42 +02:00
Moritz Bunkus
20a448d2af format_timecode: formatting by a format string like %H:%M:%S 2015-10-04 11:10:37 +02:00
Moritz Bunkus
4da5f7db4d format_timecode: round for precision == 0, too
For every other precision the timestamp output is rounded, so for
consistency's sake do it for precision == 0, too.

Add unit tests.
2015-10-04 11:10:37 +02:00