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

Unified Diff: media/formats/mp2t/es_parser_h264.cc

Issue 2268183009: H264SPS: Centralize computation of coded size and visible rect. (Closed)
Patch Set: Make sure fuzzing code actually runs. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/h264_parser_unittest.cc ('k') | media/gpu/h264_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mp2t/es_parser_h264.cc
diff --git a/media/formats/mp2t/es_parser_h264.cc b/media/formats/mp2t/es_parser_h264.cc
index c074d544356fb581f3369d2c528f19ddbc14ccd8..89d7c4c285d9d778b738b7381c0417713a291433 100644
--- a/media/formats/mp2t/es_parser_h264.cc
+++ b/media/formats/mp2t/es_parser_h264.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/optional.h"
#include "media/base/encryption_scheme.h"
#include "media/base/media_util.h"
#include "media/base/stream_parser_buffer.h"
@@ -261,48 +262,34 @@ bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps,
int sar_width = (sps->sar_width == 0) ? 1 : sps->sar_width;
int sar_height = (sps->sar_height == 0) ? 1 : sps->sar_height;
- // TODO(damienv): a MAP unit can be either 16 or 32 pixels.
- // although it's 16 pixels for progressive non MBAFF frames.
- int width_mb = sps->pic_width_in_mbs_minus1 + 1;
- int height_mb = sps->pic_height_in_map_units_minus1 + 1;
- if (width_mb > std::numeric_limits<int>::max() / 16 ||
- height_mb > std::numeric_limits<int>::max() / 16) {
- DVLOG(1) << "Picture size is too big: width_mb=" << width_mb
- << " height_mb=" << height_mb;
+ base::Optional<gfx::Size> coded_size = sps->GetCodedSize();
+ if (!coded_size)
return false;
- }
- gfx::Size coded_size(16 * width_mb, 16 * height_mb);
- gfx::Rect visible_rect(
- sps->frame_crop_left_offset,
- sps->frame_crop_top_offset,
- (coded_size.width() - sps->frame_crop_right_offset) -
- sps->frame_crop_left_offset,
- (coded_size.height() - sps->frame_crop_bottom_offset) -
- sps->frame_crop_top_offset);
- if (visible_rect.width() <= 0 || visible_rect.height() <= 0)
+ base::Optional<gfx::Rect> visible_rect = sps->GetVisibleRect();
+ if (!visible_rect)
return false;
- if (visible_rect.width() > std::numeric_limits<int>::max() / sar_width) {
+
+ if (visible_rect->width() > std::numeric_limits<int>::max() / sar_width) {
DVLOG(1) << "Integer overflow detected: visible_rect.width()="
- << visible_rect.width() << " sar_width=" << sar_width;
+ << visible_rect->width() << " sar_width=" << sar_width;
return false;
}
- gfx::Size natural_size(
- (visible_rect.width() * sar_width) / sar_height,
- visible_rect.height());
+ gfx::Size natural_size((visible_rect->width() * sar_width) / sar_height,
+ visible_rect->height());
if (natural_size.width() == 0)
return false;
VideoDecoderConfig video_decoder_config(
kCodecH264, H264Parser::ProfileIDCToVideoCodecProfile(sps->profile_idc),
- PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, coded_size, visible_rect,
- natural_size, EmptyExtraData(), scheme);
+ PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, coded_size.value(),
+ visible_rect.value(), natural_size, EmptyExtraData(), scheme);
if (!video_decoder_config.Matches(last_video_decoder_config_)) {
DVLOG(1) << "Profile IDC: " << sps->profile_idc;
DVLOG(1) << "Level IDC: " << sps->level_idc;
- DVLOG(1) << "Pic width: " << coded_size.width();
- DVLOG(1) << "Pic height: " << coded_size.height();
+ DVLOG(1) << "Pic width: " << coded_size->width();
+ DVLOG(1) << "Pic height: " << coded_size->height();
DVLOG(1) << "log2_max_frame_num_minus4: "
<< sps->log2_max_frame_num_minus4;
DVLOG(1) << "SAR: width=" << sps->sar_width
« no previous file with comments | « media/filters/h264_parser_unittest.cc ('k') | media/gpu/h264_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698