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

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

Issue 137023008: Add support for Tegra V4L2 VDA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor nit Created 6 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
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 // This file contains an implementation of VideoDecodeAccelerator 5 // This file contains an implementation of VideoDecodeAccelerator
6 // that utilizes hardware video decoders, which expose Video4Linux 2 API 6 // that utilizes hardware video decoders, which expose Video4Linux 2 API
7 // (http://linuxtv.org/downloads/v4l-dvb-apis/). 7 // (http://linuxtv.org/downloads/v4l-dvb-apis/).
8 8
9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 9 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_
10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 10 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 off_t bytes_used; // bytes filled in the mmap() segment. 148 off_t bytes_used; // bytes filled in the mmap() segment.
149 int32 input_id; // triggering input_id as given to Decode(). 149 int32 input_id; // triggering input_id as given to Decode().
150 }; 150 };
151 151
152 // Record for output buffers. 152 // Record for output buffers.
153 struct OutputRecord { 153 struct OutputRecord {
154 OutputRecord(); 154 OutputRecord();
155 ~OutputRecord(); 155 ~OutputRecord();
156 bool at_device; // held by device. 156 bool at_device; // held by device.
157 bool at_client; // held by client. 157 bool at_client; // held by client.
158 int fds[2]; // file descriptors for each plane.
159 EGLImageKHR egl_image; // EGLImageKHR for the output buffer. 158 EGLImageKHR egl_image; // EGLImageKHR for the output buffer.
160 EGLSyncKHR egl_sync; // sync the compositor's use of the EGLImage. 159 EGLSyncKHR egl_sync; // sync the compositor's use of the EGLImage.
161 int32 picture_id; // picture buffer id as returned to PictureReady(). 160 int32 picture_id; // picture buffer id as returned to PictureReady().
162 bool cleared; // Whether the texture is cleared and safe to render 161 bool cleared; // Whether the texture is cleared and safe to render
163 // from. See TextureManager for details. 162 // from. See TextureManager for details.
164 }; 163 };
165 164
166 // 165 //
167 // Decoding tasks, to be run on decode_thread_. 166 // Decoding tasks, to be run on decode_thread_.
168 // 167 //
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // caller can error out on resolution change. 286 // caller can error out on resolution change.
288 bool DestroyOutputBuffers(); 287 bool DestroyOutputBuffers();
289 void ResolutionChangeDestroyBuffers(); 288 void ResolutionChangeDestroyBuffers();
290 289
291 // Send decoded pictures to PictureReady. 290 // Send decoded pictures to PictureReady.
292 void SendPictureReady(); 291 void SendPictureReady();
293 292
294 // Callback that indicates a picture has been cleared. 293 // Callback that indicates a picture has been cleared.
295 void PictureCleared(); 294 void PictureCleared();
296 295
296 // This method determines whether a resolution change event processing
297 // is indeed required by returning true iff:
298 // - width or height of the new format is different than previous format; or
299 // - V4L2_CID_MIN_BUFFERS_FOR_CAPTURE has changed.
300 bool IsResolutionChangeNecessary();
301
297 // Our original calling message loop for the child thread. 302 // Our original calling message loop for the child thread.
298 scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; 303 scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_;
299 304
300 // Message loop of the IO thread. 305 // Message loop of the IO thread.
301 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 306 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
302 307
303 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or 308 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or
304 // device worker threads back to the child thread. Because the worker threads 309 // device worker threads back to the child thread. Because the worker threads
305 // are members of this class, any task running on those threads is guaranteed 310 // are members of this class, any task running on those threads is guaranteed
306 // that this object is still alive. As a result, tasks posted from the child 311 // that this object is still alive. As a result, tasks posted from the child
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 std::queue<linked_ptr<BitstreamBufferRef> > decoder_input_queue_; 360 std::queue<linked_ptr<BitstreamBufferRef> > decoder_input_queue_;
356 // For H264 decode, hardware requires that we send it frame-sized chunks. 361 // For H264 decode, hardware requires that we send it frame-sized chunks.
357 // We'll need to parse the stream. 362 // We'll need to parse the stream.
358 scoped_ptr<media::H264Parser> decoder_h264_parser_; 363 scoped_ptr<media::H264Parser> decoder_h264_parser_;
359 // Set if the decoder has a pending incomplete frame in an input buffer. 364 // Set if the decoder has a pending incomplete frame in an input buffer.
360 bool decoder_partial_frame_pending_; 365 bool decoder_partial_frame_pending_;
361 366
362 // 367 //
363 // Hardware state and associated queues. Since decoder_thread_ services 368 // Hardware state and associated queues. Since decoder_thread_ services
364 // the hardware, decoder_thread_ owns these too. 369 // the hardware, decoder_thread_ owns these too.
365 // output_buffer_map_ and free_output_buffers_ are an exception during the 370 // output_buffer_map_, free_output_buffers_ and output_planes_count_ are an
366 // buffer (re)allocation sequence, when the decoder_thread_ is blocked briefly 371 // exception during the buffer (re)allocation sequence, when the
367 // while the Child thread manipulates them. 372 // decoder_thread_ is blocked briefly while the Child thread manipulates
373 // them.
368 // 374 //
369 375
370 // Completed decode buffers. 376 // Completed decode buffers.
371 std::queue<int> input_ready_queue_; 377 std::queue<int> input_ready_queue_;
372 378
373 // Input buffer state. 379 // Input buffer state.
374 bool input_streamon_; 380 bool input_streamon_;
375 // Input buffers enqueued to device. 381 // Input buffers enqueued to device.
376 int input_buffer_queued_count_; 382 int input_buffer_queued_count_;
377 // Input buffers ready to use, as a LIFO since we don't care about ordering. 383 // Input buffers ready to use, as a LIFO since we don't care about ordering.
378 std::vector<int> free_input_buffers_; 384 std::vector<int> free_input_buffers_;
379 // Mapping of int index to input buffer record. 385 // Mapping of int index to input buffer record.
380 std::vector<InputRecord> input_buffer_map_; 386 std::vector<InputRecord> input_buffer_map_;
381 387
382 // Output buffer state. 388 // Output buffer state.
383 bool output_streamon_; 389 bool output_streamon_;
384 // Output buffers enqueued to device. 390 // Output buffers enqueued to device.
385 int output_buffer_queued_count_; 391 int output_buffer_queued_count_;
386 // Output buffers ready to use, as a FIFO since we want oldest-first to hide 392 // Output buffers ready to use, as a FIFO since we want oldest-first to hide
387 // synchronization latency with GL. 393 // synchronization latency with GL.
388 std::queue<int> free_output_buffers_; 394 std::queue<int> free_output_buffers_;
389 // Mapping of int index to output buffer record. 395 // Mapping of int index to output buffer record.
390 std::vector<OutputRecord> output_buffer_map_; 396 std::vector<OutputRecord> output_buffer_map_;
391 // Output pixel format. 397 // Output pixel format.
392 uint32 output_buffer_pixelformat_; 398 uint32 output_buffer_pixelformat_;
393 // Required size of DPB for decoding. 399 // Required size of DPB for decoding.
394 int output_dpb_size_; 400 int output_dpb_size_;
401 // Stores the number of planes (i.e. separate memory buffers) for output.
402 size_t output_planes_count_;
395 403
396 // Pictures that are ready but not sent to PictureReady yet. 404 // Pictures that are ready but not sent to PictureReady yet.
397 std::queue<PictureRecord> pending_picture_ready_; 405 std::queue<PictureRecord> pending_picture_ready_;
398 406
399 // The number of pictures that are sent to PictureReady and will be cleared. 407 // The number of pictures that are sent to PictureReady and will be cleared.
400 int picture_clearing_count_; 408 int picture_clearing_count_;
401 409
402 // Used by the decoder thread to wait for AssignPictureBuffers to arrive 410 // Used by the decoder thread to wait for AssignPictureBuffers to arrive
403 // to avoid races with potential Reset requests. 411 // to avoid races with potential Reset requests.
404 base::WaitableEvent pictures_assigned_; 412 base::WaitableEvent pictures_assigned_;
(...skipping 20 matching lines...) Expand all
425 433
426 // The codec we'll be decoding for. 434 // The codec we'll be decoding for.
427 media::VideoCodecProfile video_profile_; 435 media::VideoCodecProfile video_profile_;
428 436
429 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); 437 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator);
430 }; 438 };
431 439
432 } // namespace content 440 } // namespace content
433 441
434 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 442 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/tegra_v4l2_video_device.cc ('k') | content/common/gpu/media/v4l2_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698