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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 jobject output_buffer = | 775 jobject output_buffer = |
776 jni->GetObjectArrayElement(output_buffers, output_buffer_index); | 776 jni->GetObjectArrayElement(output_buffers, output_buffer_index); |
777 uint8_t* payload = reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress( | 777 uint8_t* payload = reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress( |
778 output_buffer)); | 778 output_buffer)); |
779 if (CheckException(jni)) { | 779 if (CheckException(jni)) { |
780 return false; | 780 return false; |
781 } | 781 } |
782 payload += output_buffer_offset; | 782 payload += output_buffer_offset; |
783 | 783 |
784 // Create yuv420 frame. | 784 // Create yuv420 frame. |
785 frame_buffer = decoded_frame_pool_.CreateBuffer(width, height); | 785 rtc::scoped_refptr<webrtc::I420Buffer> i420_buffer; |
| 786 |
| 787 i420_buffer = decoded_frame_pool_.CreateBuffer(width, height); |
786 if (color_format == COLOR_FormatYUV420Planar) { | 788 if (color_format == COLOR_FormatYUV420Planar) { |
787 RTC_CHECK_EQ(0, stride % 2); | 789 RTC_CHECK_EQ(0, stride % 2); |
788 RTC_CHECK_EQ(0, slice_height % 2); | 790 RTC_CHECK_EQ(0, slice_height % 2); |
789 const int uv_stride = stride / 2; | 791 const int uv_stride = stride / 2; |
790 const int u_slice_height = slice_height / 2; | 792 const int u_slice_height = slice_height / 2; |
791 const uint8_t* y_ptr = payload; | 793 const uint8_t* y_ptr = payload; |
792 const uint8_t* u_ptr = y_ptr + stride * slice_height; | 794 const uint8_t* u_ptr = y_ptr + stride * slice_height; |
793 const uint8_t* v_ptr = u_ptr + uv_stride * u_slice_height; | 795 const uint8_t* v_ptr = u_ptr + uv_stride * u_slice_height; |
794 libyuv::I420Copy(y_ptr, stride, | 796 libyuv::I420Copy(y_ptr, stride, |
795 u_ptr, uv_stride, | 797 u_ptr, uv_stride, |
796 v_ptr, uv_stride, | 798 v_ptr, uv_stride, |
797 frame_buffer->MutableDataY(), | 799 i420_buffer->MutableDataY(), i420_buffer->StrideY(), |
798 frame_buffer->StrideY(), | 800 i420_buffer->MutableDataU(), i420_buffer->StrideU(), |
799 frame_buffer->MutableDataU(), | 801 i420_buffer->MutableDataV(), i420_buffer->StrideV(), |
800 frame_buffer->StrideU(), | |
801 frame_buffer->MutableDataV(), | |
802 frame_buffer->StrideV(), | |
803 width, height); | 802 width, height); |
804 } else { | 803 } else { |
805 // All other supported formats are nv12. | 804 // All other supported formats are nv12. |
806 const uint8_t* y_ptr = payload; | 805 const uint8_t* y_ptr = payload; |
807 const uint8_t* uv_ptr = y_ptr + stride * slice_height; | 806 const uint8_t* uv_ptr = y_ptr + stride * slice_height; |
808 libyuv::NV12ToI420( | 807 libyuv::NV12ToI420( |
809 y_ptr, stride, | 808 y_ptr, stride, |
810 uv_ptr, stride, | 809 uv_ptr, stride, |
811 frame_buffer->MutableDataY(), | 810 i420_buffer->MutableDataY(), i420_buffer->StrideY(), |
812 frame_buffer->StrideY(), | 811 i420_buffer->MutableDataU(), i420_buffer->StrideU(), |
813 frame_buffer->MutableDataU(), | 812 i420_buffer->MutableDataV(), i420_buffer->StrideV(), |
814 frame_buffer->StrideU(), | |
815 frame_buffer->MutableDataV(), | |
816 frame_buffer->StrideV(), | |
817 width, height); | 813 width, height); |
818 } | 814 } |
| 815 frame_buffer = i420_buffer; |
| 816 |
819 // Return output byte buffer back to codec. | 817 // Return output byte buffer back to codec. |
820 jni->CallVoidMethod( | 818 jni->CallVoidMethod( |
821 *j_media_codec_video_decoder_, | 819 *j_media_codec_video_decoder_, |
822 j_return_decoded_byte_buffer_method_, | 820 j_return_decoded_byte_buffer_method_, |
823 output_buffer_index); | 821 output_buffer_index); |
824 if (CheckException(jni)) { | 822 if (CheckException(jni)) { |
825 ALOGE << "returnDecodedOutputBuffer error"; | 823 ALOGE << "returnDecodedOutputBuffer error"; |
826 return false; | 824 return false; |
827 } | 825 } |
828 } | 826 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 webrtc::VideoDecoder* decoder) { | 984 webrtc::VideoDecoder* decoder) { |
987 ALOGD << "Destroy video decoder."; | 985 ALOGD << "Destroy video decoder."; |
988 delete decoder; | 986 delete decoder; |
989 } | 987 } |
990 | 988 |
991 const char* MediaCodecVideoDecoder::ImplementationName() const { | 989 const char* MediaCodecVideoDecoder::ImplementationName() const { |
992 return "MediaCodec"; | 990 return "MediaCodec"; |
993 } | 991 } |
994 | 992 |
995 } // namespace webrtc_jni | 993 } // namespace webrtc_jni |
OLD | NEW |