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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Class to provide video decode acceleration for Intel systems with hardware | 46 // Class to provide video decode acceleration for Intel systems with hardware |
47 // support for it, and on which libva is available. | 47 // support for it, and on which libva is available. |
48 // Decoding tasks are performed in a separate decoding thread. | 48 // Decoding tasks are performed in a separate decoding thread. |
49 // | 49 // |
50 // Threading/life-cycle: this object is created & destroyed on the GPU | 50 // Threading/life-cycle: this object is created & destroyed on the GPU |
51 // ChildThread. A few methods on it are called on the decoder thread which is | 51 // ChildThread. A few methods on it are called on the decoder thread which is |
52 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread | 52 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread |
53 // can assume |*this| is still alive. See |weak_this_| below for more details. | 53 // can assume |*this| is still alive. See |weak_this_| below for more details. |
54 class MEDIA_GPU_EXPORT VaapiVideoDecodeAccelerator | 54 class MEDIA_GPU_EXPORT VaapiVideoDecodeAccelerator |
55 : public media::VideoDecodeAccelerator { | 55 : public VideoDecodeAccelerator { |
56 public: | 56 public: |
57 class VaapiDecodeSurface; | 57 class VaapiDecodeSurface; |
58 | 58 |
59 VaapiVideoDecodeAccelerator( | 59 VaapiVideoDecodeAccelerator( |
60 const MakeGLContextCurrentCallback& make_context_current_cb, | 60 const MakeGLContextCurrentCallback& make_context_current_cb, |
61 const BindGLImageCallback& bind_image_cb); | 61 const BindGLImageCallback& bind_image_cb); |
62 | 62 |
63 ~VaapiVideoDecodeAccelerator() override; | 63 ~VaapiVideoDecodeAccelerator() override; |
64 | 64 |
65 // media::VideoDecodeAccelerator implementation. | 65 // VideoDecodeAccelerator implementation. |
66 bool Initialize(const Config& config, Client* client) override; | 66 bool Initialize(const Config& config, Client* client) override; |
67 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 67 void Decode(const BitstreamBuffer& bitstream_buffer) override; |
68 void AssignPictureBuffers( | 68 void AssignPictureBuffers(const std::vector<PictureBuffer>& buffers) override; |
69 const std::vector<media::PictureBuffer>& buffers) override; | |
70 #if defined(USE_OZONE) | 69 #if defined(USE_OZONE) |
71 void ImportBufferForPicture( | 70 void ImportBufferForPicture( |
72 int32_t picture_buffer_id, | 71 int32_t picture_buffer_id, |
73 const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) override; | 72 const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) override; |
74 #endif | 73 #endif |
75 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 74 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
76 void Flush() override; | 75 void Flush() override; |
77 void Reset() override; | 76 void Reset() override; |
78 void Destroy() override; | 77 void Destroy() override; |
79 bool TryToSetupDecodeOnSeparateThread( | 78 bool TryToSetupDecodeOnSeparateThread( |
80 const base::WeakPtr<Client>& decode_client, | 79 const base::WeakPtr<Client>& decode_client, |
81 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) | 80 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
82 override; | 81 override; |
83 | 82 |
84 static media::VideoDecodeAccelerator::SupportedProfiles | 83 static VideoDecodeAccelerator::SupportedProfiles GetSupportedProfiles(); |
85 GetSupportedProfiles(); | |
86 | 84 |
87 private: | 85 private: |
88 class VaapiH264Accelerator; | 86 class VaapiH264Accelerator; |
89 class VaapiVP8Accelerator; | 87 class VaapiVP8Accelerator; |
90 class VaapiVP9Accelerator; | 88 class VaapiVP9Accelerator; |
91 | 89 |
92 // Notify the client that an error has occurred and decoding cannot continue. | 90 // Notify the client that an error has occurred and decoding cannot continue. |
93 void NotifyError(Error error); | 91 void NotifyError(Error error); |
94 | 92 |
95 // Map the received input buffer into this process' address space and | 93 // Map the received input buffer into this process' address space and |
96 // queue it for decode. | 94 // queue it for decode. |
97 void MapAndQueueNewInputBuffer( | 95 void MapAndQueueNewInputBuffer(const BitstreamBuffer& bitstream_buffer); |
98 const media::BitstreamBuffer& bitstream_buffer); | |
99 | 96 |
100 // 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 |
101 // 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 |
102 // 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 |
103 // reset/flush/destroy). | 100 // reset/flush/destroy). |
104 bool GetInputBuffer_Locked(); | 101 bool GetInputBuffer_Locked(); |
105 | 102 |
106 // 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 |
107 // returned. Will also release the mapping. | 104 // returned. Will also release the mapping. |
108 void ReturnCurrInputBuffer_Locked(); | 105 void ReturnCurrInputBuffer_Locked(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 316 |
320 // The WeakPtrFactory for |weak_this_|. | 317 // The WeakPtrFactory for |weak_this_|. |
321 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; | 318 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; |
322 | 319 |
323 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); | 320 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); |
324 }; | 321 }; |
325 | 322 |
326 } // namespace media | 323 } // namespace media |
327 | 324 |
328 #endif // MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 325 #endif // MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |