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

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: Rebase 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() {
22 }
20 23
21 // static 24 // static
22 scoped_ptr<V4L2Device> V4L2Device::Create(Type type) { 25 scoped_refptr<V4L2Device> V4L2Device::Create(Type type) {
23 DVLOG(3) << __PRETTY_FUNCTION__; 26 DVLOG(3) << __PRETTY_FUNCTION__;
24 27
25 scoped_ptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type)); 28 scoped_refptr<GenericV4L2Device> generic_device(new GenericV4L2Device(type));
26 if (generic_device->Initialize()) 29 if (generic_device->Initialize())
27 return generic_device.Pass(); 30 return generic_device;
28 31
29 #if defined(ARCH_CPU_ARMEL) 32 #if defined(ARCH_CPU_ARMEL)
30 scoped_ptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type)); 33 scoped_refptr<TegraV4L2Device> tegra_device(new TegraV4L2Device(type));
31 if (tegra_device->Initialize()) 34 if (tegra_device->Initialize())
32 return tegra_device.Pass(); 35 return tegra_device;
33 #endif 36 #endif
34 37
35 LOG(ERROR) << "Failed to create V4L2Device"; 38 LOG(ERROR) << "Failed to create V4L2Device";
36 return scoped_ptr<V4L2Device>(); 39 return scoped_refptr<V4L2Device>();
37 } 40 }
38 41
39 // static 42 // static
40 media::VideoFrame::Format V4L2Device::V4L2PixFmtToVideoFrameFormat( 43 media::VideoFrame::Format V4L2Device::V4L2PixFmtToVideoFrameFormat(
41 uint32 pix_fmt) { 44 uint32 pix_fmt) {
42 switch (pix_fmt) { 45 switch (pix_fmt) {
43 case V4L2_PIX_FMT_NV12: 46 case V4L2_PIX_FMT_NV12:
44 case V4L2_PIX_FMT_NV12M: 47 case V4L2_PIX_FMT_NV12M:
45 return media::VideoFrame::NV12; 48 return media::VideoFrame::NV12;
46 49
(...skipping 21 matching lines...) Expand all
68 return V4L2_PIX_FMT_YUV420M; 71 return V4L2_PIX_FMT_YUV420M;
69 72
70 default: 73 default:
71 LOG(FATAL) << "Add more cases as needed"; 74 LOG(FATAL) << "Add more cases as needed";
72 return 0; 75 return 0;
73 } 76 }
74 } 77 }
75 78
76 // static 79 // static
77 uint32 V4L2Device::VideoCodecProfileToV4L2PixFmt( 80 uint32 V4L2Device::VideoCodecProfileToV4L2PixFmt(
78 media::VideoCodecProfile profile) { 81 media::VideoCodecProfile profile,
82 bool slice_based) {
79 if (profile >= media::H264PROFILE_MIN && 83 if (profile >= media::H264PROFILE_MIN &&
80 profile <= media::H264PROFILE_MAX) { 84 profile <= media::H264PROFILE_MAX) {
81 return V4L2_PIX_FMT_H264; 85 if (slice_based)
86 return V4L2_PIX_FMT_H264_SLICE;
87 else
88 return V4L2_PIX_FMT_H264;
82 } else if (profile >= media::VP8PROFILE_MIN && 89 } else if (profile >= media::VP8PROFILE_MIN &&
83 profile <= media::VP8PROFILE_MAX) { 90 profile <= media::VP8PROFILE_MAX) {
84 return V4L2_PIX_FMT_VP8; 91 if (slice_based)
92 return V4L2_PIX_FMT_VP8_FRAME;
93 else
94 return V4L2_PIX_FMT_VP8;
85 } else if (profile >= media::VP9PROFILE_MIN && 95 } else if (profile >= media::VP9PROFILE_MIN &&
86 profile <= media::VP9PROFILE_MAX) { 96 profile <= media::VP9PROFILE_MAX) {
87 return V4L2_PIX_FMT_VP9; 97 return V4L2_PIX_FMT_VP9;
88 } else { 98 } else {
89 LOG(FATAL) << "Add more cases as needed"; 99 LOG(FATAL) << "Add more cases as needed";
90 return 0; 100 return 0;
91 } 101 }
92 } 102 }
93 103
94 // static 104 // 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 196 // Sanity checks. Calculated coded size has to contain given visible size
187 // and fulfill buffer byte size requirements. 197 // and fulfill buffer byte size requirements.
188 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size))); 198 DCHECK(gfx::Rect(coded_size).Contains(gfx::Rect(visible_size)));
189 DCHECK_LE(sizeimage, 199 DCHECK_LE(sizeimage,
190 media::VideoFrame::AllocationSize(frame_format, coded_size)); 200 media::VideoFrame::AllocationSize(frame_format, coded_size));
191 201
192 return coded_size; 202 return coded_size;
193 } 203 }
194 204
195 } // namespace content 205 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/v4l2_video_device.h ('k') | content/common/gpu/media/v4l2_video_encode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698