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

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

Issue 833063003: Add accelerated video decoder interface, VP8 and H.264 implementations and hook up to V4L2SVDA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed all comments. Created 5 years, 11 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 <libdrm/drm_fourcc.h> 5 #include <libdrm/drm_fourcc.h>
6 #include <linux/videodev2.h> 6 #include <linux/videodev2.h>
7 7
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "content/common/gpu/media/generic_v4l2_video_device.h" 9 #include "content/common/gpu/media/generic_v4l2_video_device.h"
10 #if defined(ARCH_CPU_ARMEL) 10 #if defined(ARCH_CPU_ARMEL)
11 #include "content/common/gpu/media/tegra_v4l2_video_device.h" 11 #include "content/common/gpu/media/tegra_v4l2_video_device.h"
12 #endif 12 #endif
13 13
14 // TODO(posciak): remove this once V4L2 headers are updated. 14 // TODO(posciak): remove this once V4L2 headers are updated.
15 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') 15 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')
16 #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4')
17 #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F')
16 18
17 namespace content { 19 namespace content {
18 20
19 V4L2Device::~V4L2Device() {} 21 V4L2Device::~V4L2Device() {}
20 22
21 // static 23 // static
22 scoped_ptr<V4L2Device> V4L2Device::Create(Type type) { 24 scoped_refptr<V4L2Device> V4L2Device::Create(Type type) {
23 DVLOG(3) << __PRETTY_FUNCTION__; 25 DVLOG(3) << __PRETTY_FUNCTION__;
24 26
25 scoped_ptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type)); 27 scoped_refptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type));
26 if (generic_device->Initialize()) 28 if (generic_device->Initialize())
27 return generic_device.Pass(); 29 return generic_device;
28 30
29 #if defined(ARCH_CPU_ARMEL) 31 #if defined(ARCH_CPU_ARMEL)
30 scoped_ptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type)); 32 scoped_refptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type));
31 if (tegra_device->Initialize()) 33 if (tegra_device->Initialize())
32 return tegra_device.Pass(); 34 return tegra_device;
33 #endif 35 #endif
34 36
35 LOG(ERROR) << "Failed to create V4L2Device"; 37 LOG(ERROR) << "Failed to create V4L2Device";
36 return scoped_ptr<V4L2Device>(); 38 return scoped_refptr<V4L2Device>();
37 } 39 }
38 40
39 // static 41 // static
40 media::VideoFrame::Format V4L2Device::V4L2PixFmtToVideoFrameFormat( 42 media::VideoFrame::Format V4L2Device::V4L2PixFmtToVideoFrameFormat(
41 uint32 pix_fmt) { 43 uint32 pix_fmt) {
42 switch (pix_fmt) { 44 switch (pix_fmt) {
43 case V4L2_PIX_FMT_NV12: 45 case V4L2_PIX_FMT_NV12:
44 case V4L2_PIX_FMT_NV12M: 46 case V4L2_PIX_FMT_NV12M:
45 return media::VideoFrame::NV12; 47 return media::VideoFrame::NV12;
46 48
(...skipping 21 matching lines...) Expand all
68 return V4L2_PIX_FMT_YUV420M; 70 return V4L2_PIX_FMT_YUV420M;
69 71
70 default: 72 default:
71 LOG(FATAL) << "Add more cases as needed"; 73 LOG(FATAL) << "Add more cases as needed";
72 return 0; 74 return 0;
73 } 75 }
74 } 76 }
75 77
76 // static 78 // static
77 uint32 V4L2Device::VideoCodecProfileToV4L2PixFmt( 79 uint32 V4L2Device::VideoCodecProfileToV4L2PixFmt(
78 media::VideoCodecProfile profile) { 80 media::VideoCodecProfile profile,
81 bool slice_based) {
79 if (profile >= media::H264PROFILE_MIN && 82 if (profile >= media::H264PROFILE_MIN &&
80 profile <= media::H264PROFILE_MAX) { 83 profile <= media::H264PROFILE_MAX) {
81 return V4L2_PIX_FMT_H264; 84 if (slice_based)
85 return V4L2_PIX_FMT_H264_SLICE;
86 else
87 return V4L2_PIX_FMT_H264;
82 } else if (profile >= media::VP8PROFILE_MIN && 88 } else if (profile >= media::VP8PROFILE_MIN &&
83 profile <= media::VP8PROFILE_MAX) { 89 profile <= media::VP8PROFILE_MAX) {
84 return V4L2_PIX_FMT_VP8; 90 if (slice_based)
91 return V4L2_PIX_FMT_VP8_FRAME;
92 else
93 return V4L2_PIX_FMT_VP8;
85 } else if (profile >= media::VP9PROFILE_MIN && 94 } else if (profile >= media::VP9PROFILE_MIN &&
86 profile <= media::VP9PROFILE_MAX) { 95 profile <= media::VP9PROFILE_MAX) {
87 return V4L2_PIX_FMT_VP9; 96 return V4L2_PIX_FMT_VP9;
88 } else { 97 } else {
89 LOG(FATAL) << "Add more cases as needed"; 98 LOG(FATAL) << "Add more cases as needed";
90 return 0; 99 return 0;
91 } 100 }
92 } 101 }
93 102
94 // static 103 // static
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Sanity checks. Calculated coded size has to contain given visible size 195 // Sanity checks. Calculated coded size has to contain given visible size
187 // and fulfill buffer byte size requirements. 196 // and fulfill buffer byte size requirements.
188 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size))); 197 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size)));
189 DCHECK_LE(sizeimage, 198 DCHECK_LE(sizeimage,
190 media::VideoFrame::AllocationSize(frame_format, coded_size)); 199 media::VideoFrame::AllocationSize(frame_format, coded_size));
191 200
192 return coded_size; 201 return coded_size;
193 } 202 }
194 203
195 } // namespace content 204 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698