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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
index d7927eb7ba161f36bc99d7a143493a083211e443..b2c159fad5e81a0a7e3d40717d1f7f05734a2911 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
@@ -164,14 +164,16 @@ int SequenceCoder(webrtc::test::CommandLineParser* parser) {
int frame_cnt = 1;
int frames_processed = 0;
input_frame.CreateEmptyFrame(width, height, width, half_width, half_width);
- while (!feof(input_file) &&
- (num_frames == -1 || frames_processed < num_frames)) {
- if (fread(frame_buffer.get(), 1, length, input_file) != length)
- continue;
+ while (num_frames == -1 || frames_processed < num_frames) {
+ rtc::scoped_refptr<VideoFrameBuffer> buffer(
+ test::ReadI420Buffer(width, height, input_file));
+ if (!buffer) {
+ // EOF or read error.
+ break;
+ }
if (frame_cnt >= start_frame) {
- webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0, width,
- height, 0, webrtc::kVideoRotation_0, &input_frame);
- encoder->Encode(input_frame, NULL, NULL);
+ encoder->Encode(VideoFrame(buffer, webrtc::kVideoRotation_0, 0),
+ NULL, NULL);
decoder->Decode(encoder_callback.encoded_image(), false, NULL);
++frames_processed;
}

Powered by Google App Engine
This is Rietveld 408576698