| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains an implementation of VideoDecoderAccelerator | 5 // This file contains an implementation of VideoDecoderAccelerator |
| 6 // that utilizes hardware video decoder present on Intel CPUs. | 6 // that utilizes hardware video decoder present on Intel CPUs. |
| 7 | 7 |
| 8 #ifndef MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 8 #ifndef MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
| 9 #define MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 9 #define MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 static VideoDecodeAccelerator::SupportedProfiles GetSupportedProfiles(); | 84 static VideoDecodeAccelerator::SupportedProfiles GetSupportedProfiles(); |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 class VaapiH264Accelerator; | 87 class VaapiH264Accelerator; |
| 88 class VaapiVP8Accelerator; | 88 class VaapiVP8Accelerator; |
| 89 class VaapiVP9Accelerator; | 89 class VaapiVP9Accelerator; |
| 90 | 90 |
| 91 // Notify the client that an error has occurred and decoding cannot continue. | 91 // Notify the client that an error has occurred and decoding cannot continue. |
| 92 void NotifyError(Error error); | 92 void NotifyError(Error error); |
| 93 | 93 |
| 94 // Map the received input buffer into this process' address space and | 94 // Queue a input buffer for decode. |
| 95 // queue it for decode. | 95 void QueueInputBuffer(const BitstreamBuffer& bitstream_buffer); |
| 96 void MapAndQueueNewInputBuffer(const BitstreamBuffer& bitstream_buffer); | |
| 97 | 96 |
| 98 // Get a new input buffer from the queue and set it up in decoder. This will | 97 // Get a new input buffer from the queue and set it up in decoder. This will |
| 99 // sleep if no input buffers are available. Return true if a new buffer has | 98 // sleep if no input buffers are available. Return true if a new buffer has |
| 100 // been set up, false if an early exit has been requested (due to initiated | 99 // been set up, false if an early exit has been requested (due to initiated |
| 101 // reset/flush/destroy). | 100 // reset/flush/destroy). |
| 102 bool GetInputBuffer_Locked(); | 101 bool GetInputBuffer_Locked(); |
| 103 | 102 |
| 104 // Signal the client that the current buffer has been read and can be | 103 // Signal the client that the current buffer has been read and can be |
| 105 // returned. Will also release the mapping. | 104 // returned. Will also release the mapping. |
| 106 void ReturnCurrInputBuffer_Locked(); | 105 void ReturnCurrInputBuffer_Locked(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 scoped_refptr<VaapiDecodeSurface> CreateSurface(); | 188 scoped_refptr<VaapiDecodeSurface> CreateSurface(); |
| 190 | 189 |
| 191 // VAVDA state. | 190 // VAVDA state. |
| 192 enum State { | 191 enum State { |
| 193 // Initialize() not called yet or failed. | 192 // Initialize() not called yet or failed. |
| 194 kUninitialized, | 193 kUninitialized, |
| 195 // DecodeTask running. | 194 // DecodeTask running. |
| 196 kDecoding, | 195 kDecoding, |
| 197 // Resetting, waiting for decoder to finish current task and cleanup. | 196 // Resetting, waiting for decoder to finish current task and cleanup. |
| 198 kResetting, | 197 kResetting, |
| 199 // Flushing, waiting for decoder to finish current task and cleanup. | |
| 200 kFlushing, | |
| 201 // Idle, decoder in state ready to start/resume decoding. | 198 // Idle, decoder in state ready to start/resume decoding. |
| 202 kIdle, | 199 kIdle, |
| 203 // Destroying, waiting for the decoder to finish current task. | 200 // Destroying, waiting for the decoder to finish current task. |
| 204 kDestroying, | 201 kDestroying, |
| 205 }; | 202 }; |
| 206 | 203 |
| 207 // Protects input buffer and surface queues and state_. | 204 // Protects input buffer and surface queues and state_. |
| 208 base::Lock lock_; | 205 base::Lock lock_; |
| 209 State state_; | 206 State state_; |
| 210 Config::OutputMode output_mode_; | 207 Config::OutputMode output_mode_; |
| 211 | 208 |
| 212 // An input buffer awaiting consumption, provided by the client. | 209 // An input buffer awaiting consumption, provided by the client. |
| 213 struct InputBuffer { | 210 struct InputBuffer { |
| 214 InputBuffer(); | 211 InputBuffer(); |
| 215 ~InputBuffer(); | 212 ~InputBuffer(); |
| 216 | 213 |
| 217 int32_t id; | 214 // Indicates this is a dummy buffer for flush request. |
| 215 bool is_flush() const { return shm == nullptr; } |
| 216 |
| 217 int32_t id = -1; |
| 218 std::unique_ptr<SharedMemoryRegion> shm; | 218 std::unique_ptr<SharedMemoryRegion> shm; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 // Queue for available PictureBuffers (picture_buffer_ids). | 221 // Queue for available PictureBuffers (picture_buffer_ids). |
| 222 typedef std::queue<linked_ptr<InputBuffer>> InputBuffers; | 222 typedef std::queue<linked_ptr<InputBuffer>> InputBuffers; |
| 223 InputBuffers input_buffers_; | 223 InputBuffers input_buffers_; |
| 224 // Signalled when input buffers are queued onto the input_buffers_ queue. | 224 // Signalled when input buffers are queued onto the input_buffers_ queue. |
| 225 base::ConditionVariable input_ready_; | 225 base::ConditionVariable input_ready_; |
| 226 | 226 |
| 227 // Current input buffer at decoder. | 227 // Current input buffer at decoder. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 // The WeakPtrFactory for |weak_this_|. | 320 // The WeakPtrFactory for |weak_this_|. |
| 321 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; | 321 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; |
| 322 | 322 |
| 323 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); | 323 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); |
| 324 }; | 324 }; |
| 325 | 325 |
| 326 } // namespace media | 326 } // namespace media |
| 327 | 327 |
| 328 #endif // MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 328 #endif // MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |