Remove expensive and unnecessary memory alloc for sending black frames on video
mute. Remove old crusty is_black_ member var in webrtcvideoengine which was not adding value. R=henrike@webrtc.org, tpsiaki@google.com Review URL: https://webrtc-codereview.appspot.com/26229004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7731 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
1153322cf8
commit
88d14f483b
@ -927,15 +927,20 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
|
|||||||
void ProcessFrame(const VideoFrame& original_frame, bool mute,
|
void ProcessFrame(const VideoFrame& original_frame, bool mute,
|
||||||
VideoFrame** processed_frame) {
|
VideoFrame** processed_frame) {
|
||||||
if (!mute) {
|
if (!mute) {
|
||||||
*processed_frame = original_frame.Copy();
|
*processed_frame = original_frame.Copy(); // Shallow copy.
|
||||||
} else {
|
} else {
|
||||||
WebRtcVideoFrame* black_frame = new WebRtcVideoFrame();
|
// Cache a black frame of the same dimensions as original_frame.
|
||||||
black_frame->InitToBlack(static_cast<int>(original_frame.GetWidth()),
|
if (black_frame_.GetWidth() != original_frame.GetWidth() ||
|
||||||
static_cast<int>(original_frame.GetHeight()),
|
black_frame_.GetHeight() != original_frame.GetHeight()) {
|
||||||
1, 1,
|
black_frame_.InitToBlack(static_cast<int>(original_frame.GetWidth()),
|
||||||
original_frame.GetElapsedTime(),
|
static_cast<int>(original_frame.GetHeight()),
|
||||||
original_frame.GetTimeStamp());
|
1, 1,
|
||||||
*processed_frame = black_frame;
|
original_frame.GetElapsedTime(),
|
||||||
|
original_frame.GetTimeStamp());
|
||||||
|
}
|
||||||
|
*processed_frame = black_frame_.Copy(); // Shallow copy.
|
||||||
|
(*processed_frame)->SetElapsedTime(original_frame.GetElapsedTime());
|
||||||
|
(*processed_frame)->SetTimeStamp(original_frame.GetTimeStamp());
|
||||||
}
|
}
|
||||||
local_stream_info_.UpdateFrame(*processed_frame);
|
local_stream_info_.UpdateFrame(*processed_frame);
|
||||||
}
|
}
|
||||||
@ -979,6 +984,7 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
|
|||||||
|
|
||||||
VideoFormat adapt_format_;
|
VideoFormat adapt_format_;
|
||||||
AdaptFormatType adapt_format_type_;
|
AdaptFormatType adapt_format_type_;
|
||||||
|
WebRtcVideoFrame black_frame_; // Cached frame for mute.
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool GetCpuOveruseOptions(const VideoOptions& options,
|
static bool GetCpuOveruseOptions(const VideoOptions& options,
|
||||||
|
@ -106,7 +106,7 @@ const webrtc::VideoFrame* WebRtcVideoFrame::FrameBuffer::frame() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebRtcVideoFrame::WebRtcVideoFrame()
|
WebRtcVideoFrame::WebRtcVideoFrame()
|
||||||
: video_buffer_(new RefCountedBuffer()), is_black_(false) {}
|
: video_buffer_(new RefCountedBuffer()) {}
|
||||||
|
|
||||||
WebRtcVideoFrame::~WebRtcVideoFrame() {}
|
WebRtcVideoFrame::~WebRtcVideoFrame() {}
|
||||||
|
|
||||||
@ -148,10 +148,7 @@ bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width,
|
|||||||
size_t pixel_height, int64 elapsed_time,
|
size_t pixel_height, int64 elapsed_time,
|
||||||
int64 time_stamp) {
|
int64 time_stamp) {
|
||||||
InitToEmptyBuffer(w, h, pixel_width, pixel_height, elapsed_time, time_stamp);
|
InitToEmptyBuffer(w, h, pixel_width, pixel_height, elapsed_time, time_stamp);
|
||||||
if (!is_black_) {
|
return SetToBlack();
|
||||||
return SetToBlack();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcVideoFrame::Alias(
|
void WebRtcVideoFrame::Alias(
|
||||||
@ -261,7 +258,6 @@ void WebRtcVideoFrame::Attach(
|
|||||||
if (video_buffer_.get() == video_buffer) {
|
if (video_buffer_.get() == video_buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
is_black_ = false;
|
|
||||||
video_buffer_ = video_buffer;
|
video_buffer_ = video_buffer;
|
||||||
frame()->SetWidth(w);
|
frame()->SetWidth(w);
|
||||||
frame()->SetHeight(h);
|
frame()->SetHeight(h);
|
||||||
|
@ -121,7 +121,6 @@ class WebRtcVideoFrame : public VideoFrame {
|
|||||||
int64 elapsed_time, int64 time_stamp);
|
int64 elapsed_time, int64 time_stamp);
|
||||||
|
|
||||||
rtc::scoped_refptr<RefCountedBuffer> video_buffer_;
|
rtc::scoped_refptr<RefCountedBuffer> video_buffer_;
|
||||||
bool is_black_;
|
|
||||||
size_t pixel_width_;
|
size_t pixel_width_;
|
||||||
size_t pixel_height_;
|
size_t pixel_height_;
|
||||||
int64 elapsed_time_;
|
int64 elapsed_time_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user