Mercurial > mplayer.hg
annotate libao2/pl_extrastereo.c @ 8739:66f3204117d6
trivial bigendian fix
author | colin |
---|---|
date | Fri, 03 Jan 2003 14:49:02 +0000 |
parents | 776b686069af |
children | 46d21c0f36aa |
rev | line source |
---|---|
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
1 /* Extrastereo effect plugin |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
2 * (linearly increases difference between L&R channels) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
3 * |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
4 * Current limitations: |
8739 | 5 * - only AFMT_S16_HE is supported currently |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
6 * |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
7 * License: GPLv2 (as a mix of pl_volume.c and |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
8 * xmms:stereo_plugin/stereo.c) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
9 * |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
10 * Author: pl <p_l@gmx.fr> (c) 2002 and beyond... |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
11 * */ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
12 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
13 #define PLUGIN |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
14 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
15 #include <stdio.h> |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
16 #include <stdlib.h> |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
17 #include <inttypes.h> |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
18 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
19 #include "audio_out.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
20 #include "audio_plugin.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
21 #include "audio_plugin_internal.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
22 #include "afmt.h" |
8739 | 23 #include "../config.h" |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
24 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
25 static ao_info_t info = { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
26 "Extra stereo plugin", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
27 "extrastereo", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
28 "pl <p_l@gmx.fr>", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
29 "" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
30 }; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
31 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
32 LIBAO_PLUGIN_EXTERN(extrastereo) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
33 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
34 // local data |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
35 static struct { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
36 float mul; // intensity |
6795 | 37 int inuse; // This plugin is in use TRUE, FALSE |
38 int format; // sample format | |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
39 } pl_extrastereo = {2.5, 0, 0}; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
40 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
41 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
42 // to set/get/query special features/parameters |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
43 static int control(int cmd,int arg){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
44 switch(cmd){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
45 case AOCONTROL_PLUGIN_SET_LEN: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
46 return CONTROL_OK; |
6795 | 47 case AOCONTROL_PLUGIN_ES_SET: |
48 pl_extrastereo.mul=*((float*)arg); | |
49 return CONTROL_OK; | |
50 case AOCONTROL_PLUGIN_ES_GET: | |
51 *((float*)arg)=pl_extrastereo.mul; | |
52 return CONTROL_OK; | |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
53 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
54 return CONTROL_UNKNOWN; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
55 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
56 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
57 // open & setup audio device |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
58 // return: 1=success 0=fail |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
59 static int init(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
60 switch(ao_plugin_data.format){ |
8739 | 61 #ifndef WORDS_BIGENDIAN |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
62 case(AFMT_S16_LE): |
8739 | 63 #else |
64 case(AFMT_S16_BE): | |
65 #endif | |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
66 break; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
67 default: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
68 fprintf(stderr,"[pl_extrastereo] Audio format not yet suported \n"); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
69 return 0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
70 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
71 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
72 pl_extrastereo.mul=ao_plugin_cfg.pl_extrastereo_mul; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
73 pl_extrastereo.format=ao_plugin_data.format; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
74 pl_extrastereo.inuse=1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
75 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
76 printf("[pl_extrastereo] Extra stereo plugin in use (multiplier=%2.2f).\n", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
77 pl_extrastereo.mul); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
78 return 1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
79 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
80 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
81 // close plugin |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
82 static void uninit(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
83 pl_extrastereo.inuse=0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
84 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
85 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
86 // empty buffers |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
87 static void reset(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
88 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
89 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
90 // processes 'ao_plugin_data.len' bytes of 'data' |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
91 // called for every block of data |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
92 static int play(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
93 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
94 switch(pl_extrastereo.format){ |
8739 | 95 #ifndef WORDS_BIGENDIAN |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
96 case(AFMT_S16_LE): { |
8739 | 97 #else |
98 case(AFMT_S16_BE): { | |
99 #endif | |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
100 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
101 int16_t* data=(int16_t*)ao_plugin_data.data; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
102 int len=ao_plugin_data.len / 2; // 16 bits samples |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
103 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
104 float mul = pl_extrastereo.mul; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
105 int32_t i, avg, ltmp, rtmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
106 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
107 for (i=0; i < len ; i += 2) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
108 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
109 avg = (data[i] + data[i + 1]) / 2; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
110 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
111 ltmp = avg + (int) (mul * (data[i] - avg)); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
112 rtmp = avg + (int) (mul * (data[i + 1] - avg)); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
113 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
114 if (ltmp < -32768) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
115 ltmp = -32768; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
116 } else if (ltmp > 32767) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
117 ltmp = 32767; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
118 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
119 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
120 if (rtmp < -32768) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
121 rtmp = -32768; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
122 } else if (rtmp > 32767) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
123 rtmp = 32767; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
124 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
125 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
126 data[i] = ltmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
127 data[i + 1] = rtmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
128 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
129 break; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
130 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
131 default: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
132 return 0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
133 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
134 return 1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
135 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
136 |