diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 01:17:14 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 01:17:14 +0000 |
commit | f72f38623b7a32e7ba8c92f4a6d98d05fc51c311 (patch) | |
tree | 90aed0b30067c9c798a8d6850307476df9b93209 /media/base/media_posix.cc | |
parent | 597dbf7d2957462aa97c4cbd4ba28266d948d9b3 (diff) | |
download | chromium_src-f72f38623b7a32e7ba8c92f4a6d98d05fc51c311.zip chromium_src-f72f38623b7a32e7ba8c92f4a6d98d05fc51c311.tar.gz chromium_src-f72f38623b7a32e7ba8c92f4a6d98d05fc51c311.tar.bz2 |
Use av_rescale_q() for converting FFmpeg timestamps to base::TimeDelta.
Previously we were using integer math to convert to microseconds, but depending on the frame rate and packet size we could introduce enough error that could accumulate and introduce audio/video synchronization drift. av_rescale_q() is a simple function but is designed to minimize error as much as possible.
Review URL: http://codereview.chromium.org/113598
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/media_posix.cc')
-rw-r--r-- | media/base/media_posix.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc index 4bddf6d..94c1a89 100644 --- a/media/base/media_posix.cc +++ b/media/base/media_posix.cc @@ -122,6 +122,11 @@ void av_free(void* ptr) { return av_free_ptr(ptr); } +int64_t (*av_rescale_q_ptr)(int64_t a, AVRational bq, AVRational cq) = NULL; +int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) { + return av_rescale_q_ptr(a, bq, cq); +} + } // extern "C" @@ -240,6 +245,9 @@ bool InitializeMediaLibrary(const FilePath& module_dir) { av_free_ptr = reinterpret_cast<void (*)(void*)>( dlsym(libs[FILE_LIBAVUTIL], "av_free")); + av_rescale_q_ptr = + reinterpret_cast<int64_t (*)(int64_t, AVRational, AVRational)>( + dlsym(libs[FILE_LIBAVUTIL], "av_rescale_q")); // Check that all the symbols were loaded correctly before returning true. if (av_get_bits_per_sample_format_ptr && @@ -259,7 +267,8 @@ bool InitializeMediaLibrary(const FilePath& module_dir) { av_register_protocol_ptr && av_malloc_ptr && - av_free_ptr) { + av_free_ptr && + av_rescale_q_ptr) { return true; } |