Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: content/common/gpu/media/vaapi_video_decode_accelerator.h

Issue 1832123002: Revert of Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 11 #include <stddef.h>
12 #include <stdint.h> 12 #include <stdint.h>
13 13
14 #include <list> 14 #include <list>
15 #include <map> 15 #include <map>
16 #include <queue> 16 #include <queue>
17 #include <utility> 17 #include <utility>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/linked_ptr.h" 22 #include "base/memory/linked_ptr.h"
23 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
24 #include "base/message_loop/message_loop.h" 24 #include "base/message_loop/message_loop.h"
25 #include "base/synchronization/condition_variable.h" 25 #include "base/synchronization/condition_variable.h"
26 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
27 #include "base/threading/thread.h" 27 #include "base/threading/thread.h"
28 #include "content/common/content_export.h" 28 #include "content/common/content_export.h"
29 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h"
30 #include "content/common/gpu/media/shared_memory_region.h" 29 #include "content/common/gpu/media/shared_memory_region.h"
31 #include "content/common/gpu/media/vaapi_wrapper.h" 30 #include "content/common/gpu/media/vaapi_wrapper.h"
32 #include "media/base/bitstream_buffer.h" 31 #include "media/base/bitstream_buffer.h"
33 #include "media/video/picture.h" 32 #include "media/video/picture.h"
34 #include "media/video/video_decode_accelerator.h" 33 #include "media/video/video_decode_accelerator.h"
35 34
36 namespace gl { 35 namespace gl {
37 class GLImage; 36 class GLImage;
38 } 37 }
39 38
40 namespace content { 39 namespace content {
41 40
42 class AcceleratedVideoDecoder; 41 class AcceleratedVideoDecoder;
43 class VaapiPicture; 42 class VaapiPicture;
44 43
45 // Class to provide video decode acceleration for Intel systems with hardware 44 // Class to provide video decode acceleration for Intel systems with hardware
46 // support for it, and on which libva is available. 45 // support for it, and on which libva is available.
47 // Decoding tasks are performed in a separate decoding thread. 46 // Decoding tasks are performed in a separate decoding thread.
48 // 47 //
49 // Threading/life-cycle: this object is created & destroyed on the GPU 48 // Threading/life-cycle: this object is created & destroyed on the GPU
50 // ChildThread. A few methods on it are called on the decoder thread which is 49 // ChildThread. A few methods on it are called on the decoder thread which is
51 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread 50 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread
52 // can assume |*this| is still alive. See |weak_this_| below for more details. 51 // can assume |*this| is still alive. See |weak_this_| below for more details.
53 class CONTENT_EXPORT VaapiVideoDecodeAccelerator 52 class CONTENT_EXPORT VaapiVideoDecodeAccelerator
54 : public media::VideoDecodeAccelerator { 53 : public media::VideoDecodeAccelerator {
55 public: 54 public:
56 class VaapiDecodeSurface; 55 class VaapiDecodeSurface;
57 56
58 VaapiVideoDecodeAccelerator( 57 VaapiVideoDecodeAccelerator(
59 const MakeGLContextCurrentCallback& make_context_current_cb, 58 const MakeContextCurrentCallback& make_context_current,
60 const BindGLImageCallback& bind_image_cb); 59 const BindImageCallback& bind_image);
61
62 ~VaapiVideoDecodeAccelerator() override; 60 ~VaapiVideoDecodeAccelerator() override;
63 61
64 // media::VideoDecodeAccelerator implementation. 62 // media::VideoDecodeAccelerator implementation.
65 bool Initialize(const Config& config, Client* client) override; 63 bool Initialize(const Config& config, Client* client) override;
66 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; 64 void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
67 void AssignPictureBuffers( 65 void AssignPictureBuffers(
68 const std::vector<media::PictureBuffer>& buffers) override; 66 const std::vector<media::PictureBuffer>& buffers) override;
69 void ReusePictureBuffer(int32_t picture_buffer_id) override; 67 void ReusePictureBuffer(int32_t picture_buffer_id) override;
70 void Flush() override; 68 void Flush() override;
71 void Reset() override; 69 void Reset() override;
72 void Destroy() override; 70 void Destroy() override;
73 bool TryToSetupDecodeOnSeparateThread( 71 bool CanDecodeOnIOThread() override;
74 const base::WeakPtr<Client>& decode_client,
75 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
76 override;
77 72
78 static media::VideoDecodeAccelerator::SupportedProfiles 73 static media::VideoDecodeAccelerator::SupportedProfiles
79 GetSupportedProfiles(); 74 GetSupportedProfiles();
80 75
81 private: 76 private:
82 class VaapiH264Accelerator; 77 class VaapiH264Accelerator;
83 class VaapiVP8Accelerator; 78 class VaapiVP8Accelerator;
84 class VaapiVP9Accelerator; 79 class VaapiVP9Accelerator;
85 80
86 // Notify the client that an error has occurred and decoding cannot continue. 81 // Notify the client that an error has occurred and decoding cannot continue.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // On Intel, we don't have to explicitly maintain the ordering however, as the 172 // On Intel, we don't have to explicitly maintain the ordering however, as the
178 // driver will maintain ordering, as well as dependencies, and will process 173 // driver will maintain ordering, as well as dependencies, and will process
179 // each submitted command in order, and run each command only if its 174 // each submitted command in order, and run each command only if its
180 // dependencies are ready. 175 // dependencies are ready.
181 void SurfaceReady(const scoped_refptr<VaapiDecodeSurface>& dec_surface); 176 void SurfaceReady(const scoped_refptr<VaapiDecodeSurface>& dec_surface);
182 177
183 // Return a new VaapiDecodeSurface for decoding into, or nullptr if not 178 // Return a new VaapiDecodeSurface for decoding into, or nullptr if not
184 // available. 179 // available.
185 scoped_refptr<VaapiDecodeSurface> CreateSurface(); 180 scoped_refptr<VaapiDecodeSurface> CreateSurface();
186 181
182
183 // Client-provided GL state.
184 MakeContextCurrentCallback make_context_current_;
185
187 // VAVDA state. 186 // VAVDA state.
188 enum State { 187 enum State {
189 // Initialize() not called yet or failed. 188 // Initialize() not called yet or failed.
190 kUninitialized, 189 kUninitialized,
191 // DecodeTask running. 190 // DecodeTask running.
192 kDecoding, 191 kDecoding,
193 // Resetting, waiting for decoder to finish current task and cleanup. 192 // Resetting, waiting for decoder to finish current task and cleanup.
194 kResetting, 193 kResetting,
195 // Flushing, waiting for decoder to finish current task and cleanup. 194 // Flushing, waiting for decoder to finish current task and cleanup.
196 kFlushing, 195 kFlushing,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 bool finish_flush_pending_; 296 bool finish_flush_pending_;
298 297
299 // Decoder requested a new surface set and we are waiting for all the surfaces 298 // Decoder requested a new surface set and we are waiting for all the surfaces
300 // to be returned before we can free them. 299 // to be returned before we can free them.
301 bool awaiting_va_surfaces_recycle_; 300 bool awaiting_va_surfaces_recycle_;
302 301
303 // Last requested number/resolution of output picture buffers. 302 // Last requested number/resolution of output picture buffers.
304 size_t requested_num_pics_; 303 size_t requested_num_pics_;
305 gfx::Size requested_pic_size_; 304 gfx::Size requested_pic_size_;
306 305
307 // Callback to make GL context current. 306 // Binds the provided GLImage to a givenr client texture ID & texture target
308 MakeGLContextCurrentCallback make_context_current_cb_; 307 // combination in GLES.
309 308 BindImageCallback bind_image_;
310 // Callback to bind a GLImage to a given texture.
311 BindGLImageCallback bind_image_cb_;
312 309
313 // The WeakPtrFactory for |weak_this_|. 310 // The WeakPtrFactory for |weak_this_|.
314 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; 311 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_;
315 312
316 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); 313 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator);
317 }; 314 };
318 315
319 } // namespace content 316 } // namespace content
320 317
321 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ 318 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/vaapi_tfp_picture.cc ('k') | content/common/gpu/media/vaapi_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698