File: audio.h

package info (click to toggle)
gavl 2.0.0~svn6298-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,808 kB
  • sloc: ansic: 465,657; makefile: 325; sh: 109
file content (132 lines) | stat: -rw-r--r-- 4,206 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*****************************************************************
 * gavl - a general purpose audio/video processing library
 *
 * Copyright (c) 2001 - 2012 Members of the Gmerlin project
 * gmerlin-general@lists.sourceforge.net
 * http://gmerlin.sourceforge.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * *****************************************************************/

/* Private structures for the audio converter */

#include <gavl.h>
#include <samplerate.h>

#include "config.h"

struct gavl_audio_options_s
  {
  /*
   *  Quality setting from 1 to 5 (0 means undefined).
   *  3 means Standard C routines or accellerated version with
   *  equal quality. Lower numbers mean accellerated versions with lower
   *  quality.
   */
  int quality;         

  /* Explicit accel_flags are mainly for debugging purposes */
  uint32_t accel_flags;     /* CPU Acceleration flags */

  /* #defines from above */
    
  uint32_t conversion_flags;

  gavl_audio_dither_mode_t dither_mode;
  gavl_resample_mode_t resample_mode;
  
  const double ** mix_matrix;
  };

typedef struct gavl_audio_convert_context_s gavl_audio_convert_context_t;
typedef struct gavl_mix_matrix_s gavl_mix_matrix_t;

typedef void (*gavl_audio_func_t)(struct gavl_audio_convert_context_s * ctx);

typedef struct gavl_samplerate_converter_s gavl_samplerate_converter_t;

typedef struct gavl_audio_dither_context_s gavl_audio_dither_context_t;

struct gavl_samplerate_converter_s
  {
  int num_resamplers;
  SRC_STATE ** resamplers;
  SRC_DATA data;
  double ratio;
  };

struct gavl_audio_convert_context_s
  {
  const gavl_audio_frame_t * input_frame;
  gavl_audio_frame_t * output_frame;

  gavl_audio_format_t input_format;
  gavl_audio_format_t output_format;
  
  /* Conversion function to be called */

  gavl_audio_func_t func;

  /* Private data */
  
  gavl_mix_matrix_t * mix_matrix;
  gavl_samplerate_converter_t * samplerate_converter;
  gavl_audio_dither_context_t * dither_context;
    
  /* For chaining */
  
  struct gavl_audio_convert_context_s * next;
  };

gavl_audio_convert_context_t *
gavl_audio_convert_context_create(gavl_audio_format_t  * input_format,
                                  gavl_audio_format_t  * output_format);

gavl_audio_convert_context_t *
gavl_mix_context_create(gavl_audio_options_t * opt,
                        gavl_audio_format_t  * input_format,
                        gavl_audio_format_t  * output_format);

gavl_audio_convert_context_t *
gavl_interleave_context_create(gavl_audio_options_t * opt,
                               gavl_audio_format_t  * input_format,
                               gavl_audio_format_t  * output_format);

gavl_audio_convert_context_t *
gavl_sampleformat_context_create(gavl_audio_options_t * opt,
                                 gavl_audio_format_t  * input_format,
                                 gavl_audio_format_t  * output_format);

gavl_audio_convert_context_t *
gavl_samplerate_context_create(gavl_audio_options_t * opt,
                               gavl_audio_format_t  * input_format,
                               gavl_audio_format_t  * output_format);

/* Resampling support */

gavl_audio_convert_context_t *
gavl_samplerate_context_create(gavl_audio_options_t * opt,
                               gavl_audio_format_t  * input_format,
                               gavl_audio_format_t  * output_format);


/* Destroy samplerate converter */

void gavl_samplerate_converter_destroy(gavl_samplerate_converter_t * s);

/* Destroy dither context */

void gavl_audio_dither_context_destroy(gavl_audio_dither_context_t * s);