Commit Graph

104 Commits

Author SHA1 Message Date
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 92345027fb Use generic `toInt()` function which relies less on compiler optimizations 2023-05-18 00:52:28 +02:00
Martchus 90cace1e95 Fix computation of effective size when APE tag is present at end of file 2023-05-18 00:41:35 +02:00
Martchus 5745632af7 Move `maxFullParseSize()` to `MediaFileInfo` as non-static member 2023-05-16 23:11:53 +02:00
Martchus 6f321b7b00 Fix typo in ContainerFormat enum 2023-05-16 23:00:32 +02:00
Martchus c5cd20682d Determine "effective size" via file info instead of track implementations
This allows removing duplicated code from the track implementations to take
APE tags into account.
2023-05-16 22:39:26 +02:00
Martchus 8ad28f857b Allow extending important classes without ABI break
This allows to make ABI breaks less often while still
being able to extend many aspects of the library.
2023-05-16 22:20:48 +02:00
Martchus 0a2b948f26 Detect APE tags, emit according messages and update README
It is likely not worth adding support for APE tags at this point.
However, it still makes sense to acknowledge the presence of them
despite not being actually supported to avoid possible confusion.

With this change, APE tags at the beginning of the file will be
dropped when applying changes as the container offset is updated
when skipping the tag. I suppose that makes sense considering
putting those tags at the beginning is not recommended anyways.
The diag messages and README have been updated accordingly.
2023-05-06 13:04:01 +02:00
Martchus 981db492e4 Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +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 6a07d60649 Avoid message "Parsing tags not implemented …" for MPEG audio frames
This info message that is generated for e.g. MP3 files without ID3 tags is
misleading.
2023-01-08 21:11:57 +01:00
Martchus 93da1f1e25 Create ID3v2 tag for AIFF files within `createAppropriateTags()`
Wikipedia says an ID3v2 tag can be added and other software seems to be
able to cope with it.
2022-08-17 23:11:20 +02:00
Martchus df27013c2f Avoid misleading log message
"Writing frames" should just be "Writing data" because whatever the file
contains might not be (some kind of) frames.
2022-08-12 00:07:02 +02:00
Martchus 5dd5e301b3 Fix adding ID3v2 tag to file with unknown container format
The bytes skipped while searching for MP3 frames should not be used as
container offset. The container offset should just the offset after the
first ID3v2 tag (or zero if there are no tags).
2022-08-12 00:02:38 +02:00
Martchus 2484cb03f8 Fix merging ID3v2 tags 2022-08-11 23:59:40 +02:00
Martchus 503fb725a2 Improve handling time values of MP4 files
* Cache result of `verifyPresentTrackHeader()` instead of running the code
  unnecassarily multiple times
* Do not tamper with existing/raw values by default to avoid
  inconsistencies through rounding errors and possibly fix
  https://github.com/Martchus/tageditor/issues/80
* Avoid conversions to double (depending on the time scale rounding errors
  might still occur)
2022-02-15 23:22:48 +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 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 3f5d5e3098 Add functions to return only tags which have actually been parsed 2021-08-08 00:04:12 +02:00
Jonas Kvinge ea23d71e8a Fix spelling and typos 2021-07-02 11:12:39 +02:00
Martchus ad6c3baf85 Remove macros to configure default parsing behavior
The macro FORCE_FULL_PARSE_DEFAULT doesn't seem to be set anywhere anyways
at this point.
2021-05-13 15:33:27 +02:00
Martchus 32cd02217b Replace boolean fields in MediaFileInfo with flag enums 2021-05-13 15:30:22 +02:00
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 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 64d98f5530 Use std::string_view where it makes sense 2021-01-30 21:53:06 +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 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 214c8eecb3 Don't emit warning about zero-bytes for designated padding 2020-11-26 23:11:22 +01:00
Martchus 41184e704d Improve skipping padding
* Skip up to 0x800 bytes
* Skip zero bytes also if there are less than four consecutive zero bytes
  remaining
2020-11-14 22:52:27 +01:00
Martchus 7043c3d2a9 Don't suppress IO errors when writing files
* Close or flush streams explicitely so writing is not
  deferred
    * to catch errors in the right place
    * to avoid suppressing errors completely when writing
      would be deferred to the destructor invocation
* Improve comments
2019-12-15 19:43:16 +01:00
Martchus 6e9b39726d Add conversion from ISO-639-2/B codes to language names 2019-08-17 20:56:09 +02:00
Martchus 5ad00a083c Adapt to changes in c++utilities 2019-06-10 23:11:39 +02:00
Martchus 3288d49d62 Support 'file://' URLs also when saving 2019-05-04 16:04:37 +02:00
Martchus 7efa7a0d5a Adapt to c++utilities v5 2019-05-04 16:04:21 +02:00
Martchus 0452b42bfc Add MediaFileInfo::overallAverageBitrate() 2019-03-10 16:31:47 +01:00
Martchus c4adad4297 Detect AV1 in IVF stream 2018-07-28 14:56:00 +02:00
Martchus e81c6bb169 Implement small TODOs for v8 2018-07-12 12:34:38 +02:00
Martchus a87ad5f5ec Don't use global variable for backup directory 2018-07-12 12:34:38 +02:00
Martchus 3265e0bea4 Fix documentation which was still using the old namespace 2018-06-03 20:38:32 +02:00
Martchus e29f9bd4f8 Fix warnings in MediaFileInfo, make safe casts explicit 2018-04-30 19:00:02 +02:00
Martchus 1889afef8f Take over track parsing status when parsing FLAC tags 2018-04-30 18:59:17 +02:00
Martchus 9cbc708a56 Apply clang-format 2018-04-29 21:15:34 +02:00
Martchus 388945d2b4 Add diag message when padding not supported 2018-04-29 21:13:30 +02:00
Martchus 30553c947c Fix warnings and improve style in makeMp3File() 2018-04-29 18:58:41 +02:00
Martchus ae65ad0408 Fix removing tags from FLAC files 2018-04-29 18:17:24 +02:00
Martchus 96010768f0 Improve documentation in MediaFileInfo 2018-04-29 18:11:15 +02:00
Martchus b76c334606 Apply clang-format 2018-04-29 17:19:33 +02:00
Martchus 0f0260fb77 Fix parseTags() for FLAC, consider tags unsupported if container unknown
FLAC stores tags on track level. Hence we must parse the
tracks here in order to parse the tags. This hasn't been taken
into account when refactoring the tag editor CLI leading to
https://github.com/Martchus/tageditor/issues/36.

So let's handle these format specific details in the tagparser
library which will now internally parse tracks when calling
parseTags() on FLAC files.

This also fixes the weird behavior to consider tags supported
although the container format is unknown.
2018-04-29 17:18:17 +02:00