Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2853)

Unified Diff: chrome/gpu/arc_gpu_video_decode_accelerator.h

Issue 1549473002: Add ArcGpuVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move code from content/ to /chrome Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/gpu/arc_gpu_video_decode_accelerator.h
diff --git a/chrome/gpu/arc_gpu_video_decode_accelerator.h b/chrome/gpu/arc_gpu_video_decode_accelerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..77d705385538570597d82742a5096a0f368f1fa8
--- /dev/null
+++ b/chrome/gpu/arc_gpu_video_decode_accelerator.h
@@ -0,0 +1,142 @@
+// Copyright 2016 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 CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
+#define CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
+
+#include <list>
+#include <queue>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "chrome/gpu/arc_video_accelerator.h"
+#include "media/video/video_decode_accelerator.h"
+
+namespace chromeos {
+namespace arc {
+
+// This class is excuted in Chromium's GPU process. It takes decoding requests
Pawel Osciak 2016/02/29 08:25:20 s/excuted/executed/
Owen Lin 2016/03/03 06:30:43 Done.
+// from ARC via IPC channels and translates and send those requests to the
+// real VDA on Chromium. It also returns the decoded frames back to the
Pawel Osciak 2016/02/29 08:25:21 s/real VDA/to an implementation of the VideoDecode
Owen Lin 2016/03/03 06:30:43 Done.
+// ARC side.
+class ArcGpuVideoDecodeAccelerator
+ : public ArcVideoAccelerator,
+ public media::VideoDecodeAccelerator::Client,
+ public base::SupportsWeakPtr<ArcGpuVideoDecodeAccelerator> {
+ public:
+ ArcGpuVideoDecodeAccelerator(
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
+ ~ArcGpuVideoDecodeAccelerator() override;
+
+ // Implementation of the ArcVideoAccelerator interface.
+ bool Initialize(DeviceType device_type,
+ ArcVideoAccelerator::Client* client) override;
+ bool SetBufferCount(PortType port, size_t* count) override;
+ bool SetBufferFormat(PortType port, const BufferFormat& format) override;
+ bool BindSharedMemory(PortType port,
Pawel Osciak 2016/02/29 08:25:20 Could we make all calls (apart from perhaps Initia
Owen Lin 2016/03/03 06:30:43 The reason is? Let's make BindSharedMemory void, b
+ uint32_t index,
+ int ashmem_fd,
+ size_t offset,
+ size_t length) override;
+ bool BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) override;
+ void UseBuffer(PortType port,
+ uint32_t index,
+ const BufferMetadata& metadata) override;
+ void Reset() override;
+
+ // Implementation of the VideoDecodeAccelerator::Client interface.
+ void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
+ const gfx::Size& dimensions,
+ uint32_t texture_target) override;
+ void DismissPictureBuffer(int32_t picture_buffer) override;
+ void PictureReady(const media::Picture& picture) override;
+ void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override;
+ void NotifyFlushDone() override;
+ void NotifyResetDone() override;
+ void NotifyError(media::VideoDecodeAccelerator::Error error) override;
+
+ private:
+ struct InputRecord {
+ int32_t bitstream_buffer_id;
+ uint32_t buffer_index;
+ int64_t timestamp;
+
+ InputRecord(int32_t bitstream_buffer_id,
+ uint32_t buffer_index,
+ int64_t timestamp);
+ };
+
+ struct InputBufferInfo {
+ // The file handle to access the buffer. It is owned by this ArcGVDA and
Pawel Osciak 2016/02/29 08:25:21 s/ArcGVDA/class/
Owen Lin 2016/03/03 06:30:43 Done.
+ // should be freed if not used.
Pawel Osciak 2016/02/29 08:25:20 s/freed if not used/closed after use/
Owen Lin 2016/03/03 06:30:43 Done.
+ base::ScopedFD handle;
+ off_t offset;
+ size_t length;
+
+ InputBufferInfo();
+ InputBufferInfo(InputBufferInfo&&);
+ ~InputBufferInfo();
+ };
+
+ struct PortInfo {
+ MemoryType memory_type;
+ size_t num_buffers;
+
+ PortInfo();
+ };
+
+ // Helper function to Send the end-of-stream output buffer if
+ // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA.
+ void SendEosIfNeededOrReusePicture(uint32_t index);
+
+ // Helper functions to validate |port| (and |index|).
+ bool ValidatePort(PortType port);
+ bool ValidatePortAndIndex(PortType port, uint32_t index);
+
+ // Indicates a pending EOS output buffer. When it is true, an EOS output
Pawel Osciak 2016/02/29 08:25:20 s/Indicates a pending EOS output buffer. When it i
Owen Lin 2016/03/03 06:30:43 Done.
+ // buffer need to be sent to |arc_client_| once an output buffer is available.
+ bool pending_eos_output_buffer_;
Pawel Osciak 2016/02/29 08:25:20 Please move members to after methods.
Owen Lin 2016/03/03 06:30:43 Done.
+ scoped_ptr<media::VideoDecodeAccelerator> vda_;
+
+ // Sets InputRecord for the given |bitstream_buffer_id|. The |buffer_index|
+ // is the index of the associated input buffer. The |timestamp| is the
+ // time the video frame should be displayed.
+ void SetInputRecord(int32_t bitstream_buffer_id,
+ uint32_t buffer_index,
+ int64_t timestamp);
+
+ // Finds the InputRecord which matches to given |bitstream_buffer_id|.
+ // Returns |nullptr| if it cannot be found.
+ InputRecord* FindInputRecord(int32_t bitstream_buffer_id);
+
+ // It's safe to use the pointer here, the life cycle of the |arc_client_|
+ // is longer than this ArcGpuVideoDecodeAccelerator.
+ ArcVideoAccelerator::Client* arc_client_;
Pawel Osciak 2016/02/29 08:25:20 We could perhaps use WeakPtr here...
Owen Lin 2016/03/03 06:30:43 Not so sure, WeakPtr somehow means we expect it to
+
+ // The callback called when reset completes.
+ base::Closure reset_done_callback_;
+
+ PortInfo port_info_[PORT_COUNT];
Pawel Osciak 2016/02/29 08:25:21 Unless I'm missing something, we are not using mem
Owen Lin 2016/03/03 06:30:43 Done.
+
+ // The next ID for the bitstream buffer, started from 0.
+ int32_t next_bitstream_buffer_id_;
+
+ gfx::Size coded_size_;
+
+ // The index of buffers returned while Flushing, will be used for sending
Pawel Osciak 2016/02/29 08:25:20 picture_buffer_ids for Pictures that were returned
Owen Lin 2016/03/03 06:30:43 Done.
+ // EOS buffer back to |arc_client_|.
+ std::queue<uint32_t> buffers_pending_eos_;
+ std::list<InputRecord> input_records_;
+ std::vector<InputBufferInfo> input_buffer_info_;
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+ base::ThreadChecker thread_checker_;
+ size_t output_buffer_size_;
+};
Pawel Osciak 2016/02/29 08:25:21 Do we need DISALLOW_IMPLICIT_CONSTRUCTORS()?
Owen Lin 2016/03/03 06:30:43 Done.
+
+} // namespace arc
+} // namespace chromeos
+
+#endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698