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, | |
fgalligan1
2013/12/17 01:16:54
nit: I think we use int other places.
vignesh
2013/12/17 18:24:25
i tried int first. clang was not happy as libvpx e
| |
52 vpx_codec_frame_buffer* fb); | |
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 (jitter buffers) + 1 (work | |
65 // buffer) = 13. | |
fgalligan1
2013/12/17 01:16:54
These have to be static const int.
vignesh
2013/12/17 18:24:25
Done.
| |
66 const int kVP9MaxFrameBuffers = 13; | |
fgalligan1
2013/12/17 01:16:54
I think you can move this to the .cc file. Or are
vignesh
2013/12/17 18:24:25
Done.
| |
67 | |
68 // Minimum libvpx decoder ABI version required to support direct rendering. | |
69 const int kVP9MinABIVersion = 6; | |
fgalligan1
2013/12/17 01:16:54
Move this to the .cc and I would change the name t
vignesh
2013/12/17 18:24:25
Done.
| |
70 | |
53 // Handles (re-)initializing the decoder with a (new) config. | 71 // Handles (re-)initializing the decoder with a (new) config. |
54 // Returns true when initialization was successful. | 72 // Returns true when initialization was successful. |
55 bool ConfigureDecoder(const VideoDecoderConfig& config); | 73 bool ConfigureDecoder(const VideoDecoderConfig& config); |
56 | 74 |
57 void CloseDecoder(); | 75 void CloseDecoder(); |
58 | 76 |
59 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); | 77 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); |
60 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, | 78 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, |
61 scoped_refptr<VideoFrame>* video_frame); | 79 scoped_refptr<VideoFrame>* video_frame); |
62 | 80 |
(...skipping 13 matching lines...) Expand all Loading... | |
76 DecodeCB decode_cb_; | 94 DecodeCB decode_cb_; |
77 base::Closure reset_cb_; | 95 base::Closure reset_cb_; |
78 | 96 |
79 VideoDecoderConfig config_; | 97 VideoDecoderConfig config_; |
80 | 98 |
81 vpx_codec_ctx* vpx_codec_; | 99 vpx_codec_ctx* vpx_codec_; |
82 vpx_codec_ctx* vpx_codec_alpha_; | 100 vpx_codec_ctx* vpx_codec_alpha_; |
83 | 101 |
84 VideoFramePool frame_pool_; | 102 VideoFramePool frame_pool_; |
85 | 103 |
104 // Frame Buffers used for VP9 decoding. | |
105 vpx_codec_frame_buffer* frame_buffers_; | |
106 | |
86 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | 107 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
87 }; | 108 }; |
88 | 109 |
89 } // namespace media | 110 } // namespace media |
90 | 111 |
91 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 112 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
OLD | NEW |