Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 VideoDecoderAccelerator | 5 // This file contains an implementation of VideoDecoderAccelerator |
| 6 // that utilizes the hardware video decoder present on the Exynos SoC. | 6 // that utilizes the hardware video decoder present on the Exynos SoC. |
| 7 | 7 |
| 8 #ifndef CONTENT_COMMON_GPU_MEDIA_EXYNOS_VIDEO_DECODE_ACCELERATOR_H_ | 8 #ifndef CONTENT_COMMON_GPU_MEDIA_EXYNOS_VIDEO_DECODE_ACCELERATOR_H_ |
| 9 #define CONTENT_COMMON_GPU_MEDIA_EXYNOS_VIDEO_DECODE_ACCELERATOR_H_ | 9 #define CONTENT_COMMON_GPU_MEDIA_EXYNOS_VIDEO_DECODE_ACCELERATOR_H_ |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/gpu/media/video_decode_accelerator_impl.h" | 19 #include "content/common/gpu/media/video_decode_accelerator_impl.h" |
| 20 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
| 21 #include "media/base/video_decoder_config.h" | 21 #include "media/base/video_decoder_config.h" |
| 22 #include "media/video/picture.h" | |
| 22 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
| 23 #include "ui/gl/gl_bindings.h" | 24 #include "ui/gl/gl_bindings.h" |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class MessageLoopProxy; | 27 class MessageLoopProxy; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 class H264Parser; | 31 class H264Parser; |
| 31 | 32 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 // Decode() to DecodeTask(). | 130 // Decode() to DecodeTask(). |
| 130 struct BitstreamBufferRef; | 131 struct BitstreamBufferRef; |
| 131 | 132 |
| 132 // Auto-destruction reference for an array of PictureBuffer, for | 133 // Auto-destruction reference for an array of PictureBuffer, for |
| 133 // message-passing from AssignPictureBuffers() to AssignPictureBuffersTask(). | 134 // message-passing from AssignPictureBuffers() to AssignPictureBuffersTask(). |
| 134 struct PictureBufferArrayRef; | 135 struct PictureBufferArrayRef; |
| 135 | 136 |
| 136 // Auto-destruction reference for EGLSync (for message-passing). | 137 // Auto-destruction reference for EGLSync (for message-passing). |
| 137 struct EGLSyncKHRRef; | 138 struct EGLSyncKHRRef; |
| 138 | 139 |
| 140 // Record for decoded pictures that can be sent to PictureReady. | |
| 141 struct PictureRecord; | |
| 142 | |
| 139 // Record for MFC input buffers. | 143 // Record for MFC input buffers. |
| 140 struct MfcInputRecord { | 144 struct MfcInputRecord { |
| 141 MfcInputRecord(); | 145 MfcInputRecord(); |
| 142 ~MfcInputRecord(); | 146 ~MfcInputRecord(); |
| 143 bool at_device; // held by device. | 147 bool at_device; // held by device. |
| 144 void* address; // mmap() address. | 148 void* address; // mmap() address. |
| 145 size_t length; // mmap() length. | 149 size_t length; // mmap() length. |
| 146 off_t bytes_used; // bytes filled in the mmap() segment. | 150 off_t bytes_used; // bytes filled in the mmap() segment. |
| 147 int32 input_id; // triggering input_id as given to Decode(). | 151 int32 input_id; // triggering input_id as given to Decode(). |
| 148 }; | 152 }; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 170 // Record for GSC output buffers. | 174 // Record for GSC output buffers. |
| 171 struct GscOutputRecord { | 175 struct GscOutputRecord { |
| 172 GscOutputRecord(); | 176 GscOutputRecord(); |
| 173 ~GscOutputRecord(); | 177 ~GscOutputRecord(); |
| 174 bool at_device; // held by device. | 178 bool at_device; // held by device. |
| 175 bool at_client; // held by client. | 179 bool at_client; // held by client. |
| 176 int fd; // file descriptor from backing EGLImage. | 180 int fd; // file descriptor from backing EGLImage. |
| 177 EGLImageKHR egl_image; // backing EGLImage. | 181 EGLImageKHR egl_image; // backing EGLImage. |
| 178 EGLSyncKHR egl_sync; // sync the compositor's use of the EGLImage. | 182 EGLSyncKHR egl_sync; // sync the compositor's use of the EGLImage. |
| 179 int32 picture_id; // picture buffer id as returned to PictureReady(). | 183 int32 picture_id; // picture buffer id as returned to PictureReady(). |
| 184 bool cleared; // whether the texture has been cleared | |
|
Pawel Osciak
2013/10/01 07:45:34
I guess everyone here is familiar with what "clear
wuchengli
2013/10/01 13:54:50
Done.
| |
| 180 }; | 185 }; |
| 181 | 186 |
| 182 // | 187 // |
| 183 // Decoding tasks, to be run on decode_thread_. | 188 // Decoding tasks, to be run on decode_thread_. |
| 184 // | 189 // |
| 185 | 190 |
| 186 // Enqueue a BitstreamBuffer to decode. This will enqueue a buffer to the | 191 // Enqueue a BitstreamBuffer to decode. This will enqueue a buffer to the |
| 187 // decoder_input_queue_, then queue a DecodeBufferTask() to actually decode | 192 // decoder_input_queue_, then queue a DecodeBufferTask() to actually decode |
| 188 // the buffer. | 193 // the buffer. |
| 189 void DecodeTask(const media::BitstreamBuffer& bitstream_buffer); | 194 void DecodeTask(const media::BitstreamBuffer& bitstream_buffer); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 // Methods run on child thread. | 314 // Methods run on child thread. |
| 310 // | 315 // |
| 311 | 316 |
| 312 // Destroy buffers. | 317 // Destroy buffers. |
| 313 void DestroyMfcInputBuffers(); | 318 void DestroyMfcInputBuffers(); |
| 314 void DestroyMfcOutputBuffers(); | 319 void DestroyMfcOutputBuffers(); |
| 315 void DestroyGscInputBuffers(); | 320 void DestroyGscInputBuffers(); |
| 316 void DestroyGscOutputBuffers(); | 321 void DestroyGscOutputBuffers(); |
| 317 void ResolutionChangeDestroyBuffers(); | 322 void ResolutionChangeDestroyBuffers(); |
| 318 | 323 |
| 324 // Send decoded pictures to PictureReady. | |
| 325 void SendPictureReady(); | |
| 326 | |
| 327 // Callback that indicates a picture has been cleared. | |
| 328 void PictureCleared(); | |
| 329 | |
| 319 // Our original calling message loop for the child thread. | 330 // Our original calling message loop for the child thread. |
| 320 scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; | 331 scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; |
| 321 | 332 |
| 322 // Message loop of the IO thread. | 333 // Message loop of the IO thread. |
| 323 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 334 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 324 | 335 |
| 325 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or | 336 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or |
| 326 // device worker threads back to the child thread. Because the worker threads | 337 // device worker threads back to the child thread. Because the worker threads |
| 327 // are members of this class, any task running on those threads is guaranteed | 338 // are members of this class, any task running on those threads is guaranteed |
| 328 // that this object is still alive. As a result, tasks posted from the child | 339 // that this object is still alive. As a result, tasks posted from the child |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 | 441 |
| 431 // GSC output buffer state. | 442 // GSC output buffer state. |
| 432 bool gsc_output_streamon_; | 443 bool gsc_output_streamon_; |
| 433 // GSC output buffers enqueued to device. | 444 // GSC output buffers enqueued to device. |
| 434 int gsc_output_buffer_queued_count_; | 445 int gsc_output_buffer_queued_count_; |
| 435 // Output buffers ready to use. We need a FIFO here. | 446 // Output buffers ready to use. We need a FIFO here. |
| 436 std::list<int> gsc_free_output_buffers_; | 447 std::list<int> gsc_free_output_buffers_; |
| 437 // Mapping of int index to GSC output buffer record. | 448 // Mapping of int index to GSC output buffer record. |
| 438 std::vector<GscOutputRecord> gsc_output_buffer_map_; | 449 std::vector<GscOutputRecord> gsc_output_buffer_map_; |
| 439 | 450 |
| 451 // Pictures that are ready but not sent to PictureReady yet. | |
| 452 std::queue<PictureRecord> pending_picture_ready_; | |
| 453 | |
| 454 // The number of pictures that are sent to PictureReady and will be cleared. | |
| 455 int picture_clearing_count_; | |
| 456 | |
| 440 // Output picture size. | 457 // Output picture size. |
| 441 gfx::Size frame_buffer_size_; | 458 gfx::Size frame_buffer_size_; |
| 442 | 459 |
| 443 // | 460 // |
| 444 // The device polling thread handles notifications of V4L2 device changes. | 461 // The device polling thread handles notifications of V4L2 device changes. |
| 445 // | 462 // |
| 446 | 463 |
| 447 // The thread. | 464 // The thread. |
| 448 base::Thread device_poll_thread_; | 465 base::Thread device_poll_thread_; |
| 449 // eventfd fd to signal device poll thread when its poll() should be | 466 // eventfd fd to signal device poll thread when its poll() should be |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 463 | 480 |
| 464 // The codec we'll be decoding for. | 481 // The codec we'll be decoding for. |
| 465 media::VideoCodecProfile video_profile_; | 482 media::VideoCodecProfile video_profile_; |
| 466 | 483 |
| 467 DISALLOW_COPY_AND_ASSIGN(ExynosVideoDecodeAccelerator); | 484 DISALLOW_COPY_AND_ASSIGN(ExynosVideoDecodeAccelerator); |
| 468 }; | 485 }; |
| 469 | 486 |
| 470 } // namespace content | 487 } // namespace content |
| 471 | 488 |
| 472 #endif // CONTENT_COMMON_GPU_MEDIA_EXYNOS_VIDEO_DECODE_ACCELERATOR_H_ | 489 #endif // CONTENT_COMMON_GPU_MEDIA_EXYNOS_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |