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

Unified Diff: remoting/client/plugin/pepper_video_renderer_3d.cc

Issue 1411283003: Add workaround for PPB_VideoDecoder not setting visible_rect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
Index: remoting/client/plugin/pepper_video_renderer_3d.cc
diff --git a/remoting/client/plugin/pepper_video_renderer_3d.cc b/remoting/client/plugin/pepper_video_renderer_3d.cc
index 9e05d77aaba6dc965a4da6963aba05826960b5be..06330845485c4cf321b06d8c1d40ce761c672a55 100644
--- a/remoting/client/plugin/pepper_video_renderer_3d.cc
+++ b/remoting/client/plugin/pepper_video_renderer_3d.cc
@@ -21,12 +21,12 @@
namespace remoting {
// The implementation here requires that the decoder allocates at least 3
-// pictures. PPB_VideoDecode didn't support this parameter prior to
+// pictures. PPB_VideoDecoder didn't support this parameter prior to
// 1.1, so we have to pass 0 for backwards compatibility with older versions of
// the browser. Currently all API implementations allocate more than 3 buffers
// by default.
//
-// TODO(sergeyu): Change this to 3 once PPB_VideoDecode v1.1 is enabled on
+// TODO(sergeyu): Change this to 3 once PPB_VideoDecoder v1.1 is enabled on
// stable channel.
Wez 2015/10/19 21:56:16 nit: Is there a bug filed for that work? If so, re
Sergey Ulanov 2015/10/19 22:19:51 Added reference to the bug to get 1.1 API enabled
const uint32_t kMinimumPictureCount = 0; // 3
@@ -245,6 +245,10 @@ void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
event_handler_->OnVideoFrameDirtyRegion(dirty_region);
}
+ if (frame_sizes_) {
+ frame_sizes_->insert(std::make_pair(packet->frame_id(), frame_size_));
+ }
+
pending_packets_.push_back(
new PendingPacket(packet.Pass(), done_runner.Release()));
DecodeNextPacket();
@@ -313,6 +317,33 @@ void PepperVideoRenderer3D::OnPictureReady(int32_t result,
perf_tracker_->OnFrameDecoded(picture.decode_id);
+ // Workaround crbug.com/542945 by filling in visible_rect if it isn't set.
+ if (picture.visible_rect.size.width == 0 ||
+ picture.visible_rect.size.height == 0 || frame_sizes_) {
+
+ // Enable workaround by creating |frame_sizes_|.
+ if (!frame_sizes_) {
+ LOG(WARNING) << "PPB_VideoDecoder doesn't set visible_rect.";
+ frame_sizes_.reset(new FrameSizesMap());
+ }
+
+ FrameSizesMap::iterator size_it = frame_sizes_->find(picture.decode_id);
+ if (size_it != frame_sizes_->end()) {
+ picture.visible_rect.size.width = size_it->second.width();
+ picture.visible_rect.size.height = size_it->second.height();
+ frame_sizes_->erase(size_it);
+ } else {
+ // For the first few frames |frames_sizes_| will be empty as
+ // |frame_sizes_| is created only after the first picture is received and
+ // it's known that the workaround is necessary. So here we use
+ // |texture_size| as frame size. This may result is some minor visual
+ // artifacts, which will disappear with the next frame processed by
+ // ProcessVideoPacket().
+ picture.visible_rect.size.width = picture.texture_size.width;
+ picture.visible_rect.size.height = picture.texture_size.width;
+ }
+ }
+
next_picture_.reset(new Picture(&video_decoder_, picture));
PaintIfNeeded();
@@ -340,6 +371,7 @@ void PepperVideoRenderer3D::PaintIfNeeded() {
double scale_x = picture.visible_rect.size.width;
double scale_y = picture.visible_rect.size.height;
if (picture.texture_target != GL_TEXTURE_RECTANGLE_ARB) {
+ CHECK(picture.texture_size.width > 0 && picture.texture_size.height > 0);
Sergey Ulanov 2015/10/19 21:47:20 These CHECKs will help to diagnose similar issues
scale_x /= picture.texture_size.width;
scale_y /= picture.texture_size.height;
}
@@ -365,6 +397,8 @@ void PepperVideoRenderer3D::PaintIfNeeded() {
// nearest-neighbor scaling to achieve crisper image. Linear filter is used in
// all other cases.
GLint mag_filter = GL_LINEAR;
+ CHECK(picture.visible_rect.size.width > 0 &&
+ picture.visible_rect.size.height > 0);
if (view_size_.width() % picture.visible_rect.size.width == 0 &&
view_size_.height() % picture.visible_rect.size.height == 0) {
mag_filter = GL_NEAREST;

Powered by Google App Engine
This is Rietveld 408576698