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

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

Issue 2278883002: Move MutableDataY{,U,V} methods to I420Buffer only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete unused variable. 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 inst.startBitrate = target_bitrate; 141 inst.startBitrate = target_bitrate;
142 inst.maxBitrate = 8000; 142 inst.maxBitrate = 8000;
143 inst.width = width; 143 inst.width = width;
144 inst.height = height; 144 inst.height = height;
145 145
146 if (encoder->InitEncode(&inst, 1, 1440) < 0) { 146 if (encoder->InitEncode(&inst, 1, 1440) < 0) {
147 fprintf(stderr, "Error: Cannot initialize vp8 encoder\n"); 147 fprintf(stderr, "Error: Cannot initialize vp8 encoder\n");
148 return -1; 148 return -1;
149 } 149 }
150 EXPECT_EQ(0, decoder->InitDecode(&inst, 1)); 150 EXPECT_EQ(0, decoder->InitDecode(&inst, 1));
151 webrtc::VideoFrame input_frame; 151
152 size_t length = webrtc::CalcBufferSize(webrtc::kI420, width, height); 152 size_t length = webrtc::CalcBufferSize(webrtc::kI420, width, height);
153 std::unique_ptr<uint8_t[]> frame_buffer(new uint8_t[length]); 153 std::unique_ptr<uint8_t[]> frame_buffer(new uint8_t[length]);
154 154
155 int half_width = (width + 1) / 2; 155 int half_width = (width + 1) / 2;
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 input_frame.CreateEmptyFrame(width, height, width, half_width, half_width); 166 rtc::scoped_refptr<webrtc::I420Buffer> i420_buffer =
167 webrtc::I420Buffer::Create(width, height, width, half_width, half_width);
168
167 while (!feof(input_file) && 169 while (!feof(input_file) &&
168 (num_frames == -1 || frames_processed < num_frames)) { 170 (num_frames == -1 || frames_processed < num_frames)) {
169 if (fread(frame_buffer.get(), 1, length, input_file) != length) 171 if (fread(frame_buffer.get(), 1, length, input_file) != length)
170 continue; 172 continue;
171 if (frame_cnt >= start_frame) { 173 if (frame_cnt >= start_frame) {
172 webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0, width, 174 webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0, width,
173 height, 0, webrtc::kVideoRotation_0, &input_frame); 175 height, 0, webrtc::kVideoRotation_0, &i420_buffer);
176 webrtc::VideoFrame input_frame(i420_buffer, 0, 0,
177 webrtc::kVideoRotation_0);
174 encoder->Encode(input_frame, NULL, NULL); 178 encoder->Encode(input_frame, NULL, NULL);
175 decoder->Decode(encoder_callback.encoded_image(), false, NULL); 179 decoder->Decode(encoder_callback.encoded_image(), false, NULL);
176 ++frames_processed; 180 ++frames_processed;
177 } 181 }
178 ++frame_cnt; 182 ++frame_cnt;
179 } 183 }
180 printf("\nProcessed %d frames\n", frames_processed); 184 printf("\nProcessed %d frames\n", frames_processed);
181 int64_t endtime = rtc::TimeMillis(); 185 int64_t endtime = rtc::TimeMillis();
182 int64_t totalExecutionTime = endtime - starttime; 186 int64_t totalExecutionTime = endtime - starttime;
183 printf("Total execution time: %.2lf ms\n", 187 printf("Total execution time: %.2lf ms\n",
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 243
240 parser.ProcessFlags(); 244 parser.ProcessFlags();
241 if (parser.GetFlag("help") == "true") { 245 if (parser.GetFlag("help") == "true") {
242 parser.PrintUsageMessage(); 246 parser.PrintUsageMessage();
243 exit(EXIT_SUCCESS); 247 exit(EXIT_SUCCESS);
244 } 248 }
245 parser.PrintEnteredFlags(); 249 parser.PrintEnteredFlags();
246 250
247 return SequenceCoder(&parser); 251 return SequenceCoder(&parser);
248 } 252 }
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc ('k') | webrtc/modules/video_processing/test/denoiser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698