diff options
Diffstat (limited to 'third_party/jpeg-xl/plugins')
6 files changed, 58 insertions, 52 deletions
diff --git a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c index bafa57b167..6a0de0486b 100644 --- a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c +++ b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c @@ -331,9 +331,8 @@ static gboolean load_increment(gpointer context, const guchar *buf, guint size, GError **error) { GdkPixbufJxlAnimation *decoder_state = context; if (decoder_state->done == TRUE) { - g_set_error(error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED, - "JXL decoder load_increment called after end of file"); - return FALSE; + g_warning_once("Trailing data found at end of JXL file"); + return TRUE; } JxlDecoderStatus status; @@ -491,9 +490,8 @@ static gboolean load_increment(gpointer context, const guchar *buf, guint size, decoder_state->frames->len - 1) .data; decoder_state->pixel_format.align = gdk_pixbuf_get_rowstride(output); - guchar *dst = gdk_pixbuf_get_pixels(output); - size_t num_pixels = decoder_state->xsize * decoder_state->ysize; - size_t size = num_pixels * decoder_state->pixel_format.num_channels; + guint size; + guchar *dst = gdk_pixbuf_get_pixels_with_length(output, &size); if (JXL_DEC_SUCCESS != JxlDecoderSetImageOutBuffer( decoder_state->decoder, &decoder_state->pixel_format, dst, size)) { diff --git a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc index 5e5642d491..a2e5dc9703 100644 --- a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc +++ b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc @@ -16,12 +16,13 @@ int main(int argc, char* argv[]) { const char* loaders_cache = argv[1]; const char* filename = argv[2]; - setenv("GDK_PIXBUF_MODULE_FILE", loaders_cache, true); + const int kDoOverwrite = 1; + setenv("GDK_PIXBUF_MODULE_FILE", loaders_cache, kDoOverwrite); // XDG_DATA_HOME is the path where we look for the mime cache. // XDG_DATA_DIRS directories are used in addition to XDG_DATA_HOME. - setenv("XDG_DATA_HOME", ".", true); - setenv("XDG_DATA_DIRS", "", true); + setenv("XDG_DATA_HOME", ".", kDoOverwrite); + setenv("XDG_DATA_DIRS", "", kDoOverwrite); if (!gdk_init_check(nullptr, nullptr)) { fprintf(stderr, "This test requires a DISPLAY\n"); diff --git a/third_party/jpeg-xl/plugins/gimp/common.cc b/third_party/jpeg-xl/plugins/gimp/common.cc index 1a884570cb..a40340aaca 100644 --- a/third_party/jpeg-xl/plugins/gimp/common.cc +++ b/third_party/jpeg-xl/plugins/gimp/common.cc @@ -15,13 +15,10 @@ JpegXlGimpProgress::JpegXlGimpProgress(const char *message) { } void JpegXlGimpProgress::update() { - gimp_progress_update((float)++cur_progress / (float)max_progress); - return; + gimp_progress_update(static_cast<float>(++cur_progress) / + static_cast<float>(max_progress)); } -void JpegXlGimpProgress::finished() { - gimp_progress_update(1.0); - return; -} +void JpegXlGimpProgress::finished() { gimp_progress_update(1.0); } } // namespace jxl diff --git a/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc b/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc index 4796c1708c..07acd524d2 100644 --- a/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc +++ b/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc @@ -39,11 +39,14 @@ bool LoadJpegXlImage(const gchar *const filename, gint32 *const image_id) { GimpColorProfile *profile_icc = nullptr; GimpColorProfile *profile_int = nullptr; bool is_linear = false; - unsigned long xsize = 0, ysize = 0; - long crop_x0 = 0, crop_y0 = 0; + unsigned long xsize = 0; + unsigned long ysize = 0; + long crop_x0 = 0; + long crop_y0 = 0; size_t layer_idx = 0; uint32_t frame_duration = 0; - double tps_denom = 1.f, tps_numer = 1.f; + double tps_denom = 1.f; + double tps_numer = 1.f; gint32 layer; @@ -356,13 +359,13 @@ bool LoadJpegXlImage(const gchar *const filename, gint32 *const image_id) { const GString *blend_null_flag = g_string_new(""); const GString *blend_replace_flag = g_string_new(" (replace)"); const GString *blend_combine_flag = g_string_new(" (combine)"); - GString *blend; + const GString *blend; if (blend_mode == JXL_BLEND_REPLACE) { - blend = (GString *)blend_replace_flag; + blend = blend_replace_flag; } else if (blend_mode == JXL_BLEND_BLEND) { - blend = (GString *)blend_combine_flag; + blend = blend_combine_flag; } else { - blend = (GString *)blend_null_flag; + blend = blend_null_flag; } char *temp_frame_name = nullptr; bool must_free_frame_name = false; @@ -433,8 +436,10 @@ bool LoadJpegXlImage(const gchar *const filename, gint32 *const image_id) { " Warning: JxlDecoderGetFrameHeader: Unhandled blend mode: %d\n", blend_mode); } - if ((frame_name_len = frame_header.name_length) > 0) { - frame_name = (char *)realloc(frame_name, frame_name_len); + frame_name_len = frame_header.name_length; + if (frame_name_len > 0) { + frame_name = + reinterpret_cast<char *>(realloc(frame_name, frame_name_len)); if (JXL_DEC_SUCCESS != JxlDecoderGetFrameName(dec.get(), frame_name, frame_name_len)) { g_printerr(LOAD_PROC "Error: JxlDecoderGetFrameName failed"); diff --git a/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc b/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc index 45aaa1f8df..284a9f2771 100644 --- a/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc +++ b/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc @@ -7,6 +7,7 @@ #include <jxl/encode.h> #include <jxl/encode_cxx.h> +#include <jxl/types.h> #include <cmath> #include <utility> @@ -229,7 +230,7 @@ bool JpegXlSaveGui::GuiOnChangeAdvancedMode(GtkWidget* toggle, gtk_widget_set_sensitive(self->frame_advanced, jxl_save_opts.advanced_mode); if (!jxl_save_opts.advanced_mode) { - jxl_save_opts.basic_info.uses_original_profile = false; + jxl_save_opts.basic_info.uses_original_profile = JXL_FALSE; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->toggle_no_xyb), false); jxl_save_opts.use_container = true; @@ -290,19 +291,20 @@ bool JpegXlSaveGui::SaveDialog() { "\n\td\u00A0=\u00A03\tFair" "\n\td\u00A0=\u00A06\tPoor"; - entry_distance = (GtkAdjustment*)gimp_scale_entry_new( - GTK_TABLE(table), 0, 0, "Distance", SCALE_WIDTH, 0, - jxl_save_opts.distance, 0.0, 15.0, 0.001, 1.0, 3, true, 0.0, 0.0, - distance_help, SAVE_PROC); - gimp_scale_entry_set_logarithmic((GtkObject*)entry_distance, true); + entry_distance = reinterpret_cast<GtkAdjustment*>( + gimp_scale_entry_new(GTK_TABLE(table), 0, 0, "Distance", SCALE_WIDTH, 0, + jxl_save_opts.distance, 0.0, 15.0, 0.001, 1.0, 3, + true, 0.0, 0.0, distance_help, SAVE_PROC)); + gimp_scale_entry_set_logarithmic(reinterpret_cast<GtkObject*>(entry_distance), + true); // Quality Slider static gchar quality_help[] = "JPEG-style Quality is remapped to distance. " "Values roughly match libjpeg quality settings."; - entry_quality = (GtkAdjustment*)gimp_scale_entry_new( + entry_quality = reinterpret_cast<GtkAdjustment*>(gimp_scale_entry_new( GTK_TABLE(table), 0, 1, "Quality", SCALE_WIDTH, 0, jxl_save_opts.quality, - 8.26, 100.0, 1.0, 10.0, 2, true, 0.0, 0.0, quality_help, SAVE_PROC); + 8.26, 100.0, 1.0, 10.0, 2, true, 0.0, 0.0, quality_help, SAVE_PROC)); // Distance and Quality Signals handle_entry_distance = g_signal_connect( @@ -322,10 +324,10 @@ bool JpegXlSaveGui::SaveDialog() { "the encoder uses less effort to hit distance targets. " "As\u00A0a\u00A0result, image quality may be decreased. " "Default\u00A0=\u00A03."; - entry_effort = (GtkAdjustment*)gimp_scale_entry_new( - GTK_TABLE(table), 0, 3, "Speed", SCALE_WIDTH, 0, - 10 - jxl_save_opts.encoding_effort, 1, 9, 1, 2, 0, true, 0.0, 0.0, - effort_help, SAVE_PROC); + entry_effort = reinterpret_cast<GtkAdjustment*>( + gimp_scale_entry_new(GTK_TABLE(table), 0, 3, "Speed", SCALE_WIDTH, 0, + 10 - jxl_save_opts.encoding_effort, 1, 9, 1, 2, 0, + true, 0.0, 0.0, effort_help, SAVE_PROC)); // effort signal g_signal_connect(entry_effort, "value-changed", G_CALLBACK(GuiOnChangeEffort), @@ -415,10 +417,10 @@ bool JpegXlSaveGui::SaveDialog() { gtk_container_add(GTK_CONTAINER(vbox), table); gtk_widget_show(table); - entry_faster = (GtkAdjustment*)gimp_scale_entry_new( - GTK_TABLE(table), 0, 0, "Faster Decoding", SCALE_WIDTH, 0, - jxl_save_opts.faster_decoding, 0, 4, 1, 1, 0, true, 0.0, 0.0, faster_help, - SAVE_PROC); + entry_faster = reinterpret_cast<GtkAdjustment*>( + gimp_scale_entry_new(GTK_TABLE(table), 0, 0, "Faster Decoding", + SCALE_WIDTH, 0, jxl_save_opts.faster_decoding, 0, 4, + 1, 1, 0, true, 0.0, 0.0, faster_help, SAVE_PROC)); // Faster Decoding Signals g_signal_connect(entry_faster, "value-changed", @@ -472,7 +474,6 @@ JpegXlSaveOpts::JpegXlSaveOpts() { pixel_format.align = 0; JxlEncoderInitBasicInfo(&basic_info); - return; } // JpegXlSaveOpts constructor bool JpegXlSaveOpts::SetModel(bool is_linear_) { @@ -568,7 +569,8 @@ bool JpegXlSaveOpts::SetNumChannels(int channels) { pixel_format.num_channels = 2; basic_info.num_color_channels = 1; basic_info.num_extra_channels = 1; - basic_info.alpha_bits = int(std::fmin(16, basic_info.bits_per_sample)); + basic_info.alpha_bits = + static_cast<int>(std::fmin(16, basic_info.bits_per_sample)); basic_info.alpha_exponent_bits = 0; break; case 3: @@ -582,7 +584,8 @@ bool JpegXlSaveOpts::SetNumChannels(int channels) { pixel_format.num_channels = 4; basic_info.num_color_channels = 3; basic_info.num_extra_channels = 1; - basic_info.alpha_bits = int(std::fmin(16, basic_info.bits_per_sample)); + basic_info.alpha_bits = + static_cast<int>(std::fmin(16, basic_info.bits_per_sample)); basic_info.alpha_exponent_bits = 0; break; default: @@ -698,7 +701,7 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, // treat layers as animation frames, for now if (nlayers > 1) { - jxl_save_opts.basic_info.have_animation = true; + jxl_save_opts.basic_info.have_animation = JXL_TRUE; jxl_save_opts.basic_info.animation.tps_numerator = 100; } @@ -738,12 +741,12 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, jxl_save_opts.icc_attached = true; } else { g_printerr(SAVE_PROC " Warning: JxlEncoderSetICCProfile failed.\n"); - jxl_save_opts.basic_info.uses_original_profile = false; + jxl_save_opts.basic_info.uses_original_profile = JXL_FALSE; jxl_save_opts.lossless = false; } } else { g_printerr(SAVE_PROC " Warning: Using internal profile.\n"); - jxl_save_opts.basic_info.uses_original_profile = false; + jxl_save_opts.basic_info.uses_original_profile = JXL_FALSE; jxl_save_opts.lossless = false; } @@ -751,9 +754,11 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, JxlColorEncoding color_encoding = {}; if (jxl_save_opts.is_linear) { - JxlColorEncodingSetToLinearSRGB(&color_encoding, jxl_save_opts.is_gray); + JxlColorEncodingSetToLinearSRGB(&color_encoding, + TO_JXL_BOOL(jxl_save_opts.is_gray)); } else { - JxlColorEncodingSetToSRGB(&color_encoding, jxl_save_opts.is_gray); + JxlColorEncodingSetToSRGB(&color_encoding, + TO_JXL_BOOL(jxl_save_opts.is_gray)); } if (JXL_ENC_SUCCESS != @@ -777,15 +782,15 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, // lossless mode doesn't work well with floating point jxl_save_opts.distance = 0.01; jxl_save_opts.lossless = false; - JxlEncoderSetFrameLossless(frame_settings, false); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); JxlEncoderSetFrameDistance(frame_settings, 0.01); } else { JxlEncoderSetFrameDistance(frame_settings, 0); - JxlEncoderSetFrameLossless(frame_settings, true); + JxlEncoderSetFrameLossless(frame_settings, JXL_TRUE); } } else { jxl_save_opts.lossless = false; - JxlEncoderSetFrameLossless(frame_settings, false); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); JxlEncoderSetFrameDistance(frame_settings, jxl_save_opts.distance); } diff --git a/third_party/jpeg-xl/plugins/mime/README.md b/third_party/jpeg-xl/plugins/mime/README.md index 4d398c7b90..6954a91e48 100644 --- a/third_party/jpeg-xl/plugins/mime/README.md +++ b/third_party/jpeg-xl/plugins/mime/README.md @@ -1,6 +1,6 @@ ## :warning: Not needed anymore -As `image/jxl` is now supported by [shared-mine-info 2.2](https://gitlab.freedesktop.org/xdg/shared-mime-info/-/releases/2.2), it should not be necessary anymore to install this plugin. +As `image/jxl` is now supported by [shared-mime-info 2.2](https://gitlab.freedesktop.org/xdg/shared-mime-info/-/releases/2.2), it should not be necessary anymore to install this plugin. You can test if your system correctly understand the MIME type of JPEG XL image by obtaining a JPEG XL image, e.g. with ```bash |