Skip to content

fix: Stop the remaining readers from dropping or inventing a value - #186

Open
decriptor wants to merge 5 commits into
mainfrom
fix/wrong-values
Open

decriptor wants to merge 5 commits into
mainfrom
fix/wrong-values

Conversation

@decriptor

Copy link
Copy Markdown
Owner

Description

Stops several readers from returning a value the file does not store, or dropping one it does.

  • ID3 text lists (ID3v2.2, v2.3, v2.4). A list now splits on NUL only. Before, AC/DC read as two performers, AC and DC. Now it is one value. Track and disc n/m and "(17)" as the ID3v1 genre Rock are unchanged.
  • Tagless files (MP3, raw AAC, DSF, DFF, MPEG PS, AIFF, WAV, FLAC). Tag used to be null. It is now a view that is always present: reading it writes nothing, and the first assignment creates the stored tag (ID3v2 for MP3, AAC, DSF, DFF, MPEG PS and AIFF; the Vorbis comment for FLAC; a RIFF INFO tag for WAV). A save writes an empty tag block only if it was assigned. A title can be set on a file that had no tag.
  • Matroska. The album follows the untargeted ALBUM tag that ffmpeg writes, without replacing the title. When both TITLE at target 50 and ALBUM exist, setting the album updates both. If the only title is the untargeted one, it is kept as TITLE at target 30.
  • JPEG. A JPEG title is stored as IFD0 XPTitle (0x9C9B) and XMP dc:title. It is added to Exif or XMP that is already there but lacks the field, and clearing the title removes both. Before, assigning a title changed nothing.
  • MP4. A vide sample entry is read as video (width, height, codec), not as an audio sample rate. A 90 or 270 degree track matrix swaps the reported width and height, so a rotated video reports its display size. Public API: Mp4File.Video (see below).
  • Pictures. An MP4 covr role other than front now round-trips (stored in the top byte of a zero locale, one higher than the ID3 picture type; ExifTool still shows a normal cover). An APE picture with role Other keeps its Cover Art (Other) key instead of becoming Cover Art (Front).

The README, ROADMAP and docs describe ID3 versions and the values stored: ID3v2.2 is read and is not written back as v2.2, and a new tag is v2.4.

Motivation and Context

Each of these returned a value that does not match what the file stores, or lost one on a round trip. The ID3 split was checked against ffprobe, and the JPEG title against what ExifTool and Exiv2 read. The Matroska behaviour matches the ALBUM tag ffmpeg writes.

No open issue is fully resolved by this branch, so there is no Fixes line.

Related, not closed: #167 (JPEG title, artist, description, copyright and year). This branch adds the title only.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring (no functional changes)

Behaviour callers may rely on that changes:

  • Tag on a tagless MP3, AAC, DSF, DFF, MPEG PS, AIFF, WAV or FLAC file is no longer null. Code that tests file.Tag is null to mean "no tag" must test the stored tags instead.
  • A slash in an ID3 text list no longer splits the value.
  • Mp4File.Video is a new public property (additive).

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the project's code style
  • I have added tests that prove my fix/feature works (WrongValueTests.cs, Matroska and Mp3 tests, updated MP4, APE, FLAC, AIFF, MPEG PS and image tests)
  • All new and existing tests pass (dotnet test): CI to confirm
  • I have updated documentation as needed (README, ROADMAP, docs). CHANGELOG.md is not changed, see Additional Notes
  • My changes generate no new warnings: CI to confirm

Implementation guide (docs/IMPLEMENTATION-GUIDE.md)

  • Design note with the behaviour table: writers, what each reader shows before and after, the spec citation per cell
  • Twin table: every entry point, sibling format, write path, view, and render/parse, each with its pinning test
  • Kit run on the final head: before/after grid, fuzz, depth tests, allocation bounds, reader comparison, mutation testing (results below)
  • Pre-review: an independent review of the diff at the reviewer checklist level, findings fixed or declined with evidence

None of these are ticked: the commits show no design note, twin table, kit results or pre-review record. The tests do cite specs inline (ID3v2.4 structure, XMP Part 1, ISO/IEC 14496-12), and the tagless-file change was applied across sibling formats.

Commits

  • c67af1a6 fix: Stop the remaining readers from dropping or inventing a value. Tagless files accept a title without writing an empty tag; picture roles and JPEG titles round-trip; a rotated video reports the display size.
  • f4d4de57 docs: Describe ID3 versions and the values this branch stores. README, ROADMAP and docs match the code for ID3 versions, JPEG title, Matroska ALBUM, MP4 video size and the covr role.
  • 7b2f80c7 fix: Stop returning values the file does not store. ID3 lists split on NUL only, Matroska album follows ALBUM, JPEG title is stored as XPTitle and dc:title, an MP4 video sample entry is read as video, and a non-front cover role survives a round trip.

Testing

Not run for this description; CI will run the suite. New tests are in tests/TagLibSharp2.Tests/Core/WrongValueTests.cs and Matroska/MatroskaFileTests.cs. Existing tests that asserted the old behaviour were changed to the new one (Tag null on a tagless file, slash-split artists, APE Other key, JPEG title not stored).

Additional Notes

Public API snapshot: one added line, public TagLibSharp2.Core.VideoProperties? Video { get; } on TagLibSharp2.Mp4.Mp4File.

CHANGELOG.md has an [Unreleased] section with a Breaking Changes heading, and this branch does not add to it, including for the Tag change above.

ID3 lists now split only on NUL, so a name like AC/DC stays one value and matches ffprobe. Matroska album follows the ALBUM tag ffmpeg writes without replacing the title. A JPEG title is stored as XPTitle and XMP dc:title. An MP4 video sample entry is read as video, and a cover role other than front survives a round trip.
ID3v2.2 is read and not written back as v2.2. Text lists split on NUL only. JPEG title, Matroska ALBUM, MP4 video size, and the covr picture role match the code.
Tagless files accept a title without writing an empty tag, picture roles and JPEG titles round-trip, and a rotated video reports the display size.
List the breaking changes (tagless Tag views, NUL-only ID3 lists, APE picture keys, MP4 video and picture roles), the additions (Mp4File.Video, the JPEG title, picture roles) and the fixes this branch makes.
The generic Enum.IsDefined overload exists from .NET 5. The guard only excluded netstandard2.0, so netstandard2.1 failed to compile (CS7036). Use the generic overload on NET5_0_OR_GREATER and the typeof form elsewhere.
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.98982% with 173 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.21%. Comparing base (01b8d6c) to head (bfbd4a6).

Files with missing lines Patch % Lines
src/TagLibSharp2/Image/Jpeg/JpegTitle.cs 59.10% 86 Missing and 33 partials ⚠️
src/TagLibSharp2/Mp4/Mp4File.cs 70.58% 11 Missing and 9 partials ⚠️
src/TagLibSharp2/Matroska/MatroskaTag.cs 83.33% 6 Missing and 3 partials ⚠️
src/TagLibSharp2/Image/Jpeg/JpegRewriter.cs 88.88% 2 Missing and 2 partials ⚠️
tests/TagLibSharp2.Tests/Core/WrongValueTests.cs 97.38% 3 Missing and 1 partial ⚠️
src/TagLibSharp2/Mp4/Mp4Picture.cs 72.72% 1 Missing and 2 partials ⚠️
src/TagLibSharp2/Ape/ApePicture.cs 77.77% 1 Missing and 1 partial ⚠️
src/TagLibSharp2/Dff/DffFile.cs 71.42% 1 Missing and 1 partial ⚠️
src/TagLibSharp2/Dsf/DsfFile.cs 71.42% 1 Missing and 1 partial ⚠️
src/TagLibSharp2/Mpeg/Mp3File.cs 80.00% 1 Missing and 1 partial ⚠️
... and 5 more

❌ Your patch check has failed because the patch coverage (77.98%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #186      +/-   ##
==========================================
- Coverage   93.27%   93.21%   -0.06%     
==========================================
  Files         558      560       +2     
  Lines      109406   110095     +689     
  Branches    14187    14373     +186     
==========================================
+ Hits       102045   102630     +585     
- Misses       4396     4506     +110     
+ Partials     2965     2959       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Read and write JPEG title, artist, description, copyright and year through Exif, XMP and IPTC

1 participant