diff options
author | gimli <ebsi4711@gmail.com> | 2012-09-11 06:51:13 +0200 |
---|---|---|
committer | gimli <ebsi4711@gmail.com> | 2012-09-11 06:51:13 +0200 |
commit | c8f8fb7913433198b724f5e80c2fb4d5dbf37982 (patch) | |
tree | 17bced779046e63258292ca82eafd6c94216c2b1 | |
parent | db4a7dc2ce1109d34be6dd8d10dd3966332b55be (diff) |
[rbp] fixed omx audio codec compile after dcd820ffedfd50e54effc61503dc9b33280d3e97
-rw-r--r-- | xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp | 33 | ||||
-rw-r--r-- | xbmc/cores/omxplayer/OMXAudioCodecOMX.h | 4 |
2 files changed, 17 insertions, 20 deletions
diff --git a/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp b/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp index 830f2b0149..78eae5ed5f 100644 --- a/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp +++ b/xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp @@ -98,7 +98,7 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints) AVCodec* pCodec; m_bOpenedCodec = false; - if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load()) + if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load() || !m_dllSwResample.Load()) return false; m_dllAvCodec.avcodec_register_all(); @@ -154,10 +154,7 @@ void COMXAudioCodecOMX::Dispose() m_pFrame1 = NULL; if (m_pConvert) - { - m_dllAvCodec.av_audio_convert_free(m_pConvert); - m_pConvert = NULL; - } + m_dllSwResample.swr_free(&m_pConvert); if (m_pCodecContext) { @@ -169,6 +166,7 @@ void COMXAudioCodecOMX::Dispose() m_dllAvCodec.Unload(); m_dllAvUtil.Unload(); + m_dllSwResample.Unload(); m_iBufferSize1 = 0; m_iBufferSize2 = 0; @@ -213,19 +211,20 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize) if(m_pCodecContext->sample_fmt != AV_SAMPLE_FMT_S16 && m_iBufferSize1 > 0) { - if(m_pConvert && m_pCodecContext->sample_fmt != m_iSampleFormat) - { - m_dllAvCodec.av_audio_convert_free(m_pConvert); - m_pConvert = NULL; - } + m_dllSwResample.swr_free(&m_pConvert); if(!m_pConvert) { m_iSampleFormat = m_pCodecContext->sample_fmt; - m_pConvert = m_dllAvCodec.av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1, m_pCodecContext->sample_fmt, 1, NULL, 0); + m_pConvert = m_dllSwResample.swr_alloc_set_opts(NULL, + m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), + AV_SAMPLE_FMT_S16, m_pCodecContext->sample_rate, + m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), + m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate, + 0, NULL); } - if(!m_pConvert) + if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0) { CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert %d to AV_SAMPLE_FMT_S16", m_pCodecContext->sample_fmt); m_iBufferSize1 = 0; @@ -233,12 +232,8 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize) return iBytesUsed; } - const void *ibuf[6] = { m_pFrame1->data[0] }; - void *obuf[6] = { m_pBuffer2 }; - int istr[6] = { m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt) }; - int ostr[6] = { (int) (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3) }; - int len = m_iBufferSize1 / istr[0]; - if(m_dllAvCodec.av_audio_convert(m_pConvert, obuf, ostr, ibuf, istr, len) < 0) + int len = m_iBufferSize1 / m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt); + if(m_dllSwResample.swr_convert(m_pConvert, &m_pBuffer2, len, (const uint8_t**)m_pFrame1->data, m_pFrame1->nb_samples) < 0) { CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert %d to AV_SAMPLE_FMT_S16", (int)m_pCodecContext->sample_fmt); m_iBufferSize1 = 0; @@ -247,7 +242,7 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize) } m_iBufferSize1 = 0; - m_iBufferSize2 = len * ostr[0]; + m_iBufferSize2 = len * m_dllAvUtil.av_get_bytes_per_sample(AV_SAMPLE_FMT_S16); } return iBytesUsed; diff --git a/xbmc/cores/omxplayer/OMXAudioCodecOMX.h b/xbmc/cores/omxplayer/OMXAudioCodecOMX.h index d2ae9644f4..42a4a5ff7e 100644 --- a/xbmc/cores/omxplayer/OMXAudioCodecOMX.h +++ b/xbmc/cores/omxplayer/OMXAudioCodecOMX.h @@ -24,6 +24,7 @@ #include "DllAvCodec.h" #include "DllAvFormat.h" #include "DllAvUtil.h" +#include "DllSwResample.h" #include "DVDStreamInfo.h" #include "linux/PlatformDefs.h" @@ -50,7 +51,7 @@ public: protected: AVCodecContext* m_pCodecContext; - AVAudioConvert* m_pConvert;; + SwrContext* m_pConvert; enum AVSampleFormat m_iSampleFormat; CAEChannelInfo m_channelLayout; @@ -71,6 +72,7 @@ protected: DllAvCodec m_dllAvCodec; DllAvUtil m_dllAvUtil; + DllSwResample m_dllSwResample; void BuildChannelMap(); }; |