| 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 "content/public/renderer/render_thread.h" | 13 #include "content/public/renderer/render_thread.h" |
| 14 #include "content/renderer/pepper/pepper_video_decoder_host.h" | 14 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
| 15 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
| 16 #include "gpu/command_buffer/client/gles2_implementation.h" | 16 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 17 #include "media/base/decoder_buffer.h" | 17 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/limits.h" | 18 #include "media/base/limits.h" |
| 19 #include "media/base/video_decoder.h" | 19 #include "media/base/video_decoder.h" |
| 20 #include "media/filters/ffmpeg_video_decoder.h" | 20 #include "media/filters/ffmpeg_video_decoder.h" |
| 21 #include "media/filters/vpx_video_decoder.h" |
| 21 #include "media/video/picture.h" | 22 #include "media/video/picture.h" |
| 22 #include "media/video/video_decode_accelerator.h" | 23 #include "media/video/video_decode_accelerator.h" |
| 23 #include "ppapi/c/pp_errors.h" | 24 #include "ppapi/c/pp_errors.h" |
| 24 #include "third_party/libyuv/include/libyuv.h" | 25 #include "third_party/libyuv/include/libyuv.h" |
| 25 #include "webkit/common/gpu/context_provider_web_context.h" | 26 #include "webkit/common/gpu/context_provider_web_context.h" |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 | 29 |
| 29 struct VideoDecoderShim::PendingDecode { | 30 struct VideoDecoderShim::PendingDecode { |
| 30 PendingDecode(uint32_t decode_id, | 31 PendingDecode(uint32_t decode_id, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 decode_id_(0) { | 118 decode_id_(0) { |
| 118 } | 119 } |
| 119 | 120 |
| 120 VideoDecoderShim::DecoderImpl::~DecoderImpl() { | 121 VideoDecoderShim::DecoderImpl::~DecoderImpl() { |
| 121 DCHECK(pending_decodes_.empty()); | 122 DCHECK(pending_decodes_.empty()); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void VideoDecoderShim::DecoderImpl::Initialize( | 125 void VideoDecoderShim::DecoderImpl::Initialize( |
| 125 media::VideoDecoderConfig config) { | 126 media::VideoDecoderConfig config) { |
| 126 DCHECK(!decoder_); | 127 DCHECK(!decoder_); |
| 127 scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( | 128 if (config.codec() == media::kCodecVP9) { |
| 128 new media::FFmpegVideoDecoder(base::MessageLoopProxy::current())); | 129 decoder_.reset( |
| 129 ffmpeg_video_decoder->set_decode_nalus(true); | 130 new media::VpxVideoDecoder(base::MessageLoopProxy::current())); |
| 130 decoder_ = ffmpeg_video_decoder.Pass(); | 131 } else { |
| 132 scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( |
| 133 new media::FFmpegVideoDecoder(base::MessageLoopProxy::current())); |
| 134 ffmpeg_video_decoder->set_decode_nalus(true); |
| 135 decoder_ = ffmpeg_video_decoder.Pass(); |
| 136 } |
| 131 max_decodes_at_decoder_ = decoder_->GetMaxDecodeRequests(); | 137 max_decodes_at_decoder_ = decoder_->GetMaxDecodeRequests(); |
| 132 // We can use base::Unretained() safely in decoder callbacks because we call | 138 // We can use base::Unretained() safely in decoder callbacks because we call |
| 133 // VideoDecoder::Stop() before deletion. Stop() guarantees there will be no | 139 // VideoDecoder::Stop() before deletion. Stop() guarantees there will be no |
| 134 // outstanding callbacks after it returns. | 140 // outstanding callbacks after it returns. |
| 135 decoder_->Initialize( | 141 decoder_->Initialize( |
| 136 config, | 142 config, |
| 137 true /* low_delay */, | 143 true /* low_delay */, |
| 138 base::Bind(&VideoDecoderShim::DecoderImpl::OnPipelineStatus, | 144 base::Bind(&VideoDecoderShim::DecoderImpl::OnPipelineStatus, |
| 139 base::Unretained(this)), | 145 base::Unretained(this)), |
| 140 base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, | 146 base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 media::VideoCodecProfile profile, | 323 media::VideoCodecProfile profile, |
| 318 media::VideoDecodeAccelerator::Client* client) { | 324 media::VideoDecodeAccelerator::Client* client) { |
| 319 DCHECK_EQ(client, host_); | 325 DCHECK_EQ(client, host_); |
| 320 DCHECK(RenderThreadImpl::current()); | 326 DCHECK(RenderThreadImpl::current()); |
| 321 DCHECK_EQ(state_, UNINITIALIZED); | 327 DCHECK_EQ(state_, UNINITIALIZED); |
| 322 media::VideoCodec codec = media::kUnknownVideoCodec; | 328 media::VideoCodec codec = media::kUnknownVideoCodec; |
| 323 if (profile <= media::H264PROFILE_MAX) | 329 if (profile <= media::H264PROFILE_MAX) |
| 324 codec = media::kCodecH264; | 330 codec = media::kCodecH264; |
| 325 else if (profile <= media::VP8PROFILE_MAX) | 331 else if (profile <= media::VP8PROFILE_MAX) |
| 326 codec = media::kCodecVP8; | 332 codec = media::kCodecVP8; |
| 333 else if (profile <= media::VP9PROFILE_MAX) |
| 334 codec = media::kCodecVP9; |
| 327 DCHECK_NE(codec, media::kUnknownVideoCodec); | 335 DCHECK_NE(codec, media::kUnknownVideoCodec); |
| 328 | 336 |
| 329 media::VideoDecoderConfig config( | 337 media::VideoDecoderConfig config( |
| 330 codec, | 338 codec, |
| 331 profile, | 339 profile, |
| 332 media::VideoFrame::YV12, | 340 media::VideoFrame::YV12, |
| 333 gfx::Size(32, 24), // Small sizes that won't fail. | 341 gfx::Size(32, 24), // Small sizes that won't fail. |
| 334 gfx::Rect(32, 24), | 342 gfx::Rect(32, 24), |
| 335 gfx::Size(32, 24), | 343 gfx::Size(32, 24), |
| 336 NULL /* extra_data */, // TODO(bbudge) Verify this isn't needed. | 344 NULL /* extra_data */, // TODO(bbudge) Verify this isn't needed. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 586 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { |
| 579 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 587 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 580 gles2->DeleteTextures(1, &texture_id); | 588 gles2->DeleteTextures(1, &texture_id); |
| 581 } | 589 } |
| 582 | 590 |
| 583 void VideoDecoderShim::FlushCommandBuffer() { | 591 void VideoDecoderShim::FlushCommandBuffer() { |
| 584 context_provider_->ContextGL()->Flush(); | 592 context_provider_->ContextGL()->Flush(); |
| 585 } | 593 } |
| 586 | 594 |
| 587 } // namespace content | 595 } // namespace content |
| OLD | NEW |