FFmpeg 3 & 4 support, Travis CI support, OpenMP schedule change (#160)

* FFmpeg4 support. Compile warnings fixes. Credit goes to many people, including ferdnyc, peterM, and other awesome folks!

* Adding environment checking to enable/disable omp taskwait after each video/audio frame is processed. This is experimental for some users with crashes.

* Moving `omp taskwait` to after the ProcessVideoPacket() method, since that is the only place it is useful.

* Fixing crashes on missing Clip source file, and changing FFmpeg scaling algorthm from SWS_BILINEAR to  SWS_LANCZOS (for higher quality scaling)

* Update FindFFmpeg.cmake module, and updating build script. Also enabling debug builds.

* Updating experimental travis build script

* Fixed unit test for newer version of FFmpeg (audio resampling)

* Experimental travis multiple jobs

* Adding OMP schedule hint (thanks PeterM), which prevents crashes in some circumstances.
This commit is contained in:
Jonathan Thomas
2018-09-11 00:40:31 -05:00
committed by GitHub
parent 1989b09c29
commit e879188a7d
19 changed files with 567 additions and 303 deletions

View File

@@ -376,6 +376,7 @@ std::shared_ptr<Frame> FrameMapper::GetOrCreateFrame(int64_t number)
new_frame = std::make_shared<Frame>(number, info.width, info.height, "#000000", samples_in_frame, reader->info.channels);
new_frame->SampleRate(reader->info.sample_rate);
new_frame->ChannelsLayout(info.channel_layout);
new_frame->AddAudioSilence(samples_in_frame);
return new_frame;
}
@@ -650,8 +651,8 @@ void FrameMapper::Close()
// Deallocate resample buffer
if (avr) {
avresample_close(avr);
avresample_free(&avr);
SWR_CLOSE(avr);
SWR_FREE(&avr);
avr = NULL;
}
}
@@ -741,8 +742,8 @@ void FrameMapper::ChangeMapping(Fraction target_fps, PulldownType target_pulldow
// Deallocate resample buffer
if (avr) {
avresample_close(avr);
avresample_free(&avr);
SWR_CLOSE(avr);
SWR_FREE(&avr);
avr = NULL;
}
@@ -817,7 +818,7 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr<Frame> frame, int64_t orig
// setup resample context
if (!avr) {
avr = avresample_alloc_context();
avr = SWR_ALLOC();
av_opt_set_int(avr, "in_channel_layout", channel_layout_in_frame, 0);
av_opt_set_int(avr, "out_channel_layout", info.channel_layout, 0);
av_opt_set_int(avr, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
@@ -826,11 +827,11 @@ void FrameMapper::ResampleMappedAudio(std::shared_ptr<Frame> frame, int64_t orig
av_opt_set_int(avr, "out_sample_rate", info.sample_rate, 0);
av_opt_set_int(avr, "in_channels", channels_in_frame, 0);
av_opt_set_int(avr, "out_channels", info.channels, 0);
avresample_open(avr);
SWR_INIT(avr);
}
// Convert audio samples
nb_samples = avresample_convert(avr, // audio resample context
nb_samples = SWR_CONVERT(avr, // audio resample context
audio_converted->data, // output data pointers
audio_converted->linesize[0], // output plane size, in bytes. (0 if unknown)
audio_converted->nb_samples, // maximum number of samples that the output buffer can hold