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

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

Issue 1369673002: H264Decoder: Handle gaps in frame_num. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 CONTENT_COMMON_GPU_MEDIA_H264_DECODER_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_H264_DECODER_H_
6 #define CONTENT_COMMON_GPU_MEDIA_H264_DECODER_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_H264_DECODER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Internal state of the decoder. 122 // Internal state of the decoder.
123 enum State { 123 enum State {
124 kNeedStreamMetadata, // After initialization, need an SPS. 124 kNeedStreamMetadata, // After initialization, need an SPS.
125 kDecoding, // Ready to decode from any point. 125 kDecoding, // Ready to decode from any point.
126 kAfterReset, // After Reset(), need a resume point. 126 kAfterReset, // After Reset(), need a resume point.
127 kError, // Error in decode, can't continue. 127 kError, // Error in decode, can't continue.
128 }; 128 };
129 129
130 // Process H264 stream structures. 130 // Process H264 stream structures.
131 bool ProcessSPS(int sps_id, bool* need_new_buffers); 131 bool ProcessSPS(int sps_id, bool* need_new_buffers);
132 bool ProcessPPS(int pps_id); 132 // Process current slice header to discover if we need to start a new picture,
133 bool PreprocessSlice(media::H264SliceHeader* slice_hdr); 133 // finishing up the current one.
134 bool ProcessSlice(media::H264SliceHeader* slice_hdr); 134 bool PreprocessCurrentSlice();
135 // Process current slice as a slice of the current picture.
136 bool ProcessCurrentSlice();
137
138 // Return true if we need to start a new picture.
139 bool IsNewPrimaryCodedPicture(const media::H264SliceHeader* slice_hdr) const;
xhwang 2015/10/12 18:01:17 Here and throughout this CL, for input only parame
Pawel Osciak 2015/10/13 01:23:22 I agree and had considered this, but wanted to kee
135 140
136 // Initialize the current picture according to data in |slice_hdr|. 141 // Initialize the current picture according to data in |slice_hdr|.
137 bool InitCurrPicture(media::H264SliceHeader* slice_hdr); 142 bool InitCurrPicture(const media::H264SliceHeader* slice_hdr);
138 143
139 // Calculate picture order counts for the new picture 144 // Initialize |pic| as a "non-existing" picture (see spec) with |frame_num|,
140 // on initialization of a new frame (see spec). 145 // to be used for frame gap concealment.
141 bool CalculatePicOrderCounts(media::H264SliceHeader* slice_hdr); 146 bool InitNonexistingPicture(scoped_refptr<H264Picture> pic, int frame_num);
142 147
143 // Update PicNum values in pictures stored in DPB on creation of new 148 // Calculate picture order counts for |pic| on initialization
144 // frame (see spec). 149 // of a new frame (see spec).
145 void UpdatePicNums(); 150 bool CalculatePicOrderCounts(scoped_refptr<H264Picture> pic);
151
152 // Update PicNum values in pictures stored in DPB on creation of
153 // a picture with |frame_num|.
154 void UpdatePicNums(int frame_num);
146 155
147 bool UpdateMaxNumReorderFrames(const media::H264SPS* sps); 156 bool UpdateMaxNumReorderFrames(const media::H264SPS* sps);
148 157
149 // Prepare reference picture lists for the current frame. 158 // Prepare reference picture lists for the current frame.
150 void PrepareRefPicLists(media::H264SliceHeader* slice_hdr); 159 void PrepareRefPicLists(const media::H264SliceHeader* slice_hdr);
151 // Prepare reference picture lists for the given slice. 160 // Prepare reference picture lists for the given slice.
152 bool ModifyReferencePicLists(media::H264SliceHeader* slice_hdr, 161 bool ModifyReferencePicLists(const media::H264SliceHeader* slice_hdr,
153 H264Picture::Vector* ref_pic_list0, 162 H264Picture::Vector* ref_pic_list0,
154 H264Picture::Vector* ref_pic_list1); 163 H264Picture::Vector* ref_pic_list1);
155 164
156 // Construct initial reference picture lists for use in decoding of 165 // Construct initial reference picture lists for use in decoding of
157 // P and B pictures (see 8.2.4 in spec). 166 // P and B pictures (see 8.2.4 in spec).
158 void ConstructReferencePicListsP(media::H264SliceHeader* slice_hdr); 167 void ConstructReferencePicListsP(const media::H264SliceHeader* slice_hdr);
159 void ConstructReferencePicListsB(media::H264SliceHeader* slice_hdr); 168 void ConstructReferencePicListsB(const media::H264SliceHeader* slice_hdr);
160 169
161 // Helper functions for reference list construction, per spec. 170 // Helper functions for reference list construction, per spec.
162 int PicNumF(const scoped_refptr<H264Picture>& pic); 171 int PicNumF(const scoped_refptr<H264Picture>& pic);
163 int LongTermPicNumF(const scoped_refptr<H264Picture>& pic); 172 int LongTermPicNumF(const scoped_refptr<H264Picture>& pic);
164 173
165 // Perform the reference picture lists' modification (reordering), as 174 // Perform the reference picture lists' modification (reordering), as
166 // specified in spec (8.2.4). 175 // specified in spec (8.2.4).
167 // 176 //
168 // |list| indicates list number and should be either 0 or 1. 177 // |list| indicates list number and should be either 0 or 1.
169 bool ModifyReferencePicList(media::H264SliceHeader* slice_hdr, 178 bool ModifyReferencePicList(const media::H264SliceHeader* slice_hdr,
170 int list, 179 int list,
171 H264Picture::Vector* ref_pic_listx); 180 H264Picture::Vector* ref_pic_listx);
172 181
173 // Perform reference picture memory management operations (marking/unmarking 182 // Perform reference picture memory management operations (marking/unmarking
174 // of reference pictures, long term picture management, discarding, etc.). 183 // of reference pictures, long term picture management, discarding, etc.).
175 // See 8.2.5 in spec. 184 // See 8.2.5 in spec.
176 bool HandleMemoryManagementOps(); 185 bool HandleMemoryManagementOps(scoped_refptr<H264Picture> pic);
177 void ReferencePictureMarking(); 186 bool ReferencePictureMarking(scoped_refptr<H264Picture> pic);
187 bool SlidingWindowPictureMarking();
188
189 // Handle a gap in frame_num in the stream up to |frame_num|, by creating
190 // "non-existing" pictures (see spec).
191 bool HandleFrameNumGap(int frame_num);
178 192
179 // Start processing a new frame. 193 // Start processing a new frame.
180 bool StartNewFrame(media::H264SliceHeader* slice_hdr); 194 bool StartNewFrame(const media::H264SliceHeader* slice_hdr);
181 195
182 // All data for a frame received, process it and decode. 196 // All data for a frame received, process it and decode.
183 bool FinishPrevFrameIfPresent(); 197 bool FinishPrevFrameIfPresent();
184 198
185 // Called after decoding, performs all operations to be done after decoding, 199 // Called after we are done processing |pic|. Performs all operations to be
186 // including DPB management, reference picture marking and memory management 200 // done after decoding, including DPB management, reference picture marking
187 // operations. 201 // and memory management operations.
188 // This will also output a picture if one is ready for output. 202 // This will also output pictures if any have become ready to be outputted
189 bool FinishPicture(); 203 // after processing |pic|.
204 bool FinishPicture(scoped_refptr<H264Picture> pic);
190 205
191 // Clear DPB contents and remove all surfaces in DPB from *in_use_ list. 206 // Clear DPB contents and remove all surfaces in DPB from *in_use_ list.
192 // Cleared pictures will be made available for decode, unless they are 207 // Cleared pictures will be made available for decode, unless they are
193 // at client waiting to be displayed. 208 // at client waiting to be displayed.
194 void ClearDPB(); 209 void ClearDPB();
195 210
196 // Commits all pending data for HW decoder and starts HW decoder. 211 // Commits all pending data for HW decoder and starts HW decoder.
197 bool DecodePicture(); 212 bool DecodePicture();
198 213
199 // Notifies client that a picture is ready for output. 214 // Notifies client that a picture is ready for output.
(...skipping 13 matching lines...) Expand all
213 228
214 // Picture currently being processed/decoded. 229 // Picture currently being processed/decoded.
215 scoped_refptr<H264Picture> curr_pic_; 230 scoped_refptr<H264Picture> curr_pic_;
216 231
217 // Reference picture lists, constructed for each frame. 232 // Reference picture lists, constructed for each frame.
218 H264Picture::Vector ref_pic_list_p0_; 233 H264Picture::Vector ref_pic_list_p0_;
219 H264Picture::Vector ref_pic_list_b0_; 234 H264Picture::Vector ref_pic_list_b0_;
220 H264Picture::Vector ref_pic_list_b1_; 235 H264Picture::Vector ref_pic_list_b1_;
221 236
222 // Global state values, needed in decoding. See spec. 237 // Global state values, needed in decoding. See spec.
223 int max_pic_order_cnt_lsb_;
224 int max_frame_num_; 238 int max_frame_num_;
225 int max_pic_num_; 239 int max_pic_num_;
226 int max_long_term_frame_idx_; 240 int max_long_term_frame_idx_;
227 size_t max_num_reorder_frames_; 241 size_t max_num_reorder_frames_;
228 242
229 int frame_num_;
230 int prev_frame_num_; 243 int prev_frame_num_;
244 int prev_ref_frame_num_;
231 int prev_frame_num_offset_; 245 int prev_frame_num_offset_;
232 bool prev_has_memmgmnt5_; 246 bool prev_has_memmgmnt5_;
233 247
234 // Values related to previously decoded reference picture. 248 // Values related to previously decoded reference picture.
235 bool prev_ref_has_memmgmnt5_; 249 bool prev_ref_has_memmgmnt5_;
236 int prev_ref_top_field_order_cnt_; 250 int prev_ref_top_field_order_cnt_;
237 int prev_ref_pic_order_cnt_msb_; 251 int prev_ref_pic_order_cnt_msb_;
238 int prev_ref_pic_order_cnt_lsb_; 252 int prev_ref_pic_order_cnt_lsb_;
239 H264Picture::Field prev_ref_field_; 253 H264Picture::Field prev_ref_field_;
240 254
(...skipping 12 matching lines...) Expand all
253 int last_output_poc_; 267 int last_output_poc_;
254 268
255 H264Accelerator* accelerator_; 269 H264Accelerator* accelerator_;
256 270
257 DISALLOW_COPY_AND_ASSIGN(H264Decoder); 271 DISALLOW_COPY_AND_ASSIGN(H264Decoder);
258 }; 272 };
259 273
260 } // namespace content 274 } // namespace content
261 275
262 #endif // CONTENT_COMMON_GPU_MEDIA_H264_DECODER_H_ 276 #endif // CONTENT_COMMON_GPU_MEDIA_H264_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/h264_decoder.cc » ('j') | content/common/gpu/media/h264_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698