1 /*
2  * This file is part of mpv.
3  *
4  * mpv is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * mpv is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with mpv.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MPLAYER_AF_FORMAT_H
19 #define MPLAYER_AF_FORMAT_H
20 
21 #include <stddef.h>
22 #include <stdbool.h>
23 
24 enum af_format {
25     AF_FORMAT_UNKNOWN = 0,
26 
27     AF_FORMAT_U8,
28     AF_FORMAT_S16,
29     AF_FORMAT_S32,
30     AF_FORMAT_S64,
31     AF_FORMAT_FLOAT,
32     AF_FORMAT_DOUBLE,
33 
34     // Planar variants
35     AF_FORMAT_U8P,
36     AF_FORMAT_S16P,
37     AF_FORMAT_S32P,
38     AF_FORMAT_S64P,
39     AF_FORMAT_FLOATP,
40     AF_FORMAT_DOUBLEP,
41 
42     // All of these use IEC61937 framing, and otherwise pretend to be like PCM.
43     AF_FORMAT_S_AAC,
44     AF_FORMAT_S_AC3,
45     AF_FORMAT_S_DTS,
46     AF_FORMAT_S_DTSHD,
47     AF_FORMAT_S_EAC3,
48     AF_FORMAT_S_MP3,
49     AF_FORMAT_S_TRUEHD,
50 
51     AF_FORMAT_COUNT
52 };
53 
54 const char *af_fmt_to_str(int format);
55 
56 int af_fmt_to_bytes(int format);
57 
58 bool af_fmt_is_valid(int format);
59 bool af_fmt_is_unsigned(int format);
60 bool af_fmt_is_float(int format);
61 bool af_fmt_is_int(int format);
62 bool af_fmt_is_planar(int format);
63 bool af_fmt_is_spdif(int format);
64 bool af_fmt_is_pcm(int format);
65 
66 int af_fmt_to_planar(int format);
67 int af_fmt_from_planar(int format);
68 
69 void af_fill_silence(void *dst, size_t bytes, int format);
70 
71 void af_get_best_sample_formats(int src_format, int *out_formats);
72 int af_format_conversion_score(int dst_format, int src_format);
73 int af_select_best_samplerate(int src_sampelrate, const int *available);
74 
75 int af_format_sample_alignment(int format);
76 
77 #endif /* MPLAYER_AF_FORMAT_H */
78