| 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_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 base::ScopedFD ashmem_fd, | 40 base::ScopedFD ashmem_fd, |
| 41 off_t offset, | 41 off_t offset, |
| 42 size_t length) override; | 42 size_t length) override; |
| 43 void BindDmabuf(PortType port, | 43 void BindDmabuf(PortType port, |
| 44 uint32_t index, | 44 uint32_t index, |
| 45 base::ScopedFD dmabuf_fd) override; | 45 base::ScopedFD dmabuf_fd) override; |
| 46 void UseBuffer(PortType port, | 46 void UseBuffer(PortType port, |
| 47 uint32_t index, | 47 uint32_t index, |
| 48 const BufferMetadata& metadata) override; | 48 const BufferMetadata& metadata) override; |
| 49 void Reset() override; | 49 void Reset() override; |
| 50 void Flush() override; |
| 50 | 51 |
| 51 // Implementation of the VideoDecodeAccelerator::Client interface. | 52 // Implementation of the VideoDecodeAccelerator::Client interface. |
| 52 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, | 53 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, |
| 53 uint32_t textures_per_buffer, | 54 uint32_t textures_per_buffer, |
| 54 const gfx::Size& dimensions, | 55 const gfx::Size& dimensions, |
| 55 uint32_t texture_target) override; | 56 uint32_t texture_target) override; |
| 56 void DismissPictureBuffer(int32_t picture_buffer) override; | 57 void DismissPictureBuffer(int32_t picture_buffer) override; |
| 57 void PictureReady(const media::Picture& picture) override; | 58 void PictureReady(const media::Picture& picture) override; |
| 58 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; | 59 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; |
| 59 void NotifyFlushDone() override; | 60 void NotifyFlushDone() override; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 79 // should be closed after use. | 80 // should be closed after use. |
| 80 base::ScopedFD handle; | 81 base::ScopedFD handle; |
| 81 off_t offset; | 82 off_t offset; |
| 82 size_t length; | 83 size_t length; |
| 83 | 84 |
| 84 InputBufferInfo(); | 85 InputBufferInfo(); |
| 85 InputBufferInfo(InputBufferInfo&& other); | 86 InputBufferInfo(InputBufferInfo&& other); |
| 86 ~InputBufferInfo(); | 87 ~InputBufferInfo(); |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 // Helper function to Send the end-of-stream output buffer if | |
| 90 // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA. | |
| 91 void SendEosIfNeededOrReusePicture(uint32_t index); | |
| 92 | |
| 93 // Helper function to validate |port| and |index|. | 90 // Helper function to validate |port| and |index|. |
| 94 bool ValidatePortAndIndex(PortType port, uint32_t index); | 91 bool ValidatePortAndIndex(PortType port, uint32_t index); |
| 95 | 92 |
| 96 // Creates an InputRecord for the given |bitstream_buffer_id|. The | 93 // Creates an InputRecord for the given |bitstream_buffer_id|. The |
| 97 // |buffer_index| is the index of the associated input buffer. The |timestamp| | 94 // |buffer_index| is the index of the associated input buffer. The |timestamp| |
| 98 // is the time the video frame should be displayed. | 95 // is the time the video frame should be displayed. |
| 99 void CreateInputRecord(int32_t bitstream_buffer_id, | 96 void CreateInputRecord(int32_t bitstream_buffer_id, |
| 100 uint32_t buffer_index, | 97 uint32_t buffer_index, |
| 101 int64_t timestamp); | 98 int64_t timestamp); |
| 102 | 99 |
| 103 // Finds the InputRecord which matches to given |bitstream_buffer_id|. | 100 // Finds the InputRecord which matches to given |bitstream_buffer_id|. |
| 104 // Returns |nullptr| if it cannot be found. | 101 // Returns |nullptr| if it cannot be found. |
| 105 InputRecord* FindInputRecord(int32_t bitstream_buffer_id); | 102 InputRecord* FindInputRecord(int32_t bitstream_buffer_id); |
| 106 | 103 |
| 107 // When true, an EOS output buffer need to be sent to |arc_client_| once an | |
| 108 // output buffer is available. | |
| 109 bool pending_eos_output_buffer_; | |
| 110 | |
| 111 std::unique_ptr<media::VideoDecodeAccelerator> vda_; | 104 std::unique_ptr<media::VideoDecodeAccelerator> vda_; |
| 112 | 105 |
| 113 // It's safe to use the pointer here, the life cycle of the |arc_client_| | 106 // It's safe to use the pointer here, the life cycle of the |arc_client_| |
| 114 // is longer than this ArcGpuVideoDecodeAccelerator. | 107 // is longer than this ArcGpuVideoDecodeAccelerator. |
| 115 ArcVideoAccelerator::Client* arc_client_; | 108 ArcVideoAccelerator::Client* arc_client_; |
| 116 | 109 |
| 117 // The next ID for the bitstream buffer, started from 0. | 110 // The next ID for the bitstream buffer, started from 0. |
| 118 int32_t next_bitstream_buffer_id_; | 111 int32_t next_bitstream_buffer_id_; |
| 119 | 112 |
| 120 gfx::Size coded_size_; | 113 gfx::Size coded_size_; |
| 121 | 114 |
| 122 // The |picture_buffer_id|s for Pictures that were returned to us from VDA | |
| 123 // via PictureReady() while flushing. We keep them until NotifyFlushDone(); | |
| 124 // once it's called, we send one of the pending buffers from this queue (if | |
| 125 // not empty), marked with an EOS flag, to |arc_client_|, and return the rest | |
| 126 // to VDA for reuse. | |
| 127 std::queue<int32_t> buffers_pending_eos_; | |
| 128 | |
| 129 // A list of most recent |kMaxNumberOfInputRecord| InputRecords. | 115 // A list of most recent |kMaxNumberOfInputRecord| InputRecords. |
| 130 // |kMaxNumberOfInputRecord| is defined in the cc file. | 116 // |kMaxNumberOfInputRecord| is defined in the cc file. |
| 131 std::list<InputRecord> input_records_; | 117 std::list<InputRecord> input_records_; |
| 132 | 118 |
| 133 // The details of the shared memory of each input buffers. | 119 // The details of the shared memory of each input buffers. |
| 134 std::vector<InputBufferInfo> input_buffer_info_; | 120 std::vector<InputBufferInfo> input_buffer_info_; |
| 135 | 121 |
| 136 // To keep those output buffers which have been bound by bindDmabuf() but not | 122 // To keep those output buffers which have been bound by bindDmabuf() but not |
| 137 // be used yet. Will call VDA::ImportBufferForPicture() when those buffers are | 123 // be used yet. Will call VDA::ImportBufferForPicture() when those buffers are |
| 138 // used for the first time. | 124 // used for the first time. |
| 139 std::vector<base::ScopedFD> buffers_pending_import_; | 125 std::vector<base::ScopedFD> buffers_pending_import_; |
| 140 | 126 |
| 141 base::ThreadChecker thread_checker_; | 127 base::ThreadChecker thread_checker_; |
| 142 size_t output_buffer_size_; | 128 size_t output_buffer_size_; |
| 143 | 129 |
| 144 gpu::GpuPreferences gpu_preferences_; | 130 gpu::GpuPreferences gpu_preferences_; |
| 145 | 131 |
| 146 DISALLOW_COPY_AND_ASSIGN(ArcGpuVideoDecodeAccelerator); | 132 DISALLOW_COPY_AND_ASSIGN(ArcGpuVideoDecodeAccelerator); |
| 147 }; | 133 }; |
| 148 | 134 |
| 149 } // namespace arc | 135 } // namespace arc |
| 150 } // namespace chromeos | 136 } // namespace chromeos |
| 151 | 137 |
| 152 #endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 138 #endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |