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

Side by Side Diff: content/renderer/media/rtc_video_decoder.cc

Issue 1942123002: Plumb decoded video pixel format from GPU process to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test on bots Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_video_decoder.h" 5 #include "content/renderer/media/rtc_video_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 RTCVideoDecoder::BufferData::BufferData() {} 59 RTCVideoDecoder::BufferData::BufferData() {}
60 60
61 RTCVideoDecoder::BufferData::~BufferData() {} 61 RTCVideoDecoder::BufferData::~BufferData() {}
62 62
63 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, 63 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type,
64 media::GpuVideoAcceleratorFactories* factories) 64 media::GpuVideoAcceleratorFactories* factories)
65 : vda_error_counter_(0), 65 : vda_error_counter_(0),
66 video_codec_type_(type), 66 video_codec_type_(type),
67 factories_(factories), 67 factories_(factories),
68 decoder_texture_target_(0), 68 decoder_texture_target_(0),
69 pixel_format_(media::PIXEL_FORMAT_UNKNOWN),
69 next_picture_buffer_id_(0), 70 next_picture_buffer_id_(0),
70 state_(UNINITIALIZED), 71 state_(UNINITIALIZED),
71 decode_complete_callback_(nullptr), 72 decode_complete_callback_(nullptr),
72 num_shm_buffers_(0), 73 num_shm_buffers_(0),
73 next_bitstream_buffer_id_(0), 74 next_bitstream_buffer_id_(0),
74 reset_bitstream_buffer_id_(ID_INVALID), 75 reset_bitstream_buffer_id_(ID_INVALID),
75 weak_factory_(this) { 76 weak_factory_(this) {
76 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); 77 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread());
77 } 78 }
78 79
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 state_ = RESETTING; 305 state_ = RESETTING;
305 factories_->GetTaskRunner()->PostTask( 306 factories_->GetTaskRunner()->PostTask(
306 FROM_HERE, 307 FROM_HERE,
307 base::Bind(&RTCVideoDecoder::ResetInternal, 308 base::Bind(&RTCVideoDecoder::ResetInternal,
308 weak_factory_.GetWeakPtr())); 309 weak_factory_.GetWeakPtr()));
309 } 310 }
310 return WEBRTC_VIDEO_CODEC_OK; 311 return WEBRTC_VIDEO_CODEC_OK;
311 } 312 }
312 313
313 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, 314 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count,
315 media::VideoPixelFormat format,
314 uint32_t textures_per_buffer, 316 uint32_t textures_per_buffer,
315 const gfx::Size& size, 317 const gfx::Size& size,
316 uint32_t texture_target) { 318 uint32_t texture_target) {
317 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 319 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
318 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; 320 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target;
319 DCHECK_EQ(1u, textures_per_buffer); 321 DCHECK_EQ(1u, textures_per_buffer);
320 322
321 if (!vda_) 323 if (!vda_)
322 return; 324 return;
323 325
324 std::vector<uint32_t> texture_ids; 326 std::vector<uint32_t> texture_ids;
325 std::vector<gpu::Mailbox> texture_mailboxes; 327 std::vector<gpu::Mailbox> texture_mailboxes;
326 decoder_texture_target_ = texture_target; 328 decoder_texture_target_ = texture_target;
329
330 if (format == media::PIXEL_FORMAT_UNKNOWN)
331 format = media::PIXEL_FORMAT_ARGB;
332
333 if ((pixel_format_ != media::PIXEL_FORMAT_UNKNOWN) &&
334 (format != pixel_format_)) {
335 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
336 return;
337 }
338
339 pixel_format_ = format;
327 if (!factories_->CreateTextures(count, 340 if (!factories_->CreateTextures(count,
328 size, 341 size,
329 &texture_ids, 342 &texture_ids,
330 &texture_mailboxes, 343 &texture_mailboxes,
331 decoder_texture_target_)) { 344 decoder_texture_target_)) {
332 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 345 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
333 return; 346 return;
334 } 347 }
335 DCHECK_EQ(count, texture_ids.size()); 348 DCHECK_EQ(count, texture_ids.size());
336 DCHECK_EQ(count, texture_mailboxes.size()); 349 DCHECK_EQ(count, texture_mailboxes.size());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 visible_rect = picture.visible_rect(); 406 visible_rect = picture.visible_rect();
394 407
395 const media::PictureBuffer& pb = it->second; 408 const media::PictureBuffer& pb = it->second;
396 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { 409 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) {
397 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() 410 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString()
398 << " should fit in " << pb.size().ToString(); 411 << " should fit in " << pb.size().ToString();
399 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 412 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
400 return; 413 return;
401 } 414 }
402 415
403 media::VideoPixelFormat pixel_format = vda_->GetOutputFormat();
404 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN)
405 pixel_format = media::PIXEL_FORMAT_ARGB;
406
407 scoped_refptr<media::VideoFrame> frame = 416 scoped_refptr<media::VideoFrame> frame =
408 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format); 417 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format_);
409 if (!frame) { 418 if (!frame) {
410 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 419 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
411 return; 420 return;
412 } 421 }
413 bool inserted = picture_buffers_at_display_ 422 bool inserted = picture_buffers_at_display_
414 .insert(std::make_pair(picture.picture_buffer_id(), 423 .insert(std::make_pair(picture.picture_buffer_id(),
415 pb.texture_ids()[0])) 424 pb.texture_ids()[0]))
416 .second; 425 .second;
417 DCHECK(inserted); 426 DCHECK(inserted);
418 427
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 886
878 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { 887 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() {
879 lock_.AssertAcquired(); 888 lock_.AssertAcquired();
880 889
881 if (vda_error_counter_ == 0) 890 if (vda_error_counter_ == 0)
882 return; 891 return;
883 vda_error_counter_ = 0; 892 vda_error_counter_ = 0;
884 } 893 }
885 894
886 } // namespace content 895 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_decoder.h ('k') | content/renderer/pepper/pepper_video_decoder_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698