简体   繁体   English

VideoToolBox可以控制RGB转YUV矩阵吗?

[英]Is it possible to control the conversion of RGB to YUV matrix in VideoToolBox?

I found that different Iphone hardware encoders have different matrices for converting input RGB to YUV.That is, in the function OSStatus VTCompressionSessionEncodeFrame(VTCompressionSessionRef session, CVImageBufferRef imageBuffer, CMTime presentationTimeStamp, CMTime duration, CFDictionaryRef frameProperties, void *sourceFrameRefcon, VTEncodeInfoFlags *infoFlagsOut);我发现不同的 Iphone 硬件编码器有不同的矩阵将输入的 RGB 转换为 YUV。也就是说,在函数 OSStatus VTCompressionSessionEncodeFrame(VTCompressionSessionRef session, CVImageBufferRef imageBuffer, CMTime presentationTimeStamp, CMTime duration, CFDictionaryRef frameProperties, void *sourceFrameRefcon, VTEncodeInfoFlags); *infoFlags the imageBuffer format is RGB.Before encoding, VideoToolBox will convert RGB to YUV and send it to the encoder.I want to know what kind of matrix VideoToolBox uses for RGB conversion to YUV, and how to control the selection of the conversion matrix. imageBuffer格式为RGB,编码前VideoToolBox会将RGB转YUV发送给encoder。 Among the input parameters of the hardware encoder VideoToolbox, only kVTCompressionPropertyKey_YCbCrMatrix is related to color conversion.But this parameter does not control the input RGB to YUV matrix.硬件编码器VideoToolbox的输入参数中,只有kVTCompressionPropertyKey_YCbCrMatrix与颜色转换相关,但该参数不控制输入RGB转YUV矩阵。 Because I tried to enter a different value, it didn't change.This leads to the inability to match the matrix during decoding, which causes chromatic aberration.I am searching for a long time on net.因为我尝试输入不同的值,它没有改变。这导致解码时无法匹配矩阵,从而导致色差。我在网上搜索了很长时间。 But no use.但是没有用。 Please help or try to give some ideas how to achieve this.请帮助或尝试提供一些想法如何实现这一点。

The problem has been resolved.这个问题已经解决。 Set kVTCompressionPropertyKey_PixelTransferProperties to control the conversion of RGB to YUV matrix in VideoToolBox在VideoToolBox中设置kVTCompressionPropertyKey_PixelTransferProperties来控制RGB到YUV矩阵的转换

    CFMutableDictionaryRef attrs = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFDictionarySetValue(attrs, kVTPixelTransferPropertyKey_DestinationYCbCrMatrix, kCVImageBufferYCbCrMatrix_ITU_R_601_4);//kCVImageBufferYCbCrMatrix_ITU_R_709_2
    status = VTSessionSetProperty(_encoderSession, kVTCompressionPropertyKey_PixelTransferProperties, attrs);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM