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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 return false; | 802 return false; |
803 } | 803 } |
804 payload += output_buffer_offset; | 804 payload += output_buffer_offset; |
805 | 805 |
806 // Create yuv420 frame. | 806 // Create yuv420 frame. |
807 rtc::scoped_refptr<webrtc::I420Buffer> i420_buffer; | 807 rtc::scoped_refptr<webrtc::I420Buffer> i420_buffer; |
808 | 808 |
809 i420_buffer = decoded_frame_pool_.CreateBuffer(width, height); | 809 i420_buffer = decoded_frame_pool_.CreateBuffer(width, height); |
810 if (color_format == COLOR_FormatYUV420Planar) { | 810 if (color_format == COLOR_FormatYUV420Planar) { |
811 RTC_CHECK_EQ(0, stride % 2); | 811 RTC_CHECK_EQ(0, stride % 2); |
812 RTC_CHECK_EQ(0, slice_height % 2); | |
813 const int uv_stride = stride / 2; | 812 const int uv_stride = stride / 2; |
814 const int u_slice_height = slice_height / 2; | |
815 const uint8_t* y_ptr = payload; | 813 const uint8_t* y_ptr = payload; |
816 const uint8_t* u_ptr = y_ptr + stride * slice_height; | 814 const uint8_t* u_ptr = y_ptr + stride * slice_height; |
817 const uint8_t* v_ptr = u_ptr + uv_stride * u_slice_height; | 815 // This offset is weird when |slice_height| is not dividable by two, since |
816 // the last u row might not be full, but this is what's used in practice. | |
817 // See http://bugs.webrtc.org/6651 for more info. | |
818 const int u_offset = (uv_stride * slice_height + 1) / 2; | |
819 const uint8_t* v_ptr = u_ptr + u_offset; | |
818 libyuv::I420Copy(y_ptr, stride, u_ptr, uv_stride, v_ptr, uv_stride, | 820 libyuv::I420Copy(y_ptr, stride, u_ptr, uv_stride, v_ptr, uv_stride, |
sakal
2017/02/23 12:59:07
Hmm, it seems I420Copy is reading uv_stride * ((he
magjed_webrtc
2017/02/23 14:19:30
No. I made a new patch set that is more complicate
| |
819 i420_buffer->MutableDataY(), i420_buffer->StrideY(), | 821 i420_buffer->MutableDataY(), i420_buffer->StrideY(), |
820 i420_buffer->MutableDataU(), i420_buffer->StrideU(), | 822 i420_buffer->MutableDataU(), i420_buffer->StrideU(), |
821 i420_buffer->MutableDataV(), i420_buffer->StrideV(), | 823 i420_buffer->MutableDataV(), i420_buffer->StrideV(), |
822 width, height); | 824 width, height); |
823 } else { | 825 } else { |
824 // All other supported formats are nv12. | 826 // All other supported formats are nv12. |
825 const uint8_t* y_ptr = payload; | 827 const uint8_t* y_ptr = payload; |
826 const uint8_t* uv_ptr = y_ptr + stride * slice_height; | 828 const uint8_t* uv_ptr = y_ptr + stride * slice_height; |
827 libyuv::NV12ToI420(y_ptr, stride, uv_ptr, stride, | 829 libyuv::NV12ToI420(y_ptr, stride, uv_ptr, stride, |
828 i420_buffer->MutableDataY(), i420_buffer->StrideY(), | 830 i420_buffer->MutableDataY(), i420_buffer->StrideY(), |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 webrtc::VideoDecoder* decoder) { | 1003 webrtc::VideoDecoder* decoder) { |
1002 ALOGD << "Destroy video decoder."; | 1004 ALOGD << "Destroy video decoder."; |
1003 delete decoder; | 1005 delete decoder; |
1004 } | 1006 } |
1005 | 1007 |
1006 const char* MediaCodecVideoDecoder::ImplementationName() const { | 1008 const char* MediaCodecVideoDecoder::ImplementationName() const { |
1007 return "MediaCodec"; | 1009 return "MediaCodec"; |
1008 } | 1010 } |
1009 | 1011 |
1010 } // namespace webrtc_jni | 1012 } // namespace webrtc_jni |
OLD | NEW |