Dive media: prepare for video-thumbnails

Video thumbnails are more complex than simple picture thumbnails.
We store a duration and might want to store multiple images.

Therefore, refactor the thumbnailing in imagedownloader.cpp. Move
the thumbnail-writing down in the call chain to where the thumbnails
are created, since we have more information there (i.e. whether we
could parse the file but not extract an image, etc.).

Split the write-to-cache function into three versions:
  - pictures
  - videos
  - unknown

Define the video-thumbnail on-disk format as
  - uint32  MEDIATYPE_VIDEO
  - uint32  duration of video in seconds
  - uint32  number of pictures
  for each picture:
	- uint32  offset in msec from begining of video
	- QImage  frame

Currently, we write 0 pictures. This will be filled in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-07-13 22:55:35 +02:00 committed by Dirk Hohndel
parent 7dd49acf4b
commit c742885984
2 changed files with 99 additions and 26 deletions

View file

@ -52,13 +52,18 @@ private:
struct Thumbnail {
QImage img;
mediatype_t type;
duration_t duration;
};
Thumbnailer();
static void addThumbnailToCache(const Thumbnail &thumbnail, const QString &picture_filename);
static void addPictureThumbnailToCache(const QString &picture_filename, const QImage &thumbnail);
static void addVideoThumbnailToCache(const QString &picture_filename, duration_t duration);
static void addUnknownThumbnailToCache(const QString &picture_filename);
void recalculate(QString filename);
void processItem(QString filename, bool tryDownload);
Thumbnail getThumbnailFromCache(const QString &picture_filename);
Thumbnail getPictureThumbnailFromStream(QDataStream &stream);
Thumbnail getVideoThumbnailFromStream(QDataStream &stream);
Thumbnail fetchImage(const QString &filename, const QString &originalFilename, bool tryDownload);
Thumbnail getHashedImage(const QString &filename, bool tryDownload);