| 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 data_size += height * strides_[plane]; | 849 data_size += height * strides_[plane]; |
| 850 } | 850 } |
| 851 | 851 |
| 852 // The extra line of UV being allocated is because h264 chroma MC | 852 // The extra line of UV being allocated is because h264 chroma MC |
| 853 // overreads by one line in some cases, see libavcodec/utils.c: | 853 // overreads by one line in some cases, see libavcodec/utils.c: |
| 854 // avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm: | 854 // avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm: |
| 855 // put_h264_chroma_mc4_ssse3(). | 855 // put_h264_chroma_mc4_ssse3(). |
| 856 DCHECK(IsValidPlane(kUPlane, format_)); | 856 DCHECK(IsValidPlane(kUPlane, format_)); |
| 857 data_size += strides_[kUPlane] + kFrameSizePadding; | 857 data_size += strides_[kUPlane] + kFrameSizePadding; |
| 858 | 858 |
| 859 // FFmpeg expects the initialize allocation to be zero-initialized. Failure | |
| 860 // to do so can lead to unitialized value usage. See http://crbug.com/390941 | |
| 861 uint8* data = reinterpret_cast<uint8*>( | 859 uint8* data = reinterpret_cast<uint8*>( |
| 862 base::AlignedAlloc(data_size, kFrameAddressAlignment)); | 860 base::AlignedAlloc(data_size, kFrameAddressAlignment)); |
| 863 memset(data, 0, data_size); | |
| 864 | 861 |
| 865 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 862 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
| 866 data_[plane] = data + offset[plane]; | 863 data_[plane] = data + offset[plane]; |
| 867 | 864 |
| 868 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 865 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
| 869 } | 866 } |
| 870 | 867 |
| 871 } // namespace media | 868 } // namespace media |
| OLD | NEW |