diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 00:25:27 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 00:25:27 +0000 |
commit | 20fab9ec3cc2f1387247339c6eab504873b3824f (patch) | |
tree | e38482897fe4cb876c409610a26b74d5dd8d3bc8 /media/base/media_posix.cc | |
parent | 8de57342e6e4c50337c553f49f39a59ff1d825d3 (diff) | |
download | chromium_src-20fab9ec3cc2f1387247339c6eab504873b3824f.zip chromium_src-20fab9ec3cc2f1387247339c6eab504873b3824f.tar.gz chromium_src-20fab9ec3cc2f1387247339c6eab504873b3824f.tar.bz2 |
Clean up FFmpeg media formats and switch to using av_get_bits_per_sample_format().
Before we were relying on codecs setting bits_per_raw_sample, which turns out isn't a valid assumption at all (i.e., vorbis). However, codecs always set the sample format so we can use the FFmpeg utility function av_get_bits_per_sample_format() to convert the SampleFormat enum to an integer number of bits.
Review URL: http://codereview.chromium.org/99160
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/media_posix.cc')
-rw-r--r-- | media/base/media_posix.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc index 331a143..edbced0 100644 --- a/media/base/media_posix.cc +++ b/media/base/media_posix.cc @@ -22,6 +22,11 @@ // be promising, but I don't quite understand it yet. extern "C" { +int (*av_get_bits_per_sample_format_ptr)(enum SampleFormat sample_fmt); +int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) { + return av_get_bits_per_sample_format(sample_fmt); +} + void (*avcodec_init_ptr)(void) = NULL; void avcodec_init(void) { avcodec_init_ptr(); @@ -54,7 +59,7 @@ int avcodec_decode_audio2(AVCodecContext* avctx, int16_t* samples, int* frame_size_ptr, const uint8_t* buf, int buf_size) { - return avcodec_decode_audio2_ptr(avctx, samples, frame_size_ptr, buf, + return avcodec_decode_audio2_ptr(avctx, samples, frame_size_ptr, buf, buf_size); } @@ -164,6 +169,9 @@ bool InitializeMediaLibrary(const FilePath& module_dir) { // TODO(ajwong): Extract this to somewhere saner, and hopefully // autogenerate the bindings from the .def files. Having all this // code here is incredibly ugly. + av_get_bits_per_sample_format_ptr = + reinterpret_cast<int (*)(enum SampleFormat)>( + dlsym(libs[FILE_LIBAVCODEC], "av_get_bits_per_sample_format")); avcodec_init_ptr = reinterpret_cast<void(*)(void)>( dlsym(libs[FILE_LIBAVCODEC], "avcodec_init")); |