OLD | NEW |
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 MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 9 #ifndef MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
10 #define MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 10 #define MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 std::unique_ptr<EGLSyncKHRRef> egl_sync_ref); | 283 std::unique_ptr<EGLSyncKHRRef> egl_sync_ref); |
284 | 284 |
285 // Flush() task. Child thread should not submit any more buffers until it | 285 // Flush() task. Child thread should not submit any more buffers until it |
286 // receives the NotifyFlushDone callback. This task will schedule an empty | 286 // receives the NotifyFlushDone callback. This task will schedule an empty |
287 // BitstreamBufferRef (with input_id == kFlushBufferId) to perform the flush. | 287 // BitstreamBufferRef (with input_id == kFlushBufferId) to perform the flush. |
288 void FlushTask(); | 288 void FlushTask(); |
289 // Notify the client of a flush completion, if required. This should be | 289 // Notify the client of a flush completion, if required. This should be |
290 // called any time a relevant queue could potentially be emptied: see | 290 // called any time a relevant queue could potentially be emptied: see |
291 // function definition. | 291 // function definition. |
292 void NotifyFlushDoneIfNeeded(); | 292 void NotifyFlushDoneIfNeeded(); |
| 293 // Returns true if VIDIOC_DECODER_CMD is supported. |
| 294 bool IsDecoderCmdSupported(); |
| 295 // Send V4L2_DEC_CMD_START to the driver. Return true if success. |
| 296 bool SendDecoderCmdStop(); |
293 | 297 |
294 // Reset() task. Drop all input buffers. If V4L2VDA is not doing resolution | 298 // Reset() task. Drop all input buffers. If V4L2VDA is not doing resolution |
295 // change or waiting picture buffers, call FinishReset. | 299 // change or waiting picture buffers, call FinishReset. |
296 void ResetTask(); | 300 void ResetTask(); |
297 // This will schedule a ResetDoneTask() that will send the NotifyResetDone | 301 // This will schedule a ResetDoneTask() that will send the NotifyResetDone |
298 // callback, then set the decoder state to kResetting so that all intervening | 302 // callback, then set the decoder state to kResetting so that all intervening |
299 // tasks will drain. | 303 // tasks will drain. |
300 void FinishReset(); | 304 void FinishReset(); |
301 void ResetDoneTask(); | 305 void ResetDoneTask(); |
302 | 306 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 // delay these buffers until after the flush or reset completes. | 446 // delay these buffers until after the flush or reset completes. |
443 int decoder_delay_bitstream_buffer_id_; | 447 int decoder_delay_bitstream_buffer_id_; |
444 // Input buffer we're presently filling. | 448 // Input buffer we're presently filling. |
445 int decoder_current_input_buffer_; | 449 int decoder_current_input_buffer_; |
446 // We track the number of buffer decode tasks we have scheduled, since each | 450 // We track the number of buffer decode tasks we have scheduled, since each |
447 // task execution should complete one buffer. If we fall behind (due to | 451 // task execution should complete one buffer. If we fall behind (due to |
448 // resource backpressure, etc.), we'll have to schedule more to catch up. | 452 // resource backpressure, etc.), we'll have to schedule more to catch up. |
449 int decoder_decode_buffer_tasks_scheduled_; | 453 int decoder_decode_buffer_tasks_scheduled_; |
450 // Picture buffers held by the client. | 454 // Picture buffers held by the client. |
451 int decoder_frames_at_client_; | 455 int decoder_frames_at_client_; |
| 456 |
452 // Are we flushing? | 457 // Are we flushing? |
453 bool decoder_flushing_; | 458 bool decoder_flushing_; |
| 459 // True if VIDIOC_DECODER_CMD is supported. |
| 460 bool decoder_cmd_supported_; |
| 461 // True if flushing is waiting for last output buffer. After |
| 462 // VIDIOC_DECODER_CMD is sent to the driver, this flag will be set to true to |
| 463 // wait for the last output buffer. When this flag is true, flush done will |
| 464 // not be sent. After an output buffer that has the flag V4L2_BUF_FLAG_LAST is |
| 465 // received, this is set to false. |
| 466 bool flush_awaiting_last_output_buffer_; |
| 467 |
454 // Got a reset request while we were performing resolution change or waiting | 468 // Got a reset request while we were performing resolution change or waiting |
455 // picture buffers. | 469 // picture buffers. |
456 bool reset_pending_; | 470 bool reset_pending_; |
457 // Input queue for decoder_thread_: BitstreamBuffers in. | 471 // Input queue for decoder_thread_: BitstreamBuffers in. |
458 std::queue<linked_ptr<BitstreamBufferRef>> decoder_input_queue_; | 472 std::queue<linked_ptr<BitstreamBufferRef>> decoder_input_queue_; |
459 // For H264 decode, hardware requires that we send it frame-sized chunks. | 473 // For H264 decode, hardware requires that we send it frame-sized chunks. |
460 // We'll need to parse the stream. | 474 // We'll need to parse the stream. |
461 std::unique_ptr<H264Parser> decoder_h264_parser_; | 475 std::unique_ptr<H264Parser> decoder_h264_parser_; |
462 // Set if the decoder has a pending incomplete frame in an input buffer. | 476 // Set if the decoder has a pending incomplete frame in an input buffer. |
463 bool decoder_partial_frame_pending_; | 477 bool decoder_partial_frame_pending_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 572 |
559 // The WeakPtrFactory for |weak_this_|. | 573 // The WeakPtrFactory for |weak_this_|. |
560 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_; | 574 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_; |
561 | 575 |
562 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); | 576 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); |
563 }; | 577 }; |
564 | 578 |
565 } // namespace media | 579 } // namespace media |
566 | 580 |
567 #endif // MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 581 #endif // MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |