Chromium Code Reviews| 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 // 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 <GL/glx.h> | 12 #include <list> |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
unused if you take my suggestion below.
Pawel Osciak
2013/05/21 22:32:35
Done.
| |
| 13 | 13 #include <vector> |
| 14 #include <queue> | |
| 15 | 14 |
| 16 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
| 17 #include "base/lazy_instance.h" | |
| 18 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 19 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 20 #include "content/common/gpu/media/h264_dpb.h" | 18 #include "content/common/gpu/media/h264_dpb.h" |
| 21 #include "content/common/gpu/media/h264_parser.h" | 19 #include "content/common/gpu/media/h264_parser.h" |
| 22 #include "media/base/video_decoder_config.h" | 20 #include "content/common/gpu/media/vaapi_delegate.h" |
| 23 #include "media/base/limits.h" | 21 #include "media/base/limits.h" |
| 24 #include "third_party/libva/va/va.h" | |
| 25 | 22 |
| 26 namespace content { | 23 namespace content { |
| 27 | 24 |
| 28 // An H264 decoder for use for VA-API-specific decoding. Provides features not | 25 // An H264 decoder that utilizes VA-API. Provides features not supported by |
| 29 // supported by libva, including stream parsing, reference picture management | 26 // the VA-API userspace library (libva), including stream parsing, reference |
| 30 // and other operations not supported by the HW codec. | 27 // picture management and other operations not supported by the HW codec. |
| 31 // | 28 // |
| 32 // Provides functionality to allow plugging VAAPI HW acceleration into the | 29 // Provides functionality to allow plugging VAAPI HW acceleration into the |
| 33 // VDA framework. | 30 // VDA framework. |
| 34 // | 31 // |
| 35 // Clients of this class are expected to pass H264 Annex-B byte stream and | 32 // Clients of this class are expected to pass H264 Annex-B byte stream and |
| 36 // will receive decoded pictures via client-provided |OutputPicCB|. | 33 // will receive decoded surfaces via client-provided |OutputPicCB|. |
| 37 // | |
| 38 // If used in multi-threaded environment, some of the functions have to be | |
| 39 // called on the child thread, i.e. the main thread of the GPU process | |
| 40 // (the one that has the GLX context passed to Initialize() set as current). | |
| 41 // This is essential so that the GLX calls can work properly. | |
| 42 // Decoder thread, on the other hand, does not require a GLX context and should | |
| 43 // be the same as the one on which Decode*() functions are called. | |
| 44 class VaapiH264Decoder { | 34 class VaapiH264Decoder { |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
doco threaded characteristics (which I believe are
Pawel Osciak
2013/05/21 22:32:35
Done.
| |
| 45 public: | 35 public: |
| 46 // Callback invoked on the client when a picture is to be displayed. | 36 // Callback invoked on the client when a surface is to be displayed. |
| 47 // Arguments: input buffer id, output buffer id (both provided by the client | 37 // Arguments: input buffer id provided at the time of Decode() |
| 48 // at the time of Decode() and AssignPictureBuffer() calls). | 38 // and VASurface to output. |
| 49 typedef base::Callback<void(int32, int32)> OutputPicCB; | 39 typedef base::Callback< |
| 40 void(int32, const scoped_refptr<VASurface>&)> OutputPicCB; | |
| 50 | 41 |
| 51 // Callback invoked on the client to start a GPU job to decode and render | 42 enum VAVDAH264DecoderFailure { |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
s/VAVDA/VAAPI/ ?
Pawel Osciak
2013/05/21 22:32:35
All errors but VAAPI_ERROR are actually VAVDA-spec
Ami GONE FROM CHROMIUM
2013/05/22 23:59:47
My point was that VaapiH264Decoder is a thing, and
Pawel Osciak
2013/05/24 01:46:39
The name is already out there in histograms since
| |
| 52 // a video frame into a pixmap/texture. Callee has to call SubmitDecode() | 43 FRAME_MBS_ONLY_FLAG_NOT_ONE = 0, |
| 53 // for the given picture. | 44 GAPS_IN_FRAME_NUM = 1, |
| 54 // Arguments: output buffer id (provided by the client at the time of | 45 MID_STREAM_RESOLUTION_CHANGE = 2, |
| 55 // AssignPictureBuffer() call), va buffer and slice buffer queues to be | 46 INTERLACED_STREAM = 3, |
| 56 // passed to SubmitDecode(). | 47 VAAPI_ERROR = 4, |
| 57 typedef base::Callback< | 48 VAVDA_H264_DECODER_FAILURES_MAX, |
| 58 void(int32, | 49 }; |
| 59 scoped_ptr<std::queue<VABufferID> >, | 50 |
| 60 scoped_ptr<std::queue<VABufferID> >)> SubmitDecodeCB; | 51 // Callback to report errors for UMA purposes, not used to return errors |
| 52 // to clients. | |
| 53 typedef base::Callback<void(VAVDAH264DecoderFailure err)> ReportErrorCB; | |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
s/err/error/
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
ReportErrorToUmaCB
Pawel Osciak
2013/05/21 22:32:35
Done.
Pawel Osciak
2013/05/21 22:32:35
Done.
| |
| 61 | 54 |
| 62 // Decode result codes. | 55 // Decode result codes. |
| 63 enum DecResult { | 56 enum DecResult { |
| 64 kDecodeError, // Error while decoding. | 57 kDecodeError, // Error while decoding. |
| 65 // TODO posciak: unsupported streams are currently treated as error | 58 // TODO posciak: unsupported streams are currently treated as error |
| 66 // in decoding; in future it could perhaps be possible to fall back | 59 // in decoding; in future it could perhaps be possible to fall back |
| 67 // to software decoding instead. | 60 // to software decoding instead. |
| 68 // kStreamError, // Error in stream. | 61 // kStreamError, // Error in stream. |
| 69 kReadyToDecode, // Successfully initialized. | 62 kReadyToDecode, // Successfully initialized. |
| 70 kDecodedFrame, // Successfully decoded a frame. | |
| 71 kNeedMoreStreamData, // Need more stream data to decode the next frame. | 63 kNeedMoreStreamData, // Need more stream data to decode the next frame. |
| 72 kNoOutputAvailable, // Waiting for the client to free up output surfaces. | 64 kNoOutputAvailable, // Waiting for the client to free up output surfaces. |
| 73 }; | 65 }; |
| 74 | 66 |
| 75 VaapiH264Decoder(); | 67 // |vaapi_delegate| should be initialized. |
| 76 // Should be called on the GLX thread, for the surface cleanup to work | 68 // |output_pic_cb| notifies the client a surface is to be displayed. |
| 77 // properly. | 69 // |report_error_cb| called on errors for UMA purposes, not used to report |
| 70 // errors to clients. | |
| 71 VaapiH264Decoder(const scoped_refptr<VaapiDelegate>& vaapi_delegate, | |
| 72 const OutputPicCB& output_pic_cb, | |
| 73 const ReportErrorCB& report_error_cb); | |
| 74 | |
| 78 ~VaapiH264Decoder(); | 75 ~VaapiH264Decoder(); |
| 79 | 76 |
| 80 // Initializes and sets up libva connection and GL/X11 resources. | |
| 81 // Must be called on the GLX thread with |glx_context| being current and | |
| 82 // with decoder thread not yet running. | |
| 83 // |output_pic_cb| will be called to notify when a picture can be displayed. | |
| 84 bool Initialize(media::VideoCodecProfile profile, | |
| 85 Display* x_display, | |
| 86 GLXContext glx_context, | |
| 87 const base::Callback<bool(void)>& make_context_current, | |
| 88 const OutputPicCB& output_pic_cb, | |
| 89 const SubmitDecodeCB& submit_decode_cb) WARN_UNUSED_RESULT; | |
| 90 void Destroy(); | |
| 91 | |
| 92 // Notify the decoder that this output buffer has been consumed and | |
| 93 // can be reused (overwritten). | |
| 94 // Must be run on the decoder thread. | |
| 95 void ReusePictureBuffer(int32 picture_buffer_id); | |
| 96 | |
| 97 // Give a new picture buffer (texture) to decoder for use. | |
| 98 // Must be run on the GLX thread with decoder thread not yet running. | |
| 99 bool AssignPictureBuffer(int32 picture_buffer_id, uint32 texture_id) | |
| 100 WARN_UNUSED_RESULT; | |
| 101 | |
| 102 // Decode and put results into texture associated with given | |
| 103 // |picture_buffer_id|, using the buffers provided as arguments. Takes | |
| 104 // ownership of queues' memory and frees it once done. | |
| 105 // Must be run on the GLX thread. | |
| 106 bool SubmitDecode( | |
| 107 int32 picture_buffer_id, | |
| 108 scoped_ptr<std::queue<VABufferID> > va_bufs, | |
| 109 scoped_ptr<std::queue<VABufferID> > slice_bufs) WARN_UNUSED_RESULT; | |
| 110 | |
| 111 // Have the decoder flush its state and trigger output of all previously | 77 // Have the decoder flush its state and trigger output of all previously |
| 112 // decoded pictures via OutputPicCB. | 78 // decoded surfaces via OutputPicCB. |
| 113 // Returns false if any of the resulting invocations of the callback fail. | 79 // Returns false if any of the resulting invocations of the callback fail. |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
OutputPicCB returns void; how can its invocation "
Pawel Osciak
2013/05/21 22:32:35
Yeah, fallout. Should be if other stuff fails now.
| |
| 114 bool Flush() WARN_UNUSED_RESULT; | 80 bool Flush() WARN_UNUSED_RESULT; |
| 115 | 81 |
| 116 // Called while decoding. | 82 // To be called during decoding. |
| 117 // Stop decoding, discarding all remaining input/output, but do not flush | 83 // Stop (pause) decoding, discarding all remaining inputs and outputs, |
| 118 // state, so the playback of the same stream can be resumed (possibly from | 84 // but do not flush decoder state, so that the playback can be resumed laster, |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
typo: laster
Pawel Osciak
2013/05/21 22:32:35
Done.
| |
| 119 // another location). | 85 // possibly from a different location. |
| 120 void Reset(); | 86 void Reset(); |
| 121 | 87 |
| 122 // Set current stream data pointer to |ptr| and |size|. | 88 // Set current stream data pointer to |ptr| and |size|. |
| 123 // Must be run on decoder thread. | |
| 124 void SetStream(uint8* ptr, size_t size); | 89 void SetStream(uint8* ptr, size_t size); |
| 125 | 90 |
| 126 // Start parsing stream to detect picture sizes. Does not produce any | 91 // To be called at the start of decode or after reset. |
| 127 // decoded pictures and can be called without providing output textures. | 92 // When this call returns kReadyToDecode, the decoder is in a suitable |
| 128 // Also to be used after Reset() to find a suitable location in the | 93 // location in the stream to begin/resume decoding from and subsequent |
| 129 // stream to resume playback from. | 94 // decode requests should go via DecodeOneFrame. |
| 130 DecResult DecodeInitial(int32 input_id) WARN_UNUSED_RESULT; | 95 DecResult DecodeInitial(int32 input_id) WARN_UNUSED_RESULT; |
| 131 | 96 |
| 132 // Runs until a frame is decoded or end of provided stream data buffer | 97 // Runs until a frame is decoded or end of provided stream data buffer |
| 133 // is reached. Decoded pictures will be returned asynchronously via | 98 // is reached. Decoded surfaces will be returned asynchronously via |
| 134 // OutputPicCB. | 99 // OutputPicCB. Should be called after DecodeInitial returns kReadyToDecode. |
| 135 DecResult DecodeOneFrame(int32 input_id) WARN_UNUSED_RESULT; | 100 DecResult DecodeOneFrame(int32 input_id) WARN_UNUSED_RESULT; |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
should |input_id| (here and in DecodeInitial) actu
Pawel Osciak
2013/05/21 22:32:35
This assumes knowledge of VDA specifics that it sp
Ami GONE FROM CHROMIUM
2013/05/22 23:59:47
I don't see that, plus it's not true (a single NAL
Pawel Osciak
2013/05/24 01:46:39
Completing is not decoding, as decode order != out
| |
| 136 | 101 |
| 137 // Return dimensions for output buffer (texture) allocation. | 102 // Return dimensions/required number of output surfaces that client should |
| 103 // be ready to provide for the decoder to function properly. | |
| 138 // Valid only after a successful DecodeInitial(). | 104 // Valid only after a successful DecodeInitial(). |
| 139 int pic_height() { return pic_height_; } | 105 gfx::Size GetPicSize() { return pic_size_; } |
| 140 int pic_width() { return pic_width_; } | |
| 141 | |
| 142 // Return the number of output pictures required for decoding. | |
| 143 // Valid after a successful DecodeInitial(). | |
| 144 size_t GetRequiredNumOfPictures(); | 106 size_t GetRequiredNumOfPictures(); |
| 145 | 107 |
| 146 // Do any necessary initialization before the sandbox is enabled. | 108 // To be used by the client to feed decoder with output surfaces. |
| 147 static void PreSandboxInitialization(); | 109 void ReuseSurface(const scoped_refptr<VASurface>& va_surface); |
| 148 | |
| 149 // Lazily initialize static data after sandbox is enabled. Return false on | |
| 150 // init failure. | |
| 151 static bool PostSandboxInitialization(); | |
| 152 | 110 |
| 153 private: | 111 private: |
| 154 // We need to keep at most kDPBMaxSize pictures in DPB for | 112 // We need to keep at most kDPBMaxSize pictures in DPB for |
| 155 // reference/to display later and an additional one for the one currently | 113 // reference/to display later and an additional one for the one currently |
| 156 // being decoded. We also ask for some additional ones since VDA needs | 114 // being decoded. We also ask for some additional ones since VDA needs |
| 157 // to accumulate a few ready-to-output pictures before it actually starts | 115 // to accumulate a few ready-to-output pictures before it actually starts |
| 158 // displaying and giving them back. +2 instead of +1 because of subjective | 116 // displaying and giving them back. +2 instead of +1 because of subjective |
| 159 // smoothness improvement during testing. | 117 // smoothness improvement during testing. |
| 160 enum { | 118 enum { |
| 161 kPicsInPipeline = media::limits::kMaxVideoFrames + 2, | 119 kPicsInPipeline = media::limits::kMaxVideoFrames + 2, |
| 162 kMaxNumReqPictures = H264DPB::kDPBMaxSize + kPicsInPipeline, | 120 kMaxNumReqPictures = H264DPB::kDPBMaxSize + kPicsInPipeline, |
| 163 }; | 121 }; |
| 164 | 122 |
| 165 // Internal state of the decoder. | 123 // Internal state of the decoder. |
| 166 enum State { | 124 enum State { |
| 167 kUninitialized, // Initialize() not yet called. | 125 kIdle, // After initialization or after Reset(), need a resume point. |
| 168 kInitialized, // Initialize() called, pictures requested. | 126 kDecoding, // DecodeInitial() successful, ready to decode. |
| 169 kDecoding, // DecodeInitial() successful, output surfaces allocated. | 127 kError, // Error in decode, can't continue. |
| 170 kAfterReset, // After Reset() during decoding. | |
| 171 kError, // Error in kDecoding state. | |
| 172 }; | 128 }; |
| 173 | 129 |
| 174 // Get usable framebuffer configuration for use in binding textures | |
| 175 // or return false on failure. | |
| 176 bool InitializeFBConfig(); | |
| 177 | |
| 178 // Process H264 stream structures. | 130 // Process H264 stream structures. |
| 179 bool ProcessSPS(int sps_id); | 131 bool ProcessSPS(int sps_id); |
| 180 bool ProcessPPS(int pps_id); | 132 bool ProcessPPS(int pps_id); |
| 181 bool ProcessSlice(H264SliceHeader* slice_hdr); | 133 bool ProcessSlice(H264SliceHeader* slice_hdr); |
| 182 | 134 |
| 183 // Initialize the current picture according to data in |slice_hdr|. | 135 // Initialize the current picture according to data in |slice_hdr|. |
| 184 bool InitCurrPicture(H264SliceHeader* slice_hdr); | 136 bool InitCurrPicture(H264SliceHeader* slice_hdr); |
| 185 | 137 |
| 186 // Calculate picture order counts for the new picture | 138 // Calculate picture order counts for the new picture |
| 187 // on initialization of a new frame (see spec). | 139 // on initialization of a new frame (see spec). |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 217 | 169 |
| 218 // All data for a frame received, process it and decode. | 170 // All data for a frame received, process it and decode. |
| 219 bool FinishPrevFrameIfPresent(); | 171 bool FinishPrevFrameIfPresent(); |
| 220 | 172 |
| 221 // Called after decoding, performs all operations to be done after decoding, | 173 // Called after decoding, performs all operations to be done after decoding, |
| 222 // including DPB management, reference picture marking and memory management | 174 // including DPB management, reference picture marking and memory management |
| 223 // operations. | 175 // operations. |
| 224 // This will also output a picture if one is ready for output. | 176 // This will also output a picture if one is ready for output. |
| 225 bool FinishPicture(); | 177 bool FinishPicture(); |
| 226 | 178 |
| 227 // Convert VideoCodecProfile to VAProfile and set it as active. | 179 bool StartNewFakeFrame(int unused_frame_num); |
| 228 bool SetProfile(media::VideoCodecProfile profile); | 180 bool ConcealLostFrames(); |
| 181 bool ConcealLostIDR(); | |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
These three lines fell from the future through a t
Pawel Osciak
2013/05/21 22:32:35
Wow, indeed. Final rebase artifact
| |
| 229 | 182 |
| 230 // Vaapi-related functions. | 183 // Clear DPB contents and remove all pictures in DPB from *in_use_ list. |
| 231 | 184 // Cleared pictures will be made available for decode, unless they are |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
s/pictures/surfaces/ ?
Pawel Osciak
2013/05/21 22:32:35
Done.
| |
| 232 // Allocates VASurfaces and creates a VAContext for them. | 185 // at client waiting to be displayed. |
| 233 bool CreateVASurfaces(); | 186 void ClearDPB(); |
| 234 | |
| 235 // Destroys allocated VASurfaces and related VAContext. | |
| 236 void DestroyVASurfaces(); | |
| 237 // Destroys all buffers in |pending_slice_bufs_| and |pending_va_bufs_|. | |
| 238 void DestroyPendingBuffers(); | |
| 239 // Destroys a list of buffers. | |
| 240 void DestroyBuffers(size_t num_va_buffers, const VABufferID* va_buffers); | |
| 241 | 187 |
| 242 // These queue up data for HW decoder to be committed on running HW decode. | 188 // These queue up data for HW decoder to be committed on running HW decode. |
| 243 bool SendPPS(); | 189 bool SendPPS(); |
| 244 bool SendIQMatrix(); | 190 bool SendIQMatrix(); |
| 245 bool SendVASliceParam(H264SliceHeader* slice_hdr); | 191 bool SendVASliceParam(H264SliceHeader* slice_hdr); |
| 246 bool SendSliceData(const uint8* ptr, size_t size); | 192 bool SendSliceData(const uint8* ptr, size_t size); |
| 247 bool QueueSlice(H264SliceHeader* slice_hdr); | 193 bool QueueSlice(H264SliceHeader* slice_hdr); |
| 248 | 194 |
| 249 // Helper methods for filling HW structures. | 195 // Helper methods for filling HW structures. |
| 250 void FillVAPicture(VAPictureH264 *va_pic, H264Picture* pic); | 196 void FillVAPicture(VAPictureH264 *va_pic, H264Picture* pic); |
| 251 int FillVARefFramesFromDPB(VAPictureH264 *va_pics, int num_pics); | 197 int FillVARefFramesFromDPB(VAPictureH264 *va_pics, int num_pics); |
| 252 | 198 |
| 253 // Commits all pending data for HW decoder and starts HW decoder. | 199 // Commits all pending data for HW decoder and starts HW decoder. |
| 254 bool DecodePicture(); | 200 bool DecodePicture(); |
| 255 | 201 |
| 256 // Notifies client that a picture is ready for output. | 202 // Notifies client that a picture is ready for output. |
| 257 bool OutputPic(H264Picture* pic); | 203 bool OutputPic(H264Picture* pic); |
| 258 | 204 |
| 205 // Output all pictures in DPB that have not been outputted yet. | |
| 206 bool OutputAllRemainingPics(); | |
| 207 | |
| 208 // Decoder state. | |
| 259 State state_; | 209 State state_; |
| 260 | 210 |
| 261 // A frame has been sent to hardware as the result of the last | |
| 262 // DecodeOneFrame() call. | |
| 263 bool frame_ready_at_hw_; | |
| 264 | |
| 265 // Parser in use. | 211 // Parser in use. |
| 266 H264Parser parser_; | 212 H264Parser parser_; |
| 267 | 213 |
| 268 // DPB in use. | 214 // DPB in use. |
| 269 H264DPB dpb_; | 215 H264DPB dpb_; |
| 270 | 216 |
| 271 // Picture currently being processed/decoded. | 217 // Picture currently being processed/decoded. |
| 272 scoped_ptr<H264Picture> curr_pic_; | 218 scoped_ptr<H264Picture> curr_pic_; |
| 273 | 219 |
| 274 // Reference picture lists, constructed for each picture before decoding. | 220 // Reference picture lists, constructed for each picture before decoding. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 292 int prev_ref_top_field_order_cnt_; | 238 int prev_ref_top_field_order_cnt_; |
| 293 int prev_ref_pic_order_cnt_msb_; | 239 int prev_ref_pic_order_cnt_msb_; |
| 294 int prev_ref_pic_order_cnt_lsb_; | 240 int prev_ref_pic_order_cnt_lsb_; |
| 295 H264Picture::Field prev_ref_field_; | 241 H264Picture::Field prev_ref_field_; |
| 296 | 242 |
| 297 // Currently active SPS and PPS. | 243 // Currently active SPS and PPS. |
| 298 int curr_sps_id_; | 244 int curr_sps_id_; |
| 299 int curr_pps_id_; | 245 int curr_pps_id_; |
| 300 | 246 |
| 301 // Output picture size. | 247 // Output picture size. |
| 302 int pic_width_; | 248 gfx::Size pic_size_; |
| 303 int pic_height_; | |
| 304 | 249 |
| 305 // Data queued up for HW decoder, to be committed on next HW decode. | 250 // Represents a frame being decoded. Will always have a VASurface |
| 306 std::queue<VABufferID> pending_slice_bufs_; | 251 // assigned to it, which will eventually contain decoded picture data. |
| 307 std::queue<VABufferID> pending_va_bufs_; | |
| 308 | |
| 309 // Manages binding of a client-provided output buffer (texture) to VASurface. | |
| 310 class DecodeSurface; | 252 class DecodeSurface; |
| 311 | 253 |
| 312 // Maps output_buffer_id to a decode surface. Used to look up surfaces | 254 // Maps H.264 PicOrderCount to currently used DecodeSurfaces; |
| 313 // on requests from the client. | 255 typedef std::map<int, linked_ptr<DecodeSurface> > DecSurfacesInUse; |
| 314 typedef std::map<int32, linked_ptr<DecodeSurface> > DecodeSurfaces; | 256 DecSurfacesInUse decode_surfaces_in_use_; |
| 315 DecodeSurfaces decode_surfaces_; | 257 DecodeSurface* DecodeSurfaceByPoC(int poc); |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
Here and elsewhere: methods precede members.
Pawel Osciak
2013/05/21 22:32:35
Not a big fan of this rule, I prefer things in log
| |
| 316 | 258 |
| 317 // Number of decode surface currently available for decoding. | 259 // Unused VA surfaces returned by client, ready to be reused. |
| 318 int num_available_decode_surfaces_; | 260 std::list<scoped_refptr<VASurface> > available_va_surfaces_; |
|
Ami GONE FROM CHROMIUM
2013/05/17 23:19:15
FWIW could use a vector and always pop from the ba
Pawel Osciak
2013/05/21 22:32:35
Done.
| |
| 319 | 261 |
| 320 // Maps decode surfaces to PicOrderCount, used to look up output buffers | 262 // Assign an available surface to the given PicOrderCnt |poc|, |
| 321 // when a decision to output a picture has been made. | |
| 322 typedef std::map<int, DecodeSurface*> POCToDecodeSurfaces; | |
| 323 POCToDecodeSurfaces poc_to_decode_surfaces_; | |
| 324 | |
| 325 // Find an available surface and assign it to given PicOrderCnt |poc|, | |
| 326 // removing it from the available surfaces pool. Return true if a surface | 263 // removing it from the available surfaces pool. Return true if a surface |
| 327 // has been found, false otherwise. | 264 // has been found, false otherwise. |
| 328 bool AssignSurfaceToPoC(int poc); | 265 bool AssignSurfaceToPoC(int32 input_id, int poc); |
| 329 | 266 |
| 330 // Mark a surface as unused for decoding, unassigning it from |poc|. If the | 267 // Indicate that a surface is no longer needed by decoder. |
| 331 // corresponding picture is not at client to be displayed, | |
| 332 // release the surface. | |
| 333 void UnassignSurfaceFromPoC(int poc); | 268 void UnassignSurfaceFromPoC(int poc); |
| 334 | 269 |
| 335 // The id of current input buffer, which will be associated with an | 270 // The id of current input buffer, which will be associated with an |
| 336 // output picture if a frame is decoded successfully. | 271 // output surface when a frame is successfully decoded. |
| 337 int32 curr_input_id_; | 272 int32 curr_input_id_; |
| 338 | 273 |
| 339 // Any method that uses GL/VA routines probably wants to make sure | 274 scoped_refptr<VaapiDelegate> vaapi_delegate_; |
| 340 // make_context_current_.Run() is called at the top of the method. | |
| 341 // X/GLX handles. | |
| 342 Display* x_display_; | |
| 343 base::Callback<bool(void)> make_context_current_; | |
| 344 GLXFBConfig fb_config_; | |
| 345 | 275 |
| 346 // VA handles. | 276 // Called by decoder when a surface should be outputted. |
| 347 VADisplay va_display_; | |
| 348 VAConfigID va_config_id_; | |
| 349 VAContextID va_context_id_; | |
| 350 VAProfile profile_; | |
| 351 bool va_context_created_; | |
| 352 | |
| 353 // Allocated VASurfaces. | |
| 354 VASurfaceID va_surface_ids_[kMaxNumReqPictures]; | |
| 355 | |
| 356 // Called by decoder when a picture should be outputted. | |
| 357 OutputPicCB output_pic_cb_; | 277 OutputPicCB output_pic_cb_; |
| 358 | 278 |
| 359 // Called by decoder to post a decode job on the ChildThread. | 279 // Called to report decoding error to UMA, not used to indicate errors |
| 360 SubmitDecodeCB submit_decode_cb_; | 280 // to clients. |
| 281 ReportErrorCB report_error_cb_; | |
| 361 | 282 |
| 362 // PicOrderCount of the previously outputted frame. | 283 // PicOrderCount of the previously outputted frame. |
| 363 int last_output_poc_; | 284 int last_output_poc_; |
| 364 | 285 |
| 365 // Maximum size of DPB required by codec level. | 286 // Maximum size of DPB required by codec level. |
| 366 int max_dpb_size_; | 287 int max_dpb_size_; |
| 367 | 288 |
| 368 // Has static initialization of pre-sandbox components completed successfully? | |
| 369 static bool pre_sandbox_init_done_; | |
| 370 | |
| 371 DISALLOW_COPY_AND_ASSIGN(VaapiH264Decoder); | 289 DISALLOW_COPY_AND_ASSIGN(VaapiH264Decoder); |
| 372 }; | 290 }; |
| 373 | 291 |
| 374 } // namespace content | 292 } // namespace content |
| 375 | 293 |
| 376 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ | 294 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_H264_DECODER_H_ |
| OLD | NEW |