Commit Graph

150 Commits

Author SHA1 Message Date
Kim Woelders 4109f54c4a test_load_2: Check some more y4m files 2024-01-01 16:57:36 +01: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 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 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
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
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
NRK cf5b462d92 file: Remove unused functions some more 2023-07-05 18:55:05 +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 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 41be1c88f8 test_scale: Update for new scaling 2023-06-24 17:32:39 +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
Kim Woelders 38b422b8de test: Add basic qoi checks 2023-06-20 13:59:55 +02:00
Kim Woelders e9de0b1d38 test: Fix pr_info() when not printing to stdout 2023-05-20 08:42:05 +02:00
Kim Woelders a55f36133d Add JXL saver
old/legacy-imlib2#9
2023-04-30 20:02:15 +02: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
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
Kim Woelders 82db0b0e29 test_grab: Debug tweak 2023-03-06 08:37:00 +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 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 9657d6a291 test_grab: Rearrange code 2023-02-19 16:57:20 +01:00
Kim Woelders ce0ac1eeff Add imlib_save_image_fd()
old/legacy-imlib2#7
2023-02-15 18:31:19 +01:00
Guilherme Janczak 84314f013f
remove bad unused function
__imlib_FileCanRead() suffers from TOCTTOU issues. The file behind the
path it takes as a parameter can change while the function executes, and
also between the function's return and the caller's use of the path.

The function is also unused, so just delete it.
2023-02-04 04:17:57 +00:00
Kim Woelders 1ca706b79a test: test_save: Check that files are written and ok 2023-01-22 17:20:01 +01:00
Kim Woelders 87bd2fa58a test: test_save: Trivial changes 2023-01-22 17:19:48 +01:00
Kim Woelders 9b9abcdc1e test: Introduce image_get_crc32() 2023-01-22 17:14:52 +01:00
Kim Woelders 0f27c5e6ec test: Add some pam tests 2023-01-12 22:14:03 +01:00
Kim Woelders 8fc05e400e test: Add a few tests for obscure pnm formats 2023-01-12 22:13:54 +01:00
Kim Woelders 8416d2b244 test: test_load_2: Check frame 0/1 loading too 2022-11-15 11:49:47 +01:00
Kim Woelders d4f604230a test: test_load: Quit when loading primary image fails 2022-10-31 07:17:34 +01:00
Kim Woelders ed89effcf3 api: error_return adjustments
- Drop imlib_load_image_fde()
- Remove error_return from imlib_load_image_mem()

It is becoming somewhat messy having functions with and without error
returns, so drop error returns in API functions added since v1.9.1.
Use imlib_get_error() to get the error instead.
2022-09-30 06:08:29 +02:00
Kim Woelders 43c54e1345 Introduce imlib_get_error()
Some of the image loading functions have a version with an error_return,
and some not.
With imlib_get_error() it is now possible to fetch the load error for
any image loading function call.
2022-09-30 06:04:27 +02:00
Kim Woelders 51906190a1 image: Don't munmap external memory
When loading image from memory (imlib_load_image[_frame]_mem()) the
memory was unintentionally munmapped after loading.

This would cause trouble if loading multiple times from the same mmap'ed
memory, but not from malloced memory as the munmap would then just fail
silently.

old/legacy-imlib2#1
2022-09-29 13:48:46 +02:00
Kim Woelders 9f9779e698 test: Re-generate test images with recent tool/library versions
Converters and library versions used:
 convert                ImageMagick-6.9.12.64
 cjxl                   libjxl-0.7.0
 heif-enc               libheif-1.13.0
 opj2_compress          openjpeg2-2.5.0
 pnmtopnm,pamtoxvmini   netpbm-10.99.00
2022-09-28 18:19:07 +02:00
Kim Woelders 87bcf92524 Includes tweaks
- Drop unneeded errno.h includes.
- Include stdarg.h only where needed.
2022-09-28 18:19:07 +02:00
Kim Woelders af587674a4 Introduce imlib_load_image_mem()
For loading images from memory.
2022-07-10 12:51:15 +02:00
Kim Woelders cea1207efe Introduce imlib_load_image_fde()
Same as imlib_load_image_fd() but with error return.
2022-07-07 12:59:40 +02:00
Kim Woelders 90824fc2fd test: Add test_misc 2022-06-24 21:33:23 +02:00
Kim Woelders 416f847dc3 Introduce strsplit() 2022-06-23 07:36:23 +02:00