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

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

Issue 239893002: Allow multiple concurrent Decode() requests in VideoDecoder interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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_GPU_VIDEO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // VideoDecoder implementation. 44 // VideoDecoder implementation.
45 virtual void Initialize(const VideoDecoderConfig& config, 45 virtual void Initialize(const VideoDecoderConfig& config,
46 const PipelineStatusCB& status_cb) OVERRIDE; 46 const PipelineStatusCB& status_cb) OVERRIDE;
47 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 47 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
48 const DecodeCB& decode_cb) OVERRIDE; 48 const DecodeCB& decode_cb) OVERRIDE;
49 virtual void Reset(const base::Closure& closure) OVERRIDE; 49 virtual void Reset(const base::Closure& closure) OVERRIDE;
50 virtual void Stop() OVERRIDE; 50 virtual void Stop() OVERRIDE;
51 virtual bool NeedsBitstreamConversion() const OVERRIDE; 51 virtual bool NeedsBitstreamConversion() const OVERRIDE;
52 virtual bool CanReadWithoutStalling() const OVERRIDE; 52 virtual bool CanReadWithoutStalling() const OVERRIDE;
53 virtual int GetMaxDecodeRequests() const OVERRIDE;
53 54
54 // VideoDecodeAccelerator::Client implementation. 55 // VideoDecodeAccelerator::Client implementation.
55 virtual void ProvidePictureBuffers(uint32 count, 56 virtual void ProvidePictureBuffers(uint32 count,
56 const gfx::Size& size, 57 const gfx::Size& size,
57 uint32 texture_target) OVERRIDE; 58 uint32 texture_target) OVERRIDE;
58 virtual void DismissPictureBuffer(int32 id) OVERRIDE; 59 virtual void DismissPictureBuffer(int32 id) OVERRIDE;
59 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 60 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
60 virtual void NotifyEndOfBitstreamBuffer(int32 id) OVERRIDE; 61 virtual void NotifyEndOfBitstreamBuffer(int32 id) OVERRIDE;
61 virtual void NotifyFlushDone() OVERRIDE; 62 virtual void NotifyFlushDone() OVERRIDE;
62 virtual void NotifyResetDone() OVERRIDE; 63 virtual void NotifyResetDone() OVERRIDE;
(...skipping 21 matching lines...) Expand all
84 // A SHMBuffer and the DecoderBuffer its data came from. 85 // A SHMBuffer and the DecoderBuffer its data came from.
85 struct BufferPair { 86 struct BufferPair {
86 BufferPair(SHMBuffer* s, const scoped_refptr<DecoderBuffer>& b); 87 BufferPair(SHMBuffer* s, const scoped_refptr<DecoderBuffer>& b);
87 ~BufferPair(); 88 ~BufferPair();
88 SHMBuffer* shm_buffer; 89 SHMBuffer* shm_buffer;
89 scoped_refptr<DecoderBuffer> buffer; 90 scoped_refptr<DecoderBuffer> buffer;
90 }; 91 };
91 92
92 typedef std::map<int32, PictureBuffer> PictureBufferMap; 93 typedef std::map<int32, PictureBuffer> PictureBufferMap;
93 94
94 // Return true if more decode work can be piled on to the VDA. 95 void DeliverFrame( const scoped_refptr<VideoFrame>& frame);
95 bool CanMoreDecodeWorkBeDone();
96
97 // Enqueue a frame for later delivery (or drop it on the floor if a
98 // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest
99 // ready frame to the client if there is a pending read. A NULL |frame|
100 // merely triggers delivery, and requires the ready_video_frames_ queue not be
101 // empty.
102 void EnqueueFrameAndTriggerFrameDelivery(
103 const scoped_refptr<VideoFrame>& frame);
104 96
105 // Static method is to allow it to run even after GVD is deleted. 97 // Static method is to allow it to run even after GVD is deleted.
106 static void ReleaseMailbox( 98 static void ReleaseMailbox(
107 base::WeakPtr<GpuVideoDecoder> decoder, 99 base::WeakPtr<GpuVideoDecoder> decoder,
108 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, 100 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories,
109 int64 picture_buffer_id, 101 int64 picture_buffer_id,
110 uint32 texture_id, 102 uint32 texture_id,
111 scoped_ptr<gpu::MailboxHolder> mailbox_holder); 103 scoped_ptr<gpu::MailboxHolder> mailbox_holder);
112 // Indicate the picture buffer can be reused by the decoder. 104 // Indicate the picture buffer can be reused by the decoder.
113 void ReusePictureBuffer(int64 picture_buffer_id); 105 void ReusePictureBuffer(int64 picture_buffer_id);
(...skipping 19 matching lines...) Expand all
133 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; 125 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const;
134 126
135 bool needs_bitstream_conversion_; 127 bool needs_bitstream_conversion_;
136 128
137 scoped_refptr<GpuVideoAcceleratorFactories> factories_; 129 scoped_refptr<GpuVideoAcceleratorFactories> factories_;
138 130
139 // Populated during Initialize() (on success) and unchanged until an error 131 // Populated during Initialize() (on success) and unchanged until an error
140 // occurs. 132 // occurs.
141 scoped_ptr<VideoDecodeAccelerator> vda_; 133 scoped_ptr<VideoDecodeAccelerator> vda_;
142 134
143 // Callbacks that are !is_null() only during their respective operation being 135 // Callbacks for the pending Decode requests (not more than
144 // asynchronously executed. 136 // GetMaxDecodeRequests()).
145 DecodeCB pending_decode_cb_; 137 std::list<DecodeCB> pending_decode_callbacks_;
138
139 // Not null only during reset.
146 base::Closure pending_reset_cb_; 140 base::Closure pending_reset_cb_;
147 141
148 State state_; 142 State state_;
149 143
150 VideoDecoderConfig config_; 144 VideoDecoderConfig config_;
151 145
152 // Shared-memory buffer pool. Since allocating SHM segments requires a 146 // Shared-memory buffer pool. Since allocating SHM segments requires a
153 // round-trip to the browser process, we keep allocation out of the 147 // round-trip to the browser process, we keep allocation out of the
154 // steady-state of the decoder. 148 // steady-state of the decoder.
155 std::vector<SHMBuffer*> available_shm_segments_; 149 std::vector<SHMBuffer*> available_shm_segments_;
(...skipping 18 matching lines...) Expand all
174 ~BufferData(); 168 ~BufferData();
175 int32 bitstream_buffer_id; 169 int32 bitstream_buffer_id;
176 base::TimeDelta timestamp; 170 base::TimeDelta timestamp;
177 gfx::Rect visible_rect; 171 gfx::Rect visible_rect;
178 gfx::Size natural_size; 172 gfx::Size natural_size;
179 }; 173 };
180 std::list<BufferData> input_buffer_data_; 174 std::list<BufferData> input_buffer_data_;
181 175
182 // picture_buffer_id and the frame wrapping the corresponding Picture, for 176 // picture_buffer_id and the frame wrapping the corresponding Picture, for
183 // frames that have been decoded but haven't been requested by a Decode() yet. 177 // frames that have been decoded but haven't been requested by a Decode() yet.
184 std::list<scoped_refptr<VideoFrame> > ready_video_frames_;
185 int32 next_picture_buffer_id_; 178 int32 next_picture_buffer_id_;
186 int32 next_bitstream_buffer_id_; 179 int32 next_bitstream_buffer_id_;
187 180
188 // Set during ProvidePictureBuffers(), used for checking and implementing 181 // Set during ProvidePictureBuffers(), used for checking and implementing
189 // HasAvailableOutputFrames(). 182 // HasAvailableOutputFrames().
190 int available_pictures_; 183 int available_pictures_;
191 184
192 // Bound to factories_->GetMessageLoop(). 185 // Bound to factories_->GetMessageLoop().
193 // NOTE: Weak pointers must be invalidated before all other member variables. 186 // NOTE: Weak pointers must be invalidated before all other member variables.
194 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; 187 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_;
195 188
196 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); 189 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
197 }; 190 };
198 191
199 } // namespace media 192 } // namespace media
200 193
201 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 194 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698