| 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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 // CommonAlignment() check should be made in IsValidConfig()? | 931 // CommonAlignment() check should be made in IsValidConfig()? |
| 932 // http://crbug.com/555909 | 932 // http://crbug.com/555909 |
| 933 frame->strides_[kUPlane] = coded_size.width() / 2; | 933 frame->strides_[kUPlane] = coded_size.width() / 2; |
| 934 frame->strides_[kVPlane] = coded_size.width() / 2; | 934 frame->strides_[kVPlane] = coded_size.width() / 2; |
| 935 frame->data_[kYPlane] = data; | 935 frame->data_[kYPlane] = data; |
| 936 frame->data_[kUPlane] = data + coded_size.GetArea(); | 936 frame->data_[kUPlane] = data + coded_size.GetArea(); |
| 937 frame->data_[kVPlane] = data + (coded_size.GetArea() * 5 / 4); | 937 frame->data_[kVPlane] = data + (coded_size.GetArea() * 5 / 4); |
| 938 return frame; | 938 return frame; |
| 939 } | 939 } |
| 940 | 940 |
| 941 void VideoFrame::set_data(size_t plane, uint8_t* ptr) { |
| 942 DCHECK(IsValidPlane(plane, format_)); |
| 943 DCHECK(ptr); |
| 944 data_[plane] = ptr; |
| 945 } |
| 946 |
| 947 void VideoFrame::set_stride(size_t plane, int stride) { |
| 948 DCHECK(IsValidPlane(plane, format_)); |
| 949 DCHECK_GT(stride, 0); |
| 950 strides_[plane] = stride; |
| 951 } |
| 952 |
| 941 VideoFrame::VideoFrame(VideoPixelFormat format, | 953 VideoFrame::VideoFrame(VideoPixelFormat format, |
| 942 StorageType storage_type, | 954 StorageType storage_type, |
| 943 const gfx::Size& coded_size, | 955 const gfx::Size& coded_size, |
| 944 const gfx::Rect& visible_rect, | 956 const gfx::Rect& visible_rect, |
| 945 const gfx::Size& natural_size, | 957 const gfx::Size& natural_size, |
| 946 base::TimeDelta timestamp) | 958 base::TimeDelta timestamp) |
| 947 : format_(format), | 959 : format_(format), |
| 948 storage_type_(storage_type), | 960 storage_type_(storage_type), |
| 949 coded_size_(coded_size), | 961 coded_size_(coded_size), |
| 950 visible_rect_(visible_rect), | 962 visible_rect_(visible_rect), |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 if (zero_initialize_memory) | 1092 if (zero_initialize_memory) |
| 1081 memset(data, 0, data_size); | 1093 memset(data, 0, data_size); |
| 1082 | 1094 |
| 1083 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1095 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
| 1084 data_[plane] = data + offset[plane]; | 1096 data_[plane] = data + offset[plane]; |
| 1085 | 1097 |
| 1086 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1098 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
| 1087 } | 1099 } |
| 1088 | 1100 |
| 1089 } // namespace media | 1101 } // namespace media |
| OLD | NEW |