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

Side by Side Diff: content/common/gpu/media/vt_video_decode_accelerator.cc

Issue 1207043002: Introduce a client minimum picture pool size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 <algorithm> 5 #include <algorithm>
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 10
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 return lhs->bitstream_id > rhs->bitstream_id; 284 return lhs->bitstream_id > rhs->bitstream_id;
285 } 285 }
286 286
287 VTVideoDecodeAccelerator::VTVideoDecodeAccelerator( 287 VTVideoDecodeAccelerator::VTVideoDecodeAccelerator(
288 CGLContextObj cgl_context, 288 CGLContextObj cgl_context,
289 const base::Callback<bool(void)>& make_context_current) 289 const base::Callback<bool(void)>& make_context_current)
290 : cgl_context_(cgl_context), 290 : cgl_context_(cgl_context),
291 make_context_current_(make_context_current), 291 make_context_current_(make_context_current),
292 client_(nullptr), 292 client_(nullptr),
293 state_(STATE_DECODING), 293 state_(STATE_DECODING),
294 num_picture_buffers_(kNumPictureBuffers),
294 format_(nullptr), 295 format_(nullptr),
295 session_(nullptr), 296 session_(nullptr),
296 last_sps_id_(-1), 297 last_sps_id_(-1),
297 last_pps_id_(-1), 298 last_pps_id_(-1),
298 gpu_task_runner_(base::ThreadTaskRunnerHandle::Get()), 299 gpu_task_runner_(base::ThreadTaskRunnerHandle::Get()),
299 decoder_thread_("VTDecoderThread"), 300 decoder_thread_("VTDecoderThread"),
300 weak_this_factory_(this) { 301 weak_this_factory_(this) {
301 DCHECK(!make_context_current_.is_null()); 302 DCHECK(!make_context_current_.is_null());
302 callback_.decompressionOutputCallback = OutputThunk; 303 callback_.decompressionOutputCallback = OutputThunk;
303 callback_.decompressionOutputRefCon = this; 304 callback_.decompressionOutputRefCon = this;
304 weak_this_ = weak_this_factory_.GetWeakPtr(); 305 weak_this_ = weak_this_factory_.GetWeakPtr();
305 } 306 }
306 307
307 VTVideoDecodeAccelerator::~VTVideoDecodeAccelerator() { 308 VTVideoDecodeAccelerator::~VTVideoDecodeAccelerator() {
308 } 309 }
309 310
310 bool VTVideoDecodeAccelerator::Initialize( 311 bool VTVideoDecodeAccelerator::Initialize(
311 media::VideoCodecProfile profile, 312 media::VideoCodecProfile profile,
313 uint32_t min_picture_count,
312 Client* client) { 314 Client* client) {
313 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 315 DCHECK(gpu_thread_checker_.CalledOnValidThread());
314 client_ = client; 316 client_ = client;
315 317
318 num_picture_buffers_ = std::max(min_picture_count,
319 static_cast<uint32_t>(kNumPictureBuffers));
320
316 if (!InitializeVideoToolbox()) 321 if (!InitializeVideoToolbox())
317 return false; 322 return false;
318 323
319 bool profile_supported = false; 324 bool profile_supported = false;
320 for (const auto& supported_profile : kSupportedProfiles) { 325 for (const auto& supported_profile : kSupportedProfiles) {
321 if (profile == supported_profile) { 326 if (profile == supported_profile) {
322 profile_supported = true; 327 profile_supported = true;
323 break; 328 break;
324 } 329 }
325 } 330 }
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 if (picture_size_ != frame.coded_size) { 965 if (picture_size_ != frame.coded_size) {
961 // Dismiss current pictures. 966 // Dismiss current pictures.
962 for (int32_t picture_id : assigned_picture_ids_) 967 for (int32_t picture_id : assigned_picture_ids_)
963 client_->DismissPictureBuffer(picture_id); 968 client_->DismissPictureBuffer(picture_id);
964 assigned_picture_ids_.clear(); 969 assigned_picture_ids_.clear();
965 available_picture_ids_.clear(); 970 available_picture_ids_.clear();
966 971
967 // Request new pictures. 972 // Request new pictures.
968 picture_size_ = frame.coded_size; 973 picture_size_ = frame.coded_size;
969 client_->ProvidePictureBuffers( 974 client_->ProvidePictureBuffers(
970 kNumPictureBuffers, coded_size_, GL_TEXTURE_RECTANGLE_ARB); 975 num_picture_buffers_, coded_size_, GL_TEXTURE_RECTANGLE_ARB);
971 return false; 976 return false;
972 } 977 }
973 if (!SendFrame(frame)) 978 if (!SendFrame(frame))
974 return false; 979 return false;
975 } 980 }
976 981
977 return true; 982 return true;
978 } 983 }
979 984
980 bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) { 985 bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 SupportedProfile profile; 1095 SupportedProfile profile;
1091 profile.profile = supported_profile; 1096 profile.profile = supported_profile;
1092 profile.min_resolution.SetSize(16, 16); 1097 profile.min_resolution.SetSize(16, 16);
1093 profile.max_resolution.SetSize(4096, 2160); 1098 profile.max_resolution.SetSize(4096, 2160);
1094 profiles.push_back(profile); 1099 profiles.push_back(profile);
1095 } 1100 }
1096 return profiles; 1101 return profiles;
1097 } 1102 }
1098 1103
1099 } // namespace content 1104 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698