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

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

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: Rebased against origin/master Created 7 years, 5 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 (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/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 395
396 // VideoFrameStream ensures no kConfigChanged is passed to VideoDecoders. 396 // VideoFrameStream ensures no kConfigChanged is passed to VideoDecoders.
397 DCHECK_EQ(status, DemuxerStream::kOk) << status; 397 DCHECK_EQ(status, DemuxerStream::kOk) << status;
398 398
399 if (!vda_) { 399 if (!vda_) {
400 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame()); 400 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame());
401 return; 401 return;
402 } 402 }
403 403
404 if (buffer->IsEndOfStream()) { 404 if (buffer->end_of_stream()) {
405 if (state_ == kNormal) { 405 if (state_ == kNormal) {
406 state_ = kDrainingDecoder; 406 state_ = kDrainingDecoder;
407 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 407 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
408 &VideoDecodeAccelerator::Flush, weak_vda_)); 408 &VideoDecodeAccelerator::Flush, weak_vda_));
409 } 409 }
410 return; 410 return;
411 } 411 }
412 412
413 if (!pending_reset_cb_.is_null()) 413 if (!pending_reset_cb_.is_null())
414 return; 414 return;
415 415
416 size_t size = buffer->GetDataSize(); 416 size_t size = buffer->data_size();
417 SHMBuffer* shm_buffer = GetSHM(size); 417 SHMBuffer* shm_buffer = GetSHM(size);
418 if (!shm_buffer) 418 if (!shm_buffer)
419 return; 419 return;
420 420
421 memcpy(shm_buffer->shm->memory(), buffer->GetData(), size); 421 memcpy(shm_buffer->shm->memory(), buffer->data(), size);
422 BitstreamBuffer bitstream_buffer( 422 BitstreamBuffer bitstream_buffer(
423 next_bitstream_buffer_id_, shm_buffer->shm->handle(), size); 423 next_bitstream_buffer_id_, shm_buffer->shm->handle(), size);
424 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. 424 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
425 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; 425 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
426 bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair( 426 bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair(
427 bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second; 427 bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second;
428 DCHECK(inserted); 428 DCHECK(inserted);
429 RecordBufferData(bitstream_buffer, *buffer.get()); 429 RecordBufferData(bitstream_buffer, *buffer.get());
430 430
431 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 431 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
432 &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer)); 432 &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer));
433 433
434 if (CanMoreDecodeWorkBeDone()) { 434 if (CanMoreDecodeWorkBeDone()) {
435 // Force post here to prevent reentrancy into DemuxerStream. 435 // Force post here to prevent reentrancy into DemuxerStream.
436 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 436 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
437 &GpuVideoDecoder::EnsureDemuxOrDecode, weak_this_)); 437 &GpuVideoDecoder::EnsureDemuxOrDecode, weak_this_));
438 } 438 }
439 } 439 }
440 440
441 void GpuVideoDecoder::RecordBufferData( 441 void GpuVideoDecoder::RecordBufferData(
442 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer) { 442 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer) {
443 input_buffer_data_.push_front(BufferData( 443 input_buffer_data_.push_front(BufferData(
444 bitstream_buffer.id(), buffer.GetTimestamp(), 444 bitstream_buffer.id(), buffer.timestamp(),
445 demuxer_stream_->video_decoder_config().visible_rect(), 445 demuxer_stream_->video_decoder_config().visible_rect(),
446 demuxer_stream_->video_decoder_config().natural_size())); 446 demuxer_stream_->video_decoder_config().natural_size()));
447 // Why this value? Because why not. avformat.h:MAX_REORDER_DELAY is 16, but 447 // Why this value? Because why not. avformat.h:MAX_REORDER_DELAY is 16, but
448 // that's too small for some pathological B-frame test videos. The cost of 448 // that's too small for some pathological B-frame test videos. The cost of
449 // using too-high a value is low (192 bits per extra slot). 449 // using too-high a value is low (192 bits per extra slot).
450 static const size_t kMaxInputBufferDataSize = 128; 450 static const size_t kMaxInputBufferDataSize = 128;
451 // Pop from the back of the list, because that's the oldest and least likely 451 // Pop from the back of the list, because that's the oldest and least likely
452 // to be useful in the future data. 452 // to be useful in the future data.
453 if (input_buffer_data_.size() > kMaxInputBufferDataSize) 453 if (input_buffer_data_.size() > kMaxInputBufferDataSize)
454 input_buffer_data_.pop_back(); 454 input_buffer_data_.pop_back();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 std::map<int32, BufferPair>::iterator it = 683 std::map<int32, BufferPair>::iterator it =
684 bitstream_buffers_in_decoder_.find(id); 684 bitstream_buffers_in_decoder_.find(id);
685 if (it == bitstream_buffers_in_decoder_.end()) { 685 if (it == bitstream_buffers_in_decoder_.end()) {
686 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 686 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
687 NOTREACHED() << "Missing bitstream buffer: " << id; 687 NOTREACHED() << "Missing bitstream buffer: " << id;
688 return; 688 return;
689 } 689 }
690 690
691 PutSHM(it->second.shm_buffer); 691 PutSHM(it->second.shm_buffer);
692 const scoped_refptr<DecoderBuffer>& buffer = it->second.buffer; 692 const scoped_refptr<DecoderBuffer>& buffer = it->second.buffer;
693 if (buffer->GetDataSize()) { 693 if (buffer->data_size()) {
694 PipelineStatistics statistics; 694 PipelineStatistics statistics;
695 statistics.video_bytes_decoded = buffer->GetDataSize(); 695 statistics.video_bytes_decoded = buffer->data_size();
696 statistics_cb_.Run(statistics); 696 statistics_cb_.Run(statistics);
697 } 697 }
698 bitstream_buffers_in_decoder_.erase(it); 698 bitstream_buffers_in_decoder_.erase(it);
699 699
700 if (pending_reset_cb_.is_null() && state_ != kDrainingDecoder && 700 if (pending_reset_cb_.is_null() && state_ != kDrainingDecoder &&
701 CanMoreDecodeWorkBeDone()) { 701 CanMoreDecodeWorkBeDone()) {
702 EnsureDemuxOrDecode(); 702 EnsureDemuxOrDecode();
703 } 703 }
704 } 704 }
705 705
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 768
769 state_ = kError; 769 state_ = kError;
770 770
771 if (!pending_read_cb_.is_null()) { 771 if (!pending_read_cb_.is_null()) {
772 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 772 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
773 return; 773 return;
774 } 774 }
775 } 775 }
776 776
777 } // namespace media 777 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698