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

Side by Side Diff: content/renderer/media/gpu/rtc_video_decoder.cc

Issue 2532953009: RtcVideoDecoder: do not fallback to software when getting size 0x0 keyframe. (Closed)
Patch Set: fix the test Created 4 years 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
« no previous file with comments | « no previous file | content/renderer/media/gpu/rtc_video_decoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/gpu/rtc_video_decoder.h" 5 #include "content/renderer/media/gpu/rtc_video_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // internally. Platforms whose VDAs fail to support mid-stream resolution 203 // internally. Platforms whose VDAs fail to support mid-stream resolution
204 // change gracefully need to have their clients cover for them, and we do that 204 // change gracefully need to have their clients cover for them, and we do that
205 // here. 205 // here.
206 #ifdef ANDROID 206 #ifdef ANDROID
207 const bool kVDACanHandleMidstreamResize = false; 207 const bool kVDACanHandleMidstreamResize = false;
208 #else 208 #else
209 const bool kVDACanHandleMidstreamResize = true; 209 const bool kVDACanHandleMidstreamResize = true;
210 #endif 210 #endif
211 211
212 bool need_to_reset_for_midstream_resize = false; 212 bool need_to_reset_for_midstream_resize = false;
213 if (inputImage._frameType == webrtc::kVideoFrameKey) { 213 const gfx::Size new_frame_size(inputImage._encodedWidth,
214 const gfx::Size new_frame_size(inputImage._encodedWidth, 214 inputImage._encodedHeight);
215 inputImage._encodedHeight); 215 if (!new_frame_size.IsEmpty() && new_frame_size != frame_size_) {
216 DVLOG(2) << "Got key frame. size=" << new_frame_size.ToString(); 216 DVLOG(2) << "Got new size=" << new_frame_size.ToString();
217 217
218 if (new_frame_size.width() > max_resolution_.width() || 218 if (new_frame_size.width() > max_resolution_.width() ||
219 new_frame_size.width() < min_resolution_.width() || 219 new_frame_size.width() < min_resolution_.width() ||
220 new_frame_size.height() > max_resolution_.height() || 220 new_frame_size.height() > max_resolution_.height() ||
221 new_frame_size.height() < min_resolution_.height()) { 221 new_frame_size.height() < min_resolution_.height()) {
222 DVLOG(1) << "Resolution unsupported, falling back to software decode"; 222 DVLOG(1) << "Resolution unsupported, falling back to software decode";
223 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE; 223 return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
224 } 224 }
225 225
226 gfx::Size prev_frame_size = frame_size_; 226 gfx::Size prev_frame_size = frame_size_;
227 frame_size_ = new_frame_size; 227 frame_size_ = new_frame_size;
228 if (!kVDACanHandleMidstreamResize && !prev_frame_size.IsEmpty() && 228 if (!kVDACanHandleMidstreamResize && !prev_frame_size.IsEmpty() &&
229 prev_frame_size != frame_size_) { 229 prev_frame_size != frame_size_) {
230 need_to_reset_for_midstream_resize = true; 230 need_to_reset_for_midstream_resize = true;
231 } 231 }
232 } else if (IsFirstBufferAfterReset(next_bitstream_buffer_id_, 232 } else if (IsFirstBufferAfterReset(next_bitstream_buffer_id_,
233 reset_bitstream_buffer_id_)) { 233 reset_bitstream_buffer_id_)) {
234 // TODO(wuchengli): VDA should handle it. Remove this when 234 // TODO(wuchengli): VDA should handle it. Remove this when
235 // http://crosbug.com/p/21913 is fixed. 235 // http://crosbug.com/p/21913 is fixed.
236 236
237 // If we're are in an error condition, increase the counter. 237 // If we're are in an error condition, increase the counter.
238 vda_error_counter_ += vda_error_counter_ ? 1 : 0; 238 vda_error_counter_ += vda_error_counter_ ? 1 : 0;
239 239
240 DVLOG(1) << "The first frame should be a key frame. Drop this."; 240 DVLOG(1) << "The first frame should have resolution. Drop this.";
241 return WEBRTC_VIDEO_CODEC_ERROR; 241 return WEBRTC_VIDEO_CODEC_ERROR;
242 } 242 }
243 243
244 // Create buffer metadata. 244 // Create buffer metadata.
245 BufferData buffer_data(next_bitstream_buffer_id_, 245 BufferData buffer_data(next_bitstream_buffer_id_,
246 inputImage._timeStamp, 246 inputImage._timeStamp,
247 inputImage._length, 247 inputImage._length,
248 gfx::Rect(frame_size_)); 248 gfx::Rect(frame_size_));
249 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. 249 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
250 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & ID_LAST; 250 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & ID_LAST;
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } 887 }
888 888
889 void RTCVideoDecoder::ClearPendingBuffers() { 889 void RTCVideoDecoder::ClearPendingBuffers() {
890 // Delete WebRTC input buffers. 890 // Delete WebRTC input buffers.
891 for (const auto& pending_buffer : pending_buffers_) 891 for (const auto& pending_buffer : pending_buffers_)
892 delete[] pending_buffer.first._buffer; 892 delete[] pending_buffer.first._buffer;
893 pending_buffers_.clear(); 893 pending_buffers_.clear();
894 } 894 }
895 895
896 } // namespace content 896 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/gpu/rtc_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698