Refactor embedded image extractor for greater extensibility
ClosedPublic

Authored by astippich on Nov 4 2018, 8:21 PM.

Details

Summary

refactor the embedded image data extractor so that
support for different mime types can be added
in the future more easily

Diff Detail

Repository
R286 KFileMetaData
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
astippich created this revision.Nov 4 2018, 8:21 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptNov 4 2018, 8:21 PM
Restricted Application added subscribers: Baloo, kde-frameworks-devel. · View Herald Transcript
astippich requested review of this revision.Nov 4 2018, 8:21 PM
astippich updated this revision to Diff 44982.Nov 6 2018, 7:33 PM
  • more cleanup
bruns added inline comments.Nov 8 2018, 10:47 PM
src/embeddedimagedata.cpp
237

I know you have only moved this code here ...

TagLib::ByteVector::find returns -1 on not found, and we add 1, so this is safe here. But maybe we should return QByteArray() instead?

astippich added inline comments.Nov 10 2018, 1:44 PM
src/embeddedimagedata.cpp
237

The code also works if only the picture data is there without the name.
I could return an empty QByteArray if dataPosition == -1 and pictureData.size == 0.
Do you prefer if I do that separately?

anyone? I would like to extend the support to the same file types as supported by the taglibextractor

bruns added inline comments.Dec 4 2018, 11:31 PM
src/embeddedimagedata.cpp
142–145

Does Taglib signal an error when it fails to parse the file? Or is calling pictureList() always safe?

156

Not sure if this is an issue, but the old code only called tag()->pictureList() after !tag()->isEmpty() - is this safe without?
Dito for oggFile above.

237

Is it safe to call find on an empty ByteVector - most likely yes ...
Then return QByteArray on dataPosition == -1, so it is obvious the error case is handled, and keep the rest as is.

bruns added inline comments.Dec 4 2018, 11:41 PM
src/embeddedimagedata.cpp
214

Nitpick - add an empty line in-between functions

astippich updated this revision to Diff 46880.Dec 5 2018, 7:19 AM
  • new lines, handle dataPosition == -1
astippich marked 2 inline comments as done.Dec 5 2018, 7:20 AM
astippich added inline comments.
src/embeddedimagedata.cpp
142–145

Docs don't say, so I fed a musepack file into this codepath and it still ran without issues (no cover extracted of course). Good enough?

156

Yes, the list will be empty.

bruns accepted this revision.Dec 5 2018, 2:38 PM
bruns added inline comments.
src/embeddedimagedata.cpp
142–145

Yes, thanks.

207

You can check for >= 0 and let the -1 case fall through ...

This revision is now accepted and ready to land.Dec 5 2018, 2:38 PM
This revision was automatically updated to reflect the committed changes.