Chromium Code Reviews| 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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1079 DVLOG(1) << "frame_mbs_only_flag != 1 not supported"; | 1079 DVLOG(1) << "frame_mbs_only_flag != 1 not supported"; |
| 1080 return false; | 1080 return false; |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 // Calculate picture height/width in macroblocks and pixels | 1083 // Calculate picture height/width in macroblocks and pixels |
| 1084 // (spec 7.4.2.1.1, 7.4.3). | 1084 // (spec 7.4.2.1.1, 7.4.3). |
| 1085 int width_mb = sps->pic_width_in_mbs_minus1 + 1; | 1085 int width_mb = sps->pic_width_in_mbs_minus1 + 1; |
| 1086 int height_mb = (2 - sps->frame_mbs_only_flag) * | 1086 int height_mb = (2 - sps->frame_mbs_only_flag) * |
| 1087 (sps->pic_height_in_map_units_minus1 + 1); | 1087 (sps->pic_height_in_map_units_minus1 + 1); |
| 1088 | 1088 |
| 1089 if (width_mb > std::numeric_limits<int>::max() / 16 || | |
|
Pawel Osciak
2016/04/20 04:22:09
Could we perhaps use:
base::IsValueInRangeForNumer
servolk
2016/04/20 17:32:53
Well, we are actually trying to avoid integer over
Pawel Osciak
2016/04/21 01:03:53
Yes, unless the result was of a larger type:
int a
servolk
2016/04/21 01:24:06
First of all, you probably meant 16ull, as 16u is
| |
| 1090 height_mb > std::numeric_limits<int>::max() / 16) { | |
| 1091 DVLOG(1) << "Picture size is too big: width_mb=" << width_mb | |
| 1092 << " height_mb=" << height_mb; | |
| 1093 return false; | |
| 1094 } | |
| 1095 | |
| 1089 gfx::Size new_pic_size(16 * width_mb, 16 * height_mb); | 1096 gfx::Size new_pic_size(16 * width_mb, 16 * height_mb); |
| 1090 if (new_pic_size.IsEmpty()) { | 1097 if (new_pic_size.IsEmpty()) { |
| 1091 DVLOG(1) << "Invalid picture size: " << new_pic_size.ToString(); | 1098 DVLOG(1) << "Invalid picture size: " << new_pic_size.ToString(); |
| 1092 return false; | 1099 return false; |
| 1093 } | 1100 } |
| 1094 | 1101 |
| 1095 if (!pic_size_.IsEmpty() && new_pic_size == pic_size_) { | 1102 if (!pic_size_.IsEmpty() && new_pic_size == pic_size_) { |
| 1096 // Already have surfaces and this SPS keeps the same resolution, | 1103 // Already have surfaces and this SPS keeps the same resolution, |
| 1097 // no need to request a new set. | 1104 // no need to request a new set. |
| 1098 return true; | 1105 return true; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1414 | 1421 |
| 1415 gfx::Size H264Decoder::GetPicSize() const { | 1422 gfx::Size H264Decoder::GetPicSize() const { |
| 1416 return pic_size_; | 1423 return pic_size_; |
| 1417 } | 1424 } |
| 1418 | 1425 |
| 1419 size_t H264Decoder::GetRequiredNumOfPictures() const { | 1426 size_t H264Decoder::GetRequiredNumOfPictures() const { |
| 1420 return dpb_.max_num_pics() + kPicsInPipeline; | 1427 return dpb_.max_num_pics() + kPicsInPipeline; |
| 1421 } | 1428 } |
| 1422 | 1429 |
| 1423 } // namespace content | 1430 } // namespace content |
| OLD | NEW |