| 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 "media/gpu/v4l2_video_decode_accelerator.h" | 5 #include "media/gpu/v4l2_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <linux/videodev2.h> | 10 #include <linux/videodev2.h> |
| (...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2103 << ", EGLImage size: " << egl_image_size_.ToString() | 2103 << ", EGLImage size: " << egl_image_size_.ToString() |
| 2104 << ", EGLImage plane count: " << egl_image_planes_count_; | 2104 << ", EGLImage plane count: " << egl_image_planes_count_; |
| 2105 | 2105 |
| 2106 return CreateOutputBuffers(); | 2106 return CreateOutputBuffers(); |
| 2107 } | 2107 } |
| 2108 | 2108 |
| 2109 gfx::Size V4L2VideoDecodeAccelerator::GetVisibleSize( | 2109 gfx::Size V4L2VideoDecodeAccelerator::GetVisibleSize( |
| 2110 const gfx::Size& coded_size) { | 2110 const gfx::Size& coded_size) { |
| 2111 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); | 2111 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| 2112 | 2112 |
| 2113 struct v4l2_crop crop_arg; | 2113 struct v4l2_rect* visible_rect; |
| 2114 memset(&crop_arg, 0, sizeof(crop_arg)); | 2114 struct v4l2_selection selection_arg; |
| 2115 crop_arg.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 2115 memset(&selection_arg, 0, sizeof(selection_arg)); |
| 2116 selection_arg.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 2117 selection_arg.target = V4L2_SEL_TGT_COMPOSE; |
| 2116 | 2118 |
| 2117 if (device_->Ioctl(VIDIOC_G_CROP, &crop_arg) != 0) { | 2119 if (device_->Ioctl(VIDIOC_G_SELECTION, &selection_arg) == 0) { |
| 2118 PLOGF(ERROR) << "ioctl() VIDIOC_G_CROP failed"; | 2120 DVLOGF(2) << "VIDIOC_G_SELECTION is supported"; |
| 2119 return coded_size; | 2121 visible_rect = &selection_arg.r; |
| 2122 } else { |
| 2123 DVLOGF(2) << "Fallback to VIDIOC_G_CROP"; |
| 2124 struct v4l2_crop crop_arg; |
| 2125 memset(&crop_arg, 0, sizeof(crop_arg)); |
| 2126 crop_arg.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 2127 |
| 2128 if (device_->Ioctl(VIDIOC_G_CROP, &crop_arg) != 0) { |
| 2129 PLOGF(ERROR) << "ioctl() VIDIOC_G_CROP failed"; |
| 2130 return coded_size; |
| 2131 } |
| 2132 visible_rect = &crop_arg.c; |
| 2120 } | 2133 } |
| 2121 | 2134 |
| 2122 gfx::Rect rect(crop_arg.c.left, crop_arg.c.top, crop_arg.c.width, | 2135 gfx::Rect rect(visible_rect->left, visible_rect->top, visible_rect->width, |
| 2123 crop_arg.c.height); | 2136 visible_rect->height); |
| 2124 VLOGF(2) << "visible rectangle is " << rect.ToString(); | 2137 VLOGF(2) << "visible rectangle is " << rect.ToString(); |
| 2125 if (!gfx::Rect(coded_size).Contains(rect)) { | 2138 if (!gfx::Rect(coded_size).Contains(rect)) { |
| 2126 DLOGF(ERROR) << "visible rectangle " << rect.ToString() | 2139 DLOGF(ERROR) << "visible rectangle " << rect.ToString() |
| 2127 << " is not inside coded size " << coded_size.ToString(); | 2140 << " is not inside coded size " << coded_size.ToString(); |
| 2128 return coded_size; | 2141 return coded_size; |
| 2129 } | 2142 } |
| 2130 if (rect.IsEmpty()) { | 2143 if (rect.IsEmpty()) { |
| 2131 DLOGF(ERROR) << "visible size is empty"; | 2144 DLOGF(ERROR) << "visible size is empty"; |
| 2132 return coded_size; | 2145 return coded_size; |
| 2133 } | 2146 } |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2640 StartResolutionChange(); | 2653 StartResolutionChange(); |
| 2641 } | 2654 } |
| 2642 } | 2655 } |
| 2643 | 2656 |
| 2644 void V4L2VideoDecodeAccelerator::ImageProcessorError() { | 2657 void V4L2VideoDecodeAccelerator::ImageProcessorError() { |
| 2645 LOGF(ERROR) << "Image processor error"; | 2658 LOGF(ERROR) << "Image processor error"; |
| 2646 NOTIFY_ERROR(PLATFORM_FAILURE); | 2659 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 2647 } | 2660 } |
| 2648 | 2661 |
| 2649 } // namespace media | 2662 } // namespace media |
| OLD | NEW |