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

Unified Diff: content/common/gpu/media/vaapi_h264_decoder.cc

Issue 10843058: VAVDA: Destroy vaapi buffers after we're done drawing. (Closed) Base URL: https://git.chromium.org/git/chromium/src@master
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/vaapi_h264_decoder.cc
diff --git a/content/common/gpu/media/vaapi_h264_decoder.cc b/content/common/gpu/media/vaapi_h264_decoder.cc
index cb716b29fb75c32969b160cbd644919ceb60394d..f602a889c2852b4b980d8495bb66fe8ec69a85a4 100644
--- a/content/common/gpu/media/vaapi_h264_decoder.cc
+++ b/content/common/gpu/media/vaapi_h264_decoder.cc
@@ -1021,50 +1021,52 @@ bool VaapiH264Decoder::DecodePicture() {
dec_surface->va_surface_id());
VA_SUCCESS_OR_RETURN(va_res, "vaBeginPicture failed", false);
- // Put buffer IDs for pending parameter buffers into buffers[].
- VABufferID buffers[kMaxVABuffers];
- size_t num_buffers = pending_va_bufs_.size();
- for (size_t i = 0; i < num_buffers && i < kMaxVABuffers; ++i) {
- buffers[i] = pending_va_bufs_.front();
+ // Put buffer IDs for pending parameter buffers into va_buffers[].
+ VABufferID va_buffers[kMaxVABuffers];
+ size_t num_va_buffers = pending_va_bufs_.size();
+ for (size_t i = 0; i < num_va_buffers && i < kMaxVABuffers; ++i) {
+ va_buffers[i] = pending_va_bufs_.front();
pending_va_bufs_.pop();
}
// And send them to the HW decoder.
- va_res = VAAPI_RenderPicture(va_display_, va_context_id_, buffers,
- num_buffers);
+ va_res = VAAPI_RenderPicture(va_display_, va_context_id_, va_buffers,
+ num_va_buffers);
VA_SUCCESS_OR_RETURN(va_res, "vaRenderPicture for va_bufs failed", false);
piman 2012/08/02 23:36:42 Can't we have a leak here if we return early becau
Pawel Osciak 2012/08/03 02:13:20 TL;DR: yes, and everywhere else you mentioned too.
- DVLOG(4) << "Committed " << num_buffers << "VA buffers";
+ DVLOG(4) << "Committed " << num_va_buffers << "VA buffers";
- for (size_t i = 0; i < num_buffers; ++i) {
- va_res = VAAPI_DestroyBuffer(va_display_, buffers[i]);
- VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for va_bufs failed", false);
- }
-
- // Put buffer IDs for pending slice data buffers into buffers[].
- num_buffers = pending_slice_bufs_.size();
- for (size_t i = 0; i < num_buffers && i < kMaxVABuffers; ++i) {
- buffers[i] = pending_slice_bufs_.front();
+ // Put buffer IDs for pending slice data buffers into slice_buffers[].
+ VABufferID slice_buffers[kMaxVABuffers];
+ size_t num_slice_buffers = pending_slice_bufs_.size();
+ for (size_t i = 0; i < num_slice_buffers && i < kMaxVABuffers; ++i) {
+ slice_buffers[i] = pending_slice_bufs_.front();
pending_slice_bufs_.pop();
}
// And send them to the Hw decoder.
- va_res = VAAPI_RenderPicture(va_display_, va_context_id_, buffers,
- num_buffers);
+ va_res = VAAPI_RenderPicture(va_display_, va_context_id_, slice_buffers,
+ num_slice_buffers);
VA_SUCCESS_OR_RETURN(va_res, "vaRenderPicture for slices failed", false);
piman 2012/08/02 23:36:42 Same here?
- DVLOG(4) << "Committed " << num_buffers << "slice buffers";
-
- for (size_t i = 0; i < num_buffers; ++i) {
- va_res = VAAPI_DestroyBuffer(va_display_, buffers[i]);
- VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for slices failed", false);
- }
+ DVLOG(4) << "Committed " << num_slice_buffers << "slice buffers";
// Instruct HW decoder to start processing committed buffers (decode this
// picture). This does not block until the end of decode.
va_res = VAAPI_EndPicture(va_display_, va_context_id_);
VA_SUCCESS_OR_RETURN(va_res, "vaEndPicture failed", false);
piman 2012/08/02 23:36:42 And here
+ // Now that EndPicture has passed we can destroy our buffers.
+ for (size_t i = 0; i < num_va_buffers; ++i) {
+ va_res = VAAPI_DestroyBuffer(va_display_, va_buffers[i]);
+ VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for va_bufs failed", false);
piman 2012/08/02 23:36:42 And here
+ }
+
+ for (size_t i = 0; i < num_slice_buffers; ++i) {
+ va_res = VAAPI_DestroyBuffer(va_display_, slice_buffers[i]);
+ VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for slices failed", false);
piman 2012/08/02 23:36:42 And here
+ }
+
// Used to notify clients that we had sufficient data to start decoding
// a new frame.
frame_ready_at_hw_ = true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698