| Index: content/common/gpu/media/fake_video_decode_accelerator.cc
|
| diff --git a/content/common/gpu/media/fake_video_decode_accelerator.cc b/content/common/gpu/media/fake_video_decode_accelerator.cc
|
| index f8111623d0581a4f34191b0c73a4c9e3fc449731..f3fa5137ccedb0d529c92f47fa840abe3b260197 100644
|
| --- a/content/common/gpu/media/fake_video_decode_accelerator.cc
|
| +++ b/content/common/gpu/media/fake_video_decode_accelerator.cc
|
| @@ -53,6 +53,14 @@ bool FakeVideoDecodeAccelerator::Initialize(const Config& config,
|
| return false;
|
| }
|
|
|
| + if (config.flush_mode != Config::FlushMode::KEEP_OUTPUT_BUFFERS &&
|
| + config.flush_mode != Config::FlushMode::RETURN_OUTPUT_BUFFERS) {
|
| + NOTIMPLEMENTED() << "Unsupported Config::FlushMode";
|
| + return false;
|
| + }
|
| +
|
| + config_ = config;
|
| +
|
| // V4L2VideoDecodeAccelerator waits until first decode call to ask for buffers
|
| // This class asks for it on initialization instead.
|
| client_ = client;
|
| @@ -80,11 +88,9 @@ void FakeVideoDecodeAccelerator::Decode(
|
| weak_this_factory_.GetWeakPtr()));
|
| }
|
|
|
| -// Similar to UseOutputBitstreamBuffer for the encode accelerator.
|
| void FakeVideoDecodeAccelerator::AssignPictureBuffers(
|
| const std::vector<media::PictureBuffer>& buffers) {
|
| - DCHECK(buffers.size() == kNumBuffers);
|
| - DCHECK(!(buffers.size()%2));
|
| + DCHECK_GE(buffers.size(), kNumBuffers);
|
|
|
| // Save buffers and mark all buffers as ready for use.
|
| std::unique_ptr<uint8_t[]> white_data(
|
| @@ -165,29 +171,38 @@ bool FakeVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
|
| return false;
|
| }
|
|
|
| +void FakeVideoDecodeAccelerator::ReturnPicture(int32_t picture_buffer_id,
|
| + int32_t bitstream_buffer_id) {
|
| + const media::Picture picture =
|
| + media::Picture(picture_buffer_id, bitstream_buffer_id,
|
| + gfx::Rect(frame_buffer_size_), false);
|
| +
|
| + client_->PictureReady(picture);
|
| +}
|
| +
|
| void FakeVideoDecodeAccelerator::DoPictureReady() {
|
| - if (flushing_ && queued_bitstream_ids_.empty()) {
|
| - flushing_ = false;
|
| - client_->NotifyFlushDone();
|
| - }
|
| while (!free_output_buffers_.empty() && !queued_bitstream_ids_.empty()) {
|
| int bitstream_id = queued_bitstream_ids_.front();
|
| queued_bitstream_ids_.pop();
|
| +
|
| int buffer_id = free_output_buffers_.front();
|
| free_output_buffers_.pop();
|
|
|
| - const media::Picture picture =
|
| - media::Picture(buffer_id,
|
| - bitstream_id,
|
| - gfx::Rect(frame_buffer_size_),
|
| - false);
|
| - client_->PictureReady(picture);
|
| - // Bitstream no longer needed.
|
| + ReturnPicture(buffer_id, bitstream_id);
|
| client_->NotifyEndOfBitstreamBuffer(bitstream_id);
|
| - if (flushing_ && queued_bitstream_ids_.empty()) {
|
| - flushing_ = false;
|
| - client_->NotifyFlushDone();
|
| + }
|
| +
|
| + if (flushing_ && queued_bitstream_ids_.empty()) {
|
| + if (config_.flush_mode == Config::FlushMode::RETURN_OUTPUT_BUFFERS) {
|
| + while (!free_output_buffers_.empty()) {
|
| + int32_t picture_buffer_id = free_output_buffers_.front();
|
| + free_output_buffers_.pop();
|
| + ReturnPicture(picture_buffer_id, -1);
|
| + }
|
| }
|
| +
|
| + flushing_ = false;
|
| + client_->NotifyFlushDone();
|
| }
|
| }
|
|
|
|
|