OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 #include "webrtc/base/trace_event.h" | 24 #include "webrtc/base/trace_event.h" |
25 #include "webrtc/common_types.h" | 25 #include "webrtc/common_types.h" |
26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
27 #include "webrtc/modules/include/module_common_types.h" | 27 #include "webrtc/modules/include/module_common_types.h" |
28 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 28 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
29 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" | 29 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
30 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" | 30 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" |
31 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | 31 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
32 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" | 32 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" |
33 #include "webrtc/system_wrappers/include/clock.h" | 33 #include "webrtc/system_wrappers/include/clock.h" |
| 34 #include "webrtc/system_wrappers/include/metrics.h" |
34 | 35 |
35 namespace webrtc { | 36 namespace webrtc { |
36 namespace { | 37 namespace { |
37 | 38 |
38 enum { kVp8ErrorPropagationTh = 30 }; | 39 enum { kVp8ErrorPropagationTh = 30 }; |
39 enum { kVp832ByteAlign = 32 }; | 40 enum { kVp832ByteAlign = 32 }; |
40 | 41 |
41 // VP8 denoiser states. | 42 // VP8 denoiser states. |
42 enum denoiserState { | 43 enum denoiserState { |
43 kDenoiserOff, | 44 kDenoiserOff, |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 return WEBRTC_VIDEO_CODEC_OK; | 1049 return WEBRTC_VIDEO_CODEC_OK; |
1049 } | 1050 } |
1050 | 1051 |
1051 int VP8EncoderImpl::RegisterEncodeCompleteCallback( | 1052 int VP8EncoderImpl::RegisterEncodeCompleteCallback( |
1052 EncodedImageCallback* callback) { | 1053 EncodedImageCallback* callback) { |
1053 encoded_complete_callback_ = callback; | 1054 encoded_complete_callback_ = callback; |
1054 return WEBRTC_VIDEO_CODEC_OK; | 1055 return WEBRTC_VIDEO_CODEC_OK; |
1055 } | 1056 } |
1056 | 1057 |
1057 VP8DecoderImpl::VP8DecoderImpl() | 1058 VP8DecoderImpl::VP8DecoderImpl() |
1058 : decode_complete_callback_(NULL), | 1059 : buffer_pool_(false, 300 /* max_number_of_buffers*/), |
| 1060 decode_complete_callback_(NULL), |
1059 inited_(false), | 1061 inited_(false), |
1060 feedback_mode_(false), | 1062 feedback_mode_(false), |
1061 decoder_(NULL), | 1063 decoder_(NULL), |
1062 image_format_(VPX_IMG_FMT_NONE), | 1064 image_format_(VPX_IMG_FMT_NONE), |
1063 ref_frame_(NULL), | 1065 ref_frame_(NULL), |
1064 propagation_cnt_(-1), | 1066 propagation_cnt_(-1), |
1065 last_frame_width_(0), | 1067 last_frame_width_(0), |
1066 last_frame_height_(0), | 1068 last_frame_height_(0), |
1067 key_frame_required_(true) {} | 1069 key_frame_required_(true) {} |
1068 | 1070 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 int64_t ntp_time_ms) { | 1265 int64_t ntp_time_ms) { |
1264 if (img == NULL) { | 1266 if (img == NULL) { |
1265 // Decoder OK and NULL image => No show frame | 1267 // Decoder OK and NULL image => No show frame |
1266 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; | 1268 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; |
1267 } | 1269 } |
1268 last_frame_width_ = img->d_w; | 1270 last_frame_width_ = img->d_w; |
1269 last_frame_height_ = img->d_h; | 1271 last_frame_height_ = img->d_h; |
1270 // Allocate memory for decoded image. | 1272 // Allocate memory for decoded image. |
1271 rtc::scoped_refptr<I420Buffer> buffer = | 1273 rtc::scoped_refptr<I420Buffer> buffer = |
1272 buffer_pool_.CreateBuffer(img->d_w, img->d_h); | 1274 buffer_pool_.CreateBuffer(img->d_w, img->d_h); |
| 1275 if (!buffer.get()) { |
| 1276 // Pool has too many pending frames. |
| 1277 RTC_HISTOGRAM_BOOLEAN("WebRTC.Video.VP8DecoderImpl.TooManyPendingFrames", |
| 1278 1); |
| 1279 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; |
| 1280 } |
1273 | 1281 |
1274 libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], | 1282 libyuv::I420Copy(img->planes[VPX_PLANE_Y], img->stride[VPX_PLANE_Y], |
1275 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], | 1283 img->planes[VPX_PLANE_U], img->stride[VPX_PLANE_U], |
1276 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], | 1284 img->planes[VPX_PLANE_V], img->stride[VPX_PLANE_V], |
1277 buffer->MutableDataY(), buffer->StrideY(), | 1285 buffer->MutableDataY(), buffer->StrideY(), |
1278 buffer->MutableDataU(), buffer->StrideU(), | 1286 buffer->MutableDataU(), buffer->StrideU(), |
1279 buffer->MutableDataV(), buffer->StrideV(), | 1287 buffer->MutableDataV(), buffer->StrideV(), |
1280 img->d_w, img->d_h); | 1288 img->d_w, img->d_h); |
1281 | 1289 |
1282 VideoFrame decoded_image(buffer, timestamp, 0, kVideoRotation_0); | 1290 VideoFrame decoded_image(buffer, timestamp, 0, kVideoRotation_0); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 return -1; | 1334 return -1; |
1327 } | 1335 } |
1328 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != | 1336 if (vpx_codec_control(copy->decoder_, VP8_SET_REFERENCE, ref_frame_) != |
1329 VPX_CODEC_OK) { | 1337 VPX_CODEC_OK) { |
1330 return -1; | 1338 return -1; |
1331 } | 1339 } |
1332 return 0; | 1340 return 0; |
1333 } | 1341 } |
1334 | 1342 |
1335 } // namespace webrtc | 1343 } // namespace webrtc |
OLD | NEW |