Index: content/common/gpu/media/v4l2_video_decode_accelerator.cc |
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
index 7aa737406c9f2f92347c9024e4f03f2146254f8d..5f087e7e429c1c4636fefc8ba7713c1814d29d6a 100644 |
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
@@ -21,6 +21,7 @@ |
#include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
#include "media/base/media_switches.h" |
#include "media/filters/h264_parser.h" |
+#include "ui/gfx/geometry/rect.h" |
#include "ui/gl/scoped_binders.h" |
#define NOTIFY_ERROR(x) \ |
@@ -745,6 +746,8 @@ bool V4L2VideoDecodeAccelerator::DecodeBufferInitial( |
// Success! Setup our parameters. |
if (!CreateBuffersForFormat(format)) |
return false; |
+ if (!GetCropSize(frame_buffer_size_, &frame_visible_size_)) |
+ frame_visible_size_ = frame_buffer_size_; |
// We expect to process the initial buffer once during stream init to |
// configure stream parameters, but will not consume the steam data on that |
@@ -1084,9 +1087,8 @@ void V4L2VideoDecodeAccelerator::Dequeue() { |
DVLOG(3) << "Dequeue(): returning input_id=" << dqbuf.timestamp.tv_sec |
<< " as picture_id=" << output_record.picture_id; |
const media::Picture& picture = |
- media::Picture(output_record.picture_id, |
- dqbuf.timestamp.tv_sec, |
- gfx::Rect(frame_buffer_size_)); |
+ media::Picture(output_record.picture_id, dqbuf.timestamp.tv_sec, |
+ gfx::Rect(frame_visible_size_)); |
pending_picture_ready_.push( |
PictureRecord(output_record.cleared, picture)); |
SendPictureReady(); |
@@ -1546,6 +1548,8 @@ void V4L2VideoDecodeAccelerator::FinishResolutionChange() { |
NOTIFY_ERROR(PLATFORM_FAILURE); |
return; |
} |
+ if (!GetCropSize(frame_buffer_size_, &frame_visible_size_)) |
Pawel Osciak
2015/01/29 05:02:04
Could we call this from GetFormatInfo()?
kcwu
2015/01/29 09:33:11
Done.
|
+ frame_visible_size_ = frame_buffer_size_; |
decoder_state_ = kDecoding; |
@@ -1658,6 +1662,34 @@ bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat( |
return true; |
} |
+bool V4L2VideoDecodeAccelerator::GetCropSize(const gfx::Size& buffer_size, |
+ gfx::Size* crop_size) { |
+ DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
+ |
+ struct v4l2_crop crop_arg; |
Pawel Osciak
2015/01/29 05:02:04
memset to 0 please.
kcwu
2015/01/29 09:33:10
Done.
|
+ crop_arg.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
+ |
+ IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CROP, &crop_arg); |
+ |
+ gfx::Rect rect(crop_arg.c.left, crop_arg.c.top, crop_arg.c.width, |
+ crop_arg.c.height); |
+ DVLOG(3) << "Crop rectangle is " << rect.ToString(); |
Pawel Osciak
2015/01/29 05:02:04
Let's stop calling this crop and say visible size
kcwu
2015/01/29 09:33:11
Done.
|
+ if (!gfx::Rect(buffer_size).Contains(rect)) { |
Pawel Osciak
2015/01/29 05:02:04
Please also check if it's !Empty()
kcwu
2015/01/29 09:33:10
Done.
|
+ DLOG(ERROR) << "crop rectangle " << rect.ToString() |
+ << " is not inside buffer size " << buffer_size.ToString(); |
+ return false; |
+ } |
+ |
+ if (!rect.origin().IsOrigin()) { |
Pawel Osciak
2015/01/29 05:02:04
Please add a comment why.
kcwu
2015/01/29 09:33:10
Done.
|
+ DLOG(ERROR) << "Unexpected crop rectangle " << rect.ToString() |
+ << ", top-left is not origin"; |
+ return false; |
+ } |
+ *crop_size = rect.size(); |
+ |
+ return true; |
+} |
+ |
bool V4L2VideoDecodeAccelerator::CreateInputBuffers() { |
DVLOG(3) << "CreateInputBuffers()"; |
// We always run this as we prepare to initialize. |
@@ -1978,6 +2010,14 @@ bool V4L2VideoDecodeAccelerator::IsResolutionChangeNecessary() { |
DVLOG(3) << "IsResolutionChangeNecessary(): Resolution change detected"; |
return true; |
} |
+ |
+ gfx::Size new_crop_size; |
+ if (GetCropSize(new_size, &new_crop_size) && |
+ new_crop_size != frame_visible_size_) { |
+ DVLOG(3) << "IsResolutionChangeNecessary(): crop size change detected"; |
Pawel Osciak
2015/01/29 05:02:04
Crop size does not influence resolution change. If
kcwu
2015/01/29 09:33:11
Done.
|
+ return true; |
+ } |
+ |
return false; |
} |