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

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

Issue 1549473002: Add ArcGpuVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Pawel's comments 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 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 namespace chromeos {
9 namespace arc {
10
11 enum HalPixelFormatExtension {
12 HAL_PIXEL_FORMAT_H264 = 0x34363248,
13 HAL_PIXEL_FORMAT_VP8 = 0x00385056,
14 };
15
16 enum PortType {
17 PORT_INPUT = 0,
18 PORT_OUTPUT = 1,
19 PORT_COUNT = 2,
20 };
21
22 enum BufferFlag {
23 BUFFER_FLAG_EOS = 1 << 0,
24 };
25
26 struct BufferMetadata {
27 int64_t timestamp = 0; // in microseconds
28 uint32_t flags = 0; // Flags defined in BufferFlag.
29 uint32_t bytes_used = 0;
30 };
31
32 struct VideoFormat {
33 uint32_t pixel_format = 0;
34 uint32_t buffer_size = 0;
35
36 // Minimal number of buffers required to decode/encode the stream.
Pawel Osciak 2016/03/25 08:38:45 s/Minimal/Minimum/
Owen Lin 2016/03/29 07:10:41 Done.
37 uint32_t min_num_buffers = 0;
38 uint32_t coded_width = 0;
39 uint32_t coded_height = 0;
40 uint32_t crop_left = 0;
41 uint32_t crop_width = 0;
42 uint32_t crop_top = 0;
43 uint32_t crop_height = 0;
44 };
45
46 class ArcVideoAccelerator {
Pawel Osciak 2016/03/25 08:38:45 We should still have some comment what this class
Owen Lin 2016/03/29 07:10:42 Done.
47 public:
48 enum Error {
49 ILLEGAL_STATE = 1,
50 INVALID_ARGUMENT = 2,
51 UNREADABLE_INPUT = 3,
52 PLATFORM_FAILURE = 4,
53 };
54
55 struct Config {
56 enum DeviceType {
57 DEVICE_ENCODER = 0,
58 DEVICE_DECODER = 1,
59 };
60
61 DeviceType device_type = DEVICE_DECODER;
62 size_t num_input_buffers = 0;
63 uint32_t input_pixel_format = 0;
64 // TODO(owenlin): Add output_pixel_format. For now only the native pixel
65 // format of each VDA on Chromium is supported.
66 };
67
68 // The callbacks of the ArcVideoAccelerator. The user of this class should
69 // implement this interface.
70 class Client {
71 public:
72 virtual ~Client() {}
73
74 // Called when an asynchronous error happens. The errors in Initialize()
75 // will not be reported here, but will be indicated by a false return value
76 // there.
77 virtual void OnError(Error error) = 0;
78
79 // Called when a buffer with the specified |index| and |port| has been
80 // processed and is no longer used in the accelerator. For input buffers,
81 // the Client may fill them with new content. For output buffers, indicates
82 // they are ready to be consumed by the client.
83 virtual void OnBufferDone(PortType port,
84 uint32_t index,
85 const BufferMetadata& metadata) = 0;
86
87 // Called when the output format has changed or the output format
88 // becomes available at beginning of the stream after initial parsing.
89 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0;
90
91 // Called as a completion notification for Reset().
92 virtual void OnResetDone() = 0;
93 };
94
95 // Initializes the ArcVideoAccelerator with specific configuration. This
96 // must be called before any other methods. This call is synchronous and
97 // returns true iff initialization is successful.
98 virtual bool Initialize(const Config& config, Client* client) = 0;
99
100 // Assigns a shared memory to be used for the accelerator at the specified
101 // port and index. A buffer must be successfully bound before it can be passed
102 // to the accelerator via UseBuffer(). Already bound buffers may be reused
103 // multiple times without additional bindings.
104 virtual void BindSharedMemory(PortType port,
105 uint32_t index,
106 int ashmem_fd,
107 off_t offset,
108 size_t length) = 0;
109
110 // Assigns a buffer to be used for the accelerator at the specified
111 // port and index. A buffer must be successfully bound before it can be
112 // passed to the accelerator via UseBuffer. Already bound buffers may be
113 // resued multiple times without additional bindings.
114 virtual void BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) = 0;
115
116 // Passes a buffer to the accelerator. For input buffer, the accelerator
117 // will process it. For output buffer, the accelerator will output content
118 // to it.
119 virtual void UseBuffer(PortType port,
120 uint32_t index,
121 const BufferMetadata& metadata) = 0;
122
123 // Sets the number of output buffers. When it fails, Client::OnError() will
124 // be called.
125 virtual void SetNumberOfOutputBuffers(size_t number) = 0;
126
127 // Resets the accelerator. When it is done, Client::OnResetDone() will
128 // be called. Afterwords, all buffers won't be accessed by the accelerator
Pawel Osciak 2016/03/25 08:38:45 s/Afterwords/Afterwards/
Owen Lin 2016/03/29 07:10:41 Done.
129 // and there won't be more callbacks.
130 virtual void Reset() = 0;
131
132 virtual ~ArcVideoAccelerator() {}
133 };
134
135 } // namespace arc
136 } // namespace chromeos
137
138 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698