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

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

Issue 2061823003: media: Drop "media::" in media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work around clang format by adding an empty line Created 4 years, 6 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 MEDIA_GPU_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ 5 #ifndef MEDIA_GPU_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_
6 #define MEDIA_GPU_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
(...skipping 10 matching lines...) Expand all
21 #include "media/gpu/va_surface.h" 21 #include "media/gpu/va_surface.h"
22 #include "media/gpu/vaapi_wrapper.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 media { 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 MEDIA_GPU_EXPORT VaapiVideoEncodeAccelerator 30 class MEDIA_GPU_EXPORT VaapiVideoEncodeAccelerator
31 : public media::VideoEncodeAccelerator { 31 : public VideoEncodeAccelerator {
32 public: 32 public:
33 VaapiVideoEncodeAccelerator(); 33 VaapiVideoEncodeAccelerator();
34 ~VaapiVideoEncodeAccelerator() override; 34 ~VaapiVideoEncodeAccelerator() override;
35 35
36 // media::VideoEncodeAccelerator implementation. 36 // VideoEncodeAccelerator implementation.
37 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() 37 VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() override;
38 override; 38 bool Initialize(VideoPixelFormat format,
39 bool Initialize(media::VideoPixelFormat format,
40 const gfx::Size& input_visible_size, 39 const gfx::Size& input_visible_size,
41 media::VideoCodecProfile output_profile, 40 VideoCodecProfile output_profile,
42 uint32_t initial_bitrate, 41 uint32_t initial_bitrate,
43 Client* client) override; 42 Client* client) override;
44 void Encode(const scoped_refptr<media::VideoFrame>& frame, 43 void Encode(const scoped_refptr<VideoFrame>& frame,
45 bool force_keyframe) override; 44 bool force_keyframe) override;
46 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override; 45 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override;
47 void RequestEncodingParametersChange(uint32_t bitrate, 46 void RequestEncodingParametersChange(uint32_t bitrate,
48 uint32_t framerate) override; 47 uint32_t framerate) override;
49 void Destroy() override; 48 void Destroy() override;
50 49
51 private: 50 private:
52 // Reference picture list. 51 // Reference picture list.
53 typedef std::list<scoped_refptr<VASurface>> RefPicList; 52 typedef std::list<scoped_refptr<VASurface>> RefPicList;
54 53
55 // Encode job for one frame. Created when an input frame is awaiting and 54 // 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 55 // enough resources are available to proceed. Once the job is prepared and
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 }; 87 };
89 88
90 // Holds input frames coming from the client ready to be encoded. 89 // Holds input frames coming from the client ready to be encoded.
91 struct InputFrameRef; 90 struct InputFrameRef;
92 // Holds output buffers coming from the client ready to be filled. 91 // Holds output buffers coming from the client ready to be filled.
93 struct BitstreamBufferRef; 92 struct BitstreamBufferRef;
94 93
95 // Tasks for each of the VEA interface calls to be executed on the 94 // Tasks for each of the VEA interface calls to be executed on the
96 // encoder thread. 95 // encoder thread.
97 void InitializeTask(); 96 void InitializeTask();
98 void EncodeTask(const scoped_refptr<media::VideoFrame>& frame, 97 void EncodeTask(const scoped_refptr<VideoFrame>& frame, bool force_keyframe);
99 bool force_keyframe);
100 void UseOutputBitstreamBufferTask( 98 void UseOutputBitstreamBufferTask(
101 std::unique_ptr<BitstreamBufferRef> buffer_ref); 99 std::unique_ptr<BitstreamBufferRef> buffer_ref);
102 void RequestEncodingParametersChangeTask(uint32_t bitrate, 100 void RequestEncodingParametersChangeTask(uint32_t bitrate,
103 uint32_t framerate); 101 uint32_t framerate);
104 void DestroyTask(); 102 void DestroyTask();
105 103
106 // Prepare and schedule an encode job if we have an input to encode 104 // Prepare and schedule an encode job if we have an input to encode
107 // and enough resources to proceed. 105 // and enough resources to proceed.
108 void EncodeFrameTask(); 106 void EncodeFrameTask();
109 107
(...skipping 19 matching lines...) Expand all
129 // End current frame, updating reference picture lists and storing current 127 // End current frame, updating reference picture lists and storing current
130 // job in the jobs awaiting completion on submitted_encode_jobs_. 128 // job in the jobs awaiting completion on submitted_encode_jobs_.
131 void EndFrame(); 129 void EndFrame();
132 130
133 // Submit parameters for the current frame to the hardware. 131 // Submit parameters for the current frame to the hardware.
134 bool SubmitFrameParameters(); 132 bool SubmitFrameParameters();
135 // Submit keyframe headers to the hardware if the current frame is a keyframe. 133 // Submit keyframe headers to the hardware if the current frame is a keyframe.
136 bool SubmitHeadersIfNeeded(); 134 bool SubmitHeadersIfNeeded();
137 135
138 // Upload image data from |frame| to the input surface for current job. 136 // Upload image data from |frame| to the input surface for current job.
139 bool UploadFrame(const scoped_refptr<media::VideoFrame>& frame); 137 bool UploadFrame(const scoped_refptr<VideoFrame>& frame);
140 138
141 // Execute encode in hardware. This does not block and will return before 139 // Execute encode in hardware. This does not block and will return before
142 // the job is finished. 140 // the job is finished.
143 bool ExecuteEncode(); 141 bool ExecuteEncode();
144 142
145 // Callback that returns a no longer used VASurfaceID to 143 // Callback that returns a no longer used VASurfaceID to
146 // available_va_surface_ids_ for reuse. 144 // available_va_surface_ids_ for reuse.
147 void RecycleVASurfaceID(VASurfaceID va_surface_id); 145 void RecycleVASurfaceID(VASurfaceID va_surface_id);
148 146
149 // Tries to return a bitstream buffer if both a submitted job awaits to 147 // Tries to return a bitstream buffer if both a submitted job awaits to
150 // be completed and we have bitstream buffers from the client available 148 // be completed and we have bitstream buffers from the client available
151 // to download the encoded data to. 149 // to download the encoded data to.
152 void TryToReturnBitstreamBuffer(); 150 void TryToReturnBitstreamBuffer();
153 151
154 // Puts the encoder into en error state and notifies client about the error. 152 // Puts the encoder into en error state and notifies client about the error.
155 void NotifyError(Error error); 153 void NotifyError(Error error);
156 154
157 // Sets the encoder state on the correct thread. 155 // Sets the encoder state on the correct thread.
158 void SetState(State state); 156 void SetState(State state);
159 157
160 // VaapiWrapper is the owner of all HW resources (surfaces and buffers) 158 // VaapiWrapper is the owner of all HW resources (surfaces and buffers)
161 // and will free them on destruction. 159 // and will free them on destruction.
162 scoped_refptr<VaapiWrapper> vaapi_wrapper_; 160 scoped_refptr<VaapiWrapper> vaapi_wrapper_;
163 161
164 // Input profile and sizes. 162 // Input profile and sizes.
165 media::VideoCodecProfile profile_; 163 VideoCodecProfile profile_;
166 gfx::Size visible_size_; 164 gfx::Size visible_size_;
167 gfx::Size coded_size_; // Macroblock-aligned. 165 gfx::Size coded_size_; // Macroblock-aligned.
168 // Width/height in macroblocks. 166 // Width/height in macroblocks.
169 unsigned int mb_width_; 167 unsigned int mb_width_;
170 unsigned int mb_height_; 168 unsigned int mb_height_;
171 169
172 // Maximum size of the reference list 0. 170 // Maximum size of the reference list 0.
173 unsigned int max_ref_idx_l0_size_; 171 unsigned int max_ref_idx_l0_size_;
174 172
175 // Initial QP. 173 // Initial QP.
(...skipping 30 matching lines...) Expand all
206 // True if the parameters have changed and we need to submit a keyframe 204 // True if the parameters have changed and we need to submit a keyframe
207 // with updated parameters. 205 // with updated parameters.
208 bool encoding_parameters_changed_; 206 bool encoding_parameters_changed_;
209 207
210 // Job currently being prepared for encode. 208 // Job currently being prepared for encode.
211 std::unique_ptr<EncodeJob> current_encode_job_; 209 std::unique_ptr<EncodeJob> current_encode_job_;
212 210
213 // Current SPS, PPS and their packed versions. Packed versions are their NALUs 211 // Current SPS, PPS and their packed versions. Packed versions are their NALUs
214 // in AnnexB format *without* emulation prevention three-byte sequences 212 // in AnnexB format *without* emulation prevention three-byte sequences
215 // (those will be added by the driver). 213 // (those will be added by the driver).
216 media::H264SPS current_sps_; 214 H264SPS current_sps_;
217 media::H264BitstreamBuffer packed_sps_; 215 H264BitstreamBuffer packed_sps_;
218 media::H264PPS current_pps_; 216 H264PPS current_pps_;
219 media::H264BitstreamBuffer packed_pps_; 217 H264BitstreamBuffer packed_pps_;
220 218
221 // Picture currently being prepared for encode. 219 // Picture currently being prepared for encode.
222 scoped_refptr<H264Picture> current_pic_; 220 scoped_refptr<H264Picture> current_pic_;
223 221
224 // VA surfaces available for reuse. 222 // VA surfaces available for reuse.
225 std::vector<VASurfaceID> available_va_surface_ids_; 223 std::vector<VASurfaceID> available_va_surface_ids_;
226 224
227 // VA buffers for coded frames. 225 // VA buffers for coded frames.
228 std::vector<VABufferID> available_va_buffer_ids_; 226 std::vector<VABufferID> available_va_buffer_ids_;
229 227
(...skipping 30 matching lines...) Expand all
260 // thread (it's a member of this class). 258 // thread (it's a member of this class).
261 base::WeakPtr<VaapiVideoEncodeAccelerator> weak_this_; 259 base::WeakPtr<VaapiVideoEncodeAccelerator> weak_this_;
262 base::WeakPtrFactory<VaapiVideoEncodeAccelerator> weak_this_ptr_factory_; 260 base::WeakPtrFactory<VaapiVideoEncodeAccelerator> weak_this_ptr_factory_;
263 261
264 DISALLOW_COPY_AND_ASSIGN(VaapiVideoEncodeAccelerator); 262 DISALLOW_COPY_AND_ASSIGN(VaapiVideoEncodeAccelerator);
265 }; 263 };
266 264
267 } // namespace media 265 } // namespace media
268 266
269 #endif // MEDIA_GPU_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