OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <climits> | 8 #include <climits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 frame->strides_[kVPlane] = v_stride; | 368 frame->strides_[kVPlane] = v_stride; |
369 frame->data_[kYPlane] = y_data; | 369 frame->data_[kYPlane] = y_data; |
370 frame->data_[kUPlane] = u_data; | 370 frame->data_[kUPlane] = u_data; |
371 frame->data_[kVPlane] = v_data; | 371 frame->data_[kVPlane] = v_data; |
372 frame->gpu_memory_buffer_handles_.push_back(y_handle); | 372 frame->gpu_memory_buffer_handles_.push_back(y_handle); |
373 frame->gpu_memory_buffer_handles_.push_back(u_handle); | 373 frame->gpu_memory_buffer_handles_.push_back(u_handle); |
374 frame->gpu_memory_buffer_handles_.push_back(v_handle); | 374 frame->gpu_memory_buffer_handles_.push_back(v_handle); |
375 return frame; | 375 return frame; |
376 } | 376 } |
377 | 377 |
378 // static | |
379 scoped_refptr<VideoFrame> VideoFrame::WrapExternalYuvaData( | |
380 VideoPixelFormat format, | |
381 const gfx::Size& coded_size, | |
382 const gfx::Rect& visible_rect, | |
383 const gfx::Size& natural_size, | |
384 int32_t y_stride, | |
385 int32_t u_stride, | |
386 int32_t v_stride, | |
387 int32_t a_stride, | |
388 uint8_t* y_data, | |
389 uint8_t* u_data, | |
390 uint8_t* v_data, | |
391 uint8_t* a_data, | |
392 base::TimeDelta timestamp) { | |
393 const StorageType storage = STORAGE_UNOWNED_MEMORY; | |
394 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | |
395 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | |
DaleCurtis
2016/01/15 18:31:09
I believe there's another CL which changed these m
vignesh
2016/01/15 19:05:14
Done.
| |
396 << ConfigToString(format, storage, coded_size, visible_rect, | |
397 natural_size); | |
398 return nullptr; | |
399 } | |
400 | |
401 if (NumPlanes(format) != 4) { | |
402 DLOG(ERROR) << "Expecting Y, U, V and A planes to be present for the video" | |
403 << " format."; | |
404 return nullptr; | |
405 } | |
406 | |
407 scoped_refptr<VideoFrame> frame(new VideoFrame( | |
408 format, storage, coded_size, visible_rect, natural_size, timestamp)); | |
409 frame->strides_[kYPlane] = y_stride; | |
410 frame->strides_[kUPlane] = u_stride; | |
411 frame->strides_[kVPlane] = v_stride; | |
412 frame->strides_[kAPlane] = a_stride; | |
413 frame->data_[kYPlane] = y_data; | |
414 frame->data_[kUPlane] = u_data; | |
415 frame->data_[kVPlane] = v_data; | |
416 frame->data_[kAPlane] = a_data; | |
417 return frame; | |
418 } | |
419 | |
378 #if defined(OS_LINUX) | 420 #if defined(OS_LINUX) |
379 // static | 421 // static |
380 scoped_refptr<VideoFrame> VideoFrame::WrapExternalDmabufs( | 422 scoped_refptr<VideoFrame> VideoFrame::WrapExternalDmabufs( |
381 VideoPixelFormat format, | 423 VideoPixelFormat format, |
382 const gfx::Size& coded_size, | 424 const gfx::Size& coded_size, |
383 const gfx::Rect& visible_rect, | 425 const gfx::Rect& visible_rect, |
384 const gfx::Size& natural_size, | 426 const gfx::Size& natural_size, |
385 const std::vector<int>& dmabuf_fds, | 427 const std::vector<int>& dmabuf_fds, |
386 base::TimeDelta timestamp) { | 428 base::TimeDelta timestamp) { |
387 #if defined(OS_CHROMEOS) | 429 #if defined(OS_CHROMEOS) |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 if (zero_initialize_memory) | 1057 if (zero_initialize_memory) |
1016 memset(data, 0, data_size); | 1058 memset(data, 0, data_size); |
1017 | 1059 |
1018 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1060 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
1019 data_[plane] = data + offset[plane]; | 1061 data_[plane] = data + offset[plane]; |
1020 | 1062 |
1021 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1063 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
1022 } | 1064 } |
1023 | 1065 |
1024 } // namespace media | 1066 } // namespace media |
OLD | NEW |