Commit Graph

832 Commits

Author SHA1 Message Date
Martchus 92e80a9286 Improve passing paths
* Use `std::string_view` instead of `const std::string &`
* Add overloads taking `std::string &&` for re-using existing strings
2021-04-23 22:16:43 +02:00
Martchus f5cb2c5cba Preserve media type of MP4 tracks if media type is unknown 2021-04-09 22:15:44 +02:00
Martchus 4fca95afa3 Preserve implicit language setting "English" via ISO language code of MKV tracks 2021-04-07 21:21:52 +02:00
Martchus c7e95ad8d5 Avoid implicit conversion 2021-04-07 20:53:14 +02:00
Martchus 9e2629a668 Fix crash when applying changes to Matroska file with track with IETF language 2021-04-07 09:22:33 +02:00
Martchus 0a041f6ad2 Fix warnings 2021-03-20 21:26:25 +01:00
Martchus ec2f8213b0 Consider 4:3 resolutions as well in Size::abbreviation()
So e.g. 960×720 is considered 720p (and not just 1280×720).
2021-02-16 00:07:42 +01:00
Martchus 65597fd71e Add API to allow aborting overall/expensive parsing functions
* Not really implemented within the various code paths of the parsers at
  this point; this commit mainly adds the API.
* Adjust example in README
2021-02-04 23:21:50 +01:00
Martchus 763eb1bd53 Adjust code for turning Vorbis comment field "YEAR" into "DATE"
Maybe this way it will compile with GCC 8.
2021-02-03 14:11:40 +01:00
Martchus 8cd115c69d Adapt tests to use KnownField::RecordDate instead of KnownField::Year 2021-02-01 17:22:57 +01:00
Martchus f21ac07da0 Get rid of deprecated fields 2021-02-01 17:11:08 +01:00
Martchus 709b4a409f Ensure attachments have been parsed before making MKV file 2021-02-01 17:10:29 +01:00
Martchus 78439e2e3f Fix returning nullptr where now a std::string_view is required 2021-02-01 17:10:01 +01:00
Martchus 64d98f5530 Use std::string_view where it makes sense 2021-01-30 21:53:06 +01:00
Martchus 49154905b1 Improve code in Mp4Tag::setValues() 2021-01-30 19:22:06 +01:00
Martchus 42eac2074d Return additional values stored within MP4 fields via values() 2021-01-30 19:18:29 +01:00
Martchus 5629a808be Clear current values of a field before assigning a new one via setValues()
Some tag fields allow to store additional values or other data related to
the value. It likely doesn't make much sense to keep the this data when
setting a new value.
2021-01-30 19:15:41 +01:00
Martchus 7692eec9af Make it easier to customize getting internal values 2021-01-30 19:12:04 +01:00
Martchus 65d52b2d57 Improve customization point for clearing tag field
* Allow customizing clearing only the value
* Use same naming scheme as in other places
* Avoid having to add an empty reset() function in subclasses
2021-01-30 19:10:16 +01:00
Martchus cbd7e75972 Remove unused TagField::cleared() 2021-01-30 18:16:02 +01:00
Martchus 5b6c65aa27 Improve diag messages when parsing MP4 tag fields 2021-01-30 15:13:42 +01:00
Martchus 8efe6e5a63 Avoid converting MP4 data when text of correct encoding is assigned anyways 2021-01-30 15:00:10 +01:00
Martchus 84183aaf02 Improve handling of MP4 tags
* Preserve multiple data atoms
* Assume JPEG as raw data type when making cover field (instead of UTF-8)
* Split certain functions
* Simplify code
2021-01-30 13:59:48 +01:00
Martchus 047d739918 Fix Vorbis Comment mapping for encoderSettings()
* The "Encoder settings" field should correspond to `ENCODER_OPTIONS`
  rather than `ENCODING`
* See https://github.com/Martchus/tageditor/issues/62
* See https://exiftool.org/TagNames/Vorbis.html
2021-01-29 21:38:59 +01:00
Martchus fd4c538180 Improve performance of Matroska writer
Especially when dealing with big files the performance is quite bad. This
change speeds it up a little by using an unordered map to find the elements
for certain offsets instead of using linear lookup.

According to callgrind the modified functions where one with the biggest
own cost. The function updateRelativeOffsets() was actually the 2nd costly
function just below  __memcpy_avx_unaligned_erms.

Now TagParser::EbmlElement::internalParse(TagParser::Diagnostics&) is quite
high as well as standard IO stream functions.
2021-01-27 21:24:53 +01:00
Martchus b39e9dc475 Simlify code, avoid try-catch, remove disabled code 2021-01-27 21:24:53 +01:00
Martchus 1499b71b37 Fix typo 2021-01-27 20:22:00 +01:00
Martchus aed719bacf Fix usage of bibliographic language codes 2021-01-20 22:39:42 +01:00
Martchus 2d67ddeeea Don't map language code "und"
The library uses empty strings if there's no value
and the ISO language code mapping should not make and
exception.
2021-01-20 22:19:43 +01:00
Martchus abd4fbb868 Allow to specify location of JSON document for ISO-639-2 2021-01-20 21:59:34 +01:00
Martchus cae88246ec Generate code for ISO-639-2/B mapping from iso-codes package 2021-01-20 21:45:14 +01:00
Martchus 2e5ef20af3 Remove unused optional header from localehelper.h 2021-01-20 20:10:56 +01:00
Martchus e5c259c4fa Make functions for dealing with ISO-639-2 names private in favor of Locale class 2021-01-20 20:08:13 +01:00
Martchus 761e3ee44b Mark all "final" tag, track and container classes as such 2020-12-18 21:13:52 +01:00
Martchus e4a89af3c0 Improve documentation 2020-12-16 17:49:02 +01:00
Martchus 6b469f1c26 Add Locale class to deal with differently specified languages/countries
Different media/tag formats specify languages and countries
differently. This change introduces a Locale class to keep track
of the format being used. So far there are no automatic conversions
implemented so it is entirely up to the user to pass valid values using
a format which matches the one required by the media/tag format.

This change also adds support for Matroska's IETF elements so at least the
raw value can be read, written and is preserved.
2020-12-16 17:48:08 +01:00
Martchus 4cc2dbd9e6 Use flags instead of tons of boolean fields in AbstractTrack 2020-12-16 17:48:08 +01:00
Martchus b5983d40ad Add TagValue::nativeData() to store tag format specific meta-data 2020-12-05 21:03:00 +01:00
Martchus 007251c604 Improve documentation of TagValue 2020-12-05 20:52:19 +01:00
Martchus 9368b7a245 Add flags to TagValue, replacing dedicated field for read-only flag 2020-12-05 20:52:01 +01:00
Martchus aa23750307 Make many constructors explicit to avoid unintended implicit conversions 2020-12-05 20:48:57 +01:00
Martchus ed37b6c5e5 Return name for DiagLevel::Debug 2020-12-01 01:51:27 +01:00
Martchus bcf00b0df5 Fix handling AVC config errors leading to crashes
See https://github.com/Martchus/tageditor/issues/60
2020-12-01 01:44:51 +01:00
Martchus 31e8741db0 Improve coding style in AVC config parser
* Avoid magic numbers
* Avoid needlessly verbose syntax
* Add comments
2020-12-01 01:13:01 +01:00
Martchus 40031b8ddf Be more error resilient when checking the container and MP3 frames
Most players/tools can cope with MP3 files which have some bytes of junk
after the ID3v2 tag just fine, e.g. ffmpeg shows just
```
[mp3 @ 0x559e1f4cbd80] Skipping 1670 bytes of junk at 1165.
```
and most players can play the file just fine.

This change makes the tag editor also more resilient, allowing it to skip
a certain amount of junk bytes before a known container is detected. It
will also skip a certain amount of junk MPEG audio frames.
2020-11-27 00:13:26 +01:00
Martchus f371efe642 Don't support IETF language elements explicitely
For now let's just ignore these elements explicitely until they are
actually supported. This way the warnings are at least more specific and
there will be no inconsistency when updating the track language.
2020-11-26 23:18:14 +01:00
Martchus 5d4a211d5d Add IDs of Matroska elements for IETF language info 2020-11-26 23:12:47 +01:00
Martchus 214c8eecb3 Don't emit warning about zero-bytes for designated padding 2020-11-26 23:11:22 +01:00
Martchus 5f39e377dc Use std::size_t consistently 2020-11-25 17:54:30 +01:00
Martchus 9a5d366ce0 Vorbis comment: Turn "YEAR" into "DATE" (unless "DATE" exists)
"DATE" is an official field and "YEAR" only an inofficial one but present
in some files. In consistency with MediaInfo and VLC player it is treated
like "DATE" here.
2020-11-25 01:39:57 +01:00