/* JfifSupport.c generated by valac 0.56.19, the Vala compiler
 * generated from JfifSupport.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU LGPL (version 2.1 or later).
 * See the COPYING file in this distribution.
 */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "metadata.h"
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#define JPEG_MARKER_PREFIX ((guint8) 0xFF)
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_PHOTO_FILE_FORMAT_DRIVER (photo_file_format_driver_get_type ())
#define PHOTO_FILE_FORMAT_DRIVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_FORMAT_DRIVER, PhotoFileFormatDriver))
#define PHOTO_FILE_FORMAT_DRIVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_FORMAT_DRIVER, PhotoFileFormatDriverClass))
#define IS_PHOTO_FILE_FORMAT_DRIVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_FORMAT_DRIVER))
#define IS_PHOTO_FILE_FORMAT_DRIVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_FORMAT_DRIVER))
#define PHOTO_FILE_FORMAT_DRIVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_FORMAT_DRIVER, PhotoFileFormatDriverClass))

typedef struct _PhotoFileFormatDriver PhotoFileFormatDriver;
typedef struct _PhotoFileFormatDriverClass PhotoFileFormatDriverClass;
typedef struct _PhotoFileFormatDriverPrivate PhotoFileFormatDriverPrivate;

#define TYPE_PHOTO_FILE_FORMAT_PROPERTIES (photo_file_format_properties_get_type ())
#define PHOTO_FILE_FORMAT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_FORMAT_PROPERTIES, PhotoFileFormatProperties))
#define PHOTO_FILE_FORMAT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_FORMAT_PROPERTIES, PhotoFileFormatPropertiesClass))
#define IS_PHOTO_FILE_FORMAT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_FORMAT_PROPERTIES))
#define IS_PHOTO_FILE_FORMAT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_FORMAT_PROPERTIES))
#define PHOTO_FILE_FORMAT_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_FORMAT_PROPERTIES, PhotoFileFormatPropertiesClass))

typedef struct _PhotoFileFormatProperties PhotoFileFormatProperties;
typedef struct _PhotoFileFormatPropertiesClass PhotoFileFormatPropertiesClass;

#define TYPE_PHOTO_FILE_ADAPTER (photo_file_adapter_get_type ())
#define PHOTO_FILE_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_ADAPTER, PhotoFileAdapter))
#define PHOTO_FILE_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_ADAPTER, PhotoFileAdapterClass))
#define IS_PHOTO_FILE_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_ADAPTER))
#define IS_PHOTO_FILE_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_ADAPTER))
#define PHOTO_FILE_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_ADAPTER, PhotoFileAdapterClass))

typedef struct _PhotoFileAdapter PhotoFileAdapter;
typedef struct _PhotoFileAdapterClass PhotoFileAdapterClass;

#define TYPE_PHOTO_FILE_READER (photo_file_reader_get_type ())
#define PHOTO_FILE_READER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_READER, PhotoFileReader))
#define PHOTO_FILE_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_READER, PhotoFileReaderClass))
#define IS_PHOTO_FILE_READER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_READER))
#define IS_PHOTO_FILE_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_READER))
#define PHOTO_FILE_READER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_READER, PhotoFileReaderClass))

typedef struct _PhotoFileReader PhotoFileReader;
typedef struct _PhotoFileReaderClass PhotoFileReaderClass;

#define TYPE_PHOTO_METADATA (photo_metadata_get_type ())
#define PHOTO_METADATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_METADATA, PhotoMetadata))
#define PHOTO_METADATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_METADATA, PhotoMetadataClass))
#define IS_PHOTO_METADATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_METADATA))
#define IS_PHOTO_METADATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_METADATA))
#define PHOTO_METADATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_METADATA, PhotoMetadataClass))

typedef struct _PhotoMetadata PhotoMetadata;
typedef struct _PhotoMetadataClass PhotoMetadataClass;

#define TYPE_PHOTO_FILE_WRITER (photo_file_writer_get_type ())
#define PHOTO_FILE_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_WRITER, PhotoFileWriter))
#define PHOTO_FILE_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_WRITER, PhotoFileWriterClass))
#define IS_PHOTO_FILE_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_WRITER))
#define IS_PHOTO_FILE_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_WRITER))
#define PHOTO_FILE_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_WRITER, PhotoFileWriterClass))

typedef struct _PhotoFileWriter PhotoFileWriter;
typedef struct _PhotoFileWriterClass PhotoFileWriterClass;

#define TYPE_PHOTO_FILE_METADATA_WRITER (photo_file_metadata_writer_get_type ())
#define PHOTO_FILE_METADATA_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_METADATA_WRITER, PhotoFileMetadataWriter))
#define PHOTO_FILE_METADATA_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_METADATA_WRITER, PhotoFileMetadataWriterClass))
#define IS_PHOTO_FILE_METADATA_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_METADATA_WRITER))
#define IS_PHOTO_FILE_METADATA_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_METADATA_WRITER))
#define PHOTO_FILE_METADATA_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_METADATA_WRITER, PhotoFileMetadataWriterClass))

typedef struct _PhotoFileMetadataWriter PhotoFileMetadataWriter;
typedef struct _PhotoFileMetadataWriterClass PhotoFileMetadataWriterClass;
typedef enum  {
	PHOTO_FILE_SNIFFER_OPTIONS_GET_ALL = 0x00000000,
	PHOTO_FILE_SNIFFER_OPTIONS_NO_MD5 = 0x00000001
} PhotoFileSnifferOptions;

#define PHOTO_FILE_SNIFFER_TYPE_OPTIONS (photo_file_sniffer_options_get_type ())

#define TYPE_PHOTO_FILE_SNIFFER (photo_file_sniffer_get_type ())
#define PHOTO_FILE_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer))
#define PHOTO_FILE_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHOTO_FILE_SNIFFER, PhotoFileSnifferClass))
#define IS_PHOTO_FILE_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHOTO_FILE_SNIFFER))
#define IS_PHOTO_FILE_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHOTO_FILE_SNIFFER))
#define PHOTO_FILE_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHOTO_FILE_SNIFFER, PhotoFileSnifferClass))

typedef struct _PhotoFileSniffer PhotoFileSniffer;
typedef struct _PhotoFileSnifferClass PhotoFileSnifferClass;

#define TYPE_JFIF_FILE_FORMAT_DRIVER (jfif_file_format_driver_get_type ())
#define JFIF_FILE_FORMAT_DRIVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver))
#define JFIF_FILE_FORMAT_DRIVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriverClass))
#define IS_JFIF_FILE_FORMAT_DRIVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_JFIF_FILE_FORMAT_DRIVER))
#define IS_JFIF_FILE_FORMAT_DRIVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_JFIF_FILE_FORMAT_DRIVER))
#define JFIF_FILE_FORMAT_DRIVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriverClass))

typedef struct _JfifFileFormatDriver JfifFileFormatDriver;
typedef struct _JfifFileFormatDriverClass JfifFileFormatDriverClass;
typedef struct _JfifFileFormatDriverPrivate JfifFileFormatDriverPrivate;
#define _photo_file_format_driver_unref0(var) ((var == NULL) ? NULL : (var = (photo_file_format_driver_unref (var), NULL)))

#define TYPE_JFIF_FILE_FORMAT_PROPERTIES (jfif_file_format_properties_get_type ())
#define JFIF_FILE_FORMAT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties))
#define JFIF_FILE_FORMAT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatPropertiesClass))
#define IS_JFIF_FILE_FORMAT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_JFIF_FILE_FORMAT_PROPERTIES))
#define IS_JFIF_FILE_FORMAT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_JFIF_FILE_FORMAT_PROPERTIES))
#define JFIF_FILE_FORMAT_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatPropertiesClass))

typedef struct _JfifFileFormatProperties JfifFileFormatProperties;
typedef struct _JfifFileFormatPropertiesClass JfifFileFormatPropertiesClass;

#define TYPE_GDK_READER (gdk_reader_get_type ())
#define GDK_READER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GDK_READER, GdkReader))
#define GDK_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GDK_READER, GdkReaderClass))
#define IS_GDK_READER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GDK_READER))
#define IS_GDK_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GDK_READER))
#define GDK_READER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GDK_READER, GdkReaderClass))

typedef struct _GdkReader GdkReader;
typedef struct _GdkReaderClass GdkReaderClass;

#define TYPE_JFIF_READER (jfif_reader_get_type ())
#define JFIF_READER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_JFIF_READER, JfifReader))
#define JFIF_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_JFIF_READER, JfifReaderClass))
#define IS_JFIF_READER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_JFIF_READER))
#define IS_JFIF_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_JFIF_READER))
#define JFIF_READER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_JFIF_READER, JfifReaderClass))

typedef struct _JfifReader JfifReader;
typedef struct _JfifReaderClass JfifReaderClass;

#define TYPE_JFIF_WRITER (jfif_writer_get_type ())
#define JFIF_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_JFIF_WRITER, JfifWriter))
#define JFIF_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_JFIF_WRITER, JfifWriterClass))
#define IS_JFIF_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_JFIF_WRITER))
#define IS_JFIF_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_JFIF_WRITER))
#define JFIF_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_JFIF_WRITER, JfifWriterClass))

typedef struct _JfifWriter JfifWriter;
typedef struct _JfifWriterClass JfifWriterClass;

#define TYPE_JFIF_METADATA_WRITER (jfif_metadata_writer_get_type ())
#define JFIF_METADATA_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_JFIF_METADATA_WRITER, JfifMetadataWriter))
#define JFIF_METADATA_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_JFIF_METADATA_WRITER, JfifMetadataWriterClass))
#define IS_JFIF_METADATA_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_JFIF_METADATA_WRITER))
#define IS_JFIF_METADATA_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_JFIF_METADATA_WRITER))
#define JFIF_METADATA_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_JFIF_METADATA_WRITER, JfifMetadataWriterClass))

typedef struct _JfifMetadataWriter JfifMetadataWriter;
typedef struct _JfifMetadataWriterClass JfifMetadataWriterClass;

#define TYPE_GDK_SNIFFER (gdk_sniffer_get_type ())
#define GDK_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GDK_SNIFFER, GdkSniffer))
#define GDK_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GDK_SNIFFER, GdkSnifferClass))
#define IS_GDK_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GDK_SNIFFER))
#define IS_GDK_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GDK_SNIFFER))
#define GDK_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GDK_SNIFFER, GdkSnifferClass))

typedef struct _GdkSniffer GdkSniffer;
typedef struct _GdkSnifferClass GdkSnifferClass;

#define TYPE_JFIF_SNIFFER (jfif_sniffer_get_type ())
#define JFIF_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_JFIF_SNIFFER, JfifSniffer))
#define JFIF_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_JFIF_SNIFFER, JfifSnifferClass))
#define IS_JFIF_SNIFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_JFIF_SNIFFER))
#define IS_JFIF_SNIFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_JFIF_SNIFFER))
#define JFIF_SNIFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_JFIF_SNIFFER, JfifSnifferClass))

typedef struct _JfifSniffer JfifSniffer;
typedef struct _JfifSnifferClass JfifSnifferClass;
typedef struct _PhotoFileFormatPropertiesPrivate PhotoFileFormatPropertiesPrivate;
typedef enum  {
	PHOTO_FILE_FORMAT_JFIF,
	PHOTO_FILE_FORMAT_RAW,
	PHOTO_FILE_FORMAT_PNG,
	PHOTO_FILE_FORMAT_TIFF,
	PHOTO_FILE_FORMAT_BMP,
	PHOTO_FILE_FORMAT_GIF,
	PHOTO_FILE_FORMAT_WEBP,
	PHOTO_FILE_FORMAT_AVIF,
	PHOTO_FILE_FORMAT_HEIF,
	PHOTO_FILE_FORMAT_JPEGXL,
	PHOTO_FILE_FORMAT_UNKNOWN
} PhotoFileFormat;

#define TYPE_PHOTO_FILE_FORMAT (photo_file_format_get_type ())
typedef enum  {
	PHOTO_FILE_FORMAT_FLAGS_NONE = 0x00000000
} PhotoFileFormatFlags;

#define TYPE_PHOTO_FILE_FORMAT_FLAGS (photo_file_format_flags_get_type ())
typedef struct _JfifFileFormatPropertiesPrivate JfifFileFormatPropertiesPrivate;
#define _photo_file_format_properties_unref0(var) ((var == NULL) ? NULL : (var = (photo_file_format_properties_unref (var), NULL)))
typedef struct _PhotoFileSnifferPrivate PhotoFileSnifferPrivate;

#define TYPE_DETECTED_PHOTO_INFORMATION (detected_photo_information_get_type ())
#define DETECTED_PHOTO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DETECTED_PHOTO_INFORMATION, DetectedPhotoInformation))
#define DETECTED_PHOTO_INFORMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DETECTED_PHOTO_INFORMATION, DetectedPhotoInformationClass))
#define IS_DETECTED_PHOTO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DETECTED_PHOTO_INFORMATION))
#define IS_DETECTED_PHOTO_INFORMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DETECTED_PHOTO_INFORMATION))
#define DETECTED_PHOTO_INFORMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DETECTED_PHOTO_INFORMATION, DetectedPhotoInformationClass))

typedef struct _DetectedPhotoInformation DetectedPhotoInformation;
typedef struct _DetectedPhotoInformationClass DetectedPhotoInformationClass;
typedef struct _GdkSnifferPrivate GdkSnifferPrivate;
typedef struct _JfifSnifferPrivate JfifSnifferPrivate;
#define _detected_photo_information_unref0(var) ((var == NULL) ? NULL : (var = (detected_photo_information_unref (var), NULL)))
typedef struct _DetectedPhotoInformationPrivate DetectedPhotoInformationPrivate;

#define TYPE_DIMENSIONS (dimensions_get_type ())
typedef struct _Dimensions Dimensions;
#define _media_metadata_unref0(var) ((var == NULL) ? NULL : (var = (media_metadata_unref (var), NULL)))
typedef enum  {
	JPEG_MARKER_INVALID = 0x00,
	JPEG_MARKER_SOI = 0xD8,
	JPEG_MARKER_EOI = 0xD9,
	JPEG_MARKER_APP0 = 0xE0,
	JPEG_MARKER_APP1 = 0xE1
} JpegMarker;

#define JPEG_TYPE_MARKER (jpeg_marker_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _PhotoFileAdapterPrivate PhotoFileAdapterPrivate;
typedef struct _PhotoFileReaderPrivate PhotoFileReaderPrivate;
typedef struct _GdkReaderPrivate GdkReaderPrivate;
typedef struct _JfifReaderPrivate JfifReaderPrivate;
typedef struct _PhotoFileWriterPrivate PhotoFileWriterPrivate;
typedef enum  {
	JPEG_QUALITY_LOW = 50,
	JPEG_QUALITY_MEDIUM = 75,
	JPEG_QUALITY_HIGH = 90,
	JPEG_QUALITY_MAXIMUM = 100
} JpegQuality;

#define JPEG_TYPE_QUALITY (jpeg_quality_get_type ())
typedef struct _JfifWriterPrivate JfifWriterPrivate;
typedef struct _PhotoFileMetadataWriterPrivate PhotoFileMetadataWriterPrivate;
typedef struct _JfifMetadataWriterPrivate JfifMetadataWriterPrivate;

struct _PhotoFileFormatDriver {
	GTypeInstance parent_instance;
	volatile int ref_count;
	PhotoFileFormatDriverPrivate * priv;
};

struct _PhotoFileFormatDriverClass {
	GTypeClass parent_class;
	void (*finalize) (PhotoFileFormatDriver *self);
	PhotoFileFormatProperties* (*get_properties) (PhotoFileFormatDriver* self);
	PhotoFileReader* (*create_reader) (PhotoFileFormatDriver* self, const gchar* filepath);
	PhotoMetadata* (*create_metadata) (PhotoFileFormatDriver* self);
	gboolean (*can_write_image) (PhotoFileFormatDriver* self);
	gboolean (*can_write_metadata) (PhotoFileFormatDriver* self);
	PhotoFileWriter* (*create_writer) (PhotoFileFormatDriver* self, const gchar* filepath);
	PhotoFileMetadataWriter* (*create_metadata_writer) (PhotoFileFormatDriver* self, const gchar* filepath);
	PhotoFileSniffer* (*create_sniffer) (PhotoFileFormatDriver* self, GFile* file, PhotoFileSnifferOptions options);
};

struct _JfifFileFormatDriver {
	PhotoFileFormatDriver parent_instance;
	JfifFileFormatDriverPrivate * priv;
};

struct _JfifFileFormatDriverClass {
	PhotoFileFormatDriverClass parent_class;
};

struct _PhotoFileFormatProperties {
	GTypeInstance parent_instance;
	volatile int ref_count;
	PhotoFileFormatPropertiesPrivate * priv;
};

struct _PhotoFileFormatPropertiesClass {
	GTypeClass parent_class;
	void (*finalize) (PhotoFileFormatProperties *self);
	PhotoFileFormat (*get_file_format) (PhotoFileFormatProperties* self);
	PhotoFileFormatFlags (*get_flags) (PhotoFileFormatProperties* self);
	gboolean (*is_recognized_extension) (PhotoFileFormatProperties* self, const gchar* ext);
	gchar* (*get_default_extension) (PhotoFileFormatProperties* self);
	gchar** (*get_known_extensions) (PhotoFileFormatProperties* self, gint* result_length1);
	gchar* (*get_default_mime_type) (PhotoFileFormatProperties* self);
	gchar** (*get_mime_types) (PhotoFileFormatProperties* self, gint* result_length1);
	gchar* (*get_user_visible_name) (PhotoFileFormatProperties* self);
};

struct _JfifFileFormatProperties {
	PhotoFileFormatProperties parent_instance;
	JfifFileFormatPropertiesPrivate * priv;
};

struct _JfifFileFormatPropertiesClass {
	PhotoFileFormatPropertiesClass parent_class;
};

struct _PhotoFileSniffer {
	GTypeInstance parent_instance;
	volatile int ref_count;
	PhotoFileSnifferPrivate * priv;
	GFile* file;
	PhotoFileSnifferOptions options;
	gboolean calc_md5;
};

struct _PhotoFileSnifferClass {
	GTypeClass parent_class;
	void (*finalize) (PhotoFileSniffer *self);
	DetectedPhotoInformation* (*sniff) (PhotoFileSniffer* self, gboolean* is_corrupted, GError** error);
};

struct _GdkSniffer {
	PhotoFileSniffer parent_instance;
	GdkSnifferPrivate * priv;
};

struct _GdkSnifferClass {
	PhotoFileSnifferClass parent_class;
};

struct _JfifSniffer {
	GdkSniffer parent_instance;
	JfifSnifferPrivate * priv;
};

struct _JfifSnifferClass {
	GdkSnifferClass parent_class;
};

struct _Dimensions {
	gint width;
	gint height;
};

struct _DetectedPhotoInformation {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DetectedPhotoInformationPrivate * priv;
	PhotoFileFormat file_format;
	PhotoMetadata* metadata;
	gchar* md5;
	gchar* exif_md5;
	gchar* thumbnail_md5;
	gchar* format_name;
	Dimensions image_dim;
	GdkColorspace colorspace;
	gint channels;
	gint bits_per_channel;
};

struct _DetectedPhotoInformationClass {
	GTypeClass parent_class;
	void (*finalize) (DetectedPhotoInformation *self);
};

struct _PhotoFileAdapter {
	GTypeInstance parent_instance;
	volatile int ref_count;
	PhotoFileAdapterPrivate * priv;
};

struct _PhotoFileAdapterClass {
	GTypeClass parent_class;
	void (*finalize) (PhotoFileAdapter *self);
};

struct _PhotoFileReader {
	PhotoFileAdapter parent_instance;
	PhotoFileReaderPrivate * priv;
};

struct _PhotoFileReaderClass {
	PhotoFileAdapterClass parent_class;
	PhotoMetadata* (*read_metadata) (PhotoFileReader* self, GError** error);
	GdkPixbuf* (*unscaled_read) (PhotoFileReader* self, GError** error);
	GdkPixbuf* (*scaled_read) (PhotoFileReader* self, Dimensions* full, Dimensions* scaled, GError** error);
};

struct _GdkReader {
	PhotoFileReader parent_instance;
	GdkReaderPrivate * priv;
};

struct _GdkReaderClass {
	PhotoFileReaderClass parent_class;
};

struct _JfifReader {
	GdkReader parent_instance;
	JfifReaderPrivate * priv;
};

struct _JfifReaderClass {
	GdkReaderClass parent_class;
};

struct _PhotoFileWriter {
	PhotoFileAdapter parent_instance;
	PhotoFileWriterPrivate * priv;
};

struct _PhotoFileWriterClass {
	PhotoFileAdapterClass parent_class;
	void (*write) (PhotoFileWriter* self, GdkPixbuf* pixbuf, JpegQuality quality, GError** error);
};

struct _JfifWriter {
	PhotoFileWriter parent_instance;
	JfifWriterPrivate * priv;
};

struct _JfifWriterClass {
	PhotoFileWriterClass parent_class;
};

struct _PhotoFileMetadataWriter {
	PhotoFileAdapter parent_instance;
	PhotoFileMetadataWriterPrivate * priv;
};

struct _PhotoFileMetadataWriterClass {
	PhotoFileAdapterClass parent_class;
	void (*write_metadata) (PhotoFileMetadataWriter* self, PhotoMetadata* metadata, GError** error);
};

struct _JfifMetadataWriter {
	PhotoFileMetadataWriter parent_instance;
	JfifMetadataWriterPrivate * priv;
};

struct _JfifMetadataWriterClass {
	PhotoFileMetadataWriterClass parent_class;
};

static gpointer jfif_file_format_driver_parent_class = NULL;
static JfifFileFormatDriver* jfif_file_format_driver_instance;
static JfifFileFormatDriver* jfif_file_format_driver_instance = NULL;
static gpointer jfif_file_format_properties_parent_class = NULL;
static gchar** jfif_file_format_properties_KNOWN_EXTENSIONS;
static gint jfif_file_format_properties_KNOWN_EXTENSIONS_length1;
static gchar** jfif_file_format_properties_KNOWN_EXTENSIONS = NULL;
static gint jfif_file_format_properties_KNOWN_EXTENSIONS_length1 = 0;
static gint _jfif_file_format_properties_KNOWN_EXTENSIONS_size_ = 0;
static gchar** jfif_file_format_properties_KNOWN_MIME_TYPES;
static gint jfif_file_format_properties_KNOWN_MIME_TYPES_length1;
static gchar** jfif_file_format_properties_KNOWN_MIME_TYPES = NULL;
static gint jfif_file_format_properties_KNOWN_MIME_TYPES_length1 = 0;
static gint _jfif_file_format_properties_KNOWN_MIME_TYPES_size_ = 0;
static JfifFileFormatProperties* jfif_file_format_properties_instance;
static JfifFileFormatProperties* jfif_file_format_properties_instance = NULL;
static gpointer jfif_sniffer_parent_class = NULL;
static gpointer jfif_reader_parent_class = NULL;
static gpointer jfif_writer_parent_class = NULL;
static gpointer jfif_metadata_writer_parent_class = NULL;

VALA_EXTERN gpointer photo_file_format_driver_ref (gpointer instance);
VALA_EXTERN void photo_file_format_driver_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_photo_file_format_driver (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void value_set_photo_file_format_driver (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void value_take_photo_file_format_driver (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer value_get_photo_file_format_driver (const GValue* value);
VALA_EXTERN GType photo_file_format_driver_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileFormatDriver, photo_file_format_driver_unref)
VALA_EXTERN gpointer photo_file_format_properties_ref (gpointer instance);
VALA_EXTERN void photo_file_format_properties_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_photo_file_format_properties (const gchar* name,
                                                     const gchar* nick,
                                                     const gchar* blurb,
                                                     GType object_type,
                                                     GParamFlags flags);
VALA_EXTERN void value_set_photo_file_format_properties (GValue* value,
                                             gpointer v_object);
VALA_EXTERN void value_take_photo_file_format_properties (GValue* value,
                                              gpointer v_object);
VALA_EXTERN gpointer value_get_photo_file_format_properties (const GValue* value);
VALA_EXTERN GType photo_file_format_properties_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileFormatProperties, photo_file_format_properties_unref)
VALA_EXTERN gpointer photo_file_adapter_ref (gpointer instance);
VALA_EXTERN void photo_file_adapter_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_photo_file_adapter (const gchar* name,
                                           const gchar* nick,
                                           const gchar* blurb,
                                           GType object_type,
                                           GParamFlags flags);
VALA_EXTERN void value_set_photo_file_adapter (GValue* value,
                                   gpointer v_object);
VALA_EXTERN void value_take_photo_file_adapter (GValue* value,
                                    gpointer v_object);
VALA_EXTERN gpointer value_get_photo_file_adapter (const GValue* value);
VALA_EXTERN GType photo_file_adapter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileAdapter, photo_file_adapter_unref)
VALA_EXTERN GType photo_file_reader_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileReader, photo_file_adapter_unref)
VALA_EXTERN GType photo_metadata_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoMetadata, media_metadata_unref)
VALA_EXTERN GType photo_file_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileWriter, photo_file_adapter_unref)
VALA_EXTERN GType photo_file_metadata_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileMetadataWriter, photo_file_adapter_unref)
VALA_EXTERN GType photo_file_sniffer_options_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer photo_file_sniffer_ref (gpointer instance);
VALA_EXTERN void photo_file_sniffer_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_photo_file_sniffer (const gchar* name,
                                           const gchar* nick,
                                           const gchar* blurb,
                                           GType object_type,
                                           GParamFlags flags);
VALA_EXTERN void value_set_photo_file_sniffer (GValue* value,
                                   gpointer v_object);
VALA_EXTERN void value_take_photo_file_sniffer (GValue* value,
                                    gpointer v_object);
VALA_EXTERN gpointer value_get_photo_file_sniffer (const GValue* value);
VALA_EXTERN GType photo_file_sniffer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoFileSniffer, photo_file_sniffer_unref)
VALA_EXTERN GType jfif_file_format_driver_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JfifFileFormatDriver, photo_file_format_driver_unref)
VALA_EXTERN PhotoFileFormatProperties* photo_file_format_driver_get_properties (PhotoFileFormatDriver* self);
VALA_EXTERN PhotoFileReader* photo_file_format_driver_create_reader (PhotoFileFormatDriver* self,
                                                         const gchar* filepath);
VALA_EXTERN PhotoMetadata* photo_file_format_driver_create_metadata (PhotoFileFormatDriver* self);
VALA_EXTERN gboolean photo_file_format_driver_can_write_image (PhotoFileFormatDriver* self);
VALA_EXTERN gboolean photo_file_format_driver_can_write_metadata (PhotoFileFormatDriver* self);
VALA_EXTERN PhotoFileWriter* photo_file_format_driver_create_writer (PhotoFileFormatDriver* self,
                                                         const gchar* filepath);
VALA_EXTERN PhotoFileMetadataWriter* photo_file_format_driver_create_metadata_writer (PhotoFileFormatDriver* self,
                                                                          const gchar* filepath);
VALA_EXTERN PhotoFileSniffer* photo_file_format_driver_create_sniffer (PhotoFileFormatDriver* self,
                                                           GFile* file,
                                                           PhotoFileSnifferOptions options);
VALA_EXTERN void jfif_file_format_driver_init (void);
VALA_EXTERN JfifFileFormatDriver* jfif_file_format_driver_new (void);
VALA_EXTERN JfifFileFormatDriver* jfif_file_format_driver_construct (GType object_type);
VALA_EXTERN void jfif_file_format_properties_init (void);
VALA_EXTERN JfifFileFormatDriver* jfif_file_format_driver_get_instance (void);
static PhotoFileFormatProperties* jfif_file_format_driver_real_get_properties (PhotoFileFormatDriver* base);
VALA_EXTERN GType jfif_file_format_properties_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JfifFileFormatProperties, photo_file_format_properties_unref)
VALA_EXTERN JfifFileFormatProperties* jfif_file_format_properties_get_instance (void);
static PhotoFileReader* jfif_file_format_driver_real_create_reader (PhotoFileFormatDriver* base,
                                                             const gchar* filepath);
VALA_EXTERN JfifReader* jfif_reader_new (const gchar* filepath);
VALA_EXTERN JfifReader* jfif_reader_construct (GType object_type,
                                   const gchar* filepath);
VALA_EXTERN GType gdk_reader_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GdkReader, photo_file_adapter_unref)
VALA_EXTERN GType jfif_reader_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JfifReader, photo_file_adapter_unref)
static PhotoMetadata* jfif_file_format_driver_real_create_metadata (PhotoFileFormatDriver* base);
VALA_EXTERN PhotoMetadata* photo_metadata_new (void);
VALA_EXTERN PhotoMetadata* photo_metadata_construct (GType object_type);
static gboolean jfif_file_format_driver_real_can_write_image (PhotoFileFormatDriver* base);
static gboolean jfif_file_format_driver_real_can_write_metadata (PhotoFileFormatDriver* base);
static PhotoFileWriter* jfif_file_format_driver_real_create_writer (PhotoFileFormatDriver* base,
                                                             const gchar* filepath);
VALA_EXTERN JfifWriter* jfif_writer_new (const gchar* filepath);
VALA_EXTERN JfifWriter* jfif_writer_construct (GType object_type,
                                   const gchar* filepath);
VALA_EXTERN GType jfif_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JfifWriter, photo_file_adapter_unref)
static PhotoFileMetadataWriter* jfif_file_format_driver_real_create_metadata_writer (PhotoFileFormatDriver* base,
                                                                              const gchar* filepath);
VALA_EXTERN JfifMetadataWriter* jfif_metadata_writer_new (const gchar* filepath);
VALA_EXTERN JfifMetadataWriter* jfif_metadata_writer_construct (GType object_type,
                                                    const gchar* filepath);
VALA_EXTERN GType jfif_metadata_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JfifMetadataWriter, photo_file_adapter_unref)
static PhotoFileSniffer* jfif_file_format_driver_real_create_sniffer (PhotoFileFormatDriver* base,
                                                               GFile* file,
                                                               PhotoFileSnifferOptions options);
VALA_EXTERN JfifSniffer* jfif_sniffer_new (GFile* file,
                               PhotoFileSnifferOptions options);
VALA_EXTERN JfifSniffer* jfif_sniffer_construct (GType object_type,
                                     GFile* file,
                                     PhotoFileSnifferOptions options);
VALA_EXTERN GType gdk_sniffer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GdkSniffer, photo_file_sniffer_unref)
VALA_EXTERN GType jfif_sniffer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (JfifSniffer, photo_file_sniffer_unref)
VALA_EXTERN PhotoFileFormatDriver* photo_file_format_driver_construct (GType object_type);
static void jfif_file_format_driver_finalize (PhotoFileFormatDriver * obj);
static GType jfif_file_format_driver_get_type_once (void);
VALA_EXTERN GType photo_file_format_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType photo_file_format_flags_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PhotoFileFormat photo_file_format_properties_get_file_format (PhotoFileFormatProperties* self);
VALA_EXTERN PhotoFileFormatFlags photo_file_format_properties_get_flags (PhotoFileFormatProperties* self);
VALA_EXTERN gchar* photo_file_format_properties_get_default_extension (PhotoFileFormatProperties* self);
VALA_EXTERN gchar* photo_file_format_properties_get_user_visible_name (PhotoFileFormatProperties* self);
VALA_EXTERN gchar** photo_file_format_properties_get_known_extensions (PhotoFileFormatProperties* self,
                                                           gint* result_length1);
VALA_EXTERN gchar* photo_file_format_properties_get_default_mime_type (PhotoFileFormatProperties* self);
VALA_EXTERN gchar** photo_file_format_properties_get_mime_types (PhotoFileFormatProperties* self,
                                                     gint* result_length1);
VALA_EXTERN JfifFileFormatProperties* jfif_file_format_properties_new (void);
VALA_EXTERN JfifFileFormatProperties* jfif_file_format_properties_construct (GType object_type);
static PhotoFileFormat jfif_file_format_properties_real_get_file_format (PhotoFileFormatProperties* base);
static PhotoFileFormatFlags jfif_file_format_properties_real_get_flags (PhotoFileFormatProperties* base);
static gchar* jfif_file_format_properties_real_get_default_extension (PhotoFileFormatProperties* base);
static gchar* jfif_file_format_properties_real_get_user_visible_name (PhotoFileFormatProperties* base);
static gchar** jfif_file_format_properties_real_get_known_extensions (PhotoFileFormatProperties* base,
                                                               gint* result_length1);
static gchar** _vala_array_dup6 (gchar** self,
                          gssize length);
static gchar* jfif_file_format_properties_real_get_default_mime_type (PhotoFileFormatProperties* base);
static gchar** jfif_file_format_properties_real_get_mime_types (PhotoFileFormatProperties* base,
                                                         gint* result_length1);
static gchar** _vala_array_dup7 (gchar** self,
                          gssize length);
VALA_EXTERN PhotoFileFormatProperties* photo_file_format_properties_construct (GType object_type);
static void jfif_file_format_properties_finalize (PhotoFileFormatProperties * obj);
static GType jfif_file_format_properties_get_type_once (void);
VALA_EXTERN gpointer detected_photo_information_ref (gpointer instance);
VALA_EXTERN void detected_photo_information_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_detected_photo_information (const gchar* name,
                                                   const gchar* nick,
                                                   const gchar* blurb,
                                                   GType object_type,
                                                   GParamFlags flags);
VALA_EXTERN void value_set_detected_photo_information (GValue* value,
                                           gpointer v_object);
VALA_EXTERN void value_take_detected_photo_information (GValue* value,
                                            gpointer v_object);
VALA_EXTERN gpointer value_get_detected_photo_information (const GValue* value);
VALA_EXTERN GType detected_photo_information_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DetectedPhotoInformation, detected_photo_information_unref)
VALA_EXTERN DetectedPhotoInformation* photo_file_sniffer_sniff (PhotoFileSniffer* self,
                                                    gboolean* is_corrupted,
                                                    GError** error);
VALA_EXTERN GdkSniffer* gdk_sniffer_construct (GType object_type,
                                   GFile* file,
                                   PhotoFileSnifferOptions options);
static DetectedPhotoInformation* jfif_sniffer_real_sniff (PhotoFileSniffer* base,
                                                   gboolean* is_corrupted,
                                                   GError** error);
static DetectedPhotoInformation* jfif_sniffer_fast_sniff (JfifSniffer* self,
                                                   gboolean* is_corrupted,
                                                   GError** error);
VALA_EXTERN gboolean jpeg_is_jpeg (GFile* file,
                       GError** error);
VALA_EXTERN GType dimensions_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Dimensions* dimensions_dup (const Dimensions* self);
VALA_EXTERN void dimensions_free (Dimensions* self);
VALA_EXTERN DetectedPhotoInformation* detected_photo_information_new (void);
VALA_EXTERN DetectedPhotoInformation* detected_photo_information_construct (GType object_type);
VALA_EXTERN GType jpeg_marker_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gint32 jpeg_read_marker_2 (GDataInputStream* dins,
                           JpegMarker* marker,
                           GError** error);
VALA_EXTERN gboolean jpeg_marker_is_sof (JpegMarker self);
VALA_EXTERN void dimensions_init (Dimensions *self,
                      gint width,
                      gint height);
VALA_EXTERN PhotoFileFormat photo_file_format_from_pixbuf_name (const gchar* name);
static GType jfif_sniffer_get_type_once (void);
VALA_EXTERN GdkReader* gdk_reader_construct (GType object_type,
                                 const gchar* filepath,
                                 PhotoFileFormat file_format);
static GType jfif_reader_get_type_once (void);
VALA_EXTERN GType jpeg_quality_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void photo_file_writer_write (PhotoFileWriter* self,
                              GdkPixbuf* pixbuf,
                              JpegQuality quality,
                              GError** error);
VALA_EXTERN PhotoFileWriter* photo_file_writer_construct (GType object_type,
                                              const gchar* filepath,
                                              PhotoFileFormat file_format);
static void jfif_writer_real_write (PhotoFileWriter* base,
                             GdkPixbuf* pixbuf,
                             JpegQuality quality,
                             GError** error);
VALA_EXTERN GdkPixbuf* apply_alpha_channel (GdkPixbuf* source,
                                gboolean strip);
VALA_EXTERN gchar* photo_file_adapter_get_filepath (PhotoFileAdapter* self);
VALA_EXTERN gchar* jpeg_quality_get_pct_text (JpegQuality self);
static GType jfif_writer_get_type_once (void);
VALA_EXTERN void photo_file_metadata_writer_write_metadata (PhotoFileMetadataWriter* self,
                                                PhotoMetadata* metadata,
                                                GError** error);
VALA_EXTERN PhotoFileMetadataWriter* photo_file_metadata_writer_construct (GType object_type,
                                                               const gchar* filepath,
                                                               PhotoFileFormat file_format);
static void jfif_metadata_writer_real_write_metadata (PhotoFileMetadataWriter* base,
                                               PhotoMetadata* metadata,
                                               GError** error);
VALA_EXTERN void photo_metadata_write_to_file (PhotoMetadata* self,
                                   GFile* file,
                                   GError** error);
VALA_EXTERN GFile* photo_file_adapter_get_file (PhotoFileAdapter* self);
static GType jfif_metadata_writer_get_type_once (void);
VALA_EXTERN guint8 jpeg_marker_get_byte (JpegMarker self);
VALA_EXTERN gint jpeg_quality_get_pct (JpegQuality self);
VALA_EXTERN JpegQuality* jpeg_quality_get_all (gint* result_length1);
VALA_EXTERN gchar* jpeg_quality_to_string (JpegQuality self);
VALA_EXTERN gboolean jpeg_is_jpeg_stream (GInputStream* ins,
                              GError** error);
VALA_EXTERN gint jpeg_read_marker (GInputStream* fins,
                       JpegMarker* marker,
                       GError** error);
VALA_EXTERN gboolean jpeg_is_jpeg_bytes (GBytes* bytes,
                             GError** error);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
jfif_file_format_driver_init (void)
{
	JfifFileFormatDriver* _tmp0_;
	_tmp0_ = jfif_file_format_driver_new ();
	_photo_file_format_driver_unref0 (jfif_file_format_driver_instance);
	jfif_file_format_driver_instance = _tmp0_;
	jfif_file_format_properties_init ();
}

static gpointer
_photo_file_format_driver_ref0 (gpointer self)
{
	return self ? photo_file_format_driver_ref (self) : NULL;
}

JfifFileFormatDriver*
jfif_file_format_driver_get_instance (void)
{
	JfifFileFormatDriver* _tmp0_;
	JfifFileFormatDriver* _tmp1_;
	JfifFileFormatDriver* result;
	_tmp0_ = jfif_file_format_driver_instance;
	_tmp1_ = _photo_file_format_driver_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static PhotoFileFormatProperties*
jfif_file_format_driver_real_get_properties (PhotoFileFormatDriver* base)
{
	JfifFileFormatDriver * self;
	JfifFileFormatProperties* _tmp0_;
	PhotoFileFormatProperties* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	_tmp0_ = jfif_file_format_properties_get_instance ();
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_PHOTO_FILE_FORMAT_PROPERTIES, PhotoFileFormatProperties);
	return result;
}

static PhotoFileReader*
jfif_file_format_driver_real_create_reader (PhotoFileFormatDriver* base,
                                            const gchar* filepath)
{
	JfifFileFormatDriver * self;
	JfifReader* _tmp0_;
	PhotoFileReader* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	g_return_val_if_fail (filepath != NULL, NULL);
	_tmp0_ = jfif_reader_new (filepath);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_PHOTO_FILE_READER, PhotoFileReader);
	return result;
}

static PhotoMetadata*
jfif_file_format_driver_real_create_metadata (PhotoFileFormatDriver* base)
{
	JfifFileFormatDriver * self;
	PhotoMetadata* _tmp0_;
	PhotoMetadata* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	_tmp0_ = photo_metadata_new ();
	result = _tmp0_;
	return result;
}

static gboolean
jfif_file_format_driver_real_can_write_image (PhotoFileFormatDriver* base)
{
	JfifFileFormatDriver * self;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	result = TRUE;
	return result;
}

static gboolean
jfif_file_format_driver_real_can_write_metadata (PhotoFileFormatDriver* base)
{
	JfifFileFormatDriver * self;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	result = TRUE;
	return result;
}

static PhotoFileWriter*
jfif_file_format_driver_real_create_writer (PhotoFileFormatDriver* base,
                                            const gchar* filepath)
{
	JfifFileFormatDriver * self;
	JfifWriter* _tmp0_;
	PhotoFileWriter* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	g_return_val_if_fail (filepath != NULL, NULL);
	_tmp0_ = jfif_writer_new (filepath);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_PHOTO_FILE_WRITER, PhotoFileWriter);
	return result;
}

static PhotoFileMetadataWriter*
jfif_file_format_driver_real_create_metadata_writer (PhotoFileFormatDriver* base,
                                                     const gchar* filepath)
{
	JfifFileFormatDriver * self;
	JfifMetadataWriter* _tmp0_;
	PhotoFileMetadataWriter* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	g_return_val_if_fail (filepath != NULL, NULL);
	_tmp0_ = jfif_metadata_writer_new (filepath);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_PHOTO_FILE_METADATA_WRITER, PhotoFileMetadataWriter);
	return result;
}

static PhotoFileSniffer*
jfif_file_format_driver_real_create_sniffer (PhotoFileFormatDriver* base,
                                             GFile* file,
                                             PhotoFileSnifferOptions options)
{
	JfifFileFormatDriver * self;
	JfifSniffer* _tmp0_;
	PhotoFileSniffer* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (file, g_file_get_type ()), NULL);
	_tmp0_ = jfif_sniffer_new (file, options);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer);
	return result;
}

JfifFileFormatDriver*
jfif_file_format_driver_construct (GType object_type)
{
	JfifFileFormatDriver* self = NULL;
	self = (JfifFileFormatDriver*) photo_file_format_driver_construct (object_type);
	return self;
}

JfifFileFormatDriver*
jfif_file_format_driver_new (void)
{
	return jfif_file_format_driver_construct (TYPE_JFIF_FILE_FORMAT_DRIVER);
}

static void
jfif_file_format_driver_class_init (JfifFileFormatDriverClass * klass,
                                    gpointer klass_data)
{
	jfif_file_format_driver_parent_class = g_type_class_peek_parent (klass);
	((PhotoFileFormatDriverClass *) klass)->finalize = jfif_file_format_driver_finalize;
	((PhotoFileFormatDriverClass *) klass)->get_properties = (PhotoFileFormatProperties* (*) (PhotoFileFormatDriver*)) jfif_file_format_driver_real_get_properties;
	((PhotoFileFormatDriverClass *) klass)->create_reader = (PhotoFileReader* (*) (PhotoFileFormatDriver*, const gchar*)) jfif_file_format_driver_real_create_reader;
	((PhotoFileFormatDriverClass *) klass)->create_metadata = (PhotoMetadata* (*) (PhotoFileFormatDriver*)) jfif_file_format_driver_real_create_metadata;
	((PhotoFileFormatDriverClass *) klass)->can_write_image = (gboolean (*) (PhotoFileFormatDriver*)) jfif_file_format_driver_real_can_write_image;
	((PhotoFileFormatDriverClass *) klass)->can_write_metadata = (gboolean (*) (PhotoFileFormatDriver*)) jfif_file_format_driver_real_can_write_metadata;
	((PhotoFileFormatDriverClass *) klass)->create_writer = (PhotoFileWriter* (*) (PhotoFileFormatDriver*, const gchar*)) jfif_file_format_driver_real_create_writer;
	((PhotoFileFormatDriverClass *) klass)->create_metadata_writer = (PhotoFileMetadataWriter* (*) (PhotoFileFormatDriver*, const gchar*)) jfif_file_format_driver_real_create_metadata_writer;
	((PhotoFileFormatDriverClass *) klass)->create_sniffer = (PhotoFileSniffer* (*) (PhotoFileFormatDriver*, GFile*, PhotoFileSnifferOptions)) jfif_file_format_driver_real_create_sniffer;
}

static void
jfif_file_format_driver_instance_init (JfifFileFormatDriver * self,
                                       gpointer klass)
{
}

static void
jfif_file_format_driver_finalize (PhotoFileFormatDriver * obj)
{
	JfifFileFormatDriver * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_JFIF_FILE_FORMAT_DRIVER, JfifFileFormatDriver);
	PHOTO_FILE_FORMAT_DRIVER_CLASS (jfif_file_format_driver_parent_class)->finalize (obj);
}

static GType
jfif_file_format_driver_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (JfifFileFormatDriverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) jfif_file_format_driver_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (JfifFileFormatDriver), 0, (GInstanceInitFunc) jfif_file_format_driver_instance_init, NULL };
	GType jfif_file_format_driver_type_id;
	jfif_file_format_driver_type_id = g_type_register_static (TYPE_PHOTO_FILE_FORMAT_DRIVER, "JfifFileFormatDriver", &g_define_type_info, 0);
	return jfif_file_format_driver_type_id;
}

GType
jfif_file_format_driver_get_type (void)
{
	static volatile gsize jfif_file_format_driver_type_id__once = 0;
	if (g_once_init_enter (&jfif_file_format_driver_type_id__once)) {
		GType jfif_file_format_driver_type_id;
		jfif_file_format_driver_type_id = jfif_file_format_driver_get_type_once ();
		g_once_init_leave (&jfif_file_format_driver_type_id__once, jfif_file_format_driver_type_id);
	}
	return jfif_file_format_driver_type_id__once;
}

void
jfif_file_format_properties_init (void)
{
	JfifFileFormatProperties* _tmp0_;
	_tmp0_ = jfif_file_format_properties_new ();
	_photo_file_format_properties_unref0 (jfif_file_format_properties_instance);
	jfif_file_format_properties_instance = _tmp0_;
}

static gpointer
_photo_file_format_properties_ref0 (gpointer self)
{
	return self ? photo_file_format_properties_ref (self) : NULL;
}

JfifFileFormatProperties*
jfif_file_format_properties_get_instance (void)
{
	JfifFileFormatProperties* _tmp0_;
	JfifFileFormatProperties* _tmp1_;
	JfifFileFormatProperties* result;
	_tmp0_ = jfif_file_format_properties_instance;
	_tmp1_ = _photo_file_format_properties_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static PhotoFileFormat
jfif_file_format_properties_real_get_file_format (PhotoFileFormatProperties* base)
{
	JfifFileFormatProperties * self;
	PhotoFileFormat result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	result = PHOTO_FILE_FORMAT_JFIF;
	return result;
}

static PhotoFileFormatFlags
jfif_file_format_properties_real_get_flags (PhotoFileFormatProperties* base)
{
	JfifFileFormatProperties * self;
	PhotoFileFormatFlags result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	result = PHOTO_FILE_FORMAT_FLAGS_NONE;
	return result;
}

static gchar*
jfif_file_format_properties_real_get_default_extension (PhotoFileFormatProperties* base)
{
	JfifFileFormatProperties * self;
	gchar* _tmp0_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	_tmp0_ = g_strdup ("jpg");
	result = _tmp0_;
	return result;
}

static gchar*
jfif_file_format_properties_real_get_user_visible_name (PhotoFileFormatProperties* base)
{
	JfifFileFormatProperties * self;
	gchar* _tmp0_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	_tmp0_ = g_strdup (_ ("JPEG"));
	result = _tmp0_;
	return result;
}

static gchar**
_vala_array_dup6 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
jfif_file_format_properties_real_get_known_extensions (PhotoFileFormatProperties* base,
                                                       gint* result_length1)
{
	JfifFileFormatProperties * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	_tmp0_ = jfif_file_format_properties_KNOWN_EXTENSIONS;
	_tmp0__length1 = jfif_file_format_properties_KNOWN_EXTENSIONS_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup6 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static gchar*
jfif_file_format_properties_real_get_default_mime_type (PhotoFileFormatProperties* base)
{
	JfifFileFormatProperties * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	_tmp0_ = jfif_file_format_properties_KNOWN_MIME_TYPES;
	_tmp0__length1 = jfif_file_format_properties_KNOWN_MIME_TYPES_length1;
	_tmp1_ = _tmp0_[0];
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	return result;
}

static gchar**
_vala_array_dup7 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
jfif_file_format_properties_real_get_mime_types (PhotoFileFormatProperties* base,
                                                 gint* result_length1)
{
	JfifFileFormatProperties * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	_tmp0_ = jfif_file_format_properties_KNOWN_MIME_TYPES;
	_tmp0__length1 = jfif_file_format_properties_KNOWN_MIME_TYPES_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup7 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

JfifFileFormatProperties*
jfif_file_format_properties_construct (GType object_type)
{
	JfifFileFormatProperties* self = NULL;
	self = (JfifFileFormatProperties*) photo_file_format_properties_construct (object_type);
	return self;
}

JfifFileFormatProperties*
jfif_file_format_properties_new (void)
{
	return jfif_file_format_properties_construct (TYPE_JFIF_FILE_FORMAT_PROPERTIES);
}

static void
jfif_file_format_properties_class_init (JfifFileFormatPropertiesClass * klass,
                                        gpointer klass_data)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	jfif_file_format_properties_parent_class = g_type_class_peek_parent (klass);
	((PhotoFileFormatPropertiesClass *) klass)->finalize = jfif_file_format_properties_finalize;
	((PhotoFileFormatPropertiesClass *) klass)->get_file_format = (PhotoFileFormat (*) (PhotoFileFormatProperties*)) jfif_file_format_properties_real_get_file_format;
	((PhotoFileFormatPropertiesClass *) klass)->get_flags = (PhotoFileFormatFlags (*) (PhotoFileFormatProperties*)) jfif_file_format_properties_real_get_flags;
	((PhotoFileFormatPropertiesClass *) klass)->get_default_extension = (gchar* (*) (PhotoFileFormatProperties*)) jfif_file_format_properties_real_get_default_extension;
	((PhotoFileFormatPropertiesClass *) klass)->get_user_visible_name = (gchar* (*) (PhotoFileFormatProperties*)) jfif_file_format_properties_real_get_user_visible_name;
	((PhotoFileFormatPropertiesClass *) klass)->get_known_extensions = (gchar** (*) (PhotoFileFormatProperties*, gint*)) jfif_file_format_properties_real_get_known_extensions;
	((PhotoFileFormatPropertiesClass *) klass)->get_default_mime_type = (gchar* (*) (PhotoFileFormatProperties*)) jfif_file_format_properties_real_get_default_mime_type;
	((PhotoFileFormatPropertiesClass *) klass)->get_mime_types = (gchar** (*) (PhotoFileFormatProperties*, gint*)) jfif_file_format_properties_real_get_mime_types;
	_tmp0_ = g_strdup ("jpg");
	_tmp1_ = g_strdup ("jpeg");
	_tmp2_ = g_strdup ("jpe");
	_tmp3_ = g_strdup ("thm");
	_tmp4_ = g_strdup ("mpo");
	_tmp5_ = g_new0 (gchar*, 5 + 1);
	_tmp5_[0] = _tmp0_;
	_tmp5_[1] = _tmp1_;
	_tmp5_[2] = _tmp2_;
	_tmp5_[3] = _tmp3_;
	_tmp5_[4] = _tmp4_;
	jfif_file_format_properties_KNOWN_EXTENSIONS = _tmp5_;
	jfif_file_format_properties_KNOWN_EXTENSIONS_length1 = 5;
	_jfif_file_format_properties_KNOWN_EXTENSIONS_size_ = jfif_file_format_properties_KNOWN_EXTENSIONS_length1;
	_tmp6_ = g_strdup ("image/jpeg");
	_tmp7_ = g_new0 (gchar*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	jfif_file_format_properties_KNOWN_MIME_TYPES = _tmp7_;
	jfif_file_format_properties_KNOWN_MIME_TYPES_length1 = 1;
	_jfif_file_format_properties_KNOWN_MIME_TYPES_size_ = jfif_file_format_properties_KNOWN_MIME_TYPES_length1;
}

static void
jfif_file_format_properties_instance_init (JfifFileFormatProperties * self,
                                           gpointer klass)
{
}

static void
jfif_file_format_properties_finalize (PhotoFileFormatProperties * obj)
{
	JfifFileFormatProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_JFIF_FILE_FORMAT_PROPERTIES, JfifFileFormatProperties);
	PHOTO_FILE_FORMAT_PROPERTIES_CLASS (jfif_file_format_properties_parent_class)->finalize (obj);
}

static GType
jfif_file_format_properties_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (JfifFileFormatPropertiesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) jfif_file_format_properties_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (JfifFileFormatProperties), 0, (GInstanceInitFunc) jfif_file_format_properties_instance_init, NULL };
	GType jfif_file_format_properties_type_id;
	jfif_file_format_properties_type_id = g_type_register_static (TYPE_PHOTO_FILE_FORMAT_PROPERTIES, "JfifFileFormatProperties", &g_define_type_info, 0);
	return jfif_file_format_properties_type_id;
}

GType
jfif_file_format_properties_get_type (void)
{
	static volatile gsize jfif_file_format_properties_type_id__once = 0;
	if (g_once_init_enter (&jfif_file_format_properties_type_id__once)) {
		GType jfif_file_format_properties_type_id;
		jfif_file_format_properties_type_id = jfif_file_format_properties_get_type_once ();
		g_once_init_leave (&jfif_file_format_properties_type_id__once, jfif_file_format_properties_type_id);
	}
	return jfif_file_format_properties_type_id__once;
}

JfifSniffer*
jfif_sniffer_construct (GType object_type,
                        GFile* file,
                        PhotoFileSnifferOptions options)
{
	JfifSniffer* self = NULL;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (file, g_file_get_type ()), NULL);
	self = (JfifSniffer*) gdk_sniffer_construct (object_type, file, options);
	return self;
}

JfifSniffer*
jfif_sniffer_new (GFile* file,
                  PhotoFileSnifferOptions options)
{
	return jfif_sniffer_construct (TYPE_JFIF_SNIFFER, file, options);
}

static gpointer
_detected_photo_information_ref0 (gpointer self)
{
	return self ? detected_photo_information_ref (self) : NULL;
}

static DetectedPhotoInformation*
jfif_sniffer_real_sniff (PhotoFileSniffer* base,
                         gboolean* is_corrupted,
                         GError** error)
{
	JfifSniffer * self;
	gboolean _vala_is_corrupted = FALSE;
	GError* _inner_error0_ = NULL;
	DetectedPhotoInformation* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_SNIFFER, JfifSniffer);
	_vala_is_corrupted = FALSE;
	if (!G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer)->calc_md5) {
		DetectedPhotoInformation* _tmp0_ = NULL;
		gboolean _tmp1_ = FALSE;
		DetectedPhotoInformation* _tmp2_;
		DetectedPhotoInformation* _tmp3_;
		_tmp2_ = jfif_sniffer_fast_sniff (self, &_tmp1_, &_inner_error0_);
		_vala_is_corrupted = _tmp1_;
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp3_;
		_detected_photo_information_unref0 (_tmp0_);
		if (is_corrupted) {
			*is_corrupted = _vala_is_corrupted;
		}
		return result;
	} else {
		gboolean _tmp4_ = FALSE;
		GFile* _tmp5_;
		DetectedPhotoInformation* detected = NULL;
		gboolean _tmp6_ = FALSE;
		DetectedPhotoInformation* _tmp7_;
		DetectedPhotoInformation* _tmp8_;
		DetectedPhotoInformation* _tmp9_ = NULL;
		DetectedPhotoInformation* _tmp10_;
		DetectedPhotoInformation* _tmp12_;
		_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer)->file;
		_tmp4_ = jpeg_is_jpeg (_tmp5_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		}
		if (!_tmp4_) {
			result = NULL;
			if (is_corrupted) {
				*is_corrupted = _vala_is_corrupted;
			}
			return result;
		}
		_tmp7_ = PHOTO_FILE_SNIFFER_CLASS (jfif_sniffer_parent_class)->sniff (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_GDK_SNIFFER, GdkSniffer), TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer), &_tmp6_, &_inner_error0_);
		_vala_is_corrupted = _tmp6_;
		detected = _tmp7_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		}
		_tmp8_ = detected;
		if (_tmp8_ == NULL) {
			result = NULL;
			_detected_photo_information_unref0 (detected);
			if (is_corrupted) {
				*is_corrupted = _vala_is_corrupted;
			}
			return result;
		}
		_tmp10_ = detected;
		if (_tmp10_->file_format == PHOTO_FILE_FORMAT_JFIF) {
			DetectedPhotoInformation* _tmp11_;
			_tmp11_ = detected;
			_tmp9_ = _tmp11_;
		} else {
			_tmp9_ = NULL;
		}
		_tmp12_ = _detected_photo_information_ref0 (_tmp9_);
		result = _tmp12_;
		_detected_photo_information_unref0 (detected);
		if (is_corrupted) {
			*is_corrupted = _vala_is_corrupted;
		}
		return result;
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static DetectedPhotoInformation*
jfif_sniffer_fast_sniff (JfifSniffer* self,
                         gboolean* is_corrupted,
                         GError** error)
{
	gboolean _vala_is_corrupted = FALSE;
	DetectedPhotoInformation* detected = NULL;
	DetectedPhotoInformation* _tmp0_;
	DetectedPhotoInformation* _tmp1_;
	PhotoMetadata* _tmp2_;
	GFileInputStream* fins = NULL;
	GFile* _tmp7_;
	GFileInputStream* _tmp8_;
	GDataInputStream* dins = NULL;
	GFileInputStream* _tmp9_;
	GDataInputStream* _tmp10_;
	GDataInputStream* _tmp11_;
	GSeekable* seekable = NULL;
	GDataInputStream* _tmp12_;
	GSeekable* _tmp13_;
	JpegMarker marker = 0;
	gint32 length = 0;
	GDataInputStream* _tmp14_;
	JpegMarker _tmp15_ = 0;
	gint32 _tmp16_;
	gint32 _tmp17_ = 0;
	GDataInputStream* _tmp18_;
	JpegMarker _tmp19_ = 0;
	gint32 _tmp20_;
	GError* _inner_error0_ = NULL;
	DetectedPhotoInformation* result;
	g_return_val_if_fail (IS_JFIF_SNIFFER (self), NULL);
	_vala_is_corrupted = FALSE;
	_tmp0_ = detected_photo_information_new ();
	detected = _tmp0_;
	_tmp1_ = detected;
	_tmp2_ = photo_metadata_new ();
	_media_metadata_unref0 (_tmp1_->metadata);
	_tmp1_->metadata = _tmp2_;
	{
		DetectedPhotoInformation* _tmp3_;
		PhotoMetadata* _tmp4_;
		GFile* _tmp5_;
		_tmp3_ = detected;
		_tmp4_ = _tmp3_->metadata;
		_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer)->file;
		media_metadata_read_from_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_MEDIA_METADATA, MediaMetadata), _tmp5_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		DetectedPhotoInformation* _tmp6_;
		g_clear_error (&_inner_error0_);
		_tmp6_ = detected;
		_media_metadata_unref0 (_tmp6_->metadata);
		_tmp6_->metadata = NULL;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_detected_photo_information_unref0 (detected);
		return NULL;
	}
	_tmp7_ = G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_SNIFFER, PhotoFileSniffer)->file;
	_tmp8_ = g_file_read (_tmp7_, NULL, &_inner_error0_);
	fins = _tmp8_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_detected_photo_information_unref0 (detected);
		return NULL;
	}
	_tmp9_ = fins;
	_tmp10_ = g_data_input_stream_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, g_input_stream_get_type (), GInputStream));
	dins = _tmp10_;
	_tmp11_ = dins;
	g_data_input_stream_set_byte_order (_tmp11_, G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN);
	_tmp12_ = dins;
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, g_seekable_get_type (), GSeekable));
	seekable = _tmp13_;
	marker = JPEG_MARKER_INVALID;
	_tmp14_ = dins;
	_tmp16_ = jpeg_read_marker_2 (_tmp14_, &_tmp15_, &_inner_error0_);
	marker = _tmp15_;
	length = _tmp16_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (seekable);
		_g_object_unref0 (dins);
		_g_object_unref0 (fins);
		_detected_photo_information_unref0 (detected);
		return NULL;
	}
	if (marker != JPEG_MARKER_SOI) {
		result = NULL;
		_g_object_unref0 (seekable);
		_g_object_unref0 (dins);
		_g_object_unref0 (fins);
		_detected_photo_information_unref0 (detected);
		if (is_corrupted) {
			*is_corrupted = _vala_is_corrupted;
		}
		return result;
	}
	_tmp18_ = dins;
	_tmp20_ = jpeg_read_marker_2 (_tmp18_, &_tmp19_, &_inner_error0_);
	marker = _tmp19_;
	_tmp17_ = _tmp20_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (seekable);
		_g_object_unref0 (dins);
		_g_object_unref0 (fins);
		_detected_photo_information_unref0 (detected);
		return NULL;
	}
	length = _tmp17_;
	while (TRUE) {
		gboolean _tmp21_ = FALSE;
		GSeekable* _tmp22_;
		gint32 _tmp23_ = 0;
		GDataInputStream* _tmp24_;
		JpegMarker _tmp25_ = 0;
		gint32 _tmp26_;
		if (!jpeg_marker_is_sof (marker)) {
			_tmp21_ = length > ((gint32) 0);
		} else {
			_tmp21_ = FALSE;
		}
		if (!_tmp21_) {
			break;
		}
		_tmp22_ = seekable;
		g_seekable_seek (_tmp22_, (gint64) length, G_SEEK_CUR, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (seekable);
			_g_object_unref0 (dins);
			_g_object_unref0 (fins);
			_detected_photo_information_unref0 (detected);
			return NULL;
		}
		_tmp24_ = dins;
		_tmp26_ = jpeg_read_marker_2 (_tmp24_, &_tmp25_, &_inner_error0_);
		marker = _tmp25_;
		_tmp23_ = _tmp26_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (seekable);
			_g_object_unref0 (dins);
			_g_object_unref0 (fins);
			_detected_photo_information_unref0 (detected);
			return NULL;
		}
		length = _tmp23_;
	}
	if (jpeg_marker_is_sof (marker)) {
		GDataInputStream* _tmp27_;
		guint16 height = 0U;
		GDataInputStream* _tmp28_;
		guint16 width = 0U;
		GDataInputStream* _tmp29_;
		DetectedPhotoInformation* _tmp30_;
		DetectedPhotoInformation* _tmp31_;
		DetectedPhotoInformation* _tmp32_;
		DetectedPhotoInformation* _tmp33_;
		DetectedPhotoInformation* _tmp34_;
		gchar* _tmp35_;
		DetectedPhotoInformation* _tmp36_;
		DetectedPhotoInformation* _tmp37_;
		const gchar* _tmp38_;
		if (length < ((gint32) 6)) {
			_vala_is_corrupted = TRUE;
			result = NULL;
			_g_object_unref0 (seekable);
			_g_object_unref0 (dins);
			_g_object_unref0 (fins);
			_detected_photo_information_unref0 (detected);
			if (is_corrupted) {
				*is_corrupted = _vala_is_corrupted;
			}
			return result;
		}
		_tmp27_ = dins;
		g_data_input_stream_read_byte (_tmp27_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (seekable);
			_g_object_unref0 (dins);
			_g_object_unref0 (fins);
			_detected_photo_information_unref0 (detected);
			return NULL;
		}
		_tmp28_ = dins;
		height = g_data_input_stream_read_uint16 (_tmp28_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (seekable);
			_g_object_unref0 (dins);
			_g_object_unref0 (fins);
			_detected_photo_information_unref0 (detected);
			return NULL;
		}
		_tmp29_ = dins;
		width = g_data_input_stream_read_uint16 (_tmp29_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (seekable);
			_g_object_unref0 (dins);
			_g_object_unref0 (fins);
			_detected_photo_information_unref0 (detected);
			return NULL;
		}
		_tmp30_ = detected;
		dimensions_init (&_tmp30_->image_dim, (gint) width, (gint) height);
		_tmp31_ = detected;
		_tmp31_->colorspace = GDK_COLORSPACE_RGB;
		_tmp32_ = detected;
		_tmp32_->channels = 3;
		_tmp33_ = detected;
		_tmp33_->bits_per_channel = 8;
		_tmp34_ = detected;
		_tmp35_ = g_strdup ("jpeg");
		_g_free0 (_tmp34_->format_name);
		_tmp34_->format_name = _tmp35_;
		_tmp36_ = detected;
		_tmp37_ = detected;
		_tmp38_ = _tmp37_->format_name;
		_tmp36_->file_format = photo_file_format_from_pixbuf_name (_tmp38_);
	} else {
		_vala_is_corrupted = TRUE;
	}
	result = detected;
	_g_object_unref0 (seekable);
	_g_object_unref0 (dins);
	_g_object_unref0 (fins);
	if (is_corrupted) {
		*is_corrupted = _vala_is_corrupted;
	}
	return result;
}

static void
jfif_sniffer_class_init (JfifSnifferClass * klass,
                         gpointer klass_data)
{
	jfif_sniffer_parent_class = g_type_class_peek_parent (klass);
	((PhotoFileSnifferClass *) klass)->sniff = (DetectedPhotoInformation* (*) (PhotoFileSniffer*, gboolean*, GError**)) jfif_sniffer_real_sniff;
}

static void
jfif_sniffer_instance_init (JfifSniffer * self,
                            gpointer klass)
{
}

static GType
jfif_sniffer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (JfifSnifferClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) jfif_sniffer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (JfifSniffer), 0, (GInstanceInitFunc) jfif_sniffer_instance_init, NULL };
	GType jfif_sniffer_type_id;
	jfif_sniffer_type_id = g_type_register_static (TYPE_GDK_SNIFFER, "JfifSniffer", &g_define_type_info, 0);
	return jfif_sniffer_type_id;
}

GType
jfif_sniffer_get_type (void)
{
	static volatile gsize jfif_sniffer_type_id__once = 0;
	if (g_once_init_enter (&jfif_sniffer_type_id__once)) {
		GType jfif_sniffer_type_id;
		jfif_sniffer_type_id = jfif_sniffer_get_type_once ();
		g_once_init_leave (&jfif_sniffer_type_id__once, jfif_sniffer_type_id);
	}
	return jfif_sniffer_type_id__once;
}

JfifReader*
jfif_reader_construct (GType object_type,
                       const gchar* filepath)
{
	JfifReader* self = NULL;
	g_return_val_if_fail (filepath != NULL, NULL);
	self = (JfifReader*) gdk_reader_construct (object_type, filepath, PHOTO_FILE_FORMAT_JFIF);
	return self;
}

JfifReader*
jfif_reader_new (const gchar* filepath)
{
	return jfif_reader_construct (TYPE_JFIF_READER, filepath);
}

static void
jfif_reader_class_init (JfifReaderClass * klass,
                        gpointer klass_data)
{
	jfif_reader_parent_class = g_type_class_peek_parent (klass);
}

static void
jfif_reader_instance_init (JfifReader * self,
                           gpointer klass)
{
}

static GType
jfif_reader_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (JfifReaderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) jfif_reader_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (JfifReader), 0, (GInstanceInitFunc) jfif_reader_instance_init, NULL };
	GType jfif_reader_type_id;
	jfif_reader_type_id = g_type_register_static (TYPE_GDK_READER, "JfifReader", &g_define_type_info, 0);
	return jfif_reader_type_id;
}

GType
jfif_reader_get_type (void)
{
	static volatile gsize jfif_reader_type_id__once = 0;
	if (g_once_init_enter (&jfif_reader_type_id__once)) {
		GType jfif_reader_type_id;
		jfif_reader_type_id = jfif_reader_get_type_once ();
		g_once_init_leave (&jfif_reader_type_id__once, jfif_reader_type_id);
	}
	return jfif_reader_type_id__once;
}

JfifWriter*
jfif_writer_construct (GType object_type,
                       const gchar* filepath)
{
	JfifWriter* self = NULL;
	g_return_val_if_fail (filepath != NULL, NULL);
	self = (JfifWriter*) photo_file_writer_construct (object_type, filepath, PHOTO_FILE_FORMAT_JFIF);
	return self;
}

JfifWriter*
jfif_writer_new (const gchar* filepath)
{
	return jfif_writer_construct (TYPE_JFIF_WRITER, filepath);
}

static void
jfif_writer_real_write (PhotoFileWriter* base,
                        GdkPixbuf* pixbuf,
                        JpegQuality quality,
                        GError** error)
{
	JfifWriter * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_WRITER, JfifWriter);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (pixbuf, gdk_pixbuf_get_type ()));
	_tmp0_ = gdk_pixbuf_get_has_alpha (pixbuf);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		GdkPixbuf* _tmp2_;
		GdkPixbuf* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp2_ = apply_alpha_channel (pixbuf, FALSE);
		_tmp3_ = _tmp2_;
		_tmp4_ = photo_file_adapter_get_filepath (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_ADAPTER, PhotoFileAdapter));
		_tmp5_ = _tmp4_;
		_tmp6_ = jpeg_quality_get_pct_text (quality);
		_tmp7_ = _tmp6_;
		gdk_pixbuf_save (_tmp3_, _tmp5_, "jpeg", &_inner_error0_, "quality", _tmp7_, NULL);
		_g_free0 (_tmp7_);
		_g_free0 (_tmp5_);
		_g_object_unref0 (_tmp3_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	} else {
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp8_ = photo_file_adapter_get_filepath (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_ADAPTER, PhotoFileAdapter));
		_tmp9_ = _tmp8_;
		_tmp10_ = jpeg_quality_get_pct_text (quality);
		_tmp11_ = _tmp10_;
		gdk_pixbuf_save (pixbuf, _tmp9_, "jpeg", &_inner_error0_, "quality", _tmp11_, NULL);
		_g_free0 (_tmp11_);
		_g_free0 (_tmp9_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	}
}

static void
jfif_writer_class_init (JfifWriterClass * klass,
                        gpointer klass_data)
{
	jfif_writer_parent_class = g_type_class_peek_parent (klass);
	((PhotoFileWriterClass *) klass)->write = (void (*) (PhotoFileWriter*, GdkPixbuf*, JpegQuality, GError**)) jfif_writer_real_write;
}

static void
jfif_writer_instance_init (JfifWriter * self,
                           gpointer klass)
{
}

static GType
jfif_writer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (JfifWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) jfif_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (JfifWriter), 0, (GInstanceInitFunc) jfif_writer_instance_init, NULL };
	GType jfif_writer_type_id;
	jfif_writer_type_id = g_type_register_static (TYPE_PHOTO_FILE_WRITER, "JfifWriter", &g_define_type_info, 0);
	return jfif_writer_type_id;
}

GType
jfif_writer_get_type (void)
{
	static volatile gsize jfif_writer_type_id__once = 0;
	if (g_once_init_enter (&jfif_writer_type_id__once)) {
		GType jfif_writer_type_id;
		jfif_writer_type_id = jfif_writer_get_type_once ();
		g_once_init_leave (&jfif_writer_type_id__once, jfif_writer_type_id);
	}
	return jfif_writer_type_id__once;
}

JfifMetadataWriter*
jfif_metadata_writer_construct (GType object_type,
                                const gchar* filepath)
{
	JfifMetadataWriter* self = NULL;
	g_return_val_if_fail (filepath != NULL, NULL);
	self = (JfifMetadataWriter*) photo_file_metadata_writer_construct (object_type, filepath, PHOTO_FILE_FORMAT_JFIF);
	return self;
}

JfifMetadataWriter*
jfif_metadata_writer_new (const gchar* filepath)
{
	return jfif_metadata_writer_construct (TYPE_JFIF_METADATA_WRITER, filepath);
}

static void
jfif_metadata_writer_real_write_metadata (PhotoFileMetadataWriter* base,
                                          PhotoMetadata* metadata,
                                          GError** error)
{
	JfifMetadataWriter * self;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_JFIF_METADATA_WRITER, JfifMetadataWriter);
	g_return_if_fail (IS_PHOTO_METADATA (metadata));
	_tmp0_ = photo_file_adapter_get_file (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PHOTO_FILE_ADAPTER, PhotoFileAdapter));
	_tmp1_ = _tmp0_;
	photo_metadata_write_to_file (metadata, _tmp1_, &_inner_error0_);
	_g_object_unref0 (_tmp1_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

static void
jfif_metadata_writer_class_init (JfifMetadataWriterClass * klass,
                                 gpointer klass_data)
{
	jfif_metadata_writer_parent_class = g_type_class_peek_parent (klass);
	((PhotoFileMetadataWriterClass *) klass)->write_metadata = (void (*) (PhotoFileMetadataWriter*, PhotoMetadata*, GError**)) jfif_metadata_writer_real_write_metadata;
}

static void
jfif_metadata_writer_instance_init (JfifMetadataWriter * self,
                                    gpointer klass)
{
}

static GType
jfif_metadata_writer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (JfifMetadataWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) jfif_metadata_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (JfifMetadataWriter), 0, (GInstanceInitFunc) jfif_metadata_writer_instance_init, NULL };
	GType jfif_metadata_writer_type_id;
	jfif_metadata_writer_type_id = g_type_register_static (TYPE_PHOTO_FILE_METADATA_WRITER, "JfifMetadataWriter", &g_define_type_info, 0);
	return jfif_metadata_writer_type_id;
}

GType
jfif_metadata_writer_get_type (void)
{
	static volatile gsize jfif_metadata_writer_type_id__once = 0;
	if (g_once_init_enter (&jfif_metadata_writer_type_id__once)) {
		GType jfif_metadata_writer_type_id;
		jfif_metadata_writer_type_id = jfif_metadata_writer_get_type_once ();
		g_once_init_leave (&jfif_metadata_writer_type_id__once, jfif_metadata_writer_type_id);
	}
	return jfif_metadata_writer_type_id__once;
}

guint8
jpeg_marker_get_byte (JpegMarker self)
{
	guint8 result;
	result = (guint8) self;
	return result;
}

gboolean
jpeg_marker_is_sof (JpegMarker self)
{
	JpegMarker variant = 0;
	gboolean _tmp0_ = FALSE;
	gboolean result;
	if ((self >> 4) != 0xC) {
		result = FALSE;
		return result;
	}
	variant = self & 0x0F;
	if (variant == 0) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = (variant % 4) != 0;
	}
	result = _tmp0_;
	return result;
}

static GType
jpeg_marker_get_type_once (void)
{
	static const GEnumValue values[] = {{JPEG_MARKER_INVALID, "JPEG_MARKER_INVALID", "invalid"}, {JPEG_MARKER_SOI, "JPEG_MARKER_SOI", "soi"}, {JPEG_MARKER_EOI, "JPEG_MARKER_EOI", "eoi"}, {JPEG_MARKER_APP0, "JPEG_MARKER_APP0", "app0"}, {JPEG_MARKER_APP1, "JPEG_MARKER_APP1", "app1"}, {0, NULL, NULL}};
	GType jpeg_marker_type_id;
	jpeg_marker_type_id = g_enum_register_static ("JpegMarker", values);
	return jpeg_marker_type_id;
}

GType
jpeg_marker_get_type (void)
{
	static volatile gsize jpeg_marker_type_id__once = 0;
	if (g_once_init_enter (&jpeg_marker_type_id__once)) {
		GType jpeg_marker_type_id;
		jpeg_marker_type_id = jpeg_marker_get_type_once ();
		g_once_init_leave (&jpeg_marker_type_id__once, jpeg_marker_type_id);
	}
	return jpeg_marker_type_id__once;
}

gint
jpeg_quality_get_pct (JpegQuality self)
{
	gint result;
	result = (gint) self;
	return result;
}

gchar*
jpeg_quality_get_pct_text (JpegQuality self)
{
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_strdup_printf ("%d", (gint) self);
	result = _tmp0_;
	return result;
}

JpegQuality*
jpeg_quality_get_all (gint* result_length1)
{
	JpegQuality* _tmp0_;
	JpegQuality* _tmp1_;
	gint _tmp1__length1;
	JpegQuality* result;
	_tmp0_ = g_new0 (JpegQuality, 4);
	_tmp0_[0] = JPEG_QUALITY_LOW;
	_tmp0_[1] = JPEG_QUALITY_MEDIUM;
	_tmp0_[2] = JPEG_QUALITY_HIGH;
	_tmp0_[3] = JPEG_QUALITY_MAXIMUM;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = 4;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

gchar*
jpeg_quality_to_string (JpegQuality self)
{
	gchar* result;
	switch (self) {
		case JPEG_QUALITY_LOW:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup_printf (_ ("Low (%d%%)"), (gint) self);
			result = _tmp0_;
			return result;
		}
		case JPEG_QUALITY_MEDIUM:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup_printf (_ ("Medium (%d%%)"), (gint) self);
			result = _tmp1_;
			return result;
		}
		case JPEG_QUALITY_HIGH:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup_printf (_ ("High (%d%%)"), (gint) self);
			result = _tmp2_;
			return result;
		}
		case JPEG_QUALITY_MAXIMUM:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup_printf (_ ("Maximum (%d%%)"), (gint) self);
			result = _tmp3_;
			return result;
		}
		default:
		break;
	}
	g_warn_if_reached ();
	result = NULL;
	return result;
}

static GType
jpeg_quality_get_type_once (void)
{
	static const GEnumValue values[] = {{JPEG_QUALITY_LOW, "JPEG_QUALITY_LOW", "low"}, {JPEG_QUALITY_MEDIUM, "JPEG_QUALITY_MEDIUM", "medium"}, {JPEG_QUALITY_HIGH, "JPEG_QUALITY_HIGH", "high"}, {JPEG_QUALITY_MAXIMUM, "JPEG_QUALITY_MAXIMUM", "maximum"}, {0, NULL, NULL}};
	GType jpeg_quality_type_id;
	jpeg_quality_type_id = g_enum_register_static ("JpegQuality", values);
	return jpeg_quality_type_id;
}

GType
jpeg_quality_get_type (void)
{
	static volatile gsize jpeg_quality_type_id__once = 0;
	if (g_once_init_enter (&jpeg_quality_type_id__once)) {
		GType jpeg_quality_type_id;
		jpeg_quality_type_id = jpeg_quality_get_type_once ();
		g_once_init_leave (&jpeg_quality_type_id__once, jpeg_quality_type_id);
	}
	return jpeg_quality_type_id__once;
}

gboolean
jpeg_is_jpeg (GFile* file,
              GError** error)
{
	GFileInputStream* fins = NULL;
	GFileInputStream* _tmp0_;
	gboolean _tmp2_ = FALSE;
	GFileInputStream* _tmp3_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (file, g_file_get_type ()), FALSE);
	_tmp0_ = g_file_read (file, NULL, &_inner_error0_);
	fins = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	_tmp3_ = fins;
	_tmp2_ = jpeg_is_jpeg_stream (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, g_input_stream_get_type (), GInputStream), &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp4_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (fins);
		return _tmp4_;
	}
	result = _tmp2_;
	_g_object_unref0 (fins);
	return result;
}

gboolean
jpeg_is_jpeg_stream (GInputStream* ins,
                     GError** error)
{
	JpegMarker marker = 0;
	gint segment_length = 0;
	JpegMarker _tmp0_ = 0;
	gint _tmp1_;
	gboolean _tmp3_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ins, g_input_stream_get_type ()), FALSE);
	_tmp1_ = jpeg_read_marker (ins, &_tmp0_, &_inner_error0_);
	marker = _tmp0_;
	segment_length = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp2_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp2_;
	}
	if (marker == JPEG_MARKER_SOI) {
		_tmp3_ = segment_length == 0;
	} else {
		_tmp3_ = FALSE;
	}
	result = _tmp3_;
	return result;
}

gboolean
jpeg_is_jpeg_bytes (GBytes* bytes,
                    GError** error)
{
	GMemoryInputStream* mins = NULL;
	GMemoryInputStream* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (bytes != NULL, FALSE);
	_tmp0_ = (GMemoryInputStream*) g_memory_input_stream_new_from_bytes (bytes);
	mins = _tmp0_;
	_tmp1_ = jpeg_is_jpeg_stream (G_TYPE_CHECK_INSTANCE_CAST (mins, g_input_stream_get_type (), GInputStream), &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp2_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (mins);
		return _tmp2_;
	}
	result = _tmp1_;
	_g_object_unref0 (mins);
	return result;
}

gint32
jpeg_read_marker_2 (GDataInputStream* dins,
                    JpegMarker* marker,
                    GError** error)
{
	JpegMarker _vala_marker = 0;
	guint8 _tmp0_ = 0U;
	guint8 _tmp2_ = 0U;
	gboolean _tmp4_ = FALSE;
	guint16 length = 0U;
	GSeekable* seekable = NULL;
	GSeekable* _tmp6_;
	gboolean _tmp7_ = FALSE;
	GError* _inner_error0_ = NULL;
	gint32 result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (dins, g_data_input_stream_get_type ()), -1);
	_vala_marker = JPEG_MARKER_INVALID;
	_tmp0_ = g_data_input_stream_read_byte (dins, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint32 _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	if (_tmp0_ != JPEG_MARKER_PREFIX) {
		result = (gint32) -1;
		if (marker) {
			*marker = _vala_marker;
		}
		return result;
	}
	_tmp2_ = g_data_input_stream_read_byte (dins, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint32 _tmp3_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	_vala_marker = (JpegMarker) _tmp2_;
	if (_vala_marker == JPEG_MARKER_SOI) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = _vala_marker == JPEG_MARKER_EOI;
	}
	if (_tmp4_) {
		result = (gint32) 0;
		if (marker) {
			*marker = _vala_marker;
		}
		return result;
	}
	length = g_data_input_stream_read_uint16 (dins, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint32 _tmp5_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp5_;
	}
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (dins, g_seekable_get_type ()) ? ((GSeekable*) dins) : NULL);
	seekable = _tmp6_;
	if (((gint) length) < 2) {
		_tmp7_ = dins != NULL;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		GSeekable* _tmp8_;
		_tmp8_ = seekable;
		g_debug ("Invalid length %Xh at ofs %" G_GINT64_FORMAT "Xh", length, g_seekable_tell (_tmp8_) - 2);
		result = (gint32) -1;
		_g_object_unref0 (seekable);
		if (marker) {
			*marker = _vala_marker;
		}
		return result;
	}
	result = (gint32) (length - 2);
	_g_object_unref0 (seekable);
	if (marker) {
		*marker = _vala_marker;
	}
	return result;
}

gint
jpeg_read_marker (GInputStream* fins,
                  JpegMarker* marker,
                  GError** error)
{
	JpegMarker _vala_marker = 0;
	GDataInputStream* dins = NULL;
	GDataInputStream* _tmp0_;
	gint32 _tmp1_ = 0;
	JpegMarker _tmp2_ = 0;
	gint32 _tmp3_;
	GError* _inner_error0_ = NULL;
	gint result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (fins, g_input_stream_get_type ()), -1);
	_tmp0_ = g_data_input_stream_new (fins);
	dins = _tmp0_;
	g_data_input_stream_set_byte_order (dins, G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN);
	_tmp3_ = jpeg_read_marker_2 (dins, &_tmp2_, &_inner_error0_);
	_vala_marker = _tmp2_;
	_tmp1_ = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp4_ = -1;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (dins);
		return _tmp4_;
	}
	result = (gint) _tmp1_;
	_g_object_unref0 (dins);
	if (marker) {
		*marker = _vala_marker;
	}
	return result;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

