Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1905 serge 1
/*
2
	synth_8bit.h: Wrappers over optimized synth_xtoy for converting signed short to 8bit.
3
 
4
	copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
5
	see COPYING and AUTHORS files in distribution or http://mpg123.org
6
	initially written by Michael Hipp, code generalized to the wrapper by Thomas Orgis
7
 
8
	Only variable is the BLOCK size to choose 1to1, 2to1 or 4to1.
9
	Oh, and the names: BASE_SYNTH_NAME, SYNTH_NAME, MONO_NAME, MONO2STEREO_NAME
10
	(p.ex. opt_synth_1to1(fr), synth_1to1_8bit, synth_1to1_8bit_mono, ...).
11
*/
12
 
13
int SYNTH_NAME(real *bandPtr, int channel, mpg123_handle *fr, int final)
14
{
15
	short samples_tmp[BLOCK];
16
	short *tmp1 = samples_tmp + channel;
17
	int i,ret;
18
 
19
	unsigned char *samples = fr->buffer.data;
20
	int pnt = fr->buffer.fill;
21
	fr->buffer.data = (unsigned char*) samples_tmp;
22
	fr->buffer.fill = 0;
23
	ret = BASE_SYNTH_NAME(bandPtr, channel, fr , 0);
24
	fr->buffer.data = samples;
25
 
26
	samples += channel + pnt;
27
	for(i=0;i<(BLOCK/2);i++)
28
	{
29
		*samples = fr->conv16to8[*tmp1>>AUSHIFT];
30
		samples += 2;
31
		tmp1 += 2;
32
	}
33
	fr->buffer.fill = pnt + (final ? BLOCK : 0 );
34
 
35
	return ret;
36
}
37
 
38
int MONO_NAME(real *bandPtr, mpg123_handle *fr)
39
{
40
	short samples_tmp[BLOCK];
41
	short *tmp1 = samples_tmp;
42
	int i,ret;
43
 
44
	unsigned char *samples = fr->buffer.data;
45
	int pnt = fr->buffer.fill;
46
	fr->buffer.data = (unsigned char*) samples_tmp;
47
	fr->buffer.fill = 0;
48
	ret = BASE_SYNTH_NAME(bandPtr, 0, fr, 0);
49
	fr->buffer.data = samples;
50
 
51
	samples += pnt;
52
	for(i=0;i<(BLOCK/2);i++)
53
	{
54
		*samples++ = fr->conv16to8[*tmp1>>AUSHIFT];
55
		tmp1+=2;
56
	}
57
	fr->buffer.fill = pnt + BLOCK/2;
58
 
59
	return ret;
60
}
61
 
62
int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr)
63
{
64
	short samples_tmp[BLOCK];
65
	short *tmp1 = samples_tmp;
66
	int i,ret;
67
 
68
	unsigned char *samples = fr->buffer.data;
69
	int pnt = fr->buffer.fill;
70
	fr->buffer.data = (unsigned char*) samples_tmp;
71
	fr->buffer.fill = 0;
72
	ret = BASE_SYNTH_NAME(bandPtr, 0, fr, 0);
73
	fr->buffer.data = samples;
74
 
75
	samples += pnt;
76
	for(i=0;i<(BLOCK/2);i++)
77
	{
78
		*samples++ = fr->conv16to8[*tmp1>>AUSHIFT];
79
		*samples++ = fr->conv16to8[*tmp1>>AUSHIFT];
80
		tmp1 += 2;
81
	}
82
	fr->buffer.fill = pnt + BLOCK;
83
 
84
	return ret;
85
}
86