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_FFMPEG_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 } | 22 } |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 | 25 |
26 class DecoderBuffer; | 26 class DecoderBuffer; |
27 class ScopedPtrAVFreeContext; | 27 class ScopedPtrAVFreeContext; |
28 class ScopedPtrAVFreeFrame; | 28 class ScopedPtrAVFreeFrame; |
29 | 29 |
30 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { | 30 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { |
31 public: | 31 public: |
32 explicit FFmpegVideoDecoder( | 32 // Threading mode determines how frames should be distributed between |
33 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 33 // decoding threads. |
34 enum ThreadingMode { | |
35 // Each thread decode a single frame and multiple frames may be decoded in | |
Ami GONE FROM CHROMIUM
2014/01/28 07:17:10
s/decode/decodes/
| |
36 // parallel. In this mode FFmpeg will delay N-1 frames when using N threads. | |
37 THREADING_FRAME, | |
38 | |
39 // Each frame is distributed between decode threads. If the video contains | |
40 // only one slice per frame then only one thread will be used for decoding. | |
41 THREADING_SLICE, | |
42 }; | |
43 | |
44 FFmpegVideoDecoder( | |
45 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
46 ThreadingMode threading_mode); | |
34 virtual ~FFmpegVideoDecoder(); | 47 virtual ~FFmpegVideoDecoder(); |
35 | 48 |
36 // VideoDecoder implementation. | 49 // VideoDecoder implementation. |
37 virtual void Initialize(const VideoDecoderConfig& config, | 50 virtual void Initialize(const VideoDecoderConfig& config, |
38 const PipelineStatusCB& status_cb) OVERRIDE; | 51 const PipelineStatusCB& status_cb) OVERRIDE; |
39 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 52 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
40 const DecodeCB& decode_cb) OVERRIDE; | 53 const DecodeCB& decode_cb) OVERRIDE; |
41 virtual void Reset(const base::Closure& closure) OVERRIDE; | 54 virtual void Reset(const base::Closure& closure) OVERRIDE; |
42 virtual void Stop(const base::Closure& closure) OVERRIDE; | 55 virtual void Stop(const base::Closure& closure) OVERRIDE; |
43 | 56 |
(...skipping 21 matching lines...) Expand all Loading... | |
65 bool ConfigureDecoder(); | 78 bool ConfigureDecoder(); |
66 | 79 |
67 // Releases resources associated with |codec_context_| and |av_frame_| | 80 // Releases resources associated with |codec_context_| and |av_frame_| |
68 // and resets them to NULL. | 81 // and resets them to NULL. |
69 void ReleaseFFmpegResources(); | 82 void ReleaseFFmpegResources(); |
70 | 83 |
71 // Reset decoder and call |reset_cb_|. | 84 // Reset decoder and call |reset_cb_|. |
72 void DoReset(); | 85 void DoReset(); |
73 | 86 |
74 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 87 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
88 ThreadingMode threading_mode_; | |
89 | |
75 base::WeakPtrFactory<FFmpegVideoDecoder> weak_factory_; | 90 base::WeakPtrFactory<FFmpegVideoDecoder> weak_factory_; |
76 base::WeakPtr<FFmpegVideoDecoder> weak_this_; | 91 base::WeakPtr<FFmpegVideoDecoder> weak_this_; |
77 | 92 |
78 DecoderState state_; | 93 DecoderState state_; |
79 | 94 |
80 DecodeCB decode_cb_; | 95 DecodeCB decode_cb_; |
81 base::Closure reset_cb_; | 96 base::Closure reset_cb_; |
82 | 97 |
83 // FFmpeg structures owned by this object. | 98 // FFmpeg structures owned by this object. |
84 scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; | 99 scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; |
85 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; | 100 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; |
86 | 101 |
87 VideoDecoderConfig config_; | 102 VideoDecoderConfig config_; |
88 | 103 |
89 VideoFramePool frame_pool_; | 104 VideoFramePool frame_pool_; |
90 | 105 |
91 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); | 106 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); |
92 }; | 107 }; |
93 | 108 |
94 } // namespace media | 109 } // namespace media |
95 | 110 |
96 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 111 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
OLD | NEW |