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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 StorageType storage_type, | 798 StorageType storage_type, |
799 const gfx::Size& coded_size, | 799 const gfx::Size& coded_size, |
800 const gfx::Rect& visible_rect, | 800 const gfx::Rect& visible_rect, |
801 const gfx::Size& natural_size, | 801 const gfx::Size& natural_size, |
802 base::TimeDelta timestamp) | 802 base::TimeDelta timestamp) |
803 : format_(format), | 803 : format_(format), |
804 storage_type_(storage_type), | 804 storage_type_(storage_type), |
805 coded_size_(coded_size), | 805 coded_size_(coded_size), |
806 visible_rect_(visible_rect), | 806 visible_rect_(visible_rect), |
807 natural_size_(natural_size), | 807 natural_size_(natural_size), |
| 808 allocated_size_(0), |
808 shared_memory_handle_(base::SharedMemory::NULLHandle()), | 809 shared_memory_handle_(base::SharedMemory::NULLHandle()), |
809 shared_memory_offset_(0), | 810 shared_memory_offset_(0), |
810 timestamp_(timestamp), | 811 timestamp_(timestamp), |
811 release_sync_point_(0) { | 812 release_sync_point_(0) { |
812 DCHECK(IsValidConfig(format_, storage_type, coded_size_, visible_rect_, | 813 DCHECK(IsValidConfig(format_, storage_type, coded_size_, visible_rect_, |
813 natural_size_)); | 814 natural_size_)); |
814 memset(&mailbox_holders_, 0, sizeof(mailbox_holders_)); | 815 memset(&mailbox_holders_, 0, sizeof(mailbox_holders_)); |
815 memset(&strides_, 0, sizeof(strides_)); | 816 memset(&strides_, 0, sizeof(strides_)); |
816 memset(&data_, 0, sizeof(data_)); | 817 memset(&data_, 0, sizeof(data_)); |
817 } | 818 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 889 |
889 // The extra line of UV being allocated is because h264 chroma MC | 890 // The extra line of UV being allocated is because h264 chroma MC |
890 // overreads by one line in some cases, see libavcodec/utils.c: | 891 // overreads by one line in some cases, see libavcodec/utils.c: |
891 // avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm: | 892 // avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm: |
892 // put_h264_chroma_mc4_ssse3(). | 893 // put_h264_chroma_mc4_ssse3(). |
893 DCHECK(IsValidPlane(kUPlane, format_)); | 894 DCHECK(IsValidPlane(kUPlane, format_)); |
894 data_size += strides_[kUPlane] + kFrameSizePadding; | 895 data_size += strides_[kUPlane] + kFrameSizePadding; |
895 | 896 |
896 uint8* data = reinterpret_cast<uint8*>( | 897 uint8* data = reinterpret_cast<uint8*>( |
897 base::AlignedAlloc(data_size, kFrameAddressAlignment)); | 898 base::AlignedAlloc(data_size, kFrameAddressAlignment)); |
898 | |
899 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 899 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
900 data_[plane] = data + offset[plane]; | 900 data_[plane] = data + offset[plane]; |
901 | 901 |
902 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 902 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
| 903 |
| 904 // Make sure that allocated_size() returns the same size as allocated here. |
| 905 allocated_size_ = data_size; |
903 } | 906 } |
904 | 907 |
905 } // namespace media | 908 } // namespace media |
OLD | NEW |