Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ | |
| 7 | |
| 8 #include <linux/videodev2.h> | |
| 9 #include <queue> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/memory/linked_ptr.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "base/synchronization/waitable_event.h" | |
| 17 #include "base/threading/thread.h" | |
| 18 #include "content/common/content_export.h" | |
| 19 #include "content/common/gpu/media/h264_decoder.h" | |
| 20 #include "content/common/gpu/media/v4l2_video_device.h" | |
| 21 #include "content/common/gpu/media/vp8_decoder.h" | |
| 22 #include "media/video/video_decode_accelerator.h" | |
| 23 | |
| 24 namespace content { | |
| 25 | |
| 26 // An implementation of VideoDecodeAccelerator that utilizes the V4L2 slice | |
| 27 // level codec API for decoding. The slice level API provides only a low-level | |
| 28 // decoding functionality and requires userspace to provide support for parsing | |
| 29 // the input stream and managing decoder state across frames. | |
| 30 class CONTENT_EXPORT V4L2SliceVideoDecodeAccelerator | |
| 31 : public media::VideoDecodeAccelerator { | |
| 32 public: | |
| 33 class V4L2DecodeSurface : public base::RefCounted<V4L2DecodeSurface> { | |
| 34 public: | |
| 35 using ReleaseCB = base::Callback<void(int)>; | |
| 36 | |
| 37 V4L2DecodeSurface(int32 bitstream_id, | |
| 38 int input_record, | |
| 39 int output_record, | |
| 40 const ReleaseCB& release_cb); | |
| 41 virtual ~V4L2DecodeSurface(); | |
| 42 | |
| 43 // Mark the surface as decoded. This will also release all references, as | |
| 44 // they are not needed anymore. | |
| 45 void SetDecoded(); | |
| 46 bool decoded() const { return decoded_; } | |
| 47 | |
| 48 int32 bitstream_id() const { return bitstream_id_; } | |
| 49 int input_record() const { return input_record_; } | |
| 50 int output_record() const { return output_record_; } | |
| 51 uint32_t config_store() const { return config_store_; } | |
| 52 | |
| 53 // Take references to each reference surface and keep them until the | |
| 54 // target surface is decoded. | |
| 55 void SetReferenceSurfaces( | |
| 56 const std::vector<scoped_refptr<V4L2DecodeSurface>>& ref_surfaces); | |
| 57 | |
| 58 std::string ToString() const; | |
|
Owen Lin
2015/01/09 09:56:14
const std::string&
Pawel Osciak
2015/01/12 07:18:19
I'm not sure we want a reference, the string is lo
| |
| 59 | |
| 60 private: | |
| 61 int32 bitstream_id_; | |
| 62 int input_record_; | |
| 63 int output_record_; | |
| 64 uint32_t config_store_; | |
| 65 | |
| 66 bool decoded_; | |
| 67 ReleaseCB release_cb_; | |
| 68 | |
| 69 std::vector<scoped_refptr<V4L2DecodeSurface>> reference_surfaces_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(V4L2DecodeSurface); | |
| 72 }; | |
| 73 | |
| 74 V4L2SliceVideoDecodeAccelerator( | |
| 75 const scoped_refptr<V4L2Device>& device, | |
| 76 EGLDisplay egl_display, | |
| 77 EGLContext egl_context, | |
| 78 const base::WeakPtr<Client>& io_client_, | |
| 79 const base::Callback<bool(void)>& make_context_current, | |
| 80 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); | |
| 81 virtual ~V4L2SliceVideoDecodeAccelerator(); | |
| 82 | |
| 83 // media::VideoDecodeAccelerator implementation. | |
| 84 virtual bool Initialize(media::VideoCodecProfile profile, | |
| 85 VideoDecodeAccelerator::Client* client) override; | |
| 86 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | |
| 87 virtual void AssignPictureBuffers( | |
| 88 const std::vector<media::PictureBuffer>& buffers) override; | |
| 89 virtual void ReusePictureBuffer(int32 picture_buffer_id) override; | |
| 90 virtual void Flush() override; | |
| 91 virtual void Reset() override; | |
| 92 virtual void Destroy() override; | |
| 93 virtual bool CanDecodeOnIOThread() override; | |
| 94 | |
| 95 bool SubmitSlice(int index, const uint8_t* data, size_t size); | |
|
Owen Lin
2015/01/09 09:56:14
I am confused, which one feed the input to this cl
Pawel Osciak
2015/01/12 07:18:20
Added docs.
| |
| 96 bool SubmitExtControls(struct v4l2_ext_controls* ext_ctrls); | |
| 97 | |
| 98 private: | |
| 99 class V4L2H264Accelerator : public H264Decoder::H264Accelerator { | |
| 100 public: | |
| 101 V4L2H264Accelerator(V4L2SliceVideoDecodeAccelerator* v4l2_dec); | |
| 102 virtual ~V4L2H264Accelerator() {} | |
| 103 | |
| 104 // H264Decoder::H264Accelerator implementation. | |
| 105 scoped_refptr<H264Picture> CreateH264Picture() override; | |
| 106 | |
| 107 bool SubmitFrameMetadata(const media::H264SPS* sps, | |
| 108 const media::H264PPS* pps, | |
| 109 const H264DPB& dpb, | |
| 110 const H264Picture::Vector& ref_pic_listp0, | |
| 111 const H264Picture::Vector& ref_pic_listb0, | |
| 112 const H264Picture::Vector& ref_pic_listb1, | |
| 113 const scoped_refptr<H264Picture>& pic) override; | |
| 114 | |
| 115 bool SubmitSlice(const media::H264PPS* pps, | |
| 116 const media::H264SliceHeader* slice_hdr, | |
| 117 const H264Picture::Vector& ref_pic_list0, | |
| 118 const H264Picture::Vector& ref_pic_list1, | |
| 119 const scoped_refptr<H264Picture>& pic, | |
| 120 const uint8_t* data, | |
| 121 size_t size) override; | |
| 122 | |
| 123 bool SubmitDecode(const scoped_refptr<H264Picture>& pic) override; | |
| 124 bool OutputPicture(const scoped_refptr<H264Picture>& pic) override; | |
| 125 | |
| 126 private: | |
| 127 void H264PictureListToDPBIndicesList( | |
| 128 const H264Picture::Vector& src_pic_list, | |
| 129 uint8_t dst_list[32]); | |
| 130 | |
| 131 void H264DPBToV4L2DPB( | |
| 132 const H264DPB& dpb, | |
| 133 std::vector<scoped_refptr<V4L2DecodeSurface>>* ref_surfaces); | |
| 134 | |
| 135 scoped_refptr<V4L2DecodeSurface> H264PictureToV4L2DecodeSurface( | |
| 136 const scoped_refptr<H264Picture>& pic); | |
| 137 | |
| 138 size_t num_slices_; | |
| 139 V4L2SliceVideoDecodeAccelerator* v4l2_dec_; | |
| 140 | |
| 141 // TODO(posciak): This should be queried from hardware once supported. | |
| 142 static const size_t kMaxSlices = 16; | |
| 143 struct v4l2_ctrl_h264_slice_param v4l2_slice_params_[kMaxSlices]; | |
| 144 struct v4l2_ctrl_h264_decode_param v4l2_decode_param_; | |
| 145 | |
| 146 DISALLOW_COPY_AND_ASSIGN(V4L2H264Accelerator); | |
| 147 }; | |
| 148 | |
| 149 class V4L2VP8Accelerator : public VP8Decoder::VP8Accelerator { | |
| 150 public: | |
| 151 V4L2VP8Accelerator(V4L2SliceVideoDecodeAccelerator* v4l2_dec); | |
| 152 virtual ~V4L2VP8Accelerator() {} | |
| 153 | |
| 154 // H264Decoder::VP8Accelerator implementation. | |
| 155 scoped_refptr<VP8Picture> CreateVP8Picture() override; | |
| 156 | |
| 157 bool SubmitDecode(const scoped_refptr<VP8Picture>& pic, | |
| 158 const media::VP8FrameHeader* frame_hdr, | |
| 159 const scoped_refptr<VP8Picture>& last_frame, | |
| 160 const scoped_refptr<VP8Picture>& golden_frame, | |
| 161 const scoped_refptr<VP8Picture>& alt_frame) override; | |
| 162 | |
| 163 bool OutputPicture(const scoped_refptr<VP8Picture>& pic) override; | |
| 164 | |
| 165 private: | |
| 166 scoped_refptr<V4L2DecodeSurface> VP8PictureToV4L2DecodeSurface( | |
| 167 const scoped_refptr<VP8Picture>& pic); | |
| 168 | |
| 169 V4L2SliceVideoDecodeAccelerator* v4l2_dec_; | |
| 170 | |
| 171 DISALLOW_COPY_AND_ASSIGN(V4L2VP8Accelerator); | |
| 172 }; | |
| 173 | |
| 174 // Record for input buffers. | |
| 175 struct InputRecord { | |
| 176 InputRecord(); | |
| 177 int32 input_id; | |
| 178 void* address; | |
| 179 size_t length; | |
| 180 size_t bytes_used; | |
| 181 bool at_device; | |
| 182 }; | |
| 183 | |
| 184 // Record for output buffers. | |
| 185 struct OutputRecord { | |
| 186 OutputRecord(); | |
| 187 bool at_device; | |
| 188 bool at_client; | |
| 189 int32 picture_id; | |
| 190 EGLImageKHR egl_image; | |
| 191 EGLSyncKHR egl_sync; | |
| 192 bool cleared; | |
| 193 }; | |
| 194 | |
| 195 enum { | |
| 196 // See http://crbug.com/255116. | |
| 197 // Input bitstream buffer size for up to 1080p streams. | |
| 198 kInputBufferMaxSizeFor1080p = 1024 * 1024, | |
|
kcwu
2015/01/09 15:36:46
const size_t, not enum.
Pawel Osciak
2015/01/12 07:18:19
Done.
| |
| 199 // Input bitstream buffer size for up to 4k streams. | |
| 200 kInputBufferMaxSizeFor4k = 4 * kInputBufferMaxSizeFor1080p, | |
| 201 }; | |
| 202 | |
| 203 // Recycle V4L2 output buffer with |index|. Used as surface release callback. | |
| 204 void ReuseOutputBuffer(int index); | |
| 205 | |
| 206 // Queue a |dec_surface| to device for decoding. | |
| 207 void Enqueue(const scoped_refptr<V4L2DecodeSurface>& dec_surface); | |
| 208 | |
| 209 // Dequeue any V4L2 buffers available and process. | |
| 210 void Dequeue(); | |
| 211 | |
| 212 // V4L2 QBUF helpers. | |
| 213 bool EnqueueInputRecord(int index, uint32_t config_store); | |
| 214 bool EnqueueOutputRecord(int index); | |
| 215 | |
| 216 // Set input and output formats in hardware. | |
| 217 bool SetupFormats(); | |
| 218 | |
| 219 // Create input and output buffers. | |
| 220 bool CreateInputBuffers(); | |
| 221 bool CreateOutputBuffers(); | |
| 222 | |
| 223 // Destroy input buffers. | |
| 224 void DestroyInputBuffers(); | |
| 225 | |
| 226 // Destroy output buffers and release associated resources (textures, | |
| 227 // EGLImages). If |dismiss| is true, also dismissing the associated | |
| 228 // PictureBuffers. | |
| 229 void DestroyOutputs(bool dismiss); | |
| 230 | |
| 231 // Used by DestroyOutputs. | |
| 232 void DestroyOutputBuffers(); | |
| 233 | |
| 234 // Dismiss all |picture_buffer_ids| via Client::DismissPictureBuffer() | |
| 235 // and signal |done| after finishing. | |
| 236 void DismissPictures(std::vector<int32> picture_buffer_ids, | |
| 237 base::WaitableEvent* done); | |
| 238 | |
| 239 // Task to finish initialization on decoder_thread_. | |
| 240 void InitializeTask(); | |
| 241 | |
| 242 // Surface set change (resolution change) flow. | |
| 243 // If we have no surfaces allocated, just allocate them and return. | |
| 244 // Otherwise mark us as pending for surface set change. | |
| 245 void InitiateSurfaceSetChange(); | |
| 246 // If a surface set change is pending and we are ready, stop the device, | |
| 247 // destroy outputs, releasing resources and dismissing pictures as required, | |
| 248 // followed by allocating a new set for the new resolution/DPB size | |
| 249 // as provided by decoder. Finally, try to resume decoding. | |
| 250 void FinishSurfaceSetChangeIfNeeded(); | |
| 251 | |
| 252 void NotifyError(Error error); | |
| 253 void DestroyTask(); | |
| 254 | |
| 255 // Flush flow when requested by client. | |
| 256 // When Flush() is called, it posts a FlushTask, which checks the input queue. | |
| 257 // If nothing is pending for decode on decoder_input_queue_, we call | |
| 258 // InitiateFlush() directly. Otherwise, we push a dummy BitstreamBufferRef | |
| 259 // onto the decoder_input_queue_ to schedule a flush. When we reach it later | |
| 260 // on, we call InitiateFlush() to perform it at the correct time. | |
| 261 void FlushTask(); | |
| 262 // Tell the decoder to flush all frames, reset it and mark us as scheduled | |
| 263 // for flush, so that we can finish it once all pending decodes are finished. | |
| 264 void InitiateFlush(); | |
| 265 // If all pending frames are decoded and we are waiting to flush, perform it. | |
| 266 // This will send all pending pictures to client and notify the client that | |
| 267 // flush is complete and puts us in a state ready to resume. | |
| 268 void FinishFlushIfNeeded(); | |
| 269 | |
| 270 // Reset flow when requested by client. | |
| 271 // Drop all inputs and reset the decoder and mark us as pending for reset. | |
| 272 void ResetTask(); | |
| 273 // If all pending frames are decoded and we are waiting to reset, perform it. | |
| 274 // This drops all pending outputs (client is not interested anymore), | |
| 275 // notifies the client we are done and puts us in a state ready to resume. | |
| 276 void FinishResetIfNeeded(); | |
| 277 | |
| 278 // Performed on decoder_thread_ as a consequence of poll() on decoder_thread_ | |
| 279 // returning an event. | |
| 280 void ServiceDeviceTask(); | |
| 281 | |
| 282 // Attempt to start/stop device_poll_thread_. | |
| 283 bool StartDevicePoll(); | |
| 284 bool StopDevicePoll(bool keep_input_state); | |
| 285 | |
| 286 // Ran on device_poll_thread_ to wait for device events. | |
| 287 void DevicePollTask(bool poll_device); | |
| 288 | |
| 289 enum State { | |
| 290 // We are in this state until InitializeTask() finishes successfully. | |
| 291 kUninitialized, | |
| 292 // This state allows making progress decoding more input stream. | |
| 293 kDecoding, | |
| 294 // Transitional state when we are not decoding any more stream, but are | |
| 295 // performing flush, reset, resolution change or are destroying ourselves. | |
| 296 kIdle, | |
| 297 // Error state, set when sending NotifyError to client. | |
| 298 kError, | |
| 299 }; | |
| 300 // Sets state on decoder thread if running. | |
| 301 void SetDecoderState(State state); | |
| 302 | |
| 303 enum BufferId { | |
| 304 kFlushBufferId = -2 // Buffer id for flush buffer, queued by FlushTask(). | |
|
kcwu
2015/01/09 15:36:46
Give -1 a name as well. Otherwise -2 looks weird.
Pawel Osciak
2015/01/12 07:18:19
Done.
| |
| 305 }; | |
| 306 | |
| 307 void DecodeTask(const media::BitstreamBuffer& bitstream_buffer); | |
| 308 void DecodeBufferTask(); | |
| 309 void ScheduleDecodeBufferTaskIfNeeded(); | |
| 310 bool TrySetNewBistreamBuffer(); | |
| 311 | |
| 312 // Auto-destruction reference for EGLSync (for message-passing). | |
| 313 struct EGLSyncKHRRef; | |
| 314 void ReusePictureBufferTask(int32 picture_buffer_id, | |
| 315 scoped_ptr<EGLSyncKHRRef> egl_sync_ref); | |
| 316 | |
| 317 // Called by accelerator implementations: | |
| 318 // Decode of |dec_surface| is ready to be submitted and all codec-specific | |
| 319 // settings are set in hardware. | |
| 320 void DecodeSurface(const scoped_refptr<V4L2DecodeSurface>& dec_surface); | |
| 321 | |
| 322 // |dec_surface| is ready to be outputted once decode is finished. | |
| 323 // This can be called before decode is actually done in hardware, and this | |
| 324 // method is responsible to maintain the order, i.e. the surfaces will | |
| 325 // be outputted in the same order as SurfaceReady calls. To do so, the | |
| 326 // surfaces are put on decoder_display_queue_ and sent to output in that | |
| 327 // order once all preceding surfaces are sent. | |
| 328 void SurfaceReady(const scoped_refptr<V4L2DecodeSurface>& dec_surface); | |
| 329 | |
| 330 // Called to actually send |dec_surface| to the client, after it is decoded | |
| 331 // preserving the order in which it was scheduled via SurfaceReady(). | |
| 332 void OutputSurface(const scoped_refptr<V4L2DecodeSurface>& dec_surface); | |
| 333 | |
| 334 // Goes over the |decoder_display_queue_| and sends all buffers from the | |
| 335 // front of the queue that are already decoded to the client, in order. | |
| 336 void TryOutputSurfaces(); | |
| 337 | |
| 338 // Creates a new decode surface or returns nullptr if one is not available. | |
| 339 scoped_refptr<V4L2DecodeSurface> CreateSurface(); | |
| 340 | |
| 341 // Send decoded pictures to PictureReady. | |
| 342 void SendPictureReady(); | |
| 343 | |
| 344 // Callback that indicates a picture has been cleared. | |
| 345 void PictureCleared(); | |
| 346 | |
| 347 size_t input_planes_count_; | |
| 348 size_t output_planes_count_; | |
| 349 | |
| 350 // GPU Child thread message loop. | |
| 351 const scoped_refptr<base::MessageLoopProxy> child_message_loop_proxy_; | |
| 352 | |
| 353 // IO thread message loop. | |
| 354 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | |
| 355 | |
| 356 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder or | |
| 357 // device worker threads back to the child thread. | |
| 358 base::WeakPtr<V4L2SliceVideoDecodeAccelerator> weak_this_; | |
| 359 | |
| 360 // To expose client callbacks from VideoDecodeAccelerator. | |
| 361 // NOTE: all calls to these objects *MUST* be executed on | |
| 362 // child_message_loop_proxy_. | |
| 363 scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator::Client>> | |
| 364 client_ptr_factory_; | |
| 365 base::WeakPtr<VideoDecodeAccelerator::Client> client_; | |
| 366 // Callbacks to |io_client_| must be executed on |io_message_loop_proxy_|. | |
| 367 base::WeakPtr<Client> io_client_; | |
| 368 | |
| 369 // V4L2 device in use. | |
| 370 scoped_refptr<V4L2Device> device_; | |
| 371 | |
| 372 // Thread to communicate with the device on. | |
| 373 base::Thread decoder_thread_; | |
| 374 scoped_refptr<base::MessageLoopProxy> decoder_thread_proxy_; | |
| 375 | |
| 376 // Thread used to poll the device for events. | |
| 377 base::Thread device_poll_thread_; | |
| 378 | |
| 379 // Input queue state. | |
| 380 bool input_streamon_; | |
| 381 // Number of input buffers enqueued to the device. | |
| 382 int input_buffer_queued_count_; | |
| 383 // Input buffers ready to use; LIFO since we don't care about ordering. | |
| 384 std::list<int> free_input_buffers_; | |
| 385 // Mapping of int index to an input buffer record. | |
| 386 std::vector<InputRecord> input_buffer_map_; | |
| 387 | |
| 388 // Output queue state. | |
| 389 bool output_streamon_; | |
| 390 // Number of output buffers enqueued to the device. | |
| 391 int output_buffer_queued_count_; | |
| 392 // Output buffers ready to use. | |
| 393 std::list<int> free_output_buffers_; | |
| 394 // Mapping of int index to an output buffer record. | |
| 395 std::vector<OutputRecord> output_buffer_map_; | |
| 396 | |
| 397 media::VideoCodecProfile video_profile_; | |
| 398 uint32_t output_format_fourcc_; | |
| 399 gfx::Size frame_buffer_size_; | |
| 400 size_t output_dpb_size_; | |
| 401 | |
| 402 struct BitstreamBufferRef; | |
| 403 // Input queue of stream buffers coming from the client. | |
| 404 std::queue<linked_ptr<BitstreamBufferRef>> decoder_input_queue_; | |
| 405 // BitstreamBuffer currently being processed. | |
| 406 scoped_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; | |
| 407 | |
| 408 // Queue storing decode surfaces ready to be output as soon as they are | |
| 409 // decoded. The surfaces must be output in order they are queued. | |
| 410 std::queue<scoped_refptr<V4L2DecodeSurface>> decoder_display_queue_; | |
| 411 | |
| 412 // Decoder state. | |
| 413 State state_; | |
| 414 | |
| 415 // If any of these are true, we are waiting for the device to finish decoding | |
| 416 // all previously-queued frames, so we can finish the flush/reset/surface | |
| 417 // change flows. These can stack. | |
| 418 bool decoder_flushing_; | |
| 419 bool decoder_resetting_; | |
| 420 bool surface_set_change_pending_; | |
| 421 | |
| 422 // Hardware accelerators. | |
| 423 // TODO(posciak): Try to have a superclass here if possible. | |
| 424 scoped_ptr<V4L2H264Accelerator> h264_accelerator_; | |
| 425 scoped_ptr<V4L2VP8Accelerator> vp8_accelerator_; | |
| 426 | |
| 427 // Codec-specific software decoder in use. | |
| 428 scoped_ptr<AcceleratedVideoDecoder> decoder_; | |
| 429 | |
| 430 // Surfaces queued to device to keep references to them while decoded. | |
| 431 using V4L2DecodeSurfaceByOutputId = | |
| 432 std::map<int, scoped_refptr<V4L2DecodeSurface>>; | |
| 433 V4L2DecodeSurfaceByOutputId surfaces_at_device_; | |
| 434 | |
| 435 // Surfaces sent to client to keep references to them while displayed. | |
| 436 using V4L2DecodeSurfaceByPictureBufferId = | |
| 437 std::map<int32, scoped_refptr<V4L2DecodeSurface>>; | |
| 438 V4L2DecodeSurfaceByPictureBufferId surfaces_at_display_; | |
| 439 | |
| 440 // Record for decoded pictures that can be sent to PictureReady. | |
| 441 struct PictureRecord; | |
| 442 // Pictures that are ready but not sent to PictureReady yet. | |
| 443 std::queue<PictureRecord> pending_picture_ready_; | |
| 444 | |
| 445 // The number of pictures that are sent to PictureReady and will be cleared. | |
| 446 int picture_clearing_count_; | |
| 447 | |
| 448 // Used by the decoder thread to wait for AssignPictureBuffers to arrive | |
| 449 // to avoid races with potential Reset requests. | |
| 450 base::WaitableEvent pictures_assigned_; | |
| 451 | |
| 452 // Make the GL context current callback. | |
| 453 base::Callback<bool(void)> make_context_current_; | |
| 454 | |
| 455 // EGL state | |
| 456 EGLDisplay egl_display_; | |
| 457 EGLContext egl_context_; | |
| 458 | |
| 459 // The WeakPtrFactory for |weak_this_|. | |
| 460 base::WeakPtrFactory<V4L2SliceVideoDecodeAccelerator> weak_this_factory_; | |
| 461 | |
| 462 DISALLOW_COPY_AND_ASSIGN(V4L2SliceVideoDecodeAccelerator); | |
| 463 }; | |
| 464 | |
| 465 // Codec-specific subclasses of software decoder picture classes. | |
| 466 // This allows us to keep decoders oblivious of our implementation details. | |
| 467 class V4L2H264Picture : public H264Picture { | |
| 468 public: | |
| 469 V4L2H264Picture(const scoped_refptr< | |
| 470 V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>& dec_surface) | |
| 471 : dec_surface_(dec_surface) {} | |
| 472 virtual ~V4L2H264Picture() {} | |
| 473 | |
| 474 V4L2H264Picture* AsV4L2H264Picture() override { return this; } | |
|
Owen Lin
2015/01/09 09:56:14
Why we need this ? What it overrides, there is no
Pawel Osciak
2015/01/12 07:18:19
There is one, sorry didn't upload the file for pre
| |
| 475 scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface> | |
| 476 dec_surface() { | |
| 477 return dec_surface_; | |
| 478 } | |
| 479 | |
| 480 private: | |
| 481 scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface> | |
| 482 dec_surface_; | |
| 483 | |
| 484 DISALLOW_COPY_AND_ASSIGN(V4L2H264Picture); | |
| 485 }; | |
| 486 | |
| 487 class V4L2VP8Picture : public VP8Picture { | |
| 488 public: | |
| 489 V4L2VP8Picture(const scoped_refptr< | |
| 490 V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface>& dec_surface) | |
| 491 : dec_surface_(dec_surface) {} | |
| 492 virtual ~V4L2VP8Picture() {} | |
| 493 | |
| 494 V4L2VP8Picture* AsV4L2VP8Picture() override { return this; } | |
| 495 scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface> | |
| 496 dec_surface() { | |
| 497 return dec_surface_; | |
| 498 } | |
| 499 | |
| 500 private: | |
| 501 scoped_refptr<V4L2SliceVideoDecodeAccelerator::V4L2DecodeSurface> | |
| 502 dec_surface_; | |
| 503 | |
| 504 DISALLOW_COPY_AND_ASSIGN(V4L2VP8Picture); | |
| 505 }; | |
| 506 | |
| 507 } // namespace content | |
| 508 | |
| 509 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_SLICE_VIDEO_DECODE_ACCELERATOR_H_ | |
| OLD | NEW |