Commit c466a388 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] report correct max decode count in FuchsiaVideoDecoder

Previously FuchsiaVideoDecoder was always returning 1 from
FuchsiaVideoDecoder::GetMaxDecodeRequests() for encrypted streams. As
result the decoder had at most one decode request and so it wasn't
decoding quickly enough. As result the renderer was sometimes running
of output buffers. This change updates GetMaxDecodeRequests() to return
value that includes the number of input buffers in the decryptor which
allows to run decoder pipeline more efficiently.

Bug: b/172062874
Change-Id: I394513debc02b43ea1bad801adc21a5b9efa5d0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536450Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827109}
parent f84f9ac5
......@@ -310,7 +310,6 @@ class FuchsiaVideoDecoder : public VideoDecoder,
uint64_t input_buffer_lifetime_ordinal_ = 1;
std::unique_ptr<SysmemBufferPool::Creator> input_buffer_collection_creator_;
std::unique_ptr<SysmemBufferPool> input_buffer_collection_;
size_t num_input_buffers_ = 0;
base::flat_map<size_t, InputDecoderPacket> in_flight_input_packets_;
// Output buffers for |decoder_|.
......@@ -515,9 +514,15 @@ bool FuchsiaVideoDecoder::CanReadWithoutStalling() const {
}
int FuchsiaVideoDecoder::GetMaxDecodeRequests() const {
// Add one extra request to be able to send new InputBuffer immediately after
// OnFreeInputPacket().
return num_input_buffers_ + 1;
if (!decryptor_) {
// Add one extra request to be able to send a new InputBuffer immediately
// after OnFreeInputPacket().
return input_writer_queue_.num_buffers() + 1;
}
// For encrypted streams we need enough decode requests to fill the
// decryptor's queue and all decoder buffers. Add one extra same as above.
return decryptor_->GetMaxDecryptRequests() + kNumInputBuffers + 1;
}
bool FuchsiaVideoDecoder::InitializeDecryptor(CdmContext* cdm_context) {
......@@ -652,8 +657,6 @@ void FuchsiaVideoDecoder::OnWriterCreated(
return;
}
num_input_buffers_ = writer->num_buffers();
input_writer_queue_.Start(
std::move(writer),
base::BindRepeating(&FuchsiaVideoDecoder::SendInputPacket,
......@@ -1052,7 +1055,6 @@ void FuchsiaVideoDecoder::ReleaseInputBuffers() {
input_writer_queue_.ResetBuffers();
input_buffer_collection_creator_.reset();
input_buffer_collection_.reset();
num_input_buffers_ = 0;
// |in_flight_input_packets_| must be destroyed after
// |input_writer_queue_.ResetBuffers()|. Otherwise |input_writer_queue_| may
......
......@@ -105,6 +105,10 @@ FuchsiaStreamDecryptorBase::~FuchsiaStreamDecryptorBase() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
int FuchsiaStreamDecryptorBase::GetMaxDecryptRequests() const {
return input_writer_queue_.num_buffers() + 1;
}
void FuchsiaStreamDecryptorBase::DecryptInternal(
scoped_refptr<DecoderBuffer> encrypted) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -25,6 +25,8 @@ class FuchsiaStreamDecryptorBase : public StreamProcessorHelper::Client {
size_t min_buffer_size);
~FuchsiaStreamDecryptorBase() override;
int GetMaxDecryptRequests() const;
protected:
// StreamProcessorHelper::Client overrides.
void AllocateInputBuffers(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment