| 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 | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 41     kProgram_GrGLBackendState | kPixelStore_GrGLBackendState; | 41     kProgram_GrGLBackendState | kPixelStore_GrGLBackendState; | 
| 42 | 42 | 
| 43 namespace { | 43 namespace { | 
| 44 | 44 | 
| 45 bool IsCodecSupported(media::VideoCodec codec) { | 45 bool IsCodecSupported(media::VideoCodec codec) { | 
| 46 #if !defined(MEDIA_DISABLE_LIBVPX) | 46 #if !defined(MEDIA_DISABLE_LIBVPX) | 
| 47   if (codec == media::kCodecVP9) | 47   if (codec == media::kCodecVP9) | 
| 48     return true; | 48     return true; | 
| 49 #endif | 49 #endif | 
| 50 | 50 | 
|  | 51 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(DISABLE_FFMPEG_VIDEO_DECODERS) | 
| 51   return media::FFmpegVideoDecoder::IsCodecSupported(codec); | 52   return media::FFmpegVideoDecoder::IsCodecSupported(codec); | 
|  | 53 #else | 
|  | 54   return false; | 
|  | 55 #endif | 
| 52 } | 56 } | 
| 53 | 57 | 
| 54 }  // namespace | 58 }  // namespace | 
| 55 | 59 | 
| 56 // YUV->RGB converter class using a shader and FBO. | 60 // YUV->RGB converter class using a shader and FBO. | 
| 57 class VideoDecoderShim::YUVConverter { | 61 class VideoDecoderShim::YUVConverter { | 
| 58  public: | 62  public: | 
| 59   YUVConverter(const scoped_refptr<cc_blink::ContextProviderWebContext>&); | 63   YUVConverter(const scoped_refptr<cc_blink::ContextProviderWebContext>&); | 
| 60   ~YUVConverter(); | 64   ~YUVConverter(); | 
| 61   bool Initialize(); | 65   bool Initialize(); | 
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 681 | 685 | 
| 682 void VideoDecoderShim::DecoderImpl::Initialize( | 686 void VideoDecoderShim::DecoderImpl::Initialize( | 
| 683     media::VideoDecoderConfig config) { | 687     media::VideoDecoderConfig config) { | 
| 684   DCHECK(!decoder_); | 688   DCHECK(!decoder_); | 
| 685 #if !defined(MEDIA_DISABLE_LIBVPX) | 689 #if !defined(MEDIA_DISABLE_LIBVPX) | 
| 686   if (config.codec() == media::kCodecVP9) { | 690   if (config.codec() == media::kCodecVP9) { | 
| 687     decoder_.reset( | 691     decoder_.reset( | 
| 688         new media::VpxVideoDecoder(base::ThreadTaskRunnerHandle::Get())); | 692         new media::VpxVideoDecoder(base::ThreadTaskRunnerHandle::Get())); | 
| 689   } else | 693   } else | 
| 690 #endif | 694 #endif | 
|  | 695 | 
|  | 696 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(DISABLE_FFMPEG_VIDEO_DECODERS) | 
| 691   { | 697   { | 
| 692     scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( | 698     scoped_ptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder( | 
| 693         new media::FFmpegVideoDecoder(base::ThreadTaskRunnerHandle::Get())); | 699         new media::FFmpegVideoDecoder(base::ThreadTaskRunnerHandle::Get())); | 
| 694     ffmpeg_video_decoder->set_decode_nalus(true); | 700     ffmpeg_video_decoder->set_decode_nalus(true); | 
| 695     decoder_ = ffmpeg_video_decoder.Pass(); | 701     decoder_ = ffmpeg_video_decoder.Pass(); | 
| 696   } | 702   } | 
|  | 703 #elif defined(MEDIA_DISABLE_LIBVPX) | 
|  | 704   OnInitDone(false); | 
|  | 705   return; | 
|  | 706 #endif | 
| 697 | 707 | 
| 698   // VpxVideoDecoder and FFmpegVideoDecoder support only one pending Decode() | 708   // VpxVideoDecoder and FFmpegVideoDecoder support only one pending Decode() | 
| 699   // request. | 709   // request. | 
| 700   DCHECK_EQ(decoder_->GetMaxDecodeRequests(), 1); | 710   DCHECK_EQ(decoder_->GetMaxDecodeRequests(), 1); | 
| 701 | 711 | 
| 702   decoder_->Initialize( | 712   decoder_->Initialize( | 
| 703       config, true /* low_delay */, | 713       config, true /* low_delay */, | 
| 704       base::Bind(&VideoDecoderShim::DecoderImpl::OnInitDone, | 714       base::Bind(&VideoDecoderShim::DecoderImpl::OnInitDone, | 
| 705                  weak_ptr_factory_.GetWeakPtr()), | 715                  weak_ptr_factory_.GetWeakPtr()), | 
| 706       base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, | 716       base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, | 
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1106 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 1116 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { | 
| 1107   gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 1117   gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 
| 1108   gles2->DeleteTextures(1, &texture_id); | 1118   gles2->DeleteTextures(1, &texture_id); | 
| 1109 } | 1119 } | 
| 1110 | 1120 | 
| 1111 void VideoDecoderShim::FlushCommandBuffer() { | 1121 void VideoDecoderShim::FlushCommandBuffer() { | 
| 1112   context_provider_->ContextGL()->Flush(); | 1122   context_provider_->ContextGL()->Flush(); | 
| 1113 } | 1123 } | 
| 1114 | 1124 | 
| 1115 }  // namespace content | 1125 }  // namespace content | 
| OLD | NEW | 
|---|