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

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: Created 4 years, 3 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 input_frame.CreateEmptyFrame(width, height, width, half_width, half_width); 166 input_frame.CreateEmptyFrame(width, height, width, half_width, half_width);
167 while (!feof(input_file) && 167 while (num_frames == -1 || frames_processed < num_frames) {
168 (num_frames == -1 || frames_processed < num_frames)) { 168 rtc::scoped_refptr<VideoFrameBuffer> buffer(
169 if (fread(frame_buffer.get(), 1, length, input_file) != length) 169 test::ReadI420Buffer(width, height, input_file));
170 continue; 170 if (!buffer) {
171 // EOF or read error.
172 break;
173 }
171 if (frame_cnt >= start_frame) { 174 if (frame_cnt >= start_frame) {
172 webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0, width, 175 encoder->Encode(VideoFrame(buffer, webrtc::kVideoRotation_0, 0),
173 height, 0, webrtc::kVideoRotation_0, &input_frame); 176 NULL, NULL);
174 encoder->Encode(input_frame, NULL, NULL);
175 decoder->Decode(encoder_callback.encoded_image(), false, NULL); 177 decoder->Decode(encoder_callback.encoded_image(), false, NULL);
176 ++frames_processed; 178 ++frames_processed;
177 } 179 }
178 ++frame_cnt; 180 ++frame_cnt;
179 } 181 }
180 printf("\nProcessed %d frames\n", frames_processed); 182 printf("\nProcessed %d frames\n", frames_processed);
181 int64_t endtime = rtc::TimeMillis(); 183 int64_t endtime = rtc::TimeMillis();
182 int64_t totalExecutionTime = endtime - starttime; 184 int64_t totalExecutionTime = endtime - starttime;
183 printf("Total execution time: %.2lf ms\n", 185 printf("Total execution time: %.2lf ms\n",
184 static_cast<double>(totalExecutionTime)); 186 static_cast<double>(totalExecutionTime));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 241
240 parser.ProcessFlags(); 242 parser.ProcessFlags();
241 if (parser.GetFlag("help") == "true") { 243 if (parser.GetFlag("help") == "true") {
242 parser.PrintUsageMessage(); 244 parser.PrintUsageMessage();
243 exit(EXIT_SUCCESS); 245 exit(EXIT_SUCCESS);
244 } 246 }
245 parser.PrintEnteredFlags(); 247 parser.PrintEnteredFlags();
246 248
247 return SequenceCoder(&parser); 249 return SequenceCoder(&parser);
248 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698