mirror of https://github.com/mpv-player/mpv
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).
This commit is contained in:
parent
bb0290145a
commit
c7e620df96
|
@ -37,7 +37,6 @@
|
|||
|
||||
#if HAVE_LIBAVRESAMPLE
|
||||
#include <libavresample/avresample.h>
|
||||
#define USE_SET_CHANNEL_MAPPING HAVE_AVRESAMPLE_SET_CHANNEL_MAPPING
|
||||
#elif HAVE_LIBSWRESAMPLE
|
||||
#include <libswresample/swresample.h>
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
* common functions for reordering audio channels
|
||||
*
|
||||
* Copyright (C) 2007 Ulion <ulion A gmail P com>
|
||||
*
|
||||
* 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 <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* common functions for reordering audio channels
|
||||
*
|
||||
* Copyright (C) 2007 Ulion <ulion A gmail P com>
|
||||
*
|
||||
* 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 <inttypes.h>
|
||||
|
||||
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 */
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
7
wscript
7
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',
|
||||
|
|
|
@ -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" ),
|
||||
|
|
Loading…
Reference in New Issue