Commit 26eb905d authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

vaapi deco cleanup: extract VaapiDecodeSurface into its own file

This CL extracts VaapiDecodeSurface out of VaapiVideoDecodeAccelerator
into a file on its own, because vaapi_video_decode_accelerator.cc is
quite large at 1902 lines.

It also introduces =default and adds DISALLOW_COPY_AND_ASSIGN to the
extracted class. Otherwise no new code, just moving things around.

There's also a side bonus: VaapiVideoDecodeAccelerator::VaapiDecodeSurface
uses are shortened in vaapi_video_decode_accelerator.

Test: Compile and run in simplechrome on soraka. Ran vp8, vp9
videos of crosvideo.appspot.com, verified GpuVideoDecoder engaged.

Bug: 717265
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ibd7c88357b2f993a5d72e45f65dfff5d67c4194a
Reviewed-on: https://chromium-review.googlesource.com/922981
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarEmircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537201}
parent 895b1571
...@@ -53,6 +53,8 @@ source_set("vaapi") { ...@@ -53,6 +53,8 @@ source_set("vaapi") {
sources = [ sources = [
"va_surface.cc", "va_surface.cc",
"va_surface.h", "va_surface.h",
"vaapi_decode_surface.cc",
"vaapi_decode_surface.h",
"vaapi_jpeg_decode_accelerator.cc", "vaapi_jpeg_decode_accelerator.cc",
"vaapi_jpeg_decode_accelerator.h", "vaapi_jpeg_decode_accelerator.h",
"vaapi_jpeg_decoder.cc", "vaapi_jpeg_decoder.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/gpu/vaapi/vaapi_decode_surface.h"
namespace media {
VaapiDecodeSurface::VaapiDecodeSurface(
int32_t bitstream_id,
const scoped_refptr<VASurface>& va_surface)
: bitstream_id_(bitstream_id), va_surface_(va_surface) {}
VaapiDecodeSurface::~VaapiDecodeSurface() = default;
} // namespace media
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_GPU_VAAPI_VAAPI_DECODE_SURFACE_H_
#define MEDIA_GPU_VAAPI_VAAPI_DECODE_SURFACE_H_
#include "base/memory/ref_counted.h"
#include "media/gpu/media_gpu_export.h"
#include "media/gpu/vaapi/va_surface.h"
#include "ui/gfx/geometry/rect.h"
namespace media {
// Wrapper of a VASurface with an id and visible area.
class MEDIA_GPU_EXPORT VaapiDecodeSurface
: public base::RefCountedThreadSafe<VaapiDecodeSurface> {
public:
VaapiDecodeSurface(int32_t bitstream_id,
const scoped_refptr<VASurface>& va_surface);
int32_t bitstream_id() const { return bitstream_id_; }
scoped_refptr<VASurface> va_surface() { return va_surface_; }
gfx::Rect visible_rect() const { return visible_rect_; }
void set_visible_rect(const gfx::Rect& visible_rect) {
visible_rect_ = visible_rect;
}
private:
friend class base::RefCountedThreadSafe<VaapiDecodeSurface>;
~VaapiDecodeSurface();
const int32_t bitstream_id_;
const scoped_refptr<VASurface> va_surface_;
gfx::Rect visible_rect_;
DISALLOW_COPY_AND_ASSIGN(VaapiDecodeSurface);
};
} // namespace media
#endif // MEDIA_GPU_VAAPI_VAAPI_DECODE_SURFACE_H_
...@@ -79,51 +79,18 @@ static void ReportToUMA(VAVDADecoderFailure failure) { ...@@ -79,51 +79,18 @@ static void ReportToUMA(VAVDADecoderFailure failure) {
} \ } \
} while (0) } while (0)
class VaapiVideoDecodeAccelerator::VaapiDecodeSurface
: public base::RefCountedThreadSafe<VaapiDecodeSurface> {
public:
VaapiDecodeSurface(int32_t bitstream_id,
const scoped_refptr<VASurface>& va_surface);
int32_t bitstream_id() const { return bitstream_id_; }
scoped_refptr<VASurface> va_surface() { return va_surface_; }
gfx::Rect visible_rect() const { return visible_rect_; }
void set_visible_rect(const gfx::Rect& visible_rect) {
visible_rect_ = visible_rect;
}
private:
friend class base::RefCountedThreadSafe<VaapiDecodeSurface>;
~VaapiDecodeSurface();
const int32_t bitstream_id_;
const scoped_refptr<VASurface> va_surface_;
gfx::Rect visible_rect_;
};
VaapiVideoDecodeAccelerator::VaapiDecodeSurface::VaapiDecodeSurface(
int32_t bitstream_id,
const scoped_refptr<VASurface>& va_surface)
: bitstream_id_(bitstream_id), va_surface_(va_surface) {}
VaapiVideoDecodeAccelerator::VaapiDecodeSurface::~VaapiDecodeSurface() {}
class VaapiH264Picture : public H264Picture { class VaapiH264Picture : public H264Picture {
public: public:
explicit VaapiH264Picture( explicit VaapiH264Picture(scoped_refptr<VaapiDecodeSurface> surface)
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> surface)
: dec_surface_(surface) {} : dec_surface_(surface) {}
VaapiH264Picture* AsVaapiH264Picture() override { return this; } VaapiH264Picture* AsVaapiH264Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() { scoped_refptr<VaapiDecodeSurface> dec_surface() { return dec_surface_; }
return dec_surface_;
}
private: private:
~VaapiH264Picture() override {} ~VaapiH264Picture() override {}
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface_; scoped_refptr<VaapiDecodeSurface> dec_surface_;
DISALLOW_COPY_AND_ASSIGN(VaapiH264Picture); DISALLOW_COPY_AND_ASSIGN(VaapiH264Picture);
}; };
...@@ -178,19 +145,16 @@ class VaapiVideoDecodeAccelerator::VaapiH264Accelerator ...@@ -178,19 +145,16 @@ class VaapiVideoDecodeAccelerator::VaapiH264Accelerator
class VaapiVP8Picture : public VP8Picture { class VaapiVP8Picture : public VP8Picture {
public: public:
explicit VaapiVP8Picture( explicit VaapiVP8Picture(scoped_refptr<VaapiDecodeSurface> surface)
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> surface)
: dec_surface_(surface) {} : dec_surface_(surface) {}
VaapiVP8Picture* AsVaapiVP8Picture() override { return this; } VaapiVP8Picture* AsVaapiVP8Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() { scoped_refptr<VaapiDecodeSurface> dec_surface() { return dec_surface_; }
return dec_surface_;
}
private: private:
~VaapiVP8Picture() override {} ~VaapiVP8Picture() override {}
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface_; scoped_refptr<VaapiDecodeSurface> dec_surface_;
DISALLOW_COPY_AND_ASSIGN(VaapiVP8Picture); DISALLOW_COPY_AND_ASSIGN(VaapiVP8Picture);
}; };
...@@ -227,19 +191,16 @@ class VaapiVideoDecodeAccelerator::VaapiVP8Accelerator ...@@ -227,19 +191,16 @@ class VaapiVideoDecodeAccelerator::VaapiVP8Accelerator
class VaapiVP9Picture : public VP9Picture { class VaapiVP9Picture : public VP9Picture {
public: public:
explicit VaapiVP9Picture( explicit VaapiVP9Picture(scoped_refptr<VaapiDecodeSurface> surface)
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> surface)
: dec_surface_(surface) {} : dec_surface_(surface) {}
VaapiVP9Picture* AsVaapiVP9Picture() override { return this; } VaapiVP9Picture* AsVaapiVP9Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() { scoped_refptr<VaapiDecodeSurface> dec_surface() { return dec_surface_; }
return dec_surface_;
}
private: private:
~VaapiVP9Picture() override {} ~VaapiVP9Picture() override {}
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface_; scoped_refptr<VaapiDecodeSurface> dec_surface_;
DISALLOW_COPY_AND_ASSIGN(VaapiVP9Picture); DISALLOW_COPY_AND_ASSIGN(VaapiVP9Picture);
}; };
...@@ -1118,8 +1079,7 @@ void VaapiVideoDecodeAccelerator::SurfaceReady( ...@@ -1118,8 +1079,7 @@ void VaapiVideoDecodeAccelerator::SurfaceReady(
TryOutputSurface(); TryOutputSurface();
} }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> scoped_refptr<VaapiDecodeSurface> VaapiVideoDecodeAccelerator::CreateSurface() {
VaapiVideoDecodeAccelerator::CreateSurface() {
DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
...@@ -1414,9 +1374,9 @@ void VaapiVideoDecodeAccelerator::VaapiH264Accelerator::Reset() { ...@@ -1414,9 +1374,9 @@ void VaapiVideoDecodeAccelerator::VaapiH264Accelerator::Reset() {
vaapi_wrapper_->DestroyPendingBuffers(); vaapi_wrapper_->DestroyPendingBuffers();
} }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> scoped_refptr<VaapiDecodeSurface> VaapiVideoDecodeAccelerator::
VaapiVideoDecodeAccelerator::VaapiH264Accelerator:: VaapiH264Accelerator::H264PictureToVaapiDecodeSurface(
H264PictureToVaapiDecodeSurface(const scoped_refptr<H264Picture>& pic) { const scoped_refptr<H264Picture>& pic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VaapiH264Picture* vaapi_pic = pic->AsVaapiH264Picture(); VaapiH264Picture* vaapi_pic = pic->AsVaapiH264Picture();
CHECK(vaapi_pic); CHECK(vaapi_pic);
...@@ -1706,9 +1666,9 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::OutputPicture( ...@@ -1706,9 +1666,9 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::OutputPicture(
return true; return true;
} }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> scoped_refptr<VaapiDecodeSurface> VaapiVideoDecodeAccelerator::
VaapiVideoDecodeAccelerator::VaapiVP8Accelerator:: VaapiVP8Accelerator::VP8PictureToVaapiDecodeSurface(
VP8PictureToVaapiDecodeSurface(const scoped_refptr<VP8Picture>& pic) { const scoped_refptr<VP8Picture>& pic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VaapiVP8Picture* vaapi_pic = pic->AsVaapiVP8Picture(); VaapiVP8Picture* vaapi_pic = pic->AsVaapiVP8Picture();
CHECK(vaapi_pic); CHECK(vaapi_pic);
...@@ -1884,9 +1844,9 @@ bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::GetFrameContext( ...@@ -1884,9 +1844,9 @@ bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::GetFrameContext(
return false; return false;
} }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> scoped_refptr<VaapiDecodeSurface> VaapiVideoDecodeAccelerator::
VaapiVideoDecodeAccelerator::VaapiVP9Accelerator:: VaapiVP9Accelerator::VP9PictureToVaapiDecodeSurface(
VP9PictureToVaapiDecodeSurface(const scoped_refptr<VP9Picture>& pic) { const scoped_refptr<VP9Picture>& pic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VaapiVP9Picture* vaapi_pic = pic->AsVaapiVP9Picture(); VaapiVP9Picture* vaapi_pic = pic->AsVaapiVP9Picture();
CHECK(vaapi_pic); CHECK(vaapi_pic);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/synchronization/condition_variable.h" #include "base/synchronization/condition_variable.h"
...@@ -31,6 +30,7 @@ ...@@ -31,6 +30,7 @@
#include "media/gpu/gpu_video_decode_accelerator_helpers.h" #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
#include "media/gpu/media_gpu_export.h" #include "media/gpu/media_gpu_export.h"
#include "media/gpu/shared_memory_region.h" #include "media/gpu/shared_memory_region.h"
#include "media/gpu/vaapi/vaapi_decode_surface.h"
#include "media/gpu/vaapi/vaapi_picture_factory.h" #include "media/gpu/vaapi/vaapi_picture_factory.h"
#include "media/gpu/vaapi/vaapi_wrapper.h" #include "media/gpu/vaapi/vaapi_wrapper.h"
#include "media/video/picture.h" #include "media/video/picture.h"
...@@ -56,9 +56,6 @@ class VaapiPicture; ...@@ -56,9 +56,6 @@ class VaapiPicture;
class MEDIA_GPU_EXPORT VaapiVideoDecodeAccelerator class MEDIA_GPU_EXPORT VaapiVideoDecodeAccelerator
: public VideoDecodeAccelerator { : public VideoDecodeAccelerator {
public: public:
// Wrapper of a VASurface with id and visible area.
class VaapiDecodeSurface;
VaapiVideoDecodeAccelerator( VaapiVideoDecodeAccelerator(
const MakeGLContextCurrentCallback& make_context_current_cb, const MakeGLContextCurrentCallback& make_context_current_cb,
const BindGLImageCallback& bind_image_cb); const BindGLImageCallback& bind_image_cb);
......
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