Commit 91e1a496 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

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

This reverts commit 659a4e4e.

Reason for revert: Closed the tree with a compile failure:

https://ci.chromium.org/p/chromium/builders/ci/mac-arm64-rel/334

[263/11988] OBJCXX clang_x64/obj/base/base/sdk_forward_declarations.o
FAILED: clang_x64/obj/base/base/sdk_forward_declarations.o
/opt/s/w/ir/cache/goma/client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -...(too long)
In file included from ../../base/mac/sdk_forward_declarations.mm:5:
../../base/mac/sdk_forward_declarations.h:70:3: error: declaration shadows a variable in the global namespace [-Werror,-Wshadow]
kCMVideoCodecType_VP9 = 'vp09'
^
../../build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CMFormatDescription.h:618:2: note: previous declaration is here

Original change's description:
> Reland: "Add support for creating VP9 format extensions for VTVDA."
> 
> Creates a vpcc box based on the configuration info. Reland now uses
> a forward declaration for the kCMVideoCodecType_VP9 which is in the
> 11.0/10.16 SDK.
> 
> R=​avi, sandersd
> 
> Bug: 1103432, 1105187
> Test: Updated unittests.
> Change-Id: I15158ec3329054981cab4eefc3316283952f2f48
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348330
> Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#796873}

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

Change-Id: I6b767665887cee003dea63c3b037769a34021ea7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1103432
Bug: 1105187
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346979Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796907}
parent bccd92f7
......@@ -8,6 +8,7 @@
#ifndef BASE_MAC_SDK_FORWARD_DECLARATIONS_H_
#define BASE_MAC_SDK_FORWARD_DECLARATIONS_H_
#import <AppKit/AppKit.h>
#include <AvailabilityMacros.h>
#include <os/availability.h>
......@@ -63,12 +64,7 @@
//
// ----------------------------------------------------------------------------
#if !defined(MAC_OS_X_VERSION_10_16) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_16
#include <CoreMedia/CoreMedia.h>
enum : CMVideoCodecType {
kCMVideoCodecType_VP9 = 'vp09'
};
#endif // MAC_OS_X_VERSION_MAX_ALLOWED
// Chromium currently is building with the most recent SDK. WWDC is not far
// away, though....
#endif // BASE_MAC_SDK_FORWARD_DECLARATIONS_H_
......@@ -415,49 +415,6 @@ gfx::ColorSpace::MatrixID GetImageBufferMatrix(CVImageBufferRef image_buffer) {
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 media {
......@@ -503,9 +460,6 @@ CFMutableDictionaryRef CreateFormatExtensions(
SetMasteringMetadata(*hdr_metadata, extensions);
}
if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX)
SetVp9CodecConfigurationBox(profile, color_space, extensions);
return base::mac::NSToCFCast(extensions);
}
......
......@@ -4,40 +4,38 @@
#include "media/gpu/mac/vt_config_util.h"
#include <CoreMedia/CoreMedia.h>
#include "base/containers/span.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h"
#include "media/formats/mp4/box_definitions.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
std::string GetStrValue(CFDictionaryRef dict, CFStringRef key) {
std::string GetStrValue(CFMutableDictionaryRef dict, CFStringRef key) {
return base::SysCFStringRefToUTF8(
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));
}
int GetIntValue(CFDictionaryRef dict, CFStringRef key) {
int GetIntValue(CFMutableDictionaryRef dict, CFStringRef key) {
CFNumberRef value =
base::mac::CFCastStrict<CFNumberRef>(CFDictionaryGetValue(dict, key));
int result;
return CFNumberGetValue(value, kCFNumberIntType, &result) ? result : -1;
}
bool GetBoolValue(CFDictionaryRef dict, CFStringRef key) {
bool GetBoolValue(CFMutableDictionaryRef dict, CFStringRef key) {
return CFBooleanGetValue(
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 =
base::mac::CFCastStrict<CFDataRef>(CFDictionaryGetValue(dict, key));
return data ? base::span<const uint8_t>(
......@@ -46,17 +44,9 @@ base::span<const uint8_t> GetDataValue(CFDictionaryRef dict, CFStringRef key) {
: 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(
media::VideoColorSpace cs) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt(
base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(
CreateFormatExtensions(kCMVideoCodecType_H264, media::H264PROFILE_MAIN,
cs, media::HDRMetadata()));
......@@ -81,7 +71,7 @@ gfx::ColorSpace ToBT709_APPLE(gfx::ColorSpace cs) {
cs.GetMatrixID(), cs.GetRangeID());
}
void AssertHasEmptyHDRMetadata(CFDictionaryRef fmt) {
void AssertHasEmptyHDRMetadata(CFMutableDictionaryRef fmt) {
if (__builtin_available(macos 10.13, *)) {
// We constructed with an empty HDRMetadata, so all values should be zero.
auto mdcv = GetDataValue(
......@@ -98,15 +88,12 @@ void AssertHasEmptyHDRMetadata(CFDictionaryRef fmt) {
}
}
constexpr char kBitDepthKey[] = "BitsPerComponent";
constexpr char kVpccKey[] = "vpcC";
} // namespace
namespace media {
TEST(VTConfigUtil, CreateFormatExtensions_H264_BT709) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt(
base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(
CreateFormatExtensions(kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace::REC709(), base::nullopt));
EXPECT_EQ("avc1", GetStrValue(fmt, kCMFormatDescriptionExtension_FormatName));
......@@ -131,7 +118,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_H264_BT709) {
}
TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_PQ) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions(
base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace(VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::SMPTEST2084,
......@@ -155,7 +142,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_PQ) {
}
TEST(VTConfigUtil, CreateFormatExtensions_H264_BT2020_HLG) {
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions(
base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace(VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::ARIB_STD_B67,
......@@ -191,7 +178,7 @@ TEST(VTConfigUtil, CreateFormatExtensions_HDRMetadata) {
mastering.primary_b = gfx::PointF(0.15, 0.06);
mastering.white_point = gfx::PointF(0.3127, 0.3290);
base::ScopedCFTypeRef<CFDictionaryRef> fmt(CreateFormatExtensions(
base::ScopedCFTypeRef<CFMutableDictionaryRef> fmt(CreateFormatExtensions(
kCMVideoCodecType_H264, H264PROFILE_MAIN,
VideoColorSpace(VideoColorSpace::PrimaryID::BT2020,
VideoColorSpace::TransferID::SMPTEST2084,
......@@ -239,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) {
auto cs = VideoColorSpace::REC601();
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