Index: media/filters/ffmpeg_demuxer.cc |
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc |
index e33bada6f1b74043169fdedf0510b91856949267..e9e2303f923f3555521e3953df5f47f4864ed8b3 100644 |
--- a/media/filters/ffmpeg_demuxer.cc |
+++ b/media/filters/ffmpeg_demuxer.cc |
@@ -519,10 +519,8 @@ void FFmpegDemuxer::InitializeTask(DataSource* data_source, |
std::max(max_duration, |
ConvertFromTimeBase(av_time_base, format_context_->duration)); |
} else { |
- // The duration is not a valid value. Assume that this is a live stream |
- // and set duration to the maximum int64 number to represent infinity. |
- max_duration = base::TimeDelta::FromMicroseconds( |
- Limits::kMaxTimeInMicroseconds); |
+ // The duration is unknown, in which case this is likely a live stream. |
+ max_duration = base::TimeDelta::FromMicroseconds(limits::kInfiniteDuration); |
} |
// Some demuxers, like WAV, do not put timestamps on their frames. We |
@@ -559,17 +557,19 @@ int FFmpegDemuxer::GetBitrate() { |
if (bitrate > 0) |
return bitrate; |
- // If there isn't a bitrate set in the container or streams, but there is a |
- // valid duration, approximate the bitrate using the duration. |
- if (max_duration_.InMilliseconds() > 0 && |
- max_duration_.InMicroseconds() < Limits::kMaxTimeInMicroseconds) { |
- int64 filesize_in_bytes; |
- if (GetSize(&filesize_in_bytes)) |
- return 8000 * filesize_in_bytes / max_duration_.InMilliseconds(); |
- } |
+ // See if we can approximate the bitrate as long as we have a filesize and |
+ // valid duration. |
+ int64 filesize_in_bytes; |
+ if (max_duration_.InMicroseconds() <= 0 || |
+ max_duration_.InMicroseconds() == limits::kInfiniteDuration || |
+ !GetSize(&filesize_in_bytes)) |
+ return 0; |
Ami GONE FROM CHROMIUM
2011/12/07 01:04:48
Need braces.
scherkus (not reviewing)
2011/12/07 05:56:56
Done.
|
- // Bitrate could not be determined. |
- return 0; |
+ // Do math in floating point as we'd overflow an int64 if the filesize was |
+ // larger than ~1073GB. |
+ double bytes = filesize_in_bytes; |
+ double duration = max_duration_.InMicroseconds(); |
+ return bytes * 8000000.0 / duration; |
Ami GONE FROM CHROMIUM
2011/12/07 01:04:48
Personally I prefer 8e6 to counting zeros, but I d
scherkus (not reviewing)
2011/12/07 05:56:56
I like my zeros!
also my efforts to prevent overf
|
} |
bool FFmpegDemuxer::IsLocalSource() { |