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/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 bool VideoFrame::IsMappable() const { | 647 bool VideoFrame::IsMappable() const { |
648 return IsStorageTypeMappable(storage_type_); | 648 return IsStorageTypeMappable(storage_type_); |
649 } | 649 } |
650 | 650 |
651 bool VideoFrame::HasTextures() const { | 651 bool VideoFrame::HasTextures() const { |
652 return !mailbox_holders_[0].mailbox.IsZero(); | 652 return !mailbox_holders_[0].mailbox.IsZero(); |
653 } | 653 } |
654 | 654 |
655 gfx::ColorSpace VideoFrame::ColorSpace() const { | 655 gfx::ColorSpace VideoFrame::ColorSpace() const { |
656 int videoframe_color_space; | 656 if (color_space_ == gfx::ColorSpace()) { |
657 if (metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE, | 657 int videoframe_color_space; |
658 &videoframe_color_space)) { | 658 if (metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE, |
659 switch (videoframe_color_space) { | 659 &videoframe_color_space)) { |
660 case media::COLOR_SPACE_JPEG: | 660 switch (videoframe_color_space) { |
661 return gfx::ColorSpace::CreateJpeg(); | 661 case media::COLOR_SPACE_JPEG: |
662 case media::COLOR_SPACE_HD_REC709: | 662 return gfx::ColorSpace::CreateJpeg(); |
663 return gfx::ColorSpace::CreateREC709(); | 663 case media::COLOR_SPACE_HD_REC709: |
664 case media::COLOR_SPACE_SD_REC601: | 664 return gfx::ColorSpace::CreateREC709(); |
665 return gfx::ColorSpace::CreateREC601(); | 665 case media::COLOR_SPACE_SD_REC601: |
666 default: | 666 return gfx::ColorSpace::CreateREC601(); |
667 break; | 667 default: |
| 668 break; |
| 669 } |
668 } | 670 } |
669 } | 671 } |
670 return gfx::ColorSpace(); | 672 return color_space_; |
| 673 } |
| 674 |
| 675 void VideoFrame::set_color_space(const gfx::ColorSpace& color_space) { |
| 676 color_space_ = color_space; |
671 } | 677 } |
672 | 678 |
673 int VideoFrame::stride(size_t plane) const { | 679 int VideoFrame::stride(size_t plane) const { |
674 DCHECK(IsValidPlane(plane, format_)); | 680 DCHECK(IsValidPlane(plane, format_)); |
675 return strides_[plane]; | 681 return strides_[plane]; |
676 } | 682 } |
677 | 683 |
678 int VideoFrame::row_bytes(size_t plane) const { | 684 int VideoFrame::row_bytes(size_t plane) const { |
679 return RowBytes(plane, format_, coded_size_.width()); | 685 return RowBytes(plane, format_, coded_size_.width()); |
680 } | 686 } |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 if (zero_initialize_memory) | 1154 if (zero_initialize_memory) |
1149 memset(data, 0, data_size); | 1155 memset(data, 0, data_size); |
1150 | 1156 |
1151 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1157 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
1152 data_[plane] = data + offset[plane]; | 1158 data_[plane] = data + offset[plane]; |
1153 | 1159 |
1154 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1160 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
1155 } | 1161 } |
1156 | 1162 |
1157 } // namespace media | 1163 } // namespace media |
OLD | NEW |