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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // Decoding tasks are performed in a separate decoding thread. | 38 // Decoding tasks are performed in a separate decoding thread. |
39 // | 39 // |
40 // Threading/life-cycle: this object is created & destroyed on the GPU | 40 // 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 | 41 // 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 | 42 // 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. | 43 // can assume |*this| is still alive. See |weak_this_| below for more details. |
44 class CONTENT_EXPORT VaapiVideoDecodeAccelerator | 44 class CONTENT_EXPORT VaapiVideoDecodeAccelerator |
45 : public VideoDecodeAcceleratorImpl { | 45 : public VideoDecodeAcceleratorImpl { |
46 public: | 46 public: |
47 VaapiVideoDecodeAccelerator( | 47 VaapiVideoDecodeAccelerator( |
| 48 #if defined(VIDEO_TEXTURE_GLX_BACKEND) |
48 Display* x_display, GLXContext glx_context, | 49 Display* x_display, GLXContext glx_context, |
| 50 #elif defined(VIDEO_TEXTURE_EGL_BACKEND) |
| 51 EGLDisplay egl_display, EGLContext egl_context, |
| 52 #endif |
49 Client* client, | 53 Client* client, |
50 const base::Callback<bool(void)>& make_context_current); | 54 const base::Callback<bool(void)>& make_context_current); |
51 virtual ~VaapiVideoDecodeAccelerator(); | 55 virtual ~VaapiVideoDecodeAccelerator(); |
52 | 56 |
53 // media::VideoDecodeAccelerator implementation. | 57 // media::VideoDecodeAccelerator implementation. |
54 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | 58 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
55 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 59 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
56 virtual void AssignPictureBuffers( | 60 virtual void AssignPictureBuffers( |
57 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 61 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
58 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 62 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // buffers). Schedules a FinishReset afterwards. | 114 // buffers). Schedules a FinishReset afterwards. |
111 void ResetTask(); | 115 void ResetTask(); |
112 | 116 |
113 // Scheduled by ResetTask after it's done putting VAVDA into an idle state. | 117 // Scheduled by ResetTask after it's done putting VAVDA into an idle state. |
114 // Drops remaining input buffers and notifies the client that reset has been | 118 // Drops remaining input buffers and notifies the client that reset has been |
115 // finished. | 119 // finished. |
116 void FinishReset(); | 120 void FinishReset(); |
117 | 121 |
118 // Helper for Destroy(), doing all the actual work except for deleting self. | 122 // Helper for Destroy(), doing all the actual work except for deleting self. |
119 void Cleanup(); | 123 void Cleanup(); |
120 | 124 #if defined(VIDEO_TEXTURE_GLX_BACKEND) |
121 // Get a usable framebuffer configuration for use in binding textures | 125 // Get a usable framebuffer configuration for use in binding textures |
122 // or return false on failure. | 126 // or return false on failure. |
123 bool InitializeFBConfig(); | 127 bool InitializeFBConfig(); |
124 | 128 #endif |
125 // Callback for the decoder to execute when it wants us to output given | 129 // Callback for the decoder to execute when it wants us to output given |
126 // |va_surface|. | 130 // |va_surface|. |
127 void SurfaceReady(int32 input_id, const scoped_refptr<VASurface>& va_surface); | 131 void SurfaceReady(int32 input_id, const scoped_refptr<VASurface>& va_surface); |
128 | 132 |
129 // Represents a texture bound to an X Pixmap for output purposes. | 133 // Represents a texture bound to an X Pixmap for output purposes. |
130 class TFPPicture; | 134 class TFPPicture; |
131 | 135 |
132 // Callback to be executed once we have a |va_surface| to be output and | 136 // Callback to be executed once we have a |va_surface| to be output and |
133 // an available |tfp_picture| to use for output. | 137 // an available |tfp_picture| to use for output. |
134 // Puts contents of |va_surface| into given |tfp_picture|, releases the | 138 // Puts contents of |va_surface| into given |tfp_picture|, releases the |
(...skipping 11 matching lines...) Expand all Loading... |
146 void RecycleVASurfaceID(VASurfaceID va_surface_id); | 150 void RecycleVASurfaceID(VASurfaceID va_surface_id); |
147 | 151 |
148 // Initiate wait cycle for surfaces to be released before we release them | 152 // Initiate wait cycle for surfaces to be released before we release them |
149 // and allocate new ones, as requested by the decoder. | 153 // and allocate new ones, as requested by the decoder. |
150 void InitiateSurfaceSetChange(size_t num_pics, gfx::Size size); | 154 void InitiateSurfaceSetChange(size_t num_pics, gfx::Size size); |
151 // Check if the surfaces have been released or post ourselves for later. | 155 // Check if the surfaces have been released or post ourselves for later. |
152 void TryFinishSurfaceSetChange(); | 156 void TryFinishSurfaceSetChange(); |
153 | 157 |
154 // Client-provided X/GLX state. | 158 // Client-provided X/GLX state. |
155 Display* x_display_; | 159 Display* x_display_; |
| 160 |
| 161 #if defined(VIDEO_TEXTURE_GLX_BACKEND) |
156 GLXContext glx_context_; | 162 GLXContext glx_context_; |
| 163 GLXFBConfig fb_config_; |
| 164 #elif defined(VIDEO_TEXTURE_EGL_BACKEND) |
| 165 EGLDisplay egl_display_; |
| 166 EGLContext egl_context_; |
| 167 #endif |
157 base::Callback<bool(void)> make_context_current_; | 168 base::Callback<bool(void)> make_context_current_; |
158 GLXFBConfig fb_config_; | |
159 | 169 |
160 // VAVDA state. | 170 // VAVDA state. |
161 enum State { | 171 enum State { |
162 // Initialize() not called yet or failed. | 172 // Initialize() not called yet or failed. |
163 kUninitialized, | 173 kUninitialized, |
164 // DecodeTask running. | 174 // DecodeTask running. |
165 kDecoding, | 175 kDecoding, |
166 // Resetting, waiting for decoder to finish current task and cleanup. | 176 // Resetting, waiting for decoder to finish current task and cleanup. |
167 kResetting, | 177 kResetting, |
168 // Flushing, waiting for decoder to finish current task and cleanup. | 178 // Flushing, waiting for decoder to finish current task and cleanup. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Last requested number/resolution of output picture buffers. | 274 // Last requested number/resolution of output picture buffers. |
265 size_t requested_num_pics_; | 275 size_t requested_num_pics_; |
266 gfx::Size requested_pic_size_; | 276 gfx::Size requested_pic_size_; |
267 | 277 |
268 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); | 278 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); |
269 }; | 279 }; |
270 | 280 |
271 } // namespace content | 281 } // namespace content |
272 | 282 |
273 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ | 283 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |