OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 21 matching lines...) Expand all Loading... |
32 #include "webrtc/base/timeutils.h" | 32 #include "webrtc/base/timeutils.h" |
33 #include "webrtc/base/weak_ptr.h" | 33 #include "webrtc/base/weak_ptr.h" |
34 #include "webrtc/common_types.h" | 34 #include "webrtc/common_types.h" |
35 #include "webrtc/common_video/h264/h264_bitstream_parser.h" | 35 #include "webrtc/common_video/h264/h264_bitstream_parser.h" |
36 #include "webrtc/common_video/h264/h264_common.h" | 36 #include "webrtc/common_video/h264/h264_common.h" |
37 #include "webrtc/common_video/h264/profile_level_id.h" | 37 #include "webrtc/common_video/h264/profile_level_id.h" |
38 #include "webrtc/media/engine/internalencoderfactory.h" | 38 #include "webrtc/media/engine/internalencoderfactory.h" |
39 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 39 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
40 #include "webrtc/modules/video_coding/utility/quality_scaler.h" | 40 #include "webrtc/modules/video_coding/utility/quality_scaler.h" |
41 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" | 41 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" |
| 42 #include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h" |
42 #include "webrtc/sdk/android/src/jni/androidmediacodeccommon.h" | 43 #include "webrtc/sdk/android/src/jni/androidmediacodeccommon.h" |
43 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" | 44 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" |
44 #include "webrtc/sdk/android/src/jni/native_handle_impl.h" | 45 #include "webrtc/sdk/android/src/jni/native_handle_impl.h" |
45 #include "webrtc/system_wrappers/include/field_trial.h" | 46 #include "webrtc/system_wrappers/include/field_trial.h" |
46 | 47 |
47 using rtc::Bind; | 48 using rtc::Bind; |
48 using rtc::Thread; | 49 using rtc::Thread; |
49 using rtc::ThreadManager; | 50 using rtc::ThreadManager; |
50 | 51 |
51 using webrtc::CodecSpecificInfo; | 52 using webrtc::CodecSpecificInfo; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 const VideoCodecType codec_type = GetCodecType(); | 398 const VideoCodecType codec_type = GetCodecType(); |
398 RTC_CHECK(codec_settings->codecType == codec_type) | 399 RTC_CHECK(codec_settings->codecType == codec_type) |
399 << "Unsupported codec " << codec_settings->codecType << " for " | 400 << "Unsupported codec " << codec_settings->codecType << " for " |
400 << codec_type; | 401 << codec_type; |
401 if (sw_fallback_required_) { | 402 if (sw_fallback_required_) { |
402 return WEBRTC_VIDEO_CODEC_OK; | 403 return WEBRTC_VIDEO_CODEC_OK; |
403 } | 404 } |
404 codec_mode_ = codec_settings->mode; | 405 codec_mode_ = codec_settings->mode; |
405 int init_width = codec_settings->width; | 406 int init_width = codec_settings->width; |
406 int init_height = codec_settings->height; | 407 int init_height = codec_settings->height; |
407 // Scaling is disabled for VP9, but optionally enabled for VP8. | 408 // Scaling is optionally enabled for VP8 and VP9. |
408 // TODO(pbos): Extract automaticResizeOn out of VP8 settings. | 409 // TODO(pbos): Extract automaticResizeOn out of VP8 settings. |
409 scale_ = false; | 410 scale_ = false; |
410 if (codec_type == kVideoCodecVP8) { | 411 if (codec_type == kVideoCodecVP8) { |
411 scale_ = codec_settings->VP8().automaticResizeOn; | 412 scale_ = codec_settings->VP8().automaticResizeOn; |
412 } else if (codec_type != kVideoCodecVP9) { | 413 } else if (codec_type == kVideoCodecVP9) { |
| 414 scale_ = codec_settings->VP9().automaticResizeOn; |
| 415 } else { |
413 scale_ = true; | 416 scale_ = true; |
414 } | 417 } |
415 | 418 |
416 ALOGD << "InitEncode request: " << init_width << " x " << init_height; | 419 ALOGD << "InitEncode request: " << init_width << " x " << init_height; |
417 ALOGD << "Encoder automatic resize " << (scale_ ? "enabled" : "disabled"); | 420 ALOGD << "Encoder automatic resize " << (scale_ ? "enabled" : "disabled"); |
418 | 421 |
419 return InitEncodeInternal( | 422 return InitEncodeInternal( |
420 init_width, init_height, codec_settings->startBitrate, | 423 init_width, init_height, codec_settings->startBitrate, |
421 codec_settings->maxFramerate, codec_settings->expect_encode_from_texture); | 424 codec_settings->maxFramerate, codec_settings->expect_encode_from_texture); |
422 } | 425 } |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 header.fragmentationOffset[0] = 0; | 1100 header.fragmentationOffset[0] = 0; |
1098 header.fragmentationLength[0] = image->_length; | 1101 header.fragmentationLength[0] = image->_length; |
1099 header.fragmentationPlType[0] = 0; | 1102 header.fragmentationPlType[0] = 0; |
1100 header.fragmentationTimeDiff[0] = 0; | 1103 header.fragmentationTimeDiff[0] = 0; |
1101 if (codec_type == kVideoCodecVP8) { | 1104 if (codec_type == kVideoCodecVP8) { |
1102 int qp; | 1105 int qp; |
1103 if (webrtc::vp8::GetQp(payload, payload_size, &qp)) { | 1106 if (webrtc::vp8::GetQp(payload, payload_size, &qp)) { |
1104 current_acc_qp_ += qp; | 1107 current_acc_qp_ += qp; |
1105 image->qp_ = qp; | 1108 image->qp_ = qp; |
1106 } | 1109 } |
| 1110 } else if (codec_type == kVideoCodecVP9) { |
| 1111 int qp; |
| 1112 if (webrtc::vp9::GetQp(payload, payload_size, &qp)) { |
| 1113 current_acc_qp_ += qp; |
| 1114 image->qp_ = qp; |
| 1115 } |
1107 } | 1116 } |
1108 } else if (codec_type == kVideoCodecH264) { | 1117 } else if (codec_type == kVideoCodecH264) { |
1109 h264_bitstream_parser_.ParseBitstream(payload, payload_size); | 1118 h264_bitstream_parser_.ParseBitstream(payload, payload_size); |
1110 int qp; | 1119 int qp; |
1111 if (h264_bitstream_parser_.GetLastSliceQp(&qp)) { | 1120 if (h264_bitstream_parser_.GetLastSliceQp(&qp)) { |
1112 current_acc_qp_ += qp; | 1121 current_acc_qp_ += qp; |
1113 image->qp_ = qp; | 1122 image->qp_ = qp; |
1114 } | 1123 } |
1115 // For H.264 search for start codes. | 1124 // For H.264 search for start codes. |
1116 const std::vector<webrtc::H264::NaluIndex> nalu_idxs = | 1125 const std::vector<webrtc::H264::NaluIndex> nalu_idxs = |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 } | 1360 } |
1352 } | 1361 } |
1353 | 1362 |
1354 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1363 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1355 webrtc::VideoEncoder* encoder) { | 1364 webrtc::VideoEncoder* encoder) { |
1356 ALOGD << "Destroy video encoder."; | 1365 ALOGD << "Destroy video encoder."; |
1357 delete encoder; | 1366 delete encoder; |
1358 } | 1367 } |
1359 | 1368 |
1360 } // namespace webrtc_jni | 1369 } // namespace webrtc_jni |
OLD | NEW |