Index: webrtc/examples/peerconnection/client/linux/main_wnd.cc |
diff --git a/webrtc/examples/peerconnection/client/linux/main_wnd.cc b/webrtc/examples/peerconnection/client/linux/main_wnd.cc |
index 95229c9e13febe2efcef6941deeb1e9d05647c9e..eda66178265b72eb8bc23adebcd760b01bdf91d1 100644 |
--- a/webrtc/examples/peerconnection/client/linux/main_wnd.cc |
+++ b/webrtc/examples/peerconnection/client/linux/main_wnd.cc |
@@ -14,6 +14,7 @@ |
#include <gtk/gtk.h> |
#include <stddef.h> |
+#include "libyuv/convert_from.h" |
#include "webrtc/examples/peerconnection/client/defaults.h" |
#include "webrtc/base/common.h" |
#include "webrtc/base/logging.h" |
@@ -492,23 +493,13 @@ void GtkMainWnd::VideoRenderer::OnFrame( |
SetSize(frame.width(), frame.height()); |
- int size = width_ * height_ * 4; |
- // TODO(henrike): Convert directly to RGBA |
- frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB, |
- image_.get(), |
- size, |
- width_ * 4); |
- // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. |
- // The 'A' is just padding for GTK, so we can use it as temp. |
- uint8_t* pix = image_.get(); |
- uint8_t* end = image_.get() + size; |
- while (pix < end) { |
- pix[3] = pix[0]; // Save B to A. |
- pix[0] = pix[2]; // Set Red. |
- pix[2] = pix[3]; // Set Blue. |
- pix[3] = 0xFF; // Fixed Alpha. |
- pix += 4; |
- } |
+ rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( |
+ frame.video_frame_buffer()); |
+ libyuv::I420ToRGBA(buffer->DataY(), buffer->StrideY(), |
+ buffer->DataU(), buffer->StrideU(), |
+ buffer->DataV(), buffer->StrideV(), |
+ image_.get(), width_ * 4, |
+ buffer->width(), buffer->height()); |
gdk_threads_leave(); |