试图解决编译错误

This commit is contained in:
Mike Solar
2025-06-18 08:54:06 +08:00
parent 7e0e94abf6
commit 5f9508434f
7 changed files with 35 additions and 32 deletions
+22 -20
View File
@@ -439,9 +439,9 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
} else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
// Create an audio stream object
uint64_t channel_layout = avstream->codecpar->channel_layout;
if (!channel_layout) {
channel_layout = static_cast<uint64_t>(av_get_default_channel_layout(avstream->codecpar->channels));
AVChannelLayout channel_layout = avstream->codecpar->ch_layout;
if (!channel_layout.nb_channels==0) {
av_channel_layout_default(&channel_layout,avstream->codecpar->ch_layout.nb_channels);
}
if (avstream->duration == AV_NOPTS_VALUE || duration_guessed_from_bitrate) {
@@ -551,22 +551,23 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector<QString> &filenames, cons
instance_.Seek(0);
// Handle NULL channel layout
uint64_t channel_layout = ValidateChannelLayout(instance_.avstream());
if (!channel_layout) {
AVChannelLayout channel_layout = ValidateChannelLayout(instance_.avstream());
if (!av_channel_layout_check(&channel_layout)) {
qCritical() << "Failed to determine channel layout of audio file, could not conform";
return false;
}
// Create resampling context
SwrContext* resampler = swr_alloc_set_opts(nullptr,
params.channel_layout(),
FFmpegUtils::GetFFmpegSampleFormat(params.format()),
params.sample_rate(),
channel_layout,
static_cast<AVSampleFormat>(instance_.avstream()->codecpar->format),
instance_.avstream()->codecpar->sample_rate,
0,
nullptr);
AVChannelLayout layout=params.channel_layout();
SwrContext* resampler;
swr_alloc_set_opts2(&resampler,
&layout,
FFmpegUtils::GetFFmpegSampleFormat(params.format()),
params.sample_rate(),
&channel_layout,
static_cast<AVSampleFormat>(instance_.avstream()->codecpar->format),
instance_.avstream()->codecpar->sample_rate,
0,
nullptr);
swr_init(resampler);
@@ -689,13 +690,14 @@ int FFmpegDecoder::GetNativeChannelCount(AVPixelFormat pix_fmt)
}
}
uint64_t FFmpegDecoder::ValidateChannelLayout(AVStream* stream)
AVChannelLayout FFmpegDecoder::ValidateChannelLayout(AVStream* stream)
{
if (stream->codecpar->channel_layout) {
return stream->codecpar->channel_layout;
if (av_channel_layout_check(&stream->codecpar->ch_layout)) {
return stream->codecpar->ch_layout;
}
return av_get_default_channel_layout(stream->codecpar->channels);
AVChannelLayout layout;
av_channel_layout_default(&layout,stream->codecpar->ch_layout.nb_channels);
return layout;
}
const char *FFmpegDecoder::GetInterlacingModeInFFmpeg(VideoParams::Interlacing interlacing)