diff options
Diffstat (limited to 'media/ffmpeg')
-rw-r--r-- | media/ffmpeg/ffmpeg_util.cc | 18 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_util.h | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_util.cc b/media/ffmpeg/ffmpeg_util.cc new file mode 100644 index 0000000..1be3b12 --- /dev/null +++ b/media/ffmpeg/ffmpeg_util.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#include "media/ffmpeg/ffmpeg_util.h" + +#include "media/filters/ffmpeg_common.h" + +namespace media { + +static const AVRational kMicrosBase = { 1, base::Time::kMicrosecondsPerSecond }; + +base::TimeDelta ConvertTimestamp(const AVRational& time_base, int64 timestamp) { + int64 microseconds = av_rescale_q(timestamp, time_base, kMicrosBase); + return base::TimeDelta::FromMicroseconds(microseconds); +} + +} // namespace media diff --git a/media/ffmpeg/ffmpeg_util.h b/media/ffmpeg/ffmpeg_util.h new file mode 100644 index 0000000..6799cc4 --- /dev/null +++ b/media/ffmpeg/ffmpeg_util.h @@ -0,0 +1,18 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this +// source code is governed by a BSD-style license that can be found in the +// LICENSE file. + +#ifndef MEDIA_FFMPEG_FFMPEG_UTIL_H_ +#define MEDIA_FFMPEG_FFMPEG_UTIL_H_ + +#include "base/time.h" + +struct AVRational; + +namespace media { + +base::TimeDelta ConvertTimestamp(const AVRational& time_base, int64 timestamp); + +} // namespace media + +#endif // MEDIA_FFMPEG_FFMPEG_UTIL_H_ |