Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.

Commit f762b42

Browse files
committed
Change work-around for a CoreVideo bug in custom pixel-format registration so it will continue to produce correctly sized buffers if the bug is ever fixed. Use bzero instead of BlockZero
1 parent 6a8c28b commit f762b42

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

source/PixelFormats.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void HapCodecRegisterDXTPixelFormat(OSType fmt, short bits_per_pixel, SIn
4545
0,
4646
&kCFTypeDictionaryKeyCallBacks,
4747
&kCFTypeDictionaryValueCallBacks);
48-
BlockZero(&pixelInfo, sizeof(pixelInfo));
48+
bzero(&pixelInfo, sizeof(pixelInfo));
4949
pixelInfo.size = sizeof(ICMPixelFormatInfo);
5050
pixelInfo.formatFlags = (has_alpha ? kICMPixelFormatHasAlphaChannel : 0);
5151
pixelInfo.bitsPerPixel[0] = bits_per_pixel;
@@ -56,12 +56,13 @@ static void HapCodecRegisterDXTPixelFormat(OSType fmt, short bits_per_pixel, SIn
5656
ICMSetPixelFormatInfo(fmt, &pixelInfo);
5757

5858
addNumberToDictionary(dict, kCVPixelFormatConstant, fmt);
59-
addNumberToDictionary(dict, kCVPixelFormatBlockWidth, 4);
60-
addNumberToDictionary(dict, kCVPixelFormatBlockHeight, 4);
6159

62-
// CV has a bug where it disregards kCVPixelFormatBlockHeight, so the following line is a lie to
63-
// produce correctly-sized buffers
60+
// CV has a bug where it disregards kCVPixelFormatBlockHeight, so we lie about block size
61+
// (4x1 instead of actual 4x4) and add a vertical block-alignment key instead
6462
addNumberToDictionary(dict, kCVPixelFormatBitsPerBlock, bits_per_pixel * 4);
63+
addNumberToDictionary(dict, kCVPixelFormatBlockWidth, 4);
64+
addNumberToDictionary(dict, kCVPixelFormatBlockVerticalAlignment, 4);
65+
6566
addNumberToDictionary(dict, kCVPixelFormatOpenGLInternalFormat, open_gl_internal_format);
6667

6768
CFDictionarySetValue(dict, kCVPixelFormatOpenGLCompatibility, kCFBooleanTrue);
@@ -81,7 +82,7 @@ static void HapCodecRegisterYCoCgPixelFormat(void)
8182
0,
8283
&kCFTypeDictionaryKeyCallBacks,
8384
&kCFTypeDictionaryValueCallBacks);
84-
BlockZero(&pixelInfo, sizeof(pixelInfo));
85+
bzero(&pixelInfo, sizeof(pixelInfo));
8586
pixelInfo.size = sizeof(ICMPixelFormatInfo);
8687
pixelInfo.formatFlags = 0;
8788
pixelInfo.bitsPerPixel[0] = 32;

0 commit comments

Comments
 (0)