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

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: 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
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | media/filters/opus_audio_decoder.cc » ('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"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 case kDecoderDrained: 345 case kDecoderDrained:
346 if (!ready_video_frames_.empty()) { 346 if (!ready_video_frames_.empty()) {
347 EnqueueFrameAndTriggerFrameDelivery(NULL); 347 EnqueueFrameAndTriggerFrameDelivery(NULL);
348 return; 348 return;
349 } 349 }
350 state_ = kNormal; 350 state_ = kNormal;
351 // Fall-through. 351 // Fall-through.
352 case kNormal: 352 case kNormal:
353 break; 353 break;
354 case kDrainingDecoder: 354 case kDrainingDecoder:
355 DCHECK(buffer->IsEndOfStream()); 355 DCHECK(buffer->end_of_stream());
356 // Do nothing. Will be satisfied either by a PictureReady or 356 // Do nothing. Will be satisfied either by a PictureReady or
357 // NotifyFlushDone below. 357 // NotifyFlushDone below.
358 return; 358 return;
359 case kError: 359 case kError:
360 NOTREACHED(); 360 NOTREACHED();
361 return; 361 return;
362 } 362 }
363 363
364 if (buffer->IsEndOfStream()) { 364 if (buffer->end_of_stream()) {
365 if (state_ == kNormal) { 365 if (state_ == kNormal) {
366 state_ = kDrainingDecoder; 366 state_ = kDrainingDecoder;
367 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 367 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
368 &VideoDecodeAccelerator::Flush, weak_vda_)); 368 &VideoDecodeAccelerator::Flush, weak_vda_));
369 } 369 }
370 return; 370 return;
371 } 371 }
372 372
373 size_t size = buffer->GetDataSize(); 373 size_t size = buffer->data_size();
374 SHMBuffer* shm_buffer = GetSHM(size); 374 SHMBuffer* shm_buffer = GetSHM(size);
375 if (!shm_buffer) { 375 if (!shm_buffer) {
376 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 376 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
377 return; 377 return;
378 } 378 }
379 379
380 memcpy(shm_buffer->shm->memory(), buffer->GetData(), size); 380 memcpy(shm_buffer->shm->memory(), buffer->data(), size);
381 BitstreamBuffer bitstream_buffer( 381 BitstreamBuffer bitstream_buffer(
382 next_bitstream_buffer_id_, shm_buffer->shm->handle(), size); 382 next_bitstream_buffer_id_, shm_buffer->shm->handle(), size);
383 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. 383 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
384 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; 384 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
385 bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair( 385 bool inserted = bitstream_buffers_in_decoder_.insert(std::make_pair(
386 bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second; 386 bitstream_buffer.id(), BufferPair(shm_buffer, buffer))).second;
387 DCHECK(inserted); 387 DCHECK(inserted);
388 RecordBufferData(bitstream_buffer, *buffer.get()); 388 RecordBufferData(bitstream_buffer, *buffer.get());
389 389
390 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 390 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
391 &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer)); 391 &VideoDecodeAccelerator::Decode, weak_vda_, bitstream_buffer));
392 392
393 if (!ready_video_frames_.empty()) { 393 if (!ready_video_frames_.empty()) {
394 EnqueueFrameAndTriggerFrameDelivery(NULL); 394 EnqueueFrameAndTriggerFrameDelivery(NULL);
395 return; 395 return;
396 } 396 }
397 397
398 if (CanMoreDecodeWorkBeDone()) 398 if (CanMoreDecodeWorkBeDone())
399 base::ResetAndReturn(&pending_read_cb_).Run(kNotEnoughData, NULL); 399 base::ResetAndReturn(&pending_read_cb_).Run(kNotEnoughData, NULL);
400 } 400 }
401 401
402 bool GpuVideoDecoder::CanMoreDecodeWorkBeDone() { 402 bool GpuVideoDecoder::CanMoreDecodeWorkBeDone() {
403 return bitstream_buffers_in_decoder_.size() < kMaxInFlightDecodes; 403 return bitstream_buffers_in_decoder_.size() < kMaxInFlightDecodes;
404 } 404 }
405 405
406 void GpuVideoDecoder::RecordBufferData(const BitstreamBuffer& bitstream_buffer, 406 void GpuVideoDecoder::RecordBufferData(const BitstreamBuffer& bitstream_buffer,
407 const DecoderBuffer& buffer) { 407 const DecoderBuffer& buffer) {
408 input_buffer_data_.push_front(BufferData(bitstream_buffer.id(), 408 input_buffer_data_.push_front(BufferData(bitstream_buffer.id(),
409 buffer.GetTimestamp(), 409 buffer.timestamp(),
410 config_.visible_rect(), 410 config_.visible_rect(),
411 config_.natural_size())); 411 config_.natural_size()));
412 // Why this value? Because why not. avformat.h:MAX_REORDER_DELAY is 16, but 412 // Why this value? Because why not. avformat.h:MAX_REORDER_DELAY is 16, but
413 // that's too small for some pathological B-frame test videos. The cost of 413 // that's too small for some pathological B-frame test videos. The cost of
414 // using too-high a value is low (192 bits per extra slot). 414 // using too-high a value is low (192 bits per extra slot).
415 static const size_t kMaxInputBufferDataSize = 128; 415 static const size_t kMaxInputBufferDataSize = 128;
416 // Pop from the back of the list, because that's the oldest and least likely 416 // Pop from the back of the list, because that's the oldest and least likely
417 // to be useful in the future data. 417 // to be useful in the future data.
418 if (input_buffer_data_.size() > kMaxInputBufferDataSize) 418 if (input_buffer_data_.size() > kMaxInputBufferDataSize)
419 input_buffer_data_.pop_back(); 419 input_buffer_data_.pop_back();
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 719
720 state_ = kError; 720 state_ = kError;
721 721
722 if (!pending_read_cb_.is_null()) { 722 if (!pending_read_cb_.is_null()) {
723 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 723 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
724 return; 724 return;
725 } 725 }
726 } 726 }
727 727
728 } // namespace media 728 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | media/filters/opus_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698