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

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

Issue 9814001: Add VAVDA, the VAAPI Video Decode Accelerator for Intel CPUs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for occasional decode freeze on output falling behind for more demanding streams. Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/gpu/media/gpu_video_decode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 12
13 #if defined(OS_WIN) 13 #if defined(OS_WIN)
14 #include "base/win/windows_version.h" 14 #include "base/win/windows_version.h"
15 #endif // OS_WIN 15 #endif // OS_WIN
16 16
17 #include "gpu/command_buffer/common/command_buffer.h" 17 #include "gpu/command_buffer/common/command_buffer.h"
18 #include "ipc/ipc_message_macros.h" 18 #include "ipc/ipc_message_macros.h"
19 #include "ipc/ipc_message_utils.h" 19 #include "ipc/ipc_message_utils.h"
20 #include "content/common/gpu/gpu_channel.h" 20 #include "content/common/gpu/gpu_channel.h"
21 #include "content/common/gpu/gpu_command_buffer_stub.h" 21 #include "content/common/gpu/gpu_command_buffer_stub.h"
22 #include "content/common/gpu/gpu_messages.h" 22 #include "content/common/gpu/gpu_messages.h"
23 23
24 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN)
25 #if defined(OS_WIN) 24 #if defined(OS_WIN)
26 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 25 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
27 #else // OS_WIN 26
27 #elif defined(OS_CHROMEOS)
Ami GONE FROM CHROMIUM 2012/04/09 02:41:47 else isn't buying you clarity here; I'd close the
Pawel Osciak 2012/05/03 16:22:07 Done.
28 #if defined(ARCH_CPU_ARMEL)
28 #include "content/common/gpu/media/omx_video_decode_accelerator.h" 29 #include "content/common/gpu/media/omx_video_decode_accelerator.h"
30 #elif defined(ARCH_CPU_X86_FAMILY)
Ami GONE FROM CHROMIUM 2012/04/09 02:41:47 Is it the case that all cros/intel have VA HW supp
Pawel Osciak 2012/05/03 16:22:07 No, not all of them, but it's harmless, libva will
31 #include "ui/gfx/gl/gl_context_glx.h"
32 #include "ui/gfx/gl/gl_surface_glx.h"
33 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
34 #endif // OS_CHROMEOS
35
29 #endif // OS_WIN 36 #endif // OS_WIN
37
38 #if defined(OS_WIN) || defined(OS_CHROMEOS)
30 #include "ui/gfx/gl/gl_context.h" 39 #include "ui/gfx/gl/gl_context.h"
31 #include "ui/gfx/gl/gl_surface_egl.h" 40 #include "ui/gfx/gl/gl_surface_egl.h"
32 #endif 41 #endif // OS_WIN || OS_CHROMEOS
33 42
34 #include "gpu/command_buffer/service/texture_manager.h" 43 #include "gpu/command_buffer/service/texture_manager.h"
35 #include "ui/gfx/size.h" 44 #include "ui/gfx/size.h"
36 45
37 using gpu::gles2::TextureManager; 46 using gpu::gles2::TextureManager;
38 47
39 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( 48 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
40 IPC::Message::Sender* sender, 49 IPC::Message::Sender* sender,
41 int32 host_route_id, 50 int32 host_route_id,
42 GpuCommandBufferStub* stub) 51 GpuCommandBufferStub* stub)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 125
117 void GpuVideoDecodeAccelerator::Initialize( 126 void GpuVideoDecodeAccelerator::Initialize(
118 const media::VideoCodecProfile profile, 127 const media::VideoCodecProfile profile,
119 IPC::Message* init_done_msg, 128 IPC::Message* init_done_msg,
120 base::ProcessHandle renderer_process) { 129 base::ProcessHandle renderer_process) {
121 DCHECK(!video_decode_accelerator_.get()); 130 DCHECK(!video_decode_accelerator_.get());
122 DCHECK(!init_done_msg_); 131 DCHECK(!init_done_msg_);
123 DCHECK(init_done_msg); 132 DCHECK(init_done_msg);
124 init_done_msg_ = init_done_msg; 133 init_done_msg_ = init_done_msg;
125 134
126 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN) 135 #if defined(OS_CHROMEOS) || defined(OS_WIN)
127 DCHECK(stub_ && stub_->decoder()); 136 DCHECK(stub_ && stub_->decoder());
128 #if defined(OS_WIN) 137 #if defined(OS_WIN)
129 if (base::win::GetVersion() < base::win::VERSION_WIN7) { 138 if (base::win::GetVersion() < base::win::VERSION_WIN7) {
130 NOTIMPLEMENTED() << "HW video decode acceleration not available."; 139 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
131 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 140 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
132 return; 141 return;
133 } 142 }
134 DLOG(INFO) << "Initializing DXVA HW decoder for windows."; 143 DLOG(INFO) << "Initializing DXVA HW decoder for windows.";
135 DXVAVideoDecodeAccelerator* video_decoder = 144 DXVAVideoDecodeAccelerator* video_decoder =
136 new DXVAVideoDecodeAccelerator(this, renderer_process); 145 new DXVAVideoDecodeAccelerator(this, renderer_process);
137 #else // OS_WIN 146 #elif defined(OS_CHROMEOS) // OS_WIN
147 #if defined(ARCH_CPU_ARMEL)
138 OmxVideoDecodeAccelerator* video_decoder = 148 OmxVideoDecodeAccelerator* video_decoder =
139 new OmxVideoDecodeAccelerator(this); 149 new OmxVideoDecodeAccelerator(this);
140 video_decoder->SetEglState( 150 video_decoder->SetEglState(
141 gfx::GLSurfaceEGL::GetHardwareDisplay(), 151 gfx::GLSurfaceEGL::GetHardwareDisplay(),
142 stub_->decoder()->GetGLContext()->GetHandle()); 152 stub_->decoder()->GetGLContext()->GetHandle());
153 #elif defined(ARCH_CPU_X86_FAMILY)
154 VaapiVideoDecodeAccelerator* video_decoder =
155 new VaapiVideoDecodeAccelerator(this);
156 gfx::GLContextGLX* glx_context =
157 static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext());
158 Display* display = glx_context->GetDisplay();
159 GLXContext glx_context_handle =
160 static_cast<GLXContext>(glx_context->GetHandle());
161 video_decoder->SetGlxState(display, glx_context_handle);
162 #endif // ARCH_CPU_ARMEL
143 #endif // OS_WIN 163 #endif // OS_WIN
144 video_decode_accelerator_ = video_decoder; 164 video_decode_accelerator_ = video_decoder;
145 if (!video_decode_accelerator_->Initialize(profile)) 165 if (!video_decode_accelerator_->Initialize(profile))
146 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 166 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
147 #else // Update RenderViewImpl::createMediaPlayer when adding clauses. 167 #else // Update RenderViewImpl::createMediaPlayer when adding clauses.
148 NOTIMPLEMENTED() << "HW video decode acceleration not available."; 168 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
149 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 169 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
150 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 170 #endif // defined(OS_CHROMEOS) || defined(OS_WIN)
151 } 171 }
152 172
153 void GpuVideoDecodeAccelerator::OnDecode( 173 void GpuVideoDecodeAccelerator::OnDecode(
154 base::SharedMemoryHandle handle, int32 id, int32 size) { 174 base::SharedMemoryHandle handle, int32 id, int32 size) {
155 DCHECK(video_decode_accelerator_.get()); 175 DCHECK(video_decode_accelerator_.get());
156 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); 176 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size));
157 } 177 }
158 178
159 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( 179 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers(
160 const std::vector<int32>& buffer_ids, 180 const std::vector<int32>& buffer_ids,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 256
237 void GpuVideoDecodeAccelerator::NotifyResetDone() { 257 void GpuVideoDecodeAccelerator::NotifyResetDone() {
238 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) 258 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_)))
239 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; 259 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed";
240 } 260 }
241 261
242 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { 262 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) {
243 DCHECK(sender_); 263 DCHECK(sender_);
244 return sender_->Send(message); 264 return sender_->Send(message);
245 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698