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

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

Issue 1863523003: Revert "V4L2SVDA: Move allocation from GPU Child thread to decoder thread." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « no previous file | content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <linux/videodev2.h> 8 #include <linux/videodev2.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Destroy output buffers and release associated resources (textures, 150 // Destroy output buffers and release associated resources (textures,
151 // EGLImages). If |dismiss| is true, also dismissing the associated 151 // EGLImages). If |dismiss| is true, also dismissing the associated
152 // PictureBuffers. 152 // PictureBuffers.
153 bool DestroyOutputs(bool dismiss); 153 bool DestroyOutputs(bool dismiss);
154 154
155 // Used by DestroyOutputs. 155 // Used by DestroyOutputs.
156 bool DestroyOutputBuffers(); 156 bool DestroyOutputBuffers();
157 157
158 // Dismiss all |picture_buffer_ids| via Client::DismissPictureBuffer() 158 // Dismiss all |picture_buffer_ids| via Client::DismissPictureBuffer()
159 // and signal |done| after finishing. 159 // and signal |done| after finishing.
160 void DismissPictures(const std::vector<int32_t>& picture_buffer_ids, 160 void DismissPictures(std::vector<int32_t> picture_buffer_ids,
161 base::WaitableEvent* done); 161 base::WaitableEvent* done);
162 162
163 // Task to finish initialization on decoder_thread_. 163 // Task to finish initialization on decoder_thread_.
164 void InitializeTask(); 164 void InitializeTask();
165 165
166 // Surface set change (resolution change) flow. 166 // Surface set change (resolution change) flow.
167 // If we have no surfaces allocated, start it immediately, otherwise mark 167 // If we have no surfaces allocated, just allocate them and return.
168 // ourselves as pending for surface set change. 168 // Otherwise mark us as pending for surface set change.
169 void InitiateSurfaceSetChange(); 169 void InitiateSurfaceSetChange();
170 // If a surface set change is pending and we are ready, stop the device, 170 // If a surface set change is pending and we are ready, stop the device,
171 // destroy outputs, releasing resources and dismissing pictures as required, 171 // destroy outputs, releasing resources and dismissing pictures as required,
172 // followed by starting the flow to allocate a new set for the current 172 // followed by allocating a new set for the new resolution/DPB size
173 // resolution/DPB size, as provided by decoder. 173 // as provided by decoder. Finally, try to resume decoding.
174 bool FinishSurfaceSetChange(); 174 void FinishSurfaceSetChangeIfNeeded();
175 175
176 void NotifyError(Error error); 176 void NotifyError(Error error);
177 void DestroyTask(); 177 void DestroyTask();
178 178
179 // Sets the state to kError and notifies client if needed. 179 // Sets the state to kError and notifies client if needed.
180 void SetErrorState(Error error); 180 void SetErrorState(Error error);
181 181
182 // Flush flow when requested by client. 182 // Flush flow when requested by client.
183 // When Flush() is called, it posts a FlushTask, which checks the input queue. 183 // When Flush() is called, it posts a FlushTask, which checks the input queue.
184 // If nothing is pending for decode on decoder_input_queue_, we call 184 // If nothing is pending for decode on decoder_input_queue_, we call
185 // InitiateFlush() directly. Otherwise, we push a dummy BitstreamBufferRef 185 // InitiateFlush() directly. Otherwise, we push a dummy BitstreamBufferRef
186 // onto the decoder_input_queue_ to schedule a flush. When we reach it later 186 // onto the decoder_input_queue_ to schedule a flush. When we reach it later
187 // on, we call InitiateFlush() to perform it at the correct time. 187 // on, we call InitiateFlush() to perform it at the correct time.
188 void FlushTask(); 188 void FlushTask();
189 // Tell the decoder to flush all frames, reset it and mark us as scheduled 189 // Tell the decoder to flush all frames, reset it and mark us as scheduled
190 // for flush, so that we can finish it once all pending decodes are finished. 190 // for flush, so that we can finish it once all pending decodes are finished.
191 void InitiateFlush(); 191 void InitiateFlush();
192 // To be called if decoder_flushing_ is true. If not all pending frames are 192 // If all pending frames are decoded and we are waiting to flush, perform it.
193 // decoded, return false, requesting the caller to try again later. 193 // This will send all pending pictures to client and notify the client that
194 // Otherwise perform flush by sending all pending pictures to the client, 194 // flush is complete and puts us in a state ready to resume.
195 // notify it that flush is finished and return true, informing the caller 195 void FinishFlushIfNeeded();
196 // that further progress can be made.
197 bool FinishFlush();
198 196
199 // Reset flow when requested by client. 197 // Reset flow when requested by client.
200 // Drop all inputs, reset the decoder and mark us as pending for reset. 198 // Drop all inputs and reset the decoder and mark us as pending for reset.
201 void ResetTask(); 199 void ResetTask();
202 // To be called if decoder_resetting_ is true. If not all pending frames are 200 // If all pending frames are decoded and we are waiting to reset, perform it.
203 // decoded, return false, requesting the caller to try again later. 201 // This drops all pending outputs (client is not interested anymore),
204 // Otherwise perform reset by dropping all pending outputs (client is not 202 // notifies the client we are done and puts us in a state ready to resume.
205 // interested anymore), notifying it that reset is finished, and return true, 203 void FinishResetIfNeeded();
206 // informing the caller that further progress can be made.
207 bool FinishReset();
208 204
209 // Allocate V4L2 buffers and assign them to |buffers| provided by the client 205 // Process pending events if any.
210 // via AssignPictureBuffers() on decoder thread.
211 void AssignPictureBuffersTask(
212 const std::vector<media::PictureBuffer>& buffers);
213
214 // Create EGLImages bound to textures in |buffers| for given
215 // |output_format_fourcc| and |output_planes_count|.
216 void CreateEGLImages(const std::vector<media::PictureBuffer>& buffers,
217 uint32_t output_format_fourcc,
218 size_t output_planes_count);
219
220 // Assign |egl_images| to previously-allocated V4L2 buffers in
221 // output_buffer_map_ and picture ids from |buffers| and finish the surface
222 // change sequence.
223 void AssignEGLImages(const std::vector<media::PictureBuffer>& buffers,
224 const std::vector<EGLImageKHR>& egl_images);
225
226 // Process pending events, if any.
227 void ProcessPendingEventsIfNeeded(); 206 void ProcessPendingEventsIfNeeded();
228 207
229 // Performed on decoder_thread_ as a consequence of poll() on decoder_thread_ 208 // Performed on decoder_thread_ as a consequence of poll() on decoder_thread_
230 // returning an event. 209 // returning an event.
231 void ServiceDeviceTask(); 210 void ServiceDeviceTask();
232 211
233 // Schedule poll if we have any buffers queued and the poll thread 212 // Schedule poll if we have any buffers queued and the poll thread
234 // is not stopped (on surface set change). 213 // is not stopped (on surface set change).
235 void SchedulePollIfNeeded(); 214 void SchedulePollIfNeeded();
236 215
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 V4L2DecodeSurfaceByPictureBufferId surfaces_at_display_; 372 V4L2DecodeSurfaceByPictureBufferId surfaces_at_display_;
394 373
395 // Record for decoded pictures that can be sent to PictureReady. 374 // Record for decoded pictures that can be sent to PictureReady.
396 struct PictureRecord; 375 struct PictureRecord;
397 // Pictures that are ready but not sent to PictureReady yet. 376 // Pictures that are ready but not sent to PictureReady yet.
398 std::queue<PictureRecord> pending_picture_ready_; 377 std::queue<PictureRecord> pending_picture_ready_;
399 378
400 // The number of pictures that are sent to PictureReady and will be cleared. 379 // The number of pictures that are sent to PictureReady and will be cleared.
401 int picture_clearing_count_; 380 int picture_clearing_count_;
402 381
382 // Used by the decoder thread to wait for AssignPictureBuffers to arrive
383 // to avoid races with potential Reset requests.
384 base::WaitableEvent pictures_assigned_;
385
403 // EGL state 386 // EGL state
404 EGLDisplay egl_display_; 387 EGLDisplay egl_display_;
405 388
406 // Callback to get current GLContext. 389 // Callback to get current GLContext.
407 GetGLContextCallback get_gl_context_cb_; 390 GetGLContextCallback get_gl_context_cb_;
408 // Callback to set the correct gl context. 391 // Callback to set the correct gl context.
409 MakeGLContextCurrentCallback make_context_current_cb_; 392 MakeGLContextCurrentCallback make_context_current_cb_;
410 393
411 // The WeakPtrFactory for |weak_this_|. 394 // The WeakPtrFactory for |weak_this_|.
412 base::WeakPtrFactory<V4L2SliceVideoDecodeAccelerator> weak_this_factory_; 395 base::WeakPtrFactory<V4L2SliceVideoDecodeAccelerator> weak_this_factory_;
413 396
414 DISALLOW_COPY_AND_ASSIGN(V4L2SliceVideoDecodeAccelerator); 397 DISALLOW_COPY_AND_ASSIGN(V4L2SliceVideoDecodeAccelerator);
415 }; 398 };
416 399
417 class V4L2H264Picture; 400 class V4L2H264Picture;
418 class V4L2VP8Picture; 401 class V4L2VP8Picture;
419 402
420 } // namespace content 403 } // namespace content
421 404
422 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ 405 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/v4l2_slice_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698