@@ -34,69 +34,69 @@ void RecognizeICC(std::shared_ptr<heif_image_handle> &handle,
34
34
std::vector<uint8_t > &iccProfile,
35
35
std::string &colorSpaceName,
36
36
heif_color_profile_nclx **nclx,
37
- bool * hasNclx) {
37
+ bool * hasNclx) {
38
38
39
- auto type = heif_image_get_color_profile_type (image.get ());
39
+ auto type = heif_image_get_color_profile_type (image.get ());
40
40
41
- auto nclxColorProfile = heif_image_handle_get_nclx_color_profile (handle.get (),
42
- nclx);
41
+ auto nclxColorProfile = heif_image_handle_get_nclx_color_profile (handle.get (),
42
+ nclx);
43
43
44
- if (nclxColorProfile.code == heif_error_Ok) {
45
- *hasNclx = true ;
46
- auto colorProfileNclx = *nclx;
47
- if (colorProfileNclx && colorProfileNclx->color_primaries != 0 &&
48
- colorProfileNclx->transfer_characteristics != 0 ) {
49
- auto transfer = colorProfileNclx->transfer_characteristics ;
50
- auto colorPrimaries = colorProfileNclx->color_primaries ;
51
- if (colorPrimaries == heif_color_primaries_ITU_R_BT_2020_2_and_2100_0 &&
52
- transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_PQ) {
53
- colorSpaceName = " BT2020_PQ" ;
54
- } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_709_5 &&
55
- transfer == heif_transfer_characteristic_linear) {
56
- colorSpaceName = " LINEAR_SRGB" ;
57
- } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_2020_2_and_2100_0 &&
58
- transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_HLG) {
59
- colorSpaceName = " BT2020_HLG" ;
60
- } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_709_5 &&
61
- transfer == heif_transfer_characteristic_ITU_R_BT_709_5) {
62
- colorSpaceName = " BT709" ;
63
- } else if ((transfer == heif_transfer_characteristic_ITU_R_BT_2020_2_10bit ||
64
- transfer == heif_transfer_characteristic_ITU_R_BT_2020_2_12bit)) {
65
- colorSpaceName = " BT2020" ;
66
- } else if (colorPrimaries == heif_color_primaries_SMPTE_EG_432_1 &&
67
- transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_HLG) {
68
- colorSpaceName = " DISPLAY_P3_HLG" ;
69
- } else if (colorPrimaries == heif_color_primaries_SMPTE_EG_432_1 &&
70
- transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_PQ) {
71
- colorSpaceName = " DISPLAY_P3_PQ" ;
72
- } else if (colorPrimaries == heif_color_primaries_SMPTE_EG_432_1 &&
73
- transfer == heif_transfer_characteristic_ITU_R_BT_709_5) {
74
- colorSpaceName = " DISPLAY_P3" ;
75
- } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_2020_2_and_2100_0) {
76
- colorSpaceName = " BT2020" ;
77
- } else if (transfer == heif_transfer_characteristic_SMPTE_ST_428_1) {
78
- colorSpaceName = " SMPTE_428" ;
79
- } else if (transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_PQ) {
80
- colorSpaceName = " BT2020_PQ" ;
81
- } else if (transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_HLG) {
82
- colorSpaceName = " BT2020_HLG" ;
83
- }
84
- }
85
- } else if (type == heif_color_profile_type_prof || type == heif_color_profile_type_rICC) {
86
- auto profileSize = heif_image_get_raw_color_profile_size (image.get ());
87
- if (profileSize > 0 ) {
88
- iccProfile.resize (profileSize);
89
- auto iccStatus = heif_image_get_raw_color_profile (image.get (), iccProfile.data ());
90
- if (iccStatus.code != heif_error_Ok) {
91
- if (iccStatus.message ) {
92
- __android_log_print (ANDROID_LOG_ERROR, " AVIF" ,
93
- " ICC profile retrieving failed with: %s" ,
94
- iccStatus.message );
95
- } else {
96
- __android_log_print (ANDROID_LOG_ERROR, " AVIF" ,
97
- " ICC profile retrieving failed with unknown error" );
98
- }
99
- }
44
+ if (type == heif_color_profile_type_prof || type == heif_color_profile_type_rICC) {
45
+ auto profileSize = heif_image_get_raw_color_profile_size (image.get ());
46
+ if (profileSize > 0 ) {
47
+ iccProfile.resize (profileSize);
48
+ auto iccStatus = heif_image_get_raw_color_profile (image.get (), iccProfile.data ());
49
+ if (iccStatus.code != heif_error_Ok) {
50
+ if (iccStatus.message ) {
51
+ __android_log_print (ANDROID_LOG_ERROR, " AVIF" ,
52
+ " ICC profile retrieving failed with: %s" ,
53
+ iccStatus.message );
54
+ } else {
55
+ __android_log_print (ANDROID_LOG_ERROR, " AVIF" ,
56
+ " ICC profile retrieving failed with unknown error" );
100
57
}
58
+ }
59
+ }
60
+ } else if (nclxColorProfile.code == heif_error_Ok) {
61
+ *hasNclx = true ;
62
+ auto colorProfileNclx = *nclx;
63
+ if (colorProfileNclx && colorProfileNclx->color_primaries != 0 &&
64
+ colorProfileNclx->transfer_characteristics != 0 ) {
65
+ auto transfer = colorProfileNclx->transfer_characteristics ;
66
+ auto colorPrimaries = colorProfileNclx->color_primaries ;
67
+ if (colorPrimaries == heif_color_primaries_ITU_R_BT_2020_2_and_2100_0 &&
68
+ transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_PQ) {
69
+ colorSpaceName = " BT2020_PQ" ;
70
+ } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_709_5 &&
71
+ transfer == heif_transfer_characteristic_linear) {
72
+ colorSpaceName = " LINEAR_SRGB" ;
73
+ } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_2020_2_and_2100_0 &&
74
+ transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_HLG) {
75
+ colorSpaceName = " BT2020_HLG" ;
76
+ } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_709_5 &&
77
+ transfer == heif_transfer_characteristic_ITU_R_BT_709_5) {
78
+ colorSpaceName = " BT709" ;
79
+ } else if ((transfer == heif_transfer_characteristic_ITU_R_BT_2020_2_10bit ||
80
+ transfer == heif_transfer_characteristic_ITU_R_BT_2020_2_12bit)) {
81
+ colorSpaceName = " BT2020" ;
82
+ } else if (colorPrimaries == heif_color_primaries_SMPTE_EG_432_1 &&
83
+ transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_HLG) {
84
+ colorSpaceName = " DISPLAY_P3_HLG" ;
85
+ } else if (colorPrimaries == heif_color_primaries_SMPTE_EG_432_1 &&
86
+ transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_PQ) {
87
+ colorSpaceName = " DISPLAY_P3_PQ" ;
88
+ } else if (colorPrimaries == heif_color_primaries_SMPTE_EG_432_1 &&
89
+ transfer == heif_transfer_characteristic_ITU_R_BT_709_5) {
90
+ colorSpaceName = " DISPLAY_P3" ;
91
+ } else if (colorPrimaries == heif_color_primaries_ITU_R_BT_2020_2_and_2100_0) {
92
+ colorSpaceName = " BT2020" ;
93
+ } else if (transfer == heif_transfer_characteristic_SMPTE_ST_428_1) {
94
+ colorSpaceName = " SMPTE_428" ;
95
+ } else if (transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_PQ) {
96
+ colorSpaceName = " BT2020_PQ" ;
97
+ } else if (transfer == heif_transfer_characteristic_ITU_R_BT_2100_0_HLG) {
98
+ colorSpaceName = " BT2020_HLG" ;
99
+ }
101
100
}
101
+ }
102
102
}
0 commit comments