forked from external-repos/squoosh
Don't copy dem pixels
This commit is contained in:
@@ -48,8 +48,8 @@ val encode(std::string buffer, int width, int height, AvifOptions options) {
|
|||||||
|
|
||||||
avifRGBImage srcRGB;
|
avifRGBImage srcRGB;
|
||||||
avifRGBImageSetDefaults(&srcRGB, image);
|
avifRGBImageSetDefaults(&srcRGB, image);
|
||||||
avifRGBImageAllocatePixels(&srcRGB);
|
srcRGB.pixels = rgba;
|
||||||
memcpy(srcRGB.pixels, rgba, width * height * 4);
|
srcRGB.rowBytes = width * 4;
|
||||||
avifImageRGBToYUV(image, &srcRGB);
|
avifImageRGBToYUV(image, &srcRGB);
|
||||||
|
|
||||||
avifEncoder* encoder = avifEncoderCreate();
|
avifEncoder* encoder = avifEncoderCreate();
|
||||||
@@ -65,7 +65,6 @@ val encode(std::string buffer, int width, int height, AvifOptions options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto js_result = Uint8Array.new_(typed_memory_view(output.size, output.data));
|
auto js_result = Uint8Array.new_(typed_memory_view(output.size, output.data));
|
||||||
avifRGBImageFreePixels(&srcRGB);
|
|
||||||
avifImageDestroy(image);
|
avifImageDestroy(image);
|
||||||
avifEncoderDestroy(encoder);
|
avifEncoderDestroy(encoder);
|
||||||
return js_result;
|
return js_result;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user