Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc

Issue 2927943003: Return WrappedI444Buffer in VP9Impl (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 return WEBRTC_VIDEO_CODEC_NO_OUTPUT; 959 return WEBRTC_VIDEO_CODEC_NO_OUTPUT;
960 } 960 }
961 961
962 // This buffer contains all of |img|'s image data, a reference counted 962 // This buffer contains all of |img|'s image data, a reference counted
963 // Vp9FrameBuffer. (libvpx is done with the buffers after a few 963 // Vp9FrameBuffer. (libvpx is done with the buffers after a few
964 // vpx_codec_decode calls or vpx_codec_destroy). 964 // vpx_codec_decode calls or vpx_codec_destroy).
965 Vp9FrameBufferPool::Vp9FrameBuffer* img_buffer = 965 Vp9FrameBufferPool::Vp9FrameBuffer* img_buffer =
966 static_cast<Vp9FrameBufferPool::Vp9FrameBuffer*>(img->fb_priv); 966 static_cast<Vp9FrameBufferPool::Vp9FrameBuffer*>(img->fb_priv);
967 // The buffer can be used directly by the VideoFrame (without copy) by 967 // The buffer can be used directly by the VideoFrame (without copy) by
968 // using a WrappedI420Buffer. 968 // using a WrappedI420Buffer.
969 rtc::scoped_refptr<WrappedI420Buffer> img_wrapped_buffer( 969 rtc::scoped_refptr<VideoFrameBuffer> img_wrapped_buffer;
970 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>( 970
971 img->d_w, img->d_h, img->planes[VPX_PLANE_Y], 971 if (img->fmt == VPX_IMG_FMT_I444) {
972 img->stride[VPX_PLANE_Y], img->planes[VPX_PLANE_U], 972 img_wrapped_buffer = new rtc::RefCountedObject<webrtc::WrappedI444Buffer>(
nisse-webrtc 2017/06/09 09:01:22 It's a pity classes aren't first class in C++, but
Yuwei 2017/06/10 00:13:53 Unfortunately function that returns scoped_refptr<
magjed_webrtc 2017/06/13 11:38:27 Yeah, I would like to spare users this duplication
nisse-webrtc 2017/06/13 12:29:09 Ouch. One would need to wrap them in a lambda or s
nisse-webrtc 2017/06/13 12:29:09 Sounds good to me too.
Yuwei 2017/06/19 21:33:26 Added the WrapYuvBuffer function. Functional tric
Yuwei 2017/06/19 21:33:26 Done.
973 img->stride[VPX_PLANE_U], img->planes[VPX_PLANE_V], 973 img->d_w, img->d_h, img->planes[VPX_PLANE_Y],
974 img->stride[VPX_PLANE_V], 974 img->stride[VPX_PLANE_Y], img->planes[VPX_PLANE_U],
975 // WrappedI420Buffer's mechanism for allowing the release of its frame 975 img->stride[VPX_PLANE_U], img->planes[VPX_PLANE_V],
976 // buffer is through a callback function. This is where we should 976 img->stride[VPX_PLANE_V],
977 // release |img_buffer|. 977 // WrappedI444Buffer's mechanism for allowing the release of its frame
978 rtc::KeepRefUntilDone(img_buffer))); 978 // buffer is through a callback function. This is where we should
979 // release |img_buffer|.
980 rtc::KeepRefUntilDone(img_buffer));
981 } else {
982 img_wrapped_buffer = new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(
983 img->d_w, img->d_h, img->planes[VPX_PLANE_Y],
984 img->stride[VPX_PLANE_Y], img->planes[VPX_PLANE_U],
985 img->stride[VPX_PLANE_U], img->planes[VPX_PLANE_V],
986 img->stride[VPX_PLANE_V],
987 // WrappedI420Buffer's mechanism for allowing the release of its frame
988 // buffer is through a callback function. This is where we should
989 // release |img_buffer|.
990 rtc::KeepRefUntilDone(img_buffer));
991 }
979 992
980 VideoFrame decoded_image(img_wrapped_buffer, timestamp, 993 VideoFrame decoded_image(img_wrapped_buffer, timestamp,
981 0 /* render_time_ms */, webrtc::kVideoRotation_0); 994 0 /* render_time_ms */, webrtc::kVideoRotation_0);
982 decoded_image.set_ntp_time_ms(ntp_time_ms); 995 decoded_image.set_ntp_time_ms(ntp_time_ms);
983 996
984 decode_complete_callback_->Decoded(decoded_image, rtc::Optional<int32_t>(), 997 decode_complete_callback_->Decoded(decoded_image, rtc::Optional<int32_t>(),
985 rtc::Optional<uint8_t>(qp)); 998 rtc::Optional<uint8_t>(qp));
986 return WEBRTC_VIDEO_CODEC_OK; 999 return WEBRTC_VIDEO_CODEC_OK;
987 } 1000 }
988 1001
(...skipping 19 matching lines...) Expand all
1008 frame_buffer_pool_.ClearPool(); 1021 frame_buffer_pool_.ClearPool();
1009 inited_ = false; 1022 inited_ = false;
1010 return WEBRTC_VIDEO_CODEC_OK; 1023 return WEBRTC_VIDEO_CODEC_OK;
1011 } 1024 }
1012 1025
1013 const char* VP9DecoderImpl::ImplementationName() const { 1026 const char* VP9DecoderImpl::ImplementationName() const {
1014 return "libvpx"; 1027 return "libvpx";
1015 } 1028 }
1016 1029
1017 } // namespace webrtc 1030 } // namespace webrtc
OLDNEW
« webrtc/common_video/include/video_frame_buffer.h ('K') | « webrtc/common_video/video_frame_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698