Skip to content

Commit a1a048f

Browse files
committed
adjust_pixel_format: refuse 2 channels + simplify
1 parent 5eaa309 commit a1a048f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/gpujpeg_reader.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,8 @@ static enum gpujpeg_pixel_format
15511551
adjust_pixel_format(struct gpujpeg_parameters * param, struct gpujpeg_image_parameters * param_image) {
15521552
assert(param_image->pixel_format == GPUJPEG_PIXFMT_AUTODETECT || param_image->pixel_format == GPUJPEG_PIXFMT_STD ||
15531553
param_image->pixel_format == GPUJPEG_PIXFMT_NATIVE);
1554+
GPUJPEG_ASSERT(param->comp_count != 2);
1555+
15541556
if ( param->comp_count == 1 ) {
15551557
return GPUJPEG_U8;
15561558
}
@@ -1572,13 +1574,11 @@ adjust_pixel_format(struct gpujpeg_parameters * param, struct gpujpeg_image_para
15721574
return GPUJPEG_444_U8_P0P1P2;
15731575
}
15741576

1575-
1576-
switch (param->comp_count) {
1577-
case 3: return GPUJPEG_444_U8_P012;
1578-
case 4:
1579-
return param_image->pixel_format == GPUJPEG_PIXFMT_NO_ALPHA ? GPUJPEG_444_U8_P012 : GPUJPEG_4444_U8_P0123;
1580-
default: GPUJPEG_ASSERT(0 && "Unhandled JPEG internal component count detected!");
1577+
if ( param->comp_count == 3 ) {
1578+
return GPUJPEG_444_U8_P012;
15811579
}
1580+
assert(param->comp_count == 4);
1581+
return param_image->pixel_format == GPUJPEG_PIXFMT_NO_ALPHA ? GPUJPEG_444_U8_P012 : GPUJPEG_4444_U8_P0123;
15821582
}
15831583

15841584
static void

0 commit comments

Comments
 (0)