| 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
|
|
|