Mercurial > mplayer.hg
annotate libaf/af_sweep.c @ 23962:33428cfa2af0
i_certify_that_my_video_stream_does_not_use_b_frames is gone.
author | diego |
---|---|
date | Wed, 01 Aug 2007 08:37:16 +0000 |
parents | fd6f824ef894 |
children | b2402b4f0afa |
rev | line source |
---|---|
13721 | 1 // Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at> |
2 // #inlcude <GPL_v2.h> | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <string.h> | |
7 #include <inttypes.h> | |
8 #include <math.h> | |
9 | |
16982 | 10 #include "config.h" |
13721 | 11 #include "af.h" |
12 | |
13 typedef struct af_sweep_s{ | |
14 double x; | |
15 double delta; | |
16 }af_sweept; | |
17 | |
18 | |
19 // Initialization and runtime control | |
20 static int control(struct af_instance_s* af, int cmd, void* arg) | |
21 { | |
22 af_sweept* s = (af_sweept*)af->setup; | |
23 af_data_t *data= (af_data_t*)arg; | |
24 | |
25 switch(cmd){ | |
26 case AF_CONTROL_REINIT: | |
27 af->data->nch = data->nch; | |
14245 | 28 af->data->format = AF_FORMAT_S16_NE; |
13721 | 29 af->data->bps = 2; |
30 af->data->rate = data->rate; | |
31 | |
32 return AF_OK; | |
33 case AF_CONTROL_COMMAND_LINE: | |
34 sscanf((char*)arg,"%lf", &s->delta); | |
35 return AF_OK; | |
36 /* case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET: | |
37 af->data->rate = *(int*)arg; | |
38 return AF_OK;*/ | |
39 } | |
40 return AF_UNKNOWN; | |
41 } | |
42 | |
43 // Deallocate memory | |
44 static void uninit(struct af_instance_s* af) | |
45 { | |
46 if(af->data) | |
47 free(af->data); | |
48 if(af->setup){ | |
49 af_sweept *s = af->setup; | |
50 free(s); | |
51 } | |
52 } | |
53 | |
54 // Filter data through filter | |
55 static af_data_t* play(struct af_instance_s* af, af_data_t* data) | |
56 { | |
57 af_sweept *s = af->setup; | |
58 int i, j; | |
59 int16_t *in = (int16_t*)data->audio; | |
60 int chans = data->nch; | |
61 int in_len = data->len/(2*chans); | |
62 | |
63 for(i=0; i<in_len; i++){ | |
64 for(j=0; j<chans; j++) | |
65 in[i*chans+j]= 32000*sin(s->x*s->x); | |
66 s->x += s->delta; | |
67 if(2*s->x*s->delta >= 3.141592) s->x=0; | |
68 } | |
69 | |
70 return data; | |
71 } | |
72 | |
22746
fd6f824ef894
Rename open to af_open so as not to conflict with a previous header definition.
diego
parents:
16982
diff
changeset
|
73 static int af_open(af_instance_t* af){ |
13721 | 74 af->control=control; |
75 af->uninit=uninit; | |
76 af->play=play; | |
77 af->mul.n=1; | |
78 af->mul.d=1; | |
79 af->data=calloc(1,sizeof(af_data_t)); | |
80 af->setup=calloc(1,sizeof(af_sweept)); | |
81 return AF_OK; | |
82 } | |
83 | |
84 af_info_t af_info_sweep = { | |
85 "sine sweep", | |
86 "sweep", | |
87 "Michael Niedermayer", | |
88 "", | |
89 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
|
90 af_open |
13721 | 91 }; |
92 |