Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: media/base/video_frame.cc

Issue 1267003004: Revert to zero-initializing buffers for FFmpegVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed method name. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 618
619 bool VideoFrame::HasTextures() const { 619 bool VideoFrame::HasTextures() const {
620 return !mailbox_holders_[0].mailbox.IsZero(); 620 return !mailbox_holders_[0].mailbox.IsZero();
621 } 621 }
622 622
623 int VideoFrame::stride(size_t plane) const { 623 int VideoFrame::stride(size_t plane) const {
624 DCHECK(IsValidPlane(plane, format_)); 624 DCHECK(IsValidPlane(plane, format_));
625 return strides_[plane]; 625 return strides_[plane];
626 } 626 }
627 627
628 size_t VideoFrame::allocated_size() const {
629 DCHECK(IsYuvPlanar(format_));
630 DCHECK_EQ(storage_type_, STORAGE_OWNED_MEMORY);
631
632 // If CreateFrame() method is used, return the size with alignments and
633 // padding.
634 if (allocated_size_)
DaleCurtis 2015/08/04 19:07:44 Just default to zero in all cases except the Alloc
emircan 2015/08/04 19:54:35 Done.
635 return allocated_size_;
636
637 return VideoFrame::AllocationSize(format_, coded_size_);
638 }
639
628 int VideoFrame::row_bytes(size_t plane) const { 640 int VideoFrame::row_bytes(size_t plane) const {
629 return RowBytes(plane, format_, coded_size_.width()); 641 return RowBytes(plane, format_, coded_size_.width());
630 } 642 }
631 643
632 int VideoFrame::rows(size_t plane) const { 644 int VideoFrame::rows(size_t plane) const {
633 return Rows(plane, format_, coded_size_.height()); 645 return Rows(plane, format_, coded_size_.height());
634 } 646 }
635 647
636 const uint8* VideoFrame::data(size_t plane) const { 648 const uint8* VideoFrame::data(size_t plane) const {
637 DCHECK(IsValidPlane(plane, format_)); 649 DCHECK(IsValidPlane(plane, format_));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 900
889 // The extra line of UV being allocated is because h264 chroma MC 901 // The extra line of UV being allocated is because h264 chroma MC
890 // overreads by one line in some cases, see libavcodec/utils.c: 902 // overreads by one line in some cases, see libavcodec/utils.c:
891 // avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm: 903 // avcodec_align_dimensions2() and libavcodec/x86/h264_chromamc.asm:
892 // put_h264_chroma_mc4_ssse3(). 904 // put_h264_chroma_mc4_ssse3().
893 DCHECK(IsValidPlane(kUPlane, format_)); 905 DCHECK(IsValidPlane(kUPlane, format_));
894 data_size += strides_[kUPlane] + kFrameSizePadding; 906 data_size += strides_[kUPlane] + kFrameSizePadding;
895 907
896 uint8* data = reinterpret_cast<uint8*>( 908 uint8* data = reinterpret_cast<uint8*>(
897 base::AlignedAlloc(data_size, kFrameAddressAlignment)); 909 base::AlignedAlloc(data_size, kFrameAddressAlignment));
898
899 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 910 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
900 data_[plane] = data + offset[plane]; 911 data_[plane] = data + offset[plane];
901 912
902 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 913 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
914
915 // Make sure that allocated_size() returns the same size as allocated here.
916 allocated_size_ = data_size;
903 } 917 }
904 918
905 } // namespace media 919 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698