Scaler: Recycle allocations using buffer pool.
BUG=1128 R=stefan@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/49489004 Cr-Commit-Position: refs/heads/master@{#8828} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8828 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
09b6ff9460
commit
d4e7d49628
@ -226,4 +226,9 @@ rtc::scoped_refptr<VideoFrameBuffer> I420VideoFrame::video_frame_buffer()
|
||||
return video_frame_buffer_;
|
||||
}
|
||||
|
||||
void I420VideoFrame::set_video_frame_buffer(
|
||||
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer) {
|
||||
video_frame_buffer_ = buffer;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -15,6 +15,7 @@
|
||||
#ifndef WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
|
||||
#define WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
|
||||
|
||||
#include "webrtc/common_video/interface/i420_buffer_pool.h"
|
||||
#include "webrtc/common_video/interface/i420_video_frame.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -43,8 +44,7 @@ class Scaler {
|
||||
ScaleMethod method);
|
||||
|
||||
// Scale frame
|
||||
// Memory is allocated by user. If dst_frame is not of sufficient size,
|
||||
// the frame will be reallocated to the appropriate size.
|
||||
// Memory is allocated by this object and recycled using |buffer_pool_|.
|
||||
// Return value: 0 - OK,
|
||||
// -1 - parameter error
|
||||
// -2 - scaler not set
|
||||
@ -62,6 +62,7 @@ class Scaler {
|
||||
int dst_width_;
|
||||
int dst_height_;
|
||||
bool set_;
|
||||
I420BufferPool buffer_pool_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -56,10 +56,8 @@ int Scaler::Scale(const I420VideoFrame& src_frame,
|
||||
return -2;
|
||||
|
||||
// Making sure that destination frame is of sufficient size.
|
||||
// Aligning stride values based on width.
|
||||
dst_frame->CreateEmptyFrame(dst_width_, dst_height_,
|
||||
dst_width_, (dst_width_ + 1) / 2,
|
||||
(dst_width_ + 1) / 2);
|
||||
dst_frame->set_video_frame_buffer(
|
||||
buffer_pool_.CreateBuffer(dst_width_, dst_height_));
|
||||
|
||||
// We want to preserve aspect ratio instead of stretching the frame.
|
||||
// Therefore, we need to crop the source frame. Calculate the largest center
|
||||
|
@ -162,6 +162,10 @@ class I420VideoFrame {
|
||||
// Return the underlying buffer.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;
|
||||
|
||||
// Set the underlying buffer.
|
||||
void set_video_frame_buffer(
|
||||
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer);
|
||||
|
||||
private:
|
||||
// An opaque reference counted handle that stores the pixel data.
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
||||
@ -202,4 +206,3 @@ class EncodedImage {
|
||||
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_VIDEO_FRAME_H_
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user