|
Lines 41-46
@interface RTCVideoDecoderH264 ()
a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm_sec1
|
| 41 |
- (void)setError:(OSStatus)error; |
41 |
- (void)setError:(OSStatus)error; |
| 42 |
@end |
42 |
@end |
| 43 |
|
43 |
|
|
|
44 |
// VideoToolbox will assume video data with no color space information is Rec.601 |
| 45 |
// and put the guessed color space attachments on the CVImageBuffer. To avoid |
| 46 |
// confusing users of the color space attachments, detect when that guess has been |
| 47 |
// made and override it to the WebRTC default, sRGB. |
| 48 |
static void overrideColorSpaceAttachmentsIfNeeded(CVImageBufferRef imageBuffer) { |
| 49 |
auto guess = CVBufferGetAttachment(imageBuffer, (CFStringRef)@"ColorInfoGuessedBy", nullptr); |
| 50 |
if (!guess || !CFEqual(guess, (CFStringRef)@"VideoToolbox")) |
| 51 |
return; |
| 52 |
|
| 53 |
auto colorPrimaries = CVBufferGetAttachment(imageBuffer, kCVImageBufferColorPrimariesKey, nullptr); |
| 54 |
if (!colorPrimaries || !CFEqual(colorPrimaries, kCVImageBufferColorPrimaries_SMPTE_C)) |
| 55 |
return; |
| 56 |
|
| 57 |
CVBufferRemoveAttachment(imageBuffer, kCVImageBufferCGColorSpaceKey); |
| 58 |
CVBufferSetAttachment(imageBuffer, kCVImageBufferColorPrimariesKey, kCVImageBufferColorPrimaries_ITU_R_709_2, kCVAttachmentMode_ShouldPropagate); |
| 59 |
CVBufferSetAttachment(imageBuffer, kCVImageBufferTransferFunctionKey, kCVImageBufferTransferFunction_sRGB, kCVAttachmentMode_ShouldPropagate); |
| 60 |
CVBufferSetAttachment(imageBuffer, kCVImageBufferYCbCrMatrixKey, kCVImageBufferYCbCrMatrix_ITU_R_709_2, kCVAttachmentMode_ShouldPropagate); |
| 61 |
CVBufferSetAttachment(imageBuffer, (CFStringRef)@"ColorInfoGuessedBy", (CFStringRef)@"RTCVideoDecoderH264", kCVAttachmentMode_ShouldPropagate); |
| 62 |
} |
| 63 |
|
| 44 |
// This is the callback function that VideoToolbox calls when decode is |
64 |
// This is the callback function that VideoToolbox calls when decode is |
| 45 |
// complete. |
65 |
// complete. |
| 46 |
void decompressionOutputCallback(void *decoderRef, |
66 |
void decompressionOutputCallback(void *decoderRef, |
|
Lines 57-62
void decompressionOutputCallback(void *decoderRef,
a/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm_sec2
|
| 57 |
return; |
77 |
return; |
| 58 |
} |
78 |
} |
| 59 |
|
79 |
|
|
|
80 |
overrideColorSpaceAttachmentsIfNeeded(imageBuffer); |
| 81 |
|
| 60 |
std::unique_ptr<RTCFrameDecodeParams> decodeParams(reinterpret_cast<RTCFrameDecodeParams *>(params)); |
82 |
std::unique_ptr<RTCFrameDecodeParams> decodeParams(reinterpret_cast<RTCFrameDecodeParams *>(params)); |
| 61 |
// TODO(tkchin): Handle CVO properly. |
83 |
// TODO(tkchin): Handle CVO properly. |
| 62 |
RTCCVPixelBuffer *frameBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:imageBuffer]; |
84 |
RTCCVPixelBuffer *frameBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:imageBuffer]; |