swresample_internal.h 2.8 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_INTERNAL_H
  21. #define SWR_INTERNAL_H
  22. #include "swresample.h"
  23. typedef struct AudioData{
  24. uint8_t *ch[SWR_CH_MAX];
  25. uint8_t *data;
  26. int ch_count;
  27. int bps;
  28. int count;
  29. int planar;
  30. } AudioData;
  31. typedef struct SwrContext { //FIXME find unused fields
  32. const AVClass *av_class;
  33. int log_level_offset;
  34. void *log_ctx;
  35. enum AVSampleFormat in_sample_fmt;
  36. enum AVSampleFormat int_sample_fmt; ///<AV_SAMPLE_FMT_FLT OR AV_SAMPLE_FMT_S16
  37. enum AVSampleFormat out_sample_fmt;
  38. int64_t in_ch_layout;
  39. int64_t out_ch_layout;
  40. int in_sample_rate;
  41. int out_sample_rate;
  42. int flags;
  43. float slev, clev;
  44. //below are private
  45. int int_bps;
  46. int resample_first;
  47. int rematrix; ///< flag to indicate if rematrixing is used
  48. AudioData in, postin, midbuf, preout, out, in_buffer;
  49. int in_buffer_index;
  50. int in_buffer_count;
  51. int resample_in_constraint;
  52. struct AVAudioConvert *in_convert;
  53. struct AVAudioConvert *out_convert;
  54. struct AVAudioConvert *full_convert;
  55. struct AVResampleContext *resample;
  56. float matrix[SWR_CH_MAX][SWR_CH_MAX];
  57. int16_t matrix16[SWR_CH_MAX][SWR_CH_MAX];
  58. uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1];
  59. //TODO callbacks for asm optims
  60. }SwrContext;
  61. struct AVResampleContext *swr_resample_init(struct AVResampleContext *, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff);
  62. void swr_resample_free(struct AVResampleContext **c);
  63. int swr_multiple_resample(struct AVResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed);
  64. void swr_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  65. int swr_resample(struct AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  66. int swr_rematrix_init(SwrContext *s);
  67. int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
  68. #endif