Commit Graph

1855 Commits

Author SHA1 Message Date
Kim Woelders 4d5b1413b1 scaling: Improve non-AA scale-up case
Make source sampling more evenly distributed.
Most visible for small source dimensions.
2023-08-09 17:58:05 +02:00
Kim Woelders 29397453e4 scaling: Various trivial changes 2023-08-09 17:58:05 +02:00
Chema Gonzalez a88b95c289 Y4M loader: fix support for 420 colorspaces
Includes:
* add support for 420mpeg2 (ffmpeg-only)
* add example for 420mpeg2
* add examples for 420, 420paldv
* fix 420jpeg example
2023-08-03 12:34:30 +02:00
Chema Gonzalez 63106616b9 test_load2: make error messages more descriptive
Tested:

Before:
```
$ IMLIB2_LOADER_PATH=../src/modules/loaders/.libs ./test_load_2
...
[ RUN      ] LOAD2.load_1
test_load_2.cpp:121: Failure
Expected equality of these values:
  crc
    Which is: 671661664
  tii[i].crc
    Which is: 4016720483
test_load_2.cpp:128: Failure
Expected equality of these values:
  crc
    Which is: 671661664
  tii[i].crc
    Which is: 4016720483
test_load_2.cpp:135: Failure
Expected equality of these values:
  crc
    Which is: 671661664
  tii[i].crc
    Which is: 4016720483
[  FAILED  ] LOAD2.load_1 (70 ms)
...
```

After:
```
$ IMLIB2_LOADER_PATH=../src/modules/loaders/.libs ./test_load_2
...
test_load_2.cpp:122: Failure
Expected equality of these values:
  crc
    Which is: 671661664
  tii[i].crc
    Which is: 4016720483
wrong crc file: ./images/icon-64.xpm expected: 4016720483 actual: 671661664
test_load_2.cpp:131: Failure
Expected equality of these values:
  crc
    Which is: 671661664
  tii[i]. crc
    Which is: 4016720483
wrong crc file: ./images/icon-64.xpm expected: 4016720483 actual: 671661664
test_load_2.cpp:142: Failure
Expected equality of these values:
  crc
    Which is: 671661664
  tii[i]. crc
    Which is: 4016720483
wrong crc file: ./images/icon-64.xpm expected: 4016720483 actual: 671661664
[  FAILED  ] LOAD2.load_1 (69 ms)
...
```
2023-08-03 12:34:30 +02:00
Kim Woelders 310e9e162d Revert "test_scale: Update for new scaling"
This reverts commit 41be1c88f8.
2023-07-30 17:33:44 +02:00
Kim Woelders fae1423025 Revert "scaling: Correct scaling up"
Correction is not correct :(

This reverts commit 58f2fcb4c7.
2023-07-30 17:33:14 +02:00
Kim Woelders 9d5f704036 image cache: Rework cleanup
Eliminates a nested loop in __imlib_CurrentCacheSize().

Only add to cached size if image data are loaded.
2023-07-19 21:44:04 +02:00
Kim Woelders 26dd602fa0 image cache: Drop redundant cleanup
Already done in __imlib_CurrentCacheSize().
2023-07-19 21:44:04 +02:00
Kim Woelders 2474de6f94 image cache: Avoid negative refcounts
Presumably unintended, obscures things.
2023-07-19 21:44:04 +02:00
Kim Woelders 173edae4bf image: Fix preservation of alpha chanel flag in imlib_clone_image()
#17:

As per subject, the imlib_clone_image() function no longer preserves
the alpha channel value since imlib2 1.10.0.

This bug report was initially filed by Niko Tyni in Debian's bug tracker.
If you follow the subsequent link you will also find a test program that
demonstrates the regression.

https://bugs.debian.org/1041406

This upstream change is most likely the root cause of the problem

b39d33c800

It looks like an oversight where other functions were adapted
to the new alpha channel implementation, but imlib_clone_image() remains
unchanged and only copies the flags and not the new alpha byte.
2023-07-19 18:50:11 +02:00
NRK 50295779a1 introduce imlib_image_decache_file()
Fixes: #16
2023-07-07 18:49:08 +02:00
Kim Woelders a1ea31e070 image: Use sub-second time info when available 2023-07-07 13:14:35 +02:00
NRK cf5b462d92 file: Remove unused functions some more 2023-07-05 18:55:05 +02:00
Kim Woelders 70bd7e3488 TIFF loader: Slightly more strict signature check
Avoid starting libtiff on various raw image types.
2023-07-02 21:33:39 +02:00
Kim Woelders 59ab21a580 Add new raw loader
#10
2023-07-02 21:33:39 +02:00
Kim Woelders 1afc1302c9 test_load: Minor fix in debug message 2023-07-02 21:33:20 +02:00
Kim Woelders efd0bccb92 test: Bypass wrappers when running tests 2023-07-02 21:24:40 +02:00
Kim Woelders 31b50aee15 image: Fix potentially using incorrect file size - fixup
Close opened file if we don't like it (zero size, directory).
2023-07-02 21:24:40 +02:00
Kim Woelders 595d0a322d file: Remove a couple of unused functions
__imlib_IsRealFile() and __imlib_FileExists() are not used.
__imlib_FileStat() can now be private.
2023-06-26 08:13:25 +02:00
Kim Woelders aec432b3ce image: Fix potentially using incorrect file size
During load from file we would do stat(file), then fopen(file),
and assume the stat'ed size corresponds to the fopen'ed file.
However, the file may be changed between stat() and fopen(), which may
cause trouble.
This should now be fixed by always using fstat() on the opened file
descriptor.
2023-06-26 08:13:25 +02:00
Kim Woelders f1fcc4bfed image: Fix missing munmap() when using imlib_load_image_fd() 2023-06-25 12:01:47 +02:00
Kim Woelders 41be1c88f8 test_scale: Update for new scaling 2023-06-24 17:32:39 +02:00
Kim Woelders 58f2fcb4c7 scaling: Correct scaling up
When scaling up it worked like there was a 1 pixel border right and
bottom.

This change may affect applications that rely on the old behavior.
Setting the environment variable IMLIB2_LEGACY_SCALING to any value will
make imlib2 use the old algorithm.

When using e16 with the new (default) algorithm a few themes have
incorrectly rendered elements (unintended window border fading, opaque
pager highligt frame, more?).

Hopefully this change should go mostly unnoticed but if it turns out it
causes grief the default will probably have to be changed back.
2023-06-24 17:32:05 +02:00
Kim Woelders a72fe3796b scaling: Minor refactoring 2023-06-24 17:01:15 +02:00
Kim Woelders 166de6a93e scaling: Cosmetics 2023-06-24 17:00:21 +02:00
Kim Woelders ee61df6877 scaling: Change ypoints[] from pointers to indices
Now the calculation of ypoints[] and xpoints[] can be done by the same
function and we can avoid some essentially duplicated code.
May be slightly less optimal although I doubt it makes any significant
difference.
2023-06-24 16:58:42 +02:00
Kim Woelders eafaa11ff3 scaling: Simplify scaling points calculation (eliminate j) 2023-06-24 16:58:42 +02:00
Kim Woelders a75fc4c5c8 scaling: Cosmetics (comments) 2023-06-24 16:57:56 +02:00
Kim Woelders 61a180f3b0 scaling: Move scaling function call sequence into common __imlib_Scale() 2023-06-24 09:42:58 +02:00
Kim Woelders 5c0c98428d scaling: Correct scaleinfo array length
The +1 length may have been used in the old OLD_SCALE_DOWN case.
2023-06-24 09:42:58 +02:00
Kim Woelders 41a6517319 scaling: Unifdef OLD_SCALE_DOWN
And adjust some comments.
2023-06-24 09:42:58 +02:00
Kim Woelders fea92d74b5 test_scale: Test scaling some more 2023-06-24 09:42:58 +02:00
NRK f8bb5eb256 test_load: allow y4m memory loading
the new y4m loader can load from memory.
2023-06-22 19:49:27 +02:00
NRK 336e9374ff Y4M loader: use custom y4m parser
avoid dependency on liby4m, which has some quality issues and isn't
available on any distros according to repology.

additionally, the new loader now supports:

* loading from memory
* multi-frame images
* mono colourspace y4m images

Fixes: #13
2023-06-21 17:49:20 +02:00
Kim Woelders 38b422b8de test: Add basic qoi checks 2023-06-20 13:59:55 +02:00
NRK bb53bcfb9d loading: check for alloc failure
free(NULL) is no-op, so goto bail works here.
2023-06-20 13:55:12 +02:00
NRK 3dfef024c9 loading: add some debug logs 2023-06-20 13:55:12 +02:00
Kim Woelders 36c1daef60 TGA loader: Fix TGA v2.0 signature check
With normal struct padding the footer pointer was not calculated correctly.
Now also checking the last two bytes ('.', '\0').
2023-06-20 10:56:06 +02:00
Kim Woelders 924bf0c527 Loaders: Static constify some data that may as well be 2023-06-18 07:12:51 +02:00
NRK 28d9c6b7d2 Y4M loader: check file size before magic check 2023-06-18 07:02:10 +02:00
NRK 29d3204a16 QOI loader: use memcmp for magic and endmarker check
original code didn't use memcmp to avoid libc, but that shouldn't be an
issue in imlib2.
2023-06-16 06:41:36 +02:00
NRK 3bcd40dd16 QOI loader: fix build on non-gnu compilers 2023-06-16 06:37:52 +02:00
Kim Woelders bcf88d4431 QOI loader: Add progress calback, indent, cosmetics 2023-06-15 23:03:52 +02:00
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