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

Side by Side Diff: media/gpu/vaapi_video_encode_accelerator.h

Issue 1939683002: Test X11 header pollution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ 5 #ifndef MEDIA_GPU_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ 6 #define MEDIA_GPU_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <list> 11 #include <list>
12 #include <memory> 12 #include <memory>
13 #include <queue> 13 #include <queue>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "content/common/content_export.h"
19 #include "content/common/gpu/media/h264_dpb.h"
20 #include "content/common/gpu/media/va_surface.h"
21 #include "content/common/gpu/media/vaapi_wrapper.h"
22 #include "media/filters/h264_bitstream_buffer.h" 18 #include "media/filters/h264_bitstream_buffer.h"
19 #include "media/gpu/h264_dpb.h"
20 #include "media/gpu/media_gpu_export.h"
21 #include "media/gpu/va_surface.h"
22 #include "media/gpu/vaapi_wrapper.h"
23 #include "media/video/video_encode_accelerator.h" 23 #include "media/video/video_encode_accelerator.h"
24 24
25 namespace content { 25 namespace media {
26 26
27 // A VideoEncodeAccelerator implementation that uses VA-API 27 // A VideoEncodeAccelerator implementation that uses VA-API
28 // (http://www.freedesktop.org/wiki/Software/vaapi) for HW-accelerated 28 // (http://www.freedesktop.org/wiki/Software/vaapi) for HW-accelerated
29 // video encode. 29 // video encode.
30 class CONTENT_EXPORT VaapiVideoEncodeAccelerator 30 class MEDIA_GPU_EXPORT VaapiVideoEncodeAccelerator
31 : public media::VideoEncodeAccelerator { 31 : public media::VideoEncodeAccelerator {
32 public: 32 public:
33 VaapiVideoEncodeAccelerator(); 33 VaapiVideoEncodeAccelerator();
34 ~VaapiVideoEncodeAccelerator() override; 34 ~VaapiVideoEncodeAccelerator() override;
35 35
36 // media::VideoEncodeAccelerator implementation. 36 // media::VideoEncodeAccelerator implementation.
37 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() 37 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles()
38 override; 38 override;
39 bool Initialize(media::VideoPixelFormat format, 39 bool Initialize(media::VideoPixelFormat format,
40 const gfx::Size& input_visible_size, 40 const gfx::Size& input_visible_size,
41 media::VideoCodecProfile output_profile, 41 media::VideoCodecProfile output_profile,
42 uint32_t initial_bitrate, 42 uint32_t initial_bitrate,
43 Client* client) override; 43 Client* client) override;
44 void Encode(const scoped_refptr<media::VideoFrame>& frame, 44 void Encode(const scoped_refptr<media::VideoFrame>& frame,
45 bool force_keyframe) override; 45 bool force_keyframe) override;
46 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override; 46 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override;
47 void RequestEncodingParametersChange(uint32_t bitrate, 47 void RequestEncodingParametersChange(uint32_t bitrate,
48 uint32_t framerate) override; 48 uint32_t framerate) override;
49 void Destroy() override; 49 void Destroy() override;
50 50
51 private: 51 private:
52 // Reference picture list. 52 // Reference picture list.
53 typedef std::list<scoped_refptr<VASurface> > RefPicList; 53 typedef std::list<scoped_refptr<VASurface>> RefPicList;
54 54
55 // Encode job for one frame. Created when an input frame is awaiting and 55 // Encode job for one frame. Created when an input frame is awaiting and
56 // enough resources are available to proceed. Once the job is prepared and 56 // enough resources are available to proceed. Once the job is prepared and
57 // submitted to the hardware, it awaits on the submitted_encode_jobs_ queue 57 // submitted to the hardware, it awaits on the submitted_encode_jobs_ queue
58 // for an output bitstream buffer to become available. Once one is ready, 58 // for an output bitstream buffer to become available. Once one is ready,
59 // the encoded bytes are downloaded to it and job resources are released 59 // the encoded bytes are downloaded to it and job resources are released
60 // and become available for reuse. 60 // and become available for reuse.
61 struct EncodeJob { 61 struct EncodeJob {
62 // Input surface for video frame data. 62 // Input surface for video frame data.
63 scoped_refptr<VASurface> input_surface; 63 scoped_refptr<VASurface> input_surface;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // VA buffers for coded frames. 225 // VA buffers for coded frames.
226 std::vector<VABufferID> available_va_buffer_ids_; 226 std::vector<VABufferID> available_va_buffer_ids_;
227 227
228 // Currently active reference surfaces. 228 // Currently active reference surfaces.
229 RefPicList ref_pic_list0_; 229 RefPicList ref_pic_list0_;
230 230
231 // Callback via which finished VA surfaces are returned to us. 231 // Callback via which finished VA surfaces are returned to us.
232 VASurface::ReleaseCB va_surface_release_cb_; 232 VASurface::ReleaseCB va_surface_release_cb_;
233 233
234 // VideoFrames passed from the client, waiting to be encoded. 234 // VideoFrames passed from the client, waiting to be encoded.
235 std::queue<linked_ptr<InputFrameRef> > encoder_input_queue_; 235 std::queue<linked_ptr<InputFrameRef>> encoder_input_queue_;
236 236
237 // BitstreamBuffers mapped, ready to be filled. 237 // BitstreamBuffers mapped, ready to be filled.
238 std::queue<linked_ptr<BitstreamBufferRef> > available_bitstream_buffers_; 238 std::queue<linked_ptr<BitstreamBufferRef>> available_bitstream_buffers_;
239 239
240 // Jobs submitted for encode, awaiting bitstream buffers to become available. 240 // Jobs submitted for encode, awaiting bitstream buffers to become available.
241 std::queue<linked_ptr<EncodeJob> > submitted_encode_jobs_; 241 std::queue<linked_ptr<EncodeJob>> submitted_encode_jobs_;
242 242
243 // Encoder thread. All tasks are executed on it. 243 // Encoder thread. All tasks are executed on it.
244 base::Thread encoder_thread_; 244 base::Thread encoder_thread_;
245 scoped_refptr<base::SingleThreadTaskRunner> encoder_thread_task_runner_; 245 scoped_refptr<base::SingleThreadTaskRunner> encoder_thread_task_runner_;
246 246
247 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; 247 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
248 248
249 // To expose client callbacks from VideoEncodeAccelerator. 249 // To expose client callbacks from VideoEncodeAccelerator.
250 // NOTE: all calls to these objects *MUST* be executed on 250 // NOTE: all calls to these objects *MUST* be executed on
251 // child_task_runner_. 251 // child_task_runner_.
252 std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; 252 std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_;
253 base::WeakPtr<Client> client_; 253 base::WeakPtr<Client> client_;
254 254
255 // WeakPtr to post from the encoder thread back to the ChildThread, as it may 255 // WeakPtr to post from the encoder thread back to the ChildThread, as it may
256 // outlive this. Posting from the ChildThread using base::Unretained(this) 256 // outlive this. Posting from the ChildThread using base::Unretained(this)
257 // to the encoder thread is safe, because |this| always outlives the encoder 257 // to the encoder thread is safe, because |this| always outlives the encoder
258 // thread (it's a member of this class). 258 // thread (it's a member of this class).
259 base::WeakPtr<VaapiVideoEncodeAccelerator> weak_this_; 259 base::WeakPtr<VaapiVideoEncodeAccelerator> weak_this_;
260 base::WeakPtrFactory<VaapiVideoEncodeAccelerator> weak_this_ptr_factory_; 260 base::WeakPtrFactory<VaapiVideoEncodeAccelerator> weak_this_ptr_factory_;
261 261
262 DISALLOW_COPY_AND_ASSIGN(VaapiVideoEncodeAccelerator); 262 DISALLOW_COPY_AND_ASSIGN(VaapiVideoEncodeAccelerator);
263 }; 263 };
264 264
265 } // namespace content 265 } // namespace media
266 266
267 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ 267 #endif // MEDIA_GPU_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « media/gpu/vaapi_video_decode_accelerator.cc ('k') | media/gpu/vaapi_video_encode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698