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 #include <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <libdrm/drm_fourcc.h> | 8 #include <libdrm/drm_fourcc.h> |
9 #include <linux/videodev2.h> | 9 #include <linux/videodev2.h> |
10 #include <poll.h> | 10 #include <poll.h> |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); | 350 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); |
351 DCHECK_EQ(output_record.picture_id, -1); | 351 DCHECK_EQ(output_record.picture_id, -1); |
352 DCHECK_EQ(output_record.cleared, false); | 352 DCHECK_EQ(output_record.cleared, false); |
353 | 353 |
354 attrs[7] = output_record.fds[0]; | 354 attrs[7] = output_record.fds[0]; |
355 attrs[9] = 0; | 355 attrs[9] = 0; |
356 attrs[11] = frame_buffer_size_.width(); | 356 attrs[11] = frame_buffer_size_.width(); |
357 attrs[13] = output_record.fds[1]; | 357 attrs[13] = output_record.fds[1]; |
358 attrs[15] = 0; | 358 attrs[15] = 0; |
359 attrs[17] = frame_buffer_size_.width(); | 359 attrs[17] = frame_buffer_size_.width(); |
360 | 360 EGLImageKHR egl_image = device_->CreateEGLImage( |
361 EGLImageKHR egl_image = eglCreateImageKHR( | 361 egl_display_, attrs, buffers[i].texture_id(), i); |
362 egl_display_, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attrs); | |
363 if (egl_image == EGL_NO_IMAGE_KHR) { | 362 if (egl_image == EGL_NO_IMAGE_KHR) { |
364 DLOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; | 363 DLOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; |
365 // Ownership of EGLImages allocated in previous iterations of this loop | 364 // Ownership of EGLImages allocated in previous iterations of this loop |
366 // has been transferred to output_buffer_map_. After we error-out here | 365 // has been transferred to output_buffer_map_. After we error-out here |
367 // the destructor will handle their cleanup. | 366 // the destructor will handle their cleanup. |
368 NOTIFY_ERROR(PLATFORM_FAILURE); | 367 NOTIFY_ERROR(PLATFORM_FAILURE); |
369 return; | 368 return; |
370 } | 369 } |
371 | 370 |
372 glBindTexture(GL_TEXTURE_EXTERNAL_OES, buffers[i].texture_id()); | |
373 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); | |
374 | |
375 output_record.egl_image = egl_image; | 371 output_record.egl_image = egl_image; |
376 output_record.picture_id = buffers[i].id(); | 372 output_record.picture_id = buffers[i].id(); |
377 free_output_buffers_.push(i); | 373 free_output_buffers_.push(i); |
378 DVLOG(3) << "AssignPictureBuffers(): buffer[" << i | 374 DVLOG(3) << "AssignPictureBuffers(): buffer[" << i |
379 << "]: picture_id=" << output_record.picture_id; | 375 << "]: picture_id=" << output_record.picture_id; |
380 } | 376 } |
381 | 377 |
382 pictures_assigned_.Signal(); | 378 pictures_assigned_.Signal(); |
383 } | 379 } |
384 | 380 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 const void* data, size_t size, size_t* endpos) { | 703 const void* data, size_t size, size_t* endpos) { |
708 DVLOG(3) << "DecodeBufferInitial(): data=" << data << ", size=" << size; | 704 DVLOG(3) << "DecodeBufferInitial(): data=" << data << ", size=" << size; |
709 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 705 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
710 DCHECK_NE(decoder_state_, kUninitialized); | 706 DCHECK_NE(decoder_state_, kUninitialized); |
711 DCHECK_NE(decoder_state_, kDecoding); | 707 DCHECK_NE(decoder_state_, kDecoding); |
712 DCHECK(!device_poll_thread_.IsRunning()); | 708 DCHECK(!device_poll_thread_.IsRunning()); |
713 // Initial decode. We haven't been able to get output stream format info yet. | 709 // Initial decode. We haven't been able to get output stream format info yet. |
714 // Get it, and start decoding. | 710 // Get it, and start decoding. |
715 | 711 |
716 // Copy in and send to HW. | 712 // Copy in and send to HW. |
717 if (!AppendToInputFrame(data, size)) | 713 if (!AppendToInputFrame(data, size)) |
shivdasp
2014/02/20 08:51:02
I think there is a bug here. Imagine a situation w
Pawel Osciak
2014/02/21 05:36:42
If free_input_buffers_ is empty in ATIF(), then it
shivdasp
2014/02/25 09:38:15
The issue is that we try to Dequeue() only once in
sheu
2014/03/06 08:51:34
I think there's an actual bug here. The reason wh
shivdasp
2014/03/06 11:10:09
I have attempted a fix for this in patchset#7. Cou
| |
718 return false; | 714 return false; |
719 | 715 |
720 // If we only have a partial frame, don't flush and process yet. | 716 // If we only have a partial frame, don't flush and process yet. |
721 if (decoder_partial_frame_pending_) | 717 if (decoder_partial_frame_pending_) |
722 return true; | 718 return true; |
723 | 719 |
724 if (!FlushInputFrame()) | 720 if (!FlushInputFrame()) |
725 return false; | 721 return false; |
726 | 722 |
727 // Recycle buffers. | 723 // Recycle buffers. |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1751 | 1747 |
1752 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " | 1748 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " |
1753 << "buffer_count=" << output_buffer_map_.size() | 1749 << "buffer_count=" << output_buffer_map_.size() |
1754 << ", width=" << frame_buffer_size_.width() | 1750 << ", width=" << frame_buffer_size_.width() |
1755 << ", height=" << frame_buffer_size_.height(); | 1751 << ", height=" << frame_buffer_size_.height(); |
1756 child_message_loop_proxy_->PostTask(FROM_HERE, | 1752 child_message_loop_proxy_->PostTask(FROM_HERE, |
1757 base::Bind(&Client::ProvidePictureBuffers, | 1753 base::Bind(&Client::ProvidePictureBuffers, |
1758 client_, | 1754 client_, |
1759 output_buffer_map_.size(), | 1755 output_buffer_map_.size(), |
1760 frame_buffer_size_, | 1756 frame_buffer_size_, |
1761 GL_TEXTURE_EXTERNAL_OES)); | 1757 device_->GetTextureTarget())); |
1762 | 1758 |
1763 // Wait for the client to call AssignPictureBuffers() on the Child thread. | 1759 // Wait for the client to call AssignPictureBuffers() on the Child thread. |
1764 // We do this, because if we continue decoding without finishing buffer | 1760 // We do this, because if we continue decoding without finishing buffer |
1765 // allocation, we may end up Resetting before AssignPictureBuffers arrives, | 1761 // allocation, we may end up Resetting before AssignPictureBuffers arrives, |
1766 // resulting in unnecessary complications and subtle bugs. | 1762 // resulting in unnecessary complications and subtle bugs. |
1767 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) | 1763 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) |
1768 // in a sequence, and Decode(Input1) results in us getting here and exiting | 1764 // in a sequence, and Decode(Input1) results in us getting here and exiting |
1769 // without waiting, we might end up running Reset{,Done}Task() before | 1765 // without waiting, we might end up running Reset{,Done}Task() before |
1770 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers | 1766 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers |
1771 // to the free_output_buffers_ map twice. If we somehow marked buffers as | 1767 // to the free_output_buffers_ map twice. If we somehow marked buffers as |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1919 | 1915 |
1920 void V4L2VideoDecodeAccelerator::PictureCleared() { | 1916 void V4L2VideoDecodeAccelerator::PictureCleared() { |
1921 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; | 1917 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; |
1922 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 1918 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
1923 DCHECK_GT(picture_clearing_count_, 0); | 1919 DCHECK_GT(picture_clearing_count_, 0); |
1924 picture_clearing_count_--; | 1920 picture_clearing_count_--; |
1925 SendPictureReady(); | 1921 SendPictureReady(); |
1926 } | 1922 } |
1927 | 1923 |
1928 } // namespace content | 1924 } // namespace content |
OLD | NEW |