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

Side by Side Diff: chrome/gpu/arc_video_accelerator.h

Issue 2919193002: ArcBridge: Rename VideoAcceleratorService to VideoDecodeAccelerator. (Closed)
Patch Set: Address review comments Created 3 years, 6 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_VIDEO_ACCELERATOR_H_
6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
7
8 #include <vector>
9
10 #include "base/files/scoped_file.h"
11 #include "components/arc/video_accelerator/video_accelerator.h"
12
13 namespace chromeos {
14 namespace arc {
15
16 enum HalPixelFormatExtension {
17 // The pixel formats defined in Android but are used here. They are defined
18 // in "system/core/include/system/graphics.h"
19 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
20 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
21
22 // The following formats are not defined in Android, but used in
23 // ArcVideoAccelerator to identify the input format.
24 HAL_PIXEL_FORMAT_H264 = 0x34363248,
25 HAL_PIXEL_FORMAT_VP8 = 0x00385056,
26 HAL_PIXEL_FORMAT_VP9 = 0x00395056,
27 };
28
29 enum PortType {
30 PORT_INPUT = 0,
31 PORT_OUTPUT = 1,
32 PORT_COUNT = 2,
33 };
34
35 struct BufferMetadata {
36 int64_t timestamp = 0; // in microseconds
37 uint32_t bytes_used = 0;
38 };
39
40 struct VideoFormat {
41 uint32_t pixel_format = 0;
42 uint32_t buffer_size = 0;
43
44 // Minimum number of buffers required to decode/encode the stream.
45 uint32_t min_num_buffers = 0;
46 uint32_t coded_width = 0;
47 uint32_t coded_height = 0;
48 uint32_t crop_left = 0;
49 uint32_t crop_width = 0;
50 uint32_t crop_top = 0;
51 uint32_t crop_height = 0;
52 };
53
54 // The IPC interface between Android and Chromium for video decoding and
55 // encoding. Input buffers are sent from Android side and get processed in
56 // Chromium and the output buffers are returned back to Android side.
57 class ArcVideoAccelerator {
58 public:
59 enum Result {
60 // Note: this enum is used for UMA reporting. The existing values should not
61 // be rearranged, reused or removed and any additions should include updates
62 // to UMA reporting and histograms.xml.
63 SUCCESS = 0,
64 ILLEGAL_STATE = 1,
65 INVALID_ARGUMENT = 2,
66 UNREADABLE_INPUT = 3,
67 PLATFORM_FAILURE = 4,
68 INSUFFICIENT_RESOURCES = 5,
69 RESULT_MAX = 6,
70 };
71
72 struct Config {
73 enum DeviceType {
74 DEVICE_ENCODER = 0,
75 DEVICE_DECODER = 1,
76 };
77
78 DeviceType device_type = DEVICE_DECODER;
79 size_t num_input_buffers = 0;
80 uint32_t input_pixel_format = 0;
81 // TODO(owenlin): Add output_pixel_format. For now only the native pixel
82 // format of each VDA on Chromium is supported.
83 };
84
85 // The callbacks of the ArcVideoAccelerator. The user of this class should
86 // implement this interface.
87 class Client {
88 public:
89 virtual ~Client() {}
90
91 // Called when an asynchronous error happens. The errors in Initialize()
92 // will not be reported here, but will be indicated by a return value
93 // there.
94 virtual void OnError(Result error) = 0;
95
96 // Called when a buffer with the specified |index| and |port| has been
97 // processed and is no longer used in the accelerator. For input buffers,
98 // the Client may fill them with new content. For output buffers, indicates
99 // they are ready to be consumed by the client.
100 virtual void OnBufferDone(PortType port,
101 uint32_t index,
102 const BufferMetadata& metadata) = 0;
103
104 // Called when the output format has changed or the output format
105 // becomes available at beginning of the stream after initial parsing.
106 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0;
107
108 // Called as a completion notification for Reset().
109 virtual void OnResetDone() = 0;
110
111 // Called as a completion notification for Flush().
112 virtual void OnFlushDone() = 0;
113 };
114
115 // Initializes the ArcVideoAccelerator with specific configuration. This
116 // must be called before any other methods. This call is synchronous and
117 // returns SUCCESS iff initialization is successful.
118 virtual Result Initialize(const Config& config, Client* client) = 0;
119
120 // Assigns a shared memory to be used for the accelerator at the specified
121 // port and index. A buffer must be successfully bound before it can be passed
122 // to the accelerator via UseBuffer(). Already bound buffers may be reused
123 // multiple times without additional bindings.
124 virtual void BindSharedMemory(PortType port,
125 uint32_t index,
126 base::ScopedFD ashmem_fd,
127 off_t offset,
128 size_t length) = 0;
129
130 // Assigns a buffer to be used for the accelerator at the specified
131 // port and index. A buffer must be successfully bound before it can be
132 // passed to the accelerator via UseBuffer(). Already bound buffers may be
133 // reused multiple times without additional bindings.
134 virtual void BindDmabuf(
135 PortType port,
136 uint32_t index,
137 base::ScopedFD dmabuf_fd,
138 const std::vector<::arc::ArcVideoAcceleratorDmabufPlane>&
139 dmabuf_planes) = 0;
140
141 // Passes a buffer to the accelerator. For input buffer, the accelerator
142 // will process it. For output buffer, the accelerator will output content
143 // to it.
144 virtual void UseBuffer(PortType port,
145 uint32_t index,
146 const BufferMetadata& metadata) = 0;
147
148 // Sets the number of output buffers. When it fails, Client::OnError() will
149 // be called.
150 virtual void SetNumberOfOutputBuffers(size_t number) = 0;
151
152 // Resets the accelerator. When it is done, Client::OnResetDone() will
153 // be called. Afterwards, all buffers won't be accessed by the accelerator
154 // and there won't be more callbacks.
155 virtual void Reset() = 0;
156
157 // Flushes the accelerator. After all the output buffers pending decode have
158 // been returned to client by OnBufferDone(), Client::OnFlushDone() will be
159 // called.
160 virtual void Flush() = 0;
161
162 virtual ~ArcVideoAccelerator() {}
163 };
164
165 } // namespace arc
166 } // namespace chromeos
167
168 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « chrome/gpu/arc_gpu_video_decode_accelerator.cc ('k') | chrome/gpu/arc_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698