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

Unified Diff: media/cast/test/linux_output_window.cc

Issue 892383002: RELAND: [Cast] Software encoder support for varying video frame sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for 'access to uninitialized memory' error. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/test/fake_media_source.cc ('k') | media/cast/test/sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/linux_output_window.cc
diff --git a/media/cast/test/linux_output_window.cc b/media/cast/test/linux_output_window.cc
index 5a934aada4394cb8881729ead4159167c50c9eb2..486db98cc5f8f67d07b2d1a9100d3554f720738d 100644
--- a/media/cast/test/linux_output_window.cc
+++ b/media/cast/test/linux_output_window.cc
@@ -4,6 +4,8 @@
#include "media/cast/test/linux_output_window.h"
+#include <algorithm>
+
#include "base/logging.h"
#include "media/base/video_frame.h"
#include "third_party/libyuv/include/libyuv/convert.h"
@@ -118,18 +120,27 @@ void LinuxOutputWindow::CreateWindow(int x_pos,
void LinuxOutputWindow::RenderFrame(
const scoped_refptr<media::VideoFrame>& video_frame) {
- CHECK_LE(video_frame->coded_size().width(), image_->width);
- CHECK_LE(video_frame->coded_size().height(), image_->height);
- libyuv::I420ToARGB(video_frame->data(VideoFrame::kYPlane),
- video_frame->stride(VideoFrame::kYPlane),
- video_frame->data(VideoFrame::kUPlane),
- video_frame->stride(VideoFrame::kUPlane),
- video_frame->data(VideoFrame::kVPlane),
- video_frame->stride(VideoFrame::kVPlane),
- reinterpret_cast<uint8_t*>(image_->data),
- image_->bytes_per_line,
- video_frame->coded_size().width(),
- video_frame->coded_size().height());
+ const gfx::Size damage_size(std::min(video_frame->visible_rect().width(),
+ image_->width),
+ std::min(video_frame->visible_rect().height(),
+ image_->height));
+
+ if (damage_size.width() < image_->width ||
+ damage_size.height() < image_->height)
+ memset(image_->data, 0x00, image_->bytes_per_line * image_->height);
+
+ if (!damage_size.IsEmpty()) {
+ libyuv::I420ToARGB(video_frame->visible_data(VideoFrame::kYPlane),
+ video_frame->stride(VideoFrame::kYPlane),
+ video_frame->visible_data(VideoFrame::kUPlane),
+ video_frame->stride(VideoFrame::kUPlane),
+ video_frame->visible_data(VideoFrame::kVPlane),
+ video_frame->stride(VideoFrame::kVPlane),
+ reinterpret_cast<uint8_t*>(image_->data),
+ image_->bytes_per_line,
+ damage_size.width(),
+ damage_size.height());
+ }
// Place image in window.
XShmPutImage(display_,
@@ -140,8 +151,8 @@ void LinuxOutputWindow::RenderFrame(
0,
0,
0,
- video_frame->coded_size().width(),
- video_frame->coded_size().height(),
+ image_->width,
+ image_->height,
true);
// Very important for the image to update properly!
« no previous file with comments | « media/cast/test/fake_media_source.cc ('k') | media/cast/test/sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698