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

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

Issue 2745743002: Added BitsPerChannel method to video frame class. (Closed)
Patch Set: Added BitsPerChannel method to video frame class. Created 3 years, 9 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
« no previous file with comments | « media/base/video_frame.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <climits> 8 #include <climits>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 if (metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM)) 788 if (metadata()->IsTrue(media::VideoFrameMetadata::END_OF_STREAM))
789 return "end of stream"; 789 return "end of stream";
790 790
791 std::ostringstream s; 791 std::ostringstream s;
792 s << ConfigToString(format_, storage_type_, coded_size_, visible_rect_, 792 s << ConfigToString(format_, storage_type_, coded_size_, visible_rect_,
793 natural_size_) 793 natural_size_)
794 << " timestamp:" << timestamp_.InMicroseconds(); 794 << " timestamp:" << timestamp_.InMicroseconds();
795 return s.str(); 795 return s.str();
796 } 796 }
797 797
798 int VideoFrame::BitsPerChannel(VideoPixelFormat format) {
799 int bits_per_channel = 0;
800 switch (format) {
801 case media::PIXEL_FORMAT_UNKNOWN:
802 NOTREACHED();
803 // Fall through!
804 case media::PIXEL_FORMAT_I420:
805 case media::PIXEL_FORMAT_YV12:
806 case media::PIXEL_FORMAT_YV16:
807 case media::PIXEL_FORMAT_YV12A:
808 case media::PIXEL_FORMAT_YV24:
809 case media::PIXEL_FORMAT_NV12:
810 case media::PIXEL_FORMAT_NV21:
811 case media::PIXEL_FORMAT_UYVY:
812 case media::PIXEL_FORMAT_YUY2:
813 case media::PIXEL_FORMAT_ARGB:
814 case media::PIXEL_FORMAT_XRGB:
815 case media::PIXEL_FORMAT_RGB24:
816 case media::PIXEL_FORMAT_RGB32:
817 case media::PIXEL_FORMAT_MJPEG:
818 case media::PIXEL_FORMAT_MT21:
819 case media::PIXEL_FORMAT_Y8:
820 case media::PIXEL_FORMAT_I422:
821 bits_per_channel = 8;
822 break;
823 case media::PIXEL_FORMAT_YUV420P9:
824 case media::PIXEL_FORMAT_YUV422P9:
825 case media::PIXEL_FORMAT_YUV444P9:
826 bits_per_channel = 9;
827 break;
828 case media::PIXEL_FORMAT_YUV420P10:
829 case media::PIXEL_FORMAT_YUV422P10:
830 case media::PIXEL_FORMAT_YUV444P10:
831 bits_per_channel = 10;
832 break;
833 case media::PIXEL_FORMAT_YUV420P12:
834 case media::PIXEL_FORMAT_YUV422P12:
835 case media::PIXEL_FORMAT_YUV444P12:
836 bits_per_channel = 12;
837 break;
838 case media::PIXEL_FORMAT_Y16:
839 bits_per_channel = 16;
840 break;
841 }
842 return bits_per_channel;
843 }
844
798 // static 845 // static
799 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage( 846 scoped_refptr<VideoFrame> VideoFrame::WrapExternalStorage(
800 VideoPixelFormat format, 847 VideoPixelFormat format,
801 StorageType storage_type, 848 StorageType storage_type,
802 const gfx::Size& coded_size, 849 const gfx::Size& coded_size,
803 const gfx::Rect& visible_rect, 850 const gfx::Rect& visible_rect,
804 const gfx::Size& natural_size, 851 const gfx::Size& natural_size,
805 uint8_t* data, 852 uint8_t* data,
806 size_t data_size, 853 size_t data_size,
807 base::TimeDelta timestamp, 854 base::TimeDelta timestamp,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 if (zero_initialize_memory) 1199 if (zero_initialize_memory)
1153 memset(data, 0, data_size); 1200 memset(data, 0, data_size);
1154 1201
1155 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) 1202 for (size_t plane = 0; plane < NumPlanes(format_); ++plane)
1156 data_[plane] = data + offset[plane]; 1203 data_[plane] = data + offset[plane];
1157 1204
1158 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); 1205 AddDestructionObserver(base::Bind(&base::AlignedFree, data));
1159 } 1206 }
1160 1207
1161 } // namespace media 1208 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698