Mercurial > mplayer.hg
annotate libaf/af_sweep.c @ 35141:ef73eb8a2c43
Support FFmpeg's TAK decoder.
Patch by Xidorn Quan, quanxunzhen gmail
author | cehoyos |
---|---|
date | Mon, 08 Oct 2012 11:36:22 +0000 |
parents | 8fa2f43cb760 |
children |
rev | line source |
---|---|
25529
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
1 /* |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
2 * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
3 * |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
4 * This file is part of MPlayer. |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
5 * |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
9 * (at your option) any later version. |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
10 * |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
14 * GNU General Public License for more details. |
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
15 * |
26740
b3a38b361fef
Use standard license headers with standard formatting.
diego
parents:
25529
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
b3a38b361fef
Use standard license headers with standard formatting.
diego
parents:
25529
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
b3a38b361fef
Use standard license headers with standard formatting.
diego
parents:
25529
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
25529
867ee1c2114b
Relicense GPL v2 files as GPL v2+ and add proper license headers.
diego
parents:
24888
diff
changeset
|
19 */ |
13721 | 20 |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <inttypes.h> | |
25 #include <math.h> | |
26 | |
16982 | 27 #include "config.h" |
13721 | 28 #include "af.h" |
29 | |
30 typedef struct af_sweep_s{ | |
31 double x; | |
32 double delta; | |
33 }af_sweept; | |
34 | |
35 | |
36 // Initialization and runtime control | |
37 static int control(struct af_instance_s* af, int cmd, void* arg) | |
38 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26740
diff
changeset
|
39 af_sweept* s = (af_sweept*)af->setup; |
13721 | 40 af_data_t *data= (af_data_t*)arg; |
41 | |
42 switch(cmd){ | |
43 case AF_CONTROL_REINIT: | |
44 af->data->nch = data->nch; | |
14245 | 45 af->data->format = AF_FORMAT_S16_NE; |
13721 | 46 af->data->bps = 2; |
47 af->data->rate = data->rate; | |
48 | |
49 return AF_OK; | |
50 case AF_CONTROL_COMMAND_LINE: | |
51 sscanf((char*)arg,"%lf", &s->delta); | |
52 return AF_OK; | |
53 /* case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET: | |
54 af->data->rate = *(int*)arg; | |
55 return AF_OK;*/ | |
56 } | |
57 return AF_UNKNOWN; | |
58 } | |
59 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26740
diff
changeset
|
60 // Deallocate memory |
13721 | 61 static void uninit(struct af_instance_s* af) |
62 { | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30633
diff
changeset
|
63 free(af->data); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30633
diff
changeset
|
64 free(af->setup); |
13721 | 65 } |
66 | |
67 // Filter data through filter | |
68 static af_data_t* play(struct af_instance_s* af, af_data_t* data) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26740
diff
changeset
|
69 { |
13721 | 70 af_sweept *s = af->setup; |
71 int i, j; | |
72 int16_t *in = (int16_t*)data->audio; | |
73 int chans = data->nch; | |
74 int in_len = data->len/(2*chans); | |
75 | |
76 for(i=0; i<in_len; i++){ | |
77 for(j=0; j<chans; j++) | |
78 in[i*chans+j]= 32000*sin(s->x*s->x); | |
79 s->x += s->delta; | |
80 if(2*s->x*s->delta >= 3.141592) s->x=0; | |
81 } | |
82 | |
83 return data; | |
84 } | |
85 | |
22746
fd6f824ef894
Rename open to af_open so as not to conflict with a previous header definition.
diego
parents:
16982
diff
changeset
|
86 static int af_open(af_instance_t* af){ |
13721 | 87 af->control=control; |
88 af->uninit=uninit; | |
89 af->play=play; | |
24888 | 90 af->mul=1; |
13721 | 91 af->data=calloc(1,sizeof(af_data_t)); |
92 af->setup=calloc(1,sizeof(af_sweept)); | |
93 return AF_OK; | |
94 } | |
95 | |
96 af_info_t af_info_sweep = { | |
97 "sine sweep", | |
98 "sweep", | |
99 "Michael Niedermayer", | |
100 "", | |
101 AF_FLAGS_REENTRANT, | |
22746
fd6f824ef894
Rename open to af_open so as not to conflict with a previous header definition.
diego
parents:
16982
diff
changeset
|
102 af_open |
13721 | 103 }; |