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

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

Powered by Google App Engine
This is Rietveld 408576698