Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d2980dab7 | ||
|
|
21cd4ff05b | ||
|
|
1f436f65f2 | ||
|
|
9001083685 | ||
|
|
92ba630796 | ||
|
|
b638a413c3 | ||
|
|
ad2d10af19 | ||
|
|
3ab6af4f59 | ||
|
|
49660bcc3e | ||
|
|
183e2cda30 | ||
|
|
67b7038be3 | ||
|
|
534571f794 | ||
|
|
af90616ebe | ||
|
|
1841cac9f8 | ||
|
|
82f102cfe3 | ||
|
|
84a3c21beb | ||
|
|
31539884c8 | ||
|
|
5e124a4ac3 | ||
|
|
a842ad8f50 | ||
|
|
1762d33971 | ||
|
|
72aea5a12b | ||
|
|
a6a358ce61 | ||
|
|
8bafd68fff | ||
|
|
3d2fb9e9a8 | ||
|
|
08dbaf1dcc | ||
|
|
71fa2e6fc2 | ||
|
|
b4bbfea71d | ||
|
|
174ca8b172 | ||
|
|
b654aaea0a | ||
|
|
503c6f7fd6 | ||
|
|
f0b15ad447 | ||
|
|
441b605de2 | ||
|
|
933fa7d225 | ||
|
|
b5f620ae75 | ||
|
|
36c6c0f79b | ||
|
|
2f562825e0 | ||
|
|
f0794d0544 | ||
|
|
935c8402bc | ||
|
|
ebc341ddd4 | ||
|
|
87b09a180a | ||
|
|
f3549ff76a | ||
|
|
0e298bb95a | ||
|
|
7c181e5b9b | ||
|
|
9ee340c3af | ||
|
|
289edadb8d | ||
|
|
d52b2981c0 | ||
|
|
65b858f7d3 | ||
|
|
1bb1543a88 | ||
|
|
943f76e6ce | ||
|
|
3ca0208566 | ||
|
|
4ee7ff026c | ||
|
|
da24cb9e3e | ||
|
|
297fdcc095 | ||
|
|
d549c4e402 | ||
|
|
f04cb7bf48 | ||
|
|
6640b22a8c | ||
|
|
b3804e71af | ||
|
|
ee5ba9678a | ||
|
|
e832e46bd6 | ||
|
|
53ef4822e8 | ||
|
|
bf0801a14a | ||
|
|
c01aaabb3e | ||
|
|
57c31f4130 | ||
|
|
d6af58c699 | ||
|
|
0d40140668 | ||
|
|
2d1f42089c | ||
|
|
084162d6fe | ||
|
|
941885b62c | ||
|
|
50d9a2609a | ||
|
|
f371367aac | ||
|
|
3dfb07854b | ||
|
|
88c83f450a | ||
|
|
5d761dd342 | ||
|
|
d5348a66dc | ||
|
|
01743f4ecd | ||
|
|
cd0a34feb3 | ||
|
|
ce0b99314b | ||
|
|
3c3cd0c540 | ||
|
|
0af5335383 | ||
|
|
ae55896f42 | ||
|
|
65f9af1d40 | ||
|
|
f2b039da77 | ||
|
|
f219a48dca | ||
|
|
8aeaa34a5c | ||
|
|
733e0b23c8 | ||
|
|
39ab426f05 | ||
|
|
b7034db4af | ||
|
|
012a8ef2cc | ||
|
|
acf239a45c | ||
|
|
06f1e934db | ||
|
|
543f6df2a6 | ||
|
|
74a8fd3702 | ||
|
|
e1e052a58e | ||
|
|
fa821de8b2 | ||
|
|
d3ed550792 | ||
|
|
0970763f69 | ||
|
|
90089b860c | ||
|
|
cf323d0cc1 | ||
|
|
f9f3175487 | ||
|
|
0868546f9d | ||
|
|
1cfcc1e1d5 | ||
|
|
0b427c54ad | ||
|
|
0287736119 | ||
|
|
fd80fcd3f3 | ||
|
|
337ad4fef4 | ||
|
|
8e4eee9a9a | ||
|
|
6eae6a785c | ||
|
|
166fa30f4b | ||
|
|
dccda5189d | ||
|
|
d3f32cba32 | ||
|
|
eff2e575f1 | ||
|
|
69b0af06ec | ||
|
|
ed6c04b1e5 | ||
|
|
8af7112802 | ||
|
|
4b97869e5f | ||
|
|
ff0112e08d | ||
|
|
a75f40e0d7 | ||
|
|
57ea367963 | ||
|
|
7caecc53b0 | ||
|
|
b7f6dfc19a | ||
|
|
668ba7441a | ||
|
|
3d09bd77dd | ||
|
|
5ca35aafdb | ||
|
|
3d9e1ad363 | ||
|
|
09d61032ca | ||
|
|
c3348d86f2 | ||
|
|
5d0c89a039 | ||
|
|
9f6dfaabf9 | ||
|
|
f04e7bc529 | ||
|
|
eb6b2b6e50 | ||
|
|
77cb44d759 | ||
|
|
3314483a02 | ||
|
|
563b4785da | ||
|
|
a0d3ce4819 | ||
|
|
fb5f732798 | ||
|
|
bb6ae0e50b | ||
|
|
ffb1d7807e | ||
|
|
1661ba09eb | ||
|
|
c0de087ba1 | ||
|
|
45345d9c41 | ||
|
|
8af70561a4 | ||
|
|
242dbc6c2c | ||
|
|
1aa2ae5404 | ||
|
|
2b58738545 | ||
|
|
fd339e3f53 | ||
|
|
b4f63cbbec | ||
|
|
155f7fac9d | ||
|
|
6cbd7d6390 | ||
|
|
363a225364 | ||
|
|
54d0f5bc9a | ||
|
|
a38f313bcc | ||
|
|
1b6a191ea3 | ||
|
|
35bdb63952 | ||
|
|
5d94977477 | ||
|
|
04783e11c9 | ||
|
|
8996f79edb | ||
|
|
b7e613f261 | ||
|
|
a080432992 | ||
|
|
5c8378b71a | ||
|
|
ab318aeea8 | ||
|
|
07d8a0e142 | ||
|
|
d53942dd79 | ||
|
|
05ffde6599 | ||
|
|
a9dfd8d557 | ||
|
|
c440ee99a4 | ||
|
|
006c9694c0 | ||
|
|
ca9124cd07 | ||
|
|
e42a08340b | ||
|
|
effc466222 | ||
|
|
a8dd0abb6d | ||
|
|
942a6729fa | ||
|
|
526d578bee | ||
|
|
c00dc5c5c6 | ||
|
|
c5a48c6332 | ||
|
|
340deb4e6e | ||
|
|
d980fd0856 | ||
|
|
354c1fc06d | ||
|
|
946ee29a7d | ||
|
|
939ad0889b | ||
|
|
d2942f1bcd | ||
|
|
4d5d25fdbb | ||
|
|
e927ff1666 | ||
|
|
f1072be3b7 | ||
|
|
dea42f77db | ||
|
|
c7ec8fdfe7 | ||
|
|
a18aa9e632 | ||
|
|
fb3b8e1e25 | ||
|
|
f8bb24184b | ||
|
|
34bead4859 | ||
|
|
7b6e3772ab | ||
|
|
beb7094301 | ||
|
|
fc3ca14ef7 | ||
|
|
d8aeeaa4b1 | ||
|
|
502763fcc7 | ||
|
|
475d346174 | ||
|
|
6462eabff3 | ||
|
|
521110054d | ||
|
|
bd1fb6f9b1 | ||
|
|
b53cb8de5e | ||
|
|
271cabe6a5 | ||
|
|
7f300b4204 | ||
|
|
eaf2eebb50 | ||
|
|
a160405284 | ||
|
|
266d8368e8 | ||
|
|
223588b36a | ||
|
|
3a015b9ec7 | ||
|
|
3c4f13c23a | ||
|
|
d917efcd58 | ||
|
|
75d29b1457 | ||
|
|
809786df42 | ||
|
|
7c991706c5 | ||
|
|
fae88b8113 | ||
|
|
2e3a508387 | ||
|
|
f176104ed5 | ||
|
|
4c25f49236 | ||
|
|
135a7217b9 | ||
|
|
ce0b26c60f | ||
|
|
ff7884e635 | ||
|
|
2df448b1f3 | ||
|
|
ff4bd73fcb | ||
|
|
657dd4b807 | ||
|
|
50c701574d | ||
|
|
04ec417d41 | ||
|
|
536efe6faf | ||
|
|
7bb9203f7f | ||
|
|
fef8b7984b | ||
|
|
27ecc417fe | ||
|
|
03b50d4bf6 | ||
|
|
9a2a0b0bba | ||
|
|
b2a5c16a9d | ||
|
|
346cf7abf0 | ||
|
|
ab59c5f522 | ||
|
|
e904129b79 | ||
|
|
c406f83d37 | ||
|
|
68366b05f2 | ||
|
|
ca00e347fc | ||
|
|
ac966ded11 | ||
|
|
930b0d1cf6 | ||
|
|
ff43215960 | ||
|
|
f352669157 | ||
|
|
a8abb53a5d | ||
|
|
aaafbfcc06 | ||
|
|
30031edce3 | ||
|
|
c365b44e19 | ||
|
|
7737499a74 | ||
|
|
0d3a67ab2c | ||
|
|
e4ec0f42e4 | ||
|
|
8a9b64329c | ||
|
|
6fafdd5142 | ||
|
|
ae4b0f3f7c | ||
|
|
a99b63db08 | ||
|
|
cd5eb1bb19 | ||
|
|
48c9101a5b | ||
|
|
f9cefbfec4 | ||
|
|
ed3e5330ec | ||
|
|
1781bf26f1 | ||
|
|
5053f4cc3f | ||
|
|
46bcdb7039 | ||
|
|
5986861c9c | ||
|
|
f15a79d144 | ||
|
|
488f569d99 | ||
|
|
6f35d4df5a | ||
|
|
2bbed80135 | ||
|
|
dfe630c5d1 | ||
|
|
418c98dec7 | ||
|
|
0ed170ec0b | ||
|
|
d1d6257731 | ||
|
|
ba9b2f1e49 | ||
|
|
7b4ccb3e9f | ||
|
|
4195a345a5 | ||
|
|
004bc95263 | ||
|
|
24fc176dfb | ||
|
|
056901b2be | ||
|
|
20991a95b8 | ||
|
|
31adc87bde | ||
|
|
2d4e8b623d | ||
|
|
bc1dce5d5b | ||
|
|
0fad73862c | ||
|
|
49690dd54b | ||
|
|
c9204fe3a5 | ||
|
|
24e7fac50b | ||
|
|
554c65e466 | ||
|
|
8128b7c8e2 | ||
|
|
0c9b655477 | ||
|
|
9fb949b49a | ||
|
|
909b8f89d8 | ||
|
|
77bac5b550 | ||
|
|
64067a9b7c | ||
|
|
62acd315ad | ||
|
|
c55b242b4e | ||
|
|
1e46bda0f8 | ||
|
|
16723d4bb1 | ||
|
|
4c3f95708f | ||
|
|
9a88b118b4 | ||
|
|
785eacf4f3 | ||
|
|
5722f93a74 | ||
|
|
bf13bd0d47 | ||
|
|
dd973da108 | ||
|
|
cbda46370c | ||
|
|
a4cdf1a727 | ||
|
|
e420464ba6 | ||
|
|
6fc0fe4426 | ||
|
|
671df54e4d | ||
|
|
81f3b3aafe | ||
|
|
796d5266f1 | ||
|
|
7c804cd796 | ||
|
|
ea442fa047 | ||
|
|
0915a8497b | ||
|
|
8135838018 | ||
|
|
f54ae2031e | ||
|
|
453ea2cb6c | ||
|
|
9fee7077d4 | ||
|
|
30fd858e5e | ||
|
|
9acea8759b | ||
|
|
31a4547187 | ||
|
|
994459e4ce | ||
|
|
a1f949d3b8 | ||
|
|
459b40cc4b | ||
|
|
9628edede0 | ||
|
|
bd5a02d080 | ||
|
|
2a80680d95 | ||
|
|
8e87ddd7fe | ||
|
|
e4a1086cfb | ||
|
|
12b4f177ec | ||
|
|
6a73fcc9ed | ||
|
|
2dd8982f73 | ||
|
|
6eccd4a573 | ||
|
|
27bc881cd8 | ||
|
|
b0c1455aa4 | ||
|
|
e2d90b383b | ||
|
|
c19f634e6c | ||
|
|
82e81421d7 | ||
|
|
0d05038790 | ||
|
|
38636345b1 | ||
|
|
9604c45e24 | ||
|
|
e69d1f2780 | ||
|
|
e9af0592d9 | ||
|
|
ce60c1adf7 | ||
|
|
35f43dfacb | ||
|
|
b7e179f6d3 | ||
|
|
3909e4cdfc | ||
|
|
3e90a5fe81 | ||
|
|
27ccad541a | ||
|
|
bf611ff0f6 | ||
|
|
0c877d2fdc | ||
|
|
8368ead1fa | ||
|
|
d22d24a6d5 | ||
|
|
fb84c6974d | ||
|
|
92ded6c6fd | ||
|
|
3d03298e86 | ||
|
|
c1002f6a28 | ||
|
|
861c126b08 | ||
|
|
8fda7247ff | ||
|
|
172ce98433 | ||
|
|
481d15ae60 | ||
|
|
0b5af5639b | ||
|
|
0015afd059 | ||
|
|
d0cd7fa31b | ||
|
|
a655432bbe | ||
|
|
09f0f68959 | ||
|
|
dac5b598f5 | ||
|
|
cb8b0cc329 | ||
|
|
029e31f1c5 | ||
|
|
efb9943637 | ||
|
|
243a2976a8 | ||
|
|
c725f39bae | ||
|
|
1f38c2107d | ||
|
|
2f4bd58f4a | ||
|
|
fa315705be | ||
|
|
2c3f4850b8 | ||
|
|
13ade4f1bc | ||
|
|
9163bdc38a | ||
|
|
d5f29a3c36 | ||
|
|
de0523ba7b | ||
|
|
ad072b17ce | ||
|
|
2059ba2c40 | ||
|
|
492e3deb95 | ||
|
|
fb185e4e79 | ||
|
|
dcffeaccf1 | ||
|
|
b5d0195023 | ||
|
|
b47bf06f97 | ||
|
|
9b3daa4974 | ||
|
|
4c1deb680d | ||
|
|
97d50538cd | ||
|
|
1f62f38106 | ||
|
|
d85753b79e | ||
|
|
50c379e2d8 | ||
|
|
d9f8b9f7b2 | ||
|
|
d804e7b903 | ||
|
|
7df475f860 | ||
|
|
aa587580c8 | ||
|
|
4d43a0c997 | ||
|
|
b637d6366c | ||
|
|
05444e8135 | ||
|
|
190dea149a | ||
|
|
8d4a179c14 | ||
|
|
ce8524cb47 | ||
|
|
504286b006 | ||
|
|
fb8285c7a7 | ||
|
|
7dff6a2842 | ||
|
|
0710ced079 | ||
|
|
6d9cb89333 | ||
|
|
940007cbf9 | ||
|
|
bbb65ed84b | ||
|
|
30074f8440 | ||
|
|
a042dcc700 | ||
|
|
3973a953df | ||
|
|
082c23515f | ||
|
|
6bec6ac558 | ||
|
|
946bd52a1d | ||
|
|
25497226cf | ||
|
|
f9ba1a3ddf | ||
|
|
b0381d27eb | ||
|
|
3e1aed8f40 | ||
|
|
ff520054c8 | ||
|
|
1a6f3c56ea | ||
|
|
af958221a1 | ||
|
|
2037426a65 | ||
|
|
e8960c69e9 | ||
|
|
23a5329690 | ||
|
|
eac0665b8d | ||
|
|
3de6c9aa42 | ||
|
|
8673343957 | ||
|
|
d1119cc069 | ||
|
|
ad25de5903 | ||
|
|
f8b09658f4 | ||
|
|
d5274d9298 | ||
|
|
5afa68835a | ||
|
|
5360baa49e | ||
|
|
fccc3d3894 | ||
|
|
7fa06e46c4 | ||
|
|
0afb1acab3 | ||
|
|
05b6646d7a | ||
|
|
35296c1f33 | ||
|
|
3ae726e8dd | ||
|
|
c188240ab9 | ||
|
|
099fdde7a4 | ||
|
|
cbc951d491 | ||
|
|
fc7212b214 | ||
|
|
f2187de8bb | ||
|
|
31c29495ca | ||
|
|
a191712169 | ||
|
|
517a35da94 | ||
|
|
821e8fb9d0 | ||
|
|
4b81398b4e | ||
|
|
d1cbff37be | ||
|
|
aa5f04c7a0 | ||
|
|
e15526153e | ||
|
|
48b103cad7 | ||
|
|
7f313afd08 | ||
|
|
7558d1ed7b | ||
|
|
0563eb914f | ||
|
|
abbb43759a | ||
|
|
6205d87a7f | ||
|
|
491958a724 | ||
|
|
808653a9b6 | ||
|
|
d2013b3f50 | ||
|
|
5790bbba61 | ||
|
|
f1a2610c4f | ||
|
|
2da533bec3 | ||
|
|
127da1613f | ||
|
|
c01935986c | ||
|
|
0a0bb9059f | ||
|
|
1f7c099dc0 | ||
|
|
78bfee53dd | ||
|
|
cd24fdcd5a | ||
|
|
47f2f554a3 | ||
|
|
a0519f1d18 | ||
|
|
4cc1861378 | ||
|
|
6154c1d06d | ||
|
|
32cd85bc7e | ||
|
|
3394d37b4e | ||
|
|
d2baaaa7df | ||
|
|
fc9eef3b81 | ||
|
|
58d45f7b3e | ||
|
|
8a9cde4999 | ||
|
|
3925dff2e6 | ||
|
|
f1909bc231 | ||
|
|
5dd5dc66c1 | ||
|
|
00135a87f0 | ||
|
|
687b552db1 | ||
|
|
2c7db48195 | ||
|
|
7137afeb2c | ||
|
|
ad80cc4eee | ||
|
|
f36c17d715 | ||
|
|
04af005c35 | ||
|
|
74c11f0c84 | ||
|
|
e798cf1ff6 | ||
|
|
cab942acae | ||
|
|
c7985fe5f7 | ||
|
|
29226e6a99 | ||
|
|
d0fd68f6df | ||
|
|
8d0a6cd035 | ||
|
|
f24ba544cd | ||
|
|
000285ee8e | ||
|
|
67a4892ee3 | ||
|
|
e1993d5ad2 | ||
|
|
0607dcebff | ||
|
|
3d12312806 | ||
|
|
a6521f3941 | ||
|
|
475fe453cc | ||
|
|
3da91a673a | ||
|
|
47e6ef0bdf | ||
|
|
6d36c432ab | ||
|
|
45ae0716be | ||
|
|
c5c7b239b6 | ||
|
|
c2d0d7818f | ||
|
|
0d7d935e88 | ||
|
|
3d66a5d14e | ||
|
|
c138505813 | ||
|
|
663415b914 | ||
|
|
c569d4f6ed | ||
|
|
e6058d3dc3 | ||
|
|
c1a96de41c | ||
|
|
18fe6e6dc8 | ||
|
|
aaa64b879e | ||
|
|
159eb3f962 | ||
|
|
9db50c6760 | ||
|
|
970606e491 | ||
|
|
7d7ea72854 | ||
|
|
0262295c4b | ||
|
|
48ed48f7b8 | ||
|
|
94c062d0d2 | ||
|
|
04934e86dd | ||
|
|
ff1eaea3e7 | ||
|
|
9a240dc82e | ||
|
|
a7cf091519 | ||
|
|
a2e7642d3c | ||
|
|
565efeeada | ||
|
|
c46106d633 | ||
|
|
63204eda5d | ||
|
|
791228f2ab | ||
|
|
19b0b1df51 | ||
|
|
30bbcd6452 | ||
|
|
832cb56f2d | ||
|
|
68c6da69f7 | ||
|
|
f626bef7c8 | ||
|
|
81746a1798 | ||
|
|
01c418f9df | ||
|
|
3b6c7275bc | ||
|
|
6562d4a562 | ||
|
|
17507b5935 | ||
|
|
57e691b901 | ||
|
|
344d44681e | ||
|
|
03d311823d | ||
|
|
9cb7646071 | ||
|
|
42a0f4d87b | ||
|
|
69cc002c92 | ||
|
|
b325ed1105 | ||
|
|
30f18b8dc7 | ||
|
|
e1d414c992 | ||
|
|
7f3cf75c5a | ||
|
|
ece794d905 | ||
|
|
3fa76c84be | ||
|
|
66d93c711b | ||
|
|
03a81a9d85 | ||
|
|
e2c0e7f5c2 | ||
|
|
8bf34950c1 | ||
|
|
2b990ac810 | ||
|
|
005f03d99f | ||
|
|
6ff1cd5502 | ||
|
|
9fc74d5acd | ||
|
|
2b07d3eb47 | ||
|
|
73e0d545ce | ||
|
|
50d43a1db4 | ||
|
|
318e9801f2 | ||
|
|
ea1caa474a | ||
|
|
7023c383b2 | ||
|
|
2bee47fd27 | ||
|
|
c8e0e35709 | ||
|
|
9afd62bfcd | ||
|
|
eec844a06e | ||
|
|
50bb209a80 | ||
|
|
41f2c653e2 | ||
|
|
85498a0797 | ||
|
|
b250c19a38 | ||
|
|
69ba4f776f | ||
|
|
4c111fbcde | ||
|
|
12eb8b2de8 | ||
|
|
44376d2d9b | ||
|
|
b8bcf0f466 | ||
|
|
1fe64c61be | ||
|
|
772961f0ce | ||
|
|
5bc9b273b3 | ||
|
|
0425741754 | ||
|
|
19c1a208ec | ||
|
|
422ed42817 | ||
|
|
fa2fdaab0a | ||
|
|
b7d614aa0d | ||
|
|
dab2e909af | ||
|
|
06df54a111 | ||
|
|
ef918b239e | ||
|
|
00b7fb3023 | ||
|
|
4f103b2093 | ||
|
|
2e401201ad | ||
|
|
b2e8d5749b | ||
|
|
52af1f72e2 | ||
|
|
c9d1aa1d3c | ||
|
|
718807b78b | ||
|
|
d2efa56d48 | ||
|
|
01a2af6c7c | ||
|
|
b38094ad91 | ||
|
|
9817473163 | ||
|
|
c5a4fd9bee | ||
|
|
d5df90a295 | ||
|
|
3245b7f275 | ||
|
|
59eb489425 | ||
|
|
4fd0cd4a73 | ||
|
|
6df3fa2ec1 | ||
|
|
1a8b06f67e | ||
|
|
92d06f43fa | ||
|
|
23f3b99003 | ||
|
|
b86a59aa4f | ||
|
|
368431f57c | ||
|
|
94147762fc | ||
|
|
e10727baa7 | ||
|
|
a6fb80baa4 | ||
|
|
f9a2fc592f | ||
|
|
76e4374d06 | ||
|
|
7e285a6f71 | ||
|
|
516e7d19da | ||
|
|
58caf577f1 | ||
|
|
76fcef618b | ||
|
|
74c862c68e | ||
|
|
9f858cc759 | ||
|
|
ca77bcd543 | ||
|
|
e086d40486 | ||
|
|
eda518f558 | ||
|
|
e76ec2c963 | ||
|
|
a3195381d1 | ||
|
|
8ff2058681 | ||
|
|
0ec35fa111 | ||
|
|
25fe9e89e7 | ||
|
|
0e0f07bbef | ||
|
|
c7a39b8521 | ||
|
|
5a89150a46 | ||
|
|
85450d06a1 | ||
|
|
70df1608d6 | ||
|
|
e24e0ccd68 | ||
|
|
514f5d760e | ||
|
|
05be95c8ce | ||
|
|
6b22b21651 | ||
|
|
07c546b2b4 | ||
|
|
bf0b178e71 | ||
|
|
883d311413 | ||
|
|
c7d82dd25c | ||
|
|
cf3b34f17a | ||
|
|
a790009a63 | ||
|
|
542d88472f | ||
|
|
9f43778eb2 | ||
|
|
0f3dedebb4 | ||
|
|
70d46a9fb8 | ||
|
|
c362c3d7ae | ||
|
|
07b8abbd62 | ||
|
|
d5981924fe | ||
|
|
62b386c2fd | ||
|
|
fad254562b | ||
|
|
d32c4c75ef | ||
|
|
624c9e46ce | ||
|
|
f0feea5591 | ||
|
|
def87f1e5f | ||
|
|
b726fefe5d | ||
|
|
49a41bf4df | ||
|
|
384b13c5fd | ||
|
|
977869a804 | ||
|
|
7c4fe02d01 | ||
|
|
b7398cbdd8 | ||
|
|
9774be0d15 | ||
|
|
a33a44cf4e | ||
|
|
273607c1c6 | ||
|
|
fee45c0170 | ||
|
|
9a6ec9de2f | ||
|
|
4682b0147e | ||
|
|
479eb93d9e | ||
|
|
9d9f863f55 | ||
|
|
dd0c85679b | ||
|
|
4efadb2808 | ||
|
|
cf5b117553 | ||
|
|
434512827f | ||
|
|
03bbaad686 | ||
|
|
3dc0f2ecf0 | ||
|
|
eeb5f98758 | ||
|
|
caa497ee8a | ||
|
|
930f841589 | ||
|
|
8baf773d0e | ||
|
|
11888a9270 | ||
|
|
76e50f6a3d | ||
|
|
7d5282ea5d | ||
|
|
f757163058 | ||
|
|
ac64ce71d6 | ||
|
|
16cd20c46f | ||
|
|
8f7b12d9ae | ||
|
|
66f8e45311 | ||
|
|
0ff3ffb2be | ||
|
|
d91434756b | ||
|
|
03013e0fd7 | ||
|
|
62f261a7b8 | ||
|
|
c3f2ef5491 | ||
|
|
67caea357c | ||
|
|
b1893d2084 | ||
|
|
46cee66563 | ||
|
|
0062c98dff | ||
|
|
6bbb1e4cf9 | ||
|
|
1356755ad4 | ||
|
|
2dc18a2f82 | ||
|
|
a7f51f8fd4 | ||
|
|
5a7c22a1ac | ||
|
|
617aff6cda | ||
|
|
b984ec52aa | ||
|
|
9693e0f57a | ||
|
|
647b360a0a | ||
|
|
68ac45e487 | ||
|
|
9e10cd9fa1 | ||
|
|
b2a3e877c0 | ||
|
|
5f89ba707d | ||
|
|
cfa4952f7c | ||
|
|
945df57357 | ||
|
|
fb193713a3 | ||
|
|
27dc834f37 | ||
|
|
3f73d63523 | ||
|
|
4c43c30421 | ||
|
|
7438f208c3 | ||
|
|
017f3d0674 | ||
|
|
2cf9ee989c | ||
|
|
66ed50aa00 | ||
|
|
179d7317e7 | ||
|
|
3108a3a001 | ||
|
|
8f7cf9443f | ||
|
|
e3db686e87 | ||
|
|
db1fc3628f | ||
|
|
3ad03f6673 | ||
|
|
f00edfd9c5 | ||
|
|
e6a395c297 | ||
|
|
be49da72ea | ||
|
|
46f59f25c2 | ||
|
|
0ca8b290a4 | ||
|
|
5a18c5ea91 | ||
|
|
a9833a71ce | ||
|
|
350d902799 | ||
|
|
e187de7eed | ||
|
|
49d94853b5 | ||
|
|
163c6ad862 | ||
|
|
4058b418bf | ||
|
|
4e358a9636 | ||
|
|
9d4aff8ac7 | ||
|
|
e162a5bf04 | ||
|
|
8d415b2e01 | ||
|
|
d634394da6 | ||
|
|
609de236a9 | ||
|
|
3f0d831af0 | ||
|
|
587bb5e811 | ||
|
|
c2220c526d | ||
|
|
b58e4abc01 | ||
|
|
3fb161ecd2 | ||
|
|
1d2d649281 | ||
|
|
8e8b420c9d | ||
|
|
9de8730dc9 | ||
|
|
30a6106477 | ||
|
|
f1e767b6a2 | ||
|
|
8581835161 | ||
|
|
cdeb0e4c72 | ||
|
|
8fd63c8f0c | ||
|
|
b92fd602ce | ||
|
|
7984d25ceb | ||
|
|
2b6241a09a | ||
|
|
93f748e77f | ||
|
|
7c6d7017bd | ||
|
|
344b65c4db | ||
|
|
03cf69f0a8 | ||
|
|
05e39ec513 | ||
|
|
7aba3a5d96 | ||
|
|
acd5816a6d | ||
|
|
8737732035 | ||
|
|
67aab3a9f6 | ||
|
|
8eb7cb28f9 | ||
|
|
3dec68ba47 | ||
|
|
d5b8d77a17 | ||
|
|
a1315c7644 | ||
|
|
532f05b83d | ||
|
|
5b7d0fbab3 | ||
|
|
ec567d8a77 | ||
|
|
33489feca8 | ||
|
|
ce82d88215 | ||
|
|
d1ad0815fe | ||
|
|
fc3f1e7c54 | ||
|
|
466658ee7e | ||
|
|
cf18922d19 | ||
|
|
3c081dfd93 | ||
|
|
a135c9cffc | ||
|
|
f891b24cb5 | ||
|
|
70aa3b04f8 | ||
|
|
c24921d56b | ||
|
|
aaec2aba38 | ||
|
|
3b95dd47d5 | ||
|
|
555ecbb70e | ||
|
|
919707efb7 | ||
|
|
c1de8cdc38 | ||
|
|
0cc440f291 | ||
|
|
0524907c18 | ||
|
|
c971fefd41 | ||
|
|
9ed289ef90 | ||
|
|
f3a003e550 | ||
|
|
48c2e9d67d | ||
|
|
0ffaf653a2 | ||
|
|
76d1b430b0 | ||
|
|
ec27d573f4 | ||
|
|
72d3c5ef00 | ||
|
|
81109dcbb6 | ||
|
|
fa510bd00c | ||
|
|
c21c26472c | ||
|
|
d6e7190836 | ||
|
|
d1a46c2c32 | ||
|
|
a02f3a5dd4 | ||
|
|
17b4fb02b3 | ||
|
|
252dcdcc99 | ||
|
|
97fc4f4a85 | ||
|
|
ad6e7c31df | ||
|
|
bf6b981367 | ||
|
|
72ded5ccef | ||
|
|
0344abd67a | ||
|
|
56fefde7e2 | ||
|
|
955c6843b6 | ||
|
|
d1528e51d5 | ||
|
|
53c720d412 | ||
|
|
878f12885b | ||
|
|
0a1a5707bf | ||
|
|
dd08018e9e | ||
|
|
56d04c6570 | ||
|
|
96eb480299 | ||
|
|
14bb3d06a2 | ||
|
|
1a1ac76d2a | ||
|
|
d93a9be656 | ||
|
|
dda16ee1fb | ||
|
|
78112c8582 | ||
|
|
ff778f6d68 | ||
|
|
cee9aeaf6b | ||
|
|
eb66038d4f | ||
|
|
1ee8ce75f1 | ||
|
|
0121d00478 | ||
|
|
e157d005ba | ||
|
|
251107076b | ||
|
|
750c29766f | ||
|
|
b0b67cdf5d | ||
|
|
50f8548b2f | ||
|
|
0ab6031d76 | ||
|
|
667b968939 | ||
|
|
e1128c8b28 | ||
|
|
e3de309804 | ||
|
|
9ca312b4b1 | ||
|
|
d27d91715f | ||
|
|
0eb45343ca | ||
|
|
7e7ef2f01d | ||
|
|
76bfd5b4a2 | ||
|
|
8d414e2fe7 | ||
|
|
2483dab54d | ||
|
|
3a7a2385df | ||
|
|
3274fabeb3 | ||
|
|
e0f8d79772 | ||
|
|
da496ae2fe | ||
|
|
184426175f | ||
|
|
1f9c4f19cf | ||
|
|
8b291aff96 | ||
|
|
8d004f07a4 | ||
|
|
14a2993796 | ||
|
|
3804376ccc | ||
|
|
bddd1e9e3b | ||
|
|
9e7069fde2 | ||
|
|
94b6a1054e | ||
|
|
d714c8380a | ||
|
|
b7ba2e2c57 | ||
|
|
52de5ea6ad | ||
|
|
78caf6ae86 | ||
|
|
46c499d02a | ||
|
|
dbbde6161d | ||
|
|
a62dcdd5f4 | ||
|
|
f7124be091 | ||
|
|
6499224888 | ||
|
|
252d5b319a | ||
|
|
280251656c | ||
|
|
aa796c23db | ||
|
|
0a41c6f0ec | ||
|
|
66aa54d319 | ||
|
|
288eaacd85 | ||
|
|
ecb776f88e | ||
|
|
1c593f1497 | ||
|
|
b4804a4b26 | ||
|
|
5015759334 | ||
|
|
3c292395ca | ||
|
|
8e654d3f78 | ||
|
|
0e245b3752 | ||
|
|
6fb926a560 | ||
|
|
8f33c65fe0 | ||
|
|
beae60bcd5 | ||
|
|
29e42b78c0 | ||
|
|
54fbda2ba4 | ||
|
|
e694d67366 | ||
|
|
6890de958d | ||
|
|
c855ab5624 | ||
|
|
3ccac74de2 | ||
|
|
ee283843fa | ||
|
|
291f301c10 | ||
|
|
e448e10fd7 | ||
|
|
e72ca08554 | ||
|
|
e87f705497 | ||
|
|
93db4233af | ||
|
|
fe993a6712 | ||
|
|
69bc7e34b9 | ||
|
|
a9ed9e329c | ||
|
|
8a21cb1cd3 | ||
|
|
bd87598af9 | ||
|
|
f4d62da8f0 | ||
|
|
ae7212963e | ||
|
|
24f34c9e8e | ||
|
|
98c4ab6d13 | ||
|
|
4a07205963 | ||
|
|
7c5f41ff5f | ||
|
|
a2a2cdb5bc | ||
|
|
41bf41e416 | ||
|
|
ebb43f5176 | ||
|
|
aff6e8e8da | ||
|
|
1b7e8ff6c5 | ||
|
|
739452361f | ||
|
|
ee63c9c210 | ||
|
|
b4491c00c4 | ||
|
|
12cd48a8a9 | ||
|
|
31316e9ca0 | ||
|
|
853fe788f8 | ||
|
|
1dd7b7bddc | ||
|
|
15ef9f9ee6 | ||
|
|
ad2ab5893e | ||
|
|
144571da9b | ||
|
|
8aa8417aa3 | ||
|
|
1fa674c109 | ||
|
|
710872bc22 | ||
|
|
1ff32236fa | ||
|
|
2a7811176c | ||
|
|
2e5df94f0f | ||
|
|
0c494c238a | ||
|
|
375886c777 | ||
|
|
0aa548457f | ||
|
|
e0cb65e8ac | ||
|
|
6875e6a779 | ||
|
|
ac5538c7df | ||
|
|
0ae8aebb89 | ||
|
|
361040f9d9 | ||
|
|
d2281935b3 | ||
|
|
0a6c334b59 | ||
|
|
38b747bb67 | ||
|
|
993bee38ca | ||
|
|
0b87bf9b72 | ||
|
|
456366b63b | ||
|
|
ec356d3efe | ||
|
|
5786d07450 | ||
|
|
8d8a2045bd | ||
|
|
0e9cfa6b64 | ||
|
|
d47dff3faa | ||
|
|
b81d9c79a8 | ||
|
|
57831d52dc | ||
|
|
b14c9eb748 | ||
|
|
cb1c072534 | ||
|
|
c17ff1703a | ||
|
|
65ad85790a | ||
|
|
17cd6798a6 | ||
|
|
d8d4e18835 | ||
|
|
009dfbe3b6 | ||
|
|
2ed9370bd6 | ||
|
|
e0c005cb75 | ||
|
|
4d6c1be7b6 | ||
|
|
f8c57433b9 | ||
|
|
ead2933792 | ||
|
|
79f8ee2808 | ||
|
|
e3e6c1939f | ||
|
|
4d747400bb | ||
|
|
8838c4a5b1 | ||
|
|
a75e933dac | ||
|
|
ab7ac46bcc | ||
|
|
7a19eb490e | ||
|
|
8782354e6d | ||
|
|
f287ccf017 | ||
|
|
2f4e01e772 | ||
|
|
9d2bc9a4ac | ||
|
|
3586e6ceeb | ||
|
|
21e5e4da4b | ||
|
|
bad743aed5 | ||
|
|
126367bb09 | ||
|
|
1e53308d65 | ||
|
|
fea1e09a9c | ||
|
|
7020908691 | ||
|
|
876e93d8b7 | ||
|
|
4e0e24c3c2 | ||
|
|
f095e86b61 | ||
|
|
c2ee824c26 | ||
|
|
d96f6edf49 | ||
|
|
e76f503fff | ||
|
|
1557d2d470 | ||
|
|
7eacfdcd25 | ||
|
|
09c61e0a45 | ||
|
|
b7144ad8bf | ||
|
|
269f271b73 | ||
|
|
fdf6e5f5aa | ||
|
|
e9822f6012 | ||
|
|
e721660e6d | ||
|
|
60a617df31 | ||
|
|
e45f469280 | ||
|
|
dc04541ba8 | ||
|
|
9e04e31906 | ||
|
|
a8eae12af5 | ||
|
|
e2139488ff | ||
|
|
f1205293a7 | ||
|
|
2492b5f119 | ||
|
|
d3bd5c9541 | ||
|
|
b4abcbd19d | ||
|
|
97363e176d | ||
|
|
95d5bee832 | ||
|
|
eb56807b41 | ||
|
|
7929e36e93 | ||
|
|
44eda2177d | ||
|
|
deebc55014 | ||
|
|
944fa1214a | ||
|
|
37544e53dc | ||
|
|
f622f9d3a3 | ||
|
|
ab6f6aa61e | ||
|
|
af0b903afa | ||
|
|
4eae4a5da7 | ||
|
|
0eb72d786c | ||
|
|
8a9c9e0ede | ||
|
|
cd32179627 | ||
|
|
f3b00ec142 | ||
|
|
7c73f70b89 | ||
|
|
392ae68e5f | ||
|
|
a6694b7b96 | ||
|
|
23f6f3f50c | ||
|
|
215afe7a41 | ||
|
|
d04d2380e3 | ||
|
|
091bfa3abf |
No files matched your search
@@ -15,6 +15,7 @@
|
||||
/tags
|
||||
/TAGS
|
||||
/video/out/x11_icon.inc
|
||||
/video/out/opengl/nnedi3_weights.inc
|
||||
/demux/ebml_defs.c
|
||||
/demux/ebml_types.h
|
||||
/sub/osd_font.h
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
Reporting bugs
|
||||
==============
|
||||
|
||||
- State your platform and mpv version.
|
||||
- Make sure you're actually using the latest mpv release. Linux distributions
|
||||
in particular love redistributing ancient and unmaintained mpv releases.
|
||||
- Attach a log file made with ``-v`` or ``--log-file=output.txt``.
|
||||
- Avoid attaching text files packed in archive files (zip/rar/...), unless
|
||||
explicitly asked so. There are better means, such as using http://sprunge.us
|
||||
- If you think this is file specific, upload a sample file and link it.
|
||||
- Don't report multiple unrelated/barely related bugs in one issue.
|
||||
- If you don't get a reply after days, be sure to post a new message to the
|
||||
issue - it could have been overlooked or forgotten.
|
||||
- Read: https://mpv.io/bug-reports/
|
||||
|
||||
Asking questions
|
||||
================
|
||||
|
||||
Preferably, asking questions should be done via IRC (#mpv on irc.freenode.net),
|
||||
but asking questions by opening a github issue is also barely tolerated.
|
||||
|
||||
When asking on IRC (#mpv on irc.freenode.net), don't ask to ask, just state
|
||||
your problem. Stay long enough until someone gets a chance to reply. Sometimes
|
||||
it can take hours.
|
||||
|
||||
Sending patches
|
||||
===============
|
||||
|
||||
See: https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md
|
||||
|
||||
In particular, be aware that all changes to GPL code must come with the
|
||||
implicit agreement that they might be LGPLv2.1+ relicensed at a later point.
|
||||
@@ -12,6 +12,9 @@ the code to LGPLv2.1+ at a later point without asking the contributor. (This
|
||||
is a safeguard for making potential relicensing of the project to LGPLv2.1+
|
||||
easier.) Using a more liberal license compatible to LGPLv2.1+ is also ok.
|
||||
|
||||
Some GPLv3 or LGPLv3 code in mpv can be enabled by building with --enable-gpl3,
|
||||
and in this case, the resulting binaries must be distributed under GPLv3.
|
||||
|
||||
For information about authors and contributors, consult the git log, which
|
||||
contains the complete SVN and CVS history as well.
|
||||
|
||||
|
||||
@@ -32,14 +32,20 @@ API changes
|
||||
|
||||
::
|
||||
|
||||
... - add "GL_MP_D3D_interfaces" pseudo extension to make it possible to
|
||||
--- mpv 0.12.0 ---
|
||||
1.20 - deprecate "GL_MP_D3D_interfaces"/"glMPGetD3DInterface", and introduce
|
||||
"GL_MP_MPGetNativeDisplay"/"glMPGetNativeDisplay" (this is a
|
||||
backwards-compatible rename)
|
||||
--- mpv 0.11.0 ---
|
||||
--- mpv 0.10.0 ---
|
||||
1.19 - add "GL_MP_D3D_interfaces" pseudo extension to make it possible to
|
||||
use DXVA2 in OpenGL fullscreen mode in some situations
|
||||
1.19 - mpv_request_log_messages() now accepts "terminal-default" as parameter
|
||||
- mpv_request_log_messages() now accepts "terminal-default" as parameter
|
||||
1.18 - add MPV_END_FILE_REASON_REDIRECT, and change behavior of
|
||||
MPV_EVENT_END_FILE accordingly
|
||||
- a bunch of interface-changes.rst changes
|
||||
1.17 - mpv_initialize() now blocks SIGPIPE (details see client.h)
|
||||
--- mpv 0.9.0 is released ---
|
||||
--- mpv 0.9.0 ---
|
||||
1.16 - add mpv_opengl_cb_report_flip()
|
||||
- introduce mpv_opengl_cb_draw() and deprecate mpv_opengl_cb_render()
|
||||
- add MPV_FORMAT_BYTE_ARRAY
|
||||
@@ -48,7 +54,7 @@ API changes
|
||||
mpv.conf.
|
||||
- minor backwards-compatible change to the "seek" and "screenshot"
|
||||
commands (new flag syntax, old additional args deprecated)
|
||||
--- mpv 0.8.0 is released ---
|
||||
--- mpv 0.8.0 ---
|
||||
1.14 - add mpv_wait_async_requests()
|
||||
- the --msg-level option changes its native type from a flat string to
|
||||
a key-value list (setting/reading the option as string still works)
|
||||
@@ -61,7 +67,7 @@ API changes
|
||||
its own and mpv's OpenGL rendering
|
||||
Warning: this API is not stable yet - anything in opengl_cb.h might
|
||||
be changed in completely incompatible ways in minor API bumps
|
||||
--- mpv 0.7.0 is released ---
|
||||
--- mpv 0.7.0 ---
|
||||
1.10 - deprecate/disable everything directly related to script_dispatch
|
||||
(most likely affects nobody)
|
||||
1.9 - add enum mpv_end_file_reason for mpv_event_end_file.reason
|
||||
@@ -84,7 +90,7 @@ API changes
|
||||
1.6 - modify "core-idle" property behavior
|
||||
- MPV_EVENT_LOG_MESSAGE now always sends complete lines
|
||||
- introduce numeric log levels (mpv_log_level)
|
||||
--- mpv 0.6.0 is released ---
|
||||
--- mpv 0.6.0 ---
|
||||
1.5 - change in X11 and "--wid" behavior again. The previous change didn't
|
||||
work as expected, and now the behavior can be explicitly controlled
|
||||
with the "input-x11-keyboard" option. This is only a temporary
|
||||
@@ -93,7 +99,7 @@ API changes
|
||||
although the old option name still works.
|
||||
1.4 - subtle change in X11 and "--wid" behavior
|
||||
(this change was added to 0.5.2, and broke some things, see #1090)
|
||||
--- mpv 0.5.0 is released ---
|
||||
--- mpv 0.5.0 ---
|
||||
1.3 - add MPV_MAKE_VERSION()
|
||||
1.2 - remove "stream-time-pos" property (no replacement)
|
||||
1.1 - remap dvdnav:// to dvd://
|
||||
@@ -105,6 +111,6 @@ API changes
|
||||
insignificant is now significant
|
||||
- add "cache-free" and "cache-used" properties
|
||||
- OSX: the "coreaudio" AO spdif code is split into a separate AO
|
||||
--- mpv 0.4.0 is released ---
|
||||
--- mpv 0.4.0 ---
|
||||
1.0 - the API is declared stable
|
||||
|
||||
@@ -1,35 +1,114 @@
|
||||
Client API examples
|
||||
===================
|
||||
# Client API examples
|
||||
|
||||
All these examples use the mpv client API through libmpv.
|
||||
|
||||
cocoa
|
||||
-----
|
||||
## Where are the docs?
|
||||
|
||||
The libmpv C API is documented directly in the header files (on normal Unix
|
||||
systems, this is in `/usr/include/mpv/client.h`.
|
||||
|
||||
libmpv merely gives you access to mpv's command interface, which is documented
|
||||
here:
|
||||
* Options (`mpv_set_option()` and friends): http://mpv.io/manual/master/#options
|
||||
* Commands (`mpv_command()` and friends): http://mpv.io/manual/master/#list-of-input-commands
|
||||
* Properties (`mpv_set_property()` and friends): http://mpv.io/manual/master/#properties
|
||||
|
||||
Essentially everything is done with them, including loading a file, retrieving
|
||||
playback progress, and so on.
|
||||
|
||||
## Methods of embedding the video window
|
||||
|
||||
All of these examples concentrate on how to integrate mpv's video renderers
|
||||
with your own GUI. This is generally the hardest part. libmpv enforces a
|
||||
somewhat efficient video output method, rather than e.g. returning a RGBA
|
||||
surface in memory for each frame. The latter would be prohibitively inefficient,
|
||||
because it would require conversion on the CPU. The goal is also not requiring
|
||||
the API users to reinvent their own video rendering/scaling/presentation
|
||||
mechanisms.
|
||||
|
||||
There are currently 2 methods of embedding video.
|
||||
|
||||
### Native window embedding
|
||||
|
||||
This uses the platform's native method of nesting multiple windows. For example,
|
||||
Linux/X11 can nest a window from a completely different process. The nested
|
||||
window can redraw contents on its own, and receive user input if the user
|
||||
interacts with this window.
|
||||
|
||||
libmpv lets you specify a parent window for its own video window via the `wid`
|
||||
option. Then libmpv will create its window with your window as parent, and
|
||||
render its video inside of it.
|
||||
|
||||
This method is highly OS-dependent. Some behavior is OS-specific. There are
|
||||
problems with focusing on X11 (the ancient X11 focus policy mismatches with
|
||||
that of modern UI toolkits - it's normally worked around, but this is not
|
||||
easily possible with raw window embedding). It seems to have stability problems
|
||||
on OSX when using the Qt toolkit.
|
||||
|
||||
### OpenGL embedding
|
||||
|
||||
This method lets you use libmpv's OpenGL renderer directly. You create an
|
||||
OpenGL context, and then use `mpv_opengl_cb_draw()` to render the video on
|
||||
each frame.
|
||||
|
||||
This is more complicated, because libmpv will work directly on your own OpenGL
|
||||
state. It's also not possible to have mpv automatically receive user input.
|
||||
You will have to simulate this with the `mouse`/`keypress`/`keydown`/`keyup`
|
||||
commands.
|
||||
|
||||
You also get much more flexibility. For example, you can actually render your
|
||||
own OSD on top of the video, something that is not possible with raw window
|
||||
embedding.
|
||||
|
||||
### Which one to use?
|
||||
|
||||
Due to the various platform-specific behavior and problems (in particular on
|
||||
OSX), OpenGL embedding is recommended. If you're not comfortable with requiring
|
||||
OpenGL, or want to support "direct" video output such as vdpau (which might
|
||||
win when it comes to performance and energy-saving), you should probably
|
||||
support both methods if possible.
|
||||
|
||||
## List of examples
|
||||
|
||||
### simple
|
||||
|
||||
Very primitive terminal-only example. Shows some most basic API usage.
|
||||
|
||||
### cocoa
|
||||
|
||||
Shows how to embed the mpv video window in Objective-C/Cocoa.
|
||||
|
||||
qt
|
||||
--
|
||||
### cocoa-openglcb
|
||||
|
||||
Similar to the cocoa sample, but shows how to integrate mpv's OpenGL renderer
|
||||
using libmpv's opengl-cb API. Since it does not require complicated interaction
|
||||
with Cocoa elements from different libraries, it's more robust.
|
||||
|
||||
### qt
|
||||
|
||||
Shows how to embed the mpv video window in Qt (using normal desktop widgets).
|
||||
|
||||
qml
|
||||
---
|
||||
### qt_opengl
|
||||
|
||||
Shows how to use mpv's OpenGL video renderer in QtQuick2 with QML.
|
||||
Shows how to use mpv's OpenGL video renderer in Qt. This uses the opengl-cb API
|
||||
for video. Since it does not rely on embedding "foreign" native Windows, it's
|
||||
usually more robust, potentially faster, and it's easier to control how your
|
||||
GUI interacts with the video. You can do your own OpenGL rendering on top of
|
||||
the video as well.
|
||||
|
||||
qml_direct
|
||||
----------
|
||||
### qml
|
||||
|
||||
Shows how to use mpv's OpenGL video renderer in QtQuick2 with QML. Uses the
|
||||
opengl-cb API for video. Since the video is a normal QML element, it's trivial
|
||||
to create OSD overlays with QML-native graphical elements as well.
|
||||
|
||||
### qml_direct
|
||||
|
||||
Alternative example, which typically avoids a FBO indirection. Might be
|
||||
slightly faster, but is less flexible and harder to use.
|
||||
slightly faster, but is less flexible and harder to use. In particular, the
|
||||
video is not a normal QML element. Uses the opengl-cb API for video.
|
||||
|
||||
sdl
|
||||
---
|
||||
### sdl
|
||||
|
||||
Show how to embed the mpv OpenGL renderer in SDL.
|
||||
|
||||
simple
|
||||
------
|
||||
|
||||
Very primitive terminal-only example. Shows some most basic API usage.
|
||||
Show how to embed the mpv OpenGL renderer in SDL. Uses the opengl-cb API for
|
||||
video.
|
||||
@@ -50,7 +50,7 @@ Item {
|
||||
text: "Make video look like on a Smart TV"
|
||||
onClicked: {
|
||||
if (checkbox.checked) {
|
||||
renderer.command(["vo_cmdline", "scale=sharpen3:scale-param1=5.0"])
|
||||
renderer.command(["vo_cmdline", "sharpen=5.0"])
|
||||
} else {
|
||||
renderer.command(["vo_cmdline", ""])
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
// Qt sets the locale in the QApplication constructor, but libmpv requires
|
||||
// the LC_NUMERIC category to be set to "C", so change it back.
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "mainwindow.h"
|
||||
#include "mpvwidget.h"
|
||||
#include <QPushButton>
|
||||
#include <QSlider>
|
||||
#include <QLayout>
|
||||
#include <QFileDialog>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_mpv = new MpvWidget(this);
|
||||
m_slider = new QSlider();
|
||||
m_slider->setOrientation(Qt::Horizontal);
|
||||
m_openBtn = new QPushButton("Open");
|
||||
m_playBtn = new QPushButton("Pause");
|
||||
QHBoxLayout *hb = new QHBoxLayout();
|
||||
hb->addWidget(m_openBtn);
|
||||
hb->addWidget(m_playBtn);
|
||||
QVBoxLayout *vl = new QVBoxLayout();
|
||||
vl->addWidget(m_mpv);
|
||||
vl->addWidget(m_slider);
|
||||
vl->addLayout(hb);
|
||||
setLayout(vl);
|
||||
connect(m_slider, SIGNAL(sliderMoved(int)), SLOT(seek(int)));
|
||||
connect(m_openBtn, SIGNAL(clicked()), SLOT(openMedia()));
|
||||
connect(m_playBtn, SIGNAL(clicked()), SLOT(pauseResume()));
|
||||
connect(m_mpv, SIGNAL(positionChanged(int)), m_slider, SLOT(setValue(int)));
|
||||
connect(m_mpv, SIGNAL(durationChanged(int)), this, SLOT(setSliderRange(int)));
|
||||
}
|
||||
|
||||
void MainWindow::openMedia()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(0, "Open a video");
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
m_mpv->command(QStringList() << "loadfile" << file);
|
||||
}
|
||||
|
||||
void MainWindow::seek(int pos)
|
||||
{
|
||||
m_mpv->command(QVariantList() << "seek" << pos << "absolute");
|
||||
}
|
||||
|
||||
void MainWindow::pauseResume()
|
||||
{
|
||||
const bool paused = m_mpv->getProperty("pause").toBool();
|
||||
m_mpv->setProperty("pause", !paused);
|
||||
}
|
||||
|
||||
void MainWindow::setSliderRange(int duration)
|
||||
{
|
||||
m_slider->setRange(0, duration);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MainWindow_H
|
||||
#define MainWindow_H
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
class MpvWidget;
|
||||
class QSlider;
|
||||
class QPushButton;
|
||||
class MainWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
public Q_SLOTS:
|
||||
void openMedia();
|
||||
void seek(int pos);
|
||||
void pauseResume();
|
||||
private Q_SLOTS:
|
||||
void setSliderRange(int duration);
|
||||
private:
|
||||
MpvWidget *m_mpv;
|
||||
QSlider *m_slider;
|
||||
QPushButton *m_openBtn;
|
||||
QPushButton *m_playBtn;
|
||||
};
|
||||
|
||||
#endif // MainWindow_H
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "mpvwidget.h"
|
||||
#include <stdexcept>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtCore/QMetaObject>
|
||||
|
||||
static void wakeup(void *ctx)
|
||||
{
|
||||
QMetaObject::invokeMethod((MpvWidget*)ctx, "on_mpv_events", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void *get_proc_address(void *ctx, const char *name) {
|
||||
Q_UNUSED(ctx);
|
||||
QOpenGLContext *glctx = QOpenGLContext::currentContext();
|
||||
if (!glctx)
|
||||
return NULL;
|
||||
return (void *)glctx->getProcAddress(QByteArray(name));
|
||||
}
|
||||
|
||||
MpvWidget::MpvWidget(QWidget *parent, Qt::WindowFlags f)
|
||||
: QOpenGLWidget(parent, f)
|
||||
{
|
||||
mpv = mpv::qt::Handle::FromRawHandle(mpv_create());
|
||||
if (!mpv)
|
||||
throw std::runtime_error("could not create mpv context");
|
||||
|
||||
mpv_set_option_string(mpv, "terminal", "yes");
|
||||
mpv_set_option_string(mpv, "msg-level", "all=v");
|
||||
if (mpv_initialize(mpv) < 0)
|
||||
throw std::runtime_error("could not initialize mpv context");
|
||||
|
||||
// Make use of the MPV_SUB_API_OPENGL_CB API.
|
||||
mpv::qt::set_option_variant(mpv, "vo", "opengl-cb");
|
||||
|
||||
// Request hw decoding, just for testing.
|
||||
mpv::qt::set_option_variant(mpv, "hwdec", "auto");
|
||||
|
||||
mpv_gl = (mpv_opengl_cb_context *)mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB);
|
||||
if (!mpv_gl)
|
||||
throw std::runtime_error("OpenGL not compiled in");
|
||||
mpv_opengl_cb_set_update_callback(mpv_gl, MpvWidget::on_update, (void *)this);
|
||||
connect(this, SIGNAL(frameSwapped()), SLOT(swapped()));
|
||||
|
||||
mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_DOUBLE);
|
||||
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
|
||||
mpv_set_wakeup_callback(mpv, wakeup, this);
|
||||
}
|
||||
|
||||
MpvWidget::~MpvWidget()
|
||||
{
|
||||
makeCurrent();
|
||||
if (mpv_gl)
|
||||
mpv_opengl_cb_set_update_callback(mpv_gl, NULL, NULL);
|
||||
// Until this call is done, we need to make sure the player remains
|
||||
// alive. This is done implicitly with the mpv::qt::Handle instance
|
||||
// in this class.
|
||||
mpv_opengl_cb_uninit_gl(mpv_gl);
|
||||
}
|
||||
|
||||
void MpvWidget::command(const QVariant& params)
|
||||
{
|
||||
mpv::qt::command_variant(mpv, params);
|
||||
}
|
||||
|
||||
void MpvWidget::setProperty(const QString& name, const QVariant& value)
|
||||
{
|
||||
mpv::qt::set_property_variant(mpv, name, value);
|
||||
}
|
||||
|
||||
QVariant MpvWidget::getProperty(const QString &name) const
|
||||
{
|
||||
return mpv::qt::get_property_variant(mpv, name);
|
||||
}
|
||||
|
||||
void MpvWidget::initializeGL()
|
||||
{
|
||||
int r = mpv_opengl_cb_init_gl(mpv_gl, NULL, get_proc_address, NULL);
|
||||
if (r < 0)
|
||||
throw std::runtime_error("could not initialize OpenGL");
|
||||
}
|
||||
|
||||
void MpvWidget::paintGL()
|
||||
{
|
||||
mpv_opengl_cb_draw(mpv_gl, defaultFramebufferObject(), width(), -height());
|
||||
}
|
||||
|
||||
void MpvWidget::swapped()
|
||||
{
|
||||
mpv_opengl_cb_report_flip(mpv_gl, 0);
|
||||
}
|
||||
|
||||
void MpvWidget::on_mpv_events()
|
||||
{
|
||||
// Process all events, until the event queue is empty.
|
||||
while (mpv) {
|
||||
mpv_event *event = mpv_wait_event(mpv, 0);
|
||||
if (event->event_id == MPV_EVENT_NONE) {
|
||||
break;
|
||||
}
|
||||
handle_mpv_event(event);
|
||||
}
|
||||
}
|
||||
|
||||
void MpvWidget::handle_mpv_event(mpv_event *event)
|
||||
{
|
||||
switch (event->event_id) {
|
||||
case MPV_EVENT_PROPERTY_CHANGE: {
|
||||
mpv_event_property *prop = (mpv_event_property *)event->data;
|
||||
if (strcmp(prop->name, "time-pos") == 0) {
|
||||
if (prop->format == MPV_FORMAT_DOUBLE) {
|
||||
double time = *(double *)prop->data;
|
||||
Q_EMIT positionChanged(time);
|
||||
}
|
||||
} else if (strcmp(prop->name, "duration") == 0) {
|
||||
if (prop->format == MPV_FORMAT_DOUBLE) {
|
||||
double time = *(double *)prop->data;
|
||||
Q_EMIT durationChanged(time);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
// Ignore uninteresting or unknown events.
|
||||
}
|
||||
}
|
||||
|
||||
void MpvWidget::on_update(void *ctx)
|
||||
{
|
||||
QMetaObject::invokeMethod((MpvWidget*)ctx, "update");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef PLAYERWINDOW_H
|
||||
#define PLAYERWINDOW_H
|
||||
|
||||
#include <QtWidgets/QOpenGLWidget>
|
||||
#include <mpv/client.h>
|
||||
#include <mpv/opengl_cb.h>
|
||||
#include <mpv/qthelper.hpp>
|
||||
|
||||
class MpvWidget Q_DECL_FINAL: public QOpenGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MpvWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
~MpvWidget();
|
||||
void command(const QVariant& params);
|
||||
void setProperty(const QString& name, const QVariant& value);
|
||||
QVariant getProperty(const QString& name) const;
|
||||
QSize sizeHint() const { return QSize(480, 270);}
|
||||
Q_SIGNALS:
|
||||
void durationChanged(int value);
|
||||
void positionChanged(int value);
|
||||
protected:
|
||||
void initializeGL() Q_DECL_OVERRIDE;
|
||||
void paintGL() Q_DECL_OVERRIDE;
|
||||
private Q_SLOTS:
|
||||
void swapped();
|
||||
void on_mpv_events();
|
||||
private:
|
||||
void handle_mpv_event(mpv_event *event);
|
||||
static void on_update(void *ctx);
|
||||
|
||||
mpv::qt::Handle mpv;
|
||||
mpv_opengl_cb_context *mpv_gl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PLAYERWINDOW_H
|
||||
@@ -0,0 +1,13 @@
|
||||
CONFIG -= app_bundle
|
||||
QT += widgets
|
||||
|
||||
QT_CONFIG -= no-pkg-config
|
||||
CONFIG += link_pkgconfig debug
|
||||
PKGCONFIG += mpv
|
||||
|
||||
HEADERS = \
|
||||
mpvwidget.h \
|
||||
mainwindow.h
|
||||
SOURCES = main.cpp \
|
||||
mpvwidget.cpp \
|
||||
mainwindow.cpp
|
||||
@@ -52,7 +52,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_Window *window =
|
||||
SDL_CreateWindow("hi", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
1000, 500, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
|
||||
1000, 500, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN |
|
||||
SDL_WINDOW_RESIZABLE);
|
||||
if (!window)
|
||||
die("failed to create SDL window");
|
||||
|
||||
|
||||
+1
-38
@@ -68,7 +68,7 @@ echo "MXE_TARGETS := i686-w64-mingw32.static" >> settings.mk
|
||||
# Build required packages. The following provide a minimum required to build
|
||||
# a reasonable mpv binary (though not an absolute minimum).
|
||||
|
||||
make gcc ffmpeg libass jpeg pthreads lua
|
||||
make gcc ffmpeg libass jpeg lua
|
||||
|
||||
# Add MXE binaries to $PATH
|
||||
export PATH=/opt/mxe/usr/bin/:$PATH
|
||||
@@ -173,40 +173,3 @@ mv -f /mingw64/bin/libmpv.dll.a /mingw64/lib/
|
||||
sed -i 's_/mingw64/bin_/mingw64/lib_' /mingw64/lib/pkgconfig/mpv.pc
|
||||
rmdir /mingw64/bin/pkgconfig
|
||||
```
|
||||
|
||||
Additional dependencies
|
||||
=======================
|
||||
|
||||
pthreads
|
||||
--------
|
||||
|
||||
mpv will use a pthreads wrapper by default. Either pthreads-win32 or
|
||||
winpthreads should work. The latter is packaged with most MinGW-w64
|
||||
environments, including MSYS2, so it shouldn't be a problem. If you don't have
|
||||
a pthreads wrapper or you want to build mpv without one, configure with:
|
||||
|
||||
```bash
|
||||
./waf configure --enable-win32-internal-pthreads
|
||||
```
|
||||
|
||||
libwaio
|
||||
-------
|
||||
|
||||
If you want to use ``--input-file``, you need libwaio. It's available from
|
||||
git://midipix.org/waio
|
||||
|
||||
To compile libwaio in MSYS2, run:
|
||||
|
||||
```bash
|
||||
git clone git://midipix.org/waio && cd waio
|
||||
|
||||
# 32-bit build, run from mingw32_shell.bat
|
||||
./build-mingw-nt32 lib-static CC=gcc AR=ar
|
||||
cp -r include/waio /mingw32/include
|
||||
cp lib32/libwaio.a /mingw32/lib
|
||||
|
||||
# 64-bit build, run from mingw64_shell.bat
|
||||
./build-mingw-nt64 lib-static CC=gcc AR=ar
|
||||
cp -r include/waio /mingw64/include
|
||||
cp lib64/libwaio.a /mingw64/lib
|
||||
```
|
||||
+11
-9
@@ -14,9 +14,11 @@ Sending patches
|
||||
``git format-patch``. diffs posted as pastebins (especially if the http link
|
||||
returns HTML) just cause extra work for everyone, because they lack commit
|
||||
message and authorship information.
|
||||
- When creating pull requests, be sure to test your changes. If you didn't, please
|
||||
say so in the pull request message.
|
||||
|
||||
- All new code must be LGPLv2.1+ licensed, or come with the implicit agreement
|
||||
that it will be relicensed to LGPLv2.1+ later (see ``Copyright`` in the
|
||||
repository root directory).
|
||||
- When creating pull requests, be sure to test your changes. If you didn't,
|
||||
please say so in the pull request message.
|
||||
- Write informative commit messages. Use present tense to describe the
|
||||
situation with the patch applied, and past tense for the situation before
|
||||
the change.
|
||||
@@ -27,8 +29,8 @@ Sending patches
|
||||
|
||||
For example, you fixed a crash in af_volume.c:
|
||||
|
||||
Bad: ``fixed the bug (wtf?)``
|
||||
Good: ``af_volume: fix crash due to null pointer access``
|
||||
- Bad: ``fixed the bug (wtf?)``
|
||||
- Good: ``af_volume: fix crash due to null pointer access``
|
||||
|
||||
Having a prefix gives context, and is especially useful when trying to find
|
||||
a specific change by looking at the history, or when running ``git blame``.
|
||||
@@ -53,10 +55,10 @@ Sending patches
|
||||
something like reformatting a whole file, and hiding an actual functional
|
||||
change in the same commit.
|
||||
- If you add a new command line option, document it in options.rst. If you
|
||||
add a new input property, document it in input.rst.
|
||||
- All new code must be LGPLv2.1+ licensed, or come with the implicit agreement
|
||||
that it will be relicensed to LGPLv2.1+ later (see ``Copyright`` in the
|
||||
repository root directory).
|
||||
add a new input property, document it in input.rst. Changes to the user
|
||||
interface (options, properties, commands) should be documented in
|
||||
interface-changes.rst. Changes to libmpv should be documented in
|
||||
client-api-changes.rst.
|
||||
|
||||
Code formatting
|
||||
---------------
|
||||
|
||||
+2
-3
@@ -31,9 +31,8 @@ estimated remaining duration of the source file is used.
|
||||
|
||||
Note::
|
||||
|
||||
mpv can't use ordered chapter files in EDL entries. Usage of relative or
|
||||
absolute paths as well as any protocol prefixes is prevented for security
|
||||
reasons.
|
||||
Usage of relative or absolute paths as well as any protocol prefixes may be
|
||||
prevented for security reasons.
|
||||
|
||||
|
||||
Syntax of mpv EDL files
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
mpv provides access to its internal via the following means:
|
||||
mpv provides access to its internals via the following means:
|
||||
|
||||
- options
|
||||
- commands
|
||||
@@ -19,7 +19,51 @@ Interface changes
|
||||
|
||||
::
|
||||
|
||||
--- mpv 0.10.0 will be released ---
|
||||
--- mpv 0.16.0 ---
|
||||
- change --audio-channels default to stereo (use --audio-channels=auto to
|
||||
get the old default)
|
||||
- add --audio-normalize-downmix
|
||||
- change the default downmix behavior (--audio-normalize-downmix=yes to get
|
||||
the old default)
|
||||
- VO opengl custom shaders must now use "sample_pixel" as function name,
|
||||
instead of "sample"
|
||||
- change VO opengl scaler-resizes-only default to enabled
|
||||
- add VO opengl "interpolation-threshold" suboption (introduces new default
|
||||
behavior, which can change e.g. ``--video-sync=display-vdrop`` to the
|
||||
worse, but is usually what you want)
|
||||
- make "volume" and "mute" properties changeable even if no audio output is
|
||||
active (this gives not-ideal behavior if --softvol=no is used)
|
||||
- add "volume-max" and "mixer-active" properties
|
||||
- ignore --input-cursor option for events injected by input commands like
|
||||
"mouse", "keydown", etc.
|
||||
--- mpv 0.15.0 ---
|
||||
- change "yadif" video filter defaults
|
||||
--- mpv 0.14.0 ---
|
||||
- vo_opengl interpolation now requires --video-sync=display-... to be set
|
||||
- change some vo_opengl defaults (including changing tscale)
|
||||
- add "vsync-ratio", "estimated-display-fps" properties
|
||||
- add --rebase-start-time option
|
||||
This is a breaking change to start time handling. Instead of making start
|
||||
time handling an aspect of different options and properties (like
|
||||
"time-pos" vs. "playback-time"), make it dependent on the new option. For
|
||||
compatibility, the "time-start" property now always returns 0, so code
|
||||
which attempted to handle rebasing manually will not break.
|
||||
--- mpv 0.13.0 ---
|
||||
- remove VO opengl-cb frame queue suboptions (no replacement)
|
||||
--- mpv 0.12.0 ---
|
||||
- remove --use-text-osd (useless; fontconfig isn't a requirement anymore,
|
||||
and text rendering is also lazily initialized)
|
||||
- some time properties (at least "playback-time", "time-pos",
|
||||
"time-remaining", "playtime-remaining") now are unavailable if the time
|
||||
is unknown, instead of just assuming that the internal playback position
|
||||
is 0
|
||||
- add --audio-fallback-to-null option
|
||||
- replace vf_format outputlevels suboption with "video-output-levels" global
|
||||
property/option; also remove "colormatrix-output-range" property
|
||||
- vo_opengl: remove sharpen3/sharpen5 scale filters, add sharpen sub-option
|
||||
--- mpv 0.11.0 ---
|
||||
- add "af-metadata" property
|
||||
--- mpv 0.10.0 ---
|
||||
- add --video-aspect-method option
|
||||
- add --playlist-pos option
|
||||
- add --video-sync* options
|
||||
@@ -85,4 +129,4 @@ Interface changes
|
||||
- add --screenshot-high-bit-depth
|
||||
- add --screenshot-jpeg-source-chroma
|
||||
- default action for "rescan_external_files" command changes
|
||||
--- mpv 0.9.0 is released ---
|
||||
--- mpv 0.9.0 ---
|
||||
+8
-181
@@ -11,6 +11,10 @@ syntax is:
|
||||
|
||||
To get a full list of available audio filters, see ``--af=help``.
|
||||
|
||||
Also, keep in mind that most actual filters are available via the ``lavfi``
|
||||
wrapper, which gives you access to most of libavfilter's filters. This
|
||||
includes all filters that have been ported from MPlayer to libavfilter.
|
||||
|
||||
You can also set defaults for each filter. The defaults are applied before the
|
||||
normal filter parameters.
|
||||
|
||||
@@ -59,6 +63,9 @@ Available filters are:
|
||||
(If you just want to set defaults for this filter that will be used
|
||||
even by automatically inserted lavrresample instances, you should
|
||||
prefer setting them with ``--af-defaults=lavrresample:...``.)
|
||||
``normalize=<yes|no|auto>``
|
||||
Whether to normalize when remixing channel layouts (default: auto).
|
||||
``auto`` uses the value set by ``--audio-normalize-downmix``.
|
||||
``o=<string>``
|
||||
Set AVOptions on the SwrContext or AVAudioResampleContext. These should
|
||||
be documented by FFmpeg or Libav.
|
||||
@@ -96,59 +103,6 @@ Available filters are:
|
||||
If the input channel number is less than ``<minch>``, the filter will
|
||||
detach itself (default: 3).
|
||||
|
||||
``sweep[=speed]``
|
||||
Produces a sine sweep.
|
||||
|
||||
``<0.0-1.0>``
|
||||
Sine function delta, use very low values to hear the sweep.
|
||||
|
||||
``sinesuppress[=freq:decay]``
|
||||
Remove a sine at the specified frequency. Useful to get rid of the 50/60 Hz
|
||||
noise on low quality audio equipment. It only works on mono input.
|
||||
|
||||
``<freq>``
|
||||
The frequency of the sine which should be removed (in Hz) (default:
|
||||
50)
|
||||
``<decay>``
|
||||
Controls the adaptivity (a larger value will make the filter adapt to
|
||||
amplitude and phase changes quicker, a smaller value will make the
|
||||
adaptation slower) (default: 0.0001). Reasonable values are around
|
||||
0.001.
|
||||
|
||||
``bs2b[=option1:option2:...]``
|
||||
Bauer stereophonic to binaural transformation using libbs2b. Improves the
|
||||
headphone listening experience by making the sound similar to that from
|
||||
loudspeakers, allowing each ear to hear both channels and taking into
|
||||
account the distance difference and the head shadowing effect. It is
|
||||
applicable only to 2-channel audio.
|
||||
|
||||
``fcut=<300-1000>``
|
||||
Set cut frequency in Hz.
|
||||
``feed=<10-150>``
|
||||
Set feed level for low frequencies in 0.1*dB.
|
||||
``profile=<value>``
|
||||
Several profiles are available for convenience:
|
||||
|
||||
:default: will be used if nothing else was specified (fcut=700,
|
||||
feed=45)
|
||||
:cmoy: Chu Moy circuit implementation (fcut=700, feed=60)
|
||||
:jmeier: Jan Meier circuit implementation (fcut=650, feed=95)
|
||||
|
||||
If ``fcut`` or ``feed`` options are specified together with a profile, they
|
||||
will be applied on top of the selected profile.
|
||||
|
||||
``hrtf[=flag]``
|
||||
Head-related transfer function: Converts multichannel audio to 2-channel
|
||||
output for headphones, preserving the spatiality of the sound.
|
||||
|
||||
==== ===================================
|
||||
Flag Meaning
|
||||
==== ===================================
|
||||
m matrix decoding of the rear channel
|
||||
s 2-channel matrix decoding
|
||||
0 no matrix decoding (default)
|
||||
==== ===================================
|
||||
|
||||
``equalizer=g1:g2:g3:...:g10``
|
||||
10 octave band graphic equalizer, implemented using 10 IIR band-pass
|
||||
filters. This means that it works regardless of what type of audio is
|
||||
@@ -206,7 +160,7 @@ Available filters are:
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
``mpv --af=channels=4:[0-1,1-0,0-2,1-3] media.avi``
|
||||
``mpv --af=channels=4:[0-1,1-0,2-2,3-3] media.avi``
|
||||
Would change the number of channels to 4 and set up 4 routes that
|
||||
swap channel 0 and channel 1 and leave channel 2 and 3 intact.
|
||||
Observe that if media containing two channels were played back,
|
||||
@@ -354,64 +308,6 @@ Available filters are:
|
||||
``mpv '--af=format=channels=5.1' '--audio-channels=5.1'`` would always force
|
||||
remixing audio to 5.1 and output it like this.
|
||||
|
||||
``sub[=fc:ch]``
|
||||
Adds a subwoofer channel to the audio stream. The audio data used for
|
||||
creating the subwoofer channel is an average of the sound in channel 0 and
|
||||
channel 1. The resulting sound is then low-pass filtered by a 4th order
|
||||
Butterworth filter with a default cutoff frequency of 60Hz and added to a
|
||||
separate channel in the audio stream.
|
||||
|
||||
.. warning::
|
||||
|
||||
Disable this filter when you are playing media with an LFE channel
|
||||
(e.g. 5.1 surround sound), otherwise this filter will disrupt the sound
|
||||
to the subwoofer.
|
||||
|
||||
``<fc>``
|
||||
cutoff frequency in Hz for the low-pass filter (20 Hz to 300 Hz)
|
||||
(default: 60 Hz) For the best result try setting the cutoff frequency
|
||||
as low as possible. This will improve the stereo or surround sound
|
||||
experience.
|
||||
``<ch>``
|
||||
Determines the channel number in which to insert the sub-channel
|
||||
audio. Channel number can be between 0 and 7 (default: 5). Observe
|
||||
that the number of channels will automatically be increased to <ch> if
|
||||
necessary.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``mpv --af=sub=100:4 --audio-channels=5 media.avi``
|
||||
Would add a subwoofer channel with a cutoff frequency of 100 Hz to
|
||||
output channel 4.
|
||||
|
||||
``center``
|
||||
Creates a center channel from the front channels. May currently be low
|
||||
quality as it does not implement a high-pass filter for proper extraction
|
||||
yet, but averages and halves the channels instead.
|
||||
|
||||
``<ch>``
|
||||
Determines the channel number in which to insert the center channel.
|
||||
Channel number can be between 0 and 7 (default: 5). Observe that the
|
||||
number of channels will automatically be increased to ``<ch>`` if
|
||||
necessary.
|
||||
|
||||
``surround[=delay]``
|
||||
Decoder for matrix encoded surround sound like Dolby Surround. Some files
|
||||
with 2-channel audio actually contain matrix encoded surround sound.
|
||||
|
||||
``<delay>``
|
||||
delay time in ms for the rear speakers (0 to 1000) (default: 20) This
|
||||
delay should be set as follows: If d1 is the distance from the
|
||||
listening position to the front speakers and d2 is the distance from
|
||||
the listening position to the rear speakers, then the delay should be
|
||||
set to 15ms if d1 <= d2 and to 15 + 5*(d1-d2) if d1 > d2.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``mpv --af=surround=15 --audio-channels=4 media.avi``
|
||||
Would add surround sound decoding with 15 ms delay for the sound to
|
||||
the rear speakers.
|
||||
|
||||
``delay[=[ch1,ch2,...]]``
|
||||
Delays the sound to the loudspeakers such that the sound from the
|
||||
different channels arrives at the listening position simultaneously. It is
|
||||
@@ -440,36 +336,6 @@ Available filters are:
|
||||
Would delay front left and right by 10.5 ms, the two rear channels
|
||||
and the subwoofer by 0 ms and the center channel by 7 ms.
|
||||
|
||||
``export=mmapped_file:nsamples]``
|
||||
Exports the incoming signal to other processes using memory mapping
|
||||
(``mmap()``). Memory mapped areas contain a header::
|
||||
|
||||
int nch /* number of channels */
|
||||
int size /* buffer size */
|
||||
unsigned long long counter /* Used to keep sync, updated every time
|
||||
new data is exported. */
|
||||
|
||||
The rest is payload (non-interleaved) 16-bit data.
|
||||
|
||||
``<mmapped_file>``
|
||||
File to map data to (required)
|
||||
``<nsamples>``
|
||||
number of samples per channel (default: 512).
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``mpv --af=export=/tmp/mpv-af_export:1024 media.avi``
|
||||
Would export 1024 samples per channel to ``/tmp/mpv-af_export``.
|
||||
|
||||
``extrastereo[=mul]``
|
||||
(Linearly) increases the difference between left and right channels which
|
||||
adds some sort of "live" effect to playback.
|
||||
|
||||
``<mul>``
|
||||
Sets the difference coefficient (default: 2.5). 0.0 means mono sound
|
||||
(average of both channels), with 1.0 sound will be unchanged, with
|
||||
-1.0 left and right channels will be swapped.
|
||||
|
||||
``drc[=method:target]``
|
||||
Applies dynamic range compression. This maximizes the volume by compressing
|
||||
the audio signal's dynamic range. (Formerly called ``volnorm``.)
|
||||
@@ -493,45 +359,6 @@ Available filters are:
|
||||
This filter can cause distortion with audio signals that have a very
|
||||
large dynamic range.
|
||||
|
||||
``ladspa=file:label:[<control0>,<control1>,...]``
|
||||
Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin. This
|
||||
filter is reentrant, so multiple LADSPA plugins can be used at once.
|
||||
|
||||
``<file>``
|
||||
Specifies the LADSPA plugin library file.
|
||||
|
||||
.. note::
|
||||
|
||||
See also the note about the ``LADSPA_PATH`` variable in the
|
||||
`ENVIRONMENT VARIABLES`_ section.
|
||||
``<label>``
|
||||
Specifies the filter within the library. Some libraries contain only
|
||||
one filter, but others contain many of them. Entering 'help' here
|
||||
will list all available filters within the specified library, which
|
||||
eliminates the use of 'listplugins' from the LADSPA SDK.
|
||||
``[<control0>,<control1>,...]``
|
||||
Controls are zero or more ``,`` separated floating point values that
|
||||
determine the behavior of the loaded plugin (for example delay,
|
||||
threshold or gain).
|
||||
In verbose mode (add ``-v`` to the mpv command line), all
|
||||
available controls and their valid ranges are printed. This eliminates
|
||||
the use of 'analyseplugin' from the LADSPA SDK.
|
||||
Note that ``,`` is already used by the option parser to separate
|
||||
filters, so you must quote the list of values with ``[...]`` or
|
||||
similar.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``mpv --af=ladspa='/usr/lib/ladspa/delay.so':delay_5s:[0.5,0.2] media.avi``
|
||||
Does something.
|
||||
|
||||
``karaoke``
|
||||
Simple voice removal filter exploiting the fact that voice is usually
|
||||
recorded with mono gear and later 'center' mixed onto the final audio
|
||||
stream. Beware that this filter will turn your signal into mono. Works
|
||||
well for 2 channel tracks; do not bother trying it on anything but 2
|
||||
channel stereo.
|
||||
|
||||
``scaletempo[=option1:option2:...]``
|
||||
Scales audio tempo without altering pitch, optionally synced to playback
|
||||
speed (default).
|
||||
|
||||
+9
-26
@@ -20,10 +20,8 @@ normal driver parameters.
|
||||
|
||||
See ``--ao=help`` for a list of compiled-in audio output drivers. The
|
||||
driver ``--ao=alsa`` is preferred. ``--ao=pulse`` is preferred on systems
|
||||
where PulseAudio is used. On Windows, ``--ao=wasapi`` is preferred,
|
||||
though it might cause trouble sometimes, in which case ``--ao=dsound``
|
||||
should be used. On BSD systems, ``--ao=oss`` or `--ao=sndio`` may work
|
||||
(the latter being experimental). On OS X systems, use ``--ao=coreaudio``.
|
||||
where PulseAudio is used. On BSD systems, ``--ao=oss`` or ``--ao=sndio``
|
||||
may work (the latter being experimental).
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
@@ -139,16 +137,13 @@ Available audio output drivers are:
|
||||
Automatically create connections to output ports (default: enabled).
|
||||
When enabled, the maximum number of output channels will be limited to
|
||||
the number of available output ports.
|
||||
``std-channel-layout=alsa|waveext|any``
|
||||
Select the standard channel layout (default: alsa). JACK itself has no
|
||||
``std-channel-layout=waveext|any``
|
||||
Select the standard channel layout (default: waveext). JACK itself has no
|
||||
notion of channel layouts (i.e. assigning which speaker a given
|
||||
channel is supposed to map to) - it just takes whatever the application
|
||||
outputs, and reroutes it to whatever the user defines. This means the
|
||||
user and the application are in charge of dealing with the channel
|
||||
layout. ``alsa`` uses the old MPlayer layout, which is inspired by
|
||||
ALSA's standard layouts. In this mode, ao_jack will refuse to play 3
|
||||
or 7 channels (because these do not really have a defined meaning in
|
||||
MPlayer). ``waveext`` uses WAVE_FORMAT_EXTENSIBLE order, which, even
|
||||
layout. ``waveext`` uses WAVE_FORMAT_EXTENSIBLE order, which, even
|
||||
though it was defined by Microsoft, is the standard on many systems.
|
||||
The value ``any`` makes JACK accept whatever comes from the audio
|
||||
filter chain, regardless of channel layout and without reordering. This
|
||||
@@ -168,7 +163,7 @@ Available audio output drivers are:
|
||||
will actually work. The disadvantage is that it will change the
|
||||
system-wide audio settings. This is equivalent to changing the ``Format``
|
||||
setting in the ``Audio Devices`` dialog in the ``Audio MIDI Setup``
|
||||
utility. Note that this does not effect the selected speaker setup.
|
||||
utility. Note that this does not affect the selected speaker setup.
|
||||
|
||||
``exclusive``
|
||||
Use exclusive mode access. This merely redirects to
|
||||
@@ -208,19 +203,7 @@ Available audio output drivers are:
|
||||
(it used to be required to get good behavior on old PulseAudio versions).
|
||||
|
||||
If you have stuttering video when using pulse, try to enable this
|
||||
option. (Or alternatively, try to update PulseAudio.)
|
||||
|
||||
``dsound`` (Windows only)
|
||||
DirectX DirectSound audio output driver
|
||||
|
||||
.. note:: This driver is for compatibility with old systems.
|
||||
|
||||
``device=<devicenum>``
|
||||
Sets the device number to use. Playing a file with ``-v`` will show a
|
||||
list of available devices.
|
||||
|
||||
``buffersize=<ms>``
|
||||
DirectSound buffer size in milliseconds (default: 200).
|
||||
option. (Or try to update PulseAudio.)
|
||||
|
||||
``sdl``
|
||||
SDL 1.2+ audio output driver. Should work on any platform supported by SDL
|
||||
@@ -259,7 +242,7 @@ Available audio output drivers are:
|
||||
``speed``
|
||||
Simulated audio playback speed as a multiplier. Usually, a real audio
|
||||
device will not go exactly as fast as the system clock. It will deviate
|
||||
just a little, and this option helps simulating this.
|
||||
just a little, and this option helps to simulate this.
|
||||
|
||||
``latency``
|
||||
Simulated device latency. This is additional to EOF.
|
||||
@@ -328,7 +311,7 @@ Available audio output drivers are:
|
||||
String are valid; the GUID string is guaranteed to not change
|
||||
unless the driver is uninstalled.
|
||||
|
||||
Also supports searching active devices by human readable name. If more
|
||||
Also supports searching active devices by human-readable name. If more
|
||||
than one device matches the name, refuses loading it.
|
||||
|
||||
This option is mostly deprecated in favour of the more general
|
||||
|
||||
+4
-4
@@ -93,8 +93,8 @@ You can encode files from one format/codec to another using this facility.
|
||||
Completely empties the options list.
|
||||
|
||||
``--oafirst``
|
||||
Force the audio stream to become the first stream in the output. By default
|
||||
the order is unspecified.
|
||||
Force the audio stream to become the first stream in the output.
|
||||
By default, the order is unspecified.
|
||||
|
||||
``--ovc=<codec>``
|
||||
Specifies the output video codec. This can be a comma separated list of
|
||||
@@ -134,8 +134,8 @@ You can encode files from one format/codec to another using this facility.
|
||||
Completely empties the options list.
|
||||
|
||||
``--ovfirst``
|
||||
Force the video stream to become the first stream in the output. By default
|
||||
the order is unspecified.
|
||||
Force the video stream to become the first stream in the output.
|
||||
By default, the order is unspecified.
|
||||
|
||||
``--ocopyts``
|
||||
Copies input pts to the output video (not supported by some output
|
||||
|
||||
+143
-31
@@ -329,9 +329,9 @@ List of Input Commands
|
||||
This is similar to ``sub-step``, except that it seeks video and audio
|
||||
instead of adjusting the subtitle delay.
|
||||
|
||||
Like with ``sub-step``, this works with external text subtitles only. For
|
||||
embedded text subtitles (like with Matroska), this works only with subtitle
|
||||
events that have already been displayed.
|
||||
For embedded subtitles (like with Matroska), this works only with subtitle
|
||||
events that have already been displayed, or are within a short prefetch
|
||||
range.
|
||||
|
||||
``osd [<level>]``
|
||||
Toggle OSD level. If ``<level>`` is specified, set the OSD mode
|
||||
@@ -418,7 +418,7 @@ List of Input Commands
|
||||
|
||||
<reselect> (default)
|
||||
Select the default audio and subtitle streams, which typically selects
|
||||
external files with highest preference. (The implementation is not
|
||||
external files with the highest preference. (The implementation is not
|
||||
perfect, and could be improved on request.)
|
||||
|
||||
<keep-selection>
|
||||
@@ -546,6 +546,12 @@ Input Commands that are Possibly Subject to Change
|
||||
Always bind a key. (The input section that was made active most recently
|
||||
wins if there are ambiguities.)
|
||||
|
||||
This command can be used to dispatch arbitrary keys to a script or a client
|
||||
API user. If the input section defines ``script-binding`` commands, it is
|
||||
also possible to get separate events on key up/down, and relatively detailed
|
||||
information about the key state. The special key name ``unmapped`` can be
|
||||
used to match any unmapped key.
|
||||
|
||||
``overlay-add <id> <x> <y> "<file>" <offset> "<fmt>" <w> <h> <stride>``
|
||||
Add an OSD overlay sourced from raw data. This might be useful for scripts
|
||||
and applications controlling mpv, and which want to display things on top
|
||||
@@ -647,14 +653,20 @@ Input Commands that are Possibly Subject to Change
|
||||
For completeness, here is how this command works internally. The details
|
||||
could change any time. On any matching key event, ``script_message_to``
|
||||
or ``script_message`` is called (depending on whether the script name is
|
||||
included), where the first argument is the string ``key-binding``, the
|
||||
second argument is the name of the binding, and the third argument is the
|
||||
key state as string. The key state consists of a number of letters. The
|
||||
first letter is one of ``d`` (key was pressed down), ``u`` (was released),
|
||||
``r`` (key is still down, and was repeated; only if key repeat is enabled
|
||||
for this binding), ``p`` (key was pressed; happens if up/down can't be
|
||||
tracked). The second letter whether the event originates from the mouse,
|
||||
either ``m`` (mouse button) or ``-`` (something else).
|
||||
included), with the following arguments:
|
||||
|
||||
1. The string ``key-binding``.
|
||||
2. The name of the binding (as established above).
|
||||
3. The key state as string (see below).
|
||||
4. The key name (since mpv 0.15.0).
|
||||
|
||||
The key state consists of 2 letters:
|
||||
|
||||
1. One of ``d`` (key was pressed down), ``u`` (was released), ``r`` (key
|
||||
is still down, and was repeated; only if key repeat is enabled for this
|
||||
binding), ``p`` (key was pressed; happens if up/down can't be tracked).
|
||||
2. Whether the event originates from the mouse, either ``m`` (mouse button)
|
||||
or ``-`` (something else).
|
||||
|
||||
``ab-loop``
|
||||
Cycle through A-B loop states. The first command will set the ``A`` point
|
||||
@@ -682,6 +694,18 @@ Input Commands that are Possibly Subject to Change
|
||||
field is of type MPV_FORMAT_BYTE_ARRAY with the actual image data. The image
|
||||
is freed as soon as the result node is freed.
|
||||
|
||||
``vf-command "<label>" "<cmd>" "<args>"``
|
||||
Send a command to the filter with the given ``<label>``. Use ``all`` to send
|
||||
it to all filters at once. The command and argument string is filter
|
||||
specific. Currently, this only works with the ``lavfi`` filter - see
|
||||
the libavfilter documentation for which commands a filter supports.
|
||||
|
||||
Note that the ``<label>`` is a mpv filter label, not a libavfilter filter
|
||||
name.
|
||||
|
||||
``af-command "<label>" "<cmd>" "<args>"``
|
||||
Same as ``vf-command``, but for audio filters.
|
||||
|
||||
Undocumented commands: ``tv-last-channel`` (TV/DVB only),
|
||||
``ao-reload`` (experimental/internal).
|
||||
|
||||
@@ -741,6 +765,17 @@ The following hooks are currently defined:
|
||||
``file-local-options/<option name>``. The player will wait until all
|
||||
hooks are run.
|
||||
|
||||
``on_preloaded``
|
||||
Called after a file has been opened, and before tracks are selected and
|
||||
decoders are created. This has some usefulness if an API users wants
|
||||
to select tracks manually, based on the set of available tracks. It's
|
||||
also useful to initialize ``--lavfi-complex`` in a specific way by API,
|
||||
without having to "probe" the available streams at first.
|
||||
|
||||
Note that this does not yet apply default track selection. Which operations
|
||||
exactly can be done and not be done, and what information is available and
|
||||
what is not yet available yet, is all subject to change.
|
||||
|
||||
``on_unload``
|
||||
Run before closing a file, and before actually uninitializing
|
||||
everything. It's not possible to resume playback in this state.
|
||||
@@ -782,7 +817,7 @@ Input sections group a set of bindings, and enable or disable them at once.
|
||||
In ``input.conf``, each key binding is assigned to an input section, rather
|
||||
than actually having explicit text sections.
|
||||
|
||||
Also see ``enable_section`` and ``disable_section`` commands.
|
||||
See also: ``enable_section`` and ``disable_section`` commands.
|
||||
|
||||
Predefined bindings:
|
||||
|
||||
@@ -860,7 +895,11 @@ Property list
|
||||
quantities: fps and possibly rounded timestamps.)
|
||||
|
||||
``path``
|
||||
Full path of the currently played file.
|
||||
Full path of the currently played file. Usually this is exactly the same
|
||||
string you pass on the mpv command line or the ``loadfile`` command, even
|
||||
if it's a relative path. If you expect an absolute path, you will have to
|
||||
determine it yourself, for example by using the ``working-directory``
|
||||
property.
|
||||
|
||||
``media-title``
|
||||
If the currently played file has a ``title`` tag, use that.
|
||||
@@ -913,6 +952,26 @@ Property list
|
||||
``vo-drop-frame-count``
|
||||
Frames dropped by VO (when using ``--framedrop=vo``).
|
||||
|
||||
``mistimed-frame-count``
|
||||
Number of video frames that were not timed correctly in display-sync mode
|
||||
for the sake of keeping A/V sync. This does not include external
|
||||
circumstances, such as video rendering being too slow or the graphics
|
||||
driver somehow skipping a vsync. It does not include rounding errors either
|
||||
(which can happen especially with bad source timestamps). For example,
|
||||
using the ``display-desync`` mode should never change this value from 0.
|
||||
|
||||
``vsync-ratio``
|
||||
For how many vsyncs a frame is displayed on average. This is available if
|
||||
display-sync is active only. For 30 FPS video on a 60 Hz screen, this will
|
||||
be 2. This is the moving average of what actually has been scheduled, so
|
||||
24 FPS on 60 Hz will never remain exactly on 2.5, but jitter depending on
|
||||
the last frame displayed.
|
||||
|
||||
``vo-delayed-frame-count``
|
||||
Estimated number of frames delayed due to external circumstances in
|
||||
display-sync mode. Note that in general, mpv has to guess that this is
|
||||
happening, and the guess can be inaccurate.
|
||||
|
||||
``percent-pos`` (RW)
|
||||
Position in current file (0-100). The advantage over using this instead of
|
||||
calculating it out of other properties is that it properly falls back to
|
||||
@@ -923,8 +982,9 @@ Property list
|
||||
Position in current file in seconds.
|
||||
|
||||
``time-start``
|
||||
Return the start time of the file. (Usually 0, but some kind of files,
|
||||
especially transport streams, can have a different start time.)
|
||||
Deprecated. Always returns 0. Before mpv 0.14, this used to return the start
|
||||
time of the file (could affect e.g. transport streams). See
|
||||
``--rebase-start-time`` option.
|
||||
|
||||
``time-remaining``
|
||||
Remaining length of the file in seconds. Note that the file duration is not
|
||||
@@ -934,9 +994,10 @@ Property list
|
||||
``time-remaining`` scaled by the current ``speed``.
|
||||
|
||||
``playback-time`` (RW)
|
||||
The playback time, which is the time relative to playback start. (This can
|
||||
be different from the ``time-pos`` property if the file does not start at
|
||||
position ``0``, in which case ``time-pos`` is the source timestamp.)
|
||||
Position in current file in seconds. Unlike ``time-pos``, the time is
|
||||
clamped to the range of the file. (Inaccurate file durations etc. could
|
||||
make it go out of range. Useful on attempts to seek outside of the file,
|
||||
as the seek target time is considered the current position during seeking.)
|
||||
|
||||
``chapter`` (RW)
|
||||
Current chapter number. The number of the first chapter is 0.
|
||||
@@ -1082,15 +1143,18 @@ Property list
|
||||
|
||||
``vf-metadata/<filter-label>``
|
||||
Metadata added by video filters. Accessed by the filter label,
|
||||
which if not explicitly specified using the ``@filter-label:`` syntax,
|
||||
which, if not explicitly specified using the ``@filter-label:`` syntax,
|
||||
will be ``<filter-name>NN``.
|
||||
|
||||
Works similar to ``metadata`` property. It allows the same access
|
||||
methods (using sub-properties).
|
||||
|
||||
An example of these kind of metadata are the cropping parameters
|
||||
An example of this kind of metadata are the cropping parameters
|
||||
added by ``--vf=lavfi=cropdetect``.
|
||||
|
||||
``af-metadata/<filter-label>``
|
||||
Equivalent to ``vf-metadata/<filter-label>``, but for audio filters.
|
||||
|
||||
``pause`` (RW)
|
||||
Pause status. This is usually ``yes`` or ``no``. See ``--pause``.
|
||||
|
||||
@@ -1111,11 +1175,13 @@ Property list
|
||||
Network cache fill state (0-100.0).
|
||||
|
||||
``cache-size`` (RW)
|
||||
Total network cache size in KB. This is similar to ``--cache``. This allows
|
||||
to set the cache size at runtime. Currently, it's not possible to enable
|
||||
Network cache size in KB. This is similar to ``--cache``. This allows
|
||||
setting the cache size at runtime. Currently, it's not possible to enable
|
||||
or disable the cache at runtime using this property, just to resize an
|
||||
existing cache.
|
||||
|
||||
This does not include the backbuffer size (changed after mpv 0.10.0).
|
||||
|
||||
Note that this tries to keep the cache contents as far as possible. To make
|
||||
this easier, the cache resizing code will allocate the new cache while the
|
||||
old cache is still allocated.
|
||||
@@ -1166,17 +1232,33 @@ Property list
|
||||
is loaded, or when switching ordered chapter segments. This is because
|
||||
the same underlying code is used for seeking and resyncing.)
|
||||
|
||||
``pts-association-mode`` (RW)
|
||||
See ``--pts-association-mode``.
|
||||
|
||||
``hr-seek`` (RW)
|
||||
See ``--hr-seek``.
|
||||
|
||||
``mixer-active``
|
||||
Return ``yes`` if the audio mixer is active, ``no`` otherwise. This has
|
||||
implications for ``--softvol=no`` mode: if the mixer is active, changing
|
||||
``volume`` doesn't actually change anything on the system mixer. If the
|
||||
``--volume`` or ``--mute`` option are used, these might not be applied
|
||||
property until the mixer becomes active either. (The options, if set, will
|
||||
just overwrite the mixer state at audio initialization.)
|
||||
|
||||
While the behavior with ``mixer-active==yes`` is relatively well-defined,
|
||||
the ``no`` case will provide possibly wrong or insignificant values.
|
||||
|
||||
Note that an active mixer does not necessarily imply active audio output,
|
||||
although this is implied in the current implementation.
|
||||
|
||||
``volume`` (RW)
|
||||
Current volume (see ``--volume`` for details).
|
||||
Current volume (see ``--volume`` for details). Also see ``mixer-active``
|
||||
property.
|
||||
|
||||
``volume-max``
|
||||
Current maximum value the volume property can be set to. (This may depend
|
||||
on the ``--softvol-max`` option.)
|
||||
|
||||
``mute`` (RW)
|
||||
Current mute status (``yes``/``no``).
|
||||
Current mute status (``yes``/``no``). Also see ``mixer-active`` property.
|
||||
|
||||
``audio-delay`` (RW)
|
||||
See ``--audio-delay``.
|
||||
@@ -1255,8 +1337,8 @@ Property list
|
||||
``colormatrix-input-range`` (R)
|
||||
See ``colormatrix``.
|
||||
|
||||
``colormatrix-output-range`` (R)
|
||||
See ``colormatrix``.
|
||||
``video-output-levels`` (RW)
|
||||
See ``--video-output-levels``,
|
||||
|
||||
``colormatrix-primaries`` (R)
|
||||
See ``colormatrix``.
|
||||
@@ -1416,6 +1498,19 @@ Property list
|
||||
|
||||
Has the same sub-properties as ``video-params``.
|
||||
|
||||
``video-frame-info``
|
||||
Approximate information of the current frame. Note that if any of these
|
||||
are used on OSD, the information might be off by a few frames due to OSD
|
||||
redrawing and frame display being somewhat disconnected, and you might
|
||||
have to pause and force a redraw.
|
||||
|
||||
Sub-properties:
|
||||
|
||||
``video-frame-info/picture-type``
|
||||
``video-frame-info/interlaced``
|
||||
``video-frame-info/tff``
|
||||
``video-frame-info/repeat``
|
||||
|
||||
``fps``
|
||||
Container FPS. This can easily contain bogus values. For videos that use
|
||||
modern container formats or video codecs, this will often be incorrect.
|
||||
@@ -1442,13 +1537,21 @@ Property list
|
||||
Names of the displays that the mpv window covers. On X11, these
|
||||
are the xrandr names (LVDS1, HDMI1, DP1, VGA1, etc.).
|
||||
|
||||
``display-fps``
|
||||
``display-fps`` (RW)
|
||||
The refresh rate of the current display. Currently, this is the lowest FPS
|
||||
of any display covered by the video, as retrieved by the underlying system
|
||||
APIs (e.g. xrandr on X11). It is not the measured FPS. It's not necessarily
|
||||
available on all platforms. Note that any of the listed facts may change
|
||||
any time without a warning.
|
||||
|
||||
``estimated-display-fps``
|
||||
Only available if display-sync mode (as selected by ``--video-sync``) is
|
||||
active. Returns the actual rate at which display refreshes seem to occur,
|
||||
measured by system time.
|
||||
|
||||
``vsync-jitter``
|
||||
Estimated deviation factor of the vsync duration.
|
||||
|
||||
``video-aspect`` (RW)
|
||||
Video aspect, see ``--video-aspect``.
|
||||
|
||||
@@ -1481,6 +1584,15 @@ Property list
|
||||
``program`` (W)
|
||||
Switch TS program (write-only).
|
||||
|
||||
``dvb-channel`` (W)
|
||||
Pair of integers: card,channel of current DVB stream.
|
||||
Can be switched to switch to another channel on the same card.
|
||||
|
||||
``dvb-channel-name`` (RW)
|
||||
Name of current DVB program.
|
||||
On write, a channel-switch to the named channel on the same
|
||||
card is performed. Can also be used for channel switching.
|
||||
|
||||
``sid`` (RW)
|
||||
Current subtitle track (similar to ``--sid``).
|
||||
|
||||
|
||||
+5
-3
@@ -111,7 +111,7 @@ rely on this.
|
||||
Commands
|
||||
--------
|
||||
|
||||
Additionally to the commands described in `List of Input Commands`_, a few
|
||||
In addition to the commands described in `List of Input Commands`_, a few
|
||||
extra commands can also be used as part of the protocol:
|
||||
|
||||
``client_name``
|
||||
@@ -189,7 +189,7 @@ extra commands can also be used as part of the protocol:
|
||||
|
||||
``unobserve_property``
|
||||
Undo ``observe_property`` or ``observe_property_string``. This requires the
|
||||
numeric id passed to the observe command as argument.
|
||||
numeric id passed to the observed command as argument.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -228,7 +228,9 @@ extra commands can also be used as part of the protocol:
|
||||
|
||||
``get_version``
|
||||
Returns the client API version the C API of the remote mpv instance
|
||||
provides. (Also see ``DOCS/client-api-changes.rst``.)
|
||||
provides.
|
||||
|
||||
See also: ``DOCS/client-api-changes.rst``.
|
||||
|
||||
UTF-8
|
||||
-----
|
||||
|
||||
+6
-6
@@ -198,7 +198,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
be called (unless the user remapped the key with another binding).
|
||||
|
||||
The ``name`` argument should be a short symbolic string. It allows the user
|
||||
to remap the key binding via input.conf using the ``script_message``
|
||||
to remap the key binding via input.conf using the ``script-message``
|
||||
command, and the name of the key binding (see below for
|
||||
an example). The name should be unique across other bindings in the same
|
||||
script - if not, the previous binding with the same name will be
|
||||
@@ -220,8 +220,8 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
has an ``is_mouse`` entry, which tells whether the event was caused
|
||||
by a mouse button.
|
||||
|
||||
Internally, key bindings are dispatched via the ``script_message_to`` or
|
||||
``script_binding`` input commands and ``mp.register_script_message``.
|
||||
Internally, key bindings are dispatched via the ``script-message-to`` or
|
||||
``script-binding`` input commands and ``mp.register_script_message``.
|
||||
|
||||
Trying to map multiple commands to a key will essentially prefer a random
|
||||
binding, while the other bindings are not called. It is guaranteed that
|
||||
@@ -244,7 +244,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
|
||||
::
|
||||
|
||||
y script_binding something
|
||||
y script-binding something
|
||||
|
||||
|
||||
This will print the message when the key ``y`` is pressed. (``x`` will
|
||||
@@ -255,7 +255,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
|
||||
::
|
||||
|
||||
y script_binding fooscript.something
|
||||
y script-binding fooscript.something
|
||||
|
||||
``mp.add_forced_key_binding(...)``
|
||||
This works almost the same as ``mp.add_key_binding``, but registers the
|
||||
@@ -389,7 +389,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
``mp.get_script_name()``
|
||||
Return the name of the current script. The name is usually made of the
|
||||
filename of the script, with directory and file extension removed. If
|
||||
there are several script which would have the same name, it's made unique
|
||||
there are several scripts which would have the same name, it's made unique
|
||||
by appending a number.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
+125
-81
@@ -37,6 +37,10 @@ LIRC support - configure remotes as input devices instead).
|
||||
|
||||
See the ``--input-`` options for ways to customize it.
|
||||
|
||||
The following listings are not necessarily complete. See ``etc/input.conf`` for
|
||||
a list of default bindings. User ``input.conf`` files and Lua scripts can
|
||||
define additional key bindings.
|
||||
|
||||
Keyboard Control
|
||||
----------------
|
||||
|
||||
@@ -50,7 +54,7 @@ UP and DOWN
|
||||
|
||||
Ctrl+LEFT and Ctrl+RIGHT
|
||||
Seek to the previous/next subtitle. Subject to some restrictions and
|
||||
might not work always; see ``sub_seek`` command.
|
||||
might not always work; see ``sub_seek`` command.
|
||||
|
||||
[ and ]
|
||||
Decrease/increase current playback speed by 10%.
|
||||
@@ -128,7 +132,7 @@ x and z
|
||||
Adjust subtitle delay by +/- 0.1 seconds.
|
||||
|
||||
l
|
||||
Set/clear A-B loop points. See ``ab_loop`` command for details.
|
||||
Set/clear A-B loop points. See ``ab-loop`` command for details.
|
||||
|
||||
L
|
||||
Toggle infinite looping.
|
||||
@@ -192,23 +196,19 @@ corresponding adjustment, or the software equalizer (``--vf=eq``).)
|
||||
7 and 8
|
||||
Adjust saturation.
|
||||
|
||||
(The following keys are valid only on OS X.)
|
||||
|
||||
command + 0
|
||||
Alt+0 (and command+0 on OSX)
|
||||
Resize video window to half its original size.
|
||||
(On other platforms, you can bind keys to change the ``window-scale``
|
||||
property.)
|
||||
|
||||
command + 1
|
||||
Alt+1 (and command+1 on OSX)
|
||||
Resize video window to its original size.
|
||||
|
||||
command + 2
|
||||
Alt+2 (and command+2 on OSX)
|
||||
Resize video window to double its original size.
|
||||
|
||||
command + f
|
||||
command + f (OSX only)
|
||||
Toggle fullscreen (see also ``--fs``).
|
||||
|
||||
command + [ and command + ]
|
||||
command + [ and command + ] (OSX only)
|
||||
Set video window alpha.
|
||||
|
||||
(The following keys are valid if you have a keyboard with multimedia keys.)
|
||||
@@ -226,7 +226,10 @@ PREVIOUS and NEXT
|
||||
support.)
|
||||
|
||||
h and k
|
||||
Select previous/next channel.
|
||||
Select previous/next tv-channel.
|
||||
|
||||
H and K
|
||||
Select previous/next dvb-channel.
|
||||
|
||||
Mouse Control
|
||||
-------------
|
||||
@@ -262,7 +265,7 @@ parser puts several options into a single string, and passes them to a
|
||||
component at once, instead of using multiple options on the level of the
|
||||
command line.
|
||||
|
||||
The suboption parser can quote strings with ``"``, ``'``, and ``[...]``.
|
||||
The suboption parser can quote strings with ``"`` and ``[...]``.
|
||||
Additionally, there is a special form of quoting with ``%n%`` described below.
|
||||
|
||||
For example, the ``opengl`` VO can take multiple options:
|
||||
@@ -382,6 +385,45 @@ file stops playing. If option ``--c`` is changed during playback of
|
||||
``file2.mkv``, it is reset when advancing to ``file3.mkv``. This only affects
|
||||
file-local options. The option ``--a`` is never reset here.
|
||||
|
||||
|
||||
Playing DVDs
|
||||
------------
|
||||
|
||||
DVDs can be played with the ``dvd://[title]`` syntax. The optional
|
||||
title specifier is a number which selects between separate video
|
||||
streams on the DVD. If no title is given (``dvd://``) then the longest
|
||||
title is selected automatically by the library. This is usually what
|
||||
you want. mpv does not support DVD menus.
|
||||
|
||||
DVDs which have been copied on to a hard drive or other mounted
|
||||
filesystem (by e.g. the ``dvdbackup`` tool) are accommodated by
|
||||
specifying the path to the local copy: ``--dvd-device=PATH``.
|
||||
Alternatively, running ``mpv PATH`` should auto-detect a DVD directory
|
||||
tree and play the longest title.
|
||||
|
||||
.. note::
|
||||
|
||||
mpv uses a different default DVD library than MPlayer. MPlayer
|
||||
uses libdvdread by default, and mpv uses libdvdnav by default.
|
||||
Both libraries are developed in parallel, but libdvdnav is
|
||||
intended to support more sophisticated DVD features such as menus
|
||||
and multi-angle playback. mpv uses libdvdnav for files specified
|
||||
as either ``dvd://...`` or ``dvdnav://...``. To use libdvdread,
|
||||
which will produce behavior more like MPlayer, specify
|
||||
``dvdread://...`` instead. Some users have experienced problems
|
||||
when using libdvdnav, in which playback gets stuck in a DVD menu
|
||||
stream. These problems are reported to go away when auto-selecting
|
||||
the title (``dvd://`` rather than ``dvd://1``) or when using
|
||||
libdvdread (e.g. ``dvdread://0``).
|
||||
|
||||
DVDs use image-based subtitles. Image subtitles are implemented as
|
||||
a bitmap video stream which can be superimposed over the main
|
||||
movie. mpv's subtitle styling and positioning options and keyboard
|
||||
shortcuts generally do not work with image-based subtitles.
|
||||
Exceptions include options like ``--stretch-dvd-subs`` and
|
||||
``--stretch-image-subs-to-screen``.
|
||||
|
||||
|
||||
CONFIGURATION FILES
|
||||
===================
|
||||
|
||||
@@ -392,10 +434,11 @@ You can put all of the options in configuration files which will be read every
|
||||
time mpv is run. The system-wide configuration file 'mpv.conf' is in your
|
||||
configuration directory (e.g. ``/etc/mpv`` or ``/usr/local/etc/mpv``), the
|
||||
user-specific one is ``~/.config/mpv/mpv.conf``. For details and platform
|
||||
specifics see the `FILES`_ section.
|
||||
specifics (in particular Windows paths) see the `FILES`_ section.
|
||||
|
||||
User-specific options override system-wide options and options given on the
|
||||
command line override either. The syntax of the configuration files is
|
||||
``option=<value>``; everything after a *#* is considered a comment. Options
|
||||
``option=value``. Everything after a *#* is considered a comment. Options
|
||||
that work without values can be enabled by setting them to *yes* and disabled by
|
||||
setting them to *no*. Even suboptions can be specified in this way.
|
||||
|
||||
@@ -413,7 +456,7 @@ Escaping spaces and special characters
|
||||
|
||||
This is done like with command line options. The shell is not involved here,
|
||||
but option values still need to be quoted as a whole if it contains certain
|
||||
characters like spaces. A config entry can be quoted with ``"`` and ``'``,
|
||||
characters like spaces. A config entry can be quoted with ``"``,
|
||||
as well as with the fixed-length syntax (``%n%``) mentioned before. This is like
|
||||
passing the exact contents of the quoted string as command line option. C-style
|
||||
escapes are currently _not_ interpreted on this level, although some options do
|
||||
@@ -460,7 +503,38 @@ description (shown by ``--profile=help``) can be defined with the
|
||||
``profile-desc`` option. To end the profile, start another one or use the
|
||||
profile name ``default`` to continue with normal options.
|
||||
|
||||
.. admonition:: Example mpv profile
|
||||
.. admonition:: Example mpv config file with profiles
|
||||
|
||||
::
|
||||
|
||||
# normal top-level option
|
||||
fullscreen=yes
|
||||
|
||||
# a profile that can be enabled with --profile=big-cache
|
||||
[big-cache]
|
||||
cache=123400
|
||||
demuxer-readahead-secs=20
|
||||
|
||||
[slow]
|
||||
profile-desc="some profile name"
|
||||
vo=opengl:scale=ewa_lanczos:scale-radius=16
|
||||
|
||||
[fast]
|
||||
vo=vdpau
|
||||
|
||||
# using a profile again extends it
|
||||
[slow]
|
||||
framedrop=no
|
||||
# you can also include other profiles
|
||||
profile=big-cache
|
||||
|
||||
|
||||
Auto profiles
|
||||
-------------
|
||||
|
||||
Some profiles are loaded automatically. The following example demonstrates this:
|
||||
|
||||
.. admonition:: Auto profile loading
|
||||
|
||||
::
|
||||
|
||||
@@ -479,14 +553,22 @@ profile name ``default`` to continue with normal options.
|
||||
[ao.alsa]
|
||||
device=spdif
|
||||
|
||||
The profile name follows the schema ``type.name``, where type can be ``vo``
|
||||
to match the value the ``--vo`` option is set to, ``ao`` for ``--ao``,
|
||||
``protocol`` for the input/output protocol in use (see ``--list-protocols``),
|
||||
and ``extension`` for the extension of the path of the currently played file
|
||||
(*not* the file format).
|
||||
|
||||
This feature is very limited, and there are no other auto profiles.
|
||||
|
||||
TAKING SCREENSHOTS
|
||||
==================
|
||||
|
||||
Screenshots of the currently played file can be taken using the 'screenshot'
|
||||
input mode command, which is by default bound to the ``s`` key. Files named
|
||||
``shotNNNN.jpg`` will be saved in the working directory, using the first
|
||||
available number - no files will be overwritten.
|
||||
``mpv-shotNNNN.jpg`` will be saved in the working directory, using the first
|
||||
available number - no files will be overwritten. In pseudo-GUI mode, the
|
||||
screenshot will be saved somewhere else. See `PSEUDO GUI MODE`_.
|
||||
|
||||
A screenshot will usually contain the unscaled video contents at the end of the
|
||||
video filter chain and subtitles. By default, ``S`` takes screenshots without
|
||||
@@ -527,16 +609,16 @@ listed.
|
||||
this will indicate a problem. (``total-avsync-change`` property.)
|
||||
- Encoding state in ``{...}``, only shown in encoding mode.
|
||||
- Display sync state. If display sync is active (``display-sync-active``
|
||||
property), this shows ``DS: +0.02598%``, where the number is the speed change
|
||||
factor applied to audio to achieve sync to display, expressed in percent
|
||||
deviation from 1.0 (``audio-speed-correction`` property). In sync modes which
|
||||
don't resample, this will always be ``+0.00000%``.
|
||||
- Missed frames, e.g. ``Missed: 4``. (``vo-missed-frame-count`` property.) Shows
|
||||
up in display sync mode only. This is incremented each time a frame took
|
||||
longer to display than intended.
|
||||
property), this shows ``DS: 2.500/13``, where the first number is average
|
||||
number of vsyncs per video frame (e.g. 2.5 when playing 24Hz videos on 60Hz
|
||||
screens), which might jitter if the ratio doesn't round off, or there are
|
||||
mistimed frames (``vsync-ratio``), and the second number of estimated number
|
||||
of vsyncs which took too long (``vo-delayed-frame-count`` property). The
|
||||
latter is a heuristic, as it's generally not possible to determine this with
|
||||
certainty.
|
||||
- Dropped frames, e.g. ``Dropped: 4``. Shows up only if the count is not 0. Can
|
||||
grow if the video framerate is higher than that of the display, or if video
|
||||
rendering is too slow. Also can be incremented on "hiccups" and when the video
|
||||
rendering is too slow. May also be incremented on "hiccups" and when the video
|
||||
frame couldn't be displayed on time. (``vo-drop-frame-count`` property.)
|
||||
If the decoder drops frames, the number of decoder-dropped frames is appended
|
||||
to the display as well, e.g.: ``Dropped: 4/34``. This happens only if
|
||||
@@ -567,7 +649,7 @@ PROTOCOLS
|
||||
Play a path from Samba share.
|
||||
|
||||
``bd://[title][/device]`` ``--bluray-device=PATH``
|
||||
Play a Blu-Ray disc. Currently, this does not accept ISO files. Instead,
|
||||
Play a Blu-ray disc. Currently, this does not accept ISO files. Instead,
|
||||
you must mount the ISO file as filesystem, and point ``--bluray-device``
|
||||
to the mounted directory directly.
|
||||
|
||||
@@ -619,9 +701,8 @@ PROTOCOLS
|
||||
absolute path.
|
||||
|
||||
``fd://123``
|
||||
Read data from the given UNIX FD (for example 123). This is similar to
|
||||
piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
||||
Will not work correctly on MS Windows.
|
||||
Read data from the given file descriptor (for example 123). This is similar
|
||||
to piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
||||
|
||||
``edl://[edl specification as in edl-mpv.rst]``
|
||||
Stitch together parts of multiple files and play them.
|
||||
@@ -688,6 +769,15 @@ The profile always overrides other settings in ``mpv.conf``.
|
||||
|
||||
.. include:: changes.rst
|
||||
|
||||
|
||||
EMBEDDING INTO OTHER PROGRAMS (LIBMPV)
|
||||
======================================
|
||||
|
||||
mpv can be embedded into other programs as video/audio playback backend. The
|
||||
recommended way to do so is using libmpv. See ``libmpv/client.h`` in the mpv
|
||||
source code repository. This provides a C API. Bindings for other languages
|
||||
might be available (see wiki).
|
||||
|
||||
ENVIRONMENT VARIABLES
|
||||
=====================
|
||||
|
||||
@@ -759,7 +849,7 @@ libdvdcss:
|
||||
|
||||
key
|
||||
is the default method. libdvdcss will use a set of calculated
|
||||
player keys to try and get the disc key. This can fail if the drive
|
||||
player keys to try to get the disc key. This can fail if the drive
|
||||
does not recognize any of the player keys.
|
||||
|
||||
disc
|
||||
@@ -875,7 +965,7 @@ locations are different. They are generally located under ``%APPDATA%/mpv/``.
|
||||
For example, the path to mpv.conf is ``%APPDATA%/mpv/mpv.conf``, which maps to
|
||||
a system and user-specific path, for example
|
||||
|
||||
``C:\users\USERNAME\Application Data\mpv\mpv.conf``
|
||||
``C:\users\USERNAME\AppData\Roaming\mpv\mpv.conf``
|
||||
|
||||
You can find the exact path by running ``echo %APPDATA%\mpv\mpv.conf`` in cmd.exe.
|
||||
|
||||
@@ -898,56 +988,10 @@ lower priority. Some config files are loaded only once, which means that
|
||||
e.g. of 2 ``input.conf`` files located in two config directories, only the
|
||||
one from the directory with higher priority will be loaded.
|
||||
|
||||
A third config directory with lowest priority is the directory named ``mpv``
|
||||
in the same directory as ``mpv.exe``. This used to be the directory with
|
||||
A third config directory with the lowest priority is the directory named ``mpv``
|
||||
in the same directory as ``mpv.exe``. This used to be the directory with the
|
||||
highest priority, but is now discouraged to use and might be removed in the
|
||||
future.
|
||||
|
||||
Note that mpv likes to mix ``/`` and ``\`` path separators for simplicity.
|
||||
kernel32.dll accepts this, but cmd.exe does not.
|
||||
|
||||
EXAMPLES OF MPV USAGE
|
||||
=====================
|
||||
|
||||
Blu-ray playback:
|
||||
- ``mpv bd:////path/to/disc``
|
||||
- ``mpv bd:// --bluray-device=/path/to/disc``
|
||||
|
||||
Play in Japanese with English subtitles:
|
||||
``mpv dvd://1 --alang=ja --slang=en``
|
||||
|
||||
Play only chapters 5, 6, 7:
|
||||
``mpv dvd://1 --chapter=5-7``
|
||||
|
||||
Play only titles 5, 6, 7:
|
||||
``mpv dvd://5-7``
|
||||
|
||||
Play a multi-angle DVD:
|
||||
``mpv dvd://1 --dvd-angle=2``
|
||||
|
||||
Play from a different DVD device:
|
||||
``mpv dvd://1 --dvd-device=/dev/dvd2``
|
||||
|
||||
Play DVD video from a directory with VOB files:
|
||||
``mpv dvd://1 --dvd-device=/path/to/directory/``
|
||||
|
||||
Stream from HTTP:
|
||||
``mpv http://example.com/example.avi``
|
||||
|
||||
Stream using RTSP:
|
||||
``mpv rtsp://server.example.com/streamName``
|
||||
|
||||
Play a libavfilter graph:
|
||||
``mpv avdevice://lavfi:mandelbrot``
|
||||
|
||||
AUTHORS
|
||||
=======
|
||||
|
||||
mpv is a MPlayer fork based on mplayer2, which in turn is a fork of MPlayer.
|
||||
|
||||
MPlayer was initially written by Arpad Gereoffy. See the ``AUTHORS`` file for
|
||||
a list of some of the many other contributors.
|
||||
|
||||
MPlayer is (C) 2000-2013 The MPlayer Team
|
||||
|
||||
This man page was written mainly by Gabucino, Jonas Jermann and Diego Biurrun.
|
||||
+253
-162
@@ -69,7 +69,8 @@ Playback Control
|
||||
|
||||
The general format for absolute times is ``[[hh:]mm:]ss[.ms]``. If the time
|
||||
is given with a prefix of ``+`` or ``-``, the seek is relative from the start
|
||||
or end of the file.
|
||||
or end of the file. (Since mpv 0.14, the start of the file is always
|
||||
considered 0.)
|
||||
|
||||
``pp%`` seeks to percent position pp (0-100).
|
||||
|
||||
@@ -101,6 +102,14 @@ Playback Control
|
||||
Stop after a given time relative to the start time.
|
||||
See ``--start`` for valid option values and examples.
|
||||
|
||||
``--rebase-start-time=<yes|no>``
|
||||
Whether to move the file start time to ``00:00:00`` (default: yes). This
|
||||
is less awkward for files which start at a random timestamp, such as
|
||||
transport streams. On the other hand, if there are timestamp resets, the
|
||||
resulting behavior can be rather weird. For this reason, and in case you
|
||||
are actually interested in the real timestamps, this behavior can be
|
||||
disabled with ``no``.
|
||||
|
||||
``--speed=<0.01-100>``
|
||||
Slow down or speed up playback by the factor given as parameter.
|
||||
|
||||
@@ -127,7 +136,9 @@ Playback Control
|
||||
|
||||
``--chapter=<start[-end]>``
|
||||
Specify which chapter to start playing at. Optionally specify which
|
||||
chapter to end playing at. Also see ``--start``.
|
||||
chapter to end playing at.
|
||||
|
||||
See also: ``--start``.
|
||||
|
||||
``--playlist-pos=<no|index>``
|
||||
Set which file on the internal playlist to start playback with. The index
|
||||
@@ -312,7 +323,7 @@ Program Behavior
|
||||
Files explicitly requested by command line options, like
|
||||
``--include`` or ``--use-filedir-conf``, will still be loaded.
|
||||
|
||||
Also see ``--config-dir``.
|
||||
See also: ``--config-dir``.
|
||||
|
||||
``--list-options``
|
||||
Prints all available options.
|
||||
@@ -383,8 +394,7 @@ Program Behavior
|
||||
|
||||
``--merge-files``
|
||||
Pretend that all files passed to mpv are concatenated into a single, big
|
||||
file. This uses timeline/EDL support internally. Note that this won't work
|
||||
for ordered chapter files.
|
||||
file. This uses timeline/EDL support internally.
|
||||
|
||||
``--no-resume-playback``
|
||||
Do not restore playback position from the ``watch_later`` configuration
|
||||
@@ -456,16 +466,13 @@ Program Behavior
|
||||
|
||||
If the script can't do anything with an URL, it will do nothing.
|
||||
|
||||
(Note: this is the replacement for the now removed libquvi support.)
|
||||
|
||||
``--ytdl-format=<best|worst|mp4|webm|...>``
|
||||
Video format/quality that is directly passed to youtube-dl. The possible
|
||||
values are specific to the website and the video, for a given url the
|
||||
available formats can be found with the command
|
||||
``youtube-dl --list-formats URL``. See youtube-dl's documentation for
|
||||
available aliases. To use experimental DASH support for youtube, use
|
||||
``bestvideo+bestaudio``.
|
||||
(Default: ``best``)
|
||||
available aliases.
|
||||
(Default: youtube-dl's default, currently ``bestvideo+bestaudio/best``)
|
||||
|
||||
``--ytdl-raw-options=<key>=<value>[,<key>=<value>[,...]]``
|
||||
Pass arbitrary options to youtube-dl. Parameter and argument should be
|
||||
@@ -531,7 +538,7 @@ Video
|
||||
filters all frames, but doesn't render them on the VO. It tries to query
|
||||
the display FPS (X11 only, not correct on multi-monitor systems), or
|
||||
assumes infinite display FPS if that fails. Drops are indicated in
|
||||
the terminal status line as ``D:`` field. If the decoder is too slow,
|
||||
the terminal status line as ``Dropped:`` field. If the decoder is too slow,
|
||||
in theory all frames would have to be dropped (because all frames are
|
||||
too late) - to avoid this, frame dropping stops if the effective
|
||||
framerate is below 10 FPS.
|
||||
@@ -551,11 +558,14 @@ Video
|
||||
differences to other VOs are possible.
|
||||
|
||||
``--display-fps=<fps>``
|
||||
Set the maximum assumed display FPS used with ``--framedrop``. By default
|
||||
a detected value is used (X11 only, not correct on multi-monitor systems),
|
||||
or infinite display FPS if that fails. Infinite FPS means only frames too
|
||||
late are dropped. If a correct FPS is provided, frames that are predicted
|
||||
to be too late are dropped too.
|
||||
Set the display FPS used with the ``--video-sync=display-*`` modes. By
|
||||
default, a detected value is used. Keep in mind that setting an incorrect
|
||||
value (even if slightly incorrect) can ruin video playback. On multi-monitor
|
||||
systems, there is a chance that the detected value is from the wrong
|
||||
monitor.
|
||||
|
||||
Set this option only if you have reason to believe the automatically
|
||||
determined value is wrong.
|
||||
|
||||
``--hwdec=<api>``
|
||||
Specify the hardware video decoding API that should be used if possible.
|
||||
@@ -567,12 +577,11 @@ Video
|
||||
:no: always use software decoding (default)
|
||||
:auto: see below
|
||||
:vdpau: requires ``--vo=vdpau`` or ``--vo=opengl`` (Linux only)
|
||||
:vaapi: requires ``--vo=opengl`` or ``--vo=vaapi`` (Linux with Intel GPUs only)
|
||||
:vaapi: requires ``--vo=opengl`` or ``--vo=vaapi`` (Linux only)
|
||||
:vaapi-copy: copies video back into system RAM (Linux with Intel GPUs only)
|
||||
:vda: requires ``--vo=opengl`` (OS X only)
|
||||
:videotoolbox: requires ``--vo=opengl`` (newer OS X only)
|
||||
:videotoolbox: requires ``--vo=opengl`` (OS X 10.8 and up only)
|
||||
:dxva2-copy: copies video back to system RAM (Windows only)
|
||||
:rpi: requires ``--vo=rpi`` (Raspberry Pi only - default if available)
|
||||
:rpi: requires ``--vo=rpi`` (Raspberry Pi only - default if available)
|
||||
|
||||
``auto`` tries to automatically enable hardware decoding using the first
|
||||
available method. This still depends what VO you are using. For example,
|
||||
@@ -581,6 +590,12 @@ Video
|
||||
work, it will always fall back to software decoding, instead of trying the
|
||||
next method (might matter on some Linux systems).
|
||||
|
||||
The ``vaapi`` mode, if used with ``--vo=opengl``, requires Mesa 11 and most
|
||||
likely works with Intel GPUs only. It also requires the opengl EGL backend
|
||||
(automatically used if available). You can also try the old GLX backend by
|
||||
forcing it with ``--vo=opengl:backend=x11``, but the vaapi/GLX interop is
|
||||
said to be slower than ``vaapi-copy``.
|
||||
|
||||
The ``vaapi-copy`` mode allows you to use vaapi with any VO. Because
|
||||
this copies the decoded video back to system RAM, it's likely less efficient
|
||||
than the ``vaapi`` mode.
|
||||
@@ -603,10 +618,18 @@ Video
|
||||
|
||||
For ``opengl-cb``, if set, load the interop context as soon as the OpenGL
|
||||
context is created. Since ``opengl-cb`` has no on-demand loading, this
|
||||
allows enabling hardware decoding at runtime at all, without having to
|
||||
allows enabling hardware decoding at runtime at all, without having
|
||||
to temporarily set the ``hwdec`` option just during OpenGL context
|
||||
initialization with ``mpv_opengl_cb_init_gl()``.
|
||||
|
||||
``--videotoolbox-format=<name>``
|
||||
Set the internal pixel format used by ``--hwdec=videotoolbox`` on OSX. The
|
||||
choice of the format can influence performance considerably. On the other
|
||||
hand, there doesn't appear to be a good way to detect the best format for
|
||||
the given hardware. ``nv12``, the default, works better on modern hardware,
|
||||
while ``uyvy422`` appears to be better for old hardware. ``rgb0`` also
|
||||
works.
|
||||
|
||||
``--panscan=<0.0-1.0>``
|
||||
Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9
|
||||
video to make it fit a 4:3 display without black bands). The range
|
||||
@@ -657,7 +680,7 @@ Video
|
||||
example ``--video-zoom`` does nothing if this option is enabled.)
|
||||
|
||||
The video and monitor aspects aspect will be ignored. Aspect correction
|
||||
would require to scale the video in the X or Y direction, but this option
|
||||
would require scaling the video in the X or Y direction, but this option
|
||||
disables scaling, disabling all aspect correction.
|
||||
|
||||
Note that the scaler algorithm may still be used, even if the video isn't
|
||||
@@ -677,7 +700,7 @@ Video
|
||||
|
||||
This option is disabled if the ``--no-keepaspect`` option is used.
|
||||
|
||||
``--video-rotate=<0-360|no>``
|
||||
``--video-rotate=<0-359|no>``
|
||||
Rotate the video clockwise, in degrees. Currently supports 90° steps only.
|
||||
If ``no`` is given, the video is never rotated, even if the file has
|
||||
rotation metadata. (The rotation value is added to the rotation metadata,
|
||||
@@ -745,7 +768,7 @@ Video
|
||||
if supported.
|
||||
|
||||
This behaves exactly like the ``deinterlace`` input property (usually
|
||||
mapped to ``Shift+D``).
|
||||
mapped to ``d``).
|
||||
|
||||
``auto`` is a technicality. Strictly speaking, the default for this option
|
||||
is deinterlacing disabled, but the ``auto`` case is needed if ``yadif`` was
|
||||
@@ -761,6 +784,10 @@ Video
|
||||
:top: top field first
|
||||
:bottom: bottom field first
|
||||
|
||||
.. note::
|
||||
|
||||
Setting either ``top`` or ``bottom`` will flag all frames as interlaced.
|
||||
|
||||
``--frames=<number>``
|
||||
Play/convert only first ``<number>`` video frames, then quit.
|
||||
|
||||
@@ -771,6 +798,26 @@ Video
|
||||
For audio-only playback, any value greater than 0 will quit playback
|
||||
immediately after initialization. The value 0 works as with video.
|
||||
|
||||
``--video-output-levels=<outputlevels>``
|
||||
RGB color levels used with YUV to RGB conversion. Normally, output devices
|
||||
such as PC monitors use full range color levels. However, some TVs and
|
||||
video monitors expect studio RGB levels. Providing full range output to a
|
||||
device expecting studio level input results in crushed blacks and whites,
|
||||
the reverse in dim gray blacks and dim whites.
|
||||
|
||||
Not all VOs support this option. Some will silently ignore it.
|
||||
|
||||
Available color ranges are:
|
||||
|
||||
:auto: automatic selection (equals to full range) (default)
|
||||
:limited: limited range (16-235 per component), studio levels
|
||||
:full: full range (0-255 per component), PC levels
|
||||
|
||||
.. note::
|
||||
|
||||
It is advisable to use your graphics driver's color range option
|
||||
instead, if available.
|
||||
|
||||
``--hwdec-codecs=<codec1,codec2,...|all>``
|
||||
Allow hardware decoding for a given list of codecs only. The special value
|
||||
``all`` always allows all codecs.
|
||||
@@ -778,9 +825,9 @@ Video
|
||||
You can get the list of allowed codecs with ``mpv --vd=help``. Remove the
|
||||
prefix, e.g. instead of ``lavc:h264`` use ``h264``.
|
||||
|
||||
By default this is set to ``h264,vc1,wmv3,hevc``. Note that the hardware
|
||||
acceleration special codecs like ``h264_vdpau`` are not relevant anymore,
|
||||
and in fact have been removed from Libav in this form.
|
||||
By default, this is set to ``h264,vc1,wmv3,hevc,mpeg2video``. Note that the
|
||||
hardware acceleration special codecs like ``h264_vdpau`` are not relevant
|
||||
anymore, and in fact have been removed from Libav in this form.
|
||||
|
||||
This is usually only needed with broken GPUs, where a codec is reported
|
||||
as supported, but decoding causes more problems than it solves.
|
||||
@@ -797,6 +844,11 @@ Video
|
||||
The result is most likely broken decoding, but may also help if the
|
||||
detected or reported profiles are somehow incorrect.
|
||||
|
||||
``--vd-lavc-software-fallback=<yes|no|N>``
|
||||
Fallback to software decoding if the hardware-accelerated decoder fails
|
||||
(default: 3). If this is a number, then fallback will be triggered if
|
||||
N frames fail to decode in a row. 1 is equivalent to ``yes``.
|
||||
|
||||
``--vd-lavc-bitexact``
|
||||
Only use bit-exact algorithms in all decoding steps (for codec testing).
|
||||
|
||||
@@ -817,7 +869,7 @@ Video
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``--vd--lavc-o=debug=pict``
|
||||
``--vd-lavc-o=debug=pict``
|
||||
|
||||
``--vd-lavc-show-all=<yes|no>``
|
||||
Show even broken/corrupt frames (default: no). If this option is set to
|
||||
@@ -888,6 +940,14 @@ Audio
|
||||
|
||||
Currently not implemented for most AOs.
|
||||
|
||||
``--audio-fallback-to-null=<yes|no>``
|
||||
If no audio device can be opened, behave as if ``--ao=null`` was given. This
|
||||
is useful in combination with ``--audio-device``: instead of causing an
|
||||
error if the selected device does not exist, the client API user (or a
|
||||
Lua script) could let playback continue normally, and check the
|
||||
``current-ao`` and ``audio-device-list`` properties to make high-level
|
||||
decisions about how to continue.
|
||||
|
||||
``--ao=<driver1[:suboption1[=value]:...],driver2,...[,]>``
|
||||
Specify a priority list of audio output drivers to be used. For
|
||||
interactive use one would normally specify a single one to use, but in
|
||||
@@ -918,7 +978,7 @@ Audio
|
||||
|
||||
There is not much reason to use this. HDMI supports uncompressed
|
||||
multichannel PCM, and mpv supports lossless DTS-HD decoding via
|
||||
FFmpeg's libdcadec wrapper.
|
||||
FFmpeg's new DCA decoder (based on libdcadec).
|
||||
|
||||
``--ad=<[+|-]family1:(*|decoder1),[+|-]family2:(*|decoder2),...[-]>``
|
||||
Specify a priority list of audio decoders to be used, according to their
|
||||
@@ -972,7 +1032,9 @@ Audio
|
||||
|
||||
``--mute=<auto|yes|no>``
|
||||
Set startup audio mute status. ``auto`` (default) will not change the mute
|
||||
status. Also see ``--volume``.
|
||||
status.
|
||||
|
||||
See also: ``--volume``.
|
||||
|
||||
``--softvol=<mode>``
|
||||
Control whether to use the volume controls of the audio output driver or
|
||||
@@ -1030,8 +1092,8 @@ Audio
|
||||
This and enabling passthrough via ``--ad`` are deprecated in favor of
|
||||
using ``--audio-spdif=dts-hd``.
|
||||
|
||||
``--audio-channels=<number|layout>``
|
||||
Request a channel layout for audio output (default: auto). This will ask
|
||||
``--audio-channels=<auto|number|layout>``
|
||||
Request a channel layout for audio output (default: stereo). This will ask
|
||||
the AO to open a device with the given channel layout. It's up to the AO
|
||||
to accept this layout, or to pick a fallback or to error out if the
|
||||
requested layout is not supported.
|
||||
@@ -1044,9 +1106,10 @@ Audio
|
||||
lists speaker names, which can be used to express arbitrary channel
|
||||
layouts (e.g. ``fl-fr-lfe`` is 2.1).
|
||||
|
||||
The default is ``--audio-channels=auto``, which tries to play audio using
|
||||
the input file's channel layout. (Or more precisely, the output of the
|
||||
audio filter chain.) (``empty`` is an accepted obsolete alias for ``auto``.)
|
||||
``--audio-channels=auto`` tries to play audio using the input file's
|
||||
channel layout. There is no guarantee that the audio API handles this
|
||||
correctly. See the HDMI warning below.
|
||||
(``empty`` is an accepted obsolete alias for ``auto``.)
|
||||
|
||||
This will also request the channel layout from the decoder. If the decoder
|
||||
does not support the layout, it will fall back to its native channel layout.
|
||||
@@ -1065,6 +1128,16 @@ Audio
|
||||
channel layout, random things can happen, such as dropping the
|
||||
additional channels, or adding noise.
|
||||
|
||||
``--audio-normalize-downmix=<yes|no>``
|
||||
Enable/disable normalization if surround audio is downmixed to stereo
|
||||
(default: no). If this is disabled, downmix can cause clipping. If it's
|
||||
enabled, the output might be too silent. It depends on the source audio.
|
||||
|
||||
Technically, this changes the ``normalize`` suboption of the
|
||||
``lavrresample`` audio filter, which performs the downmixing.
|
||||
|
||||
If downmix happens outside of mpv for some reason, this has no effect.
|
||||
|
||||
``--audio-display=<no|attachment>``
|
||||
Setting this option to ``attachment`` (default) will display image
|
||||
attachments (e.g. album cover art) when playing audio files. It will
|
||||
@@ -1097,8 +1170,8 @@ Audio
|
||||
point of file change. Default: ``weak``.
|
||||
|
||||
:no: Disable gapless audio.
|
||||
:yes: The audio device is opened using parameters chosen according to the
|
||||
first file played and is then kept open for gapless playback. This
|
||||
:yes: The audio device is opened using parameters chosen for the first
|
||||
file played and is then kept open for gapless playback. This
|
||||
means that if the first file for example has a low sample rate, then
|
||||
the following files may get resampled to the same low sample rate,
|
||||
resulting in reduced sound quality. If you play files with different
|
||||
@@ -1145,7 +1218,11 @@ Audio
|
||||
:no: Don't automatically load external audio files.
|
||||
:exact: Load the media filename with audio file extension (default).
|
||||
:fuzzy: Load all audio files containing media filename.
|
||||
:all: Load all audio files in the current directory.
|
||||
:all: Load all aufio files in the current and ``--audio-file-paths``
|
||||
directories.
|
||||
|
||||
``--audio-file-paths=<path1:path2:...>``
|
||||
Equivalent to ``--sub-paths`` option, but for auto-loaded audio files.
|
||||
|
||||
``--audio-client-name=<name>``
|
||||
The application name the player reports to the audio API. Can be useful
|
||||
@@ -1182,6 +1259,14 @@ Audio
|
||||
Subtitles
|
||||
---------
|
||||
|
||||
.. note::
|
||||
|
||||
Changing styling and position does not work with all subtitles. Image-based
|
||||
subtitles (DVD, Bluray/PGS, DVB) can not changed for fundamental reasons.
|
||||
Subtitles in ASS format are normally not changed intentionally, but
|
||||
overriding them can be controlled with ``--ass-style-override``.
|
||||
|
||||
|
||||
``--no-sub``
|
||||
Do not select any subtitle when the file is loaded.
|
||||
|
||||
@@ -1279,8 +1364,8 @@ Subtitles
|
||||
|
||||
``--sub-speed=<0.1-10.0>``
|
||||
Multiply the subtitle event timestamps with the given value. Can be used
|
||||
to fix the playback speed for frame-based subtitle formats. Works for
|
||||
external text subtitles only.
|
||||
to fix the playback speed for frame-based subtitle formats. Affects text
|
||||
subtitles only.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
@@ -1310,7 +1395,7 @@ Subtitles
|
||||
.. admonition:: Warning
|
||||
|
||||
Enabling hinting can lead to mispositioned text (in situations it's
|
||||
supposed to match up with video background), or reduce the smoothness
|
||||
supposed to match up video background), or reduce the smoothness
|
||||
of animations with some badly authored ASS scripts. It is recommended
|
||||
to not use this option, unless really needed.
|
||||
|
||||
@@ -1528,27 +1613,27 @@ Subtitles
|
||||
This mode doesn't take language or fallback codepage.
|
||||
|
||||
``--sub-fix-timing``, ``--no-sub-fix-timing``
|
||||
By default, external text subtitles are preprocessed to remove minor gaps
|
||||
or overlaps between subtitles (if the difference is smaller than 200 ms,
|
||||
the gap or overlap is removed). This does not affect image subtitles,
|
||||
subtitles muxed with audio/video, or subtitles in the ASS format.
|
||||
By default, subtitle timing is adjusted to remove minor gaps or overlaps
|
||||
between subtitles (if the difference is smaller than 210 ms, the gap or
|
||||
overlap is removed).
|
||||
|
||||
``--sub-forced-only``
|
||||
Display only forced subtitles for the DVD subtitle stream selected by e.g.
|
||||
``--slang``.
|
||||
|
||||
``--sub-fps=<rate>``
|
||||
Specify the framerate of the subtitle file (default: video fps).
|
||||
Specify the framerate of the subtitle file (default: video fps). Affects
|
||||
text subtitles only.
|
||||
|
||||
.. note::
|
||||
|
||||
``<rate>`` > video fps speeds the subtitles up for frame-based
|
||||
subtitle files and slows them down for time-based ones.
|
||||
|
||||
Also see ``--sub-speed`` option.
|
||||
See also: ``--sub-speed``.
|
||||
|
||||
``--sub-gauss=<0.0-3.0>``
|
||||
Apply Gaussian blur to image subtitles (default: 0). This can help making
|
||||
Apply Gaussian blur to image subtitles (default: 0). This can help to make
|
||||
pixelated DVD/Vobsubs look nicer. A value other than 0 also switches to
|
||||
software subtitle scaling. Might be slow.
|
||||
|
||||
@@ -1557,7 +1642,7 @@ Subtitles
|
||||
Never applied to text subtitles.
|
||||
|
||||
``--sub-gray``
|
||||
Convert image subtitles to grayscale. Can help making yellow DVD/Vobsubs
|
||||
Convert image subtitles to grayscale. Can help to make yellow DVD/Vobsubs
|
||||
look nicer.
|
||||
|
||||
.. note::
|
||||
@@ -1698,6 +1783,10 @@ Window
|
||||
``--ontop``
|
||||
Makes the player window stay on top of other windows.
|
||||
|
||||
On Windows, if combined with fullscreen mode, this causes mpv to be
|
||||
treated as exclusive fullscreen window that bypasses the Desktop Window
|
||||
Manager.
|
||||
|
||||
``--border``, ``--no-border``
|
||||
Play video with window border and decorations. Since this is on by
|
||||
default, use ``--no-border`` to disable the standard window decorations.
|
||||
@@ -1925,8 +2014,8 @@ Window
|
||||
always re-enabled when the player is paused.
|
||||
|
||||
This is not supported on all video outputs or platforms. Sometimes it is
|
||||
implemented, but does not work (happens often on GNOME). You might be able
|
||||
to to work this around using ``--heartbeat-cmd`` instead.
|
||||
implemented, but does not work (known to happen with GNOME). You might be
|
||||
able to work around this using ``--heartbeat-cmd`` instead.
|
||||
|
||||
``--wid=<ID>``
|
||||
This tells mpv to attach to an existing window. If a VO is selected that
|
||||
@@ -1945,7 +2034,7 @@ Window
|
||||
parent, like with X11.
|
||||
|
||||
On OSX/Cocoa, the ID is interpreted as ``NSView*``. Pass it as value cast
|
||||
to ``intptr_t``. mpv will creates its own sub-view. Because OSX does not
|
||||
to ``intptr_t``. mpv will create its own sub-view. Because OSX does not
|
||||
support window embedding of foreign processes, this works only with libmpv,
|
||||
and will crash when used from the command line.
|
||||
|
||||
@@ -1976,6 +2065,10 @@ Window
|
||||
|
||||
This option might be removed in the future.
|
||||
|
||||
``--x11-bypass-compositor=<yes|no>``
|
||||
If set to ``yes`` (default), then ask the compositor to unredirect the
|
||||
mpv window. This uses the ``_NET_WM_BYPASS_COMPOSITOR`` hint.
|
||||
|
||||
|
||||
Disc Devices
|
||||
------------
|
||||
@@ -2150,7 +2243,7 @@ Demuxer
|
||||
Encryption key the demuxer should use. This is the raw binary data of
|
||||
the key converted to a hexadecimal string.
|
||||
|
||||
``--demuxer-mkv-subtitle-preroll``, ``--mkv-subtitle-preroll``
|
||||
``--demuxer-mkv-subtitle-preroll=<yes|index|no>``, ``--mkv-subtitle-preroll``
|
||||
Try harder to show embedded soft subtitles when seeking somewhere. Normally,
|
||||
it can happen that the subtitle at the seek target is not shown due to how
|
||||
some container file formats are designed. The subtitles appear only if
|
||||
@@ -2182,7 +2275,11 @@ Demuxer
|
||||
overlap with a seek target. In these cases, mpv will reduce the amount
|
||||
of data read to a minimum. (Although it will still read *all* data between
|
||||
the cluster that contains the first wanted subtitle packet, and the seek
|
||||
target.)
|
||||
target.) If the ``index`` choice (which is the default) is specified, then
|
||||
prerolling will be done only if this information is actually available. If
|
||||
this method is used, the maximum amount of data to skip can be additionally
|
||||
controlled by ``--demuxer-mkv-subtitle-preroll-secs-index`` (it still uses
|
||||
the value of the option without ``-index`` if that is higher).
|
||||
|
||||
See also ``--hr-seek-demuxer-offset`` option. This option can achieve a
|
||||
similar effect, but only if hr-seek is active. It works with any demuxer,
|
||||
@@ -2194,6 +2291,9 @@ Demuxer
|
||||
``--demuxer-mkv-subtitle-preroll-secs=<value>``
|
||||
See ``--demuxer-mkv-subtitle-preroll``.
|
||||
|
||||
``--demuxer-mkv-subtitle-preroll-secs-index=<value>``
|
||||
See ``--demuxer-mkv-subtitle-preroll``.
|
||||
|
||||
``--demuxer-mkv-probe-video-duration=<yes|no|full>``
|
||||
When opening the file, seek to the end of it, and check what timestamp the
|
||||
last video packet has, and report that as file duration. This is strictly
|
||||
@@ -2206,18 +2306,6 @@ Demuxer
|
||||
file and can make a reliable estimate even without an index present (such
|
||||
as partial files).
|
||||
|
||||
``--demuxer-mkv-fix-timestamps=<yes|no>``
|
||||
Fix rounded Matroska timestamps (disabled by default). Matroska usually
|
||||
stores timestamps rounded to milliseconds. This means timestamps jitter
|
||||
by some amount around the intended timestamp. mpv can correct the timestamps
|
||||
based on the framerate value stored in the file: the timestamp is rounded
|
||||
to the next frame (according to the framerate), unless the new timestamp
|
||||
would deviate more than 1ms from the old one. This should undo the rounding
|
||||
done by the muxer.
|
||||
|
||||
(The allowed deviation can be less than 1ms if the file uses a non-standard
|
||||
timecode scale.)
|
||||
|
||||
``--demuxer-rawaudio-channels=<value>``
|
||||
Number of channels (or channel layout) if ``--demuxer=rawaudio`` is used
|
||||
(default: stereo).
|
||||
@@ -2330,7 +2418,7 @@ Input
|
||||
|
||||
``--input-key-fifo-size=<2-65000>``
|
||||
Specify the size of the FIFO that buffers key events (default: 7). If it
|
||||
is too small some events may be lost. The main disadvantage of setting it
|
||||
is too small, some events may be lost. The main disadvantage of setting it
|
||||
to a very large value is that if you hold down a key triggering some
|
||||
particularly slow command then the player may be unresponsive while it
|
||||
processes all the queued commands.
|
||||
@@ -2397,7 +2485,7 @@ Input
|
||||
|
||||
On X11, a sub-window with input enabled grabs all keyboard input as long
|
||||
as it is 1. a child of a focused window, and 2. the mouse is inside of
|
||||
the sub-window. The can steal away all keyboard input from the
|
||||
the sub-window. It can steal away all keyboard input from the
|
||||
application embedding the mpv window, and on the other hand, the mpv
|
||||
window will receive no input if the mouse is outside of the mpv window,
|
||||
even though mpv has focus. Modern toolkits work around this weird X11
|
||||
@@ -2437,14 +2525,14 @@ OSD
|
||||
``--osd-duration=<time>``
|
||||
Set the duration of the OSD messages in ms (default: 1000).
|
||||
|
||||
``--osd-font=<pattern>``, ``--sub-text-font=<pattern>``
|
||||
``--osd-font=<name>``, ``--sub-text-font=<name>``
|
||||
Specify font to use for OSD and for subtitles that do not themselves
|
||||
specify a particular font. The default is ``sans-serif``.
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
- ``--osd-font='Bitstream Vera Sans'``
|
||||
- ``--osd-font='Bitstream Vera Sans:style=Bold'`` (fontconfig pattern)
|
||||
- ``--osd-font='MS Comic Sans'``
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -2452,6 +2540,9 @@ OSD
|
||||
options) are ignored when ASS-subtitles are rendered, unless the
|
||||
``--no-sub-ass`` option is specified.
|
||||
|
||||
This used to support fontconfig patterns. Starting with libass 0.13.0,
|
||||
this stopped working.
|
||||
|
||||
``--osd-font-size=<size>``, ``--sub-text-font-size=<size>``
|
||||
Specify the OSD/sub font size. The unit is the size in scaled pixels at a
|
||||
window height of 720. The actual pixel size is scaled with the window
|
||||
@@ -2632,17 +2723,6 @@ OSD
|
||||
|
||||
Default: 0.
|
||||
|
||||
``--use-text-osd=<yes|no>``
|
||||
Disable text OSD rendering completely. (This includes the complete OSC as
|
||||
well.) This is mostly useful for avoiding loading fontconfig in situations
|
||||
where fontconfig does not behave well, and OSD is unused - this could for
|
||||
example allow GUI programs using libmpv to workaround fontconfig issues.
|
||||
|
||||
Note that selecting subtitles of any kind still initializes fontconfig.
|
||||
|
||||
Default: ``no``.
|
||||
|
||||
|
||||
Screenshot
|
||||
----------
|
||||
|
||||
@@ -2675,7 +2755,7 @@ Screenshot
|
||||
Specify the filename template used to save screenshots. The template
|
||||
specifies the filename without file extension, and can contain format
|
||||
specifiers, which will be substituted when taking a screenshot.
|
||||
By default the template is ``mpv-shot%n``, which results in filenames like
|
||||
By default, the template is ``mpv-shot%n``, which results in filenames like
|
||||
``mpv-shot0012.png`` for example.
|
||||
|
||||
The template can start with a relative or absolute path, in order to
|
||||
@@ -2831,7 +2911,7 @@ Terminal
|
||||
Particularly useful on slow terminals or broken ones which do not properly
|
||||
handle carriage return (i.e. ``\r``).
|
||||
|
||||
Also see ``--really-quiet`` and ``--msg-level``.
|
||||
See also: ``--really-quiet`` and ``--msg-level``.
|
||||
|
||||
``--really-quiet``
|
||||
Display even less output and status messages than with ``--quiet``.
|
||||
@@ -2964,8 +3044,9 @@ TV
|
||||
maximum size of the capture buffer in megabytes (default: dynamical)
|
||||
|
||||
``--tv-norm=<value>``
|
||||
See the console output for a list of all available norms, also see the
|
||||
``normid`` option below.
|
||||
See the console output for a list of all available norms.
|
||||
|
||||
See also: ``--tv-normid``.
|
||||
|
||||
``--tv-normid=<value> (v4l2 only)``
|
||||
Sets the TV norm to the given numeric ID. The TV norm depends on the
|
||||
@@ -3175,7 +3256,7 @@ Cache
|
||||
multiple cache streams, and using the same file for them obviously
|
||||
clashes.
|
||||
|
||||
Also see ``--cache-file-size``.
|
||||
See also: ``--cache-file-size``.
|
||||
|
||||
``--cache-file-size=<kBytes>``
|
||||
Maximum size of the file created with ``--cache-file``. For read accesses
|
||||
@@ -3241,6 +3322,13 @@ Network
|
||||
Verify peer certificates when using TLS (e.g. with ``https://...``).
|
||||
(Silently fails with older FFmpeg or Libav versions.)
|
||||
|
||||
``--tls-cert-file``
|
||||
A file containing a certificate to use in the handshake with the
|
||||
peer.
|
||||
|
||||
``--tls-key-file``
|
||||
A file containing the private key for the certificate.
|
||||
|
||||
``--referrer=<string>``
|
||||
Specify a referrer path or URL for HTTP requests.
|
||||
|
||||
@@ -3296,72 +3384,18 @@ DVB
|
||||
|
||||
``--dvbin-full-transponder=<yes|no>``
|
||||
Apply no filters on program PIDs, only tune to frequency and pass full
|
||||
transponder to demuxer. This is useful to record multiple programs
|
||||
on a single transponder, or to work around issues in the ``channels.conf``.
|
||||
transponder to demuxer.
|
||||
The player frontend selects the streams from the full TS in this case,
|
||||
so the program which is shown initially may not match the chosen channel.
|
||||
Switching between the programs is possible by cycling the ``program``
|
||||
property.
|
||||
This is useful to record multiple programs on a single transponder,
|
||||
or to work around issues in the ``channels.conf``.
|
||||
It is also recommended to use this for channels which switch PIDs
|
||||
on-the-fly, e.g. for regional news.
|
||||
|
||||
Default: ``no``
|
||||
|
||||
PVR
|
||||
---
|
||||
|
||||
``--pvr-...``
|
||||
These options tune various encoding properties of the PVR capture module.
|
||||
It has to be used with any hardware MPEG encoder based card supported by
|
||||
the V4L2 driver. The Hauppauge WinTV PVR-150/250/350/500 and all IVTV
|
||||
based cards are known as PVR capture cards. Be aware that only Linux
|
||||
2.6.18 kernel and above is able to handle MPEG stream through V4L2 layer.
|
||||
For hardware capture of an MPEG stream and watching it with mpv, use
|
||||
``pvr://`` as media URL.
|
||||
|
||||
|
||||
``--pvr-aspect=<0-3>``
|
||||
Specify input aspect ratio:
|
||||
|
||||
:0: 1:1
|
||||
:1: 4:3 (default)
|
||||
:2: 16:9
|
||||
:3: 2.21:1
|
||||
|
||||
``--pvr-arate=<32000-48000>``
|
||||
Specify encoding audio rate (default: 48000 Hz, available: 32000,
|
||||
44100 and 48000 Hz).
|
||||
|
||||
``--pvr-alayer=<1-3>``
|
||||
Specify MPEG audio layer encoding (default: 2).
|
||||
|
||||
``--pvr-abitrate=<32-448>``
|
||||
Specify audio encoding bitrate in kbps (default: 384).
|
||||
|
||||
``--pvr-amode=<value>``
|
||||
Specify audio encoding mode. Available preset values are 'stereo',
|
||||
'joint_stereo', 'dual' and 'mono' (default: stereo).
|
||||
|
||||
``--pvr-vbitrate=<value>``
|
||||
Specify average video bitrate encoding in Mbps (default: 6).
|
||||
|
||||
``--pvr-vmode=<value>``
|
||||
Specify video encoding mode:
|
||||
|
||||
:vbr: Variable Bit Rate (default)
|
||||
:cbr: Constant Bit Rate
|
||||
|
||||
``--pvr-vpeak=<value>``
|
||||
Specify peak video bitrate encoding in Mbps (only useful for VBR
|
||||
encoding, default: 9.6).
|
||||
|
||||
``--pvr-fmt=<value>``
|
||||
Choose an MPEG format for encoding:
|
||||
|
||||
:ps: MPEG-2 Program Stream (default)
|
||||
:ts: MPEG-2 Transport Stream
|
||||
:mpeg1: MPEG-1 System Stream
|
||||
:vcd: Video CD compatible stream
|
||||
:svcd: Super Video CD compatible stream
|
||||
:dvd: DVD compatible stream
|
||||
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
|
||||
@@ -3389,7 +3423,7 @@ Miscellaneous
|
||||
implement a perfect audio delay measurement. With this value, if large A/V
|
||||
sync offsets occur, they will only take about 1 or 2 seconds to settle
|
||||
out. This delay in reaction time to sudden A/V offsets should be the only
|
||||
side-effect of turning this option on, for all sound drivers.
|
||||
side effect of turning this option on, for all sound drivers.
|
||||
|
||||
``--video-sync=<audio|...>``
|
||||
How the player synchronizes audio and video.
|
||||
@@ -3426,6 +3460,11 @@ Miscellaneous
|
||||
:display-vdrop: Drop or repeat video frames to compensate desyncing
|
||||
video. (Although it should have the same effects as
|
||||
``audio``, the implementation is very different.)
|
||||
:display-adrop: Drop or repeat audio data to compensate desyncing
|
||||
video. See ``--video-sync-adrop-size``. This mode will
|
||||
cause severe audio artifacts if the real monitor
|
||||
refresh rate is too different from the reported or
|
||||
forced rate.
|
||||
:display-desync: Sync video to display, and let audio play on its own.
|
||||
:desync: Sync video according to system clock, and let audio play
|
||||
on its own.
|
||||
@@ -3457,6 +3496,13 @@ Miscellaneous
|
||||
frame dropping due to the audio "overshooting" and skipping multiple video
|
||||
frames before the sync logic can react.
|
||||
|
||||
``--video-sync-adrop-size=<value``
|
||||
For the ``--video-sync=display-adrop`` mode. This mode duplicates/drops
|
||||
audio data to keep audio in sync with video. To avoid audio artifacts on
|
||||
jitter (which would add/remove samples all the time), this is done in
|
||||
relatively large, fixed units, controlled by this option. The unit is
|
||||
seconds.
|
||||
|
||||
``--mf-fps=<value>``
|
||||
Framerate used when decoding from multiple PNG or JPEG files with ``mf://``
|
||||
(default: 1).
|
||||
@@ -3488,6 +3534,10 @@ Miscellaneous
|
||||
other options such as e.g. user agent are not available with all protocols,
|
||||
and printing errors for unknown options would end up being too noisy.)
|
||||
|
||||
``--vo-mmcss-profile=<name>``
|
||||
(Windows only.)
|
||||
Set the MMCSS profile for the video renderer thread (default: ``Playback``).
|
||||
|
||||
``--priority=<prio>``
|
||||
(Windows only.)
|
||||
Set process priority for mpv according to the predefined priorities
|
||||
@@ -3498,21 +3548,62 @@ Miscellaneous
|
||||
|
||||
.. warning:: Using realtime priority can cause system lockup.
|
||||
|
||||
``--pts-association-mode=<decode|sort|auto>``
|
||||
Select the method used to determine which container packet timestamp
|
||||
corresponds to a particular output frame from the video decoder. Normally
|
||||
you should not need to change this option.
|
||||
|
||||
:decoder: Use decoder reordering functionality. Unlike in classic MPlayer
|
||||
and mplayer2, this includes a DTS fallback. (Default.)
|
||||
:sort: Maintain a buffer of unused pts values and use the lowest value
|
||||
for the frame.
|
||||
:auto: Try to pick a working mode from the ones above automatically.
|
||||
|
||||
You can also try to use ``--no-correct-pts`` for files with completely
|
||||
broken timestamps.
|
||||
|
||||
``--force-media-title=<string>``
|
||||
Force the contents of the ``media-title`` property to this value. Useful
|
||||
for scripts which want to set a title, without overriding the user's
|
||||
setting in ``--title``.
|
||||
|
||||
``--external-file=<filename>``
|
||||
Add all tracks from the given file. Unlike ``--sub-file`` and
|
||||
``--audio-file``, this includes all tracks, and does not cause default
|
||||
stream selection over the "proper" file.
|
||||
|
||||
``--lavfi-complex=<string>``
|
||||
Set a "complex" libavfilter filter, which means a single filter graph can
|
||||
take input from multiple source audio and video tracks. The graph can result
|
||||
in a single audio or video output (or both).
|
||||
|
||||
Currently, the filter graph labels are used to select the participating
|
||||
input tracks and audio/video output. The following rules apply:
|
||||
|
||||
- A label of the form ``aidN`` selects audio track N as input (e.g.
|
||||
``aid1``).
|
||||
- A label of the form ``vidN`` selects video track N as input.
|
||||
- A label named ``ao`` will be connected to the audio input.
|
||||
- A label named ``vo`` will be connected to the video output.
|
||||
|
||||
Each label can be used only once. If you want to use e.g. an audio stream
|
||||
for multiple filters, you need to use the ``asplit`` filter. Multiple
|
||||
video or audio outputs are not possible, but you can use filters to merge
|
||||
them into one.
|
||||
|
||||
The complex filter can not be changed yet during playback. It's also not
|
||||
possible to change the tracks connected to the filter at runtime. Other
|
||||
tracks, as long as they're not connected to the filter, and the
|
||||
corresponding output is not connected to the filter, can still be freely
|
||||
changed.
|
||||
|
||||
Note that the normal filter chains (``--af``, ``--vf``) are applied between
|
||||
the complex graphs (e.g. ``ao`` label) and the actual output.
|
||||
|
||||
.. admonition:: Examples
|
||||
|
||||
- ``--lavfi-complex='[aid1] asplit [ao] [t] ; [t] aphasemeter [vo]'``
|
||||
Play audio track 1, and visualize it as video using the ``aphasemeter``
|
||||
filter.
|
||||
- ``--lavfi-complex='[aid1] [aid2] amix [ao]'``
|
||||
Play audio track 1 and 2 at the same time.
|
||||
- ``--lavfi-complex='[vid1] [vid2] vstack [vo]'``
|
||||
Stack video track 1 and 2 and play them at the same time. Note that
|
||||
both tracks need to have the same width, or filter initialization
|
||||
will fail (you can add ``scale`` filters before the ``vstack`` filter
|
||||
to fix the size).
|
||||
- ``--lavfi-complex='[aid1] asplit [ao] [t] ; [t] aphasemeter [t2] ; [vid1] [t2] overlay [vo]'``
|
||||
Play audio track 1, and overlay its visualization over video track 1.
|
||||
- ``--lavfi-complex='[aid1] asplit [t1] [ao] ; [t1] showvolume [t2] ; [vid1] [t2] overlay [vo]'``
|
||||
Play audio track 1, and overlay the measured volume for each speaker
|
||||
over video track 1.
|
||||
|
||||
See the FFmpeg libavfilter documentation for details on the filter.
|
||||
|
||||
|
||||
+13
-12
@@ -130,7 +130,7 @@ these keys. In case of collision, the function needs to be bound to a
|
||||
different key. See the `Script Commands`_ section.
|
||||
|
||||
============= ================================================
|
||||
del Hide the OSC permanently until mpv is restarted.
|
||||
del Cycles visibility between never / auto (mouse-move) / always
|
||||
============= ================================================
|
||||
|
||||
Configuration
|
||||
@@ -206,8 +206,8 @@ Configurable Options
|
||||
|
||||
``hidetimeout``
|
||||
| Default: 500
|
||||
| Duration in ms until the OSC hides if no mouse movement, negative value
|
||||
disables auto-hide
|
||||
| Duration in ms until the OSC hides if no mouse movement, must not be
|
||||
negative
|
||||
|
||||
``fadeduration``
|
||||
| Default: 200
|
||||
@@ -243,28 +243,29 @@ Configurable Options
|
||||
| Default: no
|
||||
| Display timecodes with milliseconds
|
||||
|
||||
``visibility``
|
||||
| Default: auto (auto hide/show on mouse move)
|
||||
| Also supports ``never`` and ``always``
|
||||
|
||||
Script Commands
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
The OSC script listens to certain script commands. These commands can bound
|
||||
in ``input.conf``, or sent by other scripts.
|
||||
|
||||
``enable-osc``
|
||||
Undoes ``disable-osc`` or the effect of the ``del`` key.
|
||||
|
||||
``disable-osc``
|
||||
Hide the OSC permanently. This is also what the ``del`` key does.
|
||||
|
||||
``osc-message``
|
||||
Show a message on screen using the OSC. First argument is the message,
|
||||
second the duration in seconds.
|
||||
|
||||
``osc-visibility``
|
||||
Controls visibility mode ``never`` / ``auto`` (on mouse move) / ``always``
|
||||
and also ``cycle`` to cycle between the modes
|
||||
|
||||
Example
|
||||
|
||||
You could put this into ``input.conf`` to hide the OSC with the ``a`` key and
|
||||
to unhide it with ``b``::
|
||||
to set auto mode (the default) with ``b``::
|
||||
|
||||
a script_message disable-osc
|
||||
b script_message enable-osc
|
||||
a script_message osc-visibility never
|
||||
b script_message osc-visibility auto
|
||||
|
||||
+41
-126
@@ -17,6 +17,10 @@ normal filter parameters.
|
||||
|
||||
To get a full list of available video filters, see ``--vf=help``.
|
||||
|
||||
Also, keep in mind that most actual filters are available via the ``lavfi``
|
||||
wrapper, which gives you access to most of libavfilter's filters. This
|
||||
includes all filters that have been ported from MPlayer to libavfilter.
|
||||
|
||||
Video filters are managed in lists. There are a few commands to manage the
|
||||
filter list.
|
||||
|
||||
@@ -147,15 +151,15 @@ Available filters are:
|
||||
:yes: Enable accurate rounding.
|
||||
|
||||
``dsize[=w:h:aspect-method:r:aspect]``
|
||||
Changes the intended display size/aspect at an arbitrary point in the
|
||||
Changes the intended display aspect at an arbitrary point in the
|
||||
filter chain. Aspect can be given as a fraction (4/3) or floating point
|
||||
number (1.33). Alternatively, you may specify the exact display width and
|
||||
height desired. Note that this filter does *not* do any scaling itself; it
|
||||
number (1.33). Note that this filter does *not* do any scaling itself; it
|
||||
just affects what later scalers (software or hardware) will do when
|
||||
auto-scaling to the correct aspect.
|
||||
|
||||
``<w>,<h>``
|
||||
New display width and height.
|
||||
New aspect ratio given by a display width and height. Unlike older mpv
|
||||
versions or MPlayer, this does not set the display size.
|
||||
|
||||
Can also be these special values:
|
||||
|
||||
@@ -255,26 +259,6 @@ Available filters are:
|
||||
:limited: limited range (16-235 for luma, 16-240 for chroma)
|
||||
:full: full range (0-255 for both luma and chroma)
|
||||
|
||||
``<outputlevels>``
|
||||
RGB color levels used with YUV to RGB conversion. Normally, output devices
|
||||
such as PC monitors use full range color levels. However, some TVs and
|
||||
video monitors expect studio RGB levels. Providing full range output to a
|
||||
device expecting studio level input results in crushed blacks and whites,
|
||||
the reverse in dim gray blacks and dim whites.
|
||||
|
||||
The same limitations as with ``<colormatrix>`` apply.
|
||||
|
||||
Available color ranges are:
|
||||
|
||||
:auto: automatic selection (equals to full range) (default)
|
||||
:limited: limited range (16-235 per component), studio levels
|
||||
:full: full range (0-255 per component), PC levels
|
||||
|
||||
.. note::
|
||||
|
||||
It is advisable to use your graphics driver's color range option
|
||||
instead, if available.
|
||||
|
||||
``<primaries>``
|
||||
RGB primaries the source file was encoded with. Normally this should be set
|
||||
in the file header, but when playing broken or mistagged files this can be
|
||||
@@ -305,27 +289,27 @@ Available filters are:
|
||||
:prophoto: ProPhoto RGB (ROMM)
|
||||
:cie1931: CIE 1931 RGB
|
||||
|
||||
``<gamma>``
|
||||
Gamma function the source file was encoded with. Normally this should be set
|
||||
in the file header, but when playing broken or mistagged files this can be
|
||||
used to override the setting.
|
||||
``<gamma>``
|
||||
Gamma function the source file was encoded with. Normally this should be set
|
||||
in the file header, but when playing broken or mistagged files this can be
|
||||
used to override the setting.
|
||||
|
||||
This option only affects video output drivers that perform color management.
|
||||
This option only affects video output drivers that perform color management.
|
||||
|
||||
If this option is set to ``auto`` (which is the default), the gamma will
|
||||
be set to BT.1886 for YCbCr content, sRGB for RGB content and Linear for
|
||||
XYZ content.
|
||||
If this option is set to ``auto`` (which is the default), the gamma will
|
||||
be set to BT.1886 for YCbCr content, sRGB for RGB content and Linear for
|
||||
XYZ content.
|
||||
|
||||
Available gamma functions are:
|
||||
Available gamma functions are:
|
||||
|
||||
:auto: automatic selection (default)
|
||||
:bt.1886: ITU-R BT.1886 (approximation of BT.601/BT.709/BT.2020 curve)
|
||||
:srgb: IEC 61966-2-4 (sRGB)
|
||||
:linear: Linear light
|
||||
:gamma1.8: Pure power curve (gamma 1.8)
|
||||
:gamma2.2: Pure power curve (gamma 2.2)
|
||||
:gamma2.8: Pure power curve (gamma 2.8)
|
||||
:prophoto: ProPhoto RGB (ROMM) curve
|
||||
:auto: automatic selection (default)
|
||||
:bt.1886: ITU-R BT.1886 (approximation of BT.601/BT.709/BT.2020 curve)
|
||||
:srgb: IEC 61966-2-4 (sRGB)
|
||||
:linear: Linear light
|
||||
:gamma1.8: Pure power curve (gamma 1.8)
|
||||
:gamma2.2: Pure power curve (gamma 2.2)
|
||||
:gamma2.8: Pure power curve (gamma 2.8)
|
||||
:prophoto: ProPhoto RGB (ROMM) curve
|
||||
|
||||
``<stereo-in>``
|
||||
Set the stereo mode the video is assumed to be encoded in. Takes the
|
||||
@@ -409,41 +393,6 @@ Available filters are:
|
||||
``'--vf=lavfi=yadif:o="threads=2,thread_type=slice"'``
|
||||
forces a specific threading configuration.
|
||||
|
||||
``noise[=<strength>[:averaged][:pattern][:temporal][:uniform][:hq]``
|
||||
Adds noise.
|
||||
|
||||
``strength``
|
||||
Set the noise for all components. If you want different strength
|
||||
values for luma and chroma, use libavfilter's noise filter directly
|
||||
(using ``--vf=lavfi=[noise=...]``), or tell the libavfilter developers
|
||||
to stop being stupid.
|
||||
|
||||
``averaged``
|
||||
averaged temporal noise (smoother, but a lot slower)
|
||||
|
||||
``pattern``
|
||||
mix random noise with a (semi)regular pattern
|
||||
|
||||
``temporal``
|
||||
temporal noise (noise pattern changes between frames)
|
||||
|
||||
``uniform``
|
||||
uniform noise (Gaussian otherwise)
|
||||
|
||||
``hqdn3d[=luma_spatial:chroma_spatial:luma_tmp:chroma_tmp]``
|
||||
This filter aims to reduce image noise producing smooth images and making
|
||||
still images really still (This should enhance compressibility.).
|
||||
|
||||
``<luma_spatial>``
|
||||
spatial luma strength (default: 4)
|
||||
``<chroma_spatial>``
|
||||
spatial chroma strength (default: 3)
|
||||
``<luma_tmp>``
|
||||
luma temporal strength (default: 6)
|
||||
``<chroma_tmp>``
|
||||
chroma temporal strength (default:
|
||||
``luma_tmp*chroma_spatial/luma_spatial``)
|
||||
|
||||
``eq[=gamma:contrast:brightness:saturation:rg:gg:bg:weight]``
|
||||
Software equalizer that uses lookup tables (slow), allowing gamma correction
|
||||
in addition to simple brightness and contrast adjustment. The parameters are
|
||||
@@ -470,23 +419,6 @@ Available filters are:
|
||||
and just plain white. A value of 0.0 turns the gamma correction all
|
||||
the way down while 1.0 leaves it at its full strength (default: 1.0).
|
||||
|
||||
``unsharp[=lx:ly:la:cx:cy:ca]``
|
||||
unsharp mask / Gaussian blur
|
||||
|
||||
``l`` is for the luma component, ``c`` for the chroma component. ``x``/``y``
|
||||
is the filter size. ``a`` is the amount.
|
||||
|
||||
``lx``, ``ly``, ``cx``, ``cy``
|
||||
width and height of the matrix, odd sized in both directions (min =
|
||||
3:3, max = 13:11 or 11:13, usually something between 3:3 and 7:7)
|
||||
|
||||
``la``, ``ca``
|
||||
Relative amount of sharpness/blur to add to the image (a sane range
|
||||
should be -1.5-1.5).
|
||||
|
||||
:<0: blur
|
||||
:>0: sharpen
|
||||
|
||||
``pullup[=jl:jr:jt:jb:sb:mp]``
|
||||
Pulldown reversal (inverse telecine) filter, capable of handling mixed
|
||||
hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
|
||||
@@ -506,9 +438,8 @@ Available filters are:
|
||||
generating an occasional mismatched frame, but it may also cause an
|
||||
excessive number of frames to be dropped during high motion sequences.
|
||||
Conversely, setting it to -1 will make ``pullup`` match fields more
|
||||
easily. This may help processing of video where there is slight
|
||||
blurring between the fields, but may also cause there to be interlaced
|
||||
frames in the output.
|
||||
easily. This may help process video with slight blurring between the
|
||||
fields, but may also cause interlaced frames in the output.
|
||||
|
||||
``mp`` (metric plane)
|
||||
This option may be set to ``u`` or ``v`` to use a chroma plane instead of the
|
||||
@@ -523,44 +454,27 @@ Available filters are:
|
||||
|
||||
``<mode>``
|
||||
:frame: Output 1 frame for each frame.
|
||||
:field: Output 1 frame for each field.
|
||||
:field: Output 1 frame for each field (default).
|
||||
:frame-nospatial: Like ``frame`` but skips spatial interlacing check.
|
||||
:field-nospatial: Like ``field`` but skips spatial interlacing check.
|
||||
|
||||
``<interlaced-only>``
|
||||
:no: Deinterlace all frames (default).
|
||||
:yes: Only deinterlace frames marked as interlaced (default if this
|
||||
filter is inserted via ``deinterlace`` property).
|
||||
:no: Deinterlace all frames.
|
||||
:yes: Only deinterlace frames marked as interlaced (default).
|
||||
|
||||
This filter, is automatically inserted when using the ``D`` key (or any
|
||||
This filter is automatically inserted when using the ``d`` key (or any
|
||||
other key that toggles the ``deinterlace`` property or when using the
|
||||
``--deinterlace`` switch), assuming the video output does not have native
|
||||
deinterlacing support.
|
||||
|
||||
If you just want to set the default mode, put this filter and its options
|
||||
into ``--vf-defaults`` instead, and enable deinterlacing with ``D`` or
|
||||
into ``--vf-defaults`` instead, and enable deinterlacing with ``d`` or
|
||||
``--deinterlace``.
|
||||
|
||||
Also note that the ``D`` key is stupid enough to insert an interlacer twice
|
||||
Also, note that the ``d`` key is stupid enough to insert a deinterlacer twice
|
||||
when inserting yadif with ``--vf``, so using the above methods is
|
||||
recommended.
|
||||
|
||||
``delogo[=x:y:w:h:t:show]``
|
||||
Suppresses a TV station logo by a simple interpolation of the surrounding
|
||||
pixels. Just set a rectangle covering the logo and watch it disappear (and
|
||||
sometimes something even uglier appear - your mileage may vary).
|
||||
|
||||
``<x>,<y>``
|
||||
top left corner of the logo
|
||||
``<w>,<h>``
|
||||
width and height of the cleared rectangle
|
||||
``<t>``
|
||||
Thickness of the fuzzy edge of the rectangle (added to ``w`` and
|
||||
``h``). When set to -1, a green rectangle is drawn on the screen to
|
||||
simplify finding the right ``x``,``y``,``w``,``h`` parameters.
|
||||
``show``
|
||||
Draw a rectangle showing the area defined by x/y/w/h.
|
||||
|
||||
``sub=[=bottom-margin:top-margin]``
|
||||
Moves subtitle rendering to an arbitrary point in the filter chain, or force
|
||||
subtitle rendering in the video filter as opposed to using video output OSD
|
||||
@@ -729,10 +643,11 @@ Available filters are:
|
||||
``buffered-frames``
|
||||
Maximum number of decoded video frames that should be buffered before
|
||||
the filter (default: 4). This specifies the maximum number of frames
|
||||
the script can requests backwards. E.g. if ``buffered-frames=5``, and
|
||||
the script just requested frame 15, it can still request frame 10, but
|
||||
frame 9 is not available anymore. If it requests frame 30, mpv will
|
||||
decode 15 more frames, and keep only frames 25-30.
|
||||
the script can request in reverse direction.
|
||||
E.g. if ``buffered-frames=5``, and the script just requested frame 15,
|
||||
it can still request frame 10, but frame 9 is not available anymore.
|
||||
If it requests frame 30, mpv will decode 15 more frames, and keep only
|
||||
frames 25-30.
|
||||
|
||||
The actual number of buffered frames also depends on the value of the
|
||||
``concurrent-frames`` option. Currently, both option values are
|
||||
@@ -805,7 +720,7 @@ Available filters are:
|
||||
``vavpp``
|
||||
VA-AP-API video post processing. Works with ``--vo=vaapi`` and ``--vo=opengl``
|
||||
only. Currently deinterlaces. This filter is automatically inserted if
|
||||
deinterlacing is requested (either using the ``D`` key, by default mapped to
|
||||
deinterlacing is requested (either using the ``d`` key, by default mapped to
|
||||
the command ``cycle deinterlace``, or the ``--deinterlace`` option).
|
||||
|
||||
``deint=<method>``
|
||||
@@ -829,7 +744,7 @@ Available filters are:
|
||||
``vdpaupp``
|
||||
VDPAU video post processing. Works with ``--vo=vdpau`` and ``--vo=opengl``
|
||||
only. This filter is automatically inserted if deinterlacing is requested
|
||||
(either using the ``D`` key, by default mapped to the command
|
||||
(either using the ``d`` key, by default mapped to the command
|
||||
``cycle deinterlace``, or the ``--deinterlace`` option). When enabling
|
||||
deinterlacing, it is always preferred over software deinterlacer filters
|
||||
if the ``vdpau`` VO is used, and also if ``opengl`` is used and hardware
|
||||
@@ -887,6 +802,6 @@ Available filters are:
|
||||
|
||||
``buffer=<num>``
|
||||
Buffer ``<num>`` frames in the filter chain. This filter is probably pretty
|
||||
useless, except for debugging. (Note that this won't help smoothing out
|
||||
useless, except for debugging. (Note that this won't help to smooth out
|
||||
latencies with decoding, because the filter will never output a frame if
|
||||
the buffer isn't full, except on EOF.)
|
||||
+249
-87
@@ -20,13 +20,10 @@ normal driver parameters.
|
||||
|
||||
See ``--vo=help`` for a list of compiled-in video output drivers.
|
||||
|
||||
The recommended output drivers are ``--vo=vdpau`` and ``--vo=opengl-hq``.
|
||||
All other drivers are just for compatibility or special purposes.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
``--vo=opengl,xv,``
|
||||
Try the ``opengl`` driver, then the ``xv`` driver, then others.
|
||||
The recommended output driver is ``--vo=opengl-hq``. All other drivers are
|
||||
for compatibility or special purposes. By default, ``--vo=opengl`` is used,
|
||||
but if that appears not to work, it fallback to other drivers (in the same
|
||||
order as listed by ``--vo=help``).
|
||||
|
||||
Available video output drivers are:
|
||||
|
||||
@@ -75,6 +72,12 @@ Available video output drivers are:
|
||||
not responding quickly enough if video FPS is close to or higher than
|
||||
the display refresh rate.
|
||||
|
||||
``x11`` (X11 only)
|
||||
Shared memory video output driver without hardware acceleration that works
|
||||
whenever X11 is present.
|
||||
|
||||
.. note:: This is a fallback only, and should not be normally used.
|
||||
|
||||
``vdpau`` (X11 only)
|
||||
Uses the VDPAU interface to display and optionally also decode video.
|
||||
Hardware decoding is used with ``--hwdec=vdpau``.
|
||||
@@ -102,7 +105,7 @@ Available video output drivers are:
|
||||
Select deinterlacing mode (default: 0). In older versions (as well as
|
||||
MPlayer/mplayer2) you could use this option to enable deinterlacing.
|
||||
This doesn't work anymore, and deinterlacing is enabled with either
|
||||
the ``D`` key (by default mapped to the command ``cycle deinterlace``),
|
||||
the ``d`` key (by default mapped to the command ``cycle deinterlace``),
|
||||
or the ``--deinterlace`` option. Also, to select the default deint mode,
|
||||
you should use something like ``--vf-defaults=vdpaupp:deint-mode=temporal``
|
||||
instead of this sub-option.
|
||||
@@ -290,6 +293,29 @@ Available video output drivers are:
|
||||
color space conversion and chroma upsampling is generally in the hand of
|
||||
the hardware decoder APIs.
|
||||
|
||||
``opengl`` makes use of FBOs by default. Sometimes you can achieve better
|
||||
quality or performance by changing the ``fbo-format`` suboption to
|
||||
``rgb16f``, ``rgb32f`` or ``rgb``. Known problems include Mesa/Intel not
|
||||
accepting ``rgb16``, Mesa sometimes not being compiled with float texture
|
||||
support, and some OS X setups being very slow with ``rgb16`` but fast
|
||||
with ``rgb32f``. If you have problems, you can also try passing the
|
||||
``dumb-mode=yes`` sub-option.
|
||||
|
||||
``dumb-mode=<yes|no>``
|
||||
This mode is extremely restricted, and will disable most extended
|
||||
OpenGL features. This includes high quality scalers and custom
|
||||
shaders!
|
||||
|
||||
It is intended for hardware that does not support FBOs (including GLES,
|
||||
which supports it insufficiently), or to get some more performance out
|
||||
of bad or old hardware.
|
||||
|
||||
This mode is forced automatically if needed, and this option is mostly
|
||||
useful for debugging. It's also enabled automatically if nothing uses
|
||||
features which require FBOs.
|
||||
|
||||
This option might be silently removed in the future.
|
||||
|
||||
``scale=<filter>``
|
||||
|
||||
``bilinear``
|
||||
@@ -355,10 +381,6 @@ Available video output drivers are:
|
||||
Scale parameter (``t``). Increasing this makes the result blurrier.
|
||||
Defaults to 1.
|
||||
|
||||
sharpen3, sharpen5
|
||||
Sharpening strength. Increasing this makes the image sharper but
|
||||
adds more ringing and aliasing. Defaults to 0.5.
|
||||
|
||||
oversample
|
||||
Minimum distance to an edge before interpolation is used. Setting
|
||||
this to 0 will always interpolate edges, whereas setting it to 0.5
|
||||
@@ -388,8 +410,8 @@ Available video output drivers are:
|
||||
between 0.0 and 1.0. The default value of 0.0 disables antiringing
|
||||
entirely.
|
||||
|
||||
Note that this doesn't affect the special filters ``bilinear``,
|
||||
``bicubic_fast`` or ``sharpen``.
|
||||
Note that this doesn't affect the special filters ``bilinear`` and
|
||||
``bicubic_fast``.
|
||||
|
||||
``scale-window=<window>``
|
||||
(Advanced users only) Choose a custom windowing function for the kernel.
|
||||
@@ -409,17 +431,28 @@ Available video output drivers are:
|
||||
Scale parameter (t). Increasing this makes the window wider.
|
||||
Defaults to 1.
|
||||
|
||||
``scaler-lut-size=<4..10>``
|
||||
Set the size of the lookup texture for scaler kernels (default: 6).
|
||||
The actual size of the texture is ``2^N`` for an option value of ``N``.
|
||||
So the lookup texture with the default setting uses 64 samples.
|
||||
|
||||
All weights are bilinearly interpolated from those samples, so
|
||||
increasing the size of lookup table might improve the accuracy of
|
||||
scaler.
|
||||
|
||||
``scaler-resizes-only``
|
||||
Disable the scaler if the video image is not resized. In that case,
|
||||
``bilinear`` is used instead whatever is set with ``scale``. Bilinear
|
||||
will reproduce the source image perfectly if no scaling is performed.
|
||||
Note that this option never affects ``cscale``.
|
||||
Enabled by default. Note that this option never affects ``cscale``.
|
||||
|
||||
``pbo``
|
||||
Enable use of PBOs. This is slightly faster, but can sometimes lead to
|
||||
sporadic and temporary image corruption (in theory, because reupload
|
||||
is not retried when it fails), and perhaps actually triggers slower
|
||||
paths with drivers that don't support PBOs properly.
|
||||
Enable use of PBOs. On some drivers this can be faster, especially if
|
||||
the source video size is huge (e.g. so called "4K" video). On other
|
||||
drivers it might be slower or cause latency issues.
|
||||
|
||||
In theory, this can sometimes lead to sporadic and temporary image
|
||||
corruption (because reupload is not retried when it fails).
|
||||
|
||||
``dither-depth=<N|no|auto>``
|
||||
Set dither target depth to N. Default: no.
|
||||
@@ -450,7 +483,7 @@ Available video output drivers are:
|
||||
|
||||
``temporal-dither``
|
||||
Enable temporal dithering. (Only active if dithering is enabled in
|
||||
general.) This changes between 8 different dithering pattern on each
|
||||
general.) This changes between 8 different dithering patterns on each
|
||||
frame by changing the orientation of the tiled dithering matrix.
|
||||
Unfortunately, this can lead to flicker on LCD displays, since these
|
||||
have a high reaction time.
|
||||
@@ -461,7 +494,7 @@ Available video output drivers are:
|
||||
video frame, 2 on every other frame, etc.
|
||||
|
||||
``debug``
|
||||
Check for OpenGL errors, i.e. call ``glGetError()``. Also request a
|
||||
Check for OpenGL errors, i.e. call ``glGetError()``. Also, request a
|
||||
debug OpenGL context (which does nothing with current graphics drivers
|
||||
as of this writing).
|
||||
|
||||
@@ -469,6 +502,10 @@ Available video output drivers are:
|
||||
Reduce stuttering caused by mismatches in the video fps and display
|
||||
refresh rate (also known as judder).
|
||||
|
||||
.. warning:: This requires setting the ``--video-sync`` option to one
|
||||
of the ``display-`` modes, or it will be silently disabled.
|
||||
This was not required before mpv 0.14.0.
|
||||
|
||||
This essentially attempts to interpolate the missing frames by
|
||||
convoluting the video along the temporal axis. The filter used can be
|
||||
controlled using the ``tscale`` setting.
|
||||
@@ -500,7 +537,7 @@ Available video output drivers are:
|
||||
The filter used for interpolating the temporal axis (frames). This is
|
||||
only used if ``interpolation`` is enabled. The only valid choices
|
||||
for ``tscale`` are separable convolution filters (use ``tscale=help``
|
||||
to get a list). The default is ``oversample``.
|
||||
to get a list). The default is ``mitchell``.
|
||||
|
||||
Note that the maximum supported filter radius is currently 3, due to
|
||||
limitations in the number of video textures that can be loaded
|
||||
@@ -512,6 +549,20 @@ Available video output drivers are:
|
||||
manifest themselves as short flashes or fringes of black, mostly
|
||||
around moving edges) in exchange for potentially adding more blur.
|
||||
|
||||
``interpolation-threshold=<0..1,-1>``
|
||||
Threshold below which frame ratio interpolation gets disabled (default:
|
||||
``0.0001``). This is calculated as ``abs(disphz/vfps - 1) < threshold``,
|
||||
where ``vfps`` is the speed-adjusted display FPS, and ``disphz`` the
|
||||
display refresh rate.
|
||||
|
||||
The default is intended to almost always enable interpolation if the
|
||||
playback rate is even slightly different from the display refresh rate.
|
||||
But note that if you use e.g. ``--video-sync=display-vdrop``, small
|
||||
deviations in the rate can disable interpolation and introduce a
|
||||
discontinuity every other minute.
|
||||
|
||||
Set this to ``-1`` to disable this logic.
|
||||
|
||||
``dscale-radius``, ``cscale-radius``, ``tscale-radius``, etc.
|
||||
Set filter parameters for ``dscale``, ``cscale`` and ``tscale``,
|
||||
respectively.
|
||||
@@ -522,25 +573,86 @@ Available video output drivers are:
|
||||
Scale in linear light. It should only be used with a ``fbo-format``
|
||||
that has at least 16 bit precision.
|
||||
|
||||
``fancy-downscaling``
|
||||
``correct-downscaling``
|
||||
When using convolution based filters, extend the filter size
|
||||
when downscaling. Trades quality for reduced downscaling performance.
|
||||
when downscaling. Increases quality, but reduces performance while
|
||||
downscaling.
|
||||
|
||||
This is automatically disabled for anamorphic video, because this
|
||||
feature doesn't work correctly with different scale factors in
|
||||
different directions.
|
||||
This will perform slightly sub-optimally for anamorphic video (but still
|
||||
better than without it) since it will extend the size to match only the
|
||||
milder of the scale factors between the axes.
|
||||
|
||||
``source-shader=<file>``, ``scale-shader=<file>``, ``pre-shaders=<files>``, ``post-shaders=<files>``
|
||||
``prescale=<filter>``
|
||||
This option provides non-convolution-based filters for upscaling. These
|
||||
filters resize the video to multiple of the original size (all currently
|
||||
supported prescalers can only perform image doubling in a single pass).
|
||||
Generally another convolution based filter (the main scaler) will be
|
||||
applied after prescaler to match the target display size.
|
||||
|
||||
``none``
|
||||
Disable all prescalers. This is the default.
|
||||
|
||||
``superxbr``
|
||||
A relatively fast prescaler originally developed for pixel art.
|
||||
|
||||
Some parameters can be tuned with ``superxbr-sharpness`` and
|
||||
``superxbr-edge-strength`` options.
|
||||
|
||||
``nnedi3``
|
||||
An artificial neural network based deinterlacer, which can be used
|
||||
to upscale images.
|
||||
|
||||
Extremely slow and requires a recent mid or high end graphics card
|
||||
to work smoothly (as of 2015).
|
||||
|
||||
Note that all the filters above are designed (or implemented) to process
|
||||
luma plane only and probably won't work as intended for video in RGB
|
||||
format.
|
||||
|
||||
``prescale-passes=<1..5>``
|
||||
The number of passes to apply the prescaler (defaults to be 1). Setting
|
||||
it to 2 will perform a 4x upscaling.
|
||||
|
||||
``prescale-downscaling-threshold=<0..32>``
|
||||
This option prevents "overkill" use of prescalers, which can be caused
|
||||
by misconfiguration, or user trying to play a video with much larger
|
||||
size. With this option, user can specify the maximal allowed downscaling
|
||||
ratio in both dimension. To satisfy it, the number of passes for
|
||||
prescaler will be reduced, and if necessary prescaler could also be
|
||||
disabled.
|
||||
|
||||
The default value is 2.0, and should be able to prevent most seemingly
|
||||
unreasonable use of prescalers. Most user would probably want to set it
|
||||
to a smaller value between 1.0 and 1.5 for better performance.
|
||||
|
||||
A value less than 1.0 will disable the check.
|
||||
|
||||
``nnedi3-neurons=<16|32|64|128>``
|
||||
Specify the neurons for nnedi3 prescaling (defaults to be 32). The
|
||||
rendering time is expected to be linear to the number of neurons.
|
||||
|
||||
``nnedi3-window=<8x4|8x6>``
|
||||
Specify the size of local window for sampling in nnedi3 prescaling
|
||||
(defaults to be ``8x4``). The ``8x6`` window produces sharper images,
|
||||
but is also slower.
|
||||
|
||||
``nnedi3-upload=<ubo|shader>``
|
||||
Specify how to upload the NN weights to GPU. Depending on the graphics
|
||||
card, driver, shader compiler and nnedi3 settings, both method can be
|
||||
faster or slower.
|
||||
|
||||
``ubo``
|
||||
Upload these weights via uniform buffer objects. This is the
|
||||
default. (requires OpenGL 3.1 / GLES 3.0)
|
||||
|
||||
``shader``
|
||||
Hard code all the weights into the shader source code. (requires
|
||||
OpenGL 3.3 / GLES 3.0)
|
||||
|
||||
|
||||
``pre-shaders=<files>``, ``post-shaders=<files>``, ``scale-shader=<file>``
|
||||
Custom GLSL fragment shaders.
|
||||
|
||||
source-shader
|
||||
This gets applied directly onto the source planes, before
|
||||
any sort of upscaling or conversion whatsoever. For YCbCr content,
|
||||
this means it gets applied on the luma and chroma planes
|
||||
separately. In general, this shader shouldn't be making any
|
||||
assumptions about the colorspace. It could be RGB, YCbCr, XYZ or
|
||||
something else entirely. It's used purely for fixing numerical
|
||||
quirks of the input, eg. debanding or deblocking.
|
||||
pre-shaders (list)
|
||||
These get applied after conversion to RGB and before linearization
|
||||
and upscaling. Operates on non-linear RGB (same as input). This is
|
||||
@@ -559,7 +671,11 @@ Available video output drivers are:
|
||||
|
||||
These files must define a function with the following signature::
|
||||
|
||||
vec4 sample(sampler2D tex, vec2 pos, vec2 tex_size)
|
||||
vec4 sample_pixel(sampler2D tex, vec2 pos, vec2 tex_size)
|
||||
|
||||
(If there is no string ``sample_pixel`` in the shader script, it will
|
||||
use ``sample`` instead. This is a compatibility hack for older shader
|
||||
scripts, and is deprecated.)
|
||||
|
||||
The meanings of the parameters are as follows:
|
||||
|
||||
@@ -581,10 +697,6 @@ Available video output drivers are:
|
||||
never resets (regardless of seeks).
|
||||
vec2 image_size
|
||||
The size in pixels of the input image.
|
||||
float cmul (source-shader only)
|
||||
The multiplier needed to pull colors up to the right bit depth. The
|
||||
source-shader must multiply any sampled colors by this, in order
|
||||
to normalize them to the full scale.
|
||||
|
||||
For example, a shader that inverts the colors could look like this::
|
||||
|
||||
@@ -594,6 +706,37 @@ Available video output drivers are:
|
||||
return vec4(1.0 - color.rgb, color.a);
|
||||
}
|
||||
|
||||
``deband``
|
||||
Enable the debanding algorithm. This greatly reduces the amount of
|
||||
visible banding, blocking and other quantization artifacts, at the
|
||||
expensive of very slightly blurring some of the finest details. In
|
||||
practice, it's virtually always an improvement - the only reason to
|
||||
disable it would be for performance.
|
||||
|
||||
``deband-iterations=<1..16>``
|
||||
The number of debanding steps to perform per sample. Each step reduces
|
||||
a bit more banding, but takes time to compute. Note that the strength
|
||||
of each step falls off very quickly, so high numbers (>4) are
|
||||
practically useless. (Default 1)
|
||||
|
||||
``deband-threshold=<0..4096>``
|
||||
The debanding filter's cut-off threshold. Higher numbers increase the
|
||||
debanding strength dramatically but progressively diminish image
|
||||
details. (Default 64)
|
||||
|
||||
``deband-range=<1..64>``
|
||||
The debanding filter's initial radius. The radius increases linearly
|
||||
for each iteration. A higher radius will find more gradients, but
|
||||
a lower radius will smooth more aggressively. (Default 16)
|
||||
|
||||
If you increase the ``deband-iterations``, you should probably
|
||||
decrease this to compensate.
|
||||
|
||||
``deband-grain=<0..4096>``
|
||||
Add some extra noise to the image. This significantly helps cover up
|
||||
remaining quantization artifacts. Higher numbers add more noise.
|
||||
(Default 48)
|
||||
|
||||
``sigmoid-upscaling``
|
||||
When upscaling, use a sigmoidal color transform to avoid emphasizing
|
||||
ringing artifacts. This also implies ``linear-scaling``.
|
||||
@@ -606,9 +749,19 @@ Available video output drivers are:
|
||||
The slope of the sigmoid curve used for ``sigmoid-upscaling``, must
|
||||
be a float between 1.0 and 20.0. Defaults to 6.5 if not specified.
|
||||
|
||||
``sharpen=<value>``
|
||||
If set to a value other than 0, enable an unsharp masking filter.
|
||||
Positive values will sharpen the image (but add more ringing and
|
||||
aliasing). Negative values will blur the image. If your GPU is powerful
|
||||
enough, consider alternatives like the ``ewa_lanczossharp`` scale
|
||||
filter, or the ``scale-blur`` sub-option.
|
||||
|
||||
(This feature is the replacement for the old ``sharpen3`` and
|
||||
``sharpen5`` scalers.)
|
||||
|
||||
``glfinish``
|
||||
Call ``glFinish()`` before and after swapping buffers (default: disabled).
|
||||
Slower, but might help getting better results when doing framedropping.
|
||||
Slower, but might improve results when doing framedropping.
|
||||
Can completely ruin performance. The details depend entirely on the
|
||||
OpenGL driver.
|
||||
|
||||
@@ -619,14 +772,27 @@ Available video output drivers are:
|
||||
|
||||
X11/GLX only.
|
||||
|
||||
``dwmflush=<no|windowed|yes>``
|
||||
Calls ``DwmFlush`` after swapping buffers on Windows (default: no).
|
||||
``vsync-fences=<N>``
|
||||
Synchronize the CPU to the Nth past frame using the ``GL_ARB_sync``
|
||||
extension. A value of 0 disables this behavior (default). A value of
|
||||
1 means it will synchronize to the current frame after rendering it.
|
||||
Like ``glfinish`` and ``waitvsync``, this can lower or ruin performance.
|
||||
Its advantage is that it can span multiple frames, and effectively limit
|
||||
the number of frames the GPU queues ahead (which also has an influence
|
||||
on vsync).
|
||||
|
||||
``dwmflush=<no|windowed|yes|auto>``
|
||||
Calls ``DwmFlush`` after swapping buffers on Windows (default: auto).
|
||||
It also sets ``SwapInterval(0)`` to ignore the OpenGL timing. Values
|
||||
are: no (disabled), windowed (only in windowed mode), yes (also in
|
||||
full screen).
|
||||
This may help getting more consistent frame intervals, especially with
|
||||
high-fps clips - which might also reduce dropped frames. Typically a
|
||||
value of ``windowed`` should be enough since full screen may bypass the
|
||||
|
||||
The value ``auto`` will try to determine whether the compositor is
|
||||
active, and calls ``DwmFlush`` only if it seems to be.
|
||||
|
||||
This may help to get more consistent frame intervals, especially with
|
||||
high-fps clips - which might also reduce dropped frames. Typically, a
|
||||
value of ``windowed`` should be enough, since full screen may bypass the
|
||||
DWM.
|
||||
|
||||
Windows only.
|
||||
@@ -645,23 +811,39 @@ Available video output drivers are:
|
||||
Cocoa/OS X
|
||||
win
|
||||
Win32/WGL
|
||||
angle
|
||||
Direct3D11 through the OpenGL ES translation layer ANGLE. This
|
||||
supports almost everything the ``win`` backend does, except ICC
|
||||
profiles, and the ``nnedi3`` prescaler.
|
||||
dxinterop (experimental)
|
||||
Win32, using WGL for rendering and Direct3D 9Ex for presentation.
|
||||
Works on Nvidia and AMD only.
|
||||
x11
|
||||
X11/GLX
|
||||
wayland
|
||||
Wayland/EGL
|
||||
drm-egl
|
||||
DRM/EGL
|
||||
x11egl
|
||||
X11/EGL
|
||||
|
||||
``es``
|
||||
Force or prefer GLES2/3 over desktop OpenGL, if supported.
|
||||
``es=<mode>``
|
||||
Select whether to use GLES:
|
||||
|
||||
yes
|
||||
Try to prefer ES over Desktop GL
|
||||
no
|
||||
Try to prefer desktop GL over ES
|
||||
auto
|
||||
Use the default for each backend (default)
|
||||
|
||||
``fbo-format=<fmt>``
|
||||
Selects the internal format of textures used for FBOs. The format can
|
||||
influence performance and quality of the video output. (FBOs are not
|
||||
always used, and typically only when using extended scalers.)
|
||||
influence performance and quality of the video output.
|
||||
``fmt`` can be one of: rgb, rgba, rgb8, rgb10, rgb10_a2, rgb16, rgb16f,
|
||||
rgb32f, rgba12, rgba16, rgba16f, rgba32f.
|
||||
Default: rgba16.
|
||||
Default: ``auto``, which maps to rgba16 on desktop GL, and rgba16f or
|
||||
rgb10_a2 on GLES (e.g. ANGLE).
|
||||
|
||||
``gamma=<0.1..2.0>``
|
||||
Set a gamma value (default: 1.0). If gamma is adjusted in other ways
|
||||
@@ -741,7 +923,8 @@ Available video output drivers are:
|
||||
Automatically select the ICC display profile currently specified by
|
||||
the display settings of the operating system.
|
||||
|
||||
NOTE: Only implemented on OS X and X11
|
||||
NOTE: On Windows, the default profile must be an ICC profile. WCS
|
||||
profiles are not supported.
|
||||
|
||||
``icc-cache-dir=<dirname>``
|
||||
Store and load the 3D LUTs created from the ICC profile in this directory.
|
||||
@@ -792,9 +975,11 @@ Available video output drivers are:
|
||||
things like softsubbed ASS signs to match the video colors,
|
||||
but may cause SRT subtitles or similar to look slightly off.
|
||||
|
||||
``alpha=<blend|yes|no>``
|
||||
Decides what to do if the input has an alpha component (default: blend).
|
||||
``alpha=<blend-tiles|blend|yes|no>``
|
||||
Decides what to do if the input has an alpha component.
|
||||
|
||||
blend-tiles
|
||||
Blend the frame against a 16x16 gray/white tiles background (default).
|
||||
blend
|
||||
Blend the frame against a black background.
|
||||
yes
|
||||
@@ -821,18 +1006,11 @@ Available video output drivers are:
|
||||
|
||||
This is equivalent to::
|
||||
|
||||
--vo=opengl:scale=spline36:cscale=spline36:dscale=mitchell:dither-depth=auto:fancy-downscaling:sigmoid-upscaling:pbo
|
||||
--vo=opengl:scale=spline36:cscale=spline36:dscale=mitchell:dither-depth=auto:correct-downscaling:sigmoid-upscaling:deband:es=no
|
||||
|
||||
Note that some cheaper LCDs do dithering that gravely interferes with
|
||||
``opengl``'s dithering. Disabling dithering with ``dither-depth=no`` helps.
|
||||
|
||||
Unlike ``opengl``, ``opengl-hq`` makes use of FBOs by default. Sometimes you
|
||||
can achieve better quality or performance by changing the ``fbo-format``
|
||||
suboption to ``rgb16f``, ``rgb32f`` or ``rgb``. Known problems include
|
||||
Mesa/Intel not accepting ``rgb16``, Mesa sometimes not being compiled with
|
||||
float texture support, and some OS X setups being very slow with ``rgb16``
|
||||
but fast with ``rgb32f``.
|
||||
|
||||
``sdl``
|
||||
SDL 2.0+ Render video output driver, depending on system with or without
|
||||
hardware acceleration. Should work on all platforms supported by SDL 2.0.
|
||||
@@ -868,7 +1046,7 @@ Available video output drivers are:
|
||||
|
||||
``deint-mode=<mode>``
|
||||
Select deinterlacing algorithm. Note that by default deinterlacing is
|
||||
initially always off, and needs to be enabled with the ``D`` key
|
||||
initially always off, and needs to be enabled with the ``d`` key
|
||||
(default key binding for ``cycle deinterlace``).
|
||||
|
||||
This option doesn't apply if libva supports video post processing (vpp).
|
||||
@@ -966,27 +1144,6 @@ Available video output drivers are:
|
||||
``opengl-cb``
|
||||
For use with libmpv direct OpenGL embedding; useless in any other contexts.
|
||||
(See ``<mpv/opengl_cb.h>``.)
|
||||
Usually, ``opengl-cb`` renders frames asynchronously by client and this
|
||||
can cause some frame drops. In order to provide a way to handle this
|
||||
situation, ``opengl-cb`` has its own frame queue and calls update callback
|
||||
more frequently if the queue is not empty regardless of existence of new frame.
|
||||
Once the queue is filled, ``opengl-cb`` drops frames automatically.
|
||||
|
||||
With default options, ``opengl-cb`` renders only the latest frame and drops
|
||||
all frames handed over while waiting render function after update callback.
|
||||
|
||||
``frame-queue-size=<1..100>``
|
||||
The maximum count of frames which the frame queue can hold (default: 1)
|
||||
|
||||
``frame-drop-mode=<pop|clear|block>``
|
||||
Select the behavior when the frame queue is full.
|
||||
|
||||
pop
|
||||
Drop the oldest frame in the frame queue.
|
||||
clear
|
||||
Drop all frames in the frame queue.
|
||||
block
|
||||
Wait for a short time, behave like ``clear`` on timeout. (default)
|
||||
|
||||
This also supports many of the suboptions the ``opengl`` VO has. Run
|
||||
``mpv --vo=opengl-cb:help`` for a list.
|
||||
@@ -1011,10 +1168,15 @@ Available video output drivers are:
|
||||
Normally it's better to kill the console framebuffer instead, which
|
||||
gives better performance.
|
||||
|
||||
``osd=<yes|no>``
|
||||
Enabled by default. If disabled with ``no``, no OSD layer is created.
|
||||
This also means there will be no subtitles rendered.
|
||||
|
||||
``drm`` (Direct Rendering Manager)
|
||||
Video output driver using Kernel Mode Setting / Direct Rendering Manager.
|
||||
Does not support hardware acceleration. Should be used when one doesn't
|
||||
want to install full-blown graphical environment (e.g. no X).
|
||||
Should be used when one doesn't want to install full-blown graphical
|
||||
environment (e.g. no X). Does not support hardware acceleration (if you
|
||||
need this, check the ``drm-egl`` backend for ``opengl`` VO).
|
||||
|
||||
``connector=<number>``
|
||||
Select the connector to use (usually this is a monitor.) If set to -1,
|
||||
|
||||
+69
-27
@@ -1,64 +1,106 @@
|
||||
Release Policy
|
||||
==============
|
||||
|
||||
Every few months, a new release is cut off of the master branch and is assigned
|
||||
a 0.X.0 version number.
|
||||
Once or twice a month, a new release is cut off of the master branch and is
|
||||
assigned a 0.X.Y version number, where X is incremented each time a release
|
||||
contains breaking changes, such as changed options or added/removed features,
|
||||
and Y is incremented if a release contains only bugfixes and other minor
|
||||
changes.
|
||||
|
||||
As part of the maintenance process, minor releases are made, which are assigned
|
||||
0.X.Y version numbers. Minor releases contain bug fixes only. They never merge
|
||||
the master branch, and no features are added to it. Only the latest release is
|
||||
maintained.
|
||||
There is only one release branch that keeps track of the latest version and
|
||||
will not be maintained separately.
|
||||
|
||||
The goal of releases is to provide stability and an unchanged base for the sake
|
||||
of Linux distributions. If you want the newest features, just use the master
|
||||
branch, which is stable most of the time, except sometimes, when it's not.
|
||||
The goal of releases is to provide Linux distributions with something to
|
||||
package. If you want the newest features, just use the master branch.
|
||||
We try our best to keep it deployable at all times.
|
||||
|
||||
Releases other than the latest release are unsupported and unmaintained.
|
||||
|
||||
Release procedure
|
||||
-----------------
|
||||
|
||||
- Create branch release/0.X or cherry-pick commits to the relevant branch.
|
||||
- Merge master into branch release/current.
|
||||
|
||||
- Create and/or update the ``RELEASE_NOTES`` file.
|
||||
- Create and/or update the `RELEASE_NOTES` file.
|
||||
|
||||
- Create and/or update the ``VERSION`` file.
|
||||
- Create and/or update the `VERSION` file.
|
||||
|
||||
- Update ``DOCS/client-api-changes.rst`` (on major releases).
|
||||
- Update `DOCS/client-api-changes.rst` (on major releases).
|
||||
|
||||
- Create tag v0.X.Y.
|
||||
|
||||
- Push branch and tag to GitHub.
|
||||
|
||||
- Create a new GitHub release using the content of ``RELEASE_NOTES`` related to
|
||||
- Create a new GitHub release using the content of `RELEASE_NOTES` related to
|
||||
the new version.
|
||||
|
||||
Release notes template
|
||||
----------------------
|
||||
|
||||
Here is a template that can be used for writing the ``RELEASE_NOTES`` file.
|
||||
Here is a template that can be used for writing the `RELEASE_NOTES` file.
|
||||
|
||||
```markdown
|
||||
Release 0.X.Y
|
||||
=============
|
||||
|
||||
Changes
|
||||
-------
|
||||
Features
|
||||
--------
|
||||
|
||||
- List of changes.
|
||||
New
|
||||
~~~
|
||||
|
||||
Bug fixes
|
||||
---------
|
||||
- List of new features
|
||||
|
||||
- List of bug fixes.
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
New features
|
||||
------------
|
||||
- List of removed features
|
||||
|
||||
- List of new features.
|
||||
Deprecated
|
||||
~~~~~~~~~~
|
||||
|
||||
- List of deprecated features
|
||||
|
||||
Behavior
|
||||
--------
|
||||
|
||||
- List of user-visible changes in behavior
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- List of added options and commands
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- List of changed options and commands
|
||||
|
||||
Renamed
|
||||
~~~~~~~
|
||||
|
||||
- List of renamed options and commands
|
||||
|
||||
Deprecated
|
||||
~~~~~~~~~~
|
||||
|
||||
- List of deprecated options and commands
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- List of removed options and commands
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- List of fixes and minor enhancements
|
||||
|
||||
This listing is not complete. There are many more bug fixes and changes. The
|
||||
complete change log can be viewed by running ``git log <start>..<end>`` in
|
||||
complete change log can be viewed by running `git log <start>..<end>` in
|
||||
the git repository.
|
||||
```
|
||||
|
||||
@@ -66,6 +108,6 @@ Note that the "Release 0.X.Y" title should be removed when creating a new GitHub
|
||||
release.
|
||||
|
||||
When creating a new point release its changes should be added on top of the
|
||||
``RELEASE_NOTES`` file (with the appropriate title) so that all the changes in
|
||||
the current 0.X branch will be included. This way the ``RELEASE_NOTES`` file
|
||||
`RELEASE_NOTES` file (with the appropriate title) so that all the changes in
|
||||
the current 0.X branch will be included. This way the `RELEASE_NOTES` file
|
||||
can be used by distributors as changelog for point releases too.
|
||||
@@ -26,6 +26,21 @@ variety of video file formats, audio and video codecs, and subtitle types.
|
||||
|
||||
Releases can be found on the [release list][releases].
|
||||
|
||||
## System requirements
|
||||
|
||||
- A not too ancient Linux, or Windows Vista or later, or OSX 10.8 or later.
|
||||
- A somewhat capable CPU. Hardware decoding might sometimes help if the CPU
|
||||
is too slow to decode video realtime, but must be explicitly enabled with
|
||||
the `--hwdec` option. On Windows, a CPU with SSE4 instruction set is required
|
||||
to get decent hardware decoding performance.
|
||||
- A not too crappy GPU. mpv is not intended to be used with bad GPUs. There are
|
||||
many caveats with drivers or system compositors causing tearing, stutter,
|
||||
etc. On Windows, you might want to make sure the graphics drivers are
|
||||
current, especially OpenGL. In some cases, ancient fallback video output
|
||||
methods can help (such as `--vo=xv` on Linux), but this use is not
|
||||
recommended or supported.
|
||||
|
||||
|
||||
## Downloads
|
||||
|
||||
|
||||
@@ -70,7 +85,7 @@ Essential dependencies (incomplete list):
|
||||
- libass (OSD, OSC, text subtitles)
|
||||
- Lua (optional, required for the OSC pseudo-GUI and youtube-dl integration)
|
||||
- libjpeg (optional, used for screenshots only)
|
||||
- Enca (optional, for subtitle charset detection)
|
||||
- uchardet (optional, for subtitle charset detection)
|
||||
- vdpau and vaapi libraries for hardware decoding on Linux (optional)
|
||||
|
||||
Libass dependencies:
|
||||
@@ -96,13 +111,10 @@ the separately available build wrapper ([mpv-build][mpv-build]) that first compi
|
||||
libraries and libass, and then compiles the player statically linked against
|
||||
those.
|
||||
|
||||
If you are running Mac OSX and using homebrew we provide [homebrew-mpv][homebrew-mpv], an up
|
||||
to date formula that compiles mpv with sensible dependencies and defaults for
|
||||
OSX.
|
||||
|
||||
If you want to build a Windows binary, you either have to use MSYS2 and MinGW,
|
||||
or cross-compile from Linux with MinGW. See [Windows compilation][windows_compilation].
|
||||
|
||||
|
||||
## FFmpeg vs. Libav
|
||||
|
||||
|
||||
@@ -187,7 +199,7 @@ only if discretion is required.
|
||||
[windows_compilation]: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md
|
||||
[mplayer-changes]: https://github.com/mpv-player/mpv/blob/master/DOCS/mplayer-changes.rst
|
||||
|
||||
## License
|
||||
## License
|
||||
|
||||
|
||||
[GPLv2](https://github.com/mpv-player/mpv/blob/master/LICENSE)
|
||||
Mostly GPLv2 or later. See [details.](https://github.com/mpv-player/mpv/blob/master/Copyright)
|
||||
+525
@@ -1,3 +1,528 @@
|
||||
Release 0.16.0
|
||||
==============
|
||||
|
||||
This release changes the license of some non-MPlayer source files to LGPL 2.1 or later.
|
||||
|
||||
|
||||
Build System Changes
|
||||
--------------------
|
||||
|
||||
- build: enable vaapi under drm-only as well (issue #2808)
|
||||
- build: enable vo_opengl_cb if GL headers are present
|
||||
- build: make libavfilter mandatory
|
||||
- build: make posix_spawn optional
|
||||
- wscript: don’t install the encoding profiles with encoding disabled
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- Initial Android support
|
||||
- ao: initial OpenSL ES support
|
||||
- dxva2: support HEVC Main 10
|
||||
- osc: add always-on mode and unify visibility mode (always/never/auto)
|
||||
- player: add complex filter graph support
|
||||
- rpi: add mpeg-4, vc-1 decoding support
|
||||
- stream_dvb: support frontends with multiple delivery systems (e.g. DVB-C/DVB-T combo cards)
|
||||
- vo_opengl: 10 bit support with ANGLE
|
||||
- vo_opengl: add KMS/DRM VAAPI hardware decoding interop
|
||||
- vo_opengl: dxinterop: add dxva2 passthrough
|
||||
- vo_rpi: add geometry handling (--geometry, --autofit, fullscreen switching, etc.)
|
||||
- vo_x11: add 16bpp support
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- --lavfi-complex option for complex filter graphs
|
||||
- audio: change downmix behavior, add --audio-normalize-downmix
|
||||
- command: add vf-command and af-command commands
|
||||
- player: add --external-file option
|
||||
- vo_opengl: add interpolation-threshold sub-option
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- audio: change --audio-channels default back to stereo
|
||||
- audio: remove default preference for libdcadec (decoder was merged with FFmpeg)
|
||||
- command: always allow setting volume/mute properties
|
||||
- command: show original aspect in video-aspect property too
|
||||
- input: ignore --input-cursor for events injected by input commands (issue #2750)
|
||||
- options: set fs=yes by default on RPI, and change RPI defaults handling
|
||||
- sub: implement "sub-seek 0" (issue #2791)
|
||||
- vo_opengl: default scaler-resizes-only sub-option to yes
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- OS X/cocoa: fix charcode retrieving for accented characters
|
||||
- TOOLS/lua/ao-null-reload.lua: send ao-reload on audio-device-list change (issue #2738)
|
||||
- TOOLS/lua/autoload.lua: remove the extension prior to sort
|
||||
- Windows: fix dropping URIs (issue #2782)
|
||||
- af_lavrresample: prevent channels from being dropped, e.g. when going 7.1 -> 7.1(wide) and similar cases
|
||||
- ao_coreaudio: fix 7.1(rear) channel mapping
|
||||
- ao_openal: wipe out global context on init error (PR #2719)
|
||||
- ao_wasapi: avoid under-run cascade in exclusive mode
|
||||
- ao_wasapi: set buffer size to device period in exclusive mode
|
||||
- audio: fix spdif PCM fallback
|
||||
- build: add special openbsd case for iconv check (issue #2710)
|
||||
- command: fix NULL pointer deref in "video-codec" property (issue #2729)
|
||||
- command: fix track cycling logic (issue #2784)
|
||||
- demux: disable stream cache if no tracks are selected (issue #2692)
|
||||
- demux_mkv: add hack to fix opus gapless behavior
|
||||
- demux_mkv: support channel layout in VfW muxed PCM (issue #2820)
|
||||
- osc: fix runtime enable_osc(true/false)
|
||||
- player: fix initial audio sync in certain cases (issue #2770)
|
||||
- player: honor --force-window if video is selected, but inactive
|
||||
- player: never show "DS: (unavailable)"
|
||||
- player: restore old/correct --force-window behavior (issue #2825)
|
||||
- player: rewrite timeline/ordered chapter support
|
||||
- vaapi: fix compilation on older FFmpeg/Libav (issue #2737)
|
||||
- vdpau: force driver to report preemption early
|
||||
- video: don't wait for last video frame in the normal case (issue #2745)
|
||||
- video: fix coverart switching
|
||||
- video: slightly improve video stream switching
|
||||
- vo_opengl: add precision qualifier to usampler2D on ANGLE (issue #2761)
|
||||
- vo_opengl: default to rgba16f FBOs on ANGLE
|
||||
- vo_opengl: don't use normalized coords for debanding rectangle textures (issue #2831)
|
||||
- vo_opengl: dxinterop: fix compatibility issue with Vista
|
||||
- vo_opengl: pass the correct target to deband functions with Apple hwdec interop
|
||||
- vo_opengl: rename custom shader entrypoint from sample to sample_pixel (issue #2733)
|
||||
- x11: get *current* XRandR screen configuration instead of polling for new screens, too
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.15.0..v0.16.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.15.0...v0.16.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.15.0..v0.16.0
|
||||
|
||||
|
||||
|
||||
Release 0.15.0
|
||||
==============
|
||||
|
||||
Build System Changes
|
||||
--------------------
|
||||
|
||||
- OS X bundle: remove git sha from the Info.plist version (issue #2677)
|
||||
- add "lua51" ("51obsd") to list of possible lua names
|
||||
- add option to customize config files system path (issue #2704)
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: implement support for transparent video display on OS X (alpha=yes suboption)
|
||||
- vo_opengl: use a checkerboard pattern as background for transparent video by default
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- add --audio-file-paths (issue #2632)
|
||||
- player, stream_dvb: implement dvb-channel-name property, add switch binding
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- vf_stereo3d: add alternating modes
|
||||
- vo_opengl: disable pbo by default for opengl-hq due to driver problems
|
||||
- vf_yadif: change defaults (issue #2539)
|
||||
- command: change heuristic for files with 1 chapter (issue #2550)
|
||||
- demux_mkv: adjust subtitle preroll defaults
|
||||
- exclude 360 from --video-rotate range (issue #2647)
|
||||
- osd: make osd-width/height properties watchable
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- ao_pulse: check for sample rate bounds, attempt fallback (issue #2654)
|
||||
- ao_wasapi: remove volume "restore" on exit
|
||||
- demux_cue: better error resilience
|
||||
- mixer: fix volume initialization with --af=volume
|
||||
- mpv.desktop: add audio/mp4 mime type
|
||||
- player: detect audio PTS jumps, make video PTS heuristic less aggressive
|
||||
- player: make watch later/resume work when "playing" directories
|
||||
- player: reset playback abort when reloading a file (issue #2568)
|
||||
- recognize frame sequenced 3D Matroska video
|
||||
- stream_dvb: fix channel switching
|
||||
- vaapi: add VP9 profile (requires VA-API 0.38.1 or newer)
|
||||
- vo_opengl: dxinterop: prevent crash after lost device
|
||||
- vo_opengl: enable brightness/contrast controls for RGB
|
||||
- vo_opengl: fix operation on GLES 2.0
|
||||
- vo_opengl: fix operation on GLSL versions earlier than 1.30
|
||||
- vo_opengl: flip screenshot image if backend uses flipped rendering (issue #2635)
|
||||
- vo_opengl: reset nnedi3 weights properly (issue #2661)
|
||||
- vo_rpi: handle rotation
|
||||
- vo_rpi: work around firmware oddness leading to incorrect video rect
|
||||
- windows: fix fd://
|
||||
- ytdl: Include Referer header as well
|
||||
- TOOLS/zsh.pl: add .opus extension in zsh completions
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.14.0..v0.15.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.14.0...v0.15.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.14.0..v0.15.0
|
||||
|
||||
|
||||
|
||||
Release 0.14.0
|
||||
==============
|
||||
|
||||
Build System Changes
|
||||
--------------------
|
||||
|
||||
- build: install scalable svg icon as well
|
||||
- vo_opengl: require --enable-gpl3 for nnedi
|
||||
- win32: enable internal pthreads wrapper by default
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: add experimental dxinterop backend (renders with OpenGL, displays through Direct3D; broken with Intel drivers)
|
||||
- vo_opengl: add initial ANGLE support
|
||||
- windows: implement icc-profile-auto
|
||||
- windows: support taskbar button progress indicator (issue #2399)
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- Windows XP support
|
||||
- demux: remove old subtitle parser (FFmpeg users are unaffected; Libav loses support for some minor formats)
|
||||
- demux_libass: remove this demuxer (libavformat takes its place)
|
||||
- stream: drop old Linux PVR support
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- command, vo: add estimated-display-fps property
|
||||
- command: add vsync-ratio property
|
||||
- command: export some per-video-frame information (issue #2444)
|
||||
- vo_opengl: make LOOKUP_TEXTURE_SIZE configurable
|
||||
- windows: add option to set VO MMCSS profile
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- --sub-fix-timing now applies to ASS subtitles as well
|
||||
- command: rename vo-missed-frame-count property to vo-delayed-frame-count
|
||||
- input.conf: add default bindings for changing window scale (issue #2500)
|
||||
- videotoolbox: make decoder format customizable
|
||||
- vo_opengl: disable interpolation without display-sync
|
||||
- vo_opengl: make tscale=mitchell:tscale-clamp the default
|
||||
- vo_rpi: add an option to disable OSD
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- af_lavrresample: clamp float output to range
|
||||
- ao: disambiguate default device list entries
|
||||
- ao_alsa: filter audio device list
|
||||
- ao_alsa: list bidirectional devices too
|
||||
- ao_openal: accommodate more sample formats (issue #2494)
|
||||
- ao_openal: fix virtual speaker positioning
|
||||
- ao_wasapi: only report per-app volume in shared mode
|
||||
- ao_wasapi: work around DTS passthrough failure
|
||||
- build: make vaapi-wayland depend on gl-wayland (issue #2476)
|
||||
- demux: fix seeking in .ts
|
||||
- demux_lavf: mark ASS tracks as always UTF-8
|
||||
- demux_mkv: fix incremental indexing with single-keyframe files (issue #2498)
|
||||
- drm: fix setting up connectors
|
||||
- dxva2: reject 10 bit HEVC (issue #2516)
|
||||
- player: replace mistimed-frame-count with vsync-ratio on status line
|
||||
- sd_ass: fix secondary subtitle mode
|
||||
- various display-sync improvements
|
||||
- vo_opengl: enable NNEDI3 prescaler on OpenGL ES 3.0
|
||||
- vo_opengl: enable colormatrix even for RGB input
|
||||
- vo_opengl: fix backend autoprobing, attempt to improve GLX vs. EGL backend detection
|
||||
- vo_opengl: fix backend=x11 on Intel
|
||||
- vo_opengl: fix issues with some obscure pixel formats (e.g. rgb555)
|
||||
- vo_opengl: fix precision loss of fruit dithering matrix
|
||||
- vo_opengl: force dumb mode if RG textures are not available
|
||||
- vo_opengl: improve boundary check for polar filters
|
||||
- vo_opengl: various GLES compatibility improvements
|
||||
- vo_opengl: win32: test for exclusive mode
|
||||
- vo_opengl_cb: do not block on flipping when redrawing
|
||||
- vo_rpi: set aspect ratio
|
||||
- win32: fix console output with raw stdio functions
|
||||
- windows: try to avoid detection as exclusive fullscreen window (issue #2177)
|
||||
- x11: request bypassing compositor (issue #2502)
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.13.0..v0.14.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.13.0...v0.14.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.13.0..v0.14.0
|
||||
|
||||
|
||||
Release 0.13.0
|
||||
==============
|
||||
|
||||
NOTE: The previous release changed the default format for youtube-dl and
|
||||
removed some workarounds related to MPEG DASH support. However, the required
|
||||
changes to FFmpeg code (FFmpeg commit 4ab56667594842283dc5ae07f0daba2a2cb4d3af)
|
||||
are not in any FFmpeg release yet (as of 2015-11-10), so for now, playing DASH
|
||||
streams requires using FFmpeg git master. You can work around this by using the
|
||||
--ytdl-format=best option.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- SVG version of the icon (with symbolic counterpart)
|
||||
- stream_libarchive: add multivolume support
|
||||
- vo_opengl: add prescaling framework along with Super-xBR and NNEDI3 (currently very slow) prescalers (issue #2230)
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- command: add mistimed-frame-count property
|
||||
- vo_opengl: add vsync-fences option
|
||||
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- command: make display-fps property writable
|
||||
- options: enable mpeg2 hw decoding by default if hw decoding is requested
|
||||
- vo_opengl: rename fancy-downscaling to correct-downscaling
|
||||
- vo_opengl: correct-downscaling: enable also for anamorphic clips
|
||||
- vo_opengl: rename "drm_egl" to "drm-egl"
|
||||
- vo_opengl: disable drm-egl autopickup
|
||||
- vo_opengl: never load vaapi GLX interop by default
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- ao_alsa: fix 7.1 over HDMI
|
||||
- audio: do not require full audio chain reinit for speed changes
|
||||
- rpi: add support for codecs other than h264 (mpeg2 for now)
|
||||
- vd_lavc: make hwdec fallback more tolerant
|
||||
- video: fix playback of pal8
|
||||
- video: multiple display-sync fixes
|
||||
- vo: fix no-audio mode with interpolation enabled/display-sync disabled
|
||||
- vo_direct3d: fix operation (issue #2434)
|
||||
- vo_drm: handle possible errors from sigaction
|
||||
- vo_drm: show osd in audio only mode
|
||||
- vo_opengl: do not attempt to cache frames in FBO in dumb-mode (issue #2432)
|
||||
- vo_opengl: win32: always request MMCSS for DWM
|
||||
- vo_opengl: win32: try to enable DwmFlush by default
|
||||
- vo_vdpau: check VDP_RGBA_FORMAT_A8 support
|
||||
- win32: request MMCSS "Playback" profile
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.12.0..v0.13.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.12.0...v0.13.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.12.0..v0.13.0
|
||||
|
||||
|
||||
Release 0.12.0
|
||||
==============
|
||||
|
||||
NOTE: This release changes the default format for youtube-dl and removes some
|
||||
workarounds related to MPEG DASH support. However, the required changes to
|
||||
FFmpeg code are not in any FFmpeg release yet (as of 2015-10-29), so for now,
|
||||
playing DASH streams requires using FFmpeg git master. You can work around
|
||||
this by using the --ytdl-format=best option.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: support new VAAPI EGL interop (requires Mesa 11)
|
||||
- vo_opengl: vaapi: add Wayland support
|
||||
- bring back the x11 video output
|
||||
- vo_opengl: support all kinds of GBRP formats
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- video: remove VDA support (VideoToolbox is preferred)
|
||||
|
||||
Behavior
|
||||
--------
|
||||
|
||||
- vo_opengl: enable X11 EGL backend by default (disabled for NVIDIA due to driver bugs)
|
||||
- ytdl: don't override user-set format in no-video mode
|
||||
- sub: adjust behavior on mismatching video/subtitle aspect ratio
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- audio: add option for falling back to ao_null
|
||||
- options: add support for client certificate authentication
|
||||
- input: add key name for U+3000 IDEOGRAPHIC SPACE
|
||||
- player: add audio drop/duplicate mode to video-sync
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- vo_opengl: remove sharpen scalers, add sharpen sub-option
|
||||
- vo_opengl: make sw suboption work without explicit backend selection
|
||||
- command: make time properties unavailable if timestamp is unknown
|
||||
- command: do not return 0 for bitrate if unknown (make property unavailable instead)
|
||||
- vo_opengl: make the default debanding settings less excessive
|
||||
- ytdl: disable --all-subs if "sub-lang" is in raw-options
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- video: remove user-controllable PTS sorting (--pts-association-mode)
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- player: fix another --force-window bug
|
||||
- player: add wav to list of external audio file extensions
|
||||
- ao_alsa: fix failure to find any sample format
|
||||
- player: make stop command actually stop in all cases
|
||||
- audio: various fixes related to audio device hotplugging
|
||||
- vo_xv: fix crash with --wid
|
||||
- ytdl: Remove DASH hacks, use DASH by default
|
||||
- player: be slightly less prone to framedrop in display sync mode
|
||||
- sd_lavc: extend subtitle resolution if images go outside video frame
|
||||
- player: offset chapter display by start time
|
||||
- command: make bitrate properties work correctly for external tracks
|
||||
- w32_common: disable IME
|
||||
- player: fix display-sync A/V calculation on high playback speeds
|
||||
- player: fix display sync A/V difference estimation on drops
|
||||
- player: raise display sync desync tolerance
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.11.0..v0.12.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.11.0...v0.12.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.11.0..v0.12.0
|
||||
|
||||
|
||||
Release 0.11.0
|
||||
==============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
New
|
||||
~~~
|
||||
|
||||
- vo_opengl: implement debanding
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- audio/filter: remove center, extrastereo, karaoke, sinesuppress, sub,
|
||||
surround, sweep, ladspa, hrtf, export and bs2b filters (these are either
|
||||
considered useless or have replacements in lavfi)
|
||||
- video/filter: remove lavfi wrappers for noise, hqdn3d, unsharp and delogo
|
||||
(these filters remain usable through lavfi)
|
||||
|
||||
Behavior
|
||||
--------
|
||||
|
||||
- vo_opengl: require FBOs by default (use dumb-mode suboption for old hardware
|
||||
and broken drivers)
|
||||
- vo_opengl: enable debanding by default for the opengl-hq preset
|
||||
- audio/out: use new sample format determination code
|
||||
- player: prefer logical current directory path (affects logic for resuming
|
||||
playback)
|
||||
- vf_vdpaurb: Pass through non-hardware-decoded content
|
||||
- player: make force-window=immediate work in auto-profiles
|
||||
|
||||
|
||||
Options and Commands
|
||||
--------------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
- af_lavrresample: add normalize suboption
|
||||
- vo_opengl: add deband, deband-iterations, deband-threshold, deband-range and
|
||||
deband-grain suboptions
|
||||
- af_lavfi: implement af-metadata property (like vf-metadata)
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
- command: make "add <property> 0" not change the value
|
||||
|
||||
Removed
|
||||
~~~~~~~
|
||||
|
||||
- vo_opengl: remove source-shader suboption
|
||||
|
||||
|
||||
Fixes and Minor Enhancements
|
||||
----------------------------
|
||||
|
||||
- options: fix --no-config
|
||||
- cache: do not include backbuffer size in total stream cache size
|
||||
- audio/format: actually prefer float over double sample format for
|
||||
int->float conversions
|
||||
- audio/format: fix interlaved vs. non-interleaved conversions
|
||||
- audio/format: revise format conversion scoring
|
||||
- video: make --field-dominance set interlaced flag
|
||||
- vf: vf_stereo3d compilation depends on libavfilter
|
||||
- vf_yadif: add hack for Libav compatibility
|
||||
- player: add opus to list of external audio file extensions
|
||||
- build: allow disabling vapoursynth completely
|
||||
- libmpv/win32: allow multiple windows at the same time
|
||||
|
||||
|
||||
This listing is not complete. Check DOCS/client-api-changes.rst for a history
|
||||
of changes to the client API. A complete changelog can be seen by running
|
||||
`git log v0.10.0..v0.11.0` in the git repository or by visiting either
|
||||
https://github.com/mpv-player/mpv/compare/v0.10.0...v0.11.0 or
|
||||
http://git.srsfckn.biz/mpv/log/?qt=range&q=v0.10.0..v0.11.0
|
||||
|
||||
|
||||
Release 0.10.0
|
||||
==============
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ use warnings;
|
||||
# the exact contents of the original file.
|
||||
# FIXME: why not a char array?
|
||||
|
||||
# treat only alphanumeric and not-" punctuation as safe
|
||||
my $unsafe_chars = qr{[^][A-Za-z0-9!#%&'()*+,./:;<=>?^_{|}~ -]};
|
||||
# treat only alphanumeric and punctuations (excluding " and ?) as safe
|
||||
my $unsafe_chars = qr{[^][A-Za-z0-9!#%&'()*+,./:;<=>^_{|}~ -]};
|
||||
|
||||
for my $file (@ARGV) {
|
||||
open my $fh, '<:raw', $file or next;
|
||||
|
||||
Regular → Executable
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
conv() {
|
||||
echo
|
||||
identify -format "icon: %w %h" "$1"
|
||||
echo `identify -format "icon: %w %h" "$1"`
|
||||
convert "$1" -depth 8 rgba:-
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -95,18 +95,18 @@ case "$verdict" in
|
||||
exit 0
|
||||
;;
|
||||
interlaced-tff)
|
||||
judge "$@" --vf-clr --vf-pre=pullup --field-dominance=top
|
||||
judge "$@" --vf-clr --vf-pre=lavfi=\[setfield=tff\],pullup
|
||||
case "$verdict" in
|
||||
progressive)
|
||||
[ -n "$ILDETECT_DRY_RUN" ] || \
|
||||
$ILDETECT_MPV "$@" --vf-pre=pullup --field-dominance=top
|
||||
$ILDETECT_MPV "$@" --vf-pre=lavfi=\[setfield=tff\],pullup
|
||||
r=$?
|
||||
[ $r -eq 0 ] || exit $((r | 16))
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
[ -n "$ILDETECT_DRY_RUN" ] || \
|
||||
$ILDETECT_MPV "$@" --vf-pre=yadif --field-dominance=top
|
||||
$ILDETECT_MPV "$@" --vf-pre=lavfi=\[setfield=tff\],yadif
|
||||
r=$?
|
||||
[ $r -eq 0 ] || exit $((r | 16))
|
||||
exit 2
|
||||
@@ -114,18 +114,18 @@ case "$verdict" in
|
||||
esac
|
||||
;;
|
||||
interlaced-bff)
|
||||
judge "$@" --vf-clr --vf-pre=pullup --field-dominance=bottom
|
||||
judge "$@" --vf-clr --vf-pre=lavfi=\[setfield=bff\],pullup
|
||||
case "$verdict" in
|
||||
progressive)
|
||||
[ -n "$ILDETECT_DRY_RUN" ] || \
|
||||
$ILDETECT_MPV "$@" --vf-pre=pullup --field-dominance=bottom
|
||||
$ILDETECT_MPV "$@" --vf-pre=lavfi=\[setfield=bff\],pullup
|
||||
r=$?
|
||||
[ $r -eq 0 ] || exit $((r | 16))
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
[ -n "$ILDETECT_DRY_RUN" ] || \
|
||||
$ILDETECT_MPV "$@" --vf-pre=yadif --field-dominance=bottom
|
||||
$ILDETECT_MPV "$@" --vf-pre=lavfi=\[setfield=bff\],yadif
|
||||
r=$?
|
||||
[ $r -eq 0 ] || exit $((r | 16))
|
||||
exit 2
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
-- Handles the edge case where previous attempts to init audio have failed, but
|
||||
-- might start working due to a newly added device. This is required in
|
||||
-- particular for ao=wasapi, since the internal IMMNotificationClient code that
|
||||
-- normally triggers ao-reload will not be running in this case.
|
||||
|
||||
function do_reload()
|
||||
mp.command("ao-reload")
|
||||
reloading = nil
|
||||
end
|
||||
|
||||
function on_audio_device_list_change()
|
||||
if mp.get_property("current-ao") == "null" and not reloading then
|
||||
mp.msg.verbose("audio-device-list changed: reloading audio")
|
||||
-- avoid calling ao-reload too often
|
||||
reloading = mp.add_timeout(0.5, do_reload)
|
||||
end
|
||||
end
|
||||
|
||||
mp.set_property("options/audio-fallback-to-null", "yes")
|
||||
mp.observe_property("audio-device-list", "native", on_audio_device_list_change)
|
||||
+11
-1
@@ -30,7 +30,12 @@ function add_files_at(index, files)
|
||||
end
|
||||
|
||||
function get_extension(path)
|
||||
return string.match(path, "%.([^%.]+)$" )
|
||||
match = string.match(path, "%.([^%.]+)$" )
|
||||
if match == nil then
|
||||
return "nomatch"
|
||||
else
|
||||
return match
|
||||
end
|
||||
end
|
||||
|
||||
table.filter = function(t, iter)
|
||||
@@ -67,6 +72,11 @@ function find_and_add_entries()
|
||||
return EXTENSIONS[string.lower(ext)]
|
||||
end)
|
||||
table.sort(files, function (a, b)
|
||||
local len = string.len(a) - string.len(b)
|
||||
if len ~= 0 then -- case for ordering filename ending with such as X.Y.Z
|
||||
local ext = string.len(get_extension(a)) + 1
|
||||
return string.sub(a, 1, -ext) < string.sub(b, 1, -ext)
|
||||
end
|
||||
return string.lower(a) < string.lower(b)
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,999 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# Original version (C) 2000 Pontscho/fresh!mindworkz pontscho@makacs.poliod.hu
|
||||
# Cleanups all over the place (c) 2001 pl
|
||||
# Rewritten for mpv in 2014.
|
||||
#
|
||||
#
|
||||
# Warning: this is not officially supported. Use on your own risk. Might require
|
||||
# modifications when used on systems other than Linux. Contributors
|
||||
# are not expected to update these files when making changes to the
|
||||
# normal/preferred waf build system.
|
||||
#
|
||||
#
|
||||
# This configure script is *not* autoconf-based and has different semantics.
|
||||
# It attempts to autodetect all settings and options where possible. It is
|
||||
# possible to override autodetection with the --enable-option/--disable-option
|
||||
# command line parameters. --enable-option forces the option on skipping
|
||||
# autodetection. Yes, this means that compilation may fail and yes, this is not
|
||||
# how autoconf-based configure scripts behave.
|
||||
#
|
||||
# configure generates a series of configuration files:
|
||||
# - config.h contains #defines that are used in the C code.
|
||||
# - config.mak is included from the Makefiles.
|
||||
#
|
||||
# If you want to add a new check for $feature, look at the existing checks
|
||||
# and try to use helper functions where you can.
|
||||
#############################################################################
|
||||
|
||||
# Prevent locale nonsense from breaking basic text processing utils
|
||||
export LC_ALL=C
|
||||
|
||||
# Store the configure line that was used
|
||||
configuration="$*"
|
||||
|
||||
# Prefer these macros to full length text !
|
||||
# These macros only return an error code - NO display is done
|
||||
command_check() {
|
||||
echo >> "$TMPLOG"
|
||||
echo "$@" >> "$TMPLOG"
|
||||
"$@" >> "$TMPLOG" 2>&1
|
||||
TMPRES="$?"
|
||||
echo >> "$TMPLOG"
|
||||
return "$TMPRES"
|
||||
}
|
||||
|
||||
compile_check() {
|
||||
source="$1"
|
||||
shift
|
||||
echo >> "$TMPLOG"
|
||||
cat "$source" >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
echo "$_cc $OURCFLAGS $CFLAGS $source $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o $TMPEXE $@" >> "$TMPLOG"
|
||||
rm -f "$TMPEXE"
|
||||
$_cc $OURCFLAGS $CFLAGS "$source" $extra_cflags $_ld_static $extra_ldflags $libs_mplayer -o "$TMPEXE" $@ >> "$TMPLOG" 2>&1
|
||||
TMPRES="$?"
|
||||
echo >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
return "$TMPRES"
|
||||
}
|
||||
|
||||
cflag_check() {
|
||||
echo "int main(void) { return 0; }" > $TMPC
|
||||
compile_check $TMPC $@
|
||||
}
|
||||
|
||||
statement_check() {
|
||||
echo "" > $TMPC
|
||||
for _header in $1 ; do echo "#include <$_header>" >> $TMPC ; done
|
||||
echo "int main(void) { $2; return 0; }" >> $TMPC
|
||||
shift 2
|
||||
compile_check $TMPC $@
|
||||
}
|
||||
|
||||
pkg_config_add() {
|
||||
echo >> "$TMPLOG"
|
||||
echo "$_pkg_config --cflags $@" >> "$TMPLOG"
|
||||
ctmp=$($_pkg_config --cflags "$@" 2>> "$TMPLOG") || return $?
|
||||
echo >> "$TMPLOG"
|
||||
echo "$_pkg_config --libs $@" >> "$TMPLOG"
|
||||
ltmp=$($_pkg_config --libs "$@" 2>> "$TMPLOG") || return $?
|
||||
echo >> "$TMPLOG"
|
||||
echo "cflags: $ctmp" >> "$TMPLOG"
|
||||
echo "libs: $ltmp" >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
extra_cflags="$extra_cflags $ctmp"
|
||||
libs_mplayer="$libs_mplayer $ltmp"
|
||||
}
|
||||
|
||||
# Display error message, flushes tempfile, exit
|
||||
die () {
|
||||
echo
|
||||
echo "Error: $@" >&2
|
||||
echo >&2
|
||||
rm -f "$TMPEXE" "$TMPC"
|
||||
echo "Check \"$TMPLOG\" if you do not understand why it failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Use this before starting a check
|
||||
echocheck() {
|
||||
echo "============ Checking for $@ ============" >> "$TMPLOG"
|
||||
echo ${_echo_n} "Checking for $@ ... ${_echo_c}"
|
||||
}
|
||||
|
||||
# Use this to echo the results of a check
|
||||
echores() {
|
||||
test "$res_comment" && res_comment="($res_comment)"
|
||||
echo "Result is: $@ $res_comment" >> "$TMPLOG"
|
||||
echo "##########################################" >> "$TMPLOG"
|
||||
echo "" >> "$TMPLOG"
|
||||
echo "$@ $res_comment"
|
||||
res_comment=""
|
||||
}
|
||||
|
||||
# Check how echo works in this /bin/sh
|
||||
case $(echo -n) in
|
||||
-n) _echo_n= _echo_c='\c' ;; # SysV echo
|
||||
*) _echo_n='-n ' _echo_c= ;; # BSD echo
|
||||
esac
|
||||
|
||||
# setind $a b sets the variable named by the value of the variable a to b
|
||||
setind() { eval "$1=\"\$2\"" ; }
|
||||
|
||||
# Generate --enable-NAME/--disable-NAME options, set $1 to the option value.
|
||||
# Since shell has no data structures, do a weird statemachine thing.
|
||||
# Arguments: "_name"($1) "description"($2) "default"($3)
|
||||
# If "default"($3) is empty, use "auto"
|
||||
# Option name: a leading "_" in name is stripped, further "_" are changed to "-"
|
||||
opt_yes_no() {
|
||||
_name=$(echo "$1" | sed 's/^_//' | tr _ -)
|
||||
_defval="$3"
|
||||
test -z "$_defval" && _defval=auto
|
||||
|
||||
case "$_opt_state_mode" in
|
||||
init)
|
||||
setind "$1" "$_defval"
|
||||
;;
|
||||
help)
|
||||
if test "$_defval" = yes || test "$_defval" = auto ; then
|
||||
_defdesc=enable
|
||||
test "$_defval" = auto && _defdesc=auto
|
||||
printf " %-21s disable $2 [$_defdesc]\n" "--disable-$_name"
|
||||
unset _defdesc
|
||||
else
|
||||
printf " %-21s enable $2 [disable]\n" "--enable-$_name"
|
||||
fi
|
||||
;;
|
||||
parse)
|
||||
if test "$_opt_state_name" = "--enable-$_name" ; then
|
||||
setind "$1" yes
|
||||
_opt_state_known=yes
|
||||
elif test "$_opt_state_name" = "--disable-$_name" ; then
|
||||
setind "$1" no
|
||||
_opt_state_known=yes
|
||||
elif test "$_opt_state_name" = "--auto-$_name" ; then
|
||||
setind "$1" auto
|
||||
_opt_state_known=yes
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
unset _name
|
||||
unset _defval
|
||||
}
|
||||
|
||||
options_state_machine() {
|
||||
_opt_state_mode=$1
|
||||
_opt_state_name=$2
|
||||
_opt_state_known=no
|
||||
|
||||
opt_yes_no _gl "OpenGL video output"
|
||||
opt_yes_no _libguess "libguess"
|
||||
opt_yes_no _termios "termios database for key codes"
|
||||
opt_yes_no _iconv "iconv for encoding conversion"
|
||||
opt_yes_no _vm "X video mode extensions"
|
||||
opt_yes_no _dvb "DVB input"
|
||||
opt_yes_no _tv "TV interface (TV/DVB grabbers)" yes
|
||||
opt_yes_no _tv_v4l2 "Video4Linux2 TV interface"
|
||||
opt_yes_no _libv4l2 "libv4l2"
|
||||
opt_yes_no _pvr "Video4Linux2 MPEG PVR"
|
||||
opt_yes_no _smb "Samba (SMB) input"
|
||||
opt_yes_no _lcms2 "LCMS2 support"
|
||||
opt_yes_no _bluray "Blu-ray support"
|
||||
opt_yes_no _dvdread "libdvdread"
|
||||
opt_yes_no _dvdnav "libdvdnav"
|
||||
opt_yes_no _enca "ENCA charset oracle library"
|
||||
opt_yes_no _uchardet "uchardet charset detection library"
|
||||
opt_yes_no _libass "subtitle rendering with libass"
|
||||
opt_yes_no _libavdevice "libavdevice demuxers"
|
||||
opt_yes_no _libavfilter "libavfilter"
|
||||
opt_yes_no _jpeg "support for writing JPEG screenshots"
|
||||
opt_yes_no _libcdio "libcdio support"
|
||||
opt_yes_no _librubberband "librubberband support"
|
||||
opt_yes_no _ffmpeg "skip FFmpeg/Libav autodetection"
|
||||
opt_yes_no _ladspa "LADSPA plugin support"
|
||||
opt_yes_no _libbs2b "libbs2b audio filter support"
|
||||
opt_yes_no _libavresample "libavresample (preferred over libswresample)"
|
||||
opt_yes_no _libswresample "libswresample"
|
||||
opt_yes_no _caca "CACA video output"
|
||||
opt_yes_no _sdl2 "SDL2 video and audio outputs" no
|
||||
opt_yes_no _xv "Xv video output"
|
||||
opt_yes_no _vdpau "VDPAU acceleration"
|
||||
opt_yes_no _vaapi "VAAPI acceleration"
|
||||
opt_yes_no _xrandr "Xrandr support (used for monitor FPS detection)"
|
||||
opt_yes_no _xinerama "Xinerama support"
|
||||
opt_yes_no _x11 "X11 video output"
|
||||
opt_yes_no _wayland "Wayland video output"
|
||||
opt_yes_no _xss "support for disabling screensaver via xss"
|
||||
opt_yes_no _alsa "ALSA audio output"
|
||||
opt_yes_no _ossaudio "OSS audio output"
|
||||
opt_yes_no _rsound "RSound audio output"
|
||||
opt_yes_no _sndio "sndio audio output"
|
||||
opt_yes_no _pulse "Pulseaudio audio output"
|
||||
opt_yes_no _jack "JACK audio output"
|
||||
opt_yes_no _openal "OpenAL audio output"
|
||||
opt_yes_no _shm "X11/Xv shared memory"
|
||||
opt_yes_no _lua "Lua scripting"
|
||||
opt_yes_no _vapoursynth "VapourSynth filter bridge (Python)"
|
||||
opt_yes_no _vapoursynth_lazy "VapourSynth filter bridge (Lua)"
|
||||
opt_yes_no _libarchive "libarchive"
|
||||
opt_yes_no _encoding "encoding functionality" yes
|
||||
opt_yes_no _build_man "building manpage"
|
||||
}
|
||||
|
||||
show_help(){
|
||||
cat << EOF
|
||||
Usage: $0 [OPTIONS]...
|
||||
|
||||
Configuration:
|
||||
-h, --help display this help and exit
|
||||
|
||||
Installation directories:
|
||||
--prefix=DIR prefix directory for installation [/usr/local]
|
||||
--bindir=DIR directory for installing binaries [PREFIX/bin]
|
||||
--datadir=DIR directory for installing machine independent
|
||||
data files (skins, etc) [PREFIX/share/mpv]
|
||||
--mandir=DIR directory for installing man pages [PREFIX/share/man]
|
||||
--confdir=DIR directory for installing configuration files
|
||||
[PREFIX/etc/mpv]
|
||||
|
||||
Compilation options:
|
||||
--cc=COMPILER C compiler to build mpv [gcc]
|
||||
--pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config]
|
||||
--enable-static build a statically linked binary
|
||||
--disable-debug compile-in debugging information [enable]
|
||||
--disable-optimization compile without -O2 [enable]
|
||||
|
||||
Use these options if autodetection fails:
|
||||
--extra-cflags=FLAGS extra CFLAGS
|
||||
--extra-ldflags=FLAGS extra LDFLAGS
|
||||
--extra-libs=FLAGS extra linker flags
|
||||
|
||||
Features:
|
||||
EOF
|
||||
options_state_machine help
|
||||
cat << EOF
|
||||
|
||||
This configure script is NOT autoconf-based, even though its output is similar.
|
||||
It will try to autodetect all configuration options. If you --enable an option
|
||||
it will be forcefully turned on, skipping autodetection. This can break
|
||||
compilation, so you need to know what you are doing.
|
||||
EOF
|
||||
exit 0
|
||||
} #show_help()
|
||||
|
||||
# GOTCHA: the variables below defines the default behavior for autodetection
|
||||
# and have - unless stated otherwise - at least 2 states : yes no
|
||||
# If autodetection is available then the third state is: auto
|
||||
_pkg_config=auto
|
||||
_cc=auto
|
||||
test -n "$CC" && _cc="$CC"
|
||||
_opt=-O2
|
||||
_prefix="/usr/local"
|
||||
options_state_machine init
|
||||
for ac_option do
|
||||
case "$ac_option" in
|
||||
--help|-help|-h)
|
||||
show_help
|
||||
;;
|
||||
--prefix=*)
|
||||
_prefix=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--bindir=*)
|
||||
_bindir=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--mandir=*)
|
||||
_mandir=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--confdir=*)
|
||||
_confdir=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--extra-cflags=*)
|
||||
extra_cflags="$extra_cflags $(echo $ac_option | cut -d '=' -f 2-)"
|
||||
;;
|
||||
--extra-ldflags=*)
|
||||
extra_ldflags="$extra_ldflags $(echo $ac_option | cut -d '=' -f 2-)"
|
||||
;;
|
||||
--extra-libs=*)
|
||||
libs_mplayer=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--cc=*)
|
||||
_cc=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--pkg-config=*)
|
||||
_pkg_config=$(echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--enable-static)
|
||||
_ld_static='-static'
|
||||
;;
|
||||
--disable-static)
|
||||
_ld_static=''
|
||||
;;
|
||||
--enable-optimization)
|
||||
_opt='-O2'
|
||||
;;
|
||||
--enable-optimization=*)
|
||||
_opt=$(echo $_echo_n '-O'$_echo_c; echo $ac_option | cut -d '=' -f 2)
|
||||
;;
|
||||
--disable-optimization)
|
||||
_opt=
|
||||
;;
|
||||
*)
|
||||
options_state_machine parse "$ac_option"
|
||||
if test "$_opt_state_known" != yes ; then
|
||||
echo "Unknown parameter: $ac_option" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$_bindir" && _bindir="$_prefix/bin"
|
||||
test -z "$_mandir" && _mandir="$_prefix/share/man"
|
||||
test -z "$_confdir" && _confdir="$_prefix/etc/mpv"
|
||||
|
||||
mplayer_tmpdir=$(mktemp -d -p ${TMPDIR:=/tmp} mpv-configure-XXXXXX)
|
||||
test -n "$mplayer_tmpdir" || die "Unable to create tmpdir."
|
||||
trap 'rm -rf "$mplayer_tmpdir"' EXIT
|
||||
|
||||
mkdir old_build 2> /dev/null
|
||||
|
||||
TMPLOG="old_build/config.log"
|
||||
|
||||
rm -f "$TMPLOG"
|
||||
echo Parameters configure was run with: > "$TMPLOG"
|
||||
echo CFLAGS="'$CFLAGS'" PKG_CONFIG_PATH="'$PKG_CONFIG_PATH'" ./configure $configuration >> "$TMPLOG"
|
||||
echo >> "$TMPLOG"
|
||||
|
||||
TMPC="$mplayer_tmpdir/tmp.c"
|
||||
TMPEXE="$mplayer_tmpdir/tmp"
|
||||
CONFIG_MAK="$mplayer_tmpdir/config.mak"
|
||||
CONFIG_H="$mplayer_tmpdir/config.h"
|
||||
|
||||
echo > $CONFIG_MAK
|
||||
echo > $CONFIG_H
|
||||
|
||||
test "$_pkg_config" = auto && _pkg_config=pkg-config
|
||||
test "$_cc" = auto && _cc=cc
|
||||
|
||||
extra_cflags="-I. -D_GNU_SOURCE $extra_cflags"
|
||||
|
||||
_rst2man=rst2man
|
||||
test -f "$(which rst2man.py)" && _rst2man=rst2man.py
|
||||
|
||||
echocheck "whether to build manpages with rst2man"
|
||||
if test "$_build_man" = auto ; then
|
||||
_build_man=no
|
||||
command_check "$_rst2man" --version && _build_man=yes
|
||||
fi
|
||||
echores "$_build_man"
|
||||
|
||||
echocheck "working compiler"
|
||||
cflag_check "" || die "Compiler is not functioning correctly. Check your installation and custom CFLAGS $CFLAGS ."
|
||||
echores "yes"
|
||||
|
||||
echocheck "perl"
|
||||
command_check perl -Mv5.8 -e';' || die "Perl is not functioning correctly or is ancient. Install the latest perl available."
|
||||
echores yes
|
||||
|
||||
echocheck "compiler support of -pipe option"
|
||||
cflag_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no"
|
||||
|
||||
addcflags() { cflag_check "$@" && OURCFLAGS="$OURCFLAGS $@" ; }
|
||||
|
||||
OURCFLAGS="-std=c99 -Wall $_opt"
|
||||
|
||||
addcflags -g -g3 -ggdb
|
||||
addcflags -Wundef -Wmissing-prototypes -Wshadow -Wno-switch -Wparentheses -Wpointer-arith -Wno-redundant-decls -Wno-pointer-sign -Werror=implicit-function-declaration -Wno-error=deprecated-declarations -Wno-error=unused-function
|
||||
# clang
|
||||
addcflags -Wno-logical-op-parentheses -fcolor-diagnostics -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare
|
||||
# extra
|
||||
addcflags -Wno-format-zero-length -Wempty-body -Wdisabled-optimization -Wstrict-prototypes
|
||||
|
||||
cflag_check -MD -MP && DEPFLAGS="-MD -MP"
|
||||
cflag_check -lm && _ld_lm="-lm"
|
||||
|
||||
extra_ldflags="$extra_ldflags $LDFLAGS"
|
||||
extra_cflags="$extra_cflags $CPPFLAGS"
|
||||
|
||||
# If $1 is "yes", define $2 as 1 in config.h, else define it as 0
|
||||
define_yes_no() {
|
||||
if test "$1" = yes ; then
|
||||
echo "#define $2 1" >> $CONFIG_H
|
||||
else
|
||||
echo "#define $2 0" >> $CONFIG_H
|
||||
fi
|
||||
}
|
||||
|
||||
# Write the results of a check to config.mak/.h.
|
||||
# Arguments: "yes/no"($1) "name"($2)
|
||||
check_yes_no() {
|
||||
define_yes_no $1 "HAVE_$2"
|
||||
echo "$2 = $1" >> $CONFIG_MAK
|
||||
}
|
||||
|
||||
check_trivial() {
|
||||
echocheck "$1"
|
||||
check_yes_no $2 $3
|
||||
echores "$2"
|
||||
}
|
||||
|
||||
# Arguments: "message"($1) "setting"($2) "name"($3) "code"($4)
|
||||
# Also, $5 - $N can be libraries needed - it'll try each separately.
|
||||
# Use " " as first entry if you want to try with no libraries too.
|
||||
check_compile() {
|
||||
_res="$2"
|
||||
_name="$3"
|
||||
_code="$4"
|
||||
echocheck "$1"
|
||||
if test $_res = auto ; then
|
||||
_res=no
|
||||
if test $# -gt 4 ; then
|
||||
shift 4
|
||||
else
|
||||
shift $#
|
||||
fi
|
||||
while true ; do
|
||||
compile_check "$_code" "$1" && libs_mplayer="$libs_mplayer $1" && _res=yes && break
|
||||
test -z "$1" && break
|
||||
shift
|
||||
done
|
||||
fi
|
||||
check_yes_no $_res $_name
|
||||
echores $_res
|
||||
test $_res = yes && return 0 || return 1
|
||||
}
|
||||
|
||||
# Arguments: "message"($1) "setting"($2) "name"($3) "include"($4) "statement"($5)
|
||||
# Also, $6 - $N can be libraries needed - it'll try each separately.
|
||||
# Use " " as first entry if you want to try with no libraries too.
|
||||
check_statement_libs() {
|
||||
_res="$2"
|
||||
_name="$3"
|
||||
_inc="$4"
|
||||
_st="$5"
|
||||
echocheck "$1"
|
||||
if test $_res = auto ; then
|
||||
_res=no
|
||||
if test $# -gt 5 ; then
|
||||
shift 5
|
||||
else
|
||||
shift $#
|
||||
fi
|
||||
while true ; do
|
||||
statement_check "$_inc" "$_st" "$1" && libs_mplayer="$libs_mplayer $1" && _res=yes && break
|
||||
test -z "$1" && break
|
||||
shift
|
||||
done
|
||||
fi
|
||||
check_yes_no $_res $_name
|
||||
echores $_res
|
||||
test $_res = yes && return 0 || return 1
|
||||
}
|
||||
|
||||
# Print "yes" if previous command succeeded, else "no"
|
||||
defretval() { # shell is retarded?
|
||||
if test $? = 0 ; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
}
|
||||
|
||||
echocheck "dynamic loader"
|
||||
_dl=no
|
||||
for _ld_tmp in "" "-ldl"; do
|
||||
statement_check dlfcn.h 'dlopen("", 0)' $_ld_tmp && _ld_dl="$_ld_tmp" && _dl=yes && break
|
||||
done
|
||||
define_yes_no $_dl HAVE_LIBDL
|
||||
echores "$_dl"
|
||||
|
||||
echocheck "pthread"
|
||||
cflag_check -pthread && _ld_pthread="$_ld_pthread -pthread"
|
||||
cflag_check -lpthread && _ld_pthread="$_ld_pthread -lpthread"
|
||||
cflag_check -lrt && _ld_pthread="$_ld_pthread -lrt"
|
||||
extra_cflags="$extra_cflags -D_REENTRANT -D_THREAD_SAFE"
|
||||
compile_check waftools/fragments/pthreads.c "$_ld_pthread" || die "Unable to find pthreads support."
|
||||
echores "yes"
|
||||
|
||||
check_statement_libs "support for stdatomic.h" auto STDATOMIC \
|
||||
stdatomic.h 'atomic_int_least64_t test = ATOMIC_VAR_INIT(123); int test2 = atomic_load(&test)' \
|
||||
" " "-latomic"
|
||||
_stdatomic=$(defretval)
|
||||
|
||||
_atomic=auto
|
||||
test "$_stdatomic" = yes && _atomic=no
|
||||
check_statement_libs "compiler support for __atomic built-ins" $_atomic ATOMIC_BUILTINS \
|
||||
stdint.h 'int64_t test = 0; test = __atomic_add_fetch(&test, 1, __ATOMIC_SEQ_CST)' \
|
||||
" " "-latomic"
|
||||
_atomic=$(defretval)
|
||||
|
||||
_sync=auto
|
||||
(test "$_atomic" = yes || test "$_stdatomic" = yes ) && _sync=no
|
||||
check_statement_libs "compiler support for __sync built-ins" $_sync SYNC_BUILTINS \
|
||||
stdint.h 'int64_t test = 0; test = __sync_add_and_fetch(&test, 1)'
|
||||
_sync=$(defretval)
|
||||
|
||||
_any_atomic=yes
|
||||
if test "$_atomic" = no && test "$_sync" = no && test "$_stdatomic" = no ; then
|
||||
echo "your compiler must support either stdatomic.h, or __atomic, or __sync built-ins."
|
||||
_any_atomic=no
|
||||
fi
|
||||
define_yes_no $_any_atomic HAVE_ATOMICS
|
||||
|
||||
check_compile "iconv" $_iconv ICONV waftools/fragments/iconv.c " " "-liconv" "-liconv $_ld_dl"
|
||||
_iconv=$(defretval)
|
||||
if test "$_iconv" != yes ; then
|
||||
die "Unable to find iconv which should be part of standard compilation environment. Aborting. If you really mean to compile without iconv support use --disable-iconv."
|
||||
fi
|
||||
|
||||
_soundcard_header=sys/soundcard.h
|
||||
_check_snd=yes
|
||||
check_statement_libs "sys/soundcard.h" auto SYS_SOUNDCARD_H sys/soundcard.h
|
||||
test $(defretval) = yes && _soundcard_header=sys/soundcard.h && _check_snd=no
|
||||
check_statement_libs "soundcard.h" $_check_snd SOUNDCARD_H soundcard.h
|
||||
test $(defretval) = yes && _soundcard_header=soundcard.h
|
||||
|
||||
check_statement_libs "sys/videoio.h" auto SYS_VIDEOIO_H sys/videoio.h
|
||||
|
||||
_termios_ok=no
|
||||
check_statement_libs "termios.h" $_termios TERMIOS_H termios.h
|
||||
test $(defretval) = yes && _termios_ok=yes && _termios=no
|
||||
check_statement_libs "sys/termios.h" $_termios SYS_TERMIOS_H 'sys/termios.h'
|
||||
test $(defretval) = yes && _termios_ok=yes
|
||||
define_yes_no $_termios_ok HAVE_TERMIOS
|
||||
|
||||
check_statement_libs "shm" $_shm SHM "sys/types.h sys/ipc.h sys/shm.h" \
|
||||
"shmget(0, 0, 0); shmat(0, 0, 0); shmctl(0, 0, 0);"
|
||||
|
||||
echocheck "pkg-config"
|
||||
if $($_pkg_config --version > /dev/null 2>&1); then
|
||||
if test "$_ld_static"; then
|
||||
_pkg_config="$_pkg_config --static"
|
||||
fi
|
||||
echores "yes"
|
||||
else
|
||||
_pkg_config=false
|
||||
echores "no"
|
||||
fi
|
||||
|
||||
# Arguments: "message"($1) "setting"($2) "name"($3) "pkg-config string"($4)
|
||||
# The name will be used as "#define HAVE_$name 1/0" in config.h, and as
|
||||
# "$name = yes/no" in config.mak
|
||||
# "setting"($2) is yes/no/auto and represents the --enable/--disable option
|
||||
check_pkg_config() {
|
||||
echocheck "$1"
|
||||
_res=$2
|
||||
if test "$2" = auto ; then
|
||||
_res=no
|
||||
if pkg_config_add "$4" ; then
|
||||
_res=yes
|
||||
fi
|
||||
fi
|
||||
check_yes_no $_res $3
|
||||
echores "$_res"
|
||||
test $_res = yes && return 0 || return 1
|
||||
}
|
||||
|
||||
check_pkg_config "libguess support" $_libguess LIBGUESS 'libguess >= 1.0'
|
||||
|
||||
check_pkg_config "Samba support (libsmbclient)" $_smb LIBSMBCLIENT 'smbclient >= 0.2.0'
|
||||
|
||||
_wlver="1.6.0"
|
||||
check_pkg_config "Wayland" $_wayland WAYLAND "wayland-client >= $_wlver wayland-cursor >= $_wlver xkbcommon >= 0.3.0"
|
||||
_wayland=$(defretval)
|
||||
|
||||
check_pkg_config "X11" $_x11 X11 "x11"
|
||||
_x11=$(defretval)
|
||||
|
||||
# Disable X11 dependencies
|
||||
_xext=auto
|
||||
if test "$_x11" = no ; then
|
||||
_xss=no
|
||||
_xext=no
|
||||
_xv=no
|
||||
_vdpau=no
|
||||
_vaapi=no
|
||||
_xinerama=no
|
||||
_vm=no
|
||||
fi
|
||||
|
||||
check_pkg_config "Xss screensaver extensions" $_xss XSS "xscrnsaver"
|
||||
|
||||
check_pkg_config "X extensions" $_xext XEXT "xext"
|
||||
|
||||
check_pkg_config "Xv" $_xv XV "xv"
|
||||
|
||||
check_pkg_config "VDPAU" $_vdpau VDPAU "vdpau >= 0.2"
|
||||
_vdpau=$(defretval)
|
||||
define_yes_no $_vdpau HAVE_VDPAU_HWACCEL
|
||||
|
||||
check_pkg_config "VAAPI" $_vaapi VAAPI 'libva >= 0.32.0 libva-x11 >= 0.32.0'
|
||||
_vaapi=$(defretval)
|
||||
define_yes_no $_vaapi HAVE_VAAPI_HWACCEL
|
||||
|
||||
if test "$_vaapi" = yes ; then
|
||||
check_pkg_config "VAAPI VPP" auto VAAPI_VPP 'libva >= 0.34.0'
|
||||
else
|
||||
check_yes_no no VAAPI_VPP
|
||||
fi
|
||||
|
||||
check_pkg_config "Xinerama" $_xinerama XINERAMA 'xinerama'
|
||||
|
||||
check_pkg_config "Xrandr" $_xrandr XRANDR 'xrandr >= 1.2.0'
|
||||
|
||||
check_pkg_config "CACA" $_caca CACA 'caca >= 0.99.beta18'
|
||||
|
||||
check_compile "DVB" $_dvb DVB waftools/fragments/dvb.c
|
||||
_dvbin=$(defretval)
|
||||
check_yes_no $_dvbin DVBIN
|
||||
|
||||
check_statement_libs "JPEG support" $_jpeg JPEG "stdio.h jpeglib.h" "" "-ljpeg $_ld_lm"
|
||||
|
||||
_gl_x11_egl=no
|
||||
(test "$_x11" = no && test "$_wayland" = no) && _gl=no
|
||||
echocheck "OpenGL"
|
||||
#Note: this test is run even with --enable-gl since we autodetect linker flags
|
||||
if test "$_gl" != no ; then
|
||||
cat > $TMPC << EOF
|
||||
#if defined(GL_WAYLAND) || defined(EGL_X11)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
#if defined(GL_WAYLAND)
|
||||
eglCreateContext(NULL, NULL, EGL_NO_CONTEXT, NULL);
|
||||
#else
|
||||
glXCreateContext(NULL, NULL, NULL, True);
|
||||
#endif
|
||||
glFinish();
|
||||
return !GL_INVALID_FRAMEBUFFER_OPERATION; // check correct glext.h
|
||||
}
|
||||
EOF
|
||||
_gl=no
|
||||
if test "$_x11" = yes ; then
|
||||
for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do
|
||||
if compile_check $TMPC $_ld_tmp $_ld_lm ; then
|
||||
_gl=yes
|
||||
_gl_x11=yes
|
||||
libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl"
|
||||
test "$_gl_x11" = yes && res_comment="$res_comment x11"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if test "$_wayland" = yes && compile_check $TMPC -DGL_WAYLAND -lGL -lEGL &&
|
||||
pkg_config_add "wayland-egl >= 9.0.0"; then
|
||||
_gl=yes
|
||||
_gl_wayland=yes
|
||||
libs_mplayer="$libs_mplayer -lGL -lEGL"
|
||||
test "$_gl_wayland" = yes && res_comment="$res_comment wayland"
|
||||
else
|
||||
_gl_wayland=no
|
||||
fi
|
||||
if test "$_x11" = yes && test "$_gl" = yes && pkg_config_add "egl"; then
|
||||
_gl_x11_egl=yes
|
||||
res_comment="$res_comment x11egl"
|
||||
fi
|
||||
else
|
||||
_gl=no
|
||||
fi
|
||||
|
||||
if test "$_gl" = no ; then
|
||||
_gl_x11=no
|
||||
_gl_wayland=no
|
||||
_gl_x11_egl=no
|
||||
fi
|
||||
check_yes_no $_gl GL
|
||||
check_yes_no $_gl_x11 GL_X11
|
||||
check_yes_no $_gl_x11_egl EGL_X11
|
||||
check_yes_no $_gl_wayland GL_WAYLAND
|
||||
echores "$_gl"
|
||||
|
||||
echocheck "VDPAU with OpenGL/X11"
|
||||
_vdpau_gl_x11=no
|
||||
(test "$_gl_x11" = yes && test "$_vdpau" = yes) && _vdpau_gl_x11=yes
|
||||
check_yes_no $_vdpau_gl_x11 VDPAU_GL_X11
|
||||
echores "$_vdpau_gl_x11"
|
||||
|
||||
_vaapi_glx=no
|
||||
(test "$_gl_x11" = yes && test "$_vaapi" = yes) && _vaapi_glx=auto
|
||||
check_pkg_config "VAAPI with OpenGL/X11" $_vaapi_glx VAAPI_GLX 'libva-glx >= 0.32.0'
|
||||
|
||||
check_pkg_config "SDL 2.0" $_sdl2 SDL2 'sdl2'
|
||||
|
||||
check_statement_libs "OSS Audio" $_ossaudio OSS_AUDIO $_soundcard_header "int x = SNDCTL_DSP_SETFRAGMENT;"
|
||||
|
||||
check_statement_libs "RSound" $_rsound RSOUND rsound.h 'rsd_init(NULL);' -lrsound
|
||||
|
||||
check_statement_libs "sndio" $_sndio SNDIO sndio.h 'struct sio_par par; sio_initpar(&par); const char *s = SIO_DEVANY' -lsndio
|
||||
|
||||
check_pkg_config "PulseAudio" $_pulse PULSE 'libpulse >= 1.0'
|
||||
|
||||
check_pkg_config "JACK" $_jack JACK 'jack'
|
||||
|
||||
check_pkg_config "OpenAL" $_openal OPENAL 'openal >= 1.13'
|
||||
|
||||
check_pkg_config "ALSA audio" $_alsa ALSA 'alsa >= 1.0.9'
|
||||
|
||||
check_pkg_config "Blu-ray support" $_bluray LIBBLURAY 'libbluray >= 0.3.0'
|
||||
|
||||
check_pkg_config "dvdread" $_dvdread DVDREAD 'dvdread >= 4.1.0'
|
||||
|
||||
check_pkg_config "dvdnav" $_dvdnav DVDNAV 'dvdnav >= 4.2.0'
|
||||
|
||||
check_pkg_config "libcdio" $_libcdio CDDA 'libcdio_paranoia'
|
||||
|
||||
check_pkg_config "rubberband" $_librubberband RUBBERBAND 'rubberband'
|
||||
|
||||
_oldass=$_libass
|
||||
check_pkg_config "SSA/ASS support" $_libass LIBASS 'libass'
|
||||
_libass=$(defretval)
|
||||
if test $_oldass != no && test $_libass = no ; then
|
||||
die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass."
|
||||
fi
|
||||
|
||||
_dummy_osd=yes
|
||||
test $_libass = yes && _dummy_osd=no
|
||||
echo "LIBASS_OSD = $_libass" >> $CONFIG_MAK
|
||||
echo "DUMMY_OSD = $_dummy_osd" >> $CONFIG_MAK
|
||||
|
||||
check_pkg_config "ENCA" $_enca ENCA 'enca'
|
||||
check_pkg_config "uchardet" $_uchardet UCHARDET 'uchardet'
|
||||
|
||||
check_pkg_config "zlib" auto ZLIB 'zlib'
|
||||
test $(defretval) = no && die "Unable to find development files for zlib."
|
||||
|
||||
test "$_dl" = no && _ladspa=no
|
||||
check_statement_libs "LADSPA plugin support" $_ladspa LADSPA ladspa.h 'LADSPA_Descriptor ld = {0}'
|
||||
|
||||
check_pkg_config "libbs2b audio filter support" $_libbs2b LIBBS2B 'libbs2b'
|
||||
|
||||
check_pkg_config "LCMS2 support" $_lcms2 LCMS2 'lcms2 >= 2.6'
|
||||
|
||||
check_pkg_config "FFmpeg/Libav" $_ffmpeg FFMPEG \
|
||||
"libavutil >= 54.02.0 libavcodec >= 56.1.0 libavformat >= 56.01.0 libswscale >= 2.1.3"
|
||||
test $(defretval) = no && die "Unable to find development files for some of the required Libav libraries above. Aborting."
|
||||
|
||||
check_pkg_config "Libswresample" $_libswresample LIBSWRESAMPLE 'libswresample >= 1.1.100'
|
||||
_libswresample=$(defretval)
|
||||
|
||||
_libavresample=auto
|
||||
test $_libswresample = yes && _libavresample=no
|
||||
check_pkg_config "Libavresample" $_libavresample LIBAVRESAMPLE 'libavresample >= 2.1.0'
|
||||
_libavresample=$(defretval)
|
||||
|
||||
if test "$_libswresample" = no && test "$_libavresample" = no ; then
|
||||
die "No resampler found. Install libavresample or libswresample (FFmpeg)."
|
||||
fi
|
||||
|
||||
# Arguments: "message"($1) "define"($2) "header"($3) "code"($4)
|
||||
api_statement_check() {
|
||||
echocheck "$1"
|
||||
_res=no
|
||||
statement_check "$3" "$4" && _res=yes
|
||||
define_yes_no $_res "$2"
|
||||
echores "$_res"
|
||||
}
|
||||
|
||||
api_statement_check \
|
||||
"libavcodec avcodec_enum_to_chroma_pos API" \
|
||||
HAVE_AVCODEC_CHROMA_POS_API \
|
||||
libavcodec/avcodec.h \
|
||||
'int x, y; avcodec_enum_to_chroma_pos(&x, &y, AVCHROMA_LOC_UNSPECIFIED)'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil AVFrame metadata" \
|
||||
HAVE_AVFRAME_METADATA \
|
||||
libavutil/frame.h \
|
||||
'av_frame_get_metadata(NULL)'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil AVFrame skip samples metadata" \
|
||||
HAVE_AVFRAME_SKIP_SAMPLES \
|
||||
libavutil/frame.h \
|
||||
'enum AVFrameSideDataType type = AV_FRAME_DATA_SKIP_SAMPLES'
|
||||
|
||||
api_statement_check \
|
||||
"libavutil av_version_info()" \
|
||||
HAVE_AV_VERSION_INFO \
|
||||
libavutil/avutil.h \
|
||||
'const char *x = av_version_info()'
|
||||
|
||||
check_pkg_config "libavfilter" $_libavfilter LIBAVFILTER 'libavfilter >= 5.0.0'
|
||||
|
||||
check_pkg_config "libavdevice" $_libavdevice LIBAVDEVICE 'libavdevice >= 55.0.0'
|
||||
|
||||
check_trivial "TV interface" $_tv TV
|
||||
|
||||
check_statement_libs "Video 4 Linux 2 TV interface" $_tv_v4l2 TV_V4L2 \
|
||||
"sys/time.h linux/videodev2.h"
|
||||
_tv_v4l2=$(defretval)
|
||||
check_trivial "TV audio input" $_tv_v4l2 AUDIO_INPUT
|
||||
|
||||
test $_tv_v4l2 = no && _libv4l2=no
|
||||
check_pkg_config "libv4l2 support" $_libv4l2 LIBV4L2 'libv4l2'
|
||||
|
||||
test "$_tv_v4l2" = no && _pvr=no
|
||||
check_compile "Video 4 Linux 2 MPEG PVR interface" $_pvr PVR waftools/fragments/pvr.c
|
||||
|
||||
# Note: Lua has no official .pc file, so there are different OS-specific ones.
|
||||
# Also, we support luajit, which is compatible to 5.1.
|
||||
|
||||
test_lua() {
|
||||
if test "$_lua" = auto && $_pkg_config "$1" ; then
|
||||
check_pkg_config "Lua ($1)" $_lua LUA "$1"
|
||||
_lua=$(defretval)
|
||||
fi
|
||||
}
|
||||
|
||||
test_lua "lua >= 5.1.0 lua < 5.2.0"
|
||||
test_lua "lua5.1 >= 5.1.0" # debian
|
||||
test_lua "lua51 >= 5.1.0" # OpenBSD
|
||||
test_lua "luajit >= 2.0.0"
|
||||
test_lua "lua5.2 >= 5.2.0" # debian
|
||||
test_lua "lua52 >= 5.2.0" # OpenBSD
|
||||
test_lua "lua >= 5.2.0"
|
||||
|
||||
test "$_lua" != yes && check_yes_no no LUA
|
||||
|
||||
if ! ( $_pkg_config 'vapoursynth >= 24' ) ; then
|
||||
_vapoursynth=no
|
||||
_vapoursynth_lazy=no
|
||||
fi
|
||||
check_pkg_config "VapourSynth support (Python)" $_vapoursynth VAPOURSYNTH 'vapoursynth >= 23 vapoursynth-script >= 23'
|
||||
_vapoursynth=$(defretval)
|
||||
if test "$_lua" = no ; then
|
||||
_vapoursynth_lazy=no
|
||||
fi
|
||||
check_pkg_config "VapourSynth support (Lua)" $_vapoursynth_lazy VAPOURSYNTH_LAZY 'vapoursynth >= 23'
|
||||
_vapoursynth_lazy=$(defretval)
|
||||
|
||||
_vapoursynth_core=yes
|
||||
if test "$_vapoursynth" = no && test "$_vapoursynth_lazy" = no ; then
|
||||
_vapoursynth_core=no
|
||||
fi
|
||||
check_trivial "VapourSynth core" $_vapoursynth_core VAPOURSYNTH_CORE
|
||||
|
||||
check_pkg_config "libarchive support" $_libarchive LIBARCHIVE 'libarchive >= 3.0.0'
|
||||
|
||||
check_trivial "encoding" $_encoding ENCODING
|
||||
|
||||
# needs dlopen on unix
|
||||
_dlopen="$_dl"
|
||||
check_yes_no $_dlopen DLOPEN
|
||||
|
||||
extra_ldflags="$extra_ldflags $_ld_pthread"
|
||||
libs_mplayer="$libs_mplayer $_ld_dl"
|
||||
|
||||
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"
|
||||
|
||||
# This is done so waf builds won't conflict with this. In fact, waf and old
|
||||
# build system can coexist in parallel, at the same time. This is because
|
||||
# waf always does out-of-tree builds, while this build system does always
|
||||
# in-tree builds.
|
||||
|
||||
if test ! -f Makefile ; then
|
||||
ln -s TOOLS/old-makefile Makefile
|
||||
fi
|
||||
|
||||
cat > old_build/config.mak << EOF
|
||||
# -------- Generated by configure -----------
|
||||
export LC_ALL = C
|
||||
|
||||
CONFIGURATION = $configuration
|
||||
|
||||
prefix = \$(DESTDIR)$_prefix
|
||||
BINDIR = \$(DESTDIR)$_bindir
|
||||
MANDIR = \$(DESTDIR)$_mandir
|
||||
CONFDIR = \$(DESTDIR)$_confdir
|
||||
|
||||
CC = $_cc
|
||||
INSTALL = install
|
||||
|
||||
CFLAGS = -Iold_build $OURCFLAGS $CFLAGS $extra_cflags
|
||||
DEPFLAGS = $DEPFLAGS
|
||||
|
||||
EXTRALIBS = $extra_ldflags $_ld_static $_ld_lm $libs_mplayer $end_ldflags
|
||||
|
||||
RST2MAN = $_rst2man
|
||||
BUILD_MAN = $_build_man
|
||||
|
||||
# features
|
||||
EOF
|
||||
cat $CONFIG_MAK >> old_build/config.mak
|
||||
|
||||
cat > $TMPC << EOF
|
||||
/*----------------------------------------------------------------------------
|
||||
** This file has been automatically generated by configure any changes in it
|
||||
** will be lost when you run configure again.
|
||||
** Instead of modifying definitions here, use the --enable/--disable options
|
||||
** of the configure script! See ./configure --help for details.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MPV_CONFIG_H
|
||||
#define MPV_CONFIG_H
|
||||
|
||||
#define CONFIGURATION "$configuration"
|
||||
|
||||
#define MPV_CONFDIR "$_confdir"
|
||||
|
||||
/* we didn't bother to add actual config checks for this, or they are
|
||||
for platforms not supported by this configure script */
|
||||
#define HAVE_BSD_FSTATFS 0
|
||||
#define HAVE_LINUX_FSTATFS 1
|
||||
#define HAVE_VDA_AV_VDA_ALLOC_CONTEXT 0
|
||||
#define HAVE_VDA_HWACCEL 0
|
||||
#define HAVE_VDA_LIBAVCODEC_REFCOUNTING 0
|
||||
#define HAVE_VDA_GL 0
|
||||
#define HAVE_GL_COCOA 0
|
||||
#define HAVE_COCOA 0
|
||||
#define HAVE_COCOA_APPLICATION 0
|
||||
#define HAVE_COREVIDEO 0
|
||||
#define HAVE_COREAUDIO 0
|
||||
#define HAVE_GL_WIN32 0
|
||||
#define HAVE_DIRECT3D 0
|
||||
#define HAVE_DSOUND 0
|
||||
#define HAVE_WASAPI 0
|
||||
#define HAVE_DOS_PATHS 0
|
||||
#define HAVE_PRIORITY 0
|
||||
#define HAVE_GLOB 1
|
||||
#define HAVE_NANOSLEEP 1
|
||||
#define HAVE_SDL1 0
|
||||
#define HAVE_WAIO 0
|
||||
#define HAVE_POSIX_SPAWN 1
|
||||
#define HAVE_GLIBC_THREAD_NAME (!!__GLIBC__)
|
||||
#define HAVE_OSX_THREAD_NAME 0
|
||||
#define HAVE_BSD_THREAD_NAME 0
|
||||
#define HAVE_NETBSD_THREAD_NAME 0
|
||||
#define HAVE_DXVA2_HWACCEL 0
|
||||
#define HAVE_FCHMOD 0
|
||||
#define HAVE_RPI 0
|
||||
#define HAVE_RPI_GLES 0
|
||||
#define HAVE_AV_PIX_FMT_MMAL 0
|
||||
#define HAVE_DRM 0
|
||||
#define HAVE_VIDEOTOOLBOX_HWACCEL 0
|
||||
#define HAVE_VIDEOTOOLBOX_GL 0
|
||||
#define HAVE_VIDEOTOOLBOX_VDA_GL 0
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#define DEFAULT_CDROM_DEVICE "/dev/rcd0c"
|
||||
#define DEFAULT_DVD_DEVICE "/dev/rcd0c"
|
||||
#else
|
||||
#define DEFAULT_CDROM_DEVICE "/dev/cdrom"
|
||||
#define DEFAULT_DVD_DEVICE "/dev/dvd"
|
||||
#endif
|
||||
#define PATH_DEV_DSP "/dev/dsp"
|
||||
#define PATH_DEV_MIXER "/dev/mixer"
|
||||
|
||||
EOF
|
||||
cat $CONFIG_H >> $TMPC
|
||||
echo '#endif /* MPV_CONFIG_H */' >> $TMPC
|
||||
|
||||
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
|
||||
cmp -s "$TMPC" old_build/config.h || mv -f "$TMPC" old_build/config.h
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Configuration successful. See $TMPLOG for details.
|
||||
|
||||
NOTE: The --enable-* parameters unconditionally force options on, completely
|
||||
skipping autodetection. This behavior is unlike what you may be used to from
|
||||
autoconf-based configure scripts that can decide to override you. This greater
|
||||
level of control comes at a price. You may have to provide the correct compiler
|
||||
and linker flags yourself.
|
||||
If you used one of these options and experience a compilation or
|
||||
linking failure, make sure you have passed the necessary compiler/linker flags
|
||||
to configure.
|
||||
|
||||
WARNING: The ./old-configure + make build system you are using is deprecated in
|
||||
favour of waf and will be removed in a future version of mpv. Check the
|
||||
README for instructions on how to build mpv with the new build system.
|
||||
This will not work correctly on MinGW, Cygwin, OSX, and other systems.
|
||||
|
||||
EOF
|
||||
@@ -1,495 +0,0 @@
|
||||
# MPlayer Makefile
|
||||
#
|
||||
# copyright (c) 2008 Diego Biurrun
|
||||
# Rewritten entirely from a set of Makefiles written by Arpi and many others.
|
||||
#
|
||||
# This file is part of MPlayer.
|
||||
#
|
||||
# MPlayer is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# MPlayer is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
include old_build/config.mak
|
||||
|
||||
###### variable declarations #######
|
||||
|
||||
SOURCES_AUDIO_INPUT-$(ALSA) += stream/ai_alsa1x.c
|
||||
SOURCES_AUDIO_INPUT-$(OSS_AUDIO)+= stream/ai_oss.c
|
||||
SOURCES_AUDIO_INPUT-$(SNDIO) += stream/ai_sndio.c
|
||||
SOURCES-$(AUDIO_INPUT) += $(SOURCES_AUDIO_INPUT-yes)
|
||||
SOURCES-$(CDDA) += stream/stream_cdda.c
|
||||
SOURCES-$(DVBIN) += stream/dvb_tune.c \
|
||||
stream/stream_dvb.c
|
||||
SOURCES-$(DVDREAD) += stream/stream_dvd.c \
|
||||
stream/stream_dvd_common.c
|
||||
SOURCES-$(DVDNAV) += stream/stream_dvdnav.c \
|
||||
stream/stream_dvd_common.c
|
||||
|
||||
SOURCES-$(LADSPA) += audio/filter/af_ladspa.c
|
||||
SOURCES-$(RUBBERBAND) += audio/filter/af_rubberband.c
|
||||
SOURCES-$(LIBASS) += sub/ass_mp.c sub/sd_ass.c \
|
||||
demux/demux_libass.c
|
||||
|
||||
SOURCES-$(LIBBLURAY) += stream/stream_bluray.c
|
||||
SOURCES-$(LIBBS2B) += audio/filter/af_bs2b.c
|
||||
|
||||
SOURCES-$(LIBSMBCLIENT) += stream/stream_smb.c
|
||||
|
||||
SOURCES-$(PVR) += stream/stream_pvr.c
|
||||
|
||||
SOURCES-$(TV) += stream/stream_tv.c stream/tv.c \
|
||||
stream/frequencies.c stream/tvi_dummy.c \
|
||||
demux/demux_tv.c
|
||||
|
||||
SOURCES-$(TV_V4L2) += stream/tvi_v4l2.c stream/audio_in.c
|
||||
SOURCES-$(DUMMY_OSD) += sub/osd_dummy.c
|
||||
SOURCES-$(LIBASS_OSD) += sub/osd_libass.c
|
||||
|
||||
SOURCES-$(ALSA) += audio/out/ao_alsa.c
|
||||
SOURCES-$(CACA) += video/out/vo_caca.c
|
||||
SOURCES-$(SDL2) += audio/out/ao_sdl.c video/out/vo_sdl.c
|
||||
SOURCES-$(GL) += video/out/gl_common.c video/out/gl_osd.c \
|
||||
video/out/vo_opengl.c video/out/gl_lcms.c \
|
||||
video/out/gl_video.c video/out/dither.c \
|
||||
video/out/gl_hwdec.c video/out/gl_utils.c \
|
||||
video/out/vo_opengl_cb.c
|
||||
|
||||
SOURCES-$(ENCODING) += video/out/vo_lavc.c audio/out/ao_lavc.c \
|
||||
common/encode_lavc.c
|
||||
|
||||
SOURCES-$(GL_X11) += video/out/x11_common.c video/out/gl_x11.c
|
||||
SOURCES-$(EGL_X11) += video/out/x11_common.c video/out/gl_x11egl.c
|
||||
SOURCES-$(GL_WAYLAND) += video/out/wayland_common.c \
|
||||
video/out/gl_wayland.c
|
||||
|
||||
SOURCES-$(JACK) += audio/out/ao_jack.c
|
||||
SOURCES-$(OPENAL) += audio/out/ao_openal.c
|
||||
SOURCES-$(OSS_AUDIO) += audio/out/ao_oss.c
|
||||
SOURCES-$(PULSE) += audio/out/ao_pulse.c
|
||||
SOURCES-$(RSOUND) += audio/out/ao_rsound.c
|
||||
SOURCES-$(SNDIO) += audio/out/ao_sndio.c
|
||||
SOURCES-$(VDPAU) += video/vdpau.c video/vdpau_mixer.c \
|
||||
video/out/vo_vdpau.c video/decode/vdpau.c \
|
||||
video/filter/vf_vdpaupp.c \
|
||||
video/filter/vf_vdpaurb.c
|
||||
SOURCES-$(VDPAU_GL_X11) += video/out/gl_hwdec_vdpau.c
|
||||
SOURCES-$(VAAPI) += video/out/vo_vaapi.c \
|
||||
video/decode/vaapi.c \
|
||||
video/vaapi.c
|
||||
SOURCES-$(VAAPI_VPP) += video/filter/vf_vavpp.c
|
||||
SOURCES-$(VAAPI_GLX) += video/out/gl_hwdec_vaglx.c
|
||||
|
||||
SOURCES-$(XV) += video/out/x11_common.c video/out/vo_xv.c
|
||||
SOURCES-$(WAYLAND) += video/out/vo_wayland.c \
|
||||
video/out/wayland_common.c \
|
||||
video/out/wayland/buffer.c \
|
||||
video/out/wayland/memfile.c
|
||||
|
||||
SOURCES-$(LIBAVFILTER) += video/filter/vf_lavfi.c \
|
||||
video/filter/vf_delogo.c \
|
||||
video/filter/vf_gradfun.c \
|
||||
video/filter/vf_hqdn3d.c \
|
||||
video/filter/vf_noise.c \
|
||||
video/filter/vf_pullup.c \
|
||||
video/filter/vf_rotate.c \
|
||||
video/filter/vf_unsharp.c \
|
||||
video/filter/vf_yadif.c \
|
||||
audio/filter/af_lavfi.c
|
||||
|
||||
SOURCES-$(LUA) += player/lua.c
|
||||
SOURCES-$(VAPOURSYNTH_CORE) += video/filter/vf_vapoursynth.c
|
||||
SOURCES-$(LIBARCHIVE) += demux/demux_libarchive.c \
|
||||
stream/stream_libarchive.c
|
||||
SOURCES-$(DLOPEN) += video/filter/vf_dlopen.c
|
||||
|
||||
SOURCES = audio/audio.c \
|
||||
audio/audio_buffer.c \
|
||||
audio/chmap.c \
|
||||
audio/chmap_sel.c \
|
||||
audio/fmt-conversion.c \
|
||||
audio/format.c \
|
||||
audio/mixer.c \
|
||||
audio/decode/ad_lavc.c \
|
||||
audio/decode/ad_spdif.c \
|
||||
audio/decode/dec_audio.c \
|
||||
audio/filter/af.c \
|
||||
audio/filter/af_center.c \
|
||||
audio/filter/af_channels.c \
|
||||
audio/filter/af_delay.c \
|
||||
audio/filter/af_equalizer.c \
|
||||
audio/filter/af_export.c \
|
||||
audio/filter/af_extrastereo.c \
|
||||
audio/filter/af_format.c \
|
||||
audio/filter/af_hrtf.c \
|
||||
audio/filter/af_karaoke.c \
|
||||
audio/filter/af_lavcac3enc.c \
|
||||
audio/filter/af_lavrresample.c \
|
||||
audio/filter/af_pan.c \
|
||||
audio/filter/af_scaletempo.c \
|
||||
audio/filter/af_sinesuppress.c \
|
||||
audio/filter/af_sub.c \
|
||||
audio/filter/af_surround.c \
|
||||
audio/filter/af_sweep.c \
|
||||
audio/filter/af_drc.c \
|
||||
audio/filter/af_volume.c \
|
||||
audio/filter/filter.c \
|
||||
audio/filter/tools.c \
|
||||
audio/filter/window.c \
|
||||
audio/out/ao.c \
|
||||
audio/out/ao_null.c \
|
||||
audio/out/ao_pcm.c \
|
||||
audio/out/pull.c \
|
||||
audio/out/push.c \
|
||||
common/av_common.c \
|
||||
common/av_log.c \
|
||||
common/codecs.c \
|
||||
common/common.c \
|
||||
common/msg.c \
|
||||
common/playlist.c \
|
||||
common/tags.c \
|
||||
common/version.c \
|
||||
demux/codec_tags.c \
|
||||
demux/cue.c \
|
||||
demux/demux.c \
|
||||
demux/demux_edl.c \
|
||||
demux/demux_cue.c \
|
||||
demux/demux_disc.c \
|
||||
demux/demux_lavf.c \
|
||||
demux/demux_mf.c \
|
||||
demux/demux_mkv.c \
|
||||
demux/demux_mkv_timeline.c \
|
||||
demux/demux_playlist.c \
|
||||
demux/demux_rar.c \
|
||||
demux/demux_raw.c \
|
||||
demux/demux_subreader.c \
|
||||
demux/ebml.c \
|
||||
demux/packet.c \
|
||||
demux/timeline.c \
|
||||
input/cmd_list.c \
|
||||
input/cmd_parse.c \
|
||||
input/event.c \
|
||||
input/input.c \
|
||||
input/ipc.c \
|
||||
input/keycodes.c \
|
||||
misc/bstr.c \
|
||||
misc/charset_conv.c \
|
||||
misc/dispatch.c \
|
||||
misc/json.c \
|
||||
misc/rendezvous.c \
|
||||
misc/ring.c \
|
||||
options/m_config.c \
|
||||
options/m_option.c \
|
||||
options/m_property.c \
|
||||
options/options.c \
|
||||
options/parse_commandline.c \
|
||||
options/parse_configfile.c \
|
||||
options/path.c \
|
||||
osdep/io.c \
|
||||
osdep/path-unix.c \
|
||||
osdep/semaphore_osx.c \
|
||||
osdep/subprocess.c \
|
||||
osdep/subprocess-posix.c \
|
||||
osdep/terminal-unix.c \
|
||||
osdep/timer.c \
|
||||
osdep/timer-linux.c \
|
||||
osdep/threads.c \
|
||||
player/audio.c \
|
||||
player/client.c \
|
||||
player/configfiles.c \
|
||||
player/command.c \
|
||||
player/loadfile.c \
|
||||
player/main.c \
|
||||
player/misc.c \
|
||||
player/osd.c \
|
||||
player/playloop.c \
|
||||
player/screenshot.c \
|
||||
player/scripting.c \
|
||||
player/sub.c \
|
||||
player/video.c \
|
||||
stream/cache.c \
|
||||
stream/cache_file.c \
|
||||
stream/cookies.c \
|
||||
stream/rar.c \
|
||||
stream/stream.c \
|
||||
stream/stream_avdevice.c \
|
||||
stream/stream_edl.c \
|
||||
stream/stream_file.c \
|
||||
stream/stream_lavf.c \
|
||||
stream/stream_memory.c \
|
||||
stream/stream_mf.c \
|
||||
stream/stream_null.c \
|
||||
stream/stream_rar.c \
|
||||
sub/dec_sub.c \
|
||||
sub/draw_bmp.c \
|
||||
sub/find_subfiles.c \
|
||||
sub/img_convert.c \
|
||||
sub/osd.c \
|
||||
sub/sd_lavc.c \
|
||||
sub/sd_lavc_conv.c \
|
||||
sub/sd_lavf_srt.c \
|
||||
sub/sd_microdvd.c \
|
||||
sub/sd_movtext.c \
|
||||
sub/sd_srt.c \
|
||||
ta/ta.c \
|
||||
ta/ta_utils.c \
|
||||
ta/ta_talloc.c \
|
||||
video/csputils.c \
|
||||
video/fmt-conversion.c \
|
||||
video/image_writer.c \
|
||||
video/img_format.c \
|
||||
video/mp_image.c \
|
||||
video/mp_image_pool.c \
|
||||
video/sws_utils.c \
|
||||
video/decode/dec_video.c \
|
||||
video/decode/vd_lavc.c \
|
||||
video/filter/vf.c \
|
||||
video/filter/vf_buffer.c \
|
||||
video/filter/vf_crop.c \
|
||||
video/filter/vf_dsize.c \
|
||||
video/filter/vf_eq.c \
|
||||
video/filter/vf_expand.c \
|
||||
video/filter/vf_flip.c \
|
||||
video/filter/vf_format.c \
|
||||
video/filter/vf_mirror.c \
|
||||
video/filter/vf_noformat.c \
|
||||
video/filter/vf_scale.c \
|
||||
video/filter/vf_stereo3d.c \
|
||||
video/filter/vf_sub.c \
|
||||
video/out/bitmap_packer.c \
|
||||
video/out/aspect.c \
|
||||
video/out/filter_kernels.c \
|
||||
video/out/vo.c \
|
||||
video/out/vo_null.c \
|
||||
video/out/vo_image.c \
|
||||
video/out/win_state.c \
|
||||
$(SOURCES-yes)
|
||||
|
||||
OBJECTS += $(addsuffix .o, $(basename $(SOURCES)))
|
||||
OBJECTS += $(OBJECTS-yes)
|
||||
|
||||
DEP_FILES = $(patsubst %.S,%.d,$(patsubst %.cpp,%.d,$(patsubst %.c,%.d,$(SOURCES:.m=.d) $(SOURCES:.m=.d))))
|
||||
|
||||
ALL_TARGETS += mpv
|
||||
|
||||
INSTALL_BIN += install-mpv
|
||||
INSTALL_BIN_STRIP += install-mpv-strip
|
||||
INSTALL_MAN =
|
||||
|
||||
ifeq ($(BUILD_MAN),yes)
|
||||
INSTALL_MAN += install-mpv-man
|
||||
ALL_TARGETS += DOCS/man/mpv.1
|
||||
endif
|
||||
|
||||
DIRS = . \
|
||||
audio \
|
||||
audio/decode \
|
||||
audio/filter \
|
||||
audio/out \
|
||||
common \
|
||||
compat \
|
||||
input \
|
||||
player/timeline \
|
||||
demux \
|
||||
misc \
|
||||
options \
|
||||
osdep \
|
||||
osdep/ar \
|
||||
player \
|
||||
stream \
|
||||
sub \
|
||||
ta \
|
||||
video \
|
||||
video/decode \
|
||||
video/filter \
|
||||
video/out
|
||||
|
||||
|
||||
ADDSUFFIXES = $(foreach suf,$(1),$(addsuffix $(suf),$(2)))
|
||||
ADD_ALL_DIRS = $(call ADDSUFFIXES,$(1),$(DIRS))
|
||||
|
||||
###### brief build output #######
|
||||
|
||||
ifndef V
|
||||
$(eval override CC = @printf "CC\t$$@\n"; $(CC))
|
||||
$(eval override RM = @$(RM))
|
||||
endif
|
||||
|
||||
###### generic rules #######
|
||||
|
||||
all: $(ALL_TARGETS)
|
||||
|
||||
%.1: %.rst
|
||||
$(RST2MAN) $< $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
mpv: $(OBJECTS) osdep/main-fn-unix.o
|
||||
$(CC) -o $@ $^ $(EXTRALIBS)
|
||||
|
||||
input/input.c: input/input_conf.h
|
||||
input/input_conf.h: TOOLS/file2string.pl etc/input.conf
|
||||
./$^ >$@
|
||||
|
||||
MKVLIB_DEPS = TOOLS/lib/Parse/Matroska.pm \
|
||||
TOOLS/lib/Parse/Matroska/Definitions.pm \
|
||||
TOOLS/lib/Parse/Matroska/Element.pm \
|
||||
TOOLS/lib/Parse/Matroska/Reader.pm \
|
||||
TOOLS/lib/Parse/Matroska/Utils.pm \
|
||||
|
||||
demux/ebml.c demux/demux_mkv.c: demux/ebml_types.h
|
||||
demux/ebml_types.h: TOOLS/matroska.pl $(MKVLIB_DEPS)
|
||||
./$< --generate-header > $@
|
||||
|
||||
demux/ebml.c: demux/ebml_defs.c
|
||||
demux/ebml_defs.c: TOOLS/matroska.pl $(MKVLIB_DEPS)
|
||||
./$< --generate-definitions > $@
|
||||
|
||||
video/out/x11_common.c: video/out/x11_icon.inc
|
||||
video/out/x11_icon.inc: TOOLS/file2string.pl video/out/x11_icon.bin
|
||||
./$^ >$@
|
||||
|
||||
sub/osd_libass.c: sub/osd_font.h
|
||||
sub/osd_font.h: TOOLS/file2string.pl sub/osd_font.otf
|
||||
./$^ >$@
|
||||
|
||||
player/lua/%.inc: TOOLS/file2string.pl player/lua/%.lua
|
||||
./$^ >$@
|
||||
|
||||
player/lua.c: player/lua/defaults.inc \
|
||||
player/lua/assdraw.inc \
|
||||
player/lua/osc.inc \
|
||||
player/lua/ytdl_hook.inc \
|
||||
player/lua/options.inc
|
||||
|
||||
etc/_mpv: TOOLS/zsh.pl ./mpv
|
||||
./$< > $@
|
||||
|
||||
# ./configure must be rerun if it changed
|
||||
config.mak: configure
|
||||
@echo "############################################################"
|
||||
@echo "####### Please run ./configure again - it's changed! #######"
|
||||
@echo "############################################################"
|
||||
|
||||
old_build/version.h .version: version.sh
|
||||
./version.sh --versionh=old_build/version.h
|
||||
|
||||
# Force version.sh to run to potentially regenerate version.h
|
||||
-include .version
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
|
||||
###### dependency declarations / specific CFLAGS ######
|
||||
|
||||
common/version.c: old_build/version.h
|
||||
|
||||
DOCS/man/mpv.1: DOCS/man/af.rst \
|
||||
DOCS/man/ao.rst \
|
||||
DOCS/man/changes.rst \
|
||||
DOCS/man/encode.rst \
|
||||
DOCS/man/input.rst \
|
||||
DOCS/man/options.rst \
|
||||
DOCS/man/vf.rst \
|
||||
DOCS/man/vo.rst
|
||||
|
||||
###### installation / clean / generic rules #######
|
||||
|
||||
install: $(INSTALL_BIN) install-data $(INSTALL_MAN)
|
||||
install-no-man: $(INSTALL_BIN) install-data
|
||||
install-strip: $(INSTALL_BIN_STRIP) install-data $(INSTALL_MAN)
|
||||
install-strip-no-man: $(INSTALL_BIN_STRIP) install-data
|
||||
|
||||
install-dirs:
|
||||
if test ! -d $(BINDIR) ; then $(INSTALL) -d $(BINDIR) ; fi
|
||||
|
||||
install-%: % install-dirs
|
||||
$(INSTALL) -m 755 $< $(BINDIR)
|
||||
|
||||
install-%-strip: % install-dirs
|
||||
$(INSTALL) -m 755 -s $< $(BINDIR)
|
||||
|
||||
install-mpv-man: install-mpv-man-en
|
||||
|
||||
install-mpv-man-en: DOCS/man/mpv.1
|
||||
if test ! -d $(MANDIR)/man1 ; then $(INSTALL) -d $(MANDIR)/man1 ; fi
|
||||
$(INSTALL) -m 644 DOCS/man/mpv.1 $(MANDIR)/man1/
|
||||
|
||||
ICONSIZES = 16x16 32x32 64x64
|
||||
|
||||
define ICON_INSTALL_RULE
|
||||
install-mpv-icon-$(size): etc/mpv-icon-8bit-$(size).png
|
||||
$(INSTALL) -d $(prefix)/share/icons/hicolor/$(size)/apps
|
||||
$(INSTALL) -m 644 etc/mpv-icon-8bit-$(size).png $(prefix)/share/icons/hicolor/$(size)/apps/mpv.png
|
||||
endef
|
||||
|
||||
$(foreach size,$(ICONSIZES),$(eval $(ICON_INSTALL_RULE)))
|
||||
|
||||
install-mpv-icons: $(foreach size,$(ICONSIZES),install-mpv-icon-$(size))
|
||||
|
||||
install-mpv-desktop: etc/mpv.desktop
|
||||
$(INSTALL) -d $(prefix)/share/applications
|
||||
$(INSTALL) -m 644 etc/mpv.desktop $(prefix)/share/applications/
|
||||
|
||||
install-mpv-config: etc/encoding-profiles.conf
|
||||
$(INSTALL) -d $(CONFDIR)
|
||||
$(INSTALL) -m 644 etc/encoding-profiles.conf $(CONFDIR)
|
||||
|
||||
install-mpv-zsh: etc/_mpv
|
||||
$(INSTALL) -d $(prefix)/share/zsh/vendor-completions
|
||||
$(INSTALL) -m 644 etc/_mpv $(prefix)/share/zsh/vendor-completions/
|
||||
|
||||
install-data: install-mpv-icons install-mpv-desktop install-mpv-config install-mpv-zsh
|
||||
|
||||
uninstall:
|
||||
$(RM) $(BINDIR)/mpv
|
||||
$(RM) $(MANDIR)/man1/mpv.1 $(MANDIR)/man1/mpv.1
|
||||
$(RM) $(prefix)/share/applications/mpv.desktop
|
||||
$(RM) $(prefix)/share/zsh/vendor-completions/_mpv
|
||||
$(RM) $(foreach size,$(ICONSIZES),$(prefix)/share/icons/hicolor/$(size)/apps/mpv.png)
|
||||
|
||||
clean:
|
||||
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.d /*.a /*.ho /*~)
|
||||
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.a /*.ho /*~)
|
||||
-$(RM) mpv
|
||||
-$(RM) DOCS/man/*/mpv.1
|
||||
-$(RM) old_build/version.h version.h
|
||||
-$(RM) input/input_conf.h
|
||||
-$(RM) video/out/vdpau_template.c
|
||||
-$(RM) demux/ebml_types.h demux/ebml_defs.c
|
||||
-$(RM) video/out/x11_icon.inc
|
||||
-$(RM) sub/osd_font.h
|
||||
-$(RM) player/lua/defaults.inc
|
||||
-$(RM) player/lua/assdraw.inc
|
||||
-$(RM) player/lua/osc.inc
|
||||
-$(RM) player/lua/ytdl_hook.inc
|
||||
-$(RM) player/lua/options.inc
|
||||
|
||||
distclean: clean
|
||||
-$(RM) config.log old_build/config.h old_build/config.mak Makefile
|
||||
-rmdir old_build/
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
.PHONY: all *install* *clean .version
|
||||
|
||||
# Disable suffix rules. Most of the builtin rules are suffix rules,
|
||||
# so this saves some time on slow systems.
|
||||
.SUFFIXES:
|
||||
|
||||
# If a command returns failure but changed its target file, delete the
|
||||
# (presumably malformed) file. Otherwise the file would be considered to
|
||||
# be up to date if make is restarted.
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
+10
-1
@@ -39,8 +39,17 @@ def apply_plist_template(plist_file, version):
|
||||
for line in fileinput.input(plist_file, inplace=1):
|
||||
print (line.rstrip().replace('${VERSION}', version))
|
||||
|
||||
def bundle_version():
|
||||
if os.path.exists('VERSION'):
|
||||
x = open('VERSION')
|
||||
version = x.read()
|
||||
x.close()
|
||||
else:
|
||||
version = sh("./version.sh").strip()
|
||||
return version
|
||||
|
||||
def main():
|
||||
version = sh("./version.sh").strip()
|
||||
version = bundle_version().rstrip()
|
||||
|
||||
usage = "usage: %prog [options] arg"
|
||||
parser = OptionParser(usage)
|
||||
|
||||
+32
-14
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import matplotlib.pyplot as plot
|
||||
from pyqtgraph.Qt import QtGui, QtCore
|
||||
import pyqtgraph as pg
|
||||
import sys
|
||||
import re
|
||||
|
||||
@@ -38,8 +39,8 @@ Currently, the following event types are supported:
|
||||
class G:
|
||||
events = {}
|
||||
start = None
|
||||
# http://matplotlib.org/api/markers_api.html#module-matplotlib.markers
|
||||
markers = ["o", "8", "s", "p", "*", "h", "+", "x", "D"]
|
||||
markers = ["o", "s", "t", "d"]
|
||||
curveno = {}
|
||||
|
||||
def find_marker():
|
||||
if len(G.markers) == 0:
|
||||
@@ -65,6 +66,10 @@ def get_event(event, evtype):
|
||||
G.events[event] = e
|
||||
return G.events[event]
|
||||
|
||||
colors = [(0.0, 0.5, 0.0), (0.0, 0.0, 1.0), (0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.75, 0.75, 0), (0.0, 0.75, 0.75), (0.75, 0, 0.75)]
|
||||
def mkColor(t):
|
||||
return pg.mkColor(int(t[0] * 255), int(t[1] * 255), int(t[2] * 255))
|
||||
|
||||
SCALE = 1e6 # microseconds to seconds
|
||||
|
||||
for line in [line.split("#")[0].strip() for line in open(filename, "r")]:
|
||||
@@ -128,20 +133,33 @@ for e, index in zip(G.sevents, range(len(G.sevents))):
|
||||
else:
|
||||
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
||||
|
||||
fig = plot.figure()
|
||||
fig.hold(True)
|
||||
pg.setConfigOption('background', 'w')
|
||||
pg.setConfigOption('foreground', 'k')
|
||||
app = QtGui.QApplication([])
|
||||
win = pg.GraphicsWindow()
|
||||
#win.resize(1500, 900)
|
||||
|
||||
ax = [None, None]
|
||||
plots = 2 if hasval else 1
|
||||
ax[0] = fig.add_subplot(plots, 1, 1)
|
||||
ax[0] = win.addPlot()
|
||||
if hasval:
|
||||
ax[1] = fig.add_subplot(plots, 1, 2, sharex=ax[0])
|
||||
legends = [[], []]
|
||||
win.nextRow()
|
||||
ax[1] = win.addPlot()
|
||||
ax[1].setXLink(ax[0])
|
||||
for cur in ax:
|
||||
if cur is not None:
|
||||
cur.addLegend(offset = (-1, 1))
|
||||
for e in G.sevents:
|
||||
cur = ax[1 if e.type == "value" else 0]
|
||||
pl, = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], label=e.name)
|
||||
args = {'name': e.name,'antialias':True}
|
||||
if e.type == "event-signal":
|
||||
plot.setp(pl, marker = e.marker, linestyle = "None")
|
||||
for cur in ax:
|
||||
if cur is not None:
|
||||
cur.legend()
|
||||
plot.show()
|
||||
args['symbol'] = e.marker
|
||||
args['pen'] = None
|
||||
else:
|
||||
if not cur in G.curveno:
|
||||
G.curveno[cur] = 0
|
||||
args['pen'] = pg.mkPen(mkColor(colors[G.curveno[cur] % len(colors)]), width=0)
|
||||
G.curveno[cur] += 1
|
||||
n = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], **args)
|
||||
|
||||
QtGui.QApplication.instance().exec_()
|
||||
+3
-3
@@ -120,7 +120,7 @@ $profile_comp
|
||||
_tags files urls
|
||||
while _tags; do
|
||||
_requested files expl 'media file' _files -g \\
|
||||
"*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
|
||||
"*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
|
||||
if _requested urls; then
|
||||
while _next_label urls expl URL; do
|
||||
_urls "\$expl[@]" && rc=0
|
||||
@@ -232,8 +232,8 @@ sub call_mpv {
|
||||
my $output = `"$mpv" --no-config $cmd`;
|
||||
if ($? == -1) {
|
||||
die "Could not run mpv: $!";
|
||||
} elsif ($? != 0) {
|
||||
die "mpv returned " . ($? >> 8) . " with output:\n$output";
|
||||
} elsif ((my $exit_code = $? >> 8) != 0) {
|
||||
die "mpv returned $exit_code with output:\n$output";
|
||||
}
|
||||
return split /\n/, $output;
|
||||
}
|
||||
+116
-13
@@ -22,9 +22,10 @@
|
||||
|
||||
#include <libavutil/buffer.h>
|
||||
#include <libavutil/frame.h>
|
||||
#include <libavutil/mem.h>
|
||||
#include <libavutil/version.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "common/common.h"
|
||||
#include "fmt-conversion.h"
|
||||
#include "audio.h"
|
||||
@@ -58,13 +59,6 @@ void mp_audio_set_num_channels(struct mp_audio *mpa, int num_channels)
|
||||
update_redundant_info(mpa);
|
||||
}
|
||||
|
||||
// Use old MPlayer/ALSA channel layout.
|
||||
void mp_audio_set_channels_old(struct mp_audio *mpa, int num_channels)
|
||||
{
|
||||
mp_chmap_from_channels_alsa(&mpa->channels, num_channels);
|
||||
update_redundant_info(mpa);
|
||||
}
|
||||
|
||||
void mp_audio_set_channels(struct mp_audio *mpa, const struct mp_chmap *chmap)
|
||||
{
|
||||
mpa->channels = *chmap;
|
||||
@@ -258,8 +252,43 @@ void mp_audio_skip_samples(struct mp_audio *data, int samples)
|
||||
data->planes[n] = (uint8_t *)data->planes[n] + samples * data->sstride;
|
||||
|
||||
data->samples -= samples;
|
||||
|
||||
if (data->pts != MP_NOPTS_VALUE)
|
||||
data->pts += samples / (double)data->rate;
|
||||
}
|
||||
|
||||
// Clip the given frame to the given timestamp range. Adjusts the frame size
|
||||
// and timestamp.
|
||||
void mp_audio_clip_timestamps(struct mp_audio *f, double start, double end)
|
||||
{
|
||||
if (f->pts == MP_NOPTS_VALUE || f->rate < 1)
|
||||
return;
|
||||
double f_end = f->pts + f->samples / (double)f->rate;
|
||||
if (end != MP_NOPTS_VALUE) {
|
||||
if (f_end >= end) {
|
||||
if (f->pts >= end) {
|
||||
f->samples = 0;
|
||||
} else {
|
||||
int new = (end - f->pts) * f->rate;
|
||||
f->samples = MPCLAMP(new, 0, f->samples);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start != MP_NOPTS_VALUE) {
|
||||
if (f->pts < start) {
|
||||
if (f_end <= start) {
|
||||
f->samples = 0;
|
||||
f->pts = f_end;
|
||||
} else {
|
||||
int skip = (start - f->pts) * f->rate;
|
||||
skip = MPCLAMP(skip, 0, f->samples);
|
||||
mp_audio_skip_samples(f, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return false if the frame data is shared, true otherwise.
|
||||
// Will return true for non-refcounted frames.
|
||||
bool mp_audio_is_writeable(struct mp_audio *data)
|
||||
@@ -330,21 +359,23 @@ struct mp_audio *mp_audio_from_avframe(struct AVFrame *avframe)
|
||||
}
|
||||
|
||||
// If we can't handle the format (e.g. too many channels), bail out.
|
||||
if (!mp_audio_config_valid(new) || avframe->nb_extended_buf)
|
||||
if (!mp_audio_config_valid(new))
|
||||
goto fail;
|
||||
|
||||
for (int n = 0; n < AV_NUM_DATA_POINTERS; n++) {
|
||||
if (!avframe->buf[n])
|
||||
for (int n = 0; n < AV_NUM_DATA_POINTERS + avframe->nb_extended_buf; n++) {
|
||||
AVBufferRef *buf = n < AV_NUM_DATA_POINTERS ? avframe->buf[n]
|
||||
: avframe->extended_buf[n - AV_NUM_DATA_POINTERS];
|
||||
if (!buf)
|
||||
break;
|
||||
if (n >= MP_NUM_CHANNELS)
|
||||
goto fail;
|
||||
new->allocated[n] = av_buffer_ref(avframe->buf[n]);
|
||||
new->allocated[n] = av_buffer_ref(buf);
|
||||
if (!new->allocated[n])
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (int n = 0; n < new->num_planes; n++)
|
||||
new->planes[n] = avframe->data[n];
|
||||
new->planes[n] = avframe->extended_data[n];
|
||||
new->samples = avframe->nb_samples;
|
||||
|
||||
return new;
|
||||
@@ -355,6 +386,78 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Returns NULL on failure. The input is always unreffed.
|
||||
struct AVFrame *mp_audio_to_avframe_and_unref(struct mp_audio *frame)
|
||||
{
|
||||
struct AVFrame *avframe = av_frame_alloc();
|
||||
if (!avframe)
|
||||
goto fail;
|
||||
|
||||
avframe->nb_samples = frame->samples;
|
||||
avframe->format = af_to_avformat(frame->format);
|
||||
if (avframe->format == AV_SAMPLE_FMT_NONE)
|
||||
goto fail;
|
||||
|
||||
avframe->channel_layout = mp_chmap_to_lavc(&frame->channels);
|
||||
if (!avframe->channel_layout)
|
||||
goto fail;
|
||||
#if LIBAVUTIL_VERSION_MICRO >= 100
|
||||
// FFmpeg being a stupid POS (but I respect it)
|
||||
avframe->channels = frame->channels.num;
|
||||
#endif
|
||||
avframe->sample_rate = frame->rate;
|
||||
|
||||
if (frame->num_planes > AV_NUM_DATA_POINTERS) {
|
||||
avframe->extended_data =
|
||||
av_mallocz_array(frame->num_planes, sizeof(avframe->extended_data[0]));
|
||||
int extbufs = frame->num_planes - AV_NUM_DATA_POINTERS;
|
||||
avframe->extended_buf =
|
||||
av_mallocz_array(extbufs, sizeof(avframe->extended_buf[0]));
|
||||
if (!avframe->extended_data || !avframe->extended_buf)
|
||||
goto fail;
|
||||
avframe->nb_extended_buf = extbufs;
|
||||
}
|
||||
|
||||
for (int p = 0; p < frame->num_planes; p++)
|
||||
avframe->extended_data[p] = frame->planes[p];
|
||||
avframe->linesize[0] = frame->samples * frame->sstride;
|
||||
|
||||
for (int p = 0; p < AV_NUM_DATA_POINTERS; p++)
|
||||
avframe->data[p] = avframe->extended_data[p];
|
||||
|
||||
for (int p = 0; p < frame->num_planes; p++) {
|
||||
if (!frame->allocated[p])
|
||||
break;
|
||||
AVBufferRef *nref = av_buffer_ref(frame->allocated[p]);
|
||||
if (!nref)
|
||||
goto fail;
|
||||
if (p < AV_NUM_DATA_POINTERS) {
|
||||
avframe->buf[p] = nref;
|
||||
} else {
|
||||
avframe->extended_buf[p - AV_NUM_DATA_POINTERS] = nref;
|
||||
}
|
||||
}
|
||||
|
||||
// Force refcounted frame.
|
||||
if (!avframe->buf[0]) {
|
||||
AVFrame *tmp = av_frame_alloc();
|
||||
if (!tmp)
|
||||
goto fail;
|
||||
if (av_frame_ref(tmp, avframe) < 0)
|
||||
goto fail;
|
||||
av_frame_free(&avframe);
|
||||
avframe = tmp;
|
||||
}
|
||||
|
||||
talloc_free(frame);
|
||||
return avframe;
|
||||
|
||||
fail:
|
||||
av_frame_free(&avframe);
|
||||
talloc_free(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct mp_audio_pool {
|
||||
AVBufferPool *avpool;
|
||||
int element_size;
|
||||
|
||||
+4
-1
@@ -37,6 +37,8 @@ struct mp_audio {
|
||||
int num_planes; // number of planes
|
||||
int bps; // size of sub-samples (af_fmt_to_bytes(format))
|
||||
|
||||
double pts; // currently invalid within the filter chain
|
||||
|
||||
// --- private
|
||||
// These do not necessarily map directly to planes[]. They can have
|
||||
// different order or count. There shouldn't be more buffers than planes.
|
||||
@@ -46,7 +48,6 @@ struct mp_audio {
|
||||
|
||||
void mp_audio_set_format(struct mp_audio *mpa, int format);
|
||||
void mp_audio_set_num_channels(struct mp_audio *mpa, int num_channels);
|
||||
void mp_audio_set_channels_old(struct mp_audio *mpa, int num_channels);
|
||||
void mp_audio_set_channels(struct mp_audio *mpa, const struct mp_chmap *chmap);
|
||||
void mp_audio_copy_config(struct mp_audio *dst, const struct mp_audio *src);
|
||||
bool mp_audio_config_equals(const struct mp_audio *a, const struct mp_audio *b);
|
||||
@@ -71,12 +72,14 @@ void mp_audio_copy(struct mp_audio *dst, int dst_offset,
|
||||
struct mp_audio *src, int src_offset, int length);
|
||||
void mp_audio_copy_attributes(struct mp_audio *dst, struct mp_audio *src);
|
||||
void mp_audio_skip_samples(struct mp_audio *data, int samples);
|
||||
void mp_audio_clip_timestamps(struct mp_audio *f, double start, double end);
|
||||
|
||||
bool mp_audio_is_writeable(struct mp_audio *data);
|
||||
int mp_audio_make_writeable(struct mp_audio *data);
|
||||
|
||||
struct AVFrame;
|
||||
struct mp_audio *mp_audio_from_avframe(struct AVFrame *avframe);
|
||||
struct AVFrame *mp_audio_to_avframe_and_unref(struct mp_audio *frame);
|
||||
|
||||
struct mp_audio_pool;
|
||||
struct mp_audio_pool *mp_audio_pool_create(void *ta_parent);
|
||||
|
||||
+16
-7
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -119,6 +119,15 @@ void mp_audio_buffer_prepend_silence(struct mp_audio_buffer *ab, int samples)
|
||||
mp_audio_fill_silence(ab->buffer, 0, samples);
|
||||
}
|
||||
|
||||
void mp_audio_buffer_duplicate(struct mp_audio_buffer *ab, int samples)
|
||||
{
|
||||
assert(samples >= 0 && samples <= ab->buffer->samples);
|
||||
int oldlen = ab->buffer->samples;
|
||||
ab->buffer->samples += samples;
|
||||
mp_audio_realloc_min(ab->buffer, ab->buffer->samples);
|
||||
mp_audio_copy(ab->buffer, oldlen, ab->buffer, oldlen - samples, samples);
|
||||
}
|
||||
|
||||
// Get the start of the current readable buffer.
|
||||
void mp_audio_buffer_peek(struct mp_audio_buffer *ab, struct mp_audio *out_mpa)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MP_AUDIO_BUFFER_H
|
||||
@@ -35,6 +35,7 @@ void mp_audio_buffer_get_write_buffer(struct mp_audio_buffer *ab, int minsamples
|
||||
void mp_audio_buffer_finish_write(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_append(struct mp_audio_buffer *ab, struct mp_audio *mpa);
|
||||
void mp_audio_buffer_prepend_silence(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_duplicate(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_peek(struct mp_audio_buffer *ab, struct mp_audio *out_mpa);
|
||||
void mp_audio_buffer_skip(struct mp_audio_buffer *ab, int samples);
|
||||
void mp_audio_buffer_clear(struct mp_audio_buffer *ab);
|
||||
|
||||
+18
-36
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -93,7 +93,7 @@ static const char *const std_layout_names[][2] = {
|
||||
{"7.1(alsa)", "fl-fr-bl-br-fc-lfe-sl-sr"}, // not in lavc
|
||||
{"7.1(wide)", "fl-fr-fc-lfe-bl-br-flc-frc"},
|
||||
{"7.1(wide-side)", "fl-fr-fc-lfe-flc-frc-sl-sr"},
|
||||
{"7.1(rear)", "fl-fr-fc-lfe-bl-br-sdl-sdr"},
|
||||
{"7.1(rear)", "fl-fr-fc-lfe-bl-br-sdl-sdr"}, // not in lavc
|
||||
{"octagonal", "fl-fr-fc-bl-br-bc-sl-sr"},
|
||||
{"downmix", "dl-dr"},
|
||||
{"auto", ""}, // not in lavc
|
||||
@@ -112,19 +112,6 @@ static const struct mp_chmap default_layouts[] = {
|
||||
MP_CHMAP8(FL, FR, FC, LFE, BL, BR, SL, SR), // 7.1
|
||||
};
|
||||
|
||||
// The channel order was lavc/waveex, but differs from lavc for 5, 6 and 8
|
||||
// channels. 3 and 7 channels were likely undefined (no ALSA support).
|
||||
// I'm not sure about the 4 channel case: ALSA uses "quad", while the ffmpeg
|
||||
// default layout is "4.0".
|
||||
static const char *const mplayer_layouts[MP_NUM_CHANNELS + 1] = {
|
||||
[1] = "mono",
|
||||
[2] = "stereo",
|
||||
[4] = "quad",
|
||||
[5] = "5.0(alsa)",
|
||||
[6] = "5.1(alsa)",
|
||||
[8] = "7.1(alsa)",
|
||||
};
|
||||
|
||||
// Returns true if speakers are mapped uniquely, and there's at least 1 channel.
|
||||
bool mp_chmap_is_valid(const struct mp_chmap *src)
|
||||
{
|
||||
@@ -227,19 +214,6 @@ void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels)
|
||||
mp_chmap_set_unknown(dst, num_channels);
|
||||
}
|
||||
|
||||
// Try to do what mplayer/mplayer2/mpv did before channel layouts were
|
||||
// introduced, i.e. get the old default channel order.
|
||||
void mp_chmap_from_channels_alsa(struct mp_chmap *dst, int num_channels)
|
||||
{
|
||||
if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
|
||||
*dst = (struct mp_chmap) {0};
|
||||
} else {
|
||||
mp_chmap_from_str(dst, bstr0(mplayer_layouts[num_channels]));
|
||||
if (!dst->num)
|
||||
mp_chmap_from_channels(dst, num_channels);
|
||||
}
|
||||
}
|
||||
|
||||
// Set *dst to an unknown layout for the given numbers of channels.
|
||||
// If the number of channels is invalid, an invalid map is set, and
|
||||
// mp_chmap_is_valid(dst) will return false.
|
||||
@@ -298,12 +272,18 @@ void mp_chmap_remove_useless_channels(struct mp_chmap *map,
|
||||
// Speakers not representable by ffmpeg/libav are dropped.
|
||||
// Warning: this ignores the order of the channels, and will return a channel
|
||||
// mask even if the order is different from libavcodec's.
|
||||
// Also, "unknown" channel maps are translated to non-sense channel
|
||||
// maps with the same number of channels.
|
||||
uint64_t mp_chmap_to_lavc_unchecked(const struct mp_chmap *src)
|
||||
{
|
||||
// lavc has no concept for unknown layouts yet, so pick a default
|
||||
struct mp_chmap t = *src;
|
||||
if (t.num > 64)
|
||||
return 0;
|
||||
// lavc has no concept for unknown layouts yet, so pick something that does
|
||||
// the job of signaling the number of channels, even if it makes no sense
|
||||
// as a proper layout.
|
||||
if (mp_chmap_is_unknown(&t))
|
||||
mp_chmap_from_channels(&t, t.num);
|
||||
return t.num == 64 ? (uint64_t)-1 : (1ULL << t.num) - 1;
|
||||
uint64_t mask = 0;
|
||||
for (int n = 0; n < t.num; n++) {
|
||||
if (t.speaker[n] < 64) // ignore MP_SPEAKER_ID_NA etc.
|
||||
@@ -359,6 +339,8 @@ bool mp_chmap_is_lavc(const struct mp_chmap *src)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Warning: for "unknown" channel maps, this returns something that may not
|
||||
// make sense. Invalid channel maps are not changed.
|
||||
void mp_chmap_reorder_to_lavc(struct mp_chmap *map)
|
||||
{
|
||||
if (!mp_chmap_is_valid(map))
|
||||
|
||||
+8
-9
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MP_CHMAP_H
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "misc/bstr.h"
|
||||
|
||||
#define MP_NUM_CHANNELS 8
|
||||
#define MP_NUM_CHANNELS 16
|
||||
|
||||
// Speaker a channel can be assigned to.
|
||||
// This corresponds to WAVEFORMATEXTENSIBLE channel mask bit indexes.
|
||||
@@ -108,7 +108,6 @@ void mp_chmap_fill_na(struct mp_chmap *map, int num);
|
||||
|
||||
void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels);
|
||||
void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels);
|
||||
void mp_chmap_from_channels_alsa(struct mp_chmap *dst, int num_channels);
|
||||
|
||||
void mp_chmap_remove_useless_channels(struct mp_chmap *map,
|
||||
const struct mp_chmap *requested);
|
||||
|
||||
+44
-27
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/msg.h"
|
||||
#include "chmap_sel.h"
|
||||
|
||||
static const struct mp_chmap speaker_replacements[][2] = {
|
||||
@@ -94,17 +95,6 @@ void mp_chmap_sel_add_waveext(struct mp_chmap_sel *s)
|
||||
s->allow_waveext = true;
|
||||
}
|
||||
|
||||
// Classic ALSA-based MPlayer layouts.
|
||||
void mp_chmap_sel_add_alsa_def(struct mp_chmap_sel *s)
|
||||
{
|
||||
for (int n = 1; n <= MP_NUM_CHANNELS; n++) {
|
||||
struct mp_chmap t;
|
||||
mp_chmap_from_channels_alsa(&t, n);
|
||||
if (t.num)
|
||||
mp_chmap_sel_add_map(s, &t);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a channel map that should be allowed.
|
||||
void mp_chmap_sel_add_map(struct mp_chmap_sel *s, const struct mp_chmap *map)
|
||||
{
|
||||
@@ -284,19 +274,25 @@ static bool mp_chmap_is_better(struct mp_chmap *req, struct mp_chmap *old,
|
||||
if (new_lost_r != old_lost_r)
|
||||
return new_lost_r < old_lost_r;
|
||||
|
||||
int old_lost = mp_chmap_diffn(req, old);
|
||||
int new_lost = mp_chmap_diffn(req, new);
|
||||
|
||||
// If the situation is equal with replaced speakers, but one of them loses
|
||||
// less if no replacements are performed, pick the better one, even if it
|
||||
// means an upmix. This prefers exact supersets over inexact equivalents.
|
||||
if (new_lost != old_lost)
|
||||
return new_lost < old_lost;
|
||||
|
||||
struct mp_chmap old_p = *old, new_p = *new;
|
||||
mp_chmap_remove_na(&old_p);
|
||||
mp_chmap_remove_na(&new_p);
|
||||
|
||||
// If the situation is equal with replaced speakers, but the replacement is
|
||||
// perfect for only one of them, let the better one win. This prefers
|
||||
// inexact equivalents over exact supersets.
|
||||
bool perfect_r_new = !new_lost_r && new_p.num <= old_p.num;
|
||||
bool perfect_r_old = !old_lost_r && old_p.num <= new_p.num;
|
||||
if (perfect_r_new != perfect_r_old)
|
||||
return perfect_r_new;
|
||||
|
||||
int old_lost = mp_chmap_diffn(req, old);
|
||||
int new_lost = mp_chmap_diffn(req, new);
|
||||
// If the situation is equal with replaced speakers, pick the better one,
|
||||
// even if it means an upmix.
|
||||
if (new_lost != old_lost)
|
||||
return new_lost < old_lost;
|
||||
|
||||
// Some kind of upmix. If it's perfect, prefer the smaller one. Even if not,
|
||||
// both have equal loss, so also prefer the smaller one.
|
||||
// Drop padding channels (NA) for the sake of this check, as the number of
|
||||
@@ -357,3 +353,24 @@ bool mp_chmap_sel_get_def(const struct mp_chmap_sel *s, struct mp_chmap *map,
|
||||
}
|
||||
return map->num > 0;
|
||||
}
|
||||
|
||||
// Print the set of allowed channel layouts.
|
||||
void mp_chmal_sel_log(const struct mp_chmap_sel *s, struct mp_log *log, int lev)
|
||||
{
|
||||
if (!mp_msg_test(log, lev))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < s->num_chmaps; i++)
|
||||
mp_msg(log, lev, " - %s\n", mp_chmap_to_str(&s->chmaps[i]));
|
||||
for (int i = 0; i < MP_SPEAKER_ID_COUNT; i++) {
|
||||
if (!s->speakers[i])
|
||||
continue;
|
||||
struct mp_chmap l = {.num = 1, .speaker = { i }};
|
||||
mp_msg(log, lev, " - #%s\n",
|
||||
i == MP_SPEAKER_ID_FC ? "fc" : mp_chmap_to_str_hr(&l));
|
||||
}
|
||||
if (s->allow_waveext)
|
||||
mp_msg(log, lev, " - waveext\n");
|
||||
if (s->allow_any)
|
||||
mp_msg(log, lev, " - anything\n");
|
||||
}
|
||||
+10
-8
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MP_CHMAP_SEL_H
|
||||
@@ -37,7 +37,6 @@ struct mp_chmap_sel {
|
||||
void mp_chmap_sel_add_any(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_waveext(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_waveext_def(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_alsa_def(struct mp_chmap_sel *s);
|
||||
void mp_chmap_sel_add_map(struct mp_chmap_sel *s, const struct mp_chmap *map);
|
||||
void mp_chmap_sel_add_speaker(struct mp_chmap_sel *s, int id);
|
||||
bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map);
|
||||
@@ -45,4 +44,7 @@ bool mp_chmap_sel_fallback(const struct mp_chmap_sel *s, struct mp_chmap *map);
|
||||
bool mp_chmap_sel_get_def(const struct mp_chmap_sel *s, struct mp_chmap *map,
|
||||
int num);
|
||||
|
||||
struct mp_log;
|
||||
void mp_chmal_sel_log(const struct mp_chmap_sel *s, struct mp_log *log, int lev);
|
||||
|
||||
#endif
|
||||
+2
-1
@@ -35,7 +35,8 @@ struct ad_functions {
|
||||
int (*init)(struct dec_audio *da, const char *decoder);
|
||||
void (*uninit)(struct dec_audio *da);
|
||||
int (*control)(struct dec_audio *da, int cmd, void *arg);
|
||||
int (*decode_packet)(struct dec_audio *da, struct mp_audio **out);
|
||||
int (*decode_packet)(struct dec_audio *da, struct demux_packet *pkt,
|
||||
struct mp_audio **out);
|
||||
};
|
||||
|
||||
enum ad_ctrl {
|
||||
|
||||
+60
-60
@@ -26,7 +26,7 @@
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/intreadwrite.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "common/av_common.h"
|
||||
@@ -42,8 +42,9 @@ struct priv {
|
||||
AVFrame *avframe;
|
||||
struct mp_audio frame;
|
||||
bool force_channel_map;
|
||||
struct demux_packet *packet;
|
||||
uint32_t skip_samples;
|
||||
uint32_t skip_samples, trim_samples;
|
||||
bool preroll_done;
|
||||
double next_pts;
|
||||
};
|
||||
|
||||
static void uninit(struct dec_audio *da);
|
||||
@@ -60,7 +61,7 @@ const struct m_sub_options ad_lavc_conf = {
|
||||
.opts = (const m_option_t[]) {
|
||||
OPT_FLOATRANGE("ac3drc", ac3drc, 0, 0, 6),
|
||||
OPT_FLAG("downmix", downmix, 0),
|
||||
OPT_INTRANGE("threads", threads, 0, 1, 16),
|
||||
OPT_INTRANGE("threads", threads, 0, 0, 16),
|
||||
OPT_KEYVALUELIST("o", avopts, 0),
|
||||
{0}
|
||||
},
|
||||
@@ -78,13 +79,12 @@ static int init(struct dec_audio *da, const char *decoder)
|
||||
struct ad_lavc_params *opts = mpopts->ad_lavc_params;
|
||||
AVCodecContext *lavc_context;
|
||||
AVCodec *lavc_codec;
|
||||
struct sh_stream *sh = da->header;
|
||||
struct sh_audio *sh_audio = sh->audio;
|
||||
struct mp_codec_params *c = da->codec;
|
||||
|
||||
struct priv *ctx = talloc_zero(NULL, struct priv);
|
||||
da->priv = ctx;
|
||||
|
||||
ctx->force_channel_map = sh_audio->force_channels;
|
||||
ctx->force_channel_map = c->force_channels;
|
||||
|
||||
lavc_codec = avcodec_find_decoder_by_name(decoder);
|
||||
if (!lavc_codec) {
|
||||
@@ -116,20 +116,20 @@ static int init(struct dec_audio *da, const char *decoder)
|
||||
|
||||
mp_set_avopts(da->log, lavc_context, opts->avopts);
|
||||
|
||||
lavc_context->codec_tag = sh->codec_tag;
|
||||
lavc_context->sample_rate = sh_audio->samplerate;
|
||||
lavc_context->bit_rate = sh_audio->bitrate;
|
||||
lavc_context->block_align = sh_audio->block_align;
|
||||
lavc_context->bits_per_coded_sample = sh_audio->bits_per_coded_sample;
|
||||
lavc_context->channels = sh_audio->channels.num;
|
||||
if (!mp_chmap_is_unknown(&sh_audio->channels))
|
||||
lavc_context->channel_layout = mp_chmap_to_lavc(&sh_audio->channels);
|
||||
lavc_context->codec_tag = c->codec_tag;
|
||||
lavc_context->sample_rate = c->samplerate;
|
||||
lavc_context->bit_rate = c->bitrate;
|
||||
lavc_context->block_align = c->block_align;
|
||||
lavc_context->bits_per_coded_sample = c->bits_per_coded_sample;
|
||||
lavc_context->channels = c->channels.num;
|
||||
if (!mp_chmap_is_unknown(&c->channels))
|
||||
lavc_context->channel_layout = mp_chmap_to_lavc(&c->channels);
|
||||
|
||||
// demux_mkv
|
||||
mp_lavc_set_extradata(lavc_context, sh->extradata, sh->extradata_size);
|
||||
mp_lavc_set_extradata(lavc_context, c->extradata, c->extradata_size);
|
||||
|
||||
if (sh->lav_headers)
|
||||
mp_copy_lav_codec_headers(lavc_context, sh->lav_headers);
|
||||
if (c->lav_headers)
|
||||
mp_copy_lav_codec_headers(lavc_context, c->lav_headers);
|
||||
|
||||
mp_set_avcodec_threads(da->log, lavc_context, opts->threads);
|
||||
|
||||
@@ -140,6 +140,8 @@ static int init(struct dec_audio *da, const char *decoder)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->next_pts = MP_NOPTS_VALUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -165,38 +167,26 @@ static int control(struct dec_audio *da, int cmd, void *arg)
|
||||
switch (cmd) {
|
||||
case ADCTRL_RESET:
|
||||
avcodec_flush_buffers(ctx->avctx);
|
||||
talloc_free(ctx->packet);
|
||||
ctx->packet = NULL;
|
||||
ctx->skip_samples = 0;
|
||||
ctx->trim_samples = 0;
|
||||
ctx->preroll_done = false;
|
||||
ctx->next_pts = MP_NOPTS_VALUE;
|
||||
return CONTROL_TRUE;
|
||||
}
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
|
||||
static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
|
||||
struct mp_audio **out)
|
||||
{
|
||||
struct priv *priv = da->priv;
|
||||
AVCodecContext *avctx = priv->avctx;
|
||||
|
||||
struct demux_packet *mpkt = priv->packet;
|
||||
if (!mpkt) {
|
||||
if (demux_read_packet_async(da->header, &mpkt) == 0)
|
||||
return AD_WAIT;
|
||||
}
|
||||
|
||||
priv->packet = talloc_steal(priv, mpkt);
|
||||
|
||||
int in_len = mpkt ? mpkt->len : 0;
|
||||
|
||||
AVPacket pkt;
|
||||
mp_set_av_packet(&pkt, mpkt, NULL);
|
||||
|
||||
// If we don't have a PTS yet, use the first packet PTS we can get.
|
||||
if (da->pts == MP_NOPTS_VALUE && mpkt && mpkt->pts != MP_NOPTS_VALUE) {
|
||||
da->pts = mpkt->pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
|
||||
int got_frame = 0;
|
||||
av_frame_unref(priv->avframe);
|
||||
int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
|
||||
@@ -209,59 +199,69 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
mpkt->len -= ret;
|
||||
mpkt->pts = MP_NOPTS_VALUE; // don't reset PTS next time
|
||||
}
|
||||
if (mpkt->len == 0 || ret < 0) {
|
||||
talloc_free(mpkt);
|
||||
priv->packet = NULL;
|
||||
}
|
||||
// LATM may need many packets to find mux info
|
||||
if (ret == AVERROR(EAGAIN))
|
||||
return AD_OK;
|
||||
if (ret == AVERROR(EAGAIN)) {
|
||||
mpkt->len = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (ret < 0) {
|
||||
MP_ERR(da, "Error decoding audio.\n");
|
||||
return AD_ERR;
|
||||
return -1;
|
||||
}
|
||||
if (!got_frame)
|
||||
return mpkt ? AD_OK : AD_EOF;
|
||||
return 0;
|
||||
|
||||
double out_pts = mp_pts_from_av(priv->avframe->pkt_pts, NULL);
|
||||
if (out_pts != MP_NOPTS_VALUE) {
|
||||
da->pts = out_pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
|
||||
struct mp_audio *mpframe = mp_audio_from_avframe(priv->avframe);
|
||||
if (!mpframe)
|
||||
return AD_ERR;
|
||||
return -1;
|
||||
|
||||
struct mp_chmap lavc_chmap = mpframe->channels;
|
||||
if (lavc_chmap.num != avctx->channels)
|
||||
mp_chmap_from_channels(&lavc_chmap, avctx->channels);
|
||||
if (priv->force_channel_map) {
|
||||
struct sh_audio *sh_audio = da->header->audio;
|
||||
if (lavc_chmap.num == sh_audio->channels.num)
|
||||
lavc_chmap = sh_audio->channels;
|
||||
if (lavc_chmap.num == da->codec->channels.num)
|
||||
lavc_chmap = da->codec->channels;
|
||||
}
|
||||
mp_audio_set_channels(mpframe, &lavc_chmap);
|
||||
|
||||
mpframe->pts = out_pts;
|
||||
|
||||
if (mpframe->pts == MP_NOPTS_VALUE)
|
||||
mpframe->pts = priv->next_pts;
|
||||
if (mpframe->pts != MP_NOPTS_VALUE)
|
||||
priv->next_pts = mpframe->pts + mpframe->samples / (double)mpframe->rate;
|
||||
|
||||
#if HAVE_AVFRAME_SKIP_SAMPLES
|
||||
AVFrameSideData *sd =
|
||||
av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES);
|
||||
if (sd && sd->size >= 10) {
|
||||
char *d = sd->data;
|
||||
priv->skip_samples += AV_RL32(d + 0);
|
||||
uint32_t pad = AV_RL32(d + 4);
|
||||
uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples);
|
||||
if (skip) {
|
||||
mp_audio_skip_samples(mpframe, skip);
|
||||
da->pts_offset += skip;
|
||||
priv->skip_samples -= skip;
|
||||
}
|
||||
if (pad <= mpframe->samples)
|
||||
mpframe->samples -= pad;
|
||||
priv->trim_samples += AV_RL32(d + 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!priv->preroll_done) {
|
||||
// Skip only if this isn't already handled by AV_FRAME_DATA_SKIP_SAMPLES.
|
||||
if (!priv->skip_samples)
|
||||
priv->skip_samples = avctx->delay;
|
||||
priv->preroll_done = true;
|
||||
}
|
||||
|
||||
uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples);
|
||||
if (skip) {
|
||||
mp_audio_skip_samples(mpframe, skip);
|
||||
priv->skip_samples -= skip;
|
||||
}
|
||||
uint32_t trim = MPMIN(priv->trim_samples, mpframe->samples);
|
||||
if (trim) {
|
||||
mpframe->samples -= trim;
|
||||
priv->trim_samples -= trim;
|
||||
}
|
||||
|
||||
*out = mpframe;
|
||||
|
||||
av_frame_unref(priv->avframe);
|
||||
|
||||
+15
-16
@@ -41,6 +41,7 @@ struct spdifContext {
|
||||
bool need_close;
|
||||
bool use_dts_hd;
|
||||
struct mp_audio fmt;
|
||||
struct mp_audio_pool *pool;
|
||||
};
|
||||
|
||||
static int write_packet(void *p, uint8_t *buf, int buf_size)
|
||||
@@ -79,6 +80,7 @@ static int init(struct dec_audio *da, const char *decoder)
|
||||
da->priv = spdif_ctx;
|
||||
spdif_ctx->log = da->log;
|
||||
spdif_ctx->use_dts_hd = da->opts->dtshd;
|
||||
spdif_ctx->pool = mp_audio_pool_create(spdif_ctx);
|
||||
|
||||
if (strcmp(decoder, "dts-hd") == 0) {
|
||||
decoder = "dts";
|
||||
@@ -189,7 +191,8 @@ static int init_filter(struct dec_audio *da, AVPacket *pkt)
|
||||
break;
|
||||
case AV_CODEC_ID_DTS: {
|
||||
bool is_hd = profile == FF_PROFILE_DTS_HD_HRA ||
|
||||
profile == FF_PROFILE_DTS_HD_MA;
|
||||
profile == FF_PROFILE_DTS_HD_MA ||
|
||||
profile == FF_PROFILE_UNKNOWN;
|
||||
if (spdif_ctx->use_dts_hd && is_hd) {
|
||||
av_dict_set(&format_opts, "dtshd_rate", "768000", 0); // 4*192000
|
||||
sample_format = AF_FORMAT_S_DTSHD;
|
||||
@@ -240,42 +243,38 @@ fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int decode_packet(struct dec_audio *da, struct mp_audio **out)
|
||||
static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
|
||||
struct mp_audio **out)
|
||||
{
|
||||
struct spdifContext *spdif_ctx = da->priv;
|
||||
|
||||
spdif_ctx->out_buffer_len = 0;
|
||||
|
||||
struct demux_packet *mpkt;
|
||||
if (demux_read_packet_async(da->header, &mpkt) == 0)
|
||||
return AD_WAIT;
|
||||
|
||||
if (!mpkt)
|
||||
return AD_EOF;
|
||||
return 0;
|
||||
|
||||
double pts = mpkt->pts;
|
||||
|
||||
AVPacket pkt;
|
||||
mp_set_av_packet(&pkt, mpkt, NULL);
|
||||
mpkt->len = 0; // will be fully consumed
|
||||
pkt.pts = pkt.dts = 0;
|
||||
if (mpkt->pts != MP_NOPTS_VALUE) {
|
||||
da->pts = mpkt->pts;
|
||||
da->pts_offset = 0;
|
||||
}
|
||||
if (!spdif_ctx->lavf_ctx) {
|
||||
if (init_filter(da, &pkt) < 0)
|
||||
return AD_ERR;
|
||||
return -1;
|
||||
}
|
||||
int ret = av_write_frame(spdif_ctx->lavf_ctx, &pkt);
|
||||
talloc_free(mpkt);
|
||||
avio_flush(spdif_ctx->lavf_ctx->pb);
|
||||
if (ret < 0)
|
||||
return AD_ERR;
|
||||
return -1;
|
||||
|
||||
int samples = spdif_ctx->out_buffer_len / spdif_ctx->fmt.sstride;
|
||||
*out = mp_audio_pool_get(da->pool, &spdif_ctx->fmt, samples);
|
||||
*out = mp_audio_pool_get(spdif_ctx->pool, &spdif_ctx->fmt, samples);
|
||||
if (!*out)
|
||||
return AD_ERR;
|
||||
return -1;
|
||||
|
||||
memcpy((*out)->planes[0], spdif_ctx->out_buffer, spdif_ctx->out_buffer_len);
|
||||
(*out)->pts = pts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+122
-102
@@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <libavutil/mem.h>
|
||||
@@ -60,8 +61,6 @@ static void uninit_decoder(struct dec_audio *d_audio)
|
||||
d_audio->ad_driver = NULL;
|
||||
talloc_free(d_audio->priv);
|
||||
d_audio->priv = NULL;
|
||||
d_audio->afilter->initialized = -1;
|
||||
d_audio->decode_format = (struct mp_audio){0};
|
||||
}
|
||||
|
||||
static int init_audio_codec(struct dec_audio *d_audio, const char *decoder)
|
||||
@@ -87,12 +86,12 @@ struct mp_decoder_list *audio_decoder_list(void)
|
||||
static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio)
|
||||
{
|
||||
struct MPOpts *opts = d_audio->opts;
|
||||
const char *codec = d_audio->header->codec;
|
||||
const char *codec = d_audio->codec->codec;
|
||||
|
||||
struct mp_decoder_list *list = audio_decoder_list();
|
||||
struct mp_decoder_list *new =
|
||||
mp_select_decoders(list, codec, opts->audio_decoders);
|
||||
if (d_audio->spdif_passthrough) {
|
||||
if (d_audio->try_spdif) {
|
||||
struct mp_decoder_list *spdif =
|
||||
mp_select_decoder_list(list, codec, "spdif", opts->audio_spdif);
|
||||
mp_append_decoders(spdif, new);
|
||||
@@ -145,7 +144,7 @@ int audio_init_best_codec(struct dec_audio *d_audio)
|
||||
MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc);
|
||||
} else {
|
||||
MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
|
||||
d_audio->header->codec ? d_audio->header->codec : "<unknown>");
|
||||
d_audio->codec->codec);
|
||||
}
|
||||
|
||||
talloc_free(list);
|
||||
@@ -156,111 +155,132 @@ void audio_uninit(struct dec_audio *d_audio)
|
||||
{
|
||||
if (!d_audio)
|
||||
return;
|
||||
MP_VERBOSE(d_audio, "Uninit audio filters...\n");
|
||||
uninit_decoder(d_audio);
|
||||
af_destroy(d_audio->afilter);
|
||||
talloc_free(d_audio->waiting);
|
||||
talloc_free(d_audio);
|
||||
}
|
||||
|
||||
static int decode_new_frame(struct dec_audio *da)
|
||||
{
|
||||
while (!da->waiting) {
|
||||
int ret = da->ad_driver->decode_packet(da, &da->waiting);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps)
|
||||
da->pts = 0;
|
||||
|
||||
if (da->waiting) {
|
||||
da->pts_offset += da->waiting->samples;
|
||||
da->decode_format = *da->waiting;
|
||||
mp_audio_set_null_data(&da->decode_format);
|
||||
}
|
||||
}
|
||||
return mp_audio_config_valid(da->waiting) ? AD_OK : AD_ERR;
|
||||
}
|
||||
|
||||
/* Decode packets until we know the audio format. Then reinit the buffer.
|
||||
* Returns AD_OK on success, negative AD_* code otherwise.
|
||||
* Also returns AD_OK if already initialized (and does nothing).
|
||||
*/
|
||||
int initial_audio_decode(struct dec_audio *da)
|
||||
{
|
||||
return decode_new_frame(da);
|
||||
}
|
||||
|
||||
static bool copy_output(struct af_stream *afs, struct mp_audio_buffer *outbuf,
|
||||
int minsamples, bool eof)
|
||||
{
|
||||
while (mp_audio_buffer_samples(outbuf) < minsamples) {
|
||||
if (af_output_frame(afs, eof) < 0)
|
||||
return true; // error, stop doing stuff
|
||||
struct mp_audio *mpa = af_read_output_frame(afs);
|
||||
if (!mpa)
|
||||
return false; // out of data
|
||||
mp_audio_buffer_append(outbuf, mpa);
|
||||
talloc_free(mpa);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Try to get at least minsamples decoded+filtered samples in outbuf
|
||||
* (total length including possible existing data).
|
||||
* Return 0 on success, or negative AD_* error code.
|
||||
* In the former case outbuf has at least minsamples buffered on return.
|
||||
* In case of EOF/error it might or might not be. */
|
||||
int audio_decode(struct dec_audio *da, struct mp_audio_buffer *outbuf,
|
||||
int minsamples)
|
||||
{
|
||||
struct af_stream *afs = da->afilter;
|
||||
if (afs->initialized < 1)
|
||||
return AD_ERR;
|
||||
|
||||
MP_STATS(da, "start audio");
|
||||
|
||||
int res;
|
||||
while (1) {
|
||||
res = 0;
|
||||
|
||||
if (copy_output(afs, outbuf, minsamples, false))
|
||||
break;
|
||||
|
||||
res = decode_new_frame(da);
|
||||
if (res < 0) {
|
||||
// drain filters first (especially for true EOF case)
|
||||
copy_output(afs, outbuf, minsamples, true);
|
||||
break;
|
||||
}
|
||||
|
||||
// On format change, make sure to drain the filter chain.
|
||||
if (!mp_audio_config_equals(&afs->input, da->waiting)) {
|
||||
copy_output(afs, outbuf, minsamples, true);
|
||||
res = AD_NEW_FMT;
|
||||
break;
|
||||
}
|
||||
|
||||
struct mp_audio *mpa = da->waiting;
|
||||
da->waiting = NULL;
|
||||
if (af_filter_frame(afs, mpa) < 0)
|
||||
return AD_ERR;
|
||||
}
|
||||
|
||||
MP_STATS(da, "end audio");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void audio_reset_decoding(struct dec_audio *d_audio)
|
||||
{
|
||||
if (d_audio->ad_driver)
|
||||
d_audio->ad_driver->control(d_audio, ADCTRL_RESET, NULL);
|
||||
af_seek_reset(d_audio->afilter);
|
||||
d_audio->pts = MP_NOPTS_VALUE;
|
||||
d_audio->pts_offset = 0;
|
||||
if (d_audio->waiting) {
|
||||
talloc_free(d_audio->waiting);
|
||||
d_audio->waiting = NULL;
|
||||
talloc_free(d_audio->current_frame);
|
||||
d_audio->current_frame = NULL;
|
||||
talloc_free(d_audio->packet);
|
||||
d_audio->packet = NULL;
|
||||
talloc_free(d_audio->new_segment);
|
||||
d_audio->new_segment = NULL;
|
||||
d_audio->start = d_audio->end = MP_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
static void fix_audio_pts(struct dec_audio *da)
|
||||
{
|
||||
if (!da->current_frame)
|
||||
return;
|
||||
|
||||
if (da->current_frame->pts != MP_NOPTS_VALUE) {
|
||||
double newpts = da->current_frame->pts;
|
||||
// Keep the interpolated timestamp if it doesn't deviate more
|
||||
// than 1 ms from the real one. (MKV rounded timestamps.)
|
||||
if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - newpts) > 0.001)
|
||||
da->pts = da->current_frame->pts;
|
||||
}
|
||||
|
||||
if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps)
|
||||
da->pts = 0;
|
||||
|
||||
da->current_frame->pts = da->pts;
|
||||
|
||||
if (da->pts != MP_NOPTS_VALUE)
|
||||
da->pts += da->current_frame->samples / (double)da->current_frame->rate;
|
||||
}
|
||||
|
||||
void audio_work(struct dec_audio *da)
|
||||
{
|
||||
if (da->current_frame)
|
||||
return;
|
||||
|
||||
if (!da->packet && demux_read_packet_async(da->header, &da->packet) == 0) {
|
||||
da->current_state = DATA_WAIT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (da->packet && da->packet->new_segment) {
|
||||
assert(!da->new_segment);
|
||||
da->new_segment = da->packet;
|
||||
da->packet = NULL;
|
||||
}
|
||||
|
||||
bool had_packet = da->packet || da->new_segment;
|
||||
|
||||
int ret = da->ad_driver->decode_packet(da, da->packet, &da->current_frame);
|
||||
if (ret < 0 || (da->packet && da->packet->len == 0)) {
|
||||
talloc_free(da->packet);
|
||||
da->packet = NULL;
|
||||
}
|
||||
|
||||
if (da->current_frame && !mp_audio_config_valid(da->current_frame)) {
|
||||
talloc_free(da->current_frame);
|
||||
da->current_frame = NULL;
|
||||
}
|
||||
|
||||
da->current_state = DATA_OK;
|
||||
if (!da->current_frame) {
|
||||
da->current_state = DATA_EOF;
|
||||
if (had_packet)
|
||||
da->current_state = DATA_AGAIN;
|
||||
}
|
||||
|
||||
fix_audio_pts(da);
|
||||
|
||||
bool segment_end = true;
|
||||
|
||||
if (da->current_frame) {
|
||||
mp_audio_clip_timestamps(da->current_frame, da->start, da->end);
|
||||
if (da->current_frame->pts != MP_NOPTS_VALUE && da->start != MP_NOPTS_VALUE)
|
||||
segment_end = da->current_frame->pts >= da->start;
|
||||
if (da->current_frame->samples == 0) {
|
||||
talloc_free(da->current_frame);
|
||||
da->current_frame = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// If there's a new segment, start it as soon as we're drained/finished.
|
||||
if (segment_end && da->new_segment) {
|
||||
struct demux_packet *new_segment = da->new_segment;
|
||||
da->new_segment = NULL;
|
||||
|
||||
// Could avoid decoder reinit; would still need flush.
|
||||
da->codec = new_segment->codec;
|
||||
if (da->ad_driver)
|
||||
da->ad_driver->uninit(da);
|
||||
da->ad_driver = NULL;
|
||||
audio_init_best_codec(da);
|
||||
|
||||
da->start = new_segment->start;
|
||||
da->end = new_segment->end;
|
||||
|
||||
new_segment->new_segment = false;
|
||||
|
||||
da->packet = new_segment;
|
||||
da->current_state = DATA_AGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch an audio frame decoded with audio_work(). Returns one of:
|
||||
// DATA_OK: *out_frame is set to a new image
|
||||
// DATA_WAIT: waiting for demuxer; will receive a wakeup signal
|
||||
// DATA_EOF: end of file, no more frames to be expected
|
||||
// DATA_AGAIN: dropped frame or something similar
|
||||
int audio_get_frame(struct dec_audio *da, struct mp_audio **out_frame)
|
||||
{
|
||||
*out_frame = NULL;
|
||||
if (da->current_frame) {
|
||||
*out_frame = da->current_frame;
|
||||
da->current_frame = NULL;
|
||||
return DATA_OK;
|
||||
}
|
||||
if (da->current_state == DATA_OK)
|
||||
return DATA_AGAIN;
|
||||
return da->current_state;
|
||||
}
|
||||
+17
-23
@@ -30,39 +30,33 @@ struct dec_audio {
|
||||
struct mp_log *log;
|
||||
struct MPOpts *opts;
|
||||
struct mpv_global *global;
|
||||
bool spdif_passthrough;
|
||||
const struct ad_functions *ad_driver;
|
||||
struct sh_stream *header;
|
||||
struct af_stream *afilter;
|
||||
struct mp_codec_params *codec;
|
||||
char *decoder_desc;
|
||||
int init_retries;
|
||||
struct mp_audio_pool *pool;
|
||||
struct mp_audio decode_format;
|
||||
struct mp_audio *waiting; // used on format-change
|
||||
// set by decoder
|
||||
int bitrate; // input bitrate, can change with VBR sources
|
||||
// last known pts value in output from decoder
|
||||
double pts;
|
||||
// number of samples output by decoder after last known pts
|
||||
int pts_offset;
|
||||
|
||||
bool try_spdif;
|
||||
|
||||
// For free use by the ad_driver
|
||||
void *priv;
|
||||
};
|
||||
|
||||
enum {
|
||||
AD_OK = 0,
|
||||
AD_ERR = -1,
|
||||
AD_EOF = -2,
|
||||
AD_NEW_FMT = -3,
|
||||
AD_WAIT = -4,
|
||||
// Strictly internal (dec_audio.c).
|
||||
|
||||
double pts; // endpts of previous frame
|
||||
double start, end;
|
||||
struct demux_packet *packet;
|
||||
struct demux_packet *new_segment;
|
||||
struct mp_audio *current_frame;
|
||||
int current_state;
|
||||
};
|
||||
|
||||
struct mp_decoder_list *audio_decoder_list(void);
|
||||
int audio_init_best_codec(struct dec_audio *d_audio);
|
||||
int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
|
||||
int minsamples);
|
||||
int initial_audio_decode(struct dec_audio *d_audio);
|
||||
void audio_reset_decoding(struct dec_audio *d_audio);
|
||||
void audio_uninit(struct dec_audio *d_audio);
|
||||
|
||||
void audio_work(struct dec_audio *d_audio);
|
||||
int audio_get_frame(struct dec_audio *d_audio, struct mp_audio **out_frame);
|
||||
|
||||
void audio_reset_decoding(struct dec_audio *d_audio);
|
||||
|
||||
#endif /* MPLAYER_DEC_AUDIO_H */
|
||||
+27
-43
@@ -34,23 +34,12 @@
|
||||
extern const struct af_info af_info_delay;
|
||||
extern const struct af_info af_info_channels;
|
||||
extern const struct af_info af_info_format;
|
||||
extern const struct af_info af_info_force;
|
||||
extern const struct af_info af_info_volume;
|
||||
extern const struct af_info af_info_equalizer;
|
||||
extern const struct af_info af_info_pan;
|
||||
extern const struct af_info af_info_surround;
|
||||
extern const struct af_info af_info_sub;
|
||||
extern const struct af_info af_info_export;
|
||||
extern const struct af_info af_info_drc;
|
||||
extern const struct af_info af_info_extrastereo;
|
||||
extern const struct af_info af_info_lavcac3enc;
|
||||
extern const struct af_info af_info_lavrresample;
|
||||
extern const struct af_info af_info_sweep;
|
||||
extern const struct af_info af_info_hrtf;
|
||||
extern const struct af_info af_info_ladspa;
|
||||
extern const struct af_info af_info_center;
|
||||
extern const struct af_info af_info_sinesuppress;
|
||||
extern const struct af_info af_info_karaoke;
|
||||
extern const struct af_info af_info_scaletempo;
|
||||
extern const struct af_info af_info_bs2b;
|
||||
extern const struct af_info af_info_lavfi;
|
||||
@@ -63,31 +52,14 @@ static const struct af_info *const filter_list[] = {
|
||||
&af_info_volume,
|
||||
&af_info_equalizer,
|
||||
&af_info_pan,
|
||||
&af_info_surround,
|
||||
&af_info_sub,
|
||||
&af_info_export,
|
||||
&af_info_drc,
|
||||
&af_info_extrastereo,
|
||||
&af_info_lavcac3enc,
|
||||
&af_info_lavrresample,
|
||||
&af_info_sweep,
|
||||
&af_info_hrtf,
|
||||
#if HAVE_LADSPA
|
||||
&af_info_ladspa,
|
||||
#endif
|
||||
#if HAVE_RUBBERBAND
|
||||
&af_info_rubberband,
|
||||
#endif
|
||||
&af_info_center,
|
||||
&af_info_sinesuppress,
|
||||
&af_info_karaoke,
|
||||
&af_info_scaletempo,
|
||||
#if HAVE_LIBBS2B
|
||||
&af_info_bs2b,
|
||||
#endif
|
||||
#if HAVE_LIBAVFILTER
|
||||
&af_info_lavfi,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -185,26 +157,14 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
|
||||
MP_ERR(s, "Couldn't find audio filter '%s'.\n", name);
|
||||
return NULL;
|
||||
}
|
||||
const struct af_info *info = desc.p;
|
||||
/* Make sure that the filter is not already in the list if it is
|
||||
non-reentrant */
|
||||
if (info->flags & AF_FLAGS_NOT_REENTRANT) {
|
||||
for (struct af_instance *cur = s->first; cur; cur = cur->next) {
|
||||
if (cur->info == info) {
|
||||
MP_ERR(s, "There can only be one "
|
||||
"instance of the filter '%s' in each stream\n", name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MP_VERBOSE(s, "Adding filter %s \n", name);
|
||||
|
||||
struct af_instance *af = talloc_zero(NULL, struct af_instance);
|
||||
*af = (struct af_instance) {
|
||||
.info = info,
|
||||
.info = desc.p,
|
||||
.data = talloc_zero(af, struct mp_audio),
|
||||
.log = mp_log_new(af, s->log, name),
|
||||
.opts = s->opts,
|
||||
.replaygain_data = s->replaygain_data,
|
||||
.out_pool = mp_audio_pool_create(af),
|
||||
};
|
||||
@@ -500,7 +460,8 @@ static int af_reinit(struct af_stream *s)
|
||||
struct af_instance *aft = af->prev;
|
||||
af_remove(s, af);
|
||||
af = aft->next;
|
||||
break;
|
||||
retry++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
goto negotiate_error;
|
||||
@@ -721,6 +682,29 @@ void af_control_all(struct af_stream *s, int cmd, void *arg)
|
||||
af->control(af, cmd, arg);
|
||||
}
|
||||
|
||||
int af_control_by_label(struct af_stream *s, int cmd, void *arg, bstr label)
|
||||
{
|
||||
char *label_str = bstrdup0(NULL, label);
|
||||
struct af_instance *cur = af_find_by_label(s, label_str);
|
||||
talloc_free(label_str);
|
||||
if (cur) {
|
||||
return cur->control ? cur->control(cur, cmd, arg) : CONTROL_NA;
|
||||
} else {
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
int af_send_command(struct af_stream *s, char *label, char *cmd, char *arg)
|
||||
{
|
||||
char *args[2] = {cmd, arg};
|
||||
if (strcmp(label, "all") == 0) {
|
||||
af_control_all(s, AF_CONTROL_COMMAND, args);
|
||||
return 0;
|
||||
} else {
|
||||
return af_control_by_label(s, AF_CONTROL_COMMAND, args, bstr0(label));
|
||||
}
|
||||
}
|
||||
|
||||
// Used by filters to add a filtered frame to the output queue.
|
||||
// Ownership of frame is transferred from caller to the filter chain.
|
||||
void af_add_output_frame(struct af_instance *af, struct mp_audio *frame)
|
||||
|
||||
+12
-12
@@ -27,6 +27,7 @@
|
||||
#include "audio/chmap.h"
|
||||
#include "audio/audio.h"
|
||||
#include "common/msg.h"
|
||||
#include "common/common.h"
|
||||
|
||||
struct af_instance;
|
||||
struct mpv_global;
|
||||
@@ -34,10 +35,6 @@ struct mpv_global;
|
||||
// Number of channels
|
||||
#define AF_NCH MP_NUM_CHANNELS
|
||||
|
||||
// Flags used for defining the behavior of an audio filter
|
||||
#define AF_FLAGS_REENTRANT 0x00000000
|
||||
#define AF_FLAGS_NOT_REENTRANT 0x00000001
|
||||
|
||||
// Flags for af->filter()
|
||||
#define AF_FILTER_FLAG_EOF 1
|
||||
|
||||
@@ -46,7 +43,6 @@ struct mpv_global;
|
||||
struct af_info {
|
||||
const char *info;
|
||||
const char *name;
|
||||
const int flags;
|
||||
int (*open)(struct af_instance *vf);
|
||||
int priv_size;
|
||||
const void *priv_defaults;
|
||||
@@ -57,6 +53,7 @@ struct af_info {
|
||||
struct af_instance {
|
||||
const struct af_info *info;
|
||||
struct mp_log *log;
|
||||
struct MPOpts *opts;
|
||||
struct replaygain_data *replaygain_data;
|
||||
int (*control)(struct af_instance *af, int cmd, void *arg);
|
||||
void (*uninit)(struct af_instance *af);
|
||||
@@ -104,13 +101,12 @@ struct af_stream {
|
||||
};
|
||||
|
||||
// Return values
|
||||
#define AF_DETACH 2
|
||||
#define AF_OK 1
|
||||
#define AF_TRUE 1
|
||||
#define AF_FALSE 0
|
||||
#define AF_UNKNOWN -1
|
||||
#define AF_ERROR -2
|
||||
#define AF_FATAL -3
|
||||
#define AF_DETACH (CONTROL_OK + 1)
|
||||
#define AF_OK CONTROL_OK
|
||||
#define AF_TRUE CONTROL_TRUE
|
||||
#define AF_FALSE CONTROL_FALSE
|
||||
#define AF_UNKNOWN CONTROL_UNKNOWN
|
||||
#define AF_ERROR CONTROL_ERROR
|
||||
|
||||
// Parameters for af_control_*
|
||||
enum af_control {
|
||||
@@ -127,6 +123,8 @@ enum af_control {
|
||||
AF_CONTROL_GET_PAN_BALANCE,
|
||||
AF_CONTROL_SET_PLAYBACK_SPEED,
|
||||
AF_CONTROL_SET_PLAYBACK_SPEED_RESAMPLE,
|
||||
AF_CONTROL_GET_METADATA,
|
||||
AF_CONTROL_COMMAND,
|
||||
};
|
||||
|
||||
// Argument for AF_CONTROL_SET_PAN_LEVEL
|
||||
@@ -145,7 +143,9 @@ int af_remove_by_label(struct af_stream *s, char *label);
|
||||
struct af_instance *af_find_by_label(struct af_stream *s, char *label);
|
||||
struct af_instance *af_control_any_rev(struct af_stream *s, int cmd, void *arg);
|
||||
void af_control_all(struct af_stream *s, int cmd, void *arg);
|
||||
int af_control_by_label(struct af_stream *s, int cmd, void *arg, bstr label);
|
||||
void af_seek_reset(struct af_stream *s);
|
||||
int af_send_command(struct af_stream *s, char *label, char *cmd, char *arg);
|
||||
|
||||
void af_add_output_frame(struct af_instance *af, struct mp_audio *frame);
|
||||
int af_filter_frame(struct af_stream *s, struct mp_audio *frame);
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* The Bauer stereophonic-to-binaural DSP using bs2b library:
|
||||
* http://bs2b.sourceforge.net/
|
||||
*
|
||||
* Copyright (c) 2009 Andrew Savchenko
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <bs2b.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "af.h"
|
||||
#include "options/m_option.h"
|
||||
|
||||
/// Internal specific data of the filter
|
||||
struct af_bs2b {
|
||||
int fcut; ///< cut frequency in Hz
|
||||
int feed; ///< feed level for low frequencies in 0.1*dB
|
||||
int profile ; ///< profile (available crossfeed presets)
|
||||
t_bs2bdp filter; ///< instance of a library filter
|
||||
};
|
||||
|
||||
#define DEF_FILTER(fmt, name) \
|
||||
static int filter_##name(struct af_instance *af, struct mp_audio *data) \
|
||||
{ \
|
||||
if (!data) \
|
||||
return 0; \
|
||||
if (af_make_writeable(af, data) < 0) { \
|
||||
talloc_free(data); \
|
||||
return -1; \
|
||||
} \
|
||||
bs2b_cross_feed_##name(((struct af_bs2b*)(af->priv))->filter, \
|
||||
(data->planes[0]), data->samples); \
|
||||
af_add_output_frame(af, data); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define GET_FILTER(fmt, name) \
|
||||
case AF_FORMAT_##fmt: return filter_##name;
|
||||
|
||||
#define FILTERS \
|
||||
FILTER(FLOAT, f) \
|
||||
FILTER(S32, s32) \
|
||||
FILTER(S24, s24) \
|
||||
FILTER(S16, s16) \
|
||||
FILTER(U8, u8)
|
||||
|
||||
#define FILTER DEF_FILTER
|
||||
FILTERS
|
||||
#undef FILTER
|
||||
|
||||
typedef int (*filter)(struct af_instance *af, struct mp_audio *d);
|
||||
static filter get_filter(int fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
#define FILTER GET_FILTER
|
||||
FILTERS
|
||||
#undef FILTER
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialization and runtime control
|
||||
static int control(struct af_instance *af, int cmd, void *arg)
|
||||
{
|
||||
struct af_bs2b *s = af->priv;
|
||||
|
||||
switch (cmd) {
|
||||
case AF_CONTROL_REINIT: {
|
||||
int format;
|
||||
// Sanity check
|
||||
if (!arg) return AF_ERROR;
|
||||
|
||||
format = ((struct mp_audio*)arg)->format;
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
mp_audio_set_num_channels(af->data, 2); // bs2b is useful only for 2ch audio
|
||||
mp_audio_set_format(af->data, format);
|
||||
|
||||
/* check for formats supported by libbs2b
|
||||
and assign corresponding handlers */
|
||||
af->filter_frame = get_filter(format);
|
||||
if (!af->filter_frame) {
|
||||
af->filter_frame = filter_f;
|
||||
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
|
||||
}
|
||||
|
||||
// bs2b have srate limits, try to resample if needed
|
||||
if (af->data->rate > BS2B_MAXSRATE || af->data->rate < BS2B_MINSRATE) {
|
||||
af->data->rate = BS2B_DEFAULT_SRATE;
|
||||
MP_WARN(af, "Requested sample rate %d Hz is out of bounds [%d..%d] Hz.\n"
|
||||
"Trying to resample to %d Hz.\n",
|
||||
af->data->rate, BS2B_MINSRATE, BS2B_MAXSRATE, BS2B_DEFAULT_SRATE);
|
||||
}
|
||||
bs2b_set_srate(s->filter, (long)af->data->rate);
|
||||
MP_VERBOSE(af, "using format %s\n",
|
||||
af_fmt_to_str(af->data->format));
|
||||
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
/// Deallocate memory and close library
|
||||
static void uninit(struct af_instance *af)
|
||||
{
|
||||
struct af_bs2b *s = af->priv;
|
||||
if (s->filter)
|
||||
bs2b_close(s->filter);
|
||||
}
|
||||
|
||||
/// Allocate memory, set function pointers and init library
|
||||
static int af_open(struct af_instance *af)
|
||||
{
|
||||
struct af_bs2b *s = af->priv;
|
||||
af->control = control;
|
||||
af->uninit = uninit;
|
||||
|
||||
// NULL means failed initialization
|
||||
if (!(s->filter = bs2b_open())) {
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
if (s->profile)
|
||||
bs2b_set_level(s->filter, s->profile);
|
||||
// set fcut and feed only if specified, otherwise defaults will be used
|
||||
if (s->fcut)
|
||||
bs2b_set_level_fcut(s->filter, s->fcut);
|
||||
if (s->feed)
|
||||
bs2b_set_level_feed(s->filter, s->feed);
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT struct af_bs2b
|
||||
|
||||
/// Description of this filter
|
||||
const struct af_info af_info_bs2b = {
|
||||
.info = "Bauer stereophonic-to-binaural audio filter",
|
||||
.name = "bs2b",
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(struct af_bs2b),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_INTRANGE("fcut", fcut, 0, BS2B_MINFCUT, BS2B_MAXFCUT),
|
||||
OPT_INTRANGE("feed", feed, 0, BS2B_MINFEED, BS2B_MAXFEED),
|
||||
OPT_CHOICE("profile", profile, 0,
|
||||
({"unset", 0},
|
||||
{"default", BS2B_DEFAULT_CLEVEL},
|
||||
{"cmoy", BS2B_CMOY_CLEVEL},
|
||||
{"jmeier", BS2B_JMEIER_CLEVEL})),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* This filter adds a center channel to the audio stream by
|
||||
* averaging the left and right channel.
|
||||
* There are two runtime controls one for setting which channel
|
||||
* to insert the center-audio into called AF_CONTROL_SUB_CH.
|
||||
*
|
||||
* FIXME: implement a high-pass filter for better results.
|
||||
*
|
||||
* copyright (c) 2005 Alex Beregszaszi
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "af.h"
|
||||
|
||||
// Data for specific instances of this filter
|
||||
typedef struct af_center_s
|
||||
{
|
||||
int ch; // Channel number which to insert the filtered data
|
||||
}af_center_t;
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
af_center_t* s = af->priv;
|
||||
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
mp_audio_set_channels_old(af->data, MPMAX(s->ch+1,((struct mp_audio*)arg)->nch));
|
||||
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
|
||||
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
static int filter_frame(struct af_instance* af, struct mp_audio* data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
if (af_make_writeable(af, data) < 0) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_center_t* s = af->priv; // Setup for this instance
|
||||
float* a = c->planes[0]; // Audio data
|
||||
int nch = c->nch; // Number of channels
|
||||
int len = c->samples*c->nch; // Number of samples in current audio block
|
||||
int ch = s->ch; // Channel in which to insert the center audio
|
||||
register int i;
|
||||
|
||||
// Run filter
|
||||
for(i=0;i<len;i+=nch){
|
||||
// Average left and right
|
||||
a[i+ch] = (a[i]/2) + (a[i+1]/2);
|
||||
}
|
||||
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate memory and set function pointers
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control=control;
|
||||
af->filter_frame = filter_frame;
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_center_t
|
||||
const struct af_info af_info_center = {
|
||||
.info = "Audio filter for adding a center channel",
|
||||
.name = "center",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_center_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_INTRANGE("channel", ch, 0, 0, AF_NCH - 1, OPTDEF_INT(1)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -324,7 +324,6 @@ static int af_open(struct af_instance* af){
|
||||
const struct af_info af_info_drc = {
|
||||
.info = "Dynamic range compression filter",
|
||||
.name = "drc",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_drc_t),
|
||||
.options = (const struct m_option[]) {
|
||||
|
||||
@@ -203,7 +203,6 @@ static int af_open(struct af_instance* af){
|
||||
const struct af_info af_info_equalizer = {
|
||||
.info = "Equalizer audio filter",
|
||||
.name = "equalizer",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_equalizer_t),
|
||||
.options = (const struct m_option[]) {
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
* This audio filter exports the incoming signal to other processes
|
||||
* using memory mapping. The memory mapped area contains a header:
|
||||
* int nch,
|
||||
* int size,
|
||||
* unsigned long long counter (updated every time the contents of
|
||||
* the area changes),
|
||||
* the rest is payload (non-interleaved).
|
||||
*
|
||||
* Authors: Anders; Gustavo Sverzut Barbieri <gustavo.barbieri@ic.unicamp.br>
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "osdep/io.h"
|
||||
|
||||
#include "talloc.h"
|
||||
#include "af.h"
|
||||
#include "options/path.h"
|
||||
|
||||
#define DEF_SZ 512 // default buffer size (in samples)
|
||||
#define SHARED_FILE "mpv-af_export" /* default file name
|
||||
(relative to ~/.mpv/ */
|
||||
|
||||
#define SIZE_HEADER (2 * sizeof(int) + sizeof(unsigned long long))
|
||||
|
||||
// Data for specific instances of this filter
|
||||
typedef struct af_export_s
|
||||
{
|
||||
unsigned long long count; // Used for sync
|
||||
void* buf[AF_NCH]; // Buffers for storing the data before it is exported
|
||||
int sz; // Size of buffer in samples
|
||||
int wi; // Write index
|
||||
int fd; // File descriptor to shared memory area
|
||||
char* filename; // File to export data
|
||||
uint8_t *mmap_area; // MMap shared area
|
||||
} af_export_t;
|
||||
|
||||
|
||||
/* Initialization and runtime control
|
||||
af audio filter instance
|
||||
cmd control command
|
||||
arg argument
|
||||
*/
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
af_export_t* s = af->priv;
|
||||
switch (cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
int i=0;
|
||||
int mapsize;
|
||||
|
||||
// Free previous buffers
|
||||
free(s->buf[0]);
|
||||
|
||||
// unmap previous area
|
||||
if(s->mmap_area)
|
||||
munmap(s->mmap_area, SIZE_HEADER + (af->data->bps*s->sz*af->data->nch));
|
||||
// close previous file descriptor
|
||||
if(s->fd)
|
||||
close(s->fd);
|
||||
|
||||
// Accept only int16_t as input format (which sucks)
|
||||
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
|
||||
mp_audio_set_format(af->data, AF_FORMAT_S16);
|
||||
|
||||
// Allocate new buffers (as one continuous block)
|
||||
s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
|
||||
if(NULL == s->buf[0]) {
|
||||
MP_FATAL(af, "Out of memory\n");
|
||||
return AF_ERROR;
|
||||
}
|
||||
for(i = 1; i < af->data->nch; i++)
|
||||
s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
|
||||
|
||||
if (!s->filename) {
|
||||
MP_FATAL(af, "No filename set.\n");
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
// Init memory mapping
|
||||
s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
|
||||
MP_INFO(af, "Exporting to file: %s\n", s->filename);
|
||||
if(s->fd < 0) {
|
||||
MP_FATAL(af, "Could not open/create file: %s\n",
|
||||
s->filename);
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
// header + buffer
|
||||
mapsize = (SIZE_HEADER + (af->data->bps * s->sz * af->data->nch));
|
||||
|
||||
// grow file to needed size
|
||||
for(i = 0; i < mapsize; i++){
|
||||
char null = 0;
|
||||
write(s->fd, (void*) &null, 1);
|
||||
}
|
||||
|
||||
// mmap size
|
||||
s->mmap_area = mmap(0, mapsize, PROT_READ|PROT_WRITE,MAP_SHARED, s->fd, 0);
|
||||
if(s->mmap_area == NULL)
|
||||
MP_FATAL(af, "Could not mmap file %s\n", s->filename);
|
||||
MP_INFO(af, "Memory mapped to file: %s (%p)\n",
|
||||
s->filename, s->mmap_area);
|
||||
|
||||
// Initialize header
|
||||
*((int*)s->mmap_area) = af->data->nch;
|
||||
*((int*)s->mmap_area + 1) = s->sz * af->data->bps * af->data->nch;
|
||||
msync(s->mmap_area, mapsize, MS_ASYNC);
|
||||
|
||||
// Use test_output to return FALSE if necessary
|
||||
return af_test_output(af, (struct mp_audio*)arg);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Free allocated memory and clean up other stuff too.
|
||||
af audio filter instance
|
||||
*/
|
||||
static void uninit( struct af_instance* af )
|
||||
{
|
||||
af_export_t* s = af->priv;
|
||||
|
||||
free(s->buf[0]);
|
||||
|
||||
// Free mmaped area
|
||||
if(s->mmap_area)
|
||||
munmap(s->mmap_area, sizeof(af_export_t));
|
||||
|
||||
if(s->fd > -1)
|
||||
close(s->fd);
|
||||
}
|
||||
|
||||
/* Filter data through filter
|
||||
af audio filter instance
|
||||
data audio data
|
||||
*/
|
||||
static int filter(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_export_t* s = af->priv; // Setup for this instance
|
||||
int16_t* a = c->planes[0]; // Incoming sound
|
||||
int nch = c->nch; // Number of channels
|
||||
int len = c->samples*c->nch; // Number of sample in data chunk
|
||||
int sz = s->sz; // buffer size (in samples)
|
||||
int flag = 0; // Set to 1 if buffer is filled
|
||||
|
||||
int ch, i;
|
||||
|
||||
// Fill all buffers
|
||||
for(ch = 0; ch < nch; ch++){
|
||||
int wi = s->wi; // Reset write index
|
||||
int16_t* b = s->buf[ch]; // Current buffer
|
||||
|
||||
// Copy data to export buffers
|
||||
for(i = ch; i < len; i += nch){
|
||||
b[wi++] = a[i];
|
||||
if(wi >= sz){ // Don't write outside the end of the buffer
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s->wi = wi % s->sz;
|
||||
}
|
||||
|
||||
// Export buffer to mmaped area
|
||||
if(flag){
|
||||
// update buffer in mapped area
|
||||
memcpy(s->mmap_area + SIZE_HEADER, s->buf[0], sz * c->bps * nch);
|
||||
s->count++; // increment counter (to sync)
|
||||
memcpy(s->mmap_area + SIZE_HEADER - sizeof(s->count),
|
||||
&(s->count), sizeof(s->count));
|
||||
}
|
||||
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate memory and set function pointers
|
||||
af audio filter instance
|
||||
returns AF_OK or AF_ERROR
|
||||
*/
|
||||
static int af_open( struct af_instance* af )
|
||||
{
|
||||
af->control = control;
|
||||
af->uninit = uninit;
|
||||
af->filter_frame = filter;
|
||||
af_export_t *priv = af->priv;
|
||||
|
||||
if (!priv->filename || !priv->filename[0]) {
|
||||
MP_FATAL(af, "no export filename given");
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_export_t
|
||||
const struct af_info af_info_export = {
|
||||
.info = "Sound export filter",
|
||||
.name = "export",
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_export_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_STRING("filename", filename, 0),
|
||||
OPT_INTRANGE("buffersamples", sz, 0, 1, 2048, OPTDEF_INT(DEF_SZ)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2004 Alex Beregszaszi & Pierre Lombard
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "af.h"
|
||||
|
||||
// Data for specific instances of this filter
|
||||
typedef struct af_extrastereo_s
|
||||
{
|
||||
float mul;
|
||||
}af_extrastereo_t;
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
|
||||
mp_audio_force_interleaved_format(af->data);
|
||||
mp_audio_set_num_channels(af->data, 2);
|
||||
if (af->data->format != AF_FORMAT_FLOAT)
|
||||
mp_audio_set_format(af->data, AF_FORMAT_S16);
|
||||
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
// Filter data through filter
|
||||
static void play_s16(af_extrastereo_t *s, struct mp_audio* data)
|
||||
{
|
||||
register int i = 0;
|
||||
int16_t *a = (int16_t*)data->planes[0]; // Audio data
|
||||
int len = data->samples*data->nch; // Number of samples
|
||||
int avg, l, r;
|
||||
|
||||
for (i = 0; i < len; i+=2)
|
||||
{
|
||||
avg = (a[i] + a[i + 1]) / 2;
|
||||
|
||||
l = avg + (int)(s->mul * (a[i] - avg));
|
||||
r = avg + (int)(s->mul * (a[i + 1] - avg));
|
||||
|
||||
a[i] = MPCLAMP(l, SHRT_MIN, SHRT_MAX);
|
||||
a[i + 1] = MPCLAMP(r, SHRT_MIN, SHRT_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
static void play_float(af_extrastereo_t *s, struct mp_audio* data)
|
||||
{
|
||||
register int i = 0;
|
||||
float *a = (float*)data->planes[0]; // Audio data
|
||||
int len = data->samples * data->nch; // Number of samples
|
||||
float avg, l, r;
|
||||
|
||||
for (i = 0; i < len; i+=2)
|
||||
{
|
||||
avg = (a[i] + a[i + 1]) / 2;
|
||||
|
||||
l = avg + (s->mul * (a[i] - avg));
|
||||
r = avg + (s->mul * (a[i + 1] - avg));
|
||||
|
||||
a[i] = af_softclip(l);
|
||||
a[i + 1] = af_softclip(r);
|
||||
}
|
||||
}
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
if (af_make_writeable(af, data) < 0) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
if (data->format == AF_FORMAT_FLOAT) {
|
||||
play_float(af->priv, data);
|
||||
} else {
|
||||
play_s16(af->priv, data);
|
||||
}
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate memory and set function pointers
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control=control;
|
||||
af->filter_frame = filter_frame;
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_extrastereo_t
|
||||
const struct af_info af_info_extrastereo = {
|
||||
.info = "Increase difference between audio channels",
|
||||
.name = "extrastereo",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_extrastereo_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_FLOAT("mul", mul, 0, OPTDEF_FLOAT(2.5)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,670 +0,0 @@
|
||||
/*
|
||||
* Experimental audio filter that mixes 5.1 and 5.1 with matrix
|
||||
* encoded rear channels into headphone signal using FIR filtering
|
||||
* with HRTF.
|
||||
*
|
||||
* Author: ylai
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <libavutil/common.h>
|
||||
|
||||
#include "af.h"
|
||||
#include "dsp.h"
|
||||
|
||||
/* HRTF filter coefficients and adjustable parameters */
|
||||
#include "af_hrtf.h"
|
||||
|
||||
typedef struct af_hrtf_s {
|
||||
/* Lengths */
|
||||
int dlbuflen, hrflen, basslen;
|
||||
/* L, C, R, Ls, Rs channels */
|
||||
float *lf, *rf, *lr, *rr, *cf, *cr;
|
||||
const float *cf_ir, *af_ir, *of_ir, *ar_ir, *or_ir, *cr_ir;
|
||||
int cf_o, af_o, of_o, ar_o, or_o, cr_o;
|
||||
/* Bass */
|
||||
float *ba_l, *ba_r;
|
||||
float *ba_ir;
|
||||
/* Whether to matrix decode the rear center channel */
|
||||
int matrix_mode;
|
||||
/* How to decode the input:
|
||||
0 = 5/5+1 channels
|
||||
1 = 2 channels
|
||||
2 = matrix encoded 2 channels */
|
||||
int decode_mode;
|
||||
/* Full wave rectified (FWR) amplitudes and gain used to steer the
|
||||
active matrix decoding of front channels (variable names
|
||||
lpr/lmr means Lt + Rt, Lt - Rt) */
|
||||
float l_fwr, r_fwr, lpr_fwr, lmr_fwr;
|
||||
float adapt_l_gain, adapt_r_gain, adapt_lpr_gain, adapt_lmr_gain;
|
||||
/* Matrix input decoding require special FWR buffer, since the
|
||||
decoding is done in place. */
|
||||
float *fwrbuf_l, *fwrbuf_r, *fwrbuf_lr, *fwrbuf_rr;
|
||||
/* Rear channel delay buffer for matrix decoding */
|
||||
float *rear_dlbuf;
|
||||
/* Full wave rectified amplitude and gain used to steer the active
|
||||
matrix decoding of center rear channel */
|
||||
float lr_fwr, rr_fwr, lrprr_fwr, lrmrr_fwr;
|
||||
float adapt_lr_gain, adapt_rr_gain;
|
||||
float adapt_lrprr_gain, adapt_lrmrr_gain;
|
||||
/* Cyclic position on the ring buffer */
|
||||
int cyc_pos;
|
||||
int print_flag;
|
||||
int mode;
|
||||
} af_hrtf_t;
|
||||
|
||||
/* Convolution on a ring buffer
|
||||
* nx: length of the ring buffer
|
||||
* nk: length of the convolution kernel
|
||||
* sx: ring buffer
|
||||
* sk: convolution kernel
|
||||
* offset: offset on the ring buffer, can be
|
||||
*/
|
||||
static float conv(const int nx, const int nk, const float *sx, const float *sk,
|
||||
const int offset)
|
||||
{
|
||||
/* k = reminder of offset / nx */
|
||||
int k = offset >= 0 ? offset % nx : nx + (offset % nx);
|
||||
|
||||
if(nk + k <= nx)
|
||||
return af_filter_fir(nk, sx + k, sk);
|
||||
else
|
||||
return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
|
||||
af_filter_fir(nx - k, sx + k, sk);
|
||||
}
|
||||
|
||||
/* Detect when the impulse response starts (significantly) */
|
||||
static int pulse_detect(const float *sx)
|
||||
{
|
||||
/* nmax must be the reference impulse response length (128) minus
|
||||
s->hrflen */
|
||||
const int nmax = 128 - HRTFFILTLEN;
|
||||
const float thresh = IRTHRESH;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < nmax; i++)
|
||||
if(fabs(sx[i]) > thresh)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Fuzzy matrix coefficient transfer function to "lock" the matrix on
|
||||
a effectively passive mode if the gain is approximately 1 */
|
||||
static inline float passive_lock(float x)
|
||||
{
|
||||
const float x1 = x - 1;
|
||||
const float ax1s = fabs(x - 1) * (1.0 / MATAGCLOCK);
|
||||
|
||||
return x1 - x1 / (1 + ax1s * ax1s) + 1;
|
||||
}
|
||||
|
||||
/* Unified active matrix decoder for 2 channel matrix encoded surround
|
||||
sources */
|
||||
static inline void matrix_decode(short *in, const int k, const int il,
|
||||
const int ir, const int decode_rear,
|
||||
const int dlbuflen,
|
||||
float l_fwr, float r_fwr,
|
||||
float lpr_fwr, float lmr_fwr,
|
||||
float *adapt_l_gain, float *adapt_r_gain,
|
||||
float *adapt_lpr_gain, float *adapt_lmr_gain,
|
||||
float *lf, float *rf, float *lr,
|
||||
float *rr, float *cf)
|
||||
{
|
||||
const int kr = (k + MATREARDELAY) % dlbuflen;
|
||||
float l_gain = (l_fwr + r_fwr) /
|
||||
(1 + l_fwr + l_fwr);
|
||||
float r_gain = (l_fwr + r_fwr) /
|
||||
(1 + r_fwr + r_fwr);
|
||||
/* The 2nd axis has strong gain fluctuations, and therefore require
|
||||
limits. The factor corresponds to the 1 / amplification of (Lt
|
||||
- Rt) when (Lt, Rt) is strongly correlated. (e.g. during
|
||||
dialogues). It should be bigger than -12 dB to prevent
|
||||
distortion. */
|
||||
float lmr_lim_fwr = lmr_fwr > M9_03DB * lpr_fwr ?
|
||||
lmr_fwr : M9_03DB * lpr_fwr;
|
||||
float lpr_gain = (lpr_fwr + lmr_lim_fwr) /
|
||||
(1 + lpr_fwr + lpr_fwr);
|
||||
float lmr_gain = (lpr_fwr + lmr_lim_fwr) /
|
||||
(1 + lmr_lim_fwr + lmr_lim_fwr);
|
||||
float lmr_unlim_gain = (lpr_fwr + lmr_fwr) /
|
||||
(1 + lmr_fwr + lmr_fwr);
|
||||
float lpr, lmr;
|
||||
float l_agc, r_agc, lpr_agc, lmr_agc;
|
||||
float f, d_gain, c_gain, c_agc_cfk;
|
||||
|
||||
#if 0
|
||||
static int counter = 0;
|
||||
static FILE *fp_out;
|
||||
|
||||
if(counter == 0)
|
||||
fp_out = fopen("af_hrtf.log", "w");
|
||||
if(counter % 240 == 0)
|
||||
fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000),
|
||||
l_gain, r_gain, lpr_gain, lmr_gain);
|
||||
#endif
|
||||
|
||||
/*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/
|
||||
/* AGC adaption */
|
||||
d_gain = (fabs(l_gain - *adapt_l_gain) +
|
||||
fabs(r_gain - *adapt_r_gain)) * 0.5;
|
||||
f = d_gain * (1.0 / MATAGCTRIG);
|
||||
f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
|
||||
*adapt_l_gain = (1 - f) * *adapt_l_gain + f * l_gain;
|
||||
*adapt_r_gain = (1 - f) * *adapt_r_gain + f * r_gain;
|
||||
/* Matrix */
|
||||
l_agc = in[il] * passive_lock(*adapt_l_gain);
|
||||
r_agc = in[ir] * passive_lock(*adapt_r_gain);
|
||||
cf[k] = (l_agc + r_agc) * M_SQRT1_2;
|
||||
if(decode_rear) {
|
||||
lr[kr] = rr[kr] = (l_agc - r_agc) * M_SQRT1_2;
|
||||
/* Stereo rear channel is steered with the same AGC steering as
|
||||
the decoding matrix. Note this requires a fast updating AGC
|
||||
at the order of 20 ms (which is the case here). */
|
||||
lr[kr] *= (l_fwr + l_fwr) /
|
||||
(1 + l_fwr + r_fwr);
|
||||
rr[kr] *= (r_fwr + r_fwr) /
|
||||
(1 + l_fwr + r_fwr);
|
||||
}
|
||||
|
||||
/*** AXIS NO. 2: (Lt + Rt, Lt - Rt) -> (L, R) ***/
|
||||
lpr = (in[il] + in[ir]) * M_SQRT1_2;
|
||||
lmr = (in[il] - in[ir]) * M_SQRT1_2;
|
||||
/* AGC adaption */
|
||||
d_gain = fabs(lmr_unlim_gain - *adapt_lmr_gain);
|
||||
f = d_gain * (1.0 / MATAGCTRIG);
|
||||
f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
|
||||
*adapt_lpr_gain = (1 - f) * *adapt_lpr_gain + f * lpr_gain;
|
||||
*adapt_lmr_gain = (1 - f) * *adapt_lmr_gain + f * lmr_gain;
|
||||
/* Matrix */
|
||||
lpr_agc = lpr * passive_lock(*adapt_lpr_gain);
|
||||
lmr_agc = lmr * passive_lock(*adapt_lmr_gain);
|
||||
lf[k] = (lpr_agc + lmr_agc) * M_SQRT1_2;
|
||||
rf[k] = (lpr_agc - lmr_agc) * M_SQRT1_2;
|
||||
|
||||
/*** CENTER FRONT CANCELLATION ***/
|
||||
/* A heuristic approach exploits that Lt + Rt gain contains the
|
||||
information about Lt, Rt correlation. This effectively reshapes
|
||||
the front and rear "cones" to concentrate Lt + Rt to C and
|
||||
introduce Lt - Rt in L, R. */
|
||||
/* 0.67677 is the empirical lower bound for lpr_gain. */
|
||||
c_gain = 8 * (*adapt_lpr_gain - 0.67677);
|
||||
c_gain = c_gain > 0 ? c_gain : 0;
|
||||
/* c_gain should not be too high, not even reaching full
|
||||
cancellation (~ 0.50 - 0.55 at current AGC implementation), or
|
||||
the center will s0und too narrow. */
|
||||
c_gain = MATCOMPGAIN / (1 + c_gain * c_gain);
|
||||
c_agc_cfk = c_gain * cf[k];
|
||||
lf[k] -= c_agc_cfk;
|
||||
rf[k] -= c_agc_cfk;
|
||||
cf[k] += c_agc_cfk + c_agc_cfk;
|
||||
#if 0
|
||||
if(counter % 240 == 0)
|
||||
fprintf(fp_out, "%g %g %g %g %g\n",
|
||||
*adapt_l_gain, *adapt_r_gain,
|
||||
*adapt_lpr_gain, *adapt_lmr_gain,
|
||||
c_gain);
|
||||
counter++;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void update_ch(af_hrtf_t *s, short *in, const int k)
|
||||
{
|
||||
const int fwr_pos = (k + FWRDURATION) % s->dlbuflen;
|
||||
/* Update the full wave rectified total amplitude */
|
||||
/* Input matrix decoder */
|
||||
if(s->decode_mode == HRTF_MIX_MATRIX2CH) {
|
||||
s->l_fwr += abs(in[0]) - fabs(s->fwrbuf_l[fwr_pos]);
|
||||
s->r_fwr += abs(in[1]) - fabs(s->fwrbuf_r[fwr_pos]);
|
||||
s->lpr_fwr += abs(in[0] + in[1]) -
|
||||
fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
|
||||
s->lmr_fwr += abs(in[0] - in[1]) -
|
||||
fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
|
||||
}
|
||||
/* Rear matrix decoder */
|
||||
if(s->matrix_mode) {
|
||||
s->lr_fwr += abs(in[2]) - fabs(s->fwrbuf_lr[fwr_pos]);
|
||||
s->rr_fwr += abs(in[3]) - fabs(s->fwrbuf_rr[fwr_pos]);
|
||||
s->lrprr_fwr += abs(in[2] + in[3]) -
|
||||
fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
|
||||
s->lrmrr_fwr += abs(in[2] - in[3]) -
|
||||
fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
|
||||
}
|
||||
|
||||
switch (s->decode_mode) {
|
||||
case HRTF_MIX_51:
|
||||
/* 5/5+1 channel sources */
|
||||
s->lf[k] = in[0];
|
||||
s->cf[k] = in[4];
|
||||
s->rf[k] = in[1];
|
||||
s->fwrbuf_lr[k] = s->lr[k] = in[2];
|
||||
s->fwrbuf_rr[k] = s->rr[k] = in[3];
|
||||
break;
|
||||
case HRTF_MIX_MATRIX2CH:
|
||||
/* Matrix encoded 2 channel sources */
|
||||
s->fwrbuf_l[k] = in[0];
|
||||
s->fwrbuf_r[k] = in[1];
|
||||
matrix_decode(in, k, 0, 1, 1, s->dlbuflen,
|
||||
s->l_fwr, s->r_fwr,
|
||||
s->lpr_fwr, s->lmr_fwr,
|
||||
&(s->adapt_l_gain), &(s->adapt_r_gain),
|
||||
&(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
|
||||
s->lf, s->rf, s->lr, s->rr, s->cf);
|
||||
break;
|
||||
case HRTF_MIX_STEREO:
|
||||
/* Stereo sources */
|
||||
s->lf[k] = in[0];
|
||||
s->rf[k] = in[1];
|
||||
s->cf[k] = s->lr[k] = s->rr[k] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We need to update the bass compensation delay line, too. */
|
||||
// TODO: should this use lf/cf/rf etc. instead?
|
||||
s->ba_l[k] = in[0];
|
||||
s->ba_r[k] = in[1];
|
||||
if (s->decode_mode == HRTF_MIX_51) {
|
||||
s->ba_l[k] += in[4] + in[2];
|
||||
s->ba_r[k] += in[4] + in[3];
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_coeff(af_hrtf_t *s, float *c)
|
||||
{
|
||||
memset(c, 0, s->dlbuflen * sizeof(float));
|
||||
}
|
||||
|
||||
static void reset(af_hrtf_t *s)
|
||||
{
|
||||
clear_coeff(s, s->lf);
|
||||
clear_coeff(s, s->rf);
|
||||
clear_coeff(s, s->lr);
|
||||
clear_coeff(s, s->rr);
|
||||
clear_coeff(s, s->cf);
|
||||
clear_coeff(s, s->cr);
|
||||
clear_coeff(s, s->ba_l);
|
||||
clear_coeff(s, s->ba_r);
|
||||
clear_coeff(s, s->fwrbuf_l);
|
||||
clear_coeff(s, s->fwrbuf_r);
|
||||
clear_coeff(s, s->fwrbuf_lr);
|
||||
clear_coeff(s, s->fwrbuf_rr);
|
||||
}
|
||||
|
||||
/* Initialization and runtime control */
|
||||
static int control(struct af_instance *af, int cmd, void* arg)
|
||||
{
|
||||
af_hrtf_t *s = af->priv;
|
||||
int test_output_res;
|
||||
|
||||
switch(cmd) {
|
||||
case AF_CONTROL_REINIT:
|
||||
reset(s);
|
||||
af->data->rate = 48000;
|
||||
mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
|
||||
if(af->data->nch == 2) {
|
||||
/* 2 channel input */
|
||||
if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
|
||||
/* Default behavior is stereo mixing. */
|
||||
s->decode_mode = HRTF_MIX_STEREO;
|
||||
}
|
||||
} else if (af->data->nch < 5) {
|
||||
mp_audio_set_channels_old(af->data, 5);
|
||||
}
|
||||
mp_audio_set_format(af->data, AF_FORMAT_S16);
|
||||
test_output_res = af_test_output(af, (struct mp_audio*)arg);
|
||||
// after testing input set the real output format
|
||||
mp_audio_set_num_channels(af->data, 2);
|
||||
s->print_flag = 1;
|
||||
return test_output_res;
|
||||
case AF_CONTROL_RESET:
|
||||
reset(s);
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Deallocate memory */
|
||||
static void uninit(struct af_instance *af)
|
||||
{
|
||||
af_hrtf_t *s = af->priv;
|
||||
|
||||
free(s->lf);
|
||||
free(s->rf);
|
||||
free(s->lr);
|
||||
free(s->rr);
|
||||
free(s->cf);
|
||||
free(s->cr);
|
||||
free(s->ba_l);
|
||||
free(s->ba_r);
|
||||
free(s->ba_ir);
|
||||
free(s->fwrbuf_l);
|
||||
free(s->fwrbuf_r);
|
||||
free(s->fwrbuf_lr);
|
||||
free(s->fwrbuf_rr);
|
||||
}
|
||||
|
||||
/* Filter data through filter
|
||||
|
||||
Two "tricks" are used to compensate the "color" of the KEMAR data:
|
||||
|
||||
1. The KEMAR data is refiltered to ensure that the front L, R channels
|
||||
on the same side of the ear are equalized (especially in the high
|
||||
frequencies).
|
||||
|
||||
2. A bass compensation is introduced to ensure that 0-200 Hz are not
|
||||
damped (without any real 3D acoustical image, however).
|
||||
*/
|
||||
static int filter(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
af_hrtf_t *s = af->priv;
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
struct mp_audio *outframe =
|
||||
mp_audio_pool_get(af->out_pool, &af->fmt_out, data->samples);
|
||||
if (!outframe) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
mp_audio_copy_attributes(outframe, data);
|
||||
|
||||
short *in = data->planes[0]; // Input audio data
|
||||
short *out = outframe->planes[0]; // Output audio data
|
||||
short *end = in + data->samples * data->nch; // Loop end
|
||||
float common, left, right, diff, left_b, right_b;
|
||||
const int dblen = s->dlbuflen, hlen = s->hrflen, blen = s->basslen;
|
||||
|
||||
if(s->print_flag) {
|
||||
s->print_flag = 0;
|
||||
switch (s->decode_mode) {
|
||||
case HRTF_MIX_51:
|
||||
MP_INFO(af, "Using HRTF to mix %s discrete surround into "
|
||||
"L, R channels\n", s->matrix_mode ? "5+1" : "5");
|
||||
break;
|
||||
case HRTF_MIX_STEREO:
|
||||
MP_INFO(af, "Using HRTF to mix stereo into "
|
||||
"L, R channels\n");
|
||||
break;
|
||||
case HRTF_MIX_MATRIX2CH:
|
||||
MP_INFO(af, "Using active matrix to decode 2 channel "
|
||||
"input, HRTF to mix %s matrix surround into "
|
||||
"L, R channels\n", "3/2");
|
||||
break;
|
||||
default:
|
||||
MP_WARN(af, "bogus decode_mode: %d\n", s->decode_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
if(s->matrix_mode)
|
||||
MP_INFO(af, "Using active matrix to decode rear center "
|
||||
"channel\n");
|
||||
}
|
||||
|
||||
/* MPlayer's 5 channel layout (notation for the variable):
|
||||
*
|
||||
* 0: L (LF), 1: R (RF), 2: Ls (LR), 3: Rs (RR), 4: C (CF), matrix
|
||||
* encoded: Cs (CR)
|
||||
*
|
||||
* or: L = left, C = center, R = right, F = front, R = rear
|
||||
*
|
||||
* Filter notation:
|
||||
*
|
||||
* CF
|
||||
* OF AF
|
||||
* Ear->
|
||||
* OR AR
|
||||
* CR
|
||||
*
|
||||
* or: C = center, A = same side, O = opposite, F = front, R = rear
|
||||
*/
|
||||
|
||||
while(in < end) {
|
||||
const int k = s->cyc_pos;
|
||||
|
||||
update_ch(s, in, k);
|
||||
|
||||
/* Simulate a 7.5 ms -20 dB echo of the center channel in the
|
||||
front channels (like reflection from a room wall) - a kind of
|
||||
psycho-acoustically "cheating" to focus the center front
|
||||
channel, which is normally hard to be perceived as front */
|
||||
s->lf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
|
||||
s->rf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
|
||||
|
||||
switch (s->decode_mode) {
|
||||
case HRTF_MIX_51:
|
||||
case HRTF_MIX_MATRIX2CH:
|
||||
/* Mixer filter matrix */
|
||||
common = conv(dblen, hlen, s->cf, s->cf_ir, k + s->cf_o);
|
||||
if(s->matrix_mode) {
|
||||
/* In matrix decoding mode, the rear channel gain must be
|
||||
renormalized, as there is an additional channel. */
|
||||
matrix_decode(in, k, 2, 3, 0, s->dlbuflen,
|
||||
s->lr_fwr, s->rr_fwr,
|
||||
s->lrprr_fwr, s->lrmrr_fwr,
|
||||
&(s->adapt_lr_gain), &(s->adapt_rr_gain),
|
||||
&(s->adapt_lrprr_gain), &(s->adapt_lrmrr_gain),
|
||||
s->lr, s->rr, NULL, NULL, s->cr);
|
||||
common +=
|
||||
conv(dblen, hlen, s->cr, s->cr_ir, k + s->cr_o) *
|
||||
M1_76DB;
|
||||
left =
|
||||
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
|
||||
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
|
||||
(conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
|
||||
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o)) *
|
||||
M1_76DB + common);
|
||||
right =
|
||||
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
|
||||
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
|
||||
(conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
|
||||
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o)) *
|
||||
M1_76DB + common);
|
||||
} else {
|
||||
left =
|
||||
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
|
||||
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
|
||||
conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
|
||||
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o) +
|
||||
common);
|
||||
right =
|
||||
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
|
||||
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
|
||||
conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
|
||||
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o) +
|
||||
common);
|
||||
}
|
||||
break;
|
||||
case HRTF_MIX_STEREO:
|
||||
left =
|
||||
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
|
||||
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o));
|
||||
right =
|
||||
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
|
||||
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o));
|
||||
break;
|
||||
default:
|
||||
/* make gcc happy */
|
||||
left = 0.0;
|
||||
right = 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Bass compensation for the lower frequency cut of the HRTF. A
|
||||
cross talk of the left and right channel is introduced to
|
||||
match the directional characteristics of higher frequencies.
|
||||
The bass will not have any real 3D perception, but that is
|
||||
OK (note at 180 Hz, the wavelength is about 2 m, and any
|
||||
spatial perception is impossible). */
|
||||
left_b = conv(dblen, blen, s->ba_l, s->ba_ir, k);
|
||||
right_b = conv(dblen, blen, s->ba_r, s->ba_ir, k);
|
||||
left += (1 - BASSCROSS) * left_b + BASSCROSS * right_b;
|
||||
right += (1 - BASSCROSS) * right_b + BASSCROSS * left_b;
|
||||
/* Also mix the LFE channel (if available) */
|
||||
if(data->nch >= 6) {
|
||||
left += in[5] * M3_01DB;
|
||||
right += in[5] * M3_01DB;
|
||||
}
|
||||
|
||||
/* Amplitude renormalization. */
|
||||
left *= AMPLNORM;
|
||||
right *= AMPLNORM;
|
||||
|
||||
switch (s->decode_mode) {
|
||||
case HRTF_MIX_51:
|
||||
case HRTF_MIX_STEREO:
|
||||
/* "Cheating": linear stereo expansion to amplify the 3D
|
||||
perception. Note: Too much will destroy the acoustic space
|
||||
and may even result in headaches. */
|
||||
diff = STEXPAND2 * (left - right);
|
||||
out[0] = av_clip_int16(left + diff);
|
||||
out[1] = av_clip_int16(right - diff);
|
||||
break;
|
||||
case HRTF_MIX_MATRIX2CH:
|
||||
/* Do attempt any stereo expansion with matrix encoded
|
||||
sources. The L, R channels are already stereo expanded
|
||||
by the steering, any further stereo expansion will sound
|
||||
very unnatural. */
|
||||
out[0] = av_clip_int16(left);
|
||||
out[1] = av_clip_int16(right);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Next sample... */
|
||||
in = &in[data->nch];
|
||||
out = &out[af->data->nch];
|
||||
(s->cyc_pos)--;
|
||||
if(s->cyc_pos < 0)
|
||||
s->cyc_pos += dblen;
|
||||
}
|
||||
|
||||
talloc_free(data);
|
||||
af_add_output_frame(af, outframe);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int allocate(af_hrtf_t *s)
|
||||
{
|
||||
if ((s->lf = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->rf = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->lr = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->rr = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->cf = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->cr = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->ba_l = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->ba_r = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->fwrbuf_l =
|
||||
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->fwrbuf_r =
|
||||
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->fwrbuf_lr =
|
||||
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
if ((s->fwrbuf_rr =
|
||||
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate memory and set function pointers */
|
||||
static int af_open(struct af_instance* af)
|
||||
{
|
||||
int i;
|
||||
af_hrtf_t *s;
|
||||
float fc;
|
||||
|
||||
af->control = control;
|
||||
af->uninit = uninit;
|
||||
af->filter_frame = filter;
|
||||
|
||||
s = af->priv;
|
||||
|
||||
s->dlbuflen = DELAYBUFLEN;
|
||||
s->hrflen = HRTFFILTLEN;
|
||||
s->basslen = BASSFILTLEN;
|
||||
|
||||
s->cyc_pos = s->dlbuflen - 1;
|
||||
/* With a full (two axis) steering matrix decoder, s->matrix_mode
|
||||
should not be enabled lightly (it will also steer the Ls, Rs
|
||||
channels). */
|
||||
s->matrix_mode = 0;
|
||||
s->decode_mode = HRTF_MIX_51;
|
||||
|
||||
switch (s->mode) {
|
||||
case 0: /* Use matrix rear decoding. */
|
||||
s->matrix_mode = 1;
|
||||
break;
|
||||
case 1: /* Input needs matrix decoding. */
|
||||
s->decode_mode = HRTF_MIX_MATRIX2CH;
|
||||
break;
|
||||
case 2:
|
||||
s->matrix_mode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
s->print_flag = 1;
|
||||
|
||||
if (allocate(s) != 0) {
|
||||
MP_ERR(af, "Memory allocation error.\n");
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
for(i = 0; i < s->dlbuflen; i++)
|
||||
s->lf[i] = s->rf[i] = s->lr[i] = s->rr[i] = s->cf[i] =
|
||||
s->cr[i] = 0;
|
||||
|
||||
s->lr_fwr =
|
||||
s->rr_fwr = 0;
|
||||
|
||||
s->cf_ir = cf_filt + (s->cf_o = pulse_detect(cf_filt));
|
||||
s->af_ir = af_filt + (s->af_o = pulse_detect(af_filt));
|
||||
s->of_ir = of_filt + (s->of_o = pulse_detect(of_filt));
|
||||
s->ar_ir = ar_filt + (s->ar_o = pulse_detect(ar_filt));
|
||||
s->or_ir = or_filt + (s->or_o = pulse_detect(or_filt));
|
||||
s->cr_ir = cr_filt + (s->cr_o = pulse_detect(cr_filt));
|
||||
|
||||
if((s->ba_ir = malloc(s->basslen * sizeof(float))) == NULL) {
|
||||
MP_ERR(af, "Memory allocation error.\n");
|
||||
return AF_ERROR;
|
||||
}
|
||||
fc = 2.0 * BASSFILTFREQ / (float)af->data->rate;
|
||||
if(af_filter_design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) ==
|
||||
-1) {
|
||||
MP_ERR(af, "Unable to design low-pass "
|
||||
"filter.\n");
|
||||
return AF_ERROR;
|
||||
}
|
||||
for(i = 0; i < s->basslen; i++)
|
||||
s->ba_ir[i] *= BASSGAIN;
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_hrtf_t
|
||||
const struct af_info af_info_hrtf = {
|
||||
.info = "HRTF Headphone",
|
||||
.name = "hrtf",
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_hrtf_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_CHOICE("mode", mode, 0, ({"m", 0}, {"s", 1}, {"0", 2})),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,510 +0,0 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MPLAYER_AF_HRTF_H
|
||||
#define MPLAYER_AF_HRTF_H
|
||||
|
||||
#define HRTF_MIX_51 0
|
||||
#define HRTF_MIX_STEREO 1
|
||||
#define HRTF_MIX_MATRIX2CH 2
|
||||
|
||||
/* Amplitude scaling factors */
|
||||
#define M17_0DB 0.1414213562
|
||||
#define M9_03DB 0.3535533906
|
||||
#define M6_99DB 0.4472135955
|
||||
#define M4_77DB 0.5773502692
|
||||
#define M3_01DB 0.7071067812
|
||||
#define M1_76DB 0.8164965809
|
||||
|
||||
#define DELAYBUFLEN 1024 /* Length of the delay buffer */
|
||||
#define HRTFFILTLEN 64 /* HRTF filter length */
|
||||
#define IRTHRESH 0.001 /* Impulse response pruning thresh. */
|
||||
|
||||
#define AMPLNORM M6_99DB /* Overall amplitude renormalization */
|
||||
|
||||
#define BASSFILTFREQ 180 /* Bass compensation filter cut (Hz) */
|
||||
#define BASSFILTLEN 193 /* Bass compensation filter length */
|
||||
#define BASSGAIN M_SQRT2 /* Bass compensation gain */
|
||||
#define BASSCROSS 0.35 /* Bass cross talk */
|
||||
|
||||
#define FWRDURATION 240 /* FWR average duration (samples) */
|
||||
#define MATREARDELAY 720 /* Matrix mode rear delay (samples) */
|
||||
|
||||
#define MATAGCTRIG 8.0 /* (Fuzzy) AGC trigger */
|
||||
#define MATAGCDECAY 1.0 /* AGC baseline decay rate (1/samp.) */
|
||||
#define MATAGCLOCK 0.2 /* AGC range (around 1) where the
|
||||
matrix behaves passively */
|
||||
#define MATCOMPGAIN 0.37 /* Cross talk compensation gain,
|
||||
0.50 - 0.55 is full cancellation. */
|
||||
|
||||
#define CFECHODELAY 360 /* Center front echo delay (samples) */
|
||||
#define CFECHOAMPL M17_0DB /* Center front echo amplitude */
|
||||
|
||||
#define STEXPAND2 0.07 /* Stereo expansion / 2 */
|
||||
|
||||
/* Head related impulse response (HRIR) derived from KEMAR measurement
|
||||
data by Bill Gardner <billg@media.mit.edu> and Keith Martin
|
||||
<kdm@media.mit.edu>
|
||||
|
||||
URL: http://sound.media.mit.edu/KEMAR.html
|
||||
|
||||
Distributed under GPL with authors' permission
|
||||
*/
|
||||
|
||||
/* EQUALIZED KEMAR HRIR
|
||||
|
||||
How to generate these data:
|
||||
|
||||
1. You need the MIT Media Lab's KEMAR data, read it into an software
|
||||
capable of signal/time series analysis (like Mathematica, Matlab,
|
||||
...)
|
||||
|
||||
2. Construct an equalizing FIR inverse filter by calculating the
|
||||
transfer function of the front, same side impulse response, then
|
||||
take 1 over the absolute magnitude.
|
||||
|
||||
3. Cut the poles in the inverse filter's transfer function
|
||||
specification by limiting the amplification to 2.5 (note, this
|
||||
number assumes that you have correct signal processing
|
||||
normalization of the Fourier transform).
|
||||
|
||||
4. Design the FIR inverse filter by calculating the inverse Fourier
|
||||
transform, then chopping the coefficients down to a reasonable
|
||||
number (N = 15 is used here), apply the Kaiser-Bessel window (alpha
|
||||
= 2 is used here). Note the objective is remove the color bias
|
||||
only (as if you are using an equalizer), _not_ to do a full inverse
|
||||
filtering. (Note: beta = pi*alpha in other notation.)
|
||||
|
||||
For N = 15, alpha = 2, you should get the following impulse
|
||||
response:
|
||||
|
||||
0.001001558668605168, 0.00698457265741865, 0.040453643039829436,
|
||||
0.012230541722147855, -0.11939760844854072, 0.16468099899755967,
|
||||
-0.30297563073747436, 1.3140211791355982, -0.30297563073747436,
|
||||
0.16468099899755967, -0.11939760844854072, 0.012230541722147855,
|
||||
0.040453643039829436, 0.00698457265741865, 0.001001558668605168
|
||||
|
||||
5. Linearly convolve all KEMAR HRIR with this inverse filter.
|
||||
|
||||
6. Resample from 44.1 kHz sampling frequency to 48 kHz.
|
||||
*/
|
||||
|
||||
/* Center front (-5 degree) - not 0 degree in order to create a clear
|
||||
front image from a finite distance */
|
||||
static const float cf_filt[128] = {
|
||||
-0.00008638082319075036, 0.0003198059946385229,
|
||||
-0.0005010631339162132, 0.0011424741331126876,
|
||||
-0.001584220794688753, 0.001742715363246275,
|
||||
-0.0011080796626780694, 0.0001651829990860167,
|
||||
0.005235028337314985, 0.0035223828473357776,
|
||||
0.010057681388431303, -0.033469432129545514,
|
||||
0.013391253316233523, 0.004858462839827063,
|
||||
0.08172161220103627, 0.26158596134500023,
|
||||
-0.12420314583323326, -0.14298458356097565,
|
||||
0.14421897280453896, -0.1635792507629016,
|
||||
-0.02187136722480014, 0.2426863044711817,
|
||||
0.07229814207917194, 0.0942742651913879,
|
||||
0.29856830878076834, 0.2944146162057754,
|
||||
-0.12122157003421209, -0.19640092165631157,
|
||||
0.11623836502034968, -0.05794027397995521,
|
||||
-0.34313138341973776, -0.19487516249168105,
|
||||
0.010118993953802401, -0.09460218797710966,
|
||||
-0.16761521117359582, 0.004154461610153861,
|
||||
0.052768641758969316, -0.00041823982226147407,
|
||||
0.021634960445143514, 0.07562793486871108,
|
||||
0.08895407129506479, 0.039857755093416214,
|
||||
0.044257936180422945, 0.061557584906101664,
|
||||
0.015547268541895703, -0.023908191934932484,
|
||||
0.009498030443468223, 0.03816269003221337,
|
||||
-0.009820500607303615, -0.042003975527908084,
|
||||
-0.03335447117311547, -0.029294510859746596,
|
||||
-0.05212623136198511, -0.073427547153205,
|
||||
-0.061190797824958836, -0.04620925059966413,
|
||||
-0.04204619420702159, -0.02331915902615157,
|
||||
0.00211481411477094, 0.00852563995740107,
|
||||
0.008766809731743399, 0.008666632180812078,
|
||||
0.018279202191625352, 0.02924332751289675,
|
||||
0.022293148257836494, 0.012362146008584188,
|
||||
0.008572582458807008, 0.006491370763597344,
|
||||
-0.0019366944997535774, -0.006318669309634434,
|
||||
-0.006457921690218669, -0.015050265524669974,
|
||||
-0.02110660282616213, -0.017027809096377904,
|
||||
-0.01651052305334348, -0.022770064150046673,
|
||||
-0.01999875754219472, -0.012294792027337775,
|
||||
-0.011506057031057188, -0.011448970577312903,
|
||||
-0.004823572302580925, 0.0022451134042777883,
|
||||
0.004145473526859826, 0.005629030064546135,
|
||||
0.008588029213398785, 0.010092048834844231,
|
||||
0.007182013245552008, 0.0014600979508720656,
|
||||
-0.0038314646272511756, -0.003443901997881347,
|
||||
-0.0029483418254804047, -0.007609357112679647,
|
||||
-0.006518368948030822, -0.004495803701497202,
|
||||
-0.007109113004849672, -0.008346237278084265,
|
||||
-0.005560847336252453, -0.002993453167553188,
|
||||
-0.005122897816824269, -0.004389782626604215,
|
||||
-0.0010912633695218108, -0.0019712029474458835,
|
||||
-0.005870162265802235, -0.005626159534954128,
|
||||
-0.00027254977910844407, 0.0013794425431633785,
|
||||
-0.0005919083190430062, -0.0007861203545416682,
|
||||
-0.0007049560240893946, -0.0032720188494468868,
|
||||
-0.004460645567968504, -0.0032018528193571696,
|
||||
-0.0030579229375062105, -0.003593998902656612,
|
||||
-0.0038032977997776445, -0.004613776010454773,
|
||||
-0.0059796549143736845, -0.00420126194319768,
|
||||
-0.0012374419948287222, 0.0008572699213050608,
|
||||
0.0021490971020081094, 0.00047295283198381995,
|
||||
-0.0009670277915884887, -0.001354440866080231,
|
||||
-0.002962902746547851, -0.00533935813338141,
|
||||
-0.005469203016468759, -0.004355784273189485
|
||||
};
|
||||
/* Front, same side (30 degree) */
|
||||
static const float af_filt[128] = {
|
||||
-0.004140580614755493, 0.005790934614385445,
|
||||
0.003318916682081112, 0.014257145544366063,
|
||||
0.007328442487127339, -0.06550381777876194,
|
||||
0.03502225818161845, -0.013090579770708259,
|
||||
0.2517776798694195, 0.420770489950659,
|
||||
-0.3418854608834852, -0.24371032493696737,
|
||||
0.04901356150030018, -0.1778083521632833,
|
||||
0.26448004245714163, 0.23245199964546834,
|
||||
0.033053145803936305, 0.46811222821062415,
|
||||
0.5359265986255611, -0.011912195468533787,
|
||||
-0.39763432601411647, -0.034482864386898314,
|
||||
0.029445398240649626, -0.3850940407863262,
|
||||
-0.3272328478175581, -0.14701421403616477,
|
||||
-0.08522137400169517, -0.14936851633336035,
|
||||
-0.09432605283433723, 0.0991200405937827,
|
||||
0.011075012089917331, -0.0051036489980274685,
|
||||
0.0933903289749412, 0.1344189369609565,
|
||||
0.10507466913017807, 0.04240159324684365,
|
||||
0.06559270110638656, 0.026984119875617524,
|
||||
-0.03359846103238096, -0.018000197099174275,
|
||||
0.042031818548178244, 0.03849039666888434,
|
||||
-0.02450829674011345, -0.03407882403088576,
|
||||
-0.029230189282961977, -0.046964865291761734,
|
||||
-0.09458258700116245, -0.1527349330901158,
|
||||
-0.15411577687826097, -0.08761679790956928,
|
||||
-0.033623549089171874, -0.007204768531481949,
|
||||
0.008273425020444852, 0.021368717994908505,
|
||||
0.04366608267875025, 0.05660907333076205,
|
||||
0.06775726495503939, 0.05621881735271431,
|
||||
0.03576231950669927, 0.02500825834889175,
|
||||
0.015423811076054601, 0.007903258334503761,
|
||||
-0.0053873014137761945, -0.006987955469434698,
|
||||
-0.012027972007598602, -0.025228281243816594,
|
||||
-0.026225091797257318, -0.023809293997344882,
|
||||
-0.03250172017712295, -0.03195696301067249,
|
||||
-0.01784813952189948, -0.01663267233760342,
|
||||
-0.016184530450468065, -0.011659883749357463,
|
||||
-0.0035378511240219163, -0.0005485800790443406,
|
||||
0.0018432660108168625, 0.011634844139907534,
|
||||
0.018333603402051105, 0.020447379185133056,
|
||||
0.00850783664147828, 0.0004694148911037838,
|
||||
-0.0017047130409786676, -0.0022409152834483997,
|
||||
-0.000860472174892845, -0.004111075059198666,
|
||||
-0.003527843382056666, -0.009640160874903018,
|
||||
-0.01750044574231376, -0.015613389403672443,
|
||||
-0.010790028120953001, -0.0095313499955768,
|
||||
-0.007469721416726809, -0.0019186578145117315,
|
||||
-0.00014977322572890802, -0.0029803838028179728,
|
||||
-0.006520567233727221, 0.000035015132033882596,
|
||||
0.009245098100543752, 0.009896930052308656,
|
||||
0.008316744929565786, 0.004575207140193997,
|
||||
-0.0000647420103997081, -0.004502916832871627,
|
||||
-0.004225962213251224, -0.002886014126381486,
|
||||
-0.006416834142585976, -0.007156609995423569,
|
||||
-0.008840274447579472, -0.01441763751386817,
|
||||
-0.015435817484659574, -0.00924487254924743,
|
||||
-0.0021571721940235205, 0.0028540722992305453,
|
||||
0.00273577475088536, -0.000788412365513805,
|
||||
-0.0032650029728365907, -0.003880217646231338,
|
||||
-0.0035302087299613778, -0.0038531436176586246,
|
||||
-0.0011921632190514074, -0.0020722967099011938,
|
||||
-0.004985351145629344, -0.0042375588844648735,
|
||||
-0.003030360463006021, -0.0014161075428041471,
|
||||
-0.0005083025643192044, 0.00035096963769606926
|
||||
};
|
||||
/* Front, opposite (-30 degree) */
|
||||
static const float of_filt[128] = {
|
||||
-0.000013472538374193126, -0.00008048061877079751,
|
||||
0.000043927265781258155, -0.000017931700794858892,
|
||||
-0.000034774602476112886, -0.00009576223008735474,
|
||||
0.0001557797638630691, -0.00018742885883751094,
|
||||
0.00026512448626705716, -0.0001451040203319678,
|
||||
-0.00008263233117758043, 0.0006486245853639179,
|
||||
-0.0010631408451846698, 0.0026571994100746143,
|
||||
0.0014179177997092787, 0.0062326502956616256,
|
||||
-0.008194149324545333, -0.006568029415878379,
|
||||
0.009538759710818582, 0.012309193558632693,
|
||||
0.12336638055838955, 0.046164307101829005,
|
||||
-0.10228706407884815, 0.04047687260345798,
|
||||
-0.00296595313977046, -0.07057949208414134,
|
||||
0.08172114840714612, 0.08736490764127891,
|
||||
0.05105250431333021, 0.11627179512747428,
|
||||
0.20717888490340705, 0.09375052213570291,
|
||||
-0.09784374168330194, -0.010493571845901443,
|
||||
0.053131894303891716, -0.10157443971694806,
|
||||
-0.16264032634244974, -0.05402369511361273,
|
||||
-0.0274403608654217, -0.09860277022495063,
|
||||
-0.06841875821090282, -0.004434574400066223,
|
||||
-0.0005222661652743502, -0.006231881259827263,
|
||||
0.014410397820340159, 0.04885649512730243,
|
||||
0.04361962569042684, 0.03399214029009391,
|
||||
0.04961073933475931, 0.04067325604132289,
|
||||
0.007850647519227257, 0.004564440466905299,
|
||||
0.02257107958021618, 0.008183791928884486,
|
||||
-0.014913479343180557, -0.018685938460856224,
|
||||
-0.01745737397226911, -0.02327177054233603,
|
||||
-0.03723048632685227, -0.044739390162299685,
|
||||
-0.042651220125613766, -0.03730017561004743,
|
||||
-0.029039465434276192, -0.01885087458914294,
|
||||
-0.01207127752277769, -0.006779800724164512,
|
||||
-0.001930416967444157, 0.000029454577995528385,
|
||||
0.0013822760965755472, 0.0014799128583230202,
|
||||
0.0002068200609199832, 0.0022254295286201083,
|
||||
0.005143858159434566, 0.0018580542060917013,
|
||||
-0.0019426046325146259, -0.0014464042108543495,
|
||||
-0.0034430083560735582, -0.009692758426099499,
|
||||
-0.011840035292593485, -0.010716508855893968,
|
||||
-0.012939889036853034, -0.0121846427935653,
|
||||
-0.006198503315630782, -0.0023186723099380305,
|
||||
-0.002679872498314837, -0.003086020446226295,
|
||||
-0.0015709623347698936, -0.0008147490468332398,
|
||||
-0.0012384575726770983, -0.0005212877089109362,
|
||||
0.0017707578744906142, 0.001324932723905786,
|
||||
-0.0017023653780617696, -0.0045108927752919425,
|
||||
-0.005422155613096912, -0.0039489323837623835,
|
||||
-0.005295995750506547, -0.00629706566356189,
|
||||
-0.004685732198036754, -0.0048076735568143,
|
||||
-0.005978864279217503, -0.005928999306332966,
|
||||
-0.004187703549017582, -0.003213999896976475,
|
||||
-0.0028068699816073414, -0.0010889703907593833,
|
||||
0.0003276714243495386, -0.0013015007040186994,
|
||||
-0.003208050402434782, -0.0025115319088208545,
|
||||
-0.0013787553006401076, -0.0018279087370218635,
|
||||
-0.0025904836507747754, -0.002071221947222004,
|
||||
-0.0026424212922485594, -0.0039837031817577,
|
||||
-0.0041635566057380965, -0.004355223489150822,
|
||||
-0.004350395332709937, -0.0036693292471930263,
|
||||
-0.003386384394185026, -0.003972568655001128,
|
||||
-0.004332336840023821, -0.002648767912111827,
|
||||
-0.001384410080218114, -0.0011353792711849466,
|
||||
-0.0013726264946164232, -0.0020075119315034313
|
||||
};
|
||||
/* Rear, same side (135 degree) */
|
||||
static const float ar_filt[128] = {
|
||||
0.004573315040810066, 0.0013592578059426913,
|
||||
0.01553271930902704, -0.0002356117224941317,
|
||||
-0.05746098219774702, 0.03430688963370445,
|
||||
0.00808371687447385, 0.21893535841158596,
|
||||
0.2984357591724814, -0.3302799746504719,
|
||||
-0.3194029149806245, 0.21633225051331056,
|
||||
0.24371260938097083, -0.08843705549751085,
|
||||
0.03939684701343366, 0.45386926431114494,
|
||||
0.07599118140753386, -0.18114706160474578,
|
||||
0.285640624686038, 0.4049515236666218,
|
||||
-0.05347890222071792, -0.31464359045319074,
|
||||
-0.1033502246468194, -0.04553593949283157,
|
||||
-0.1880747731157464, -0.13629090230626037,
|
||||
-0.10435789106123239, -0.19818232801888755,
|
||||
-0.16701805476330397, -0.022793111199284,
|
||||
0.058049696762683685, 0.007048321372693906,
|
||||
-0.002966419183225961, 0.10140569697797763,
|
||||
0.11648999956673124, 0.05218347182779882,
|
||||
0.028427001212735392, 0.04151900310166159,
|
||||
-0.0006960604221423734, -0.05898623212226975,
|
||||
-0.03801934531173312, -0.029306970535287986,
|
||||
-0.04549125782835908, -0.0599222718506552,
|
||||
-0.058299618975430116, -0.03765579129720727,
|
||||
-0.03559302657499581, -0.020647901025903054,
|
||||
-0.005720957338744348, -0.0041915732688915545,
|
||||
-0.0011470880098346143, 0.008737404798553,
|
||||
0.023444168098121512, 0.024204226042172663,
|
||||
0.01894897166475026, 0.020807655257479588,
|
||||
0.021570431128040954, 0.006800556178576289,
|
||||
-0.009000089216921362, -0.010969824547067934,
|
||||
-0.0033653428332822374, -0.012676936164668659,
|
||||
-0.026739938673413587, -0.023427869194287573,
|
||||
-0.023302007105117244, -0.023647155590533712,
|
||||
-0.021289317515613106, -0.009120487305069884,
|
||||
0.0009251551667728967, 0.00004285344125653763,
|
||||
-0.00009042365479456271, 0.00022573242339446494,
|
||||
0.00720168491586098, 0.007111875505402431,
|
||||
0.003186514817683482, 0.00810087718334745,
|
||||
0.012619557025922575, 0.007854726400013397,
|
||||
-0.0024013592881066267, -0.001452457473161119,
|
||||
-0.0025535188366093945, -0.012428911627809337,
|
||||
-0.013729251536694145, -0.0070099675146427344,
|
||||
-0.007165284278706593, -0.01639289295622301,
|
||||
-0.015831795079778305, -0.007305768485523729,
|
||||
-0.003608863157004021, -0.0032640528878698084,
|
||||
0.0030901263998481944, 0.00749497566124848,
|
||||
0.002515185532327241, 0.00004840875738621367,
|
||||
0.0017596043486043966, 0.0046229941553338144,
|
||||
0.0034259167322926096, 0.003707347634186093,
|
||||
0.0035584806528586328, -0.0019078936035275198,
|
||||
-0.006057343815214898, -0.0069262470468817,
|
||||
-0.004345020728618624, -0.004177623355574794,
|
||||
-0.005373506556122508, -0.006624933928893836,
|
||||
-0.008679541408588839, -0.010718719681595322,
|
||||
-0.011392246979594496, -0.007893917064389902,
|
||||
-0.0027572935365832536, -0.00006064707149834412,
|
||||
-0.0012512537319656323, -0.0024501501002409786,
|
||||
-0.0022106788572895998, -0.00234124933370301,
|
||||
-0.0008953445167066823, 0.0005393670625637734,
|
||||
-0.00033175600142209297, -0.004023994309351289,
|
||||
-0.008655472335784443, -0.009899957354849682,
|
||||
-0.008664952919996412, -0.00553483124503576,
|
||||
-0.003735336089277662, -0.002754824348643885,
|
||||
-0.0026884314856593368, -0.004084181815125924
|
||||
};
|
||||
/* Rear, opposite (-135 degree) */
|
||||
static const float or_filt[128] = {
|
||||
0.0001220944028243897, -0.000021785381808441314,
|
||||
5.823057988603169e-6, -0.00001217768176447613,
|
||||
-0.00006123604397345513, 5.574117262531134e-6,
|
||||
-0.00004935331914366778, 1.1771577934768211e-6,
|
||||
-0.000059236211621095756, 9.503536190497286e-6,
|
||||
-0.0001494445696103564, 0.00012248858284145305,
|
||||
-0.0000963975321456313, 6.017905197665205e-6,
|
||||
0.00003353395360402643, -0.0001931511015359506,
|
||||
0.0005113536523931485, -0.0005676652619386114,
|
||||
0.0012057159755477467, 0.0009370492250339692,
|
||||
0.004596472288877981, -0.0018831773384237068,
|
||||
-0.008208535225621212, 0.0038178646400751056,
|
||||
0.008726517739105965, 0.06664363898418262,
|
||||
0.06788684221502142, -0.04492315162807267,
|
||||
-0.04019906311255255, 0.026203059677375153,
|
||||
0.013678129114847544, -0.014334962223993527,
|
||||
0.010141709596167392, 0.11559131576945537,
|
||||
0.1586402064538425, 0.059975334707967023,
|
||||
0.004671725963777715, 0.031498678282775874,
|
||||
0.014338626006524587, -0.014749719448472231,
|
||||
-0.02055508237941379, -0.05407690143992048,
|
||||
-0.07767559836886143, -0.05029091786216801,
|
||||
-0.030808335706574427, -0.03401958135442541,
|
||||
-0.030520368430288967, -0.014168302104259355,
|
||||
0.011907621259989802, 0.014286081013069,
|
||||
0.006377467879613449, 0.018546823568277478,
|
||||
0.028297012771618273, 0.025222339408338186,
|
||||
0.021931611353415138, 0.019708894333646355,
|
||||
0.01729258494072014, 0.017468204169564034,
|
||||
0.009729094845051928, -0.002976992018531901,
|
||||
-0.00956986166277019, -0.016125733548332074,
|
||||
-0.02934094241442545, -0.04133767871051455,
|
||||
-0.043536981145416466, -0.0385966307108608,
|
||||
-0.02784453599342459, -0.018995135307247116,
|
||||
-0.012849534096536747, -0.004437491064613308,
|
||||
0.00028385411598204655, 0.003776874988516643,
|
||||
0.008069432041547833, 0.008764754183751848,
|
||||
0.008020908861878062, 0.006830351461360802,
|
||||
0.002218330884267235, -0.0020478725582339444,
|
||||
-0.003997428121462543, -0.007066287373515421,
|
||||
-0.00940847412544698, -0.010938998446237963,
|
||||
-0.011775483016151306, -0.011391103919484287,
|
||||
-0.010586061195163017, -0.009842793078929053,
|
||||
-0.007753202010139829, -0.00569213732353025,
|
||||
-0.006506783349722073, -0.005346134281903736,
|
||||
-0.003913089814898934, -0.0036091443854759727,
|
||||
-0.0020328564301266287, 0.00017932870773467683,
|
||||
0.0032779786679056357, 0.003969695813293966,
|
||||
0.0020339334412434987, -0.00011345940675415259,
|
||||
-0.0018344103399567666, -0.003556764701666365,
|
||||
-0.004263523639408391, -0.002940568582022133,
|
||||
-0.0034341188272627556, -0.006023399920020824,
|
||||
-0.0077456903203677865, -0.007912219312377842,
|
||||
-0.00625202770436523, -0.00530785086116117,
|
||||
-0.005569722659634311, -0.004664448462594344,
|
||||
-0.0037747773914077747, -0.004175649656985592,
|
||||
-0.004659601521384289, -0.005008602967819641,
|
||||
-0.004730625079902729, -0.0034039554356604146,
|
||||
-0.0017110333873406587, -0.0006091938771510242,
|
||||
-0.0016051679050678297, -0.003312864664007262,
|
||||
-0.004505512715977288, -0.004152222189861692,
|
||||
-0.003218596419678823, -0.0027277806209877343,
|
||||
-0.001715005444317267, -0.0012589960071233749,
|
||||
-0.001852908777923165, -0.002540339553144362
|
||||
};
|
||||
/* Center rear (180 degree) */
|
||||
static const float cr_filt[128] = {
|
||||
-0.00005989110716536726, -0.00022790291829128702,
|
||||
0.0002659166098971966, -0.0003774772716776257,
|
||||
0.0004540309551867803, -0.000420238187386368,
|
||||
0.00025518536450885686, 0.00028285526288953955,
|
||||
-0.001016391007574093, 0.0028634984299063795,
|
||||
0.0021574799687976045, 0.01035121276682072,
|
||||
-0.010481720917298163, -0.013197198495899292,
|
||||
0.0031928225328717195, 0.02903137843618603,
|
||||
0.1632429772511569, 0.1047487989875262,
|
||||
-0.10464685060623742, -0.09260196288035998,
|
||||
-0.007514241993554443, 0.013596249226741712,
|
||||
-0.019876166508450258, 0.1255626123599804,
|
||||
0.3648170359521724, 0.19458249753223478,
|
||||
-0.04434070930031298, 0.046582528121935265,
|
||||
0.09484427347230277, -0.03137795311969644,
|
||||
-0.10297437925363695, -0.09351091015917065,
|
||||
-0.1129521092162064, -0.14925322995658827,
|
||||
-0.1231466295584665, -0.06356719756705227,
|
||||
-0.05442277895126282, -0.07568433015661316,
|
||||
-0.023314932828602003, 0.04260950721318558,
|
||||
0.02249026315598923, 0.02048195669571197,
|
||||
0.05651342117268278, 0.05885038917623213,
|
||||
0.03797102097397795, 0.011767394419953451,
|
||||
0.00560502503429481, 0.005051125343961189,
|
||||
-0.012925933188033823, -0.023918884651306566,
|
||||
-0.013251659441678816, -0.010694772488866284,
|
||||
-0.03080486448617846, -0.03661278237783158,
|
||||
-0.0379227303416262, -0.042189005718490775,
|
||||
-0.026595666344596286, -0.009759025956801257,
|
||||
-0.002064986663513004, -0.002420117028098389,
|
||||
-0.006629991977552491, 0.004619970897631026,
|
||||
0.019450642967537877, 0.0173521119057514,
|
||||
0.017641425439988062, 0.02270029598048491,
|
||||
0.018976431925275348, 0.009299852902290885,
|
||||
-0.001695039371619912, -0.00675162574265618,
|
||||
-0.009380968871003034, -0.011208396125485165,
|
||||
-0.01308640049201482, -0.0165636375633249,
|
||||
-0.022004099870933345, -0.025173458684139286,
|
||||
-0.016918759559175375, -0.00865150653575917,
|
||||
-0.006999929082792643, -0.005454830010518988,
|
||||
-0.0021129521131095317, 0.00018717090054046307,
|
||||
-0.0002864344788569993, 0.0017615225381095569,
|
||||
0.006985907557802283, 0.010577308310476465,
|
||||
0.006466104789306027, -0.0014988738575948326,
|
||||
-0.0039669755229277195, -0.0065156971200080235,
|
||||
-0.009343206924192169, -0.0076430644693577495,
|
||||
-0.004395214976600924, -0.003052735340422483,
|
||||
-0.007019103043066595, -0.00974109267696527,
|
||||
-0.007968015032797376, -0.007801513845528344,
|
||||
-0.007535748903681969, -0.003543341967287925,
|
||||
0.0015083125553729722, 0.0023345972556147025,
|
||||
-0.0010043623069557037, -0.0025295765105203746,
|
||||
-0.0023701840891643634, -0.0005908186035024362,
|
||||
0.0029826252289082847, 0.004829048542117764,
|
||||
0.004488360022902081, 0.00002643748103005408,
|
||||
-0.0042100779212597295, -0.006170600558114495,
|
||||
-0.007267149164680168, -0.006825522903494639,
|
||||
-0.006899834372739123, -0.0073493916110062675,
|
||||
-0.009554351265163382, -0.011790297433830197,
|
||||
-0.010645796603734424, -0.0064661575394022106,
|
||||
-0.002026743466524137, -0.0004337034584909932,
|
||||
-0.0011172647031654614, -0.0017947816283674731,
|
||||
-0.00255615052036616, -0.0017721562881944813,
|
||||
-0.0002379619297227554, 0.0007130120121089036
|
||||
};
|
||||
|
||||
#endif /* MPLAYER_AF_HRTF_H */
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* simple voice removal filter
|
||||
*
|
||||
* copyright (c) 2006 Reynaldo H. Verdejo Pinochet
|
||||
* Based on code by Alex Beregszaszi for his 'center' filter.
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "af.h"
|
||||
|
||||
// Data for specific instances of this filter
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:
|
||||
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
|
||||
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *c)
|
||||
{
|
||||
if (!c)
|
||||
return 0;
|
||||
if (af_make_writeable(af, c) < 0) {
|
||||
talloc_free(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
float* a = c->planes[0]; // Audio data
|
||||
int nch = c->nch; // Number of channels
|
||||
int len = c->samples*nch; // Number of samples in current audio block
|
||||
register int i;
|
||||
|
||||
/*
|
||||
FIXME1 add a low band pass filter to avoid suppressing
|
||||
centered bass/drums
|
||||
FIXME2 better calculated* attenuation factor
|
||||
*/
|
||||
|
||||
for(i=0;i<len;i+=nch)
|
||||
{
|
||||
a[i] = (a[i] - a[i+1]) * 0.7;
|
||||
a[i+1]=a[i];
|
||||
}
|
||||
|
||||
af_add_output_frame(af, c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate memory and set function pointers
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control = control;
|
||||
af->filter_frame = filter_frame;
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
// Description of this filter
|
||||
const struct af_info af_info_karaoke = {
|
||||
.info = "Simple karaoke/voice-removal audio filter",
|
||||
.name = "karaoke",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
};
|
||||
@@ -1,851 +0,0 @@
|
||||
/*
|
||||
* LADSPA plugin loader
|
||||
*
|
||||
* Written by Ivo van Poorten <ivop@euronet.nl>
|
||||
* Copyright (C) 2004, 2005
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Global Includes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <ladspa.h>
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Local Includes */
|
||||
|
||||
#include "af.h"
|
||||
|
||||
#define _(x) (x)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Filter specific data */
|
||||
|
||||
typedef struct af_ladspa_s
|
||||
{
|
||||
int status; /**< Status of the filter.
|
||||
* Either AF_OK or AF_ERROR
|
||||
* Because MPlayer re-inits audio filters that
|
||||
* _clearly_ returned AF_ERROR anyway, I use this
|
||||
* in play() to skip the processing and return
|
||||
* the data unchanged.
|
||||
*/
|
||||
|
||||
int activated; /**< 0 or 1. Activate LADSPA filters only once, even
|
||||
* if the buffers get resized, to avoid a stuttering
|
||||
* filter.
|
||||
*/
|
||||
|
||||
char *file;
|
||||
char *label;
|
||||
char *controls;
|
||||
|
||||
char *myname; /**< It's easy to have a concatenation of file and label */
|
||||
|
||||
void *libhandle;
|
||||
const LADSPA_Descriptor *plugin_descriptor;
|
||||
|
||||
int nports;
|
||||
|
||||
int ninputs;
|
||||
int *inputs;
|
||||
|
||||
int noutputs;
|
||||
int *outputs;
|
||||
|
||||
int ninputcontrols;
|
||||
int *inputcontrolsmap; /**< Map input port number [0-] to actual port */
|
||||
float *inputcontrols;
|
||||
|
||||
int noutputcontrols;
|
||||
int *outputcontrolsmap;
|
||||
float *outputcontrols;
|
||||
|
||||
int nch; /**< number of channels */
|
||||
int bufsize;
|
||||
float **inbufs;
|
||||
float **outbufs;
|
||||
LADSPA_Handle *chhandles;
|
||||
|
||||
} af_ladspa_t;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int af_open(struct af_instance *af);
|
||||
static int af_ladspa_malloc_failed(char*);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define OPT_BASE_STRUCT af_ladspa_t
|
||||
const struct af_info af_info_ladspa = {
|
||||
.info = "LADSPA plugin loader",
|
||||
.name = "ladspa",
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_ladspa_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_STRING("file", file, 0),
|
||||
OPT_STRING("label", label, 0),
|
||||
OPT_STRING("controls", controls, 0),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* By lack of a better word (in my vocabulary) this is called 'parse'.
|
||||
* Feel free to suggest an alternative.
|
||||
*/
|
||||
|
||||
/** \brief Check for inputs, outputs and controls of a given filter.
|
||||
*
|
||||
* This function counts and checks all input, output and control ports
|
||||
* of the filter that was loaded. If it turns out to be a valid
|
||||
* filter for MPlayer use, it prints out a list of all controls and
|
||||
* the corresponding range of its value at message level MSGL_V.
|
||||
*
|
||||
* \param setup Current setup of the filter. Must have its
|
||||
* plugin_descriptor set!
|
||||
*
|
||||
* \return Returns AF_OK if it has a valid input/output/controls
|
||||
* configuration. Else, it returns AF_ERROR.
|
||||
*/
|
||||
|
||||
static int af_ladspa_parse_plugin(struct af_instance *af) {
|
||||
af_ladspa_t *setup = af->priv;
|
||||
int p, i;
|
||||
const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
|
||||
LADSPA_PortDescriptor d;
|
||||
LADSPA_PortRangeHint hint;
|
||||
|
||||
if (!setup->libhandle)
|
||||
return AF_ERROR; /* only call parse after a successful load */
|
||||
if (!setup->plugin_descriptor)
|
||||
return AF_ERROR; /* same as above */
|
||||
|
||||
/* let's do it */
|
||||
|
||||
setup->nports = pdes->PortCount;
|
||||
|
||||
/* allocate memory for all inputs/outputs/controls */
|
||||
|
||||
setup->inputs = calloc(setup->nports, sizeof(int));
|
||||
if (!setup->inputs) return af_ladspa_malloc_failed(setup->myname);
|
||||
|
||||
setup->outputs = calloc(setup->nports, sizeof(int));
|
||||
if (!setup->outputs) return af_ladspa_malloc_failed(setup->myname);
|
||||
|
||||
setup->inputcontrolsmap = calloc(setup->nports, sizeof(int));
|
||||
if (!setup->inputcontrolsmap) return af_ladspa_malloc_failed(setup->myname);
|
||||
|
||||
setup->inputcontrols = calloc(setup->nports, sizeof(float));
|
||||
if (!setup->inputcontrols) return af_ladspa_malloc_failed(setup->myname);
|
||||
|
||||
setup->outputcontrolsmap = calloc(setup->nports, sizeof(int));
|
||||
if (!setup->outputcontrolsmap) return af_ladspa_malloc_failed(setup->myname);
|
||||
|
||||
setup->outputcontrols = calloc(setup->nports, sizeof(float));
|
||||
if (!setup->outputcontrols) return af_ladspa_malloc_failed(setup->myname);
|
||||
|
||||
/* set counts to zero */
|
||||
|
||||
setup->ninputs = 0;
|
||||
setup->noutputs = 0;
|
||||
setup->ninputcontrols = 0;
|
||||
setup->noutputcontrols = 0;
|
||||
|
||||
/* check all ports, see what type it is and set variables according to
|
||||
* what we have found
|
||||
*/
|
||||
|
||||
for (p=0; p<setup->nports; p++) {
|
||||
d = pdes->PortDescriptors[p];
|
||||
|
||||
if (LADSPA_IS_PORT_AUDIO(d)) {
|
||||
if (LADSPA_IS_PORT_INPUT(d)) {
|
||||
setup->inputs[setup->ninputs] = p;
|
||||
setup->ninputs++;
|
||||
} else if (LADSPA_IS_PORT_OUTPUT(d)) {
|
||||
setup->outputs[setup->noutputs] = p;
|
||||
setup->noutputs++;
|
||||
}
|
||||
}
|
||||
|
||||
if (LADSPA_IS_PORT_CONTROL(d)) {
|
||||
if (LADSPA_IS_PORT_INPUT(d)) {
|
||||
setup->inputcontrolsmap[setup->ninputcontrols] = p;
|
||||
setup->ninputcontrols++;
|
||||
/* set control to zero. set values after reading the rest
|
||||
* of the suboptions and check LADSPA_?_HINT's later.
|
||||
*/
|
||||
setup->inputcontrols[p] = 0.0f;
|
||||
} else if (LADSPA_IS_PORT_OUTPUT(d)) {
|
||||
/* read and handle these too, otherwise filters that have them
|
||||
* will sig11
|
||||
*/
|
||||
setup->outputcontrolsmap[setup->noutputcontrols]=p;
|
||||
setup->noutputcontrols++;
|
||||
setup->outputcontrols[p] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (setup->ninputs == 0) {
|
||||
MP_WARN(af, "%s: %s\n", setup->myname,
|
||||
_("WARNING! This LADSPA plugin has no audio inputs.\n The incoming audio signal will be lost."));
|
||||
} else if (setup->ninputs == 1) {
|
||||
MP_VERBOSE(af, "%s: this is a mono effect\n", setup->myname);
|
||||
} else if (setup->ninputs == 2) {
|
||||
MP_VERBOSE(af, "%s: this is a stereo effect\n", setup->myname);
|
||||
} else {
|
||||
MP_VERBOSE(af, "%s: this is a %i-channel effect, "
|
||||
"support is experimental\n", setup->myname, setup->ninputs);
|
||||
}
|
||||
|
||||
if (setup->noutputs == 0) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("This LADSPA plugin has no audio outputs."));
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
if (setup->noutputs != setup->ninputs ) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("The number of audio inputs and audio outputs of the LADSPA plugin differ."));
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
MP_VERBOSE(af, "%s: this plugin has %d input control(s)\n",
|
||||
setup->myname, setup->ninputcontrols);
|
||||
|
||||
/* Print list of controls and its range of values it accepts */
|
||||
|
||||
for (i=0; i<setup->ninputcontrols; i++) {
|
||||
p = setup->inputcontrolsmap[i];
|
||||
hint = pdes->PortRangeHints[p];
|
||||
MP_VERBOSE(af, " --- %d %s [", i, pdes->PortNames[p]);
|
||||
|
||||
if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) {
|
||||
MP_VERBOSE(af, "%0.2f , ", hint.LowerBound);
|
||||
} else {
|
||||
MP_VERBOSE(af, "... , ");
|
||||
}
|
||||
|
||||
if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) {
|
||||
MP_VERBOSE(af, "%0.2f]\n", hint.UpperBound);
|
||||
} else {
|
||||
MP_VERBOSE(af, "...]\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* This function might "slightly" look like dlopenLADSPA in the LADSPA SDK :-)
|
||||
* But, I changed a few things, because imho it was broken. It did not support
|
||||
* relative paths, only absolute paths that start with a /
|
||||
* I think ../../some/dir/foobar.so is just as valid. And if one wants to call
|
||||
* his library '...somename...so' he's crazy, but it should be allowed.
|
||||
* So, search the path first, try plain *filename later.
|
||||
* Also, try adding .so first! I like the recursion the SDK did, but it's
|
||||
* better the other way around. -af ladspa=cmt:amp_stereo:0.5 is easier to type
|
||||
* than -af ladspa=cmt.so:amp_stereo:0.5 :-))
|
||||
*/
|
||||
|
||||
/** \brief dlopen() wrapper
|
||||
*
|
||||
* This is a wrapper around dlopen(). It tries various variations of the
|
||||
* filename (with or without the addition of the .so extension) in various
|
||||
* directories specified by the LADSPA_PATH environment variable. If all fails
|
||||
* it tries the filename directly as an absolute path to the library.
|
||||
*
|
||||
* \param filename filename of the library to load.
|
||||
* \param flag see dlopen(3) for a description of the flags.
|
||||
*
|
||||
* \return returns a pointer to the loaded library on success, or
|
||||
* NULL if it fails to load.
|
||||
*/
|
||||
|
||||
static void* mydlopen(const char *filename, int flag) {
|
||||
char *buf;
|
||||
const char *end, *start, *ladspapath;
|
||||
int endsinso;
|
||||
size_t filenamelen;
|
||||
void *result = NULL;
|
||||
|
||||
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
/* For Windows there's only absolute path support.
|
||||
* If you have a Windows machine, feel free to fix this.
|
||||
* (path separator, shared objects extension, et cetera). */
|
||||
MP_VERBOSE(af, "\ton windows, only absolute pathnames "
|
||||
"are supported\n");
|
||||
MP_VERBOSE(af, "\ttrying %s\n", filename);
|
||||
return dlopen(filename, flag);
|
||||
#endif
|
||||
|
||||
filenamelen = strlen(filename);
|
||||
|
||||
endsinso = 0;
|
||||
if (filenamelen > 3)
|
||||
endsinso = (strcmp(filename+filenamelen-3, ".so") == 0);
|
||||
if (!endsinso) {
|
||||
buf=malloc(filenamelen+4);
|
||||
strcpy(buf, filename);
|
||||
strcat(buf, ".so");
|
||||
result=mydlopen(buf, flag);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
ladspapath=getenv("LADSPA_PATH");
|
||||
|
||||
if (ladspapath) {
|
||||
start=ladspapath;
|
||||
while (*start != '\0') {
|
||||
int needslash;
|
||||
end=start;
|
||||
while ( (*end != ':') && (*end != '\0') )
|
||||
end++;
|
||||
|
||||
buf=malloc(filenamelen + 2 + (end-start) );
|
||||
if (end > start)
|
||||
strncpy(buf, start, end-start);
|
||||
needslash=0;
|
||||
if (end > start)
|
||||
if (*(end-1) != '/') {
|
||||
needslash = 1;
|
||||
buf[end-start] = '/';
|
||||
}
|
||||
strcpy(buf+needslash+(end-start), filename);
|
||||
|
||||
result=dlopen(buf, flag);
|
||||
|
||||
free(buf);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
start = end;
|
||||
if (*start == ':')
|
||||
start++;
|
||||
} /* end while there's still more in the path */
|
||||
} /* end if there's a ladspapath */
|
||||
|
||||
/* last resort, just open it again, so the dlerror() message is correct */
|
||||
return dlopen(filename,flag);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Load a LADSPA Plugin
|
||||
*
|
||||
* This function loads the LADSPA plugin specified by the file and label
|
||||
* that are present in the setup variable. First, it loads the library.
|
||||
* If it fails, it returns AF_ERROR. If not, it continues to look for the
|
||||
* specified label. If it finds it, it sets the plugin_descriptor inside
|
||||
* setup and returns AF_OK. If it doesn't, it returns AF_ERROR. Special case
|
||||
* is a label called 'help'. In that case, it prints a list of all available
|
||||
* labels (filters) in the library specified by file.
|
||||
*
|
||||
* \param setup Current setup of the filter. Contains filename and label.
|
||||
*
|
||||
* \return Either AF_ERROR or AF_OK, depending on the success of the operation.
|
||||
*/
|
||||
|
||||
static int af_ladspa_load_plugin(struct af_instance *af) {
|
||||
af_ladspa_t *setup = af->priv;
|
||||
const LADSPA_Descriptor *ladspa_descriptor;
|
||||
LADSPA_Descriptor_Function descriptor_function;
|
||||
int i;
|
||||
|
||||
/* load library */
|
||||
MP_VERBOSE(af, "%s: loading ladspa plugin library %s\n",
|
||||
setup->myname, setup->file);
|
||||
|
||||
setup->libhandle = mydlopen(setup->file, RTLD_NOW);
|
||||
|
||||
if (!setup->libhandle) {
|
||||
MP_ERR(af, "%s: %s %s\n\t%s\n", setup->myname,
|
||||
_("failed to load"), setup->file, dlerror() );
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
MP_VERBOSE(af, "%s: library found.\n", setup->myname);
|
||||
|
||||
/* find descriptor function */
|
||||
dlerror();
|
||||
descriptor_function = (LADSPA_Descriptor_Function) dlsym (setup->libhandle,
|
||||
"ladspa_descriptor");
|
||||
|
||||
if (!descriptor_function) {
|
||||
MP_ERR(af, "%s: %s\n\t%s\n", setup->myname,
|
||||
_("Couldn't find ladspa_descriptor() function in the specified library file."), dlerror());
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
/* if label == help, list all labels in library and exit */
|
||||
|
||||
if (strcmp(setup->label, "help") == 0) {
|
||||
MP_INFO(af, "%s: %s %s:\n", setup->myname,
|
||||
_("available labels in"), setup->file);
|
||||
for (i=0; ; i++) {
|
||||
ladspa_descriptor = descriptor_function(i);
|
||||
if (ladspa_descriptor == NULL) {
|
||||
return AF_ERROR;
|
||||
}
|
||||
MP_INFO(af, " %-16s - %s (%lu)\n",
|
||||
ladspa_descriptor->Label,
|
||||
ladspa_descriptor->Name,
|
||||
ladspa_descriptor->UniqueID);
|
||||
}
|
||||
}
|
||||
|
||||
MP_VERBOSE(af, "%s: looking for label\n", setup->myname);
|
||||
|
||||
/* find label in library */
|
||||
for (i=0; ; i++) {
|
||||
ladspa_descriptor = descriptor_function(i);
|
||||
if (ladspa_descriptor == NULL) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("Couldn't find label in plugin library."));
|
||||
return AF_ERROR;
|
||||
}
|
||||
if (strcmp(ladspa_descriptor->Label, setup->label) == 0) {
|
||||
setup->plugin_descriptor = ladspa_descriptor;
|
||||
MP_VERBOSE(af, "%s: %s found\n", setup->myname,
|
||||
setup->label);
|
||||
return AF_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Print a malloc() failed error message.
|
||||
*
|
||||
* Generic function which can be called if a call to malloc(), calloc(),
|
||||
* strdup(), et cetera, failed. It prints a message to the console and
|
||||
* returns AF_ERROR.
|
||||
*
|
||||
* \return AF_ERROR
|
||||
*/
|
||||
|
||||
static int af_ladspa_malloc_failed(char *myname) {
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Controls the filter.
|
||||
*
|
||||
* Control the behaviour of the filter.
|
||||
*
|
||||
* Commands:
|
||||
* CONTROL_REINIT Sets the af structure with proper values for number
|
||||
* of channels, rate, format, et cetera.
|
||||
* \param af Audio filter instance
|
||||
* \param cmd The command to execute
|
||||
* \param arg Arguments to the command
|
||||
*
|
||||
* \return Either AF_ERROR or AF_OK, depending on the succes of the
|
||||
* operation.
|
||||
*/
|
||||
|
||||
static int control(struct af_instance *af, int cmd, void *arg) {
|
||||
af_ladspa_t *setup = (af_ladspa_t*) af->priv;
|
||||
|
||||
switch(cmd) {
|
||||
case AF_CONTROL_REINIT:
|
||||
MP_VERBOSE(af, "%s: (re)init\n", setup->myname);
|
||||
|
||||
if (!arg) return AF_ERROR;
|
||||
|
||||
/* accept FLOAT, let af_format do conversion */
|
||||
|
||||
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
|
||||
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
|
||||
|
||||
return af_test_output(af, (struct mp_audio*)arg);
|
||||
}
|
||||
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Uninitialise the LADSPA Plugin Loader filter.
|
||||
*
|
||||
* This function deactivates the plugin(s), cleans up, frees all allocated
|
||||
* memory and exits.
|
||||
*
|
||||
* \return No return value.
|
||||
*/
|
||||
|
||||
static void uninit(struct af_instance *af) {
|
||||
if (af->priv) {
|
||||
af_ladspa_t *setup = (af_ladspa_t*) af->priv;
|
||||
const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
|
||||
|
||||
if (setup->myname) {
|
||||
MP_VERBOSE(af, "%s: cleaning up\n", setup->myname);
|
||||
free(setup->myname);
|
||||
}
|
||||
|
||||
if (setup->chhandles) {
|
||||
for (int i = 0; i < setup->nch; i+=setup->ninputs) {
|
||||
if (pdes->deactivate) pdes->deactivate(setup->chhandles[i]);
|
||||
if (pdes->cleanup) pdes->cleanup(setup->chhandles[i]);
|
||||
}
|
||||
free(setup->chhandles);
|
||||
}
|
||||
|
||||
free(setup->inputcontrolsmap);
|
||||
free(setup->inputcontrols);
|
||||
free(setup->outputcontrolsmap);
|
||||
free(setup->outputcontrols);
|
||||
free(setup->inputs);
|
||||
free(setup->outputs);
|
||||
|
||||
if (setup->inbufs) {
|
||||
for(int i = 0; i < setup->nch; i++)
|
||||
free(setup->inbufs[i]);
|
||||
free(setup->inbufs);
|
||||
}
|
||||
|
||||
if (setup->outbufs) {
|
||||
for (int i = 0; i < setup->nch; i++)
|
||||
free(setup->outbufs[i]);
|
||||
free(setup->outbufs);
|
||||
}
|
||||
|
||||
if (setup->libhandle)
|
||||
dlclose(setup->libhandle);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Process chunk of audio data through the selected LADSPA Plugin.
|
||||
*
|
||||
* \param af Pointer to audio filter instance
|
||||
* \param data Pointer to chunk of audio data
|
||||
*
|
||||
* \return Either AF_ERROR or AF_OK
|
||||
*/
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
af_ladspa_t *setup = af->priv;
|
||||
const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
|
||||
float *audio = (float*)data->planes[0];
|
||||
int nsamples = data->samples*data->nch;
|
||||
int nch = data->nch;
|
||||
int rate = data->rate;
|
||||
int i, p;
|
||||
|
||||
if (setup->status !=AF_OK) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
if (af_make_writeable(af, data) < 0) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See if it's the first call. If so, setup inbufs/outbufs, instantiate
|
||||
* plugin, connect ports and activate plugin
|
||||
*/
|
||||
|
||||
if ( (setup->bufsize != nsamples/nch) || (setup->nch != nch) ) {
|
||||
|
||||
/* if setup->nch==0, it's the first call, if not, something has
|
||||
* changed and all previous mallocs have to be freed
|
||||
*/
|
||||
|
||||
if (setup->nch != 0) {
|
||||
MP_TRACE(af, "%s: bufsize change; free old buffer\n",
|
||||
setup->myname);
|
||||
|
||||
if(setup->inbufs) {
|
||||
for(i=0; i<setup->nch; i++)
|
||||
free(setup->inbufs[i]);
|
||||
free(setup->inbufs);
|
||||
}
|
||||
if(setup->outbufs) {
|
||||
for(i=0; i<setup->nch; i++)
|
||||
free(setup->outbufs[i]);
|
||||
free(setup->outbufs);
|
||||
}
|
||||
} /* everything is freed */
|
||||
|
||||
setup->bufsize = nsamples/nch;
|
||||
setup->nch = nch;
|
||||
|
||||
setup->inbufs = calloc(nch, sizeof(float*));
|
||||
setup->outbufs = calloc(nch, sizeof(float*));
|
||||
|
||||
MP_TRACE(af, "%s: bufsize = %d\n",
|
||||
setup->myname, setup->bufsize);
|
||||
|
||||
for(i=0; i<nch; i++) {
|
||||
setup->inbufs[i] = calloc(setup->bufsize, sizeof(float));
|
||||
setup->outbufs[i] = calloc(setup->bufsize, sizeof(float));
|
||||
}
|
||||
|
||||
/* only on the first call, there are no handles. */
|
||||
|
||||
if (!setup->chhandles) {
|
||||
setup->chhandles = calloc(nch, sizeof(LADSPA_Handle));
|
||||
|
||||
/* create handles
|
||||
* for stereo effects, create one handle for two channels
|
||||
*/
|
||||
|
||||
for(i=0; i<nch; i++) {
|
||||
|
||||
if (i % setup->ninputs) { /* stereo effect */
|
||||
/* copy the handle from previous channel */
|
||||
setup->chhandles[i] = setup->chhandles[i-1];
|
||||
continue;
|
||||
}
|
||||
|
||||
setup->chhandles[i] = pdes->instantiate(pdes, rate);
|
||||
}
|
||||
}
|
||||
|
||||
/* connect input/output ports for each channel/filter instance
|
||||
*
|
||||
* always (re)connect ports
|
||||
*/
|
||||
|
||||
for(i=0; i<nch; i++) {
|
||||
pdes->connect_port(setup->chhandles[i],
|
||||
setup->inputs[i % setup->ninputs],
|
||||
setup->inbufs[i]);
|
||||
pdes->connect_port(setup->chhandles[i],
|
||||
setup->outputs[i % setup->ninputs],
|
||||
setup->outbufs[i]);
|
||||
|
||||
/* connect (input) controls */
|
||||
|
||||
for (p=0; p<setup->nports; p++) {
|
||||
LADSPA_PortDescriptor d = pdes->PortDescriptors[p];
|
||||
if (LADSPA_IS_PORT_CONTROL(d)) {
|
||||
if (LADSPA_IS_PORT_INPUT(d)) {
|
||||
pdes->connect_port(setup->chhandles[i], p,
|
||||
&(setup->inputcontrols[p]) );
|
||||
} else {
|
||||
pdes->connect_port(setup->chhandles[i], p,
|
||||
&(setup->outputcontrols[p]) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Activate filter (if it isn't already :) ) */
|
||||
|
||||
if (pdes->activate && !setup->activated && i % setup->ninputs == 0)
|
||||
pdes->activate(setup->chhandles[i]);
|
||||
|
||||
} /* All channels/filters done! except for... */
|
||||
setup->activated = 1;
|
||||
|
||||
/* Stereo effect with one channel left. Use same buffer for left
|
||||
* and right. connect it to the second port.
|
||||
*/
|
||||
|
||||
for (p = i; p % setup->ninputs; p++) {
|
||||
pdes->connect_port(setup->chhandles[i-1],
|
||||
setup->inputs[p % setup->ninputs],
|
||||
setup->inbufs[i-1]);
|
||||
pdes->connect_port(setup->chhandles[i-1],
|
||||
setup->outputs[p % setup->ninputs],
|
||||
setup->outbufs[i-1]);
|
||||
} /* done! */
|
||||
|
||||
} /* setup for first call/change of bufsize is done.
|
||||
* normal playing routine follows...
|
||||
*/
|
||||
|
||||
/* Right now, I use a separate input and output buffer.
|
||||
* I could change this to in-place processing (inbuf==outbuf), but some
|
||||
* ladspa filters are broken and are not able to handle that. This seems
|
||||
* fast enough, so unless somebody complains, it stays this way :)
|
||||
*/
|
||||
|
||||
/* Fill inbufs */
|
||||
|
||||
for (p=0; p<setup->bufsize; p++) {
|
||||
for (i=0; i<nch; i++) {
|
||||
setup->inbufs[i][p] = audio[p*nch + i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Run filter(s) */
|
||||
|
||||
for (i=0; i<nch; i+=setup->ninputs) {
|
||||
pdes->run(setup->chhandles[i], setup->bufsize);
|
||||
}
|
||||
|
||||
/* Extract outbufs */
|
||||
|
||||
for (p=0; p<setup->bufsize; p++) {
|
||||
for (i=0; i<nch; i++) {
|
||||
audio[p*nch + i] = setup->outbufs[i][p];
|
||||
}
|
||||
}
|
||||
|
||||
/* done */
|
||||
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/** \brief Open LADSPA Plugin Loader Filter
|
||||
*
|
||||
* \param af Audio Filter instance
|
||||
*
|
||||
* \return Either AF_ERROR or AF_OK
|
||||
*/
|
||||
|
||||
static int af_open(struct af_instance *af) {
|
||||
|
||||
af->control=control;
|
||||
af->uninit=uninit;
|
||||
af->filter_frame = filter_frame;
|
||||
|
||||
af_ladspa_t *setup = af->priv;
|
||||
|
||||
setup->status = AF_ERROR; /* will be set to AF_OK if
|
||||
* all went OK and filter()
|
||||
* should proceed.
|
||||
*/
|
||||
|
||||
setup->myname = strdup(af_info_ladspa.name);
|
||||
if (!setup->myname)
|
||||
return af_ladspa_malloc_failed((char*)af_info_ladspa.name);
|
||||
|
||||
if (!setup->file || !setup->file[0]) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("No library file specified."));
|
||||
uninit(af);
|
||||
return AF_ERROR;
|
||||
}
|
||||
if (!setup->label || !setup->label[0]) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("No filter label specified."));
|
||||
uninit(af);
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
free(setup->myname);
|
||||
setup->myname = calloc(strlen(af_info_ladspa.name)+strlen(setup->file)+
|
||||
strlen(setup->label)+6, 1);
|
||||
snprintf(setup->myname, strlen(af_info_ladspa.name)+
|
||||
strlen(setup->file)+strlen(setup->label)+6, "%s: (%s:%s)",
|
||||
af_info_ladspa.name, setup->file, setup->label);
|
||||
|
||||
/* load plugin :) */
|
||||
|
||||
if ( af_ladspa_load_plugin(af) != AF_OK )
|
||||
return AF_ERROR;
|
||||
|
||||
/* see what inputs, outputs and controls this plugin has */
|
||||
if ( af_ladspa_parse_plugin(af) != AF_OK )
|
||||
return AF_ERROR;
|
||||
|
||||
/* ninputcontrols is set by now, read control values from arg */
|
||||
|
||||
float val;
|
||||
char *line = setup->controls;
|
||||
for (int i = 0; i < setup->ninputcontrols; i++) {
|
||||
if (!line || (i != 0 && *line != ',')) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("Not enough controls specified on the command line."));
|
||||
return AF_ERROR;
|
||||
}
|
||||
if (i != 0)
|
||||
line++;
|
||||
if (sscanf(line, "%f", &val) != 1) {
|
||||
MP_ERR(af, "%s: %s\n", setup->myname,
|
||||
_("Not enough controls specified on the command line."));
|
||||
return AF_ERROR;
|
||||
}
|
||||
setup->inputcontrols[setup->inputcontrolsmap[i]] = val;
|
||||
line = strchr(line, ',');
|
||||
}
|
||||
|
||||
MP_VERBOSE(af, "%s: input controls: ", setup->myname);
|
||||
for (int i = 0; i < setup->ninputcontrols; i++) {
|
||||
MP_VERBOSE(af, "%0.4f ",
|
||||
setup->inputcontrols[setup->inputcontrolsmap[i]]);
|
||||
}
|
||||
MP_VERBOSE(af, "\n");
|
||||
|
||||
/* check boundaries of inputcontrols */
|
||||
|
||||
MP_VERBOSE(af, "%s: checking boundaries of input controls\n",
|
||||
setup->myname);
|
||||
for (int i = 0; i < setup->ninputcontrols; i++) {
|
||||
int p = setup->inputcontrolsmap[i];
|
||||
LADSPA_PortRangeHint hint =
|
||||
setup->plugin_descriptor->PortRangeHints[p];
|
||||
val = setup->inputcontrols[p];
|
||||
|
||||
if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) &&
|
||||
val < hint.LowerBound) {
|
||||
MP_ERR(af, "%s: Input control #%d is below lower boundary of %0.4f.\n",
|
||||
setup->myname, i, hint.LowerBound);
|
||||
return AF_ERROR;
|
||||
}
|
||||
if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) &&
|
||||
val > hint.UpperBound) {
|
||||
MP_ERR(af, "%s: Input control #%d is above upper boundary of %0.4f.\n",
|
||||
setup->myname, i, hint.UpperBound);
|
||||
return AF_ERROR;
|
||||
}
|
||||
}
|
||||
MP_VERBOSE(af, "%s: all controls have sane values\n",
|
||||
setup->myname);
|
||||
|
||||
/* All is well! */
|
||||
setup->status = AF_OK;
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -49,7 +49,6 @@ const uint16_t ac3_bitrate_tab[19] = {
|
||||
typedef struct af_ac3enc_s {
|
||||
struct AVCodec *lavc_acodec;
|
||||
struct AVCodecContext *lavc_actx;
|
||||
AVPacket pkt;
|
||||
int bit_rate;
|
||||
struct mp_audio *input; // frame passed to libavcodec
|
||||
struct mp_audio *pending; // unconsumed input data
|
||||
@@ -146,7 +145,6 @@ static void uninit(struct af_instance* af)
|
||||
af_ac3enc_t *s = af->priv;
|
||||
|
||||
if (s) {
|
||||
av_free_packet(&s->pkt);
|
||||
if(s->lavc_actx) {
|
||||
avcodec_close(s->lavc_actx);
|
||||
av_free(s->lavc_actx);
|
||||
@@ -212,6 +210,8 @@ static int filter_out(struct af_instance *af)
|
||||
MP_FATAL(af, "Could not allocate memory \n");
|
||||
return -1;
|
||||
}
|
||||
int err = -1;
|
||||
|
||||
frame->nb_samples = s->in_samples;
|
||||
frame->format = s->lavc_actx->sample_fmt;
|
||||
frame->channel_layout = s->lavc_actx->channel_layout;
|
||||
@@ -221,30 +221,33 @@ static int filter_out(struct af_instance *af)
|
||||
frame->data[n] = s->input->planes[n];
|
||||
frame->linesize[0] = s->input->samples * s->input->sstride;
|
||||
|
||||
AVPacket pkt = {0};
|
||||
av_init_packet(&pkt);
|
||||
|
||||
int ok;
|
||||
int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &s->pkt, frame, &ok);
|
||||
int lavc_ret = avcodec_encode_audio2(s->lavc_actx, &pkt, frame, &ok);
|
||||
av_frame_free(&frame);
|
||||
s->input->samples = 0;
|
||||
if (lavc_ret < 0 || !ok) {
|
||||
MP_FATAL(af, "Encode failed.\n");
|
||||
return -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",
|
||||
s->pkt.size, s->pending->samples);
|
||||
pkt.size, s->pending->samples);
|
||||
|
||||
struct mp_audio *out =
|
||||
mp_audio_pool_get(af->out_pool, af->data, s->out_samples);
|
||||
if (!out)
|
||||
return -1;
|
||||
goto done;
|
||||
mp_audio_copy_attributes(out, s->pending);
|
||||
|
||||
int frame_size = s->pkt.size;
|
||||
int frame_size = pkt.size;
|
||||
int header_len = 0;
|
||||
char hdr[8];
|
||||
|
||||
if (s->cfg_add_iec61937_header && s->pkt.size > 5) {
|
||||
int bsmod = s->pkt.data[5] & 0x7;
|
||||
if (s->cfg_add_iec61937_header && pkt.size > 5) {
|
||||
int bsmod = pkt.data[5] & 0x7;
|
||||
int len = frame_size;
|
||||
|
||||
frame_size = AC3_FRAME_SIZE * 2 * 2;
|
||||
@@ -262,14 +265,18 @@ static int filter_out(struct af_instance *af)
|
||||
|
||||
char *buf = (char *)out->planes[0];
|
||||
memcpy(buf, hdr, header_len);
|
||||
memcpy(buf + header_len, s->pkt.data, s->pkt.size);
|
||||
memset(buf + header_len + s->pkt.size, 0,
|
||||
frame_size - (header_len + s->pkt.size));
|
||||
swap_16((uint16_t *)(buf + header_len), s->pkt.size / 2);
|
||||
memcpy(buf + header_len, pkt.data, pkt.size);
|
||||
memset(buf + header_len + pkt.size, 0,
|
||||
frame_size - (header_len + pkt.size));
|
||||
swap_16((uint16_t *)(buf + header_len), pkt.size / 2);
|
||||
out->samples = frame_size / out->sstride;
|
||||
af_add_output_frame(af, out);
|
||||
update_delay(af);
|
||||
return 0;
|
||||
|
||||
err = 0;
|
||||
done:
|
||||
av_packet_unref(&pkt);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int af_open(struct af_instance* af){
|
||||
@@ -307,8 +314,6 @@ static int af_open(struct af_instance* af){
|
||||
MP_VERBOSE(af, "[af_lavcac3enc]: in sample format: %s\n",
|
||||
af_fmt_to_str(s->in_sampleformat));
|
||||
|
||||
av_init_packet(&s->pkt);
|
||||
|
||||
s->input = talloc_zero(s, struct mp_audio);
|
||||
|
||||
if (s->cfg_bit_rate) {
|
||||
|
||||
+47
-30
@@ -3,18 +3,18 @@
|
||||
*
|
||||
* Filter graph creation code taken from FFmpeg ffplay.c (LGPL 2.1 or later)
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -34,11 +34,14 @@
|
||||
#include <libavfilter/buffersink.h>
|
||||
#include <libavfilter/buffersrc.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "audio/format.h"
|
||||
#include "audio/fmt-conversion.h"
|
||||
#include "af.h"
|
||||
|
||||
#include "common/av_common.h"
|
||||
#include "common/tags.h"
|
||||
|
||||
#include "options/m_option.h"
|
||||
|
||||
@@ -47,6 +50,7 @@
|
||||
#if LIBAVFILTER_VERSION_MICRO < 100
|
||||
#define graph_parse(graph, filters, inputs, outputs, log_ctx) \
|
||||
avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx)
|
||||
#define avfilter_graph_send_command(a, b, c, d, e, f, g) -1
|
||||
#else
|
||||
#define graph_parse(graph, filters, inputs, outputs, log_ctx) \
|
||||
avfilter_graph_parse_ptr(graph, filters, &(inputs), &(outputs), log_ctx)
|
||||
@@ -63,6 +67,8 @@ struct priv {
|
||||
|
||||
bool eof;
|
||||
|
||||
struct mp_tags *metadata;
|
||||
|
||||
// options
|
||||
char *cfg_graph;
|
||||
char **cfg_avopts;
|
||||
@@ -190,6 +196,10 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
if (af_to_avformat(in->format) == AV_SAMPLE_FMT_NONE)
|
||||
mp_audio_set_format(in, AF_FORMAT_FLOAT);
|
||||
|
||||
// Removing this requires fixing AVFrame.data vs. AVFrame.extended_data
|
||||
if (in->channels.num > AV_NUM_DATA_POINTERS)
|
||||
return AF_ERROR;
|
||||
|
||||
if (!mp_chmap_is_lavc(&in->channels))
|
||||
mp_chmap_reorder_to_lavc(&in->channels); // will always work
|
||||
|
||||
@@ -206,13 +216,27 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
mp_chmap_from_lavc(&out_cm, l_out->channel_layout);
|
||||
mp_audio_set_channels(out, &out_cm);
|
||||
|
||||
if (!mp_audio_config_valid(out))
|
||||
if (!mp_audio_config_valid(out) || out->channels.num > AV_NUM_DATA_POINTERS)
|
||||
return AF_ERROR;
|
||||
|
||||
p->timebase_out = l_out->time_base;
|
||||
|
||||
return mp_audio_config_equals(in, &orig_in) ? AF_OK : AF_FALSE;
|
||||
}
|
||||
case AF_CONTROL_COMMAND: {
|
||||
if (!p->graph)
|
||||
break;
|
||||
char **args = arg;
|
||||
return avfilter_graph_send_command(p->graph, "all",
|
||||
args[0], args[1], &(char){0}, 0, 0)
|
||||
>= 0 ? CONTROL_OK : CONTROL_ERROR;
|
||||
}
|
||||
case AF_CONTROL_GET_METADATA:
|
||||
if (p->metadata) {
|
||||
*(struct mp_tags *)arg = *p->metadata;
|
||||
return CONTROL_OK;
|
||||
}
|
||||
return CONTROL_NA;
|
||||
case AF_CONTROL_RESET:
|
||||
reset(af);
|
||||
return AF_OK;
|
||||
@@ -220,6 +244,17 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
static void get_metadata_from_av_frame(struct af_instance *af, AVFrame *frame)
|
||||
{
|
||||
#if HAVE_AVFRAME_METADATA
|
||||
struct priv *p = af->priv;
|
||||
if (!p->metadata)
|
||||
p->metadata = talloc_zero(p, struct mp_tags);
|
||||
|
||||
mp_tags_copy_from_av_dictionary(p->metadata, av_frame_get_metadata(frame));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
struct priv *p = af->priv;
|
||||
@@ -231,32 +266,15 @@ static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
if (!p->graph)
|
||||
goto error;
|
||||
|
||||
AVFilterLink *l_in = p->in->outputs[0];
|
||||
|
||||
if (data) {
|
||||
frame = av_frame_alloc();
|
||||
frame = mp_audio_to_avframe_and_unref(data);
|
||||
data = NULL;
|
||||
if (!frame)
|
||||
goto error;
|
||||
|
||||
frame->nb_samples = data->samples;
|
||||
frame->format = l_in->format;
|
||||
|
||||
// Timebase is 1/sample_rate
|
||||
frame->pts = p->samples_in;
|
||||
|
||||
frame->channel_layout = l_in->channel_layout;
|
||||
frame->sample_rate = l_in->sample_rate;
|
||||
#if LIBAVFILTER_VERSION_MICRO >= 100
|
||||
// FFmpeg being a stupid POS
|
||||
frame->channels = l_in->channels;
|
||||
#endif
|
||||
|
||||
frame->extended_data = frame->data;
|
||||
for (int n = 0; n < data->num_planes; n++)
|
||||
frame->data[n] = data->planes[n];
|
||||
frame->linesize[0] = frame->nb_samples * data->sstride;
|
||||
|
||||
p->samples_in += data->samples;
|
||||
p->samples_in += frame->nb_samples;
|
||||
}
|
||||
|
||||
if (av_buffersrc_add_frame(p->in, frame) < 0)
|
||||
@@ -307,6 +325,7 @@ static int filter_out(struct af_instance *af)
|
||||
af->delay = in_time - out_time;
|
||||
}
|
||||
|
||||
get_metadata_from_av_frame(af, frame);
|
||||
af_add_output_frame(af, out);
|
||||
av_frame_free(&frame);
|
||||
return 0;
|
||||
@@ -326,8 +345,6 @@ static int af_open(struct af_instance *af)
|
||||
af->uninit = uninit;
|
||||
af->filter_frame = filter_frame;
|
||||
af->filter_out = filter_out;
|
||||
// Removing this requires fixing AVFrame.data vs. AVFrame.extended_data
|
||||
assert(MP_NUM_CHANNELS <= AV_NUM_DATA_POINTERS);
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
|
||||
+124
-47
@@ -30,6 +30,7 @@
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/samplefmt.h>
|
||||
#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/mathematics.h>
|
||||
|
||||
#include "common/common.h"
|
||||
@@ -48,6 +49,7 @@
|
||||
#define avresample_convert(ctx, out, out_planesize, out_samples, in, in_planesize, in_samples) \
|
||||
swr_convert(ctx, out, out_samples, (const uint8_t**)(in), in_samples)
|
||||
#define avresample_set_channel_mapping swr_set_channel_mapping
|
||||
#define avresample_set_compensation swr_set_compensation
|
||||
#else
|
||||
#error "config.h broken or no resampler found"
|
||||
#endif
|
||||
@@ -64,14 +66,7 @@ struct af_resample_opts {
|
||||
int phase_shift;
|
||||
int linear;
|
||||
double cutoff;
|
||||
|
||||
int in_rate_af; // filter input sample rate
|
||||
int in_rate; // actual rate (used by lavr), adjusted for playback speed
|
||||
int in_format;
|
||||
struct mp_chmap in_channels;
|
||||
int out_rate;
|
||||
int out_format;
|
||||
struct mp_chmap out_channels;
|
||||
int normalize;
|
||||
};
|
||||
|
||||
struct af_resample {
|
||||
@@ -83,19 +78,26 @@ struct af_resample {
|
||||
struct mp_audio pool_fmt; // format used to allocate frames for avrctx output
|
||||
struct mp_audio pre_out_fmt; // format before final conversion (S24)
|
||||
struct AVAudioResampleContext *avrctx_out; // for output channel reordering
|
||||
struct af_resample_opts ctx; // opts in the context
|
||||
struct af_resample_opts opts; // opts requested by the user
|
||||
// At least libswresample keeps a pointer around for this:
|
||||
int reorder_in[MP_NUM_CHANNELS];
|
||||
int reorder_out[MP_NUM_CHANNELS];
|
||||
struct mp_audio_pool *reorder_buffer;
|
||||
|
||||
int in_rate_af; // filter input sample rate
|
||||
int in_rate; // actual rate (used by lavr), adjusted for playback speed
|
||||
int in_format;
|
||||
struct mp_chmap in_channels;
|
||||
int out_rate;
|
||||
int out_format;
|
||||
struct mp_chmap out_channels;
|
||||
};
|
||||
|
||||
#if HAVE_LIBAVRESAMPLE
|
||||
static double get_delay(struct af_resample *s)
|
||||
{
|
||||
return avresample_get_delay(s->avrctx) / (double)s->ctx.in_rate +
|
||||
avresample_available(s->avrctx) / (double)s->ctx.out_rate;
|
||||
return avresample_get_delay(s->avrctx) / (double)s->in_rate +
|
||||
avresample_available(s->avrctx) / (double)s->out_rate;
|
||||
}
|
||||
static void drop_all_output(struct af_resample *s)
|
||||
{
|
||||
@@ -108,7 +110,7 @@ static int get_out_samples(struct af_resample *s, int in_samples)
|
||||
#else
|
||||
static double get_delay(struct af_resample *s)
|
||||
{
|
||||
int64_t base = s->ctx.in_rate * (int64_t)s->ctx.out_rate;
|
||||
int64_t base = s->in_rate * (int64_t)s->out_rate;
|
||||
return swr_get_delay(s->avrctx, base) / (double)base;
|
||||
}
|
||||
static void drop_all_output(struct af_resample *s)
|
||||
@@ -120,8 +122,8 @@ static int get_out_samples(struct af_resample *s, int in_samples)
|
||||
#if LIBSWRESAMPLE_VERSION_MAJOR > 1 || LIBSWRESAMPLE_VERSION_MINOR >= 2
|
||||
return swr_get_out_samples(s->avrctx, in_samples);
|
||||
#else
|
||||
return av_rescale_rnd(in_samples, s->ctx.out_rate, s->ctx.in_rate, AV_ROUND_UP)
|
||||
+ swr_get_delay(s->avrctx, s->ctx.out_rate);
|
||||
return av_rescale_rnd(in_samples, s->out_rate, s->in_rate, AV_ROUND_UP)
|
||||
+ swr_get_delay(s->avrctx, s->out_rate);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -177,6 +179,37 @@ bool af_lavrresample_test_conversion(int src_format, int dst_format)
|
||||
check_output_conversion(dst_format) != AV_SAMPLE_FMT_NONE;
|
||||
}
|
||||
|
||||
static struct mp_chmap fudge_pairs[][2] = {
|
||||
{MP_CHMAP2(BL, BR), MP_CHMAP2(SL, SR)},
|
||||
{MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR)},
|
||||
{MP_CHMAP2(SDL, SDR), MP_CHMAP2(SL, SR)},
|
||||
{MP_CHMAP2(SL, SR), MP_CHMAP2(SDL, SDR)},
|
||||
};
|
||||
|
||||
// Modify out_layout and return the new value. The intention is reducing the
|
||||
// loss libswresample's rematrixing will cause by exchanging similar, but
|
||||
// strictly speaking incompatible channel pairs. For example, 7.1 should be
|
||||
// changed to 7.1(wide) without dropping the SL/SR channels. (We still leave
|
||||
// it to libswresample to create the remix matrix.)
|
||||
static uint64_t fudge_layout_conversion(struct af_instance *af,
|
||||
uint64_t in, uint64_t out)
|
||||
{
|
||||
for (int n = 0; n < MP_ARRAY_SIZE(fudge_pairs); n++) {
|
||||
uint64_t a = mp_chmap_to_lavc(&fudge_pairs[n][0]);
|
||||
uint64_t b = mp_chmap_to_lavc(&fudge_pairs[n][1]);
|
||||
if ((in & a) == a && (in & b) == 0 &&
|
||||
(out & a) == 0 && (out & b) == b)
|
||||
{
|
||||
out = (out & ~b) | a;
|
||||
|
||||
MP_VERBOSE(af, "Fudge: %s -> %s\n",
|
||||
mp_chmap_to_str(&fudge_pairs[n][0]),
|
||||
mp_chmap_to_str(&fudge_pairs[n][1]));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// mp_chmap_get_reorder() performs:
|
||||
// to->speaker[n] = from->speaker[src[n]]
|
||||
// but libavresample does:
|
||||
@@ -214,26 +247,27 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
|
||||
out_samplefmtp == AV_SAMPLE_FMT_NONE)
|
||||
goto error;
|
||||
|
||||
s->ctx.out_rate = out->rate;
|
||||
s->ctx.in_rate_af = in->rate;
|
||||
s->ctx.in_rate = rate_from_speed(in->rate, s->playback_speed);
|
||||
s->ctx.out_format = out->format;
|
||||
s->ctx.in_format = in->format;
|
||||
s->ctx.out_channels= out->channels;
|
||||
s->ctx.in_channels = in->channels;
|
||||
s->ctx.filter_size = s->opts.filter_size;
|
||||
s->ctx.phase_shift = s->opts.phase_shift;
|
||||
s->ctx.linear = s->opts.linear;
|
||||
s->ctx.cutoff = s->opts.cutoff;
|
||||
s->out_rate = out->rate;
|
||||
s->in_rate_af = in->rate;
|
||||
s->in_rate = rate_from_speed(in->rate, s->playback_speed);
|
||||
s->out_format = out->format;
|
||||
s->in_format = in->format;
|
||||
s->out_channels= out->channels;
|
||||
s->in_channels = in->channels;
|
||||
|
||||
av_opt_set_int(s->avrctx, "filter_size", s->ctx.filter_size, 0);
|
||||
av_opt_set_int(s->avrctx, "phase_shift", s->ctx.phase_shift, 0);
|
||||
av_opt_set_int(s->avrctx, "linear_interp", s->ctx.linear, 0);
|
||||
av_opt_set_int(s->avrctx, "filter_size", s->opts.filter_size, 0);
|
||||
av_opt_set_int(s->avrctx, "phase_shift", s->opts.phase_shift, 0);
|
||||
av_opt_set_int(s->avrctx, "linear_interp", s->opts.linear, 0);
|
||||
|
||||
av_opt_set_double(s->avrctx, "cutoff", s->ctx.cutoff, 0);
|
||||
av_opt_set_double(s->avrctx, "cutoff", s->opts.cutoff, 0);
|
||||
|
||||
int normalize = s->opts.normalize;
|
||||
if (normalize < 0)
|
||||
normalize = af->opts->audio_normalize;
|
||||
#if HAVE_LIBSWRESAMPLE
|
||||
av_opt_set_double(s->avrctx, "rematrix_maxval", 1.0, 0);
|
||||
av_opt_set_double(s->avrctx, "rematrix_maxval", normalize ? 1 : 1000, 0);
|
||||
#else
|
||||
av_opt_set_int(s->avrctx, "normalize_mix_level", !!normalize, 0);
|
||||
#endif
|
||||
|
||||
if (mp_set_avopts(af->log, s->avrctx, s->avopts) < 0)
|
||||
@@ -297,26 +331,29 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
|
||||
if (map_out.num > out_lavc.num)
|
||||
mp_audio_set_channels(&s->pool_fmt, &map_out);
|
||||
|
||||
out_ch_layout = fudge_layout_conversion(af, in_ch_layout, out_ch_layout);
|
||||
|
||||
// Real conversion; output is input to avrctx_out.
|
||||
av_opt_set_int(s->avrctx, "in_channel_layout", in_ch_layout, 0);
|
||||
av_opt_set_int(s->avrctx, "out_channel_layout", out_ch_layout, 0);
|
||||
av_opt_set_int(s->avrctx, "in_sample_rate", s->ctx.in_rate, 0);
|
||||
av_opt_set_int(s->avrctx, "out_sample_rate", s->ctx.out_rate, 0);
|
||||
av_opt_set_int(s->avrctx, "in_sample_rate", s->in_rate, 0);
|
||||
av_opt_set_int(s->avrctx, "out_sample_rate", s->out_rate, 0);
|
||||
av_opt_set_int(s->avrctx, "in_sample_fmt", in_samplefmt, 0);
|
||||
av_opt_set_int(s->avrctx, "out_sample_fmt", out_samplefmtp, 0);
|
||||
|
||||
// Just needs the correct number of channels.
|
||||
int fake_out_ch_layout = av_get_default_channel_layout(map_out.num);
|
||||
// Just needs the correct number of channels for deplanarization.
|
||||
struct mp_chmap fake_chmap;
|
||||
mp_chmap_set_unknown(&fake_chmap, map_out.num);
|
||||
uint64_t fake_out_ch_layout = mp_chmap_to_lavc_unchecked(&fake_chmap);
|
||||
if (!fake_out_ch_layout)
|
||||
goto error;
|
||||
|
||||
// Deplanarize if needed.
|
||||
av_opt_set_int(s->avrctx_out, "in_channel_layout", fake_out_ch_layout, 0);
|
||||
av_opt_set_int(s->avrctx_out, "out_channel_layout", fake_out_ch_layout, 0);
|
||||
|
||||
av_opt_set_int(s->avrctx_out, "in_sample_fmt", out_samplefmtp, 0);
|
||||
av_opt_set_int(s->avrctx_out, "out_sample_fmt", out_samplefmt, 0);
|
||||
av_opt_set_int(s->avrctx_out, "in_sample_rate", s->ctx.out_rate, 0);
|
||||
av_opt_set_int(s->avrctx_out, "out_sample_rate", s->ctx.out_rate, 0);
|
||||
av_opt_set_int(s->avrctx_out, "in_sample_rate", s->out_rate, 0);
|
||||
av_opt_set_int(s->avrctx_out, "out_sample_rate", s->out_rate, 0);
|
||||
|
||||
// API has weird requirements, quoting avresample.h:
|
||||
// * This function can only be called when the allocated context is not open.
|
||||
@@ -387,14 +424,6 @@ static int control(struct af_instance *af, int cmd, void *arg)
|
||||
return AF_OK;
|
||||
case AF_CONTROL_SET_PLAYBACK_SPEED_RESAMPLE: {
|
||||
s->playback_speed = *(double *)arg;
|
||||
int new_rate = rate_from_speed(s->ctx.in_rate_af, s->playback_speed);
|
||||
if (new_rate != s->ctx.in_rate && s->avrctx && af->fmt_out.format) {
|
||||
// Before reconfiguring, drain the audio that is still buffered
|
||||
// in the resampler.
|
||||
af->filter_frame(af, NULL);
|
||||
// Reinitialize resampler.
|
||||
configure_lavrr(af, &af->fmt_in, &af->fmt_out, false);
|
||||
}
|
||||
return AF_OK;
|
||||
}
|
||||
case AF_CONTROL_RESET:
|
||||
@@ -430,6 +459,18 @@ static void extra_output_conversion(struct af_instance *af, struct mp_audio *mpa
|
||||
}
|
||||
mp_audio_set_format(mpa, AF_FORMAT_S24);
|
||||
}
|
||||
|
||||
for (int p = 0; p < mpa->num_planes; p++) {
|
||||
void *ptr = mpa->planes[p];
|
||||
int total = mpa->samples * mpa->spf;
|
||||
if (af_fmt_from_planar(mpa->format) == AF_FORMAT_FLOAT) {
|
||||
for (int s = 0; s < total; s++)
|
||||
((float *)ptr)[s] = av_clipf(((float *)ptr)[s], -1.0f, 1.0f);
|
||||
} else if (af_fmt_from_planar(mpa->format) == AF_FORMAT_DOUBLE) {
|
||||
for (int s = 0; s < total; s++)
|
||||
((double *)ptr)[s] = MPCLAMP(((double *)ptr)[s], -1.0, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This relies on the tricky way mpa was allocated.
|
||||
@@ -456,7 +497,7 @@ static void reorder_planes(struct mp_audio *mpa, int *reorder,
|
||||
}
|
||||
}
|
||||
|
||||
static int filter(struct af_instance *af, struct mp_audio *in)
|
||||
static int filter_resample(struct af_instance *af, struct mp_audio *in)
|
||||
{
|
||||
struct af_resample *s = af->priv;
|
||||
|
||||
@@ -517,6 +558,39 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int filter(struct af_instance *af, struct mp_audio *in)
|
||||
{
|
||||
struct af_resample *s = af->priv;
|
||||
|
||||
int new_rate = rate_from_speed(s->in_rate_af, s->playback_speed);
|
||||
bool need_reinit = fabs(new_rate / (double)s->in_rate - 1) > 0.01;
|
||||
|
||||
if (s->avrctx) {
|
||||
AVRational r = av_d2q(s->playback_speed * s->in_rate_af / s->in_rate,
|
||||
INT_MAX / 2);
|
||||
// Essentially, swr/avresample_set_compensation() does 2 things:
|
||||
// - adjust output sample rate by sample_delta/compensation_distance
|
||||
// - reset the adjustment after compensation_distance output samples
|
||||
// Increase the compensation_distance to avoid undesired reset
|
||||
// semantics - we want to keep the ratio for the whole frame we're
|
||||
// feeding it, until the next filter() call.
|
||||
int mult = INT_MAX / 2 / MPMAX(MPMAX(abs(r.num), abs(r.den)), 1);
|
||||
r = (AVRational){ r.num * mult, r.den * mult };
|
||||
if (avresample_set_compensation(s->avrctx, r.den - r.num, r.den) < 0)
|
||||
need_reinit = true;
|
||||
}
|
||||
|
||||
if (need_reinit && new_rate != s->in_rate) {
|
||||
// Before reconfiguring, drain the audio that is still buffered
|
||||
// in the resampler.
|
||||
filter_resample(af, NULL);
|
||||
// Reinitialize resampler.
|
||||
configure_lavrr(af, &af->fmt_in, &af->fmt_out, false);
|
||||
}
|
||||
|
||||
return filter_resample(af, in);
|
||||
}
|
||||
|
||||
static int af_open(struct af_instance *af)
|
||||
{
|
||||
struct af_resample *s = af->priv;
|
||||
@@ -545,6 +619,7 @@ const struct af_info af_info_lavrresample = {
|
||||
.filter_size = 16,
|
||||
.cutoff = 0.0,
|
||||
.phase_shift = 10,
|
||||
.normalize = -1,
|
||||
},
|
||||
.playback_speed = 1.0,
|
||||
.allow_detach = 1,
|
||||
@@ -555,6 +630,8 @@ const struct af_info af_info_lavrresample = {
|
||||
OPT_FLAG("linear", opts.linear, 0),
|
||||
OPT_DOUBLE("cutoff", opts.cutoff, M_OPT_RANGE, .min = 0, .max = 1),
|
||||
OPT_FLAG("detach", allow_detach, 0),
|
||||
OPT_CHOICE("normalize", opts.normalize, 0,
|
||||
({"no", 0}, {"yes", 1}, {"auto", -1})),
|
||||
OPT_KEYVALUELIST("o", avopts, 0),
|
||||
{0}
|
||||
},
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -286,9 +286,6 @@ static void update_speed(struct af_instance *af, float speed)
|
||||
|
||||
s->frames_stride_scaled = s->scale * s->frames_stride;
|
||||
s->frames_stride_error = MPMIN(s->frames_stride_error, s->frames_stride_scaled);
|
||||
|
||||
MP_VERBOSE(af, "%.3f speed * %.3f scale_nominal = %.3f\n",
|
||||
s->speed, s->scale_nominal, s->scale);
|
||||
}
|
||||
|
||||
// Initialization and runtime control
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Michael Niedermayer
|
||||
* Copyright (C) 2004 Alex Beregszaszi
|
||||
* based upon af_extrastereo.c by Pierre Lombard
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "af.h"
|
||||
|
||||
// Data for specific instances of this filter
|
||||
typedef struct af_sinesuppress_s
|
||||
{
|
||||
double freq;
|
||||
double decay;
|
||||
double real;
|
||||
double imag;
|
||||
double ref;
|
||||
double pos;
|
||||
}af_sinesuppress_t;
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
|
||||
mp_audio_set_num_channels(af->data, 1);
|
||||
mp_audio_set_format(af->data, AF_FORMAT_S16);
|
||||
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
static int play_s16(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
if (af_make_writeable(af, data) < 0) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
af_sinesuppress_t *s = af->priv;
|
||||
register int i = 0;
|
||||
int16_t *a = (int16_t*)data->planes[0]; // Audio data
|
||||
int len = data->samples*data->nch; // Number of samples
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
double co= cos(s->pos);
|
||||
double si= sin(s->pos);
|
||||
|
||||
s->real += co * a[i];
|
||||
s->imag += si * a[i];
|
||||
s->ref += co * co;
|
||||
|
||||
a[i] -= (s->real * co + s->imag * si) / s->ref;
|
||||
|
||||
s->real -= s->real * s->decay;
|
||||
s->imag -= s->imag * s->decay;
|
||||
s->ref -= s->ref * s->decay;
|
||||
|
||||
s->pos += 2 * M_PI * s->freq / data->rate;
|
||||
}
|
||||
|
||||
MP_VERBOSE(af, "f:%8.2f: amp:%8.2f\n", s->freq, sqrt(s->real*s->real + s->imag*s->imag) / s->ref);
|
||||
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate memory and set function pointers
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control=control;
|
||||
af->filter_frame = play_s16;
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_sinesuppress_t
|
||||
const struct af_info af_info_sinesuppress = {
|
||||
.info = "Sine Suppress",
|
||||
.name = "sinesuppress",
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_sinesuppress_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_DOUBLE("freq", freq, 0, OPTDEF_DOUBLE(50.0)),
|
||||
OPT_DOUBLE("decay", decay, 0, OPTDEF_DOUBLE(0.0001)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Anders Johansson ajh@watri.uwa.edu.au
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* This filter adds a sub-woofer channels to the audio stream by
|
||||
averaging the left and right channel and low-pass filter them. The
|
||||
low-pass filter is implemented as a 4th order IIR Butterworth
|
||||
filter, with a variable cutoff frequency between 10 and 300 Hz. The
|
||||
filter gives 24dB/octave attenuation. There are two runtime
|
||||
controls one for setting which channel to insert the sub-audio into
|
||||
called AF_CONTROL_SUB_CH and one for setting the cutoff frequency
|
||||
called AF_CONTROL_SUB_FC.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "af.h"
|
||||
#include "dsp.h"
|
||||
|
||||
// Q value for low-pass filter
|
||||
#define Q 1.0
|
||||
|
||||
// Analog domain biquad section
|
||||
typedef struct{
|
||||
float a[3]; // Numerator coefficients
|
||||
float b[3]; // Denominator coefficients
|
||||
} biquad_t;
|
||||
|
||||
// S-parameters for designing 4th order Butterworth filter
|
||||
static const biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}},
|
||||
{{1.0,0.0,0.0},{1.0,1.847759,1.0}}};
|
||||
|
||||
// Data for specific instances of this filter
|
||||
typedef struct af_sub_s
|
||||
{
|
||||
float w[2][4]; // Filter taps for low-pass filter
|
||||
float q[2][2]; // Circular queues
|
||||
float fc; // Cutoff frequency [Hz] for low-pass filter
|
||||
float k; // Filter gain;
|
||||
int ch; // Channel number which to insert the filtered data
|
||||
|
||||
}af_sub_t;
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
af_sub_t* s = af->priv;
|
||||
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
// Sanity check
|
||||
if(!arg) return AF_ERROR;
|
||||
|
||||
af->data->rate = ((struct mp_audio*)arg)->rate;
|
||||
mp_audio_set_channels_old(af->data, MPMAX(s->ch+1,((struct mp_audio*)arg)->nch));
|
||||
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
|
||||
|
||||
// Design low-pass filter
|
||||
s->k = 1.0;
|
||||
if((-1 == af_filter_szxform(sp[0].a, sp[0].b, Q, s->fc,
|
||||
(float)af->data->rate, &s->k, s->w[0])) ||
|
||||
(-1 == af_filter_szxform(sp[1].a, sp[1].b, Q, s->fc,
|
||||
(float)af->data->rate, &s->k, s->w[1])))
|
||||
return AF_ERROR;
|
||||
return af_test_output(af,(struct mp_audio*)arg);
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
#ifndef IIR
|
||||
#define IIR(in,w,q,out) { \
|
||||
float h0 = (q)[0]; \
|
||||
float h1 = (q)[1]; \
|
||||
float hn = (in) - h0 * (w)[0] - h1 * (w)[1]; \
|
||||
out = hn + h0 * (w)[2] + h1 * (w)[3]; \
|
||||
(q)[1] = h0; \
|
||||
(q)[0] = hn; \
|
||||
}
|
||||
#endif
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
if (af_make_writeable(af, data) < 0) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct mp_audio* c = data; // Current working data
|
||||
af_sub_t* s = af->priv; // Setup for this instance
|
||||
float* a = c->planes[0]; // Audio data
|
||||
int len = c->samples*c->nch; // Number of samples in current audio block
|
||||
int nch = c->nch; // Number of channels
|
||||
int ch = s->ch; // Channel in which to insert the sub audio
|
||||
register int i;
|
||||
|
||||
// Run filter
|
||||
for(i=0;i<len;i+=nch){
|
||||
// Average left and right
|
||||
register float x = 0.5 * (a[i] + a[i+1]);
|
||||
IIR(x * s->k, s->w[0], s->q[0], x);
|
||||
IIR(x , s->w[1], s->q[1], a[i+ch]);
|
||||
}
|
||||
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allocate memory and set function pointers
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control=control;
|
||||
af->filter_frame = filter_frame;
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_sub_t
|
||||
const struct af_info af_info_sub = {
|
||||
.info = "Audio filter for adding a sub-base channel",
|
||||
.name = "sub",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_sub_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_FLOATRANGE("fc", fc, 0, 20, 300, OPTDEF_FLOAT(60.0)),
|
||||
OPT_INTRANGE("ch", ch, 0, 0, AF_NCH - 1, OPTDEF_INT(5)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,246 +0,0 @@
|
||||
/*
|
||||
* Filter to do simple decoding of matrixed surround sound.
|
||||
* This will provide a (basic) surround-sound effect from
|
||||
* audio encoded for Dolby Surround, Pro Logic etc.
|
||||
*
|
||||
* Original author: Steve Davies <steve@daviesfam.org>
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* The principle: Make rear channels by extracting anti-phase data
|
||||
from the front channels, delay by 20ms and feed to rear in anti-phase
|
||||
*/
|
||||
|
||||
|
||||
/* SPLITREAR: Define to decode two distinct rear channels - this
|
||||
doesn't work so well in practice because separation in a passive
|
||||
matrix is not high. C (dialogue) to Ls and Rs 14dB or so - so
|
||||
dialogue leaks to the rear. Still - give it a try and send
|
||||
feedback. Comment this define for old behavior of a single
|
||||
surround sent to rear in anti-phase */
|
||||
#define SPLITREAR 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "af.h"
|
||||
#include "dsp.h"
|
||||
|
||||
#define L 32 // Length of fir filter
|
||||
#define LD 65536 // Length of delay buffer
|
||||
|
||||
// 32 Tap fir filter loop unrolled
|
||||
#define FIR(x,w,y) \
|
||||
y = ( w[0] *x[0] +w[1] *x[1] +w[2] *x[2] +w[3] *x[3] \
|
||||
+ w[4] *x[4] +w[5] *x[5] +w[6] *x[6] +w[7] *x[7] \
|
||||
+ w[8] *x[8] +w[9] *x[9] +w[10]*x[10]+w[11]*x[11] \
|
||||
+ w[12]*x[12]+w[13]*x[13]+w[14]*x[14]+w[15]*x[15] \
|
||||
+ w[16]*x[16]+w[17]*x[17]+w[18]*x[18]+w[19]*x[19] \
|
||||
+ w[20]*x[20]+w[21]*x[21]+w[22]*x[22]+w[23]*x[23] \
|
||||
+ w[24]*x[24]+w[25]*x[25]+w[26]*x[26]+w[27]*x[27] \
|
||||
+ w[28]*x[28]+w[29]*x[29]+w[30]*x[30]+w[31]*x[31])
|
||||
|
||||
// Add to circular queue macro + update index
|
||||
#ifdef SPLITREAR
|
||||
#define ADDQUE(qi,rq,lq,r,l)\
|
||||
lq[qi]=lq[qi+L]=(l);\
|
||||
rq[qi]=rq[qi+L]=(r);\
|
||||
qi=(qi-1)&(L-1);
|
||||
#else
|
||||
#define ADDQUE(qi,lq,l)\
|
||||
lq[qi]=lq[qi+L]=(l);\
|
||||
qi=(qi-1)&(L-1);
|
||||
#endif
|
||||
|
||||
// Macro for updating queue index in delay queues
|
||||
#define UPDATEQI(qi) qi=(qi+1)&(LD-1)
|
||||
|
||||
// instance data
|
||||
typedef struct af_surround_s
|
||||
{
|
||||
float lq[2*L]; // Circular queue for filtering left rear channel
|
||||
float rq[2*L]; // Circular queue for filtering right rear channel
|
||||
float w[L]; // FIR filter coefficients for surround sound 7kHz low-pass
|
||||
float* dr; // Delay queue right rear channel
|
||||
float* dl; // Delay queue left rear channel
|
||||
float d; // Delay time
|
||||
int i; // Position in circular buffer
|
||||
int wi; // Write index for delay queue
|
||||
int ri; // Read index for delay queue
|
||||
}af_surround_t;
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
af_surround_t *s = af->priv;
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:{
|
||||
struct mp_audio *in = arg;
|
||||
float fc;
|
||||
if (!mp_chmap_is_stereo(&in->channels)) {
|
||||
MP_ERR(af, "Only stereo input is supported.\n");
|
||||
return AF_DETACH;
|
||||
}
|
||||
|
||||
mp_audio_set_format(in, AF_FORMAT_FLOAT);
|
||||
mp_audio_copy_config(af->data, in);
|
||||
mp_audio_set_channels_old(af->data, in->nch * 2);
|
||||
|
||||
// Surround filer coefficients
|
||||
fc = 2.0 * 7000.0/(float)af->data->rate;
|
||||
if (-1 == af_filter_design_fir(L, s->w, &fc, LP|HAMMING, 0)){
|
||||
MP_ERR(af, "Unable to design low-pass filter.\n");
|
||||
return AF_ERROR;
|
||||
}
|
||||
|
||||
// Free previous delay queues
|
||||
free(s->dl);
|
||||
free(s->dr);
|
||||
// Allocate new delay queues
|
||||
s->dl = calloc(LD,af->data->bps);
|
||||
s->dr = calloc(LD,af->data->bps);
|
||||
if((NULL == s->dl) || (NULL == s->dr))
|
||||
MP_FATAL(af, "Out of memory\n");
|
||||
|
||||
// Initialize delay queue index
|
||||
if(AF_OK != af_from_ms(1, &s->d, &s->wi, af->data->rate, 0.0, 1000.0))
|
||||
return AF_ERROR;
|
||||
// printf("%i\n",s->wi);
|
||||
s->ri = 0;
|
||||
|
||||
return AF_OK;
|
||||
}
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
// The beginnings of an active matrix...
|
||||
static const float steering_matrix[][12] = {
|
||||
// LL RL LR RR LS RS
|
||||
// LLs RLs LRs RRs LC RC
|
||||
{.707, .0, .0, .707, .5, -.5,
|
||||
.5878, -.3928, .3928, -.5878, .5, .5},
|
||||
};
|
||||
|
||||
// Experimental moving average dominance
|
||||
//static int amp_L = 0, amp_R = 0, amp_C = 0, amp_S = 0;
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
struct mp_audio *outframe =
|
||||
mp_audio_pool_get(af->out_pool, &af->fmt_out, data->samples);
|
||||
if (!outframe) {
|
||||
talloc_free(data);
|
||||
return -1;
|
||||
}
|
||||
mp_audio_copy_attributes(outframe, data);
|
||||
|
||||
af_surround_t* s = (af_surround_t*)af->priv;
|
||||
const float* m = steering_matrix[0];
|
||||
float* in = data->planes[0]; // Input audio data
|
||||
float* out = outframe->planes[0]; // Output audio data
|
||||
float* end = in + data->samples * data->nch;
|
||||
int i = s->i; // Filter queue index
|
||||
int ri = s->ri; // Read index for delay queue
|
||||
int wi = s->wi; // Write index for delay queue
|
||||
|
||||
while(in < end){
|
||||
/* Dominance:
|
||||
abs(in[0]) abs(in[1]);
|
||||
abs(in[0]+in[1]) abs(in[0]-in[1]);
|
||||
10 * log( abs(in[0]) / (abs(in[1])|1) );
|
||||
10 * log( abs(in[0]+in[1]) / (abs(in[0]-in[1])|1) ); */
|
||||
|
||||
/* About volume balancing...
|
||||
Surround encoding does the following:
|
||||
Lt=L+.707*C+.707*S, Rt=R+.707*C-.707*S
|
||||
So S should be extracted as:
|
||||
(Lt-Rt)
|
||||
But we are splitting the S to two output channels, so we
|
||||
must take 3dB off as we split it:
|
||||
Ls=Rs=.707*(Lt-Rt)
|
||||
Trouble is, Lt could be +1, Rt -1, so possibility that S will
|
||||
overflow. So to avoid that, we cut L/R by 3dB (*.707), and S by
|
||||
6dB (/2). This keeps the overall balance, but guarantees no
|
||||
overflow. */
|
||||
|
||||
// Output front left and right
|
||||
out[0] = m[0]*in[0] + m[1]*in[1];
|
||||
out[1] = m[2]*in[0] + m[3]*in[1];
|
||||
|
||||
// Low-pass output @ 7kHz
|
||||
FIR((&s->lq[i]), s->w, s->dl[wi]);
|
||||
|
||||
// Delay output by d ms
|
||||
out[2] = s->dl[ri];
|
||||
|
||||
#ifdef SPLITREAR
|
||||
// Low-pass output @ 7kHz
|
||||
FIR((&s->rq[i]), s->w, s->dr[wi]);
|
||||
|
||||
// Delay output by d ms
|
||||
out[3] = s->dr[ri];
|
||||
#else
|
||||
out[3] = -out[2];
|
||||
#endif
|
||||
|
||||
// Update delay queues indexes
|
||||
UPDATEQI(ri);
|
||||
UPDATEQI(wi);
|
||||
|
||||
// Calculate and save surround in circular queue
|
||||
#ifdef SPLITREAR
|
||||
ADDQUE(i, s->rq, s->lq, m[6]*in[0]+m[7]*in[1], m[8]*in[0]+m[9]*in[1]);
|
||||
#else
|
||||
ADDQUE(i, s->lq, m[4]*in[0]+m[5]*in[1]);
|
||||
#endif
|
||||
|
||||
// Next sample...
|
||||
in = &in[data->nch];
|
||||
out = &out[af->data->nch];
|
||||
}
|
||||
|
||||
// Save indexes
|
||||
s->i = i; s->ri = ri; s->wi = wi;
|
||||
|
||||
talloc_free(data);
|
||||
af_add_output_frame(af, outframe);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control=control;
|
||||
af->filter_frame = filter_frame;
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_surround_t
|
||||
const struct af_info af_info_surround =
|
||||
{
|
||||
.info = "Surround decoder filter",
|
||||
.name = "surround",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_surround_t),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_FLOATRANGE("d", d, 0, 0, 1000, OPTDEF_FLOAT(20.0)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "af.h"
|
||||
|
||||
typedef struct af_sweep_s{
|
||||
double x;
|
||||
double delta;
|
||||
}af_sweept;
|
||||
|
||||
|
||||
// Initialization and runtime control
|
||||
static int control(struct af_instance* af, int cmd, void* arg)
|
||||
{
|
||||
struct mp_audio *data= (struct mp_audio*)arg;
|
||||
|
||||
switch(cmd){
|
||||
case AF_CONTROL_REINIT:
|
||||
mp_audio_copy_config(af->data, data);
|
||||
mp_audio_set_format(af->data, AF_FORMAT_S16);
|
||||
|
||||
return af_test_output(af, data);
|
||||
}
|
||||
return AF_UNKNOWN;
|
||||
}
|
||||
|
||||
static int filter_frame(struct af_instance *af, struct mp_audio *data)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
if (af_make_writeable(af, data) < 0) {
|
||||
talloc_free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
af_sweept *s = af->priv;
|
||||
int i, j;
|
||||
int16_t *in = (int16_t*)data->planes[0];
|
||||
int chans = data->nch;
|
||||
int in_len = data->samples;
|
||||
|
||||
for(i=0; i<in_len; i++){
|
||||
for(j=0; j<chans; j++)
|
||||
in[i*chans+j]= 32000*sin(s->x*s->x);
|
||||
s->x += s->delta;
|
||||
if(2*s->x*s->delta >= 3.141592) s->x=0;
|
||||
}
|
||||
|
||||
af_add_output_frame(af, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int af_open(struct af_instance* af){
|
||||
af->control=control;
|
||||
af->filter_frame = filter_frame;
|
||||
return AF_OK;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT af_sweept
|
||||
const struct af_info af_info_sweep = {
|
||||
.info = "sine sweep",
|
||||
.name = "sweep",
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(af_sweept),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_DOUBLE("delta", delta, 0),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
@@ -168,7 +168,6 @@ static int af_open(struct af_instance *af)
|
||||
const struct af_info af_info_volume = {
|
||||
.info = "Volume control audio filter",
|
||||
.name = "volume",
|
||||
.flags = AF_FLAGS_NOT_REENTRANT,
|
||||
.open = af_open,
|
||||
.priv_size = sizeof(struct priv),
|
||||
.options = (const struct m_option[]) {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Anders Johansson ajh@atri.curtin.edu.au
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MPLAYER_DSP_H
|
||||
#define MPLAYER_DSP_H
|
||||
|
||||
/* Implementation of routines used for DSP */
|
||||
|
||||
/* Size of floating point type used in routines */
|
||||
#define FLOAT_TYPE float
|
||||
|
||||
#include "window.h"
|
||||
#include "filter.h"
|
||||
|
||||
#endif /* MPLAYER_DSP_H */
|
||||
@@ -1,359 +0,0 @@
|
||||
/*
|
||||
* design and implementation of different types of digital filters
|
||||
*
|
||||
* Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "dsp.h"
|
||||
|
||||
/******************************************************************************
|
||||
* FIR filter implementations
|
||||
******************************************************************************/
|
||||
|
||||
/* C implementation of FIR filter y=w*x
|
||||
|
||||
n number of filter taps, where mod(n,4)==0
|
||||
w filter taps
|
||||
x input signal must be a circular buffer which is indexed backwards
|
||||
*/
|
||||
inline FLOAT_TYPE af_filter_fir(register unsigned int n, const FLOAT_TYPE* w,
|
||||
const FLOAT_TYPE* x)
|
||||
{
|
||||
register FLOAT_TYPE y; // Output
|
||||
y = 0.0;
|
||||
do{
|
||||
n--;
|
||||
y+=w[n]*x[n];
|
||||
}while(n != 0);
|
||||
return y;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FIR filter design
|
||||
******************************************************************************/
|
||||
|
||||
/* Design FIR filter using the Window method
|
||||
|
||||
n filter length must be odd for HP and BS filters
|
||||
w buffer for the filter taps (must be n long)
|
||||
fc cutoff frequencies (1 for LP and HP, 2 for BP and BS)
|
||||
0 < fc < 1 where 1 <=> Fs/2
|
||||
flags window and filter type as defined in filter.h
|
||||
variables are ored together: i.e. LP|HAMMING will give a
|
||||
low pass filter designed using a hamming window
|
||||
opt beta constant used only when designing using kaiser windows
|
||||
|
||||
returns 0 if OK, -1 if fail
|
||||
*/
|
||||
int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
|
||||
unsigned int flags, FLOAT_TYPE opt)
|
||||
{
|
||||
unsigned int o = n & 1; // Indicator for odd filter length
|
||||
unsigned int end = ((n + 1) >> 1) - o; // Loop end
|
||||
unsigned int i; // Loop index
|
||||
|
||||
FLOAT_TYPE k1 = 2 * M_PI; // 2*pi*fc1
|
||||
FLOAT_TYPE k2 = 0.5 * (FLOAT_TYPE)(1 - o);// Constant used if the filter has even length
|
||||
FLOAT_TYPE k3; // 2*pi*fc2 Constant used in BP and BS design
|
||||
FLOAT_TYPE g = 0.0; // Gain
|
||||
FLOAT_TYPE t1,t2,t3; // Temporary variables
|
||||
FLOAT_TYPE fc1,fc2; // Cutoff frequencies
|
||||
|
||||
// Sanity check
|
||||
if(!w || (n == 0)) return -1;
|
||||
|
||||
// Get window coefficients
|
||||
switch(flags & WINDOW_MASK){
|
||||
case(BOXCAR):
|
||||
af_window_boxcar(n,w); break;
|
||||
case(TRIANG):
|
||||
af_window_triang(n,w); break;
|
||||
case(HAMMING):
|
||||
af_window_hamming(n,w); break;
|
||||
case(HANNING):
|
||||
af_window_hanning(n,w); break;
|
||||
case(BLACKMAN):
|
||||
af_window_blackman(n,w); break;
|
||||
case(FLATTOP):
|
||||
af_window_flattop(n,w); break;
|
||||
case(KAISER):
|
||||
af_window_kaiser(n,w,opt); break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(flags & (LP | HP)){
|
||||
fc1=*fc;
|
||||
// Cutoff frequency must be < 0.5 where 0.5 <=> Fs/2
|
||||
fc1 = ((fc1 <= 1.0) && (fc1 > 0.0)) ? fc1/2 : 0.25;
|
||||
k1 *= fc1;
|
||||
|
||||
if(flags & LP){ // Low pass filter
|
||||
|
||||
// If the filter length is odd, there is one point which is exactly
|
||||
// in the middle. The value at this point is 2*fCutoff*sin(x)/x,
|
||||
// where x is zero. To make sure nothing strange happens, we set this
|
||||
// value separately.
|
||||
if (o){
|
||||
w[end] = fc1 * w[end] * 2.0;
|
||||
g=w[end];
|
||||
}
|
||||
|
||||
// Create filter
|
||||
for (i=0 ; i<end ; i++){
|
||||
t1 = (FLOAT_TYPE)(i+1) - k2;
|
||||
w[end-i-1] = w[n-end+i] = w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
|
||||
g += 2*w[end-i-1]; // Total gain in filter
|
||||
}
|
||||
}
|
||||
else{ // High pass filter
|
||||
if (!o) // High pass filters must have odd length
|
||||
return -1;
|
||||
w[end] = 1.0 - (fc1 * w[end] * 2.0);
|
||||
g= w[end];
|
||||
|
||||
// Create filter
|
||||
for (i=0 ; i<end ; i++){
|
||||
t1 = (FLOAT_TYPE)(i+1);
|
||||
w[end-i-1] = w[n-end+i] = -1 * w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
|
||||
g += ((i&1) ? (2*w[end-i-1]) : (-2*w[end-i-1])); // Total gain in filter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flags & (BP | BS)){
|
||||
fc1=fc[0];
|
||||
fc2=fc[1];
|
||||
// Cutoff frequencies must be < 1.0 where 1.0 <=> Fs/2
|
||||
fc1 = ((fc1 <= 1.0) && (fc1 > 0.0)) ? fc1/2 : 0.25;
|
||||
fc2 = ((fc2 <= 1.0) && (fc2 > 0.0)) ? fc2/2 : 0.25;
|
||||
k3 = k1 * fc2; // 2*pi*fc2
|
||||
k1 *= fc1; // 2*pi*fc1
|
||||
|
||||
if(flags & BP){ // Band pass
|
||||
// Calculate center tap
|
||||
if (o){
|
||||
g=w[end]*(fc1+fc2);
|
||||
w[end] = (fc2 - fc1) * w[end] * 2.0;
|
||||
}
|
||||
|
||||
// Create filter
|
||||
for (i=0 ; i<end ; i++){
|
||||
t1 = (FLOAT_TYPE)(i+1) - k2;
|
||||
t2 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
|
||||
t3 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
|
||||
g += w[end-i-1] * (t3 + t2); // Total gain in filter
|
||||
w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3);
|
||||
}
|
||||
}
|
||||
else{ // Band stop
|
||||
if (!o) // Band stop filters must have odd length
|
||||
return -1;
|
||||
w[end] = 1.0 - (fc2 - fc1) * w[end] * 2.0;
|
||||
g= w[end];
|
||||
|
||||
// Create filter
|
||||
for (i=0 ; i<end ; i++){
|
||||
t1 = (FLOAT_TYPE)(i+1);
|
||||
t2 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
|
||||
t3 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
|
||||
w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3);
|
||||
g += 2*w[end-i-1]; // Total gain in filter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize gain
|
||||
g=1/g;
|
||||
for (i=0; i<n; i++)
|
||||
w[i] *= g;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* IIR filter design
|
||||
******************************************************************************/
|
||||
|
||||
/* Helper functions for the bilinear transform */
|
||||
|
||||
/* Pre-warp the coefficients of a numerator or denominator.
|
||||
Note that a0 is assumed to be 1, so there is no wrapping
|
||||
of it.
|
||||
*/
|
||||
static void af_filter_prewarp(FLOAT_TYPE* a, FLOAT_TYPE fc, FLOAT_TYPE fs)
|
||||
{
|
||||
FLOAT_TYPE wp;
|
||||
wp = 2.0 * fs * tan(M_PI * fc / fs);
|
||||
a[2] = a[2]/(wp * wp);
|
||||
a[1] = a[1]/wp;
|
||||
}
|
||||
|
||||
/* Transform the numerator and denominator coefficients of s-domain
|
||||
biquad section into corresponding z-domain coefficients.
|
||||
|
||||
The transfer function for z-domain is:
|
||||
|
||||
1 + alpha1 * z^(-1) + alpha2 * z^(-2)
|
||||
H(z) = -------------------------------------
|
||||
1 + beta1 * z^(-1) + beta2 * z^(-2)
|
||||
|
||||
Store the 4 IIR coefficients in array pointed by coef in following
|
||||
order:
|
||||
beta1, beta2 (denominator)
|
||||
alpha1, alpha2 (numerator)
|
||||
|
||||
Arguments:
|
||||
a - s-domain numerator coefficients
|
||||
b - s-domain denominator coefficients
|
||||
k - filter gain factor. Initially set to 1 and modified by each
|
||||
biquad section in such a way, as to make it the
|
||||
coefficient by which to multiply the overall filter gain
|
||||
in order to achieve a desired overall filter gain,
|
||||
specified in initial value of k.
|
||||
fs - sampling rate (Hz)
|
||||
coef - array of z-domain coefficients to be filled in.
|
||||
|
||||
Return: On return, set coef z-domain coefficients and k to the gain
|
||||
required to maintain overall gain = 1.0;
|
||||
*/
|
||||
static void af_filter_bilinear(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE* k,
|
||||
FLOAT_TYPE fs, FLOAT_TYPE *coef)
|
||||
{
|
||||
FLOAT_TYPE ad, bd;
|
||||
|
||||
/* alpha (Numerator in s-domain) */
|
||||
ad = 4. * a[2] * fs * fs + 2. * a[1] * fs + a[0];
|
||||
/* beta (Denominator in s-domain) */
|
||||
bd = 4. * b[2] * fs * fs + 2. * b[1] * fs + b[0];
|
||||
|
||||
/* Update gain constant for this section */
|
||||
*k *= ad/bd;
|
||||
|
||||
/* Denominator */
|
||||
*coef++ = (2. * b[0] - 8. * b[2] * fs * fs)/bd; /* beta1 */
|
||||
*coef++ = (4. * b[2] * fs * fs - 2. * b[1] * fs + b[0])/bd; /* beta2 */
|
||||
|
||||
/* Numerator */
|
||||
*coef++ = (2. * a[0] - 8. * a[2] * fs * fs)/ad; /* alpha1 */
|
||||
*coef = (4. * a[2] * fs * fs - 2. * a[1] * fs + a[0])/ad; /* alpha2 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* IIR filter design using bilinear transform and prewarp. Transforms
|
||||
2nd order s domain analog filter into a digital IIR biquad link. To
|
||||
create a filter fill in a, b, Q and fs and make space for coef and k.
|
||||
|
||||
|
||||
Example Butterworth design:
|
||||
|
||||
Below are Butterworth polynomials, arranged as a series of 2nd
|
||||
order sections:
|
||||
|
||||
Note: n is filter order.
|
||||
|
||||
n Polynomials
|
||||
-------------------------------------------------------------------
|
||||
2 s^2 + 1.4142s + 1
|
||||
4 (s^2 + 0.765367s + 1) * (s^2 + 1.847759s + 1)
|
||||
6 (s^2 + 0.5176387s + 1) * (s^2 + 1.414214 + 1) * (s^2 + 1.931852s + 1)
|
||||
|
||||
For n=4 we have following equation for the filter transfer function:
|
||||
1 1
|
||||
T(s) = --------------------------- * ----------------------------
|
||||
s^2 + (1/Q) * 0.765367s + 1 s^2 + (1/Q) * 1.847759s + 1
|
||||
|
||||
The filter consists of two 2nd order sections since highest s power
|
||||
is 2. Now we can take the coefficients, or the numbers by which s
|
||||
is multiplied and plug them into a standard formula to be used by
|
||||
bilinear transform.
|
||||
|
||||
Our standard form for each 2nd order section is:
|
||||
|
||||
a2 * s^2 + a1 * s + a0
|
||||
H(s) = ----------------------
|
||||
b2 * s^2 + b1 * s + b0
|
||||
|
||||
Note that Butterworth numerator is 1 for all filter sections, which
|
||||
means s^2 = 0 and s^1 = 0
|
||||
|
||||
Let's convert standard Butterworth polynomials into this form:
|
||||
|
||||
0 + 0 + 1 0 + 0 + 1
|
||||
--------------------------- * --------------------------
|
||||
1 + ((1/Q) * 0.765367) + 1 1 + ((1/Q) * 1.847759) + 1
|
||||
|
||||
Section 1:
|
||||
a2 = 0; a1 = 0; a0 = 1;
|
||||
b2 = 1; b1 = 0.765367; b0 = 1;
|
||||
|
||||
Section 2:
|
||||
a2 = 0; a1 = 0; a0 = 1;
|
||||
b2 = 1; b1 = 1.847759; b0 = 1;
|
||||
|
||||
Q is filter quality factor or resonance, in the range of 1 to
|
||||
1000. The overall filter Q is a product of all 2nd order stages.
|
||||
For example, the 6th order filter (3 stages, or biquads) with
|
||||
individual Q of 2 will have filter Q = 2 * 2 * 2 = 8.
|
||||
|
||||
|
||||
Arguments:
|
||||
a - s-domain numerator coefficients, a[1] is always assumed to be 1.0
|
||||
b - s-domain denominator coefficients
|
||||
Q - Q value for the filter
|
||||
k - filter gain factor. Initially set to 1 and modified by each
|
||||
biquad section in such a way, as to make it the
|
||||
coefficient by which to multiply the overall filter gain
|
||||
in order to achieve a desired overall filter gain,
|
||||
specified in initial value of k.
|
||||
fs - sampling rate (Hz)
|
||||
coef - array of z-domain coefficients to be filled in.
|
||||
|
||||
Note: Upon return from each call, the k argument will be set to a
|
||||
value, by which to multiply our actual signal in order for the gain
|
||||
to be one. On second call to szxform() we provide k that was
|
||||
changed by the previous section. During actual audio filtering
|
||||
k can be used for gain compensation.
|
||||
|
||||
return -1 if fail 0 if success.
|
||||
*/
|
||||
int af_filter_szxform(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE Q, FLOAT_TYPE fc,
|
||||
FLOAT_TYPE fs, FLOAT_TYPE *k, FLOAT_TYPE *coef)
|
||||
{
|
||||
FLOAT_TYPE at[3];
|
||||
FLOAT_TYPE bt[3];
|
||||
|
||||
if(!a || !b || !k || !coef || (Q>1000.0 || Q< 1.0))
|
||||
return -1;
|
||||
|
||||
memcpy(at,a,3*sizeof(FLOAT_TYPE));
|
||||
memcpy(bt,b,3*sizeof(FLOAT_TYPE));
|
||||
|
||||
bt[1]/=Q;
|
||||
|
||||
/* Calculate a and b and overwrite the original values */
|
||||
af_filter_prewarp(at, fc, fs);
|
||||
af_filter_prewarp(bt, fc, fs);
|
||||
/* Execute bilinear transform */
|
||||
af_filter_bilinear(at, bt, k, fs, coef);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined MPLAYER_DSP_H
|
||||
# error Never use filter.h directly; include dsp.h instead.
|
||||
#endif
|
||||
|
||||
#ifndef MPLAYER_FILTER_H
|
||||
#define MPLAYER_FILTER_H
|
||||
|
||||
|
||||
// Design and implementation of different types of digital filters
|
||||
|
||||
|
||||
// Flags used for filter design
|
||||
|
||||
// Filter characteristics
|
||||
#define LP 0x00010000 // Low pass
|
||||
#define HP 0x00020000 // High pass
|
||||
#define BP 0x00040000 // Band pass
|
||||
#define BS 0x00080000 // Band stop
|
||||
#define TYPE_MASK 0x000F0000
|
||||
|
||||
// Window types
|
||||
#define BOXCAR 0x00000001
|
||||
#define TRIANG 0x00000002
|
||||
#define HAMMING 0x00000004
|
||||
#define HANNING 0x00000008
|
||||
#define BLACKMAN 0x00000010
|
||||
#define FLATTOP 0x00000011
|
||||
#define KAISER 0x00000012
|
||||
#define WINDOW_MASK 0x0000001F
|
||||
|
||||
// Parallel filter design
|
||||
#define FWD 0x00000001 // Forward indexing of polyphase filter
|
||||
#define REW 0x00000002 // Reverse indexing of polyphase filter
|
||||
#define ODD 0x00000010 // Make filter HP
|
||||
|
||||
// Exported functions
|
||||
FLOAT_TYPE af_filter_fir(unsigned int n, const FLOAT_TYPE* w, const FLOAT_TYPE* x);
|
||||
|
||||
int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
|
||||
unsigned int flags, FLOAT_TYPE opt);
|
||||
|
||||
int af_filter_szxform(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE Q,
|
||||
FLOAT_TYPE fc, FLOAT_TYPE fs, FLOAT_TYPE *k,
|
||||
FLOAT_TYPE *coef);
|
||||
|
||||
/* Add new data to circular queue designed to be used with a FIR
|
||||
filter. xq is the circular queue, in pointing at the new sample, xi
|
||||
current index for xq and n the length of the filter. xq must be n*2
|
||||
long.
|
||||
*/
|
||||
#define af_filter_updateq(n,xi,xq,in)\
|
||||
xq[xi]=(xq)[(xi)+(n)]=*(in);\
|
||||
xi=(++(xi))&((n)-1);
|
||||
|
||||
#endif /* MPLAYER_FILTER_H */
|
||||
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Calculates a number of window functions. The following window
|
||||
functions are currently implemented: Boxcar, Triang, Hanning,
|
||||
Hamming, Blackman, Flattop and Kaiser. In the function call n is
|
||||
the number of filter taps and w the buffer in which the filter
|
||||
coefficients will be stored.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "dsp.h"
|
||||
|
||||
/*
|
||||
// Boxcar
|
||||
//
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
*/
|
||||
void af_window_boxcar(int n, FLOAT_TYPE* w)
|
||||
{
|
||||
int i;
|
||||
// Calculate window coefficients
|
||||
for (i=0 ; i<n ; i++)
|
||||
w[i] = 1.0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Triang a.k.a Bartlett
|
||||
//
|
||||
// | (N-1)|
|
||||
// 2 * |k - -----|
|
||||
// | 2 |
|
||||
// w = 1.0 - ---------------
|
||||
// N+1
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
*/
|
||||
void af_window_triang(int n, FLOAT_TYPE* w)
|
||||
{
|
||||
FLOAT_TYPE k1 = (FLOAT_TYPE)(n & 1);
|
||||
FLOAT_TYPE k2 = 1/((FLOAT_TYPE)n + k1);
|
||||
int end = (n + 1) >> 1;
|
||||
int i;
|
||||
|
||||
// Calculate window coefficients
|
||||
for (i=0 ; i<end ; i++)
|
||||
w[i] = w[n-i-1] = (2.0*((FLOAT_TYPE)(i+1))-(1.0-k1))*k2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Hanning
|
||||
// 2*pi*k
|
||||
// w = 0.5 - 0.5*cos(------), where 0 < k <= N
|
||||
// N+1
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
*/
|
||||
void af_window_hanning(int n, FLOAT_TYPE* w)
|
||||
{
|
||||
int i;
|
||||
FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n+1)); // 2*pi/(N+1)
|
||||
|
||||
// Calculate window coefficients
|
||||
for (i=0; i<n; i++)
|
||||
*w++ = 0.5*(1.0 - cos(k*(FLOAT_TYPE)(i+1)));
|
||||
}
|
||||
|
||||
/*
|
||||
// Hamming
|
||||
// 2*pi*k
|
||||
// w(k) = 0.54 - 0.46*cos(------), where 0 <= k < N
|
||||
// N-1
|
||||
//
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
*/
|
||||
void af_window_hamming(int n,FLOAT_TYPE* w)
|
||||
{
|
||||
int i;
|
||||
FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
|
||||
|
||||
// Calculate window coefficients
|
||||
for (i=0; i<n; i++)
|
||||
*w++ = 0.54 - 0.46*cos(k*(FLOAT_TYPE)i);
|
||||
}
|
||||
|
||||
/*
|
||||
// Blackman
|
||||
// 2*pi*k 4*pi*k
|
||||
// w(k) = 0.42 - 0.5*cos(------) + 0.08*cos(------), where 0 <= k < N
|
||||
// N-1 N-1
|
||||
//
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
*/
|
||||
void af_window_blackman(int n,FLOAT_TYPE* w)
|
||||
{
|
||||
int i;
|
||||
FLOAT_TYPE k1 = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
|
||||
FLOAT_TYPE k2 = 2*k1; // 4*pi/(N-1)
|
||||
|
||||
// Calculate window coefficients
|
||||
for (i=0; i<n; i++)
|
||||
*w++ = 0.42 - 0.50*cos(k1*(FLOAT_TYPE)i) + 0.08*cos(k2*(FLOAT_TYPE)i);
|
||||
}
|
||||
|
||||
/*
|
||||
// Flattop
|
||||
// 2*pi*k 4*pi*k
|
||||
// w(k) = 0.2810638602 - 0.5208971735*cos(------) + 0.1980389663*cos(------), where 0 <= k < N
|
||||
// N-1 N-1
|
||||
//
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
*/
|
||||
void af_window_flattop(int n,FLOAT_TYPE* w)
|
||||
{
|
||||
int i;
|
||||
FLOAT_TYPE k1 = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
|
||||
FLOAT_TYPE k2 = 2*k1; // 4*pi/(N-1)
|
||||
|
||||
// Calculate window coefficients
|
||||
for (i=0; i<n; i++)
|
||||
*w++ = 0.2810638602 - 0.5208971735*cos(k1*(FLOAT_TYPE)i)
|
||||
+ 0.1980389663*cos(k2*(FLOAT_TYPE)i);
|
||||
}
|
||||
|
||||
/* Computes the 0th order modified Bessel function of the first kind.
|
||||
// (Needed to compute Kaiser window)
|
||||
//
|
||||
// y = sum( (x/(2*n))^2 )
|
||||
// n
|
||||
*/
|
||||
#define BIZ_EPSILON 1E-21 // Max error acceptable
|
||||
|
||||
static FLOAT_TYPE besselizero(FLOAT_TYPE x)
|
||||
{
|
||||
FLOAT_TYPE temp;
|
||||
FLOAT_TYPE sum = 1.0;
|
||||
FLOAT_TYPE u = 1.0;
|
||||
FLOAT_TYPE halfx = x/2.0;
|
||||
int n = 1;
|
||||
|
||||
do {
|
||||
temp = halfx/(FLOAT_TYPE)n;
|
||||
u *=temp * temp;
|
||||
sum += u;
|
||||
n++;
|
||||
} while (u >= BIZ_EPSILON * sum);
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*
|
||||
// Kaiser
|
||||
//
|
||||
// n window length
|
||||
// w buffer for the window parameters
|
||||
// b beta parameter of Kaiser window, Beta >= 1
|
||||
//
|
||||
// Beta trades the rejection of the low pass filter against the
|
||||
// transition width from passband to stop band. Larger Beta means a
|
||||
// slower transition and greater stop band rejection. See Rabiner and
|
||||
// Gold (Theory and Application of DSP) under Kaiser windows for more
|
||||
// about Beta. The following table from Rabiner and Gold gives some
|
||||
// feel for the effect of Beta:
|
||||
//
|
||||
// All ripples in dB, width of transition band = D*N where N = window
|
||||
// length
|
||||
//
|
||||
// BETA D PB RIP SB RIP
|
||||
// 2.120 1.50 +-0.27 -30
|
||||
// 3.384 2.23 0.0864 -40
|
||||
// 4.538 2.93 0.0274 -50
|
||||
// 5.658 3.62 0.00868 -60
|
||||
// 6.764 4.32 0.00275 -70
|
||||
// 7.865 5.0 0.000868 -80
|
||||
// 8.960 5.7 0.000275 -90
|
||||
// 10.056 6.4 0.000087 -100
|
||||
*/
|
||||
void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b)
|
||||
{
|
||||
FLOAT_TYPE tmp;
|
||||
FLOAT_TYPE k1 = 1.0/besselizero(b);
|
||||
int k2 = 1 - (n & 1);
|
||||
int end = (n + 1) >> 1;
|
||||
int i;
|
||||
|
||||
// Calculate window coefficients
|
||||
for (i=0 ; i<end ; i++){
|
||||
tmp = (FLOAT_TYPE)(2*i + k2) / ((FLOAT_TYPE)n - 1.0);
|
||||
w[end-(1&(!k2))+i] = w[end-1-i] = k1 * besselizero(b*sqrt(1.0 - tmp*tmp));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Calculates a number of window functions. The following window
|
||||
functions are currently implemented: Boxcar, Triang, Hanning,
|
||||
Hamming, Blackman, Flattop and Kaiser. In the function call n is
|
||||
the number of filter taps and w the buffer in which the filter
|
||||
coefficients will be stored.
|
||||
*/
|
||||
|
||||
#if !defined MPLAYER_DSP_H
|
||||
# error Never use window.h directly; include dsp.h instead.
|
||||
#endif
|
||||
|
||||
#ifndef MPLAYER_WINDOW_H
|
||||
#define MPLAYER_WINDOW_H
|
||||
|
||||
void af_window_boxcar(int n, FLOAT_TYPE* w);
|
||||
void af_window_triang(int n, FLOAT_TYPE* w);
|
||||
void af_window_hanning(int n, FLOAT_TYPE* w);
|
||||
void af_window_hamming(int n, FLOAT_TYPE* w);
|
||||
void af_window_blackman(int n, FLOAT_TYPE* w);
|
||||
void af_window_flattop(int n, FLOAT_TYPE* w);
|
||||
void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b);
|
||||
|
||||
#endif /* MPLAYER_WINDOW_H */
|
||||
+46
-12
@@ -51,7 +51,7 @@ int af_fmt_change_bytes(int format, int bytes)
|
||||
if (af_fmt_to_bytes(fmt) == bytes &&
|
||||
af_fmt_is_float(fmt) == af_fmt_is_float(format) &&
|
||||
af_fmt_is_planar(fmt) == af_fmt_is_planar(format) &&
|
||||
af_fmt_is_spdif(fmt) == af_fmt_is_spdif(format))
|
||||
(fmt == format || (!af_fmt_is_spdif(fmt) && !af_fmt_is_spdif(format))))
|
||||
return fmt;
|
||||
}
|
||||
return 0;
|
||||
@@ -171,13 +171,11 @@ void af_fill_silence(void *dst, size_t bytes, int format)
|
||||
memset(dst, af_fmt_is_unsigned(format) ? 0x80 : 0, bytes);
|
||||
}
|
||||
|
||||
#define FMT_DIFF(type, a, b) (((a) & type) - ((b) & type))
|
||||
|
||||
// Returns a "score" that serves as heuristic how lossy or hard a conversion is.
|
||||
// If the formats are equal, 1024 is returned. If they are gravely incompatible
|
||||
// (like s16<->ac3), INT_MIN is returned. If there is implied loss of precision
|
||||
// (like s16->s8), a value <0 is returned.
|
||||
int af_format_conversion_score(int dst_format, int src_format)
|
||||
static int af_format_conversion_score(int dst_format, int src_format)
|
||||
{
|
||||
if (dst_format == AF_FORMAT_UNKNOWN || src_format == AF_FORMAT_UNKNOWN)
|
||||
return INT_MIN;
|
||||
@@ -192,25 +190,61 @@ int af_format_conversion_score(int dst_format, int src_format)
|
||||
if (af_fmt_is_float(dst_format) != af_fmt_is_float(src_format)) {
|
||||
int dst_bytes = af_fmt_to_bytes(dst_format);
|
||||
if (af_fmt_is_float(dst_format)) {
|
||||
// For int->float, always prefer 32 bit float.
|
||||
score -= dst_bytes == 4 ? 1 : 0;
|
||||
// For int->float, consider a lower bound on the precision difference.
|
||||
int bytes = (dst_bytes == 4 ? 3 : 6) - af_fmt_to_bytes(src_format);
|
||||
if (bytes >= 0) {
|
||||
score -= 8 * bytes; // excess precision
|
||||
} else {
|
||||
score += 1024 * (bytes - 1); // precision is lost (i.e. s32 -> float)
|
||||
}
|
||||
} else {
|
||||
// For float->int, always prefer highest bit depth int
|
||||
score -= 8 - dst_bytes;
|
||||
// float->int is the worst case. Penalize heavily and
|
||||
// prefer highest bit depth int.
|
||||
score -= 1048576 * (8 - dst_bytes);
|
||||
}
|
||||
// Has to convert float<->int - Consider this the worst case.
|
||||
score -= 2048;
|
||||
score -= 512; // penalty for any float <-> int conversion
|
||||
} else {
|
||||
int bytes = af_fmt_to_bytes(dst_format) - af_fmt_to_bytes(src_format);
|
||||
if (bytes > 0) {
|
||||
score -= bytes; // has to add padding
|
||||
score -= 8 * bytes; // has to add padding
|
||||
} else if (bytes < 0) {
|
||||
score -= 1024 - bytes; // has to reduce bit depth
|
||||
score += 1024 * (bytes - 1); // has to reduce bit depth
|
||||
}
|
||||
}
|
||||
return score;
|
||||
}
|
||||
|
||||
struct entry {
|
||||
int fmt;
|
||||
int score;
|
||||
};
|
||||
|
||||
static int cmp_entry(const void *a, const void *b)
|
||||
{
|
||||
#define CMP_INT(a, b) (a > b ? 1 : (a < b ? -1 : 0))
|
||||
return -CMP_INT(((struct entry *)a)->score, ((struct entry *)b)->score);
|
||||
}
|
||||
|
||||
// Return a list of sample format compatible to src_format, sorted by order
|
||||
// of preference. out_formats[0] will be src_format (as long as it's valid),
|
||||
// and the list is terminated with 0 (AF_FORMAT_UNKNOWN).
|
||||
// Keep in mind that this also returns formats with flipped interleaving
|
||||
// (e.g. for s16, it returns [s16, s16p, ...]).
|
||||
void af_get_best_sample_formats(int src_format, int out_formats[AF_FORMAT_COUNT])
|
||||
{
|
||||
int num = 0;
|
||||
struct entry e[AF_FORMAT_COUNT];
|
||||
for (int fmt = 1; fmt < AF_FORMAT_COUNT; fmt++) {
|
||||
int score = af_format_conversion_score(fmt, src_format);
|
||||
if (score > INT_MIN)
|
||||
e[num++] = (struct entry){fmt, score};
|
||||
}
|
||||
qsort(e, num, sizeof(e[0]), cmp_entry);
|
||||
for (int n = 0; n < num; n++)
|
||||
out_formats[n] = e[n].fmt;
|
||||
out_formats[num] = 0;
|
||||
}
|
||||
|
||||
// Return the number of samples that make up one frame in this format.
|
||||
// You get the byte size by multiplying them with sample size and channel count.
|
||||
int af_format_sample_alignment(int format)
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int sampler
|
||||
|
||||
void af_fill_silence(void *dst, size_t bytes, int format);
|
||||
|
||||
int af_format_conversion_score(int dst_format, int src_format);
|
||||
void af_get_best_sample_formats(int src_format, int out_formats[AF_FORMAT_COUNT]);
|
||||
|
||||
int af_format_sample_alignment(int format);
|
||||
|
||||
|
||||
+11
-5
@@ -27,7 +27,7 @@
|
||||
#include "audio/filter/af.h"
|
||||
#include "common/global.h"
|
||||
#include "common/msg.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "mixer.h"
|
||||
|
||||
struct mixer {
|
||||
@@ -120,8 +120,11 @@ void mixer_getvolume(struct mixer *mixer, float *l, float *r)
|
||||
*r = mixer->vol_r;
|
||||
}
|
||||
|
||||
static void setvolume_internal(struct mixer *mixer, float l, float r)
|
||||
static void setvolume_internal(struct mixer *mixer)
|
||||
{
|
||||
float l = mixer->vol_l, r = mixer->vol_r;
|
||||
if (mixer->emulate_mute && mixer->muted)
|
||||
l = r = 0;
|
||||
if (!mixer->softvol) {
|
||||
MP_DBG(mixer, "Setting volume on AO.\n");
|
||||
struct ao_control_vol vol = {.left = l, .right = r};
|
||||
@@ -147,8 +150,8 @@ void mixer_setvolume(struct mixer *mixer, float l, float r)
|
||||
float max = mixer_getmaxvolume(mixer);
|
||||
mixer->vol_l = MPCLAMP(l, 0, max);
|
||||
mixer->vol_r = MPCLAMP(r, 0, max);
|
||||
if (mixer->ao && !(mixer->emulate_mute && mixer->muted))
|
||||
setvolume_internal(mixer, mixer->vol_l, mixer->vol_r);
|
||||
if (mixer->ao)
|
||||
setvolume_internal(mixer);
|
||||
}
|
||||
|
||||
void mixer_getbothvolume(struct mixer *mixer, float *b)
|
||||
@@ -167,7 +170,7 @@ void mixer_setmute(struct mixer *mixer, bool mute)
|
||||
mixer->muted = mute;
|
||||
mixer->muted_by_us = mute;
|
||||
if (mixer->emulate_mute) {
|
||||
setvolume_internal(mixer, mixer->vol_l*!mute, mixer->vol_r*!mute);
|
||||
setvolume_internal(mixer);
|
||||
} else {
|
||||
ao_control(mixer->ao, AOCONTROL_SET_MUTE, &mute);
|
||||
}
|
||||
@@ -293,6 +296,8 @@ static void restore_volume(struct mixer *mixer)
|
||||
|
||||
const char *prev_driver = mixer->driver;
|
||||
mixer->driver = mixer->softvol ? "softvol" : ao_get_name(ao);
|
||||
if (!prev_driver[0])
|
||||
prev_driver = mixer->driver;
|
||||
|
||||
// Restore old parameters if volume won't survive reinitialization.
|
||||
// But not if volume scale is possibly different.
|
||||
@@ -394,4 +399,5 @@ void mixer_uninit_audio(struct mixer *mixer)
|
||||
}
|
||||
mixer->ao = NULL;
|
||||
mixer->af = NULL;
|
||||
mixer->softvol = false;
|
||||
}
|
||||
+63
-56
@@ -20,7 +20,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "ao.h"
|
||||
@@ -43,9 +43,9 @@ extern const struct ao_driver audio_out_sndio;
|
||||
extern const struct ao_driver audio_out_pulse;
|
||||
extern const struct ao_driver audio_out_jack;
|
||||
extern const struct ao_driver audio_out_openal;
|
||||
extern const struct ao_driver audio_out_opensles;
|
||||
extern const struct ao_driver audio_out_null;
|
||||
extern const struct ao_driver audio_out_alsa;
|
||||
extern const struct ao_driver audio_out_dsound;
|
||||
extern const struct ao_driver audio_out_wasapi;
|
||||
extern const struct ao_driver audio_out_pcm;
|
||||
extern const struct ao_driver audio_out_lavc;
|
||||
@@ -65,9 +65,6 @@ static const struct ao_driver * const audio_out_drivers[] = {
|
||||
#if HAVE_WASAPI
|
||||
&audio_out_wasapi,
|
||||
#endif
|
||||
#if HAVE_DSOUND
|
||||
&audio_out_dsound,
|
||||
#endif
|
||||
#if HAVE_OSS_AUDIO
|
||||
&audio_out_oss,
|
||||
#endif
|
||||
@@ -78,6 +75,9 @@ static const struct ao_driver * const audio_out_drivers[] = {
|
||||
#if HAVE_OPENAL
|
||||
&audio_out_openal,
|
||||
#endif
|
||||
#if HAVE_OPENSLES
|
||||
&audio_out_opensles,
|
||||
#endif
|
||||
#if HAVE_SDL1 || HAVE_SDL2
|
||||
&audio_out_sdl,
|
||||
#endif
|
||||
@@ -240,6 +240,7 @@ static void split_ao_device(void *tmp, char *opt, char **out_ao, char **out_dev)
|
||||
}
|
||||
|
||||
struct ao *ao_init_best(struct mpv_global *global,
|
||||
bool ao_null_fallback,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
int samplerate, int format, struct mp_chmap channels)
|
||||
@@ -248,58 +249,67 @@ struct ao *ao_init_best(struct mpv_global *global,
|
||||
void *tmp = talloc_new(NULL);
|
||||
struct mp_log *log = mp_log_new(tmp, global->log, "ao");
|
||||
struct ao *ao = NULL;
|
||||
struct m_obj_settings *ao_list = opts->audio_driver_list;
|
||||
struct m_obj_settings *ao_list = NULL;
|
||||
int ao_num = 0;
|
||||
|
||||
for (int n = 0; opts->audio_driver_list && opts->audio_driver_list[n].name; n++)
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num, opts->audio_driver_list[n]);
|
||||
|
||||
bool forced_dev = false;
|
||||
char *pref_ao, *pref_dev;
|
||||
split_ao_device(tmp, opts->audio_device, &pref_ao, &pref_dev);
|
||||
if (!(ao_list && ao_list[0].name) && pref_ao) {
|
||||
if (!ao_num && pref_ao) {
|
||||
// Reuse the autoselection code
|
||||
ao_list = talloc_zero_array(tmp, struct m_obj_settings, 2);
|
||||
ao_list[0].name = pref_ao;
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = pref_ao});
|
||||
forced_dev = true;
|
||||
}
|
||||
|
||||
if (ao_list && ao_list[0].name) {
|
||||
for (int n = 0; ao_list[n].name; n++) {
|
||||
if (strlen(ao_list[n].name) == 0)
|
||||
goto autoprobe;
|
||||
mp_verbose(log, "Trying preferred audio driver '%s'\n",
|
||||
ao_list[n].name);
|
||||
char *dev = NULL;
|
||||
if (pref_ao && strcmp(ao_list[n].name, pref_ao) == 0)
|
||||
dev = pref_dev;
|
||||
if (dev)
|
||||
mp_verbose(log, "Using preferred device '%s'\n", dev);
|
||||
ao = ao_init(false, global, input_ctx, encode_lavc_ctx,
|
||||
samplerate, format, channels, dev,
|
||||
ao_list[n].name, ao_list[n].attribs);
|
||||
if (ao)
|
||||
goto done;
|
||||
mp_err(log, "Failed to initialize audio driver '%s'\n",
|
||||
ao_list[n].name);
|
||||
if (forced_dev) {
|
||||
mp_err(log, "This audio driver/device was forced with the "
|
||||
"--audio-device option.\n"
|
||||
"Try unsetting it.\n");
|
||||
}
|
||||
bool autoprobe = ao_num == 0;
|
||||
|
||||
// Something like "--ao=a,b," means do autoprobing after a and b fail.
|
||||
if (ao_num && strlen(ao_list[ao_num - 1].name) == 0) {
|
||||
ao_num -= 1;
|
||||
autoprobe = true;
|
||||
}
|
||||
|
||||
if (autoprobe) {
|
||||
for (int n = 0; audio_out_drivers[n]; n++) {
|
||||
const struct ao_driver *driver = audio_out_drivers[n];
|
||||
if (driver == &audio_out_null)
|
||||
break;
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = (char *)driver->name});
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
autoprobe: ;
|
||||
// now try the rest...
|
||||
for (int i = 0; audio_out_drivers[i]; i++) {
|
||||
const struct ao_driver *driver = audio_out_drivers[i];
|
||||
if (driver == &audio_out_null)
|
||||
break;
|
||||
ao = ao_init(true, global, input_ctx, encode_lavc_ctx, samplerate,
|
||||
format, channels, NULL, (char *)driver->name, NULL);
|
||||
if (ao_null_fallback) {
|
||||
MP_TARRAY_APPEND(tmp, ao_list, ao_num,
|
||||
(struct m_obj_settings){.name = "null"});
|
||||
}
|
||||
|
||||
for (int n = 0; n < ao_num; n++) {
|
||||
struct m_obj_settings *entry = &ao_list[n];
|
||||
bool probing = n + 1 != ao_num;
|
||||
mp_verbose(log, "Trying audio driver '%s'\n", entry->name);
|
||||
char *dev = NULL;
|
||||
if (pref_ao && pref_dev && strcmp(entry->name, pref_ao) == 0) {
|
||||
dev = pref_dev;
|
||||
mp_verbose(log, "Using preferred device '%s'\n", dev);
|
||||
}
|
||||
ao = ao_init(probing, global, input_ctx, encode_lavc_ctx,
|
||||
samplerate, format, channels, dev,
|
||||
entry->name, entry->attribs);
|
||||
if (ao)
|
||||
goto done;
|
||||
break;
|
||||
if (!probing)
|
||||
mp_err(log, "Failed to initialize audio driver '%s'\n", entry->name);
|
||||
if (dev && forced_dev) {
|
||||
mp_err(log, "This audio driver/device was forced with the "
|
||||
"--audio-device option.\nTry unsetting it.\n");
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_free(tmp);
|
||||
return ao;
|
||||
}
|
||||
@@ -411,18 +421,11 @@ void ao_hotplug_event(struct ao *ao)
|
||||
bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s,
|
||||
struct mp_chmap *map)
|
||||
{
|
||||
if (mp_msg_test(ao->log, MSGL_DEBUG)) {
|
||||
for (int i = 0; i < s->num_chmaps; i++) {
|
||||
struct mp_chmap c = s->chmaps[i];
|
||||
MP_DBG(ao, "chmap_sel #%d: %s (%s)\n", i, mp_chmap_to_str(&c),
|
||||
mp_chmap_to_str_hr(&c));
|
||||
}
|
||||
}
|
||||
MP_VERBOSE(ao, "Channel layouts:\n");
|
||||
mp_chmal_sel_log(s, ao->log, MSGL_V);
|
||||
bool r = mp_chmap_sel_adjust(s, map);
|
||||
if (r) {
|
||||
MP_DBG(ao, "result: %s (%s)\n", mp_chmap_to_str(map),
|
||||
mp_chmap_to_str_hr(map));
|
||||
}
|
||||
if (r)
|
||||
MP_VERBOSE(ao, "result: %s\n", mp_chmap_to_str(map));
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -490,8 +493,12 @@ static void get_devices(struct ao *ao, struct ao_device_list *list)
|
||||
if (ao->driver->list_devs)
|
||||
ao->driver->list_devs(ao, list);
|
||||
// Add at least a default entry
|
||||
if (list->num_devices == num)
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){"", "Default"});
|
||||
if (list->num_devices == num) {
|
||||
char name[80] = "Default";
|
||||
if (num > 1)
|
||||
mp_snprintf_cat(name, sizeof(name), " (%s)", ao->driver->name);
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){"", name});
|
||||
}
|
||||
}
|
||||
|
||||
bool ao_hotplug_check_update(struct ao_hotplug *hp)
|
||||
|
||||
@@ -72,6 +72,7 @@ struct encode_lavc_context;
|
||||
struct mp_audio;
|
||||
|
||||
struct ao *ao_init_best(struct mpv_global *global,
|
||||
bool ao_null_fallback,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
int samplerate, int format, struct mp_chmap channels);
|
||||
|
||||
+282
-204
@@ -50,12 +50,13 @@
|
||||
|
||||
struct priv {
|
||||
snd_pcm_t *alsa;
|
||||
bool device_lost;
|
||||
snd_pcm_format_t alsa_fmt;
|
||||
int can_pause;
|
||||
bool can_pause;
|
||||
snd_pcm_sframes_t prepause_frames;
|
||||
double delay_before_pause;
|
||||
int buffersize; // in frames
|
||||
int outburst; // in frames
|
||||
snd_pcm_uframes_t buffersize;
|
||||
snd_pcm_uframes_t outburst;
|
||||
|
||||
char *cfg_device;
|
||||
char *cfg_mixer_device;
|
||||
@@ -83,6 +84,21 @@ struct priv {
|
||||
MP_WARN(ao, "%s: %s\n", (message), snd_strerror(err)); \
|
||||
} while (0)
|
||||
|
||||
// Common code for handling ENODEV, which happens if a device gets "lost", and
|
||||
// can't be used anymore. Returns true if alsa_err is not ENODEV.
|
||||
static bool check_device_present(struct ao *ao, int alsa_err)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
if (alsa_err != -ENODEV)
|
||||
return true;
|
||||
if (!p->device_lost) {
|
||||
MP_WARN(ao, "Device lost, trying to recover...\n");
|
||||
ao_request_reload(ao);
|
||||
p->device_lost = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
@@ -210,6 +226,8 @@ static const int mp_to_alsa_format[][2] = {
|
||||
{AF_FORMAT_S24,
|
||||
MP_SELECT_LE_BE(SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_S24_3BE)},
|
||||
{AF_FORMAT_FLOAT, SND_PCM_FORMAT_FLOAT},
|
||||
{AF_FORMAT_DOUBLE, SND_PCM_FORMAT_FLOAT64},
|
||||
{AF_FORMAT_S_MP3, SND_PCM_FORMAT_MPEG},
|
||||
{AF_FORMAT_UNKNOWN, SND_PCM_FORMAT_UNKNOWN},
|
||||
};
|
||||
|
||||
@@ -220,6 +238,8 @@ static int find_alsa_format(int af_format)
|
||||
if (mp_to_alsa_format[n][0] == af_format)
|
||||
return mp_to_alsa_format[n][1];
|
||||
}
|
||||
if (af_fmt_is_spdif(af_format))
|
||||
return SND_PCM_FORMAT_S16;
|
||||
return SND_PCM_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -250,6 +270,7 @@ static const int alsa_to_mp_channels[][2] = {
|
||||
{SND_CHMAP_RLC, MP_SP(SDL)},
|
||||
{SND_CHMAP_MONO, MP_SP(FC)},
|
||||
{SND_CHMAP_NA, MP_SPEAKER_ID_NA},
|
||||
{SND_CHMAP_UNKNOWN, MP_SPEAKER_ID_NA},
|
||||
{SND_CHMAP_LAST, MP_SPEAKER_ID_COUNT}
|
||||
};
|
||||
|
||||
@@ -263,28 +284,48 @@ static int find_mp_channel(int alsa_channel)
|
||||
return MP_SPEAKER_ID_COUNT;
|
||||
}
|
||||
|
||||
static int find_alsa_channel(int mp_channel)
|
||||
{
|
||||
for (int i = 0; alsa_to_mp_channels[i][1] != MP_SPEAKER_ID_COUNT; i++) {
|
||||
if (alsa_to_mp_channels[i][1] == mp_channel)
|
||||
return alsa_to_mp_channels[i][0];
|
||||
}
|
||||
#define CHMAP(n, ...) &(struct mp_chmap) MP_CONCAT(MP_CHMAP, n) (__VA_ARGS__)
|
||||
|
||||
return SND_CHMAP_UNKNOWN;
|
||||
// Replace each channel in a with b (a->num == b->num)
|
||||
static void replace_submap(struct mp_chmap *dst, struct mp_chmap *a,
|
||||
struct mp_chmap *b)
|
||||
{
|
||||
struct mp_chmap t = *dst;
|
||||
if (!mp_chmap_is_valid(&t) || mp_chmap_diffn(a, &t) != 0)
|
||||
return;
|
||||
assert(a->num == b->num);
|
||||
for (int n = 0; n < t.num; n++) {
|
||||
for (int i = 0; i < a->num; i++) {
|
||||
if (t.speaker[n] == a->speaker[i]) {
|
||||
t.speaker[n] = b->speaker[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mp_chmap_is_valid(&t))
|
||||
*dst = t;
|
||||
}
|
||||
|
||||
static int mp_chmap_from_alsa(struct mp_chmap *dst, snd_pcm_chmap_t *src)
|
||||
static bool mp_chmap_from_alsa(struct mp_chmap *dst, snd_pcm_chmap_t *src)
|
||||
{
|
||||
*dst = (struct mp_chmap) {0};
|
||||
|
||||
if (src->channels > MP_NUM_CHANNELS)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
dst->num = src->channels;
|
||||
for (int c = 0; c < dst->num; c++)
|
||||
dst->speaker[c] = find_mp_channel(src->pos[c]);
|
||||
|
||||
return 0;
|
||||
// Assume anything with 1 channel is mono.
|
||||
if (dst->num == 1)
|
||||
dst->speaker[0] = MP_SP(FC);
|
||||
|
||||
// Remap weird Intel HDA HDMI 7.1 layouts correctly.
|
||||
replace_submap(dst, CHMAP(6, FL, FR, BL, BR, SDL, SDR),
|
||||
CHMAP(6, FL, FR, SL, SR, BL, BR));
|
||||
|
||||
return mp_chmap_is_valid(dst);
|
||||
}
|
||||
|
||||
static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
@@ -297,20 +338,21 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
return false;
|
||||
|
||||
for (int i = 0; maps[i] != NULL; i++) {
|
||||
struct mp_chmap entry;
|
||||
mp_chmap_from_alsa(&entry, &maps[i]->map);
|
||||
char aname[128];
|
||||
if (snd_pcm_chmap_print(&maps[i]->map, sizeof(aname), aname) <= 0)
|
||||
aname[0] = '\0';
|
||||
|
||||
if (mp_chmap_is_valid(&entry)) {
|
||||
struct mp_chmap entry;
|
||||
if (mp_chmap_from_alsa(&entry, &maps[i]->map)) {
|
||||
struct mp_chmap reorder = entry;
|
||||
if (maps[i]->type == SND_CHMAP_TYPE_VAR)
|
||||
mp_chmap_reorder_norm(&entry);
|
||||
MP_VERBOSE(ao, "Got supported channel map: %s (type %s)\n",
|
||||
mp_chmap_to_str(&entry),
|
||||
snd_pcm_chmap_type_name(maps[i]->type));
|
||||
mp_chmap_sel_add_map(&chmap_sel, &entry);
|
||||
mp_chmap_reorder_norm(&reorder);
|
||||
MP_DBG(ao, "Got supported channel map: %s (type %s) -> %s -> %s\n",
|
||||
aname, snd_pcm_chmap_type_name(maps[i]->type),
|
||||
mp_chmap_to_str(&entry), mp_chmap_to_str(&reorder));
|
||||
mp_chmap_sel_add_map(&chmap_sel, &reorder);
|
||||
} else {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(&maps[i]->map, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "skipping unknown ALSA channel map: %s\n", tmp);
|
||||
MP_VERBOSE(ao, "skipping unknown ALSA channel map: %s\n", aname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,6 +361,108 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
return ao_chmap_sel_adjust(ao, &chmap_sel, chmap);
|
||||
}
|
||||
|
||||
// Map back our selected channel layout to an ALSA one. This is done this way so
|
||||
// that our ALSA->mp_chmap mapping function only has to go one way.
|
||||
// The return value is to be freed with free().
|
||||
static snd_pcm_chmap_t *map_back_chmap(struct ao *ao, struct mp_chmap *chmap)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
if (!mp_chmap_is_valid(chmap))
|
||||
return NULL;
|
||||
|
||||
snd_pcm_chmap_query_t **maps = snd_pcm_query_chmaps(p->alsa);
|
||||
if (!maps)
|
||||
return NULL;
|
||||
|
||||
snd_pcm_chmap_t *alsa_chmap = NULL;
|
||||
|
||||
for (int i = 0; maps[i] != NULL; i++) {
|
||||
struct mp_chmap entry;
|
||||
if (!mp_chmap_from_alsa(&entry, &maps[i]->map))
|
||||
continue;
|
||||
|
||||
if (mp_chmap_equals(chmap, &entry) ||
|
||||
(mp_chmap_equals_reordered(chmap, &entry) &&
|
||||
maps[i]->type == SND_CHMAP_TYPE_VAR))
|
||||
{
|
||||
alsa_chmap = calloc(1, sizeof(*alsa_chmap) +
|
||||
sizeof(alsa_chmap->pos[0]) * entry.num);
|
||||
if (!alsa_chmap)
|
||||
break;
|
||||
alsa_chmap->channels = entry.num;
|
||||
|
||||
// Undo if mp_chmap_reorder() was called on the result.
|
||||
int reorder[MP_NUM_CHANNELS];
|
||||
mp_chmap_get_reorder(reorder, chmap, &entry);
|
||||
for (int n = 0; n < entry.num; n++)
|
||||
alsa_chmap->pos[n] = maps[i]->map.pos[reorder[n]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
snd_pcm_free_chmaps(maps);
|
||||
return alsa_chmap;
|
||||
}
|
||||
|
||||
|
||||
static int set_chmap(struct ao *ao, struct mp_chmap *dev_chmap, int num_channels)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int err;
|
||||
|
||||
snd_pcm_chmap_t *alsa_chmap = map_back_chmap(ao, dev_chmap);
|
||||
if (alsa_chmap) {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "trying to set ALSA channel map: %s\n", tmp);
|
||||
|
||||
err = snd_pcm_set_chmap(p->alsa, alsa_chmap);
|
||||
if (err == -ENXIO) {
|
||||
// A device my not be able to set any channel map, even channel maps
|
||||
// that were reported as supported. This is either because the ALSA
|
||||
// device is broken (dmix), or because the driver has only 1
|
||||
// channel map per channel count, and setting the map is not needed.
|
||||
MP_VERBOSE(ao, "device returned ENXIO when setting channel map %s\n",
|
||||
mp_chmap_to_str(dev_chmap));
|
||||
} else {
|
||||
CHECK_ALSA_WARN("Channel map setup failed");
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
}
|
||||
|
||||
alsa_chmap = snd_pcm_get_chmap(p->alsa);
|
||||
if (alsa_chmap) {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "channel map reported by ALSA: %s\n", tmp);
|
||||
|
||||
struct mp_chmap chmap;
|
||||
mp_chmap_from_alsa(&chmap, alsa_chmap);
|
||||
|
||||
MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap));
|
||||
|
||||
if (p->cfg_ignore_chmap) {
|
||||
MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n");
|
||||
} else if (af_fmt_is_spdif(ao->format)) {
|
||||
MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n");
|
||||
} else if (!mp_chmap_is_valid(&chmap)) {
|
||||
MP_WARN(ao, "Got unknown channel map from ALSA.\n");
|
||||
} else if (chmap.num != num_channels) {
|
||||
MP_WARN(ao, "ALSA channel map conflicts with channel count!\n");
|
||||
} else {
|
||||
MP_VERBOSE(ao, "using the ALSA channel map.\n");
|
||||
if (mp_chmap_equals(&chmap, &ao->channels))
|
||||
MP_VERBOSE(ao, "which is what we requested.\n");
|
||||
ao->channels = chmap;
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* HAVE_CHMAP_API */
|
||||
|
||||
static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
@@ -326,6 +470,11 @@ static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int set_chmap(struct ao *ao, struct mp_chmap *dev_chmap, int num_channels)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* else HAVE_CHMAP_API */
|
||||
|
||||
static int map_iec958_srate(int srate)
|
||||
@@ -346,8 +495,8 @@ static int map_iec958_srate(int srate)
|
||||
}
|
||||
|
||||
// ALSA device strings can have parameters. They are usually appended to the
|
||||
// device name. Since there can be various forms, and we (sometimes) want to
|
||||
// append them to unknown device strings, which possibly already include params.
|
||||
// device name. There can be various forms, and we (sometimes) want to append
|
||||
// them to unknown device strings, which possibly already include params.
|
||||
static char *append_params(void *ta_parent, const char *device, const char *p)
|
||||
{
|
||||
if (!p || !p[0])
|
||||
@@ -418,16 +567,14 @@ static void uninit(struct ao *ao)
|
||||
int err;
|
||||
|
||||
err = snd_pcm_close(p->alsa);
|
||||
p->alsa = NULL;
|
||||
CHECK_ALSA_ERROR("pcm close error");
|
||||
}
|
||||
|
||||
alsa_error: ;
|
||||
}
|
||||
|
||||
#define INIT_OK 0
|
||||
#define INIT_ERROR -1
|
||||
#define INIT_BRAINDEATH -2
|
||||
static int init_device(struct ao *ao, bool second_try)
|
||||
static int init_device(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int err;
|
||||
@@ -445,40 +592,17 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
CHECK_ALSA_WARN("Unable to set blocking mode");
|
||||
|
||||
snd_pcm_hw_params_t *alsa_hwparams;
|
||||
snd_pcm_sw_params_t *alsa_swparams;
|
||||
|
||||
snd_pcm_hw_params_alloca(&alsa_hwparams);
|
||||
snd_pcm_sw_params_alloca(&alsa_swparams);
|
||||
|
||||
err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams);
|
||||
CHECK_ALSA_ERROR("Unable to get initial parameters");
|
||||
|
||||
if (af_fmt_is_spdif(ao->format)) {
|
||||
if (ao->format == AF_FORMAT_S_MP3) {
|
||||
p->alsa_fmt = SND_PCM_FORMAT_MPEG;
|
||||
} else {
|
||||
p->alsa_fmt = SND_PCM_FORMAT_S16;
|
||||
}
|
||||
} else {
|
||||
p->alsa_fmt = find_alsa_format(ao->format);
|
||||
// Some ALSA drivers have broken delay reporting, so disable the ALSA
|
||||
// resampling plugin by default.
|
||||
if (!p->cfg_resample) {
|
||||
err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0);
|
||||
CHECK_ALSA_ERROR("Unable to disable resampling");
|
||||
}
|
||||
if (p->alsa_fmt == SND_PCM_FORMAT_UNKNOWN) {
|
||||
p->alsa_fmt = SND_PCM_FORMAT_S16;
|
||||
ao->format = AF_FORMAT_S16;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
||||
if (err < 0) {
|
||||
if (af_fmt_is_spdif(ao->format))
|
||||
CHECK_ALSA_ERROR("Unable to set IEC61937 format");
|
||||
MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n",
|
||||
af_fmt_to_str(ao->format));
|
||||
p->alsa_fmt = SND_PCM_FORMAT_S16;
|
||||
ao->format = AF_FORMAT_S16;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
||||
CHECK_ALSA_ERROR("Unable to set format");
|
||||
|
||||
snd_pcm_access_t access = af_fmt_is_planar(ao->format)
|
||||
? SND_PCM_ACCESS_RW_NONINTERLEAVED
|
||||
@@ -491,6 +615,29 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
}
|
||||
CHECK_ALSA_ERROR("Unable to set access type");
|
||||
|
||||
bool found_format = false;
|
||||
int try_formats[AF_FORMAT_COUNT];
|
||||
af_get_best_sample_formats(ao->format, try_formats);
|
||||
for (int n = 0; try_formats[n]; n++) {
|
||||
if (af_fmt_is_planar(ao->format) != af_fmt_is_planar(try_formats[n]))
|
||||
continue; // implied SND_PCM_ACCESS mismatches
|
||||
p->alsa_fmt = find_alsa_format(try_formats[n]);
|
||||
MP_VERBOSE(ao, "trying format %s\n", af_fmt_to_str(try_formats[n]));
|
||||
if (snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt) >= 0) {
|
||||
ao->format = try_formats[n];
|
||||
found_format = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_format) {
|
||||
MP_ERR(ao, "Can't find appropriate sample format.\n");
|
||||
goto alsa_error;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt);
|
||||
CHECK_ALSA_ERROR("Unable to set format");
|
||||
|
||||
struct mp_chmap dev_chmap = ao->channels;
|
||||
if (af_fmt_is_spdif(ao->format) || p->cfg_ignore_chmap) {
|
||||
dev_chmap.num = 0; // disable chmap API
|
||||
@@ -515,157 +662,51 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
goto alsa_error;
|
||||
}
|
||||
|
||||
if (num_channels != ao->channels.num) {
|
||||
int req = ao->channels.num;
|
||||
mp_chmap_from_channels_alsa(&ao->channels, num_channels);
|
||||
if (!mp_chmap_is_valid(&ao->channels))
|
||||
mp_chmap_from_channels(&ao->channels, 2);
|
||||
MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req,
|
||||
num_channels, mp_chmap_to_str(&ao->channels));
|
||||
}
|
||||
|
||||
// Some ALSA drivers have broken delay reporting, so disable the ALSA
|
||||
// resampling plugin by default.
|
||||
if (!p->cfg_resample) {
|
||||
err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0);
|
||||
CHECK_ALSA_ERROR("Unable to disable resampling");
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_rate_near
|
||||
(p->alsa, alsa_hwparams, &ao->samplerate, NULL);
|
||||
CHECK_ALSA_ERROR("Unable to set samplerate-2");
|
||||
|
||||
snd_pcm_hw_params_t *hwparams_backup;
|
||||
snd_pcm_hw_params_alloca(&hwparams_backup);
|
||||
snd_pcm_hw_params_copy(hwparams_backup, alsa_hwparams);
|
||||
|
||||
// Cargo-culted buffer settings; might still be useful for PulseAudio.
|
||||
err = snd_pcm_hw_params_set_buffer_time_near
|
||||
(p->alsa, alsa_hwparams, &(unsigned int){BUFFER_TIME}, NULL);
|
||||
CHECK_ALSA_WARN("Unable to set buffer time near");
|
||||
|
||||
err = snd_pcm_hw_params_set_periods_near
|
||||
(p->alsa, alsa_hwparams, &(unsigned int){FRAGCOUNT}, NULL);
|
||||
CHECK_ALSA_WARN("Unable to set periods");
|
||||
if (err >= 0) {
|
||||
err = snd_pcm_hw_params_set_periods_near
|
||||
(p->alsa, alsa_hwparams, &(unsigned int){FRAGCOUNT}, NULL);
|
||||
CHECK_ALSA_WARN("Unable to set periods");
|
||||
}
|
||||
if (err < 0)
|
||||
snd_pcm_hw_params_copy(alsa_hwparams, hwparams_backup);
|
||||
|
||||
/* finally install hardware parameters */
|
||||
err = snd_pcm_hw_params(p->alsa, alsa_hwparams);
|
||||
CHECK_ALSA_ERROR("Unable to set hw-parameters");
|
||||
|
||||
/* end setting hw-params */
|
||||
if (set_chmap(ao, &dev_chmap, num_channels) < 0)
|
||||
goto alsa_error;
|
||||
|
||||
#if HAVE_CHMAP_API
|
||||
if (mp_chmap_is_valid(&dev_chmap)) {
|
||||
snd_pcm_chmap_t *alsa_chmap =
|
||||
calloc(1, sizeof(*alsa_chmap) +
|
||||
sizeof(alsa_chmap->pos[0]) * dev_chmap.num);
|
||||
if (!alsa_chmap)
|
||||
goto alsa_error;
|
||||
|
||||
alsa_chmap->channels = dev_chmap.num;
|
||||
for (int c = 0; c < dev_chmap.num; c++)
|
||||
alsa_chmap->pos[c] = find_alsa_channel(dev_chmap.speaker[c]);
|
||||
|
||||
// mpv and ALSA use different conventions for mono
|
||||
if (dev_chmap.num == 1 && dev_chmap.speaker[0] == MP_SP(FC))
|
||||
alsa_chmap->pos[0] = SND_CHMAP_MONO;
|
||||
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "trying to set ALSA channel map: %s\n", tmp);
|
||||
|
||||
err = snd_pcm_set_chmap(p->alsa, alsa_chmap);
|
||||
if (err == -ENXIO) {
|
||||
// A device my not be able to set any channel map, even channel maps
|
||||
// that were reported as supported. This is either because the ALSA
|
||||
// device is broken (dmix), or because the driver has only 1
|
||||
// channel map per channel count, and setting the map is not needed.
|
||||
MP_VERBOSE(ao, "device returned ENXIO when setting channel map %s\n",
|
||||
mp_chmap_to_str(&dev_chmap));
|
||||
} else {
|
||||
CHECK_ALSA_WARN("Channel map setup failed");
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
if (num_channels != ao->channels.num) {
|
||||
int req = ao->channels.num;
|
||||
mp_chmap_from_channels(&ao->channels, MPMIN(2, num_channels));
|
||||
MP_ERR(ao, "Asked for %d channels, got %d - fallback to %s.\n", req,
|
||||
num_channels, mp_chmap_to_str(&ao->channels));
|
||||
}
|
||||
|
||||
snd_pcm_chmap_t *alsa_chmap = snd_pcm_get_chmap(p->alsa);
|
||||
if (alsa_chmap) {
|
||||
char tmp[128];
|
||||
if (snd_pcm_chmap_print(alsa_chmap, sizeof(tmp), tmp) > 0)
|
||||
MP_VERBOSE(ao, "channel map reported by ALSA: %s\n", tmp);
|
||||
|
||||
struct mp_chmap chmap;
|
||||
mp_chmap_from_alsa(&chmap, alsa_chmap);
|
||||
|
||||
MP_VERBOSE(ao, "which we understand as: %s\n", mp_chmap_to_str(&chmap));
|
||||
|
||||
if (p->cfg_ignore_chmap) {
|
||||
MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n");
|
||||
} else if (af_fmt_is_spdif(ao->format)) {
|
||||
MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n");
|
||||
} else if (mp_chmap_is_valid(&chmap)) {
|
||||
// Is it one that contains NA channels?
|
||||
struct mp_chmap without_na = chmap;
|
||||
mp_chmap_remove_na(&without_na);
|
||||
|
||||
if (mp_chmap_is_valid(&without_na) &&
|
||||
!mp_chmap_equals(&without_na, &chmap) &&
|
||||
!mp_chmap_equals(&chmap, &ao->channels) &&
|
||||
!second_try)
|
||||
{
|
||||
// Sometimes, ALSA will advertise certain chmaps, but it's not
|
||||
// possible to set them. This can happen with dmix: as of
|
||||
// alsa 1.0.28, dmix can do stereo only, but advertises the
|
||||
// surround chmaps of the underlying device. In this case,
|
||||
// e.g. setting 6 channels will succeed, but requesting 5.1
|
||||
// afterwards will fail. Then it will return something like
|
||||
// "FL FR NA NA NA NA" as channel map. This means we would
|
||||
// have to pad stereo output to 6 channels with silence, which
|
||||
// would require lots of extra processing. You can't change
|
||||
// the number of channels to 2 either, because the hw params
|
||||
// are already set! So just fuck it and reopen the device with
|
||||
// the chmap "cleaned out" of NA entries.
|
||||
MP_VERBOSE(ao, "Working around braindead ALSA behavior.\n");
|
||||
err = snd_pcm_close(p->alsa);
|
||||
p->alsa = NULL;
|
||||
CHECK_ALSA_ERROR("pcm close error");
|
||||
ao->channels = without_na;
|
||||
return INIT_BRAINDEATH;
|
||||
}
|
||||
|
||||
if (mp_chmap_equals(&chmap, &ao->channels)) {
|
||||
MP_VERBOSE(ao, "which is what we requested.\n");
|
||||
} else if (chmap.num == ao->channels.num) {
|
||||
MP_VERBOSE(ao, "using the ALSA channel map.\n");
|
||||
ao->channels = chmap;
|
||||
} else {
|
||||
MP_WARN(ao, "ALSA channel map conflicts with channel count!\n");
|
||||
}
|
||||
} else {
|
||||
MP_WARN(ao, "Got unknown channel map from ALSA.\n");
|
||||
}
|
||||
|
||||
// mpv and ALSA use different conventions for mono
|
||||
if (ao->channels.num == 1) {
|
||||
MP_VERBOSE(ao, "assuming we actually got MONO from ALSA.\n");
|
||||
ao->channels.speaker[0] = MP_SP(FC);
|
||||
}
|
||||
|
||||
free(alsa_chmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
snd_pcm_uframes_t bufsize;
|
||||
err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize);
|
||||
err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &p->buffersize);
|
||||
CHECK_ALSA_ERROR("Unable to get buffersize");
|
||||
|
||||
p->buffersize = bufsize;
|
||||
MP_VERBOSE(ao, "got buffersize=%i samples\n", p->buffersize);
|
||||
|
||||
snd_pcm_uframes_t chunk_size;
|
||||
err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &chunk_size, NULL);
|
||||
err = snd_pcm_hw_params_get_period_size(alsa_hwparams, &p->outburst, NULL);
|
||||
CHECK_ALSA_ERROR("Unable to get period size");
|
||||
|
||||
MP_VERBOSE(ao, "got period size %li\n", chunk_size);
|
||||
p->outburst = chunk_size;
|
||||
p->can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
|
||||
|
||||
snd_pcm_sw_params_t *alsa_swparams;
|
||||
snd_pcm_sw_params_alloca(&alsa_swparams);
|
||||
|
||||
/* setting software parameters */
|
||||
err = snd_pcm_sw_params_current(p->alsa, alsa_swparams);
|
||||
CHECK_ALSA_ERROR("Unable to get sw-parameters");
|
||||
|
||||
@@ -675,7 +716,7 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
|
||||
/* start playing when one period has been written */
|
||||
err = snd_pcm_sw_params_set_start_threshold
|
||||
(p->alsa, alsa_swparams, chunk_size);
|
||||
(p->alsa, alsa_swparams, p->outburst);
|
||||
CHECK_ALSA_ERROR("Unable to set start threshold");
|
||||
|
||||
/* disable underrun reporting */
|
||||
@@ -691,15 +732,15 @@ static int init_device(struct ao *ao, bool second_try)
|
||||
err = snd_pcm_sw_params(p->alsa, alsa_swparams);
|
||||
CHECK_ALSA_ERROR("Unable to set sw-parameters");
|
||||
|
||||
/* end setting sw-params */
|
||||
MP_VERBOSE(ao, "hw pausing supported: %s\n", p->can_pause ? "yes" : "no");
|
||||
MP_VERBOSE(ao, "buffersize: %d samples\n", (int)p->buffersize);
|
||||
MP_VERBOSE(ao, "period size: %d samples\n", (int)p->outburst);
|
||||
|
||||
p->can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
|
||||
|
||||
return INIT_OK;
|
||||
return 0;
|
||||
|
||||
alsa_error:
|
||||
uninit(ao);
|
||||
return INIT_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int init(struct ao *ao)
|
||||
@@ -710,10 +751,33 @@ static int init(struct ao *ao)
|
||||
|
||||
MP_VERBOSE(ao, "using ALSA version: %s\n", snd_asoundlib_version());
|
||||
|
||||
int r = init_device(ao, false);
|
||||
if (r == INIT_BRAINDEATH)
|
||||
r = init_device(ao, true); // retry with normalized channel layout
|
||||
return r == INIT_OK ? 0 : -1;
|
||||
int r = init_device(ao);
|
||||
|
||||
// Sometimes, ALSA will advertise certain chmaps, but it's not possible to
|
||||
// set them. This can happen with dmix: as of alsa 1.0.29, dmix can do
|
||||
// stereo only, but advertises the surround chmaps of the underlying device.
|
||||
// In this case, e.g. setting 6 channels will succeed, but requesting 5.1
|
||||
// afterwards will fail. Then it will return something like "FL FR NA NA NA NA"
|
||||
// as channel map. This means we would have to pad stereo output to 6
|
||||
// channels with silence, which would require lots of extra processing. You
|
||||
// can't change the number of channels to 2 either, because the hw params
|
||||
// are already set! So just fuck it and reopen the device with the chmap
|
||||
// "cleaned out" of NA entries.
|
||||
if (r >= 0) {
|
||||
struct mp_chmap without_na = ao->channels;
|
||||
mp_chmap_remove_na(&without_na);
|
||||
|
||||
if (mp_chmap_is_valid(&without_na) && without_na.num <= 2 &&
|
||||
ao->channels.num > 2)
|
||||
{
|
||||
MP_VERBOSE(ao, "Working around braindead dmix multichannel behavior.\n");
|
||||
uninit(ao);
|
||||
ao->channels = without_na;
|
||||
r = init_device(ao);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void drain(struct ao *ao)
|
||||
@@ -731,6 +795,8 @@ static int get_space(struct ao *ao)
|
||||
snd_pcm_status_alloca(&status);
|
||||
|
||||
err = snd_pcm_status(p->alsa, status);
|
||||
if (!check_device_present(ao, err))
|
||||
goto alsa_error;
|
||||
CHECK_ALSA_ERROR("cannot get pcm status");
|
||||
|
||||
unsigned space = snd_pcm_status_get_avail(status);
|
||||
@@ -774,7 +840,6 @@ static void audio_pause(struct ao *ao)
|
||||
CHECK_ALSA_ERROR("pcm pause error");
|
||||
}
|
||||
} else {
|
||||
MP_VERBOSE(ao, "pause not supported by hardware\n");
|
||||
if (snd_pcm_delay(p->alsa, &p->prepause_frames) < 0
|
||||
|| p->prepause_frames < 0)
|
||||
p->prepause_frames = 0;
|
||||
@@ -857,9 +922,8 @@ static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
|
||||
if (res == -EINTR || res == -EAGAIN) { /* retry */
|
||||
res = 0;
|
||||
} else if (res == -ENODEV) {
|
||||
MP_WARN(ao, "Device lost, trying to recover...\n");
|
||||
ao_request_reload(ao);
|
||||
} else if (!check_device_present(ao, res)) {
|
||||
goto alsa_error;
|
||||
} else if (res < 0) {
|
||||
if (res == -ESTRPIPE) { /* suspend */
|
||||
resume_device(ao);
|
||||
@@ -913,6 +977,20 @@ alsa_error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static bool is_useless_device(char *name)
|
||||
{
|
||||
char *crap[] = {"front", "rear", "center_lfe", "side", "surround21",
|
||||
"surround40", "surround41", "surround50", "surround51", "surround71",
|
||||
"sysdefault", "pulse", "null", "dsnoop", "dmix", "hw", "iec958"};
|
||||
for (int i = 0; i < MP_ARRAY_SIZE(crap); i++) {
|
||||
int l = strlen(crap[i]);
|
||||
if (name && strncmp(name, crap[i], l) == 0 &&
|
||||
(!name[l] || name[l] == ':'))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
{
|
||||
void **hints;
|
||||
@@ -923,7 +1001,7 @@ static void list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
char *name = snd_device_name_get_hint(hints[n], "NAME");
|
||||
char *desc = snd_device_name_get_hint(hints[n], "DESC");
|
||||
char *io = snd_device_name_get_hint(hints[n], "IOID");
|
||||
if (io && strcmp(io, "Output") == 0) {
|
||||
if (!is_useless_device(name) && (!io || strcmp(io, "Output") == 0)) {
|
||||
char desc2[1024];
|
||||
snprintf(desc2, sizeof(desc2), "%s", desc ? desc : "");
|
||||
for (int i = 0; desc2[i]; i++) {
|
||||
|
||||
@@ -180,6 +180,8 @@ static void init_physical_format(struct ao *ao)
|
||||
struct priv *p = ao->priv;
|
||||
OSErr err;
|
||||
|
||||
void *tmp = talloc_new(NULL);
|
||||
|
||||
AudioStreamBasicDescription asbd;
|
||||
ca_fill_asbd(ao, &asbd);
|
||||
|
||||
@@ -190,6 +192,8 @@ static void init_physical_format(struct ao *ao)
|
||||
&streams, &n_streams);
|
||||
CHECK_CA_ERROR("could not get number of streams");
|
||||
|
||||
talloc_steal(tmp, streams);
|
||||
|
||||
MP_VERBOSE(ao, "Found %zd substream(s).\n", n_streams);
|
||||
|
||||
for (int i = 0; i < n_streams; i++) {
|
||||
@@ -204,6 +208,7 @@ static void init_physical_format(struct ao *ao)
|
||||
if (!CHECK_CA_WARN("could not get number of stream formats"))
|
||||
continue; // try next one
|
||||
|
||||
talloc_steal(tmp, formats);
|
||||
|
||||
uint32_t direction;
|
||||
err = CA_GET(streams[i], kAudioStreamPropertyDirection, &direction);
|
||||
@@ -232,6 +237,12 @@ static void init_physical_format(struct ao *ao)
|
||||
&p->original_asbd);
|
||||
CHECK_CA_WARN("could not get current physical stream format");
|
||||
|
||||
if (ca_asbd_equals(&p->original_asbd, &best_asbd)) {
|
||||
MP_VERBOSE(ao, "Requested format already set, not changing.\n");
|
||||
p->original_asbd.mFormatID = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ca_change_physical_format_sync(ao, streams[i], best_asbd))
|
||||
p->original_asbd = (AudioStreamBasicDescription){0};
|
||||
break;
|
||||
@@ -239,6 +250,7 @@ static void init_physical_format(struct ao *ao)
|
||||
}
|
||||
|
||||
coreaudio_error:
|
||||
talloc_free(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -372,8 +384,8 @@ static int hotplug_init(struct ao *ao)
|
||||
err = AudioObjectAddPropertyListener(
|
||||
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
|
||||
if (err != noErr) {
|
||||
char *c1 = fourcc_repr(hotplug_properties[i]);
|
||||
char *c2 = fourcc_repr(err);
|
||||
char *c1 = mp_tag_str(hotplug_properties[i]);
|
||||
char *c2 = mp_tag_str(err);
|
||||
MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2);
|
||||
goto coreaudio_error;
|
||||
}
|
||||
@@ -397,8 +409,8 @@ static void hotplug_uninit(struct ao *ao)
|
||||
err = AudioObjectRemovePropertyListener(
|
||||
kAudioObjectSystemObject, &addr, hotplug_cb, (void *)ao);
|
||||
if (err != noErr) {
|
||||
char *c1 = fourcc_repr(hotplug_properties[i]);
|
||||
char *c2 = fourcc_repr(err);
|
||||
char *c1 = mp_tag_str(hotplug_properties[i]);
|
||||
char *c2 = mp_tag_str(err);
|
||||
MP_ERR(ao, "failed to set device listener %s (%s)", c1, c2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "common/common.h"
|
||||
@@ -98,6 +98,9 @@ static AudioChannelLayout *ca_layout_to_custom_layout(struct ao *ao,
|
||||
AudioChannelLayout *r;
|
||||
OSStatus err;
|
||||
|
||||
if (tag == kAudioChannelLayoutTag_UseChannelDescriptions)
|
||||
return l;
|
||||
|
||||
if (tag == kAudioChannelLayoutTag_UseChannelBitmap) {
|
||||
uint32_t psize;
|
||||
err = AudioFormatGetPropertyInfo(
|
||||
@@ -109,7 +112,7 @@ static AudioChannelLayout *ca_layout_to_custom_layout(struct ao *ao,
|
||||
kAudioFormatProperty_ChannelLayoutForBitmap,
|
||||
sizeof(uint32_t), &l->mChannelBitmap, &psize, r);
|
||||
CHECK_CA_ERROR("failed to convert channel bitmap to descriptions (get)");
|
||||
} else if (tag != kAudioChannelLayoutTag_UseChannelDescriptions) {
|
||||
} else {
|
||||
uint32_t psize;
|
||||
err = AudioFormatGetPropertyInfo(
|
||||
kAudioFormatProperty_ChannelLayoutForTag,
|
||||
@@ -120,36 +123,58 @@ static AudioChannelLayout *ca_layout_to_custom_layout(struct ao *ao,
|
||||
kAudioFormatProperty_ChannelLayoutForTag,
|
||||
sizeof(AudioChannelLayoutTag), &l->mChannelLayoutTag, &psize, r);
|
||||
CHECK_CA_ERROR("failed to convert channel tag to descriptions (get)");
|
||||
} else {
|
||||
r = l;
|
||||
}
|
||||
|
||||
MP_VERBOSE(ao, "converted input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_V, l);
|
||||
|
||||
return r;
|
||||
coreaudio_error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#define CHMAP(n, ...) &(struct mp_chmap) MP_CONCAT(MP_CHMAP, n) (__VA_ARGS__)
|
||||
|
||||
// Replace each channel in a with b (a->num == b->num)
|
||||
static void replace_submap(struct mp_chmap *dst, struct mp_chmap *a,
|
||||
struct mp_chmap *b)
|
||||
{
|
||||
struct mp_chmap t = *dst;
|
||||
if (!mp_chmap_is_valid(&t) || mp_chmap_diffn(a, &t) != 0)
|
||||
return;
|
||||
assert(a->num == b->num);
|
||||
for (int n = 0; n < t.num; n++) {
|
||||
for (int i = 0; i < a->num; i++) {
|
||||
if (t.speaker[n] == a->speaker[i]) {
|
||||
t.speaker[n] = b->speaker[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mp_chmap_is_valid(&t))
|
||||
*dst = t;
|
||||
}
|
||||
|
||||
static bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout,
|
||||
struct mp_chmap *chmap)
|
||||
{
|
||||
void *talloc_ctx = talloc_new(NULL);
|
||||
|
||||
MP_DBG(ao, "input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_DEBUG, layout);
|
||||
MP_VERBOSE(ao, "input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_V, layout);
|
||||
|
||||
AudioChannelLayout *l = ca_layout_to_custom_layout(ao, talloc_ctx, layout);
|
||||
if (!l)
|
||||
goto coreaudio_error;
|
||||
|
||||
MP_VERBOSE(ao, "converted input channel layout:\n");
|
||||
ca_log_layout(ao, MSGL_V, l);
|
||||
|
||||
if (l->mNumberChannelDescriptions > MP_NUM_CHANNELS) {
|
||||
MP_VERBOSE(ao, "layout has too many descriptions (%u, max: %d)\n",
|
||||
(unsigned) l->mNumberChannelDescriptions, MP_NUM_CHANNELS);
|
||||
return false;
|
||||
}
|
||||
|
||||
chmap->num = l->mNumberChannelDescriptions;
|
||||
for (int n = 0; n < l->mNumberChannelDescriptions; n++) {
|
||||
AudioChannelLabel label = l->mChannelDescriptions[n].mChannelLabel;
|
||||
int speaker = ca_label_to_mp_speaker_id(label);
|
||||
@@ -157,14 +182,17 @@ static bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout,
|
||||
MP_VERBOSE(ao, "channel label=%u unusable to build channel "
|
||||
"bitmap, skipping layout\n", (unsigned) label);
|
||||
goto coreaudio_error;
|
||||
} else {
|
||||
chmap->speaker[n] = speaker;
|
||||
chmap->num = n + 1;
|
||||
}
|
||||
chmap->speaker[n] = speaker;
|
||||
}
|
||||
|
||||
// Remap weird 7.1(rear) layouts correctly.
|
||||
replace_submap(chmap, CHMAP(6, FL, FR, BL, BR, SDL, SDR),
|
||||
CHMAP(6, FL, FR, SL, SR, BL, BR));
|
||||
|
||||
talloc_free(talloc_ctx);
|
||||
return chmap->num > 0;
|
||||
MP_VERBOSE(ao, "mp chmap: %s\n", mp_chmap_to_str(chmap));
|
||||
return mp_chmap_is_valid(chmap) && !mp_chmap_is_unknown(chmap);
|
||||
coreaudio_error:
|
||||
MP_VERBOSE(ao, "converted input channel layout (failed):\n");
|
||||
ca_log_layout(ao, MSGL_V, layout);
|
||||
@@ -234,34 +262,68 @@ coreaudio_error:
|
||||
return r;
|
||||
}
|
||||
|
||||
bool ca_init_chmap(struct ao *ao, AudioDeviceID device)
|
||||
static void ca_retrieve_layouts(struct ao *ao, struct mp_chmap_sel *s,
|
||||
AudioDeviceID device)
|
||||
{
|
||||
void *ta_ctx = talloc_new(NULL);
|
||||
|
||||
struct mp_chmap_sel chmap_sel = {.tmp = ta_ctx};
|
||||
struct mp_chmap chmap = {0};
|
||||
|
||||
mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_MONO);
|
||||
struct mp_chmap chmap;
|
||||
|
||||
AudioChannelLayout *ml = ca_query_layout(ao, device, ta_ctx);
|
||||
if (ml && ca_layout_to_mp_chmap(ao, ml, &chmap))
|
||||
mp_chmap_sel_add_map(&chmap_sel, &chmap);
|
||||
mp_chmap_sel_add_map(s, &chmap);
|
||||
|
||||
AudioChannelLayout *sl = ca_query_stereo_layout(ao, device, ta_ctx);
|
||||
if (sl && ca_layout_to_mp_chmap(ao, sl, &chmap))
|
||||
mp_chmap_sel_add_map(&chmap_sel, &chmap);
|
||||
mp_chmap_sel_add_map(s, &chmap);
|
||||
|
||||
talloc_free(ta_ctx);
|
||||
}
|
||||
|
||||
bool ca_init_chmap(struct ao *ao, AudioDeviceID device)
|
||||
{
|
||||
struct mp_chmap_sel chmap_sel = {0};
|
||||
ca_retrieve_layouts(ao, &chmap_sel, device);
|
||||
|
||||
if (!chmap_sel.num_chmaps)
|
||||
mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_STEREO);
|
||||
|
||||
mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_MONO);
|
||||
|
||||
if (!ao_chmap_sel_adjust(ao, &chmap_sel, &ao->channels)) {
|
||||
MP_ERR(ao, "could not select a suitable channel map among the "
|
||||
"hardware supported ones. Make sure to configure your "
|
||||
"output device correctly in 'Audio MIDI Setup.app'\n");
|
||||
goto coreaudio_error;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
|
||||
struct mp_chmap *out_map)
|
||||
{
|
||||
// Apparently, we have to guess by looking back at the supported layouts,
|
||||
// and I haven't found a property that retrieves the actual currently
|
||||
// active channel layout.
|
||||
|
||||
struct mp_chmap_sel chmap_sel = {0};
|
||||
ca_retrieve_layouts(ao, &chmap_sel, device);
|
||||
|
||||
// Use any exact match.
|
||||
for (int n = 0; n < chmap_sel.num_chmaps; n++) {
|
||||
if (chmap_sel.chmaps[n].num == channel_count) {
|
||||
MP_VERBOSE(ao, "mismatching channels - fallback #%d\n", n);
|
||||
*out_map = chmap_sel.chmaps[n];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
talloc_free(ta_ctx);
|
||||
return true;
|
||||
|
||||
coreaudio_error:
|
||||
talloc_free(ta_ctx);
|
||||
return false;
|
||||
// Fall back to stereo or mono, and fill the rest with silence. (We don't
|
||||
// know what the device expects. We could use a larger default layout here,
|
||||
// but let's not.)
|
||||
mp_chmap_from_channels(out_map, MPMIN(2, channel_count));
|
||||
out_map->num = channel_count;
|
||||
for (int n = 2; n < out_map->num; n++)
|
||||
out_map->speaker[n] = MP_SPEAKER_ID_NA;
|
||||
MP_WARN(ao, "mismatching channels - falling back to %s\n",
|
||||
mp_chmap_to_str(out_map));
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* mpv is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MPV_COREAUDIO_CHMAP_H
|
||||
@@ -20,6 +20,10 @@
|
||||
|
||||
#include <AudioToolbox/AudioToolbox.h>
|
||||
|
||||
struct mp_chmap;
|
||||
|
||||
bool ca_init_chmap(struct ao *ao, AudioDeviceID device);
|
||||
void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
|
||||
struct mp_chmap *out_map);
|
||||
|
||||
#endif
|
||||
@@ -300,6 +300,12 @@ static int init(struct ao *ao)
|
||||
|
||||
ca_print_asbd(ao, "virtual format", &p->stream_asbd);
|
||||
|
||||
if (p->stream_asbd.mChannelsPerFrame > MP_NUM_CHANNELS) {
|
||||
MP_ERR(ao, "unsupported number of channels: %d > %d.\n",
|
||||
p->stream_asbd.mChannelsPerFrame, MP_NUM_CHANNELS);
|
||||
goto coreaudio_error;
|
||||
}
|
||||
|
||||
int new_format = ca_asbd_to_mp_format(&p->stream_asbd);
|
||||
|
||||
// If both old and new formats are spdif, avoid changing it due to the
|
||||
@@ -315,7 +321,10 @@ static int init(struct ao *ao)
|
||||
ao->samplerate = p->stream_asbd.mSampleRate;
|
||||
|
||||
if (ao->channels.num != p->stream_asbd.mChannelsPerFrame) {
|
||||
// We really expect that ca_init_chmap() fixes the layout to the HW's.
|
||||
ca_get_active_chmap(ao, p->device, p->stream_asbd.mChannelsPerFrame,
|
||||
&ao->channels);
|
||||
}
|
||||
if (!ao->channels.num) {
|
||||
MP_ERR(ao, "number of channels changed, and unknown channel layout!\n");
|
||||
goto coreaudio_error;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "audio/out/ao_coreaudio_properties.h"
|
||||
#include "audio/out/ao_coreaudio_utils.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||
uint32_t size, void *data)
|
||||
|
||||
@@ -51,7 +51,9 @@ static bool ca_is_output_device(struct ao *ao, AudioDeviceID dev)
|
||||
size_t n_buffers;
|
||||
AudioBufferList *buffers;
|
||||
const ca_scope scope = kAudioDevicePropertyStreamConfiguration;
|
||||
CA_GET_ARY_O(dev, scope, &buffers, &n_buffers);
|
||||
OSStatus err = CA_GET_ARY_O(dev, scope, &buffers, &n_buffers);
|
||||
if (err != noErr)
|
||||
return false;
|
||||
talloc_free(buffers);
|
||||
return n_buffers > 0;
|
||||
}
|
||||
@@ -71,11 +73,16 @@ void ca_get_device_list(struct ao *ao, struct ao_device_list *list)
|
||||
char *name;
|
||||
char *desc;
|
||||
err = CA_GET_STR(devs[i], kAudioDevicePropertyDeviceUID, &name);
|
||||
if (err != noErr) {
|
||||
MP_VERBOSE(ao, "skipping device %d, which has no UID\n", i);
|
||||
talloc_free(ta_ctx);
|
||||
continue;
|
||||
}
|
||||
talloc_steal(ta_ctx, name);
|
||||
err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &desc);
|
||||
talloc_steal(ta_ctx, desc);
|
||||
if (err != noErr)
|
||||
desc = "Unknown";
|
||||
desc = talloc_strdup(NULL, "Unknown");
|
||||
talloc_steal(ta_ctx, desc);
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){name, desc});
|
||||
talloc_free(ta_ctx);
|
||||
}
|
||||
@@ -129,36 +136,11 @@ coreaudio_error:
|
||||
return err;
|
||||
}
|
||||
|
||||
char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code)
|
||||
{
|
||||
// Extract FourCC letters from the uint32_t and finde out if it's a valid
|
||||
// code that is made of letters.
|
||||
unsigned char fcc[4] = {
|
||||
(code >> 24) & 0xFF,
|
||||
(code >> 16) & 0xFF,
|
||||
(code >> 8) & 0xFF,
|
||||
code & 0xFF,
|
||||
};
|
||||
|
||||
bool valid_fourcc = true;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (fcc[i] < 32 || fcc[i] >= 128)
|
||||
valid_fourcc = false;
|
||||
}
|
||||
|
||||
if (valid_fourcc)
|
||||
snprintf(buf, buf_size, "'%c%c%c%c'", fcc[0], fcc[1], fcc[2], fcc[3]);
|
||||
else
|
||||
snprintf(buf, buf_size, "%u", (unsigned int)code);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message)
|
||||
{
|
||||
if (code == noErr) return true;
|
||||
|
||||
mp_msg(ao->log, level, "%s (%s)\n", message, fourcc_repr(code));
|
||||
mp_msg(ao->log, level, "%s (%s)\n", message, mp_tag_str(code));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -251,7 +233,7 @@ void ca_print_asbd(struct ao *ao, const char *description,
|
||||
const AudioStreamBasicDescription *asbd)
|
||||
{
|
||||
uint32_t flags = asbd->mFormatFlags;
|
||||
char *format = fourcc_repr(asbd->mFormatID);
|
||||
char *format = mp_tag_str(asbd->mFormatID);
|
||||
int mpfmt = ca_asbd_to_mp_format(asbd);
|
||||
|
||||
MP_VERBOSE(ao,
|
||||
@@ -463,7 +445,7 @@ int64_t ca_get_device_latency_us(struct ao *ao, AudioDeviceID device)
|
||||
if (err == noErr) {
|
||||
latency_frames += temp;
|
||||
MP_VERBOSE(ao, "Latency property %s: %d frames\n",
|
||||
fourcc_repr(latency_properties[n]), (int)temp);
|
||||
mp_tag_str(latency_properties[n]), (int)temp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,6 +480,8 @@ bool ca_change_physical_format_sync(struct ao *ao, AudioStreamID stream,
|
||||
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &prev_format);
|
||||
CHECK_CA_ERROR("can't get current physical format");
|
||||
|
||||
ca_print_asbd(ao, "format in use before switching:", &prev_format);
|
||||
|
||||
/* Install the callback. */
|
||||
AudioObjectPropertyAddress p_addr = {
|
||||
.mSelector = kAudioStreamPropertyPhysicalFormat,
|
||||
@@ -516,7 +500,7 @@ bool ca_change_physical_format_sync(struct ao *ao, AudioStreamID stream,
|
||||
|
||||
/* The AudioStreamSetProperty is not only asynchronous,
|
||||
* it is also not Atomic, in its behaviour. */
|
||||
struct timespec timeout = mp_rel_time_to_timespec(0.5);
|
||||
struct timespec timeout = mp_rel_time_to_timespec(2.0);
|
||||
AudioStreamBasicDescription actual_format = {0};
|
||||
while (1) {
|
||||
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &actual_format);
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
CFStringRef cfstr_from_cstr(char *str);
|
||||
char *cfstr_get_cstr(CFStringRef cfstr);
|
||||
|
||||
char *fourcc_repr_buf(char *buf, size_t buf_size, uint32_t code);
|
||||
#define fourcc_repr(code) fourcc_repr_buf((char[40]){0}, 40, code)
|
||||
|
||||
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);
|
||||
|
||||
#define CHECK_CA_ERROR_L(label, message) \
|
||||
|
||||
@@ -1,707 +0,0 @@
|
||||
/*
|
||||
* Windows DirectSound interface
|
||||
*
|
||||
* Copyright (c) 2004 Gabor Szecsi <deje@miki.hu>
|
||||
*
|
||||
* This file is part of mpv.
|
||||
*
|
||||
* mpv is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* mpv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
\todo verify/extend multichannel support
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#define DIRECTSOUND_VERSION 0x0600
|
||||
#include <dsound.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/common.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "audio/format.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
#include "common/msg.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "osdep/io.h"
|
||||
#include "options/m_option.h"
|
||||
|
||||
/**
|
||||
\todo use the definitions from the win32 api headers when they define these
|
||||
*/
|
||||
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
|
||||
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
|
||||
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE
|
||||
|
||||
static const GUID KSDATAFORMAT_SUBTYPE_PCM = {
|
||||
0x1, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define DSSPEAKER_HEADPHONE 0x00000001
|
||||
#define DSSPEAKER_MONO 0x00000002
|
||||
#define DSSPEAKER_QUAD 0x00000003
|
||||
#define DSSPEAKER_STEREO 0x00000004
|
||||
#define DSSPEAKER_SURROUND 0x00000005
|
||||
#define DSSPEAKER_5POINT1 0x00000006
|
||||
#endif
|
||||
|
||||
#ifndef _WAVEFORMATEXTENSIBLE_
|
||||
typedef struct {
|
||||
WAVEFORMATEX Format;
|
||||
union {
|
||||
WORD wValidBitsPerSample; /* bits of precision */
|
||||
WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */
|
||||
WORD wReserved; /* If neither applies, set to zero. */
|
||||
} Samples;
|
||||
DWORD dwChannelMask; /* which channels are */
|
||||
/* present in stream */
|
||||
GUID SubFormat;
|
||||
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
|
||||
#endif
|
||||
|
||||
struct priv {
|
||||
HINSTANCE hdsound_dll; ///handle to the dll
|
||||
LPDIRECTSOUND hds; ///direct sound object
|
||||
LPDIRECTSOUNDBUFFER hdspribuf; ///primary direct sound buffer
|
||||
LPDIRECTSOUNDBUFFER hdsbuf; ///secondary direct sound buffer (stream buffer)
|
||||
int buffer_size; ///size in bytes of the direct sound buffer
|
||||
int write_offset; ///offset of the write cursor in the direct sound buffer
|
||||
int min_free_space; ///if the free space is below this value get_space() will return 0
|
||||
///there will always be at least this amout of free space to prevent
|
||||
///get_space() from returning wrong values when buffer is 100% full.
|
||||
///will be replaced with nBlockAlign in init()
|
||||
int underrun_check; ///0 or last reported free space (underrun detection)
|
||||
int device_num; ///wanted device number
|
||||
GUID device; ///guid of the device
|
||||
int audio_volume;
|
||||
|
||||
int device_index;
|
||||
|
||||
int outburst; ///play in multiple of chunks of this size
|
||||
|
||||
int cfg_device;
|
||||
int cfg_buffersize;
|
||||
|
||||
struct ao_device_list *listing; ///temporary during list_devs()
|
||||
};
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief output error message
|
||||
\param err error code
|
||||
\return string with the error message
|
||||
*/
|
||||
static char * dserr2str(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case DS_OK: return "DS_OK";
|
||||
case DS_NO_VIRTUALIZATION: return "DS_NO_VIRTUALIZATION";
|
||||
case DSERR_ALLOCATED: return "DS_NO_VIRTUALIZATION";
|
||||
case DSERR_CONTROLUNAVAIL: return "DSERR_CONTROLUNAVAIL";
|
||||
case DSERR_INVALIDPARAM: return "DSERR_INVALIDPARAM";
|
||||
case DSERR_INVALIDCALL: return "DSERR_INVALIDCALL";
|
||||
case DSERR_GENERIC: return "DSERR_GENERIC";
|
||||
case DSERR_PRIOLEVELNEEDED: return "DSERR_PRIOLEVELNEEDED";
|
||||
case DSERR_OUTOFMEMORY: return "DSERR_OUTOFMEMORY";
|
||||
case DSERR_BADFORMAT: return "DSERR_BADFORMAT";
|
||||
case DSERR_UNSUPPORTED: return "DSERR_UNSUPPORTED";
|
||||
case DSERR_NODRIVER: return "DSERR_NODRIVER";
|
||||
case DSERR_ALREADYINITIALIZED: return "DSERR_ALREADYINITIALIZED";
|
||||
case DSERR_NOAGGREGATION: return "DSERR_NOAGGREGATION";
|
||||
case DSERR_BUFFERLOST: return "DSERR_BUFFERLOST";
|
||||
case DSERR_OTHERAPPHASPRIO: return "DSERR_OTHERAPPHASPRIO";
|
||||
case DSERR_UNINITIALIZED: return "DSERR_UNINITIALIZED";
|
||||
case DSERR_NOINTERFACE: return "DSERR_NOINTERFACE";
|
||||
case DSERR_ACCESSDENIED: return "DSERR_ACCESSDENIED";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
\brief uninitialize direct sound
|
||||
*/
|
||||
static void UninitDirectSound(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
// finally release the DirectSound object
|
||||
if (p->hds) {
|
||||
IDirectSound_Release(p->hds);
|
||||
p->hds = NULL;
|
||||
}
|
||||
// free DSOUND.DLL
|
||||
if (p->hdsound_dll) {
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
p->hdsound_dll = NULL;
|
||||
}
|
||||
MP_VERBOSE(ao, "DirectSound uninitialized\n");
|
||||
}
|
||||
|
||||
/**
|
||||
\brief enumerate direct sound devices
|
||||
\return TRUE to continue with the enumeration
|
||||
*/
|
||||
static BOOL CALLBACK DirectSoundEnum(LPGUID guid, LPCSTR desc, LPCSTR module,
|
||||
LPVOID context)
|
||||
{
|
||||
struct ao *ao = context;
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
MP_VERBOSE(ao, "%i %s ", p->device_index, desc);
|
||||
if (p->device_num == p->device_index) {
|
||||
MP_VERBOSE(ao, "<--");
|
||||
if (guid)
|
||||
memcpy(&p->device, guid, sizeof(GUID));
|
||||
}
|
||||
char *guidstr = talloc_strdup(NULL, "");
|
||||
if (guid) {
|
||||
wchar_t guidwstr[80] = {0};
|
||||
StringFromGUID2(guid, guidwstr, MP_ARRAY_SIZE(guidwstr));
|
||||
char *nstr = mp_to_utf8(NULL, guidwstr);
|
||||
if (nstr) {
|
||||
talloc_free(guidstr);
|
||||
guidstr = nstr;
|
||||
}
|
||||
}
|
||||
if (p->device_num < 0 && ao->device) {
|
||||
if (strcmp(ao->device, guidstr) == 0) {
|
||||
MP_VERBOSE(ao, "<--");
|
||||
p->device_num = p->device_index;
|
||||
if (guid)
|
||||
memcpy(&p->device, guid, sizeof(GUID));
|
||||
}
|
||||
}
|
||||
if (p->listing) {
|
||||
struct ao_device_desc e = {guidstr, desc};
|
||||
ao_device_list_add(p->listing, ao, &e);
|
||||
}
|
||||
talloc_free(guidstr);
|
||||
|
||||
MP_VERBOSE(ao, "\n");
|
||||
p->device_index++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void EnumDevs(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
p->device_index = 0;
|
||||
p->device_num = p->cfg_device;
|
||||
|
||||
HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKA, LPVOID);
|
||||
OurDirectSoundEnumerate = (void *)GetProcAddress(p->hdsound_dll,
|
||||
"DirectSoundEnumerateA");
|
||||
|
||||
if (OurDirectSoundEnumerate == NULL) {
|
||||
MP_ERR(ao, "GetProcAddress FAILED\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Enumerate all directsound p->devices
|
||||
MP_VERBOSE(ao, "Output Devices:\n");
|
||||
OurDirectSoundEnumerate(DirectSoundEnum, ao);
|
||||
}
|
||||
|
||||
static int LoadDirectSound(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
// initialize directsound
|
||||
p->hdsound_dll = LoadLibrary(L"DSOUND.DLL");
|
||||
if (p->hdsound_dll == NULL) {
|
||||
MP_ERR(ao, "cannot load DSOUND.DLL\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
bool need_init = !p->hdsound_dll;
|
||||
if (need_init && !LoadDirectSound(ao))
|
||||
return;
|
||||
|
||||
p->listing = list;
|
||||
EnumDevs(ao);
|
||||
p->listing = NULL;
|
||||
|
||||
if (need_init)
|
||||
UninitDirectSound(ao);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief initilize direct sound
|
||||
\return 0 if error, 1 if ok
|
||||
*/
|
||||
static int InitDirectSound(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
DSCAPS dscaps;
|
||||
|
||||
if (!LoadDirectSound(ao))
|
||||
return 0;
|
||||
|
||||
HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
|
||||
OurDirectSoundCreate =
|
||||
(void *)GetProcAddress(p->hdsound_dll, "DirectSoundCreate");
|
||||
|
||||
if (OurDirectSoundCreate == NULL) {
|
||||
MP_ERR(ao, "GetProcAddress FAILED\n");
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EnumDevs(ao);
|
||||
|
||||
// Create the direct sound object
|
||||
if (FAILED(OurDirectSoundCreate((p->device_num > 0) ? &p->device : NULL,
|
||||
&p->hds, NULL)))
|
||||
{
|
||||
MP_ERR(ao, "cannot create a DirectSound device\n");
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set DirectSound Cooperative level, ie what control we want over Windows
|
||||
* sound device. In our case, DSSCL_EXCLUSIVE means that we can modify the
|
||||
* settings of the primary buffer, but also that only the sound of our
|
||||
* application will be audible when it will have the focus.
|
||||
* !!! (this is not really working as intended yet because to set the
|
||||
* cooperative level you need the window handle of your application, and
|
||||
* I don't know of any easy way to get it. Especially since we might play
|
||||
* sound without any video, and so what window handle should we use ???
|
||||
* The hack for now is to use the Desktop window handle - it seems to be
|
||||
* working */
|
||||
if (IDirectSound_SetCooperativeLevel(p->hds, GetDesktopWindow(),
|
||||
DSSCL_EXCLUSIVE))
|
||||
{
|
||||
MP_ERR(ao, "cannot set direct sound cooperative level\n");
|
||||
IDirectSound_Release(p->hds);
|
||||
FreeLibrary(p->hdsound_dll);
|
||||
return 0;
|
||||
}
|
||||
MP_VERBOSE(ao, "DirectSound initialized\n");
|
||||
|
||||
memset(&dscaps, 0, sizeof(DSCAPS));
|
||||
dscaps.dwSize = sizeof(DSCAPS);
|
||||
if (DS_OK == IDirectSound_GetCaps(p->hds, &dscaps)) {
|
||||
if (dscaps.dwFlags & DSCAPS_EMULDRIVER)
|
||||
MP_VERBOSE(ao, "DirectSound is emulated\n");
|
||||
} else {
|
||||
MP_VERBOSE(ao, "cannot get device capabilities\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief destroy the direct sound buffer
|
||||
*/
|
||||
static void DestroyBuffer(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
if (p->hdsbuf) {
|
||||
IDirectSoundBuffer_Release(p->hdsbuf);
|
||||
p->hdsbuf = NULL;
|
||||
}
|
||||
if (p->hdspribuf) {
|
||||
IDirectSoundBuffer_Release(p->hdspribuf);
|
||||
p->hdspribuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\brief fill sound buffer
|
||||
\param data pointer to the sound data to copy
|
||||
\param len length of the data to copy in bytes
|
||||
\return number of copyed bytes
|
||||
*/
|
||||
static int write_buffer(struct ao *ao, unsigned char *data, int len)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
HRESULT res;
|
||||
LPVOID lpvPtr1;
|
||||
DWORD dwBytes1;
|
||||
LPVOID lpvPtr2;
|
||||
DWORD dwBytes2;
|
||||
|
||||
p->underrun_check = 0;
|
||||
|
||||
// Lock the buffer
|
||||
res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1,
|
||||
&dwBytes1, &lpvPtr2, &dwBytes2, 0);
|
||||
// If the buffer was lost, restore and retry lock.
|
||||
if (DSERR_BUFFERLOST == res) {
|
||||
IDirectSoundBuffer_Restore(p->hdsbuf);
|
||||
res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1,
|
||||
&dwBytes1, &lpvPtr2, &dwBytes2, 0);
|
||||
}
|
||||
|
||||
|
||||
if (SUCCEEDED(res)) {
|
||||
memcpy(lpvPtr1, data, dwBytes1);
|
||||
if (NULL != lpvPtr2)
|
||||
memcpy(lpvPtr2, data + dwBytes1, dwBytes2);
|
||||
p->write_offset += dwBytes1 + dwBytes2;
|
||||
if (p->write_offset >= p->buffer_size)
|
||||
p->write_offset = dwBytes2;
|
||||
|
||||
// Release the data back to DirectSound.
|
||||
res = IDirectSoundBuffer_Unlock(p->hdsbuf, lpvPtr1, dwBytes1, lpvPtr2,
|
||||
dwBytes2);
|
||||
if (SUCCEEDED(res)) {
|
||||
// Success.
|
||||
DWORD status;
|
||||
IDirectSoundBuffer_GetStatus(p->hdsbuf, &status);
|
||||
if (!(status & DSBSTATUS_PLAYING))
|
||||
res = IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING);
|
||||
return dwBytes1 + dwBytes2;
|
||||
}
|
||||
}
|
||||
// Lock, Unlock, or Restore failed.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
/**
|
||||
\brief handle control commands
|
||||
\param cmd command
|
||||
\param arg argument
|
||||
\return CONTROL_OK or CONTROL_UNKNOWN in case the command is not supported
|
||||
*/
|
||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
DWORD volume;
|
||||
switch (cmd) {
|
||||
case AOCONTROL_GET_VOLUME: {
|
||||
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
||||
vol->left = vol->right = p->audio_volume;
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case AOCONTROL_SET_VOLUME: {
|
||||
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
||||
volume = p->audio_volume = vol->right;
|
||||
if (volume < 1)
|
||||
volume = 1;
|
||||
volume = (DWORD)(log10(volume) * 5000.0) - 10000;
|
||||
IDirectSoundBuffer_SetVolume(p->hdsbuf, volume);
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case AOCONTROL_HAS_SOFT_VOLUME:
|
||||
return CONTROL_TRUE;
|
||||
}
|
||||
return CONTROL_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief setup sound device
|
||||
\param rate samplerate
|
||||
\param channels number of channels
|
||||
\param format format
|
||||
\param flags unused
|
||||
\return 0=success -1=fail
|
||||
*/
|
||||
static int init(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int res;
|
||||
|
||||
if (!InitDirectSound(ao))
|
||||
return -1;
|
||||
|
||||
p->audio_volume = 100;
|
||||
|
||||
// ok, now create the buffers
|
||||
WAVEFORMATEXTENSIBLE wformat;
|
||||
DSBUFFERDESC dsbpridesc;
|
||||
DSBUFFERDESC dsbdesc;
|
||||
int format = af_fmt_from_planar(ao->format);
|
||||
int rate = ao->samplerate;
|
||||
|
||||
if (!af_fmt_is_spdif(format)) {
|
||||
struct mp_chmap_sel sel = {0};
|
||||
mp_chmap_sel_add_waveext(&sel);
|
||||
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
|
||||
return -1;
|
||||
}
|
||||
switch (format) {
|
||||
case AF_FORMAT_S24:
|
||||
case AF_FORMAT_S16:
|
||||
case AF_FORMAT_U8:
|
||||
break;
|
||||
default:
|
||||
if (af_fmt_is_spdif(format))
|
||||
break;
|
||||
MP_VERBOSE(ao, "format %s not supported defaulting to Signed 16-bit Little-Endian\n",
|
||||
af_fmt_to_str(format));
|
||||
format = AF_FORMAT_S16;
|
||||
}
|
||||
//set our audio parameters
|
||||
ao->samplerate = rate;
|
||||
ao->format = format;
|
||||
ao->bps = ao->channels.num * rate * af_fmt_to_bytes(format);
|
||||
int buffersize = ao->bps * p->cfg_buffersize / 1000;
|
||||
MP_VERBOSE(ao, "Samplerate:%iHz Channels:%i Format:%s\n", rate,
|
||||
ao->channels.num, af_fmt_to_str(format));
|
||||
MP_VERBOSE(ao, "Buffersize:%d bytes (%f msec)\n",
|
||||
buffersize, buffersize * 1000.0 / ao->bps);
|
||||
|
||||
//fill waveformatex
|
||||
ZeroMemory(&wformat, sizeof(WAVEFORMATEXTENSIBLE));
|
||||
wformat.Format.cbSize = (ao->channels.num > 2)
|
||||
? sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) : 0;
|
||||
wformat.Format.nChannels = ao->channels.num;
|
||||
wformat.Format.nSamplesPerSec = rate;
|
||||
if (af_fmt_is_spdif(format)) {
|
||||
// Whether it also works with e.g. DTS is unknown, but probably does.
|
||||
wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
|
||||
wformat.Format.wBitsPerSample = 16;
|
||||
wformat.Format.nBlockAlign = 4;
|
||||
} else {
|
||||
wformat.Format.wFormatTag = (ao->channels.num > 2)
|
||||
? WAVE_FORMAT_EXTENSIBLE : WAVE_FORMAT_PCM;
|
||||
int bps = af_fmt_to_bytes(format);
|
||||
wformat.Format.wBitsPerSample = bps * 8;
|
||||
wformat.Format.nBlockAlign = wformat.Format.nChannels * bps;
|
||||
}
|
||||
|
||||
// fill in primary sound buffer descriptor
|
||||
memset(&dsbpridesc, 0, sizeof(DSBUFFERDESC));
|
||||
dsbpridesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbpridesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||
dsbpridesc.dwBufferBytes = 0;
|
||||
dsbpridesc.lpwfxFormat = NULL;
|
||||
|
||||
// fill in the secondary sound buffer (=stream buffer) descriptor
|
||||
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
|
||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 /** Better position accuracy */
|
||||
| DSBCAPS_GLOBALFOCUS /** Allows background playing */
|
||||
| DSBCAPS_CTRLVOLUME; /** volume control enabled */
|
||||
|
||||
if (ao->channels.num > 2) {
|
||||
wformat.dwChannelMask = mp_chmap_to_waveext(&ao->channels);
|
||||
wformat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
wformat.Samples.wValidBitsPerSample = wformat.Format.wBitsPerSample;
|
||||
// Needed for 5.1 on emu101k - shit soundblaster
|
||||
dsbdesc.dwFlags |= DSBCAPS_LOCHARDWARE;
|
||||
}
|
||||
wformat.Format.nAvgBytesPerSec = wformat.Format.nSamplesPerSec *
|
||||
wformat.Format.nBlockAlign;
|
||||
|
||||
dsbdesc.dwBufferBytes = buffersize;
|
||||
dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat;
|
||||
p->buffer_size = dsbdesc.dwBufferBytes;
|
||||
p->write_offset = 0;
|
||||
p->min_free_space = wformat.Format.nBlockAlign;
|
||||
p->outburst = wformat.Format.nBlockAlign * 512;
|
||||
|
||||
// create primary buffer and set its format
|
||||
|
||||
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbpridesc, &p->hdspribuf, NULL);
|
||||
if (res != DS_OK) {
|
||||
UninitDirectSound(ao);
|
||||
MP_ERR(ao, "cannot create primary buffer (%s)\n", dserr2str(res));
|
||||
return -1;
|
||||
}
|
||||
res = IDirectSoundBuffer_SetFormat(p->hdspribuf, (WAVEFORMATEX *)&wformat);
|
||||
if (res != DS_OK) {
|
||||
MP_WARN(ao, "cannot set primary buffer format (%s), using "
|
||||
"standard setting (bad quality)", dserr2str(res));
|
||||
}
|
||||
|
||||
MP_VERBOSE(ao, "primary buffer created\n");
|
||||
|
||||
// now create the stream buffer
|
||||
|
||||
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbdesc, &p->hdsbuf, NULL);
|
||||
if (res != DS_OK) {
|
||||
if (dsbdesc.dwFlags & DSBCAPS_LOCHARDWARE) {
|
||||
// Try without DSBCAPS_LOCHARDWARE
|
||||
dsbdesc.dwFlags &= ~DSBCAPS_LOCHARDWARE;
|
||||
res = IDirectSound_CreateSoundBuffer(p->hds, &dsbdesc, &p->hdsbuf, NULL);
|
||||
}
|
||||
if (res != DS_OK) {
|
||||
UninitDirectSound(ao);
|
||||
MP_ERR(ao, "cannot create secondary (stream)buffer (%s)\n",
|
||||
dserr2str(res));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
MP_VERBOSE(ao, "secondary (stream)buffer created\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief stop playing and empty buffers (for seeking/pause)
|
||||
*/
|
||||
static void reset(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
IDirectSoundBuffer_Stop(p->hdsbuf);
|
||||
// reset directsound buffer
|
||||
IDirectSoundBuffer_SetCurrentPosition(p->hdsbuf, 0);
|
||||
p->write_offset = 0;
|
||||
p->underrun_check = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief stop playing, keep buffers (for pause)
|
||||
*/
|
||||
static void audio_pause(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
IDirectSoundBuffer_Stop(p->hdsbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief resume playing, after audio_pause()
|
||||
*/
|
||||
static void audio_resume(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief close audio device
|
||||
\param immed stop playback immediately
|
||||
*/
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
reset(ao);
|
||||
|
||||
DestroyBuffer(ao);
|
||||
UninitDirectSound(ao);
|
||||
}
|
||||
|
||||
// return exact number of free (safe to write) bytes
|
||||
static int check_free_buffer_size(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int space;
|
||||
DWORD play_offset;
|
||||
IDirectSoundBuffer_GetCurrentPosition(p->hdsbuf, &play_offset, NULL);
|
||||
space = p->buffer_size - (p->write_offset - play_offset);
|
||||
// | | <-- const --> | | |
|
||||
// buffer start play_cursor write_cursor p->write_offset buffer end
|
||||
// play_cursor is the actual position of the play cursor
|
||||
// write_cursor is the position after which it is assumed to be save to write data
|
||||
// p->write_offset is the position where we actually write the data to
|
||||
if (space > p->buffer_size)
|
||||
space -= p->buffer_size; // p->write_offset < play_offset
|
||||
// Check for buffer underruns. An underrun happens if DirectSound
|
||||
// started to play old data beyond the current p->write_offset. Detect this
|
||||
// by checking whether the free space shrinks, even though no data was
|
||||
// written (i.e. no write_buffer). Doesn't always work, but the only
|
||||
// reason we need this is to deal with the situation when playback ends,
|
||||
// and the buffer is only half-filled.
|
||||
if (space < p->underrun_check) {
|
||||
// there's no useful data in the buffers
|
||||
space = p->buffer_size;
|
||||
reset(ao);
|
||||
}
|
||||
p->underrun_check = space;
|
||||
return space;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief find out how many bytes can be written into the audio buffer without
|
||||
\return free space in bytes, has to return 0 if the buffer is almost full
|
||||
*/
|
||||
static int get_space(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
int space = check_free_buffer_size(ao);
|
||||
if (space < p->min_free_space)
|
||||
return 0;
|
||||
return (space - p->min_free_space) / p->outburst * p->outburst / ao->sstride;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief play 'len' bytes of 'data'
|
||||
\param data pointer to the data to play
|
||||
\param len size in bytes of the data buffer, gets rounded down to outburst*n
|
||||
\param flags currently unused
|
||||
\return number of played bytes
|
||||
*/
|
||||
static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
int len = samples * ao->sstride;
|
||||
|
||||
int space = check_free_buffer_size(ao);
|
||||
if (space < len)
|
||||
len = space;
|
||||
|
||||
if (!(flags & AOPLAY_FINAL_CHUNK))
|
||||
len = (len / p->outburst) * p->outburst;
|
||||
return write_buffer(ao, data[0], len) / ao->sstride;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief get the delay between the first and last sample in the buffer
|
||||
\return delay in seconds
|
||||
*/
|
||||
static double get_delay(struct ao *ao)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
int space = check_free_buffer_size(ao);
|
||||
return (p->buffer_size - space) / (double)ao->bps;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT struct priv
|
||||
|
||||
const struct ao_driver audio_out_dsound = {
|
||||
.description = "Windows DirectSound audio output",
|
||||
.name = "dsound",
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.control = control,
|
||||
.get_space = get_space,
|
||||
.play = play,
|
||||
.get_delay = get_delay,
|
||||
.pause = audio_pause,
|
||||
.resume = audio_resume,
|
||||
.reset = reset,
|
||||
.list_devs = list_devs,
|
||||
.priv_size = sizeof(struct priv),
|
||||
.options = (const struct m_option[]) {
|
||||
OPT_INT("device", cfg_device, 0, OPTDEF_INT(-1)),
|
||||
OPT_INTRANGE("buffersize", cfg_buffersize, 0, 1, 10000, OPTDEF_INT(200)),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
+1
-5
@@ -162,10 +162,6 @@ static int init(struct ao *ao)
|
||||
mp_chmap_sel_add_waveext(&sel);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
mp_chmap_sel_add_alsa_def(&sel);
|
||||
break;
|
||||
|
||||
default:
|
||||
mp_chmap_sel_add_any(&sel);
|
||||
}
|
||||
@@ -236,7 +232,7 @@ const struct ao_driver audio_out_jack = {
|
||||
OPT_FLAG("autostart", autostart, 0),
|
||||
OPT_FLAG("connect", connect, 0),
|
||||
OPT_CHOICE("std-channel-layout", stdlayout, 0,
|
||||
({"waveext", 0}, {"alsa", 1}, {"any", 2})),
|
||||
({"waveext", 0}, {"any", 1})),
|
||||
{0}
|
||||
},
|
||||
};
|
||||
+19
-21
@@ -31,7 +31,7 @@
|
||||
#include "common/common.h"
|
||||
#include "audio/format.h"
|
||||
#include "audio/fmt-conversion.h"
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
#include "common/msg.h"
|
||||
@@ -58,33 +58,28 @@ struct priv {
|
||||
bool shutdown;
|
||||
};
|
||||
|
||||
static void select_format(struct ao *ao, AVCodec *codec)
|
||||
static bool supports_format(AVCodec *codec, int format)
|
||||
{
|
||||
int best_score = INT_MIN;
|
||||
int best_format = 0;
|
||||
|
||||
// Check the encoder's list of supported formats.
|
||||
for (const enum AVSampleFormat *sampleformat = codec->sample_fmts;
|
||||
sampleformat && *sampleformat != AV_SAMPLE_FMT_NONE;
|
||||
++sampleformat)
|
||||
{
|
||||
int fmt = af_from_avformat(*sampleformat);
|
||||
if (!fmt) {
|
||||
MP_WARN(ao, "unsupported lavc format %s\n",
|
||||
av_get_sample_fmt_name(*sampleformat));
|
||||
continue;
|
||||
}
|
||||
int score = af_format_conversion_score(fmt, ao->format);
|
||||
if (score > best_score) {
|
||||
best_score = score;
|
||||
best_format = fmt;
|
||||
}
|
||||
if (af_from_avformat(*sampleformat) == format)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (best_format) {
|
||||
ao->format = best_format;
|
||||
} else {
|
||||
MP_ERR(ao, "sample format not found\n"); // shouldn't happen
|
||||
static void select_format(struct ao *ao, AVCodec *codec)
|
||||
{
|
||||
int formats[AF_FORMAT_COUNT];
|
||||
af_get_best_sample_formats(ao->format, formats);
|
||||
|
||||
for (int n = 0; formats[n]; n++) {
|
||||
if (supports_format(codec, formats[n])) {
|
||||
ao->format = formats[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +164,9 @@ static int init(struct ao *ao)
|
||||
|
||||
ao->untimed = true;
|
||||
|
||||
if (ao->channels.num > AV_NUM_DATA_POINTERS)
|
||||
goto fail;
|
||||
|
||||
pthread_mutex_unlock(&ao->encode_lavc_ctx->lock);
|
||||
return 0;
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "talloc.h"
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "osdep/timer.h"
|
||||
|
||||
+67
-29
@@ -44,8 +44,7 @@
|
||||
|
||||
#define MAX_CHANS MP_NUM_CHANNELS
|
||||
#define NUM_BUF 128
|
||||
#define CHUNK_SIZE 512
|
||||
#define CHUNK_SAMPLES (CHUNK_SIZE / 2)
|
||||
#define CHUNK_SAMPLES 256
|
||||
static ALuint buffers[MAX_CHANS][NUM_BUF];
|
||||
static ALuint sources[MAX_CHANS];
|
||||
|
||||
@@ -56,6 +55,8 @@ static struct ao *ao_data;
|
||||
|
||||
struct priv {
|
||||
char *cfg_device;
|
||||
ALenum al_format;
|
||||
int chunk_size;
|
||||
};
|
||||
|
||||
static void reset(struct ao *ao);
|
||||
@@ -117,22 +118,51 @@ struct speaker {
|
||||
};
|
||||
|
||||
static const struct speaker speaker_pos[] = {
|
||||
{MP_SPEAKER_ID_FL, {-1, 0, 0.5}},
|
||||
{MP_SPEAKER_ID_FR, { 1, 0, 0.5}},
|
||||
{MP_SPEAKER_ID_FC, { 0, 0, 1}},
|
||||
{MP_SPEAKER_ID_LFE, { 0, 0, 0.1}},
|
||||
{MP_SPEAKER_ID_BL, {-1, 0, -1}},
|
||||
{MP_SPEAKER_ID_BR, { 1, 0, -1}},
|
||||
{MP_SPEAKER_ID_BC, { 0, 0, -1}},
|
||||
{MP_SPEAKER_ID_SL, {-1, 0, 0}},
|
||||
{MP_SPEAKER_ID_SR, { 1, 0, 0}},
|
||||
{MP_SPEAKER_ID_FL, {-0.500, 0, -0.866}}, // -30 deg
|
||||
{MP_SPEAKER_ID_FR, { 0.500, 0, -0.866}}, // 30 deg
|
||||
{MP_SPEAKER_ID_FC, { 0, 0, -1}}, // 0 deg
|
||||
{MP_SPEAKER_ID_LFE, { 0, -1, 0}}, // below
|
||||
{MP_SPEAKER_ID_BL, {-0.609, 0, 0.793}}, // -142.5 deg
|
||||
{MP_SPEAKER_ID_BR, { 0.609, 0, 0.793}}, // 142.5 deg
|
||||
{MP_SPEAKER_ID_BC, { 0, 0, 1}}, // 180 deg
|
||||
{MP_SPEAKER_ID_SL, {-0.985, 0, 0.174}}, // -100 deg
|
||||
{MP_SPEAKER_ID_SR, { 0.985, 0, 0.174}}, // 100 deg
|
||||
{-1},
|
||||
};
|
||||
|
||||
static ALenum get_al_format(int format)
|
||||
{
|
||||
switch (format) {
|
||||
case AF_FORMAT_U8P: return AL_FORMAT_MONO8;
|
||||
case AF_FORMAT_S16P: return AL_FORMAT_MONO16;
|
||||
case AF_FORMAT_FLOATP:
|
||||
if (alIsExtensionPresent((ALchar*)"AL_EXT_float32") == AL_TRUE)
|
||||
return AL_FORMAT_MONO_FLOAT32;
|
||||
break;
|
||||
case AF_FORMAT_DOUBLEP:
|
||||
if (alIsExtensionPresent((ALchar*)"AL_EXT_double") == AL_TRUE)
|
||||
return AL_FORMAT_MONO_DOUBLE_EXT;
|
||||
break;
|
||||
}
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
// close audio device
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
ALCcontext *ctx = alcGetCurrentContext();
|
||||
ALCdevice *dev = alcGetContextsDevice(ctx);
|
||||
reset(ao);
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(ctx);
|
||||
alcCloseDevice(dev);
|
||||
ao_data = NULL;
|
||||
}
|
||||
|
||||
static int init(struct ao *ao)
|
||||
{
|
||||
float position[3] = {0, 0, 0};
|
||||
float direction[6] = {0, 0, 1, 0, -1, 0};
|
||||
float direction[6] = {0, 0, -1, 0, 1, 0};
|
||||
ALCdevice *dev = NULL;
|
||||
ALCcontext *ctx = NULL;
|
||||
ALCint freq = 0;
|
||||
@@ -184,23 +214,30 @@ static int init(struct ao *ao)
|
||||
alcGetIntegerv(dev, ALC_FREQUENCY, 1, &freq);
|
||||
if (alcGetError(dev) == ALC_NO_ERROR && freq)
|
||||
ao->samplerate = freq;
|
||||
ao->format = AF_FORMAT_S16P;
|
||||
|
||||
p->al_format = AL_FALSE;
|
||||
int try_formats[AF_FORMAT_COUNT];
|
||||
af_get_best_sample_formats(ao->format, try_formats);
|
||||
for (int n = 0; try_formats[n]; n++) {
|
||||
p->al_format = get_al_format(try_formats[n]);
|
||||
if (p->al_format != AL_FALSE) {
|
||||
ao->format = try_formats[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->al_format == AL_FALSE) {
|
||||
MP_FATAL(ao, "Can't find appropriate sample format.\n");
|
||||
uninit(ao);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
p->chunk_size = CHUNK_SAMPLES * af_fmt_to_bytes(ao->format);
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
// close audio device
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
ALCcontext *ctx = alcGetCurrentContext();
|
||||
ALCdevice *dev = alcGetContextsDevice(ctx);
|
||||
reset(ao);
|
||||
alcMakeContextCurrent(NULL);
|
||||
alcDestroyContext(ctx);
|
||||
alcCloseDevice(dev);
|
||||
ao_data = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void drain(struct ao *ao)
|
||||
@@ -274,14 +311,15 @@ static int get_space(struct ao *ao)
|
||||
*/
|
||||
static int play(struct ao *ao, void **data, int samples, int flags)
|
||||
{
|
||||
struct priv *p = ao->priv;
|
||||
ALint state;
|
||||
int num = samples / CHUNK_SAMPLES;
|
||||
for (int i = 0; i < num; i++) {
|
||||
for (int ch = 0; ch < ao->channels.num; ch++) {
|
||||
int16_t *d = data[ch];
|
||||
d += i * CHUNK_SAMPLES;
|
||||
alBufferData(buffers[ch][cur_buf[ch]], AL_FORMAT_MONO16, d,
|
||||
CHUNK_SIZE, ao->samplerate);
|
||||
char *d = data[ch];
|
||||
d += i * p->chunk_size;
|
||||
alBufferData(buffers[ch][cur_buf[ch]], p->al_format, d,
|
||||
p->chunk_size, ao->samplerate);
|
||||
alSourceQueueBuffers(sources[ch], 1, &buffers[ch][cur_buf[ch]]);
|
||||
cur_buf[ch] = (cur_buf[ch] + 1) % NUM_BUF;
|
||||
}
|
||||
|
||||
Loaded 100 of 423 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user