internal.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_INTERNAL_H
  21. #define AVRESAMPLE_INTERNAL_H
  22. #include "libavutil/audio_fifo.h"
  23. #include "libavutil/log.h"
  24. #include "libavutil/opt.h"
  25. #include "libavutil/samplefmt.h"
  26. #include "avresample.h"
  27. typedef struct AudioData AudioData;
  28. typedef struct AudioConvert AudioConvert;
  29. typedef struct AudioMix AudioMix;
  30. typedef struct ResampleContext ResampleContext;
  31. enum RemapPoint {
  32. REMAP_NONE,
  33. REMAP_IN_COPY,
  34. REMAP_IN_CONVERT,
  35. REMAP_OUT_COPY,
  36. REMAP_OUT_CONVERT,
  37. };
  38. typedef struct ChannelMapInfo {
  39. int channel_map[AVRESAMPLE_MAX_CHANNELS]; /**< source index of each output channel, -1 if not remapped */
  40. int do_remap; /**< remap needed */
  41. int channel_copy[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to copy from */
  42. int do_copy; /**< copy needed */
  43. int channel_zero[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to zero */
  44. int do_zero; /**< zeroing needed */
  45. int input_map[AVRESAMPLE_MAX_CHANNELS]; /**< dest index of each input channel */
  46. } ChannelMapInfo;
  47. struct AVAudioResampleContext {
  48. const AVClass *av_class; /**< AVClass for logging and AVOptions */
  49. uint64_t in_channel_layout; /**< input channel layout */
  50. enum AVSampleFormat in_sample_fmt; /**< input sample format */
  51. int in_sample_rate; /**< input sample rate */
  52. uint64_t out_channel_layout; /**< output channel layout */
  53. enum AVSampleFormat out_sample_fmt; /**< output sample format */
  54. int out_sample_rate; /**< output sample rate */
  55. enum AVSampleFormat internal_sample_fmt; /**< internal sample format */
  56. enum AVMixCoeffType mix_coeff_type; /**< mixing coefficient type */
  57. double center_mix_level; /**< center mix level */
  58. double surround_mix_level; /**< surround mix level */
  59. double lfe_mix_level; /**< lfe mix level */
  60. int normalize_mix_level; /**< enable mix level normalization */
  61. int force_resampling; /**< force resampling */
  62. int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */
  63. int phase_shift; /**< log2 of the number of entries in the resampling polyphase filterbank */
  64. int linear_interp; /**< if 1 then the resampling FIR filter will be linearly interpolated */
  65. double cutoff; /**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */
  66. enum AVResampleFilterType filter_type; /**< resampling filter type */
  67. int kaiser_beta; /**< beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) */
  68. enum AVResampleDitherMethod dither_method; /**< dither method */
  69. int in_channels; /**< number of input channels */
  70. int out_channels; /**< number of output channels */
  71. int resample_channels; /**< number of channels used for resampling */
  72. int downmix_needed; /**< downmixing is needed */
  73. int upmix_needed; /**< upmixing is needed */
  74. int mixing_needed; /**< either upmixing or downmixing is needed */
  75. int resample_needed; /**< resampling is needed */
  76. int in_convert_needed; /**< input sample format conversion is needed */
  77. int out_convert_needed; /**< output sample format conversion is needed */
  78. int in_copy_needed; /**< input data copy is needed */
  79. AudioData *in_buffer; /**< buffer for converted input */
  80. AudioData *resample_out_buffer; /**< buffer for output from resampler */
  81. AudioData *out_buffer; /**< buffer for converted output */
  82. AVAudioFifo *out_fifo; /**< FIFO for output samples */
  83. AudioConvert *ac_in; /**< input sample format conversion context */
  84. AudioConvert *ac_out; /**< output sample format conversion context */
  85. ResampleContext *resample; /**< resampling context */
  86. AudioMix *am; /**< channel mixing context */
  87. enum AVMatrixEncoding matrix_encoding; /**< matrixed stereo encoding */
  88. /**
  89. * mix matrix
  90. * only used if avresample_set_matrix() is called before avresample_open()
  91. */
  92. double *mix_matrix;
  93. int use_channel_map;
  94. enum RemapPoint remap_point;
  95. ChannelMapInfo ch_map_info;
  96. };
  97. void ff_audio_resample_init_aarch64(ResampleContext *c,
  98. enum AVSampleFormat sample_fmt);
  99. void ff_audio_resample_init_arm(ResampleContext *c,
  100. enum AVSampleFormat sample_fmt);
  101. #endif /* AVRESAMPLE_INTERNAL_H */