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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 22875014: Merge 217276 "Add media::VideoEncodeAccelerator with WebRTC inte..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/filters/gpu_video_decoder_factories.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/cpu.h" 11 #include "base/cpu.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/task_runner_util.h" 14 #include "base/task_runner_util.h"
15 #include "media/base/bind_to_loop.h" 15 #include "media/base/bind_to_loop.h"
16 #include "media/base/decoder_buffer.h" 16 #include "media/base/decoder_buffer.h"
17 #include "media/base/pipeline.h" 17 #include "media/base/pipeline.h"
18 #include "media/base/pipeline_status.h" 18 #include "media/base/pipeline_status.h"
19 #include "media/base/video_decoder_config.h" 19 #include "media/base/video_decoder_config.h"
20 #include "media/filters/gpu_video_decoder_factories.h" 20 #include "media/filters/gpu_video_accelerator_factories.h"
21 21
22 namespace media { 22 namespace media {
23 23
24 // Maximum number of concurrent VDA::Decode() operations GVD will maintain. 24 // Maximum number of concurrent VDA::Decode() operations GVD will maintain.
25 // Higher values allow better pipelining in the GPU, but also require more 25 // Higher values allow better pipelining in the GPU, but also require more
26 // resources. 26 // resources.
27 enum { kMaxInFlightDecodes = 4 }; 27 enum { kMaxInFlightDecodes = 4 };
28 28
29 // Size of shared-memory segments we allocate. Since we reuse them we let them 29 // Size of shared-memory segments we allocate. Since we reuse them we let them
30 // be on the beefy side. 30 // be on the beefy side.
(...skipping 14 matching lines...) Expand all
45 45
46 GpuVideoDecoder::BufferData::BufferData( 46 GpuVideoDecoder::BufferData::BufferData(
47 int32 bbid, base::TimeDelta ts, const gfx::Rect& vr, const gfx::Size& ns) 47 int32 bbid, base::TimeDelta ts, const gfx::Rect& vr, const gfx::Size& ns)
48 : bitstream_buffer_id(bbid), timestamp(ts), visible_rect(vr), 48 : bitstream_buffer_id(bbid), timestamp(ts), visible_rect(vr),
49 natural_size(ns) { 49 natural_size(ns) {
50 } 50 }
51 51
52 GpuVideoDecoder::BufferData::~BufferData() {} 52 GpuVideoDecoder::BufferData::~BufferData() {}
53 53
54 GpuVideoDecoder::GpuVideoDecoder( 54 GpuVideoDecoder::GpuVideoDecoder(
55 const scoped_refptr<GpuVideoDecoderFactories>& factories) 55 const scoped_refptr<GpuVideoAcceleratorFactories>& factories)
56 : needs_bitstream_conversion_(false), 56 : needs_bitstream_conversion_(false),
57 gvd_loop_proxy_(factories->GetMessageLoop()), 57 gvd_loop_proxy_(factories->GetMessageLoop()),
58 weak_factory_(this), 58 weak_factory_(this),
59 factories_(factories), 59 factories_(factories),
60 state_(kNormal), 60 state_(kNormal),
61 decoder_texture_target_(0), 61 decoder_texture_target_(0),
62 next_picture_buffer_id_(0), 62 next_picture_buffer_id_(0),
63 next_bitstream_buffer_id_(0), 63 next_bitstream_buffer_id_(0),
64 available_pictures_(0) { 64 available_pictures_(0) {
65 DCHECK(factories_.get()); 65 DCHECK(factories_.get());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 needs_bitstream_conversion_ = (config.codec() == kCodecH264); 166 needs_bitstream_conversion_ = (config.codec() == kCodecH264);
167 167
168 if (previously_initialized) { 168 if (previously_initialized) {
169 // Reinitialization with a different config (but same codec and profile). 169 // Reinitialization with a different config (but same codec and profile).
170 // VDA should handle it by detecting this in-stream by itself, 170 // VDA should handle it by detecting this in-stream by itself,
171 // no need to notify it. 171 // no need to notify it.
172 status_cb.Run(PIPELINE_OK); 172 status_cb.Run(PIPELINE_OK);
173 return; 173 return;
174 } 174 }
175 175
176 vda_.reset(factories_->CreateVideoDecodeAccelerator(config.profile(), this)); 176 vda_ =
177 factories_->CreateVideoDecodeAccelerator(config.profile(), this).Pass();
177 if (!vda_) { 178 if (!vda_) {
178 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); 179 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED);
179 return; 180 return;
180 } 181 }
181 182
182 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded."; 183 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded.";
183 status_cb.Run(PIPELINE_OK); 184 status_cb.Run(PIPELINE_OK);
184 } 185 }
185 186
186 void GpuVideoDecoder::DestroyTextures() { 187 void GpuVideoDecoder::DestroyTextures() {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 pb.texture_mailbox(), 429 pb.texture_mailbox(),
429 0, // sync_point 430 0, // sync_point
430 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReusePictureBuffer, 431 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReusePictureBuffer,
431 weak_this_, 432 weak_this_,
432 picture.picture_buffer_id()))), 433 picture.picture_buffer_id()))),
433 decoder_texture_target_, 434 decoder_texture_target_,
434 pb.size(), 435 pb.size(),
435 visible_rect, 436 visible_rect,
436 natural_size, 437 natural_size,
437 timestamp, 438 timestamp,
438 base::Bind(&GpuVideoDecoderFactories::ReadPixels, 439 base::Bind(&GpuVideoAcceleratorFactories::ReadPixels,
439 factories_, 440 factories_,
440 pb.texture_id(), 441 pb.texture_id(),
441 decoder_texture_target_, 442 decoder_texture_target_,
442 gfx::Size(visible_rect.width(), visible_rect.height())), 443 gfx::Size(visible_rect.width(), visible_rect.height())),
443 base::Closure())); 444 base::Closure()));
444 CHECK_GT(available_pictures_, 0); 445 CHECK_GT(available_pictures_, 0);
445 --available_pictures_; 446 --available_pictures_;
446 bool inserted = 447 bool inserted =
447 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; 448 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second;
448 DCHECK(inserted); 449 DCHECK(inserted);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 598
598 state_ = kError; 599 state_ = kError;
599 600
600 if (!pending_decode_cb_.is_null()) { 601 if (!pending_decode_cb_.is_null()) {
601 base::ResetAndReturn(&pending_decode_cb_).Run(kDecodeError, NULL); 602 base::ResetAndReturn(&pending_decode_cb_).Run(kDecodeError, NULL);
602 return; 603 return;
603 } 604 }
604 } 605 }
605 606
606 } // namespace media 607 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/filters/gpu_video_decoder_factories.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698