OLD | NEW |
---|---|
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 "content/renderer/pepper/video_decoder_shim.h" | 5 #include "content/renderer/pepper/video_decoder_shim.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
15 #include "content/renderer/pepper/pepper_video_decoder_host.h" | 15 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
16 #include "content/renderer/render_thread_impl.h" | 16 #include "content/renderer/render_thread_impl.h" |
17 #include "gpu/command_buffer/client/gles2_implementation.h" | 17 #include "gpu/command_buffer/client/gles2_implementation.h" |
18 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
19 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
20 #include "media/base/video_decoder.h" | 20 #include "media/base/video_decoder.h" |
21 #include "media/filters/ffmpeg_video_decoder.h" | 21 #include "media/filters/ffmpeg_video_decoder.h" |
22 #include "media/filters/skcanvas_video_renderer.h" | |
22 #include "media/filters/vpx_video_decoder.h" | 23 #include "media/filters/vpx_video_decoder.h" |
23 #include "media/video/picture.h" | 24 #include "media/video/picture.h" |
24 #include "media/video/video_decode_accelerator.h" | 25 #include "media/video/video_decode_accelerator.h" |
25 #include "ppapi/c/pp_errors.h" | 26 #include "ppapi/c/pp_errors.h" |
26 #include "third_party/libyuv/include/libyuv.h" | 27 #include "third_party/libyuv/include/libyuv.h" |
sandersd (OOO until July 31)
2015/01/27 18:16:45
Remove?
bbudge
2015/01/27 18:23:01
Yep. Done.
| |
27 #include "webkit/common/gpu/context_provider_web_context.h" | 28 #include "webkit/common/gpu/context_provider_web_context.h" |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
31 struct VideoDecoderShim::PendingDecode { | 32 struct VideoDecoderShim::PendingDecode { |
32 PendingDecode(uint32_t decode_id, | 33 PendingDecode(uint32_t decode_id, |
33 const scoped_refptr<media::DecoderBuffer>& buffer); | 34 const scoped_refptr<media::DecoderBuffer>& buffer); |
34 ~PendingDecode(); | 35 ~PendingDecode(); |
35 | 36 |
36 const uint32_t decode_id; | 37 const uint32_t decode_id; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 DoDecode(); | 261 DoDecode(); |
261 } | 262 } |
262 | 263 |
263 void VideoDecoderShim::DecoderImpl::OnOutputComplete( | 264 void VideoDecoderShim::DecoderImpl::OnOutputComplete( |
264 const scoped_refptr<media::VideoFrame>& frame) { | 265 const scoped_refptr<media::VideoFrame>& frame) { |
265 scoped_ptr<PendingFrame> pending_frame; | 266 scoped_ptr<PendingFrame> pending_frame; |
266 if (!frame->end_of_stream()) { | 267 if (!frame->end_of_stream()) { |
267 pending_frame.reset(new PendingFrame( | 268 pending_frame.reset(new PendingFrame( |
268 decode_id_, frame->coded_size(), frame->visible_rect())); | 269 decode_id_, frame->coded_size(), frame->visible_rect())); |
269 // Convert the VideoFrame pixels to ABGR to match VideoDecodeAccelerator. | 270 // Convert the VideoFrame pixels to ABGR to match VideoDecodeAccelerator. |
270 libyuv::I420ToABGR(frame->data(media::VideoFrame::kYPlane), | 271 media::SkCanvasVideoRenderer::ConvertVideoFrameToRGBPixels( |
271 frame->stride(media::VideoFrame::kYPlane), | 272 frame, |
272 frame->data(media::VideoFrame::kUPlane), | 273 &pending_frame->argb_pixels.front(), |
273 frame->stride(media::VideoFrame::kUPlane), | 274 frame->coded_size().width() * 4); |
274 frame->data(media::VideoFrame::kVPlane), | |
275 frame->stride(media::VideoFrame::kVPlane), | |
276 &pending_frame->argb_pixels.front(), | |
277 frame->coded_size().width() * 4, | |
278 frame->coded_size().width(), | |
279 frame->coded_size().height()); | |
280 } else { | 275 } else { |
281 pending_frame.reset(new PendingFrame(decode_id_)); | 276 pending_frame.reset(new PendingFrame(decode_id_)); |
282 } | 277 } |
283 | 278 |
284 main_message_loop_->PostTask(FROM_HERE, | 279 main_message_loop_->PostTask(FROM_HERE, |
285 base::Bind(&VideoDecoderShim::OnOutputComplete, | 280 base::Bind(&VideoDecoderShim::OnOutputComplete, |
286 shim_, | 281 shim_, |
287 base::Passed(&pending_frame))); | 282 base::Passed(&pending_frame))); |
288 } | 283 } |
289 | 284 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 583 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { |
589 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 584 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
590 gles2->DeleteTextures(1, &texture_id); | 585 gles2->DeleteTextures(1, &texture_id); |
591 } | 586 } |
592 | 587 |
593 void VideoDecoderShim::FlushCommandBuffer() { | 588 void VideoDecoderShim::FlushCommandBuffer() { |
594 context_provider_->ContextGL()->Flush(); | 589 context_provider_->ContextGL()->Flush(); |
595 } | 590 } |
596 | 591 |
597 } // namespace content | 592 } // namespace content |
OLD | NEW |