From c7e620df96630b4e254040087f37a553bc1988df Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 16 Mar 2014 09:49:34 +0100 Subject: af_lavrresample: remove avresample_set_channel_mapping() fallbacks This function is now always available. Also remove includes of reorder_ch.h from some AOs (these are just old relicts). --- audio/filter/af_lavrresample.c | 24 ------------- audio/out/ao_alsa.c | 1 - audio/out/ao_dsound.c | 1 - audio/out/ao_pcm.c | 1 - audio/reorder_ch.c | 77 ------------------------------------------ audio/reorder_ch.h | 31 ----------------- old-configure | 14 -------- old-makefile | 1 - wscript | 7 ---- wscript_build.py | 1 - 10 files changed, 158 deletions(-) delete mode 100644 audio/reorder_ch.c delete mode 100644 audio/reorder_ch.h diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index f6537f1db0..692297bb38 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -37,7 +37,6 @@ #if HAVE_LIBAVRESAMPLE #include -#define USE_SET_CHANNEL_MAPPING HAVE_AVRESAMPLE_SET_CHANNEL_MAPPING #elif HAVE_LIBSWRESAMPLE #include #define AVAudioResampleContext SwrContext @@ -49,7 +48,6 @@ #define avresample_convert(ctx, out, out_planesize, out_samples, in, in_planesize, in_samples) \ swr_convert(ctx, out, out_samples, (const uint8_t**)(in), in_samples) #define avresample_set_channel_mapping swr_set_channel_mapping -#define USE_SET_CHANNEL_MAPPING 1 #else #error "config.h broken or no resampler found" #endif @@ -59,7 +57,6 @@ #include "common/av_opts.h" #include "audio/filter/af.h" #include "audio/fmt-conversion.h" -#include "audio/reorder_ch.h" struct af_resample_opts { int filter_size; @@ -210,13 +207,11 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in, av_opt_set_int(s->avrctx_out, "in_sample_rate", s->ctx.out_rate, 0); av_opt_set_int(s->avrctx_out, "out_sample_rate", s->ctx.out_rate, 0); -#if USE_SET_CHANNEL_MAPPING // API has weird requirements, quoting avresample.h: // * This function can only be called when the allocated context is not open. // * Also, the input channel layout must have already been set. avresample_set_channel_mapping(s->avrctx, s->reorder_in); avresample_set_channel_mapping(s->avrctx_out, s->reorder_out); -#endif if (avresample_open(s->avrctx) < 0 || avresample_open(s->avrctx_out) < 0) @@ -319,17 +314,6 @@ static void reorder_planes(struct mp_audio *mpa, int *reorder) } } -#if !USE_SET_CHANNEL_MAPPING -static void do_reorder(struct mp_audio *mpa, int *reorder) -{ - if (af_fmt_is_planar(mpa->format)) { - reorder_planes(mpa, reorder); - } else { - reorder_channels(mpa->planes[0], reorder, mpa->bps, mpa->nch, mpa->samples); - } -} -#endif - static int filter(struct af_instance *af, struct mp_audio *data, int flags) { struct af_resample *s = af->priv; @@ -344,10 +328,6 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) af->delay = get_delay(s) / (double)s->ctx.in_rate; -#if !USE_SET_CHANNEL_MAPPING - do_reorder(in, s->reorder_in); -#endif - if (out->samples) { out->samples = avresample_convert(s->avrctx, (uint8_t **) out->planes, out->samples * out->sstride, out->samples, @@ -358,7 +338,6 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) *data = *out; -#if USE_SET_CHANNEL_MAPPING if (needs_reorder(s->reorder_out, out->nch)) { if (af_fmt_is_planar(out->format)) { reorder_planes(data, s->reorder_out); @@ -373,9 +352,6 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) assert(out_samples == data->samples); } } -#else - do_reorder(data, s->reorder_out); -#endif return 0; } diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 9b53a3af2f..63cba45aac 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -48,7 +48,6 @@ #include "ao.h" #include "internal.h" #include "audio/format.h" -#include "audio/reorder_ch.h" struct priv { snd_pcm_t *alsa; diff --git a/audio/out/ao_dsound.c b/audio/out/ao_dsound.c index 6ddf080d20..aba4d882dc 100644 --- a/audio/out/ao_dsound.c +++ b/audio/out/ao_dsound.c @@ -39,7 +39,6 @@ #include "audio/format.h" #include "ao.h" #include "internal.h" -#include "audio/reorder_ch.h" #include "common/msg.h" #include "osdep/timer.h" #include "options/m_option.h" diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c index b14c9f4d79..ab5faf6173 100644 --- a/audio/out/ao_pcm.c +++ b/audio/out/ao_pcm.c @@ -32,7 +32,6 @@ #include "options/m_option.h" #include "audio/format.h" -#include "audio/reorder_ch.h" #include "ao.h" #include "internal.h" #include "common/msg.h" diff --git a/audio/reorder_ch.c b/audio/reorder_ch.c deleted file mode 100644 index e7bdaaccff..0000000000 --- a/audio/reorder_ch.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * common functions for reordering audio channels - * - * Copyright (C) 2007 Ulion - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include - -#include "chmap.h" -#include "reorder_ch.h" - -#define MAX_SAMPLESIZE 8 - -static void reorder_channels_(uint8_t *restrict data, int *restrict ch_order, - size_t sample_size, size_t num_ch, - size_t num_frames) -{ - char buffer[MP_NUM_CHANNELS * MAX_SAMPLESIZE]; - for (size_t f = 0; f < num_frames; f++) { - for (uint8_t c = 0; c < num_ch; c++) { - memcpy(buffer + sample_size * c, data + sample_size * ch_order[c], - sample_size); - } - memcpy(data, buffer, sample_size * num_ch); - data += num_ch * sample_size; - } -} - -// Reorders for each channel: -// out[ch] = in[ch_order[ch]] (but in-place) -// num_ch is the number of channels -// sample_size is e.g. 2 for s16le -// full byte size of in/out = num_ch * sample_size * num_frames -// Do not use this function in new code; use libavresample instead. -void reorder_channels(void *restrict data, int *restrict ch_order, - size_t sample_size, size_t num_ch, size_t num_frames) -{ - // Check 1:1 mapping - bool need_reorder = false; - for (int n = 0; n < num_ch; n++) - need_reorder |= ch_order[n] != n; - if (!need_reorder) - return; - assert(sample_size <= MAX_SAMPLESIZE); - assert(num_ch <= MP_NUM_CHANNELS); - // See reorder_to_planar() why this is done this way - // s16 and float are the most common sample sizes, and 6 channels is the - // most common case where reordering is required. - if (sample_size == 2 && num_ch == 6) - reorder_channels_(data, ch_order, 2, 6, num_frames); - else if (sample_size == 2) - reorder_channels_(data, ch_order, 2, num_ch, num_frames); - else if (sample_size == 4 && num_ch == 6) - reorder_channels_(data, ch_order, 4, 6, num_frames); - else if (sample_size == 4) - reorder_channels_(data, ch_order, 4, num_ch, num_frames); - else - reorder_channels_(data, ch_order, sample_size, num_ch, num_frames); -} diff --git a/audio/reorder_ch.h b/audio/reorder_ch.h deleted file mode 100644 index 1ad50bbb00..0000000000 --- a/audio/reorder_ch.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * common functions for reordering audio channels - * - * Copyright (C) 2007 Ulion - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_REORDER_CH_H -#define MPLAYER_REORDER_CH_H - -#include - -void reorder_channels(void *restrict data, int *restrict ch_order, - size_t sample_size, size_t num_ch, size_t num_frames); - -#endif /* MPLAYER_REORDER_CH_H */ diff --git a/old-configure b/old-configure index 7cc8338a4e..a1009ce6ef 100755 --- a/old-configure +++ b/old-configure @@ -2669,7 +2669,6 @@ echores "yes" _resampler=no _avresample=no -_avresample_has_set_channel_mapping=no def_libswresample='#define HAVE_LIBSWRESAMPLE 0' @@ -2685,12 +2684,6 @@ if test "$_disable_avresample" = no ; then fi echores "$_resampler" -if test "$_avresample" = yes ; then - echocheck "libavresample avresample_set_channel_mapping() API" - statement_check libavresample/avresample.h 'avresample_set_channel_mapping(NULL, NULL)' && _avresample_has_set_channel_mapping=yes - echores "$_avresample_has_set_channel_mapping" -fi - if test "$_resampler" = no ; then echocheck "libswresample >= 0.17.104" @@ -2706,12 +2699,6 @@ if test "$_resampler" = no ; then die "No resampler found. Install libavresample or libswresample (FFmpeg)." fi -if test "$_avresample_has_set_channel_mapping" = yes ; then - def_avresample_has_set_channel_mapping='#define HAVE_AVRESAMPLE_SET_CHANNEL_MAPPING 1' -else - def_avresample_has_set_channel_mapping='#define HAVE_AVRESAMPLE_SET_CHANNEL_MAPPING 0' -fi - echocheck "libavcodec avcodec_enum_to_chroma_pos API" _avcodec_has_chroma_pos_api=no @@ -3503,7 +3490,6 @@ $def_xv $def_encoding $def_libavresample $def_libswresample -$def_avresample_has_set_channel_mapping $def_fast_64bit $def_pthreads diff --git a/old-makefile b/old-makefile index fa386297d9..0a8ed75fbd 100644 --- a/old-makefile +++ b/old-makefile @@ -144,7 +144,6 @@ SOURCES = audio/audio.c \ audio/fmt-conversion.c \ audio/format.c \ audio/mixer.c \ - audio/reorder_ch.c \ audio/decode/ad_lavc.c \ audio/decode/ad_spdif.c \ audio/decode/dec_audio.c \ diff --git a/wscript b/wscript index 286da3506c..b711dffcb9 100644 --- a/wscript +++ b/wscript @@ -343,13 +343,6 @@ Libav libraries ({0}). Aborting.".format(" ".join(libav_pkg_config_checks)) 'name': '--libavresample', 'desc': 'libavresample', 'func': check_pkg_config('libavresample', '>= 1.1.0'), - }, { - 'name': 'avresample-set-channel-mapping', - 'desc': 'libavresample channel mapping API', - 'deps': [ 'libavresample' ], - 'func': check_statement('libavresample/avresample.h', - 'avresample_set_channel_mapping(NULL, NULL)', - use='libavresample'), }, { 'name': '--libswresample', 'desc': 'libswresample', diff --git a/wscript_build.py b/wscript_build.py index f0494a35a6..79682f1e17 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -94,7 +94,6 @@ def build(ctx): ( "audio/fmt-conversion.c" ), ( "audio/format.c" ), ( "audio/mixer.c" ), - ( "audio/reorder_ch.c" ), ( "audio/decode/ad_lavc.c" ), ( "audio/decode/ad_mpg123.c", "mpg123" ), ( "audio/decode/ad_spdif.c" ), -- cgit v1.2.3