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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc

Issue 2362683002: New helper function test::ReadI420Buffer, refactor FrameReader to use it. (Closed)
Patch Set: Another try to fix the 64-bit windows build. Created 4 years, 2 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Set and register callbacks. 156 // Set and register callbacks.
157 Vp8SequenceCoderEncodeCallback encoder_callback(encoded_file); 157 Vp8SequenceCoderEncodeCallback encoder_callback(encoded_file);
158 encoder->RegisterEncodeCompleteCallback(&encoder_callback); 158 encoder->RegisterEncodeCompleteCallback(&encoder_callback);
159 Vp8SequenceCoderDecodeCallback decoder_callback(output_file); 159 Vp8SequenceCoderDecodeCallback decoder_callback(output_file);
160 decoder->RegisterDecodeCompleteCallback(&decoder_callback); 160 decoder->RegisterDecodeCompleteCallback(&decoder_callback);
161 // Read->Encode->Decode sequence. 161 // Read->Encode->Decode sequence.
162 // num_frames = -1 implies unlimited encoding (entire sequence). 162 // num_frames = -1 implies unlimited encoding (entire sequence).
163 int64_t starttime = rtc::TimeMillis(); 163 int64_t starttime = rtc::TimeMillis();
164 int frame_cnt = 1; 164 int frame_cnt = 1;
165 int frames_processed = 0; 165 int frames_processed = 0;
166 rtc::scoped_refptr<webrtc::I420Buffer> i420_buffer = 166 while (num_frames == -1 || frames_processed < num_frames) {
167 webrtc::I420Buffer::Create(width, height, width, half_width, half_width); 167 rtc::scoped_refptr<VideoFrameBuffer> buffer(
168 168 test::ReadI420Buffer(width, height, input_file));
169 while (!feof(input_file) && 169 if (!buffer) {
170 (num_frames == -1 || frames_processed < num_frames)) { 170 // EOF or read error.
171 if (fread(frame_buffer.get(), 1, length, input_file) != length) 171 break;
172 continue; 172 }
173 if (frame_cnt >= start_frame) { 173 if (frame_cnt >= start_frame) {
174 webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0, width, 174 encoder->Encode(VideoFrame(buffer, webrtc::kVideoRotation_0, 0),
175 height, 0, webrtc::kVideoRotation_0, &i420_buffer); 175 NULL, NULL);
176 webrtc::VideoFrame input_frame(i420_buffer, 0, 0,
177 webrtc::kVideoRotation_0);
178 encoder->Encode(input_frame, NULL, NULL);
179 decoder->Decode(encoder_callback.encoded_image(), false, NULL); 176 decoder->Decode(encoder_callback.encoded_image(), false, NULL);
180 ++frames_processed; 177 ++frames_processed;
181 } 178 }
182 ++frame_cnt; 179 ++frame_cnt;
183 } 180 }
184 printf("\nProcessed %d frames\n", frames_processed); 181 printf("\nProcessed %d frames\n", frames_processed);
185 int64_t endtime = rtc::TimeMillis(); 182 int64_t endtime = rtc::TimeMillis();
186 int64_t totalExecutionTime = endtime - starttime; 183 int64_t totalExecutionTime = endtime - starttime;
187 printf("Total execution time: %.2lf ms\n", 184 printf("Total execution time: %.2lf ms\n",
188 static_cast<double>(totalExecutionTime)); 185 static_cast<double>(totalExecutionTime));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 240
244 parser.ProcessFlags(); 241 parser.ProcessFlags();
245 if (parser.GetFlag("help") == "true") { 242 if (parser.GetFlag("help") == "true") {
246 parser.PrintUsageMessage(); 243 parser.PrintUsageMessage();
247 exit(EXIT_SUCCESS); 244 exit(EXIT_SUCCESS);
248 } 245 }
249 parser.PrintEnteredFlags(); 246 parser.PrintEnteredFlags();
250 247
251 return SequenceCoder(&parser); 248 return SequenceCoder(&parser);
252 } 249 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698