Commit Graph

191 Commits

Author SHA1 Message Date
Martchus d48722f26c Fix unity builds
* Define `CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS` consistently
  with all necassary changes
* Avoid ambiguity between enum members and certain class/struct names
2024-01-30 23:31:15 +01:00
Martchus 909a3ee98a Improve comments in Matroska container code 2023-10-31 21:27:17 +01:00
Martchus 56ccd3da80 Use auto-syntax in places touched by previous commit consistently 2023-10-31 20:06:38 +01:00
Martchus 9f41c30443 Silence/fix GCC's maybe-uninitialized warnings
* The warning about `bsEnvCount` is actually correct.
* The warning about `lastAtomToBeWritten` might be correct.
* The warning about `relPos` is definitely unjustified because `relPos` is
  only used when `cueRelativePositionElement` is not `nullptr` and `relPos`
  is initialized in that case.
* The warnings about `pos`, `nextPageOffset` and `startOfLastMetaDataBlock`
  are also wrong for similar reasons.
2023-10-31 20:05:13 +01:00
Martchus 04795f957f Fix setting writing app name after allowing to preserve it 2023-08-09 23:26:34 +02:00
Martchus c0e9f9bf83 Fix condition for preserving muxing/writing app 2023-08-09 23:17:26 +02:00
Martchus e6bb98d6e6 Improve dealing with muxing/writing application of Matroska files
* Allow reading the current muxing/writing application
* Allow to preserve the original muxing/writing application instead of
  always overriding
2023-08-08 17:18:02 +02:00
Martchus 92345027fb Use generic `toInt()` function which relies less on compiler optimizations 2023-05-18 00:52:28 +02:00
Martchus 5745632af7 Move `maxFullParseSize()` to `MediaFileInfo` as non-static member 2023-05-16 23:11:53 +02:00
Martchus 60385aa347 Generalize copy functions in GenericFileElement to eventually use sendfile64()
Since we're still using `container().stream()` in `copyInternal()` this change
is still not really effective.
2023-05-16 22:58:04 +02:00
Martchus 981db492e4 Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
Martchus cb93d6900c Apply clang-format 2023-02-03 13:31:40 +01:00
Martchus ca6abe31a0 Fix compilation with MSVC
Apparently the move c'tor isn't available unless explicitly specified
leading to errors when `SegmentData` is used in `std::vector`.
2023-02-02 00:28:01 +01:00
Martchus 205b119416 Use `std` more consistently in `matroskacontainer.cpp` 2023-02-02 00:24:49 +01:00
Martchus 338011e3eb Add missing headers to `matroskaseekinfo.h` 2023-02-02 00:21:37 +01:00
Martchus dc4e4082e0 Use `std::filesystem::resize_file` instead of POSIX function
* Avoid platform-specific code
* Fix build with MSVC
2023-02-01 14:05:32 +01:00
Martchus ccf77959b4 Convert text values to a supported encoding if needed on the fly
* This makes it harder to use the library wrongly and does not lead to
  worse performance as character set conversions are only done as needed.
* That's actually already done by serializers for most tag formats. This
  change ensures serializers for Matroska and Vorbis tag fields do this as
  well.
* Update documentation accordingly.
2022-07-21 23:30:45 +02:00
Martchus c3c525c352 Scale rating automatically when serializing popularity/rating field
* Allow one to get a `Popularity` where `.rating` is always between 1 and 5
  via `TagValue::toScaledPopularity()` (or a "raw" scale by specifying the
  corresponding tag format)
* Allow one to assign a `Popularity` with `.scale = TagType::Unspecified`
  and `.rating` between 1 and 5 (or a "raw" scale by specifying the
  corresponding tag format). It will then be converted internally to
  the required scale (whatever the tag format internally uses)
    * Ensure all tag formats with popularity/rating field use
      `TagValue::toScaledPopularity()` internally when a `Popularity`
      object is assigned
* Ensure all tag formats with popularity/rating field store the rating as
  popularity object to preserve the scaling information
* Keep passing raw strings around working
    * `TagValue::toString()` still does *no* scaling
    * `TagValue::toScaledPopularity()` does *no* scaling for text values
      and instead just assigns the specified scale
* See https://github.com/Martchus/tagparser/issues/23
2022-07-20 23:23:51 +02:00
Martchus bf1eee45ba Add field mappings for all fields mentioned in Matroska spec 2022-04-06 00:01:19 +02:00
Martchus 01813e7879 Add missing official Matroska tag field IDs 2022-04-05 21:54:04 +02:00
Martchus 5c4f94de8e Fix originalMediaType() 2022-04-05 21:48:02 +02:00
Martchus 169760c996 Organize matroskatagid.h with sections in accordance to specification 2022-04-05 21:47:35 +02:00
Martchus a3dc63b677 Fix parsing flags of Matroska tracks
The default for the flags "default" and "enabled" is actually 1.
2022-04-05 21:27:58 +02:00
Martchus 4e80c31e98 Avoid writing cleared-out Matroska tag fields 2021-12-31 01:16:21 +01:00
Martchus b740d2c1e0 Simplify code 2021-12-31 00:30:11 +01:00
Martchus 31c1bb47e6 Add missing `TrackFlag…` Matroska IDs 2021-12-30 22:49:06 +01:00
Martchus e277070e9c Use `std::filesystem` in backup helper code
* Fix applying changes to symlinks so that the target is modified in any
  case (and not just if a rewrite isn't necessary)
* Avoid using `std::rename` and `std::remove` because they might not work
  under Windows when the path contains non-ASCII characters
* Simplify code, remove `isRelative()`
2021-09-11 23:54:49 +02:00
Martchus 5a1cb3d86f Add v11 FIXME to move MatroskaContainer::m_maxFullParseSize to MediaFileInfo 2021-08-25 19:04:51 +02:00
Martchus 14b4185023 Normalize known Matroska tag fields so they can be recognized despite different casing
* Do this by default with an opt-out; changing only known fields should not
  be very intrusive
* Fix recognizing known fields when only the case differs, see
  https://github.com/Martchus/tageditor/issues/72
2021-08-25 18:53:20 +02:00
Martchus f39e8b4d8c Avoid useless cases when assigning tag size (which is now std::uint64_t) 2021-08-08 00:05:11 +02:00
Jonas Kvinge ea23d71e8a Fix spelling and typos 2021-07-02 11:12:39 +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 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 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 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 64d98f5530 Use std::string_view where it makes sense 2021-01-30 21:53:06 +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 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 761e3ee44b Mark all "final" tag, track and container classes as such 2020-12-18 21:13:52 +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 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 cce1e2f96d Apply clang-format 2020-11-14 22:58:55 +01:00
Martchus e7ce9e7ced Improve documentation 2020-11-05 19:52:09 +01:00
Martchus d26e594777 Deprecate 'Year' in favor of 'RecordDate' and 'ReleaseDate', fix handling in ID3v2
1. Convert TYER and related fields of old ID3v2 versions to the new TDRC
  field and only expose that via the generic accessors.
2. When writing an old ID3v2 tag, convert TDRC back to the old fields.
3. One can still manually unset the via 1. auto-populated TDRC to disable 2.
   and write the old fields directly. So the automatic handling does not
   reduce the flexibility of the library.
4. Deprecate 'Year'; it is replaced by the already existing 'RecordDate'
   which is now supposed to be used everywhere where 'Year' was used before
5. Introduce 'ReleaseDate' to support this field which is supported in
   ID3v2.4.0 and Matroska via the generic accessors.
6. Use ISO format when converting tag values of the type DateTime to/from
   string. This is closer to what's used in ID3v2 tags internally. (The
   library still allows the old format as fallback when parsing for
   compatibility.)
2020-04-24 23:15:13 +02:00