Skip to content

Commit

Permalink
fix provider releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Jan 5, 2023
1 parent 40c2ce1 commit 072cc26
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/avifc/AVIFAnimatedDecoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ -(nullable CGImageRef)get:(int)frame {
avifRGBImage rgbImage;
avifRGBImageSetDefaults(&rgbImage, _idec->image);
rgbImage.format = AVIF_RGB_FORMAT_RGBA;
rgbImage.depth = 8;
avifRGBImageAllocatePixels(&rgbImage);
avifResult rgbResult = avifImageYUVToRGB(_idec->image, &rgbImage);
if (rgbResult != AVIF_RESULT_OK) {
Expand All @@ -73,15 +74,15 @@ -(nullable CGImageRef)get:(int)frame {
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
int flags = kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast;

CGDataProviderRef provider = CGDataProviderCreateWithData(premultiplied, premultiplied, rgbImage.width*rgbImage.height*rgbImage.depth/2, AV1CGDataProviderReleaseDataCallback);
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, premultiplied, rgbImage.width*rgbImage.height*rgbImage.depth/2, AV1CGDataProviderReleaseDataCallback);
if (!provider) {
free(premultiplied);
return NULL;
}

CGImageRef image = CGImageCreate(newWidth, newHeight, depth, 32*depth / 8, newRowBytes, colorSpace, flags, provider, NULL, false, kCGRenderingIntentDefault);
CGImageRef image = CGImageCreate(newWidth, newHeight, depth, 32, newRowBytes, colorSpace, flags, provider, NULL, false, kCGRenderingIntentDefault);

CFRelease(provider);
CGDataProviderRelease(provider);
CGColorSpaceRelease(colorSpace);
return image;
}
Expand Down

0 comments on commit 072cc26

Please sign in to comment.