| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 codec_specific->codecType = kVideoCodecVP9; | 555 codec_specific->codecType = kVideoCodecVP9; |
| 556 CodecSpecificInfoVP9 *vp9_info = &(codec_specific->codecSpecific.VP9); | 556 CodecSpecificInfoVP9 *vp9_info = &(codec_specific->codecSpecific.VP9); |
| 557 // TODO(asapersson): Set correct values. | 557 // TODO(asapersson): Set correct values. |
| 558 vp9_info->inter_pic_predicted = | 558 vp9_info->inter_pic_predicted = |
| 559 (pkt.data.frame.flags & VPX_FRAME_IS_KEY) ? false : true; | 559 (pkt.data.frame.flags & VPX_FRAME_IS_KEY) ? false : true; |
| 560 vp9_info->flexible_mode = codec_.codecSpecific.VP9.flexibleMode; | 560 vp9_info->flexible_mode = codec_.codecSpecific.VP9.flexibleMode; |
| 561 vp9_info->ss_data_available = ((pkt.data.frame.flags & VPX_FRAME_IS_KEY) && | 561 vp9_info->ss_data_available = ((pkt.data.frame.flags & VPX_FRAME_IS_KEY) && |
| 562 !codec_.codecSpecific.VP9.flexibleMode) | 562 !codec_.codecSpecific.VP9.flexibleMode) |
| 563 ? true | 563 ? true |
| 564 : false; | 564 : false; |
| 565 if (pkt.data.frame.flags & VPX_FRAME_IS_KEY) | |
| 566 frames_since_kf_ = 0; | |
| 567 | 565 |
| 568 vpx_svc_layer_id_t layer_id = {0}; | 566 vpx_svc_layer_id_t layer_id = {0}; |
| 569 vpx_codec_control(encoder_, VP9E_GET_SVC_LAYER_ID, &layer_id); | 567 vpx_codec_control(encoder_, VP9E_GET_SVC_LAYER_ID, &layer_id); |
| 570 | 568 |
| 571 assert(num_temporal_layers_ > 0); | 569 assert(num_temporal_layers_ > 0); |
| 572 assert(num_spatial_layers_ > 0); | 570 assert(num_spatial_layers_ > 0); |
| 573 if (num_temporal_layers_ == 1) { | 571 if (num_temporal_layers_ == 1) { |
| 574 assert(layer_id.temporal_layer_id == 0); | 572 assert(layer_id.temporal_layer_id == 0); |
| 575 vp9_info->temporal_idx = kNoTemporalIdx; | 573 vp9_info->temporal_idx = kNoTemporalIdx; |
| 576 } else { | 574 } else { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 594 is_first_frame = | 592 is_first_frame = |
| 595 layer_id.spatial_layer_id == spatial_layer_->GetStartLayer(); | 593 layer_id.spatial_layer_id == spatial_layer_->GetStartLayer(); |
| 596 } else { | 594 } else { |
| 597 is_first_frame = layer_id.spatial_layer_id == 0; | 595 is_first_frame = layer_id.spatial_layer_id == 0; |
| 598 } | 596 } |
| 599 | 597 |
| 600 if (is_first_frame) { | 598 if (is_first_frame) { |
| 601 picture_id_ = (picture_id_ + 1) & 0x7FFF; | 599 picture_id_ = (picture_id_ + 1) & 0x7FFF; |
| 602 // TODO(asapersson): this info has to be obtained from the encoder. | 600 // TODO(asapersson): this info has to be obtained from the encoder. |
| 603 vp9_info->inter_layer_predicted = false; | 601 vp9_info->inter_layer_predicted = false; |
| 602 ++frames_since_kf_; |
| 604 } else { | 603 } else { |
| 605 // TODO(asapersson): this info has to be obtained from the encoder. | 604 // TODO(asapersson): this info has to be obtained from the encoder. |
| 606 vp9_info->inter_layer_predicted = true; | 605 vp9_info->inter_layer_predicted = true; |
| 607 } | 606 } |
| 608 | 607 |
| 608 if (pkt.data.frame.flags & VPX_FRAME_IS_KEY) { |
| 609 frames_since_kf_ = 0; |
| 610 } |
| 611 |
| 609 vp9_info->picture_id = picture_id_; | 612 vp9_info->picture_id = picture_id_; |
| 610 | 613 |
| 611 if (!vp9_info->flexible_mode) { | 614 if (!vp9_info->flexible_mode) { |
| 612 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) { | 615 if (layer_id.temporal_layer_id == 0 && layer_id.spatial_layer_id == 0) { |
| 613 tl0_pic_idx_++; | 616 tl0_pic_idx_++; |
| 614 } | 617 } |
| 615 vp9_info->tl0_pic_idx = tl0_pic_idx_; | 618 vp9_info->tl0_pic_idx = tl0_pic_idx_; |
| 616 } | 619 } |
| 617 | 620 |
| 618 // Always populate this, so that the packetizer can properly set the marker | 621 // Always populate this, so that the packetizer can properly set the marker |
| 619 // bit. | 622 // bit. |
| 620 vp9_info->num_spatial_layers = num_spatial_layers_; | 623 vp9_info->num_spatial_layers = num_spatial_layers_; |
| 621 | 624 |
| 622 vp9_info->num_ref_pics = 0; | 625 vp9_info->num_ref_pics = 0; |
| 623 if (vp9_info->flexible_mode) { | 626 if (vp9_info->flexible_mode) { |
| 624 vp9_info->gof_idx = kNoGofIdx; | 627 vp9_info->gof_idx = kNoGofIdx; |
| 625 vp9_info->num_ref_pics = num_ref_pics_[layer_id.spatial_layer_id]; | 628 vp9_info->num_ref_pics = num_ref_pics_[layer_id.spatial_layer_id]; |
| 626 for (int i = 0; i < num_ref_pics_[layer_id.spatial_layer_id]; ++i) { | 629 for (int i = 0; i < num_ref_pics_[layer_id.spatial_layer_id]; ++i) { |
| 627 vp9_info->p_diff[i] = p_diff_[layer_id.spatial_layer_id][i]; | 630 vp9_info->p_diff[i] = p_diff_[layer_id.spatial_layer_id][i]; |
| 628 } | 631 } |
| 629 } else { | 632 } else { |
| 630 vp9_info->gof_idx = | 633 vp9_info->gof_idx = |
| 631 static_cast<uint8_t>(frames_since_kf_ % gof_.num_frames_in_gof); | 634 static_cast<uint8_t>(frames_since_kf_ % gof_.num_frames_in_gof); |
| 635 vp9_info->temporal_up_switch = gof_.temporal_up_switch[vp9_info->gof_idx]; |
| 632 } | 636 } |
| 633 ++frames_since_kf_; | |
| 634 | 637 |
| 635 if (vp9_info->ss_data_available) { | 638 if (vp9_info->ss_data_available) { |
| 636 vp9_info->spatial_layer_resolution_present = true; | 639 vp9_info->spatial_layer_resolution_present = true; |
| 637 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) { | 640 for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) { |
| 638 vp9_info->width[i] = codec_.width * | 641 vp9_info->width[i] = codec_.width * |
| 639 svc_internal_.svc_params.scaling_factor_num[i] / | 642 svc_internal_.svc_params.scaling_factor_num[i] / |
| 640 svc_internal_.svc_params.scaling_factor_den[i]; | 643 svc_internal_.svc_params.scaling_factor_den[i]; |
| 641 vp9_info->height[i] = codec_.height * | 644 vp9_info->height[i] = codec_.height * |
| 642 svc_internal_.svc_params.scaling_factor_num[i] / | 645 svc_internal_.svc_params.scaling_factor_num[i] / |
| 643 svc_internal_.svc_params.scaling_factor_den[i]; | 646 svc_internal_.svc_params.scaling_factor_den[i]; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 decoder_ = NULL; | 978 decoder_ = NULL; |
| 976 } | 979 } |
| 977 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers | 980 // Releases buffers from the pool. Any buffers not in use are deleted. Buffers |
| 978 // still referenced externally are deleted once fully released, not returning | 981 // still referenced externally are deleted once fully released, not returning |
| 979 // to the pool. | 982 // to the pool. |
| 980 frame_buffer_pool_.ClearPool(); | 983 frame_buffer_pool_.ClearPool(); |
| 981 inited_ = false; | 984 inited_ = false; |
| 982 return WEBRTC_VIDEO_CODEC_OK; | 985 return WEBRTC_VIDEO_CODEC_OK; |
| 983 } | 986 } |
| 984 } // namespace webrtc | 987 } // namespace webrtc |
| OLD | NEW |