resample.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVRESAMPLE_RESAMPLE_H
  21. #define AVRESAMPLE_RESAMPLE_H
  22. #include "avresample.h"
  23. #include "internal.h"
  24. #include "audio_data.h"
  25. /**
  26. * Allocate and initialize a ResampleContext.
  27. *
  28. * The parameters in the AVAudioResampleContext are used to initialize the
  29. * ResampleContext.
  30. *
  31. * @param avr AVAudioResampleContext
  32. * @return newly-allocated ResampleContext
  33. */
  34. ResampleContext *ff_audio_resample_init(AVAudioResampleContext *avr);
  35. /**
  36. * Free a ResampleContext.
  37. *
  38. * @param c ResampleContext
  39. */
  40. void ff_audio_resample_free(ResampleContext **c);
  41. /**
  42. * Resample audio data.
  43. *
  44. * Changes the sample rate.
  45. *
  46. * @par
  47. * All samples in the source data may not be consumed depending on the
  48. * resampling parameters and the size of the output buffer. The unconsumed
  49. * samples are automatically added to the start of the source in the next call.
  50. * If the destination data can be reallocated, that may be done in this function
  51. * in order to fit all available output. If it cannot be reallocated, fewer
  52. * input samples will be consumed in order to have the output fit in the
  53. * destination data buffers.
  54. *
  55. * @param c ResampleContext
  56. * @param dst destination audio data
  57. * @param src source audio data
  58. * @return 0 on success, negative AVERROR code on failure
  59. */
  60. int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src);
  61. #endif /* AVRESAMPLE_RESAMPLE_H */