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." | |
396 << ConfigToString(format, storage, coded_size, visible_rect, | |
397 natural_size); | |
398 return nullptr; | |
399 } | |
400 | |
401 if (NumPlanes(format) != 4) { | |
402 DLOG(ERROR) << "Not expecting alpha for the video format."; | |
DaleCurtis
2016/01/13 01:32:28
Fix message. Expecting YUVA planes, etc.
vignesh
2016/01/15 18:07:13
Done.
| |
403 return nullptr; | |
404 } | |
405 | |
406 scoped_refptr<VideoFrame> frame(new VideoFrame( | |
407 format, storage, coded_size, visible_rect, natural_size, timestamp)); | |
408 frame->strides_[kYPlane] = y_stride; | |
409 frame->strides_[kUPlane] = u_stride; | |
410 frame->strides_[kVPlane] = v_stride; | |
411 frame->strides_[kAPlane] = a_stride; | |
412 frame->data_[kYPlane] = y_data; | |
413 frame->data_[kUPlane] = u_data; | |
414 frame->data_[kVPlane] = v_data; | |
415 frame->data_[kAPlane] = a_data; | |
416 return frame; | |
417 } | |
418 | |
378 #if defined(OS_LINUX) | 419 #if defined(OS_LINUX) |
379 // static | 420 // static |
380 scoped_refptr<VideoFrame> VideoFrame::WrapExternalDmabufs( | 421 scoped_refptr<VideoFrame> VideoFrame::WrapExternalDmabufs( |
381 VideoPixelFormat format, | 422 VideoPixelFormat format, |
382 const gfx::Size& coded_size, | 423 const gfx::Size& coded_size, |
383 const gfx::Rect& visible_rect, | 424 const gfx::Rect& visible_rect, |
384 const gfx::Size& natural_size, | 425 const gfx::Size& natural_size, |
385 const std::vector<int>& dmabuf_fds, | 426 const std::vector<int>& dmabuf_fds, |
386 base::TimeDelta timestamp) { | 427 base::TimeDelta timestamp) { |
387 #if defined(OS_CHROMEOS) | 428 #if defined(OS_CHROMEOS) |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 if (zero_initialize_memory) | 1056 if (zero_initialize_memory) |
1016 memset(data, 0, data_size); | 1057 memset(data, 0, data_size); |
1017 | 1058 |
1018 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1059 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
1019 data_[plane] = data + offset[plane]; | 1060 data_[plane] = data + offset[plane]; |
1020 | 1061 |
1021 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1062 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
1022 } | 1063 } |
1023 | 1064 |
1024 } // namespace media | 1065 } // namespace media |
OLD | NEW |