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 #if defined(USE_OZONE) | |
12 #include <wayland-client.h> | |
13 #endif | |
14 #include <list> | |
11 #include <map> | 15 #include <map> |
12 #include <queue> | 16 #include <queue> |
13 #include <utility> | 17 #include <utility> |
14 #include <vector> | 18 #include <vector> |
15 | 19 |
16 #include "base/logging.h" | 20 #include "base/logging.h" |
17 #include "base/memory/linked_ptr.h" | 21 #include "base/memory/linked_ptr.h" |
18 #include "base/memory/shared_memory.h" | 22 #include "base/memory/shared_memory.h" |
19 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
20 #include "base/message_loop/message_loop.h" | 24 #include "base/message_loop/message_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
37 // support for it, and on which libva is available. | 41 // support for it, and on which libva is available. |
38 // Decoding tasks are performed in a separate decoding thread. | 42 // Decoding tasks are performed in a separate decoding thread. |
39 // | 43 // |
40 // Threading/life-cycle: this object is created & destroyed on the GPU | 44 // Threading/life-cycle: this object is created & destroyed on the GPU |
41 // ChildThread. A few methods on it are called on the decoder thread which is | 45 // ChildThread. A few methods on it are called on the decoder thread which is |
42 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread | 46 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread |
43 // can assume |*this| is still alive. See |weak_this_| below for more details. | 47 // can assume |*this| is still alive. See |weak_this_| below for more details. |
44 class CONTENT_EXPORT VaapiVideoDecodeAccelerator | 48 class CONTENT_EXPORT VaapiVideoDecodeAccelerator |
45 : public VideoDecodeAcceleratorImpl { | 49 : public VideoDecodeAcceleratorImpl { |
46 public: | 50 public: |
51 #if defined(USE_OZONE) | |
52 VaapiVideoDecodeAccelerator( | |
Ami GONE FROM CHROMIUM
2014/04/18 22:40:25
single-arg ctors need "explicit"
| |
53 const base::Callback<bool(void)>& make_context_current); //NOLINT | |
Ami GONE FROM CHROMIUM
2014/04/18 22:40:25
why NOLINT?
| |
54 #else | |
47 VaapiVideoDecodeAccelerator( | 55 VaapiVideoDecodeAccelerator( |
48 Display* x_display, | 56 Display* x_display, |
49 const base::Callback<bool(void)>& make_context_current); | 57 const base::Callback<bool(void)>& make_context_current); |
58 #endif | |
50 virtual ~VaapiVideoDecodeAccelerator(); | 59 virtual ~VaapiVideoDecodeAccelerator(); |
51 | 60 |
52 // media::VideoDecodeAccelerator implementation. | 61 // media::VideoDecodeAccelerator implementation. |
53 virtual bool Initialize(media::VideoCodecProfile profile, | 62 virtual bool Initialize(media::VideoCodecProfile profile, |
54 Client* client) OVERRIDE; | 63 Client* client) OVERRIDE; |
55 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 64 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
56 virtual void AssignPictureBuffers( | 65 virtual void AssignPictureBuffers( |
57 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 66 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
58 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 67 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
59 virtual void Flush() OVERRIDE; | 68 virtual void Flush() OVERRIDE; |
60 virtual void Reset() OVERRIDE; | 69 virtual void Reset() OVERRIDE; |
61 virtual void Destroy() OVERRIDE; | 70 virtual void Destroy() OVERRIDE; |
62 | 71 |
63 private: | 72 private: |
64 // Notify the client that an error has occurred and decoding cannot continue. | 73 // Notify the client that an error has occurred and decoding cannot continue. |
65 void NotifyError(Error error); | 74 void NotifyError(Error error); |
66 | 75 |
67 // Map the received input buffer into this process' address space and | 76 // Map the received input buffer into this process' address space and |
68 // queue it for decode. | 77 // queue it for decode. |
69 void MapAndQueueNewInputBuffer( | 78 void MapAndQueueNewInputBuffer( |
70 const media::BitstreamBuffer& bitstream_buffer); | 79 const media::BitstreamBuffer& bitstream_buffer); |
71 | 80 |
72 // Get a new input buffer from the queue and set it up in decoder. This will | 81 // Get a new input buffer from the queue and set it up in decoder. This will |
73 // sleep if no input buffers are available. Return true if a new buffer has | 82 // sleep if no input buffers are available. Return true if a new buffer has |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 // synced/waiting to be synced to a picture. Returns it to available surfaces | 150 // synced/waiting to be synced to a picture. Returns it to available surfaces |
142 // pool. | 151 // pool. |
143 void RecycleVASurfaceID(VASurfaceID va_surface_id); | 152 void RecycleVASurfaceID(VASurfaceID va_surface_id); |
144 | 153 |
145 // Initiate wait cycle for surfaces to be released before we release them | 154 // Initiate wait cycle for surfaces to be released before we release them |
146 // and allocate new ones, as requested by the decoder. | 155 // and allocate new ones, as requested by the decoder. |
147 void InitiateSurfaceSetChange(size_t num_pics, gfx::Size size); | 156 void InitiateSurfaceSetChange(size_t num_pics, gfx::Size size); |
148 // Check if the surfaces have been released or post ourselves for later. | 157 // Check if the surfaces have been released or post ourselves for later. |
149 void TryFinishSurfaceSetChange(); | 158 void TryFinishSurfaceSetChange(); |
150 | 159 |
160 #if defined(USE_OZONE) | |
161 wl_display* wl_display_; | |
162 base::Callback<bool(void)> make_context_current_; //NOLINT | |
Ami GONE FROM CHROMIUM
2014/04/18 22:40:25
why NOLINT?
Ami GONE FROM CHROMIUM
2014/04/18 22:40:25
this is the same in the X11 case so why not just m
| |
163 #else | |
151 // Client-provided X/GLX state. | 164 // Client-provided X/GLX state. |
152 Display* x_display_; | 165 Display* x_display_; |
153 base::Callback<bool(void)> make_context_current_; | 166 base::Callback<bool(void)> make_context_current_; |
154 GLXFBConfig fb_config_; | 167 GLXFBConfig fb_config_; |
155 | 168 #endif |
156 // VAVDA state. | 169 // VAVDA state. |
157 enum State { | 170 enum State { |
158 // Initialize() not called yet or failed. | 171 // Initialize() not called yet or failed. |
159 kUninitialized, | 172 kUninitialized, |
160 // DecodeTask running. | 173 // DecodeTask running. |
161 kDecoding, | 174 kDecoding, |
162 // Resetting, waiting for decoder to finish current task and cleanup. | 175 // Resetting, waiting for decoder to finish current task and cleanup. |
163 kResetting, | 176 kResetting, |
164 // Flushing, waiting for decoder to finish current task and cleanup. | 177 // Flushing, waiting for decoder to finish current task and cleanup. |
165 kFlushing, | 178 kFlushing, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 | 283 |
271 // The WeakPtrFactory for |weak_this_|. | 284 // The WeakPtrFactory for |weak_this_|. |
272 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; | 285 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; |
273 | 286 |
274 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); | 287 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); |
275 }; | 288 }; |
276 | 289 |
277 } // namespace content | 290 } // namespace content |
278 | 291 |
279 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 292 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |