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

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: move code from content/ to /chrome 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 DeviceType {
23 DEVICE_ENCODER = 0,
24 DEVICE_DECODER = 1,
25 };
26
27 enum MemoryType {
28 MEMORY_SHARED_MEMORY = 0,
29 MEMORY_DMABUF = 1,
30 };
31
32 enum BufferFlag {
33 BUFFER_FLAG_EOS = 1,
34 };
35
36 struct BufferMetadata {
37 int64_t timestamp; // in microseconds
38 uint32_t flags;
39 uint32_t bytes_used;
40
41 BufferMetadata() : timestamp(0), flags(0), bytes_used(0) {}
42 };
43
44 struct BufferFormat {
45 uint32_t pixel_format; // the fourcc pixel format format
46 MemoryType memory_type;
47
48 BufferFormat() : pixel_format(0), memory_type(MEMORY_SHARED_MEMORY) {}
49 };
50
51 struct VideoFormat {
52 uint32_t pixel_format;
53 uint32_t image_size;
54
55 // minimal number of buffers required to process the video.
56 uint32_t min_num_buffers;
57 uint32_t coded_width;
58 uint32_t coded_height;
59 uint32_t crop_left;
60 uint32_t crop_width;
61 uint32_t crop_top;
62 uint32_t crop_height;
63
64 VideoFormat()
65 : pixel_format(0),
66 image_size(0),
67 min_num_buffers(0),
68 coded_width(0),
69 coded_height(0),
70 crop_left(0),
71 crop_width(0),
72 crop_top(0),
73 crop_height(0) {}
74 };
75
76 // ArcVideoAccelerator is a component of ArcCodec to deal with video
77 // buffers. It is also an IPC interface between Android and Chromium.
78 // So that the video buffers are sent to Chromium side and decoded.
79 // ArcCodec implements ArcVideoAccelerator::Client and is responsible for
80 // rendering and interacting with the Android media framework.
81 class ArcVideoAccelerator {
82 public:
83 enum Error {
84 ILLEGAL_STATE = 1,
85 INVALID_ARGUMENT = 2,
86 UNREADABLE_INPUT = 3,
87 PLATFORM_FAILURE = 4,
88 };
89
90 // The callbacks of the ArcVideoAccelerator. ArcCodec implmenets this
91 // interface.
92 class Client {
93 public:
94 virtual ~Client() {}
95
96 // Called when an asynchronous error happens. Asynchronous errors happen
97 // only when the accelerator processes the input buffer and tried to
98 // generate the output to the output buffer.
99 virtual void OnError(Error error) = 0;
100
101 // Called when a buffer with the specified |index| and |port| has been
102 // processed and is no longer used in the accelerator. For input buffer,
103 // it can be filled with new content. For output buffer, it is ready to
104 // be consumed by the client.
105 virtual void OnBufferDone(PortType port,
106 uint32_t index,
107 const BufferMetadata& metadata) = 0;
108
109 // Called when the output format has changed or the output format
110 // becomes available at beginning of the stream after initial parsing.
111 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0;
112 };
113
114 virtual bool Initialize(DeviceType device, Client* client) = 0;
115
116 // Assigns a shared memory to be used for the accelerator at the specified
117 // port and index. A buffer must be bound before asking the accelerator to
118 // use it via useBuffer().
119 virtual bool BindSharedMemory(PortType port,
120 uint32_t index,
121 int ashmem_fd,
122 size_t offset,
123 size_t length) = 0;
124
125 // Assigns a graphic buffer to be used for the accelerator at the specified
126 // port and index. A buffer must be bound before asking the accelerator to
127 // use it via useBuffer().
128 virtual bool BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) = 0;
129
130 // Passes a buffer to the accelerator. For input buffer, the accelerator
131 // will process it. For output buffer, the accelerator will output content
132 // to it.
133 virtual void UseBuffer(PortType port,
134 uint32_t index,
135 const BufferMetadata& metadata) = 0;
136
137 // Sets the number of requested buffers. The accelerator may change the
138 // count due to hardware limitation. The caller is responsible to check
139 // the returned value to see if it is acceptable.
140 virtual bool SetBufferCount(PortType port, size_t* count) = 0;
141
142 // Resets the accelerator. After this function, all buffers won't be
143 // accessed by the accelerator and there won't be more callbacks.
144 virtual void Reset() = 0;
145
146 // Sets the buffer format of the given port.
147 virtual bool SetBufferFormat(PortType port, const BufferFormat& format) = 0;
148
149 virtual ~ArcVideoAccelerator() {}
150 };
151
152 } // namespace arc
153 } // namespace chromeos
154
155 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698