我正面临一个奇怪的崩溃
VTCompressionSessionEncodeFrame(session, (CVPixelBufferRef)data, pts, dur, frameProps, NULL, &flags);
对于以下代码。
void H264Encode::pushBuffer(const uint8_t *const data, size_t size, videocore::IMetadata &metadata)
{
if(m_compressionSession) {
m_encodeMutex.lock();
VTCompressionSessionRef session = (VTCompressionSessionRef)m_compressionSession;
CMTime pts = CMTimeMake(metadata.timestampDelta + m_ctsOffset, 1000.); // timestamp is in ms.
CMTime dur = CMTimeMake(1, m_fps);
VTEncodeInfoFlags flags;
CFMutableDictionaryRef frameProps = NULL;
if(m_forceKeyframe) {
s_forcedKeyframePTS = pts.value;
frameProps = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(frameProps, kVTEncodeFrameOptionKey_ForceKeyFrame, kCFBooleanTrue);
}
VTCompressionSessionEncodeFrame(session, (CVPixelBufferRef)data, pts, dur, frameProps, NULL, &flags);
if(m_forceKeyframe) {
CFRelease(frameProps);
m_forceKeyframe = false;
}
m_encodeMutex.unlock();
}
我想要做的是将 CVPixelBufferRef 转换为 h264 视频数据。但它总是在上面提到的带有 EXEC_BAD_ACCESS 的函数中崩溃。
出现在 xcode 控制台上的崩溃日志是这样的。
Method cache corrupted. This may be a message to an invalid object, or a memory error somewhere else.
objc[29576]: receiver 0x10d2077c8, SEL 0x103734801, isa 0x600000123a20, cache 0x600000123a30, buckets 0x600000123a40, mask 0x0, occupied 0x0
objc[29576]: receiver 0 bytes, buckets 0 bytes
objc[29576]: selector '_cfTypeID'
objc[29576]: isa ' UH\211\345H\213G]\303UH\211\345SP\211\363\350\376\355\377\377\271\373\345\377\377H\205\300tH\213\204\333\225\302\266\362\272'
objc[29576]:Method cache corrupted.
有谁知道它为什么会崩溃以及可能的解决方法。任何提示或指导可能会有所帮助..