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

Side by Side Diff: content/common/gpu/media/vt_video_decode_accelerator.h

Issue 653663006: Support configuration changes in VTVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vt_make_context_current
Patch Set: Rebase Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Methods for interacting with VideoToolbox. Run on |decoder_thread_|. 87 // Methods for interacting with VideoToolbox. Run on |decoder_thread_|.
88 bool ConfigureDecoder( 88 bool ConfigureDecoder(
89 const std::vector<const uint8_t*>& nalu_data_ptrs, 89 const std::vector<const uint8_t*>& nalu_data_ptrs,
90 const std::vector<size_t>& nalu_data_sizes); 90 const std::vector<size_t>& nalu_data_sizes);
91 void DecodeTask(const media::BitstreamBuffer&); 91 void DecodeTask(const media::BitstreamBuffer&);
92 void FlushTask(); 92 void FlushTask();
93 void DropBitstream(int32_t bitstream_id); 93 void DropBitstream(int32_t bitstream_id);
94 94
95 // Methods for interacting with |client_|. Run on |gpu_task_runner_|. 95 // Methods for interacting with |client_|. Run on |gpu_task_runner_|.
96 void OutputTask(DecodedFrame frame); 96 void OutputTask(DecodedFrame frame);
97 void SizeChangedTask(gfx::Size coded_size);
98 void NotifyError(Error error); 97 void NotifyError(Error error);
99 98
100 // Send decoded frames up to and including |up_to_bitstream_id|, and return 99 // Send decoded frames up to and including |up_to_bitstream_id|, and return
101 // the last sent |bitstream_id|. 100 // the last sent |bitstream_id|.
102 int32_t SendPictures(int32_t up_to_bitstream_id); 101 int32_t SendPictures(int32_t up_to_bitstream_id);
103 102
103 // Internal helpers for SendPictures().
104 int32_t ProcessDroppedFrames(
Pawel Osciak 2014/10/30 11:02:52 Please document.
sandersd (OOO until July 31) 2014/10/30 22:54:40 Done.
105 int32_t last_sent_bitstream_id,
106 int32_t up_to_bitstream_id);
107 void ProcessSizeChange();
108
104 // Since VideoToolbox has no reset feature (only flush), and the VDA API 109 // Since VideoToolbox has no reset feature (only flush), and the VDA API
105 // allows Decode() and Flush() calls during a reset operation, it's possible 110 // allows Decode() and Flush() calls during a reset operation, it's possible
106 // to have multiple pending actions at once. We handle the fully general case 111 // to have multiple pending actions at once. We handle the fully general case
107 // of an arbitrary sequence of pending actions (in reality, there should 112 // of an arbitrary sequence of pending actions (in reality, there should
108 // probably be at most one reset and one flush at a time). 113 // probably be at most one reset and one flush at a time).
109 void QueueAction(Action action); 114 void QueueAction(Action action);
110 115
111 // Process queued decoded frames, usually by sending them (unless there 116 // Process queued decoded frames, usually by sending them (unless there
112 // is a pending ACTION_RESET or ACTION_DESTROY, in which case they are 117 // is a pending ACTION_RESET or ACTION_DESTROY, in which case they are
113 // dropped), completing queued actions along the way. 118 // dropped), completing queued actions along the way.
114 void ProcessDecodedFrames(); 119 void ProcessDecodedFrames();
115 120
116 // Complete a particular action, by eg. calling NotifyFlushDone(). 121 // Complete a particular action, by eg. calling NotifyFlushDone().
117 // Warning: Deletes |this| if |action| is ACTION_DESTROY. 122 // Warning: Deletes |this| if |action| is ACTION_DESTROY.
118 void CompleteAction(Action action); 123 void CompleteAction(Action action);
119 124
120 // Complete all actions pending for a particular |bitstream_id|. 125 // Complete all actions pending for a particular |bitstream_id|.
121 // Warning: Do not call if there is a pending ACTION_DESTROY. 126 // Warning: Do not call if there is a pending ACTION_DESTROY.
122 void CompleteActions(int32_t bitstream_id); 127 void CompleteActions(int32_t bitstream_id);
123 128
124 // 129 //
125 // GPU thread state. 130 // GPU thread state.
126 // 131 //
127 CGLContextObj cgl_context_; 132 CGLContextObj cgl_context_;
128 base::Callback<bool(void)> make_context_current_; 133 base::Callback<bool(void)> make_context_current_;
129 media::VideoDecodeAccelerator::Client* client_; 134 media::VideoDecodeAccelerator::Client* client_;
130 bool has_error_; // client_->NotifyError() called. 135 bool has_error_; // client_->NotifyError() called.
131 gfx::Size texture_size_; 136 gfx::Size picture_size_;
132 std::queue<PendingAction> pending_actions_; 137 std::queue<PendingAction> pending_actions_;
133 std::queue<int32_t> pending_bitstream_ids_; 138 std::queue<int32_t> pending_bitstream_ids_;
Pawel Osciak 2014/10/30 11:02:52 Could we please add documentation for members?
sandersd (OOO until July 31) 2014/10/30 22:54:40 Done.
139 std::set<int32_t> assigned_picture_ids_;
134 140
135 // Texture IDs of pictures. 141 // Texture IDs of pictures.
136 // TODO(sandersd): A single map of structs holding picture data. 142 // TODO(sandersd): A single map of structs holding picture data.
Pawel Osciak 2014/11/02 23:09:52 This would still be great to have...
sandersd (OOO until July 31) 2014/11/03 21:14:25 Acknowledged.
137 std::map<int32_t, uint32_t> texture_ids_; 143 std::map<int32_t, uint32_t> texture_ids_;
138 144
139 // Pictures ready to be rendered to. 145 // Pictures ready to be rendered to.
140 std::queue<int32_t> available_picture_ids_; 146 std::vector<int32_t> available_picture_ids_;
141 147
142 // Decoded frames ready to render. 148 // Decoded frames ready to render.
143 std::queue<DecodedFrame> decoded_frames_; 149 std::queue<DecodedFrame> decoded_frames_;
144 150
145 // Image buffers kept alive while they are bound to pictures. 151 // Image buffers kept alive while they are bound to pictures.
146 std::map<int32_t, base::ScopedCFTypeRef<CVImageBufferRef>> picture_bindings_; 152 std::map<int32_t, base::ScopedCFTypeRef<CVImageBufferRef>> picture_bindings_;
147 153
148 // 154 //
149 // Decoder thread state. 155 // Decoder thread state.
150 // 156 //
151 VTDecompressionOutputCallbackRecord callback_; 157 VTDecompressionOutputCallbackRecord callback_;
152 base::ScopedCFTypeRef<CMFormatDescriptionRef> format_; 158 base::ScopedCFTypeRef<CMFormatDescriptionRef> format_;
153 base::ScopedCFTypeRef<VTDecompressionSessionRef> session_; 159 base::ScopedCFTypeRef<VTDecompressionSessionRef> session_;
154 media::H264Parser parser_; 160 media::H264Parser parser_;
155 gfx::Size coded_size_; 161
162 std::vector<uint8_t> last_sps_;
163 std::vector<uint8_t> last_spsext_;
164 std::vector<uint8_t> last_pps_;
156 165
157 // 166 //
158 // Shared state (set up and torn down on GPU thread). 167 // Shared state (set up and torn down on GPU thread).
159 // 168 //
160 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; 169 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
161 170
162 // This WeakPtrFactory does not need to be last as its pointers are bound to 171 // This WeakPtrFactory does not need to be last as its pointers are bound to
163 // the same thread it is destructed on (the GPU thread). 172 // the same thread it is destructed on (the GPU thread).
164 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; 173 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_;
165 174
166 // Declared last to ensure that all decoder thread tasks complete before any 175 // Declared last to ensure that all decoder thread tasks complete before any
167 // state is destructed. 176 // state is destructed.
168 base::Thread decoder_thread_; 177 base::Thread decoder_thread_;
169 178
170 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); 179 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator);
171 }; 180 };
172 181
173 } // namespace content 182 } // namespace content
174 183
175 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ 184 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698