annotate ffmpeg/libavresample/dither.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
yading@11 3 *
yading@11 4 * This file is part of Libav.
yading@11 5 *
yading@11 6 * Libav is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * Libav is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with Libav; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 #ifndef AVRESAMPLE_DITHER_H
yading@11 22 #define AVRESAMPLE_DITHER_H
yading@11 23
yading@11 24 #include "avresample.h"
yading@11 25 #include "audio_data.h"
yading@11 26
yading@11 27 typedef struct DitherContext DitherContext;
yading@11 28
yading@11 29 typedef struct DitherDSPContext {
yading@11 30 /**
yading@11 31 * Convert samples from flt to s16 with added dither noise.
yading@11 32 *
yading@11 33 * @param dst destination float array, range -0.5 to 0.5
yading@11 34 * @param src source int array, range INT_MIN to INT_MAX.
yading@11 35 * @param dither float dither noise array
yading@11 36 * @param len number of samples
yading@11 37 */
yading@11 38 void (*quantize)(int16_t *dst, const float *src, float *dither, int len);
yading@11 39
yading@11 40 int ptr_align; ///< src and dst constraits for quantize()
yading@11 41 int samples_align; ///< len constraits for quantize()
yading@11 42
yading@11 43 /**
yading@11 44 * Convert dither noise from int to float with triangular distribution.
yading@11 45 *
yading@11 46 * @param dst destination float array, range -0.5 to 0.5
yading@11 47 * constraints: 32-byte aligned
yading@11 48 * @param src0 source int array, range INT_MIN to INT_MAX.
yading@11 49 * the array size is len * 2
yading@11 50 * constraints: 32-byte aligned
yading@11 51 * @param len number of output noise samples
yading@11 52 * constraints: multiple of 16
yading@11 53 */
yading@11 54 void (*dither_int_to_float)(float *dst, int *src0, int len);
yading@11 55 } DitherDSPContext;
yading@11 56
yading@11 57 /**
yading@11 58 * Allocate and initialize a DitherContext.
yading@11 59 *
yading@11 60 * The parameters in the AVAudioResampleContext are used to initialize the
yading@11 61 * DitherContext.
yading@11 62 *
yading@11 63 * @param avr AVAudioResampleContext
yading@11 64 * @return newly-allocated DitherContext
yading@11 65 */
yading@11 66 DitherContext *ff_dither_alloc(AVAudioResampleContext *avr,
yading@11 67 enum AVSampleFormat out_fmt,
yading@11 68 enum AVSampleFormat in_fmt,
yading@11 69 int channels, int sample_rate, int apply_map);
yading@11 70
yading@11 71 /**
yading@11 72 * Free a DitherContext.
yading@11 73 *
yading@11 74 * @param c DitherContext
yading@11 75 */
yading@11 76 void ff_dither_free(DitherContext **c);
yading@11 77
yading@11 78 /**
yading@11 79 * Convert audio sample format with dithering.
yading@11 80 *
yading@11 81 * @param c DitherContext
yading@11 82 * @param dst destination audio data
yading@11 83 * @param src source audio data
yading@11 84 * @return 0 if ok, negative AVERROR code on failure
yading@11 85 */
yading@11 86 int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src);
yading@11 87
yading@11 88 /* arch-specific initialization functions */
yading@11 89
yading@11 90 void ff_dither_init_x86(DitherDSPContext *ddsp,
yading@11 91 enum AVResampleDitherMethod method);
yading@11 92
yading@11 93 #endif /* AVRESAMPLE_DITHER_H */