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

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

Issue 119153002: Move H264Parser and H264BitReader to media/filters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 // This file contains an implementation of a class that provides H264 decode 5 // This file contains an implementation of a class that provides H264 decode
6 // support for use with VAAPI hardware video decode acceleration on Intel 6 // support for use with VAAPI hardware video decode acceleration on Intel
7 // systems. 7 // systems.
8 8
9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ 9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_
10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ 10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_
11 11
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "content/common/gpu/media/h264_dpb.h" 18 #include "content/common/gpu/media/h264_dpb.h"
19 #include "content/common/gpu/media/h264_parser.h"
20 #include "content/common/gpu/media/vaapi_wrapper.h" 19 #include "content/common/gpu/media/vaapi_wrapper.h"
21 #include "media/base/limits.h" 20 #include "media/base/limits.h"
21 #include "media/filters/h264_parser.h"
22 22
23 namespace content { 23 namespace content {
24 24
25 // An H264 decoder that utilizes VA-API. Provides features not supported by 25 // An H264 decoder that utilizes VA-API. Provides features not supported by
26 // the VA-API userspace library (libva), including stream parsing, reference 26 // the VA-API userspace library (libva), including stream parsing, reference
27 // picture management and other operations not supported by the HW codec. 27 // picture management and other operations not supported by the HW codec.
28 // 28 //
29 // Provides functionality to allow plugging VAAPI HW acceleration into the 29 // Provides functionality to allow plugging VAAPI HW acceleration into the
30 // VDA framework. 30 // VDA framework.
31 // 31 //
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool ProcessPPS(int pps_id);
133 bool ProcessSlice(H264SliceHeader* slice_hdr); 133 bool ProcessSlice(media::H264SliceHeader* slice_hdr);
134 134
135 // Initialize the current picture according to data in |slice_hdr|. 135 // Initialize the current picture according to data in |slice_hdr|.
136 bool InitCurrPicture(H264SliceHeader* slice_hdr); 136 bool InitCurrPicture(media::H264SliceHeader* slice_hdr);
137 137
138 // Calculate picture order counts for the new picture 138 // Calculate picture order counts for the new picture
139 // on initialization of a new frame (see spec). 139 // on initialization of a new frame (see spec).
140 bool CalculatePicOrderCounts(H264SliceHeader* slice_hdr); 140 bool CalculatePicOrderCounts(media::H264SliceHeader* slice_hdr);
141 141
142 // Update PicNum values in pictures stored in DPB on creation of new 142 // Update PicNum values in pictures stored in DPB on creation of new
143 // frame (see spec). 143 // frame (see spec).
144 void UpdatePicNums(); 144 void UpdatePicNums();
145 145
146 // Prepare reference picture lists (ref_pic_list[01]_). 146 // Prepare reference picture lists (ref_pic_list[01]_).
147 bool PrepareRefPicLists(H264SliceHeader* slice_hdr); 147 bool PrepareRefPicLists(media::H264SliceHeader* slice_hdr);
148 148
149 // Construct initial reference picture lists for use in decoding of 149 // Construct initial reference picture lists for use in decoding of
150 // P and B pictures (see 8.2.4 in spec). 150 // P and B pictures (see 8.2.4 in spec).
151 void ConstructReferencePicListsP(H264SliceHeader* slice_hdr); 151 void ConstructReferencePicListsP(media::H264SliceHeader* slice_hdr);
152 void ConstructReferencePicListsB(H264SliceHeader* slice_hdr); 152 void ConstructReferencePicListsB(media::H264SliceHeader* slice_hdr);
153 153
154 // Helper functions for reference list construction, per spec. 154 // Helper functions for reference list construction, per spec.
155 int PicNumF(H264Picture *pic); 155 int PicNumF(H264Picture *pic);
156 int LongTermPicNumF(H264Picture *pic); 156 int LongTermPicNumF(H264Picture *pic);
157 157
158 // Perform the reference picture lists' modification (reordering), as 158 // Perform the reference picture lists' modification (reordering), as
159 // specified in spec (8.2.4). 159 // specified in spec (8.2.4).
160 // 160 //
161 // |list| indicates list number and should be either 0 or 1. 161 // |list| indicates list number and should be either 0 or 1.
162 bool ModifyReferencePicList(H264SliceHeader *slice_hdr, int list); 162 bool ModifyReferencePicList(media::H264SliceHeader* slice_hdr, int list);
163 163
164 // Perform reference picture memory management operations (marking/unmarking 164 // Perform reference picture memory management operations (marking/unmarking
165 // of reference pictures, long term picture management, discarding, etc.). 165 // of reference pictures, long term picture management, discarding, etc.).
166 // See 8.2.5 in spec. 166 // See 8.2.5 in spec.
167 bool HandleMemoryManagementOps(); 167 bool HandleMemoryManagementOps();
168 void ReferencePictureMarking(); 168 void ReferencePictureMarking();
169 169
170 // Start processing a new frame. 170 // Start processing a new frame.
171 bool StartNewFrame(H264SliceHeader* slice_hdr); 171 bool StartNewFrame(media::H264SliceHeader* slice_hdr);
172 172
173 // All data for a frame received, process it and decode. 173 // All data for a frame received, process it and decode.
174 bool FinishPrevFrameIfPresent(); 174 bool FinishPrevFrameIfPresent();
175 175
176 // Called after decoding, performs all operations to be done after decoding, 176 // Called after decoding, performs all operations to be done after decoding,
177 // including DPB management, reference picture marking and memory management 177 // including DPB management, reference picture marking and memory management
178 // operations. 178 // operations.
179 // This will also output a picture if one is ready for output. 179 // This will also output a picture if one is ready for output.
180 bool FinishPicture(); 180 bool FinishPicture();
181 181
182 // Clear DPB contents and remove all surfaces in DPB from *in_use_ list. 182 // Clear DPB contents and remove all surfaces in DPB from *in_use_ list.
183 // Cleared pictures will be made available for decode, unless they are 183 // Cleared pictures will be made available for decode, unless they are
184 // at client waiting to be displayed. 184 // at client waiting to be displayed.
185 void ClearDPB(); 185 void ClearDPB();
186 186
187 // These queue up data for HW decoder to be committed on running HW decode. 187 // These queue up data for HW decoder to be committed on running HW decode.
188 bool SendPPS(); 188 bool SendPPS();
189 bool SendIQMatrix(); 189 bool SendIQMatrix();
190 bool SendVASliceParam(H264SliceHeader* slice_hdr); 190 bool SendVASliceParam(media::H264SliceHeader* slice_hdr);
191 bool SendSliceData(const uint8* ptr, size_t size); 191 bool SendSliceData(const uint8* ptr, size_t size);
192 bool QueueSlice(H264SliceHeader* slice_hdr); 192 bool QueueSlice(media::H264SliceHeader* slice_hdr);
193 193
194 // Helper methods for filling HW structures. 194 // Helper methods for filling HW structures.
195 void FillVAPicture(VAPictureH264 *va_pic, H264Picture* pic); 195 void FillVAPicture(VAPictureH264 *va_pic, H264Picture* pic);
196 int FillVARefFramesFromDPB(VAPictureH264 *va_pics, int num_pics); 196 int FillVARefFramesFromDPB(VAPictureH264 *va_pics, int num_pics);
197 197
198 // Commits all pending data for HW decoder and starts HW decoder. 198 // Commits all pending data for HW decoder and starts HW decoder.
199 bool DecodePicture(); 199 bool DecodePicture();
200 200
201 // Notifies client that a picture is ready for output. 201 // Notifies client that a picture is ready for output.
202 bool OutputPic(H264Picture* pic); 202 bool OutputPic(H264Picture* pic);
(...skipping 13 matching lines...) Expand all
216 // Indicate that a surface is no longer needed by decoder. 216 // Indicate that a surface is no longer needed by decoder.
217 void UnassignSurfaceFromPoC(int poc); 217 void UnassignSurfaceFromPoC(int poc);
218 218
219 // Return DecodeSurface assigned to |poc|. 219 // Return DecodeSurface assigned to |poc|.
220 DecodeSurface* DecodeSurfaceByPoC(int poc); 220 DecodeSurface* DecodeSurfaceByPoC(int poc);
221 221
222 // Decoder state. 222 // Decoder state.
223 State state_; 223 State state_;
224 224
225 // Parser in use. 225 // Parser in use.
226 H264Parser parser_; 226 media::H264Parser parser_;
227 227
228 // DPB in use. 228 // DPB in use.
229 H264DPB dpb_; 229 H264DPB dpb_;
230 230
231 // Picture currently being processed/decoded. 231 // Picture currently being processed/decoded.
232 scoped_ptr<H264Picture> curr_pic_; 232 scoped_ptr<H264Picture> curr_pic_;
233 233
234 // Reference picture lists, constructed for each picture before decoding. 234 // Reference picture lists, constructed for each picture before decoding.
235 // Those lists are not owners of the pointers (DPB is). 235 // Those lists are not owners of the pointers (DPB is).
236 H264Picture::PtrVector ref_pic_list0_; 236 H264Picture::PtrVector ref_pic_list0_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 // PicOrderCount of the previously outputted frame. 284 // PicOrderCount of the previously outputted frame.
285 int last_output_poc_; 285 int last_output_poc_;
286 286
287 DISALLOW_COPY_AND_ASSIGN(VaapiH264Decoder); 287 DISALLOW_COPY_AND_ASSIGN(VaapiH264Decoder);
288 }; 288 };
289 289
290 } // namespace content 290 } // namespace content
291 291
292 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ 292 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_
OLDNEW
« no previous file with comments | « content/common/gpu/media/v4l2_video_decode_accelerator.cc ('k') | content/common/gpu/media/vaapi_h264_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698