+/*\r
+* Copyright 2013 Sveriges Television AB http://casparcg.com/\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+* Author: Robert Nagy, ronag89@gmail.com\r
+*/\r
+\r
#include "../../StdAfx.h"\r
\r
#include "audio_resampler.h"\r
output_sample_format, input_sample_format,\r
16, 10, 0, 0.8);\r
\r
- buffer2_.resize(AVCODEC_MAX_AUDIO_FRAME_SIZE*2);\r
+ buffer2_.resize(480000*2);\r
+\r
+ char sample_fmt_string[200];\r
+ av_get_sample_fmt_string(sample_fmt_string, 200, input_sample_format);\r
\r
- CASPAR_LOG(warning) << L"Resampling." <<\r
- L" sample_rate:" << input_channels <<\r
- L" audio_channels:" << input_channels <<\r
- L" sample_fmt:" << input_sample_format;\r
+ CASPAR_LOG(warning) << L"[audio-resampler]" \r
+ << L" sample-rate: " << input_sample_rate \r
+ << L" channels: " << input_channels \r
+ << L" sample-fmt: " << widen(sample_fmt_string);\r
\r
if(resampler)\r
resampler_.reset(resampler, audio_resample_close);\r
\r
std::vector<int8_t, tbb::cache_aligned_allocator<int8_t>> resample(std::vector<int8_t, tbb::cache_aligned_allocator<int8_t>>&& data)\r
{\r
- if(resampler_)\r
+ if(resampler_ && !data.empty())\r
{\r
- buffer2_.resize(AVCODEC_MAX_AUDIO_FRAME_SIZE*2);\r
+ buffer2_.resize(480000*2);\r
auto ret = audio_resample(resampler_.get(),\r
reinterpret_cast<short*>(buffer2_.data()), \r
reinterpret_cast<short*>(data.data()), \r