Chromium Code Reviews| OLD | NEW |
|---|---|
| (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, | |
|
Pawel Osciak
2016/03/22 08:36:11
Perhaps 1 << 0 to further emphasize these to be bi
Owen Lin
2016/03/24 03:01:11
Done.
| |
| 24 }; | |
| 25 | |
| 26 struct BufferMetadata { | |
| 27 int64_t timestamp = 0; // in microseconds | |
| 28 uint32_t flags = 0; | |
|
Pawel Osciak
2016/03/22 08:36:11
Please add a comment this should use values from B
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 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. | |
|
Pawel Osciak
2016/03/22 08:36:11
s/minimal/Minimum/
s/process the video/decode\/enc
Owen Lin
2016/03/24 03:01:10
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 // 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 | |
|
Pawel Osciak
2016/03/22 08:36:11
Please remove or rephrase this sentence so that it
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 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 | |
|
Pawel Osciak
2016/03/22 08:36:11
TODO(owner):
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 70 // of each VDA on Chromium is supported. | |
| 71 }; | |
| 72 | |
| 73 // The callbacks of the ArcVideoAccelerator. ArcCodec implmenets this | |
|
Pawel Osciak
2016/03/22 08:36:11
Please update the last sentence.
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 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 | |
|
Pawel Osciak
2016/03/22 08:36:10
Is this still applicable? I think we may OnError()
Owen Lin
2016/03/24 03:01:10
Indeed. Remove the last sentence.
| |
| 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 | |
|
Pawel Osciak
2016/03/22 08:36:11
s/buffer, it can be filled/buffers, the Client may
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 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 | |
| 97 virtual bool Initialize(const Config& config, Client* client) = 0; | |
|
Pawel Osciak
2016/03/22 08:36:11
Please document.
Owen Lin
2016/03/24 03:01:11
Done.
| |
| 98 | |
| 99 // Assigns a shared memory to be used for the accelerator at the specified | |
| 100 // port and index. A buffer must be bound before asking the accelerator to | |
|
Pawel Osciak
2016/03/22 08:36:10
A buffer must be successfully bound using this met
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 101 // use it via useBuffer(). | |
| 102 virtual void BindSharedMemory(PortType port, | |
| 103 uint32_t index, | |
| 104 int ashmem_fd, | |
| 105 off_t offset, | |
| 106 size_t length) = 0; | |
| 107 | |
| 108 // Assigns a graphic buffer to be used for the accelerator at the specified | |
|
Pawel Osciak
2016/03/22 08:36:11
s/graphic//
Owen Lin
2016/03/24 03:01:10
Done.
| |
| 109 // port and index. A buffer must be bound before asking the accelerator to | |
| 110 // use it via useBuffer(). | |
| 111 virtual void BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) = 0; | |
| 112 | |
| 113 // Passes a buffer to the accelerator. For input buffer, the accelerator | |
| 114 // will process it. For output buffer, the accelerator will output content | |
| 115 // to it. | |
| 116 virtual void UseBuffer(PortType port, | |
| 117 uint32_t index, | |
| 118 const BufferMetadata& metadata) = 0; | |
| 119 | |
| 120 // Sets the number of output buffers. | |
|
Pawel Osciak
2016/03/22 08:36:10
Please document whether this can fail and what hap
Owen Lin
2016/03/24 03:01:10
This is not likely to fail in current implementati
| |
| 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_ | |
| OLD | NEW |