| 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 "media/ffmpeg/ffmpeg_common.h" | 5 #include "media/ffmpeg/ffmpeg_common.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 base::TimeDelta seek_preroll; | 364 base::TimeDelta seek_preroll; |
| 365 if (codec_context->seek_preroll > 0) { | 365 if (codec_context->seek_preroll > 0) { |
| 366 seek_preroll = base::TimeDelta::FromMicroseconds( | 366 seek_preroll = base::TimeDelta::FromMicroseconds( |
| 367 codec_context->seek_preroll * 1000000.0 / codec_context->sample_rate); | 367 codec_context->seek_preroll * 1000000.0 / codec_context->sample_rate); |
| 368 } | 368 } |
| 369 | 369 |
| 370 // AVStream occasionally has invalid extra data. See http://crbug.com/517163 | 370 // AVStream occasionally has invalid extra data. See http://crbug.com/517163 |
| 371 if ((codec_context->extradata_size == 0) != | 371 if ((codec_context->extradata_size == 0) != |
| 372 (codec_context->extradata == nullptr)) { | 372 (codec_context->extradata == nullptr)) { |
| 373 LOG(ERROR) << __FUNCTION__ | 373 LOG(ERROR) << __func__ |
| 374 << (codec_context->extradata == nullptr ? " NULL" : " Non-NULL") | 374 << (codec_context->extradata == nullptr ? " NULL" : " Non-NULL") |
| 375 << " extra data cannot have size of " | 375 << " extra data cannot have size of " |
| 376 << codec_context->extradata_size << "."; | 376 << codec_context->extradata_size << "."; |
| 377 return false; | 377 return false; |
| 378 } | 378 } |
| 379 | 379 |
| 380 std::vector<uint8_t> extra_data; | 380 std::vector<uint8_t> extra_data; |
| 381 if (codec_context->extradata_size > 0) { | 381 if (codec_context->extradata_size > 0) { |
| 382 extra_data.assign(codec_context->extradata, | 382 extra_data.assign(codec_context->extradata, |
| 383 codec_context->extradata + codec_context->extradata_size); | 383 codec_context->extradata + codec_context->extradata_size); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (color_space == COLOR_SPACE_UNSPECIFIED) { | 513 if (color_space == COLOR_SPACE_UNSPECIFIED) { |
| 514 // Otherwise, assume that SD video is usually Rec.601, and HD is usually | 514 // Otherwise, assume that SD video is usually Rec.601, and HD is usually |
| 515 // Rec.709. | 515 // Rec.709. |
| 516 color_space = (natural_size.height() < 720) ? COLOR_SPACE_SD_REC601 | 516 color_space = (natural_size.height() < 720) ? COLOR_SPACE_SD_REC601 |
| 517 : COLOR_SPACE_HD_REC709; | 517 : COLOR_SPACE_HD_REC709; |
| 518 } | 518 } |
| 519 | 519 |
| 520 // AVStream occasionally has invalid extra data. See http://crbug.com/517163 | 520 // AVStream occasionally has invalid extra data. See http://crbug.com/517163 |
| 521 if ((stream->codec->extradata_size == 0) != | 521 if ((stream->codec->extradata_size == 0) != |
| 522 (stream->codec->extradata == nullptr)) { | 522 (stream->codec->extradata == nullptr)) { |
| 523 LOG(ERROR) << __FUNCTION__ | 523 LOG(ERROR) << __func__ |
| 524 << (stream->codec->extradata == nullptr ? " NULL" : " Non-Null") | 524 << (stream->codec->extradata == nullptr ? " NULL" : " Non-Null") |
| 525 << " extra data cannot have size of " | 525 << " extra data cannot have size of " |
| 526 << stream->codec->extradata_size << "."; | 526 << stream->codec->extradata_size << "."; |
| 527 return false; | 527 return false; |
| 528 } | 528 } |
| 529 | 529 |
| 530 std::vector<uint8_t> extra_data; | 530 std::vector<uint8_t> extra_data; |
| 531 if (stream->codec->extradata_size > 0) { | 531 if (stream->codec->extradata_size > 0) { |
| 532 extra_data.assign(stream->codec->extradata, | 532 extra_data.assign(stream->codec->extradata, |
| 533 stream->codec->extradata + stream->codec->extradata_size); | 533 stream->codec->extradata + stream->codec->extradata_size); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 755 } |
| 756 | 756 |
| 757 int32_t HashCodecName(const char* codec_name) { | 757 int32_t HashCodecName(const char* codec_name) { |
| 758 // Use the first 32-bits from the SHA1 hash as the identifier. | 758 // Use the first 32-bits from the SHA1 hash as the identifier. |
| 759 int32_t hash; | 759 int32_t hash; |
| 760 memcpy(&hash, base::SHA1HashString(codec_name).substr(0, 4).c_str(), 4); | 760 memcpy(&hash, base::SHA1HashString(codec_name).substr(0, 4).c_str(), 4); |
| 761 return hash; | 761 return hash; |
| 762 } | 762 } |
| 763 | 763 |
| 764 } // namespace media | 764 } // namespace media |
| OLD | NEW |