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

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

Issue 597473002: Change log level to show real errors in release mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Pawel's review comments Created 6 years, 2 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
OLDNEW
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 <linux/videodev2.h> 5 #include <linux/videodev2.h>
6 6
7 #include "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "content/common/gpu/media/exynos_v4l2_video_device.h" 8 #include "content/common/gpu/media/exynos_v4l2_video_device.h"
9 #include "content/common/gpu/media/tegra_v4l2_video_device.h" 9 #include "content/common/gpu/media/tegra_v4l2_video_device.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 V4L2Device::~V4L2Device() {} 13 V4L2Device::~V4L2Device() {}
14 14
15 // static 15 // static
16 scoped_ptr<V4L2Device> V4L2Device::Create(Type type) { 16 scoped_ptr<V4L2Device> V4L2Device::Create(Type type) {
17 DVLOG(3) << __PRETTY_FUNCTION__; 17 DVLOG(3) << __PRETTY_FUNCTION__;
18 18
19 scoped_ptr<ExynosV4L2Device> exynos_device(new ExynosV4L2Device(type)); 19 scoped_ptr<ExynosV4L2Device> exynos_device(new ExynosV4L2Device(type));
20 if (exynos_device->Initialize()) 20 if (exynos_device->Initialize())
21 return exynos_device.PassAs<V4L2Device>(); 21 return exynos_device.PassAs<V4L2Device>();
22 22
23 scoped_ptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type)); 23 scoped_ptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type));
24 if (tegra_device->Initialize()) 24 if (tegra_device->Initialize())
25 return tegra_device.PassAs<V4L2Device>(); 25 return tegra_device.PassAs<V4L2Device>();
26 26
27 DLOG(ERROR) << "Failed to create V4L2Device"; 27 LOG(ERROR) << "Failed to create V4L2Device";
28 return scoped_ptr<V4L2Device>(); 28 return scoped_ptr<V4L2Device>();
29 } 29 }
30 30
31 // static 31 // static
32 media::VideoFrame::Format V4L2Device::V4L2PixFmtToVideoFrameFormat( 32 media::VideoFrame::Format V4L2Device::V4L2PixFmtToVideoFrameFormat(
33 uint32 pix_fmt) { 33 uint32 pix_fmt) {
34 switch (pix_fmt) { 34 switch (pix_fmt) {
35 case V4L2_PIX_FMT_NV12: 35 case V4L2_PIX_FMT_NV12:
36 case V4L2_PIX_FMT_NV12M: 36 case V4L2_PIX_FMT_NV12M:
37 return media::VideoFrame::NV12; 37 return media::VideoFrame::NV12;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 int horiz_bpp = 107 int horiz_bpp =
108 media::VideoFrame::PlaneHorizontalBitsPerPixel(frame_format, 0); 108 media::VideoFrame::PlaneHorizontalBitsPerPixel(frame_format, 0);
109 DVLOG(3) << __func__ << ": bytesperline=" << bytesperline 109 DVLOG(3) << __func__ << ": bytesperline=" << bytesperline
110 << ", sizeimage=" << sizeimage 110 << ", sizeimage=" << sizeimage
111 << ", visible_size=" << visible_size.ToString() << ", frame_format=" 111 << ", visible_size=" << visible_size.ToString() << ", frame_format="
112 << media::VideoFrame::FormatToString(frame_format) 112 << media::VideoFrame::FormatToString(frame_format)
113 << ", horiz_bpp=" << horiz_bpp; 113 << ", horiz_bpp=" << horiz_bpp;
114 if (sizeimage == 0 || bytesperline == 0 || horiz_bpp == 0 || 114 if (sizeimage == 0 || bytesperline == 0 || horiz_bpp == 0 ||
115 (bytesperline * 8) % horiz_bpp != 0) { 115 (bytesperline * 8) % horiz_bpp != 0) {
116 DLOG(ERROR) << "Invalid format provided"; 116 LOG(ERROR) << "Invalid format provided";
117 return coded_size; 117 return coded_size;
118 } 118 }
119 119
120 // Round up sizeimage to full bytesperlines. sizeimage does not have to be 120 // Round up sizeimage to full bytesperlines. sizeimage does not have to be
121 // a multiple of bytesperline, as in V4L2 terms it's just a byte size of 121 // a multiple of bytesperline, as in V4L2 terms it's just a byte size of
122 // the buffer, unrelated to its payload. 122 // the buffer, unrelated to its payload.
123 sizeimage = ((sizeimage + bytesperline - 1) / bytesperline) * bytesperline; 123 sizeimage = ((sizeimage + bytesperline - 1) / bytesperline) * bytesperline;
124 124
125 coded_size.SetSize(bytesperline * 8 / horiz_bpp, sizeimage / bytesperline); 125 coded_size.SetSize(bytesperline * 8 / horiz_bpp, sizeimage / bytesperline);
126 DVLOG(3) << "coded_size=" << coded_size.ToString(); 126 DVLOG(3) << "coded_size=" << coded_size.ToString();
127 127
128 // Sanity checks. Calculated coded size has to contain given visible size 128 // Sanity checks. Calculated coded size has to contain given visible size
129 // and fulfill buffer byte size requirements for each plane. 129 // and fulfill buffer byte size requirements for each plane.
130 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size))); 130 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size)));
131 131
132 if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) { 132 if (V4L2_TYPE_IS_MULTIPLANAR(format.type)) {
133 for (size_t i = 0; i < format.fmt.pix_mp.num_planes; ++i) { 133 for (size_t i = 0; i < format.fmt.pix_mp.num_planes; ++i) {
134 DCHECK_EQ(format.fmt.pix_mp.plane_fmt[i].bytesperline, 134 DCHECK_EQ(format.fmt.pix_mp.plane_fmt[i].bytesperline,
135 base::checked_cast<__u32>(media::VideoFrame::RowBytes( 135 base::checked_cast<__u32>(media::VideoFrame::RowBytes(
136 i, frame_format, coded_size.width()))); 136 i, frame_format, coded_size.width())));
137 } 137 }
138 } 138 }
139 139
140 return coded_size; 140 return coded_size;
141 } 141 }
142 142
143 } // namespace content 143 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698