2011-08-15 15:56:23 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 01:01:11 -08:00
|
|
|
#include <memory>
|
|
|
|
|
|
2013-01-08 19:19:59 +00:00
|
|
|
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
2015-11-18 22:31:24 +01:00
|
|
|
#include "webrtc/modules/video_processing/include/video_processing.h"
|
|
|
|
|
#include "webrtc/modules/video_processing/content_analysis.h"
|
|
|
|
|
#include "webrtc/modules/video_processing/test/video_processing_unittest.h"
|
2011-08-15 15:56:23 +00:00
|
|
|
|
2011-12-16 10:31:38 +00:00
|
|
|
namespace webrtc {
|
2011-08-15 15:56:23 +00:00
|
|
|
|
2016-01-04 22:44:05 +01:00
|
|
|
#if defined(WEBRTC_IOS)
|
2016-04-25 07:36:51 -07:00
|
|
|
TEST_F(VideoProcessingTest, DISABLED_ContentAnalysis) {
|
2016-01-04 22:44:05 +01:00
|
|
|
#else
|
2016-04-25 07:36:51 -07:00
|
|
|
TEST_F(VideoProcessingTest, ContentAnalysis) {
|
2016-01-04 22:44:05 +01:00
|
|
|
#endif
|
2015-12-07 22:54:50 -08:00
|
|
|
VPMContentAnalysis ca__c(false);
|
|
|
|
|
VPMContentAnalysis ca__sse(true);
|
2015-12-07 01:09:52 -08:00
|
|
|
VideoContentMetrics* _cM_c;
|
|
|
|
|
VideoContentMetrics* _cM_SSE;
|
2011-08-15 15:56:23 +00:00
|
|
|
|
2015-12-07 01:09:52 -08:00
|
|
|
ca__c.Initialize(width_, height_);
|
|
|
|
|
ca__sse.Initialize(width_, height_);
|
2011-08-15 15:56:23 +00:00
|
|
|
|
2016-03-02 01:01:11 -08:00
|
|
|
std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]);
|
2015-12-07 22:54:50 -08:00
|
|
|
while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
|
|
|
|
|
frame_length_) {
|
2013-10-03 16:42:41 +00:00
|
|
|
// Using ConvertToI420 to add stride to the image.
|
2015-03-09 17:07:31 +00:00
|
|
|
EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
|
|
|
|
|
0, kVideoRotation_0, &video_frame_));
|
2015-12-07 22:54:50 -08:00
|
|
|
_cM_c = ca__c.ComputeContentMetrics(video_frame_);
|
2013-10-03 16:42:41 +00:00
|
|
|
_cM_SSE = ca__sse.ComputeContentMetrics(video_frame_);
|
2011-08-15 15:56:23 +00:00
|
|
|
|
2013-10-03 16:42:41 +00:00
|
|
|
ASSERT_EQ(_cM_c->spatial_pred_err, _cM_SSE->spatial_pred_err);
|
|
|
|
|
ASSERT_EQ(_cM_c->spatial_pred_err_v, _cM_SSE->spatial_pred_err_v);
|
|
|
|
|
ASSERT_EQ(_cM_c->spatial_pred_err_h, _cM_SSE->spatial_pred_err_h);
|
|
|
|
|
ASSERT_EQ(_cM_c->motion_magnitude, _cM_SSE->motion_magnitude);
|
|
|
|
|
}
|
|
|
|
|
ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
|
2011-08-15 15:56:23 +00:00
|
|
|
}
|
2011-12-16 10:31:38 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|