OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/video/gpu_memory_buffer_video_frame_pool.h" | 5 #include "media/video/gpu_memory_buffer_video_frame_pool.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 DCHECK_EQ(0u, plane); | 218 DCHECK_EQ(0u, plane); |
219 bytes_per_row += VideoFrame::RowBytes(1, format, width); | 219 bytes_per_row += VideoFrame::RowBytes(1, format, width); |
220 } | 220 } |
221 // Copy an even number of lines, and at least one. | 221 // Copy an even number of lines, and at least one. |
222 return std::max<size_t>((kBytesPerCopyTarget / bytes_per_row) & ~1, 1); | 222 return std::max<size_t>((kBytesPerCopyTarget / bytes_per_row) & ~1, 1); |
223 } | 223 } |
224 | 224 |
225 void CopyRowsToI420Buffer(int first_row, | 225 void CopyRowsToI420Buffer(int first_row, |
226 int rows, | 226 int rows, |
227 int bytes_per_row, | 227 int bytes_per_row, |
228 const uint8* source, | 228 const uint8_t* source, |
229 int source_stride, | 229 int source_stride, |
230 uint8* output, | 230 uint8_t* output, |
231 int dest_stride, | 231 int dest_stride, |
232 const base::Closure& done) { | 232 const base::Closure& done) { |
233 TRACE_EVENT2("media", "CopyRowsToI420Buffer", "bytes_per_row", bytes_per_row, | 233 TRACE_EVENT2("media", "CopyRowsToI420Buffer", "bytes_per_row", bytes_per_row, |
234 "rows", rows); | 234 "rows", rows); |
235 if (output) { | 235 if (output) { |
236 DCHECK_NE(dest_stride, 0); | 236 DCHECK_NE(dest_stride, 0); |
237 DCHECK_LE(bytes_per_row, std::abs(dest_stride)); | 237 DCHECK_LE(bytes_per_row, std::abs(dest_stride)); |
238 DCHECK_LE(bytes_per_row, source_stride); | 238 DCHECK_LE(bytes_per_row, source_stride); |
239 | 239 |
240 libyuv::CopyPlane(source + source_stride * first_row, source_stride, | 240 libyuv::CopyPlane(source + source_stride * first_row, source_stride, |
241 output + dest_stride * first_row, dest_stride, | 241 output + dest_stride * first_row, dest_stride, |
242 bytes_per_row, rows); | 242 bytes_per_row, rows); |
243 } | 243 } |
244 done.Run(); | 244 done.Run(); |
245 } | 245 } |
246 | 246 |
247 void CopyRowsToNV12Buffer(int first_row, | 247 void CopyRowsToNV12Buffer(int first_row, |
248 int rows, | 248 int rows, |
249 int bytes_per_row, | 249 int bytes_per_row, |
250 const scoped_refptr<VideoFrame>& source_frame, | 250 const scoped_refptr<VideoFrame>& source_frame, |
251 uint8* dest_y, | 251 uint8_t* dest_y, |
252 int dest_stride_y, | 252 int dest_stride_y, |
253 uint8* dest_uv, | 253 uint8_t* dest_uv, |
254 int dest_stride_uv, | 254 int dest_stride_uv, |
255 const base::Closure& done) { | 255 const base::Closure& done) { |
256 TRACE_EVENT2("media", "CopyRowsToNV12Buffer", "bytes_per_row", bytes_per_row, | 256 TRACE_EVENT2("media", "CopyRowsToNV12Buffer", "bytes_per_row", bytes_per_row, |
257 "rows", rows); | 257 "rows", rows); |
258 if (dest_y && dest_uv) { | 258 if (dest_y && dest_uv) { |
259 DCHECK_NE(dest_stride_y, 0); | 259 DCHECK_NE(dest_stride_y, 0); |
260 DCHECK_NE(dest_stride_uv, 0); | 260 DCHECK_NE(dest_stride_uv, 0); |
261 DCHECK_LE(bytes_per_row, std::abs(dest_stride_y)); | 261 DCHECK_LE(bytes_per_row, std::abs(dest_stride_y)); |
262 DCHECK_LE(bytes_per_row, std::abs(dest_stride_uv)); | 262 DCHECK_LE(bytes_per_row, std::abs(dest_stride_uv)); |
263 DCHECK_EQ(0, first_row % 2); | 263 DCHECK_EQ(0, first_row % 2); |
(...skipping 12 matching lines...) Expand all Loading... |
276 dest_uv + first_row / 2 * dest_stride_uv, dest_stride_uv, bytes_per_row, | 276 dest_uv + first_row / 2 * dest_stride_uv, dest_stride_uv, bytes_per_row, |
277 rows); | 277 rows); |
278 } | 278 } |
279 done.Run(); | 279 done.Run(); |
280 } | 280 } |
281 | 281 |
282 void CopyRowsToUYVYBuffer(int first_row, | 282 void CopyRowsToUYVYBuffer(int first_row, |
283 int rows, | 283 int rows, |
284 int width, | 284 int width, |
285 const scoped_refptr<VideoFrame>& source_frame, | 285 const scoped_refptr<VideoFrame>& source_frame, |
286 uint8* output, | 286 uint8_t* output, |
287 int dest_stride, | 287 int dest_stride, |
288 const base::Closure& done) { | 288 const base::Closure& done) { |
289 TRACE_EVENT2("media", "CopyRowsToUYVYBuffer", "bytes_per_row", width * 2, | 289 TRACE_EVENT2("media", "CopyRowsToUYVYBuffer", "bytes_per_row", width * 2, |
290 "rows", rows); | 290 "rows", rows); |
291 if (output) { | 291 if (output) { |
292 DCHECK_NE(dest_stride, 0); | 292 DCHECK_NE(dest_stride, 0); |
293 DCHECK_LE(width, std::abs(dest_stride / 2)); | 293 DCHECK_LE(width, std::abs(dest_stride / 2)); |
294 DCHECK_EQ(0, first_row % 2); | 294 DCHECK_EQ(0, first_row % 2); |
295 libyuv::I420ToUYVY( | 295 libyuv::I420ToUYVY( |
296 source_frame->visible_data(VideoFrame::kYPlane) + | 296 source_frame->visible_data(VideoFrame::kYPlane) + |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 384 } |
385 | 385 |
386 worker_task_runner_->PostTask( | 386 worker_task_runner_->PostTask( |
387 FROM_HERE, base::Bind(&PoolImpl::CopyVideoFrameToGpuMemoryBuffers, this, | 387 FROM_HERE, base::Bind(&PoolImpl::CopyVideoFrameToGpuMemoryBuffers, this, |
388 video_frame, frame_resources, frame_ready_cb)); | 388 video_frame, frame_resources, frame_ready_cb)); |
389 } | 389 } |
390 | 390 |
391 bool GpuMemoryBufferVideoFramePool::PoolImpl::OnMemoryDump( | 391 bool GpuMemoryBufferVideoFramePool::PoolImpl::OnMemoryDump( |
392 const base::trace_event::MemoryDumpArgs& args, | 392 const base::trace_event::MemoryDumpArgs& args, |
393 base::trace_event::ProcessMemoryDump* pmd) { | 393 base::trace_event::ProcessMemoryDump* pmd) { |
394 const uint64 tracing_process_id = | 394 const uint64_t tracing_process_id = |
395 base::trace_event::MemoryDumpManager::GetInstance() | 395 base::trace_event::MemoryDumpManager::GetInstance() |
396 ->GetTracingProcessId(); | 396 ->GetTracingProcessId(); |
397 const int kImportance = 2; | 397 const int kImportance = 2; |
398 for (const FrameResources* frame_resources : resources_pool_) { | 398 for (const FrameResources* frame_resources : resources_pool_) { |
399 for (const PlaneResource& plane_resource : | 399 for (const PlaneResource& plane_resource : |
400 frame_resources->plane_resources) { | 400 frame_resources->plane_resources) { |
401 if (plane_resource.gpu_memory_buffer) { | 401 if (plane_resource.gpu_memory_buffer) { |
402 gfx::GpuMemoryBufferId buffer_id = | 402 gfx::GpuMemoryBufferId buffer_id = |
403 plane_resource.gpu_memory_buffer->GetId(); | 403 plane_resource.gpu_memory_buffer->GetId(); |
404 std::string dump_name = base::StringPrintf( | 404 std::string dump_name = base::StringPrintf( |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 738 } |
739 | 739 |
740 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame( | 740 void GpuMemoryBufferVideoFramePool::MaybeCreateHardwareFrame( |
741 const scoped_refptr<VideoFrame>& video_frame, | 741 const scoped_refptr<VideoFrame>& video_frame, |
742 const FrameReadyCB& frame_ready_cb) { | 742 const FrameReadyCB& frame_ready_cb) { |
743 DCHECK(video_frame); | 743 DCHECK(video_frame); |
744 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb); | 744 pool_impl_->CreateHardwareFrame(video_frame, frame_ready_cb); |
745 } | 745 } |
746 | 746 |
747 } // namespace media | 747 } // namespace media |
OLD | NEW |