metadata-extractor icon indicating copy to clipboard operation
metadata-extractor copied to clipboard

RafMetadataReader Unnecessary Buffer

Open payton opened this issue 5 years ago • 3 comments

RafMetadataReader.java takes in a 512 byte buffer and then continues to search that buffer for the JPEG file signature. Is there any justification for this?

We are able to get the JPEG image offset 84 bytes into the file (http://fileformats.archiveteam.org/wiki/Fujifilm_RAF) and avoid the large buffer.

https://github.com/drewnoakes/metadata-extractor/blob/5124606e5d3d1fa7183fb8435cf490448ef79279/Source/com/drew/imaging/raf/RafMetadataReader.java#L62-L82

payton avatar Jan 09 '19 21:01 payton

This is well before my time but certainly seems like it could be done in fewer bytes.

However, as a test I'm tempted to modify this reader in the RandomAccessStream PR code to not create a local buffer at all. That branch would have read in the first 2K bytes anyway and then a sequential read in the for loop is all it would need to do...

RafMetadataReader.java

Mostly a plug for reviewing that PR. A single reader is one of the advantages I'm trying to promote.

kwhopper avatar Jan 09 '19 22:01 kwhopper

Agreed! I've been taking a look at it here and there. Given the size, it's tough to find time to look through it all.

payton avatar Jan 10 '19 14:01 payton

I'm not sure of the reasoning behind such a large buffer here.

I hope to find time soon to get a stable release out of both the Java and .NET libraries as they're long overdue a release. Then I'll look at @kwhopper's PRs.

drewnoakes avatar Feb 14 '19 21:02 drewnoakes