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_codec_frame_buffer; | |
17 struct vpx_image; | 18 struct vpx_image; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class MessageLoopProxy; | 21 class MessageLoopProxy; |
21 } | 22 } |
22 | 23 |
23 namespace media { | 24 namespace media { |
24 | 25 |
25 // Libvpx video decoder wrapper. | 26 // Libvpx video decoder wrapper. |
26 // Note: VpxVideoDecoder accepts only YV12A VP8 content or VP9 content. This is | 27 // 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 | 28 // done to avoid usurping FFmpeg for all vp8 decoding, because the FFmpeg VP8 |
28 // decoder is faster than the libvpx VP8 decoder. | 29 // decoder is faster than the libvpx VP8 decoder. |
29 class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder { | 30 class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder { |
30 public: | 31 public: |
31 explicit VpxVideoDecoder( | 32 explicit VpxVideoDecoder( |
32 const scoped_refptr<base::MessageLoopProxy>& message_loop); | 33 const scoped_refptr<base::MessageLoopProxy>& message_loop); |
33 virtual ~VpxVideoDecoder(); | 34 virtual ~VpxVideoDecoder(); |
34 | 35 |
35 // VideoDecoder implementation. | 36 // VideoDecoder implementation. |
36 virtual void Initialize(const VideoDecoderConfig& config, | 37 virtual void Initialize(const VideoDecoderConfig& config, |
37 const PipelineStatusCB& status_cb) OVERRIDE; | 38 const PipelineStatusCB& status_cb) OVERRIDE; |
38 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 39 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
39 const DecodeCB& decode_cb) OVERRIDE; | 40 const DecodeCB& decode_cb) OVERRIDE; |
40 virtual void Reset(const base::Closure& closure) OVERRIDE; | 41 virtual void Reset(const base::Closure& closure) OVERRIDE; |
41 virtual void Stop(const base::Closure& closure) OVERRIDE; | 42 virtual void Stop(const base::Closure& closure) OVERRIDE; |
42 virtual bool HasAlpha() const OVERRIDE; | 43 virtual bool HasAlpha() const OVERRIDE; |
43 | 44 |
45 // Callback that will be called by libvpx if the frame buffer size needs to | |
46 // increase. Parameters: | |
47 // user_priv Data passed into libvpx (we pass NULL). | |
48 // new_size Minimum size needed by libvpx to decompress the next frame. | |
49 // fb Pointer to the frame buffer to update. | |
50 // Returns VPX_CODEC_OK on success. Returns < 0 on failure. | |
51 static int32 ReallocVP9FrameBuffer(void *user_priv, size_t new_size, | |
52 vpx_codec_frame_buffer *fb); | |
fgalligan1
2013/12/16 19:38:43
'*' should be next to the type in this file (I kno
vignesh
2013/12/16 21:10:57
Done.
| |
53 | |
44 private: | 54 private: |
45 enum DecoderState { | 55 enum DecoderState { |
46 kUninitialized, | 56 kUninitialized, |
47 kNormal, | 57 kNormal, |
48 kFlushCodec, | 58 kFlushCodec, |
49 kDecodeFinished, | 59 kDecodeFinished, |
50 kError | 60 kError |
51 }; | 61 }; |
52 | 62 |
63 // Maximum number of frame buffers allowed to be used by libvpx for VP9 | |
64 // decoding. 8 (libvpx reference buffers) + 4 (gitter buffers) + 1 (work | |
fgalligan1
2013/12/16 19:38:43
jitter
vignesh
2013/12/16 21:10:57
whoops. done.
| |
65 // buffer) = 13. | |
66 const int kVP9MaxFrameBuffers = 13; | |
67 | |
53 // Handles (re-)initializing the decoder with a (new) config. | 68 // Handles (re-)initializing the decoder with a (new) config. |
54 // Returns true when initialization was successful. | 69 // Returns true when initialization was successful. |
55 bool ConfigureDecoder(const VideoDecoderConfig& config); | 70 bool ConfigureDecoder(const VideoDecoderConfig& config); |
56 | 71 |
57 void CloseDecoder(); | 72 void CloseDecoder(); |
58 | 73 |
59 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); | 74 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); |
60 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, | 75 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, |
61 scoped_refptr<VideoFrame>* video_frame); | 76 scoped_refptr<VideoFrame>* video_frame); |
62 | 77 |
(...skipping 13 matching lines...) Expand all Loading... | |
76 DecodeCB decode_cb_; | 91 DecodeCB decode_cb_; |
77 base::Closure reset_cb_; | 92 base::Closure reset_cb_; |
78 | 93 |
79 VideoDecoderConfig config_; | 94 VideoDecoderConfig config_; |
80 | 95 |
81 vpx_codec_ctx* vpx_codec_; | 96 vpx_codec_ctx* vpx_codec_; |
82 vpx_codec_ctx* vpx_codec_alpha_; | 97 vpx_codec_ctx* vpx_codec_alpha_; |
83 | 98 |
84 VideoFramePool frame_pool_; | 99 VideoFramePool frame_pool_; |
85 | 100 |
101 // Frame Buffers used for VP9 decoding. | |
102 vpx_codec_frame_buffer* frame_buffers_; | |
103 | |
86 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | 104 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
87 }; | 105 }; |
88 | 106 |
89 } // namespace media | 107 } // namespace media |
90 | 108 |
91 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 109 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
OLD | NEW |