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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 | 8 |
9 #include "media/filters/h264_parser.h" | 9 #include "media/filters/h264_parser.h" |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } while (0) | 99 } while (0) |
100 | 100 |
101 #define TRUE_OR_RETURN(a) \ | 101 #define TRUE_OR_RETURN(a) \ |
102 do { \ | 102 do { \ |
103 if (!(a)) { \ | 103 if (!(a)) { \ |
104 DVLOG(1) << "Error in stream: invalid value, expected " << #a; \ | 104 DVLOG(1) << "Error in stream: invalid value, expected " << #a; \ |
105 return kInvalidStream; \ | 105 return kInvalidStream; \ |
106 } \ | 106 } \ |
107 } while (0) | 107 } while (0) |
108 | 108 |
109 enum AspectRatioIdc { | |
110 kExtendedSar = 255, | |
111 }; | |
112 | |
113 // ISO 14496 part 10 | 109 // ISO 14496 part 10 |
114 // VUI parameters: Table E-1 "Meaning of sample aspect ratio indicator" | 110 // VUI parameters: Table E-1 "Meaning of sample aspect ratio indicator" |
115 static const int kTableSarWidth[] = { | 111 static const int kTableSarWidth[] = { |
116 0, 1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2 | 112 0, 1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2 |
117 }; | 113 }; |
118 static const int kTableSarHeight[] = { | 114 static const int kTableSarHeight[] = { |
119 0, 1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1 | 115 0, 1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1 |
120 }; | 116 }; |
121 COMPILE_ASSERT(arraysize(kTableSarWidth) == arraysize(kTableSarHeight), | 117 COMPILE_ASSERT(arraysize(kTableSarWidth) == arraysize(kTableSarHeight), |
122 sar_tables_must_have_same_size); | 118 sar_tables_must_have_same_size); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 597 |
602 return kOk; | 598 return kOk; |
603 } | 599 } |
604 | 600 |
605 H264Parser::Result H264Parser::ParseVUIParameters(H264SPS* sps) { | 601 H264Parser::Result H264Parser::ParseVUIParameters(H264SPS* sps) { |
606 bool aspect_ratio_info_present_flag; | 602 bool aspect_ratio_info_present_flag; |
607 READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag); | 603 READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag); |
608 if (aspect_ratio_info_present_flag) { | 604 if (aspect_ratio_info_present_flag) { |
609 int aspect_ratio_idc; | 605 int aspect_ratio_idc; |
610 READ_BITS_OR_RETURN(8, &aspect_ratio_idc); | 606 READ_BITS_OR_RETURN(8, &aspect_ratio_idc); |
611 if (aspect_ratio_idc == kExtendedSar) { | 607 if (aspect_ratio_idc == H264SPS::kExtendedSar) { |
612 READ_BITS_OR_RETURN(16, &sps->sar_width); | 608 READ_BITS_OR_RETURN(16, &sps->sar_width); |
613 READ_BITS_OR_RETURN(16, &sps->sar_height); | 609 READ_BITS_OR_RETURN(16, &sps->sar_height); |
614 } else { | 610 } else { |
615 const int max_aspect_ratio_idc = arraysize(kTableSarWidth) - 1; | 611 const int max_aspect_ratio_idc = arraysize(kTableSarWidth) - 1; |
616 IN_RANGE_OR_RETURN(aspect_ratio_idc, 0, max_aspect_ratio_idc); | 612 IN_RANGE_OR_RETURN(aspect_ratio_idc, 0, max_aspect_ratio_idc); |
617 sps->sar_width = kTableSarWidth[aspect_ratio_idc]; | 613 sps->sar_width = kTableSarWidth[aspect_ratio_idc]; |
618 sps->sar_height = kTableSarHeight[aspect_ratio_idc]; | 614 sps->sar_height = kTableSarHeight[aspect_ratio_idc]; |
619 } | 615 } |
620 } | 616 } |
621 | 617 |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 | 1251 |
1256 default: | 1252 default: |
1257 DVLOG(4) << "Unsupported SEI message"; | 1253 DVLOG(4) << "Unsupported SEI message"; |
1258 break; | 1254 break; |
1259 } | 1255 } |
1260 | 1256 |
1261 return kOk; | 1257 return kOk; |
1262 } | 1258 } |
1263 | 1259 |
1264 } // namespace media | 1260 } // namespace media |
OLD | NEW |