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

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: Change ArcVideoAccelerator::Reset to asynchronous. 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,
24 };
25
26 struct BufferMetadata {
27 int64_t timestamp = 0; // in microseconds
28 uint32_t flags = 0;
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 process the video.
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 // ArcVideoAccelerator is a component of ArcCodec to deal with video
47 // buffers. It is also an IPC interface between Android and Chromium.
48 // So that the video buffers are sent to Chromium side and decoded.
49 // ArcCodec implements ArcVideoAccelerator::Client and is responsible for
50 // rendering and interacting with the Android media framework.
51 class ArcVideoAccelerator {
52 public:
53 enum Error {
54 ILLEGAL_STATE = 1,
55 INVALID_ARGUMENT = 2,
56 UNREADABLE_INPUT = 3,
57 PLATFORM_FAILURE = 4,
58 };
59
60 struct Config {
61 enum DeviceType {
62 DEVICE_ENCODER = 0,
63 DEVICE_DECODER = 1,
64 };
65
66 DeviceType device_type = DEVICE_DECODER;
67 size_t num_input_buffers = 0;
68 uint32_t input_pixel_format = 0;
69 // TODO: Add output_pixel_format. For now only the native pixel format
70 // of each VDA on Chromium is supported.
71 };
72
73 // The callbacks of the ArcVideoAccelerator. ArcCodec implmenets this
74 // interface.
75 class Client {
76 public:
77 virtual ~Client() {}
78
79 // Called when an asynchronous error happens. Asynchronous errors happen
80 // only when the accelerator processes the input buffer and tried to
81 // generate the output to the output buffer.
82 virtual void OnError(Error error) = 0;
83
84 // Called when a buffer with the specified |index| and |port| has been
85 // processed and is no longer used in the accelerator. For input buffer,
86 // it can be filled with new content. For output buffer, it is ready to
87 // be consumed by the client.
88 virtual void OnBufferDone(PortType port,
89 uint32_t index,
90 const BufferMetadata& metadata) = 0;
91
92 // Called when the output format has changed or the output format
93 // becomes available at beginning of the stream after initial parsing.
94 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0;
95
96 // Called as a completion notification for Reset().
97 virtual void OnResetDone() = 0;
98 };
99
100 virtual bool Initialize(const Config& config, Client* client) = 0;
101
102 // Assigns a shared memory to be used for the accelerator at the specified
103 // port and index. A buffer must be bound before asking the accelerator to
104 // use it via useBuffer().
105 virtual void BindSharedMemory(PortType port,
106 uint32_t index,
107 int ashmem_fd,
108 off_t offset,
109 size_t length) = 0;
110
111 // Assigns a graphic buffer to be used for the accelerator at the specified
112 // port and index. A buffer must be bound before asking the accelerator to
113 // use it via useBuffer().
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.
124 virtual void SetNumberOfOutputBuffers(size_t number) = 0;
125
126 // Resets the accelerator. When it is done, Client::OnResetDone() will
127 // be called. Afterwords, all buffers won't be accessed by the accelerator
128 // and there won't be more callbacks.
129 virtual void Reset() = 0;
130
131 virtual ~ArcVideoAccelerator() {}
132 };
133
134 } // namespace arc
135 } // namespace chromeos
136
137 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698