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

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

Issue 9416087: Add texture target field to video frame (for use by native textures). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (c) 2011 -> (c) 2012 Created 8 years, 10 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') | webkit/media/webvideoframe_impl.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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "media/base/demuxer_stream.h" 10 #include "media/base/demuxer_stream.h"
(...skipping 30 matching lines...) Expand all
41 GpuVideoDecoder::BufferTimeData::~BufferTimeData() {} 41 GpuVideoDecoder::BufferTimeData::~BufferTimeData() {}
42 42
43 GpuVideoDecoder::GpuVideoDecoder( 43 GpuVideoDecoder::GpuVideoDecoder(
44 MessageLoop* message_loop, 44 MessageLoop* message_loop,
45 const scoped_refptr<Factories>& factories) 45 const scoped_refptr<Factories>& factories)
46 : gvd_loop_proxy_(message_loop->message_loop_proxy()), 46 : gvd_loop_proxy_(message_loop->message_loop_proxy()),
47 render_loop_proxy_(base::MessageLoopProxy::current()), 47 render_loop_proxy_(base::MessageLoopProxy::current()),
48 factories_(factories), 48 factories_(factories),
49 state_(kNormal), 49 state_(kNormal),
50 demuxer_read_in_progress_(false), 50 demuxer_read_in_progress_(false),
51 decoder_texture_target_(0),
51 next_picture_buffer_id_(0), 52 next_picture_buffer_id_(0),
52 next_bitstream_buffer_id_(0), 53 next_bitstream_buffer_id_(0),
53 shutting_down_(false) { 54 shutting_down_(false) {
54 DCHECK(gvd_loop_proxy_ && factories_); 55 DCHECK(gvd_loop_proxy_ && factories_);
55 } 56 }
56 57
57 GpuVideoDecoder::~GpuVideoDecoder() { 58 GpuVideoDecoder::~GpuVideoDecoder() {
58 DCHECK(!vda_); // Stop should have been already called. 59 DCHECK(!vda_); // Stop should have been already called.
59 DCHECK(pending_read_cb_.is_null()); 60 DCHECK(pending_read_cb_.is_null());
60 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { 61 for (size_t i = 0; i < available_shm_segments_.size(); ++i) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 320
320 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count, 321 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count,
321 const gfx::Size& size) { 322 const gfx::Size& size) {
322 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 323 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
323 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 324 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
324 &GpuVideoDecoder::ProvidePictureBuffers, this, count, size)); 325 &GpuVideoDecoder::ProvidePictureBuffers, this, count, size));
325 return; 326 return;
326 } 327 }
327 328
328 std::vector<uint32> texture_ids; 329 std::vector<uint32> texture_ids;
329 if (!factories_->CreateTextures(count, size, &texture_ids)) { 330 if (!factories_->CreateTextures(
331 count, size, &texture_ids, &decoder_texture_target_)) {
330 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 332 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
331 return; 333 return;
332 } 334 }
333 335
334 if (!vda_) 336 if (!vda_)
335 return; 337 return;
336 338
337 std::vector<PictureBuffer> picture_buffers; 339 std::vector<PictureBuffer> picture_buffers;
338 for (size_t i = 0; i < texture_ids.size(); ++i) { 340 for (size_t i = 0; i < texture_ids.size(); ++i) {
339 picture_buffers.push_back(PictureBuffer( 341 picture_buffers.push_back(PictureBuffer(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 377 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
376 return; 378 return;
377 } 379 }
378 const PictureBuffer& pb = it->second; 380 const PictureBuffer& pb = it->second;
379 381
380 // Update frame's timestamp. 382 // Update frame's timestamp.
381 base::TimeDelta timestamp; 383 base::TimeDelta timestamp;
382 base::TimeDelta duration; 384 base::TimeDelta duration;
383 GetBufferTimeData(picture.bitstream_buffer_id(), &timestamp, &duration); 385 GetBufferTimeData(picture.bitstream_buffer_id(), &timestamp, &duration);
384 386
387 DCHECK(decoder_texture_target_);
385 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( 388 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture(
386 pb.texture_id(), pb.size().width(), 389 pb.texture_id(), decoder_texture_target_, pb.size().width(),
387 pb.size().height(), timestamp, duration, 390 pb.size().height(), timestamp, duration,
388 base::Bind(&GpuVideoDecoder::ReusePictureBuffer, this, 391 base::Bind(&GpuVideoDecoder::ReusePictureBuffer, this,
389 picture.picture_buffer_id()))); 392 picture.picture_buffer_id())));
390 393
391 EnqueueFrameAndTriggerFrameDelivery(frame); 394 EnqueueFrameAndTriggerFrameDelivery(frame);
392 } 395 }
393 396
394 void GpuVideoDecoder::EnqueueFrameAndTriggerFrameDelivery( 397 void GpuVideoDecoder::EnqueueFrameAndTriggerFrameDelivery(
395 const scoped_refptr<VideoFrame>& frame) { 398 const scoped_refptr<VideoFrame>& frame) {
396 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 399 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 &GpuVideoDecoder::NotifyError, this, error)); 529 &GpuVideoDecoder::NotifyError, this, error));
527 return; 530 return;
528 } 531 }
529 vda_ = NULL; 532 vda_ = NULL;
530 DLOG(ERROR) << "VDA Error: " << error; 533 DLOG(ERROR) << "VDA Error: " << error;
531 if (host()) 534 if (host())
532 host()->SetError(PIPELINE_ERROR_DECODE); 535 host()->SetError(PIPELINE_ERROR_DECODE);
533 } 536 }
534 537
535 } // namespace media 538 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | webkit/media/webvideoframe_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698