OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/filters/h264_parser.h" | 5 #include "media/filters/h264_parser.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 if (pic_width_in_mbs_minus1 > max_mb_minus1 || | 61 if (pic_width_in_mbs_minus1 > max_mb_minus1 || |
62 pic_height_in_map_units_minus1 > max_map_units_minus1) { | 62 pic_height_in_map_units_minus1 > max_map_units_minus1) { |
63 DVLOG(1) << "Coded size is too large."; | 63 DVLOG(1) << "Coded size is too large."; |
64 return base::nullopt; | 64 return base::nullopt; |
65 } | 65 } |
66 | 66 |
67 return gfx::Size(mb_unit * (pic_width_in_mbs_minus1 + 1), | 67 return gfx::Size(mb_unit * (pic_width_in_mbs_minus1 + 1), |
68 map_unit * (pic_height_in_map_units_minus1 + 1)); | 68 map_unit * (pic_height_in_map_units_minus1 + 1)); |
69 } | 69 } |
70 | 70 |
71 // Also based on section 7.4.2.1.1. | 71 // Based on T-REC-H.264 E.2.1, "VUI parameters semantics", |
72 // available from http://www.itu.int/rec/T-REC-H.264. | |
72 base::Optional<gfx::Rect> H264SPS::GetVisibleRect() const { | 73 base::Optional<gfx::Rect> H264SPS::GetVisibleRect() const { |
73 base::Optional<gfx::Size> coded_size = GetCodedSize(); | 74 base::Optional<gfx::Size> coded_size = GetCodedSize(); |
74 if (!coded_size) | 75 if (!coded_size) |
75 return base::nullopt; | 76 return base::nullopt; |
76 | 77 |
77 if (!frame_cropping_flag) | 78 if (!frame_cropping_flag) |
78 return gfx::Rect(coded_size.value()); | 79 return gfx::Rect(coded_size.value()); |
79 | 80 |
80 int crop_unit_x; | 81 int crop_unit_x; |
81 int crop_unit_y; | 82 int crop_unit_y; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 coded_size->height() - crop_top <= crop_bottom) { | 116 coded_size->height() - crop_top <= crop_bottom) { |
116 DVLOG(1) << "Frame cropping excludes entire frame."; | 117 DVLOG(1) << "Frame cropping excludes entire frame."; |
117 return base::nullopt; | 118 return base::nullopt; |
118 } | 119 } |
119 | 120 |
120 return gfx::Rect(crop_left, crop_top, | 121 return gfx::Rect(crop_left, crop_top, |
121 coded_size->width() - crop_left - crop_right, | 122 coded_size->width() - crop_left - crop_right, |
122 coded_size->height() - crop_top - crop_bottom); | 123 coded_size->height() - crop_top - crop_bottom); |
123 } | 124 } |
124 | 125 |
126 // Comers from VUI section SPS. (E | |
sandersd (OOO until July 31)
2016/09/23 00:33:50
Comment seems to have gotten corrupted?
| |
127 gfx::ColorSpace H264SPS::GetColorSpace() const { | |
128 if (colour_description_present_flag) { | |
129 return gfx::ColorSpace( | |
130 colour_primaries, transfer_characteristics, matrix_coefficients, | |
131 video_full_range_flag ? gfx::ColorSpace::RangeID::FULL | |
132 : gfx::ColorSpace::RangeID::LIMITED); | |
133 } else { | |
134 return gfx::ColorSpace(gfx::ColorSpace::PrimaryID::UNSPECIFIED, | |
135 gfx::ColorSpace::TransferID::UNSPECIFIED, | |
136 gfx::ColorSpace::MatrixID::UNSPECIFIED, | |
137 video_full_range_flag | |
138 ? gfx::ColorSpace::RangeID::FULL | |
139 : gfx::ColorSpace::RangeID::LIMITED); | |
140 } | |
141 } | |
142 | |
125 H264PPS::H264PPS() { | 143 H264PPS::H264PPS() { |
126 memset(this, 0, sizeof(*this)); | 144 memset(this, 0, sizeof(*this)); |
127 } | 145 } |
128 | 146 |
129 H264SliceHeader::H264SliceHeader() { | 147 H264SliceHeader::H264SliceHeader() { |
130 memset(this, 0, sizeof(*this)); | 148 memset(this, 0, sizeof(*this)); |
131 } | 149 } |
132 | 150 |
133 H264SEIMessage::H264SEIMessage() { | 151 H264SEIMessage::H264SEIMessage() { |
134 memset(this, 0, sizeof(*this)); | 152 memset(this, 0, sizeof(*this)); |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 sps->sar_height = kTableSarHeight[aspect_ratio_idc]; | 827 sps->sar_height = kTableSarHeight[aspect_ratio_idc]; |
810 } | 828 } |
811 } | 829 } |
812 | 830 |
813 int data; | 831 int data; |
814 // Read and ignore overscan and video signal type info. | 832 // Read and ignore overscan and video signal type info. |
815 READ_BOOL_OR_RETURN(&data); // overscan_info_present_flag | 833 READ_BOOL_OR_RETURN(&data); // overscan_info_present_flag |
816 if (data) | 834 if (data) |
817 READ_BOOL_OR_RETURN(&data); // overscan_appropriate_flag | 835 READ_BOOL_OR_RETURN(&data); // overscan_appropriate_flag |
818 | 836 |
819 READ_BOOL_OR_RETURN(&data); // video_signal_type_present_flag | 837 READ_BOOL_OR_RETURN(&sps->video_signal_type_present_flag); |
820 if (data) { | 838 if (sps->video_signal_type_present_flag) { |
821 READ_BITS_OR_RETURN(3, &data); // video_format | 839 READ_BITS_OR_RETURN(3, &sps->video_format); |
822 READ_BOOL_OR_RETURN(&data); // video_full_range_flag | 840 READ_BOOL_OR_RETURN(&sps->video_full_range_flag); |
823 READ_BOOL_OR_RETURN(&data); // colour_description_present_flag | 841 READ_BOOL_OR_RETURN(&sps->colour_description_present_flag); |
824 if (data) | 842 if (sps->colour_description_present_flag) { |
825 READ_BITS_OR_RETURN(24, &data); // color description syntax elements | 843 // color description syntax elements |
844 READ_BITS_OR_RETURN(8, &sps->colour_primaries); | |
845 READ_BITS_OR_RETURN(8, &sps->transfer_characteristics); | |
846 READ_BITS_OR_RETURN(8, &sps->matrix_coefficients); | |
847 } | |
826 } | 848 } |
827 | 849 |
828 READ_BOOL_OR_RETURN(&data); // chroma_loc_info_present_flag | 850 READ_BOOL_OR_RETURN(&data); // chroma_loc_info_present_flag |
829 if (data) { | 851 if (data) { |
830 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_top_field | 852 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_top_field |
831 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_bottom_field | 853 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_bottom_field |
832 } | 854 } |
833 | 855 |
834 // Read and ignore timing info. | 856 // Read and ignore timing info. |
835 READ_BOOL_OR_RETURN(&data); // timing_info_present_flag | 857 READ_BOOL_OR_RETURN(&data); // timing_info_present_flag |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1458 | 1480 |
1459 default: | 1481 default: |
1460 DVLOG(4) << "Unsupported SEI message"; | 1482 DVLOG(4) << "Unsupported SEI message"; |
1461 break; | 1483 break; |
1462 } | 1484 } |
1463 | 1485 |
1464 return kOk; | 1486 return kOk; |
1465 } | 1487 } |
1466 | 1488 |
1467 } // namespace media | 1489 } // namespace media |
OLD | NEW |