Skip to content

Commit

Permalink
media/gpu/chromeos: Implement missing VideoDecoder methods
Browse files Browse the repository at this point in the history
This CL implements some missing needed VideoDecoder methods in
(Vaapi|V4L2)VideoDecoder. It leaves logic/NOTIMPLEMENTED where
needed but also NOTREACHED(). It also leaves TODO()s to use them
from VideoDecoderPipeline.

No new functionality intended.

Bug: 192087509
Change-Id: Iec03d8a216b65178a98a55ed2be52f616381845f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3057467
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#907329}
  • Loading branch information
yellowdoge authored and Chromium LUCI CQ committed Jul 31, 2021
1 parent 3811ef8 commit 2ced470
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
3 changes: 3 additions & 0 deletions media/gpu/chromeos/video_decoder_pipeline.cc
Expand Up @@ -208,18 +208,21 @@ bool VideoDecoderPipeline::IsPlatformDecoder() const {
int VideoDecoderPipeline::GetMaxDecodeRequests() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);

// TODO(mcasas): query |decoder_| instead.
return 4;
}

bool VideoDecoderPipeline::NeedsBitstreamConversion() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);

// TODO(mcasas): also query |decoder_|.
return needs_bitstream_conversion_;
}

bool VideoDecoderPipeline::CanReadWithoutStalling() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);

// TODO(mcasas): also query |decoder_|.
return main_frame_pool_ && !main_frame_pool_->IsExhausted();
}

Expand Down
22 changes: 22 additions & 0 deletions media/gpu/v4l2/v4l2_video_decoder.cc
Expand Up @@ -189,10 +189,32 @@ void V4L2VideoDecoder::Initialize(const VideoDecoderConfig& config,
std::move(init_cb).Run(::media::OkStatus());
}

bool V4L2VideoDecoder::NeedsBitstreamConversion() const {
DCHECK(output_cb_) << "V4L2VideoDecoder hasn't been initialized";
NOTREACHED();
return (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX) ||
(profile_ >= HEVCPROFILE_MIN && profile_ <= HEVCPROFILE_MAX);
}

bool V4L2VideoDecoder::CanReadWithoutStalling() const {
NOTIMPLEMENTED();
NOTREACHED();
return true;
}

int V4L2VideoDecoder::GetMaxDecodeRequests() const {
NOTREACHED();
return 4;
}

VideoDecoderType V4L2VideoDecoder::GetDecoderType() const {
return VideoDecoderType::kV4L2;
}

bool V4L2VideoDecoder::IsPlatformDecoder() const {
return true;
}

StatusCode V4L2VideoDecoder::InitializeBackend() {
DVLOGF(3);
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_);
Expand Down
11 changes: 8 additions & 3 deletions media/gpu/v4l2/v4l2_video_decoder.h
Expand Up @@ -49,17 +49,22 @@ class MEDIA_GPU_EXPORT V4L2VideoDecoder

static SupportedVideoDecoderConfigs GetSupportedConfigs();

// VideoDecoderMixin implementation.
// VideoDecoderMixin implementation, VideoDecoder part.
void Initialize(const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
InitCB init_cb,
const OutputCB& output_cb,
const WaitingCB& waiting_cb) override;
void Reset(base::OnceClosure closure) override;
void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
void ApplyResolutionChange() override;
void Reset(base::OnceClosure reset_cb) override;
bool NeedsBitstreamConversion() const override;
bool CanReadWithoutStalling() const override;
int GetMaxDecodeRequests() const override;
VideoDecoderType GetDecoderType() const override;
bool IsPlatformDecoder() const override;
// VideoDecoderMixin implementation, specific part.
void ApplyResolutionChange() override;

// V4L2VideoDecoderBackend::Client implementation
void OnBackendError() override;
Expand Down
26 changes: 24 additions & 2 deletions media/gpu/vaapi/vaapi_video_decoder.cc
Expand Up @@ -832,14 +832,36 @@ void VaapiVideoDecoder::ApplyResolutionChangeWithScreenSizes(
base::BindOnce(&VaapiVideoDecoder::HandleDecodeTask, weak_this_));
}

bool VaapiVideoDecoder::NeedsTranscryption() {
return transcryption_;
bool VaapiVideoDecoder::NeedsBitstreamConversion() const {
DCHECK(output_cb_) << "VaapiVideoDecoder hasn't been initialized";
NOTREACHED();
return (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX) ||
(profile_ >= HEVCPROFILE_MIN && profile_ <= HEVCPROFILE_MAX);
}

bool VaapiVideoDecoder::CanReadWithoutStalling() const {
NOTIMPLEMENTED();
NOTREACHED();
return true;
}

int VaapiVideoDecoder::GetMaxDecodeRequests() const {
NOTREACHED();
return 4;
}

VideoDecoderType VaapiVideoDecoder::GetDecoderType() const {
return VideoDecoderType::kVaapi;
}

bool VaapiVideoDecoder::IsPlatformDecoder() const {
return true;
}

bool VaapiVideoDecoder::NeedsTranscryption() {
return transcryption_;
}

void VaapiVideoDecoder::ReleaseVideoFrame(VASurfaceID surface_id) {
DVLOGF(4);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Expand Down
9 changes: 7 additions & 2 deletions media/gpu/vaapi/vaapi_video_decoder.h
Expand Up @@ -55,7 +55,7 @@ class VaapiVideoDecoder : public VideoDecoderMixin,

static SupportedVideoDecoderConfigs GetSupportedConfigs();

// VideoDecoderMixin implementation.
// VideoDecoderMixin implementation, VideoDecoder part.
void Initialize(const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
Expand All @@ -64,9 +64,14 @@ class VaapiVideoDecoder : public VideoDecoderMixin,
const WaitingCB& waiting_cb) override;
void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
void Reset(base::OnceClosure reset_cb) override;
bool NeedsBitstreamConversion() const override;
bool CanReadWithoutStalling() const override;
int GetMaxDecodeRequests() const override;
VideoDecoderType GetDecoderType() const override;
bool IsPlatformDecoder() const override;
// VideoDecoderMixin implementation, specific part.
void ApplyResolutionChange() override;
bool NeedsTranscryption() override;
VideoDecoderType GetDecoderType() const override;

// DecodeSurfaceHandler<VASurface> implementation.
scoped_refptr<VASurface> CreateSurface() override;
Expand Down

0 comments on commit 2ced470

Please sign in to comment.