Include backward.h where it is actually used
[geeqie.git] / src / image-load-ffmpegthumbnailer.cc
index 9f5ad97..f65d86e 100644 (file)
 #include "image-load.h"
 #include "image-load-ffmpegthumbnailer.h"
 
+#include "filedata.h"
+
 #ifdef HAVE_FFMPEGTHUMBNAILER
 #include <libffmpegthumbnailer/videothumbnailerc.h>
 
-typedef struct _ImageLoaderFT ImageLoaderFT;
-struct _ImageLoaderFT {
+struct ImageLoaderFT {
        ImageLoaderBackendCbAreaUpdated area_updated_cb;
        ImageLoaderBackendCbSize size_cb;
        ImageLoaderBackendCbAreaPrepared area_prepared_cb;
@@ -52,26 +53,27 @@ static void image_loader_ft_log_cb(ThumbnailerLogLevel log_level, const char* ms
 }
 #endif
 
-void image_loader_ft_destroy_image_data(guchar *UNUSED(pixels), gpointer data)
+void image_loader_ft_destroy_image_data(guchar *, gpointer data)
 {
-       image_data *image = (image_data *) data;
+       auto image = static_cast<image_data *>(data);
 
        video_thumbnailer_destroy_image_data (image);
 }
 
-static gchar* image_loader_ft_get_format_name(gpointer UNUSED(loader))
+static gchar* image_loader_ft_get_format_name(gpointer)
 {
        return g_strdup("ffmpeg");
 }
 
-static gchar** image_loader_ft_get_format_mime_types(gpointer UNUSED(loader))
+static gchar** image_loader_ft_get_format_mime_types(gpointer)
 {
-       static gchar *mime[] = {"video/mp4", NULL};
-       return g_strdupv(mime);}
+       static const gchar *mime[] = {"video/mp4", nullptr};
+       return g_strdupv(const_cast<gchar **>(mime));
+}
 
 static gpointer image_loader_ft_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data)
 {
-       ImageLoaderFT *loader = g_new0(ImageLoaderFT, 1);
+       auto loader = g_new0(ImageLoaderFT, 1);
 
        loader->area_updated_cb = area_updated_cb;
        loader->size_cb = size_cb;
@@ -85,30 +87,28 @@ static gpointer image_loader_ft_new(ImageLoaderBackendCbAreaUpdated area_updated
        video_thumbnailer_set_log_callback(loader->vt, image_loader_ft_log_cb);
 #endif
 
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_ft_set_size(gpointer loader, int width, int height)
 {
-       ImageLoaderFT *lft = (ImageLoaderFT *) loader;
+       auto lft = static_cast<ImageLoaderFT *>(loader);
        lft->requested_width = width;
        lft->requested_height = height;
        DEBUG_1("TG: setting size, w=%d, h=%d", width, height);
 }
 
-// static gboolean image_loader_ft_loadfromdisk(gpointer loader, const gchar *path, GError **error)
-static gboolean image_loader_ft_load (gpointer loader, const guchar *UNUSED(buf), gsize UNUSED(count), GError **UNUSED(error))
+static gboolean image_loader_ft_load (gpointer loader, const guchar *, gsize, GError **)
 {
-       ImageLoaderFT *lft = (ImageLoaderFT *) loader;
-       ImageLoader *il = lft->data;
+       auto lft = static_cast<ImageLoaderFT *>(loader);
+       auto il = static_cast<ImageLoader *>(lft->data);
 
        image_data *image = video_thumbnailer_create_image_data();
 
 #ifdef HAVE_FFMPEGTHUMBNAILER_WH
-//     DEBUG_1("TG: FT requested size w=%d:h=%d for %s", lft->requested_width > 0, lft->requested_height, il->fd->path);
        video_thumbnailer_set_size(lft->vt, lft->requested_width, lft->requested_height);
 #else
-       lft->vt->thumbnail_size = MAX(lft->requested_width,lft->requested_width);
+       lft->vt->thumbnail_size = MAX(lft->requested_width,lft->requested_height);
 #endif
 
 #ifdef HAVE_FFMPEGTHUMBNAILER_METADATA
@@ -129,16 +129,16 @@ static gboolean image_loader_ft_load (gpointer loader, const guchar *UNUSED(buf)
        lft->area_updated_cb(loader, 0, 0, image->image_data_width, image->image_data_height, lft->data);
 #else
        GInputStream *image_stream;
-       image_stream = g_memory_input_stream_new_from_data (image->image_data_ptr, image->image_data_size, NULL);
+       image_stream = g_memory_input_stream_new_from_data (image->image_data_ptr, image->image_data_size, nullptr);
 
-       if (image_stream == NULL)
+       if (image_stream == nullptr)
        {
        video_thumbnailer_destroy_image_data (image);
        DEBUG_1("FFmpegthumbnailer: cannot open stream for %s", il->fd->path);
        return FALSE;
     }
 
-       lft->pixbuf  = gdk_pixbuf_new_from_stream (image_stream, NULL, NULL);
+       lft->pixbuf  = gdk_pixbuf_new_from_stream (image_stream, nullptr, nullptr);
        lft->size_cb(loader, gdk_pixbuf_get_width(lft->pixbuf), gdk_pixbuf_get_height(lft->pixbuf), lft->data);
        g_object_unref (image_stream);
        video_thumbnailer_destroy_image_data (image);
@@ -150,11 +150,11 @@ static gboolean image_loader_ft_load (gpointer loader, const guchar *UNUSED(buf)
                return FALSE;
                }
 
-/* See comment in image_loader_area_prepared_cb
+/** See comment in image_loader_area_prepared_cb
  * Geeqie uses area_prepared signal to fill pixbuf with background color.
- * We can't do it here as pixbuf already contains the data */
-//     lft->area_prepared_cb(loader, lft->data);
-
+ * We can't do it here as pixbuf already contains the data
+ * lft->area_prepared_cb(loader, lft->data);
+ */
        lft->area_updated_cb(loader, 0, 0, gdk_pixbuf_get_width(lft->pixbuf), gdk_pixbuf_get_height(lft->pixbuf), lft->data);
 
        return TRUE;
@@ -162,22 +162,22 @@ static gboolean image_loader_ft_load (gpointer loader, const guchar *UNUSED(buf)
 
 static GdkPixbuf* image_loader_ft_get_pixbuf(gpointer loader)
 {
-       ImageLoaderFT *lft = (ImageLoaderFT *) loader;
+       auto lft = static_cast<ImageLoaderFT *>(loader);
        return lft->pixbuf;
 }
 
-static void image_loader_ft_abort(gpointer UNUSED(loader))
+static void image_loader_ft_abort(gpointer)
 {
 }
 
-static gboolean image_loader_ft_close(gpointer UNUSED(loader), GError **UNUSED(error))
+static gboolean image_loader_ft_close(gpointer, GError **)
 {
        return TRUE;
 }
 
 static void image_loader_ft_free(gpointer loader)
 {
-       ImageLoaderFT *lft = (ImageLoaderFT *) loader;
+       auto lft = static_cast<ImageLoaderFT *>(loader);
        if (lft->pixbuf) g_object_unref(lft->pixbuf);
        video_thumbnailer_destroy (lft->vt);
 
@@ -189,7 +189,7 @@ void image_loader_backend_set_ft(ImageLoaderBackend *funcs)
        funcs->loader_new = image_loader_ft_new;
        funcs->set_size = image_loader_ft_set_size;
        funcs->load = image_loader_ft_load;
-       funcs->write = NULL;
+       funcs->write = nullptr;
        funcs->get_pixbuf = image_loader_ft_get_pixbuf;
        funcs->close = image_loader_ft_close;
        funcs->abort = image_loader_ft_abort;