| Index: webrtc/test/frame_generator.cc
|
| diff --git a/webrtc/test/frame_generator.cc b/webrtc/test/frame_generator.cc
|
| index 9a14ff14d75f6156b4d98055491d25e70cc90f60..55e5a41548a5192361f090a8d20dc906eba8f60c 100644
|
| --- a/webrtc/test/frame_generator.cc
|
| +++ b/webrtc/test/frame_generator.cc
|
| @@ -15,7 +15,6 @@
|
|
|
| #include "webrtc/base/checks.h"
|
| #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
| -#include "webrtc/system_wrappers/interface/clock.h"
|
|
|
| namespace webrtc {
|
| namespace test {
|
| @@ -127,108 +126,6 @@ class YuvFileGenerator : public FrameGenerator {
|
| VideoFrame last_read_frame_;
|
| VideoFrame temp_frame_copy_;
|
| };
|
| -
|
| -class ScrollingImageFrameGenerator : public FrameGenerator {
|
| - public:
|
| - ScrollingImageFrameGenerator(Clock* clock,
|
| - const std::vector<FILE*>& files,
|
| - size_t source_width,
|
| - size_t source_height,
|
| - size_t target_width,
|
| - size_t target_height,
|
| - int64_t scroll_time_ms,
|
| - int64_t pause_time_ms)
|
| - : clock_(clock),
|
| - start_time_(clock->TimeInMilliseconds()),
|
| - scroll_time_(scroll_time_ms),
|
| - pause_time_(pause_time_ms),
|
| - num_frames_(files.size()),
|
| - current_frame_num_(num_frames_ - 1),
|
| - current_source_frame_(nullptr),
|
| - file_generator_(files, source_width, source_height, 1) {
|
| - DCHECK(clock_ != nullptr);
|
| - DCHECK_GT(num_frames_, 0u);
|
| - DCHECK_GE(source_height, target_height);
|
| - DCHECK_GE(source_width, target_width);
|
| - DCHECK_GE(scroll_time_ms, 0);
|
| - DCHECK_GE(pause_time_ms, 0);
|
| - DCHECK_GT(scroll_time_ms + pause_time_ms, 0);
|
| - current_frame_.CreateEmptyFrame(target_width, target_height, target_width,
|
| - (target_width + 1) / 2,
|
| - (target_width + 1) / 2);
|
| - }
|
| -
|
| - virtual ~ScrollingImageFrameGenerator() {}
|
| -
|
| - VideoFrame* NextFrame() override {
|
| - const int64_t kFrameDisplayTime = scroll_time_ + pause_time_;
|
| - const int64_t now = clock_->TimeInMilliseconds();
|
| - int64_t ms_since_start = now - start_time_;
|
| -
|
| - size_t frame_num = (ms_since_start / kFrameDisplayTime) % num_frames_;
|
| - UpdateSourceFrame(frame_num);
|
| -
|
| - double scroll_factor;
|
| - int64_t time_into_frame = ms_since_start % kFrameDisplayTime;
|
| - if (time_into_frame < scroll_time_) {
|
| - scroll_factor = static_cast<double>(time_into_frame) / scroll_time_;
|
| - } else {
|
| - scroll_factor = 1.0;
|
| - }
|
| - CropSourceToScrolledImage(scroll_factor);
|
| -
|
| - return ¤t_frame_;
|
| - }
|
| -
|
| - void UpdateSourceFrame(size_t frame_num) {
|
| - while (current_frame_num_ != frame_num) {
|
| - current_source_frame_ = file_generator_.NextFrame();
|
| - current_frame_num_ = (current_frame_num_ + 1) % num_frames_;
|
| - }
|
| - DCHECK(current_source_frame_ != nullptr);
|
| - }
|
| -
|
| - void CropSourceToScrolledImage(double scroll_factor) {
|
| - const int kTargetWidth = current_frame_.width();
|
| - const int kTargetHeight = current_frame_.height();
|
| - int scroll_margin_x = current_source_frame_->width() - kTargetWidth;
|
| - int pixels_scrolled_x =
|
| - static_cast<int>(scroll_margin_x * scroll_factor + 0.5);
|
| - int scroll_margin_y = current_source_frame_->height() - kTargetHeight;
|
| - int pixels_scrolled_y =
|
| - static_cast<int>(scroll_margin_y * scroll_factor + 0.5);
|
| -
|
| - int offset_y = (current_source_frame_->stride(PlaneType::kYPlane) *
|
| - pixels_scrolled_y) +
|
| - pixels_scrolled_x;
|
| - int offset_u = (current_source_frame_->stride(PlaneType::kUPlane) *
|
| - (pixels_scrolled_y / 2)) +
|
| - (pixels_scrolled_x / 2);
|
| - int offset_v = (current_source_frame_->stride(PlaneType::kVPlane) *
|
| - (pixels_scrolled_y / 2)) +
|
| - (pixels_scrolled_x / 2);
|
| -
|
| - current_frame_.CreateFrame(
|
| - ¤t_source_frame_->buffer(PlaneType::kYPlane)[offset_y],
|
| - ¤t_source_frame_->buffer(PlaneType::kUPlane)[offset_u],
|
| - ¤t_source_frame_->buffer(PlaneType::kVPlane)[offset_v],
|
| - kTargetWidth, kTargetHeight,
|
| - current_source_frame_->stride(PlaneType::kYPlane),
|
| - current_source_frame_->stride(PlaneType::kUPlane),
|
| - current_source_frame_->stride(PlaneType::kVPlane));
|
| - }
|
| -
|
| - Clock* const clock_;
|
| - const int64_t start_time_;
|
| - const int64_t scroll_time_;
|
| - const int64_t pause_time_;
|
| - const size_t num_frames_;
|
| - size_t current_frame_num_;
|
| - VideoFrame* current_source_frame_;
|
| - VideoFrame current_frame_;
|
| - YuvFileGenerator file_generator_;
|
| -};
|
| -
|
| } // namespace
|
|
|
| FrameGenerator* FrameGenerator::CreateChromaGenerator(size_t width,
|
| @@ -252,27 +149,5 @@ FrameGenerator* FrameGenerator::CreateFromYuvFile(
|
| return new YuvFileGenerator(files, width, height, frame_repeat_count);
|
| }
|
|
|
| -FrameGenerator* FrameGenerator::CreateScrollingInputFromYuvFiles(
|
| - Clock* clock,
|
| - std::vector<std::string> filenames,
|
| - size_t source_width,
|
| - size_t source_height,
|
| - size_t target_width,
|
| - size_t target_height,
|
| - int64_t scroll_time_ms,
|
| - int64_t pause_time_ms) {
|
| - assert(!filenames.empty());
|
| - std::vector<FILE*> files;
|
| - for (const std::string& filename : filenames) {
|
| - FILE* file = fopen(filename.c_str(), "rb");
|
| - DCHECK(file != nullptr);
|
| - files.push_back(file);
|
| - }
|
| -
|
| - return new ScrollingImageFrameGenerator(
|
| - clock, files, source_width, source_height, target_width, target_height,
|
| - scroll_time_ms, pause_time_ms);
|
| -}
|
| -
|
| } // namespace test
|
| } // namespace webrtc
|
|
|