OLD | NEW |
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 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // they will be broken if they are used before that happens. So, schedule | 853 // they will be broken if they are used before that happens. So, schedule |
854 // future work after that happens. | 854 // future work after that happens. |
855 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( | 855 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( |
856 &VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_)); | 856 &VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_)); |
857 } | 857 } |
858 | 858 |
859 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) { | 859 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) { |
860 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 860 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
861 DCHECK(picture_info_map_.count(picture_id)); | 861 DCHECK(picture_info_map_.count(picture_id)); |
862 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); | 862 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); |
863 DCHECK_EQ(CFGetRetainCount(picture_info->cv_image), 1); | 863 DCHECK_EQ(CFGetRetainCount(picture_info->cv_image), 2); |
864 picture_info->cv_image.reset(); | 864 picture_info->cv_image.reset(); |
865 picture_info->gl_image->Destroy(false); | 865 picture_info->gl_image->Destroy(false); |
866 picture_info->gl_image = nullptr; | 866 picture_info->gl_image = nullptr; |
867 | 867 |
868 if (assigned_picture_ids_.count(picture_id) != 0) { | 868 if (assigned_picture_ids_.count(picture_id) != 0) { |
869 available_picture_ids_.push_back(picture_id); | 869 available_picture_ids_.push_back(picture_id); |
870 ProcessWorkQueues(); | 870 ProcessWorkQueues(); |
871 } else { | 871 } else { |
872 client_->DismissPictureBuffer(picture_id); | 872 client_->DismissPictureBuffer(picture_id); |
873 } | 873 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); | 1026 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); |
1027 DCHECK(!picture_info->cv_image); | 1027 DCHECK(!picture_info->cv_image); |
1028 DCHECK(!picture_info->gl_image); | 1028 DCHECK(!picture_info->gl_image); |
1029 | 1029 |
1030 if (!make_context_current_.Run()) { | 1030 if (!make_context_current_.Run()) { |
1031 DLOG(ERROR) << "Failed to make GL context current"; | 1031 DLOG(ERROR) << "Failed to make GL context current"; |
1032 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); | 1032 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); |
1033 return false; | 1033 return false; |
1034 } | 1034 } |
1035 | 1035 |
1036 IOSurfaceRef io_surface = CVPixelBufferGetIOSurface(frame.image.get()); | |
1037 | |
1038 scoped_refptr<gl::GLImageIOSurface> gl_image( | 1036 scoped_refptr<gl::GLImageIOSurface> gl_image( |
1039 new gl::GLImageIOSurface(frame.coded_size, GL_BGRA_EXT)); | 1037 new gl::GLImageIOSurface(frame.coded_size, GL_BGRA_EXT)); |
1040 if (!gl_image->Initialize(io_surface, gfx::GenericSharedMemoryId(), | 1038 if (!gl_image->InitializeWithCVPixelBuffer( |
1041 gfx::BufferFormat::YUV_420_BIPLANAR)) { | 1039 frame.image.get(), gfx::GenericSharedMemoryId(), |
| 1040 gfx::BufferFormat::YUV_420_BIPLANAR)) { |
1042 NOTIFY_STATUS("Failed to initialize GLImageIOSurface", PLATFORM_FAILURE, | 1041 NOTIFY_STATUS("Failed to initialize GLImageIOSurface", PLATFORM_FAILURE, |
1043 SFT_PLATFORM_ERROR); | 1042 SFT_PLATFORM_ERROR); |
1044 } | 1043 } |
1045 | 1044 |
1046 bind_image_.Run(picture_info->client_texture_id, GL_TEXTURE_RECTANGLE_ARB, | 1045 bind_image_.Run(picture_info->client_texture_id, GL_TEXTURE_RECTANGLE_ARB, |
1047 gl_image, false); | 1046 gl_image, false); |
1048 | 1047 |
1049 // Assign the new image(s) to the the picture info. | 1048 // Assign the new image(s) to the the picture info. |
1050 picture_info->gl_image = gl_image; | 1049 picture_info->gl_image = gl_image; |
1051 picture_info->cv_image = frame.image; | 1050 picture_info->cv_image = frame.image; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 SupportedProfile profile; | 1132 SupportedProfile profile; |
1134 profile.profile = supported_profile; | 1133 profile.profile = supported_profile; |
1135 profile.min_resolution.SetSize(16, 16); | 1134 profile.min_resolution.SetSize(16, 16); |
1136 profile.max_resolution.SetSize(4096, 2160); | 1135 profile.max_resolution.SetSize(4096, 2160); |
1137 profiles.push_back(profile); | 1136 profiles.push_back(profile); |
1138 } | 1137 } |
1139 return profiles; | 1138 return profiles; |
1140 } | 1139 } |
1141 | 1140 |
1142 } // namespace content | 1141 } // namespace content |
OLD | NEW |