This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 76f73128753ed19cefe7e80e55520edccbb01b9a (commit) via ade7565f6c0e487071582b09196ac36c7fa1e4cf (commit) from 93832f616ef3ea2dde888cf8e0b7e1a2da077d06 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/76f73128753ed19cefe7e80e55520edccbb01...
commit 76f73128753ed19cefe7e80e55520edccbb01b9a Author: Cyril Hrubis metan@ucw.cz Date: Sat May 10 14:50:37 2014 +0200
loaders: JPG: Fix segfault in load_cmyk()
Fixes typo in number of scanlines to load from a CMYK jpeg.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index a0eabd97..da4cf48f 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -113,7 +113,7 @@ static int load_cmyk(struct jpeg_decompress_struct *cinfo, GP_Context *ret, uint32_t y = cinfo->output_scanline;
JSAMPROW addr = (void*)GP_PIXEL_ADDR(ret, 0, y); - jpeg_read_scanlines(cinfo, &addr, 4); + jpeg_read_scanlines(cinfo, &addr, 1);
unsigned int i; uint8_t *buf = GP_PIXEL_ADDR(ret, 0, y);
http://repo.or.cz/w/gfxprim.git/commit/ade7565f6c0e487071582b09196ac36c7fa1e...
commit ade7565f6c0e487071582b09196ac36c7fa1e4cf Author: Cyril Hrubis metan@ucw.cz Date: Sat May 10 14:49:53 2014 +0200
tests: loaders: Add jpeg CMYK loader test.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/loaders/.gitignore b/tests/loaders/.gitignore index f6863aaf..3ef73f19 100644 --- a/tests/loaders/.gitignore +++ b/tests/loaders/.gitignore @@ -6,6 +6,7 @@ PNG PNM PPM PCX +JPG SaveAbort.gen SaveLoad.gen ZIP diff --git a/tests/loaders/JPG.c b/tests/loaders/JPG.c new file mode 100644 index 00000000..67c34dd4 --- /dev/null +++ b/tests/loaders/JPG.c @@ -0,0 +1,141 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2014 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Context.h> +#include <core/GP_GetPutPixel.h> +#include <loaders/GP_Loaders.h> + +#include "tst_test.h" + +static int test_load_JPG(const char *path) +{ + GP_Context *img; + + errno = 0; + + img = GP_LoadJPG(path, NULL); + + if (img == NULL) { + switch (errno) { + case ENOSYS: + tst_msg("Not Implemented"); + return TST_SKIPPED; + default: + tst_msg("Got %s", strerror(errno)); + return TST_FAILED; + } + } + + /* + * TODO: check correct data. + */ + + GP_ContextFree(img); + + return TST_SUCCESS; +} + +static int test_save_JPG(GP_PixelType pixel_type) +{ + GP_Context *ctx; + int ret; + + ctx = GP_ContextAlloc(100, 100, pixel_type); + + if (ctx == NULL) { + tst_msg("Failed to allocate context"); + return TST_UNTESTED; + } + + errno = 0; + + ret = GP_SaveJPG(ctx, "/dev/null", NULL); + + if (ret == 0) { + tst_msg("Saved successfully"); + GP_ContextFree(ctx); + return TST_SUCCESS; + } + + switch (errno) { + case ENOSYS: + tst_msg("Not Implemented"); + GP_ContextFree(ctx); + return TST_SKIPPED; + default: + tst_msg("Failed and errno is not ENOSYS (%i)", errno); + GP_ContextFree(ctx); + return TST_FAILED; + } +} + +const struct tst_suite tst_suite = { + .suite_name = "JPEG", + .tests = { + /* JPEG loader tests */ + {.name = "JPEG Load 100x100 CMYK", + .tst_fn = test_load_JPG, + .res_path = "data/jpeg/valid/100x100-cmyk-red.jpeg", + .data = "100x100-cmyk-red.jpeg", + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + + {.name = "JPEG Load 100x100 RGB", + .tst_fn = test_load_JPG, + .res_path = "data/jpeg/valid/100x100-red.jpeg", + .data = "100x100-red.jpeg", + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + + {.name = "JPEG Load 100x100 G8", + .tst_fn = test_load_JPG, + .res_path = "data/jpeg/valid/100x100-grayscale-white.jpeg", + .data = "100x100-grayscale-white.jpeg", + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + + {.name = "JPEG Load 100x100 G8", + .tst_fn = test_load_JPG, + .res_path = "data/jpeg/valid/100x100-grayscale-black.jpeg", + .data = "100x100-grayscale-black.jpeg", + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + + /* JPEG save tests */ + {.name = "JPEG Save 100x100 G8", + .tst_fn = test_save_JPG, + .data = (void*)GP_PIXEL_G8, + .flags = TST_CHECK_MALLOC}, + + {.name = "JPEG Save 100x100 RGB888", + .tst_fn = test_save_JPG, + .data = (void*)GP_PIXEL_RGB888, + .flags = TST_CHECK_MALLOC}, + + {.name = "JPEG Save 100x100 BGR888", + .tst_fn = test_save_JPG, + .data = (void*)GP_PIXEL_BGR888, + .flags = TST_CHECK_MALLOC}, + + {.name = NULL}, + } +}; diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile index 890e5761..fb56086d 100644 --- a/tests/loaders/Makefile +++ b/tests/loaders/Makefile @@ -1,11 +1,12 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk
-CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c ZIP.c GIF.c IO.c PNM.c PCX.c +CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c ZIP.c GIF.c IO.c PNM.c PCX.c+ JPG.c GENSOURCES=SaveLoad.gen.c SaveAbort.gen.c
APPS=loaders_suite PNG PBM PGM PPM PNM SaveLoad.gen SaveAbort.gen ZIP GIF PCX- IO + IO JPG
include ../tests.mk
diff --git a/tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg b/tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg new file mode 100644 index 00000000..cecf0700 Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg differ diff --git a/tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg b/tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg new file mode 100644 index 00000000..f0fd04bf Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg differ diff --git a/tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg b/tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg new file mode 100644 index 00000000..37ac78ff Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg differ diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt index d36b2a3e..adf857ea 100644 --- a/tests/loaders/test_list.txt +++ b/tests/loaders/test_list.txt @@ -1,6 +1,7 @@ # Loaders testsuite loaders_suite PNG +JPG GIF PBM PGM
-----------------------------------------------------------------------
Summary of changes: libs/loaders/GP_JPG.c | 2 +- tests/loaders/.gitignore | 1 + tests/loaders/{GIF.c => JPG.c} | 87 ++++++++++++++++++-- tests/loaders/Makefile | 5 +- .../loaders/data/jpeg/valid/100x100-cmyk-red.jpeg | Bin 0 -> 454 bytes .../data/jpeg/valid/100x100-grayscale-black.jpeg | Bin 0 -> 367 bytes .../data/jpeg/valid/100x100-grayscale-white.jpeg | Bin 0 -> 367 bytes tests/loaders/test_list.txt | 1 + 8 files changed, 86 insertions(+), 10 deletions(-) copy tests/loaders/{GIF.c => JPG.c} (53%) create mode 100644 tests/loaders/data/jpeg/valid/100x100-cmyk-red.jpeg create mode 100644 tests/loaders/data/jpeg/valid/100x100-grayscale-black.jpeg create mode 100644 tests/loaders/data/jpeg/valid/100x100-grayscale-white.jpeg
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.