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