From 4d4580a042f42afd1d3eb4ce652e2c02803b4cf5 Mon Sep 17 00:00:00 2001 From: "benjamin.drung@gmail.com" Date: Sat, 31 May 2014 14:01:57 +0000 Subject: [PATCH] FFmpeg: Replace long deprecated functions by current ones. --- src/FFmpeg.cpp | 12 +++--------- src/FFmpeg.h | 20 +++++++------------- src/export/ExportFFmpeg.cpp | 4 ---- src/import/ImportFFmpeg.cpp | 6 +----- src/ondemand/ODDecodeFFmpegTask.cpp | 2 +- 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index f4110b4ed..2694abe3b 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -377,11 +377,7 @@ int import_ffmpeg_decode_frame(streamContext *sc, bool flushing) } sc->m_samplefmt = sc->m_codecCtx->sample_fmt; -#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 4, 0)) - sc->m_samplesize = av_get_bits_per_sample_fmt(sc->m_samplefmt) / 8; -#else sc->m_samplesize = av_get_bytes_per_sample(sc->m_samplefmt); -#endif int channels = sc->m_codecCtx->channels; unsigned int newsize = sc->m_samplesize * frame->nb_samples * channels; @@ -859,7 +855,7 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr)) wxLogMessage(wxT("Importing symbols...")); FFMPEG_INITDYN(avformat, av_register_all); - FFMPEG_INITDYN(avformat, av_find_stream_info); + FFMPEG_INITDYN(avformat, avformat_find_stream_info); FFMPEG_INITDYN(avformat, av_read_frame); FFMPEG_INITDYN(avformat, av_seek_frame); FFMPEG_INITDYN(avformat, avformat_close_input); @@ -867,7 +863,7 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr)) FFMPEG_INITDYN(avformat, av_interleaved_write_frame); FFMPEG_INITDYN(avformat, av_iformat_next); FFMPEG_INITDYN(avformat, av_oformat_next); - FFMPEG_INITDYN(avformat, av_new_stream); + FFMPEG_INITDYN(avformat, avformat_new_stream); FFMPEG_INITDYN(avformat, avformat_alloc_context); FFMPEG_INITDYN(avformat, av_write_trailer); FFMPEG_INITDYN(avformat, av_codec_get_tag); @@ -877,7 +873,6 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr)) FFMPEG_INITDYN(avformat, av_dict_set); FFMPEG_INITDYN(avformat, avio_size); FFMPEG_INITDYN(avformat, avio_alloc_context); - FFMPEG_INITALT(avformat, avio_read, get_buffer); FFMPEG_INITALT(avformat, avio_seek, url_fseek); FFMPEG_INITALT(avformat, av_guess_format, guess_format); @@ -900,8 +895,7 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr)) FFMPEG_INITDYN(avcodec, av_codec_next); FFMPEG_INITDYN(avcodec, av_codec_is_encoder); FFMPEG_INITDYN(avcodec, avcodec_fill_audio_frame); - - FFMPEG_INITALT(avcodec, av_get_bits_per_sample_fmt, av_get_bits_per_sample_format); + FFMPEG_INITDYN(avcodec, av_get_bytes_per_sample); FFMPEG_INITDYN(avutil, av_free); FFMPEG_INITDYN(avutil, av_log_set_callback); diff --git a/src/FFmpeg.h b/src/FFmpeg.h index 086469662..9ce241734 100644 --- a/src/FFmpeg.h +++ b/src/FFmpeg.h @@ -620,13 +620,7 @@ extern "C" { ); FFMPEG_FUNCTION_WITH_RETURN( int, - av_get_bits_per_sample_format, - (enum AVSampleFormat sample_fmt), - (sample_fmt) - ); - FFMPEG_FUNCTION_WITH_RETURN( - int, - av_get_bits_per_sample_fmt, + av_get_bytes_per_sample, (enum AVSampleFormat sample_fmt), (sample_fmt) ); @@ -671,9 +665,9 @@ extern "C" { ); FFMPEG_FUNCTION_WITH_RETURN( int, - av_find_stream_info, - (AVFormatContext *ic), - (ic) + avformat_find_stream_info, + (AVFormatContext *ic, AVDictionary **options), + (ic, options) ); FFMPEG_FUNCTION_WITH_RETURN( int, @@ -718,9 +712,9 @@ extern "C" { ); FFMPEG_FUNCTION_WITH_RETURN( AVStream*, - av_new_stream, - (AVFormatContext *s, int id), - (s, id) + avformat_new_stream, + (AVFormatContext *s, const AVCodec *c), + (s, c) ); FFMPEG_FUNCTION_WITH_RETURN( AVFormatContext*, diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 2f0ca29e8..c7fa128df 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -276,11 +276,7 @@ bool ExportFFmpeg::Init(const char *shortname, AudacityProject *project, Tags *m memcpy(mEncFormatCtx->filename, OSINPUT(mName), strlen(OSINPUT(mName))+1); // At the moment Audacity can export only one audio stream -#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 10, 0)) - if ((mEncAudioStream = av_new_stream(mEncFormatCtx, 1)) == NULL) -#else if ((mEncAudioStream = avformat_new_stream(mEncFormatCtx, NULL)) == NULL) -#endif { wxLogError(wxT("FFmpeg : ERROR - Can't add audio stream to output file \"%s\"."), mName.c_str()); return false; diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp index 51fb82007..212ded36a 100644 --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -369,14 +369,10 @@ bool FFmpegImportFileHandle::Init() return false; } -#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 3, 0)) - err = av_find_stream_info(mFormatContext); -#else err = avformat_find_stream_info(mFormatContext, NULL); -#endif if (err < 0) { - wxLogError(wxT("FFmpeg : av_find_stream_info() failed for file %s"),mName.c_str()); + wxLogError(wxT("FFmpeg: avformat_find_stream_info() failed for file %s"),mName.c_str()); return false; } diff --git a/src/ondemand/ODDecodeFFmpegTask.cpp b/src/ondemand/ODDecodeFFmpegTask.cpp index a9337eb0a..8e173517e 100644 --- a/src/ondemand/ODDecodeFFmpegTask.cpp +++ b/src/ondemand/ODDecodeFFmpegTask.cpp @@ -197,7 +197,7 @@ bool ODFFmpegDecoder::SeekingAllowed() goto test_failed; } - err = av_find_stream_info(tempContext); + err = avformat_find_stream_info(tempContext, NULL); if (err < 0) { goto test_failed;