annotate src/audacious/xconvert.c @ 2901:5ed0674fabd6 trunk

replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
author Tomasz Mon <desowin@gmail.com>
date Sun, 24 Jun 2007 15:55:32 +0200
parents 3ec22a11c83e
children 3b6d316f8b09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2431
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
1 /* Audacious
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious team
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
3 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
4 * XMMS - Cross-platform multimedia player
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
5 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
6 * Thomas Nilsson and 4Front Technologies
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
7 * Copyright (C) 1999-2003 Haavard Kvaalen
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
8 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
11 * the Free Software Foundation; under version 2 of the License.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
12 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
16 * GNU General Public License for more details.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
17 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
21 */
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
22
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
23 #include "config.h"
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
24 #include <stdlib.h>
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
25 #include <audacious/plugin.h>
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
26 #include "xconvert.h"
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
27
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
28 #define IS_BIG_ENDIAN (G_BYTE_ORDER==G_BIG_ENDIAN)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
29
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
30 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
31 * buffer:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
32 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
33 * Contains data for conversion.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
34 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
35 * @buffer: A pointer to the memory being used in the conversion process.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
36 * @size: The size of the memory being referenced.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
37 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
38 struct buffer {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
39 void *buffer;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
40 int size;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
41 };
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
42
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
43 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
44 * xmms_convert_buffers:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
45 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
46 * Stores data for conversion.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
47 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
48 * @format_buffer: A buffer for converting formats.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
49 * @stereo_buffer: A buffer for downmixing or upmixing.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
50 * @freq_buffer: A buffer used for resampling.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
51 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
52 struct xmms_convert_buffers {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
53 struct buffer format_buffer, stereo_buffer, freq_buffer;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
54 };
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
55
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
56 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
57 * xmms_convert_buffers_new:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
58 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
59 * Factory for an #xmms_convert_buffers struct.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
60 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
61 * Return value: An #xmms_convert_buffers struct.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
62 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
63 struct xmms_convert_buffers *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
64 xmms_convert_buffers_new(void)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
65 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
66 return g_malloc0(sizeof(struct xmms_convert_buffers));
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
67 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
68
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
69 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
70 * convert_get_buffer:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
71 * @buffer: A buffer to resize.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
72 * @size: The new size for that buffer.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
73 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
74 * Resizes a conversion buffer.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
75 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
76 static void *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
77 convert_get_buffer(struct buffer *buffer, size_t size)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
78 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
79 if (size > 0 && size <= (size_t)buffer->size)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
80 return buffer->buffer;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
81
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
82 buffer->size = size;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
83 buffer->buffer = g_realloc(buffer->buffer, size);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
84 return buffer->buffer;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
85 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
86
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
87 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
88 * xmms_convert_buffers_free:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
89 * @buf: An xmms_convert_buffers structure to free.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
90 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
91 * Frees the actual buffers contained inside the buffer struct.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
92 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
93 void
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
94 xmms_convert_buffers_free(struct xmms_convert_buffers *buf)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
95 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
96 convert_get_buffer(&buf->format_buffer, 0);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
97 convert_get_buffer(&buf->stereo_buffer, 0);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
98 convert_get_buffer(&buf->freq_buffer, 0);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
99 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
100
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
101 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
102 * xmms_convert_buffers_destroy:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
103 * @buf: An xmms_convert_buffers structure to destroy.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
104 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
105 * Destroys an xmms_convert_buffers structure.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
106 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
107 void
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
108 xmms_convert_buffers_destroy(struct xmms_convert_buffers *buf)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
109 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
110 if (!buf)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
111 return;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
112 xmms_convert_buffers_free(buf);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
113 g_free(buf);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
114 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
115
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
116 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
117 convert_swap_endian(struct xmms_convert_buffers *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
118 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
119 guint16 *ptr = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
120 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
121 for (i = 0; i < length; i += 2, ptr++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
122 *ptr = GUINT16_SWAP_LE_BE(*ptr);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
123
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
124 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
125 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
126
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
127 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
128 convert_swap_sign_and_endian_to_native(struct
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
129 xmms_convert_buffers
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
130 *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
131 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
132 guint16 *ptr = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
133 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
134 for (i = 0; i < length; i += 2, ptr++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
135 *ptr = GUINT16_SWAP_LE_BE(*ptr) ^ 1 << 15;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
136
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
137 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
138 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
139
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
140 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
141 convert_swap_sign_and_endian_to_alien(struct
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
142 xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
143 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
144 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
145 guint16 *ptr = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
146 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
147 for (i = 0; i < length; i += 2, ptr++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
148 *ptr = GUINT16_SWAP_LE_BE(*ptr ^ 1 << 15);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
149
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
150 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
151 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
152
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
153 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
154 convert_swap_sign16(struct xmms_convert_buffers *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
155 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
156 gint16 *ptr = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
157 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
158 for (i = 0; i < length; i += 2, ptr++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
159 *ptr ^= 1 << 15;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
160
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
161 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
162 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
163
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
164 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
165 convert_swap_sign8(struct xmms_convert_buffers *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
166 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
167 gint8 *ptr = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
168 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
169 for (i = 0; i < length; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
170 *ptr++ ^= 1 << 7;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
171
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
172 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
173 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
174
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
175 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
176 convert_to_8_native_endian(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
177 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
178 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
179 gint8 *output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
180 gint16 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
181 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
182 for (i = 0; i < length / 2; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
183 *output++ = *input++ >> 8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
184
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
185 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
186 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
187
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
188 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
189 convert_to_8_native_endian_swap_sign(struct xmms_convert_buffers
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
190 *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
191 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
192 gint8 *output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
193 gint16 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
194 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
195 for (i = 0; i < length / 2; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
196 *output++ = (*input++ >> 8) ^ (1 << 7);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
197
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
198 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
199 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
200
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
201
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
202 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
203 convert_to_8_alien_endian(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
204 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
205 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
206 gint8 *output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
207 gint16 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
208 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
209 for (i = 0; i < length / 2; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
210 *output++ = *input++ & 0xff;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
211
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
212 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
213 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
214
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
215 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
216 convert_to_8_alien_endian_swap_sign(struct xmms_convert_buffers
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
217 *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
218 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
219 gint8 *output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
220 gint16 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
221 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
222 for (i = 0; i < length / 2; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
223 *output++ = (*input++ & 0xff) ^ (1 << 7);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
224
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
225 return i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
226 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
227
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
228 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
229 convert_to_16_native_endian(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
230 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
231 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
232 guint8 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
233 guint16 *output;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
234 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
235 *data = convert_get_buffer(&buf->format_buffer, length * 2);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
236 output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
237 for (i = 0; i < length; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
238 *output++ = *input++ << 8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
239
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
240 return i * 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
241 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
242
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
243 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
244 convert_to_16_native_endian_swap_sign(struct
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
245 xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
246 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
247 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
248 guint8 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
249 guint16 *output;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
250 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
251 *data = convert_get_buffer(&buf->format_buffer, length * 2);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
252 output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
253 for (i = 0; i < length; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
254 *output++ = (*input++ << 8) ^ (1 << 15);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
255
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
256 return i * 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
257 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
258
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
259
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
260 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
261 convert_to_16_alien_endian(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
262 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
263 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
264 guint8 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
265 guint16 *output;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
266 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
267 *data = convert_get_buffer(&buf->format_buffer, length * 2);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
268 output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
269 for (i = 0; i < length; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
270 *output++ = *input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
271
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
272 return i * 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
273 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
274
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
275 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
276 convert_to_16_alien_endian_swap_sign(struct xmms_convert_buffers
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
277 *buf, void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
278 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
279 guint8 *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
280 guint16 *output;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
281 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
282 *data = convert_get_buffer(&buf->format_buffer, length * 2);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
283 output = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
284 for (i = 0; i < length; i++)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
285 *output++ = *input++ ^ (1 << 7);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
286
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
287 return i * 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
288 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
289
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
290 static AFormat
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
291 unnativize(AFormat fmt)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
292 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
293 if (fmt == FMT_S16_NE) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
294 if (IS_BIG_ENDIAN)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
295 return FMT_S16_BE;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
296 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
297 return FMT_S16_LE;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
298 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
299 if (fmt == FMT_U16_NE) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
300 if (IS_BIG_ENDIAN)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
301 return FMT_U16_BE;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
302 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
303 return FMT_U16_LE;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
304 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
305 return fmt;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
306 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
307
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
308 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
309 * xmms_convert_get_func:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
310 * @output: A format to output data as.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
311 * @input: The format of the inbound data.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
312 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
313 * Looks up the proper conversion method to use.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
314 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
315 * Return value: A function pointer to the desired conversion function.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
316 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
317 convert_func_t
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
318 xmms_convert_get_func(AFormat output, AFormat input)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
319 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
320 output = unnativize(output);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
321 input = unnativize(input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
322
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
323 if (output == input)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
324 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
325
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
326 if ((output == FMT_U16_BE && input == FMT_U16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
327 (output == FMT_U16_LE && input == FMT_U16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
328 (output == FMT_S16_BE && input == FMT_S16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
329 (output == FMT_S16_LE && input == FMT_S16_BE))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
330 return convert_swap_endian;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
331
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
332 if ((output == FMT_U16_BE && input == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
333 (output == FMT_U16_LE && input == FMT_S16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
334 (output == FMT_S16_BE && input == FMT_U16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
335 (output == FMT_S16_LE && input == FMT_U16_LE))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
336 return convert_swap_sign16;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
337
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
338 if ((IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
339 ((output == FMT_U16_BE && input == FMT_S16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
340 (output == FMT_S16_BE && input == FMT_U16_LE))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
341 (!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
342 ((output == FMT_U16_LE && input == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
343 (output == FMT_S16_LE && input == FMT_U16_BE))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
344 return convert_swap_sign_and_endian_to_native;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
345
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
346 if ((!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
347 ((output == FMT_U16_BE && input == FMT_S16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
348 (output == FMT_S16_BE && input == FMT_U16_LE))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
349 (IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
350 ((output == FMT_U16_LE && input == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
351 (output == FMT_S16_LE && input == FMT_U16_BE))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
352 return convert_swap_sign_and_endian_to_alien;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
353
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
354 if ((IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
355 ((output == FMT_U8 && input == FMT_U16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
356 (output == FMT_S8 && input == FMT_S16_BE))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
357 (!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
358 ((output == FMT_U8 && input == FMT_U16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
359 (output == FMT_S8 && input == FMT_S16_LE))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
360 return convert_to_8_native_endian;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
361
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
362 if ((IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
363 ((output == FMT_U8 && input == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
364 (output == FMT_S8 && input == FMT_U16_BE))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
365 (!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
366 ((output == FMT_U8 && input == FMT_S16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
367 (output == FMT_S8 && input == FMT_U16_LE))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
368 return convert_to_8_native_endian_swap_sign;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
369
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
370 if ((!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
371 ((output == FMT_U8 && input == FMT_U16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
372 (output == FMT_S8 && input == FMT_S16_BE))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
373 (IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
374 ((output == FMT_U8 && input == FMT_U16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
375 (output == FMT_S8 && input == FMT_S16_LE))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
376 return convert_to_8_alien_endian;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
377
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
378 if ((!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
379 ((output == FMT_U8 && input == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
380 (output == FMT_S8 && input == FMT_U16_BE))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
381 (IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
382 ((output == FMT_U8 && input == FMT_S16_LE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
383 (output == FMT_S8 && input == FMT_U16_LE))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
384 return convert_to_8_alien_endian_swap_sign;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
385
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
386 if ((output == FMT_U8 && input == FMT_S8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
387 (output == FMT_S8 && input == FMT_U8))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
388 return convert_swap_sign8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
389
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
390 if ((IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
391 ((output == FMT_U16_BE && input == FMT_U8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
392 (output == FMT_S16_BE && input == FMT_S8))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
393 (!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
394 ((output == FMT_U16_LE && input == FMT_U8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
395 (output == FMT_S16_LE && input == FMT_S8))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
396 return convert_to_16_native_endian;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
397
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
398 if ((IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
399 ((output == FMT_U16_BE && input == FMT_S8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
400 (output == FMT_S16_BE && input == FMT_U8))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
401 (!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
402 ((output == FMT_U16_LE && input == FMT_S8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
403 (output == FMT_S16_LE && input == FMT_U8))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
404 return convert_to_16_native_endian_swap_sign;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
405
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
406 if ((!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
407 ((output == FMT_U16_BE && input == FMT_U8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
408 (output == FMT_S16_BE && input == FMT_S8))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
409 (IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
410 ((output == FMT_U16_LE && input == FMT_U8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
411 (output == FMT_S16_LE && input == FMT_S8))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
412 return convert_to_16_alien_endian;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
413
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
414 if ((!IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
415 ((output == FMT_U16_BE && input == FMT_S8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
416 (output == FMT_S16_BE && input == FMT_U8))) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
417 (IS_BIG_ENDIAN &&
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
418 ((output == FMT_U16_LE && input == FMT_S8) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
419 (output == FMT_S16_LE && input == FMT_U8))))
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
420 return convert_to_16_alien_endian_swap_sign;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
421
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
422 g_warning("Translation needed, but not available.\n"
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
423 "Input: %d; Output %d.", input, output);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
424 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
425 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
426
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
427 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
428 convert_mono_to_stereo(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
429 void **data, int length, int b16)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
430 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
431 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
432 void *outbuf = convert_get_buffer(&buf->stereo_buffer, length * 2);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
433
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
434 if (b16) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
435 guint16 *output = outbuf, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
436 for (i = 0; i < length / 2; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
437 *output++ = *input;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
438 *output++ = *input;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
439 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
440 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
441 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
442 else {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
443 guint8 *output = outbuf, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
444 for (i = 0; i < length; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
445 *output++ = *input;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
446 *output++ = *input;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
447 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
448 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
449 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
450 *data = outbuf;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
451
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
452 return length * 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
453 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
454
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
455 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
456 convert_mono_to_stereo_8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
457 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
458 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
459 return convert_mono_to_stereo(buf, data, length, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
460 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
461
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
462 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
463 convert_mono_to_stereo_16(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
464 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
465 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
466 return convert_mono_to_stereo(buf, data, length, TRUE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
467 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
468
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
469 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
470 convert_stereo_to_mono_u8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
471 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
472 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
473 guint8 *output = *data, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
474 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
475 for (i = 0; i < length / 2; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
476 guint16 tmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
477 tmp = *input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
478 tmp += *input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
479 *output++ = tmp / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
480 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
481 return length / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
482 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
483 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
484 convert_stereo_to_mono_s8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
485 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
486 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
487 gint8 *output = *data, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
488 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
489 for (i = 0; i < length / 2; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
490 gint16 tmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
491 tmp = *input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
492 tmp += *input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
493 *output++ = tmp / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
494 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
495 return length / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
496 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
497 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
498 convert_stereo_to_mono_u16le(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
499 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
500 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
501 guint16 *output = *data, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
502 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
503 for (i = 0; i < length / 4; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
504 guint32 tmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
505 guint16 stmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
506 tmp = GUINT16_FROM_LE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
507 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
508 tmp += GUINT16_FROM_LE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
509 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
510 stmp = tmp / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
511 *output++ = GUINT16_TO_LE(stmp);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
512 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
513 return length / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
514 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
515
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
516 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
517 convert_stereo_to_mono_u16be(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
518 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
519 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
520 guint16 *output = *data, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
521 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
522 for (i = 0; i < length / 4; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
523 guint32 tmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
524 guint16 stmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
525 tmp = GUINT16_FROM_BE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
526 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
527 tmp += GUINT16_FROM_BE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
528 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
529 stmp = tmp / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
530 *output++ = GUINT16_TO_BE(stmp);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
531 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
532 return length / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
533 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
534
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
535 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
536 convert_stereo_to_mono_s16le(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
537 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
538 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
539 gint16 *output = *data, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
540 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
541 for (i = 0; i < length / 4; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
542 gint32 tmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
543 gint16 stmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
544 tmp = GINT16_FROM_LE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
545 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
546 tmp += GINT16_FROM_LE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
547 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
548 stmp = tmp / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
549 *output++ = GINT16_TO_LE(stmp);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
550 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
551 return length / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
552 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
553
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
554 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
555 convert_stereo_to_mono_s16be(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
556 void **data, int length)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
557 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
558 gint16 *output = *data, *input = *data;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
559 int i;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
560 for (i = 0; i < length / 4; i++) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
561 gint32 tmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
562 gint16 stmp;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
563 tmp = GINT16_FROM_BE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
564 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
565 tmp += GINT16_FROM_BE(*input);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
566 input++;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
567 stmp = tmp / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
568 *output++ = GINT16_TO_BE(stmp);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
569 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
570 return length / 2;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
571 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
572
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
573 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
574 * xmms_convert_get_channel_func:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
575 * @fmt: The format of the data.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
576 * @output: The number of channels to output as.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
577 * @input: The number of channels inbound.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
578 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
579 * Looks up the proper conversion method to use.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
580 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
581 * Return value: A function pointer to the desired conversion function.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
582 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
583 convert_channel_func_t
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
584 xmms_convert_get_channel_func(AFormat fmt, int output, int input)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
585 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
586 fmt = unnativize(fmt);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
587
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
588 if (output == input)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
589 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
590
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
591 if (input == 1 && output == 2)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
592 switch (fmt) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
593 case FMT_U8:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
594 case FMT_S8:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
595 return convert_mono_to_stereo_8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
596 case FMT_U16_LE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
597 case FMT_U16_BE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
598 case FMT_S16_LE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
599 case FMT_S16_BE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
600 return convert_mono_to_stereo_16;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
601 default:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
602 g_warning("Unknown format: %d" "No conversion available.", fmt);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
603 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
604 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
605 if (input == 2 && output == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
606 switch (fmt) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
607 case FMT_U8:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
608 return convert_stereo_to_mono_u8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
609 case FMT_S8:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
610 return convert_stereo_to_mono_s8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
611 case FMT_U16_LE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
612 return convert_stereo_to_mono_u16le;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
613 case FMT_U16_BE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
614 return convert_stereo_to_mono_u16be;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
615 case FMT_S16_LE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
616 return convert_stereo_to_mono_s16le;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
617 case FMT_S16_BE:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
618 return convert_stereo_to_mono_s16be;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
619 default:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
620 g_warning("Unknown format: %d. "
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
621 "No conversion available.", fmt);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
622 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
623
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
624 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
625
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
626 g_warning("Input has %d channels, soundcard uses %d channels\n"
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
627 "No conversion is available", input, output);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
628 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
629 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
630
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
631
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
632 #define RESAMPLE_STEREO(sample_type, bswap) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
633 const int shift = sizeof (sample_type); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
634 int i, in_samples, out_samples, x, delta; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
635 sample_type *inptr = *data, *outptr; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
636 guint nlen = (((length >> shift) * ofreq) / ifreq); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
637 void *nbuf; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
638 if (nlen == 0) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
639 return 0; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
640 nlen <<= shift; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
641 if (bswap) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
642 convert_swap_endian(NULL, data, length); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
643 nbuf = convert_get_buffer(&buf->freq_buffer, nlen); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
644 outptr = nbuf; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
645 in_samples = length >> shift; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
646 out_samples = nlen >> shift; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
647 delta = (in_samples << 12) / out_samples; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
648 for (x = 0, i = 0; i < out_samples; i++) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
649 { \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
650 int x1, frac; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
651 x1 = (x >> 12) << 12; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
652 frac = x - x1; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
653 *outptr++ = \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
654 ((inptr[(x1 >> 12) << 1] * \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
655 ((1<<12) - frac) + \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
656 inptr[((x1 >> 12) + 1) << 1] * \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
657 frac) >> 12); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
658 *outptr++ = \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
659 ((inptr[((x1 >> 12) << 1) + 1] * \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
660 ((1<<12) - frac) + \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
661 inptr[(((x1 >> 12) + 1) << 1) + 1] * \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
662 frac) >> 12); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
663 x += delta; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
664 } \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
665 if (bswap) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
666 convert_swap_endian(NULL, &nbuf, nlen); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
667 *data = nbuf; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
668 return nlen; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
669
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
670
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
671 #define RESAMPLE_MONO(sample_type, bswap) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
672 const int shift = sizeof (sample_type) - 1; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
673 int i, x, delta, in_samples, out_samples; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
674 sample_type *inptr = *data, *outptr; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
675 guint nlen = (((length >> shift) * ofreq) / ifreq); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
676 void *nbuf; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
677 if (nlen == 0) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
678 return 0; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
679 nlen <<= shift; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
680 if (bswap) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
681 convert_swap_endian(NULL, data, length); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
682 nbuf = convert_get_buffer(&buf->freq_buffer, nlen); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
683 outptr = nbuf; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
684 in_samples = length >> shift; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
685 out_samples = nlen >> shift; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
686 delta = ((length >> shift) << 12) / out_samples; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
687 for (x = 0, i = 0; i < out_samples; i++) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
688 { \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
689 int x1, frac; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
690 x1 = (x >> 12) << 12; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
691 frac = x - x1; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
692 *outptr++ = \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
693 ((inptr[x1 >> 12] * ((1<<12) - frac) + \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
694 inptr[(x1 >> 12) + 1] * frac) >> 12); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
695 x += delta; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
696 } \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
697 if (bswap) \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
698 convert_swap_endian(NULL, &nbuf, nlen); \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
699 *data = nbuf; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
700 return nlen; \
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
701
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
702 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
703 convert_resample_stereo_s16ne(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
704 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
705 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
706 RESAMPLE_STEREO(gint16, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
707 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
708
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
709 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
710 convert_resample_stereo_s16ae(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
711 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
712 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
713 RESAMPLE_STEREO(gint16, TRUE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
714 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
715
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
716 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
717 convert_resample_stereo_u16ne(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
718 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
719 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
720 RESAMPLE_STEREO(guint16, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
721 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
722
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
723 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
724 convert_resample_stereo_u16ae(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
725 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
726 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
727 RESAMPLE_STEREO(guint16, TRUE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
728 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
729
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
730 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
731 convert_resample_mono_s16ne(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
732 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
733 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
734 RESAMPLE_MONO(gint16, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
735 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
736
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
737 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
738 convert_resample_mono_s16ae(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
739 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
740 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
741 RESAMPLE_MONO(gint16, TRUE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
742 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
743
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
744 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
745 convert_resample_mono_u16ne(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
746 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
747 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
748 RESAMPLE_MONO(guint16, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
749 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
750
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
751 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
752 convert_resample_mono_u16ae(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
753 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
754 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
755 RESAMPLE_MONO(guint16, TRUE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
756 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
757
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
758 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
759 convert_resample_stereo_u8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
760 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
761 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
762 RESAMPLE_STEREO(guint8, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
763 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
764
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
765 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
766 convert_resample_mono_u8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
767 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
768 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
769 RESAMPLE_MONO(guint8, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
770 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
771
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
772 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
773 convert_resample_stereo_s8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
774 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
775 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
776 RESAMPLE_STEREO(gint8, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
777 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
778
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
779 static int
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
780 convert_resample_mono_s8(struct xmms_convert_buffers *buf,
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
781 void **data, int length, int ifreq, int ofreq)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
782 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
783 RESAMPLE_MONO(gint8, FALSE);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
784 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
785
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
786
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
787 /**
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
788 * xmms_convert_get_frequency_func:
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
789 * @fmt: The format of the data.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
790 * @channels: The number of channels inbound.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
791 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
792 * Looks up the proper conversion method to use.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
793 *
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
794 * Return value: A function pointer to the desired conversion function.
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
795 **/
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
796 convert_freq_func_t
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
797 xmms_convert_get_frequency_func(AFormat fmt, int channels)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
798 {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
799 fmt = unnativize(fmt);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
800 g_message("fmt %d, channels: %d", fmt, channels);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
801
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
802 if (channels < 1 || channels > 2) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
803 g_warning("Unsupported number of channels: %d. "
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
804 "Resample function not available", channels);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
805 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
806 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
807 if ((IS_BIG_ENDIAN && fmt == FMT_U16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
808 (!IS_BIG_ENDIAN && fmt == FMT_U16_LE)) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
809 if (channels == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
810 return convert_resample_mono_u16ne;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
811 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
812 return convert_resample_stereo_u16ne;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
813 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
814 if ((IS_BIG_ENDIAN && fmt == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
815 (!IS_BIG_ENDIAN && fmt == FMT_S16_LE)) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
816 if (channels == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
817 return convert_resample_mono_s16ne;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
818 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
819 return convert_resample_stereo_s16ne;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
820 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
821 if ((!IS_BIG_ENDIAN && fmt == FMT_U16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
822 (IS_BIG_ENDIAN && fmt == FMT_U16_LE)) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
823 if (channels == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
824 return convert_resample_mono_u16ae;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
825 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
826 return convert_resample_stereo_u16ae;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
827 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
828 if ((!IS_BIG_ENDIAN && fmt == FMT_S16_BE) ||
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
829 (IS_BIG_ENDIAN && fmt == FMT_S16_LE)) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
830 if (channels == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
831 return convert_resample_mono_s16ae;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
832 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
833 return convert_resample_stereo_s16ae;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
834 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
835 if (fmt == FMT_U8) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
836 if (channels == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
837 return convert_resample_mono_u8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
838 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
839 return convert_resample_stereo_u8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
840 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
841 if (fmt == FMT_S8) {
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
842 if (channels == 1)
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
843 return convert_resample_mono_s8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
844 else
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
845 return convert_resample_stereo_s8;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
846 }
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
847 g_warning("Resample function not available" "Format %d.", fmt);
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
848 return NULL;
3ec22a11c83e [svn] - moved titlestring.* and xconvert.* from libaudacious to audacious
mf0102
parents:
diff changeset
849 }