| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/gpu/media/exynos_video_encode_accelerator.h" | 5 #include "content/common/gpu/media/exynos_video_encode_accelerator.h" |
| 6 | 6 |
| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf)) != 0) { | 700 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf)) != 0) { |
| 701 if (errno == EAGAIN) { | 701 if (errno == EAGAIN) { |
| 702 // EAGAIN if we're just out of buffers to dequeue. | 702 // EAGAIN if we're just out of buffers to dequeue. |
| 703 break; | 703 break; |
| 704 } | 704 } |
| 705 DPLOG(ERROR) << "DequeueMfc(): ioctl() failed: VIDIOC_DQBUF"; | 705 DPLOG(ERROR) << "DequeueMfc(): ioctl() failed: VIDIOC_DQBUF"; |
| 706 NOTIFY_ERROR(kPlatformFailureError); | 706 NOTIFY_ERROR(kPlatformFailureError); |
| 707 return; | 707 return; |
| 708 } | 708 } |
| 709 const bool key_frame = ((dqbuf.flags & V4L2_BUF_FLAG_KEYFRAME) != 0); | 709 const bool key_frame = ((dqbuf.flags & V4L2_BUF_FLAG_KEYFRAME) != 0); |
| 710 const size_t output_size = dqbuf.m.planes[0].bytesused; | 710 size_t output_size = dqbuf.m.planes[0].bytesused; |
| 711 MfcOutputRecord& output_record = mfc_output_buffer_map_[dqbuf.index]; | 711 MfcOutputRecord& output_record = mfc_output_buffer_map_[dqbuf.index]; |
| 712 DCHECK(output_record.at_device); | 712 DCHECK(output_record.at_device); |
| 713 DCHECK(output_record.buffer_ref.get()); | 713 DCHECK(output_record.buffer_ref.get()); |
| 714 uint8* data = | 714 uint8* data = |
| 715 reinterpret_cast<uint8*>(output_record.buffer_ref->shm->memory()); | 715 reinterpret_cast<uint8*>(output_record.buffer_ref->shm->memory()); |
| 716 if (stream_header_size_ == 0) { | 716 if (stream_header_size_ == 0) { |
| 717 // Assume that the first buffer dequeued is the stream header. | 717 // Assume that the first buffer dequeued is the stream header. |
| 718 stream_header_size_ = output_size; | 718 stream_header_size_ = output_size; |
| 719 stream_header_.reset(new uint8[stream_header_size_]); | 719 stream_header_.reset(new uint8[stream_header_size_]); |
| 720 memcpy(stream_header_.get(), data, stream_header_size_); | 720 memcpy(stream_header_.get(), data, stream_header_size_); |
| 721 } | 721 } |
| 722 if (key_frame && | 722 if (key_frame && |
| 723 output_buffer_byte_size_ - stream_header_size_ >= output_size) { | 723 output_buffer_byte_size_ - stream_header_size_ >= output_size) { |
| 724 // Insert stream header before every keyframe. | 724 // Insert stream header before every keyframe. |
| 725 memmove(data + stream_header_size_, data, output_size); | 725 memmove(data + stream_header_size_, data, output_size); |
| 726 memcpy(data, stream_header_.get(), stream_header_size_); | 726 memcpy(data, stream_header_.get(), stream_header_size_); |
| 727 output_size += stream_header_size_; |
| 727 } | 728 } |
| 728 DVLOG(3) << "DequeueMfc(): returning " | 729 DVLOG(3) << "DequeueMfc(): returning " |
| 729 "bitstream_buffer_id=" << output_record.buffer_ref->id | 730 "bitstream_buffer_id=" << output_record.buffer_ref->id |
| 730 << ", key_frame=" << key_frame; | 731 << ", key_frame=" << key_frame; |
| 731 child_message_loop_proxy_->PostTask( | 732 child_message_loop_proxy_->PostTask( |
| 732 FROM_HERE, | 733 FROM_HERE, |
| 733 base::Bind(&Client::BitstreamBufferReady, | 734 base::Bind(&Client::BitstreamBufferReady, |
| 734 client_, | 735 client_, |
| 735 output_record.buffer_ref->id, | 736 output_record.buffer_ref->id, |
| 736 dqbuf.m.planes[0].bytesused, | 737 output_size, |
| 737 key_frame)); | 738 key_frame)); |
| 738 output_record.at_device = false; | 739 output_record.at_device = false; |
| 739 output_record.buffer_ref.reset(); | 740 output_record.buffer_ref.reset(); |
| 740 mfc_free_output_buffers_.push_back(dqbuf.index); | 741 mfc_free_output_buffers_.push_back(dqbuf.index); |
| 741 mfc_output_buffer_queued_count_--; | 742 mfc_output_buffer_queued_count_--; |
| 742 } | 743 } |
| 743 } | 744 } |
| 744 | 745 |
| 745 bool ExynosVideoEncodeAccelerator::EnqueueGscInputRecord() { | 746 bool ExynosVideoEncodeAccelerator::EnqueueGscInputRecord() { |
| 746 DVLOG(3) << "EnqueueGscInputRecord()"; | 747 DVLOG(3) << "EnqueueGscInputRecord()"; |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1482 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1482 reqbufs.memory = V4L2_MEMORY_USERPTR; | 1483 reqbufs.memory = V4L2_MEMORY_USERPTR; |
| 1483 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs)) != 0) | 1484 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs)) != 0) |
| 1484 DPLOG(ERROR) << "DestroyMfcOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; | 1485 DPLOG(ERROR) << "DestroyMfcOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; |
| 1485 | 1486 |
| 1486 mfc_output_buffer_map_.clear(); | 1487 mfc_output_buffer_map_.clear(); |
| 1487 mfc_free_output_buffers_.clear(); | 1488 mfc_free_output_buffers_.clear(); |
| 1488 } | 1489 } |
| 1489 | 1490 |
| 1490 } // namespace content | 1491 } // namespace content |
| OLD | NEW |