Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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()) { |
|
Pawel Osciak
2016/12/02 00:13:00
if (!new_frame_size.IsEmpty() && new_frame_size !=
wuchengli
2016/12/02 05:54:48
Done.
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |