Skip to content

Commit

Permalink
added gpujpeg_print_pixel_formats
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPulec committed Jun 5, 2024
1 parent f3451e1 commit 1da700b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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
----------
Expand Down
3 changes: 3 additions & 0 deletions libgpujpeg/gpujpeg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions src/gpujpeg_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
13 changes: 2 additions & 11 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1da700b

Please sign in to comment.