Mercurial > mplayer.hg
annotate libaf/af_karaoke.c @ 26084:ec5749eb6f5f
Fill sh_sub_t.lang in lavf, mkv and ogg demuxers. Use it for printing subtitle
track language.
author | eugeni |
---|---|
date | Fri, 29 Feb 2008 17:25:39 +0000 |
parents | b2402b4f0afa |
children | 72d0b1444141 |
rev | line source |
---|---|
18470 | 1 /* |
2 (c)2006 MPlayer / Reynaldo H. Verdejo Pinochet | |
3 Based on code by Alex Beregszaszi for his 'center' filter | |
4 | |
5 License: GPL | |
6 | |
7 Simple voice removal filter | |
8 */ | |
9 | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <string.h> | |
13 | |
14 #include "af.h" | |
15 | |
16 // Data for specific instances of this filter | |
17 | |
18 // Initialization and runtime control | |
19 static int control(struct af_instance_s* af, int cmd, void* arg) | |
20 { | |
21 switch(cmd){ | |
22 case AF_CONTROL_REINIT: | |
23 af->data->rate = ((af_data_t*)arg)->rate; | |
24 af->data->nch = ((af_data_t*)arg)->nch; | |
25 af->data->format= AF_FORMAT_FLOAT_NE; | |
19199 | 26 af->data->bps = 4; |
18470 | 27 return af_test_output(af,(af_data_t*)arg); |
28 } | |
29 return AF_UNKNOWN; | |
30 } | |
31 | |
32 // Deallocate memory | |
33 static void uninit(struct af_instance_s* af) | |
34 { | |
35 if(af->data) | |
36 free(af->data); | |
37 } | |
38 | |
39 // Filter data through filter | |
40 static af_data_t* play(struct af_instance_s* af, af_data_t* data) | |
41 { | |
42 af_data_t* c = data; // Current working data | |
43 float* a = c->audio; // Audio data | |
19199 | 44 int len = c->len/4; // Number of samples in current audio block |
18470 | 45 int nch = c->nch; // Number of channels |
46 register int i; | |
47 | |
48 /* | |
18589 | 49 FIXME1 add a low band pass filter to avoid suppressing |
18470 | 50 centered bass/drums |
18589 | 51 FIXME2 better calculated* attenuation factor |
18470 | 52 */ |
53 | |
54 for(i=0;i<len;i+=nch) | |
55 { | |
56 a[i] = (a[i] - a[i+1]) * 0.7; | |
57 a[i+1]=a[i]; | |
58 } | |
59 | |
60 return c; | |
61 } | |
62 | |
63 // Allocate memory and set function pointers | |
22746
fd6f824ef894
Rename open to af_open so as not to conflict with a previous header definition.
diego
parents:
19199
diff
changeset
|
64 static int af_open(af_instance_t* af){ |
18470 | 65 af->control = control; |
66 af->uninit = uninit; | |
67 af->play = play; | |
24888 | 68 af->mul = 1; |
18470 | 69 af->data = calloc(1,sizeof(af_data_t)); |
70 | |
71 if(af->data == NULL) | |
72 return AF_ERROR; | |
73 | |
74 return AF_OK; | |
75 } | |
76 | |
77 // Description of this filter | |
78 af_info_t af_info_karaoke = { | |
79 "Simple karaoke/voice-removal audio filter", | |
80 "karaoke", | |
81 "Reynaldo H. Verdejo Pinochet", | |
82 "", | |
83 AF_FLAGS_NOT_REENTRANT, | |
22746
fd6f824ef894
Rename open to af_open so as not to conflict with a previous header definition.
diego
parents:
19199
diff
changeset
|
84 af_open |
18470 | 85 }; |