| OLD | NEW |
| 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 #ifndef MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "media/base/demuxer_stream.h" | 10 #include "media/base/demuxer_stream.h" |
| 11 #include "media/base/video_decoder.h" | 11 #include "media/base/video_decoder.h" |
| 12 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "media/base/video_frame_pool.h" | 14 #include "media/base/video_frame_pool.h" |
| 15 | 15 |
| 16 struct vpx_codec_ctx; | 16 struct vpx_codec_ctx; |
| 17 struct vpx_image; | 17 struct vpx_image; |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class MessageLoopProxy; | 20 class SingleThreadTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 | 24 |
| 25 // Libvpx video decoder wrapper. | 25 // Libvpx video decoder wrapper. |
| 26 // Note: VpxVideoDecoder accepts only YV12A VP8 content or VP9 content. This is | 26 // Note: VpxVideoDecoder accepts only YV12A VP8 content or VP9 content. This is |
| 27 // done to avoid usurping FFmpeg for all vp8 decoding, because the FFmpeg VP8 | 27 // done to avoid usurping FFmpeg for all vp8 decoding, because the FFmpeg VP8 |
| 28 // decoder is faster than the libvpx VP8 decoder. | 28 // decoder is faster than the libvpx VP8 decoder. |
| 29 class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder { | 29 class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder { |
| 30 public: | 30 public: |
| 31 explicit VpxVideoDecoder( | 31 explicit VpxVideoDecoder( |
| 32 const scoped_refptr<base::MessageLoopProxy>& message_loop); | 32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 33 virtual ~VpxVideoDecoder(); | 33 virtual ~VpxVideoDecoder(); |
| 34 | 34 |
| 35 // VideoDecoder implementation. | 35 // VideoDecoder implementation. |
| 36 virtual void Initialize(const VideoDecoderConfig& config, | 36 virtual void Initialize(const VideoDecoderConfig& config, |
| 37 const PipelineStatusCB& status_cb) OVERRIDE; | 37 const PipelineStatusCB& status_cb) OVERRIDE; |
| 38 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 38 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 39 const DecodeCB& decode_cb) OVERRIDE; | 39 const DecodeCB& decode_cb) OVERRIDE; |
| 40 virtual void Reset(const base::Closure& closure) OVERRIDE; | 40 virtual void Reset(const base::Closure& closure) OVERRIDE; |
| 41 virtual void Stop(const base::Closure& closure) OVERRIDE; | 41 virtual void Stop(const base::Closure& closure) OVERRIDE; |
| 42 virtual bool HasAlpha() const OVERRIDE; | 42 virtual bool HasAlpha() const OVERRIDE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, | 60 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, |
| 61 scoped_refptr<VideoFrame>* video_frame); | 61 scoped_refptr<VideoFrame>* video_frame); |
| 62 | 62 |
| 63 // Reset decoder and call |reset_cb_|. | 63 // Reset decoder and call |reset_cb_|. |
| 64 void DoReset(); | 64 void DoReset(); |
| 65 | 65 |
| 66 void CopyVpxImageTo(const vpx_image* vpx_image, | 66 void CopyVpxImageTo(const vpx_image* vpx_image, |
| 67 const struct vpx_image* vpx_image_alpha, | 67 const struct vpx_image* vpx_image_alpha, |
| 68 scoped_refptr<VideoFrame>* video_frame); | 68 scoped_refptr<VideoFrame>* video_frame); |
| 69 | 69 |
| 70 scoped_refptr<base::MessageLoopProxy> message_loop_; | 70 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 71 base::WeakPtrFactory<VpxVideoDecoder> weak_factory_; | 71 base::WeakPtrFactory<VpxVideoDecoder> weak_factory_; |
| 72 base::WeakPtr<VpxVideoDecoder> weak_this_; | 72 base::WeakPtr<VpxVideoDecoder> weak_this_; |
| 73 | 73 |
| 74 DecoderState state_; | 74 DecoderState state_; |
| 75 | 75 |
| 76 DecodeCB decode_cb_; | 76 DecodeCB decode_cb_; |
| 77 base::Closure reset_cb_; | 77 base::Closure reset_cb_; |
| 78 | 78 |
| 79 VideoDecoderConfig config_; | 79 VideoDecoderConfig config_; |
| 80 | 80 |
| 81 vpx_codec_ctx* vpx_codec_; | 81 vpx_codec_ctx* vpx_codec_; |
| 82 vpx_codec_ctx* vpx_codec_alpha_; | 82 vpx_codec_ctx* vpx_codec_alpha_; |
| 83 | 83 |
| 84 VideoFramePool frame_pool_; | 84 VideoFramePool frame_pool_; |
| 85 | 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | 86 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace media | 89 } // namespace media |
| 90 | 90 |
| 91 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 91 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| OLD | NEW |