flaclibsharp icon indicating copy to clipboard operation
flaclibsharp copied to clipboard

Optimize use of padding

Open AaronLenoir opened this issue 10 years ago • 4 comments

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.

AaronLenoir avatar Jul 26 '14 22:07 AaronLenoir

Wanted to ask of the status of padding optimization?

kborowinski avatar Jun 04 '18 14:06 kborowinski

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

AaronLenoir avatar Jun 04 '18 20:06 AaronLenoir

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.

kborowinski avatar Jun 05 '18 08:06 kborowinski

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.

AaronLenoir avatar Jun 05 '18 22:06 AaronLenoir