Skip to content

WIP: plug-ins: high bit depth support for HEIF format export.

Jehan requested to merge wip/Jehan/file-heif-highbit into master

So turns out that HEIF can support up to 16-bit per pixel since libheif 1.4.0.

Please don't push this because it actually doesn't work. The plug-in crashes when I try to export a more-than 8-bit image. I am only opening this because I am going to ask some help from libheif developers, as I am not sure if I am doing something wrong or if there is a bug in libheif.

Thread 1 (Thread 0x7fc6e86f2680 (LWP 25570)):
#0  0x00007fc6e99f4e34 in read () at /lib64/libpthread.so.0
#1  0x00007fc6eb1141d1 in gimp_stack_trace_print (prog_name=prog_name@entry=0x7ffd3af6cd5d "/home/jehan/.local/share/crossroad/roads/native/gimp/lib/gimp/2.99/plug-ins/file-heif/file-heif", stream=0x7fc6e99de780 <_IO_2_1_stdout_>, trace=trace@entry=0x0) at /home/jehan/dev/src//gimp/libgimpbase/gimputils.c:1300
        status = 1041536162
        stack_printed = 0
        gtrace = 0x0
        gimp_pid = "25570\000\000\000\242\224\024>\340\324T>"
        buffer = "\000\374\017\353\306\177\000\000@v\022\353\306\177\000\000\260\255\366:\375\177\000\000]\315\366:\375\177\000\000\360\235\021\353\306\177\000\000\220\266\366:\375\177\000\000@{\216\001\000\000\000\000D\245&\353\306\177\000\000\005", '\000' <repeats 15 times>, "P{\216\001\000\000\000\000X\001\020\353\306\177\000\000\220\255\366:\375\177\000\000\236\022'\353\306\177\000\000S\000\000\000\000\000\000\000\210\"\255\373", '\000' <repeats 12 times>, "\200\347\235\351\306\177\000\000]\315\366:\375\177\000\000\022\365a\001\000\000\000\000\340\370\235\351\306\177\000\000\236\022'\353\306\177\000\000\000\000\000\000\000\000\000\000AX\205\351\306\177\000\000\000\000\000\000\000\000\000\000"...
        read_n = <optimized out>
        sync_fd = {11, 12}
        out_fd = {13, 14}
        fork_pid = 25580
        pid = 25570
        eintr_count = 0
        tid = 25570
#2  0x00007fc6eb114630 in gimp_stack_trace_query (prog_name=0x7ffd3af6cd5d "/home/jehan/.local/share/crossroad/roads/native/gimp/lib/gimp/2.99/plug-ins/file-heif/file-heif") at /home/jehan/dev/src//gimp/libgimpbase/gimputils.c:1470
        buf = "s\n\000\000\000\000\000\000\v\000\000\000\000\000\000"
#3  0x00007fc6eb2056df in gimp_plugin_sigfatal_handler (sig_num=<optimized out>) at /home/jehan/dev/src//gimp/libgimp/gimp.c:1961
        sigset = {__val = {0 <repeats 16 times>}}
#4  0x00007fc6e99f6070 in <signal handler called> () at /lib64/libpthread.so.0
#5  0x00007fc6e9f946e0 in std::_Rb_tree<heif_channel, std::pair<heif_channel const, heif::HeifPixelImage::ImagePlane>, std::_Select1st<std::pair<heif_channel const, heif::HeifPixelImage::ImagePlane> >, std::less<heif_channel>, std::allocator<std::pair<heif_channel const, heif::HeifPixelImage::ImagePlane> > >::find(heif_channel const&) const (__k=<synthetic pointer>: <optimized out>, this=0x58) at /usr/include/c++/8/bits/stl_tree.h:2549
        iter = <optimized out>
#6  0x00007fc6e9f946e0 in std::map<heif_channel, heif::HeifPixelImage::ImagePlane, std::less<heif_channel>, std::allocator<std::pair<heif_channel const, heif::HeifPixelImage::ImagePlane> > >::find(heif_channel const&) const (__x=<synthetic pointer>: <optimized out>, this=0x58) at /usr/include/c++/8/bits/stl_map.h:1194
        iter = <optimized out>
#7  0x00007fc6e9f946e0 in heif::HeifPixelImage::get_width(heif_channel) const (this=0x0, channel=channel@entry=heif_channel_Y) at /home/jehan/dev/src/libheif/libheif/heif_image.cc:134
        iter = <optimized out>
#8  0x00007fc6e9fa9311 in heif::HeifContext::Image::encode_image_as_hevc(std::shared_ptr<heif::HeifPixelImage>, heif_encoder*, heif_encoding_options const*, heif_image_input_class) (this=0x1a7ed00, image=std::shared_ptr<heif::HeifPixelImage> (empty) = {...}, encoder=0x1643bf0, options=0x7ffd3af6b76e, input_class=heif_image_input_class_normal) at /home/jehan/dev/src/libheif/libheif/heif_context.cc:1666
        colorspace = heif_colorspace_YCbCr
        chroma = heif_chroma_420
        color_profile = std::shared_ptr<const heif::color_profile> (use count 2, weak count 0) = {get() = <optimized out>}
        c_api_image = {image = std::shared_ptr<heif::HeifPixelImage> (expired, weak count 0) = {get() = 0x7ffd3af6b650}}
        err = <optimized out>
#9  0x00007fc6e9fa9d1f in heif::HeifContext::encode_image(std::shared_ptr<heif::HeifPixelImage>, heif_encoder*, heif_encoding_options const*, heif_image_input_class, std::shared_ptr<heif::HeifContext::Image>&) (this=<optimized out>, pixel_image=std::shared_ptr<heif::HeifPixelImage> (use count 2, weak count 1) = {...}, encoder=0x1643bf0, options=options@entry=0x7ffd3af6b76e, input_class=input_class@entry=heif_image_input_class_normal, out_image=std::shared_ptr<heif::HeifContext::Image> (use count 2, weak count 0) = {...}) at /usr/include/c++/8/ext/atomicity.h:96
        image_id = <optimized out>
        error = {error_code = heif_error_Ok, sub_error_code = heif_suberror_Unspecified, message = "", static Ok = {error_code = heif_error_Ok, sub_error_code = heif_suberror_Unspecified, message = "", static Ok = <same as static member of an already seen type>, static kSuccess = 0x7fc6e9fb74e8 <heif::Error::kSuccess> "Success"}, static kSuccess = <same as static member of an already seen type>}
#10 0x00007fc6e9fa3d8b in heif_context_encode_image(heif_context*, heif_image const*, heif_encoder*, heif_encoding_options const*, heif_image_handle**) (ctx=ctx@entry=0x1a86050, input_image=<optimized out>, encoder=<optimized out>, options=0x7ffd3af6b76e, options@entry=0x0, out_image_handle=out_image_handle@entry=0x7ffd3af6b898) at /usr/include/c++/8/ext/atomicity.h:96
        default_options = {version = 1 '\001', save_alpha_channel = 1 '\001'}
        image = std::shared_ptr<heif::HeifContext::Image> (use count 2, weak count 0) = {get() = 0x1a7ed00}
        error = {error_code = heif_error_Ok, sub_error_code = heif_suberror_Unspecified, message = "", static Ok = {error_code = heif_error_Ok, sub_error_code = heif_suberror_Unspecified, message = "", static Ok = <same as static member of an already seen type>, static kSuccess = 0x7fc6e9fb74e8 <heif::Error::kSuccess> "Success"}, static kSuccess = <same as static member of an already seen type>}
#11 0x0000000000406098 in save_image (error=0x7ffd3af6b880, params=0x7ffd3af6b8a4, drawable_ID=<optimized out>, image_ID=<optimized out>, file=0x18597a0) at /home/jehan/dev/src//gimp/plug-ins/common/file-heif.c:824
        handle = 0x0
        err = {code = <optimized out>, subcode = <optimized out>, message = 0x7ffd3af6b890 "\360;d\001"}
        buffer = 0x1a85040
        bit_depth = <optimized out>
        has_alpha = <optimized out>
        output = <optimized out>
        space = 0x7fc6ea27a7c0 <space_db>
        stride = 12016
        width = 2001
        image = 0x1a86070
        context = 0x1a86050
        format_enc = 0x17641f0 "@*\207\001"
        data = 0x7fc6d0bd5010 "%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%55\312\312%%"...
        chroma = <optimized out>
        out_linear = <optimized out>
        encoder = 0x1643bf0
        writer = {writer_api_version = 989247792, write = 0x7fc6eb11175a <_gp_proc_run_read+74>}
        format = <optimized out>
        height = 1984
        __func__ = "save_image"
        file = 0x18597a0
        export = <optimized out>
        params = {quality = 50, lossless = 0, save_profile = 1}
        image_ID = 1
        drawable_ID = 2
        metadata = 0x0
        metadata_flags = GIMP_METADATA_SAVE_ALL
        values = {{type = GIMP_PDB_STATUS, data = {d_int32 = 0, d_int16 = 0, d_int8 = 0 '\000', d_float = 0, d_string = 0x0, d_int32array = 0x0, d_int16array = 0x0, d_int8array = 0x0, d_floatarray = 0x0, d_stringarray = 0x0, d_colorarray = 0x0, d_color = {r = 0, g = 0, b = 0, a = 0}, d_display = 0, d_image = 0, d_item = 0, d_layer = 0, d_layer_mask = 0, d_channel = 0, d_drawable = 0, d_selection = 0, d_boundary = 0, d_vectors = 0, d_unit = 0, d_parasite = {name = 0x0, flags = 0, size = 0, data = 0x0}, d_tattoo = 0, d_status = GIMP_PDB_EXECUTION_ERROR}}, {type = GIMP_PDB_INT32, data = {d_int32 = 0, d_int16 = 0, d_int8 = 0 '\000', d_float = 0, d_string = 0x0, d_int32array = 0x0, d_int16array = 0x0, d_int8array = 0x0, d_floatarray = 0x0, d_stringarray = 0x0, d_colorarray = 0x0, d_color = {r = 0, g = 0, b = 0, a = 0}, d_display = 0, d_image = 0, d_item = 0, d_layer = 0, d_layer_mask = 0, d_channel = 0, d_drawable = 0, d_selection = 0, d_boundary = 0, d_vectors = 0, d_unit = 0, d_parasite = {name = 0x0, flags = 0, size = 0, data = 0x0}, d_tattoo = 0, d_status = GIMP_PDB_EXECUTION_ERROR}}}
        run_mode = <optimized out>
        status = GIMP_PDB_SUCCESS
        error = 0x0
#12 0x0000000000406098 in run (name=<optimized out>, n_params=<optimized out>, param=<optimized out>, nreturn_vals=0x7ffd3af6b914, return_vals=<optimized out>) at /home/jehan/dev/src//gimp/plug-ins/common/file-heif.c:286
        file = 0x18597a0
        export = <optimized out>
        params = {quality = 50, lossless = 0, save_profile = 1}
        image_ID = 1
        drawable_ID = 2
        metadata = 0x0
        metadata_flags = GIMP_METADATA_SAVE_ALL
        values = {{type = GIMP_PDB_STATUS, data = {d_int32 = 0, d_int16 = 0, d_int8 = 0 '\000', d_float = 0, d_string = 0x0, d_int32array = 0x0, d_int16array = 0x0, d_int8array = 0x0, d_floatarray = 0x0, d_stringarray = 0x0, d_colorarray = 0x0, d_color = {r = 0, g = 0, b = 0, a = 0}, d_display = 0, d_image = 0, d_item = 0, d_layer = 0, d_layer_mask = 0, d_channel = 0, d_drawable = 0, d_selection = 0, d_boundary = 0, d_vectors = 0, d_unit = 0, d_parasite = {name = 0x0, flags = 0, size = 0, data = 0x0}, d_tattoo = 0, d_status = GIMP_PDB_EXECUTION_ERROR}}, {type = GIMP_PDB_INT32, data = {d_int32 = 0, d_int16 = 0, d_int8 = 0 '\000', d_float = 0, d_string = 0x0, d_int32array = 0x0, d_int16array = 0x0, d_int8array = 0x0, d_floatarray = 0x0, d_stringarray = 0x0, d_colorarray = 0x0, d_color = {r = 0, g = 0, b = 0, a = 0}, d_display = 0, d_image = 0, d_item = 0, d_layer = 0, d_layer_mask = 0, d_channel = 0, d_drawable = 0, d_selection = 0, d_boundary = 0, d_vectors = 0, d_unit = 0, d_parasite = {name = 0x0, flags = 0, size = 0, data = 0x0}, d_tattoo = 0, d_status = GIMP_PDB_EXECUTION_ERROR}}}
        run_mode = <optimized out>
        status = GIMP_PDB_SUCCESS
        error = 0x0
#13 0x00007fc6eb20613f in gimp_proc_run (proc_run=0x1653b00) at /home/jehan/dev/src//gimp/libgimp/gimp.c:2277
        proc_return = {name = 0x7fc6eb21e2e5 "LibGimp", nparams = 3944866547, params = 0x7fc6eb21e2ff}
        return_vals = 0x409600 <values>
        n_return_vals = 1
        msg = {type = 5, data = 0x1653b00}
        basename = <optimized out>
        env_string = <optimized out>
        debug_string = <optimized out>
        protocol_version = <optimized out>
        __func__ = "gimp_main"
#14 0x00007fc6eb20613f in gimp_loop () at /home/jehan/dev/src//gimp/libgimp/gimp.c:2111
        msg = {type = 5, data = 0x1653b00}
        basename = <optimized out>
        env_string = <optimized out>
        debug_string = <optimized out>
        protocol_version = <optimized out>
        __func__ = "gimp_main"
#15 0x00007fc6eb20613f in gimp_main (info=<optimized out>, argc=<optimized out>, argv=<optimized out>) at /home/jehan/dev/src//gimp/libgimp/gimp.c:692
        basename = <optimized out>
        env_string = <optimized out>
        debug_string = <optimized out>
        protocol_version = <optimized out>
        __func__ = "gimp_main"
#16 0x00007fc6e9841413 in __libc_start_main () at /lib64/libc.so.6
#17 0x0000000000404b5e in _start () at /home/jehan/dev/src//gimp/plug-ins/common/file-heif.c:76
[Inferior 1 (process 25570) detached]
/home/jehan/.local/share/crossroad/roads/native/gimp/lib/gimp/2.99/plug-ins/file-heif/file-heif (pid:25570): [E]xit, show [S]tack trace or [P]roceed: e
plug-in 'file-heif' aborted before sending its procedure return values

Merge request reports

Loading