Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: media/gpu/h264_decoder.cc

Issue 2268183009: H264SPS: Centralize computation of coded size and visible rect. (Closed)
Patch Set: Make sure fuzzing code actually runs. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/formats/mp2t/es_parser_h264.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/numerics/safe_conversions.h" 12 #include "base/numerics/safe_conversions.h"
13 #include "base/optional.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "media/gpu/h264_decoder.h" 15 #include "media/gpu/h264_decoder.h"
15 16
16 namespace media { 17 namespace media {
17 18
18 H264Decoder::H264Accelerator::H264Accelerator() {} 19 H264Decoder::H264Accelerator::H264Accelerator() {}
19 20
20 H264Decoder::H264Accelerator::~H264Accelerator() {} 21 H264Decoder::H264Accelerator::~H264Accelerator() {}
21 22
22 H264Decoder::H264Decoder(H264Accelerator* accelerator) 23 H264Decoder::H264Decoder(H264Accelerator* accelerator)
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 if (!sps) 1080 if (!sps)
1080 return false; 1081 return false;
1081 1082
1082 *need_new_buffers = false; 1083 *need_new_buffers = false;
1083 1084
1084 if (sps->frame_mbs_only_flag == 0) { 1085 if (sps->frame_mbs_only_flag == 0) {
1085 DVLOG(1) << "frame_mbs_only_flag != 1 not supported"; 1086 DVLOG(1) << "frame_mbs_only_flag != 1 not supported";
1086 return false; 1087 return false;
1087 } 1088 }
1088 1089
1089 // Calculate picture height/width in macroblocks and pixels 1090 gfx::Size new_pic_size = sps->GetCodedSize().value_or(gfx::Size());
1090 // (spec 7.4.2.1.1, 7.4.3). 1091 if (new_pic_size.IsEmpty()) {
1091 int width_mb = sps->pic_width_in_mbs_minus1 + 1; 1092 DVLOG(1) << "Invalid picture size";
1092 int height_mb = (2 - sps->frame_mbs_only_flag) *
1093 (sps->pic_height_in_map_units_minus1 + 1);
1094
1095 if (width_mb > std::numeric_limits<int>::max() / 16 ||
1096 height_mb > std::numeric_limits<int>::max() / 16) {
1097 DVLOG(1) << "Picture size is too big: width_mb=" << width_mb
1098 << " height_mb=" << height_mb;
1099 return false; 1093 return false;
1100 } 1094 }
1101 1095
1102 gfx::Size new_pic_size(16 * width_mb, 16 * height_mb); 1096 int width_mb = new_pic_size.width() / 16;
1103 if (new_pic_size.IsEmpty()) { 1097 int height_mb = new_pic_size.height() / 16;
1104 DVLOG(1) << "Invalid picture size: " << new_pic_size.ToString(); 1098
1099 // Verify that the values are not too large before multiplying.
1100 if (std::numeric_limits<int>::max() / width_mb < height_mb) {
1101 DVLOG(1) << "Picture size is too big: " << new_pic_size.ToString();
1105 return false; 1102 return false;
1106 } 1103 }
1107 1104
1108 if (!pic_size_.IsEmpty() && new_pic_size == pic_size_) { 1105 if (new_pic_size == pic_size_) {
1109 // Already have surfaces and this SPS keeps the same resolution, 1106 // Already have surfaces and this SPS keeps the same resolution,
1110 // no need to request a new set. 1107 // no need to request a new set.
1111 return true; 1108 return true;
1112 } 1109 }
1113 1110
1114 pic_size_ = new_pic_size; 1111 pic_size_ = new_pic_size;
1115 DVLOG(1) << "New picture size: " << pic_size_.ToString(); 1112 DVLOG(1) << "New picture size: " << pic_size_.ToString();
1116 1113
1117 int level = sps->level_idc; 1114 int level = sps->level_idc;
1118 int max_dpb_mbs = LevelToMaxDpbMbs(level); 1115 int max_dpb_mbs = LevelToMaxDpbMbs(level);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 1433
1437 gfx::Size H264Decoder::GetPicSize() const { 1434 gfx::Size H264Decoder::GetPicSize() const {
1438 return pic_size_; 1435 return pic_size_;
1439 } 1436 }
1440 1437
1441 size_t H264Decoder::GetRequiredNumOfPictures() const { 1438 size_t H264Decoder::GetRequiredNumOfPictures() const {
1442 return dpb_.max_num_pics() + kPicsInPipeline; 1439 return dpb_.max_num_pics() + kPicsInPipeline;
1443 } 1440 }
1444 1441
1445 } // namespace media 1442 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_h264.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698