Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/formats/mp2t/es_parser_h264.h" | 5 #include "media/formats/mp2t/es_parser_h264.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "media/base/stream_parser_buffer.h" | 9 #include "media/base/stream_parser_buffer.h" |
| 10 #include "media/base/timestamp_constants.h" | 10 #include "media/base/timestamp_constants.h" |
| 11 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
| 12 #include "media/filters/h264_parser.h" | 12 #include "media/filters/h264_parser.h" |
| 13 #include "media/formats/common/offset_byte_queue.h" | 13 #include "media/formats/common/offset_byte_queue.h" |
| 14 #include "media/formats/mp2t/mp2t_common.h" | 14 #include "media/formats/mp2t/mp2t_common.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 namespace mp2t { | 19 namespace mp2t { |
| 20 | 20 |
| 21 namespace { | |
| 22 | |
| 23 VideoCodecProfile ProfileIDCToVideoCodecProfile(int profile_idc) { | |
| 24 switch (profile_idc) { | |
| 25 case H264SPS::kProfileIDCBaseline: | |
| 26 return H264PROFILE_BASELINE; | |
| 27 case H264SPS::kProfileIDCMain: | |
| 28 return H264PROFILE_MAIN; | |
| 29 case H264SPS::kProfileIDCHigh: | |
| 30 return H264PROFILE_HIGH; | |
| 31 case H264SPS::kProfileIDHigh10: | |
| 32 return H264PROFILE_HIGH10PROFILE; | |
| 33 case H264SPS::kProfileIDHigh422: | |
| 34 return H264PROFILE_HIGH422PROFILE; | |
| 35 case H264SPS::kProfileIDHigh444Predictive: | |
| 36 return H264PROFILE_HIGH444PREDICTIVEPROFILE; | |
| 37 case H264SPS::kProfileIDScalableBaseline: | |
| 38 return H264PROFILE_SCALABLEBASELINE; | |
| 39 case H264SPS::kProfileIDScalableHigh: | |
| 40 return H264PROFILE_SCALABLEHIGH; | |
| 41 case H264SPS::kProfileIDStereoHigh: | |
| 42 return H264PROFILE_STEREOHIGH; | |
| 43 case H264SPS::kProfileIDSMultiviewHigh: | |
| 44 return H264PROFILE_MULTIVIEWHIGH; | |
| 45 default: | |
| 46 DVLOG(1) << "unknown video profile: " << profile_idc; | |
| 47 } | |
| 48 return VIDEO_CODEC_PROFILE_UNKNOWN; | |
|
xhwang
2016/01/26 17:18:50
nit:
Remove the default so that if this list is n
erickung1
2016/01/26 19:44:34
Done.
| |
| 49 } | |
| 50 | |
| 51 } // namespace | |
| 52 | |
| 21 // An AUD NALU is at least 4 bytes: | 53 // An AUD NALU is at least 4 bytes: |
| 22 // 3 bytes for the start code + 1 byte for the NALU type. | 54 // 3 bytes for the start code + 1 byte for the NALU type. |
| 23 const int kMinAUDSize = 4; | 55 const int kMinAUDSize = 4; |
| 24 | 56 |
| 25 EsParserH264::EsParserH264( | 57 EsParserH264::EsParserH264( |
| 26 const NewVideoConfigCB& new_video_config_cb, | 58 const NewVideoConfigCB& new_video_config_cb, |
| 27 const EmitBufferCB& emit_buffer_cb) | 59 const EmitBufferCB& emit_buffer_cb) |
| 28 : es_adapter_(new_video_config_cb, emit_buffer_cb), | 60 : es_adapter_(new_video_config_cb, emit_buffer_cb), |
| 29 h264_parser_(new H264Parser()), | 61 h264_parser_(new H264Parser()), |
| 30 current_access_unit_pos_(0), | 62 current_access_unit_pos_(0), |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 sps->frame_crop_top_offset); | 306 sps->frame_crop_top_offset); |
| 275 if (visible_rect.width() <= 0 || visible_rect.height() <= 0) | 307 if (visible_rect.width() <= 0 || visible_rect.height() <= 0) |
| 276 return false; | 308 return false; |
| 277 gfx::Size natural_size( | 309 gfx::Size natural_size( |
| 278 (visible_rect.width() * sar_width) / sar_height, | 310 (visible_rect.width() * sar_width) / sar_height, |
| 279 visible_rect.height()); | 311 visible_rect.height()); |
| 280 if (natural_size.width() == 0) | 312 if (natural_size.width() == 0) |
| 281 return false; | 313 return false; |
| 282 | 314 |
| 283 VideoDecoderConfig video_decoder_config( | 315 VideoDecoderConfig video_decoder_config( |
| 284 kCodecH264, VIDEO_CODEC_PROFILE_UNKNOWN, PIXEL_FORMAT_YV12, | 316 kCodecH264, ProfileIDCToVideoCodecProfile(sps->profile_idc), |
| 285 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, | 317 PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, coded_size, visible_rect, |
| 286 std::vector<uint8_t>(), false); | 318 natural_size, std::vector<uint8_t>(), false); |
| 287 | 319 |
| 288 if (!video_decoder_config.Matches(last_video_decoder_config_)) { | 320 if (!video_decoder_config.Matches(last_video_decoder_config_)) { |
| 289 DVLOG(1) << "Profile IDC: " << sps->profile_idc; | 321 DVLOG(1) << "Profile IDC: " << sps->profile_idc; |
| 290 DVLOG(1) << "Level IDC: " << sps->level_idc; | 322 DVLOG(1) << "Level IDC: " << sps->level_idc; |
| 291 DVLOG(1) << "Pic width: " << coded_size.width(); | 323 DVLOG(1) << "Pic width: " << coded_size.width(); |
| 292 DVLOG(1) << "Pic height: " << coded_size.height(); | 324 DVLOG(1) << "Pic height: " << coded_size.height(); |
| 293 DVLOG(1) << "log2_max_frame_num_minus4: " | 325 DVLOG(1) << "log2_max_frame_num_minus4: " |
| 294 << sps->log2_max_frame_num_minus4; | 326 << sps->log2_max_frame_num_minus4; |
| 295 DVLOG(1) << "SAR: width=" << sps->sar_width | 327 DVLOG(1) << "SAR: width=" << sps->sar_width |
| 296 << " height=" << sps->sar_height; | 328 << " height=" << sps->sar_height; |
| 297 last_video_decoder_config_ = video_decoder_config; | 329 last_video_decoder_config_ = video_decoder_config; |
| 298 es_adapter_.OnConfigChanged(video_decoder_config); | 330 es_adapter_.OnConfigChanged(video_decoder_config); |
| 299 } | 331 } |
| 300 | 332 |
| 301 return true; | 333 return true; |
| 302 } | 334 } |
| 303 | 335 |
| 304 } // namespace mp2t | 336 } // namespace mp2t |
| 305 } // namespace media | 337 } // namespace media |
| OLD | NEW |