Changeset 265073 in webkit
- Timestamp:
- Jul 29, 2020 6:01:04 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/ThirdParty/libwebrtc/ChangeLog
r264966 r265073 1 2020-07-29 Jer Noble <jer.noble@apple.com> 2 3 Support HDR decode in SW VP9 4 https://bugs.webkit.org/show_bug.cgi?id=214928 5 6 Reviewed by Eric Carlson. 7 8 Support converting I010 buffers (full-planar, 10-bit data packed into the LSB of a 16-bit int) 9 into CVPixelBuffers (bi-planar, 10-bit data packed into the MSB of a 16-bit int). This requires 10 using functions from libyuv to merge and scale 16-bit planar data, optimized for AVX2. To know 11 that incoming buffers are 10-bit, and whether they're full-range, parse the 'vpcC' atom attached 12 to the CMFormatDescription. 13 14 * Source/webrtc/sdk/WebKit/WebKitUtilities.mm: 15 (webrtc::MergeUVPlane_16): 16 (webrtc::CopyPlane_16): 17 (webrtc::CopyVideoFrameToPixelBuffer): 18 (webrtc::pixelBufferFromFrame): 19 * Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp: 20 (webrtc::createWebKitVP9Decoder): 21 (webrtc::startVP9DecoderSession): 22 (webrtc::WebKitVP9DecoderReceiver::createPixelBufferPoolForFormatDescription): 23 (webrtc::WebKitVP9DecoderReceiver::Decoded): 24 1 25 2020-07-28 Youenn Fablet <youenn@apple.com> 2 26 -
trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.mm
r263894 r265073 28 28 #include "native/src/objc_frame_buffer.h" 29 29 #include "third_party/libyuv/include/libyuv/convert_from.h" 30 #include "libyuv/cpu_id.h" 31 #include "libyuv/row.h" 30 32 #include "Framework/Headers/WebRTC/RTCVideoFrameBuffer.h" 31 33 … … 78 80 } 79 81 82 // MergeUVPlane_16 merges two separate U and V planes into a single, interleaved 83 // plane, while simultaneously scaling the output. Use '64' in the scale field to 84 // shift 10-bit data from the LSB of the 16-bit int to the MSB. 85 // NOTE: This method is based on libyuv::MergeUVPlane. If libyuv ever supports 86 // this operation directly, we should replace the below with it. 87 // NOTE: libyuv only has an opmitization of MergeUVRow_16 for AVX2 intrinsics. 88 // Calling this method on a CPU without AVX2 will fall back to a standard C 89 // implementation, and will probably be super slow. Add new MergeUVRow_16 90 // implementations as they become available in libyuv. 91 void MergeUVPlane_16(const uint16_t* src_u, int src_stride_u, const uint16_t* src_v, int src_stride_v, uint16_t* dst_uv, int dst_stride_uv, int width, int height, int scale) { 92 void (*MergeUVRow_16)(const uint16_t* src_u, const uint16_t* src_v, uint16_t* dst_uv, int scale, int width) = libyuv::MergeUVRow_16_C; 93 // Negative height means invert the image. 94 if (height < 0) { 95 height = -height; 96 dst_uv = dst_uv + (height - 1) * dst_stride_uv; 97 dst_stride_uv = -dst_stride_uv; 98 } 99 // Coalesce rows. 100 if (src_stride_u == width && src_stride_v == width && dst_stride_uv == width * 2) { 101 width *= height; 102 height = 1; 103 src_stride_u = src_stride_v = dst_stride_uv = 0; 104 } 105 #if defined(HAS_MERGEUVROW_16_AVX2) 106 if (libyuv::TestCpuFlag(libyuv::kCpuHasAVX2)) 107 MergeUVRow_16 = libyuv::MergeUVRow_16_AVX2; 108 #endif 109 110 for (int y = 0; y < height; ++y) { 111 // Merge a row of U and V into a row of UV. 112 MergeUVRow_16(src_u, src_v, dst_uv, scale, width); 113 src_u += src_stride_u / sizeof(uint16_t); 114 src_v += src_stride_v / sizeof(uint16_t); 115 dst_uv += dst_stride_uv / sizeof(uint16_t); 116 } 117 } 118 119 // CopyPlane_16 will copy a plane of 16-bit data from one location to another, 120 // while simultaneously scaling the output. Use '64' in the scale field to 121 // shift 10-bit data from the LSB of a 16-bit int to the MSB. 122 // NOTE: This method is based on MergeUVPlane_16 above, but operates on a 123 // single plane, rater than interleaving two planes. If libyuv ever supports 124 // this operation directly, we should replace the below with it. 125 // NOTE: libyuv only has an opmitization of MergeUVRow_16 for AVX2 intrinsics. 126 // Calling this method on a CPU without AVX2 will fall back to a standard C 127 // implementation, and will probably be super slow. Add new MergeUVRow_16 128 // implementations as they become available in libyuv. 129 void CopyPlane_16(const uint16_t* src, int src_stride, uint16_t* dst, int dst_stride, int width, int height, int scale) 130 { 131 void (*MultiplyRow_16)(const uint16_t* src_y, uint16_t* dst_y, int scale, int width) = libyuv::MultiplyRow_16_C; 132 // Negative height means invert the image. 133 if (height < 0) { 134 height = -height; 135 dst = dst + (height - 1) * dst_stride; 136 dst_stride = -dst_stride; 137 } 138 // Coalesce rows. 139 if (src_stride == width && dst_stride == width * 2) { 140 width *= height; 141 height = 1; 142 src_stride = dst_stride = 0; 143 } 144 #if defined(HAS_MERGEUVROW_16_AVX2) 145 if (libyuv::TestCpuFlag(libyuv::kCpuHasAVX2)) 146 MultiplyRow_16 = libyuv::MultiplyRow_16_AVX2; 147 #endif 148 149 for (int y = 0; y < height; ++y) { 150 MultiplyRow_16(src, dst, scale, width); 151 src += src_stride / sizeof(uint16_t); 152 dst += dst_stride / sizeof(uint16_t); 153 } 154 } 155 156 static bool CopyVideoFrameToPixelBuffer(const webrtc::I010BufferInterface* frame, CVPixelBufferRef pixel_buffer) 157 { 158 RTC_DCHECK(pixel_buffer); 159 RTC_DCHECK(CVPixelBufferGetPixelFormatType(pixel_buffer) == kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange || CVPixelBufferGetPixelFormatType(pixel_buffer) == kCVPixelFormatType_420YpCbCr10BiPlanarFullRange); 160 RTC_DCHECK_EQ(CVPixelBufferGetHeightOfPlane(pixel_buffer, 0), static_cast<size_t>(frame->height())); 161 RTC_DCHECK_EQ(CVPixelBufferGetWidthOfPlane(pixel_buffer, 0), static_cast<size_t>(frame->width())); 162 163 if (CVPixelBufferLockBaseAddress(pixel_buffer, 0) != kCVReturnSuccess) 164 return false; 165 166 auto src_y = const_cast<uint16_t*>(frame->DataY()); 167 auto src_u = const_cast<uint16_t*>(frame->DataU()); 168 auto src_v = const_cast<uint16_t*>(frame->DataV()); 169 auto src_width_y = frame->width(); 170 auto src_height_y = frame->height(); 171 auto src_stride_y = frame->StrideY() * sizeof(uint16_t); 172 auto src_width_uv = frame->ChromaWidth(); 173 auto src_height_uv = frame->ChromaHeight(); 174 auto src_stride_u = frame->StrideU() * sizeof(uint16_t); 175 auto src_stride_v = frame->StrideV() * sizeof(uint16_t); 176 177 auto* dst_y = reinterpret_cast<uint16_t*>(CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 0)); 178 auto dst_stride_y = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 0); 179 auto dst_width_y = CVPixelBufferGetWidthOfPlane(pixel_buffer, 0); 180 auto dst_height_y = CVPixelBufferGetHeightOfPlane(pixel_buffer, 0); 181 182 auto* dst_uv = reinterpret_cast<uint16_t*>(CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 1)); 183 auto dst_stride_uv = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 1); 184 auto dst_width_uv = CVPixelBufferGetWidthOfPlane(pixel_buffer, 1); 185 auto dst_height_uv = CVPixelBufferGetHeightOfPlane(pixel_buffer, 1); 186 187 if (src_width_y != dst_width_y 188 || src_height_y != dst_height_y 189 || src_width_uv != dst_width_uv 190 || src_height_uv != dst_height_uv) 191 return false; 192 193 CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, dst_width_y, dst_height_y, 64); 194 MergeUVPlane_16(src_u, src_stride_u, src_v, src_stride_v, dst_uv, dst_stride_uv, dst_width_uv, dst_height_uv, 64); 195 196 CVPixelBufferUnlockBaseAddress(pixel_buffer, 0); 197 return true; 198 } 199 80 200 CVPixelBufferRef pixelBufferFromFrame(const VideoFrame& frame, const std::function<CVPixelBufferRef(size_t, size_t)>& makePixelBuffer) 81 201 { 82 202 if (frame.video_frame_buffer()->type() != VideoFrameBuffer::Type::kNative) { 83 rtc::scoped_refptr<const I420BufferInterface> buffer = frame.video_frame_buffer()->GetI420(); 84 85 auto pixelBuffer = makePixelBuffer(buffer->width(), buffer->height()); 86 if (pixelBuffer) 203 auto pixelBuffer = makePixelBuffer(frame.video_frame_buffer()->width(), frame.video_frame_buffer()->height()); 204 if (!pixelBuffer) 205 return nullptr; 206 207 if (frame.video_frame_buffer()->type() == VideoFrameBuffer::Type::kI420) 87 208 CopyVideoFrameToPixelBuffer(frame.video_frame_buffer()->GetI420(), pixelBuffer); 209 else if (frame.video_frame_buffer()->type() == VideoFrameBuffer::Type::kI010) 210 CopyVideoFrameToPixelBuffer(frame.video_frame_buffer()->GetI010(), pixelBuffer); 88 211 return pixelBuffer; 89 212 } -
trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitVP9Decoder.cpp
r263894 r265073 59 59 OSStatus decoderFailed(int error); 60 60 61 void createPixelBufferPoolForFormatDescription(CMFormatDescriptionRef); 62 61 63 private: 62 64 int32_t Decoded(VideoFrame&) final; … … 170 172 decoder->m_instance = std::make_unique<VP9DecoderImpl>(); 171 173 decoder->m_receiver = std::make_unique<WebKitVP9DecoderReceiver>(session); 174 decoder->m_receiver->createPixelBufferPoolForFormatDescription(formatDescription); 172 175 173 176 decoder->m_instance->RegisterDecodeCompleteCallback(decoder->m_receiver.get()); … … 254 257 } 255 258 259 void WebKitVP9DecoderReceiver::createPixelBufferPoolForFormatDescription(CMFormatDescriptionRef formatDescription) 260 { 261 // CoreAnimation doesn't support full-planar YUV, so we must convert the buffers output 262 // by libvpx to bi-planar YUV. Create pixel buffer attributes and give those to the 263 // decoder session for use in creating its own internal CVPixelBufferPool, which we 264 // will use post-decode. 265 bool isFullRange = false; 266 bool is10Bit = false; 267 268 do { 269 auto extensions = CMFormatDescriptionGetExtensions(formatDescription); 270 if (!extensions) 271 break; 272 273 CFTypeRef extensionAtoms = CFDictionaryGetValue(extensions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms); 274 if (!extensionAtoms || CFGetTypeID(extensionAtoms) != CFDictionaryGetTypeID()) 275 break; 276 277 auto configurationRecord = static_cast<CFDataRef>(CFDictionaryGetValue((CFDictionaryRef)extensionAtoms, CFSTR("vpcC"))); 278 if (!configurationRecord || CFGetTypeID(configurationRecord) != CFDataGetTypeID()) 279 break; 280 281 auto configurationRecordSize = CFDataGetLength(configurationRecord); 282 if (configurationRecordSize < 12) 283 break; 284 285 auto configurationRecordData = CFDataGetBytePtr(configurationRecord); 286 auto bitDepthChromaAndRange = *(configurationRecordData + 6); 287 288 if ((bitDepthChromaAndRange >> 4) == 10) 289 is10Bit = true; 290 291 if (bitDepthChromaAndRange & 0x1) 292 isFullRange = true; 293 } while (false); 294 295 OSType pixelFormat; 296 if (is10Bit) 297 pixelFormat = isFullRange ? kCVPixelFormatType_420YpCbCr10BiPlanarFullRange : kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange; 298 else 299 pixelFormat = isFullRange ? kCVPixelFormatType_420YpCbCr8BiPlanarFullRange : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; 300 301 auto createPixelFormatAttributes = [] (OSType pixelFormat, int32_t borderPixels) { 302 auto createNumber = [] (int32_t format) -> CFNumberRef { 303 return CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &format); 304 }; 305 auto cfPixelFormats = CFArrayCreateMutable(kCFAllocatorDefault, 2, &kCFTypeArrayCallBacks); 306 auto formatNumber = createNumber(pixelFormat); 307 CFArrayAppendValue(cfPixelFormats, formatNumber); 308 CFRelease(formatNumber); 309 310 auto borderPixelsValue = createNumber(32); 311 312 const void* keys[] = { 313 kCVPixelBufferPixelFormatTypeKey, 314 kCVPixelBufferExtendedPixelsLeftKey, 315 kCVPixelBufferExtendedPixelsRightKey, 316 kCVPixelBufferExtendedPixelsTopKey, 317 kCVPixelBufferExtendedPixelsBottomKey, 318 }; 319 const void* values[] = { 320 cfPixelFormats, 321 borderPixelsValue, 322 borderPixelsValue, 323 borderPixelsValue, 324 borderPixelsValue, 325 }; 326 auto attributes = CFDictionaryCreate(kCFAllocatorDefault, keys, values, std::size(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 327 CFRelease(borderPixelsValue); 328 CFRelease(cfPixelFormats); 329 return attributes; 330 }; 331 332 auto pixelBufferAttributes = createPixelFormatAttributes(pixelFormat, 32); 333 VTDecoderSessionSetPixelBufferAttributes(m_session, pixelBufferAttributes); 334 CFRelease(pixelBufferAttributes); 335 336 if (m_pixelBufferPool) { 337 CFRelease(m_pixelBufferPool); 338 m_pixelBufferPool = nullptr; 339 } 340 341 m_pixelBufferPool = VTDecoderSessionGetPixelBufferPool(m_session); 342 if (m_pixelBufferPool) 343 CFRetain(m_pixelBufferPool); 344 } 345 256 346 OSStatus WebKitVP9DecoderReceiver::decoderFailed(int error) 257 347 { … … 272 362 int32_t WebKitVP9DecoderReceiver::Decoded(VideoFrame& frame) 273 363 { 274 CVPixelBufferRef newPixelBuffer { nullptr }; 275 auto pixelBuffer = pixelBufferFromFrame(frame, [this, &newPixelBuffer](size_t width, size_t height) -> CVPixelBufferRef { 276 if (!m_pixelBufferPool || m_pixelBufferWidth != width || m_pixelBufferHeight != height) { 277 if (m_pixelBufferPool) 278 CFRelease(m_pixelBufferPool); 279 m_pixelBufferPool = createPixelBufferPool(width, height); 280 if (!m_pixelBufferPool) { 281 RTC_LOG(LS_ERROR) << "VP9 decoder: unable to create pixel buffer pool"; 282 return nullptr; 283 } 284 m_pixelBufferWidth = width; 285 m_pixelBufferHeight = height; 286 } 287 288 auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_pixelBufferPool, &newPixelBuffer); 289 if (status != kCVReturnSuccess) { 290 RTC_LOG(LS_ERROR) << "VP9 decoder: unable to create pixel buffer from pool"; 291 return nullptr; 292 } 293 294 return newPixelBuffer; 364 auto pixelBuffer = pixelBufferFromFrame(frame, [this](size_t width, size_t height) -> CVPixelBufferRef { 365 CVPixelBufferRef pixelBuffer = nullptr; 366 if (CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_pixelBufferPool, &pixelBuffer) == kCVReturnSuccess) 367 return pixelBuffer; 368 return nullptr; 295 369 }); 296 370 297 371 VTDecoderSessionEmitDecodedFrame(m_session, m_currentFrame, pixelBuffer ? noErr : -1, 0, pixelBuffer); 298 372 m_currentFrame = nullptr; 299 if ( newPixelBuffer)300 CFRelease( newPixelBuffer);373 if (pixelBuffer) 374 CFRelease(pixelBuffer); 301 375 return 0; 302 376 } -
trunk/Source/WebCore/ChangeLog
r265067 r265073 1 2020-07-29 Jer Noble <jer.noble@apple.com> 2 3 Support HDR decode in SW VP9 4 https://bugs.webkit.org/show_bug.cgi?id=214928 5 6 Reviewed by Eric Carlson. 7 8 Convert the incoming properties parsed from the VP9 header into extensions to our 9 CMFormatDescription attached to each incoming video fram. 10 11 Drive-by fix: Files in the wild will have incorrect values for whether a given 12 frame is a keyframe or not. Trust the VP9 header parser rather than the container 13 in this situations. 14 15 * platform/graphics/cocoa/SourceBufferParserWebM.cpp: 16 (WebCore::convertToCMColorPrimaries): 17 (WebCore::convertToCMTransferFunction): 18 (WebCore::convertToCMYCbCRMatrix): 19 (WebCore::createFormatDescriptionFromVP9HeaderParser): 20 (WebCore::SourceBufferParserWebM::OnFrame): 21 1 22 2020-07-29 Wenson Hsieh <wenson_hsieh@apple.com> 2 23 -
trunk/Source/WebCore/PAL/ChangeLog
r265010 r265073 1 2020-07-29 Jer Noble <jer.noble@apple.com> 2 3 Support HDR decode in SW VP9 4 https://bugs.webkit.org/show_bug.cgi?id=214928 5 <rdar://problem/66284848> 6 7 Reviewed by Eric Carlson. 8 9 * pal/cf/CoreMediaSoftLink.cpp: 10 * pal/cf/CoreMediaSoftLink.h: 11 1 12 2020-07-28 Jonathan Bedard <jbedard@apple.com> 2 13 -
trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp
r262708 r265073 65 65 66 66 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, CFStringRef, PAL_EXPORT) 67 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionColorPrimaries_DCI_P3, CFStringRef, PAL_EXPORT) 68 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionColorPrimaries_ITU_R_2020, CFStringRef, PAL_EXPORT) 69 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionColorPrimaries_P3_D65, CFStringRef, PAL_EXPORT) 70 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionExtension_FullRangeVideo, CFStringRef, PAL_EXPORT) 71 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_ITU_R_2020, CFStringRef, PAL_EXPORT) 72 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG, CFStringRef, PAL_EXPORT) 73 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_Linear, CFStringRef, PAL_EXPORT) 74 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ, CFStringRef, PAL_EXPORT) 75 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1, CFStringRef, PAL_EXPORT) 76 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionYCbCrMatrix_ITU_R_2020, CFStringRef, PAL_EXPORT) 67 77 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMTextMarkupAlignmentType_End, CFStringRef, PAL_EXPORT) 68 78 SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMTextMarkupAlignmentType_Middle, CFStringRef, PAL_EXPORT) … … 177 187 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferCallBlockForEachSample, OSStatus, (CMSampleBufferRef sbuf, OSStatus (^ CMSAMPLEBUFFERCALL_NOESCAPE handler)(CMSampleBufferRef, CMItemCount)), (sbuf, handler), PAL_EXPORT) 178 188 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionExtension_ProtectedContentOriginalFormat, CFStringRef, PAL_EXPORT) 179 189 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_sRGB, CFStringRef, PAL_EXPORT) 180 190 #endif // PLATFORM(COCOA) 181 191 -
trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h
r262708 r265073 87 87 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, CFStringRef) 88 88 #define kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms get_CoreMedia_kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms() 89 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionColorPrimaries_DCI_P3, CFStringRef) 90 #define kCMFormatDescriptionExtension_kCMFormatDescriptionColorPrimaries_DCI_P3 get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionColorPrimaries_DCI_P3() 91 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionColorPrimaries_ITU_R_2020, CFStringRef) 92 #define kCMFormatDescriptionExtension_kCMFormatDescriptionColorPrimaries_ITU_R_2020 get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionColorPrimaries_ITU_R_2020() 93 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionColorPrimaries_P3_D65, CFStringRef) 94 #define kCMFormatDescriptionExtension_kCMFormatDescriptionColorPrimaries_P3_D65 get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionColorPrimaries_P3_D65() 95 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionExtension_FullRangeVideo, CFStringRef) 96 #define kCMFormatDescriptionExtension_kCMFormatDescriptionExtension_FullRangeVideo get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionExtension_FullRangeVideo() 97 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_ITU_R_2020, CFStringRef) 98 #define kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_ITU_R_2020 get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_ITU_R_2020() 99 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG, CFStringRef) 100 #define kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG() 101 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_Linear, CFStringRef) 102 #define kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_Linear get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_Linear() 103 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ, CFStringRef) 104 #define kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ() 105 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1, CFStringRef) 106 #define kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1 get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1() 107 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionYCbCrMatrix_ITU_R_2020, CFStringRef) 108 #define kCMFormatDescriptionExtension_kCMFormatDescriptionYCbCrMatrix_ITU_R_2020 get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionYCbCrMatrix_ITU_R_2020() 89 109 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionExtension_ProtectedContentOriginalFormat, CFStringRef) 90 110 #define kCMFormatDescriptionExtension_ProtectedContentOriginalFormat get_CoreMedia_kCMFormatDescriptionExtension_ProtectedContentOriginalFormat() 111 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, CoreMedia, kCMFormatDescriptionTransferFunction_sRGB, CFStringRef) 112 #define kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_sRGB get_CoreMedia_kCMFormatDescriptionExtension_kCMFormatDescriptionTransferFunction_sRGB() 91 113 SOFT_LINK_CONSTANT_FOR_HEADER(PAL, CoreMedia, kCMTextMarkupAlignmentType_End, CFStringRef) 92 114 #define kCMTextMarkupAlignmentType_End get_CoreMedia_kCMTextMarkupAlignmentType_End() -
trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp
r261460 r265073 61 61 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_ITU_R_601_4, CFStringRef) 62 62 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_SMPTE_240M_1995, CFStringRef) 63 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferColorPrimaries_EBU_3213, CFStringRef) 64 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferColorPrimaries_ITU_R_709_2, CFStringRef) 65 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferColorPrimaries_SMPTE_C, CFStringRef) 66 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferColorPrimariesKey, CFStringRef) 67 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferTransferFunctionKey, CFStringRef) 68 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferTransferFunction_ITU_R_709_2, CFStringRef) 69 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferTransferFunction_SMPTE_240M_1995, CFStringRef) 63 70 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_DCI_P3, CFStringRef) 64 71 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_P3_D65, CFStringRef) -
trunk/Source/WebCore/platform/cocoa/CoreVideoSoftLink.h
r261460 r265073 96 96 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferCGImageCompatibilityKey, CFStringRef) 97 97 #define kCVPixelBufferCGImageCompatibilityKey get_CoreVideo_kCVPixelBufferCGImageCompatibilityKey() 98 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferColorPrimaries_EBU_3213, CFStringRef) 99 #define kCVImageBufferColorPrimaries_EBU_3213 get_CoreVideo_kCVImageBufferColorPrimaries_EBU_3213() 100 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferColorPrimaries_ITU_R_709_2, CFStringRef) 101 #define kCVImageBufferColorPrimaries_ITU_R_709_2 get_CoreVideo_kCVImageBufferColorPrimaries_ITU_R_709_2() 102 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferColorPrimaries_SMPTE_C, CFStringRef) 103 #define kCVImageBufferColorPrimaries_SMPTE_C get_CoreVideo_kCVImageBufferColorPrimaries_SMPTE_C() 104 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferColorPrimariesKey, CFStringRef) 105 #define kCVImageBufferColorPrimariesKey get_CoreVideo_kCVImageBufferColorPrimariesKey() 106 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferTransferFunctionKey, CFStringRef) 107 #define kCVImageBufferTransferFunctionKey get_CoreVideo_kCVImageBufferTransferFunctionKey() 108 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferTransferFunction_ITU_R_709_2, CFStringRef) 109 #define kCVImageBufferTransferFunction_ITU_R_709_2 get_CoreVideo_kCVImageBufferTransferFunction_ITU_R_709_2() 110 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferTransferFunction_SMPTE_240M_1995, CFStringRef) 111 #define kCVImageBufferTransferFunction_SMPTE_240M_1995 get_CoreVideo_kCVImageBufferTransferFunction_SMPTE_240M_1995() 98 112 99 113 #if USE(OPENGL_ES) -
trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp
r264796 r265073 30 30 31 31 #include "AudioTrackPrivateWebM.h" 32 #include "CoreVideoSoftLink.h" 32 33 #include "InbandTextTrackPrivate.h" 33 34 #include "MediaDescription.h" … … 39 40 #include "VideoTrackPrivateWebM.h" 40 41 #include <JavaScriptCore/DataView.h> 42 #include <pal/cf/CoreMediaSoftLink.h> 41 43 #include <webm/webm_parser.h> 42 44 #include <wtf/Algorithms.h> … … 49 51 50 52 namespace WebCore { 53 54 using namespace PAL; 51 55 52 56 static bool isWebmParserAvailable() … … 532 536 return VPConfigurationColorPrimaries::EBU_Tech_3213_E; 533 537 } 538 } 539 540 static CFStringRef convertToCMColorPrimaries(uint8_t primaries) 541 { 542 switch (primaries) { 543 case VPConfigurationColorPrimaries::BT_709_6: 544 return kCVImageBufferColorPrimaries_ITU_R_709_2; 545 case VPConfigurationColorPrimaries::EBU_Tech_3213_E: 546 return kCVImageBufferColorPrimaries_EBU_3213; 547 case VPConfigurationColorPrimaries::BT_601_7: 548 case VPConfigurationColorPrimaries::SMPTE_ST_240: 549 return kCVImageBufferColorPrimaries_SMPTE_C; 550 case VPConfigurationColorPrimaries::SMPTE_RP_431_2: 551 return kCMFormatDescriptionColorPrimaries_DCI_P3; 552 case VPConfigurationColorPrimaries::SMPTE_EG_432_1: 553 return kCMFormatDescriptionColorPrimaries_P3_D65; 554 case VPConfigurationColorPrimaries::BT_2020_Nonconstant_Luminance: 555 return kCMFormatDescriptionColorPrimaries_ITU_R_2020; 556 } 557 558 return nullptr; 534 559 } 535 560 … … 574 599 } 575 600 601 static CFStringRef convertToCMTransferFunction(uint8_t characteristics) 602 { 603 switch (characteristics) { 604 case VPConfigurationTransferCharacteristics::BT_709_6: 605 return kCVImageBufferTransferFunction_ITU_R_709_2; 606 case VPConfigurationTransferCharacteristics::SMPTE_ST_240: 607 return kCVImageBufferTransferFunction_SMPTE_240M_1995; 608 case VPConfigurationTransferCharacteristics::SMPTE_ST_2084: 609 return kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ; 610 case VPConfigurationTransferCharacteristics::BT_2020_10bit: 611 case VPConfigurationTransferCharacteristics::BT_2020_12bit: 612 return kCMFormatDescriptionTransferFunction_ITU_R_2020; 613 case VPConfigurationTransferCharacteristics::SMPTE_ST_428_1: 614 return kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1; 615 case VPConfigurationTransferCharacteristics::BT_2100_HLG: 616 return kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG; 617 case VPConfigurationTransferCharacteristics::IEC_61966_2_1: 618 return PAL::canLoad_CoreMedia_kCMFormatDescriptionTransferFunction_sRGB() ? get_CoreMedia_kCMFormatDescriptionTransferFunction_sRGB() : nullptr; 619 case VPConfigurationTransferCharacteristics::Linear: 620 return kCMFormatDescriptionTransferFunction_Linear; 621 } 622 623 return nullptr; 624 } 625 576 626 static uint8_t convertToMatrixCoefficients(const MatrixCoefficients& coefficients) 577 627 { … … 598 648 return VPConfigurationMatrixCoefficients::BT_2020_Constant_Luminance; 599 649 } 650 } 651 652 static CFStringRef convertToCMYCbCRMatrix(uint8_t coefficients) 653 { 654 switch (coefficients) { 655 case VPConfigurationMatrixCoefficients::BT_2020_Nonconstant_Luminance: 656 return kCMFormatDescriptionYCbCrMatrix_ITU_R_2020; 657 case VPConfigurationMatrixCoefficients::BT_470_7_BG: 658 case VPConfigurationMatrixCoefficients::BT_601_7: 659 return kCVImageBufferYCbCrMatrix_ITU_R_601_4; 660 case VPConfigurationMatrixCoefficients::BT_709_6: 661 return kCVImageBufferYCbCrMatrix_ITU_R_709_2; 662 case VPConfigurationMatrixCoefficients::SMPTE_ST_240: 663 return kCVImageBufferYCbCrMatrix_SMPTE_240M_1995; 664 } 665 666 return nullptr; 600 667 } 601 668 … … 692 759 auto configurationDict = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, configurationKeys, configurationValues, WTF_ARRAY_LENGTH(configurationKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 693 760 694 Vector<CFTypeRef> atomsKeys { kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms }; 695 Vector<CFTypeRef> atomsValues = { configurationDict.get() }; 696 auto atoms = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, atomsKeys.data(), atomsValues.data(), atomsKeys.size(), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 761 Vector<CFTypeRef> extensionsKeys { kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms }; 762 Vector<CFTypeRef> extensionsValues = { configurationDict.get() }; 763 764 if (record.videoFullRangeFlag == VPConfigurationRange::FullRange) { 765 extensionsKeys.append(kCMFormatDescriptionExtension_FullRangeVideo); 766 extensionsValues.append(kCFBooleanTrue); 767 } 768 769 if (auto cmColorPrimaries = convertToCMColorPrimaries(record.colorPrimaries)) { 770 extensionsKeys.append(kCVImageBufferColorPrimariesKey); 771 extensionsValues.append(cmColorPrimaries); 772 } 773 774 if (auto cmTransferFunction = convertToCMTransferFunction(record.transferCharacteristics)) { 775 extensionsKeys.append(kCVImageBufferTransferFunctionKey); 776 extensionsValues.append(cmTransferFunction); 777 } 778 779 if (auto cmMatrix = convertToCMYCbCRMatrix(record.matrixCoefficients)) { 780 extensionsKeys.append(kCVImageBufferYCbCrMatrixKey); 781 extensionsValues.append(cmMatrix); 782 } 783 784 auto extensions = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, extensionsKeys.data(), extensionsValues.data(), extensionsKeys.size(), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 697 785 698 786 CMVideoFormatDescriptionRef formatDescription = nullptr; 699 if (noErr != CMVideoFormatDescriptionCreate(kCFAllocatorDefault, kCMVideoCodecType_VP9, parser.width(), parser.height(), atoms.get(), &formatDescription))787 if (noErr != CMVideoFormatDescriptionCreate(kCFAllocatorDefault, kCMVideoCodecType_VP9, parser.width(), parser.height(), extensions.get(), &formatDescription)) 700 788 return nullptr; 701 789 return adoptCF(formatDescription); … … 722 810 return Status(Status::kInvalidElementId); 723 811 724 auto isSync = WTF::switchOn(*m_currentBlock, [](Block&) {725 return false;726 }, [](SimpleBlock& block) {727 return block.is_key_frame;728 });729 730 812 auto trackNumber = block->track_number; 731 813 … … 799 881 trackData->currentBlockBufferPosition = 0; 800 882 801 if (! isSync) {883 if (!headerParser.key()) { 802 884 auto attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer.get(), true); 803 885 ASSERT(attachmentsArray);
Note: See TracChangeset
for help on using the changeset viewer.