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

Side by Side Diff: media/gpu/vt_video_decode_accelerator_mac.cc

Issue 2244853002: VTVDA: Verify |picture_id| in ResusePictureBuffer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 #include "media/gpu/vt_video_decode_accelerator_mac.h" 5 #include "media/gpu/vt_video_decode_accelerator_mac.h"
6 6
7 #include <CoreVideo/CoreVideo.h> 7 #include <CoreVideo/CoreVideo.h>
8 #include <OpenGL/CGLIOSurface.h> 8 #include <OpenGL/CGLIOSurface.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 // Pictures are not marked as uncleared until after this method returns, and 859 // Pictures are not marked as uncleared until after this method returns, and
860 // they will be broken if they are used before that happens. So, schedule 860 // they will be broken if they are used before that happens. So, schedule
861 // future work after that happens. 861 // future work after that happens.
862 gpu_task_runner_->PostTask( 862 gpu_task_runner_->PostTask(
863 FROM_HERE, 863 FROM_HERE,
864 base::Bind(&VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_)); 864 base::Bind(&VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_));
865 } 865 }
866 866
867 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) { 867 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) {
868 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 868 DCHECK(gpu_thread_checker_.CalledOnValidThread());
869 DCHECK(picture_info_map_.count(picture_id));
870 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get();
871 picture_info->cv_image.reset();
872 picture_info->gl_image->Destroy(false);
sandersd (OOO until July 31) 2016/08/12 22:03:19 ccameron@: Are we relying on this to always happen
sandersd (OOO until July 31) 2016/08/12 22:56:39 I realized there was a better factoring without th
873 picture_info->gl_image = nullptr;
874 869
875 if (assigned_picture_ids_.count(picture_id) != 0) { 870 if (assigned_picture_ids_.count(picture_id) != 0) {
871 auto it = picture_info_map_.find(picture_id);
872 DCHECK_NE(it, picture_info_map_.end());
873 PictureInfo* picture_info = it->second.get();
874 picture_info->cv_image.reset();
875 picture_info->gl_image->Destroy(false);
876 picture_info->gl_image = nullptr;
877
876 available_picture_ids_.push_back(picture_id); 878 available_picture_ids_.push_back(picture_id);
877 ProcessWorkQueues(); 879 ProcessWorkQueues();
878 } else { 880 } else {
879 client_->DismissPictureBuffer(picture_id); 881 client_->DismissPictureBuffer(picture_id);
880 } 882 }
881 } 883 }
882 884
883 void VTVideoDecodeAccelerator::ProcessWorkQueues() { 885 void VTVideoDecodeAccelerator::ProcessWorkQueues() {
884 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 886 DCHECK(gpu_thread_checker_.CalledOnValidThread());
885 switch (state_) { 887 switch (state_) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 } 1019 }
1018 1020
1019 bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) { 1021 bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) {
1020 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 1022 DCHECK(gpu_thread_checker_.CalledOnValidThread());
1021 DCHECK_EQ(state_, STATE_DECODING); 1023 DCHECK_EQ(state_, STATE_DECODING);
1022 1024
1023 if (available_picture_ids_.empty()) 1025 if (available_picture_ids_.empty())
1024 return false; 1026 return false;
1025 1027
1026 int32_t picture_id = available_picture_ids_.back(); 1028 int32_t picture_id = available_picture_ids_.back();
1027 DCHECK(picture_info_map_.count(picture_id)); 1029 auto it = picture_info_map_.find(picture_id);
1028 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); 1030 DCHECK_NE(it, picture_info_map_.end());
1031 PictureInfo* picture_info = it->second.get();
1029 DCHECK(!picture_info->cv_image); 1032 DCHECK(!picture_info->cv_image);
1030 DCHECK(!picture_info->gl_image); 1033 DCHECK(!picture_info->gl_image);
1031 1034
1032 if (!make_context_current_cb_.Run()) { 1035 if (!make_context_current_cb_.Run()) {
1033 DLOG(ERROR) << "Failed to make GL context current"; 1036 DLOG(ERROR) << "Failed to make GL context current";
1034 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); 1037 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR);
1035 return false; 1038 return false;
1036 } 1039 }
1037 1040
1038 scoped_refptr<gl::GLImageIOSurface> gl_image( 1041 scoped_refptr<gl::GLImageIOSurface> gl_image(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 SupportedProfile profile; 1142 SupportedProfile profile;
1140 profile.profile = supported_profile; 1143 profile.profile = supported_profile;
1141 profile.min_resolution.SetSize(16, 16); 1144 profile.min_resolution.SetSize(16, 16);
1142 profile.max_resolution.SetSize(4096, 2160); 1145 profile.max_resolution.SetSize(4096, 2160);
1143 profiles.push_back(profile); 1146 profiles.push_back(profile);
1144 } 1147 }
1145 return profiles; 1148 return profiles;
1146 } 1149 }
1147 1150
1148 } // namespace media 1151 } // namespace media
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