OLD | NEW |
---|---|
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 <algorithm> | 5 #include <algorithm> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1086 DVLOG(1) << "frame_mbs_only_flag != 1 not supported"; | 1086 DVLOG(1) << "frame_mbs_only_flag != 1 not supported"; |
1087 return false; | 1087 return false; |
1088 } | 1088 } |
1089 | 1089 |
1090 gfx::Size new_pic_size = sps->GetCodedSize().value_or(gfx::Size()); | 1090 gfx::Size new_pic_size = sps->GetCodedSize().value_or(gfx::Size()); |
1091 if (new_pic_size.IsEmpty()) { | 1091 if (new_pic_size.IsEmpty()) { |
1092 DVLOG(1) << "Invalid picture size"; | 1092 DVLOG(1) << "Invalid picture size"; |
1093 return false; | 1093 return false; |
1094 } | 1094 } |
1095 | 1095 |
1096 gfx::Rect new_visible_rect = sps->GetVisibleRect().value_or(gfx::Rect()); | |
1097 if (new_visible_rect.IsEmpty()) { | |
Owen Lin
2017/06/07 06:10:59
I think we shouldn't fail in the case. We can stil
kcwu
2017/06/07 07:15:27
Maybe check what spec say how to handle invalid si
johnylin1
2017/06/07 15:38:37
In H264Parser::GetVisibleRect() it already checked
| |
1098 DVLOG(1) << "Invalid visible rect"; | |
1099 return false; | |
1100 } | |
1101 | |
1096 int width_mb = new_pic_size.width() / 16; | 1102 int width_mb = new_pic_size.width() / 16; |
1097 int height_mb = new_pic_size.height() / 16; | 1103 int height_mb = new_pic_size.height() / 16; |
1098 | 1104 |
1099 // Verify that the values are not too large before multiplying. | 1105 // Verify that the values are not too large before multiplying. |
1100 if (std::numeric_limits<int>::max() / width_mb < height_mb) { | 1106 if (std::numeric_limits<int>::max() / width_mb < height_mb) { |
1101 DVLOG(1) << "Picture size is too big: " << new_pic_size.ToString(); | 1107 DVLOG(1) << "Picture size is too big: " << new_pic_size.ToString(); |
1102 return false; | 1108 return false; |
1103 } | 1109 } |
1104 | 1110 |
1105 int level = sps->level_idc; | 1111 int level = sps->level_idc; |
1106 int max_dpb_mbs = LevelToMaxDpbMbs(level); | 1112 int max_dpb_mbs = LevelToMaxDpbMbs(level); |
1107 if (max_dpb_mbs == 0) | 1113 if (max_dpb_mbs == 0) |
1108 return false; | 1114 return false; |
1109 | 1115 |
1110 size_t max_dpb_size = std::min(max_dpb_mbs / (width_mb * height_mb), | 1116 size_t max_dpb_size = std::min(max_dpb_mbs / (width_mb * height_mb), |
1111 static_cast<int>(H264DPB::kDPBMaxSize)); | 1117 static_cast<int>(H264DPB::kDPBMaxSize)); |
1112 if (max_dpb_size == 0) { | 1118 if (max_dpb_size == 0) { |
1113 DVLOG(1) << "Invalid DPB Size"; | 1119 DVLOG(1) << "Invalid DPB Size"; |
1114 return false; | 1120 return false; |
1115 } | 1121 } |
1116 | 1122 |
1117 if ((pic_size_ != new_pic_size) || (dpb_.max_num_pics() != max_dpb_size)) { | 1123 if ((pic_size_ != new_pic_size) || (visible_rect_ != new_visible_rect) || |
Owen Lin
2017/06/07 06:10:59
We don't care about visible rect change here. Mayb
johnylin1
2017/06/07 15:38:37
Done.
| |
1124 (dpb_.max_num_pics() != max_dpb_size)) { | |
1118 if (!Flush()) | 1125 if (!Flush()) |
1119 return false; | 1126 return false; |
1120 DVLOG(1) << "Codec level: " << level << ", DPB size: " << max_dpb_size | 1127 DVLOG(1) << "Codec level: " << level << ", DPB size: " << max_dpb_size |
1121 << ", Picture size: " << new_pic_size.ToString(); | 1128 << ", Picture size: " << new_pic_size.ToString() |
1129 << ", Visible rect: " << new_visible_rect.ToString(); | |
1122 *need_new_buffers = true; | 1130 *need_new_buffers = true; |
1123 pic_size_ = new_pic_size; | 1131 pic_size_ = new_pic_size; |
1132 visible_rect_ = new_visible_rect; | |
1124 dpb_.set_max_num_pics(max_dpb_size); | 1133 dpb_.set_max_num_pics(max_dpb_size); |
1125 } | 1134 } |
1126 | 1135 |
1127 if (!UpdateMaxNumReorderFrames(sps)) | 1136 if (!UpdateMaxNumReorderFrames(sps)) |
1128 return false; | 1137 return false; |
1129 DVLOG(1) << "max_num_reorder_frames: " << max_num_reorder_frames_; | 1138 DVLOG(1) << "max_num_reorder_frames: " << max_num_reorder_frames_; |
1130 | 1139 |
1131 return true; | 1140 return true; |
1132 } | 1141 } |
1133 | 1142 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1422 | 1431 |
1423 DVLOG(4) << "NALU done"; | 1432 DVLOG(4) << "NALU done"; |
1424 curr_nalu_.reset(); | 1433 curr_nalu_.reset(); |
1425 } | 1434 } |
1426 } | 1435 } |
1427 | 1436 |
1428 gfx::Size H264Decoder::GetPicSize() const { | 1437 gfx::Size H264Decoder::GetPicSize() const { |
1429 return pic_size_; | 1438 return pic_size_; |
1430 } | 1439 } |
1431 | 1440 |
1441 gfx::Rect H264Decoder::GetVisibleRect() const { | |
1442 return visible_rect_; | |
1443 } | |
1444 | |
1432 size_t H264Decoder::GetRequiredNumOfPictures() const { | 1445 size_t H264Decoder::GetRequiredNumOfPictures() const { |
1433 return dpb_.max_num_pics() + kPicsInPipeline; | 1446 return dpb_.max_num_pics() + kPicsInPipeline; |
1434 } | 1447 } |
1435 | 1448 |
1436 } // namespace media | 1449 } // namespace media |
OLD | NEW |