flaclibsharp
flaclibsharp copied to clipboard
Optimize use of padding
Optimize the writing process to allow adding metadata to a file without completely rewriting it if the additional data is smaller than the available padding size in the actual file.
Wanted to ask of the status of padding optimization?
Hi
I allocated my free time to other stuff, as I didn't think this was a very important thing.
Do you think it would be of high value? If so, I may start on this.
Driving home today I was wondering how to implement it:
- Write the metadata to a memory stream first, then check if there's enough padding available to fit everything without rewriting the file
- Go through the metadata write logic and count the required bytes without actually writing anything, would be more efficient on memory, but probably a bigger change
It would be a nice addition to already great FlacLibSharp however I missed that you support custom padding already, so if you have other more important things in mind then this can wait IMHO.
Yeah, the padding metadata is there. I've read the purpose is that it allows you to increase the size of the metadata without having to rewrite the entire file. You eat up some of the padding instead. This avoids the need to move all subsequent bytes further, which basically means copying the entire flac file: which is what I currently do.
So the padding currently provides no advantage when updating metadata using FlacLibSharp.
Would be nice to change it, but it may not be a small change.