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

Side by Side 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, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <dlfcn.h> 5 #include <dlfcn.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 DecodeSurface* dec_surface = 1014 DecodeSurface* dec_surface =
1015 poc_to_decode_surfaces_[curr_pic_->pic_order_cnt]; 1015 poc_to_decode_surfaces_[curr_pic_->pic_order_cnt];
1016 DVLOG(4) << "Decoding POC " << curr_pic_->pic_order_cnt 1016 DVLOG(4) << "Decoding POC " << curr_pic_->pic_order_cnt
1017 << " into surface " << dec_surface->va_surface_id(); 1017 << " into surface " << dec_surface->va_surface_id();
1018 1018
1019 // Get ready to decode into surface. 1019 // Get ready to decode into surface.
1020 VAStatus va_res = VAAPI_BeginPicture(va_display_, va_context_id_, 1020 VAStatus va_res = VAAPI_BeginPicture(va_display_, va_context_id_,
1021 dec_surface->va_surface_id()); 1021 dec_surface->va_surface_id());
1022 VA_SUCCESS_OR_RETURN(va_res, "vaBeginPicture failed", false); 1022 VA_SUCCESS_OR_RETURN(va_res, "vaBeginPicture failed", false);
1023 1023
1024 // Put buffer IDs for pending parameter buffers into buffers[]. 1024 // Put buffer IDs for pending parameter buffers into va_buffers[].
1025 VABufferID buffers[kMaxVABuffers]; 1025 VABufferID va_buffers[kMaxVABuffers];
1026 size_t num_buffers = pending_va_bufs_.size(); 1026 size_t num_va_buffers = pending_va_bufs_.size();
1027 for (size_t i = 0; i < num_buffers && i < kMaxVABuffers; ++i) { 1027 for (size_t i = 0; i < num_va_buffers && i < kMaxVABuffers; ++i) {
1028 buffers[i] = pending_va_bufs_.front(); 1028 va_buffers[i] = pending_va_bufs_.front();
1029 pending_va_bufs_.pop(); 1029 pending_va_bufs_.pop();
1030 } 1030 }
1031 1031
1032 // And send them to the HW decoder. 1032 // And send them to the HW decoder.
1033 va_res = VAAPI_RenderPicture(va_display_, va_context_id_, buffers, 1033 va_res = VAAPI_RenderPicture(va_display_, va_context_id_, va_buffers,
1034 num_buffers); 1034 num_va_buffers);
1035 VA_SUCCESS_OR_RETURN(va_res, "vaRenderPicture for va_bufs failed", false); 1035 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.
1036 1036
1037 DVLOG(4) << "Committed " << num_buffers << "VA buffers"; 1037 DVLOG(4) << "Committed " << num_va_buffers << "VA buffers";
1038 1038
1039 for (size_t i = 0; i < num_buffers; ++i) { 1039 // Put buffer IDs for pending slice data buffers into slice_buffers[].
1040 va_res = VAAPI_DestroyBuffer(va_display_, buffers[i]); 1040 VABufferID slice_buffers[kMaxVABuffers];
1041 VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for va_bufs failed", false); 1041 size_t num_slice_buffers = pending_slice_bufs_.size();
1042 } 1042 for (size_t i = 0; i < num_slice_buffers && i < kMaxVABuffers; ++i) {
1043 1043 slice_buffers[i] = pending_slice_bufs_.front();
1044 // Put buffer IDs for pending slice data buffers into buffers[].
1045 num_buffers = pending_slice_bufs_.size();
1046 for (size_t i = 0; i < num_buffers && i < kMaxVABuffers; ++i) {
1047 buffers[i] = pending_slice_bufs_.front();
1048 pending_slice_bufs_.pop(); 1044 pending_slice_bufs_.pop();
1049 } 1045 }
1050 1046
1051 // And send them to the Hw decoder. 1047 // And send them to the Hw decoder.
1052 va_res = VAAPI_RenderPicture(va_display_, va_context_id_, buffers, 1048 va_res = VAAPI_RenderPicture(va_display_, va_context_id_, slice_buffers,
1053 num_buffers); 1049 num_slice_buffers);
1054 VA_SUCCESS_OR_RETURN(va_res, "vaRenderPicture for slices failed", false); 1050 VA_SUCCESS_OR_RETURN(va_res, "vaRenderPicture for slices failed", false);
piman 2012/08/02 23:36:42 Same here?
1055 1051
1056 DVLOG(4) << "Committed " << num_buffers << "slice buffers"; 1052 DVLOG(4) << "Committed " << num_slice_buffers << "slice buffers";
1057
1058 for (size_t i = 0; i < num_buffers; ++i) {
1059 va_res = VAAPI_DestroyBuffer(va_display_, buffers[i]);
1060 VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for slices failed", false);
1061 }
1062 1053
1063 // Instruct HW decoder to start processing committed buffers (decode this 1054 // Instruct HW decoder to start processing committed buffers (decode this
1064 // picture). This does not block until the end of decode. 1055 // picture). This does not block until the end of decode.
1065 va_res = VAAPI_EndPicture(va_display_, va_context_id_); 1056 va_res = VAAPI_EndPicture(va_display_, va_context_id_);
1066 VA_SUCCESS_OR_RETURN(va_res, "vaEndPicture failed", false); 1057 VA_SUCCESS_OR_RETURN(va_res, "vaEndPicture failed", false);
piman 2012/08/02 23:36:42 And here
1067 1058
1059 // Now that EndPicture has passed we can destroy our buffers.
1060 for (size_t i = 0; i < num_va_buffers; ++i) {
1061 va_res = VAAPI_DestroyBuffer(va_display_, va_buffers[i]);
1062 VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for va_bufs failed", false);
piman 2012/08/02 23:36:42 And here
1063 }
1064
1065 for (size_t i = 0; i < num_slice_buffers; ++i) {
1066 va_res = VAAPI_DestroyBuffer(va_display_, slice_buffers[i]);
1067 VA_SUCCESS_OR_RETURN(va_res, "vaDestroyBuffer for slices failed", false);
piman 2012/08/02 23:36:42 And here
1068 }
1069
1068 // Used to notify clients that we had sufficient data to start decoding 1070 // Used to notify clients that we had sufficient data to start decoding
1069 // a new frame. 1071 // a new frame.
1070 frame_ready_at_hw_ = true; 1072 frame_ready_at_hw_ = true;
1071 return true; 1073 return true;
1072 } 1074 }
1073 1075
1074 1076
1075 bool VaapiH264Decoder::InitCurrPicture(H264SliceHeader* slice_hdr) { 1077 bool VaapiH264Decoder::InitCurrPicture(H264SliceHeader* slice_hdr) {
1076 DCHECK(curr_pic_.get()); 1078 DCHECK(curr_pic_.get());
1077 1079
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 } 2094 }
2093 } 2095 }
2094 } 2096 }
2095 2097
2096 // static 2098 // static
2097 size_t VaapiH264Decoder::GetRequiredNumOfPictures() { 2099 size_t VaapiH264Decoder::GetRequiredNumOfPictures() {
2098 return kNumReqPictures; 2100 return kNumReqPictures;
2099 } 2101 }
2100 2102
2101 } // namespace content 2103 } // namespace content
OLDNEW
« 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