OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 5 #ifndef CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ |
6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ |
7 | 7 |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 | 9 |
10 namespace chromeos { | 10 namespace chromeos { |
11 namespace arc { | 11 namespace arc { |
12 | 12 |
13 enum HalPixelFormatExtension { | 13 enum HalPixelFormatExtension { |
14 // The pixel formats defined in Android but are used here. They are defined | 14 // The pixel formats defined in Android but are used here. They are defined |
15 // in "system/core/include/system/graphics.h" | 15 // in "system/core/include/system/graphics.h" |
16 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, | 16 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, |
17 | 17 |
18 // The following formats are not defined in Android, but used in | 18 // The following formats are not defined in Android, but used in |
19 // ArcVideoAccelerator to identify the input format. | 19 // ArcVideoAccelerator to identify the input format. |
20 HAL_PIXEL_FORMAT_H264 = 0x34363248, | 20 HAL_PIXEL_FORMAT_H264 = 0x34363248, |
21 HAL_PIXEL_FORMAT_VP8 = 0x00385056, | 21 HAL_PIXEL_FORMAT_VP8 = 0x00385056, |
22 }; | 22 }; |
23 | 23 |
24 enum PortType { | 24 enum PortType { |
25 PORT_INPUT = 0, | 25 PORT_INPUT = 0, |
26 PORT_OUTPUT = 1, | 26 PORT_OUTPUT = 1, |
27 PORT_COUNT = 2, | 27 PORT_COUNT = 2, |
28 }; | 28 }; |
29 | 29 |
30 enum BufferFlag { | |
31 BUFFER_FLAG_EOS = 1 << 0, | |
32 }; | |
33 | |
34 struct BufferMetadata { | 30 struct BufferMetadata { |
35 int64_t timestamp = 0; // in microseconds | 31 int64_t timestamp = 0; // in microseconds |
36 uint32_t flags = 0; // Flags defined in BufferFlag. | 32 uint32_t flags = 0; // Not used. |
dcheng
2016/05/07 06:18:11
Why do we need to keep this unused field?
Owen Lin
2016/05/09 07:04:41
Just get a feeling it will be used soon. Let's rem
| |
37 uint32_t bytes_used = 0; | 33 uint32_t bytes_used = 0; |
38 }; | 34 }; |
39 | 35 |
40 struct VideoFormat { | 36 struct VideoFormat { |
41 uint32_t pixel_format = 0; | 37 uint32_t pixel_format = 0; |
42 uint32_t buffer_size = 0; | 38 uint32_t buffer_size = 0; |
43 | 39 |
44 // Minimum number of buffers required to decode/encode the stream. | 40 // Minimum number of buffers required to decode/encode the stream. |
45 uint32_t min_num_buffers = 0; | 41 uint32_t min_num_buffers = 0; |
46 uint32_t coded_width = 0; | 42 uint32_t coded_width = 0; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 virtual void OnBufferDone(PortType port, | 90 virtual void OnBufferDone(PortType port, |
95 uint32_t index, | 91 uint32_t index, |
96 const BufferMetadata& metadata) = 0; | 92 const BufferMetadata& metadata) = 0; |
97 | 93 |
98 // Called when the output format has changed or the output format | 94 // Called when the output format has changed or the output format |
99 // becomes available at beginning of the stream after initial parsing. | 95 // becomes available at beginning of the stream after initial parsing. |
100 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; | 96 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; |
101 | 97 |
102 // Called as a completion notification for Reset(). | 98 // Called as a completion notification for Reset(). |
103 virtual void OnResetDone() = 0; | 99 virtual void OnResetDone() = 0; |
100 | |
101 // Called as a completion notification for Flush(). | |
102 virtual void OnFlushDone() = 0; | |
104 }; | 103 }; |
105 | 104 |
106 // Initializes the ArcVideoAccelerator with specific configuration. This | 105 // Initializes the ArcVideoAccelerator with specific configuration. This |
107 // must be called before any other methods. This call is synchronous and | 106 // must be called before any other methods. This call is synchronous and |
108 // returns true iff initialization is successful. | 107 // returns true iff initialization is successful. |
109 virtual bool Initialize(const Config& config, Client* client) = 0; | 108 virtual bool Initialize(const Config& config, Client* client) = 0; |
110 | 109 |
111 // Assigns a shared memory to be used for the accelerator at the specified | 110 // Assigns a shared memory to be used for the accelerator at the specified |
112 // port and index. A buffer must be successfully bound before it can be passed | 111 // port and index. A buffer must be successfully bound before it can be passed |
113 // to the accelerator via UseBuffer(). Already bound buffers may be reused | 112 // to the accelerator via UseBuffer(). Already bound buffers may be reused |
(...skipping 21 matching lines...) Expand all Loading... | |
135 | 134 |
136 // Sets the number of output buffers. When it fails, Client::OnError() will | 135 // Sets the number of output buffers. When it fails, Client::OnError() will |
137 // be called. | 136 // be called. |
138 virtual void SetNumberOfOutputBuffers(size_t number) = 0; | 137 virtual void SetNumberOfOutputBuffers(size_t number) = 0; |
139 | 138 |
140 // Resets the accelerator. When it is done, Client::OnResetDone() will | 139 // Resets the accelerator. When it is done, Client::OnResetDone() will |
141 // be called. Afterwards, all buffers won't be accessed by the accelerator | 140 // be called. Afterwards, all buffers won't be accessed by the accelerator |
142 // and there won't be more callbacks. | 141 // and there won't be more callbacks. |
143 virtual void Reset() = 0; | 142 virtual void Reset() = 0; |
144 | 143 |
144 // Flushes the accelerator. After all the output buffers have been returned | |
145 // to client by OnBufferDone(), Client::OnFlushDone() will be called. | |
Pawel Osciak
2016/05/09 07:27:39
I think this is after all frames pending decode an
Owen Lin
2016/05/10 08:26:33
Comments modified accordingly.
| |
146 virtual void Flush() = 0; | |
147 | |
145 virtual ~ArcVideoAccelerator() {} | 148 virtual ~ArcVideoAccelerator() {} |
146 }; | 149 }; |
147 | 150 |
148 } // namespace arc | 151 } // namespace arc |
149 } // namespace chromeos | 152 } // namespace chromeos |
150 | 153 |
151 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 154 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ |
OLD | NEW |