Remove some ffmpeg version conditionals

The previous commit uses a FFmpeg 6.1+ API making all those conditionals broken
This commit is contained in:
Ilya Fedin
2025-09-25 20:04:27 +00:00
committed by John Preston
parent b009f06375
commit 63bad22ac4
9 changed files with 16 additions and 263 deletions
@@ -291,11 +291,7 @@ void FrameGenerator::Impl::jumpToStart() {
void FrameGenerator::Impl::resolveNextFrameTiming() {
const auto base = _format->streams[_streamId]->time_base;
#if DA_FFMPEG_HAVE_DURATION
const auto duration = _next.frame->duration;
#else
const auto duration = _next.frame->pkt_duration;
#endif
const auto framePts = _next.frame->pts;
auto framePosition = (framePts * 1000LL * base.num) / base.den;
_currentFrameDelay = _nextFrameDelay;
+2 -43
View File
@@ -512,18 +512,10 @@ void SwresampleDeleter::operator()(SwrContext *value) {
}
SwresamplePointer MakeSwresamplePointer(
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVChannelLayout *srcLayout,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
uint64_t srcLayout,
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVSampleFormat srcFormat,
int srcRate,
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVChannelLayout *dstLayout,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
uint64_t dstLayout,
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVSampleFormat dstFormat,
int dstRate,
SwresamplePointer *existing) {
@@ -534,16 +526,8 @@ SwresamplePointer MakeSwresamplePointer(
// to the resulting context, so the caching doesn't work.
if (existing && (*existing) != nullptr) {
const auto &deleter = existing->get_deleter();
if (true
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
&& srcLayout->nb_channels == deleter.srcChannels
if (srcLayout->nb_channels == deleter.srcChannels
&& dstLayout->nb_channels == deleter.dstChannels
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
&& (av_get_channel_layout_nb_channels(srcLayout)
== deleter.srcChannels)
&& (av_get_channel_layout_nb_channels(dstLayout)
== deleter.dstChannels)
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
&& srcFormat == deleter.srcFormat
&& dstFormat == deleter.dstFormat
&& srcRate == deleter.srcRate
@@ -553,10 +537,8 @@ SwresamplePointer MakeSwresamplePointer(
}
// Initialize audio resampler
AvErrorWrap error;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
auto result = (SwrContext*)nullptr;
error = AvErrorWrap(swr_alloc_set_opts2(
auto error = AvErrorWrap(swr_alloc_set_opts2(
&result,
dstLayout,
dstFormat,
@@ -570,21 +552,6 @@ SwresamplePointer MakeSwresamplePointer(
LogError(u"swr_alloc_set_opts2"_q, error);
return SwresamplePointer();
}
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
auto result = swr_alloc_set_opts(
existing ? existing->get() : nullptr,
dstLayout,
dstFormat,
dstRate,
srcLayout,
srcFormat,
srcRate,
0,
nullptr);
if (!result) {
LogError(u"swr_alloc_set_opts"_q);
}
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
error = AvErrorWrap(swr_init(result));
if (error) {
@@ -598,18 +565,10 @@ SwresamplePointer MakeSwresamplePointer(
{
srcFormat,
srcRate,
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
srcLayout->nb_channels,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_get_channel_layout_nb_channels(srcLayout),
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
dstFormat,
dstRate,
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
dstLayout->nb_channels,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_get_channel_layout_nb_channels(dstLayout),
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
});
}
@@ -24,15 +24,9 @@ extern "C" {
#include <libavutil/version.h>
} // extern "C"
#define DA_FFMPEG_NEW_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_INT >= \
AV_VERSION_INT(57, 28, 100))
#define DA_FFMPEG_CONST_WRITE_CALLBACK (LIBAVFORMAT_VERSION_INT >= \
AV_VERSION_INT(61, 01, 100))
#define DA_FFMPEG_HAVE_DURATION (LIBAVUTIL_VERSION_INT >= \
AV_VERSION_INT(58, 02, 100))
class QImage;
namespace FFmpeg {
@@ -203,18 +197,10 @@ struct SwresampleDeleter {
};
using SwresamplePointer = std::unique_ptr<SwrContext, SwresampleDeleter>;
[[nodiscard]] SwresamplePointer MakeSwresamplePointer(
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVChannelLayout *srcLayout,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
uint64_t srcLayout,
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVSampleFormat srcFormat,
int srcRate,
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVChannelLayout *dstLayout,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
uint64_t dstLayout,
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVSampleFormat dstFormat,
int dstRate,
SwresamplePointer *existing = nullptr);
@@ -398,13 +398,8 @@ bool Instance::Inner::initializeFFmpeg() {
d->codecContext->sample_fmt = AV_SAMPLE_FMT_FLTP;
d->codecContext->bit_rate = 32000;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
d->codecContext->ch_layout = AV_CHANNEL_LAYOUT_MONO;
d->channels = d->codecContext->ch_layout.nb_channels;
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
d->codecContext->channel_layout = AV_CH_LAYOUT_MONO;
d->channels = d->codecContext->channels = 1;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
d->codecContext->sample_rate = kCaptureFrequency;
if (d->fmtContext->oformat->flags & AVFMT_GLOBALHEADER) {
@@ -429,7 +424,6 @@ bool Instance::Inner::initializeFFmpeg() {
// Using _captured directly
// Prepare resampling
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
res = swr_alloc_set_opts2(
&d->swrContext,
&d->codecContext->ch_layout,
@@ -440,19 +434,6 @@ bool Instance::Inner::initializeFFmpeg() {
d->codecContext->sample_rate,
0,
nullptr);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
d->swrContext = swr_alloc_set_opts(
d->swrContext,
d->codecContext->channel_layout,
d->codecContext->sample_fmt,
d->codecContext->sample_rate,
d->codecContext->channel_layout,
AV_SAMPLE_FMT_S16,
d->codecContext->sample_rate,
0,
nullptr);
res = 0;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
if (res < 0 || !d->swrContext) {
LOG(("Audio Error: Unable to swr_alloc_set_opts2 for capture, error %1, %2").arg(res).arg(av_make_error_string(err, sizeof(err), res)));
return false;
@@ -786,12 +767,7 @@ bool Instance::Inner::processFrame(int32 offset, int32 framesize) {
AVFrame *frame = av_frame_alloc();
frame->format = d->codecContext->sample_fmt;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_channel_layout_copy(&frame->ch_layout, &d->codecContext->ch_layout);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
frame->channels = d->codecContext->channels;
frame->channel_layout = d->codecContext->channel_layout;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
frame->sample_rate = d->codecContext->sample_rate;
frame->nb_samples = d->dstSamples;
frame->pts = av_rescale_q(d->fullSamples, AVRational { 1, d->codecContext->sample_rate }, d->codecContext->time_base);
@@ -25,19 +25,6 @@ using FFmpeg::LogError;
} // namespace
#if !DA_FFMPEG_NEW_CHANNEL_LAYOUT
uint64_t AbstractFFMpegLoader::ComputeChannelLayout(
uint64_t channel_layout,
int channels) {
if (channel_layout) {
if (av_get_channel_layout_nb_channels(channel_layout) == channels) {
return channel_layout;
}
}
return av_get_default_channel_layout(channels);
}
#endif // !DA_FFMPEG_NEW_CHANNEL_LAYOUT
int64 AbstractFFMpegLoader::Mul(int64 value, AVRational rational) {
return value * rational.num / rational.den;
}
@@ -244,41 +231,14 @@ bool AbstractAudioFFMpegLoader::initUsingContext(
not_null<AVCodecContext*> context,
float64 speed) {
_swrSrcSampleFormat = context->sample_fmt;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
const AVChannelLayout mono = AV_CHANNEL_LAYOUT_MONO;
const AVChannelLayout stereo = AV_CHANNEL_LAYOUT_STEREO;
const auto useMono = !av_channel_layout_compare(
&context->ch_layout,
&mono);
const auto useStereo = !av_channel_layout_compare(
&context->ch_layout,
&stereo);
const auto copyDstChannelLayout = [&] {
av_channel_layout_copy(&_swrDstChannelLayout, &context->ch_layout);
};
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto layout = ComputeChannelLayout(
context->channel_layout,
context->channels);
if (!layout) {
LOG(("Audio Error: Unknown channel layout %1 for %2 channels."
).arg(context->channel_layout
).arg(context->channels
));
return false;
}
const auto useMono = (layout == AV_CH_LAYOUT_MONO);
const auto useStereo = (layout == AV_CH_LAYOUT_STEREO);
const auto copyDstChannelLayout = [&] {
_swrDstChannelLayout = layout;
};
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
if (useMono) {
if (!av_channel_layout_compare(&context->ch_layout, &mono)) {
switch (_swrSrcSampleFormat) {
case AV_SAMPLE_FMT_U8:
case AV_SAMPLE_FMT_U8P:
_swrDstSampleFormat = _swrSrcSampleFormat;
copyDstChannelLayout();
av_channel_layout_copy(&_swrDstChannelLayout, &context->ch_layout);
_outputChannels = 1;
_outputSampleSize = 1;
_outputFormat = AL_FORMAT_MONO8;
@@ -286,24 +246,24 @@ bool AbstractAudioFFMpegLoader::initUsingContext(
case AV_SAMPLE_FMT_S16:
case AV_SAMPLE_FMT_S16P:
_swrDstSampleFormat = _swrSrcSampleFormat;
copyDstChannelLayout();
av_channel_layout_copy(&_swrDstChannelLayout, &context->ch_layout);
_outputChannels = 1;
_outputSampleSize = sizeof(uint16);
_outputFormat = AL_FORMAT_MONO16;
break;
}
} else if (useStereo) {
} else if (!av_channel_layout_compare(&context->ch_layout, &stereo)) {
switch (_swrSrcSampleFormat) {
case AV_SAMPLE_FMT_U8:
_swrDstSampleFormat = _swrSrcSampleFormat;
copyDstChannelLayout();
av_channel_layout_copy(&_swrDstChannelLayout, &context->ch_layout);
_outputChannels = 2;
_outputSampleSize = 2;
_outputFormat = AL_FORMAT_STEREO8;
break;
case AV_SAMPLE_FMT_S16:
_swrDstSampleFormat = _swrSrcSampleFormat;
copyDstChannelLayout();
av_channel_layout_copy(&_swrDstChannelLayout, &context->ch_layout);
_outputChannels = 2;
_outputSampleSize = 2 * sizeof(uint16);
_outputFormat = AL_FORMAT_STEREO16;
@@ -400,34 +360,16 @@ auto AbstractAudioFFMpegLoader::fillFrameFromQueued()
bool AbstractAudioFFMpegLoader::frameHasDesiredFormat(
not_null<AVFrame*> frame) const {
const auto sameChannelLayout = [&] {
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
return !av_channel_layout_compare(
&frame->ch_layout,
&_swrDstChannelLayout);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto frameChannelLayout = ComputeChannelLayout(
frame->channel_layout,
frame->channels);
return (frameChannelLayout == _swrDstChannelLayout);
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
};
return true
&& (frame->format == _swrDstSampleFormat)
&& (frame->sample_rate == _swrDstRate)
&& sameChannelLayout();
&& !av_channel_layout_compare(
&frame->ch_layout,
&_swrDstChannelLayout);
}
bool AbstractAudioFFMpegLoader::initResampleForFrame() {
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto bad = !_frame->ch_layout.nb_channels;
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto frameChannelLayout = ComputeChannelLayout(
_frame->channel_layout,
_frame->channels);
const auto bad = !frameChannelLayout;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
if (bad) {
if (!_frame->ch_layout.nb_channels) {
LOG(("Audio Error: "
"Unknown channel layout for frame in file '%1', "
"data size '%2'"
@@ -443,38 +385,25 @@ bool AbstractAudioFFMpegLoader::initResampleForFrame() {
));
return false;
} else if (_swrContext) {
const auto sameChannelLayout = [&] {
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
return !av_channel_layout_compare(
&_frame->ch_layout,
&_swrSrcChannelLayout);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
return (frameChannelLayout == _swrSrcChannelLayout);
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
};
if (true
&& (_frame->format == _swrSrcSampleFormat)
&& (_frame->sample_rate == _swrSrcRate)
&& sameChannelLayout()) {
&& !av_channel_layout_compare(
&_frame->ch_layout,
&_swrSrcChannelLayout)) {
return true;
}
swr_close(_swrContext);
}
_swrSrcSampleFormat = static_cast<AVSampleFormat>(_frame->format);
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_channel_layout_copy(&_swrSrcChannelLayout, &_frame->ch_layout);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
_swrSrcChannelLayout = frameChannelLayout;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
_swrSrcRate = _frame->sample_rate;
return initResampleUsingFormat();
}
bool AbstractAudioFFMpegLoader::initResampleUsingFormat() {
AvErrorWrap error = 0;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
error = swr_alloc_set_opts2(
auto error = swr_alloc_set_opts2(
&_swrContext,
&_swrDstChannelLayout,
_swrDstSampleFormat,
@@ -484,18 +413,6 @@ bool AbstractAudioFFMpegLoader::initResampleUsingFormat() {
_swrSrcRate,
0,
nullptr);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
_swrContext = swr_alloc_set_opts(
_swrContext,
_swrDstChannelLayout,
_swrDstSampleFormat,
_swrDstRate,
_swrSrcChannelLayout,
_swrSrcSampleFormat,
_swrSrcRate,
0,
nullptr);
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
if (error || !_swrContext) {
LogError(u"swr_alloc_set_opts2"_q, error);
return false;
@@ -524,13 +441,9 @@ bool AbstractAudioFFMpegLoader::ensureResampleSpaceAvailable(int samples) {
AV_ROUND_UP)));
_resampledFrame->sample_rate = _swrDstRate;
_resampledFrame->format = _swrDstSampleFormat;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_channel_layout_copy(
&_resampledFrame->ch_layout,
&_swrDstChannelLayout);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
_resampledFrame->channel_layout = _swrDstChannelLayout;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
_resampledFrame->nb_samples = allocate;
if (AvErrorWrap error = av_frame_get_buffer(_resampledFrame.get(), 0)) {
LogError(u"av_frame_get_buffer"_q, error);
@@ -589,18 +502,10 @@ void AbstractAudioFFMpegLoader::createSpeedFilter(float64 speed) {
}
char layout[64] = { 0 };
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_channel_layout_describe(
&_swrDstChannelLayout,
layout,
sizeof(layout));
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_get_channel_layout_string(
layout,
sizeof(layout),
0,
_swrDstChannelLayout);
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_opt_set(
_filterSrc,
@@ -50,12 +50,6 @@ public:
return _samplesFrequency;
}
#if !DA_FFMPEG_NEW_CHANNEL_LAYOUT
static uint64_t ComputeChannelLayout(
uint64_t channel_layout,
int channels);
#endif // !DA_FFMPEG_NEW_CHANNEL_LAYOUT
[[nodiscard]] int64 startedAtSample() const {
return _startedAtSample;
}
@@ -72,11 +66,7 @@ protected:
uchar *ioBuffer = nullptr;
AVIOContext *ioContext = nullptr;
AVFormatContext *fmtContext = nullptr;
#if LIBAVFORMAT_VERSION_MAJOR >= 59
const AVCodec *codec = nullptr;
#else
AVCodec *codec = nullptr;
#endif
int32 streamId = 0;
bool _opened = false;
@@ -170,13 +160,8 @@ private:
const int _swrDstRate = Media::Player::kDefaultFrequency;
AVSampleFormat _swrDstSampleFormat = AV_SAMPLE_FMT_S16;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVChannelLayout _swrSrcChannelLayout = AV_CHANNEL_LAYOUT_STEREO;
AVChannelLayout _swrDstChannelLayout = AV_CHANNEL_LAYOUT_STEREO;
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
uint64_t _swrSrcChannelLayout = 0;
uint64_t _swrDstChannelLayout = AV_CH_LAYOUT_STEREO;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
AVFilterGraph *_filterGraph = nullptr;
float64 _filterSpeed = 1.;
@@ -45,12 +45,7 @@ constexpr auto kFrameSize = 4096;
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 79, 100)
auto inCodec = (const AVCodec*)nullptr;
#else
auto inCodec = (AVCodec*)nullptr;
#endif
const auto streamId = av_find_best_stream(
input.get(),
AVMEDIA_TYPE_AUDIO,
@@ -106,7 +101,6 @@ constexpr auto kFrameSize = 4096;
return {};
}
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
auto mono = AVChannelLayout(AV_CHANNEL_LAYOUT_MONO);
auto stereo = AVChannelLayout(AV_CHANNEL_LAYOUT_STEREO);
const auto in = &inCodecContext->ch_layout;
@@ -116,16 +110,6 @@ constexpr auto kFrameSize = 4096;
} else {
outCodecContext->ch_layout = AV_CHANNEL_LAYOUT_STEREO;
}
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto in = inCodecContext->channels;
if (in == 1 || in == 2) {
outCodecContext->channels = in;
outCodecContext->channel_layout = inCodecContext->channel_layout;
} else {
outCodecContext->channels = 2;
outCodecContext->channel_layout = AV_CH_LAYOUT_STEREO;
}
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
const auto rate = 44'100;
outCodecContext->sample_fmt = AV_SAMPLE_FMT_S16;
outCodecContext->time_base = AVRational{ 1, rate };
@@ -152,17 +136,10 @@ constexpr auto kFrameSize = 4096;
}
auto swrContext = MakeSwresamplePointer(
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
&inCodecContext->ch_layout,
inCodecContext->sample_fmt,
inCodecContext->sample_rate,
&outCodecContext->ch_layout,
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
inCodecContext->channel_layout,
inCodecContext->sample_fmt,
inCodecContext->sample_rate,
outCodecContext->channel_layout,
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
outCodecContext->sample_fmt,
outCodecContext->sample_rate);
if (!swrContext) {
@@ -186,14 +163,9 @@ constexpr auto kFrameSize = 4096;
outFrame->nb_samples = kFrameSize;
outFrame->format = outCodecContext->sample_fmt;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_channel_layout_copy(
&outFrame->ch_layout,
&outCodecContext->ch_layout);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
outFrame->channel_layout = outCodecContext->channel_layout;
outFrame->channels = outCodecContext->channels;
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
outFrame->sample_rate = outCodecContext->sample_rate;
error = av_frame_get_buffer(outFrame.get(), 0);
@@ -144,11 +144,7 @@ ReaderImplementation::ReadResult FFMpegReaderImplementation::readNextFrame() {
}
void FFMpegReaderImplementation::processReadFrame() {
#if DA_FFMPEG_HAVE_DURATION
int64 duration = _frame->duration;
#else
int64 duration = _frame->pkt_duration;
#endif
int64 framePts = _frame->pts;
crl::time frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
_currentFrameDelay = _nextFrameDelay;
@@ -428,12 +428,6 @@ bool RoundVideoRecorder::Private::initAudio() {
_audioCodec->sample_fmt = AV_SAMPLE_FMT_FLTP;
_audioCodec->bit_rate = kAudioBitRate;
_audioCodec->sample_rate = kAudioFrequency;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
_audioCodec->ch_layout = AV_CHANNEL_LAYOUT_MONO;
#else
_audioCodec->channel_layout = AV_CH_LAYOUT_MONO;
_audioCodec->channels = _audioChannels;
#endif
auto error = AvErrorWrap(avcodec_open2(
_audioCodec.get(),
@@ -452,7 +446,6 @@ bool RoundVideoRecorder::Private::initAudio() {
return false;
}
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
_swrContext = MakeSwresamplePointer(
&_audioCodec->ch_layout,
AV_SAMPLE_FMT_S16,
@@ -461,16 +454,6 @@ bool RoundVideoRecorder::Private::initAudio() {
_audioCodec->sample_fmt,
_audioCodec->sample_rate,
&_swrContext);
#else // DA_FFMPEG_NEW_CHANNEL_LAYOUT
_swrContext = MakeSwresamplePointer(
_audioCodec->channel_layout,
AV_SAMPLE_FMT_S16,
_audioCodec->sample_rate,
_audioCodec->channel_layout,
_audioCodec->sample_fmt,
_audioCodec->sample_rate,
&_swrContext);
#endif // DA_FFMPEG_NEW_CHANNEL_LAYOUT
if (!_swrContext) {
return false;
}
@@ -483,12 +466,7 @@ bool RoundVideoRecorder::Private::initAudio() {
_audioFrame->nb_samples = _audioCodec->frame_size;
_audioFrame->format = _audioCodec->sample_fmt;
_audioFrame->sample_rate = _audioCodec->sample_rate;
#if DA_FFMPEG_NEW_CHANNEL_LAYOUT
av_channel_layout_copy(&_audioFrame->ch_layout, &_audioCodec->ch_layout);
#else
_audioFrame->channel_layout = _audioCodec->channel_layout;
_audioFrame->channels = _audioCodec->channels;
#endif
error = AvErrorWrap(av_frame_get_buffer(_audioFrame.get(), 0));
if (error) {