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

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: Change ArcVideoAccelerator::Reset to asynchronous. Created 4 years, 9 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..339cb192d3251e793209679ee4338e5f2e85c83f
--- /dev/null
+++ b/chrome/gpu/arc_gpu_video_decode_accelerator.h
@@ -0,0 +1,136 @@
+// 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 executed in Chromium's GPU process. It takes decoding requests
Pawel Osciak 2016/03/22 10:21:13 s/Chromium's//
Owen Lin 2016/03/24 03:01:11 Done.
+// from ARC via IPC channels and translates and send those requests to an
Pawel Osciak 2016/03/22 10:21:12 s/send/sends/
Owen Lin 2016/03/24 03:01:11 Done.
+// implementation of the VideoDecodeAccelerator interface on Chromium. It also
Pawel Osciak 2016/03/22 10:21:12 s/the VideoDecodeAccelerator interface on Chromium
Owen Lin 2016/03/24 03:01:12 Done.
+// returns the decoded frames back to the ARC side.
+class ArcGpuVideoDecodeAccelerator
+ : public ArcVideoAccelerator,
+ public media::VideoDecodeAccelerator::Client,
+ public base::SupportsWeakPtr<ArcGpuVideoDecodeAccelerator> {
+ public:
+ ArcGpuVideoDecodeAccelerator();
+ ~ArcGpuVideoDecodeAccelerator() override;
+
+ // Implementation of the ArcVideoAccelerator interface.
+ bool Initialize(const Config& config,
+ ArcVideoAccelerator::Client* client) override;
+ void SetNumberOfOutputBuffers(size_t number) override;
+ void BindSharedMemory(PortType port,
+ uint32_t index,
+ int ashmem_fd,
+ off_t offset,
+ size_t length) override;
+ void 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 {
Pawel Osciak 2016/03/22 10:21:12 Please document the difference between InputRecord
Owen Lin 2016/03/24 03:01:11 Done.
+ 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 class and
+ // should be closed after use.
+ base::ScopedFD handle;
+ off_t offset = 0;
+ size_t length = 0;
+ };
+
+ // 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 function to validate |port| and |index|.
+ bool ValidatePortAndIndex(PortType port, uint32_t index);
+
+ // Sets InputRecord for the given |bitstream_buffer_id|. The |buffer_index|
Pawel Osciak 2016/03/22 10:21:13 s/Sets/Creates an/
Owen Lin 2016/03/24 03:01:12 Done.
+ // 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,
Pawel Osciak 2016/03/22 10:21:13 s/Set/Create/
Owen Lin 2016/03/24 03:01:11 Done.
+ 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);
+
+ // When true, an EOS output buffer need to be sent to |arc_client_| once an
+ // output buffer is available.
+ bool pending_eos_output_buffer_;
+ scoped_ptr<media::VideoDecodeAccelerator> vda_;
Pawel Osciak 2016/03/22 10:21:13 Please add an empty line above.
Owen Lin 2016/03/24 03:01:12 Done.
+
+ // It's safe to use the pointer here, the life cycle of the |arc_client_|
+ // is longer than this ArcGpuVideoDecodeAccelerator.
+ ArcVideoAccelerator::Client* arc_client_;
+
+ // The callback called when reset completes.
+ base::Closure reset_done_callback_;
Pawel Osciak 2016/03/22 10:21:12 Unused?
Owen Lin 2016/03/24 03:01:12 Done.
+
+ // The next ID for the bitstream buffer, started from 0.
+ int32_t next_bitstream_buffer_id_;
+
+ gfx::Size coded_size_;
+
+ // The |picture_buffer_id|s for Picutres that were returned to us from VDA
Pawel Osciak 2016/03/22 10:21:12 s/Picutres/Pictures/
Owen Lin 2016/03/24 03:01:11 Done.
+ // via PictureReady() while flushing. We keep them until NotifyFlushDone();
+ // once it's called, we send one of the pending buffers from this queue (if
+ // not empty), marked with an EOS flag, to |arc_client_|, and return the rest
+ // to VDA for reuse.
+ std::queue<int32_t> buffers_pending_eos_;
+ std::list<InputRecord> input_records_;
Pawel Osciak 2016/03/22 10:21:13 Please add an empty line above and documentation.
Owen Lin 2016/03/24 03:01:12 Done.
+ std::vector<InputBufferInfo> input_buffer_info_;
+
+ // To keep those output buffers which have been bound by bindDmabuf() but not
+ // be used yet. Will call VDA::ImportBufferForPicture() when those buffer are
Pawel Osciak 2016/03/22 10:21:13 s/but not be used yet/but cannot be used before th
Owen Lin 2016/03/24 03:01:12 Those buffer *can* be used whenever Client calls u
+ // used for the first time.
+ std::vector<base::ScopedFD> pending_import_buffer_;
Pawel Osciak 2016/03/22 10:21:13 s/pending_import_buffer_/buffers_pending_import_/
Owen Lin 2016/03/24 03:01:12 Done.
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
Pawel Osciak 2016/03/22 10:21:13 Unused?
Owen Lin 2016/03/24 03:01:11 Done.
+ base::ThreadChecker thread_checker_;
+ size_t output_buffer_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArcGpuVideoDecodeAccelerator);
+};
+
+} // namespace arc
+} // namespace chromeos
+
+#endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698