3333
3434@implementation RgbaScaler
3535
36- static bool API_AVAILABLE (macos(13.0 ), ios(16.0 ), watchos(9.0 ), tvos(16.0 ))
37- scaleF16iOS16(std::vector<uint8_t > &src, int components, int width, int height, int newWidth, int newHeight, XSampler sampler) {
38- if (components != 4 ) {
39- std::vector<uint8_t > dst (components * sizeof (uint16_t ) * newWidth * newHeight);
40-
41- scaleImageFloat16 (reinterpret_cast <uint16_t *>(src.data ()),
42- components * sizeof (uint16_t ) * width, width, height, reinterpret_cast <uint16_t *>(dst.data ()),
43- components * sizeof (uint16_t ) * newWidth, newWidth, newHeight, components, sampler);
44-
45- src = dst;
46- return true ;
47- }
36+ // static bool API_AVAILABLE(macos(13.0), ios(16.0), watchos(9.0), tvos(16.0))
37+ static bool scaleF16iOS16 (std::vector<uint8_t > &src, int components, int width, int height, int newWidth, int newHeight, XSampler sampler) {
38+ // if (components != 4) {
39+ std::vector<uint8_t > dst (components * sizeof (uint16_t ) * newWidth * newHeight);
4840
49- std::vector<uint8_t > dst (4 * sizeof (uint16_t ) * newWidth * newHeight);
50-
51- vImage_Buffer srcBuffer = {
52- .data = (void *)src.data (),
53- .width = static_cast <vImagePixelCount>(width),
54- .height = static_cast <vImagePixelCount>(height),
55- .rowBytes = width * 4 * sizeof (uint16_t )
56- };
57-
58- vImage_Buffer dstBuffer = {
59- .data = dst.data (),
60- .width = static_cast <vImagePixelCount>(newWidth),
61- .height = static_cast <vImagePixelCount>(newHeight),
62- .rowBytes = newWidth * 4 * sizeof (uint16_t )
63- };
41+ scaleImageFloat16 (reinterpret_cast <uint16_t *>(src.data ()),
42+ components * sizeof (uint16_t ) * width, width, height, reinterpret_cast <uint16_t *>(dst.data ()),
43+ components * sizeof (uint16_t ) * newWidth, newWidth, newHeight, components, sampler);
6444
65- auto result = vImageScale_ARGB16F (&srcBuffer, &dstBuffer, nullptr , kvImageUseFP16Accumulator);
66- if (result != kvImageNoError) {
67- return false ;
68- }
6945 src = dst;
7046 return true ;
47+ // }
48+ //
49+ // std::vector<uint8_t> dst(4 * sizeof(uint16_t) * newWidth * newHeight);
50+ //
51+ // vImage_Buffer srcBuffer = {
52+ // .data = (void*)src.data(),
53+ // .width = static_cast<vImagePixelCount>(width),
54+ // .height = static_cast<vImagePixelCount>(height),
55+ // .rowBytes = width * 4 * sizeof(uint16_t)
56+ // };
57+ //
58+ // vImage_Buffer dstBuffer = {
59+ // .data = dst.data(),
60+ // .width = static_cast<vImagePixelCount>(newWidth),
61+ // .height = static_cast<vImagePixelCount>(newHeight),
62+ // .rowBytes = newWidth * 4 * sizeof(uint16_t)
63+ // };
64+ //
65+ // auto result = vImageScale_ARGB16F(&srcBuffer, &dstBuffer, nullptr, kvImageUseFP16Accumulator);
66+ // if (result != kvImageNoError) {
67+ // return false;
68+ // }
69+ // src = dst;
70+ // return true;
7171}
7272
7373static bool scaleF16iOSPre16 (std::vector<uint8_t > &src, int components, int width, int height, int newWidth, int newHeight, XSampler sampler) {
@@ -146,40 +146,40 @@ static bool scaleF16iOSPre16(std::vector<uint8_t> &src, int components, int widt
146146}
147147
148148+ (bool )scaleRGB8 : (std::vector<uint8_t> &)src components : (int )components width : (int )width height : (int )height newWidth : (int )newWidth newHeight : (int )newHeight sampler : (XSampler)sampler {
149- if (components != 4 ) {
150- std::vector<uint8_t > dst (components * sizeof (uint8_t ) * newWidth * newHeight);
151-
152- scaleImageU8 (reinterpret_cast <uint8_t *>(src.data ()),
153- components * sizeof (uint8_t ) * width, width, height, reinterpret_cast <uint8_t *>(dst.data ()),
154- components * sizeof (uint8_t ) * newWidth, newWidth, newHeight, components, 8 , sampler);
155- src = dst;
156-
157- return true ;
158- }
159-
160- std::vector<uint8_t > dst (4 * sizeof (uint8_t ) * newWidth * newHeight);
161-
162- vImage_Buffer srcBuffer = {
163- .data = (void *)src.data (),
164- .width = static_cast <vImagePixelCount>(width),
165- .height = static_cast <vImagePixelCount>(height),
166- .rowBytes = width * 4 * sizeof (uint8_t )
167- };
168-
169- vImage_Buffer dstBuffer = {
170- .data = dst.data (),
171- .width = static_cast <vImagePixelCount>(newWidth),
172- .height = static_cast <vImagePixelCount>(newHeight),
173- .rowBytes = newWidth * 4 * sizeof (uint8_t )
174- };
175-
176- auto result = vImageScale_ARGB8888 (&srcBuffer, &dstBuffer, nullptr , kvImageNoFlags);
177- if (result != kvImageNoError) {
178- return false ;
179- }
149+ // if (components != 4) {
150+ std::vector<uint8_t > dst (components * sizeof (uint8_t ) * newWidth * newHeight);
180151
152+ scaleImageU8 (reinterpret_cast <uint8_t *>(src.data ()),
153+ components * sizeof (uint8_t ) * width, width, height, reinterpret_cast <uint8_t *>(dst.data ()),
154+ components * sizeof (uint8_t ) * newWidth, newWidth, newHeight, components, 8 , sampler);
181155 src = dst;
156+
182157 return true ;
158+ // }
159+ //
160+ // std::vector<uint8_t> dst(4 * sizeof(uint8_t) * newWidth * newHeight);
161+ //
162+ // vImage_Buffer srcBuffer = {
163+ // .data = (void*)src.data(),
164+ // .width = static_cast<vImagePixelCount>(width),
165+ // .height = static_cast<vImagePixelCount>(height),
166+ // .rowBytes = width * 4 * sizeof(uint8_t)
167+ // };
168+ //
169+ // vImage_Buffer dstBuffer = {
170+ // .data = dst.data(),
171+ // .width = static_cast<vImagePixelCount>(newWidth),
172+ // .height = static_cast<vImagePixelCount>(newHeight),
173+ // .rowBytes = newWidth * 4 * sizeof(uint8_t)
174+ // };
175+ //
176+ // auto result = vImageScale_ARGB8888(&srcBuffer, &dstBuffer, nullptr, kvImageNoFlags);
177+ // if (result != kvImageNoError) {
178+ // return false;
179+ // }
180+ //
181+ // src = dst;
182+ // return true;
183183}
184184
185185+(bool ) scaleData : (std::vector<uint8_t>&)src width : (int )width height : (int )height newWidth : (int )newWidth newHeight : (int )newHeight components : (int )components pixelFormat : (JxlIPixelFormat)pixelFormat sampler : (XSampler)sampler {
@@ -193,11 +193,12 @@ +(bool) scaleData:(std::vector<uint8_t>&)src width:(int)width height:(int)height
193193 if (pixelFormat == kU8 ) {
194194 return [self scaleRGB8: src components: components width: width height: height newWidth: newWidth newHeight: newHeight sampler: sampler];
195195 } else if (pixelFormat == kF16 ) {
196- if (@available (iOS 16.0 , macOS 13.0 , *)) {
197- return scaleF16iOS16 (src, components, width, height, newWidth, newHeight, sampler);
198- } else {
199- return scaleF16iOSPre16 (src, components, width, height, newWidth, newHeight, sampler);
200- }
196+ return scaleF16iOS16 (src, components, width, height, newWidth, newHeight, sampler);
197+ // if (@available(iOS 16.0, macOS 13.0, *)) {
198+ // return scaleF16iOS16(src, components, width, height, newWidth, newHeight, sampler);
199+ // } else {
200+ // return scaleF16iOSPre16(src, components, width, height, newWidth, newHeight, sampler);
201+ // }
201202 }
202203 } catch (const std::bad_alloc& e) {
203204 // Memory allocation has failed
0 commit comments