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/base/decrypt_config.h" | 9 #include "media/base/decrypt_config.h" |
10 #include "media/filters/h264_parser.h" | 10 #include "media/filters/h264_parser.h" |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 shdr->chroma_log2_weight_denom, | 1078 shdr->chroma_log2_weight_denom, |
1079 &shdr->pred_weight_table_l1); | 1079 &shdr->pred_weight_table_l1); |
1080 if (res != kOk) | 1080 if (res != kOk) |
1081 return res; | 1081 return res; |
1082 } | 1082 } |
1083 | 1083 |
1084 return kOk; | 1084 return kOk; |
1085 } | 1085 } |
1086 | 1086 |
1087 H264Parser::Result H264Parser::ParseDecRefPicMarking(H264SliceHeader* shdr) { | 1087 H264Parser::Result H264Parser::ParseDecRefPicMarking(H264SliceHeader* shdr) { |
1088 size_t bits_left_at_start = br_.NumBitsLeft(); | |
1089 | |
1090 if (shdr->idr_pic_flag) { | 1088 if (shdr->idr_pic_flag) { |
1091 READ_BOOL_OR_RETURN(&shdr->no_output_of_prior_pics_flag); | 1089 READ_BOOL_OR_RETURN(&shdr->no_output_of_prior_pics_flag); |
1092 READ_BOOL_OR_RETURN(&shdr->long_term_reference_flag); | 1090 READ_BOOL_OR_RETURN(&shdr->long_term_reference_flag); |
1093 } else { | 1091 } else { |
1094 READ_BOOL_OR_RETURN(&shdr->adaptive_ref_pic_marking_mode_flag); | 1092 READ_BOOL_OR_RETURN(&shdr->adaptive_ref_pic_marking_mode_flag); |
1095 | 1093 |
1096 H264DecRefPicMarking* marking; | 1094 H264DecRefPicMarking* marking; |
1097 if (shdr->adaptive_ref_pic_marking_mode_flag) { | 1095 if (shdr->adaptive_ref_pic_marking_mode_flag) { |
1098 size_t i; | 1096 size_t i; |
1099 for (i = 0; i < arraysize(shdr->ref_pic_marking); ++i) { | 1097 for (i = 0; i < arraysize(shdr->ref_pic_marking); ++i) { |
(...skipping 21 matching lines...) Expand all Loading... |
1121 return kInvalidStream; | 1119 return kInvalidStream; |
1122 } | 1120 } |
1123 | 1121 |
1124 if (i == arraysize(shdr->ref_pic_marking)) { | 1122 if (i == arraysize(shdr->ref_pic_marking)) { |
1125 DVLOG(1) << "Ran out of dec ref pic marking fields"; | 1123 DVLOG(1) << "Ran out of dec ref pic marking fields"; |
1126 return kUnsupportedStream; | 1124 return kUnsupportedStream; |
1127 } | 1125 } |
1128 } | 1126 } |
1129 } | 1127 } |
1130 | 1128 |
1131 shdr->dec_ref_pic_marking_bit_size = bits_left_at_start - br_.NumBitsLeft(); | |
1132 return kOk; | 1129 return kOk; |
1133 } | 1130 } |
1134 | 1131 |
1135 H264Parser::Result H264Parser::ParseSliceHeader(const H264NALU& nalu, | 1132 H264Parser::Result H264Parser::ParseSliceHeader(const H264NALU& nalu, |
1136 H264SliceHeader* shdr) { | 1133 H264SliceHeader* shdr) { |
1137 // See 7.4.3. | 1134 // See 7.4.3. |
1138 const H264SPS* sps; | 1135 const H264SPS* sps; |
1139 const H264PPS* pps; | 1136 const H264PPS* pps; |
1140 Result res; | 1137 Result res; |
1141 | 1138 |
(...skipping 26 matching lines...) Expand all Loading... |
1168 READ_BOOL_OR_RETURN(&shdr->field_pic_flag); | 1165 READ_BOOL_OR_RETURN(&shdr->field_pic_flag); |
1169 if (shdr->field_pic_flag) { | 1166 if (shdr->field_pic_flag) { |
1170 DVLOG(1) << "Interlaced streams not supported"; | 1167 DVLOG(1) << "Interlaced streams not supported"; |
1171 return kUnsupportedStream; | 1168 return kUnsupportedStream; |
1172 } | 1169 } |
1173 } | 1170 } |
1174 | 1171 |
1175 if (shdr->idr_pic_flag) | 1172 if (shdr->idr_pic_flag) |
1176 READ_UE_OR_RETURN(&shdr->idr_pic_id); | 1173 READ_UE_OR_RETURN(&shdr->idr_pic_id); |
1177 | 1174 |
1178 size_t bits_left_at_pic_order_cnt_start = br_.NumBitsLeft(); | |
1179 if (sps->pic_order_cnt_type == 0) { | 1175 if (sps->pic_order_cnt_type == 0) { |
1180 READ_BITS_OR_RETURN(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, | 1176 READ_BITS_OR_RETURN(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, |
1181 &shdr->pic_order_cnt_lsb); | 1177 &shdr->pic_order_cnt_lsb); |
1182 if (pps->bottom_field_pic_order_in_frame_present_flag && | 1178 if (pps->bottom_field_pic_order_in_frame_present_flag && |
1183 !shdr->field_pic_flag) | 1179 !shdr->field_pic_flag) |
1184 READ_SE_OR_RETURN(&shdr->delta_pic_order_cnt_bottom); | 1180 READ_SE_OR_RETURN(&shdr->delta_pic_order_cnt_bottom); |
1185 } | 1181 } |
1186 | 1182 |
1187 if (sps->pic_order_cnt_type == 1 && !sps->delta_pic_order_always_zero_flag) { | 1183 if (sps->pic_order_cnt_type == 1 && !sps->delta_pic_order_always_zero_flag) { |
1188 READ_SE_OR_RETURN(&shdr->delta_pic_order_cnt0); | 1184 READ_SE_OR_RETURN(&shdr->delta_pic_order_cnt[0]); |
1189 if (pps->bottom_field_pic_order_in_frame_present_flag && | 1185 if (pps->bottom_field_pic_order_in_frame_present_flag && |
1190 !shdr->field_pic_flag) | 1186 !shdr->field_pic_flag) |
1191 READ_SE_OR_RETURN(&shdr->delta_pic_order_cnt1); | 1187 READ_SE_OR_RETURN(&shdr->delta_pic_order_cnt[1]); |
1192 } | 1188 } |
1193 | 1189 |
1194 shdr->pic_order_cnt_bit_size = | |
1195 bits_left_at_pic_order_cnt_start - br_.NumBitsLeft(); | |
1196 | |
1197 if (pps->redundant_pic_cnt_present_flag) { | 1190 if (pps->redundant_pic_cnt_present_flag) { |
1198 READ_UE_OR_RETURN(&shdr->redundant_pic_cnt); | 1191 READ_UE_OR_RETURN(&shdr->redundant_pic_cnt); |
1199 TRUE_OR_RETURN(shdr->redundant_pic_cnt < 128); | 1192 TRUE_OR_RETURN(shdr->redundant_pic_cnt < 128); |
1200 } | 1193 } |
1201 | 1194 |
1202 if (shdr->IsBSlice()) | 1195 if (shdr->IsBSlice()) |
1203 READ_BOOL_OR_RETURN(&shdr->direct_spatial_mv_pred_flag); | 1196 READ_BOOL_OR_RETURN(&shdr->direct_spatial_mv_pred_flag); |
1204 | 1197 |
1205 if (shdr->IsPSlice() || shdr->IsSPSlice() || shdr->IsBSlice()) { | 1198 if (shdr->IsPSlice() || shdr->IsSPSlice() || shdr->IsBSlice()) { |
1206 READ_BOOL_OR_RETURN(&shdr->num_ref_idx_active_override_flag); | 1199 READ_BOOL_OR_RETURN(&shdr->num_ref_idx_active_override_flag); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 | 1309 |
1317 default: | 1310 default: |
1318 DVLOG(4) << "Unsupported SEI message"; | 1311 DVLOG(4) << "Unsupported SEI message"; |
1319 break; | 1312 break; |
1320 } | 1313 } |
1321 | 1314 |
1322 return kOk; | 1315 return kOk; |
1323 } | 1316 } |
1324 | 1317 |
1325 } // namespace media | 1318 } // namespace media |
OLD | NEW |