@@ -1507,9 +1507,6 @@ gcd(int a, int b)
15071507static enum gpujpeg_pixel_format
15081508get_native_pixel_format (struct gpujpeg_parameters * param )
15091509{
1510- if ( param -> comp_count == 1 ) {
1511- return GPUJPEG_U8 ;
1512- }
15131510 if ( param -> comp_count == 3 ) {
15141511 // reduce [2, 2; 1, 2; 1, 2] (FFmpeg) to [2, 1; 1, 1; 1, 1]
15151512 int horizontal_gcd = param -> sampling_factor [0 ].horizontal ;
@@ -1557,11 +1554,16 @@ get_native_pixel_format(struct gpujpeg_parameters* param)
15571554
15581555static enum gpujpeg_pixel_format
15591556adjust_pixel_format (struct gpujpeg_parameters * param , struct gpujpeg_image_parameters * param_image ) {
1560- assert (param_image -> pixel_format == GPUJPEG_PIXFMT_AUTODETECT || param_image -> pixel_format == GPUJPEG_PIXFMT_STD );
1557+ assert (param_image -> pixel_format == GPUJPEG_PIXFMT_AUTODETECT || param_image -> pixel_format == GPUJPEG_PIXFMT_STD ||
1558+ param_image -> pixel_format == GPUJPEG_PIXFMT_NATIVE );
15611559 if ( param -> comp_count == 1 ) {
15621560 return GPUJPEG_U8 ;
15631561 }
15641562
1563+ if ( param_image -> pixel_format == GPUJPEG_PIXFMT_NATIVE ) {
1564+ return get_native_pixel_format (param );
1565+ }
1566+
15651567 if (param_image -> pixel_format == GPUJPEG_PIXFMT_STD && param_image -> color_space != GPUJPEG_RGB ) {
15661568 struct gpujpeg_parameters tmp ;
15671569 gpujpeg_parameters_chroma_subsampling (& tmp , GPUJPEG_SUBSAMPLING_420 );
@@ -1738,6 +1740,7 @@ gpujpeg_reader_get_image_info(uint8_t *image, size_t image_size, struct gpujpeg_
17381740
17391741 struct gpujpeg_reader reader = {
17401742 .param .verbose = verbose ,
1743+ .param_image .pixel_format = GPUJPEG_PIXFMT_NATIVE ,
17411744 .image_end = image + image_size ,
17421745 .metadata = & info -> metadata ,
17431746 };
@@ -1856,8 +1859,6 @@ gpujpeg_reader_get_image_info(uint8_t *image, size_t image_size, struct gpujpeg_
18561859 info -> header_type = reader .header_type ;
18571860 info -> comment = reader .comment ;
18581861
1859- info -> param_image .pixel_format = get_native_pixel_format (& reader .param );
1860-
18611862 return 0 ;
18621863}
18631864
0 commit comments