| 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 CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 8 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
| 9 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 9 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
| 18 #include "base/memory/shared_memory.h" | 18 #include "base/memory/shared_memory.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 21 #include "base/synchronization/condition_variable.h" | 21 #include "base/synchronization/condition_variable.h" |
| 22 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
| 23 #include "base/threading/non_thread_safe.h" | 23 #include "base/threading/non_thread_safe.h" |
| 24 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
| 25 #include "content/common/content_export.h" | 25 #include "content/common/content_export.h" |
| 26 #include "content/common/gpu/media/vaapi_h264_decoder.h" | 26 #include "content/common/gpu/media/vaapi_h264_decoder.h" |
| 27 #include "content/common/gpu/media/vaapi_wrapper.h" | 27 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 28 #include "content/common/gpu/media/video_decode_accelerator_impl.h" |
| 28 #include "media/base/bitstream_buffer.h" | 29 #include "media/base/bitstream_buffer.h" |
| 29 #include "media/video/picture.h" | 30 #include "media/video/picture.h" |
| 30 #include "media/video/video_decode_accelerator.h" | 31 #include "media/video/video_decode_accelerator.h" |
| 31 #include "ui/gl/gl_bindings.h" | 32 #include "ui/gl/gl_bindings.h" |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| 34 | 35 |
| 35 // Class to provide video decode acceleration for Intel systems with hardware | 36 // Class to provide video decode acceleration for Intel systems with hardware |
| 36 // support for it, and on which libva is available. | 37 // support for it, and on which libva is available. |
| 37 // Decoding tasks are performed in a separate decoding thread. | 38 // Decoding tasks are performed in a separate decoding thread. |
| 38 // | 39 // |
| 39 // Threading/life-cycle: this object is created & destroyed on the GPU | 40 // Threading/life-cycle: this object is created & destroyed on the GPU |
| 40 // ChildThread. A few methods on it are called on the decoder thread which is | 41 // ChildThread. A few methods on it are called on the decoder thread which is |
| 41 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread | 42 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread |
| 42 // can assume |*this| is still alive. See |weak_this_| below for more details. | 43 // can assume |*this| is still alive. See |weak_this_| below for more details. |
| 43 class CONTENT_EXPORT VaapiVideoDecodeAccelerator | 44 class CONTENT_EXPORT VaapiVideoDecodeAccelerator |
| 44 : public media::VideoDecodeAccelerator { | 45 : public VideoDecodeAcceleratorImpl { |
| 45 public: | 46 public: |
| 46 VaapiVideoDecodeAccelerator( | 47 VaapiVideoDecodeAccelerator( |
| 47 Display* x_display, | 48 Display* x_display, |
| 48 const base::Callback<bool(void)>& make_context_current); | 49 const base::Callback<bool(void)>& make_context_current); |
| 49 virtual ~VaapiVideoDecodeAccelerator(); | 50 virtual ~VaapiVideoDecodeAccelerator(); |
| 50 | 51 |
| 51 // media::VideoDecodeAccelerator implementation. | 52 // media::VideoDecodeAccelerator implementation. |
| 52 virtual bool Initialize(media::VideoCodecProfile profile, | 53 virtual bool Initialize(media::VideoCodecProfile profile, |
| 53 Client* client) OVERRIDE; | 54 Client* client) OVERRIDE; |
| 54 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 55 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 55 virtual void AssignPictureBuffers( | 56 virtual void AssignPictureBuffers( |
| 56 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 57 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
| 57 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 58 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 58 virtual void Flush() OVERRIDE; | 59 virtual void Flush() OVERRIDE; |
| 59 virtual void Reset() OVERRIDE; | 60 virtual void Reset() OVERRIDE; |
| 60 virtual void Destroy() OVERRIDE; | 61 virtual void Destroy() OVERRIDE; |
| 61 virtual bool CanDecodeOnIOThread() OVERRIDE; | |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // Notify the client that an error has occurred and decoding cannot continue. | 64 // Notify the client that an error has occurred and decoding cannot continue. |
| 65 void NotifyError(Error error); | 65 void NotifyError(Error error); |
| 66 | 66 |
| 67 // Map the received input buffer into this process' address space and | 67 // Map the received input buffer into this process' address space and |
| 68 // queue it for decode. | 68 // queue it for decode. |
| 69 void MapAndQueueNewInputBuffer( | 69 void MapAndQueueNewInputBuffer( |
| 70 const media::BitstreamBuffer& bitstream_buffer); | 70 const media::BitstreamBuffer& bitstream_buffer); |
| 71 | 71 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 // The WeakPtrFactory for |weak_this_|. | 271 // The WeakPtrFactory for |weak_this_|. |
| 272 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; | 272 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; |
| 273 | 273 |
| 274 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); | 274 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); |
| 275 }; | 275 }; |
| 276 | 276 |
| 277 } // namespace content | 277 } // namespace content |
| 278 | 278 |
| 279 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 279 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |