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

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

Issue 1228253002: Remove |cgl_context| from VTVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « content/common/gpu/media/vt_video_decode_accelerator.h ('k') | 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 <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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/mac/mac_logging.h" 14 #include "base/mac/mac_logging.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/sys_byteorder.h" 16 #include "base/sys_byteorder.h"
17 #include "base/sys_info.h" 17 #include "base/sys_info.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "base/version.h" 19 #include "base/version.h"
20 #include "content/common/gpu/media/vt_video_decode_accelerator.h" 20 #include "content/common/gpu/media/vt_video_decode_accelerator.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "media/base/limits.h" 22 #include "media/base/limits.h"
23 #include "ui/gl/gl_context.h"
23 #include "ui/gl/scoped_binders.h" 24 #include "ui/gl/scoped_binders.h"
24 25
25 using content_common_gpu_media::kModuleVt; 26 using content_common_gpu_media::kModuleVt;
26 using content_common_gpu_media::InitializeStubs; 27 using content_common_gpu_media::InitializeStubs;
27 using content_common_gpu_media::IsVtInitialized; 28 using content_common_gpu_media::IsVtInitialized;
28 using content_common_gpu_media::StubPathMap; 29 using content_common_gpu_media::StubPathMap;
29 30
30 #define NOTIFY_STATUS(name, status, session_failure) \ 31 #define NOTIFY_STATUS(name, status, session_failure) \
31 do { \ 32 do { \
32 OSSTATUS_DLOG(ERROR, status) << name; \ 33 OSSTATUS_DLOG(ERROR, status) << name; \
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // existing configuration when the configuration changes. This works around a 67 // existing configuration when the configuration changes. This works around a
67 // bug in VideoToolbox that results in corruption before Mac OS X 10.10.3. The 68 // bug in VideoToolbox that results in corruption before Mac OS X 10.10.3. The
68 // value is set in InitializeVideoToolbox(). 69 // value is set in InitializeVideoToolbox().
69 static bool g_enable_compatible_configuration_reuse = true; 70 static bool g_enable_compatible_configuration_reuse = true;
70 71
71 // Build an |image_config| dictionary for VideoToolbox initialization. 72 // Build an |image_config| dictionary for VideoToolbox initialization.
72 static base::ScopedCFTypeRef<CFMutableDictionaryRef> 73 static base::ScopedCFTypeRef<CFMutableDictionaryRef>
73 BuildImageConfig(CMVideoDimensions coded_dimensions) { 74 BuildImageConfig(CMVideoDimensions coded_dimensions) {
74 base::ScopedCFTypeRef<CFMutableDictionaryRef> image_config; 75 base::ScopedCFTypeRef<CFMutableDictionaryRef> image_config;
75 76
76 // TODO(sandersd): Does it save some work or memory to use 4:2:0? 77 // 4:2:2 is used over the native 4:2:0 because only 4:2:2 can be directly
78 // bound to a texture by CGLTexImageIOSurface2D().
77 int32_t pixel_format = kCVPixelFormatType_422YpCbCr8; 79 int32_t pixel_format = kCVPixelFormatType_422YpCbCr8;
78 #define CFINT(i) CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &i) 80 #define CFINT(i) CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &i)
79 base::ScopedCFTypeRef<CFNumberRef> cf_pixel_format(CFINT(pixel_format)); 81 base::ScopedCFTypeRef<CFNumberRef> cf_pixel_format(CFINT(pixel_format));
80 base::ScopedCFTypeRef<CFNumberRef> cf_width(CFINT(coded_dimensions.width)); 82 base::ScopedCFTypeRef<CFNumberRef> cf_width(CFINT(coded_dimensions.width));
81 base::ScopedCFTypeRef<CFNumberRef> cf_height(CFINT(coded_dimensions.height)); 83 base::ScopedCFTypeRef<CFNumberRef> cf_height(CFINT(coded_dimensions.height));
82 #undef CFINT 84 #undef CFINT
83 if (!cf_pixel_format.get() || !cf_width.get() || !cf_height.get()) 85 if (!cf_pixel_format.get() || !cf_width.get() || !cf_height.get())
84 return image_config; 86 return image_config;
85 87
86 image_config.reset( 88 image_config.reset(
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (lhs->pic_order_cnt != rhs->pic_order_cnt) 280 if (lhs->pic_order_cnt != rhs->pic_order_cnt)
279 return lhs->pic_order_cnt > rhs->pic_order_cnt; 281 return lhs->pic_order_cnt > rhs->pic_order_cnt;
280 // If |pic_order_cnt| is the same, fall back on using the bitstream order. 282 // If |pic_order_cnt| is the same, fall back on using the bitstream order.
281 // TODO(sandersd): Assign a sequence number in Decode() and use that instead. 283 // TODO(sandersd): Assign a sequence number in Decode() and use that instead.
282 // TODO(sandersd): Using the sequence number, ensure that frames older than 284 // TODO(sandersd): Using the sequence number, ensure that frames older than
283 // |kMaxReorderQueueSize| are ordered first, regardless of |pic_order_cnt|. 285 // |kMaxReorderQueueSize| are ordered first, regardless of |pic_order_cnt|.
284 return lhs->bitstream_id > rhs->bitstream_id; 286 return lhs->bitstream_id > rhs->bitstream_id;
285 } 287 }
286 288
287 VTVideoDecodeAccelerator::VTVideoDecodeAccelerator( 289 VTVideoDecodeAccelerator::VTVideoDecodeAccelerator(
288 CGLContextObj cgl_context,
289 const base::Callback<bool(void)>& make_context_current) 290 const base::Callback<bool(void)>& make_context_current)
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 format_(nullptr), 294 format_(nullptr),
295 session_(nullptr), 295 session_(nullptr),
296 last_sps_id_(-1), 296 last_sps_id_(-1),
297 last_pps_id_(-1), 297 last_pps_id_(-1),
298 gpu_task_runner_(base::ThreadTaskRunnerHandle::Get()), 298 gpu_task_runner_(base::ThreadTaskRunnerHandle::Get()),
299 decoder_thread_("VTDecoderThread"), 299 decoder_thread_("VTDecoderThread"),
300 weak_this_factory_(this) { 300 weak_this_factory_(this) {
301 DCHECK(!make_context_current_.is_null()); 301 DCHECK(!make_context_current_.is_null());
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 989
990 if (!make_context_current_.Run()) { 990 if (!make_context_current_.Run()) {
991 DLOG(ERROR) << "Failed to make GL context current"; 991 DLOG(ERROR) << "Failed to make GL context current";
992 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); 992 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR);
993 return false; 993 return false;
994 } 994 }
995 995
996 glEnable(GL_TEXTURE_RECTANGLE_ARB); 996 glEnable(GL_TEXTURE_RECTANGLE_ARB);
997 gfx::ScopedTextureBinder 997 gfx::ScopedTextureBinder
998 texture_binder(GL_TEXTURE_RECTANGLE_ARB, texture_ids_[picture_id]); 998 texture_binder(GL_TEXTURE_RECTANGLE_ARB, texture_ids_[picture_id]);
999 CGLContextObj cgl_context =
1000 static_cast<CGLContextObj>(gfx::GLContext::GetCurrent()->GetHandle());
999 CGLError status = CGLTexImageIOSurface2D( 1001 CGLError status = CGLTexImageIOSurface2D(
1000 cgl_context_, // ctx 1002 cgl_context, // ctx
1001 GL_TEXTURE_RECTANGLE_ARB, // target 1003 GL_TEXTURE_RECTANGLE_ARB, // target
1002 GL_RGB, // internal_format 1004 GL_RGB, // internal_format
1003 frame.coded_size.width(), // width 1005 frame.coded_size.width(), // width
1004 frame.coded_size.height(), // height 1006 frame.coded_size.height(), // height
1005 GL_YCBCR_422_APPLE, // format 1007 GL_YCBCR_422_APPLE, // format
1006 GL_UNSIGNED_SHORT_8_8_APPLE, // type 1008 GL_UNSIGNED_SHORT_8_8_APPLE, // type
1007 surface, // io_surface 1009 surface, // io_surface
1008 0); // plane 1010 0); // plane
1011 glDisable(GL_TEXTURE_RECTANGLE_ARB);
DaleCurtis 2015/07/10 00:53:45 Why the move to before the status is checked?
1009 if (status != kCGLNoError) { 1012 if (status != kCGLNoError) {
1010 NOTIFY_STATUS("CGLTexImageIOSurface2D()", status, SFT_PLATFORM_ERROR); 1013 NOTIFY_STATUS("CGLTexImageIOSurface2D()", status, SFT_PLATFORM_ERROR);
1011 return false; 1014 return false;
1012 } 1015 }
1013 glDisable(GL_TEXTURE_RECTANGLE_ARB);
1014 1016
1015 available_picture_ids_.pop_back(); 1017 available_picture_ids_.pop_back();
1016 picture_bindings_[picture_id] = frame.image; 1018 picture_bindings_[picture_id] = frame.image;
1017 client_->PictureReady(media::Picture(picture_id, frame.bitstream_id, 1019 client_->PictureReady(media::Picture(picture_id, frame.bitstream_id,
1018 gfx::Rect(frame.coded_size), false)); 1020 gfx::Rect(frame.coded_size), false));
1019 return true; 1021 return true;
1020 } 1022 }
1021 1023
1022 void VTVideoDecodeAccelerator::NotifyError( 1024 void VTVideoDecodeAccelerator::NotifyError(
1023 Error vda_error_type, 1025 Error vda_error_type,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 SupportedProfile profile; 1092 SupportedProfile profile;
1091 profile.profile = supported_profile; 1093 profile.profile = supported_profile;
1092 profile.min_resolution.SetSize(16, 16); 1094 profile.min_resolution.SetSize(16, 16);
1093 profile.max_resolution.SetSize(4096, 2160); 1095 profile.max_resolution.SetSize(4096, 2160);
1094 profiles.push_back(profile); 1096 profiles.push_back(profile);
1095 } 1097 }
1096 return profiles; 1098 return profiles;
1097 } 1099 }
1098 1100
1099 } // namespace content 1101 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/vt_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698