Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.cc

Issue 2993063002: Remove source file writer from VideoProcessor. (Closed)
Patch Set: video_quality_measurement updates. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 } 106 }
107 107
108 VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder, 108 VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
109 webrtc::VideoDecoder* decoder, 109 webrtc::VideoDecoder* decoder,
110 FrameReader* analysis_frame_reader, 110 FrameReader* analysis_frame_reader,
111 FrameWriter* analysis_frame_writer, 111 FrameWriter* analysis_frame_writer,
112 PacketManipulator* packet_manipulator, 112 PacketManipulator* packet_manipulator,
113 const TestConfig& config, 113 const TestConfig& config,
114 Stats* stats, 114 Stats* stats,
115 FrameWriter* source_frame_writer,
116 IvfFileWriter* encoded_frame_writer, 115 IvfFileWriter* encoded_frame_writer,
117 FrameWriter* decoded_frame_writer) 116 FrameWriter* decoded_frame_writer)
118 : encoder_(encoder), 117 : encoder_(encoder),
119 decoder_(decoder), 118 decoder_(decoder),
120 bitrate_allocator_(CreateBitrateAllocator(config)), 119 bitrate_allocator_(CreateBitrateAllocator(config)),
121 encode_callback_(new VideoProcessorEncodeCompleteCallback(this)), 120 encode_callback_(new VideoProcessorEncodeCompleteCallback(this)),
122 decode_callback_(new VideoProcessorDecodeCompleteCallback(this)), 121 decode_callback_(new VideoProcessorDecodeCompleteCallback(this)),
123 packet_manipulator_(packet_manipulator), 122 packet_manipulator_(packet_manipulator),
124 config_(config), 123 config_(config),
125 analysis_frame_reader_(analysis_frame_reader), 124 analysis_frame_reader_(analysis_frame_reader),
126 analysis_frame_writer_(analysis_frame_writer), 125 analysis_frame_writer_(analysis_frame_writer),
127 source_frame_writer_(source_frame_writer),
128 encoded_frame_writer_(encoded_frame_writer), 126 encoded_frame_writer_(encoded_frame_writer),
129 decoded_frame_writer_(decoded_frame_writer), 127 decoded_frame_writer_(decoded_frame_writer),
130 initialized_(false), 128 initialized_(false),
131 last_encoded_frame_num_(-1), 129 last_encoded_frame_num_(-1),
132 last_decoded_frame_num_(-1), 130 last_decoded_frame_num_(-1),
133 first_key_frame_has_been_excluded_(false), 131 first_key_frame_has_been_excluded_(false),
134 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()), 132 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()),
135 stats_(stats), 133 stats_(stats),
136 num_dropped_frames_(0), 134 num_dropped_frames_(0),
137 num_spatial_resizes_(0) { 135 num_spatial_resizes_(0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; 201 RTC_DCHECK(initialized_) << "VideoProcessor not initialized.";
204 202
205 rtc::scoped_refptr<I420BufferInterface> buffer( 203 rtc::scoped_refptr<I420BufferInterface> buffer(
206 analysis_frame_reader_->ReadFrame()); 204 analysis_frame_reader_->ReadFrame());
207 205
208 if (!buffer) { 206 if (!buffer) {
209 // Last frame has been reached. 207 // Last frame has been reached.
210 return false; 208 return false;
211 } 209 }
212 210
213 if (source_frame_writer_) {
214 size_t length =
215 CalcBufferSize(VideoType::kI420, buffer->width(), buffer->height());
216 rtc::Buffer extracted_buffer(length);
217 int extracted_length =
218 ExtractBuffer(buffer, length, extracted_buffer.data());
219 RTC_DCHECK_EQ(extracted_length, source_frame_writer_->FrameLength());
220 RTC_CHECK(source_frame_writer_->WriteFrame(extracted_buffer.data()));
221 }
222
223 uint32_t timestamp = FrameNumberToTimestamp(frame_number); 211 uint32_t timestamp = FrameNumberToTimestamp(frame_number);
224 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0); 212 VideoFrame source_frame(buffer, timestamp, 0, webrtc::kVideoRotation_0);
225 213
226 // Store frame information during the different stages of encode and decode. 214 // Store frame information during the different stages of encode and decode.
227 frame_infos_.emplace_back(); 215 frame_infos_.emplace_back();
228 FrameInfo* frame_info = &frame_infos_.back(); 216 FrameInfo* frame_info = &frame_infos_.back();
229 frame_info->timestamp = timestamp; 217 frame_info->timestamp = timestamp;
230 218
231 // Decide if we are going to force a keyframe. 219 // Decide if we are going to force a keyframe.
232 std::vector<FrameType> frame_types(1, kVideoFrameDelta); 220 std::vector<FrameType> frame_types(1, kVideoFrameDelta);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) { 494 int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) {
507 RTC_DCHECK_GT(timestamp, 0); 495 RTC_DCHECK_GT(timestamp, 0);
508 const int ticks_per_frame = 496 const int ticks_per_frame =
509 kRtpClockRateHz / config_.codec_settings->maxFramerate; 497 kRtpClockRateHz / config_.codec_settings->maxFramerate;
510 RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0); 498 RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0);
511 return (timestamp / ticks_per_frame) - 1; 499 return (timestamp / ticks_per_frame) - 1;
512 } 500 }
513 501
514 } // namespace test 502 } // namespace test
515 } // namespace webrtc 503 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698