Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: media/filters/vpx_video_decoder.h

Issue 12025030: Add wrapper class to media for support of VP9 video, and add a command line flag to enable the supp… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_FFMPEG_VIDEO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_VPX_VIDEO_DECODER_H_
6 #define MEDIA_FILTERS_FFMPEG_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/ref_counted.h" 9 #include "base/memory/ref_counted.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 12
13 struct AVCodecContext; 13 struct vpx_codec_ctx;
14 struct AVFrame; 14 struct vpx_image;
15 15
16 namespace base { 16 namespace base {
17 class MessageLoopProxy; 17 class MessageLoopProxy;
18 } 18 }
19 19
20 namespace media { 20 namespace media {
21 21
22 class DecoderBuffer; 22 class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder {
23
24 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
25 public: 23 public:
26 explicit FFmpegVideoDecoder( 24 explicit VpxVideoDecoder(
27 const scoped_refptr<base::MessageLoopProxy>& message_loop); 25 const scoped_refptr<base::MessageLoopProxy>& message_loop);
28 26
29 // VideoDecoder implementation. 27 // VideoDecoder implementation.
30 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 28 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
31 const PipelineStatusCB& status_cb, 29 const PipelineStatusCB& status_cb,
32 const StatisticsCB& statistics_cb) OVERRIDE; 30 const StatisticsCB& statistics_cb) OVERRIDE;
33 virtual void Read(const ReadCB& read_cb) OVERRIDE; 31 virtual void Read(const ReadCB& read_cb) OVERRIDE;
34 virtual void Reset(const base::Closure& closure) OVERRIDE; 32 virtual void Reset(const base::Closure& closure) OVERRIDE;
35 virtual void Stop(const base::Closure& closure) OVERRIDE; 33 virtual void Stop(const base::Closure& closure) OVERRIDE;
36 34
37 // Callback called from within FFmpeg to allocate a buffer based on
38 // the dimensions of |codec_context|. See AVCodecContext.get_buffer
39 // documentation inside FFmpeg.
40 int GetVideoBuffer(AVCodecContext *codec_context, AVFrame* frame);
41
42 protected: 35 protected:
43 virtual ~FFmpegVideoDecoder(); 36 virtual ~VpxVideoDecoder();
44 37
45 private: 38 private:
46 enum DecoderState { 39 enum DecoderState {
47 kUninitialized, 40 kUninitialized,
48 kNormal, 41 kNormal,
49 kFlushCodec, 42 kFlushCodec,
50 kDecodeFinished 43 kDecodeFinished
51 }; 44 };
52 45
53 // Reads from the demuxer stream and corresponding read callback. 46 // Handles (re-)initializing the decoder with a (new) config.
47 // Returns true when initialization was successful.
48 bool ConfigureDecoder();
49
50 void CloseDecoder();
54 void ReadFromDemuxerStream(); 51 void ReadFromDemuxerStream();
55 void BufferReady(DemuxerStream::Status status,
56 const scoped_refptr<DecoderBuffer>& buffer);
57 52
58 // Handles decoding an unencrypted encoded buffer. 53 // Carries out the buffer processing operation scheduled by
54 // DecryptOrDecodeBuffer().
55 void DoDecryptOrDecodeBuffer(DemuxerStream::Status status,
56 const scoped_refptr<DecoderBuffer>& buffer);
57
59 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); 58 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer);
60 bool Decode(const scoped_refptr<DecoderBuffer>& buffer, 59 bool Decode(const scoped_refptr<DecoderBuffer>& buffer,
61 scoped_refptr<VideoFrame>* video_frame); 60 scoped_refptr<VideoFrame>* video_frame);
62 61
63 // Handles (re-)initializing the decoder with a (new) config.
64 // Returns true if initialization was successful.
65 bool ConfigureDecoder();
66
67 // Releases resources associated with |codec_context_| and |av_frame_|
68 // and resets them to NULL.
69 void ReleaseFFmpegResources();
70
71 // Reset decoder and call |reset_cb_|. 62 // Reset decoder and call |reset_cb_|.
72 void DoReset(); 63 void DoReset();
73 64
65 void CopyVpxImageTo(const vpx_image* vpx_image,
66 scoped_refptr<VideoFrame>* video_frame);
67
74 scoped_refptr<base::MessageLoopProxy> message_loop_; 68 scoped_refptr<base::MessageLoopProxy> message_loop_;
75 69
76 DecoderState state_; 70 DecoderState state_;
77 71
78 StatisticsCB statistics_cb_; 72 StatisticsCB statistics_cb_;
79
80 ReadCB read_cb_; 73 ReadCB read_cb_;
81 base::Closure reset_cb_; 74 base::Closure reset_cb_;
82 75
83 // FFmpeg structures owned by this object.
84 AVCodecContext* codec_context_;
85 AVFrame* av_frame_;
86
87 // Pointer to the demuxer stream that will feed us compressed buffers. 76 // Pointer to the demuxer stream that will feed us compressed buffers.
88 scoped_refptr<DemuxerStream> demuxer_stream_; 77 scoped_refptr<DemuxerStream> demuxer_stream_;
89 78
90 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); 79 vpx_codec_ctx* vpx_codec_;
80
81 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder);
91 }; 82 };
92 83
93 } // namespace media 84 } // namespace media
94 85
95 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ 86 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698