我正在使用VideoToolBox进行H263解压。但是在解码4CIF视频流时,输出像素数据都是0值,并且没有错误信息。
我不知道为什么会这样,因为具有 CIF 分辨率的视频流已正确解压缩。
有没有人有同样的问题?
这是我的一段代码:
CMFormatDescriptionRef newFmtDesc = nil;
OSStatus status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
kCMVideoCodecType_H263,
width,
height,
NULL,
&_videoFormatDescription);
if (status)
{
return -1;
}
CFMutableDictionaryRef dpba = CFDictionaryCreateMutable(kCFAllocatorDefault,
2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(dpba,
kCVPixelBufferOpenGLCompatibilityKey,
kCFBooleanFalse);
VTDictionarySetInt32(dpba,
kCVPixelBufferPixelFormatTypeKey,
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange); // use NV12
VTDictionarySetInt32(dpba,
kCVPixelBufferWidthKey,
dimension.width);
VTDictionarySetInt32(dpba,
kCVPixelBufferHeightKey,
dimension.height);
VTDictionarySetInt32(dpba,
kCVPixelBufferBytesPerRowAlignmentKey,
dimension.width);// setup decoder callback record
VTDecompressionOutputCallbackRecord decoderCallbackRecord;
decoderCallbackRecord.decompressionOutputCallback = onDecodeCallback;
decoderCallbackRecord.decompressionOutputRefCon = this;// create decompression session
status = VTDecompressionSessionCreate(kCFAllocatorDefault,
_videoFormatDescription,
nil,
dpba,
&decoderCallbackRecord,
&_session);
// Do Decode
CMSampleBufferRef sampleBuffer;
sampleBuffer = VTSampleBufferCreate(_videoFormatDescription, (void*)data_start, data_len, ts);
VTDecodeFrameFlags flags = 0;
VTDecodeInfoFlags flagOut = 0;
OSStatus decodeStatus = VTDecompressionSessionDecodeFrame(_session,
sampleBuffer,
flags,
nil,
&flagOut);
我尝试使用 VideoToolBox 压缩 H263,我以 4CIF 的分辨率进入会话,并将 4CIF NV12 图像推送到压缩会话,但 H263 流的输出是 CIF 分辨率!
VideoToolBox在压缩和解压缩上都不能支持4CIF H263 Video吗?