Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: content/common/gpu/media/exynos_video_decode_accelerator.cc

Issue 12114017: Remove redundant buffer count in ExynosVDA (Closed) Base URL: https://chromium.googlesource.com/chromium/src@git-svn
Patch Set: Nits. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/media/exynos_video_decode_accelerator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #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 <linux/videodev2.h> 8 #include <linux/videodev2.h>
9 #include <poll.h> 9 #include <poll.h>
10 #include <sys/eventfd.h> 10 #include <sys/eventfd.h>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 decoder_thread_("ExynosDecoderThread"), 208 decoder_thread_("ExynosDecoderThread"),
209 decoder_state_(kUninitialized), 209 decoder_state_(kUninitialized),
210 decoder_current_bitstream_buffer_(NULL), 210 decoder_current_bitstream_buffer_(NULL),
211 decoder_delay_bitstream_buffer_id_(-1), 211 decoder_delay_bitstream_buffer_id_(-1),
212 decoder_current_input_buffer_(-1), 212 decoder_current_input_buffer_(-1),
213 decoder_decode_buffer_tasks_scheduled_(0), 213 decoder_decode_buffer_tasks_scheduled_(0),
214 decoder_frames_at_client_(0), 214 decoder_frames_at_client_(0),
215 decoder_flushing_(false), 215 decoder_flushing_(false),
216 mfc_fd_(-1), 216 mfc_fd_(-1),
217 mfc_input_streamon_(false), 217 mfc_input_streamon_(false),
218 mfc_input_buffer_count_(0),
219 mfc_input_buffer_queued_count_(0), 218 mfc_input_buffer_queued_count_(0),
220 mfc_output_streamon_(false), 219 mfc_output_streamon_(false),
221 mfc_output_buffer_count_(0),
222 mfc_output_buffer_queued_count_(0), 220 mfc_output_buffer_queued_count_(0),
223 mfc_output_buffer_pixelformat_(0), 221 mfc_output_buffer_pixelformat_(0),
224 gsc_fd_(-1), 222 gsc_fd_(-1),
225 gsc_input_streamon_(false), 223 gsc_input_streamon_(false),
226 gsc_input_buffer_count_(0),
227 gsc_input_buffer_queued_count_(0), 224 gsc_input_buffer_queued_count_(0),
228 gsc_output_streamon_(false), 225 gsc_output_streamon_(false),
229 gsc_output_buffer_count_(0),
230 gsc_output_buffer_queued_count_(0), 226 gsc_output_buffer_queued_count_(0),
231 device_poll_thread_("ExynosDevicePollThread"), 227 device_poll_thread_("ExynosDevicePollThread"),
232 device_poll_interrupt_fd_(-1), 228 device_poll_interrupt_fd_(-1),
233 make_context_current_(make_context_current), 229 make_context_current_(make_context_current),
234 egl_display_(egl_display), 230 egl_display_(egl_display),
235 egl_context_(egl_context), 231 egl_context_(egl_context),
236 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) { 232 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {
237 } 233 }
238 234
239 ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() { 235 ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 425 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
430 &ExynosVideoDecodeAccelerator::DecodeTask, base::Unretained(this), 426 &ExynosVideoDecodeAccelerator::DecodeTask, base::Unretained(this),
431 base::Passed(&bitstream_record))); 427 base::Passed(&bitstream_record)));
432 } 428 }
433 429
434 void ExynosVideoDecodeAccelerator::AssignPictureBuffers( 430 void ExynosVideoDecodeAccelerator::AssignPictureBuffers(
435 const std::vector<media::PictureBuffer>& buffers) { 431 const std::vector<media::PictureBuffer>& buffers) {
436 DVLOG(3) << "AssignPictureBuffers(): buffer_count=" << buffers.size(); 432 DVLOG(3) << "AssignPictureBuffers(): buffer_count=" << buffers.size();
437 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 433 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
438 434
439 if (static_cast<int>(buffers.size()) != gsc_output_buffer_count_) { 435 if (buffers.size() != gsc_output_buffer_map_.size()) {
440 DLOG(ERROR) << "AssignPictureBuffers(): invalid buffer_count"; 436 DLOG(ERROR) << "AssignPictureBuffers(): invalid buffer_count";
441 NOTIFY_ERROR(INVALID_ARGUMENT); 437 NOTIFY_ERROR(INVALID_ARGUMENT);
442 return; 438 return;
443 } 439 }
444 440
445 if (!make_context_current_.Run()) { 441 if (!make_context_current_.Run()) {
446 DLOG(ERROR) << "AssignPictureBuffers(): could not make context current"; 442 DLOG(ERROR) << "AssignPictureBuffers(): could not make context current";
447 NOTIFY_ERROR(PLATFORM_FAILURE); 443 NOTIFY_ERROR(PLATFORM_FAILURE);
448 return; 444 return;
449 } 445 }
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 device_poll_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 1082 device_poll_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
1087 &ExynosVideoDecodeAccelerator::DevicePollTask, 1083 &ExynosVideoDecodeAccelerator::DevicePollTask,
1088 base::Unretained(this), 1084 base::Unretained(this),
1089 poll_fds)); 1085 poll_fds));
1090 1086
1091 DVLOG(1) << "ServiceDeviceTask(): buffer counts: DEC[" 1087 DVLOG(1) << "ServiceDeviceTask(): buffer counts: DEC["
1092 << decoder_input_queue_.size() << "->" 1088 << decoder_input_queue_.size() << "->"
1093 << mfc_input_ready_queue_.size() << "] => MFC[" 1089 << mfc_input_ready_queue_.size() << "] => MFC["
1094 << mfc_free_input_buffers_.size() << "+" 1090 << mfc_free_input_buffers_.size() << "+"
1095 << mfc_input_buffer_queued_count_ << "/" 1091 << mfc_input_buffer_queued_count_ << "/"
1096 << mfc_input_buffer_count_ << "->" 1092 << mfc_input_buffer_map_.size() << "->"
1097 << mfc_free_output_buffers_.size() << "+" 1093 << mfc_free_output_buffers_.size() << "+"
1098 << mfc_output_buffer_queued_count_ << "/" 1094 << mfc_output_buffer_queued_count_ << "/"
1099 << mfc_output_buffer_count_ << "] => " 1095 << mfc_output_buffer_map_.size() << "] => "
1100 << mfc_output_gsc_input_queue_.size() << " => GSC[" 1096 << mfc_output_gsc_input_queue_.size() << " => GSC["
1101 << gsc_free_input_buffers_.size() << "+" 1097 << gsc_free_input_buffers_.size() << "+"
1102 << gsc_input_buffer_queued_count_ << "/" 1098 << gsc_input_buffer_queued_count_ << "/"
1103 << gsc_input_buffer_count_ << "->" 1099 << gsc_input_buffer_map_.size() << "->"
1104 << gsc_free_output_buffers_.size() << "+" 1100 << gsc_free_output_buffers_.size() << "+"
1105 << gsc_output_buffer_queued_count_ << "/" 1101 << gsc_output_buffer_queued_count_ << "/"
1106 << gsc_output_buffer_count_ << "] => VDA[" 1102 << gsc_output_buffer_map_.size() << "] => VDA["
1107 << decoder_frames_at_client_ << "]"; 1103 << decoder_frames_at_client_ << "]";
1108 1104
1109 ScheduleDecodeBufferTaskIfNeeded(); 1105 ScheduleDecodeBufferTaskIfNeeded();
1110 } 1106 }
1111 1107
1112 void ExynosVideoDecodeAccelerator::EnqueueMfc() { 1108 void ExynosVideoDecodeAccelerator::EnqueueMfc() {
1113 DVLOG(3) << "EnqueueMfc()"; 1109 DVLOG(3) << "EnqueueMfc()";
1114 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current()); 1110 DCHECK_EQ(decoder_thread_.message_loop(), MessageLoop::current());
1115 DCHECK_NE(decoder_state_, kUninitialized); 1111 DCHECK_NE(decoder_state_, kUninitialized);
1116 TRACE_EVENT0("Video Decoder", "EVDA::EnqueueMfc"); 1112 TRACE_EVENT0("Video Decoder", "EVDA::EnqueueMfc");
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 gsc_input_streamon_ = false; 1712 gsc_input_streamon_ = false;
1717 if (gsc_output_streamon_) { 1713 if (gsc_output_streamon_) {
1718 __u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 1714 __u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1719 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_STREAMOFF, &type); 1715 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_STREAMOFF, &type);
1720 } 1716 }
1721 gsc_output_streamon_ = false; 1717 gsc_output_streamon_ = false;
1722 1718
1723 // Reset all our accounting info. 1719 // Reset all our accounting info.
1724 mfc_input_ready_queue_.clear(); 1720 mfc_input_ready_queue_.clear();
1725 mfc_free_input_buffers_.clear(); 1721 mfc_free_input_buffers_.clear();
1726 DCHECK_EQ(mfc_input_buffer_count_,
1727 static_cast<int>(mfc_input_buffer_map_.size()));
1728 for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) { 1722 for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) {
1729 mfc_free_input_buffers_.push_back(i); 1723 mfc_free_input_buffers_.push_back(i);
1730 mfc_input_buffer_map_[i].at_device = false; 1724 mfc_input_buffer_map_[i].at_device = false;
1731 mfc_input_buffer_map_[i].bytes_used = 0; 1725 mfc_input_buffer_map_[i].bytes_used = 0;
1732 mfc_input_buffer_map_[i].input_id = -1; 1726 mfc_input_buffer_map_[i].input_id = -1;
1733 } 1727 }
1734 mfc_input_buffer_queued_count_ = 0; 1728 mfc_input_buffer_queued_count_ = 0;
1735 mfc_free_output_buffers_.clear(); 1729 mfc_free_output_buffers_.clear();
1736 DCHECK_EQ(mfc_output_buffer_count_,
1737 static_cast<int>(mfc_output_buffer_map_.size()));
1738 for (size_t i = 0; i < mfc_output_buffer_map_.size(); ++i) { 1730 for (size_t i = 0; i < mfc_output_buffer_map_.size(); ++i) {
1739 mfc_free_output_buffers_.push_back(i); 1731 mfc_free_output_buffers_.push_back(i);
1740 mfc_output_buffer_map_[i].at_device = false; 1732 mfc_output_buffer_map_[i].at_device = false;
1741 mfc_output_buffer_map_[i].input_id = -1; 1733 mfc_output_buffer_map_[i].input_id = -1;
1742 } 1734 }
1743 mfc_output_buffer_queued_count_ = 0; 1735 mfc_output_buffer_queued_count_ = 0;
1744 mfc_output_gsc_input_queue_.clear(); 1736 mfc_output_gsc_input_queue_.clear();
1745 gsc_free_input_buffers_.clear(); 1737 gsc_free_input_buffers_.clear();
1746 DCHECK_EQ(gsc_input_buffer_count_,
1747 static_cast<int>(gsc_input_buffer_map_.size()));
1748 for (size_t i = 0; i < gsc_input_buffer_map_.size(); ++i) { 1738 for (size_t i = 0; i < gsc_input_buffer_map_.size(); ++i) {
1749 gsc_free_input_buffers_.push_back(i); 1739 gsc_free_input_buffers_.push_back(i);
1750 gsc_input_buffer_map_[i].at_device = false; 1740 gsc_input_buffer_map_[i].at_device = false;
1751 gsc_input_buffer_map_[i].mfc_output = -1; 1741 gsc_input_buffer_map_[i].mfc_output = -1;
1752 } 1742 }
1753 gsc_input_buffer_queued_count_ = 0; 1743 gsc_input_buffer_queued_count_ = 0;
1754 gsc_free_output_buffers_.clear(); 1744 gsc_free_output_buffers_.clear();
1755 DCHECK_EQ(gsc_output_buffer_count_,
1756 static_cast<int>(gsc_output_buffer_map_.size()));
1757 for (size_t i = 0; i < gsc_output_buffer_map_.size(); ++i) { 1745 for (size_t i = 0; i < gsc_output_buffer_map_.size(); ++i) {
1758 // Only mark those free that aren't being held by the VDA. 1746 // Only mark those free that aren't being held by the VDA.
1759 if (!gsc_output_buffer_map_[i].at_client) { 1747 if (!gsc_output_buffer_map_[i].at_client) {
1760 gsc_free_output_buffers_.push_back(i); 1748 gsc_free_output_buffers_.push_back(i);
1761 gsc_output_buffer_map_[i].at_device = false; 1749 gsc_output_buffer_map_[i].at_device = false;
1762 } 1750 }
1763 } 1751 }
1764 gsc_output_buffer_queued_count_ = 0; 1752 gsc_output_buffer_queued_count_ = 0;
1765 1753
1766 DVLOG(3) << "StopDevicePoll(): device poll stopped"; 1754 DVLOG(3) << "StopDevicePoll(): device poll stopped";
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 return; 1841 return;
1854 } 1842 }
1855 1843
1856 if (client_) { 1844 if (client_) {
1857 client_->NotifyError(error); 1845 client_->NotifyError(error);
1858 client_ptr_factory_.InvalidateWeakPtrs(); 1846 client_ptr_factory_.InvalidateWeakPtrs();
1859 } 1847 }
1860 } 1848 }
1861 1849
1862 void ExynosVideoDecodeAccelerator::SetDecoderState(State state) { 1850 void ExynosVideoDecodeAccelerator::SetDecoderState(State state) {
1863 DVLOG(3) << "SetDecoderState(): state=%d" << state; 1851 DVLOG(3) << "SetDecoderState(): state=" << state;
1864 1852
1865 // We can touch decoder_state_ only if this is the decoder thread or the 1853 // We can touch decoder_state_ only if this is the decoder thread or the
1866 // decoder thread isn't running. 1854 // decoder thread isn't running.
1867 if (decoder_thread_.message_loop() != NULL && 1855 if (decoder_thread_.message_loop() != NULL &&
1868 decoder_thread_.message_loop() != MessageLoop::current()) { 1856 decoder_thread_.message_loop() != MessageLoop::current()) {
1869 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 1857 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
1870 &ExynosVideoDecodeAccelerator::SetDecoderState, 1858 &ExynosVideoDecodeAccelerator::SetDecoderState,
1871 base::Unretained(this), state)); 1859 base::Unretained(this), state));
1872 } else { 1860 } else {
1873 decoder_state_ = state; 1861 decoder_state_ = state;
1874 } 1862 }
1875 } 1863 }
1876 1864
1877 bool ExynosVideoDecodeAccelerator::CreateMfcInputBuffers() { 1865 bool ExynosVideoDecodeAccelerator::CreateMfcInputBuffers() {
1878 DVLOG(3) << "CreateMfcInputBuffers()"; 1866 DVLOG(3) << "CreateMfcInputBuffers()";
1879 // We always run this as we prepare to initialize. 1867 // We always run this as we prepare to initialize.
1880 DCHECK_EQ(decoder_state_, kUninitialized); 1868 DCHECK_EQ(decoder_state_, kUninitialized);
1881 DCHECK(!mfc_input_streamon_); 1869 DCHECK(!mfc_input_streamon_);
1882 DCHECK_EQ(mfc_input_buffer_count_, 0); 1870 DCHECK(mfc_input_buffer_map_.empty());
1883 1871
1884 __u32 pixelformat = 0; 1872 __u32 pixelformat = 0;
1885 if (video_profile_ >= media::H264PROFILE_MIN && 1873 if (video_profile_ >= media::H264PROFILE_MIN &&
1886 video_profile_ <= media::H264PROFILE_MAX) { 1874 video_profile_ <= media::H264PROFILE_MAX) {
1887 pixelformat = V4L2_PIX_FMT_H264; 1875 pixelformat = V4L2_PIX_FMT_H264;
1888 } else if (video_profile_ >= media::VP8PROFILE_MIN && 1876 } else if (video_profile_ >= media::VP8PROFILE_MIN &&
1889 video_profile_ <= media::VP8PROFILE_MAX) { 1877 video_profile_ <= media::VP8PROFILE_MAX) {
1890 pixelformat = V4L2_PIX_FMT_VP8; 1878 pixelformat = V4L2_PIX_FMT_VP8;
1891 } else { 1879 } else {
1892 NOTREACHED(); 1880 NOTREACHED();
1893 } 1881 }
1894 1882
1895 struct v4l2_format format; 1883 struct v4l2_format format;
1896 memset(&format, 0, sizeof(format)); 1884 memset(&format, 0, sizeof(format));
1897 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 1885 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
1898 format.fmt.pix_mp.pixelformat = pixelformat; 1886 format.fmt.pix_mp.pixelformat = pixelformat;
1899 format.fmt.pix_mp.plane_fmt[0].sizeimage = kMfcInputBufferMaxSize; 1887 format.fmt.pix_mp.plane_fmt[0].sizeimage = kMfcInputBufferMaxSize;
1900 format.fmt.pix_mp.num_planes = 1; 1888 format.fmt.pix_mp.num_planes = 1;
1901 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_S_FMT, &format); 1889 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_S_FMT, &format);
1902 1890
1903 struct v4l2_requestbuffers reqbufs; 1891 struct v4l2_requestbuffers reqbufs;
1904 memset(&reqbufs, 0, sizeof(reqbufs)); 1892 memset(&reqbufs, 0, sizeof(reqbufs));
1905 reqbufs.count = kMfcInputBufferCount; 1893 reqbufs.count = kMfcInputBufferCount;
1906 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 1894 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
1907 reqbufs.memory = V4L2_MEMORY_MMAP; 1895 reqbufs.memory = V4L2_MEMORY_MMAP;
1908 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_REQBUFS, &reqbufs); 1896 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_REQBUFS, &reqbufs);
1909 mfc_input_buffer_count_ = reqbufs.count; 1897 mfc_input_buffer_map_.resize(reqbufs.count);
1910 mfc_input_buffer_map_.resize(mfc_input_buffer_count_); 1898 for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) {
1911 for (int i = 0; i < mfc_input_buffer_count_; ++i) {
1912 mfc_free_input_buffers_.push_back(i); 1899 mfc_free_input_buffers_.push_back(i);
1913 1900
1914 // Query for the MEMORY_MMAP pointer. 1901 // Query for the MEMORY_MMAP pointer.
1915 struct v4l2_plane planes[1]; 1902 struct v4l2_plane planes[1];
1916 struct v4l2_buffer buffer; 1903 struct v4l2_buffer buffer;
1917 memset(&buffer, 0, sizeof(buffer)); 1904 memset(&buffer, 0, sizeof(buffer));
1918 memset(planes, 0, sizeof(planes)); 1905 memset(planes, 0, sizeof(planes));
1919 buffer.index = i; 1906 buffer.index = i;
1920 buffer.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 1907 buffer.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
1921 buffer.memory = V4L2_MEMORY_MMAP; 1908 buffer.memory = V4L2_MEMORY_MMAP;
(...skipping 11 matching lines...) Expand all
1933 mfc_input_buffer_map_[i].length = buffer.m.planes[0].length; 1920 mfc_input_buffer_map_[i].length = buffer.m.planes[0].length;
1934 } 1921 }
1935 1922
1936 return true; 1923 return true;
1937 } 1924 }
1938 1925
1939 bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() { 1926 bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() {
1940 DVLOG(3) << "CreateMfcOutputBuffers()"; 1927 DVLOG(3) << "CreateMfcOutputBuffers()";
1941 DCHECK_EQ(decoder_state_, kInitialized); 1928 DCHECK_EQ(decoder_state_, kInitialized);
1942 DCHECK(!mfc_output_streamon_); 1929 DCHECK(!mfc_output_streamon_);
1943 DCHECK_EQ(mfc_output_buffer_count_, 0); 1930 DCHECK(mfc_output_buffer_map_.empty());
1944 1931
1945 // Number of MFC output buffers we need. 1932 // Number of MFC output buffers we need.
1946 struct v4l2_control ctrl; 1933 struct v4l2_control ctrl;
1947 memset(&ctrl, 0, sizeof(ctrl)); 1934 memset(&ctrl, 0, sizeof(ctrl));
1948 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; 1935 ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE;
1949 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_G_CTRL, &ctrl); 1936 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_G_CTRL, &ctrl);
1950 1937
1951 // Output format setup in Initialize(). 1938 // Output format setup in Initialize().
1952 1939
1953 // Allocate the output buffers. 1940 // Allocate the output buffers.
1954 struct v4l2_requestbuffers reqbufs; 1941 struct v4l2_requestbuffers reqbufs;
1955 memset(&reqbufs, 0, sizeof(reqbufs)); 1942 memset(&reqbufs, 0, sizeof(reqbufs));
1956 reqbufs.count = ctrl.value + kMfcOutputBufferExtraCount; 1943 reqbufs.count = ctrl.value + kMfcOutputBufferExtraCount;
1957 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 1944 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1958 reqbufs.memory = V4L2_MEMORY_MMAP; 1945 reqbufs.memory = V4L2_MEMORY_MMAP;
1959 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_REQBUFS, &reqbufs); 1946 IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_REQBUFS, &reqbufs);
1960 1947
1961 // Fill our free-buffers list, and create DMABUFs from them. 1948 // Fill our free-buffers list, and create DMABUFs from them.
1962 mfc_output_buffer_count_ = reqbufs.count; 1949 mfc_output_buffer_map_.resize(reqbufs.count);
1963 mfc_output_buffer_map_.resize(mfc_output_buffer_count_); 1950 for (size_t i = 0; i < mfc_output_buffer_map_.size(); ++i) {
1964 for (int i = 0; i < mfc_output_buffer_count_; ++i) {
1965 mfc_free_output_buffers_.push_back(i); 1951 mfc_free_output_buffers_.push_back(i);
1966 1952
1967 // Query for the MEMORY_MMAP pointer. 1953 // Query for the MEMORY_MMAP pointer.
1968 struct v4l2_plane planes[2]; 1954 struct v4l2_plane planes[2];
1969 struct v4l2_buffer buffer; 1955 struct v4l2_buffer buffer;
1970 memset(&buffer, 0, sizeof(buffer)); 1956 memset(&buffer, 0, sizeof(buffer));
1971 memset(planes, 0, sizeof(planes)); 1957 memset(planes, 0, sizeof(planes));
1972 buffer.index = i; 1958 buffer.index = i;
1973 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 1959 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
1974 buffer.memory = V4L2_MEMORY_MMAP; 1960 buffer.memory = V4L2_MEMORY_MMAP;
(...skipping 15 matching lines...) Expand all
1990 } 1976 }
1991 } 1977 }
1992 1978
1993 return true; 1979 return true;
1994 } 1980 }
1995 1981
1996 bool ExynosVideoDecodeAccelerator::CreateGscInputBuffers() { 1982 bool ExynosVideoDecodeAccelerator::CreateGscInputBuffers() {
1997 DVLOG(3) << "CreateGscInputBuffers()"; 1983 DVLOG(3) << "CreateGscInputBuffers()";
1998 DCHECK_EQ(decoder_state_, kInitialized); 1984 DCHECK_EQ(decoder_state_, kInitialized);
1999 DCHECK(!gsc_input_streamon_); 1985 DCHECK(!gsc_input_streamon_);
2000 DCHECK_EQ(gsc_input_buffer_count_, 0); 1986 DCHECK(gsc_input_buffer_map_.empty());
2001 1987
2002 struct v4l2_format format; 1988 struct v4l2_format format;
2003 memset(&format, 0, sizeof(format)); 1989 memset(&format, 0, sizeof(format));
2004 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 1990 format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
2005 format.fmt.pix_mp.width = frame_buffer_size_.width(); 1991 format.fmt.pix_mp.width = frame_buffer_size_.width();
2006 format.fmt.pix_mp.height = frame_buffer_size_.height(); 1992 format.fmt.pix_mp.height = frame_buffer_size_.height();
2007 format.fmt.pix_mp.pixelformat = mfc_output_buffer_pixelformat_; 1993 format.fmt.pix_mp.pixelformat = mfc_output_buffer_pixelformat_;
2008 format.fmt.pix_mp.plane_fmt[0].sizeimage = mfc_output_buffer_size_[0]; 1994 format.fmt.pix_mp.plane_fmt[0].sizeimage = mfc_output_buffer_size_[0];
2009 format.fmt.pix_mp.plane_fmt[1].sizeimage = mfc_output_buffer_size_[1]; 1995 format.fmt.pix_mp.plane_fmt[1].sizeimage = mfc_output_buffer_size_[1];
2010 // NV12MT_16X16 is a tiled format for which bytesperline doesn't make too much 1996 // NV12MT_16X16 is a tiled format for which bytesperline doesn't make too much
(...skipping 24 matching lines...) Expand all
2035 control.value = 255; 2021 control.value = 255;
2036 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control); 2022 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_CTRL, &control);
2037 2023
2038 struct v4l2_requestbuffers reqbufs; 2024 struct v4l2_requestbuffers reqbufs;
2039 memset(&reqbufs, 0, sizeof(reqbufs)); 2025 memset(&reqbufs, 0, sizeof(reqbufs));
2040 reqbufs.count = kGscInputBufferCount; 2026 reqbufs.count = kGscInputBufferCount;
2041 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 2027 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
2042 reqbufs.memory = V4L2_MEMORY_USERPTR; 2028 reqbufs.memory = V4L2_MEMORY_USERPTR;
2043 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs); 2029 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs);
2044 2030
2045 gsc_input_buffer_count_ = reqbufs.count; 2031 gsc_input_buffer_map_.resize(reqbufs.count);
2046 gsc_input_buffer_map_.resize(gsc_input_buffer_count_); 2032 for (size_t i = 0; i < gsc_input_buffer_map_.size(); ++i) {
2047 for (int i = 0; i < gsc_input_buffer_count_; ++i) {
2048 gsc_free_input_buffers_.push_back(i); 2033 gsc_free_input_buffers_.push_back(i);
2049 gsc_input_buffer_map_[i].mfc_output = -1; 2034 gsc_input_buffer_map_[i].mfc_output = -1;
2050 } 2035 }
2051 2036
2052 return true; 2037 return true;
2053 } 2038 }
2054 2039
2055 bool ExynosVideoDecodeAccelerator::CreateGscOutputBuffers() { 2040 bool ExynosVideoDecodeAccelerator::CreateGscOutputBuffers() {
2056 DVLOG(3) << "CreateGscOutputBuffers()"; 2041 DVLOG(3) << "CreateGscOutputBuffers()";
2057 DCHECK_EQ(decoder_state_, kInitialized); 2042 DCHECK_EQ(decoder_state_, kInitialized);
2058 DCHECK(!gsc_output_streamon_); 2043 DCHECK(!gsc_output_streamon_);
2059 DCHECK_EQ(gsc_output_buffer_count_, 0); 2044 DCHECK(gsc_output_buffer_map_.empty());
2060 2045
2061 // GSC outputs into the EGLImages we create from the textures we are 2046 // GSC outputs into the EGLImages we create from the textures we are
2062 // assigned. Assume RGBA8888 format. 2047 // assigned. Assume RGBA8888 format.
2063 struct v4l2_format format; 2048 struct v4l2_format format;
2064 memset(&format, 0, sizeof(format)); 2049 memset(&format, 0, sizeof(format));
2065 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 2050 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
2066 format.fmt.pix_mp.width = frame_buffer_size_.width(); 2051 format.fmt.pix_mp.width = frame_buffer_size_.width();
2067 format.fmt.pix_mp.height = frame_buffer_size_.height(); 2052 format.fmt.pix_mp.height = frame_buffer_size_.height();
2068 format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_RGB32; 2053 format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_RGB32;
2069 format.fmt.pix_mp.plane_fmt[0].sizeimage = 2054 format.fmt.pix_mp.plane_fmt[0].sizeimage =
2070 frame_buffer_size_.width() * frame_buffer_size_.height() * 4; 2055 frame_buffer_size_.width() * frame_buffer_size_.height() * 4;
2071 format.fmt.pix_mp.plane_fmt[0].bytesperline = frame_buffer_size_.width() * 4; 2056 format.fmt.pix_mp.plane_fmt[0].bytesperline = frame_buffer_size_.width() * 4;
2072 format.fmt.pix_mp.num_planes = 1; 2057 format.fmt.pix_mp.num_planes = 1;
2073 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_FMT, &format); 2058 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_S_FMT, &format);
2074 2059
2075 struct v4l2_requestbuffers reqbufs; 2060 struct v4l2_requestbuffers reqbufs;
2076 memset(&reqbufs, 0, sizeof(reqbufs)); 2061 memset(&reqbufs, 0, sizeof(reqbufs));
2077 reqbufs.count = kGscOutputBufferCount; 2062 reqbufs.count = kGscOutputBufferCount;
2078 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 2063 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
2079 reqbufs.memory = V4L2_MEMORY_DMABUF; 2064 reqbufs.memory = V4L2_MEMORY_DMABUF;
2080 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs); 2065 IOCTL_OR_ERROR_RETURN_FALSE(gsc_fd_, VIDIOC_REQBUFS, &reqbufs);
2081 2066
2082 // We don't actually fill in the freelist or the map here. That happens once 2067 // We don't actually fill in the freelist or the map here. That happens once
2083 // we have actual usable buffers, after AssignPictureBuffers(); 2068 // we have actual usable buffers, after AssignPictureBuffers();
2084 gsc_output_buffer_count_ = reqbufs.count; 2069 gsc_output_buffer_map_.resize(reqbufs.count);
2085 gsc_output_buffer_map_.resize(gsc_output_buffer_count_);
2086 2070
2087 DVLOG(3) << "CreateGscOutputBuffers(): ProvidePictureBuffers(): " 2071 DVLOG(3) << "CreateGscOutputBuffers(): ProvidePictureBuffers(): "
2088 << "buffer_count=" << gsc_output_buffer_count_ 2072 << "buffer_count=" << gsc_output_buffer_map_.size()
2089 << ", width=" << frame_buffer_size_.width() 2073 << ", width=" << frame_buffer_size_.width()
2090 << ", height=" << frame_buffer_size_.height(); 2074 << ", height=" << frame_buffer_size_.height();
2091 child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind( 2075 child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind(
2092 &Client::ProvidePictureBuffers, client_, gsc_output_buffer_count_, 2076 &Client::ProvidePictureBuffers, client_, gsc_output_buffer_map_.size(),
2093 gfx::Size(frame_buffer_size_.width(), frame_buffer_size_.height()), 2077 gfx::Size(frame_buffer_size_.width(), frame_buffer_size_.height()),
2094 GL_TEXTURE_2D)); 2078 GL_TEXTURE_2D));
2095 2079
2096 return true; 2080 return true;
2097 } 2081 }
2098 2082
2099 void ExynosVideoDecodeAccelerator::DestroyMfcInputBuffers() { 2083 void ExynosVideoDecodeAccelerator::DestroyMfcInputBuffers() {
2100 DVLOG(3) << "DestroyMfcInputBuffers()"; 2084 DVLOG(3) << "DestroyMfcInputBuffers()";
2101 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 2085 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
2102 DCHECK(!mfc_input_streamon_); 2086 DCHECK(!mfc_input_streamon_);
2103 2087
2104 for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) { 2088 for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) {
2105 if (mfc_input_buffer_map_[i].address != NULL) { 2089 if (mfc_input_buffer_map_[i].address != NULL) {
2106 munmap(mfc_input_buffer_map_[i].address, 2090 munmap(mfc_input_buffer_map_[i].address,
2107 mfc_input_buffer_map_[i].length); 2091 mfc_input_buffer_map_[i].length);
2108 } 2092 }
2109 } 2093 }
2110 2094
2111 struct v4l2_requestbuffers reqbufs; 2095 struct v4l2_requestbuffers reqbufs;
2112 memset(&reqbufs, 0, sizeof(reqbufs)); 2096 memset(&reqbufs, 0, sizeof(reqbufs));
2113 reqbufs.count = 0; 2097 reqbufs.count = 0;
2114 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 2098 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
2115 reqbufs.memory = V4L2_MEMORY_MMAP; 2099 reqbufs.memory = V4L2_MEMORY_MMAP;
2116 if (ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) 2100 if (ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0)
2117 DPLOG(ERROR) << "DestroyMfcInputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; 2101 DPLOG(ERROR) << "DestroyMfcInputBuffers(): ioctl() failed: VIDIOC_REQBUFS";
2118 2102
2119 mfc_input_buffer_map_.clear(); 2103 mfc_input_buffer_map_.clear();
2120 mfc_free_input_buffers_.clear(); 2104 mfc_free_input_buffers_.clear();
2121 mfc_input_buffer_count_ = 0;
2122 } 2105 }
2123 2106
2124 void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() { 2107 void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() {
2125 DVLOG(3) << "DestroyMfcOutputBuffers()"; 2108 DVLOG(3) << "DestroyMfcOutputBuffers()";
2126 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 2109 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
2127 DCHECK(!mfc_output_streamon_); 2110 DCHECK(!mfc_output_streamon_);
2128 2111
2129 for (size_t i = 0; i < mfc_output_buffer_map_.size(); ++i) { 2112 for (size_t i = 0; i < mfc_output_buffer_map_.size(); ++i) {
2130 if (mfc_output_buffer_map_[i].address[0] != NULL) 2113 if (mfc_output_buffer_map_[i].address[0] != NULL)
2131 munmap(mfc_output_buffer_map_[i].address[0], 2114 munmap(mfc_output_buffer_map_[i].address[0],
2132 mfc_output_buffer_map_[i].length[0]); 2115 mfc_output_buffer_map_[i].length[0]);
2133 if (mfc_output_buffer_map_[i].address[1] != NULL) 2116 if (mfc_output_buffer_map_[i].address[1] != NULL)
2134 munmap(mfc_output_buffer_map_[i].address[1], 2117 munmap(mfc_output_buffer_map_[i].address[1],
2135 mfc_output_buffer_map_[i].length[1]); 2118 mfc_output_buffer_map_[i].length[1]);
2136 } 2119 }
2137 2120
2138 struct v4l2_requestbuffers reqbufs; 2121 struct v4l2_requestbuffers reqbufs;
2139 memset(&reqbufs, 0, sizeof(reqbufs)); 2122 memset(&reqbufs, 0, sizeof(reqbufs));
2140 reqbufs.count = 0; 2123 reqbufs.count = 0;
2141 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 2124 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
2142 reqbufs.memory = V4L2_MEMORY_MMAP; 2125 reqbufs.memory = V4L2_MEMORY_MMAP;
2143 if (ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) 2126 if (ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0)
2144 DPLOG(ERROR) << "DestroyMfcOutputBuffers() ioctl() failed: VIDIOC_REQBUFS"; 2127 DPLOG(ERROR) << "DestroyMfcOutputBuffers() ioctl() failed: VIDIOC_REQBUFS";
2145 2128
2146 mfc_output_buffer_map_.clear(); 2129 mfc_output_buffer_map_.clear();
2147 mfc_free_output_buffers_.clear(); 2130 mfc_free_output_buffers_.clear();
2148 mfc_output_buffer_count_ = 0;
2149 } 2131 }
2150 2132
2151 void ExynosVideoDecodeAccelerator::DestroyGscInputBuffers() { 2133 void ExynosVideoDecodeAccelerator::DestroyGscInputBuffers() {
2152 DVLOG(3) << "DestroyGscInputBuffers()"; 2134 DVLOG(3) << "DestroyGscInputBuffers()";
2153 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 2135 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
2154 DCHECK(!gsc_input_streamon_); 2136 DCHECK(!gsc_input_streamon_);
2155 2137
2156 struct v4l2_requestbuffers reqbufs; 2138 struct v4l2_requestbuffers reqbufs;
2157 memset(&reqbufs, 0, sizeof(reqbufs)); 2139 memset(&reqbufs, 0, sizeof(reqbufs));
2158 reqbufs.count = 0; 2140 reqbufs.count = 0;
2159 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 2141 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
2160 reqbufs.memory = V4L2_MEMORY_DMABUF; 2142 reqbufs.memory = V4L2_MEMORY_DMABUF;
2161 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) 2143 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0)
2162 DPLOG(ERROR) << "DestroyGscInputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; 2144 DPLOG(ERROR) << "DestroyGscInputBuffers(): ioctl() failed: VIDIOC_REQBUFS";
2163 2145
2164 gsc_input_buffer_map_.clear(); 2146 gsc_input_buffer_map_.clear();
2165 gsc_free_input_buffers_.clear(); 2147 gsc_free_input_buffers_.clear();
2166 gsc_input_buffer_count_ = 0;
2167 } 2148 }
2168 2149
2169 void ExynosVideoDecodeAccelerator::DestroyGscOutputBuffers() { 2150 void ExynosVideoDecodeAccelerator::DestroyGscOutputBuffers() {
2170 DVLOG(3) << "DestroyGscOutputBuffers()"; 2151 DVLOG(3) << "DestroyGscOutputBuffers()";
2171 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 2152 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
2172 DCHECK(!gsc_output_streamon_); 2153 DCHECK(!gsc_output_streamon_);
2173 2154
2174 if (gsc_output_buffer_map_.size() != 0) { 2155 if (gsc_output_buffer_map_.size() != 0) {
2175 if (!make_context_current_.Run()) 2156 if (!make_context_current_.Run())
2176 DLOG(ERROR) << "DestroyGscOutputBuffers(): " 2157 DLOG(ERROR) << "DestroyGscOutputBuffers(): "
(...skipping 17 matching lines...) Expand all
2194 struct v4l2_requestbuffers reqbufs; 2175 struct v4l2_requestbuffers reqbufs;
2195 memset(&reqbufs, 0, sizeof(reqbufs)); 2176 memset(&reqbufs, 0, sizeof(reqbufs));
2196 reqbufs.count = 0; 2177 reqbufs.count = 0;
2197 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 2178 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
2198 reqbufs.memory = V4L2_MEMORY_DMABUF; 2179 reqbufs.memory = V4L2_MEMORY_DMABUF;
2199 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) 2180 if (ioctl(gsc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0)
2200 DPLOG(ERROR) << "DestroyGscOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; 2181 DPLOG(ERROR) << "DestroyGscOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS";
2201 2182
2202 gsc_output_buffer_map_.clear(); 2183 gsc_output_buffer_map_.clear();
2203 gsc_free_output_buffers_.clear(); 2184 gsc_free_output_buffers_.clear();
2204 gsc_output_buffer_count_ = 0;
2205 } 2185 }
2206 2186
2207 } // namespace content 2187 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/exynos_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698