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

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

Issue 1822983002: Support external buffer import in VDA interface and add a V4L2SVDA impl. (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 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 30 matching lines...) Expand all
41 EGLDisplay egl_display, 41 EGLDisplay egl_display,
42 const GetGLContextCallback& get_gl_context_cb, 42 const GetGLContextCallback& get_gl_context_cb,
43 const MakeGLContextCurrentCallback& make_context_current_cb); 43 const MakeGLContextCurrentCallback& make_context_current_cb);
44 ~V4L2SliceVideoDecodeAccelerator() override; 44 ~V4L2SliceVideoDecodeAccelerator() override;
45 45
46 // media::VideoDecodeAccelerator implementation. 46 // media::VideoDecodeAccelerator implementation.
47 bool Initialize(const Config& config, Client* client) override; 47 bool Initialize(const Config& config, Client* client) override;
48 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; 48 void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
49 void AssignPictureBuffers( 49 void AssignPictureBuffers(
50 const std::vector<media::PictureBuffer>& buffers) override; 50 const std::vector<media::PictureBuffer>& buffers) override;
51 void ImportBufferForPicture(int32_t picture_buffer_id,
52 const std::vector<gfx::GpuMemoryBufferHandle>&
53 gpu_memory_buffer_handles) override;
51 void ReusePictureBuffer(int32_t picture_buffer_id) override; 54 void ReusePictureBuffer(int32_t picture_buffer_id) override;
52 void Flush() override; 55 void Flush() override;
53 void Reset() override; 56 void Reset() override;
54 void Destroy() override; 57 void Destroy() override;
55 bool TryToSetupDecodeOnSeparateThread( 58 bool TryToSetupDecodeOnSeparateThread(
56 const base::WeakPtr<Client>& decode_client, 59 const base::WeakPtr<Client>& decode_client,
57 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) 60 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
58 override; 61 override;
62 media::VideoPixelFormat GetOutputFormat() const override;
59 63
60 static media::VideoDecodeAccelerator::SupportedProfiles 64 static media::VideoDecodeAccelerator::SupportedProfiles
61 GetSupportedProfiles(); 65 GetSupportedProfiles();
62 66
63 private: 67 private:
64 class V4L2H264Accelerator; 68 class V4L2H264Accelerator;
65 class V4L2VP8Accelerator; 69 class V4L2VP8Accelerator;
66 70
67 // Record for input buffers. 71 // Record for input buffers.
68 struct InputRecord { 72 struct InputRecord {
69 InputRecord(); 73 InputRecord();
70 int32_t input_id; 74 int32_t input_id;
71 void* address; 75 void* address;
72 size_t length; 76 size_t length;
73 size_t bytes_used; 77 size_t bytes_used;
74 bool at_device; 78 bool at_device;
75 }; 79 };
76 80
77 // Record for output buffers. 81 // Record for output buffers.
78 struct OutputRecord { 82 struct OutputRecord {
79 OutputRecord(); 83 OutputRecord();
80 bool at_device; 84 bool at_device;
kcwu 2016/03/22 05:42:54 How about merge |at_device| and |at_client| as sin
81 bool at_client; 85 bool at_client;
82 int32_t picture_id; 86 int32_t picture_id;
87 GLuint texture_id;
83 EGLImageKHR egl_image; 88 EGLImageKHR egl_image;
84 EGLSyncKHR egl_sync; 89 EGLSyncKHR egl_sync;
90 std::vector<base::ScopedFD> dmabuf_fds;
85 bool cleared; 91 bool cleared;
86 }; 92 };
87 93
88 // See http://crbug.com/255116. 94 // See http://crbug.com/255116.
89 // Input bitstream buffer size for up to 1080p streams. 95 // Input bitstream buffer size for up to 1080p streams.
90 const size_t kInputBufferMaxSizeFor1080p = 1024 * 1024; 96 const size_t kInputBufferMaxSizeFor1080p = 1024 * 1024;
91 // Input bitstream buffer size for up to 4k streams. 97 // Input bitstream buffer size for up to 4k streams.
92 const size_t kInputBufferMaxSizeFor4k = 4 * kInputBufferMaxSizeFor1080p; 98 const size_t kInputBufferMaxSizeFor4k = 4 * kInputBufferMaxSizeFor1080p;
93 const size_t kNumInputBuffers = 16; 99 const size_t kNumInputBuffers = 16;
94 100
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // To be called if decoder_resetting_ is true. If not all pending frames are 208 // To be called if decoder_resetting_ is true. If not all pending frames are
203 // decoded, return false, requesting the caller to try again later. 209 // decoded, return false, requesting the caller to try again later.
204 // Otherwise perform reset by dropping all pending outputs (client is not 210 // Otherwise perform reset by dropping all pending outputs (client is not
205 // interested anymore), notifying it that reset is finished, and return true, 211 // interested anymore), notifying it that reset is finished, and return true,
206 // informing the caller that further progress can be made. 212 // informing the caller that further progress can be made.
207 bool FinishReset(); 213 bool FinishReset();
208 214
209 // Allocate V4L2 buffers and assign them to |buffers| provided by the client 215 // Allocate V4L2 buffers and assign them to |buffers| provided by the client
210 // via AssignPictureBuffers() on decoder thread. 216 // via AssignPictureBuffers() on decoder thread.
211 void AssignPictureBuffersTask( 217 void AssignPictureBuffersTask(
212 const std::vector<media::PictureBuffer>& buffers); 218 const std::vector<media::PictureBuffer>& buffers);
213 219
214 // Create EGLImages bound to textures in |buffers| for given 220 void ImportBufferForPictureTask(
215 // |output_format_fourcc| and |output_planes_count|. 221 int32_t picture_buffer_id,
216 void CreateEGLImages(const std::vector<media::PictureBuffer>& buffers, 222 // TODO(posciak): (crbug.com/561749) we should normally be able to pass
217 uint32_t output_format_fourcc, 223 // the vector by itself via std::move, but it's not possible to do this
218 size_t output_planes_count); 224 // if this method is used as a callback.
225 scoped_ptr<std::vector<base::ScopedFD>> passed_dmabuf_fds);
219 226
220 // Assign |egl_images| to previously-allocated V4L2 buffers in 227 void CreateEGLImageFor(
221 // output_buffer_map_ and picture ids from |buffers| and finish the surface 228 size_t buffer_index,
222 // change sequence. 229 // TODO(posciak): (crbug.com/561749) we should normally be able to pass
223 void AssignEGLImages(const std::vector<media::PictureBuffer>& buffers, 230 // the vector by itself via std::move, but it's not possible to do this
224 const std::vector<EGLImageKHR>& egl_images); 231 // if this method is used as a callback.
232 scoped_ptr<std::vector<base::ScopedFD>> passed_dmabuf_fds,
233 GLuint texture_id,
234 const gfx::Size& size,
235 uint32_t fourcc);
236
237 void AssignEGLImage(
238 size_t buffer_index,
239 EGLImageKHR egl_image,
240 // TODO(posciak): (crbug.com/561749) we should normally be able to pass
241 // the vector by itself via std::move, but it's not possible to do this
242 // if this method is used as a callback.
243 scoped_ptr<std::vector<base::ScopedFD>> passed_dmabuf_fds);
225 244
226 // Process pending events, if any. 245 // Process pending events, if any.
227 void ProcessPendingEventsIfNeeded(); 246 void ProcessPendingEventsIfNeeded();
228 247
229 // Performed on decoder_thread_ as a consequence of poll() on decoder_thread_ 248 // Performed on decoder_thread_ as a consequence of poll() on decoder_thread_
230 // returning an event. 249 // returning an event.
231 void ServiceDeviceTask(); 250 void ServiceDeviceTask();
232 251
233 // Schedule poll if we have any buffers queued and the poll thread 252 // Schedule poll if we have any buffers queued and the poll thread
234 // is not stopped (on surface set change). 253 // is not stopped (on surface set change).
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // BitstreamBuffer currently being processed. 379 // BitstreamBuffer currently being processed.
361 scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; 380 scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_;
362 381
363 // Queue storing decode surfaces ready to be output as soon as they are 382 // Queue storing decode surfaces ready to be output as soon as they are
364 // decoded. The surfaces must be output in order they are queued. 383 // decoded. The surfaces must be output in order they are queued.
365 std::queue<scoped_refptr<V4L2DecodeSurface>> decoder_display_queue_; 384 std::queue<scoped_refptr<V4L2DecodeSurface>> decoder_display_queue_;
366 385
367 // Decoder state. 386 // Decoder state.
368 State state_; 387 State state_;
369 388
389 Config::OutputMode output_mode_;
390
370 // If any of these are true, we are waiting for the device to finish decoding 391 // If any of these are true, we are waiting for the device to finish decoding
371 // all previously-queued frames, so we can finish the flush/reset/surface 392 // all previously-queued frames, so we can finish the flush/reset/surface
372 // change flows. These can stack. 393 // change flows. These can stack.
373 bool decoder_flushing_; 394 bool decoder_flushing_;
374 bool decoder_resetting_; 395 bool decoder_resetting_;
375 bool surface_set_change_pending_; 396 bool surface_set_change_pending_;
376 397
377 // Hardware accelerators. 398 // Hardware accelerators.
378 // TODO(posciak): Try to have a superclass here if possible. 399 // TODO(posciak): Try to have a superclass here if possible.
379 scoped_ptr<V4L2H264Accelerator> h264_accelerator_; 400 scoped_ptr<V4L2H264Accelerator> h264_accelerator_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 434
414 DISALLOW_COPY_AND_ASSIGN(V4L2SliceVideoDecodeAccelerator); 435 DISALLOW_COPY_AND_ASSIGN(V4L2SliceVideoDecodeAccelerator);
415 }; 436 };
416 437
417 class V4L2H264Picture; 438 class V4L2H264Picture;
418 class V4L2VP8Picture; 439 class V4L2VP8Picture;
419 440
420 } // namespace content 441 } // namespace content
421 442
422 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ 443 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698