swresample.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
  3. *
  4. * This file is part of libswresample
  5. *
  6. * libswresample 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. * libswresample 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 libswresample; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef SWR_H
  21. #define SWR_H
  22. #include <inttypes.h>
  23. #include "libavutil/samplefmt.h"
  24. #define LIBSWRESAMPLE_VERSION_MAJOR 0
  25. #define LIBSWRESAMPLE_VERSION_MINOR 0
  26. #define LIBSWRESAMPLE_VERSION_MICRO 0
  27. #define SWR_CH_MAX 16
  28. #define SWR_FLAG_RESAMPLE 1///< Force resampling even if equal sample rate
  29. //TODO use int resample ?
  30. //long term TODO can we enable this dynamically?
  31. struct SwrContext;
  32. /**
  33. * Allocate SwrContext.
  34. * @see swr_init(),swr_free()
  35. * @return NULL on error
  36. */
  37. struct SwrContext *swr_alloc(void);
  38. /**
  39. * Initialize context after user parameters have been set.
  40. * @return negativo n error
  41. */
  42. int swr_init(struct SwrContext *s);
  43. /**
  44. * Allocate SwrContext.
  45. * @see swr_init(),swr_free()
  46. * @return NULL on error
  47. */
  48. struct SwrContext *swr_alloc2(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
  49. int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
  50. int log_offset, void *log_ctx);
  51. /**
  52. * Free the given SwrContext.
  53. * And set the pointer to NULL
  54. */
  55. void swr_free(struct SwrContext **s);
  56. /**
  57. * Convert audio.
  58. * @param in_count Number of input samples available in one channel.
  59. * @param out_count Amount of space available for output in samples per channel.
  60. * @return number of samples output per channel
  61. */
  62. int swr_convert(struct SwrContext *s, uint8_t *out[SWR_CH_MAX], int out_count,
  63. const uint8_t *in [SWR_CH_MAX], int in_count);
  64. void swr_compensate(struct SwrContext *s, int sample_delta, int compensation_distance);
  65. #endif