Commit Graph

1904 Commits

Author SHA1 Message Date
Kim Woelders 699fc2b8b5 Add missing CET (Control-flow Enforcement Technology) bits in asm code
Adding .note.gnu.property section data.

#23
2024-04-16 17:36:53 +02:00
Kim Woelders 0f378ef87f Add endbr32/64 instruction at the start of asm functions
Only do so when compiling with -fcf-protection (=> __CET__ is defined).

Inspired by:
004ff08738

Comment:
  Fixes SIGILL in tests on 11th gen intel (IBT)

#23
2024-04-13 15:36:12 +02:00
Kim Woelders e9a89df496 Some cleanups in asm code
Drop DO_MMX_ASM and DO_AMD64_ASM compile guards, handled by make.
Whitespace cleanups.
2024-04-13 09:59:07 +02:00
Kim Woelders af97c7c08e test_load_2: Add some more y4m test images
The ones from previous commit.
2024-04-12 17:10:23 +02:00
Chema Gonzalez e4644560f9 Y4M loader: add support for 10-bit 4:2:0
Current implementation just discards the last 2 bits.

Images generated using ffmpeg:
```
$ ffmpeg -i test/images/img-17x14.full_range.y4m -strict -1 -pix_fmt yuv420p10 -color_range full test/images/img-17x14.yuv420p10.full_range.y4m
$ ffmpeg -i test/images/img-8x8.full_range.y4m -strict -1 -pix_fmt yuv420p10 -color_range full test/images/img-8x8.yuv420p10.full_range.y4m
```

Tested:
```
$ src/bin/.libs/imlib2_view test/images/img-8x8.yuv420p10.full_range.y4m
$ feh test/images/img-8x8.yuv420p10.full_range.y4m
```
2024-04-12 17:10:02 +02:00
Kim Woelders a2e6beb37c test_load_2: Add full range color y4m image
Renamed the image as it isn't the usual 64x64 one.
2024-04-11 20:55:30 +02:00
Chema Gonzalez 98339a5708 Y4M loader: add support for full range color 2024-04-11 20:54:02 +02:00
Kim Woelders 33ab27e323 XPM loader: Major overhaul
Simplifying things somewhat, IMO.
2024-03-22 19:46:19 +01:00
Kim Woelders 13d311561d XPM loader: Fix some color table parsing errors
Correct values could be overwritten.
2024-03-22 17:11:05 +01:00
Kim Woelders 035239f5db test: Corrections for for libjxl-0.10 2024-03-22 16:58:47 +01:00
Kim Woelders f8a4510438 imlib2_load: Add crc32 printout
For comparing results before/after loader changes.
2024-03-22 16:58:25 +01:00
Kim Woelders 1bc95a8631 XPM loader: Fix potential segv on malformed file
Introduced by 6ea4cf7e66, in v1.6.0.

#22
2024-03-21 05:30:29 +01:00
Kim Woelders a860e34b19 v1.12.2 2024-02-03 17:00:34 +01:00
Kim Woelders 15ab46d03e savers: Fix error returns
The savers did not return meaningful error codes in many cases.
2024-01-04 05:05:04 +01:00
Kim Woelders 66f39b6556 TIFF loader: Properly suppress messages from libtiff 2024-01-03 20:05:26 +01:00
Kim Woelders c0d2bce375 JPG saver: Fix error path
jpeg_finish_compress() may trigger longjmp() resulting in infinite loop.
2024-01-02 20:10:51 +01:00
Kim Woelders 7614a8d9e7 PNG saver: Avoid potential issues around setjmp/longjmp
Allocate the row buffer before calling setjmp().

See also #21.
2024-01-02 19:23:07 +01:00
Kim Woelders 30107247b6 Change formatting style
No tabs, more like K&R.
Also switch to indent 2.2.13.
2024-01-02 09:47:51 +01:00
NRK cd8c225ed0 Y4M loader: don't fail on newline
regression introduce in c08ae5f. if the color space was the last thing
in the header than it would be followed by a newline rather than space.

peek to ensure next char is either ' ' or newline to avoid falsly
matching problematic colorspaces. this will also work for other cases
like "mono-whatever" instead of working just for "420", "422" and "444".

also change the return code to unsupported instead of corrupted in these
cases.
2024-01-02 06:25:52 +01:00
Kim Woelders 2d210b9af3 Y4M loader: Fix warning in non-debug build
Also simplify error text handling.
2024-01-01 22:01:55 +01:00
Kim Woelders 820c5b2ebe PNG loader: Properly suppress messages from libpng 2024-01-01 21:47:09 +01:00
NRK 3e8c01bef6 PNG saver: avoid double-free on write errors
png_write_end may trigger a write error which sets off longjmp - which
then goes ahead and tries to free `misc.data` again. move the
png_write_end call before `quit` label to avoid this.

to reproduce, build scrot and imlib2 with ASan and then try to save a
screenshot to /dev/full (`scrot -o /dev/full`).
2024-01-01 17:37:53 +01:00
Kim Woelders 9ad4769e0a ANI loader: Avoid debug line when image does not have proper signature 2024-01-01 16:57:48 +01:00
Kim Woelders 06314730ff Y4M loader: Avoid use of sscanf() in frame rate parsing
Input data is not necessarily nul-terminated.
Simplify frame rate parsing in the process.

Use of sscanf() should also be eliminated when compiling with debug -
some other day.

Based on patch by NRK.
2024-01-01 16:57:48 +01:00
Kim Woelders 4109f54c4a test_load_2: Check some more y4m files 2024-01-01 16:57:36 +01:00
Kim Woelders 6ff2ac0815 Consistently use #if IMLIB2_DEBUG (not #ifdef) 2023-12-28 16:10:19 +01:00
Kim Woelders 1bdc69a6a1 Y4M loader: Guard some debug code properly
str is effectively unused when compiling without debug.

Also, don't cast away const and drop some unnecessary casts
2023-12-28 16:08:53 +01:00
Chema Gonzalez 96e04dd8cf Y4M loader: add error messages on parsing errors
Tested:

Image with 420p10 color space.

Before:
```
$ IMLIB2_DEBUG=31:0 imlib2_view out.y4m
...
LOAD: __imlib_FindBestLoader: fmt='y4m': /usr/local/lib/imlib2/loaders/y4m.so
IMG : __imlib_LoadImageWrapper: fmt='y4m' file='out.y4m'(out.y4m) frame=1, imm=1
IMG : __imlib_LoadImageWrapper: y4m : out.y4m: Elapsed time: 0.010 ms
...
```

After:
```
$ IMLIB2_DEBUG=31:0 imlib2_view out.y4m
...
LOAD: __imlib_FindBestLoader: fmt='y4m': /usr/local/lib/imlib2/loaders/y4m.so
IMG : __imlib_LoadImageWrapper: fmt='y4m' file='out.y4m'(out.y4m) frame=1, imm=1
LDR-y4m: y4m__parse_params: unknown C: 'C420p10'
IMG : __imlib_LoadImageWrapper: y4m : out.y4m: Elapsed time: 0.010 ms
...
```
2023-12-28 13:02:38 +01:00
Chema Gonzalez c08ae5fdfb Y4M loader: fix C option analysis
ffmpeg has added multiple color space types that start with "420",
"422", and "444" (e.g. "420p16").

We cannot parse them as 8-bit color. Let's fail earier.
2023-12-27 15:09:17 -08:00
Chema Gonzalez a780b47892 Y4M loader: fix support for unexpected framerates
Add support for F1:1 images, and in general with any framerate ratio.

Also added "F60:1" mode support.

Tested:

Added a test frame with a 1:1 framerate. This is produced by ffmpeg when
converting from another image format.
```
$ ffmpeg -i in.265 out.y4m
$ head -1 out.y4m
YUV4MPEG2 W490 H490 F1:1 Ip A0:0 C420jpeg XYSCSS=420JPEG XCOLORRANGE=FULL
```

Before
```
$ imlib2_view -v ./test/images/icon-64.framerate_1_1.y4m
Show  0: './test/images/icon-64.framerate_1_1.y4m'
*** Error -2:'Imlib2: No loader for file format' loading image: './test/images/icon-64.framerate_1_1.y4m'
```

After:
```
$ IMLIB2_DEBUG=31:0 IMLIB2_LOADER_PATH=./src/modules/loaders/.libs/ LD_LIBRARY_PATH=./src/lib/.libs:${LD_LIBRARY_PATH} ./src/bin/imlib2_view -v ./test/images/icon-64.framerate_1_1.y4m
Show  0: './test/images/icon-64.framerate_1_1.y4m'
IMG : __imlib_FindCachedImage: './test/images/icon-64.framerate_1_1.y4m' frame 1
IMG :  got none
LOAD: __imlib_FindBestLoader: file='./test/images/icon-64.framerate_1_1.y4m' fmt='(null)'
FILE: __imlib_FileExtension: './test/images/icon-64.framerate_1_1.y4m'
FILE: __imlib_FileIsFile: './src/modules/loaders/.libs//y4m.so'
FILE: __imlib_FileStat: './src/modules/loaders/.libs//y4m.so'
LOAD: __imlib_ProduceLoader: ./src/modules/loaders/.libs//y4m.so
LOAD: __imlib_LookupKnownLoader: 'y4m' -> 'y4m': 0x524d50
LOAD: __imlib_FindBestLoader: fmt='y4m': ./src/modules/loaders/.libs//y4m.so
IMG : __imlib_LoadImageWrapper: fmt='y4m' file='./test/images/icon-64.framerate_1_1.y4m'(./test/images/icon-64.framerate_1_1.y4m) frame=1, imm=1
IMG : __imlib_LoadImageWrapper: y4m : ./test/images/icon-64.framerate_1_1.y4m: Elapsed time: 18.099 ms
IMG : __imlib_AddImageToCache: 0x5139e0: './test/images/icon-64.framerate_1_1.y4m' frame 1
```
2023-12-27 14:41:59 -08:00
Kim Woelders 3106fbd0d2 x11_grab: Remove some obsolete code
Should have been removed as part of 8af7975804.
2023-09-30 21:41:27 +02:00
Kim Woelders 45d58cc268 test_save: Update crcs for jxl saver (libjxl 0.8.0)
Also add a couple of missing ifdefs.
2023-09-25 05:21:26 +02:00
Kim Woelders 9198db2536 v1.12.1 2023-09-21 16:45:53 +02:00
Kim Woelders 1bd9920c07 x11_grab: Use correct depth when grabbing
Use queried drawable depth, not the context one.

Fixes grabbing of bitmaps (now using intended colormap) in the
usual 24 bit depth case.
May fix other issues as well(?).

Broken by 3ab9498777 (in v1.11.0).
2023-09-21 09:15:00 +02:00
Kim Woelders 3fd4347cfa imlib2_grab, imlib2_view: Unset context colormap
Should normally not be set when grabbing.
2023-09-21 06:45:42 +02:00
Kim Woelders be9ac449e7 loaders: Fix CPPFLAGS order
Patch by Omar Polo:

while upgrading the OpenBSD package I've come across a weird issue.
Due to the order of the flags, the heif module was loading the system'
version of Imlib2_loader.h (in /usr/local/include) instead of the one
from the tarball.  This caused failure since the previous version
(1.11.0) didn't had IMLIB_LOADER_INEX.
2023-09-04 17:01:33 +02:00
Kim Woelders f16bb23864 RAW loader: Don't unload loader
Running with valgrind or asan seems to show that unloading/reloading the
loader causes memory leaks. Not dlcose()'ing the module avoids this.
2023-09-03 20:16:12 +02:00
Kim Woelders 570c50d75a test_scale: MMX scaling is disabled 2023-09-03 17:11:21 +02:00
Kim Woelders 57403f2ec3 test_save: Fix for jxl loader on ix86
libjxl apparently behaves differently for ix86 and x86_64.
2023-09-03 17:11:21 +02:00
Kim Woelders 03cbf75a96 test_load_2: Add forgotten xeyes.png 2023-09-03 17:11:21 +02:00
Kim Woelders 1e5040e8e7 loaders: Fix build with -m32 --enable-debug 2023-09-03 17:11:21 +02:00
Kim Woelders 687e13b290 loading: Call module exit function also when not dlclosing module on unload
The proper thing to do.
Does not affect any of the current loaders.
2023-09-03 16:34:50 +02:00
Kim Woelders 66f48df4cf scaling: MMX asm scaling causes segv, disable for now
Broken in v1.12.0 by ee61df6877 (pointers
to indices), __imlib_Scale_mmx_AARGBA() needs to be fixed.
2023-09-03 10:32:10 +02:00
Kim Woelders 74dae151cd Fix some clang complaints 2023-08-24 19:07:43 +02:00
Kim Woelders 5300f19575 v1.12.0 2023-08-17 16:41:56 +02:00
Chema Gonzalez 0b08655e40 Y4M loader: add support for images with unexpected aspects
Tested:

Added a new test case with an unknown aspect (A368:375).
2023-08-16 12:12:53 +02:00
Kim Woelders a22b9b88c0 test_scale: Exercise non-AA path too 2023-08-09 20:34:30 +02:00
Kim Woelders 4f17d66965 test_scale: Update for new scaling (re-applied) 2023-08-09 17:58:20 +02:00
Kim Woelders d6b86f307e scaling: Correct scaling up - take 2
When scaling up (with AA) it worked sort of like there was a 1 pixel
border right and bottom.
2023-08-09 17:58:20 +02:00
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