Commit cc6b1b93 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media/gpu: Replace Closure with OnceClosure at VP9Decoder

This CL replaces Closure with OnceClosure to reduce the copy of
callback.

Bug: 1020668
Test: run vda_tests on kevin

Change-Id: I36814346c52217eb8b17cda4799d7f947ccec817
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1974723
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarTed Meyer <tmathmeyer@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726304}
parent aab9138d
......@@ -209,7 +209,7 @@ bool V4L2VP9Accelerator::SubmitDecode(scoped_refptr<VP9Picture> pic,
const Vp9SegmentationParams& segm_params,
const Vp9LoopFilterParams& lf_params,
const Vp9ReferenceFrameVector& ref_frames,
const base::Closure& done_cb) {
base::OnceClosure done_cb) {
const Vp9FrameHeader* frame_hdr = pic->frame_hdr.get();
DCHECK(frame_hdr);
......@@ -357,7 +357,7 @@ bool V4L2VP9Accelerator::SubmitDecode(scoped_refptr<VP9Picture> pic,
}
dec_surface->SetReferenceSurfaces(ref_surfaces);
dec_surface->SetDecodeDoneCallback(done_cb);
dec_surface->SetDecodeDoneCallback(std::move(done_cb));
if (!surface_handler_->SubmitSlice(dec_surface.get(), frame_hdr->data,
frame_hdr->frame_size))
......
......@@ -32,7 +32,7 @@ class V4L2VP9Accelerator : public VP9Decoder::VP9Accelerator {
const Vp9SegmentationParams& segm_params,
const Vp9LoopFilterParams& lf_params,
const Vp9ReferenceFrameVector& reference_frames,
const base::Closure& done_cb) override;
base::OnceClosure done_cb) override;
bool OutputPicture(scoped_refptr<VP9Picture> pic) override;
......
......@@ -36,7 +36,7 @@ bool VP9VaapiVideoDecoderDelegate::SubmitDecode(
const Vp9SegmentationParams& seg,
const Vp9LoopFilterParams& lf,
const Vp9ReferenceFrameVector& ref_frames,
const base::Closure& done_cb) {
base::OnceClosure done_cb) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// |done_cb| should be null as we return false from IsFrameContextRequired().
DCHECK(!done_cb);
......
......@@ -28,7 +28,7 @@ class VP9VaapiVideoDecoderDelegate : public VP9Decoder::VP9Accelerator,
const Vp9SegmentationParams& seg,
const Vp9LoopFilterParams& lf,
const Vp9ReferenceFrameVector& reference_frames,
const base::Closure& done_cb) override;
base::OnceClosure done_cb) override;
bool OutputPicture(scoped_refptr<VP9Picture> pic) override;
bool IsFrameContextRequired() const override;
......
......@@ -279,17 +279,19 @@ bool VP9Decoder::DecodeAndOutputPicture(scoped_refptr<VP9Picture> pic) {
DCHECK(!pic_size_.IsEmpty());
DCHECK(pic->frame_hdr);
base::Closure done_cb;
base::OnceClosure done_cb;
const auto& context_refresh_cb =
parser_.GetContextRefreshCb(pic->frame_hdr->frame_context_idx);
if (context_refresh_cb)
done_cb = base::Bind(&VP9Decoder::UpdateFrameContext,
base::Unretained(this), pic, context_refresh_cb);
done_cb = base::BindOnce(&VP9Decoder::UpdateFrameContext,
base::Unretained(this), pic, context_refresh_cb);
const Vp9Parser::Context& context = parser_.context();
if (!accelerator_->SubmitDecode(pic, context.segmentation(),
context.loop_filter(), ref_frames_, done_cb))
context.loop_filter(), ref_frames_,
std::move(done_cb))) {
return false;
}
if (pic->frame_hdr->show_frame) {
if (!accelerator_->OutputPicture(pic))
......
......@@ -65,7 +65,7 @@ class MEDIA_GPU_EXPORT VP9Decoder : public AcceleratedVideoDecoder {
const Vp9SegmentationParams& segm_params,
const Vp9LoopFilterParams& lf_params,
const Vp9ReferenceFrameVector& reference_frames,
const base::Closure& done_cb) = 0;
const base::OnceClosure done_cb) = 0;
// Schedule output (display) of |pic|.
//
......
......@@ -352,7 +352,7 @@ bool D3D11VP9Accelerator::SubmitDecode(
const Vp9SegmentationParams& segmentation_params,
const Vp9LoopFilterParams& loop_filter_params,
const Vp9ReferenceFrameVector& reference_frames,
const base::Closure& on_finished_cb) {
base::OnceClosure on_finished_cb) {
D3D11VP9Picture* pic = static_cast<D3D11VP9Picture*>(picture.get());
if (!BeginFrame(*pic))
......@@ -373,7 +373,7 @@ bool D3D11VP9Accelerator::SubmitDecode(
RETURN_ON_HR_FAILURE(DecoderEndFrame,
video_context_->DecoderEndFrame(video_decoder_.Get()));
if (on_finished_cb)
on_finished_cb.Run();
std::move(on_finished_cb).Run();
return true;
}
......
......@@ -37,7 +37,7 @@ class D3D11VP9Accelerator : public VP9Decoder::VP9Accelerator {
const Vp9SegmentationParams& segmentation_params,
const Vp9LoopFilterParams& loop_filter_params,
const Vp9ReferenceFrameVector& reference_frames,
const base::Closure& on_finished_cb) override;
base::OnceClosure on_finished_cb) override;
bool OutputPicture(scoped_refptr<VP9Picture> picture) override;
......
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