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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
6 #define CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
7
8 #include <list>
9 #include <queue>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "chrome/gpu/arc_video_accelerator.h"
16 #include "media/video/video_decode_accelerator.h"
17
18 namespace chromeos {
19 namespace arc {
20
21 // 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.
22 // from ARC via IPC channels and translates and send those requests to the
23 // 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.
24 // ARC side.
25 class ArcGpuVideoDecodeAccelerator
26 : public ArcVideoAccelerator,
27 public media::VideoDecodeAccelerator::Client,
28 public base::SupportsWeakPtr<ArcGpuVideoDecodeAccelerator> {
29 public:
30 ArcGpuVideoDecodeAccelerator(
31 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
32 ~ArcGpuVideoDecodeAccelerator() override;
33
34 // Implementation of the ArcVideoAccelerator interface.
35 bool Initialize(DeviceType device_type,
36 ArcVideoAccelerator::Client* client) override;
37 bool SetBufferCount(PortType port, size_t* count) override;
38 bool SetBufferFormat(PortType port, const BufferFormat& format) override;
39 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
40 uint32_t index,
41 int ashmem_fd,
42 size_t offset,
43 size_t length) override;
44 bool BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) override;
45 void UseBuffer(PortType port,
46 uint32_t index,
47 const BufferMetadata& metadata) override;
48 void Reset() override;
49
50 // Implementation of the VideoDecodeAccelerator::Client interface.
51 void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
52 const gfx::Size& dimensions,
53 uint32_t texture_target) override;
54 void DismissPictureBuffer(int32_t picture_buffer) override;
55 void PictureReady(const media::Picture& picture) override;
56 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override;
57 void NotifyFlushDone() override;
58 void NotifyResetDone() override;
59 void NotifyError(media::VideoDecodeAccelerator::Error error) override;
60
61 private:
62 struct InputRecord {
63 int32_t bitstream_buffer_id;
64 uint32_t buffer_index;
65 int64_t timestamp;
66
67 InputRecord(int32_t bitstream_buffer_id,
68 uint32_t buffer_index,
69 int64_t timestamp);
70 };
71
72 struct InputBufferInfo {
73 // 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.
74 // 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.
75 base::ScopedFD handle;
76 off_t offset;
77 size_t length;
78
79 InputBufferInfo();
80 InputBufferInfo(InputBufferInfo&&);
81 ~InputBufferInfo();
82 };
83
84 struct PortInfo {
85 MemoryType memory_type;
86 size_t num_buffers;
87
88 PortInfo();
89 };
90
91 // Helper function to Send the end-of-stream output buffer if
92 // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA.
93 void SendEosIfNeededOrReusePicture(uint32_t index);
94
95 // Helper functions to validate |port| (and |index|).
96 bool ValidatePort(PortType port);
97 bool ValidatePortAndIndex(PortType port, uint32_t index);
98
99 // 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.
100 // buffer need to be sent to |arc_client_| once an output buffer is available.
101 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.
102 scoped_ptr<media::VideoDecodeAccelerator> vda_;
103
104 // Sets InputRecord for the given |bitstream_buffer_id|. The |buffer_index|
105 // is the index of the associated input buffer. The |timestamp| is the
106 // time the video frame should be displayed.
107 void SetInputRecord(int32_t bitstream_buffer_id,
108 uint32_t buffer_index,
109 int64_t timestamp);
110
111 // Finds the InputRecord which matches to given |bitstream_buffer_id|.
112 // Returns |nullptr| if it cannot be found.
113 InputRecord* FindInputRecord(int32_t bitstream_buffer_id);
114
115 // It's safe to use the pointer here, the life cycle of the |arc_client_|
116 // is longer than this ArcGpuVideoDecodeAccelerator.
117 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
118
119 // The callback called when reset completes.
120 base::Closure reset_done_callback_;
121
122 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.
123
124 // The next ID for the bitstream buffer, started from 0.
125 int32_t next_bitstream_buffer_id_;
126
127 gfx::Size coded_size_;
128
129 // 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.
130 // EOS buffer back to |arc_client_|.
131 std::queue<uint32_t> buffers_pending_eos_;
132 std::list<InputRecord> input_records_;
133 std::vector<InputBufferInfo> input_buffer_info_;
134 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
135 base::ThreadChecker thread_checker_;
136 size_t output_buffer_size_;
137 };
Pawel Osciak 2016/02/29 08:25:21 Do we need DISALLOW_IMPLICIT_CONSTRUCTORS()?
Owen Lin 2016/03/03 06:30:43 Done.
138
139 } // namespace arc
140 } // namespace chromeos
141
142 #endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698