Remove libavresample support

libavresample hasn't been maintained for a long time by FFmpeg since libswresample superseded it.
In 2018 it was officially deprecated [1].

Let's remove the support for it since there is no need to maintain this option further.

[1] https://patchwork.ffmpeg.org/project/ffmpeg/patch/20171225175335.18183-1-atomnuker@gmail.com/
This commit is contained in:
Peter Keresztes Schmidt 2021-06-02 23:39:29 +02:00
parent 9cce9744d2
commit 7d501a6585
8 changed files with 11 additions and 156 deletions

View File

@ -500,16 +500,6 @@ if(FFMPEG_swresample_FOUND)
set(optlibsfound "${optlibsfound} SWResample")
else()
set(optlibsnotfound "${optlibsnotfound} SWResample")
find_package(FFMPEG COMPONENTS avresample)
if(FFMPEG_avresample_FOUND)
set(HAVE_LIBAVRESAMPLE 1)
set(HAVE_LIBAVRESAMPLE_AVRESAMPLE_H 1)
list(APPEND ZM_BIN_LIBS "${FFMPEG_avresample_LIBRARIES}")
set(optlibsfound "${optlibsfound} AVResample")
else()
set(optlibsnotfound "${optlibsnotfound} AVResample")
endif()
endif()
set(PATH_FFMPEG "")

View File

@ -14,7 +14,6 @@ This module accepts following COMPONENTS::
avutil
swresample
swscale
avresample
IMPORTED Targets
^^^^^^^^^^^^^^^^
@ -121,8 +120,6 @@ _ffmpeg_find(avfilter libavfilter avfilter.h
avutil)
_ffmpeg_find(avdevice libavdevice avdevice.h
avformat avutil)
_ffmpeg_find(avresample libavresample avresample.h
avutil)
if(TARGET FFMPEG::avutil)
set(FFMPEG_VERSION "${FFMPEG_avutil_VERSION}")

View File

@ -9,7 +9,7 @@ Build-Depends: debhelper (>= 9), dh-systemd, python3-sphinx, apache2-dev, dh-lin
,libavcodec-dev (>= 6:10~)
,libavformat-dev (>= 6:10~)
,libavutil-dev (>= 6:10~)
,libswresample-dev | libavresample-dev
,libswresample-dev
,libswscale-dev (>= 6:10~)
,ffmpeg | libav-tools
,net-tools

View File

@ -642,19 +642,8 @@ void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRat
av_packet_rescale_ts(opkt, src_tb, dst_tb);
}
#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE)
int zm_resample_audio(
#if defined(HAVE_LIBSWRESAMPLE)
SwrContext *resample_ctx,
#else
#if defined(HAVE_LIBAVRESAMPLE)
AVAudioResampleContext *resample_ctx,
#endif
#endif
AVFrame *in_frame,
AVFrame *out_frame
) {
#if defined(HAVE_LIBSWRESAMPLE)
int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_frame) {
if (in_frame) {
// Resample the in_frame into the audioSampleBuffer until we process the whole
// decoded data. Note: pts does not survive resampling or converting
@ -670,54 +659,12 @@ int zm_resample_audio(
return 0;
}
Debug(3, "swr_get_delay %" PRIi64, swr_get_delay(resample_ctx, out_frame->sample_rate));
#else
#if defined(HAVE_LIBAVRESAMPLE)
if (!in_frame) {
Error("Flushing resampler not supported by AVRESAMPLE");
return 0;
}
int ret = avresample_convert(resample_ctx, nullptr, 0, 0, in_frame->data,
0, in_frame->nb_samples);
if (ret < 0) {
Error("Could not resample frame (error '%s')",
av_make_error_string(ret).c_str());
return 0;
}
int samples_available = avresample_available(resample_ctx);
if (samples_available < out_frame->nb_samples) {
Debug(1, "Not enough samples yet (%d)", samples_available);
return 0;
}
// Read a frame audio data from the resample fifo
if (avresample_read(resample_ctx, out_frame->data, out_frame->nb_samples) !=
out_frame->nb_samples) {
Warning("Error reading resampled audio.");
return 0;
}
#endif
#endif
zm_dump_frame(out_frame, "Out frame after resample");
return 1;
}
int zm_resample_get_delay(
#if defined(HAVE_LIBSWRESAMPLE)
SwrContext *resample_ctx,
#else
#if defined(HAVE_LIBAVRESAMPLE)
AVAudioResampleContext *resample_ctx,
#endif
#endif
int time_base
) {
#if defined(HAVE_LIBSWRESAMPLE)
int zm_resample_get_delay(SwrContext *resample_ctx, int time_base) {
return swr_get_delay(resample_ctx, time_base);
#else
#if defined(HAVE_LIBAVRESAMPLE)
return avresample_available(resample_ctx);
#endif
#endif
}
#endif

View File

@ -26,11 +26,7 @@
extern "C" {
#ifdef HAVE_LIBSWRESAMPLE
#include "libswresample/swresample.h"
#else
#ifdef HAVE_LIBAVRESAMPLE
#include "libavresample/avresample.h"
#endif
#include "libswresample/swresample.h"
#endif
// AVUTIL
@ -450,29 +446,9 @@ int zm_send_frame_receive_packet(AVCodecContext *context, AVFrame *frame, AVPack
void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRational src_tb, const AVRational dst_tb);
#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE)
int zm_resample_audio(
#if defined(HAVE_LIBSWRESAMPLE)
SwrContext *resample_ctx,
#else
#if defined(HAVE_LIBAVRESAMPLE)
AVAudioResampleContext *resample_ctx,
#endif
#endif
AVFrame *in_frame,
AVFrame *out_frame
);
int zm_resample_get_delay(
#if defined(HAVE_LIBSWRESAMPLE)
SwrContext *resample_ctx,
#else
#if defined(HAVE_LIBAVRESAMPLE)
AVAudioResampleContext *resample_ctx,
#endif
#endif
int time_base
);
int zm_resample_audio(SwrContext *resample_ctx, AVFrame *in_frame, AVFrame *out_frame);
int zm_resample_get_delay(SwrContext *resample_ctx, int time_base);
#endif
int zm_add_samples_to_fifo(AVAudioFifo *fifo, AVFrame *frame);

View File

@ -87,11 +87,9 @@ VideoStore::VideoStore(
packets_written(0),
frame_count(0),
hw_device_ctx(nullptr),
#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE)
resample_ctx(nullptr),
#if defined(HAVE_LIBSWRESAMPLE)
resample_ctx(nullptr),
fifo(nullptr),
#endif
#endif
converted_in_samples(nullptr),
filename(filename_in),
@ -724,20 +722,13 @@ VideoStore::~VideoStore() {
#endif
}
#if defined(HAVE_LIBAVRESAMPLE) || defined(HAVE_LIBSWRESAMPLE)
#if defined(HAVE_LIBSWRESAMPLE)
if (resample_ctx) {
if (fifo) {
av_audio_fifo_free(fifo);
fifo = nullptr;
}
#if defined(HAVE_LIBSWRESAMPLE)
swr_free(&resample_ctx);
#else
#if defined(HAVE_LIBAVRESAMPLE)
avresample_close(resample_ctx);
avresample_free(&resample_ctx);
#endif
#endif
}
if (in_frame) {
av_frame_free(&in_frame);
@ -762,7 +753,7 @@ VideoStore::~VideoStore() {
} // VideoStore::~VideoStore()
bool VideoStore::setup_resampler() {
#if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE)
#if !defined(HAVE_LIBSWRESAMPLE)
Error("Not built with resample library. Cannot do audio conversion to AAC");
return false;
#else
@ -957,42 +948,6 @@ bool VideoStore::setup_resampler() {
return false;
}
Debug(1,"Success setting up SWRESAMPLE");
#else
#if defined(HAVE_LIBAVRESAMPLE)
// Setup the audio resampler
resample_ctx = avresample_alloc_context();
if (!resample_ctx) {
Error("Could not allocate resample ctx");
av_frame_free(&in_frame);
av_frame_free(&out_frame);
return false;
}
av_opt_set_int(resample_ctx, "in_channel_layout",
audio_in_ctx->channel_layout, 0);
av_opt_set_int(resample_ctx, "in_sample_fmt",
audio_in_ctx->sample_fmt, 0);
av_opt_set_int(resample_ctx, "in_sample_rate",
audio_in_ctx->sample_rate, 0);
av_opt_set_int(resample_ctx, "in_channels",
audio_in_ctx->channels, 0);
av_opt_set_int(resample_ctx, "out_channel_layout",
audio_in_ctx->channel_layout, 0);
av_opt_set_int(resample_ctx, "out_sample_fmt",
audio_out_ctx->sample_fmt, 0);
av_opt_set_int(resample_ctx, "out_sample_rate",
audio_out_ctx->sample_rate, 0);
av_opt_set_int(resample_ctx, "out_channels",
audio_out_ctx->channels, 0);
if ((ret = avresample_open(resample_ctx)) < 0) {
Error("Could not open resample ctx");
return false;
} else {
Debug(2, "Success opening resampler");
}
#endif
#endif
out_frame->nb_samples = audio_out_ctx->frame_size;

View File

@ -10,15 +10,11 @@
extern "C" {
#ifdef HAVE_LIBSWRESAMPLE
#include "libswresample/swresample.h"
#else
#ifdef HAVE_LIBAVRESAMPLE
#include "libavresample/avresample.h"
#endif
#include "libswresample/swresample.h"
#endif
#include "libavutil/audio_fifo.h"
#if HAVE_LIBAVUTIL_HWCONTEXT_H
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext.h"
#endif
}
@ -79,10 +75,6 @@ class VideoStore {
#ifdef HAVE_LIBSWRESAMPLE
SwrContext *resample_ctx;
AVAudioFifo *fifo;
#else
#ifdef HAVE_LIBAVRESAMPLE
AVAudioResampleContext* resample_ctx;
#endif
#endif
uint8_t *converted_in_samples;

View File

@ -48,8 +48,6 @@
#cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1
#cmakedefine HAVE_LIBSWRESAMPLE 1
#cmakedefine HAVE_LIBSWRESAMPLE_SWRESAMPLE_H 1
#cmakedefine HAVE_LIBAVRESAMPLE 1
#cmakedefine HAVE_LIBAVRESAMPLE_AVRESAMPLE_H 1
#cmakedefine HAVE_LIBVLC 1
#cmakedefine HAVE_VLC_VLC_H 1
#cmakedefine HAVE_LIBVNC 1