@@ -1508,23 +1508,10 @@ static enum gpujpeg_pixel_format
15081508get_native_pixel_format (struct gpujpeg_parameters * param )
15091509{
15101510 if ( param -> comp_count == 4 ) {
1511- _Bool subsampling_is4444 = 1 ;
1512- for (int i = 1 ; i < 4 ; ++ i ) {
1513- if (param -> sampling_factor [i ].horizontal != param -> sampling_factor [0 ].horizontal
1514- || param -> sampling_factor [i ].vertical != param -> sampling_factor [0 ].vertical ) {
1515- subsampling_is4444 = 0 ;
1516- break ;
1517- }
1518- }
1519- if (subsampling_is4444 ) {
1520- return GPUJPEG_4444_U8_P0123 ;
1521- }
1522- return GPUJPEG_PIXFMT_NONE ;
1511+ return GPUJPEG_4444_U8_P0123 ;
15231512 }
15241513
1525- if ( param -> comp_count != 3 ) {
1526- return GPUJPEG_PIXFMT_NONE ;
1527- }
1514+ assert (param -> comp_count == 3 );
15281515
15291516 // reduce [2, 2; 1, 2; 1, 2] (FFmpeg) to [2, 1; 1, 1; 1, 1]
15301517 int horizontal_gcd = param -> sampling_factor [0 ].horizontal ;
@@ -1538,6 +1525,7 @@ get_native_pixel_format(struct gpujpeg_parameters* param)
15381525 param -> sampling_factor [i ].vertical /= vertical_gcd ;
15391526 }
15401527
1528+ // handle normal 4:4:4, 4:2:2 or 4:2:0
15411529 if ( param -> sampling_factor [1 ].horizontal == 1 && param -> sampling_factor [1 ].vertical == 1 &&
15421530 param -> sampling_factor [2 ].horizontal == 1 && param -> sampling_factor [2 ].vertical == 1 ) {
15431531 int sum = param -> interleaved << 16 | param -> sampling_factor [0 ].horizontal << 8 |
@@ -1555,7 +1543,8 @@ get_native_pixel_format(struct gpujpeg_parameters* param)
15551543 }
15561544 }
15571545
1558- return GPUJPEG_PIXFMT_NONE ;
1546+ // fallback
1547+ return param -> interleaved ? GPUJPEG_444_U8_P012 : GPUJPEG_444_U8_P0P1P2 ;
15591548}
15601549
15611550static enum gpujpeg_pixel_format
0 commit comments