Created
October 29, 2015 06:05
-
-
Save petershine/49a826509cc7045d81f6 to your computer and use it in GitHub Desktop.
Essential snippet for decompressing sample into CVImageBufferRef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(compressedSample); | |
static VTDecompressionSessionRef decompressionSession; | |
if (decompressionSession == NULL) { | |
VTDecompressionSessionCreate | |
(NULL, | |
formatDescription, | |
NULL, | |
NULL, | |
NULL, | |
&decompressionSession); | |
} | |
VTDecompressionSessionDecodeFrameWithOutputHandler | |
(decompressionSession, | |
compressedSample, | |
kVTDecodeFrame_EnableAsynchronousDecompression, | |
NULL, | |
^(OSStatus status, | |
VTDecodeInfoFlags infoFlags, | |
CVImageBufferRef _Nullable imageBuffer, | |
CMTime presentationTimeStamp, | |
CMTime presentationDuration) { | |
//MARK: New CMSampleBufferRef may have to be created for other uses | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment