| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 5 #ifndef CHROME_GPU_ARC_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 6 #define CHROME_GPU_ARC_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
| 11 #include "components/arc/video_accelerator/video_accelerator.h" | 11 #include "components/arc/video_accelerator/video_accelerator.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 namespace arc { | 14 namespace arc { |
| 15 | 15 |
| 16 enum HalPixelFormatExtension { | 16 enum HalPixelFormatExtension { |
| 17 // The pixel formats defined in Android but are used here. They are defined | 17 // The pixel formats defined in Android but are used here. They are defined |
| 18 // in "system/core/include/system/graphics.h" | 18 // in "system/core/include/system/graphics.h" |
| 19 HAL_PIXEL_FORMAT_BGRA_8888 = 5, | 19 HAL_PIXEL_FORMAT_BGRA_8888 = 5, |
| 20 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, | 20 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, |
| 21 | 21 |
| 22 // The following formats are not defined in Android, but used in | 22 // The following formats are not defined in Android, but used in |
| 23 // ArcVideoAccelerator to identify the input format. | 23 // ArcVideoDecodeAccelerator to identify the input format. |
| 24 HAL_PIXEL_FORMAT_H264 = 0x34363248, | 24 HAL_PIXEL_FORMAT_H264 = 0x34363248, |
| 25 HAL_PIXEL_FORMAT_VP8 = 0x00385056, | 25 HAL_PIXEL_FORMAT_VP8 = 0x00385056, |
| 26 HAL_PIXEL_FORMAT_VP9 = 0x00395056, | 26 HAL_PIXEL_FORMAT_VP9 = 0x00395056, |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 enum PortType { | 29 enum PortType { |
| 30 PORT_INPUT = 0, | 30 PORT_INPUT = 0, |
| 31 PORT_OUTPUT = 1, | 31 PORT_OUTPUT = 1, |
| 32 PORT_COUNT = 2, | 32 PORT_COUNT = 2, |
| 33 }; | 33 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 44 // Minimum number of buffers required to decode/encode the stream. | 44 // Minimum number of buffers required to decode/encode the stream. |
| 45 uint32_t min_num_buffers = 0; | 45 uint32_t min_num_buffers = 0; |
| 46 uint32_t coded_width = 0; | 46 uint32_t coded_width = 0; |
| 47 uint32_t coded_height = 0; | 47 uint32_t coded_height = 0; |
| 48 uint32_t crop_left = 0; | 48 uint32_t crop_left = 0; |
| 49 uint32_t crop_width = 0; | 49 uint32_t crop_width = 0; |
| 50 uint32_t crop_top = 0; | 50 uint32_t crop_top = 0; |
| 51 uint32_t crop_height = 0; | 51 uint32_t crop_height = 0; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // The IPC interface between Android and Chromium for video decoding and | 54 // The IPC interface between Android and Chromium for video decoding. Input |
| 55 // encoding. Input buffers are sent from Android side and get processed in | 55 // buffers are sent from Android side and get processed in Chromium and the |
| 56 // Chromium and the output buffers are returned back to Android side. | 56 // output buffers are returned back to Android side. |
| 57 class ArcVideoAccelerator { | 57 class ArcVideoDecodeAccelerator { |
| 58 public: | 58 public: |
| 59 enum Result { | 59 enum Result { |
| 60 // Note: this enum is used for UMA reporting. The existing values should not | 60 // Note: this enum is used for UMA reporting. The existing values should not |
| 61 // be rearranged, reused or removed and any additions should include updates | 61 // be rearranged, reused or removed and any additions should include updates |
| 62 // to UMA reporting and histograms.xml. | 62 // to UMA reporting and histograms.xml. |
| 63 SUCCESS = 0, | 63 SUCCESS = 0, |
| 64 ILLEGAL_STATE = 1, | 64 ILLEGAL_STATE = 1, |
| 65 INVALID_ARGUMENT = 2, | 65 INVALID_ARGUMENT = 2, |
| 66 UNREADABLE_INPUT = 3, | 66 UNREADABLE_INPUT = 3, |
| 67 PLATFORM_FAILURE = 4, | 67 PLATFORM_FAILURE = 4, |
| 68 INSUFFICIENT_RESOURCES = 5, | 68 INSUFFICIENT_RESOURCES = 5, |
| 69 RESULT_MAX = 6, | 69 RESULT_MAX = 6, |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 struct Config { | 72 struct Config { |
| 73 enum DeviceType { | |
| 74 DEVICE_ENCODER = 0, | |
| 75 DEVICE_DECODER = 1, | |
| 76 }; | |
| 77 | |
| 78 DeviceType device_type = DEVICE_DECODER; | |
| 79 size_t num_input_buffers = 0; | 73 size_t num_input_buffers = 0; |
| 80 uint32_t input_pixel_format = 0; | 74 uint32_t input_pixel_format = 0; |
| 81 // TODO(owenlin): Add output_pixel_format. For now only the native pixel | 75 // TODO(owenlin): Add output_pixel_format. For now only the native pixel |
| 82 // format of each VDA on Chromium is supported. | 76 // format of each VDA on Chromium is supported. |
| 83 }; | 77 }; |
| 84 | 78 |
| 85 // The callbacks of the ArcVideoAccelerator. The user of this class should | 79 // The callbacks of the ArcVideoDecodeAccelerator. The user of this class |
| 86 // implement this interface. | 80 // should implement this interface. |
| 87 class Client { | 81 class Client { |
| 88 public: | 82 public: |
| 89 virtual ~Client() {} | 83 virtual ~Client() {} |
| 90 | 84 |
| 91 // Called when an asynchronous error happens. The errors in Initialize() | 85 // Called when an asynchronous error happens. The errors in Initialize() |
| 92 // will not be reported here, but will be indicated by a return value | 86 // will not be reported here, but will be indicated by a return value |
| 93 // there. | 87 // there. |
| 94 virtual void OnError(Result error) = 0; | 88 virtual void OnError(Result error) = 0; |
| 95 | 89 |
| 96 // Called when a buffer with the specified |index| and |port| has been | 90 // Called when a buffer with the specified |index| and |port| has been |
| 97 // processed and is no longer used in the accelerator. For input buffers, | 91 // processed and is no longer used in the accelerator. For input buffers, |
| 98 // the Client may fill them with new content. For output buffers, indicates | 92 // the Client may fill them with new content. For output buffers, indicates |
| 99 // they are ready to be consumed by the client. | 93 // they are ready to be consumed by the client. |
| 100 virtual void OnBufferDone(PortType port, | 94 virtual void OnBufferDone(PortType port, |
| 101 uint32_t index, | 95 uint32_t index, |
| 102 const BufferMetadata& metadata) = 0; | 96 const BufferMetadata& metadata) = 0; |
| 103 | 97 |
| 104 // Called when the output format has changed or the output format | 98 // Called when the output format has changed or the output format |
| 105 // becomes available at beginning of the stream after initial parsing. | 99 // becomes available at beginning of the stream after initial parsing. |
| 106 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; | 100 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; |
| 107 | 101 |
| 108 // Called as a completion notification for Reset(). | 102 // Called as a completion notification for Reset(). |
| 109 virtual void OnResetDone() = 0; | 103 virtual void OnResetDone() = 0; |
| 110 | 104 |
| 111 // Called as a completion notification for Flush(). | 105 // Called as a completion notification for Flush(). |
| 112 virtual void OnFlushDone() = 0; | 106 virtual void OnFlushDone() = 0; |
| 113 }; | 107 }; |
| 114 | 108 |
| 115 // Initializes the ArcVideoAccelerator with specific configuration. This | 109 // Initializes the ArcVideoDecodeAccelerator with specific configuration. This |
| 116 // must be called before any other methods. This call is synchronous and | 110 // must be called before any other methods. This call is synchronous and |
| 117 // returns SUCCESS iff initialization is successful. | 111 // returns SUCCESS iff initialization is successful. |
| 118 virtual Result Initialize(const Config& config, Client* client) = 0; | 112 virtual Result Initialize(const Config& config, Client* client) = 0; |
| 119 | 113 |
| 120 // Assigns a shared memory to be used for the accelerator at the specified | 114 // Assigns a shared memory to be used for the accelerator at the specified |
| 121 // port and index. A buffer must be successfully bound before it can be passed | 115 // port and index. A buffer must be successfully bound before it can be passed |
| 122 // to the accelerator via UseBuffer(). Already bound buffers may be reused | 116 // to the accelerator via UseBuffer(). Already bound buffers may be reused |
| 123 // multiple times without additional bindings. | 117 // multiple times without additional bindings. |
| 124 virtual void BindSharedMemory(PortType port, | 118 virtual void BindSharedMemory(PortType port, |
| 125 uint32_t index, | 119 uint32_t index, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 152 // Resets the accelerator. When it is done, Client::OnResetDone() will | 146 // Resets the accelerator. When it is done, Client::OnResetDone() will |
| 153 // be called. Afterwards, all buffers won't be accessed by the accelerator | 147 // be called. Afterwards, all buffers won't be accessed by the accelerator |
| 154 // and there won't be more callbacks. | 148 // and there won't be more callbacks. |
| 155 virtual void Reset() = 0; | 149 virtual void Reset() = 0; |
| 156 | 150 |
| 157 // Flushes the accelerator. After all the output buffers pending decode have | 151 // Flushes the accelerator. After all the output buffers pending decode have |
| 158 // been returned to client by OnBufferDone(), Client::OnFlushDone() will be | 152 // been returned to client by OnBufferDone(), Client::OnFlushDone() will be |
| 159 // called. | 153 // called. |
| 160 virtual void Flush() = 0; | 154 virtual void Flush() = 0; |
| 161 | 155 |
| 162 virtual ~ArcVideoAccelerator() {} | 156 virtual ~ArcVideoDecodeAccelerator() {} |
| 163 }; | 157 }; |
| 164 | 158 |
| 165 } // namespace arc | 159 } // namespace arc |
| 166 } // namespace chromeos | 160 } // namespace chromeos |
| 167 | 161 |
| 168 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 162 #endif // CHROME_GPU_ARC_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |