Commit Graph

1912 Commits

Author SHA1 Message Date
NRK 285dc8bd05 add a new QOI decoder 2023-06-15 23:03:52 +02:00
Kim Woelders 16496a3cb2 autofoo: Don't check for freetype if we are building without text
#11
2023-05-23 09:46:09 +02:00
Kim Woelders 4b4f72c7ff HEIF loader: Call heif_[de]init() on loader load/unload
Seems to be required as of libheif-1.16.

Note - Running the tests with valgrind shows no problems, but with asan
enabled I get a bunch of messages like:

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f186d98ee38 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e38) (BuildId: bac59ca9f1e357781008d7f6982314d30ca62672)
    #1 0x7f186c4acec9 in ColorConversionPipeline::init_ops() [clone .part.0] (/lib64/libheif.so.1+0x6fec9) (BuildId: 2823b8c3a24fbf4262672d27ed3bf5a338d185b5)
    #2 0x7f186c4a2dec in heif_init (/lib64/libheif.so.1+0x65dec) (BuildId: 2823b8c3a24fbf4262672d27ed3bf5a338d185b5)
    #3 0x7f186d824d4e in __imlib_ProduceLoader ../../../../src/lib/loaders.c:209
2023-05-20 08:42:05 +02:00
Kim Woelders 875faa3fdc loading: Enable calling function on loader load/unload 2023-05-20 08:42:05 +02:00
Kim Woelders e9de0b1d38 test: Fix pr_info() when not printing to stdout 2023-05-20 08:42:05 +02:00
Kim Woelders 3a9084a7e9 imlib2_conv: Add option to time save operations 2023-05-20 08:42:05 +02:00
Kim Woelders 3adb01befd imlib2_load: Move time_us() to separate file 2023-05-20 08:42:05 +02:00
NRK 4f928f53a7 WEBP saver: allow lossless and respect compression tag
this treats quality == 100 as lossless similar to some other savers.

in case of lossless encoding, compression is derived from "quality" if
compression_tag was not set. in case of lossy encoding, the default is
used when compression_tag isn't set.

additionally, this fixes a bug in the older saver where fwrite might
have been called with a null fdata (which is UB) in case of an error.
2023-05-12 16:21:35 +02:00
Kim Woelders 8a36ae6d8d loaders: Use common function to print error messages
Also:
- gif  loader: Add error about corrupt frame sequence
- tiff loader: Drop OOM message - Not done elsewhere
- webp loader: Drop messages about quality tag outside [0-100] -
               Not done elsewhere
2023-05-08 18:52:57 +02:00
Kim Woelders 11cef49cef Introduce __imlib_perror() to produce error messages 2023-05-08 18:52:57 +02:00
Kim Woelders c44f3a4124 GIF loader: Enable showing animated images even if truncated 2023-05-06 20:59:03 +02:00
Kim Woelders d1d95fb2b1 imlib2_view: Avoid potential use of uninitialized data 2023-05-06 20:59:03 +02:00
Kim Woelders 5d73c53640 v1.11.1 2023-05-01 11:20:27 +02:00
Kim Woelders 41c792bd7e loaders: Cosmetics
- Add missing const
- Consistently use imdata for pointer into imlib image data
- Minor changes
2023-05-01 11:19:24 +02:00
Kim Woelders a55f36133d Add JXL saver
#9
2023-04-30 20:02:15 +02:00
Kim Woelders 9468f7132c loaders: Change method used to not unload loaders
It appears that in certain environments (homebrew on MacOS) the linker
does not like the -z nodelete option, so handle this differently.

#8
2023-04-04 20:53:49 +02:00
Kim Woelders 7c18c9aca1 loaders: Fix loaders potentially being loaded more than once
A new loader instance was created every time it was attempted to save
an image with a loader that doesn't have a save() function.
2023-04-04 20:53:33 +02:00
Kim Woelders adba3ecd0c XPM loader: Add rgb.txt
No longer rely on it being provided by X11.

rgb.txt is copied from https://gitlab.freedesktop.org/xorg/app/rgb
2023-03-23 06:24:31 +01:00
Kim Woelders eb513bc0d0 autofoo: Tweak PACKAGE_DATA_DIR definition 2023-03-23 06:24:31 +01:00
Kim Woelders 6a1bcc2ab7 modules: Drop some disabled code 2023-03-23 06:24:31 +01:00
Kim Woelders 21af0e5a95 test: Print some progress info in a couple of tests 2023-03-21 18:42:16 +01:00
Kim Woelders a83de2e244 test_load: Add some y4m checks 2023-03-21 06:56:47 +01:00
Kim Woelders 5bf590ae7b test_load: Add some missing ifdefs 2023-03-21 06:56:47 +01:00
Kim Woelders 32901e3bab Y4M loader: Various minor changes
- configure.ac: Alphabetic order
- Makefile.am: Alphabetic order, no need for nodelete
- loaders.c: Add to known loaders
- loader_y4m.c: Remove some unneeded headers
2023-03-21 06:48:53 +01:00
Chema Gonzalez 7eda43371a imlib2: add y4m test examples
Prepared using:
```
$ ffmpeg -i test/images/icon-64.png -pix_fmt yuv420p test/images/icon-64.yuv420p.y4m
...
$ ffmpeg -i test/images/icon-64.png -pix_fmt yuv422p test/images/icon-64.yuv422p.y4m
...
$ ffmpeg -i test/images/icon-64.png -pix_fmt yuv444p test/images/icon-64.yuv444p.y4m
...
```

Tested:
(1) correct y4m files
```
$ LD_LIBRARY_PATH=~/proj/imlib2/src/lib/.libs/:${LD_LIBRARY_PATH} IMLIB2_MODULE_PATH=~/proj/imlib2/src/modules/loaders/.libs/ valgrind --leak-check=yes /bin/feh ~/proj/imlib2/test/images/icon-*y4m
==391567== Memcheck, a memory error detector
==391567== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==391567== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==391567== Command: /bin/feh /home/chemag/proj/imlib2/test/images/icon-64.yuv420p.y4m /home/chemag/proj/imlib2/test/images/icon-64.yuv422p.y4m /home/chemag/proj/imlib2/test/images/icon-64.yuv444p.y4m
==391567==
==391567==
==391567== HEAP SUMMARY:
==391567==     in use at exit: 297,719 bytes in 1,018 blocks
==391567==   total heap usage: 5,151 allocs, 4,133 frees, 871,023 bytes allocated
==391567==
==391567== LEAK SUMMARY:
==391567==    definitely lost: 0 bytes in 0 blocks
==391567==    indirectly lost: 0 bytes in 0 blocks
==391567==      possibly lost: 0 bytes in 0 blocks
==391567==    still reachable: 295,703 bytes in 997 blocks
==391567==         suppressed: 0 bytes in 0 blocks
==391567== Reachable blocks (those to which a pointer was found) are not shown.
==391567== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==391567==
==391567== For lists of detected and suppressed errors, rerun with: -s
==391567== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```

(2) broken y4m file
Prepared by copying test/images/icon-64.yuv420p.y4m and replacing the "C420jpeg" item in the first line with "Cfoo" (invalid color space).

```
$ LD_LIBRARY_PATH=~/proj/imlib2/src/lib/.libs/:${LD_LIBRARY_PATH} IMLIB2_MODULE_PATH=~/proj/imlib2/src/modules/loaders/.libs/ valgrind --leak-check=yes /bin/feh ~/proj/imlib2/icon-64.yuv420p.y4m
==391699== Memcheck, a memory error detector
==391699== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==391699== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==391699== Command: /bin/feh /home/chemag/proj/imlib2/icon-64.yuv420p.y4m
==391699==
liby4m: Unrecognized colourspace foo
liby4m: Unable to read file's parameter list
liby4m: Failed to parse file header
***** Imlib2 Developer Warning ***** :
  This program is calling the Imlib call:

  imlib_image_set_changes_on_disk();

  With the parameter:

  image

  being NULL. Please fix your program.
***** Imlib2 Developer Warning ***** :
  This program is calling the Imlib call:

  imlib_image_get_width();

  With the parameter:

  image

  being NULL. Please fix your program.
***** Imlib2 Developer Warning ***** :
  This program is calling the Imlib call:

  imlib_image_get_height();

  With the parameter:

  image

  being NULL. Please fix your program.
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  1 (X_CreateWindow)
  Value in failed request:  0x0
  Serial number of failed request:  15
  Current serial number in output stream:  16
==391699==
==391699== HEAP SUMMARY:
==391699==     in use at exit: 303,880 bytes in 2,116 blocks
==391699==   total heap usage: 3,405 allocs, 1,289 frees, 670,313 bytes allocated
==391699==
==391699== LEAK SUMMARY:
==391699==    definitely lost: 0 bytes in 0 blocks
==391699==    indirectly lost: 0 bytes in 0 blocks
==391699==      possibly lost: 0 bytes in 0 blocks
==391699==    still reachable: 301,864 bytes in 2,095 blocks
==391699==         suppressed: 0 bytes in 0 blocks
==391699== Reachable blocks (those to which a pointer was found) are not shown.
==391699== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==391699==
==391699== For lists of detected and suppressed errors, rerun with: -s
==391699== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```
2023-03-21 06:48:53 +01:00
Chema Gonzalez be721b0335 imlib2: added loader for y4m files (uses liby4m and libyuv)
Implemented just `_load()` for now.

Summary:

Implements a loader for y4m images. Uses liby4m and libyuv.
Only implements the `_load()` function as of now

Tested:

```
$ ./configure
...
Configuration Options Summary:

Image loaders:
 Regular image loaders
  GIF.....................: yes
  HEIF....................: yes
  Y4M.....................: yes
...

$ make -j
...

$ sudo make install
...

$ feh image.y4m
-- image shows up
```

Tested with yuv420p, yuv422p, and yuv444p images.
2023-03-21 06:48:53 +01:00
Kim Woelders 531a053d11 HEIF loader: Add some debug 2023-03-21 06:48:53 +01:00
Kim Woelders d13bd60cc4 autofoo: More CLEANFILES 2023-03-21 06:22:54 +01:00
Kim Woelders 251172573d v1.11.0 2023-03-09 18:29:40 +01:00
Kim Woelders 82db0b0e29 test_grab: Debug tweak 2023-03-06 08:37:00 +01:00
Kim Woelders eae5c3bdbf x11_grab: Eliminate some overhead in scaled grabbing
Avoid call to XGetWindowAttributes(), X-error, call to XGetGeometry().
2023-03-06 06:59:04 +01:00
Kim Woelders 8af7975804 x11_grab: Various fixes in __imlib_GrabDrawableScaledToRGBA()
- Fix clipping to source.
- Fix error when mask from shape is requested but drawable is pixmap.
- Use queried drawable depth, not the context one.
  This eliminates the last usage of the context depth in the grabbing
  functions.
2023-03-06 06:59:04 +01:00
Kim Woelders 3b21892c77 x11_grab: Clear image pixels not actually grabbed
When using imlib_create[_scaled]_image_from_drawable() with non-zero
source offsets the output image could contain pixels either not set or
copied from uninitialised parts of intermediary pixmap.
2023-03-06 06:58:48 +01:00
Kim Woelders e41499a528 x11_grab: Rework clipping
Source clipping in imlib_copy_drawable_to_image() was broken and is
already dealt with in __imlib_GrabDrawableToRGBA().
Destination clipping has now been added.
2023-03-06 06:57:32 +01:00
Kim Woelders de79c704eb x11_grab: Move window/pixmap checking to separate function 2023-03-06 06:57:32 +01:00
Kim Woelders 3ab9498777 x11: Pass X11 context around by struct
A bit nicer, I think.
2023-03-06 06:53:06 +01:00
Kim Woelders 51d74520fc test_grab: Check get-mask-from-shape too
Since only pixmap grabbing is tested for now, testing mask handling
just checks that we don't do something silly (like getting shape from
pixmap).
2023-03-05 19:24:50 +01:00
Kim Woelders 567bb5aa75 test_grab: Add some tests for imlib_copy_drawable_to_image() 2023-03-05 19:24:13 +01:00
Kim Woelders 31c8f06215 test_grab: Update 2023-03-05 19:24:13 +01:00
Kim Woelders c47e18d571 imlib2_view: Add option to set background checkerboard field size 2023-03-01 11:03:15 +01:00
Kim Woelders 8d3539234d x11_grab: Drop now unused 1:1 scaling path in __imlib_GrabDrawableScaledToRGBA() 2023-02-19 22:36:46 +01:00
Kim Woelders 5ea6a407cf imlib_create_scaled_image_from_drawable(): Simplify call path
On 1:1 scaling call  __imlib_GrabDrawableToRGBA() directly instead of
going through __imlib_GrabDrawableScaledToRGBA().

This fixes 1:1 grabbing of pixmaps.
Non-1:1 pixmaps grabs are still not ok (window grabs are).
2023-02-19 22:35:58 +01:00
Kim Woelders 61097080e5 x11_grab: Eliminate unnecessary pixmap copy
Speeds up 1:1 scaling with non-zero source offset in
imlib_create_scaled_image_from_drawable().
2023-02-19 17:53:11 +01:00
Kim Woelders f54961f0cd x11_grab: Let __imlib_Grab..() return error instead of ok 2023-02-19 17:17:22 +01:00
Kim Woelders 9657d6a291 test_grab: Rearrange code 2023-02-19 16:57:20 +01:00
Kim Woelders 702432f5ed api: Oops - debug-- 2023-02-15 21:14:15 +01:00
Kim Woelders ce0ac1eeff Add imlib_save_image_fd()
#7
2023-02-15 18:31:19 +01:00
Kim Woelders 1ba40142f7 api: Minor simplification in error handling in save functions 2023-02-15 18:23:34 +01:00
Kim Woelders 81a1d1d929 api: Cosmetics around image save functions
Consistently use "file" for the file name in save functions as well as
in load functions.
2023-02-15 18:22:39 +01:00
Kim Woelders 3840c6636c api: Update documentation for imlib_get_error() 2023-02-15 18:22:39 +01:00