Bug 420143

Summary: Kid3 - Does not tag DSF files larger than 2GB
Product: [Applications] kid3 Reporter: Christophe <christophe.gense>
Component: generalAssignee: Urs Fleisch <ufleisch>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Christophe 2020-04-16 00:01:13 UTC
SUMMARY
Does not tag DSF files larger than 2GB

STEPS TO REPRODUCE
1. find a DSF file larger than 2GB
2. select in Kid3 for tagging
3. click Save, , wait till it gives hand back

OBSERVED RESULT
No tag

EXPECTED RESULT
Tagged file

SOFTWARE/OS VERSIONS
Windows: Kid3 3.8.2/Windows 10
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Thank you for your attention
Comment 1 Urs Fleisch 2020-04-16 05:59:06 UTC
I already heard of similar problems with other audio formats, but the problem is probably the same: Kid3 uses TagLib for DSF files and TagLib uses signed 32-bit integers for file offsets, therefore it is not able to handle large files.

I think the problem is known for more than seven years now: https://github.com/taglib/taglib/pull/77
Unfortunately, this merge request was only made for taglib2, the upcoming (?) next binary incompatible release TagLib 2.0. I have already included a bunch of patches in the TagLib version which I am shipping with the binary Kid3 packages, but this one is from the taglib2 branch and probably much too invasive to be backported and then maintained. So I am afraid that we will have to live with this shortcomings until TagLib 2.0 is out. Probably this bug cannot be fixed in TagLib 1.x because this would break binary compatibility.
Comment 2 Urs Fleisch 2020-04-19 17:45:39 UTC
I have investigated the issue further. It only happens on Windows because on Linux and macOS, long values are 64-bit on 64-bit architectures whereas on Windows long is always 32-bit. To fix this, all variables which are used to index data from a large file have to be replaced by a 64-bit type. I have patched the TagLib which is used to build the Windows 64-bit edition. I have tested it with large MP4, MP3, FLAC and Opus files, but not with a large DSF file, simply because I do not have a DSF file larger than 2GB and I do not know how to easily create such a file (for the other formats it can be done using ffmpeg). The DSF format seems to be quite simple, so I could have created such a file containing large invalid data, but probably it is easier if you test it with your files. So please get the win32-x64.zip file from https://sourceforge.net/projects/kid3/files/kid3/development/ and tell me if it works.
Comment 3 Urs Fleisch 2020-04-19 17:47:32 UTC
Git commit e11dd41f4ae6891230857bda4539a5238b0f95a6 by Urs Fleisch.
Committed on 19/04/2020 at 16:42.
Pushed by ufleisch into branch 'master'.

Patch TagLib for Windows 64-bit to support large files

M  +1800 -0    buildlibs.sh
M  +20   -12   src/plugins/taglibmetadata/taglibfile.cpp

https://invent.kde.org/kde/kid3/commit/e11dd41f4ae6891230857bda4539a5238b0f95a6
Comment 4 Christophe 2020-04-19 22:14:39 UTC
Hello Urs,

Thank you very much for your investigation and fixing. As we're confined 
in France, I work from home but it's also the opportunity, to rip my 
collection of SACDs.

I test this ASAP and get back to you.

Regards, Christophe

PS : I found another issue due to file name length but workaround is 
easier, for tagging files larger 2GB I used Mp3Tag as workaround but 
Kid3 is a greater interface with useful features

On 19/04/2020 19:45, Urs Fleisch wrote:
> https://bugs.kde.org/show_bug.cgi?id=420143
>
> --- Comment #2 from Urs Fleisch <ufleisch@users.sourceforge.net> ---
> I have investigated the issue further. It only happens on Windows because on
> Linux and macOS, long values are 64-bit on 64-bit architectures whereas on
> Windows long is always 32-bit. To fix this, all variables which are used to
> index data from a large file have to be replaced by a 64-bit type. I have
> patched the TagLib which is used to build the Windows 64-bit edition. I have
> tested it with large MP4, MP3, FLAC and Opus files, but not with a large DSF
> file, simply because I do not have a DSF file larger than 2GB and I do not know
> how to easily create such a file (for the other formats it can be done using
> ffmpeg). The DSF format seems to be quite simple, so I could have created such
> a file containing large invalid data, but probably it is easier if you test it
> with your files. So please get the win32-x64.zip file from
> https://sourceforge.net/projects/kid3/files/kid3/development/ and tell me if it
> works.
>
Comment 5 Christophe 2020-04-19 22:57:22 UTC
Hello,

I confirm the problem is fixed, for DSF files, with the "dev" version 
you proposed for downloading.

Many thanks.

Regards

On 19/04/2020 19:45, Urs Fleisch wrote:
> https://bugs.kde.org/show_bug.cgi?id=420143
>
> --- Comment #2 from Urs Fleisch <ufleisch@users.sourceforge.net> ---
> I have investigated the issue further. It only happens on Windows because on
> Linux and macOS, long values are 64-bit on 64-bit architectures whereas on
> Windows long is always 32-bit. To fix this, all variables which are used to
> index data from a large file have to be replaced by a 64-bit type. I have
> patched the TagLib which is used to build the Windows 64-bit edition. I have
> tested it with large MP4, MP3, FLAC and Opus files, but not with a large DSF
> file, simply because I do not have a DSF file larger than 2GB and I do not know
> how to easily create such a file (for the other formats it can be done using
> ffmpeg). The DSF format seems to be quite simple, so I could have created such
> a file containing large invalid data, but probably it is easier if you test it
> with your files. So please get the win32-x64.zip file from
> https://sourceforge.net/projects/kid3/files/kid3/development/ and tell me if it
> works.
>
Comment 6 Urs Fleisch 2020-05-10 07:48:30 UTC
Fixed in version 3.8.3.