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

Side by Side Diff: media/gpu/v4l2_video_decode_accelerator.h

Issue 2335573002: V4L2VideoDecodeAccelerator: destroy buffers in decoder thread. (Closed)
Patch Set: address Pawel's nits in PS4 Created 4 years, 3 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
« no previous file with comments | « media/gpu/generic_v4l2_device.cc ('k') | media/gpu/v4l2_video_decode_accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file contains an implementation of VideoDecodeAccelerator 5 // This file contains an implementation of VideoDecodeAccelerator
6 // that utilizes hardware video decoders, which expose Video4Linux 2 API 6 // that utilizes hardware video decoders, which expose Video4Linux 2 API
7 // (http://linuxtv.org/downloads/v4l-dvb-apis/). 7 // (http://linuxtv.org/downloads/v4l-dvb-apis/).
8 8
9 #ifndef MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 9 #ifndef MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_
10 #define MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 10 #define MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // and +1 for a frame in transit. 126 // and +1 for a frame in transit.
127 kDpbOutputBufferExtraCount = limits::kMaxVideoFrames + 1, 127 kDpbOutputBufferExtraCount = limits::kMaxVideoFrames + 1,
128 }; 128 };
129 129
130 // Internal state of the decoder. 130 // Internal state of the decoder.
131 enum State { 131 enum State {
132 kUninitialized, // Initialize() not yet called. 132 kUninitialized, // Initialize() not yet called.
133 kInitialized, // Initialize() returned true; ready to start decoding. 133 kInitialized, // Initialize() returned true; ready to start decoding.
134 kDecoding, // DecodeBufferInitial() successful; decoding frames. 134 kDecoding, // DecodeBufferInitial() successful; decoding frames.
135 kResetting, // Presently resetting. 135 kResetting, // Presently resetting.
136 // Performing resolution change, all remaining pre-change frames decoded 136 // Performing resolution change and waiting for image processor to return
137 // and processed. 137 // all frames.
138 kChangingResolution, 138 kChangingResolution,
139 // Requested new PictureBuffers via ProvidePictureBuffers(), awaiting 139 // Requested new PictureBuffers via ProvidePictureBuffers(), awaiting
140 // AssignPictureBuffers(). 140 // AssignPictureBuffers().
141 kAwaitingPictureBuffers, 141 kAwaitingPictureBuffers,
142 kError, // Error in kDecoding state. 142 kError, // Error in kDecoding state.
143 }; 143 };
144 144
145 enum OutputRecordState { 145 enum OutputRecordState {
146 kFree, // Ready to be queued to the device. 146 kFree, // Ready to be queued to the device.
147 kAtDevice, // Held by device. 147 kAtDevice, // Held by device.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // 322 //
323 // Other utility functions. Called on decoder_thread_, unless 323 // Other utility functions. Called on decoder_thread_, unless
324 // decoder_thread_ is not yet started, in which case the child thread can call 324 // decoder_thread_ is not yet started, in which case the child thread can call
325 // these (e.g. in Initialize() or Destroy()). 325 // these (e.g. in Initialize() or Destroy()).
326 // 326 //
327 327
328 // Create the buffers we need. 328 // Create the buffers we need.
329 bool CreateInputBuffers(); 329 bool CreateInputBuffers();
330 bool CreateOutputBuffers(); 330 bool CreateOutputBuffers();
331 331
332 // Destroy buffers.
333 void DestroyInputBuffers();
334 // In contrast to DestroyInputBuffers, which is called only on destruction,
335 // we call DestroyOutputBuffers also during playback, on resolution change.
336 // Even if anything fails along the way, we still want to go on and clean
337 // up as much as possible, so return false if this happens, so that the
338 // caller can error out on resolution change.
339 bool DestroyOutputBuffers();
340
332 // Set input and output formats before starting decode. 341 // Set input and output formats before starting decode.
333 bool SetupFormats(); 342 bool SetupFormats();
334 // Return a usable input format of image processor. Return 0 if not found. 343 // Return a usable input format of image processor. Return 0 if not found.
335 uint32_t FindImageProcessorInputFormat(); 344 uint32_t FindImageProcessorInputFormat();
336 // Return a usable output format of image processor. Return 0 if not found. 345 // Return a usable output format of image processor. Return 0 if not found.
337 uint32_t FindImageProcessorOutputFormat(); 346 uint32_t FindImageProcessorOutputFormat();
338 // Reset image processor and drop all processing frames. 347 // Reset image processor and drop all processing frames.
339 bool ResetImageProcessor(); 348 bool ResetImageProcessor();
340 349
341 // 350 //
342 // Methods run on child thread. 351 // Methods run on child thread.
343 // 352 //
344 353
345 // Destroy buffers.
346 void DestroyInputBuffers();
347 // In contrast to DestroyInputBuffers, which is called only from destructor,
348 // we call DestroyOutputBuffers also during playback, on resolution change.
349 // Even if anything fails along the way, we still want to go on and clean
350 // up as much as possible, so return false if this happens, so that the
351 // caller can error out on resolution change.
352 bool DestroyOutputBuffers();
353 void ResolutionChangeDestroyBuffers();
354
355 // Send decoded pictures to PictureReady. 354 // Send decoded pictures to PictureReady.
356 void SendPictureReady(); 355 void SendPictureReady();
357 356
358 // Callback that indicates a picture has been cleared. 357 // Callback that indicates a picture has been cleared.
359 void PictureCleared(); 358 void PictureCleared();
360 359
361 // Image processor returns a processed frame. Its id is |bitstream_buffer_id| 360 // Image processor returns a processed frame. Its id is |bitstream_buffer_id|
362 // and stored in |output_buffer_index| buffer of image processor. 361 // and stored in |output_buffer_index| buffer of image processor.
363 void FrameProcessed(int32_t bitstream_buffer_id, int output_buffer_index); 362 void FrameProcessed(int32_t bitstream_buffer_id, int output_buffer_index);
364 363
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 523
525 // The WeakPtrFactory for |weak_this_|. 524 // The WeakPtrFactory for |weak_this_|.
526 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_; 525 base::WeakPtrFactory<V4L2VideoDecodeAccelerator> weak_this_factory_;
527 526
528 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator); 527 DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecodeAccelerator);
529 }; 528 };
530 529
531 } // namespace media 530 } // namespace media
532 531
533 #endif // MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_ 532 #endif // MEDIA_GPU_V4L2_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « media/gpu/generic_v4l2_device.cc ('k') | media/gpu/v4l2_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698