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:
thorcarpenter@google.com 2014-11-22 01:04:26 +00:00
parent 1153322cf8
commit 88d14f483b
3 changed files with 16 additions and 15 deletions

View File

@ -927,15 +927,20 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
void ProcessFrame(const VideoFrame& original_frame, bool mute,
VideoFrame** processed_frame) {
if (!mute) {
*processed_frame = original_frame.Copy();
*processed_frame = original_frame.Copy(); // Shallow copy.
} else {
WebRtcVideoFrame* black_frame = new WebRtcVideoFrame();
black_frame->InitToBlack(static_cast<int>(original_frame.GetWidth()),
static_cast<int>(original_frame.GetHeight()),
1, 1,
original_frame.GetElapsedTime(),
original_frame.GetTimeStamp());
*processed_frame = black_frame;
// Cache a black frame of the same dimensions as original_frame.
if (black_frame_.GetWidth() != original_frame.GetWidth() ||
black_frame_.GetHeight() != original_frame.GetHeight()) {
black_frame_.InitToBlack(static_cast<int>(original_frame.GetWidth()),
static_cast<int>(original_frame.GetHeight()),
1, 1,
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);
}
@ -979,6 +984,7 @@ class WebRtcVideoChannelSendInfo : public sigslot::has_slots<> {
VideoFormat adapt_format_;
AdaptFormatType adapt_format_type_;
WebRtcVideoFrame black_frame_; // Cached frame for mute.
};
static bool GetCpuOveruseOptions(const VideoOptions& options,

View File

@ -106,7 +106,7 @@ const webrtc::VideoFrame* WebRtcVideoFrame::FrameBuffer::frame() const {
}
WebRtcVideoFrame::WebRtcVideoFrame()
: video_buffer_(new RefCountedBuffer()), is_black_(false) {}
: video_buffer_(new RefCountedBuffer()) {}
WebRtcVideoFrame::~WebRtcVideoFrame() {}
@ -148,10 +148,7 @@ bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width,
size_t pixel_height, int64 elapsed_time,
int64 time_stamp) {
InitToEmptyBuffer(w, h, pixel_width, pixel_height, elapsed_time, time_stamp);
if (!is_black_) {
return SetToBlack();
}
return true;
return SetToBlack();
}
void WebRtcVideoFrame::Alias(
@ -261,7 +258,6 @@ void WebRtcVideoFrame::Attach(
if (video_buffer_.get() == video_buffer) {
return;
}
is_black_ = false;
video_buffer_ = video_buffer;
frame()->SetWidth(w);
frame()->SetHeight(h);

View File

@ -121,7 +121,6 @@ class WebRtcVideoFrame : public VideoFrame {
int64 elapsed_time, int64 time_stamp);
rtc::scoped_refptr<RefCountedBuffer> video_buffer_;
bool is_black_;
size_t pixel_width_;
size_t pixel_height_;
int64 elapsed_time_;