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 #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> | |
| 9 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
| 10 #include <poll.h> | 9 #include <poll.h> |
| 11 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
| 12 #include <sys/ioctl.h> | 11 #include <sys/ioctl.h> |
| 13 #include <sys/mman.h> | 12 #include <sys/mman.h> |
| 14 | 13 |
| 15 #include "base/bind.h" | 14 #include "base/bind.h" |
| 16 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
| 17 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
| 18 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 return false; | 259 return false; |
| 261 } | 260 } |
| 262 | 261 |
| 263 if (!CreateInputBuffers()) | 262 if (!CreateInputBuffers()) |
| 264 return false; | 263 return false; |
| 265 | 264 |
| 266 // Output format has to be setup before streaming starts. | 265 // Output format has to be setup before streaming starts. |
| 267 struct v4l2_format format; | 266 struct v4l2_format format; |
| 268 memset(&format, 0, sizeof(format)); | 267 memset(&format, 0, sizeof(format)); |
| 269 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 268 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 270 format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12M; | 269 format.fmt.pix_mp.pixelformat = device_->GetCapturePixelFormat(); |
| 271 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format); | 270 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format); |
| 272 | 271 |
| 273 // Subscribe to the resolution change event. | 272 // Subscribe to the resolution change event. |
| 274 struct v4l2_event_subscription sub; | 273 struct v4l2_event_subscription sub; |
| 275 memset(&sub, 0, sizeof(sub)); | 274 memset(&sub, 0, sizeof(sub)); |
| 276 sub.type = V4L2_EVENT_RESOLUTION_CHANGE; | 275 sub.type = V4L2_EVENT_RESOLUTION_CHANGE; |
| 277 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_SUBSCRIBE_EVENT, &sub); | 276 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_SUBSCRIBE_EVENT, &sub); |
| 278 | 277 |
| 279 // Initialize format-specific bits. | 278 // Initialize format-specific bits. |
| 280 if (video_profile_ >= media::H264PROFILE_MIN && | 279 if (video_profile_ >= media::H264PROFILE_MIN && |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 return; | 322 return; |
| 324 } | 323 } |
| 325 | 324 |
| 326 if (!make_context_current_.Run()) { | 325 if (!make_context_current_.Run()) { |
| 327 DLOG(ERROR) << "AssignPictureBuffers(): could not make context current"; | 326 DLOG(ERROR) << "AssignPictureBuffers(): could not make context current"; |
| 328 NOTIFY_ERROR(PLATFORM_FAILURE); | 327 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 329 return; | 328 return; |
| 330 } | 329 } |
| 331 | 330 |
| 332 gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0); | 331 gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0); |
| 333 EGLint attrs[] = { | |
| 334 EGL_WIDTH, 0, EGL_HEIGHT, 0, | |
| 335 EGL_LINUX_DRM_FOURCC_EXT, 0, EGL_DMA_BUF_PLANE0_FD_EXT, 0, | |
| 336 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, 0, | |
| 337 EGL_DMA_BUF_PLANE1_FD_EXT, 0, EGL_DMA_BUF_PLANE1_OFFSET_EXT, 0, | |
| 338 EGL_DMA_BUF_PLANE1_PITCH_EXT, 0, EGL_NONE, }; | |
| 339 attrs[1] = frame_buffer_size_.width(); | |
| 340 attrs[3] = frame_buffer_size_.height(); | |
| 341 attrs[5] = DRM_FORMAT_NV12; | |
| 342 | 332 |
| 343 // It's safe to manipulate all the buffer state here, because the decoder | 333 // It's safe to manipulate all the buffer state here, because the decoder |
| 344 // thread is waiting on pictures_assigned_. | 334 // thread is waiting on pictures_assigned_. |
| 345 DCHECK(free_output_buffers_.empty()); | 335 DCHECK(free_output_buffers_.empty()); |
| 346 for (size_t i = 0; i < output_buffer_map_.size(); ++i) { | 336 for (size_t i = 0; i < output_buffer_map_.size(); ++i) { |
| 347 DCHECK(buffers[i].size() == frame_buffer_size_); | 337 DCHECK(buffers[i].size() == frame_buffer_size_); |
| 348 | 338 |
| 349 OutputRecord& output_record = output_buffer_map_[i]; | 339 OutputRecord& output_record = output_buffer_map_[i]; |
| 350 DCHECK(!output_record.at_device); | 340 DCHECK(!output_record.at_device); |
| 351 DCHECK(!output_record.at_client); | 341 DCHECK(!output_record.at_client); |
| 352 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR); | 342 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR); |
| 353 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); | 343 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); |
| 354 DCHECK_EQ(output_record.picture_id, -1); | 344 DCHECK_EQ(output_record.picture_id, -1); |
| 355 DCHECK_EQ(output_record.cleared, false); | 345 DCHECK_EQ(output_record.cleared, false); |
| 356 | 346 |
| 357 attrs[7] = output_record.fds[0]; | 347 EGLImageKHR egl_image = device_->CreateEGLImage(egl_display_, |
| 358 attrs[9] = 0; | 348 buffers[i].texture_id(), |
| 359 attrs[11] = frame_buffer_size_.width(); | 349 frame_buffer_size_, |
| 360 attrs[13] = output_record.fds[1]; | 350 i, |
| 361 attrs[15] = 0; | 351 output_buffer_map_.size()); |
| 362 attrs[17] = frame_buffer_size_.width(); | |
| 363 | |
| 364 EGLImageKHR egl_image = eglCreateImageKHR( | |
| 365 egl_display_, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attrs); | |
| 366 if (egl_image == EGL_NO_IMAGE_KHR) { | 352 if (egl_image == EGL_NO_IMAGE_KHR) { |
| 367 DLOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; | 353 DLOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; |
| 368 // Ownership of EGLImages allocated in previous iterations of this loop | 354 // Ownership of EGLImages allocated in previous iterations of this loop |
| 369 // has been transferred to output_buffer_map_. After we error-out here | 355 // has been transferred to output_buffer_map_. After we error-out here |
| 370 // the destructor will handle their cleanup. | 356 // the destructor will handle their cleanup. |
| 371 NOTIFY_ERROR(PLATFORM_FAILURE); | 357 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 372 return; | 358 return; |
| 373 } | 359 } |
| 374 | 360 |
| 375 glBindTexture(GL_TEXTURE_EXTERNAL_OES, buffers[i].texture_id()); | |
| 376 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); | |
| 377 | |
| 378 output_record.egl_image = egl_image; | 361 output_record.egl_image = egl_image; |
| 379 output_record.picture_id = buffers[i].id(); | 362 output_record.picture_id = buffers[i].id(); |
| 380 free_output_buffers_.push(i); | 363 free_output_buffers_.push(i); |
| 381 DVLOG(3) << "AssignPictureBuffers(): buffer[" << i | 364 DVLOG(3) << "AssignPictureBuffers(): buffer[" << i |
| 382 << "]: picture_id=" << output_record.picture_id; | 365 << "]: picture_id=" << output_record.picture_id; |
| 383 } | 366 } |
| 384 | 367 |
| 385 pictures_assigned_.Signal(); | 368 pictures_assigned_.Signal(); |
| 386 } | 369 } |
| 387 | 370 |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 DCHECK_NE(decoder_state_, kUninitialized); | 981 DCHECK_NE(decoder_state_, kUninitialized); |
| 999 DVLOG(3) << "DequeueEvents()"; | 982 DVLOG(3) << "DequeueEvents()"; |
| 1000 | 983 |
| 1001 struct v4l2_event ev; | 984 struct v4l2_event ev; |
| 1002 memset(&ev, 0, sizeof(ev)); | 985 memset(&ev, 0, sizeof(ev)); |
| 1003 | 986 |
| 1004 while (device_->Ioctl(VIDIOC_DQEVENT, &ev) == 0) { | 987 while (device_->Ioctl(VIDIOC_DQEVENT, &ev) == 0) { |
| 1005 if (ev.type == V4L2_EVENT_RESOLUTION_CHANGE) { | 988 if (ev.type == V4L2_EVENT_RESOLUTION_CHANGE) { |
| 1006 DVLOG(3) << "DequeueEvents(): got resolution change event."; | 989 DVLOG(3) << "DequeueEvents(): got resolution change event."; |
| 1007 DCHECK(!resolution_change_pending_); | 990 DCHECK(!resolution_change_pending_); |
| 1008 resolution_change_pending_ = true; | 991 if (IsResolutionChangeNecessary()) { |
|
Pawel Osciak
2014/03/27 05:18:06
resolution_change_pending_ = IsResolutionChangeNec
shivdasp
2014/03/27 05:40:37
Done.
| |
| 992 resolution_change_pending_ = true; | |
| 993 } | |
| 1009 } else { | 994 } else { |
| 1010 DLOG(FATAL) << "DequeueEvents(): got an event (" << ev.type | 995 DLOG(FATAL) << "DequeueEvents(): got an event (" << ev.type |
| 1011 << ") we haven't subscribed to."; | 996 << ") we haven't subscribed to."; |
| 1012 } | 997 } |
| 1013 } | 998 } |
| 1014 } | 999 } |
| 1015 | 1000 |
| 1016 void V4L2VideoDecodeAccelerator::Dequeue() { | 1001 void V4L2VideoDecodeAccelerator::Dequeue() { |
| 1017 DVLOG(3) << "Dequeue()"; | 1002 DVLOG(3) << "Dequeue()"; |
| 1018 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 1003 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1529 } | 1514 } |
| 1530 | 1515 |
| 1531 struct v4l2_format format; | 1516 struct v4l2_format format; |
| 1532 bool again; | 1517 bool again; |
| 1533 bool ret = GetFormatInfo(&format, &again); | 1518 bool ret = GetFormatInfo(&format, &again); |
| 1534 if (!ret || again) { | 1519 if (!ret || again) { |
| 1535 DVLOG(3) << "Couldn't get format information after resolution change"; | 1520 DVLOG(3) << "Couldn't get format information after resolution change"; |
| 1536 NOTIFY_ERROR(PLATFORM_FAILURE); | 1521 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 1537 return; | 1522 return; |
| 1538 } | 1523 } |
| 1539 | |
| 1540 if (!CreateBuffersForFormat(format)) { | 1524 if (!CreateBuffersForFormat(format)) { |
| 1541 DVLOG(3) << "Couldn't reallocate buffers after resolution change"; | 1525 DVLOG(3) << "Couldn't reallocate buffers after resolution change"; |
| 1542 NOTIFY_ERROR(PLATFORM_FAILURE); | 1526 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 1543 return; | 1527 return; |
| 1544 } | 1528 } |
| 1545 | 1529 |
| 1546 decoder_state_ = kDecoding; | 1530 decoder_state_ = kDecoding; |
| 1547 | 1531 |
| 1548 if (resolution_change_reset_pending_) { | 1532 if (resolution_change_reset_pending_) { |
| 1549 resolution_change_reset_pending_ = false; | 1533 resolution_change_reset_pending_ = false; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1625 return false; | 1609 return false; |
| 1626 } | 1610 } |
| 1627 } | 1611 } |
| 1628 | 1612 |
| 1629 return true; | 1613 return true; |
| 1630 } | 1614 } |
| 1631 | 1615 |
| 1632 bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat( | 1616 bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat( |
| 1633 const struct v4l2_format& format) { | 1617 const struct v4l2_format& format) { |
| 1634 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 1618 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| 1635 CHECK_EQ(format.fmt.pix_mp.num_planes, 2); | 1619 CHECK_EQ(format.fmt.pix_mp.num_planes, device_->GetNumberOfPlanes()); |
| 1636 frame_buffer_size_.SetSize( | 1620 frame_buffer_size_.SetSize( |
| 1637 format.fmt.pix_mp.width, format.fmt.pix_mp.height); | 1621 format.fmt.pix_mp.width, format.fmt.pix_mp.height); |
| 1638 output_buffer_pixelformat_ = format.fmt.pix_mp.pixelformat; | 1622 output_buffer_pixelformat_ = format.fmt.pix_mp.pixelformat; |
| 1639 DCHECK_EQ(output_buffer_pixelformat_, V4L2_PIX_FMT_NV12M); | 1623 DCHECK_EQ(output_buffer_pixelformat_, device_->GetCapturePixelFormat()); |
| 1640 DVLOG(3) << "CreateBuffersForFormat(): new resolution: " | 1624 DVLOG(3) << "CreateBuffersForFormat(): new resolution: " |
| 1641 << frame_buffer_size_.ToString(); | 1625 << frame_buffer_size_.ToString(); |
| 1642 | 1626 |
| 1643 if (!CreateOutputBuffers()) | 1627 if (!CreateOutputBuffers()) |
| 1644 return false; | 1628 return false; |
| 1645 | 1629 |
| 1646 return true; | 1630 return true; |
| 1647 } | 1631 } |
| 1648 | 1632 |
| 1649 bool V4L2VideoDecodeAccelerator::CreateInputBuffers() { | 1633 bool V4L2VideoDecodeAccelerator::CreateInputBuffers() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1726 // Output format setup in Initialize(). | 1710 // Output format setup in Initialize(). |
| 1727 | 1711 |
| 1728 // Allocate the output buffers. | 1712 // Allocate the output buffers. |
| 1729 struct v4l2_requestbuffers reqbufs; | 1713 struct v4l2_requestbuffers reqbufs; |
| 1730 memset(&reqbufs, 0, sizeof(reqbufs)); | 1714 memset(&reqbufs, 0, sizeof(reqbufs)); |
| 1731 reqbufs.count = output_dpb_size_ + kDpbOutputBufferExtraCount; | 1715 reqbufs.count = output_dpb_size_ + kDpbOutputBufferExtraCount; |
| 1732 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1716 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1733 reqbufs.memory = V4L2_MEMORY_MMAP; | 1717 reqbufs.memory = V4L2_MEMORY_MMAP; |
| 1734 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs); | 1718 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_REQBUFS, &reqbufs); |
| 1735 | 1719 |
| 1736 // Create DMABUFs from output buffers. | |
| 1737 output_buffer_map_.resize(reqbufs.count); | 1720 output_buffer_map_.resize(reqbufs.count); |
| 1738 for (size_t i = 0; i < output_buffer_map_.size(); ++i) { | |
| 1739 OutputRecord& output_record = output_buffer_map_[i]; | |
| 1740 for (size_t j = 0; j < arraysize(output_record.fds); ++j) { | |
| 1741 // Export the DMABUF fd so we can export it as a texture. | |
| 1742 struct v4l2_exportbuffer expbuf; | |
| 1743 memset(&expbuf, 0, sizeof(expbuf)); | |
| 1744 expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | |
| 1745 expbuf.index = i; | |
| 1746 expbuf.plane = j; | |
| 1747 expbuf.flags = O_CLOEXEC; | |
| 1748 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_EXPBUF, &expbuf); | |
| 1749 output_record.fds[j] = expbuf.fd; | |
| 1750 } | |
| 1751 } | |
| 1752 | 1721 |
| 1753 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " | 1722 DVLOG(3) << "CreateOutputBuffers(): ProvidePictureBuffers(): " |
| 1754 << "buffer_count=" << output_buffer_map_.size() | 1723 << "buffer_count=" << output_buffer_map_.size() |
| 1755 << ", width=" << frame_buffer_size_.width() | 1724 << ", width=" << frame_buffer_size_.width() |
| 1756 << ", height=" << frame_buffer_size_.height(); | 1725 << ", height=" << frame_buffer_size_.height(); |
| 1757 child_message_loop_proxy_->PostTask(FROM_HERE, | 1726 child_message_loop_proxy_->PostTask(FROM_HERE, |
| 1758 base::Bind(&Client::ProvidePictureBuffers, | 1727 base::Bind(&Client::ProvidePictureBuffers, |
| 1759 client_, | 1728 client_, |
| 1760 output_buffer_map_.size(), | 1729 output_buffer_map_.size(), |
| 1761 frame_buffer_size_, | 1730 frame_buffer_size_, |
| 1762 GL_TEXTURE_EXTERNAL_OES)); | 1731 device_->GetTextureTarget())); |
| 1763 | 1732 |
| 1764 // Wait for the client to call AssignPictureBuffers() on the Child thread. | 1733 // Wait for the client to call AssignPictureBuffers() on the Child thread. |
| 1765 // We do this, because if we continue decoding without finishing buffer | 1734 // We do this, because if we continue decoding without finishing buffer |
| 1766 // allocation, we may end up Resetting before AssignPictureBuffers arrives, | 1735 // allocation, we may end up Resetting before AssignPictureBuffers arrives, |
| 1767 // resulting in unnecessary complications and subtle bugs. | 1736 // resulting in unnecessary complications and subtle bugs. |
| 1768 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) | 1737 // For example, if the client calls Decode(Input1), Reset(), Decode(Input2) |
| 1769 // in a sequence, and Decode(Input1) results in us getting here and exiting | 1738 // in a sequence, and Decode(Input1) results in us getting here and exiting |
| 1770 // without waiting, we might end up running Reset{,Done}Task() before | 1739 // without waiting, we might end up running Reset{,Done}Task() before |
| 1771 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers | 1740 // AssignPictureBuffers is scheduled, thus cleaning up and pushing buffers |
| 1772 // to the free_output_buffers_ map twice. If we somehow marked buffers as | 1741 // to the free_output_buffers_ map twice. If we somehow marked buffers as |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1805 } | 1774 } |
| 1806 | 1775 |
| 1807 bool V4L2VideoDecodeAccelerator::DestroyOutputBuffers() { | 1776 bool V4L2VideoDecodeAccelerator::DestroyOutputBuffers() { |
| 1808 DVLOG(3) << "DestroyOutputBuffers()"; | 1777 DVLOG(3) << "DestroyOutputBuffers()"; |
| 1809 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); | 1778 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| 1810 DCHECK(!output_streamon_); | 1779 DCHECK(!output_streamon_); |
| 1811 bool success = true; | 1780 bool success = true; |
| 1812 | 1781 |
| 1813 for (size_t i = 0; i < output_buffer_map_.size(); ++i) { | 1782 for (size_t i = 0; i < output_buffer_map_.size(); ++i) { |
| 1814 OutputRecord& output_record = output_buffer_map_[i]; | 1783 OutputRecord& output_record = output_buffer_map_[i]; |
| 1815 for (size_t j = 0; j < arraysize(output_record.fds); ++j) { | 1784 |
| 1816 if (output_record.fds[j] != -1) { | 1785 device_->DestroyEGLImage(i); |
| 1817 if (close(output_record.fds[j])) { | 1786 |
| 1818 DVPLOG(1) << __func__ << " close() on a dmabuf fd failed."; | |
| 1819 success = false; | |
| 1820 } | |
| 1821 } | |
| 1822 } | |
| 1823 if (output_record.egl_image != EGL_NO_IMAGE_KHR) { | 1787 if (output_record.egl_image != EGL_NO_IMAGE_KHR) { |
| 1824 if (eglDestroyImageKHR(egl_display_, output_record.egl_image) != | 1788 if (eglDestroyImageKHR(egl_display_, output_record.egl_image) != |
| 1825 EGL_TRUE) { | 1789 EGL_TRUE) { |
| 1826 DVLOG(1) << __func__ << " eglDestroyImageKHR failed."; | 1790 DVLOG(1) << __func__ << " eglDestroyImageKHR failed."; |
| 1827 success = false; | 1791 success = false; |
| 1828 } | 1792 } |
| 1829 } | 1793 } |
| 1830 | 1794 |
| 1831 if (output_record.egl_sync != EGL_NO_SYNC_KHR) { | 1795 if (output_record.egl_sync != EGL_NO_SYNC_KHR) { |
| 1832 if (eglDestroySyncKHR(egl_display_, output_record.egl_sync) != EGL_TRUE) { | 1796 if (eglDestroySyncKHR(egl_display_, output_record.egl_sync) != EGL_TRUE) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1919 } | 1883 } |
| 1920 | 1884 |
| 1921 void V4L2VideoDecodeAccelerator::PictureCleared() { | 1885 void V4L2VideoDecodeAccelerator::PictureCleared() { |
| 1922 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; | 1886 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; |
| 1923 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 1887 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| 1924 DCHECK_GT(picture_clearing_count_, 0); | 1888 DCHECK_GT(picture_clearing_count_, 0); |
| 1925 picture_clearing_count_--; | 1889 picture_clearing_count_--; |
| 1926 SendPictureReady(); | 1890 SendPictureReady(); |
| 1927 } | 1891 } |
| 1928 | 1892 |
| 1893 bool V4L2VideoDecodeAccelerator::IsResolutionChangeNecessary() { | |
| 1894 if (frame_buffer_size_.IsEmpty()) | |
| 1895 return true; | |
| 1896 | |
| 1897 struct v4l2_control ctrl; | |
| 1898 memset(&ctrl, 0, sizeof(ctrl)); | |
| 1899 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; | |
| 1900 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); | |
| 1901 if (ctrl.value != output_dpb_size_) { | |
| 1902 DVLOG(3) | |
| 1903 << "IsResolutionChangeNecessary(): Returning true since DPB mismatch "; | |
| 1904 return true; | |
| 1905 } | |
| 1906 struct v4l2_format format; | |
| 1907 bool again = false; | |
| 1908 bool ret = GetFormatInfo(&format, &again); | |
| 1909 if (!ret || again) { | |
| 1910 DVLOG(3) << "IsResolutionChangeNecessary(): GetFormatInfo() failed"; | |
| 1911 return false; | |
| 1912 } | |
| 1913 if ((static_cast<int>(format.fmt.pix_mp.width) != | |
|
Pawel Osciak
2014/03/27 05:18:06
gfx::Size new_size(base::checked_cast<int>(format.
shivdasp
2014/03/27 05:40:37
Will do.
| |
| 1914 frame_buffer_size_.width()) || | |
| 1915 (static_cast<int>(format.fmt.pix_mp.height) != | |
| 1916 frame_buffer_size_.height())) { | |
| 1917 DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; | |
| 1918 return true; | |
| 1919 } | |
| 1920 return false; | |
| 1921 } | |
| 1922 | |
| 1929 } // namespace content | 1923 } // namespace content |
| OLD | NEW |