Mercurial > mplayer.hg
annotate libao2/pl_extrastereo.c @ 6005:10ef69b1dcf3
updated -vop scale parameters
author | arpi |
---|---|
date | Mon, 06 May 2002 23:04:55 +0000 |
parents | 3022570ad7d4 |
children | 776b686069af |
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: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
5 * - only AFMT_S16_LE is supported currently |
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" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
23 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
24 static ao_info_t info = { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
25 "Extra stereo plugin", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
26 "extrastereo", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
27 "pl <p_l@gmx.fr>", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
28 "" |
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 LIBAO_PLUGIN_EXTERN(extrastereo) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
32 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
33 // local data |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
34 static struct { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
35 float mul; // intensity |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
36 int inuse; // This plugin is in use TRUE, FALSE |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
37 int format; // sample format |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
38 } pl_extrastereo = {2.5, 0, 0}; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
39 |
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 // to set/get/query special features/parameters |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
42 static int control(int cmd,int arg){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
43 switch(cmd){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
44 case AOCONTROL_PLUGIN_SET_LEN: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
45 return CONTROL_OK; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
46 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
47 return CONTROL_UNKNOWN; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
48 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
49 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
50 // open & setup audio device |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
51 // return: 1=success 0=fail |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
52 static int init(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
53 switch(ao_plugin_data.format){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
54 case(AFMT_S16_LE): |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
55 break; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
56 default: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
57 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
|
58 return 0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
59 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
60 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
61 pl_extrastereo.mul=ao_plugin_cfg.pl_extrastereo_mul; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
62 pl_extrastereo.format=ao_plugin_data.format; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
63 pl_extrastereo.inuse=1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
64 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
65 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
|
66 pl_extrastereo.mul); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
67 return 1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
68 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
69 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
70 // close plugin |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
71 static void uninit(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
72 pl_extrastereo.inuse=0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
73 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
74 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
75 // empty buffers |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
76 static void reset(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
77 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
78 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
79 // processes 'ao_plugin_data.len' bytes of 'data' |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
80 // called for every block of data |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
81 static int play(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
82 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
83 switch(pl_extrastereo.format){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
84 case(AFMT_S16_LE): { |
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 int16_t* data=(int16_t*)ao_plugin_data.data; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
87 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
|
88 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
89 float mul = pl_extrastereo.mul; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
90 int32_t i, avg, ltmp, rtmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
91 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
92 for (i=0; i < len ; i += 2) { |
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 avg = (data[i] + data[i + 1]) / 2; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
95 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
96 ltmp = avg + (int) (mul * (data[i] - avg)); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
97 rtmp = avg + (int) (mul * (data[i + 1] - avg)); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
98 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
99 if (ltmp < -32768) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
100 ltmp = -32768; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
101 } else if (ltmp > 32767) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
102 ltmp = 32767; |
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 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
105 if (rtmp < -32768) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
106 rtmp = -32768; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
107 } else if (rtmp > 32767) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
108 rtmp = 32767; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
109 } |
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 data[i] = ltmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
112 data[i + 1] = rtmp; |
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 break; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
115 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
116 default: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
117 return 0; |
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 return 1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
120 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
121 |