Chromium Code Reviews| 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 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 Loading... | |
| 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 Loading... | |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_ and free_output_buffers_ are an exception during the |
| 366 // buffer (re)allocation sequence, when the decoder_thread_ is blocked briefly | 371 // buffer (re)allocation sequence, when the decoder_thread_ is blocked briefly |
| 367 // while the Child thread manipulates them. | 372 // while the Child thread manipulates them. |
|
Ami GONE FROM CHROMIUM
2014/03/28 19:33:40
This comment is talking about vars that are normal
shivdasp
2014/03/28 20:39:26
Done.
| |
| 368 // | 373 // |
| 369 | 374 |
| 370 // Completed decode buffers. | 375 // Completed decode buffers. |
| 371 std::queue<int> input_ready_queue_; | 376 std::queue<int> input_ready_queue_; |
| 372 | 377 |
| 373 // Input buffer state. | 378 // Input buffer state. |
| 374 bool input_streamon_; | 379 bool input_streamon_; |
| 375 // Input buffers enqueued to device. | 380 // Input buffers enqueued to device. |
| 376 int input_buffer_queued_count_; | 381 int input_buffer_queued_count_; |
| 377 // Input buffers ready to use, as a LIFO since we don't care about ordering. | 382 // Input buffers ready to use, as a LIFO since we don't care about ordering. |
| 378 std::vector<int> free_input_buffers_; | 383 std::vector<int> free_input_buffers_; |
| 379 // Mapping of int index to input buffer record. | 384 // Mapping of int index to input buffer record. |
| 380 std::vector<InputRecord> input_buffer_map_; | 385 std::vector<InputRecord> input_buffer_map_; |
| 381 | 386 |
| 382 // Output buffer state. | 387 // Output buffer state. |
| 383 bool output_streamon_; | 388 bool output_streamon_; |
| 384 // Output buffers enqueued to device. | 389 // Output buffers enqueued to device. |
| 385 int output_buffer_queued_count_; | 390 int output_buffer_queued_count_; |
| 386 // Output buffers ready to use, as a FIFO since we want oldest-first to hide | 391 // Output buffers ready to use, as a FIFO since we want oldest-first to hide |
| 387 // synchronization latency with GL. | 392 // synchronization latency with GL. |
| 388 std::queue<int> free_output_buffers_; | 393 std::queue<int> free_output_buffers_; |
| 389 // Mapping of int index to output buffer record. | 394 // Mapping of int index to output buffer record. |
| 390 std::vector<OutputRecord> output_buffer_map_; | 395 std::vector<OutputRecord> output_buffer_map_; |
| 391 // Output pixel format. | 396 // Output pixel format. |
| 392 uint32 output_buffer_pixelformat_; | 397 uint32 output_buffer_pixelformat_; |
| 393 // Required size of DPB for decoding. | 398 // Required size of DPB for decoding. |
| 394 int output_dpb_size_; | 399 int output_dpb_size_; |
| 400 // Stores the number of planes (i.e. separate memory buffers) for output. | |
| 401 size_t output_planes_count_; | |
| 395 | 402 |
| 396 // Pictures that are ready but not sent to PictureReady yet. | 403 // Pictures that are ready but not sent to PictureReady yet. |
| 397 std::queue<PictureRecord> pending_picture_ready_; | 404 std::queue<PictureRecord> pending_picture_ready_; |
| 398 | 405 |
| 399 // The number of pictures that are sent to PictureReady and will be cleared. | 406 // The number of pictures that are sent to PictureReady and will be cleared. |
| 400 int picture_clearing_count_; | 407 int picture_clearing_count_; |
| 401 | 408 |
| 402 // Used by the decoder thread to wait for AssignPictureBuffers to arrive | 409 // Used by the decoder thread to wait for AssignPictureBuffers to arrive |
| 403 // to avoid races with potential Reset requests. | 410 // to avoid races with potential Reset requests. |
| 404 base::WaitableEvent pictures_assigned_; | 411 base::WaitableEvent pictures_assigned_; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 425 | 432 |
| 426 // The codec we'll be decoding for. | 433 // The codec we'll be decoding for. |
| 427 media::VideoCodecProfile video_profile_; | 434 media::VideoCodecProfile video_profile_; |
| 428 | 435 |
| 429 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); | 436 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); |
| 430 }; | 437 }; |
| 431 | 438 |
| 432 } // namespace content | 439 } // namespace content |
| 433 | 440 |
| 434 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ | 441 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |