Commit 16ebd8fb authored by Yuly Novikov's avatar Yuly Novikov Committed by Commit Bot

Revert "Add support for creating VP9 format extensions for VTVDA."

This reverts commit 320cb6fc.

Reason for revert: breaks compile on mac-arm64-rel

Original change's description:
> Add support for creating VP9 format extensions for VTVDA.
> 
> Creates a vpcc box based on the configuration info.
> 
> R=​sandersd
> 
> Bug: 1103432
> Test: Updated unittests.
> Change-Id: I3d5152b59c6f6ad82da25e699eba2d8bf5ba44ae
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346607
> Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
> Commit-Queue: Dan Sanders <sandersd@chromium.org>
> Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
> Reviewed-by: Dan Sanders <sandersd@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#796591}

TBR=dalecurtis@chromium.org,sandersd@chromium.org

Change-Id: I00b88a95637db2999f190c5945c97743112344e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1103432
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348148Reviewed-by: default avatarYuly Novikov <ynovikov@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796652}
parent bd7e63a3
...@@ -415,49 +415,6 @@ gfx::ColorSpace::MatrixID GetImageBufferMatrix(CVImageBufferRef image_buffer) { ...@@ -415,49 +415,6 @@ gfx::ColorSpace::MatrixID GetImageBufferMatrix(CVImageBufferRef image_buffer) {
return matrix_id; return matrix_id;
} }
void SetVp9CodecConfigurationBox(
media::VideoCodecProfile codec_profile,
const media::VideoColorSpace& color_space,
NSMutableDictionary<NSString*, id>* extensions) {
// Synthesize a 'vpcC' box. See
// https://www.webmproject.org/vp9/mp4/#vp-codec-configuration-box.
uint8_t version = 1;
uint8_t profile = 0;
uint8_t level = 51;
uint8_t bit_depth = 8;
uint8_t chroma_subsampling = 1; // 4:2:0 colocated with luma (0, 0).
uint8_t primaries = 1; // BT.709.
uint8_t transfer = 1; // BT.709.
uint8_t matrix = 1; // BT.709.
if (color_space.IsSpecified()) {
primaries = static_cast<uint8_t>(color_space.primaries);
transfer = static_cast<uint8_t>(color_space.transfer);
matrix = static_cast<uint8_t>(color_space.matrix);
}
if (codec_profile == media::VP9PROFILE_PROFILE2) {
profile = 2;
bit_depth = 10;
}
uint8_t vpcc[12] = {0};
vpcc[0] = version;
vpcc[4] = profile;
vpcc[5] = level;
vpcc[6] |= bit_depth << 4;
vpcc[6] |= chroma_subsampling << 1;
vpcc[7] = primaries;
vpcc[8] = transfer;
vpcc[9] = matrix;
SetDictionaryValue(
extensions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms,
@{
@"vpcC" : [NSData dataWithBytes:&vpcc length:sizeof(vpcc)],
});
SetDictionaryValue(extensions, CFSTR("BitsPerComponent"), @(bit_depth));
}
} // namespace } // namespace
namespace media { namespace media {
...@@ -503,9 +460,6 @@ CFMutableDictionaryRef CreateFormatExtensions( ...@@ -503,9 +460,6 @@ CFMutableDictionaryRef CreateFormatExtensions(
SetMasteringMetadata(*hdr_metadata, extensions); SetMasteringMetadata(*hdr_metadata, extensions);
} }
if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX)
SetVp9CodecConfigurationBox(profile, color_space, extensions);
return base::mac::NSToCFCast(extensions); return base::mac::NSToCFCast(extensions);
} }
......
...@@ -13,28 +13,29 @@ ...@@ -13,28 +13,29 @@
namespace { namespace {
std::string GetStrValue(CFDictionaryRef dict, CFStringRef key) { std::string GetStrValue(CFMutableDictionaryRef dict, CFStringRef key) {
return base::SysCFStringRefToUTF8( return base::SysCFStringRefToUTF8(
base::mac::CFCastStrict<CFStringRef>(CFDictionaryGetValue(dict, key))); base::mac::CFCastStrict<CFStringRef>(CFDictionaryGetValue(dict, key)));
} }
CFStringRef GetCFStrValue(CFDictionaryRef dict, CFStringRef key) { CFStringRef GetCFStrValue(CFMutableDictionaryRef dict, CFStringRef key) {
return base::mac::CFCastStrict<CFStringRef>(CFDictionaryGetValue(dict, key)); return base::mac::CFCastStrict<CFStringRef>(CFDictionaryGetValue(dict, key));
} }
int GetIntValue(CFDictionaryRef dict, CFStringRef key) { int GetIntValue(CFMutableDictionaryRef dict, CFStringRef key) {
CFNumberRef value = CFNumberRef value =
base::mac::CFCastStrict<CFNumberRef>(CFDictionaryGetValue(dict, key)); base::mac::CFCastStrict<CFNumberRef>(CFDictionaryGetValue(dict, key));
int result; int result;
return CFNumberGetValue(value, kCFNumberIntType, &result) ? result : -1; return CFNumberGetValue(value, kCFNumberIntType, &result) ? result : -1;
} }
bool GetBoolValue(CFDictionaryRef dict, CFStringRef key) { bool GetBoolValue(CFMutableDictionaryRef dict, CFStringRef key) {
return CFBooleanGetValue( return CFBooleanGetValue(
base::mac::CFCastStrict<CFBooleanRef>(CFDictionaryGetValue(dict, key))); base::mac::CFCastStrict<CFBooleanRef>(CFDictionaryGetValue(dict, key)));
} }
base::span<const uint8_t> GetDataValue(CFDictionaryRef dict, CFStringRef key) { base::span<const uint8_t> GetDataValue(CFMutableDictionaryRef dict,
CFStringRef key) {
CFDataRef data = CFDataRef data =
base::mac::CFCastStrict<CFDataRef>(CFDictionaryGetValue(dict, key)); base::mac::CFCastStrict<CFDataRef>(CFDictionaryGetValue(dict, key));
return data ? base::span<const uint8_t>( return data ? base::span<const uint8_t>(
...@@ -43,17 +44,9 @@ base::span<const uint8_t> GetDataValue(CFDictionaryRef dict, CFStringRef key) { ...@@ -43,17 +44,9 @@ base::span<const uint8_t> GetDataValue(CFDictionaryRef dict, CFStringRef key) {
: base::span<const uint8_t>(); : base::span<const uint8_t>();
} }
base::span<const uint8_t> GetNestedDataValue(CFDictionaryRef dict,
CFStringRef key1,
CFStringRef key2) {
CFDictionaryRef nested_dict = base::mac::CFCastStrict<CFDictionaryRef>(
CFDictionaryGetValue(dict, key1));
return GetDataValue(nested_dict, key2);
}
base::ScopedCFTypeRef<CVImageBufferRef> CreateCVImageBuffer( base::ScopedCFTypeRef<CVImageBufferRef> CreateCVImageBuffer(
media::VideoColorSpace cs) { media::VideoColorSpace cs) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt( base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(
CreateFormatExtensions(kCMVideoCodecType_H264, media::H264PROFILE_MAIN, CreateFormatExtensions(kCMVideoCodecType_H264, media::H264PROFILE_MAIN,
cs, media::HDRMetadata())); cs, media::HDRMetadata()));
...@@ -78,7 +71,7 @@ gfx::ColorSpace ToBT709_APPLE(gfx::ColorSpace cs) { ...@@ -78,7 +71,7 @@ gfx::ColorSpace ToBT709_APPLE(gfx::ColorSpace cs) {
cs.GetMatrixID(), cs.GetRangeID()); cs.GetMatrixID(), cs.GetRangeID());
} }
void AssertHasEmptyHDRMetadata(CFDictionaryRef fmt) { void AssertHasEmptyHDRMetadata(CFMutableDictionaryRef fmt) {
if (__builtin_available(macos 10.13, *)) { if (__builtin_available(macos 10.13, *)) {
// We constructed with an empty HDRMetadata, so all values should be zero. // We constructed with an empty HDRMetadata, so all values should be zero.
auto mdcv = GetDataValue( auto mdcv = GetDataValue(
...@@ -95,16 +88,12 @@ void AssertHasEmptyHDRMetadata(CFDictionaryRef fmt) { ...@@ -95,16 +88,12 @@ void AssertHasEmptyHDRMetadata(CFDictionaryRef fmt) {
} }
} }
constexpr CMVideoCodecType kCMVideoCodecType_VP9 = 'vp09';
constexpr char kBitDepthKey[] = "BitsPerComponent";
constexpr char kVpccKey[] = "vpcC";
} // namespace } // namespace
namespace media { namespace media {
TEST(VTConfigUtil, CreateFormatExtensions_H264_BT709) { TEST(VTConfigUtil, CreateFormatExtensions_H264_BT709) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt( base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(
CreateFormatExtensions(kCMVideoCodecType_H264, H264PROFILE_MAIN, CreateFormatExtensions(kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace::REC709(), base::nullopt)); VideoColorSpace::REC709(), base::nullopt));
EXPECT_EQ("avc1", GetStrValue(fmt, kCMFormatDescriptionExtension_FormatName)); EXPECT_EQ("avc1", GetStrValue(fmt, kCMFormatDescriptionExtension_FormatName));
...@@ -129,7 +118,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_H264_BT709) { ...@@ -129,7 +118,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_H264_BT709) {
} }
TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_PQ) { TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_PQ) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions( base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_H264, H264PROFILE_MAIN, kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace(VideoColorSpace::PrimaryID::BT2020, VideoColorSpace(VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::SMPTEST2084, VideoColorSpace::TransferID::SMPTEST2084,
...@@ -153,7 +142,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_PQ) { ...@@ -153,7 +142,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_PQ) {
} }
TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_HLG) { TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_HLG) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions( base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_H264, H264PROFILE_MAIN, kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace(VideoColorSpace::PrimaryID::BT2020, VideoColorSpace(VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::ARIB_STD_B67, VideoColorSpace::TransferID::ARIB_STD_B67,
...@@ -189,7 +178,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_HDRMetadata) { ...@@ -189,7 +178,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_HDRMetadata) {
mastering.primary_b = gfx::PointF(0.15, 0.06); mastering.primary_b = gfx::PointF(0.15, 0.06);
mastering.white_point = gfx::PointF(0.3127, 0.3290); mastering.white_point = gfx::PointF(0.3127, 0.3290);
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions( base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_H264, H264PROFILE_MAIN, kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace(VideoColorSpace::PrimaryID::BT2020, VideoColorSpace(VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::SMPTEST2084, VideoColorSpace::TransferID::SMPTEST2084,
...@@ -237,47 +226,6 @@ TEST(VTConfigUtil, CreateFormatExtensions_HDRMetadata) { ...@@ -237,47 +226,6 @@ TEST(VTConfigUtil, CreateFormatExtensions_HDRMetadata) {
} }
} }
TEST(VTConfigUtil, CreateFormatExtensions_VP9Profile0) {
constexpr VideoCodecProfile kTestProfile = VP9PROFILE_PROFILE0;
const auto kTestColorSpace = VideoColorSpace::REC709();
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_VP9, kTestProfile, kTestColorSpace, base::nullopt));
EXPECT_EQ(8, GetIntValue(fmt, base::SysUTF8ToCFStringRef(kBitDepthKey)));
auto vpcc = GetNestedDataValue(
fmt, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms,
base::SysUTF8ToCFStringRef(kVpccKey));
std::unique_ptr<mp4::BoxReader> box_reader(
mp4::BoxReader::ReadConcatentatedBoxes(vpcc.data(), vpcc.size(),
nullptr));
mp4::VPCodecConfigurationRecord vpcc_box;
ASSERT_TRUE(vpcc_box.Parse(box_reader.get()));
ASSERT_EQ(kTestProfile, vpcc_box.profile);
ASSERT_EQ(kTestColorSpace, vpcc_box.color_space);
}
TEST(VTConfigUtil, CreateFormatExtensions_VP9Profile2) {
constexpr VideoCodecProfile kTestProfile = VP9PROFILE_PROFILE2;
const VideoColorSpace kTestColorSpace(
VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::SMPTEST2084,
VideoColorSpace::MatrixID::BT2020_NCL, gfx::ColorSpace::RangeID::LIMITED);
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_VP9, kTestProfile, kTestColorSpace, base::nullopt));
EXPECT_EQ(10, GetIntValue(fmt, base::SysUTF8ToCFStringRef(kBitDepthKey)));
auto vpcc = GetNestedDataValue(
fmt, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms,
base::SysUTF8ToCFStringRef(kVpccKey));
std::unique_ptr<mp4::BoxReader> box_reader(
mp4::BoxReader::ReadConcatentatedBoxes(vpcc.data(), vpcc.size(),
nullptr));
mp4::VPCodecConfigurationRecord vpcc_box;
ASSERT_TRUE(vpcc_box.Parse(box_reader.get()));
ASSERT_EQ(kTestProfile, vpcc_box.profile);
ASSERT_EQ(kTestColorSpace, vpcc_box.color_space);
}
TEST(VTConfigUtil, GetImageBufferColorSpace_BT601) { TEST(VTConfigUtil, GetImageBufferColorSpace_BT601) {
auto cs = VideoColorSpace::REC601(); auto cs = VideoColorSpace::REC601();
auto image_buffer = CreateCVImageBuffer(cs); auto image_buffer = CreateCVImageBuffer(cs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment