It does not do channel layout conversion or use cpu flags.
---
avconv.c | 4 ++--
avplay.c | 4 ++--
libavcodec/audioconvert.c | 15 ++++++---------
libavcodec/audioconvert.h | 11 ++++-------
libavcodec/resample.c | 8 ++++----
5 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/avconv.c b/avconv.c
index 4027edb..6ca9289 100644
--- a/avconv.c
+++ b/avconv.c
@@ -1084,8 +1084,8 @@ need_realloc:
MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt) != ost->reformat_pair)
{
if (ost->reformat_ctx)
av_audio_convert_free(ost->reformat_ctx);
- ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1,
- dec->sample_fmt, 1, NULL,
0);
+ ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt,
+ dec->sample_fmt, 1);
if (!ost->reformat_ctx) {
av_log(NULL, AV_LOG_FATAL, "Cannot convert %s sample format to %s
sample format\n",
av_get_sample_fmt_name(dec->sample_fmt),
diff --git a/avplay.c b/avplay.c
index beb8dd1..af31eda 100644
--- a/avplay.c
+++ b/avplay.c
@@ -2047,8 +2047,8 @@ static int audio_decode_frame(VideoState *is, double
*pts_ptr)
if (dec->sample_fmt != is->audio_src_fmt) {
if (is->reformat_ctx)
av_audio_convert_free(is->reformat_ctx);
- is->reformat_ctx= av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1,
- dec->sample_fmt, 1,
NULL, 0);
+ is->reformat_ctx= av_audio_convert_alloc(AV_SAMPLE_FMT_S16,
+ dec->sample_fmt, 1);
if (!is->reformat_ctx) {
fprintf(stderr, "Cannot convert %s sample format to %s
sample format\n",
av_get_sample_fmt_name(dec->sample_fmt),
diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c
index 0e1160d..485c63e 100644
--- a/libavcodec/audioconvert.c
+++ b/libavcodec/audioconvert.c
@@ -46,22 +46,19 @@ uint64_t avcodec_guess_channel_layout(int nb_channels, enum
CodecID codec_id, co
}
struct AVAudioConvert {
- int in_channels, out_channels;
+ int channels;
int fmt_pair;
};
-AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int
out_channels,
- enum AVSampleFormat in_fmt, int
in_channels,
- const float *matrix, int flags)
+AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt,
+ enum AVSampleFormat in_fmt,
+ int channels)
{
AVAudioConvert *ctx;
- if (in_channels!=out_channels)
- return NULL; /* FIXME: not supported */
ctx = av_malloc(sizeof(AVAudioConvert));
if (!ctx)
return NULL;
- ctx->in_channels = in_channels;
- ctx->out_channels = out_channels;
+ ctx->channels = channels;
ctx->fmt_pair = out_fmt + AV_SAMPLE_FMT_NB*in_fmt;
return ctx;
}
@@ -79,7 +76,7 @@ int av_audio_convert(AVAudioConvert *ctx,
//FIXME optimize common cases
- for(ch=0; ch<ctx->out_channels; ch++){
+ for (ch = 0; ch < ctx->channels; ch++) {
const int is= in_stride[ch];
const int os= out_stride[ch];
const uint8_t *pi= in[ch];
diff --git a/libavcodec/audioconvert.h b/libavcodec/audioconvert.h
index 590dc8d..be6273d 100644
--- a/libavcodec/audioconvert.h
+++ b/libavcodec/audioconvert.h
@@ -48,16 +48,13 @@ typedef struct AVAudioConvert AVAudioConvert;
/**
* Create an audio sample format converter context
* @param out_fmt Output sample format
- * @param out_channels Number of output channels
* @param in_fmt Input sample format
- * @param in_channels Number of input channels
- * @param[in] matrix Channel mixing matrix (of dimension
in_channel*out_channels). Set to NULL to ignore.
- * @param flags See AV_CPU_FLAG_xx
+ * @param channels Number of channels
* @return NULL on error
*/
-AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int
out_channels,
- enum AVSampleFormat in_fmt, int
in_channels,
- const float *matrix, int flags);
+AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt,
+ enum AVSampleFormat in_fmt,
+ int channels);
/**
* Free audio sample format converter context
diff --git a/libavcodec/resample.c b/libavcodec/resample.c
index eacffed..7aa87e1 100644
--- a/libavcodec/resample.c
+++ b/libavcodec/resample.c
@@ -192,8 +192,8 @@ ReSampleContext *av_audio_resample_init(int
output_channels, int input_channels,
s->sample_size[1] = av_get_bytes_per_sample(s->sample_fmt[1]);
if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) {
- if (!(s->convert_ctx[0] = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1,
- s->sample_fmt[0], 1,
NULL, 0))) {
+ if (!(s->convert_ctx[0] = av_audio_convert_alloc(AV_SAMPLE_FMT_S16,
+ s->sample_fmt[0],
1))) {
av_log(s, AV_LOG_ERROR,
"Cannot convert %s sample format to s16 sample format\n",
av_get_sample_fmt_name(s->sample_fmt[0]));
@@ -203,8 +203,8 @@ ReSampleContext *av_audio_resample_init(int
output_channels, int input_channels,
}
if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) {
- if (!(s->convert_ctx[1] = av_audio_convert_alloc(s->sample_fmt[1], 1,
- AV_SAMPLE_FMT_S16, 1,
NULL, 0))) {
+ if (!(s->convert_ctx[1] = av_audio_convert_alloc(s->sample_fmt[1],
+ AV_SAMPLE_FMT_S16,
1))) {
av_log(s, AV_LOG_ERROR,
"Cannot convert s16 sample format to %s sample format\n",
av_get_sample_fmt_name(s->sample_fmt[1]));
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel