You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.2KB

  1. /*
  2. * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVRESAMPLE_AUDIO_MIX_H
  21. #define AVRESAMPLE_AUDIO_MIX_H
  22. #include <stdint.h>
  23. #include "libavutil/samplefmt.h"
  24. #include "avresample.h"
  25. #include "internal.h"
  26. #include "audio_data.h"
  27. typedef void (mix_func)(uint8_t **src, void **matrix, int len, int out_ch,
  28. int in_ch);
  29. /**
  30. * Set mixing function if the parameters match.
  31. *
  32. * This compares the parameters of the mixing function to the parameters in the
  33. * AudioMix context. If the parameters do not match, no changes are made to the
  34. * active functions. If the parameters do match and the alignment is not
  35. * constrained, the function is set as the generic mixing function. If the
  36. * parameters match and the alignment is constrained, the function is set as
  37. * the optimized mixing function.
  38. *
  39. * @param am AudioMix context
  40. * @param fmt input/output sample format
  41. * @param coeff_type mixing coefficient type
  42. * @param in_channels number of input channels, or 0 for any number of channels
  43. * @param out_channels number of output channels, or 0 for any number of channels
  44. * @param ptr_align buffer pointer alignment, in bytes
  45. * @param samples_align buffer size alignment, in samples
  46. * @param descr function type description (e.g. "C" or "SSE")
  47. * @param mix_func mixing function pointer
  48. */
  49. void ff_audio_mix_set_func(AudioMix *am, enum AVSampleFormat fmt,
  50. enum AVMixCoeffType coeff_type, int in_channels,
  51. int out_channels, int ptr_align, int samples_align,
  52. const char *descr, void *mix_func);
  53. /**
  54. * Allocate and initialize an AudioMix context.
  55. *
  56. * The parameters in the AVAudioResampleContext are used to initialize the
  57. * AudioMix context.
  58. *
  59. * @param avr AVAudioResampleContext
  60. * @return newly-allocated AudioMix context.
  61. */
  62. AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr);
  63. /**
  64. * Free an AudioMix context.
  65. */
  66. void ff_audio_mix_free(AudioMix **am);
  67. /**
  68. * Apply channel mixing to audio data using the current mixing matrix.
  69. */
  70. int ff_audio_mix(AudioMix *am, AudioData *src);
  71. /**
  72. * Get the current mixing matrix.
  73. */
  74. int ff_audio_mix_get_matrix(AudioMix *am, double *matrix, int stride);
  75. /**
  76. * Set the current mixing matrix.
  77. */
  78. int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride);
  79. /* arch-specific initialization functions */
  80. void ff_audio_mix_init_x86(AudioMix *am);
  81. #endif /* AVRESAMPLE_AUDIO_MIX_H */