summaryrefslogtreecommitdiffstats
path: root/libavresample/audio_convert.h
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-03-23 17:42:17 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-04-24 21:28:27 -0400
commitc8af852b97447491823ff9b91413e32415e2babf (patch)
tree6c02f850cf954612c7077f266a75d663bb9cde57 /libavresample/audio_convert.h
parentc5671aeb77abb18a5a10ace314ab49e8fd3d0cb3 (diff)
downloadffmpeg-streaming-c8af852b97447491823ff9b91413e32415e2babf.zip
ffmpeg-streaming-c8af852b97447491823ff9b91413e32415e2babf.tar.gz
Add libavresample
This is a new library for audio sample format, channel layout, and sample rate conversion.
Diffstat (limited to 'libavresample/audio_convert.h')
-rw-r--r--libavresample/audio_convert.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/libavresample/audio_convert.h b/libavresample/audio_convert.h
new file mode 100644
index 0000000..9227763
--- /dev/null
+++ b/libavresample/audio_convert.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVRESAMPLE_AUDIO_CONVERT_H
+#define AVRESAMPLE_AUDIO_CONVERT_H
+
+#include "libavutil/samplefmt.h"
+#include "avresample.h"
+#include "audio_data.h"
+
+typedef struct AudioConvert AudioConvert;
+
+/**
+ * Set conversion function if the parameters match.
+ *
+ * This compares the parameters of the conversion function to the parameters
+ * in the AudioConvert context. If the parameters do not match, no changes are
+ * made to the active functions. If the parameters do match and the alignment
+ * is not constrained, the function is set as the generic conversion function.
+ * If the parameters match and the alignment is constrained, the function is
+ * set as the optimized conversion function.
+ *
+ * @param ac AudioConvert context
+ * @param out_fmt output sample format
+ * @param in_fmt input sample format
+ * @param channels number of channels, or 0 for any number of channels
+ * @param ptr_align buffer pointer alignment, in bytes
+ * @param sample_align buffer size alignment, in samples
+ * @param descr function type description (e.g. "C" or "SSE")
+ * @param conv conversion function pointer
+ */
+void ff_audio_convert_set_func(AudioConvert *ac, enum AVSampleFormat out_fmt,
+ enum AVSampleFormat in_fmt, int channels,
+ int ptr_align, int samples_align,
+ const char *descr, void *conv);
+
+/**
+ * Allocate and initialize AudioConvert context for sample format conversion.
+ *
+ * @param avr AVAudioResampleContext
+ * @param out_fmt output sample format
+ * @param in_fmt input sample format
+ * @param channels number of channels
+ * @return newly-allocated AudioConvert context
+ */
+AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,
+ enum AVSampleFormat out_fmt,
+ enum AVSampleFormat in_fmt,
+ int channels);
+
+/**
+ * Convert audio data from one sample format to another.
+ *
+ * For each call, the alignment of the input and output AudioData buffers are
+ * examined to determine whether to use the generic or optimized conversion
+ * function (when available).
+ *
+ * @param ac AudioConvert context
+ * @param out output audio data
+ * @param in input audio data
+ * @param len number of samples to convert
+ * @return 0 on success, negative AVERROR code on failure
+ */
+int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in, int len);
+
+/* arch-specific initialization functions */
+
+void ff_audio_convert_init_x86(AudioConvert *ac);
+
+#endif /* AVRESAMPLE_AUDIO_CONVERT_H */
OpenPOWER on IntegriCloud