diff --git a/NEWS.md b/NEWS.md index 2e8ac897..40851abd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ -2024-06- - 0.25.3 +2024-06-05 - 0.25.3 ---------- - added gpujpeg_color_space_by_name +- addeg gpujpeg_print_pixel_format 2024-04-09 - 0.25.2 ---------- diff --git a/libgpujpeg/gpujpeg_common.h b/libgpujpeg/gpujpeg_common.h index 8b3a5399..cc9de122 100644 --- a/libgpujpeg/gpujpeg_common.h +++ b/libgpujpeg/gpujpeg_common.h @@ -629,6 +629,9 @@ gpujpeg_color_space_get_name(enum gpujpeg_color_space color_space); GPUJPEG_API enum gpujpeg_pixel_format gpujpeg_pixel_format_by_name(const char *name); +GPUJPEG_API void +gpujpeg_print_pixel_formats(); + /** Returns color space by string name */ GPUJPEG_API enum gpujpeg_color_space gpujpeg_color_space_by_name(const char *name); diff --git a/src/gpujpeg_common.c b/src/gpujpeg_common.c index 5eea3b83..03886c5c 100644 --- a/src/gpujpeg_common.c +++ b/src/gpujpeg_common.c @@ -1894,9 +1894,21 @@ gpujpeg_pixel_format_by_name(const char *name) return gpujpeg_pixel_format_desc[i].pixel_format; } } + if (strcmp(name, "help") == 0) { + gpujpeg_print_pixel_formats(); + } return GPUJPEG_PIXFMT_NONE; } +void +gpujpeg_print_pixel_formats(void) +{ + printf(" u8 (grayscale) 420-u8-p0p1p2 (planar 4:2:0)\n" + " 422-u8-p1020 (eg. UYVY) 422-u8-p0p1p2 (planar 4:2:2)\n" + " 444-u8-p012 (eg. RGB) 444-u8-p0p1p2 (planar 4:4:4)\n" + " 4444-u8-p0123 (RGBA)\n"); +} + enum gpujpeg_color_space gpujpeg_color_space_by_name(const char* name) { diff --git a/src/main.c b/src/main.c index 2ec02e57..8dc10a1c 100644 --- a/src/main.c +++ b/src/main.c @@ -43,15 +43,6 @@ #define USE_IF_NOT_NULL_ELSE(cond, alt_val) (cond) ? (cond) : (alt_val) -static void -print_pixel_formats(void) -{ - printf(" u8 (grayscale) 420-u8-p0p1p2 (planar 4:2:0)\n" - " 422-u8-p1020 (eg. UYVY) 422-u8-p0p1p2 (planar 4:2:2)\n" - " 444-u8-p012 (eg. RGB) 444-u8-p0p1p2 (planar 4:4:4)\n" - " 4444-u8-p0123 (RGBA)\n"); -} - static void print_help(void) { @@ -64,7 +55,7 @@ print_help(void) printf(" -s, --size set input image size in pixels, e.g. 1920x1080\n" " -f, --pixel-format set input/output image pixel format, one of the\n" " following (example in parenthesis):\n"); - print_pixel_formats(); + gpujpeg_print_pixel_formats(); printf("\n" " -c, --colorspace set input/output image colorspace, e.g. rgb, ycbcr-jpeg (full\n" " range BT.601), ycbcr-bt601 (limited 601), ycbcr-bt709 (limited)\n" @@ -217,7 +208,7 @@ parse_pixel_format(const char *arg) { if (strcmp(arg, "help") == 0) { printf("Available pixel formats:\n"); - print_pixel_formats(); + gpujpeg_print_pixel_formats(); return GPUJPEG_PIXFMT_NONE; } const enum gpujpeg_pixel_format ret = gpujpeg_pixel_format_by_name(arg);