Commit 253bd58a authored by Daniel McArdle's avatar Daniel McArdle Committed by Commit Bot

Revert "Replace base::MD5Context with boringssl in //media"

This reverts commit ec2ce628.

Reason for revert: Pursuing alternate strategy of preserving base::MD5 interface, but replacing its implementation with boringssl.

Original change's description:
> Replace base::MD5Context with boringssl in //media
> 
> Testing with media_unittests
> 
> Bug: 755368
> Change-Id: I9b45735a5d3054207d3bc340bce45fb25014a447
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1568847
> Auto-Submit: Daniel McArdle <dmcardle@chromium.org>
> Commit-Queue: Daniel McArdle <dmcardle@chromium.org>
> Reviewed-by: Dan Sanders <sandersd@chromium.org>
> Reviewed-by: David Benjamin <davidben@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#653350}

TBR=davidben@chromium.org,sandersd@chromium.org,dmcardle@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 755368
Change-Id: I79c40ea2ee09637b78abc7ad50b049980c934e0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1600777Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Daniel McArdle <dmcardle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657779}
parent f884ba7a
......@@ -12,7 +12,6 @@ include_rules = [
"+mojo/public/cpp/system/platform_handle.h",
"+services/ws/public/cpp/gpu/context_provider_command_buffer.h",
"+skia/ext",
"+third_party/boringssl/src/include",
"+third_party/dav1d",
"+third_party/ffmpeg",
"+third_party/libaom",
......
......@@ -306,7 +306,6 @@ jumbo_source_set("base") {
":video_facing",
"//media:media_buildflags",
"//media:shared_memory_support",
"//third_party/boringssl",
"//ui/gfx:color_space",
]
deps = [
......
......@@ -841,13 +841,15 @@ size_t VideoFrame::Columns(size_t plane, VideoPixelFormat format, int width) {
}
// static
void VideoFrame::HashFrameForTesting(MD5_CTX* context,
void VideoFrame::HashFrameForTesting(base::MD5Context* context,
const VideoFrame& frame) {
DCHECK(context);
for (size_t plane = 0; plane < NumPlanes(frame.format()); ++plane) {
for (int row = 0; row < frame.rows(plane); ++row) {
MD5_Update(context, (frame.data(plane) + frame.stride(plane) * row),
frame.row_bytes(plane));
base::MD5Update(context, base::StringPiece(reinterpret_cast<const char*>(
frame.data(plane) +
frame.stride(plane) * row),
frame.row_bytes(plane)));
}
}
}
......
......@@ -14,6 +14,7 @@
#include <vector>
#include "base/callback.h"
#include "base/hash/md5.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/aligned_memory.h"
......@@ -29,7 +30,6 @@
#include "media/base/video_frame_layout.h"
#include "media/base/video_frame_metadata.h"
#include "media/base/video_types.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
......@@ -365,8 +365,9 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
static size_t Columns(size_t plane, VideoPixelFormat format, int width);
// Used to keep a running hash of seen frames. Expects an initialized MD5
// context. Calls MD5_Update with the context and the contents of the frame.
static void HashFrameForTesting(MD5_CTX* context, const VideoFrame& frame);
// context. Calls MD5Update with the context and the contents of the frame.
static void HashFrameForTesting(base::MD5Context* context,
const VideoFrame& frame);
// Returns true if |frame| is accesible mapped in the VideoFrame memory space.
// static
......
......@@ -16,14 +16,11 @@
#include "base/memory/shared_memory.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
#include "media/base/simple_sync_token_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
#include "third_party/libyuv/include/libyuv.h"
namespace {
......@@ -53,6 +50,8 @@ void CreateTestY16Frame(const gfx::Size& coded_size,
namespace media {
using base::MD5DigestToBase16;
// Helper function that initializes a YV12 frame with white and black scan
// lines based on the |white_to_black| parameter. If 0, then the entire
// frame will be black, if 1 then the entire frame will be white.
......@@ -143,12 +142,12 @@ void ExpectFrameExtents(VideoPixelFormat format, const char* expected_hash) {
frame->stride(plane) * frame->rows(plane));
}
MD5_CTX context;
MD5_Init(&context);
base::MD5Context context;
base::MD5Init(&context);
VideoFrame::HashFrameForTesting(&context, *frame.get());
uint8_t digest[MD5_DIGEST_LENGTH];
MD5_Final(digest, &context);
EXPECT_EQ(base::HexEncode(digest, MD5_DIGEST_LENGTH), expected_hash);
base::MD5Digest digest;
base::MD5Final(&digest, &context);
EXPECT_EQ(MD5DigestToBase16(digest), expected_hash);
}
TEST(VideoFrame, CreateFrame) {
......@@ -169,23 +168,21 @@ TEST(VideoFrame, CreateFrame) {
InitializeYV12Frame(frame.get(), 0.0f);
ExpectFrameColor(frame.get(), 0xFF000000);
}
uint8_t digest[MD5_DIGEST_LENGTH];
MD5_CTX context;
MD5_Init(&context);
base::MD5Digest digest;
base::MD5Context context;
base::MD5Init(&context);
VideoFrame::HashFrameForTesting(&context, *frame.get());
MD5_Final(digest, &context);
EXPECT_EQ(base::HexEncode(digest, MD5_DIGEST_LENGTH),
"9065C841D9FCA49186EF8B4EF547E79B");
base::MD5Final(&digest, &context);
EXPECT_EQ(MD5DigestToBase16(digest), "9065c841d9fca49186ef8b4ef547e79b");
{
SCOPED_TRACE("");
InitializeYV12Frame(frame.get(), 1.0f);
ExpectFrameColor(frame.get(), 0xFFFFFFFF);
}
MD5_Init(&context);
base::MD5Init(&context);
VideoFrame::HashFrameForTesting(&context, *frame.get());
MD5_Final(digest, &context);
EXPECT_EQ(base::HexEncode(digest, MD5_DIGEST_LENGTH),
"911991D51438AD2E1A40ED5F6FC7C796");
base::MD5Final(&digest, &context);
EXPECT_EQ(MD5DigestToBase16(digest), "911991d51438ad2e1a40ed5f6fc7c796");
// Test single planar frame.
frame = VideoFrame::CreateFrame(media::PIXEL_FORMAT_ARGB, size,
......@@ -437,8 +434,8 @@ TEST(VideoFrame, WrapExternalDmabufs) {
TEST(VideoFrame, CheckFrameExtents) {
// Each call consists of a Format and the expected hash of all
// planes if filled with kFillByte (defined in ExpectFrameExtents).
ExpectFrameExtents(PIXEL_FORMAT_YV12, "8E5D54CB23CD0EDCA111DD35FFB6FF05");
ExpectFrameExtents(PIXEL_FORMAT_I422, "CCE408A044B212DB42A10DFEC304B3EF");
ExpectFrameExtents(PIXEL_FORMAT_YV12, "8e5d54cb23cd0edca111dd35ffb6ff05");
ExpectFrameExtents(PIXEL_FORMAT_I422, "cce408a044b212db42a10dfec304b3ef");
}
static void TextureCallback(gpu::SyncToken* called_sync_token,
......
......@@ -363,7 +363,6 @@ test("capture_unittests") {
"//mojo/core/embedder",
"//testing/gmock",
"//testing/gtest",
"//third_party/boringssl",
"//ui/gfx:test_support",
]
......
......@@ -25,7 +25,6 @@ source_set("android") {
"//media/capture:capture_device_specific",
"//media/capture/mojom:image_capture",
"//media/capture/mojom:image_capture_types",
"//third_party/boringssl",
"//third_party/libyuv",
"//ui/gfx:color_space",
"//ui/gfx/geometry",
......
......@@ -377,7 +377,6 @@ source_set("unit_tests") {
deps += [
# Direct dependency needed for the config
"//third_party/boringssl",
"//third_party/opus",
]
......
......@@ -11,6 +11,7 @@
#include "base/bind_helpers.h"
#include "base/containers/circular_deque.h"
#include "base/format_macros.h"
#include "base/hash/md5.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
......@@ -32,7 +33,6 @@
#include "media/filters/in_memory_url_protocol.h"
#include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
......@@ -318,17 +318,17 @@ class AudioDecoderTest
AudioBus::Create(buffer->channel_count(), buffer->frame_count());
buffer->ReadFrames(buffer->frame_count(), 0, 0, output.get());
MD5_CTX context;
MD5_Init(&context);
base::MD5Context context;
base::MD5Init(&context);
for (int ch = 0; ch < output->channels(); ++ch) {
MD5_Update(&context, reinterpret_cast<char*>(output->channel(ch)),
output->frames() * sizeof(*output->channel(ch)));
base::MD5Update(
&context,
base::StringPiece(reinterpret_cast<char*>(output->channel(ch)),
output->frames() * sizeof(*output->channel(ch))));
}
uint8_t digest[MD5_DIGEST_LENGTH];
MD5_Final(digest, &context);
return base::HexEncode(digest, MD5_DIGEST_LENGTH);
base::MD5Digest digest;
base::MD5Final(&digest, &context);
return base::MD5DigestToBase16(digest);
}
// Android MediaCodec returns wrong timestamps (shifted one frame forward)
......
......@@ -5,11 +5,10 @@
#include "media/filters/audio_file_reader.h"
#include <memory>
#include <string>
#include "base/hash/md5.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_hash.h"
......@@ -19,7 +18,6 @@
#include "media/filters/in_memory_url_protocol.h"
#include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
namespace media {
......@@ -73,11 +71,8 @@ class AudioFileReaderTest : public testing::Test {
// On the first pass save the MD5 hash of each packet, on subsequent
// passes ensure it matches.
uint8_t digest[MD5_DIGEST_LENGTH];
MD5(packet.data, packet.size, digest);
const std::string md5_hash =
base::HexEncode(packet.data, MD5_DIGEST_LENGTH);
const std::string md5_hash = base::MD5String(base::StringPiece(
reinterpret_cast<char*>(packet.data), packet.size));
if (i == 0) {
packet_md5_hashes_.push_back(md5_hash);
if (j == 0) {
......
......@@ -5,9 +5,9 @@
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include "base/files/file_path.h"
#include "base/hash/md5.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
......
......@@ -7,12 +7,10 @@
#include <memory>
#include "base/files/file_util.h"
#include "base/hash/md5.h"
#include "base/json/json_reader.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "media/base/test_data_util.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
#define VLOGF(level) VLOG(level) << __func__ << "(): "
......@@ -77,12 +75,9 @@ bool Image::Load() {
}
// Verify that the image's checksum matches the checksum in the metadata.
uint8_t digest[MD5_DIGEST_LENGTH];
MD5(mapped_file_.data(), mapped_file_.length(), digest);
const std::string md5_hash =
base::ToLowerASCII(base::HexEncode(digest, MD5_DIGEST_LENGTH));
if (md5_hash != checksum_) {
base::MD5Digest digest;
base::MD5Sum(mapped_file_.data(), mapped_file_.length(), &digest);
if (base::MD5DigestToBase16(digest) != checksum_) {
LOG(ERROR) << "Image checksum not matching metadata";
return false;
}
......
......@@ -6,16 +6,15 @@
#include "base/bind.h"
#include "base/files/file.h"
#include "base/hash/md5.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "media/base/video_frame.h"
#include "media/gpu/test/video_decode_accelerator_unittest_helpers.h"
#include "media/gpu/video_frame_mapper.h"
#include "media/gpu/video_frame_mapper_factory.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
namespace media {
namespace test {
......@@ -155,12 +154,12 @@ void VideoFrameValidator::ProcessVideoFrameTask(
std::string VideoFrameValidator::ComputeMD5FromVideoFrame(
const VideoFrame* video_frame) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(validator_thread_sequence_checker_);
MD5_CTX context;
MD5_Init(&context);
base::MD5Context context;
base::MD5Init(&context);
VideoFrame::HashFrameForTesting(&context, *video_frame);
uint8_t digest[MD5_DIGEST_LENGTH];
MD5_Final(digest, &context);
return base::ToLowerASCII(base::HexEncode(digest, MD5_DIGEST_LENGTH));
base::MD5Digest digest;
base::MD5Final(&digest, &context);
return MD5DigestToBase16(digest);
}
} // namespace test
......
......@@ -8,7 +8,6 @@
#include "base/files/file_util.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "media/base/bind_to_current_loop.h"
#include "media/gpu/test/rendering_helper.h"
......@@ -230,10 +229,8 @@ bool FrameRendererThumbnail::ValidateThumbnail() {
<< "RGBA frame has incorrect alpha";
// Calculate the thumbnail's checksum and compare it to golden values.
uint8_t digest[MD5_DIGEST_LENGTH];
MD5(reinterpret_cast<uint8_t*>(&rgb[0]), rgb.size(), digest);
std::string md5_string =
base::ToLowerASCII(base::HexEncode(digest, MD5_DIGEST_LENGTH));
std::string md5_string = base::MD5String(
base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size()));
bool is_valid_thumbnail =
base::ContainsValue(thumbnail_checksums_, md5_string);
......
......@@ -103,7 +103,6 @@ source_set("unit_test") {
deps = [
":v4l2",
"//testing/gtest",
"//third_party/boringssl",
"//ui/gfx:test_support",
"//ui/gl",
]
......
......@@ -145,7 +145,6 @@ source_set("unit_test") {
"//mojo/core/embedder",
"//testing/gmock",
"//testing/gtest",
"//third_party/boringssl",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
]
......
......@@ -34,6 +34,7 @@
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/hash/md5.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
......@@ -43,7 +44,6 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringize_macros.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
......@@ -73,7 +73,6 @@
#include "media/video/h264_parser.h"
#include "mojo/core/embedder/embedder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gl/gl_image.h"
......@@ -1399,11 +1398,8 @@ TEST_P(VideoDecodeAcceleratorParamTest, MAYBE_TestSimpleDecode) {
EXPECT_EQ(media::test::ConvertRGBAToRGB(rgba, &rgb), true)
<< "RGBA frame had incorrect alpha";
uint8_t digest[MD5_DIGEST_LENGTH];
MD5(reinterpret_cast<uint8_t*>(&rgb[0]), rgb.size(), digest);
std::string md5_string =
base::ToLowerASCII(base::HexEncode(digest, MD5_DIGEST_LENGTH));
std::string md5_string = base::MD5String(
base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size()));
base::FilePath filepath(test_video_files_[0]->file_name);
auto golden_md5s = media::test::ReadGoldenThumbnailMD5s(
filepath.AddExtension(FILE_PATH_LITERAL(".md5")));
......
......@@ -5,18 +5,13 @@
#include "media/test/pipeline_integration_test_base.h"
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
......@@ -29,7 +24,6 @@
#include "media/renderers/renderer_impl.h"
#include "media/test/fake_encrypted_media.h"
#include "media/test/test_media_source.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
#include "third_party/libaom/libaom_buildflags.h"
#if BUILDFLAG(ENABLE_LIBAOM_DECODER)
......@@ -567,14 +561,14 @@ base::TimeDelta PipelineIntegrationTestBase::GetStartTime() {
void PipelineIntegrationTestBase::ResetVideoHash() {
DVLOG(1) << __func__;
MD5_Init(&md5_context_);
base::MD5Init(&md5_context_);
}
std::string PipelineIntegrationTestBase::GetVideoHash() {
DCHECK(hashing_enabled_);
uint8_t digest[MD5_DIGEST_LENGTH];
MD5_Final(digest, &md5_context_);
return base::ToLowerASCII(base::HexEncode(digest, MD5_DIGEST_LENGTH));
base::MD5Digest digest;
base::MD5Final(&digest, &md5_context_);
return base::MD5DigestToBase16(digest);
}
std::string PipelineIntegrationTestBase::GetAudioHash() {
......
......@@ -7,11 +7,9 @@
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/callback_forward.h"
#include "base/hash/md5.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
......@@ -28,7 +26,6 @@
#include "media/renderers/audio_renderer_impl.h"
#include "media/renderers/video_renderer_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
using ::testing::NiceMock;
......@@ -156,7 +153,7 @@ class PipelineIntegrationTestBase : public Pipeline::Client {
protected:
NiceMock<MockMediaLog> media_log_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
MD5_CTX md5_context_;
base::MD5Context md5_context_;
bool hashing_enabled_;
bool clockless_playback_;
bool webaudio_attached_;
......
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