Compare commits
717 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
03bda44689 | ||
![]() |
8e8dc210cd | ||
![]() |
3af977d4d6 | ||
![]() |
cb0d255e2f | ||
![]() |
d2ceca6e8b | ||
![]() |
e8411c3b6d | ||
![]() |
3d5c38ca7d | ||
![]() |
8713b8e3fb | ||
![]() |
714dd84f20 | ||
![]() |
ebd74c42a2 | ||
![]() |
0597f05237 | ||
![]() |
227ac71a60 | ||
![]() |
d4e85004ec | ||
![]() |
514917bf1c | ||
![]() |
9ae26ef9c3 | ||
![]() |
b9be91c03d | ||
![]() |
d844179141 | ||
![]() |
707cfea374 | ||
![]() |
ebefc92a3d | ||
![]() |
11b3462aa3 | ||
![]() |
2340ce6954 | ||
![]() |
1f5678c5e4 | ||
![]() |
9a2387cfb1 | ||
![]() |
696a74e815 | ||
![]() |
3938b67621 | ||
![]() |
eb89e1b98d | ||
![]() |
05de372350 | ||
![]() |
b5f92f9603 | ||
![]() |
42a8d32697 | ||
![]() |
945a1b7ab9 | ||
![]() |
cf7bb6ceb1 | ||
![]() |
5f390ee944 | ||
![]() |
b24e68c9c3 | ||
![]() |
353ff5b4eb | ||
![]() |
47c23f9392 | ||
![]() |
d51e0dd9b4 | ||
![]() |
f30bd7c215 | ||
![]() |
e459c80fdd | ||
![]() |
15f122316e | ||
![]() |
b546b7a029 | ||
![]() |
8f596a4599 | ||
![]() |
eea1c5daa0 | ||
![]() |
2880de35b5 | ||
![]() |
0143eb9109 | ||
![]() |
93fe53da91 | ||
![]() |
88ec8021ce | ||
![]() |
8130449f32 | ||
![]() |
f741c39752 | ||
![]() |
af1bf7f277 | ||
![]() |
e770488b50 | ||
![]() |
6294d84dca | ||
![]() |
a68d4f55de | ||
![]() |
fdcdfb36b7 | ||
![]() |
238360665b | ||
![]() |
10b8ae5b10 | ||
![]() |
63b38d4a91 | ||
![]() |
260f37ee4d | ||
![]() |
da32e3c398 | ||
![]() |
6e3830cca2 | ||
![]() |
6a35680195 | ||
![]() |
cb29eb144b | ||
![]() |
2ce46a959c | ||
![]() |
8ca0d74d59 | ||
![]() |
1552b850db | ||
![]() |
47e18e2e03 | ||
![]() |
0162ad1a59 | ||
![]() |
fa73d13678 | ||
![]() |
8401ed651b | ||
![]() |
fcaf78f5f9 | ||
![]() |
8e5a021512 | ||
![]() |
a23748a804 | ||
![]() |
6961f9f9f4 | ||
![]() |
11dfd2a74a | ||
![]() |
f6c1fdba22 | ||
![]() |
f294748cbc | ||
![]() |
40e6c148f5 | ||
![]() |
9081b4dddd | ||
![]() |
58e2d529b3 | ||
![]() |
b9550ea116 | ||
![]() |
58bdec57fa | ||
![]() |
7434225ed1 | ||
![]() |
c9f17afe4e | ||
![]() |
6d33c8ec84 | ||
![]() |
238532700e | ||
![]() |
ed9ab30f4c | ||
![]() |
1fabe4ae8c | ||
![]() |
4ccde2d356 | ||
![]() |
fb487e2f66 | ||
![]() |
be9074debc | ||
![]() |
fa29e89d41 | ||
![]() |
f6cb3827df | ||
![]() |
c40631baf7 | ||
![]() |
ce364088ef | ||
![]() |
ca14a2d0e4 | ||
![]() |
b77819afbc | ||
![]() |
dccac759d3 | ||
![]() |
85b8b16917 | ||
![]() |
d946e4c1bc | ||
![]() |
0c5e6c542f | ||
![]() |
d21bf0d27b | ||
![]() |
03562c44c0 | ||
![]() |
ee21d270f8 | ||
![]() |
9f7119b7fe | ||
![]() |
d375d6395c | ||
![]() |
b1432e905d | ||
![]() |
1bccf68cae | ||
![]() |
2eb15cdeef | ||
![]() |
b701e26a4e | ||
![]() |
ea1806ce65 | ||
![]() |
ff409c7d80 | ||
![]() |
c9be276f8b | ||
![]() |
d8e89a3726 | ||
![]() |
7e8d27c851 | ||
![]() |
7fd6c9fb49 | ||
![]() |
175b53d051 | ||
![]() |
7f604a048e | ||
![]() |
7e513d85e8 | ||
![]() |
b6a0f5cde8 | ||
![]() |
1147d39bca | ||
![]() |
30e58e65e5 | ||
![]() |
af40847681 | ||
![]() |
fc53a09909 | ||
![]() |
4c1e4bc6af | ||
![]() |
c6f2ad9f94 | ||
![]() |
cf4099161a | ||
![]() |
d791e8c990 | ||
![]() |
f1a2364ceb | ||
![]() |
b00444c0bb | ||
![]() |
29b3ca743d | ||
![]() |
a32e45df82 | ||
![]() |
7a2254ab26 | ||
![]() |
cb95c1935f | ||
![]() |
26e1bccec6 | ||
![]() |
d891fc9181 | ||
![]() |
50169747db | ||
![]() |
ff5647b253 | ||
![]() |
0c58c165ab | ||
![]() |
694c3a13c9 | ||
![]() |
b0b02a2101 | ||
![]() |
51231fa6f6 | ||
![]() |
c6a4083c29 | ||
![]() |
1997487f67 | ||
![]() |
aeccfca268 | ||
![]() |
15d96c605b | ||
![]() |
67c3e3de55 | ||
![]() |
8b0880ff1b | ||
![]() |
f1f06710c4 | ||
![]() |
993c2a256d | ||
![]() |
c9fef27deb | ||
![]() |
460b948283 | ||
![]() |
798c715f4f | ||
![]() |
aa2a3ca27a | ||
![]() |
8883b5f85b | ||
![]() |
b4d72f901c | ||
![]() |
7c70cee29c | ||
![]() |
13fd80837f | ||
![]() |
f1a7bfea41 | ||
![]() |
3e3805b7fa | ||
![]() |
8ba514117b | ||
![]() |
675cf1cded | ||
![]() |
0c1a15db46 | ||
![]() |
d2a065437a | ||
![]() |
08dde7567d | ||
![]() |
cb8180885f | ||
![]() |
e2781db62a | ||
![]() |
9ac7d8f85d | ||
![]() |
fd856693de | ||
![]() |
a5c3f596d1 | ||
![]() |
ee3ce73bfb | ||
![]() |
3994eebb1e | ||
![]() |
82b44665e9 | ||
![]() |
35bf91c5b5 | ||
![]() |
c06f8bac20 | ||
![]() |
af74599e66 | ||
![]() |
74821341b9 | ||
![]() |
7adf4a92a1 | ||
![]() |
e04f68f7c5 | ||
![]() |
10238ada6d | ||
![]() |
27f60e2b0b | ||
![]() |
62ed6da016 | ||
![]() |
bf7c240a50 | ||
![]() |
03bfd8419f | ||
![]() |
3cc8d9bc1f | ||
![]() |
299c5dcfb0 | ||
![]() |
44079902c4 | ||
![]() |
a1b4d42d31 | ||
![]() |
f728782c0d | ||
![]() |
c85e5f13f6 | ||
![]() |
f1476459b7 | ||
![]() |
b5275ca1a8 | ||
![]() |
3485a07977 | ||
![]() |
d9c82cea11 | ||
![]() |
4b24eb1a03 | ||
![]() |
969028870c | ||
![]() |
9f9e773881 | ||
![]() |
10d48fe6d3 | ||
![]() |
af9799790d | ||
![]() |
6fa9741357 | ||
![]() |
bb26a88193 | ||
![]() |
55a4228ac2 | ||
![]() |
3ae81880e1 | ||
![]() |
8575f5362f | ||
![]() |
539d255871 | ||
![]() |
e38c62fe0c | ||
![]() |
1017b5914c | ||
![]() |
9f47f95e70 | ||
![]() |
9aa22918c2 | ||
![]() |
9b89824f20 | ||
![]() |
f479c17894 | ||
![]() |
1203e92181 | ||
![]() |
c693ccb89a | ||
![]() |
7e34379897 | ||
![]() |
ce795ac0f5 | ||
![]() |
5ea2a8d43e | ||
![]() |
3ada932202 | ||
![]() |
adb784ad86 | ||
![]() |
4de4eb60a1 | ||
![]() |
a0866c7129 | ||
![]() |
65830277d2 | ||
![]() |
5ae7ed3aa4 | ||
![]() |
61057f4604 | ||
![]() |
d149c14a22 | ||
![]() |
5bbee02ae0 | ||
![]() |
f53a5332b0 | ||
![]() |
e361fde8b0 | ||
![]() |
1d7a453dcf | ||
![]() |
481e55eba7 | ||
![]() |
03457cabd6 | ||
![]() |
0358a099f8 | ||
![]() |
2656036757 | ||
![]() |
f9f2591beb | ||
![]() |
cbf51c4d36 | ||
![]() |
26221a54ec | ||
![]() |
7c214e313c | ||
![]() |
7b337b1229 | ||
![]() |
51ff11647f | ||
![]() |
35f9a0896e | ||
![]() |
cdc47c4813 | ||
![]() |
e776a1e8f3 | ||
![]() |
d6d2617d07 | ||
![]() |
0e8ae6d10c | ||
![]() |
24a8dfd37b | ||
![]() |
a8f6d93071 | ||
![]() |
ffa83bcc49 | ||
![]() |
819541ff83 | ||
![]() |
c5c7e3e6f7 | ||
![]() |
5e7a5dd70b | ||
![]() |
f194f2be41 | ||
![]() |
343c87ac19 | ||
![]() |
12479588d7 | ||
![]() |
3e089e8f71 | ||
![]() |
5dcc179924 | ||
![]() |
848af79dec | ||
![]() |
50ff83e3af | ||
![]() |
2d7f139155 | ||
![]() |
b589b8a704 | ||
![]() |
5bd291e265 | ||
![]() |
bdb975ab69 | ||
![]() |
3f7d89034b | ||
![]() |
b8eaf47917 | ||
![]() |
718a2ddcb8 | ||
![]() |
bd405475ce | ||
![]() |
56eded8bc7 | ||
![]() |
f401e60063 | ||
![]() |
7f174cec8b | ||
![]() |
a3f8c6a427 | ||
![]() |
4c17e20ff0 | ||
![]() |
6960372475 | ||
![]() |
5bce35d958 | ||
![]() |
8e72a8d1c2 | ||
![]() |
a4b705b4cb | ||
![]() |
802c4f5231 | ||
![]() |
6636dd551f | ||
![]() |
8ffdcd04c4 | ||
![]() |
de32de679b | ||
![]() |
311583e779 | ||
![]() |
1a5a6ac01b | ||
![]() |
4bc7c1ba8e | ||
![]() |
0efb4ff86c | ||
![]() |
f0bb0aaaa7 | ||
![]() |
eb3330b050 | ||
![]() |
e31e66948d | ||
![]() |
835bc39b26 | ||
![]() |
bb81b2b2e0 | ||
![]() |
58287d3b10 | ||
![]() |
2a7bdbf67e | ||
![]() |
653cdf42ee | ||
![]() |
829e43017f | ||
![]() |
8d14e1d64e | ||
![]() |
5da68aff96 | ||
![]() |
55aedd679a | ||
![]() |
af26185bdc | ||
![]() |
af1fb1d467 | ||
![]() |
a9fc88ea93 | ||
![]() |
23e4284160 | ||
![]() |
42c7ed49a9 | ||
![]() |
494f2d4f9e | ||
![]() |
9597807ab1 | ||
![]() |
99fe4c577f | ||
![]() |
98e1f0a2db | ||
![]() |
3ee5458aa8 | ||
![]() |
99f953b3fe | ||
![]() |
9b9aee27f4 | ||
![]() |
7e350b7ddd | ||
![]() |
fc4d11ec9b | ||
![]() |
f06e39fe6b | ||
![]() |
fd2ba1807e | ||
![]() |
3ac156b707 | ||
![]() |
09ace619d6 | ||
![]() |
145de32896 | ||
![]() |
812955a12b | ||
![]() |
a63e83cd4b | ||
![]() |
c10f3fed25 | ||
![]() |
04d2f9ace3 | ||
![]() |
10f384e4f5 | ||
![]() |
78aa2ed620 | ||
![]() |
ad1223d6bc | ||
![]() |
a89868d714 | ||
![]() |
607863acae | ||
![]() |
2ff935a060 | ||
![]() |
2e4c649b3e | ||
![]() |
60701469ab | ||
![]() |
4d60ab62e0 | ||
![]() |
8bd27a167b | ||
![]() |
17e7edf75b | ||
![]() |
a6a8f66608 | ||
![]() |
b62704891d | ||
![]() |
0c8c6b4419 | ||
![]() |
97b6916f93 | ||
![]() |
ce1dacb435 | ||
![]() |
78dc022f6f | ||
![]() |
5379c5184b | ||
![]() |
4d90550cf9 | ||
![]() |
bacf5db196 | ||
![]() |
5358f1b507 | ||
![]() |
de75bc01cd | ||
![]() |
0b0f1cd44e | ||
![]() |
00516b5491 | ||
![]() |
3706c22992 | ||
![]() |
eac1c3f384 | ||
![]() |
163196562f | ||
![]() |
2e12af4587 | ||
![]() |
20c8f17629 | ||
![]() |
c8c93795e4 | ||
![]() |
38bd229af9 | ||
![]() |
fe8bc7d1ee | ||
![]() |
9f7a8b8f8f | ||
![]() |
9272aa4698 | ||
![]() |
aeca97a7b5 | ||
![]() |
b4c479a82a | ||
![]() |
9f883e75e6 | ||
![]() |
e47543eda5 | ||
![]() |
153deed18b | ||
![]() |
9eba02d5dd | ||
![]() |
557df77eab | ||
![]() |
f8a72f041c | ||
![]() |
9e505065b5 | ||
![]() |
eba112b4e3 | ||
![]() |
d411f07751 | ||
![]() |
8484351749 | ||
![]() |
01a58b439d | ||
![]() |
47bb4d888e | ||
![]() |
057f655dc6 | ||
![]() |
3bd0cd2677 | ||
![]() |
a4acb5b900 | ||
![]() |
c42fd4c6ee | ||
![]() |
3eee21406a | ||
![]() |
852ee0e0ad | ||
![]() |
ed2c15eadc | ||
![]() |
4ad0330b3d | ||
![]() |
9fde820d8e | ||
![]() |
b5e2ef771d | ||
![]() |
63e370b2cf | ||
![]() |
af225c41d4 | ||
![]() |
bf31271478 | ||
![]() |
8715ca0b82 | ||
![]() |
4d073ddac9 | ||
![]() |
007f3f4165 | ||
![]() |
6d2e3efd7c | ||
![]() |
fbbd6317e2 | ||
![]() |
87908de715 | ||
![]() |
de5e003369 | ||
![]() |
5c6aea5c31 | ||
![]() |
dfe0ba46bf | ||
![]() |
6bfa823b70 | ||
![]() |
701543a081 | ||
![]() |
580418bd55 | ||
![]() |
777bc81a91 | ||
![]() |
1e9e311e21 | ||
![]() |
0eb465f981 | ||
![]() |
b01e4d80c6 | ||
![]() |
68c9904669 | ||
![]() |
790606cfe9 | ||
![]() |
7b9bcd993c | ||
![]() |
aade60ab16 | ||
![]() |
3d91117df0 | ||
![]() |
9486e98712 | ||
![]() |
f3c7e604fa | ||
![]() |
4cb3efc206 | ||
![]() |
1e9d234c0c | ||
![]() |
8dc4b2c92e | ||
![]() |
251b4655be | ||
![]() |
1a65ce923a | ||
![]() |
b438451b7e | ||
![]() |
f1f8c0e558 | ||
![]() |
c93874c3a8 | ||
![]() |
e27fab0e6e | ||
![]() |
f743c4ece8 | ||
![]() |
86bf0a8871 | ||
![]() |
558d0b9483 | ||
![]() |
f78a3868fd | ||
![]() |
df2fc63543 | ||
![]() |
890c36d7ff | ||
![]() |
a2e7fd406c | ||
![]() |
7043e435dd | ||
![]() |
f7fcd40e63 | ||
![]() |
b7a4b4c145 | ||
![]() |
de1609bc2d | ||
![]() |
bd055c1768 | ||
![]() |
2892b01227 | ||
![]() |
e4a49ae561 | ||
![]() |
1feef46b90 | ||
![]() |
19382a2a10 | ||
![]() |
57588cda7b | ||
![]() |
e5162b3bc9 | ||
![]() |
ee9a440f49 | ||
![]() |
5582cfd0e4 | ||
![]() |
68c9f5cf64 | ||
![]() |
e36a005749 | ||
![]() |
9fb9419b02 | ||
![]() |
23633f4925 | ||
![]() |
be5fef6e0d | ||
![]() |
e3e5779a04 | ||
![]() |
46ecbef251 | ||
![]() |
528dd54d15 | ||
![]() |
ccdeedf22c | ||
![]() |
5c0dff6c60 | ||
![]() |
856bdcd5bc | ||
![]() |
a5fe40f728 | ||
![]() |
359bfa4c27 | ||
![]() |
bb263cc33a | ||
![]() |
f508bf7ff1 | ||
![]() |
898c51a016 | ||
![]() |
7fe88bc66c | ||
![]() |
333e708520 | ||
![]() |
0930a562e7 | ||
![]() |
fd85d03162 | ||
![]() |
26605efed7 | ||
![]() |
a32bbe54e4 | ||
![]() |
07bfb254c6 | ||
![]() |
9b89041a86 | ||
![]() |
09fcc2f865 | ||
![]() |
847d3225a8 | ||
![]() |
465742bbbe | ||
![]() |
40b8e7f168 | ||
![]() |
77783c7114 | ||
![]() |
979f97a861 | ||
![]() |
1b16302e54 | ||
![]() |
cbc6ded5b7 | ||
![]() |
93fbabb60f | ||
![]() |
a14ff5b256 | ||
![]() |
7c30ea5006 | ||
![]() |
e2d32ad18e | ||
![]() |
cea1769fb6 | ||
![]() |
082e3fd469 | ||
![]() |
747c320a19 | ||
![]() |
cf6a34b2a5 | ||
![]() |
6537f57782 | ||
![]() |
c92e37c207 | ||
![]() |
dd923878e8 | ||
![]() |
e897e0631a | ||
![]() |
b26c9f4e52 | ||
![]() |
937cedd7c0 | ||
![]() |
c5ba226c1b | ||
![]() |
cb31b6ca72 | ||
![]() |
b53db58ab7 | ||
![]() |
d0323b6234 | ||
![]() |
d502bd7410 | ||
![]() |
97e6099c0c | ||
![]() |
0b6adcf76b | ||
![]() |
116aa30db4 | ||
![]() |
e6cf47ee9e | ||
![]() |
f8602ef717 | ||
![]() |
a5bdec1c75 | ||
![]() |
dcbfba3bb6 | ||
![]() |
068bc633f2 | ||
![]() |
95275723ae | ||
![]() |
47cb05d783 | ||
![]() |
dc556d8bf7 | ||
![]() |
fbbe487b1c | ||
![]() |
7e9debb083 | ||
![]() |
256d615383 | ||
![]() |
9680f84a31 | ||
![]() |
505415b985 | ||
![]() |
d55f7a174d | ||
![]() |
cf738340d0 | ||
![]() |
861526bbd1 | ||
![]() |
7514868cb0 | ||
![]() |
4ec5c35850 | ||
![]() |
be71990da6 | ||
![]() |
99d82a07e7 | ||
![]() |
96f9b18497 | ||
![]() |
c03533ace2 | ||
![]() |
423ce8830e | ||
![]() |
5e46ad33eb | ||
![]() |
cbc1212499 | ||
![]() |
64867f3cb5 | ||
![]() |
d6a65735f9 | ||
![]() |
c4e2758eec | ||
![]() |
9f1c3cd5ad | ||
![]() |
160910acdb | ||
![]() |
c02d4c1a98 | ||
![]() |
6d2a92c467 | ||
![]() |
aa99cb15f6 | ||
![]() |
67a8a1c202 | ||
![]() |
8f3fe7c696 | ||
![]() |
64bcb5d350 | ||
![]() |
998a0389d3 | ||
![]() |
86eec54c94 | ||
![]() |
e7800543fe | ||
![]() |
fb1823e178 | ||
![]() |
a747cf8873 | ||
![]() |
002ca3e099 | ||
![]() |
fa6eef4210 | ||
![]() |
daa809fd9f | ||
![]() |
6124a7edbc | ||
![]() |
cb51d9ed25 | ||
![]() |
3f5824aa18 | ||
![]() |
a1ce54ce6a | ||
![]() |
ef81f55ec7 | ||
![]() |
c2c9b7297f | ||
![]() |
a1ac3c2d9c | ||
![]() |
ae72abf652 | ||
![]() |
9260710739 | ||
![]() |
b0558cd011 | ||
![]() |
0f84286677 | ||
![]() |
18900381e2 | ||
![]() |
944c47166d | ||
![]() |
86a816902f | ||
![]() |
8695d814e1 | ||
![]() |
ce74b92c09 | ||
![]() |
ba8d684622 | ||
![]() |
25ed0f05fd | ||
![]() |
b186a5d08c | ||
![]() |
af95e174c5 | ||
![]() |
93fc80f8bf | ||
![]() |
9aaca159bd | ||
![]() |
258eea3f2e | ||
![]() |
1c2bd6fe5f | ||
![]() |
73d5d7acb0 | ||
![]() |
80d73b4ada | ||
![]() |
b9892e1813 | ||
![]() |
d76480e6ba | ||
![]() |
33388299fb | ||
![]() |
d8dab6c3b8 | ||
![]() |
c8fb5d0f38 | ||
![]() |
5f7944a308 | ||
![]() |
f518fa6bee | ||
![]() |
51a23b0e95 | ||
![]() |
5c54fc6195 | ||
![]() |
2cdc976320 | ||
![]() |
efcfd50c9f | ||
![]() |
8bd0372937 | ||
![]() |
9761abffb6 | ||
![]() |
fbeae4a951 | ||
![]() |
88433979c2 | ||
![]() |
9d1b173aae | ||
![]() |
c7934c6c0b | ||
![]() |
04c29196ad | ||
![]() |
e2dcc4452d | ||
![]() |
24dc6b1a06 | ||
![]() |
d8e76a531c | ||
![]() |
2cfdf732ef | ||
![]() |
8268c1fea8 | ||
![]() |
d9a91dfb54 | ||
![]() |
5d2e4c918f | ||
![]() |
7e326d52a7 | ||
![]() |
71b8ef938c | ||
![]() |
5e6122ddad | ||
![]() |
1a0cdd18b0 | ||
![]() |
d33b0f7224 | ||
![]() |
6ddc1eb037 | ||
![]() |
ded74ab5d1 | ||
![]() |
f82e9deec2 | ||
![]() |
d0cabcc789 | ||
![]() |
dac0d4f354 | ||
![]() |
3f71c0c1b0 | ||
![]() |
ea56f6e5a7 | ||
![]() |
9ac3c6c2c6 | ||
![]() |
04c506e912 | ||
![]() |
bc4dc32b2a | ||
![]() |
01580c0955 | ||
![]() |
8eb7c2566c | ||
![]() |
042b8c2f06 | ||
![]() |
2fae70db2a | ||
![]() |
f08b0ff051 | ||
![]() |
f86b2e4f49 | ||
![]() |
d6373f1586 | ||
![]() |
2a39548181 | ||
![]() |
4c052a7b8b | ||
![]() |
30394adc44 | ||
![]() |
f908e3ce92 | ||
![]() |
683cbbb721 | ||
![]() |
cff8d01e15 | ||
![]() |
8c118207ea | ||
![]() |
406632d1ef | ||
![]() |
c320f9f5e9 | ||
![]() |
5fed47b94f | ||
![]() |
5a01ab0e62 | ||
![]() |
dbaf3f7b0b | ||
![]() |
4f6fbe47a9 | ||
![]() |
7251de3032 | ||
![]() |
5ba83e9091 | ||
![]() |
93fbf034c9 | ||
![]() |
10f77c165c | ||
![]() |
5a8dcc993d | ||
![]() |
aed12df7fe | ||
![]() |
7923a25fdd | ||
![]() |
510a96a211 | ||
![]() |
0af5a774eb | ||
![]() |
aaeef7fa0d | ||
![]() |
c340319559 | ||
![]() |
582aec4989 | ||
![]() |
2c23237cb4 | ||
![]() |
9eecf633f7 | ||
![]() |
7f451cb01f | ||
![]() |
a987750267 | ||
![]() |
2416eff5b9 | ||
![]() |
414c6bf094 | ||
![]() |
6f585f1e66 | ||
![]() |
85277ff936 | ||
![]() |
f544553c29 | ||
![]() |
51ee51b5eb | ||
![]() |
2e00dd4d62 | ||
![]() |
91138821fb | ||
![]() |
a4681d1043 | ||
![]() |
151c2ca8c7 | ||
![]() |
dafd8228bc | ||
![]() |
d9ab7c6292 | ||
![]() |
426715ccbd | ||
![]() |
a4e3bb0106 | ||
![]() |
cd2d8aca84 | ||
![]() |
e9d9fd1137 | ||
![]() |
e4bae0a140 | ||
![]() |
520c3d2303 | ||
![]() |
82a627c2c3 | ||
![]() |
0cb4887b83 | ||
![]() |
4a45535836 | ||
![]() |
4427e96bb1 | ||
![]() |
731f4bb6fd | ||
![]() |
898ce4d6e2 | ||
![]() |
93f80cf2cc | ||
![]() |
204c8798a8 | ||
![]() |
9767d7513c | ||
![]() |
d2b9da2f37 | ||
![]() |
395538e073 | ||
![]() |
a367ab657f | ||
![]() |
63235b8d41 | ||
![]() |
5353bd0285 | ||
![]() |
065996b984 | ||
![]() |
1ace588f4a | ||
![]() |
50a3442120 | ||
![]() |
008ae91bcc | ||
![]() |
82c3792a30 | ||
![]() |
1fa37f2bfa | ||
![]() |
d2d38531d6 | ||
![]() |
600bc1deba | ||
![]() |
77a2f4cbcf | ||
![]() |
7f8b55b560 | ||
![]() |
1ab4578c88 | ||
![]() |
52ab9e8984 | ||
![]() |
2922ab7e6f | ||
![]() |
5772cbb343 | ||
![]() |
46e1d05991 | ||
![]() |
a6f7fc8f3b | ||
![]() |
0662967d2b | ||
![]() |
ddeb6eeeb1 | ||
![]() |
5aac081110 | ||
![]() |
d8745de6ae | ||
![]() |
46fd6e4f2e | ||
![]() |
6cad940989 | ||
![]() |
c046890191 | ||
![]() |
d70bad04de | ||
![]() |
c8462bd17f | ||
![]() |
a3410b5a1f | ||
![]() |
43039f9386 | ||
![]() |
d0c4d61c8b | ||
![]() |
95db1624ef | ||
![]() |
b0b33ce148 | ||
![]() |
fa4192e31f | ||
![]() |
4c412580fd | ||
![]() |
8f558c3e10 | ||
![]() |
5ebdfbe893 | ||
![]() |
094a35aeef | ||
![]() |
62f9253781 | ||
![]() |
858864d350 | ||
![]() |
ba31b72f46 | ||
![]() |
7594868296 | ||
![]() |
09e391abd8 | ||
![]() |
b90816d94b | ||
![]() |
05015d03da | ||
![]() |
34ecaf6e88 | ||
![]() |
bb46240cbb | ||
![]() |
5ee539f69d | ||
![]() |
8ba3198549 | ||
![]() |
8355383802 | ||
![]() |
c0f7df9662 | ||
![]() |
fc6825ebb6 | ||
![]() |
f074618a9f | ||
![]() |
c6dce25967 | ||
![]() |
aba56c03b9 | ||
![]() |
2e06758479 | ||
![]() |
fc7071cb53 | ||
![]() |
2dfe3a7b4d | ||
![]() |
9d5f16f6fe | ||
![]() |
dc794d7096 | ||
![]() |
31a77177ff |
@@ -65,7 +65,7 @@ struct SwsContext *sws_opts;
|
|||||||
SwrContext *swr_opts;
|
SwrContext *swr_opts;
|
||||||
AVDictionary *format_opts, *codec_opts;
|
AVDictionary *format_opts, *codec_opts;
|
||||||
|
|
||||||
const int this_year = 2013;
|
const int this_year = 2014;
|
||||||
|
|
||||||
static FILE *report_file;
|
static FILE *report_file;
|
||||||
|
|
||||||
|
@@ -190,13 +190,13 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
|||||||
void show_help_children(const AVClass *class, int flags);
|
void show_help_children(const AVClass *class, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Per-avtool specific help handler. Implemented in each
|
* Per-fftool specific help handler. Implemented in each
|
||||||
* avtool, called by show_help().
|
* fftool, called by show_help().
|
||||||
*/
|
*/
|
||||||
void show_help_default(const char *opt, const char *arg);
|
void show_help_default(const char *opt, const char *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic -h handler common to all avtools.
|
* Generic -h handler common to all fftools.
|
||||||
*/
|
*/
|
||||||
int show_help(void *optctx, const char *opt, const char *arg);
|
int show_help(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
61
configure
vendored
61
configure
vendored
@@ -797,6 +797,13 @@ check_ld(){
|
|||||||
check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
|
check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_include(){
|
||||||
|
hdr=$1
|
||||||
|
test "${hdr%.h}" = "${hdr}" &&
|
||||||
|
echo "#include $hdr" ||
|
||||||
|
echo "#include <$hdr>"
|
||||||
|
}
|
||||||
|
|
||||||
check_code(){
|
check_code(){
|
||||||
log check_code "$@"
|
log check_code "$@"
|
||||||
check=$1
|
check=$1
|
||||||
@@ -805,7 +812,7 @@ check_code(){
|
|||||||
shift 3
|
shift 3
|
||||||
{
|
{
|
||||||
for hdr in $headers; do
|
for hdr in $headers; do
|
||||||
echo "#include <$hdr>"
|
print_include $hdr
|
||||||
done
|
done
|
||||||
echo "int main(void) { $code; return 0; }"
|
echo "int main(void) { $code; return 0; }"
|
||||||
} | check_$check "$@"
|
} | check_$check "$@"
|
||||||
@@ -889,7 +896,7 @@ check_func_headers(){
|
|||||||
shift 2
|
shift 2
|
||||||
{
|
{
|
||||||
for hdr in $headers; do
|
for hdr in $headers; do
|
||||||
echo "#include <$hdr>"
|
print_include $hdr
|
||||||
done
|
done
|
||||||
for func in $funcs; do
|
for func in $funcs; do
|
||||||
echo "long check_$func(void) { return (long) $func; }"
|
echo "long check_$func(void) { return (long) $func; }"
|
||||||
@@ -1053,6 +1060,26 @@ require_pkg_config(){
|
|||||||
add_extralibs $(get_safe ${pkg}_libs)
|
add_extralibs $(get_safe ${pkg}_libs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_libfreetype(){
|
||||||
|
log require_libfreetype "$@"
|
||||||
|
pkg="freetype2"
|
||||||
|
check_cmd $pkg_config --exists --print-errors $pkg \
|
||||||
|
|| die "ERROR: $pkg not found"
|
||||||
|
pkg_cflags=$($pkg_config --cflags $pkg)
|
||||||
|
pkg_libs=$($pkg_config --libs $pkg)
|
||||||
|
{
|
||||||
|
echo "#include <ft2build.h>"
|
||||||
|
echo "#include FT_FREETYPE_H"
|
||||||
|
echo "long check_func(void) { return (long) FT_Init_FreeType; }"
|
||||||
|
echo "int main(void) { return 0; }"
|
||||||
|
} | check_ld "cc" $pkg_cflags $pkg_libs \
|
||||||
|
&& set_safe ${pkg}_cflags $pkg_cflags \
|
||||||
|
&& set_safe ${pkg}_libs $pkg_libs \
|
||||||
|
|| die "ERROR: $pkg not found"
|
||||||
|
add_cflags $(get_safe ${pkg}_cflags)
|
||||||
|
add_extralibs $(get_safe ${pkg}_libs)
|
||||||
|
}
|
||||||
|
|
||||||
hostcc_o(){
|
hostcc_o(){
|
||||||
eval printf '%s\\n' $HOSTCC_O
|
eval printf '%s\\n' $HOSTCC_O
|
||||||
}
|
}
|
||||||
@@ -1735,7 +1762,7 @@ rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvi
|
|||||||
rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
|
rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
|
||||||
shorten_decoder_select="golomb"
|
shorten_decoder_select="golomb"
|
||||||
sipr_decoder_select="lsp"
|
sipr_decoder_select="lsp"
|
||||||
snow_decoder_select="dwt rangecoder"
|
snow_decoder_select="dwt rangecoder videodsp"
|
||||||
snow_encoder_select="aandcttables dwt error_resilience mpegvideoenc rangecoder"
|
snow_encoder_select="aandcttables dwt error_resilience mpegvideoenc rangecoder"
|
||||||
sonic_decoder_select="golomb"
|
sonic_decoder_select="golomb"
|
||||||
sonic_encoder_select="golomb"
|
sonic_encoder_select="golomb"
|
||||||
@@ -1781,14 +1808,15 @@ zmbv_encoder_select="zlib"
|
|||||||
|
|
||||||
# hardware accelerators
|
# hardware accelerators
|
||||||
crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
|
crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
|
||||||
|
dxva2_deps="dxva2api_h"
|
||||||
vaapi_deps="va_va_h"
|
vaapi_deps="va_va_h"
|
||||||
vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
|
vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
|
||||||
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
|
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
|
||||||
|
|
||||||
h263_vaapi_hwaccel_select="vaapi h263_decoder"
|
h263_vaapi_hwaccel_select="vaapi h263_decoder"
|
||||||
h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
|
h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
|
||||||
h264_dxva2_hwaccel_deps="dxva2api_h"
|
h264_dxva2_hwaccel_deps="dxva2"
|
||||||
h264_dxva2_hwaccel_select="dxva2 h264_decoder"
|
h264_dxva2_hwaccel_select="h264_decoder"
|
||||||
h264_vaapi_hwaccel_select="vaapi h264_decoder"
|
h264_vaapi_hwaccel_select="vaapi h264_decoder"
|
||||||
h264_vda_decoder_select="vda h264_parser h264_decoder"
|
h264_vda_decoder_select="vda h264_parser h264_decoder"
|
||||||
h264_vda_hwaccel_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
|
h264_vda_hwaccel_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
|
||||||
@@ -1798,8 +1826,8 @@ mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
|
|||||||
mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
|
mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
|
||||||
mpeg1_vdpau_hwaccel_select="vdpau mpeg1video_decoder"
|
mpeg1_vdpau_hwaccel_select="vdpau mpeg1video_decoder"
|
||||||
mpeg2_crystalhd_decoder_select="crystalhd"
|
mpeg2_crystalhd_decoder_select="crystalhd"
|
||||||
mpeg2_dxva2_hwaccel_deps="dxva2api_h"
|
mpeg2_dxva2_hwaccel_deps="dxva2"
|
||||||
mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
|
mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
|
||||||
mpeg2_vdpau_hwaccel_select="vdpau mpeg2video_decoder"
|
mpeg2_vdpau_hwaccel_select="vdpau mpeg2video_decoder"
|
||||||
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
|
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
|
||||||
mpeg4_crystalhd_decoder_select="crystalhd"
|
mpeg4_crystalhd_decoder_select="crystalhd"
|
||||||
@@ -1807,8 +1835,8 @@ mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
|
|||||||
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
|
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
|
||||||
msmpeg4_crystalhd_decoder_select="crystalhd"
|
msmpeg4_crystalhd_decoder_select="crystalhd"
|
||||||
vc1_crystalhd_decoder_select="crystalhd"
|
vc1_crystalhd_decoder_select="crystalhd"
|
||||||
vc1_dxva2_hwaccel_deps="dxva2api_h"
|
vc1_dxva2_hwaccel_deps="dxva2"
|
||||||
vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
|
vc1_dxva2_hwaccel_select="vc1_decoder"
|
||||||
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
|
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
|
||||||
vc1_vdpau_decoder_select="vdpau vc1_decoder"
|
vc1_vdpau_decoder_select="vdpau vc1_decoder"
|
||||||
wmv3_crystalhd_decoder_select="crystalhd"
|
wmv3_crystalhd_decoder_select="crystalhd"
|
||||||
@@ -2099,6 +2127,9 @@ enable safe_bitstream_reader
|
|||||||
enable static
|
enable static
|
||||||
enable swscale_alpha
|
enable swscale_alpha
|
||||||
|
|
||||||
|
# By default, enable only those hwaccels that have no external dependencies.
|
||||||
|
enable dxva2 vdpau
|
||||||
|
|
||||||
# build settings
|
# build settings
|
||||||
SHFLAGS='-shared -Wl,-soname,$$(@F)'
|
SHFLAGS='-shared -Wl,-soname,$$(@F)'
|
||||||
FFSERVERLDFLAGS=-Wl,-E
|
FFSERVERLDFLAGS=-Wl,-E
|
||||||
@@ -2556,7 +2587,9 @@ probe_cc(){
|
|||||||
unset _depflags _DEPCMD _DEPFLAGS
|
unset _depflags _DEPCMD _DEPFLAGS
|
||||||
_flags_filter=echo
|
_flags_filter=echo
|
||||||
|
|
||||||
if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
|
if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
|
||||||
|
true # no-op to avoid reading stdin in following checks
|
||||||
|
elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
|
||||||
_type=llvm_gcc
|
_type=llvm_gcc
|
||||||
gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
|
gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
|
||||||
_ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
|
_ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
|
||||||
@@ -3102,6 +3135,10 @@ case "$arch" in
|
|||||||
check_64bit ppc ppc64 'sizeof(void *) > 4'
|
check_64bit ppc ppc64 'sizeof(void *) > 4'
|
||||||
spic=$shared
|
spic=$shared
|
||||||
;;
|
;;
|
||||||
|
s390)
|
||||||
|
check_64bit s390 s390x 'sizeof(void *) > 4'
|
||||||
|
spic=$shared
|
||||||
|
;;
|
||||||
sparc)
|
sparc)
|
||||||
check_64bit sparc sparc64 'sizeof(void *) > 4'
|
check_64bit sparc sparc64 'sizeof(void *) > 4'
|
||||||
spic=$shared
|
spic=$shared
|
||||||
@@ -3827,7 +3864,7 @@ enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_in
|
|||||||
enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
|
enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
|
||||||
enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
|
enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
|
||||||
enabled libass && require_pkg_config libass ass/ass.h ass_library_init
|
enabled libass && require_pkg_config libass ass/ass.h ass_library_init
|
||||||
enabled libbluray && require libbluray libbluray/bluray.h bd_open -lbluray
|
enabled libbluray && require_pkg_config libbluray libbluray/bluray.h bd_open
|
||||||
enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 &&
|
enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 &&
|
||||||
{ check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
|
{ check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
|
||||||
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
|
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
|
||||||
@@ -3836,7 +3873,7 @@ enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaa
|
|||||||
enabled libfdk_aac && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
|
enabled libfdk_aac && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
|
||||||
flite_libs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
|
flite_libs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
|
||||||
enabled libflite && require2 libflite "flite/flite.h" flite_init $flite_libs
|
enabled libflite && require2 libflite "flite/flite.h" flite_init $flite_libs
|
||||||
enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
|
enabled libfreetype && require_libfreetype
|
||||||
enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
|
enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
|
||||||
enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
|
enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
|
||||||
enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
|
enabled libmodplug && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
|
||||||
|
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
|||||||
# This could be handy for archiving the generated documentation or
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 1.1.4
|
PROJECT_NUMBER = 1.1.11
|
||||||
|
|
||||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
|
# With the PROJECT_LOGO tag one can specify an logo or icon that is included
|
||||||
# in the documentation. The maximum height of the logo should not exceed 55
|
# in the documentation. The maximum height of the logo should not exceed 55
|
||||||
|
@@ -60,6 +60,78 @@ This decoder generates wave patterns according to predefined sequences. Its
|
|||||||
use is purely internal and the format of the data it accepts is not publicly
|
use is purely internal and the format of the data it accepts is not publicly
|
||||||
documented.
|
documented.
|
||||||
|
|
||||||
|
@section libcelt
|
||||||
|
|
||||||
|
libcelt decoder wrapper
|
||||||
|
|
||||||
|
libcelt allows libavcodec to decode the Xiph CELT ultra-low delay audio codec.
|
||||||
|
Requires the presence of the libcelt headers and library during configuration.
|
||||||
|
You need to explicitly configure the build with @code{--enable-libcelt}.
|
||||||
|
|
||||||
|
@section libgsm
|
||||||
|
|
||||||
|
libgsm decoder wrapper
|
||||||
|
|
||||||
|
libgsm allows libavcodec to decode the GSM full rate audio codec. Requires
|
||||||
|
the presence of the libgsm headers and library during configuration. You need
|
||||||
|
to explicitly configure the build with @code{--enable-libgsm}.
|
||||||
|
|
||||||
|
This decoder supports both the ordinary GSM and the Microsoft variant.
|
||||||
|
|
||||||
|
@section libilbc
|
||||||
|
|
||||||
|
libilbc decoder wrapper
|
||||||
|
|
||||||
|
libilbc allows libavcodec to decode the Internet Low Bitrate Codec (iLBC)
|
||||||
|
audio codec. Requires the presence of the libilbc headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libilbc}.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
The following option is supported by the libilbc wrapper.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item enhance
|
||||||
|
|
||||||
|
Enable the enhancement of the decoded audio when set to 1. The default
|
||||||
|
value is 0 (disabled).
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section libopencore-amrnb
|
||||||
|
|
||||||
|
libopencore-amrnb decoder wrapper
|
||||||
|
|
||||||
|
libopencore-amrnb allows libavcodec to decode the Adaptive Multi-Rate
|
||||||
|
Narrowband audio codec. Using it requires the presence of the
|
||||||
|
libopencore-amrnb headers and library during configuration. You need to
|
||||||
|
explicitly configure the build with @code{--enable-libopencore-amrnb}.
|
||||||
|
|
||||||
|
An FFmpeg native decoder for AMR-NB exists, so users can decode AMR-NB
|
||||||
|
without this library.
|
||||||
|
|
||||||
|
@section libopencore-amrwb
|
||||||
|
|
||||||
|
libopencore-amrwb decoder wrapper.
|
||||||
|
|
||||||
|
libopencore-amrwb allows libavcodec to decode the Adaptive Multi-Rate
|
||||||
|
Wideband audio codec. Using it requires the presence of the
|
||||||
|
libopencore-amrwb headers and library during configuration. You need to
|
||||||
|
explicitly configure the build with @code{--enable-libopencore-amrwb}.
|
||||||
|
|
||||||
|
An FFmpeg native decoder for AMR-WB exists, so users can decode AMR-WB
|
||||||
|
without this library.
|
||||||
|
|
||||||
|
@section libopus
|
||||||
|
|
||||||
|
libopus decoder wrapper.
|
||||||
|
|
||||||
|
libopus allows libavcodec to decode the Opus Interactive Audio Codec.
|
||||||
|
Requires the presence of the libopus headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libopus}.
|
||||||
|
|
||||||
@c man end AUDIO DECODERS
|
@c man end AUDIO DECODERS
|
||||||
|
|
||||||
@chapter Subtitles Decoders
|
@chapter Subtitles Decoders
|
||||||
|
@@ -25,6 +25,95 @@ enabled encoders.
|
|||||||
A description of some of the currently available audio encoders
|
A description of some of the currently available audio encoders
|
||||||
follows.
|
follows.
|
||||||
|
|
||||||
|
@anchor{aacenc}
|
||||||
|
@section aac
|
||||||
|
|
||||||
|
Advanced Audio Coding (AAC) encoder.
|
||||||
|
|
||||||
|
This encoder is an experimental FFmpeg-native AAC encoder. Currently only the
|
||||||
|
low complexity (AAC-LC) profile is supported. To use this encoder, you must set
|
||||||
|
@option{strict} option to @samp{experimental} or lower.
|
||||||
|
|
||||||
|
As this encoder is experimental, unexpected behavior may exist from time to
|
||||||
|
time. For a more stable AAC encoder, see @ref{libvo-aacenc}. However, be warned
|
||||||
|
that it has a worse quality reported by some users.
|
||||||
|
|
||||||
|
@c Comment this out until somebody writes the respective documentation.
|
||||||
|
@c See also @ref{libfaac}, @ref{libaacplus}, and @ref{libfdk-aac-enc}.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item b
|
||||||
|
Set bit rate in bits/s. Setting this automatically activates constant bit rate
|
||||||
|
(CBR) mode.
|
||||||
|
|
||||||
|
@item q
|
||||||
|
Set quality for variable bit rate (VBR) mode. This option is valid only using
|
||||||
|
the @command{ffmpeg} command-line tool. For library interface users, use
|
||||||
|
@option{global_quality}.
|
||||||
|
|
||||||
|
@item stereo_mode
|
||||||
|
Set stereo encoding mode. Possible values:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item auto
|
||||||
|
Automatically selected by the encoder.
|
||||||
|
|
||||||
|
@item ms_off
|
||||||
|
Disable middle/side encoding. This is the default.
|
||||||
|
|
||||||
|
@item ms_force
|
||||||
|
Force middle/side encoding.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item aac_coder
|
||||||
|
Set AAC encoder coding method. Possible values:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item 0
|
||||||
|
FAAC-inspired method.
|
||||||
|
|
||||||
|
This method is a simplified reimplementation of the method used in FAAC, which
|
||||||
|
sets thresholds proportional to the band energies, and then decreases all the
|
||||||
|
thresholds with quantizer steps to find the appropriate quantization with
|
||||||
|
distortion below threshold band by band.
|
||||||
|
|
||||||
|
The quality of this method is comparable to the two loop searching method
|
||||||
|
descibed below, but somewhat a little better and slower.
|
||||||
|
|
||||||
|
@item 1
|
||||||
|
Average noise to mask ratio (ANMR) trellis-based solution.
|
||||||
|
|
||||||
|
This has a theoretic best quality out of all the coding methods, but at the
|
||||||
|
cost of the slowest speed.
|
||||||
|
|
||||||
|
@item 2
|
||||||
|
Two loop searching (TLS) method.
|
||||||
|
|
||||||
|
This method first sets quantizers depending on band thresholds and then tries
|
||||||
|
to find an optimal combination by adding or subtracting a specific value from
|
||||||
|
all quantizers and adjusting some individual quantizer a little.
|
||||||
|
|
||||||
|
This method produces similar quality with the FAAC method and is the default.
|
||||||
|
|
||||||
|
@item 3
|
||||||
|
Constant quantizer method.
|
||||||
|
|
||||||
|
This method sets a constant quantizer for all bands. This is the fastest of all
|
||||||
|
the methods, yet produces the worst quality.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@subsection Tips and Tricks
|
||||||
|
|
||||||
|
According to some reports
|
||||||
|
(e.g. @url{http://d.hatena.ne.jp/kamedo2/20120729/1343545890}), setting the
|
||||||
|
@option{cutoff} option to 15000 Hz greatly improves the quality of the output
|
||||||
|
quality. As a result, we encourage you to do the same.
|
||||||
|
|
||||||
@section ac3 and ac3_fixed
|
@section ac3 and ac3_fixed
|
||||||
|
|
||||||
AC-3 audio encoders.
|
AC-3 audio encoders.
|
||||||
@@ -412,6 +501,279 @@ Selected by Encoder (default)
|
|||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@section libmp3lame
|
||||||
|
|
||||||
|
LAME (Lame Ain't an MP3 Encoder) MP3 encoder wrapper
|
||||||
|
|
||||||
|
Requires the presence of the libmp3lame headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libmp3lame}.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
The following options are supported by the libmp3lame wrapper. The
|
||||||
|
@command{lame}-equivalent of the options are listed in parentheses.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item b (@emph{-b})
|
||||||
|
Set bitrate expressed in bits/s for CBR. LAME @code{bitrate} is
|
||||||
|
expressed in kilobits/s.
|
||||||
|
|
||||||
|
@item q (@emph{-V})
|
||||||
|
Set constant quality setting for VBR. This option is valid only
|
||||||
|
using the @command{ffmpeg} command-line tool. For library interface
|
||||||
|
users, use @option{global_quality}.
|
||||||
|
|
||||||
|
@item compression_level (@emph{-q})
|
||||||
|
Set algorithm quality. Valid arguments are integers in the 0-9 range,
|
||||||
|
with 0 meaning highest quality but slowest, and 9 meaning fastest
|
||||||
|
while producing the worst quality.
|
||||||
|
|
||||||
|
@item reservoir
|
||||||
|
Enable use of bit reservoir when set to 1. Default value is 1. LAME
|
||||||
|
has this enabled by default, but can be overriden by use
|
||||||
|
@option{--nores} option.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section libopencore-amrnb
|
||||||
|
|
||||||
|
OpenCORE Adaptive Multi-Rate Narrowband encoder.
|
||||||
|
|
||||||
|
Requires the presence of the libopencore-amrnb headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libopencore-amrnb --enable-version3}.
|
||||||
|
|
||||||
|
This is a mono-only encoder. Officially it only supports 8000Hz sample rate,
|
||||||
|
but you can override it by setting @option{strict} to @samp{unofficial} or
|
||||||
|
lower.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@item b
|
||||||
|
Set bitrate in bits per second. Only the following bitrates are supported,
|
||||||
|
otherwise libavcodec will round to the nearest valid bitrate.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item 4750
|
||||||
|
@item 5150
|
||||||
|
@item 5900
|
||||||
|
@item 6700
|
||||||
|
@item 7400
|
||||||
|
@item 7950
|
||||||
|
@item 10200
|
||||||
|
@item 12200
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item dtx
|
||||||
|
Allow discontinuous transmission (generate comfort noise) when set to 1. The
|
||||||
|
default value is 0 (disabled).
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section libtwolame
|
||||||
|
|
||||||
|
TwoLAME MP2 encoder wrapper
|
||||||
|
|
||||||
|
Requires the presence of the libtwolame headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libtwolame}.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
The following options are supported by the libtwolame wrapper. The
|
||||||
|
@command{twolame}-equivalent options follow the FFmpeg ones and are in
|
||||||
|
parentheses.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item b (@emph{-b})
|
||||||
|
Set bitrate expressed in bits/s for CBR. @command{twolame} @option{b}
|
||||||
|
option is expressed in kilobits/s. Default value is 128k.
|
||||||
|
|
||||||
|
@item q (@emph{-V})
|
||||||
|
Set quality for experimental VBR support. Maximum value range is
|
||||||
|
from -50 to 50, useful range is from -10 to 10. The higher the
|
||||||
|
value, the better the quality. This option is valid only using the
|
||||||
|
@command{ffmpeg} command-line tool. For library interface users,
|
||||||
|
use @option{global_quality}.
|
||||||
|
|
||||||
|
@item mode (@emph{--mode})
|
||||||
|
Set the mode of the resulting audio. Possible values:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item auto
|
||||||
|
Choose mode automatically based on the input. This is the default.
|
||||||
|
@item stereo
|
||||||
|
Stereo
|
||||||
|
@item joint_stereo
|
||||||
|
Joint stereo
|
||||||
|
@item dual_channel
|
||||||
|
Dual channel
|
||||||
|
@item mono
|
||||||
|
Mono
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item psymodel (@emph{--psyc-mode})
|
||||||
|
Set psychoacoustic model to use in encoding. The argument must be
|
||||||
|
an integer between -1 and 4, inclusive. The higher the value, the
|
||||||
|
better the quality. The default value is 3.
|
||||||
|
|
||||||
|
@item energy_levels (@emph{--energy})
|
||||||
|
Enable energy levels extensions when set to 1. The default value is
|
||||||
|
0 (disabled).
|
||||||
|
|
||||||
|
@item error_protection (@emph{--protect})
|
||||||
|
Enable CRC error protection when set to 1. The default value is 0
|
||||||
|
(disabled).
|
||||||
|
|
||||||
|
@item copyright (@emph{--copyright})
|
||||||
|
Set MPEG audio copyright flag when set to 1. The default value is 0
|
||||||
|
(disabled).
|
||||||
|
|
||||||
|
@item original (@emph{--original})
|
||||||
|
Set MPEG audio original flag when set to 1. The default value is 0
|
||||||
|
(disabled).
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@anchor{libvo-aacenc}
|
||||||
|
@section libvo-aacenc
|
||||||
|
|
||||||
|
VisualOn AAC encoder
|
||||||
|
|
||||||
|
Requires the presence of the libvo-aacenc headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libvo-aacenc --enable-version3}.
|
||||||
|
|
||||||
|
This encoder is considered to be worse than the
|
||||||
|
@ref{aacenc,,native experimental FFmpeg AAC encoder}, according to
|
||||||
|
multiple sources.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
The VisualOn AAC encoder only support encoding AAC-LC and up to 2
|
||||||
|
channels. It is also CBR-only.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@item b
|
||||||
|
Set bit rate in bits/s.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section libvo-amrwbenc
|
||||||
|
|
||||||
|
VisualOn Adaptive Multi-Rate Wideband encoder
|
||||||
|
|
||||||
|
Requires the presence of the libvo-amrwbenc headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libvo-amrwbenc --enable-version3}.
|
||||||
|
|
||||||
|
This is a mono-only encoder. Officially it only supports 16000Hz sample
|
||||||
|
rate, but you can override it by setting @option{strict} to
|
||||||
|
@samp{unofficial} or lower.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@item b
|
||||||
|
Set bitrate in bits/s. Only the following bitrates are supported, otherwise
|
||||||
|
libavcodec will round to the nearest valid bitrate.
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item 6600
|
||||||
|
@item 8850
|
||||||
|
@item 12650
|
||||||
|
@item 14250
|
||||||
|
@item 15850
|
||||||
|
@item 18250
|
||||||
|
@item 19850
|
||||||
|
@item 23050
|
||||||
|
@item 23850
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item dtx
|
||||||
|
Allow discontinuous transmission (generate comfort noise) when set to 1. The
|
||||||
|
default value is 0 (disabled).
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section libopus
|
||||||
|
|
||||||
|
libopus Opus Interactive Audio Codec encoder wrapper.
|
||||||
|
|
||||||
|
Requires the presence of the libopus headers and library during
|
||||||
|
configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libopus}.
|
||||||
|
|
||||||
|
@subsection Option Mapping
|
||||||
|
|
||||||
|
Most libopus options are modeled after the @command{opusenc} utility from
|
||||||
|
opus-tools. The following is an option mapping chart describing options
|
||||||
|
supported by the libopus wrapper, and their @command{opusenc}-equivalent
|
||||||
|
in parentheses.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@item b (@emph{bitrate})
|
||||||
|
Set the bit rate in bits/s. FFmpeg's @option{b} option is
|
||||||
|
expressed in bits/s, while @command{opusenc}'s @option{bitrate} in
|
||||||
|
kilobits/s.
|
||||||
|
|
||||||
|
@item vbr (@emph{vbr}, @emph{hard-cbr}, and @emph{cvbr})
|
||||||
|
Set VBR mode. The FFmpeg @option{vbr} option has the following
|
||||||
|
valid arguments, with the their @command{opusenc} equivalent options
|
||||||
|
in parentheses:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item off (@emph{hard-cbr})
|
||||||
|
Use constant bit rate encoding.
|
||||||
|
|
||||||
|
@item on (@emph{vbr})
|
||||||
|
Use variable bit rate encoding (the default).
|
||||||
|
|
||||||
|
@item constrained (@emph{cvbr})
|
||||||
|
Use constrained variable bit rate encoding.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item compression_level (@emph{comp})
|
||||||
|
Set encoding algorithm complexity. Valid options are integers in
|
||||||
|
the 0-10 range. 0 gives the fastest encodes but lower quality, while 10
|
||||||
|
gives the highest quality but slowest encoding. The default is 10.
|
||||||
|
|
||||||
|
@item frame_duration (@emph{framesize})
|
||||||
|
Set maximum frame size, or duration of a frame in milliseconds. The
|
||||||
|
argument must be exactly the following: 2.5, 5, 10, 20, 40, 60. Smaller
|
||||||
|
frame sizes achieve lower latency but less quality at a given bitrate.
|
||||||
|
Sizes greater than 20ms are only interesting at fairly low bitrates.
|
||||||
|
The default is 20ms.
|
||||||
|
|
||||||
|
@item packet_loss (@emph{expect-loss})
|
||||||
|
Set expected packet loss percentage. The default is 0.
|
||||||
|
|
||||||
|
@item application (N.A.)
|
||||||
|
Set intended application type. Valid options are listed below:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item voip
|
||||||
|
Favor improved speech intelligibility.
|
||||||
|
@item audio
|
||||||
|
Favor faithfulness to the input (the default).
|
||||||
|
@item lowdelay
|
||||||
|
Restrict to only the lowest delay modes.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item cutoff (N.A.)
|
||||||
|
Set cutoff bandwidth in Hz. The argument must be exactly one of the
|
||||||
|
following: 4000, 6000, 8000, 12000, or 20000, corresponding to
|
||||||
|
narrowband, mediumband, wideband, super wideband, and fullband
|
||||||
|
respectively. The default is 0 (cutoff disabled).
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@c man end AUDIO ENCODERS
|
@c man end AUDIO ENCODERS
|
||||||
|
|
||||||
@chapter Video Encoders
|
@chapter Video Encoders
|
||||||
@@ -633,4 +995,117 @@ ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
|
|||||||
For more information about libx264 and the supported options see:
|
For more information about libx264 and the supported options see:
|
||||||
@url{http://www.videolan.org/developers/x264.html}
|
@url{http://www.videolan.org/developers/x264.html}
|
||||||
|
|
||||||
|
@section libxvid
|
||||||
|
|
||||||
|
Xvid MPEG-4 Part 2 encoder wrapper.
|
||||||
|
|
||||||
|
This encoder requires the presence of the libxvidcore headers and library
|
||||||
|
during configuration. You need to explicitly configure the build with
|
||||||
|
@code{--enable-libxvid --enable-gpl}.
|
||||||
|
|
||||||
|
The native @code{mpeg4} encoder supports the MPEG-4 Part 2 format, so
|
||||||
|
users can encode to this format without this library.
|
||||||
|
|
||||||
|
@subsection Options
|
||||||
|
|
||||||
|
The following options are supported by the libxvid wrapper. Some of
|
||||||
|
the following options are listed but are not documented, and
|
||||||
|
correspond to shared codec options. See @ref{codec-options,,the Codec
|
||||||
|
Options chapter} for their documentation. The other shared options
|
||||||
|
which are not listed have no effect for the libxvid encoder.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item b
|
||||||
|
|
||||||
|
@item g
|
||||||
|
|
||||||
|
@item qmin
|
||||||
|
|
||||||
|
@item qmax
|
||||||
|
|
||||||
|
@item mpeg_quant
|
||||||
|
|
||||||
|
@item threads
|
||||||
|
|
||||||
|
@item bf
|
||||||
|
|
||||||
|
@item b_qfactor
|
||||||
|
|
||||||
|
@item b_qoffset
|
||||||
|
|
||||||
|
@item flags
|
||||||
|
Set specific encoding flags. Possible values:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
|
||||||
|
@item mv4
|
||||||
|
Use four motion vector by macroblock.
|
||||||
|
|
||||||
|
@item aic
|
||||||
|
Enable high quality AC prediction.
|
||||||
|
|
||||||
|
@item gray
|
||||||
|
Only encode grayscale.
|
||||||
|
|
||||||
|
@item gmc
|
||||||
|
Enable the use of global motion compensation (GMC).
|
||||||
|
|
||||||
|
@item qpel
|
||||||
|
Enable quarter-pixel motion compensation.
|
||||||
|
|
||||||
|
@item cgop
|
||||||
|
Enable closed GOP.
|
||||||
|
|
||||||
|
@item global_header
|
||||||
|
Place global headers in extradata instead of every keyframe.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item trellis
|
||||||
|
|
||||||
|
@item me_method
|
||||||
|
Set motion estimation method. Possible values in decreasing order of
|
||||||
|
speed and increasing order of quality:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item zero
|
||||||
|
Use no motion estimation (default).
|
||||||
|
|
||||||
|
@item phods
|
||||||
|
@item x1
|
||||||
|
@item log
|
||||||
|
Enable advanced diamond zonal search for 16x16 blocks and half-pixel
|
||||||
|
refinement for 16x16 blocks. @samp{x1} and @samp{log} are aliases for
|
||||||
|
@samp{phods}.
|
||||||
|
|
||||||
|
@item epzs
|
||||||
|
Enable all of the things described above, plus advanced diamond zonal
|
||||||
|
search for 8x8 blocks, half-pixel refinement for 8x8 blocks, and motion
|
||||||
|
estimation on chroma planes.
|
||||||
|
|
||||||
|
@item full
|
||||||
|
Enable all of the things described above, plus extended 16x16 and 8x8
|
||||||
|
blocks search.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item mbd
|
||||||
|
Set macroblock decision algorithm. Possible values in the increasing
|
||||||
|
order of quality:
|
||||||
|
|
||||||
|
@table @samp
|
||||||
|
@item simple
|
||||||
|
Use macroblock comparing function algorithm (default).
|
||||||
|
|
||||||
|
@item bits
|
||||||
|
Enable rate distortion-based half pixel and quarter pixel refinement for
|
||||||
|
16x16 blocks.
|
||||||
|
|
||||||
|
@item rd
|
||||||
|
Enable all of the things described above, plus rate distortion-based
|
||||||
|
half pixel and quarter pixel refinement for 8x8 blocks, and rate
|
||||||
|
distortion-based search using square pattern.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@c man end VIDEO ENCODERS
|
@c man end VIDEO ENCODERS
|
||||||
|
@@ -17,6 +17,7 @@ the libavcodec library.
|
|||||||
|
|
||||||
@c man end DESCRIPTION
|
@c man end DESCRIPTION
|
||||||
|
|
||||||
|
@anchor{codec-options}
|
||||||
@chapter Codec Options
|
@chapter Codec Options
|
||||||
@c man begin CODEC OPTIONS
|
@c man begin CODEC OPTIONS
|
||||||
|
|
||||||
|
@@ -140,6 +140,12 @@ Use wallclock as timestamps.
|
|||||||
@item avoid_negative_ts @var{integer} (@emph{output})
|
@item avoid_negative_ts @var{integer} (@emph{output})
|
||||||
Shift timestamps to make them positive. 1 enables, 0 disables, default
|
Shift timestamps to make them positive. 1 enables, 0 disables, default
|
||||||
of -1 enables when required by target format.
|
of -1 enables when required by target format.
|
||||||
|
|
||||||
|
@item skip_initial_bytes @var{integer} (@emph{input})
|
||||||
|
Set number initial bytes to skip. Default is 0.
|
||||||
|
|
||||||
|
@item correct_ts_overflow @var{integer} (@emph{input})
|
||||||
|
Correct single timestamp overflows if set to 1. Default is 1.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@c man end FORMAT OPTIONS
|
@c man end FORMAT OPTIONS
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
Filtering in FFmpeg is enabled through the libavfilter library.
|
Filtering in FFmpeg is enabled through the libavfilter library.
|
||||||
|
|
||||||
In libavfilter, it is possible for filters to have multiple inputs and
|
In libavfilter, a filter can have multiple inputs and multiple
|
||||||
multiple outputs.
|
outputs.
|
||||||
To illustrate the sorts of things that are possible, we can
|
To illustrate the sorts of things that are possible, we consider the
|
||||||
use a complex filter graph. For example, the following one:
|
following filtergraph.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
input --> split ---------------------> overlay --> output
|
input --> split ---------------------> overlay --> output
|
||||||
@@ -15,25 +15,32 @@ input --> split ---------------------> overlay --> output
|
|||||||
+-----> crop --> vflip -------+
|
+-----> crop --> vflip -------+
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
splits the stream in two streams, sends one stream through the crop filter
|
This filtergraph splits the input stream in two streams, sends one
|
||||||
and the vflip filter before merging it back with the other stream by
|
stream through the crop filter and the vflip filter before merging it
|
||||||
overlaying it on top. You can use the following command to achieve this:
|
back with the other stream by overlaying it on top. You can use the
|
||||||
|
following command to achieve this:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output
|
ffmpeg -i INPUT -vf "split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2" OUTPUT
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
The result will be that in output the top half of the video is mirrored
|
The result will be that in output the top half of the video is mirrored
|
||||||
onto the bottom half.
|
onto the bottom half.
|
||||||
|
|
||||||
Filters are loaded using the @var{-vf} or @var{-af} option passed to
|
Filters in the same linear chain are separated by commas, and distinct
|
||||||
@command{ffmpeg} or to @command{ffplay}. Filters in the same linear
|
linear chains of filters are separated by semicolons. In our example,
|
||||||
chain are separated by commas. In our example, @var{split,
|
@var{crop,vflip} are in one linear chain, @var{split} and
|
||||||
overlay} are in one linear chain, and @var{crop, vflip} are in
|
@var{overlay} are separately in another. The points where the linear
|
||||||
another. The points where the linear chains join are labeled by names
|
chains join are labelled by names enclosed in square brackets. In the
|
||||||
enclosed in square brackets. In our example, that is @var{[T1]} and
|
example, the split filter generates two outputs that are associated to
|
||||||
@var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points
|
the labels @var{[main]} and @var{[tmp]}.
|
||||||
where video is input and output.
|
|
||||||
|
The stream sent to the second output of @var{split}, labelled as
|
||||||
|
@var{[tmp]}, is processed through the @var{crop} filter, which crops
|
||||||
|
away the lower half part of the video, and then vertically flipped. The
|
||||||
|
@var{overlay} filter takes in input the first unchanged output of the
|
||||||
|
split filter (which was labelled as @var{[main]}), and overlay on its
|
||||||
|
lower half the output generated by the @var{crop,vflip} filterchain.
|
||||||
|
|
||||||
Some filters take in input a list of parameters: they are specified
|
Some filters take in input a list of parameters: they are specified
|
||||||
after the filter name and an equal sign, and are separated from each other
|
after the filter name and an equal sign, and are separated from each other
|
||||||
|
@@ -24,7 +24,7 @@ instructions. To enable using OpenJPEG in FFmpeg, pass @code{--enable-libopenjp
|
|||||||
@file{./configure}.
|
@file{./configure}.
|
||||||
|
|
||||||
|
|
||||||
@section OpenCORE and VisualOn libraries
|
@section OpenCORE, VisualOn, and Fraunhofer libraries
|
||||||
|
|
||||||
Spun off Google Android sources, OpenCore, VisualOn and Fraunhofer
|
Spun off Google Android sources, OpenCore, VisualOn and Fraunhofer
|
||||||
libraries provide encoders for a number of audio codecs.
|
libraries provide encoders for a number of audio codecs.
|
||||||
@@ -32,9 +32,14 @@ libraries provide encoders for a number of audio codecs.
|
|||||||
@float NOTE
|
@float NOTE
|
||||||
OpenCORE and VisualOn libraries are under the Apache License 2.0
|
OpenCORE and VisualOn libraries are under the Apache License 2.0
|
||||||
(see @url{http://www.apache.org/licenses/LICENSE-2.0} for details), which is
|
(see @url{http://www.apache.org/licenses/LICENSE-2.0} for details), which is
|
||||||
incompatible with the LGPL version 2.1 and GPL version 2. You have to
|
incompatible to the LGPL version 2.1 and GPL version 2. You have to
|
||||||
upgrade FFmpeg's license to LGPL version 3 (or if you have enabled
|
upgrade FFmpeg's license to LGPL version 3 (or if you have enabled
|
||||||
GPL components, GPL version 3) to use it.
|
GPL components, GPL version 3) by passing @code{--enable-version3} to configure in
|
||||||
|
order to use it.
|
||||||
|
|
||||||
|
The Fraunhofer AAC library is licensed under a license incompatible to the GPL
|
||||||
|
and is not known to be compatible to the LGPL. Therefore, you have to pass
|
||||||
|
@code{--enable-nonfree} to configure to use it.
|
||||||
@end float
|
@end float
|
||||||
|
|
||||||
@subsection OpenCORE AMR
|
@subsection OpenCORE AMR
|
||||||
|
@@ -24,7 +24,7 @@ a mail for every change to every issue.
|
|||||||
The subscription URL for the ffmpeg-trac list is:
|
The subscription URL for the ffmpeg-trac list is:
|
||||||
http(s)://ffmpeg.org/mailman/listinfo/ffmpeg-trac
|
http(s)://ffmpeg.org/mailman/listinfo/ffmpeg-trac
|
||||||
The URL of the webinterface of the tracker is:
|
The URL of the webinterface of the tracker is:
|
||||||
http(s)://ffmpeg.org/trac/ffmpeg
|
http(s)://trac.ffmpeg.org
|
||||||
|
|
||||||
Type:
|
Type:
|
||||||
-----
|
-----
|
||||||
|
@@ -18,6 +18,23 @@ enabled muxers.
|
|||||||
|
|
||||||
A description of some of the currently available muxers follows.
|
A description of some of the currently available muxers follows.
|
||||||
|
|
||||||
|
@anchor{aiff}
|
||||||
|
@section aiff
|
||||||
|
|
||||||
|
Audio Interchange File Format muxer.
|
||||||
|
|
||||||
|
It accepts the following options:
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
@item write_id3v2
|
||||||
|
Enable ID3v2 tags writing when set to 1. Default is 0 (disabled).
|
||||||
|
|
||||||
|
@item id3v2_version
|
||||||
|
Select ID3v2 version to write. Currently only version 3 and 4 (aka.
|
||||||
|
ID3v2.3 and ID3v2.4) are supported. The default is version 4.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@anchor{crc}
|
@anchor{crc}
|
||||||
@section crc
|
@section crc
|
||||||
|
|
||||||
|
@@ -51,8 +51,9 @@ The toolchain provided with Xcode is sufficient to build the basic
|
|||||||
unacelerated code.
|
unacelerated code.
|
||||||
|
|
||||||
Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
|
Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
|
||||||
|
@url{https://github.com/FFmpeg/gas-preprocessor} or
|
||||||
@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
|
@url{http://github.com/yuvi/gas-preprocessor} to build the optimized
|
||||||
assembler functions. Just download the Perl script and put it somewhere
|
assembler functions. Put the Perl script somewhere
|
||||||
in your PATH, FFmpeg's configure will pick it up automatically.
|
in your PATH, FFmpeg's configure will pick it up automatically.
|
||||||
|
|
||||||
Mac OS X on amd64 and x86 requires @command{yasm} to build most of the
|
Mac OS X on amd64 and x86 requires @command{yasm} to build most of the
|
||||||
|
@@ -121,7 +121,7 @@ INF: while(<$inf>) {
|
|||||||
$chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name);
|
$chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name);
|
||||||
|
|
||||||
# start new chapter
|
# start new chapter
|
||||||
$chapter_name = $1, push (@chapters_sequence, $chapter_name);
|
$chapter_name = $1, push (@chapters_sequence, $chapter_name) unless $skipping;
|
||||||
$chapters{$chapter_name} = "" unless exists $chapters{$chapter_name};
|
$chapters{$chapter_name} = "" unless exists $chapters{$chapter_name};
|
||||||
$chapter = "";
|
$chapter = "";
|
||||||
$output = 1;
|
$output = 1;
|
||||||
@@ -169,7 +169,7 @@ INF: while(<$inf>) {
|
|||||||
} elsif ($ended =~ /^(?:example|smallexample|display)$/) {
|
} elsif ($ended =~ /^(?:example|smallexample|display)$/) {
|
||||||
$shift = "";
|
$shift = "";
|
||||||
$_ = ""; # need a paragraph break
|
$_ = ""; # need a paragraph break
|
||||||
} elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
|
} elsif ($ended =~ /^(?:itemize|enumerate|(?:multi|[fv])?table)$/) {
|
||||||
$_ = "\n=back\n";
|
$_ = "\n=back\n";
|
||||||
$ic = pop @icstack;
|
$ic = pop @icstack;
|
||||||
} else {
|
} else {
|
||||||
@@ -269,7 +269,7 @@ INF: while(<$inf>) {
|
|||||||
$endw = "enumerate";
|
$endw = "enumerate";
|
||||||
};
|
};
|
||||||
|
|
||||||
/^\@([fv]?table)\s+(\@[a-z]+)/ and do {
|
/^\@((?:multi|[fv])?table)\s+(\@[a-z]+)/ and do {
|
||||||
push @endwstack, $endw;
|
push @endwstack, $endw;
|
||||||
push @icstack, $ic;
|
push @icstack, $ic;
|
||||||
$endw = $1;
|
$endw = $1;
|
||||||
@@ -278,6 +278,7 @@ INF: while(<$inf>) {
|
|||||||
$ic =~ s/\@(?:code|kbd)/C/;
|
$ic =~ s/\@(?:code|kbd)/C/;
|
||||||
$ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
|
$ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
|
||||||
$ic =~ s/\@(?:file)/F/;
|
$ic =~ s/\@(?:file)/F/;
|
||||||
|
$ic =~ s/\@(?:columnfractions)//;
|
||||||
$_ = "\n=over 4\n";
|
$_ = "\n=over 4\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -288,6 +289,21 @@ INF: while(<$inf>) {
|
|||||||
$_ = ""; # need a paragraph break
|
$_ = ""; # need a paragraph break
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
|
||||||
|
my $columns = $1;
|
||||||
|
$columns =~ s/\@tab/ : /;
|
||||||
|
|
||||||
|
$_ = "\n=item B<". $columns .">\n";
|
||||||
|
};
|
||||||
|
|
||||||
|
/^\@tab\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
|
||||||
|
my $columns = $1;
|
||||||
|
$columns =~ s/\@tab/ : /;
|
||||||
|
|
||||||
|
$_ = " : ". $columns;
|
||||||
|
$chapter =~ s/\n+\s+$//;
|
||||||
|
};
|
||||||
|
|
||||||
/^\@itemx?\s*(.+)?$/ and do {
|
/^\@itemx?\s*(.+)?$/ and do {
|
||||||
if (defined $1) {
|
if (defined $1) {
|
||||||
# Entity escapes prevent munging by the <> processing below.
|
# Entity escapes prevent munging by the <> processing below.
|
||||||
@@ -361,6 +377,7 @@ sub postprocess
|
|||||||
s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g;
|
s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g;
|
||||||
s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g;
|
s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g;
|
||||||
s/;\s+\@pxref\{(?:[^\}]*)\}//g;
|
s/;\s+\@pxref\{(?:[^\}]*)\}//g;
|
||||||
|
s/\@ref\{(?:[^,\}]*,)(?:[^,\}]*,)([^,\}]*).*\}/$1/g;
|
||||||
s/\@ref\{([^\}]*)\}/$1/g;
|
s/\@ref\{([^\}]*)\}/$1/g;
|
||||||
s/\@noindent\s*//g;
|
s/\@noindent\s*//g;
|
||||||
s/\@refill//g;
|
s/\@refill//g;
|
||||||
|
7
ffmpeg.c
7
ffmpeg.c
@@ -152,6 +152,8 @@ static struct termios oldtty;
|
|||||||
static int restore_tty;
|
static int restore_tty;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void free_input_threads(void);
|
||||||
|
|
||||||
|
|
||||||
/* sub2video hack:
|
/* sub2video hack:
|
||||||
Convert subtitles to video with alpha to insert them in filter graphs.
|
Convert subtitles to video with alpha to insert them in filter graphs.
|
||||||
@@ -441,6 +443,9 @@ static void exit_program(void)
|
|||||||
av_freep(&output_streams[i]->logfile_prefix);
|
av_freep(&output_streams[i]->logfile_prefix);
|
||||||
av_freep(&output_streams[i]);
|
av_freep(&output_streams[i]);
|
||||||
}
|
}
|
||||||
|
#if HAVE_PTHREADS
|
||||||
|
free_input_threads();
|
||||||
|
#endif
|
||||||
for (i = 0; i < nb_input_files; i++) {
|
for (i = 0; i < nb_input_files; i++) {
|
||||||
avformat_close_input(&input_files[i]->ctx);
|
avformat_close_input(&input_files[i]->ctx);
|
||||||
av_freep(&input_files[i]);
|
av_freep(&input_files[i]);
|
||||||
@@ -1654,7 +1659,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
|
|
||||||
if (!frame_sample_aspect->num)
|
if (!frame_sample_aspect->num)
|
||||||
*frame_sample_aspect = ist->st->sample_aspect_ratio;
|
*frame_sample_aspect = ist->st->sample_aspect_ratio;
|
||||||
if (ist->dr1 && decoded_frame->type==FF_BUFFER_TYPE_USER && !changed) {
|
if (ist->dr1 && decoded_frame->type==FF_BUFFER_TYPE_USER && !changed && !do_deinterlace) {
|
||||||
FrameBuffer *buf = decoded_frame->opaque;
|
FrameBuffer *buf = decoded_frame->opaque;
|
||||||
AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
|
AVFilterBufferRef *fb = avfilter_get_video_buffer_ref_from_arrays(
|
||||||
decoded_frame->data, decoded_frame->linesize,
|
decoded_frame->data, decoded_frame->linesize,
|
||||||
|
@@ -41,12 +41,15 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum AVPixelFo
|
|||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
|
||||||
int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
|
int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
|
||||||
enum AVPixelFormat best= AV_PIX_FMT_NONE;
|
enum AVPixelFormat best= AV_PIX_FMT_NONE;
|
||||||
|
const enum AVPixelFormat mjpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
||||||
|
const enum AVPixelFormat ljpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
||||||
|
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
||||||
|
|
||||||
if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
|
if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
|
||||||
if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
|
if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
|
||||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
|
p = mjpeg_formats;
|
||||||
} else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
|
} else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
|
||||||
p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
|
p =ljpeg_formats;
|
||||||
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||||
|
@@ -328,6 +328,14 @@ static AVLFG random_state;
|
|||||||
|
|
||||||
static FILE *logfile = NULL;
|
static FILE *logfile = NULL;
|
||||||
|
|
||||||
|
static void htmlstrip(char *s) {
|
||||||
|
while (s && *s) {
|
||||||
|
s += strspn(s, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,. ");
|
||||||
|
if (*s)
|
||||||
|
*s++ = '?';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int64_t ffm_read_write_index(int fd)
|
static int64_t ffm_read_write_index(int fd)
|
||||||
{
|
{
|
||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
@@ -1887,6 +1895,7 @@ static int http_parse_request(HTTPContext *c)
|
|||||||
send_error:
|
send_error:
|
||||||
c->http_error = 404;
|
c->http_error = 404;
|
||||||
q = c->buffer;
|
q = c->buffer;
|
||||||
|
htmlstrip(msg);
|
||||||
snprintf(q, c->buffer_size,
|
snprintf(q, c->buffer_size,
|
||||||
"HTTP/1.0 404 Not Found\r\n"
|
"HTTP/1.0 404 Not Found\r\n"
|
||||||
"Content-type: text/html\r\n"
|
"Content-type: text/html\r\n"
|
||||||
|
126
libavcodec/4xm.c
126
libavcodec/4xm.c
@@ -328,12 +328,12 @@ static inline void mcdc(uint16_t *dst, const uint16_t *src, int log2w,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_assert2(0);
|
av_assert0(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
|
static int decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
|
||||||
int log2w, int log2h, int stride)
|
int log2w, int log2h, int stride)
|
||||||
{
|
{
|
||||||
const int index = size2index[log2h][log2w];
|
const int index = size2index[log2h][log2w];
|
||||||
const int h = 1 << log2h;
|
const int h = 1 << log2h;
|
||||||
@@ -342,57 +342,72 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
|
|||||||
BLOCK_TYPE_VLC_BITS, 1);
|
BLOCK_TYPE_VLC_BITS, 1);
|
||||||
uint16_t *start = (uint16_t *)f->last_picture.data[0];
|
uint16_t *start = (uint16_t *)f->last_picture.data[0];
|
||||||
uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w);
|
uint16_t *end = start + stride * (f->avctx->height - h + 1) - (1 << log2w);
|
||||||
|
int ret;
|
||||||
|
|
||||||
av_assert2(code >= 0 && code <= 6);
|
av_assert0(code >= 0 && code <= 6 && log2w >= 0);
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
if (bytestream2_get_bytes_left(&f->g) < 1) {
|
if (bytestream2_get_bytes_left(&f->g) < 1) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n");
|
av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
src += f->mv[bytestream2_get_byteu(&f->g)];
|
src += f->mv[bytestream2_get_byteu(&f->g)];
|
||||||
if (start > src || src > end) {
|
if (start > src || src > end) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
mcdc(dst, src, log2w, h, stride, 1, 0);
|
mcdc(dst, src, log2w, h, stride, 1, 0);
|
||||||
} else if (code == 1) {
|
} else if (code == 1) {
|
||||||
log2h--;
|
log2h--;
|
||||||
decode_p_block(f, dst, src, log2w, log2h, stride);
|
if ((ret = decode_p_block(f, dst, src, log2w, log2h, stride)) < 0)
|
||||||
decode_p_block(f, dst + (stride << log2h),
|
return ret;
|
||||||
src + (stride << log2h), log2w, log2h, stride);
|
if ((ret = decode_p_block(f, dst + (stride << log2h),
|
||||||
|
src + (stride << log2h),
|
||||||
|
log2w, log2h, stride)) < 0)
|
||||||
|
return ret;
|
||||||
} else if (code == 2) {
|
} else if (code == 2) {
|
||||||
log2w--;
|
log2w--;
|
||||||
decode_p_block(f, dst , src, log2w, log2h, stride);
|
if ((ret = decode_p_block(f, dst , src, log2w, log2h, stride)) < 0)
|
||||||
decode_p_block(f, dst + (1 << log2w),
|
return ret;
|
||||||
src + (1 << log2w), log2w, log2h, stride);
|
if ((ret = decode_p_block(f, dst + (1 << log2w),
|
||||||
|
src + (1 << log2w),
|
||||||
|
log2w, log2h, stride)) < 0)
|
||||||
|
return ret;
|
||||||
} else if (code == 3 && f->version < 2) {
|
} else if (code == 3 && f->version < 2) {
|
||||||
|
if (start > src || src > end) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
mcdc(dst, src, log2w, h, stride, 1, 0);
|
mcdc(dst, src, log2w, h, stride, 1, 0);
|
||||||
} else if (code == 4) {
|
} else if (code == 4) {
|
||||||
if (bytestream2_get_bytes_left(&f->g) < 1) {
|
if (bytestream2_get_bytes_left(&f->g) < 1) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n");
|
av_log(f->avctx, AV_LOG_ERROR, "bytestream overread\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
src += f->mv[bytestream2_get_byteu(&f->g)];
|
src += f->mv[bytestream2_get_byteu(&f->g)];
|
||||||
if (start > src || src > end) {
|
if (start > src || src > end) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (bytestream2_get_bytes_left(&f->g2) < 2){
|
if (bytestream2_get_bytes_left(&f->g2) < 2){
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n");
|
av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
mcdc(dst, src, log2w, h, stride, 1, bytestream2_get_le16u(&f->g2));
|
mcdc(dst, src, log2w, h, stride, 1, bytestream2_get_le16u(&f->g2));
|
||||||
} else if (code == 5) {
|
} else if (code == 5) {
|
||||||
if (bytestream2_get_bytes_left(&f->g2) < 2) {
|
if (bytestream2_get_bytes_left(&f->g2) < 2) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n");
|
av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
if (start > src || src > end) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
mcdc(dst, src, log2w, h, stride, 0, bytestream2_get_le16u(&f->g2));
|
mcdc(dst, src, log2w, h, stride, 0, bytestream2_get_le16u(&f->g2));
|
||||||
} else if (code == 6) {
|
} else if (code == 6) {
|
||||||
if (bytestream2_get_bytes_left(&f->g2) < 4) {
|
if (bytestream2_get_bytes_left(&f->g2) < 4) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n");
|
av_log(f->avctx, AV_LOG_ERROR, "wordstream overread\n");
|
||||||
return;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (log2w) {
|
if (log2w) {
|
||||||
dst[0] = bytestream2_get_le16u(&f->g2);
|
dst[0] = bytestream2_get_le16u(&f->g2);
|
||||||
@@ -402,6 +417,7 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src,
|
|||||||
dst[stride] = bytestream2_get_le16u(&f->g2);
|
dst[stride] = bytestream2_get_le16u(&f->g2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
|
static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
|
||||||
@@ -414,8 +430,20 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
|
|||||||
const int stride = f->current_picture.linesize[0] >> 1;
|
const int stride = f->current_picture.linesize[0] >> 1;
|
||||||
unsigned int bitstream_size, bytestream_size, wordstream_size, extra,
|
unsigned int bitstream_size, bytestream_size, wordstream_size, extra,
|
||||||
bytestream_offset, wordstream_offset;
|
bytestream_offset, wordstream_offset;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!f->last_picture.data[0]) {
|
||||||
|
if ((ret = ff_get_buffer(f->avctx, &f->last_picture)) < 0) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
for (y=0; y<f->avctx->height; y++)
|
||||||
|
memset(f->last_picture.data[0] + y*f->last_picture.linesize[0], 0, 2*f->avctx->width);
|
||||||
|
}
|
||||||
|
|
||||||
if (f->version > 1) {
|
if (f->version > 1) {
|
||||||
|
if (length < 20)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
extra = 20;
|
extra = 20;
|
||||||
if (length < extra)
|
if (length < extra)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -459,7 +487,8 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
|
|||||||
|
|
||||||
for (y = 0; y < height; y += 8) {
|
for (y = 0; y < height; y += 8) {
|
||||||
for (x = 0; x < width; x += 8)
|
for (x = 0; x < width; x += 8)
|
||||||
decode_p_block(f, dst + x, src + x, 3, 3, stride);
|
if ((ret = decode_p_block(f, dst + x, src + x, 3, 3, stride)) < 0)
|
||||||
|
return ret;
|
||||||
src += 8 * stride;
|
src += 8 * stride;
|
||||||
dst += 8 * stride;
|
dst += 8 * stride;
|
||||||
}
|
}
|
||||||
@@ -579,7 +608,8 @@ static int decode_i_mb(FourXContext *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const uint8_t *read_huffman_tables(FourXContext *f,
|
static const uint8_t *read_huffman_tables(FourXContext *f,
|
||||||
const uint8_t * const buf, int buf_size)
|
const uint8_t * const buf,
|
||||||
|
int buf_size)
|
||||||
{
|
{
|
||||||
int frequency[512] = { 0 };
|
int frequency[512] = { 0 };
|
||||||
uint8_t flag[512];
|
uint8_t flag[512];
|
||||||
@@ -598,8 +628,11 @@ static const uint8_t *read_huffman_tables(FourXContext *f,
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (start <= end && ptr_end - ptr < end - start + 1 + 1)
|
if (ptr_end - ptr < FFMAX(end - start + 1, 0) + 1) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "invalid data in read_huffman_tables\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = start; i <= end; i++)
|
for (i = start; i <= end; i++)
|
||||||
frequency[i] = *ptr++;
|
frequency[i] = *ptr++;
|
||||||
start = *ptr++;
|
start = *ptr++;
|
||||||
@@ -701,9 +734,9 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
|
|||||||
color[1] = bytestream2_get_le16u(&g3);
|
color[1] = bytestream2_get_le16u(&g3);
|
||||||
|
|
||||||
if (color[0] & 0x8000)
|
if (color[0] & 0x8000)
|
||||||
av_log(NULL, AV_LOG_ERROR, "unk bit 1\n");
|
av_log(f->avctx, AV_LOG_ERROR, "unk bit 1\n");
|
||||||
if (color[1] & 0x8000)
|
if (color[1] & 0x8000)
|
||||||
av_log(NULL, AV_LOG_ERROR, "unk bit 2\n");
|
av_log(f->avctx, AV_LOG_ERROR, "unk bit 2\n");
|
||||||
|
|
||||||
color[2] = mix(color[0], color[1]);
|
color[2] = mix(color[0], color[1]);
|
||||||
color[3] = mix(color[1], color[0]);
|
color[3] = mix(color[1], color[0]);
|
||||||
@@ -732,7 +765,10 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
|
|||||||
unsigned int prestream_size;
|
unsigned int prestream_size;
|
||||||
const uint8_t *prestream;
|
const uint8_t *prestream;
|
||||||
|
|
||||||
if (bitstream_size > (1<<26) || length < bitstream_size + 12) {
|
if (bitstream_size > (1 << 26))
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
if (length < bitstream_size + 12) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n");
|
av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -741,14 +777,13 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
|
|||||||
prestream = buf + bitstream_size + 12;
|
prestream = buf + bitstream_size + 12;
|
||||||
|
|
||||||
if (prestream_size + bitstream_size + 12 != length
|
if (prestream_size + bitstream_size + 12 != length
|
||||||
|| bitstream_size > (1 << 26)
|
|
||||||
|| prestream_size > (1 << 26)) {
|
|| prestream_size > (1 << 26)) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n",
|
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n",
|
||||||
prestream_size, bitstream_size, length);
|
prestream_size, bitstream_size, length);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
prestream = read_huffman_tables(f, prestream, buf + length - prestream);
|
prestream = read_huffman_tables(f, prestream, prestream_size);
|
||||||
if (!prestream) {
|
if (!prestream) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "Error reading Huffman tables.\n");
|
av_log(f->avctx, AV_LOG_ERROR, "Error reading Huffman tables.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@@ -795,30 +830,38 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
AVFrame *p, temp;
|
AVFrame *p, temp;
|
||||||
int i, frame_4cc, frame_size;
|
int i, frame_4cc, frame_size;
|
||||||
|
|
||||||
if (buf_size < 12)
|
if (buf_size < 20)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
frame_4cc = AV_RL32(buf);
|
|
||||||
if (buf_size != AV_RL32(buf + 4) + 8 || buf_size < 20)
|
av_assert0(avctx->width % 16 == 0 && avctx->height % 16 == 0);
|
||||||
|
|
||||||
|
if (buf_size < AV_RL32(buf + 4) + 8) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n",
|
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n",
|
||||||
buf_size, AV_RL32(buf + 4));
|
buf_size, AV_RL32(buf + 4));
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_4cc = AV_RL32(buf);
|
||||||
|
|
||||||
if (frame_4cc == AV_RL32("cfrm")) {
|
if (frame_4cc == AV_RL32("cfrm")) {
|
||||||
int free_index = -1;
|
int free_index = -1;
|
||||||
|
int id, whole_size;
|
||||||
const int data_size = buf_size - 20;
|
const int data_size = buf_size - 20;
|
||||||
const int id = AV_RL32(buf + 12);
|
|
||||||
const int whole_size = AV_RL32(buf + 16);
|
|
||||||
CFrameBuffer *cfrm;
|
CFrameBuffer *cfrm;
|
||||||
|
|
||||||
if (data_size < 0 || whole_size < 0) {
|
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "sizes invalid\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f->version <= 1) {
|
if (f->version <= 1) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "cfrm in version %d\n", f->version);
|
av_log(f->avctx, AV_LOG_ERROR, "cfrm in version %d\n", f->version);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = AV_RL32(buf + 12);
|
||||||
|
whole_size = AV_RL32(buf + 16);
|
||||||
|
|
||||||
|
if (data_size < 0 || whole_size < 0) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "sizes invalid\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < CFRAME_BUFFER_COUNT; i++)
|
for (i = 0; i < CFRAME_BUFFER_COUNT; i++)
|
||||||
if (f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
|
if (f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n",
|
av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n",
|
||||||
@@ -859,6 +902,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n",
|
av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n",
|
||||||
id, avctx->frame_number);
|
id, avctx->frame_number);
|
||||||
|
|
||||||
|
if (f->version <= 1)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
cfrm->size = cfrm->id = 0;
|
cfrm->size = cfrm->id = 0;
|
||||||
frame_4cc = AV_RL32("pfrm");
|
frame_4cc = AV_RL32("pfrm");
|
||||||
} else
|
} else
|
||||||
@@ -897,16 +943,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
|
} else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
|
||||||
if (!f->last_picture.data[0]) {
|
|
||||||
f->last_picture.reference = 3;
|
|
||||||
if (ff_get_buffer(avctx, &f->last_picture) < 0) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
for (i=0; i<avctx->height; i++)
|
|
||||||
memset(f->last_picture.data[0] + i*f->last_picture.linesize[0], 0, 2*avctx->width);
|
|
||||||
}
|
|
||||||
|
|
||||||
p->pict_type = AV_PICTURE_TYPE_P;
|
p->pict_type = AV_PICTURE_TYPE_P;
|
||||||
if (decode_p_frame(f, buf, frame_size) < 0) {
|
if (decode_p_frame(f, buf, frame_size) < 0) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "decode p frame failed\n");
|
av_log(f->avctx, AV_LOG_ERROR, "decode p frame failed\n");
|
||||||
|
@@ -64,7 +64,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
unsigned char *pixptr, *pixptr_end;
|
unsigned char *pixptr, *pixptr_end;
|
||||||
unsigned int height = avctx->height; // Real image height
|
unsigned int height = avctx->height; // Real image height
|
||||||
unsigned int dlen, p, row;
|
unsigned int dlen, p, row;
|
||||||
const unsigned char *lp, *dp;
|
const unsigned char *lp, *dp, *ep;
|
||||||
unsigned char count;
|
unsigned char count;
|
||||||
unsigned int planes = c->planes;
|
unsigned int planes = c->planes;
|
||||||
unsigned char *planemap = c->planemap;
|
unsigned char *planemap = c->planemap;
|
||||||
@@ -79,6 +79,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ep = encoded + buf_size;
|
||||||
|
|
||||||
/* Set data pointer after line lengths */
|
/* Set data pointer after line lengths */
|
||||||
dp = encoded + planes * (height << 1);
|
dp = encoded + planes * (height << 1);
|
||||||
|
|
||||||
@@ -90,19 +92,19 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
for (row = 0; row < height; row++) {
|
for (row = 0; row < height; row++) {
|
||||||
pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p];
|
pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p];
|
||||||
pixptr_end = pixptr + c->pic.linesize[0];
|
pixptr_end = pixptr + c->pic.linesize[0];
|
||||||
if(lp - encoded + row*2 + 1 >= buf_size)
|
if (ep - lp < row * 2 + 2)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
dlen = av_be2ne16(*(const unsigned short *)(lp + row * 2));
|
dlen = av_be2ne16(*(const unsigned short *)(lp + row * 2));
|
||||||
/* Decode a row of this plane */
|
/* Decode a row of this plane */
|
||||||
while (dlen > 0) {
|
while (dlen > 0) {
|
||||||
if (dp + 1 >= buf + buf_size)
|
if (ep - dp <= 1)
|
||||||
return -1;
|
return -1;
|
||||||
if ((count = *dp++) <= 127) {
|
if ((count = *dp++) <= 127) {
|
||||||
count++;
|
count++;
|
||||||
dlen -= count + 1;
|
dlen -= count + 1;
|
||||||
if (pixptr + count * planes > pixptr_end)
|
if (pixptr + count * planes > pixptr_end)
|
||||||
break;
|
break;
|
||||||
if (dp + count > buf + buf_size)
|
if (ep - dp < count)
|
||||||
return -1;
|
return -1;
|
||||||
while (count--) {
|
while (count--) {
|
||||||
*pixptr = *dp++;
|
*pixptr = *dp++;
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
AAC_AC3_PARSE_ERROR_SYNC = -1,
|
AAC_AC3_PARSE_ERROR_SYNC = -0x1030c0a,
|
||||||
AAC_AC3_PARSE_ERROR_BSID = -2,
|
AAC_AC3_PARSE_ERROR_BSID = -0x2030c0a,
|
||||||
AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -3,
|
AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
|
||||||
AAC_AC3_PARSE_ERROR_FRAME_SIZE = -4,
|
AAC_AC3_PARSE_ERROR_FRAME_SIZE = -0x4030c0a,
|
||||||
AAC_AC3_PARSE_ERROR_FRAME_TYPE = -5,
|
AAC_AC3_PARSE_ERROR_FRAME_TYPE = -0x5030c0a,
|
||||||
AAC_AC3_PARSE_ERROR_CRC = -6,
|
AAC_AC3_PARSE_ERROR_CRC = -0x6030c0a,
|
||||||
AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -7,
|
AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -0x7030c0a,
|
||||||
} AACAC3ParseError;
|
} AACAC3ParseError;
|
||||||
|
|
||||||
typedef struct AACAC3ParseContext {
|
typedef struct AACAC3ParseContext {
|
||||||
|
@@ -710,7 +710,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
|
|||||||
const float lambda)
|
const float lambda)
|
||||||
{
|
{
|
||||||
int start = 0, i, w, w2, g;
|
int start = 0, i, w, w2, g;
|
||||||
int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels;
|
int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f);
|
||||||
float dists[128] = { 0 }, uplims[128];
|
float dists[128] = { 0 }, uplims[128];
|
||||||
float maxvals[128];
|
float maxvals[128];
|
||||||
int fflag, minscaler;
|
int fflag, minscaler;
|
||||||
|
@@ -147,6 +147,8 @@ static av_cold int che_configure(AACContext *ac,
|
|||||||
enum ChannelPosition che_pos,
|
enum ChannelPosition che_pos,
|
||||||
int type, int id, int *channels)
|
int type, int id, int *channels)
|
||||||
{
|
{
|
||||||
|
if (*channels >= MAX_CHANNELS)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if (che_pos) {
|
if (che_pos) {
|
||||||
if (!ac->che[type][id]) {
|
if (!ac->che[type][id]) {
|
||||||
if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
|
if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
|
||||||
@@ -188,6 +190,9 @@ static int frame_configure_elements(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!avctx->channels)
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* get output buffer */
|
/* get output buffer */
|
||||||
ac->frame.nb_samples = 2048;
|
ac->frame.nb_samples = 2048;
|
||||||
if ((ret = ff_get_buffer(avctx, &ac->frame)) < 0) {
|
if ((ret = ff_get_buffer(avctx, &ac->frame)) < 0) {
|
||||||
@@ -213,28 +218,39 @@ struct elem_to_channel {
|
|||||||
|
|
||||||
static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID],
|
static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID],
|
||||||
uint8_t (*layout_map)[3], int offset, uint64_t left,
|
uint8_t (*layout_map)[3], int offset, uint64_t left,
|
||||||
uint64_t right, int pos)
|
uint64_t right, int pos)
|
||||||
{
|
{
|
||||||
if (layout_map[offset][0] == TYPE_CPE) {
|
if (layout_map[offset][0] == TYPE_CPE) {
|
||||||
e2c_vec[offset] = (struct elem_to_channel) {
|
e2c_vec[offset] = (struct elem_to_channel) {
|
||||||
.av_position = left | right, .syn_ele = TYPE_CPE,
|
.av_position = left | right,
|
||||||
.elem_id = layout_map[offset ][1], .aac_position = pos };
|
.syn_ele = TYPE_CPE,
|
||||||
|
.elem_id = layout_map[offset][1],
|
||||||
|
.aac_position = pos
|
||||||
|
};
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
e2c_vec[offset] = (struct elem_to_channel) {
|
e2c_vec[offset] = (struct elem_to_channel) {
|
||||||
.av_position = left, .syn_ele = TYPE_SCE,
|
.av_position = left,
|
||||||
.elem_id = layout_map[offset ][1], .aac_position = pos };
|
.syn_ele = TYPE_SCE,
|
||||||
|
.elem_id = layout_map[offset][1],
|
||||||
|
.aac_position = pos
|
||||||
|
};
|
||||||
e2c_vec[offset + 1] = (struct elem_to_channel) {
|
e2c_vec[offset + 1] = (struct elem_to_channel) {
|
||||||
.av_position = right, .syn_ele = TYPE_SCE,
|
.av_position = right,
|
||||||
.elem_id = layout_map[offset + 1][1], .aac_position = pos };
|
.syn_ele = TYPE_SCE,
|
||||||
|
.elem_id = layout_map[offset + 1][1],
|
||||||
|
.aac_position = pos
|
||||||
|
};
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, int *current) {
|
static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos,
|
||||||
|
int *current)
|
||||||
|
{
|
||||||
int num_pos_channels = 0;
|
int num_pos_channels = 0;
|
||||||
int first_cpe = 0;
|
int first_cpe = 0;
|
||||||
int sce_parity = 0;
|
int sce_parity = 0;
|
||||||
int i;
|
int i;
|
||||||
for (i = *current; i < tags; i++) {
|
for (i = *current; i < tags; i++) {
|
||||||
if (layout_map[i][2] != pos)
|
if (layout_map[i][2] != pos)
|
||||||
@@ -248,7 +264,7 @@ static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
num_pos_channels += 2;
|
num_pos_channels += 2;
|
||||||
first_cpe = 1;
|
first_cpe = 1;
|
||||||
} else {
|
} else {
|
||||||
num_pos_channels++;
|
num_pos_channels++;
|
||||||
sce_parity ^= 1;
|
sce_parity ^= 1;
|
||||||
@@ -256,7 +272,7 @@ static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, in
|
|||||||
}
|
}
|
||||||
if (sce_parity &&
|
if (sce_parity &&
|
||||||
((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE))
|
((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE))
|
||||||
return -1;
|
return -1;
|
||||||
*current = i;
|
*current = i;
|
||||||
return num_pos_channels;
|
return num_pos_channels;
|
||||||
}
|
}
|
||||||
@@ -264,7 +280,7 @@ static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, in
|
|||||||
static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
|
static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
|
||||||
{
|
{
|
||||||
int i, n, total_non_cc_elements;
|
int i, n, total_non_cc_elements;
|
||||||
struct elem_to_channel e2c_vec[4*MAX_ELEM_ID] = {{ 0 }};
|
struct elem_to_channel e2c_vec[4 * MAX_ELEM_ID] = { { 0 } };
|
||||||
int num_front_channels, num_side_channels, num_back_channels;
|
int num_front_channels, num_side_channels, num_back_channels;
|
||||||
uint64_t layout;
|
uint64_t layout;
|
||||||
|
|
||||||
@@ -288,8 +304,11 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
|
|||||||
i = 0;
|
i = 0;
|
||||||
if (num_front_channels & 1) {
|
if (num_front_channels & 1) {
|
||||||
e2c_vec[i] = (struct elem_to_channel) {
|
e2c_vec[i] = (struct elem_to_channel) {
|
||||||
.av_position = AV_CH_FRONT_CENTER, .syn_ele = TYPE_SCE,
|
.av_position = AV_CH_FRONT_CENTER,
|
||||||
.elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_FRONT };
|
.syn_ele = TYPE_SCE,
|
||||||
|
.elem_id = layout_map[i][1],
|
||||||
|
.aac_position = AAC_CHANNEL_FRONT
|
||||||
|
};
|
||||||
i++;
|
i++;
|
||||||
num_front_channels--;
|
num_front_channels--;
|
||||||
}
|
}
|
||||||
@@ -346,22 +365,31 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
|
|||||||
}
|
}
|
||||||
if (num_back_channels) {
|
if (num_back_channels) {
|
||||||
e2c_vec[i] = (struct elem_to_channel) {
|
e2c_vec[i] = (struct elem_to_channel) {
|
||||||
.av_position = AV_CH_BACK_CENTER, .syn_ele = TYPE_SCE,
|
.av_position = AV_CH_BACK_CENTER,
|
||||||
.elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_BACK };
|
.syn_ele = TYPE_SCE,
|
||||||
|
.elem_id = layout_map[i][1],
|
||||||
|
.aac_position = AAC_CHANNEL_BACK
|
||||||
|
};
|
||||||
i++;
|
i++;
|
||||||
num_back_channels--;
|
num_back_channels--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
|
if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
|
||||||
e2c_vec[i] = (struct elem_to_channel) {
|
e2c_vec[i] = (struct elem_to_channel) {
|
||||||
.av_position = AV_CH_LOW_FREQUENCY, .syn_ele = TYPE_LFE,
|
.av_position = AV_CH_LOW_FREQUENCY,
|
||||||
.elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_LFE };
|
.syn_ele = TYPE_LFE,
|
||||||
|
.elem_id = layout_map[i][1],
|
||||||
|
.aac_position = AAC_CHANNEL_LFE
|
||||||
|
};
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
|
while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
|
||||||
e2c_vec[i] = (struct elem_to_channel) {
|
e2c_vec[i] = (struct elem_to_channel) {
|
||||||
.av_position = UINT64_MAX, .syn_ele = TYPE_LFE,
|
.av_position = UINT64_MAX,
|
||||||
.elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_LFE };
|
.syn_ele = TYPE_LFE,
|
||||||
|
.elem_id = layout_map[i][1],
|
||||||
|
.aac_position = AAC_CHANNEL_LFE
|
||||||
|
};
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,12 +397,11 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
|
|||||||
total_non_cc_elements = n = i;
|
total_non_cc_elements = n = i;
|
||||||
do {
|
do {
|
||||||
int next_n = 0;
|
int next_n = 0;
|
||||||
for (i = 1; i < n; i++) {
|
for (i = 1; i < n; i++)
|
||||||
if (e2c_vec[i-1].av_position > e2c_vec[i].av_position) {
|
if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) {
|
||||||
FFSWAP(struct elem_to_channel, e2c_vec[i-1], e2c_vec[i]);
|
FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]);
|
||||||
next_n = i;
|
next_n = i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
n = next_n;
|
n = next_n;
|
||||||
} while (n > 0);
|
} while (n > 0);
|
||||||
|
|
||||||
@@ -416,12 +443,13 @@ static void pop_output_configuration(AACContext *ac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure output channel order based on the current program configuration element.
|
* Configure output channel order based on the current program
|
||||||
|
* configuration element.
|
||||||
*
|
*
|
||||||
* @return Returns error status. 0 - OK, !0 - error
|
* @return Returns error status. 0 - OK, !0 - error
|
||||||
*/
|
*/
|
||||||
static int output_configure(AACContext *ac,
|
static int output_configure(AACContext *ac,
|
||||||
uint8_t layout_map[MAX_ELEM_ID*4][3], int tags,
|
uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags,
|
||||||
enum OCStatus oc_type, int get_new_frame)
|
enum OCStatus oc_type, int get_new_frame)
|
||||||
{
|
{
|
||||||
AVCodecContext *avctx = ac->avctx;
|
AVCodecContext *avctx = ac->avctx;
|
||||||
@@ -493,36 +521,40 @@ static void flush(AVCodecContext *avctx)
|
|||||||
* @return Returns error status. 0 - OK, !0 - error
|
* @return Returns error status. 0 - OK, !0 - error
|
||||||
*/
|
*/
|
||||||
static int set_default_channel_config(AVCodecContext *avctx,
|
static int set_default_channel_config(AVCodecContext *avctx,
|
||||||
uint8_t (*layout_map)[3],
|
uint8_t (*layout_map)[3],
|
||||||
int *tags,
|
int *tags,
|
||||||
int channel_config)
|
int channel_config)
|
||||||
{
|
{
|
||||||
if (channel_config < 1 || channel_config > 7) {
|
if (channel_config < 1 || channel_config > 7) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"invalid default channel configuration (%d)\n",
|
||||||
channel_config);
|
channel_config);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
*tags = tags_per_config[channel_config];
|
*tags = tags_per_config[channel_config];
|
||||||
memcpy(layout_map, aac_channel_layout_map[channel_config-1], *tags * sizeof(*layout_map));
|
memcpy(layout_map, aac_channel_layout_map[channel_config - 1],
|
||||||
|
*tags * sizeof(*layout_map));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
||||||
{
|
{
|
||||||
// For PCE based channel configurations map the channels solely based on tags.
|
/* For PCE based channel configurations map the channels solely based
|
||||||
|
* on tags. */
|
||||||
if (!ac->oc[1].m4ac.chan_config) {
|
if (!ac->oc[1].m4ac.chan_config) {
|
||||||
return ac->tag_che_map[type][elem_id];
|
return ac->tag_che_map[type][elem_id];
|
||||||
}
|
}
|
||||||
// Allow single CPE stereo files to be signalled with mono configuration.
|
// Allow single CPE stereo files to be signalled with mono configuration.
|
||||||
if (!ac->tags_mapped && type == TYPE_CPE && ac->oc[1].m4ac.chan_config == 1) {
|
if (!ac->tags_mapped && type == TYPE_CPE &&
|
||||||
|
ac->oc[1].m4ac.chan_config == 1) {
|
||||||
uint8_t layout_map[MAX_ELEM_ID*4][3];
|
uint8_t layout_map[MAX_ELEM_ID*4][3];
|
||||||
int layout_map_tags;
|
int layout_map_tags;
|
||||||
push_output_configuration(ac);
|
push_output_configuration(ac);
|
||||||
|
|
||||||
av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n");
|
av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n");
|
||||||
|
|
||||||
if (set_default_channel_config(ac->avctx, layout_map, &layout_map_tags,
|
if (set_default_channel_config(ac->avctx, layout_map,
|
||||||
2) < 0)
|
&layout_map_tags, 2) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (output_configure(ac, layout_map, layout_map_tags,
|
if (output_configure(ac, layout_map, layout_map_tags,
|
||||||
OC_TRIAL_FRAME, 1) < 0)
|
OC_TRIAL_FRAME, 1) < 0)
|
||||||
@@ -532,15 +564,16 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
|||||||
ac->oc[1].m4ac.ps = 0;
|
ac->oc[1].m4ac.ps = 0;
|
||||||
}
|
}
|
||||||
// And vice-versa
|
// And vice-versa
|
||||||
if (!ac->tags_mapped && type == TYPE_SCE && ac->oc[1].m4ac.chan_config == 2) {
|
if (!ac->tags_mapped && type == TYPE_SCE &&
|
||||||
uint8_t layout_map[MAX_ELEM_ID*4][3];
|
ac->oc[1].m4ac.chan_config == 2) {
|
||||||
|
uint8_t layout_map[MAX_ELEM_ID * 4][3];
|
||||||
int layout_map_tags;
|
int layout_map_tags;
|
||||||
push_output_configuration(ac);
|
push_output_configuration(ac);
|
||||||
|
|
||||||
av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n");
|
av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n");
|
||||||
|
|
||||||
if (set_default_channel_config(ac->avctx, layout_map, &layout_map_tags,
|
if (set_default_channel_config(ac->avctx, layout_map,
|
||||||
1) < 0)
|
&layout_map_tags, 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (output_configure(ac, layout_map, layout_map_tags,
|
if (output_configure(ac, layout_map, layout_map_tags,
|
||||||
OC_TRIAL_FRAME, 1) < 0)
|
OC_TRIAL_FRAME, 1) < 0)
|
||||||
@@ -550,7 +583,8 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
|||||||
if (ac->oc[1].m4ac.sbr)
|
if (ac->oc[1].m4ac.sbr)
|
||||||
ac->oc[1].m4ac.ps = -1;
|
ac->oc[1].m4ac.ps = -1;
|
||||||
}
|
}
|
||||||
// For indexed channel configurations map the channels solely based on position.
|
/* For indexed channel configurations map the channels solely based
|
||||||
|
* on position. */
|
||||||
switch (ac->oc[1].m4ac.chan_config) {
|
switch (ac->oc[1].m4ac.chan_config) {
|
||||||
case 7:
|
case 7:
|
||||||
if (ac->tags_mapped == 3 && type == TYPE_CPE) {
|
if (ac->tags_mapped == 3 && type == TYPE_CPE) {
|
||||||
@@ -558,9 +592,12 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
|||||||
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
|
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
/* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1]
|
/* Some streams incorrectly code 5.1 audio as
|
||||||
instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have
|
* SCE[0] CPE[0] CPE[1] SCE[1]
|
||||||
encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */
|
* instead of
|
||||||
|
* SCE[0] CPE[0] CPE[1] LFE[0].
|
||||||
|
* If we seem to have encountered such a stream, transfer
|
||||||
|
* the LFE[0] element to the SCE[1]'s mapping */
|
||||||
if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
|
if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
|
||||||
ac->tags_mapped++;
|
ac->tags_mapped++;
|
||||||
return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
|
return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
|
||||||
@@ -571,13 +608,16 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
|||||||
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
|
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if (ac->tags_mapped == 2 && ac->oc[1].m4ac.chan_config == 4 && type == TYPE_SCE) {
|
if (ac->tags_mapped == 2 &&
|
||||||
|
ac->oc[1].m4ac.chan_config == 4 &&
|
||||||
|
type == TYPE_SCE) {
|
||||||
ac->tags_mapped++;
|
ac->tags_mapped++;
|
||||||
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
|
return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
case 2:
|
case 2:
|
||||||
if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && type == TYPE_CPE) {
|
if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) &&
|
||||||
|
type == TYPE_CPE) {
|
||||||
ac->tags_mapped++;
|
ac->tags_mapped++;
|
||||||
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
|
return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
|
||||||
} else if (ac->oc[1].m4ac.chan_config == 2) {
|
} else if (ac->oc[1].m4ac.chan_config == 2) {
|
||||||
@@ -594,7 +634,8 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode an array of 4 bit element IDs, optionally interleaved with a stereo/mono switching bit.
|
* Decode an array of 4 bit element IDs, optionally interleaved with a
|
||||||
|
* stereo/mono switching bit.
|
||||||
*
|
*
|
||||||
* @param type speaker type/position for these channels
|
* @param type speaker type/position for these channels
|
||||||
*/
|
*/
|
||||||
@@ -636,7 +677,8 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
|
|||||||
uint8_t (*layout_map)[3],
|
uint8_t (*layout_map)[3],
|
||||||
GetBitContext *gb)
|
GetBitContext *gb)
|
||||||
{
|
{
|
||||||
int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
|
int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc;
|
||||||
|
int sampling_index;
|
||||||
int comment_len;
|
int comment_len;
|
||||||
int tags;
|
int tags;
|
||||||
|
|
||||||
@@ -644,7 +686,9 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
|
|||||||
|
|
||||||
sampling_index = get_bits(gb, 4);
|
sampling_index = get_bits(gb, 4);
|
||||||
if (m4ac->sampling_index != sampling_index)
|
if (m4ac->sampling_index != sampling_index)
|
||||||
av_log(avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
|
av_log(avctx, AV_LOG_WARNING,
|
||||||
|
"Sample rate index in program config element does not "
|
||||||
|
"match the sample rate index configured by the container.\n");
|
||||||
|
|
||||||
num_front = get_bits(gb, 4);
|
num_front = get_bits(gb, 4);
|
||||||
num_side = get_bits(gb, 4);
|
num_side = get_bits(gb, 4);
|
||||||
@@ -685,7 +729,7 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
|
|||||||
comment_len = get_bits(gb, 8) * 8;
|
comment_len = get_bits(gb, 8) * 8;
|
||||||
if (get_bits_left(gb) < comment_len) {
|
if (get_bits_left(gb) < comment_len) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
|
av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
skip_bits_long(gb, comment_len);
|
skip_bits_long(gb, comment_len);
|
||||||
return tags;
|
return tags;
|
||||||
@@ -727,7 +771,8 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
|
|||||||
if (tags < 0)
|
if (tags < 0)
|
||||||
return tags;
|
return tags;
|
||||||
} else {
|
} else {
|
||||||
if ((ret = set_default_channel_config(avctx, layout_map, &tags, channel_config)))
|
if ((ret = set_default_channel_config(avctx, layout_map,
|
||||||
|
&tags, channel_config)))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -749,7 +794,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
|
|||||||
case AOT_ER_AAC_LTP:
|
case AOT_ER_AAC_LTP:
|
||||||
case AOT_ER_AAC_SCALABLE:
|
case AOT_ER_AAC_SCALABLE:
|
||||||
case AOT_ER_AAC_LD:
|
case AOT_ER_AAC_LD:
|
||||||
skip_bits(gb, 3); /* aacSectionDataResilienceFlag
|
skip_bits(gb, 3); /* aacSectionDataResilienceFlag
|
||||||
* aacScalefactorDataResilienceFlag
|
* aacScalefactorDataResilienceFlag
|
||||||
* aacSpectralDataResilienceFlag
|
* aacSpectralDataResilienceFlag
|
||||||
*/
|
*/
|
||||||
@@ -779,20 +824,24 @@ static int decode_audio_specific_config(AACContext *ac,
|
|||||||
int sync_extension)
|
int sync_extension)
|
||||||
{
|
{
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int i;
|
int i, ret;
|
||||||
|
|
||||||
av_dlog(avctx, "audio specific config size %d\n", bit_size >> 3);
|
av_dlog(avctx, "audio specific config size %d\n", bit_size >> 3);
|
||||||
for (i = 0; i < bit_size >> 3; i++)
|
for (i = 0; i < bit_size >> 3; i++)
|
||||||
av_dlog(avctx, "%02x ", data[i]);
|
av_dlog(avctx, "%02x ", data[i]);
|
||||||
av_dlog(avctx, "\n");
|
av_dlog(avctx, "\n");
|
||||||
|
|
||||||
init_get_bits(&gb, data, bit_size);
|
if ((ret = init_get_bits(&gb, data, bit_size)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, sync_extension)) < 0)
|
if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size,
|
||||||
return -1;
|
sync_extension)) < 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if (m4ac->sampling_index > 12) {
|
if (m4ac->sampling_index > 12) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
return -1;
|
"invalid sampling rate index %d\n",
|
||||||
|
m4ac->sampling_index);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_bits_long(&gb, i);
|
skip_bits_long(&gb, i);
|
||||||
@@ -801,18 +850,23 @@ static int decode_audio_specific_config(AACContext *ac,
|
|||||||
case AOT_AAC_MAIN:
|
case AOT_AAC_MAIN:
|
||||||
case AOT_AAC_LC:
|
case AOT_AAC_LC:
|
||||||
case AOT_AAC_LTP:
|
case AOT_AAC_LTP:
|
||||||
if (decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config))
|
if ((ret = decode_ga_specific_config(ac, avctx, &gb,
|
||||||
return -1;
|
m4ac, m4ac->chan_config)) < 0)
|
||||||
|
return ret;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
m4ac->sbr == 1? "SBR+" : "", m4ac->object_type);
|
"Audio object type %s%d is not supported.\n",
|
||||||
return -1;
|
m4ac->sbr == 1 ? "SBR+" : "",
|
||||||
|
m4ac->object_type);
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_dlog(avctx, "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
|
av_dlog(avctx,
|
||||||
|
"AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
|
||||||
m4ac->object_type, m4ac->chan_config, m4ac->sampling_index,
|
m4ac->object_type, m4ac->chan_config, m4ac->sampling_index,
|
||||||
m4ac->sample_rate, m4ac->sbr, m4ac->ps);
|
m4ac->sample_rate, m4ac->sbr,
|
||||||
|
m4ac->ps);
|
||||||
|
|
||||||
return get_bits_count(&gb);
|
return get_bits_count(&gb);
|
||||||
}
|
}
|
||||||
@@ -870,15 +924,18 @@ static void reset_predictor_group(PredictorState *ps, int group_num)
|
|||||||
reset_predict_state(&ps[i]);
|
reset_predict_state(&ps[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define AAC_INIT_VLC_STATIC(num, size) \
|
#define AAC_INIT_VLC_STATIC(num, size) \
|
||||||
INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
|
INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
|
||||||
ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
|
ff_aac_spectral_bits[num], sizeof(ff_aac_spectral_bits[num][0]), \
|
||||||
ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
|
sizeof(ff_aac_spectral_bits[num][0]), \
|
||||||
|
ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), \
|
||||||
|
sizeof(ff_aac_spectral_codes[num][0]), \
|
||||||
size);
|
size);
|
||||||
|
|
||||||
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
AACContext *ac = avctx->priv_data;
|
AACContext *ac = avctx->priv_data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ac->avctx = avctx;
|
ac->avctx = avctx;
|
||||||
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
|
ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
|
||||||
@@ -886,10 +943,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
|
|||||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
||||||
|
|
||||||
if (avctx->extradata_size > 0) {
|
if (avctx->extradata_size > 0) {
|
||||||
if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
|
if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
|
||||||
avctx->extradata,
|
avctx->extradata,
|
||||||
avctx->extradata_size*8, 1) < 0)
|
avctx->extradata_size * 8,
|
||||||
return -1;
|
1)) < 0)
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
int sr, i;
|
int sr, i;
|
||||||
uint8_t layout_map[MAX_ELEM_ID*4][3];
|
uint8_t layout_map[MAX_ELEM_ID*4][3];
|
||||||
@@ -947,9 +1005,14 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
ff_aac_tableinit();
|
ff_aac_tableinit();
|
||||||
|
|
||||||
INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
|
INIT_VLC_STATIC(&vlc_scalefactors, 7,
|
||||||
ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]),
|
FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
|
||||||
ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]),
|
ff_aac_scalefactor_bits,
|
||||||
|
sizeof(ff_aac_scalefactor_bits[0]),
|
||||||
|
sizeof(ff_aac_scalefactor_bits[0]),
|
||||||
|
ff_aac_scalefactor_code,
|
||||||
|
sizeof(ff_aac_scalefactor_code[0]),
|
||||||
|
sizeof(ff_aac_scalefactor_code[0]),
|
||||||
352);
|
352);
|
||||||
|
|
||||||
ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0));
|
ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0));
|
||||||
@@ -983,7 +1046,7 @@ static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
|
|||||||
|
|
||||||
if (get_bits_left(gb) < 8 * count) {
|
if (get_bits_left(gb) < 8 * count) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err);
|
av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
skip_bits_long(gb, 8 * count);
|
skip_bits_long(gb, 8 * count);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -995,9 +1058,11 @@ static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
|
|||||||
int sfb;
|
int sfb;
|
||||||
if (get_bits1(gb)) {
|
if (get_bits1(gb)) {
|
||||||
ics->predictor_reset_group = get_bits(gb, 5);
|
ics->predictor_reset_group = get_bits(gb, 5);
|
||||||
if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) {
|
if (ics->predictor_reset_group == 0 ||
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
|
ics->predictor_reset_group > 30) {
|
||||||
return -1;
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
|
"Invalid Predictor Reset Group.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) {
|
for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) {
|
||||||
@@ -1066,7 +1131,8 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC) {
|
} else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n");
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
|
"Prediction is not allowed in AAC-LC.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
if ((ics->ltp.present = get_bits(gb, 1)))
|
if ((ics->ltp.present = get_bits(gb, 1)))
|
||||||
@@ -1077,7 +1143,8 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
|
|||||||
|
|
||||||
if (ics->max_sfb > ics->num_swb) {
|
if (ics->max_sfb > ics->num_swb) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR,
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
"Number of scalefactor bands in group (%d) exceeds limit (%d).\n",
|
"Number of scalefactor bands in group (%d) "
|
||||||
|
"exceeds limit (%d).\n",
|
||||||
ics->max_sfb, ics->num_swb);
|
ics->max_sfb, ics->num_swb);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -1110,20 +1177,20 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120],
|
|||||||
int sect_band_type = get_bits(gb, 4);
|
int sect_band_type = get_bits(gb, 4);
|
||||||
if (sect_band_type == 12) {
|
if (sect_band_type == 12) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
|
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
sect_len_incr = get_bits(gb, bits);
|
sect_len_incr = get_bits(gb, bits);
|
||||||
sect_end += sect_len_incr;
|
sect_end += sect_len_incr;
|
||||||
if (get_bits_left(gb) < 0) {
|
if (get_bits_left(gb) < 0) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err);
|
av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (sect_end > ics->max_sfb) {
|
if (sect_end > ics->max_sfb) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR,
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
"Number of bands (%d) exceeds limit (%d).\n",
|
"Number of bands (%d) exceeds limit (%d).\n",
|
||||||
sect_end, ics->max_sfb);
|
sect_end, ics->max_sfb);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
} while (sect_len_incr == (1 << bits) - 1);
|
} while (sect_len_incr == (1 << bits) - 1);
|
||||||
for (; k < sect_end; k++) {
|
for (; k < sect_end; k++) {
|
||||||
@@ -1161,7 +1228,8 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
|||||||
if (band_type[idx] == ZERO_BT) {
|
if (band_type[idx] == ZERO_BT) {
|
||||||
for (; i < run_end; i++, idx++)
|
for (; i < run_end; i++, idx++)
|
||||||
sf[idx] = 0.;
|
sf[idx] = 0.;
|
||||||
} else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) {
|
} else if ((band_type[idx] == INTENSITY_BT) ||
|
||||||
|
(band_type[idx] == INTENSITY_BT2)) {
|
||||||
for (; i < run_end; i++, idx++) {
|
for (; i < run_end; i++, idx++) {
|
||||||
offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
|
offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
|
||||||
clipped_offset = av_clip(offset[2], -155, 100);
|
clipped_offset = av_clip(offset[2], -155, 100);
|
||||||
@@ -1194,7 +1262,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
|||||||
if (offset[0] > 255U) {
|
if (offset[0] > 255U) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR,
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
"Scalefactor (%d) out of range.\n", offset[0]);
|
"Scalefactor (%d) out of range.\n", offset[0]);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO];
|
sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO];
|
||||||
}
|
}
|
||||||
@@ -1249,10 +1317,11 @@ static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
|
|||||||
tns->length[w][filt] = get_bits(gb, 6 - 2 * is8);
|
tns->length[w][filt] = get_bits(gb, 6 - 2 * is8);
|
||||||
|
|
||||||
if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
|
if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
|
"TNS filter order %d is greater than maximum %d.\n",
|
||||||
tns->order[w][filt], tns_max_order);
|
tns->order[w][filt], tns_max_order);
|
||||||
tns->order[w][filt] = 0;
|
tns->order[w][filt] = 0;
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (tns->order[w][filt]) {
|
if (tns->order[w][filt]) {
|
||||||
tns->direction[w][filt] = get_bits1(gb);
|
tns->direction[w][filt] = get_bits1(gb);
|
||||||
@@ -1281,7 +1350,9 @@ static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb,
|
|||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
if (ms_present == 1) {
|
if (ms_present == 1) {
|
||||||
for (idx = 0; idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; idx++)
|
for (idx = 0;
|
||||||
|
idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb;
|
||||||
|
idx++)
|
||||||
cpe->ms_mask[idx] = get_bits1(gb);
|
cpe->ms_mask[idx] = get_bits1(gb);
|
||||||
} else if (ms_present == 2) {
|
} else if (ms_present == 2) {
|
||||||
memset(cpe->ms_mask, 1, sizeof(cpe->ms_mask[0]) * cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb);
|
memset(cpe->ms_mask, 1, sizeof(cpe->ms_mask[0]) * cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb);
|
||||||
@@ -1380,7 +1451,8 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
|
|||||||
float *coef_base = coef;
|
float *coef_base = coef;
|
||||||
|
|
||||||
for (g = 0; g < ics->num_windows; g++)
|
for (g = 0; g < ics->num_windows; g++)
|
||||||
memset(coef + g * 128 + offsets[ics->max_sfb], 0, sizeof(float) * (c - offsets[ics->max_sfb]));
|
memset(coef + g * 128 + offsets[ics->max_sfb], 0,
|
||||||
|
sizeof(float) * (c - offsets[ics->max_sfb]));
|
||||||
|
|
||||||
for (g = 0; g < ics->num_window_groups; g++) {
|
for (g = 0; g < ics->num_window_groups; g++) {
|
||||||
unsigned g_len = ics->group_len[g];
|
unsigned g_len = ics->group_len[g];
|
||||||
@@ -1535,7 +1607,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
|
|||||||
|
|
||||||
if (b > 8) {
|
if (b > 8) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
|
av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
SKIP_BITS(re, gb, b + 1);
|
SKIP_BITS(re, gb, b + 1);
|
||||||
@@ -1650,14 +1722,20 @@ static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
|
if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
|
||||||
for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; sfb++) {
|
for (sfb = 0;
|
||||||
for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
|
sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index];
|
||||||
|
sfb++) {
|
||||||
|
for (k = sce->ics.swb_offset[sfb];
|
||||||
|
k < sce->ics.swb_offset[sfb + 1];
|
||||||
|
k++) {
|
||||||
predict(&sce->predictor_state[k], &sce->coeffs[k],
|
predict(&sce->predictor_state[k], &sce->coeffs[k],
|
||||||
sce->ics.predictor_present && sce->ics.prediction_used[sfb]);
|
sce->ics.predictor_present &&
|
||||||
|
sce->ics.prediction_used[sfb]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sce->ics.predictor_reset_group)
|
if (sce->ics.predictor_reset_group)
|
||||||
reset_predictor_group(sce->predictor_state, sce->ics.predictor_reset_group);
|
reset_predictor_group(sce->predictor_state,
|
||||||
|
sce->ics.predictor_reset_group);
|
||||||
} else
|
} else
|
||||||
reset_all_predictors(sce->predictor_state);
|
reset_all_predictors(sce->predictor_state);
|
||||||
}
|
}
|
||||||
@@ -1678,6 +1756,7 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce,
|
|||||||
IndividualChannelStream *ics = &sce->ics;
|
IndividualChannelStream *ics = &sce->ics;
|
||||||
float *out = sce->coeffs;
|
float *out = sce->coeffs;
|
||||||
int global_gain, pulse_present = 0;
|
int global_gain, pulse_present = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* This assignment is to silence a GCC warning about the variable being used
|
/* This assignment is to silence a GCC warning about the variable being used
|
||||||
* uninitialized when in fact it always is.
|
* uninitialized when in fact it always is.
|
||||||
@@ -1691,33 +1770,38 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
|
if ((ret = decode_band_types(ac, sce->band_type,
|
||||||
return -1;
|
sce->band_type_run_end, gb, ics)) < 0)
|
||||||
if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
|
return ret;
|
||||||
return -1;
|
if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics,
|
||||||
|
sce->band_type, sce->band_type_run_end)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
pulse_present = 0;
|
pulse_present = 0;
|
||||||
if (!scale_flag) {
|
if (!scale_flag) {
|
||||||
if ((pulse_present = get_bits1(gb))) {
|
if ((pulse_present = get_bits1(gb))) {
|
||||||
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
|
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
return -1;
|
"Pulse tool not allowed in eight short sequence.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
|
if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
|
av_log(ac->avctx, AV_LOG_ERROR,
|
||||||
return -1;
|
"Pulse data corrupt or invalid.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
|
if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
if (get_bits1(gb)) {
|
if (get_bits1(gb)) {
|
||||||
av_log_missing_feature(ac->avctx, "SSR", 1);
|
av_log_missing_feature(ac->avctx, "SSR", 1);
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
|
if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present,
|
||||||
return -1;
|
&pulse, ics, sce->band_type) < 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window)
|
if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window)
|
||||||
apply_prediction(ac, sce);
|
apply_prediction(ac, sce);
|
||||||
@@ -1738,7 +1822,8 @@ static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
|
|||||||
for (g = 0; g < ics->num_window_groups; g++) {
|
for (g = 0; g < ics->num_window_groups; g++) {
|
||||||
for (i = 0; i < ics->max_sfb; i++, idx++) {
|
for (i = 0; i < ics->max_sfb; i++, idx++) {
|
||||||
if (cpe->ms_mask[idx] &&
|
if (cpe->ms_mask[idx] &&
|
||||||
cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
|
cpe->ch[0].band_type[idx] < NOISE_BT &&
|
||||||
|
cpe->ch[1].band_type[idx] < NOISE_BT) {
|
||||||
for (group = 0; group < ics->group_len[g]; group++) {
|
for (group = 0; group < ics->group_len[g]; group++) {
|
||||||
ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
|
ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
|
||||||
ch1 + group * 128 + offsets[i],
|
ch1 + group * 128 + offsets[i],
|
||||||
@@ -1758,7 +1843,8 @@ static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
|
|||||||
* [1] mask is decoded from bitstream; [2] mask is all 1s;
|
* [1] mask is decoded from bitstream; [2] mask is all 1s;
|
||||||
* [3] reserved for scalable AAC
|
* [3] reserved for scalable AAC
|
||||||
*/
|
*/
|
||||||
static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_present)
|
static void apply_intensity_stereo(AACContext *ac,
|
||||||
|
ChannelElement *cpe, int ms_present)
|
||||||
{
|
{
|
||||||
const IndividualChannelStream *ics = &cpe->ch[1].ics;
|
const IndividualChannelStream *ics = &cpe->ch[1].ics;
|
||||||
SingleChannelElement *sce1 = &cpe->ch[1];
|
SingleChannelElement *sce1 = &cpe->ch[1];
|
||||||
@@ -1769,7 +1855,8 @@ static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_p
|
|||||||
float scale;
|
float scale;
|
||||||
for (g = 0; g < ics->num_window_groups; g++) {
|
for (g = 0; g < ics->num_window_groups; g++) {
|
||||||
for (i = 0; i < ics->max_sfb;) {
|
for (i = 0; i < ics->max_sfb;) {
|
||||||
if (sce1->band_type[idx] == INTENSITY_BT || sce1->band_type[idx] == INTENSITY_BT2) {
|
if (sce1->band_type[idx] == INTENSITY_BT ||
|
||||||
|
sce1->band_type[idx] == INTENSITY_BT2) {
|
||||||
const int bt_run_end = sce1->band_type_run_end[idx];
|
const int bt_run_end = sce1->band_type_run_end[idx];
|
||||||
for (; i < bt_run_end; i++, idx++) {
|
for (; i < bt_run_end; i++, idx++) {
|
||||||
c = -1 + 2 * (sce1->band_type[idx] - 14);
|
c = -1 + 2 * (sce1->band_type[idx] - 14);
|
||||||
@@ -1809,13 +1896,14 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
|
|||||||
i = cpe->ch[1].ics.use_kb_window[0];
|
i = cpe->ch[1].ics.use_kb_window[0];
|
||||||
cpe->ch[1].ics = cpe->ch[0].ics;
|
cpe->ch[1].ics = cpe->ch[0].ics;
|
||||||
cpe->ch[1].ics.use_kb_window[1] = i;
|
cpe->ch[1].ics.use_kb_window[1] = i;
|
||||||
if (cpe->ch[1].ics.predictor_present && (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN))
|
if (cpe->ch[1].ics.predictor_present &&
|
||||||
|
(ac->oc[1].m4ac.object_type != AOT_AAC_MAIN))
|
||||||
if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1)))
|
if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1)))
|
||||||
decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
|
decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
|
||||||
ms_present = get_bits(gb, 2);
|
ms_present = get_bits(gb, 2);
|
||||||
if (ms_present == 3) {
|
if (ms_present == 3) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
|
av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
} else if (ms_present)
|
} else if (ms_present)
|
||||||
decode_mid_side_stereo(cpe, gb, ms_present);
|
decode_mid_side_stereo(cpe, gb, ms_present);
|
||||||
}
|
}
|
||||||
@@ -2676,7 +2764,8 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
if (ac->force_dmono_mode >= 0)
|
if (ac->force_dmono_mode >= 0)
|
||||||
ac->dmono_mode = ac->force_dmono_mode;
|
ac->dmono_mode = ac->force_dmono_mode;
|
||||||
|
|
||||||
init_get_bits(&gb, buf, buf_size * 8);
|
if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt)) < 0)
|
if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt)) < 0)
|
||||||
return err;
|
return err;
|
||||||
@@ -2712,13 +2801,13 @@ static av_cold int aac_decode_close(AVCodecContext *avctx)
|
|||||||
#define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
|
#define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
|
||||||
|
|
||||||
struct LATMContext {
|
struct LATMContext {
|
||||||
AACContext aac_ctx; ///< containing AACContext
|
AACContext aac_ctx; ///< containing AACContext
|
||||||
int initialized; ///< initialized after a valid extradata was seen
|
int initialized; ///< initilized after a valid extradata was seen
|
||||||
|
|
||||||
// parser data
|
// parser data
|
||||||
int audio_mux_version_A; ///< LATM syntax version
|
int audio_mux_version_A; ///< LATM syntax version
|
||||||
int frame_length_type; ///< 0/1 variable/fixed frame length
|
int frame_length_type; ///< 0/1 variable/fixed frame length
|
||||||
int frame_length; ///< frame length for fixed frame length
|
int frame_length; ///< frame length for fixed frame length
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline uint32_t latm_get_value(GetBitContext *b)
|
static inline uint32_t latm_get_value(GetBitContext *b)
|
||||||
@@ -2926,7 +3015,8 @@ static int latm_decode_frame(AVCodecContext *avctx, void *out,
|
|||||||
int muxlength, err;
|
int muxlength, err;
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
|
|
||||||
init_get_bits(&gb, avpkt->data, avpkt->size * 8);
|
if ((err = init_get_bits(&gb, avpkt->data, avpkt->size * 8)) < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
// check for LOAS sync word
|
// check for LOAS sync word
|
||||||
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
|
if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
|
||||||
|
@@ -292,7 +292,7 @@ static int parse_frame_header(AC3DecodeContext *s)
|
|||||||
return ff_eac3_parse_header(s);
|
return ff_eac3_parse_header(s);
|
||||||
} else {
|
} else {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "E-AC-3 support not compiled in\n");
|
av_log(s->avctx, AV_LOG_ERROR, "E-AC-3 support not compiled in\n");
|
||||||
return -1;
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,12 +787,12 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
if (start_subband >= end_subband) {
|
if (start_subband >= end_subband) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
|
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
|
||||||
"range (%d >= %d)\n", start_subband, end_subband);
|
"range (%d >= %d)\n", start_subband, end_subband);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (dst_start_freq >= src_start_freq) {
|
if (dst_start_freq >= src_start_freq) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
|
av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
|
||||||
"copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
|
"copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->spx_dst_start_freq = dst_start_freq;
|
s->spx_dst_start_freq = dst_start_freq;
|
||||||
@@ -869,7 +869,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
|
|
||||||
if (channel_mode < AC3_CHMODE_STEREO) {
|
if (channel_mode < AC3_CHMODE_STEREO) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n");
|
av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for enhanced coupling */
|
/* check for enhanced coupling */
|
||||||
@@ -899,7 +899,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
if (cpl_start_subband >= cpl_end_subband) {
|
if (cpl_start_subband >= cpl_end_subband) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n",
|
av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n",
|
||||||
cpl_start_subband, cpl_end_subband);
|
cpl_start_subband, cpl_end_subband);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;
|
s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;
|
||||||
s->end_freq[CPL_CH] = cpl_end_subband * 12 + 37;
|
s->end_freq[CPL_CH] = cpl_end_subband * 12 + 37;
|
||||||
@@ -921,7 +921,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
if (!blk) {
|
if (!blk) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "
|
av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "
|
||||||
"be present in block 0\n");
|
"be present in block 0\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
} else {
|
} else {
|
||||||
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
|
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
|
||||||
}
|
}
|
||||||
@@ -951,7 +951,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
} else if (!blk) {
|
} else if (!blk) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "
|
av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "
|
||||||
"be present in block 0\n");
|
"be present in block 0\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* channel not in coupling */
|
/* channel not in coupling */
|
||||||
@@ -1006,7 +1006,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
int bandwidth_code = get_bits(gbc, 6);
|
int bandwidth_code = get_bits(gbc, 6);
|
||||||
if (bandwidth_code > 60) {
|
if (bandwidth_code > 60) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\n", bandwidth_code);
|
av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\n", bandwidth_code);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
s->end_freq[ch] = bandwidth_code * 3 + 73;
|
s->end_freq[ch] = bandwidth_code * 3 + 73;
|
||||||
}
|
}
|
||||||
@@ -1029,7 +1029,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
s->num_exp_groups[ch], s->dexps[ch][0],
|
s->num_exp_groups[ch], s->dexps[ch][0],
|
||||||
&s->dexps[ch][s->start_freq[ch]+!!ch])) {
|
&s->dexps[ch][s->start_freq[ch]+!!ch])) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n");
|
av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (ch != CPL_CH && ch != s->lfe_ch)
|
if (ch != CPL_CH && ch != s->lfe_ch)
|
||||||
skip_bits(gbc, 2); /* skip gainrng */
|
skip_bits(gbc, 2); /* skip gainrng */
|
||||||
@@ -1049,7 +1049,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
} else if (!blk) {
|
} else if (!blk) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
|
av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
|
||||||
"be present in block 0\n");
|
"be present in block 0\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +1080,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
}
|
}
|
||||||
} else if (!s->eac3 && !blk) {
|
} else if (!s->eac3 && !blk) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n");
|
av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1119,7 +1119,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
} else if (!s->eac3 && !blk) {
|
} else if (!s->eac3 && !blk) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "
|
av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "
|
||||||
"be present in block 0\n");
|
"be present in block 0\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
s->first_cpl_leak = 0;
|
s->first_cpl_leak = 0;
|
||||||
}
|
}
|
||||||
@@ -1131,7 +1131,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
s->dba_mode[ch] = get_bits(gbc, 2);
|
s->dba_mode[ch] = get_bits(gbc, 2);
|
||||||
if (s->dba_mode[ch] == DBA_RESERVED) {
|
if (s->dba_mode[ch] == DBA_RESERVED) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
|
av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
|
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
|
||||||
}
|
}
|
||||||
@@ -1172,7 +1172,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
|||||||
s->dba_offsets[ch], s->dba_lengths[ch],
|
s->dba_offsets[ch], s->dba_lengths[ch],
|
||||||
s->dba_values[ch], s->mask[ch])) {
|
s->dba_values[ch], s->mask[ch])) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n");
|
av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bit_alloc_stages[ch] > 0) {
|
if (bit_alloc_stages[ch] > 0) {
|
||||||
@@ -1291,7 +1291,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
|||||||
switch (err) {
|
switch (err) {
|
||||||
case AAC_AC3_PARSE_ERROR_SYNC:
|
case AAC_AC3_PARSE_ERROR_SYNC:
|
||||||
av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
|
av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
case AAC_AC3_PARSE_ERROR_BSID:
|
case AAC_AC3_PARSE_ERROR_BSID:
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
|
||||||
break;
|
break;
|
||||||
@@ -1305,17 +1305,20 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
|||||||
/* skip frame if CRC is ok. otherwise use error concealment. */
|
/* skip frame if CRC is ok. otherwise use error concealment. */
|
||||||
/* TODO: add support for substreams and dependent frames */
|
/* TODO: add support for substreams and dependent frames */
|
||||||
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
|
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "
|
av_log(avctx, AV_LOG_WARNING, "unsupported frame type : "
|
||||||
"skipping frame\n");
|
"skipping frame\n");
|
||||||
*got_frame_ptr = 0;
|
*got_frame_ptr = 0;
|
||||||
return s->frame_size;
|
return buf_size;
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case AAC_AC3_PARSE_ERROR_CRC:
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid header\n");
|
case AAC_AC3_PARSE_ERROR_CHANNEL_CFG:
|
||||||
break;
|
break;
|
||||||
|
default: // Normal AVERROR do not try to recover.
|
||||||
|
*got_frame_ptr = 0;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* check that reported frame size fits in input buffer */
|
/* check that reported frame size fits in input buffer */
|
||||||
|
@@ -47,13 +47,8 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
offset = AV_RB16(buf + 2) + 4;
|
offset = AV_RB16(buf + 2) + 4;
|
||||||
|
|
||||||
if (offset < 6) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "offset is prior data\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if copyright string is within the provided data, validate it */
|
/* if copyright string is within the provided data, validate it */
|
||||||
if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6))
|
if (bufsize >= offset && offset >= 6 && memcmp(buf + offset - 6, "(c)CRI", 6))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* check for encoding=3 block_size=18, sample_size=4 */
|
/* check for encoding=3 block_size=18, sample_size=4 */
|
||||||
|
@@ -321,6 +321,9 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
|
|||||||
rice_history_mult[ch] = get_bits(&alac->gb, 3);
|
rice_history_mult[ch] = get_bits(&alac->gb, 3);
|
||||||
lpc_order[ch] = get_bits(&alac->gb, 5);
|
lpc_order[ch] = get_bits(&alac->gb, 5);
|
||||||
|
|
||||||
|
if (lpc_order[ch] >= alac->max_samples_per_frame)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* read the predictor table */
|
/* read the predictor table */
|
||||||
for (i = lpc_order[ch] - 1; i >= 0; i--)
|
for (i = lpc_order[ch] - 1; i >= 0; i--)
|
||||||
lpc_coefs[ch][i] = get_sbits(&alac->gb, 16);
|
lpc_coefs[ch][i] = get_sbits(&alac->gb, 16);
|
||||||
@@ -462,9 +465,8 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
channels = (element == TYPE_CPE) ? 2 : 1;
|
channels = (element == TYPE_CPE) ? 2 : 1;
|
||||||
if ( ch + channels > alac->channels
|
if (ch + channels > alac->channels ||
|
||||||
|| ff_alac_channel_layout_offsets[alac->channels - 1][ch] + channels > alac->channels
|
ff_alac_channel_layout_offsets[alac->channels - 1][ch] + channels > alac->channels) {
|
||||||
) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid element channel count\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid element channel count\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -546,7 +548,8 @@ static int alac_set_info(ALACContext *alac)
|
|||||||
bytestream2_skipu(&gb, 12); // size:4, alac:4, version:4
|
bytestream2_skipu(&gb, 12); // size:4, alac:4, version:4
|
||||||
|
|
||||||
alac->max_samples_per_frame = bytestream2_get_be32u(&gb);
|
alac->max_samples_per_frame = bytestream2_get_be32u(&gb);
|
||||||
if (!alac->max_samples_per_frame || alac->max_samples_per_frame > INT_MAX) {
|
if (!alac->max_samples_per_frame ||
|
||||||
|
alac->max_samples_per_frame > INT_MAX / sizeof(int32_t)) {
|
||||||
av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
|
av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
|
||||||
alac->max_samples_per_frame);
|
alac->max_samples_per_frame);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
@@ -275,7 +275,7 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch)
|
|||||||
// generate warm-up samples
|
// generate warm-up samples
|
||||||
residual[0] = samples[0];
|
residual[0] = samples[0];
|
||||||
for (i = 1; i <= lpc.lpc_order; i++)
|
for (i = 1; i <= lpc.lpc_order; i++)
|
||||||
residual[i] = samples[i] - samples[i-1];
|
residual[i] = sign_extend(samples[i] - samples[i-1], s->write_sample_size);
|
||||||
|
|
||||||
// perform lpc on remaining samples
|
// perform lpc on remaining samples
|
||||||
for (i = lpc.lpc_order + 1; i < s->frame_size; i++) {
|
for (i = lpc.lpc_order + 1; i < s->frame_size; i++) {
|
||||||
|
@@ -296,12 +296,12 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
avctx->extradata_size * 8, 1);
|
avctx->extradata_size * 8, 1);
|
||||||
|
|
||||||
if (config_offset < 0)
|
if (config_offset < 0)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
skip_bits_long(&gb, config_offset);
|
skip_bits_long(&gb, config_offset);
|
||||||
|
|
||||||
if (get_bits_left(&gb) < (30 << 3))
|
if (get_bits_left(&gb) < (30 << 3))
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
// read the fixed items
|
// read the fixed items
|
||||||
als_id = get_bits_long(&gb, 32);
|
als_id = get_bits_long(&gb, 32);
|
||||||
@@ -336,7 +336,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
|
|
||||||
// check for ALSSpecificConfig struct
|
// check for ALSSpecificConfig struct
|
||||||
if (als_id != MKBETAG('A','L','S','\0'))
|
if (als_id != MKBETAG('A','L','S','\0'))
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
ctx->cur_frame_length = sconf->frame_length;
|
ctx->cur_frame_length = sconf->frame_length;
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
int chan_pos_bits = av_ceil_log2(avctx->channels);
|
int chan_pos_bits = av_ceil_log2(avctx->channels);
|
||||||
int bits_needed = avctx->channels * chan_pos_bits + 7;
|
int bits_needed = avctx->channels * chan_pos_bits + 7;
|
||||||
if (get_bits_left(&gb) < bits_needed)
|
if (get_bits_left(&gb) < bits_needed)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (!(sconf->chan_pos = av_malloc(avctx->channels * sizeof(*sconf->chan_pos))))
|
if (!(sconf->chan_pos = av_malloc(avctx->channels * sizeof(*sconf->chan_pos))))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -377,7 +377,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
// read fixed header and trailer sizes,
|
// read fixed header and trailer sizes,
|
||||||
// if size = 0xFFFFFFFF then there is no data field!
|
// if size = 0xFFFFFFFF then there is no data field!
|
||||||
if (get_bits_left(&gb) < 64)
|
if (get_bits_left(&gb) < 64)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
header_size = get_bits_long(&gb, 32);
|
header_size = get_bits_long(&gb, 32);
|
||||||
trailer_size = get_bits_long(&gb, 32);
|
trailer_size = get_bits_long(&gb, 32);
|
||||||
@@ -391,10 +391,10 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
|
|
||||||
// skip the header and trailer data
|
// skip the header and trailer data
|
||||||
if (get_bits_left(&gb) < ht_size)
|
if (get_bits_left(&gb) < ht_size)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (ht_size > INT32_MAX)
|
if (ht_size > INT32_MAX)
|
||||||
return -1;
|
return AVERROR_PATCHWELCOME;
|
||||||
|
|
||||||
skip_bits_long(&gb, ht_size);
|
skip_bits_long(&gb, ht_size);
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
// initialize CRC calculation
|
// initialize CRC calculation
|
||||||
if (sconf->crc_enabled) {
|
if (sconf->crc_enabled) {
|
||||||
if (get_bits_left(&gb) < 32)
|
if (get_bits_left(&gb) < 32)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
|
if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
|
||||||
ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
|
ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
|
||||||
@@ -646,7 +646,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
|||||||
if (bd->block_length & (sub_blocks - 1)) {
|
if (bd->block_length & (sub_blocks - 1)) {
|
||||||
av_log(avctx, AV_LOG_WARNING,
|
av_log(avctx, AV_LOG_WARNING,
|
||||||
"Block length is not evenly divisible by the number of subblocks.\n");
|
"Block length is not evenly divisible by the number of subblocks.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb_length = bd->block_length >> log2_sub_blocks;
|
sb_length = bd->block_length >> log2_sub_blocks;
|
||||||
@@ -983,14 +983,13 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
|
|||||||
*bd->shift_lsbs = 0;
|
*bd->shift_lsbs = 0;
|
||||||
// read block type flag and read the samples accordingly
|
// read block type flag and read the samples accordingly
|
||||||
if (get_bits1(gb)) {
|
if (get_bits1(gb)) {
|
||||||
if ((ret = read_var_block_data(ctx, bd)) < 0)
|
ret = read_var_block_data(ctx, bd);
|
||||||
return ret;
|
|
||||||
} else {
|
} else {
|
||||||
if ((ret = read_const_block_data(ctx, bd)) < 0)
|
if ((ret = read_const_block_data(ctx, bd)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -999,12 +998,16 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
|
|||||||
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
|
static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
|
||||||
{
|
{
|
||||||
unsigned int smp;
|
unsigned int smp;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
// read block type flag and read the samples accordingly
|
// read block type flag and read the samples accordingly
|
||||||
if (*bd->const_block)
|
if (*bd->const_block)
|
||||||
decode_const_block_data(ctx, bd);
|
decode_const_block_data(ctx, bd);
|
||||||
else if (decode_var_block_data(ctx, bd))
|
else
|
||||||
return -1;
|
ret = decode_var_block_data(ctx, bd); // always return 0
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
// TODO: read RLSLMS extension data
|
// TODO: read RLSLMS extension data
|
||||||
|
|
||||||
@@ -1022,14 +1025,10 @@ static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = read_block(ctx, bd);
|
if ((ret = read_block(ctx, bd)) < 0)
|
||||||
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = decode_block(ctx, bd);
|
return decode_block(ctx, bd);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1055,6 +1054,7 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
|
|||||||
unsigned int c, const unsigned int *div_blocks,
|
unsigned int c, const unsigned int *div_blocks,
|
||||||
unsigned int *js_blocks)
|
unsigned int *js_blocks)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
unsigned int b;
|
unsigned int b;
|
||||||
ALSBlockData bd = { 0 };
|
ALSBlockData bd = { 0 };
|
||||||
|
|
||||||
@@ -1075,10 +1075,10 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
|
|||||||
for (b = 0; b < ctx->num_blocks; b++) {
|
for (b = 0; b < ctx->num_blocks; b++) {
|
||||||
bd.block_length = div_blocks[b];
|
bd.block_length = div_blocks[b];
|
||||||
|
|
||||||
if (read_decode_block(ctx, &bd)) {
|
if ((ret = read_decode_block(ctx, &bd)) < 0) {
|
||||||
// damaged block, write zero for the rest of the frame
|
// damaged block, write zero for the rest of the frame
|
||||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples);
|
zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples);
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
bd.raw_samples += div_blocks[b];
|
bd.raw_samples += div_blocks[b];
|
||||||
bd.ra_block = 0;
|
bd.ra_block = 0;
|
||||||
@@ -1097,6 +1097,7 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
|
|||||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
unsigned int b;
|
unsigned int b;
|
||||||
|
int ret;
|
||||||
ALSBlockData bd[2] = { { 0 } };
|
ALSBlockData bd[2] = { { 0 } };
|
||||||
|
|
||||||
bd[0].ra_block = ra_frame;
|
bd[0].ra_block = ra_frame;
|
||||||
@@ -1138,12 +1139,9 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
|
|||||||
bd[0].raw_other = bd[1].raw_samples;
|
bd[0].raw_other = bd[1].raw_samples;
|
||||||
bd[1].raw_other = bd[0].raw_samples;
|
bd[1].raw_other = bd[0].raw_samples;
|
||||||
|
|
||||||
if(read_decode_block(ctx, &bd[0]) || read_decode_block(ctx, &bd[1])) {
|
if ((ret = read_decode_block(ctx, &bd[0])) < 0 ||
|
||||||
// damaged block, write zero for the rest of the frame
|
(ret = read_decode_block(ctx, &bd[1])) < 0)
|
||||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd[0].raw_samples);
|
goto fail;
|
||||||
zero_remaining(b, ctx->num_blocks, div_blocks, bd[1].raw_samples);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reconstruct joint-stereo blocks
|
// reconstruct joint-stereo blocks
|
||||||
if (bd[0].js_blocks) {
|
if (bd[0].js_blocks) {
|
||||||
@@ -1169,8 +1167,19 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
|
|||||||
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
|
sizeof(*ctx->raw_samples[c]) * sconf->max_order);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
fail:
|
||||||
|
// damaged block, write zero for the rest of the frame
|
||||||
|
zero_remaining(b, ctx->num_blocks, div_blocks, bd[0].raw_samples);
|
||||||
|
zero_remaining(b, ctx->num_blocks, div_blocks, bd[1].raw_samples);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int als_weighting(GetBitContext *gb, int k, int off)
|
||||||
|
{
|
||||||
|
int idx = av_clip(decode_rice(gb, k) + off,
|
||||||
|
0, FF_ARRAY_ELEMS(mcc_weightings) - 1);
|
||||||
|
return mcc_weightings[idx];
|
||||||
|
}
|
||||||
|
|
||||||
/** Read the channel data.
|
/** Read the channel data.
|
||||||
*/
|
*/
|
||||||
@@ -1186,19 +1195,19 @@ static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
|
|||||||
|
|
||||||
if (current->master_channel >= channels) {
|
if (current->master_channel >= channels) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel.\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current->master_channel != c) {
|
if (current->master_channel != c) {
|
||||||
current->time_diff_flag = get_bits1(gb);
|
current->time_diff_flag = get_bits1(gb);
|
||||||
current->weighting[0] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
|
current->weighting[0] = als_weighting(gb, 1, 16);
|
||||||
current->weighting[1] = mcc_weightings[av_clip(decode_rice(gb, 2) + 14, 0, 31)];
|
current->weighting[1] = als_weighting(gb, 2, 14);
|
||||||
current->weighting[2] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
|
current->weighting[2] = als_weighting(gb, 1, 16);
|
||||||
|
|
||||||
if (current->time_diff_flag) {
|
if (current->time_diff_flag) {
|
||||||
current->weighting[3] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
|
current->weighting[3] = als_weighting(gb, 1, 16);
|
||||||
current->weighting[4] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
|
current->weighting[4] = als_weighting(gb, 1, 16);
|
||||||
current->weighting[5] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
|
current->weighting[5] = als_weighting(gb, 1, 16);
|
||||||
|
|
||||||
current->time_diff_sign = get_bits1(gb);
|
current->time_diff_sign = get_bits1(gb);
|
||||||
current->time_diff_index = get_bits(gb, ctx->ltp_lag_length - 3) + 3;
|
current->time_diff_index = get_bits(gb, ctx->ltp_lag_length - 3) + 3;
|
||||||
@@ -1211,7 +1220,7 @@ static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
|
|||||||
|
|
||||||
if (entries == channels) {
|
if (entries == channels) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data.\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
align_get_bits(gb);
|
align_get_bits(gb);
|
||||||
@@ -1243,7 +1252,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
|||||||
|
|
||||||
if (dep == channels) {
|
if (dep == channels) {
|
||||||
av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation.\n");
|
av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
bd->const_block = ctx->const_block + c;
|
bd->const_block = ctx->const_block + c;
|
||||||
@@ -1314,8 +1323,8 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
|||||||
unsigned int div_blocks[32]; ///< block sizes.
|
unsigned int div_blocks[32]; ///< block sizes.
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
unsigned int js_blocks[2];
|
unsigned int js_blocks[2];
|
||||||
|
|
||||||
uint32_t bs_info = 0;
|
uint32_t bs_info = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
// skip the size of the ra unit if present in the frame
|
// skip the size of the ra unit if present in the frame
|
||||||
if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
|
if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
|
||||||
@@ -1346,13 +1355,15 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
|||||||
independent_bs = 1;
|
independent_bs = 1;
|
||||||
|
|
||||||
if (independent_bs) {
|
if (independent_bs) {
|
||||||
if (decode_blocks_ind(ctx, ra_frame, c, div_blocks, js_blocks))
|
ret = decode_blocks_ind(ctx, ra_frame, c,
|
||||||
return -1;
|
div_blocks, js_blocks);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
independent_bs--;
|
independent_bs--;
|
||||||
} else {
|
} else {
|
||||||
if (decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks))
|
ret = decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks);
|
||||||
return -1;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
@@ -1371,7 +1382,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
|||||||
for (c = 0; c < avctx->channels; c++)
|
for (c = 0; c < avctx->channels; c++)
|
||||||
if (ctx->chan_data[c] < ctx->chan_data_buffer) {
|
if (ctx->chan_data[c] < ctx->chan_data_buffer) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
|
memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
|
||||||
@@ -1383,6 +1394,11 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
|||||||
|
|
||||||
for (b = 0; b < ctx->num_blocks; b++) {
|
for (b = 0; b < ctx->num_blocks; b++) {
|
||||||
bd.block_length = div_blocks[b];
|
bd.block_length = div_blocks[b];
|
||||||
|
if (bd.block_length <= 0) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_WARNING,
|
||||||
|
"Invalid block length %d in channel data!\n", bd.block_length);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (c = 0; c < avctx->channels; c++) {
|
for (c = 0; c < avctx->channels; c++) {
|
||||||
bd.const_block = ctx->const_block + c;
|
bd.const_block = ctx->const_block + c;
|
||||||
@@ -1403,11 +1419,12 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = 0; c < avctx->channels; c++)
|
for (c = 0; c < avctx->channels; c++) {
|
||||||
if (revert_channel_correlation(ctx, &bd, ctx->chan_data,
|
ret = revert_channel_correlation(ctx, &bd, ctx->chan_data,
|
||||||
reverted_channels, offset, c))
|
reverted_channels, offset, c);
|
||||||
return -1;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
for (c = 0; c < avctx->channels; c++) {
|
for (c = 0; c < avctx->channels; c++) {
|
||||||
bd.const_block = ctx->const_block + c;
|
bd.const_block = ctx->const_block + c;
|
||||||
bd.shift_lsbs = ctx->shift_lsbs + c;
|
bd.shift_lsbs = ctx->shift_lsbs + c;
|
||||||
@@ -1612,30 +1629,30 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
unsigned int channel_size;
|
unsigned int channel_size;
|
||||||
int num_buffers;
|
int num_buffers, ret;
|
||||||
ALSDecContext *ctx = avctx->priv_data;
|
ALSDecContext *ctx = avctx->priv_data;
|
||||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||||
ctx->avctx = avctx;
|
ctx->avctx = avctx;
|
||||||
|
|
||||||
if (!avctx->extradata) {
|
if (!avctx->extradata) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Missing required ALS extradata.\n");
|
av_log(avctx, AV_LOG_ERROR, "Missing required ALS extradata.\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_specific_config(ctx)) {
|
if ((ret = read_specific_config(ctx)) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n");
|
av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n");
|
||||||
decode_end(avctx);
|
goto fail;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_specific_config(ctx)) {
|
if ((ret = check_specific_config(ctx)) < 0) {
|
||||||
decode_end(avctx);
|
goto fail;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sconf->bgmc)
|
if (sconf->bgmc) {
|
||||||
ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
|
ret = ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
|
||||||
|
if (ret < 0)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
if (sconf->floating) {
|
if (sconf->floating) {
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||||
avctx->bits_per_raw_sample = 32;
|
avctx->bits_per_raw_sample = 32;
|
||||||
@@ -1670,7 +1687,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
!ctx->quant_cof_buffer || !ctx->lpc_cof_buffer ||
|
!ctx->quant_cof_buffer || !ctx->lpc_cof_buffer ||
|
||||||
!ctx->lpc_cof_reversed_buffer) {
|
!ctx->lpc_cof_reversed_buffer) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||||
return AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign quantized parcor coefficient buffers
|
// assign quantized parcor coefficient buffers
|
||||||
@@ -1695,8 +1713,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
!ctx->use_ltp || !ctx->ltp_lag ||
|
!ctx->use_ltp || !ctx->ltp_lag ||
|
||||||
!ctx->ltp_gain || !ctx->ltp_gain_buffer) {
|
!ctx->ltp_gain || !ctx->ltp_gain_buffer) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||||
decode_end(avctx);
|
ret = AVERROR(ENOMEM);
|
||||||
return AVERROR(ENOMEM);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = 0; c < num_buffers; c++)
|
for (c = 0; c < num_buffers; c++)
|
||||||
@@ -1713,8 +1731,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
if (!ctx->chan_data_buffer || !ctx->chan_data || !ctx->reverted_channels) {
|
if (!ctx->chan_data_buffer || !ctx->chan_data || !ctx->reverted_channels) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||||
decode_end(avctx);
|
ret = AVERROR(ENOMEM);
|
||||||
return AVERROR(ENOMEM);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = 0; c < num_buffers; c++)
|
for (c = 0; c < num_buffers; c++)
|
||||||
@@ -1734,8 +1752,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
// allocate previous raw sample buffer
|
// allocate previous raw sample buffer
|
||||||
if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
|
if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||||
decode_end(avctx);
|
ret = AVERROR(ENOMEM);
|
||||||
return AVERROR(ENOMEM);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign raw samples buffers
|
// assign raw samples buffers
|
||||||
@@ -1752,8 +1770,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
av_get_bytes_per_sample(avctx->sample_fmt));
|
av_get_bytes_per_sample(avctx->sample_fmt));
|
||||||
if (!ctx->crc_buffer) {
|
if (!ctx->crc_buffer) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
|
||||||
decode_end(avctx);
|
ret = AVERROR(ENOMEM);
|
||||||
return AVERROR(ENOMEM);
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1763,6 +1781,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
avctx->coded_frame = &ctx->frame;
|
avctx->coded_frame = &ctx->frame;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
decode_end(avctx);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -415,7 +415,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
switch(buf[0]) {
|
switch(buf[0]) {
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
if (s->nb_args < MAX_NB_ARGS)
|
if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553)
|
||||||
s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
|
s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0';
|
||||||
break;
|
break;
|
||||||
case ';':
|
case ';':
|
||||||
|
@@ -144,10 +144,11 @@ function ff_put_pixels8_y2_armv6, export=1
|
|||||||
eor r7, r5, r7
|
eor r7, r5, r7
|
||||||
uadd8 r10, r10, r6
|
uadd8 r10, r10, r6
|
||||||
and r7, r7, r12
|
and r7, r7, r12
|
||||||
ldr_pre r6, r1, r2
|
ldrc_pre ne, r6, r1, r2
|
||||||
uadd8 r11, r11, r7
|
uadd8 r11, r11, r7
|
||||||
strd_post r8, r9, r0, r2
|
strd_post r8, r9, r0, r2
|
||||||
ldr r7, [r1, #4]
|
it ne
|
||||||
|
ldrne r7, [r1, #4]
|
||||||
strd_post r10, r11, r0, r2
|
strd_post r10, r11, r0, r2
|
||||||
bne 1b
|
bne 1b
|
||||||
|
|
||||||
@@ -196,9 +197,10 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1
|
|||||||
uhadd8 r9, r5, r7
|
uhadd8 r9, r5, r7
|
||||||
ldr r5, [r1, #4]
|
ldr r5, [r1, #4]
|
||||||
uhadd8 r12, r4, r6
|
uhadd8 r12, r4, r6
|
||||||
ldr_pre r6, r1, r2
|
ldrc_pre ne, r6, r1, r2
|
||||||
uhadd8 r14, r5, r7
|
uhadd8 r14, r5, r7
|
||||||
ldr r7, [r1, #4]
|
it ne
|
||||||
|
ldrne r7, [r1, #4]
|
||||||
stm r0, {r8,r9}
|
stm r0, {r8,r9}
|
||||||
add r0, r0, r2
|
add r0, r0, r2
|
||||||
stm r0, {r12,r14}
|
stm r0, {r12,r14}
|
||||||
|
@@ -91,7 +91,7 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const i
|
|||||||
c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
|
c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
|
||||||
c->h264_idct_add16 = ff_h264_idct_add16_neon;
|
c->h264_idct_add16 = ff_h264_idct_add16_neon;
|
||||||
c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
|
c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
|
||||||
if (chroma_format_idc == 1)
|
if (chroma_format_idc <= 1)
|
||||||
c->h264_idct_add8 = ff_h264_idct_add8_neon;
|
c->h264_idct_add8 = ff_h264_idct_add8_neon;
|
||||||
c->h264_idct8_add = ff_h264_idct8_add_neon;
|
c->h264_idct8_add = ff_h264_idct8_add_neon;
|
||||||
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
|
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
|
||||||
|
@@ -41,10 +41,10 @@ function ff_scalarproduct_int16_neon, export=1
|
|||||||
|
|
||||||
vpadd.s32 d16, d0, d1
|
vpadd.s32 d16, d0, d1
|
||||||
vpadd.s32 d17, d2, d3
|
vpadd.s32 d17, d2, d3
|
||||||
vpadd.s32 d10, d4, d5
|
vpadd.s32 d18, d4, d5
|
||||||
vpadd.s32 d11, d6, d7
|
vpadd.s32 d19, d6, d7
|
||||||
vpadd.s32 d0, d16, d17
|
vpadd.s32 d0, d16, d17
|
||||||
vpadd.s32 d1, d10, d11
|
vpadd.s32 d1, d18, d19
|
||||||
vpadd.s32 d2, d0, d1
|
vpadd.s32 d2, d0, d1
|
||||||
vpaddl.s32 d3, d2
|
vpaddl.s32 d3, d2
|
||||||
vmov.32 r0, d3[0]
|
vmov.32 r0, d3[0]
|
||||||
@@ -81,10 +81,10 @@ function ff_scalarproduct_and_madd_int16_neon, export=1
|
|||||||
|
|
||||||
vpadd.s32 d16, d0, d1
|
vpadd.s32 d16, d0, d1
|
||||||
vpadd.s32 d17, d2, d3
|
vpadd.s32 d17, d2, d3
|
||||||
vpadd.s32 d10, d4, d5
|
vpadd.s32 d18, d4, d5
|
||||||
vpadd.s32 d11, d6, d7
|
vpadd.s32 d19, d6, d7
|
||||||
vpadd.s32 d0, d16, d17
|
vpadd.s32 d0, d16, d17
|
||||||
vpadd.s32 d1, d10, d11
|
vpadd.s32 d1, d18, d19
|
||||||
vpadd.s32 d2, d0, d1
|
vpadd.s32 d2, d0, d1
|
||||||
vpaddl.s32 d3, d2
|
vpaddl.s32 d3, d2
|
||||||
vmov.32 r0, d3[0]
|
vmov.32 r0, d3[0]
|
||||||
|
@@ -282,6 +282,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
|
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (avctx->extradata_size < 1) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "No extradata provided\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
ff_asv_common_init(avctx);
|
ff_asv_common_init(avctx);
|
||||||
init_vlcs(a);
|
init_vlcs(a);
|
||||||
ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_asv_scantab);
|
ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_asv_scantab);
|
||||||
|
@@ -665,8 +665,8 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
|
|||||||
|
|
||||||
snd->num_components = decode_tonal_components(gb, snd->components,
|
snd->num_components = decode_tonal_components(gb, snd->components,
|
||||||
snd->bands_coded);
|
snd->bands_coded);
|
||||||
if (snd->num_components == -1)
|
if (snd->num_components < 0)
|
||||||
return -1;
|
return snd->num_components;
|
||||||
|
|
||||||
num_subbands = decode_spectrum(gb, snd->spectrum);
|
num_subbands = decode_spectrum(gb, snd->spectrum);
|
||||||
|
|
||||||
@@ -743,7 +743,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
|
|||||||
|
|
||||||
|
|
||||||
/* set the bitstream reader at the start of the second Sound Unit*/
|
/* set the bitstream reader at the start of the second Sound Unit*/
|
||||||
init_get_bits(&q->gb, ptr1, avctx->block_align * 8);
|
init_get_bits(&q->gb, ptr1, (avctx->block_align - i) * 8);
|
||||||
|
|
||||||
/* Fill the Weighting coeffs delay buffer */
|
/* Fill the Weighting coeffs delay buffer */
|
||||||
memmove(q->weighting_delay, &q->weighting_delay[2],
|
memmove(q->weighting_delay, &q->weighting_delay[2],
|
||||||
@@ -952,9 +952,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
if (q->coding_mode == STEREO)
|
if (q->coding_mode == STEREO)
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
|
av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
|
||||||
else if (q->coding_mode == JOINT_STEREO)
|
else if (q->coding_mode == JOINT_STEREO) {
|
||||||
|
if (avctx->channels != 2)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n");
|
av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n");
|
||||||
else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
|
av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
|
||||||
q->coding_mode);
|
q->coding_mode);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
@@ -283,7 +283,7 @@ int av_packet_split_side_data(AVPacket *pkt){
|
|||||||
for (i=0; ; i++){
|
for (i=0; ; i++){
|
||||||
size= AV_RB32(p);
|
size= AV_RB32(p);
|
||||||
av_assert0(size<=INT_MAX && p - pkt->data >= size);
|
av_assert0(size<=INT_MAX && p - pkt->data >= size);
|
||||||
pkt->side_data[i].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
pkt->side_data[i].data = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
pkt->side_data[i].size = size;
|
pkt->side_data[i].size = size;
|
||||||
pkt->side_data[i].type = p[4]&127;
|
pkt->side_data[i].type = p[4]&127;
|
||||||
if (!pkt->side_data[i].data)
|
if (!pkt->side_data[i].data)
|
||||||
|
@@ -685,6 +685,9 @@ static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (quant_idx >= 16)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
quant = quant_matrices[quant_idx];
|
quant = quant_matrices[quant_idx];
|
||||||
|
|
||||||
block[0] = (block[0] * quant[0]) >> 11;
|
block[0] = (block[0] * quant[0]) >> 11;
|
||||||
|
@@ -140,7 +140,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame,
|
|||||||
mode += 1 + advance_mode;
|
mode += 1 + advance_mode;
|
||||||
if (mode >= 4)
|
if (mode >= 4)
|
||||||
mode -= 3;
|
mode -= 3;
|
||||||
if (FFABS(dst_end - dst) < len)
|
if (len <= 0 || FFABS(dst_end - dst) < len)
|
||||||
return -1;
|
return -1;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@@ -325,6 +325,32 @@ static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p)
|
|||||||
return p->eof;
|
return p->eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p,
|
||||||
|
GetByteContext *g,
|
||||||
|
unsigned int size)
|
||||||
|
{
|
||||||
|
memcpy(p->buffer, g->buffer, size);
|
||||||
|
p->buffer += size;
|
||||||
|
g->buffer += size;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p,
|
||||||
|
GetByteContext *g,
|
||||||
|
unsigned int size)
|
||||||
|
{
|
||||||
|
int size2;
|
||||||
|
|
||||||
|
if (p->eof)
|
||||||
|
return 0;
|
||||||
|
size = FFMIN(g->buffer_end - g->buffer, size);
|
||||||
|
size2 = FFMIN(p->buffer_end - p->buffer, size);
|
||||||
|
if (size2 != size)
|
||||||
|
p->eof = 1;
|
||||||
|
|
||||||
|
return bytestream2_copy_bufferu(p, g, size2);
|
||||||
|
}
|
||||||
|
|
||||||
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
|
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
|
||||||
uint8_t *dst,
|
uint8_t *dst,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
|
@@ -305,7 +305,7 @@ STOP_TIMER("get_cabac_bypass")
|
|||||||
|
|
||||||
for(i=0; i<SIZE; i++){
|
for(i=0; i<SIZE; i++){
|
||||||
START_TIMER
|
START_TIMER
|
||||||
if( (r[i]&1) != get_cabac(&c, state) )
|
if( (r[i]&1) != get_cabac_noinline(&c, state) )
|
||||||
av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
|
av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
|
||||||
STOP_TIMER("get_cabac")
|
STOP_TIMER("get_cabac")
|
||||||
}
|
}
|
||||||
|
@@ -604,8 +604,9 @@ static inline int decode_residual_inter(AVSContext *h)
|
|||||||
|
|
||||||
/* get coded block pattern */
|
/* get coded block pattern */
|
||||||
int cbp = get_ue_golomb(&h->gb);
|
int cbp = get_ue_golomb(&h->gb);
|
||||||
if (cbp > 63U) {
|
|
||||||
av_log(h->avctx, AV_LOG_ERROR, "illegal inter cbp\n");
|
if (cbp > 63 || cbp < 0) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR, "illegal inter cbp %d\n", cbp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
h->cbp = cbp_tab[cbp][1];
|
h->cbp = cbp_tab[cbp][1];
|
||||||
@@ -675,7 +676,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
|
|||||||
/* get coded block pattern */
|
/* get coded block pattern */
|
||||||
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I)
|
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I)
|
||||||
cbp_code = get_ue_golomb(gb);
|
cbp_code = get_ue_golomb(gb);
|
||||||
if (cbp_code > 63U) {
|
if (cbp_code > 63 || cbp_code < 0) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR, "illegal intra cbp\n");
|
av_log(h->avctx, AV_LOG_ERROR, "illegal intra cbp\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -944,6 +945,11 @@ static int decode_pic(AVSContext *h)
|
|||||||
int ret;
|
int ret;
|
||||||
enum cavs_mb mb_type;
|
enum cavs_mb mb_type;
|
||||||
|
|
||||||
|
if (!h->top_qp) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
skip_bits(&h->gb, 16);//bbv_dwlay
|
skip_bits(&h->gb, 16);//bbv_dwlay
|
||||||
if (h->stc == PIC_PB_START_CODE) {
|
if (h->stc == PIC_PB_START_CODE) {
|
||||||
h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
|
h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
|
||||||
@@ -973,7 +979,8 @@ static int decode_pic(AVSContext *h)
|
|||||||
if (h->cur.f->data[0])
|
if (h->cur.f->data[0])
|
||||||
h->avctx->release_buffer(h->avctx, h->cur.f);
|
h->avctx->release_buffer(h->avctx, h->cur.f);
|
||||||
|
|
||||||
if ((ret = ff_get_buffer(h->avctx, h->cur.f)) < 0)
|
ret = ff_get_buffer(h->avctx, h->cur.f);
|
||||||
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (!h->edge_emu_buffer) {
|
if (!h->edge_emu_buffer) {
|
||||||
|
@@ -296,7 +296,9 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
|||||||
inst = bytestream_get_byte(&buf);
|
inst = bytestream_get_byte(&buf);
|
||||||
inst &= CDG_MASK;
|
inst &= CDG_MASK;
|
||||||
buf += 2; /// skipping 2 unneeded bytes
|
buf += 2; /// skipping 2 unneeded bytes
|
||||||
bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
|
|
||||||
|
if (buf_size > CDG_HEADER_SIZE)
|
||||||
|
bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
|
||||||
|
|
||||||
if ((command & CDG_MASK) == CDG_COMMAND) {
|
if ((command & CDG_MASK) == CDG_COMMAND) {
|
||||||
switch (inst) {
|
switch (inst) {
|
||||||
|
@@ -738,10 +738,10 @@ static int dca_parse_frame_header(DCAContext *s)
|
|||||||
s->lfe = get_bits(&s->gb, 2);
|
s->lfe = get_bits(&s->gb, 2);
|
||||||
s->predictor_history = get_bits(&s->gb, 1);
|
s->predictor_history = get_bits(&s->gb, 1);
|
||||||
|
|
||||||
if (s->lfe == 3) {
|
if (s->lfe > 2) {
|
||||||
s->lfe = 0;
|
s->lfe = 0;
|
||||||
av_log_ask_for_sample(s->avctx, "LFE is 3\n");
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid LFE value: %d\n", s->lfe);
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: check CRC */
|
/* TODO: check CRC */
|
||||||
@@ -971,7 +971,13 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
|
|||||||
"Invalid channel mode %d\n", am);
|
"Invalid channel mode %d\n", am);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
for (j = base_channel; j < FFMIN(s->prim_channels, FF_ARRAY_ELEMS(dca_default_coeffs[am])); j++) {
|
if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) {
|
||||||
|
av_log_ask_for_sample(s->avctx, "Downmixing %d channels",
|
||||||
|
s->prim_channels);
|
||||||
|
return AVERROR_PATCHWELCOME;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = base_channel; j < s->prim_channels; j++) {
|
||||||
s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
|
s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
|
||||||
s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
|
s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
|
||||||
}
|
}
|
||||||
@@ -1425,6 +1431,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
|
av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -263,6 +263,8 @@ static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height
|
|||||||
segments = bytestream2_get_le16(gb);
|
segments = bytestream2_get_le16(gb);
|
||||||
}
|
}
|
||||||
line_ptr = frame;
|
line_ptr = frame;
|
||||||
|
if (frame_end - frame < width)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
frame += width;
|
frame += width;
|
||||||
y++;
|
y++;
|
||||||
while (segments--) {
|
while (segments--) {
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#ifndef AVCODEC_DIRAC_ARITH_H
|
#ifndef AVCODEC_DIRAC_ARITH_H
|
||||||
#define AVCODEC_DIRAC_ARITH_H
|
#define AVCODEC_DIRAC_ARITH_H
|
||||||
|
|
||||||
|
#include "libavutil/x86/asm.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
|
|
||||||
@@ -134,7 +135,7 @@ static inline int dirac_get_arith_bit(DiracArith *c, int ctx)
|
|||||||
|
|
||||||
range_times_prob = (c->range * prob_zero) >> 16;
|
range_times_prob = (c->range * prob_zero) >> 16;
|
||||||
|
|
||||||
#if HAVE_FAST_CMOV && HAVE_INLINE_ASM
|
#if HAVE_FAST_CMOV && HAVE_INLINE_ASM && HAVE_6REGS
|
||||||
low -= range_times_prob << 16;
|
low -= range_times_prob << 16;
|
||||||
range -= range_times_prob;
|
range -= range_times_prob;
|
||||||
bit = 0;
|
bit = 0;
|
||||||
|
@@ -1342,8 +1342,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
|
|||||||
motion_y >>= s->chroma_y_shift;
|
motion_y >>= s->chroma_y_shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
mx = motion_x & ~(-1 << s->mv_precision);
|
mx = motion_x & ~(-1U << s->mv_precision);
|
||||||
my = motion_y & ~(-1 << s->mv_precision);
|
my = motion_y & ~(-1U << s->mv_precision);
|
||||||
motion_x >>= s->mv_precision;
|
motion_x >>= s->mv_precision;
|
||||||
motion_y >>= s->mv_precision;
|
motion_y >>= s->mv_precision;
|
||||||
/* normalize subpel coordinates to epel */
|
/* normalize subpel coordinates to epel */
|
||||||
|
@@ -235,7 +235,7 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
|
|||||||
|
|
||||||
static int dnxhd_init_rc(DNXHDEncContext *ctx)
|
static int dnxhd_init_rc(DNXHDEncContext *ctx)
|
||||||
{
|
{
|
||||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail);
|
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*(ctx->m.avctx->qmax + 1)*sizeof(RCEntry), fail);
|
||||||
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
|
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD)
|
||||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
|
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail);
|
||||||
|
|
||||||
|
@@ -128,27 +128,30 @@ static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst, int size)
|
static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst,
|
||||||
|
int size)
|
||||||
{
|
{
|
||||||
while (size--)
|
while (size--)
|
||||||
*dst++ += *src++;
|
*dst++ += *src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
static int cin_decode_huffman(const unsigned char *src, int src_size,
|
||||||
|
unsigned char *dst, int dst_size)
|
||||||
{
|
{
|
||||||
int b, huff_code = 0;
|
int b, huff_code = 0;
|
||||||
unsigned char huff_code_table[15];
|
unsigned char huff_code_table[15];
|
||||||
unsigned char *dst_cur = dst;
|
unsigned char *dst_cur = dst;
|
||||||
unsigned char *dst_end = dst + dst_size;
|
unsigned char *dst_end = dst + dst_size;
|
||||||
const unsigned char *src_end = src + src_size;
|
const unsigned char *src_end = src + src_size;
|
||||||
|
|
||||||
memcpy(huff_code_table, src, 15); src += 15;
|
memcpy(huff_code_table, src, 15);
|
||||||
|
src += 15;
|
||||||
|
|
||||||
while (src < src_end) {
|
while (src < src_end) {
|
||||||
huff_code = *src++;
|
huff_code = *src++;
|
||||||
if ((huff_code >> 4) == 15) {
|
if ((huff_code >> 4) == 15) {
|
||||||
b = huff_code << 4;
|
b = huff_code << 4;
|
||||||
huff_code = *src++;
|
huff_code = *src++;
|
||||||
*dst_cur++ = b | (huff_code >> 4);
|
*dst_cur++ = b | (huff_code >> 4);
|
||||||
} else
|
} else
|
||||||
*dst_cur++ = huff_code_table[huff_code >> 4];
|
*dst_cur++ = huff_code_table[huff_code >> 4];
|
||||||
@@ -167,11 +170,12 @@ static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned c
|
|||||||
return dst_cur - dst;
|
return dst_cur - dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
static int cin_decode_lzss(const unsigned char *src, int src_size,
|
||||||
|
unsigned char *dst, int dst_size)
|
||||||
{
|
{
|
||||||
uint16_t cmd;
|
uint16_t cmd;
|
||||||
int i, sz, offset, code;
|
int i, sz, offset, code;
|
||||||
unsigned char *dst_end = dst + dst_size, *dst_start = dst;
|
unsigned char *dst_end = dst + dst_size, *dst_start = dst;
|
||||||
const unsigned char *src_end = src + src_size;
|
const unsigned char *src_end = src + src_size;
|
||||||
|
|
||||||
while (src < src_end && dst < dst_end) {
|
while (src < src_end && dst < dst_end) {
|
||||||
@@ -180,13 +184,15 @@ static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char
|
|||||||
if (code & (1 << i)) {
|
if (code & (1 << i)) {
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
} else {
|
} else {
|
||||||
cmd = AV_RL16(src); src += 2;
|
cmd = AV_RL16(src);
|
||||||
|
src += 2;
|
||||||
offset = cmd >> 4;
|
offset = cmd >> 4;
|
||||||
if ((int) (dst - dst_start) < offset + 1)
|
if ((int)(dst - dst_start) < offset + 1)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
sz = (cmd & 0xF) + 2;
|
sz = (cmd & 0xF) + 2;
|
||||||
/* don't use memcpy/memmove here as the decoding routine (ab)uses */
|
/* don't use memcpy/memmove here as the decoding routine
|
||||||
/* buffer overlappings to repeat bytes in the destination */
|
* (ab)uses buffer overlappings to repeat bytes in the
|
||||||
|
* destination */
|
||||||
sz = FFMIN(sz, dst_end - dst);
|
sz = FFMIN(sz, dst_end - dst);
|
||||||
while (sz--) {
|
while (sz--) {
|
||||||
*dst = *(dst - offset - 1);
|
*dst = *(dst - offset - 1);
|
||||||
@@ -199,10 +205,11 @@ static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
static int cin_decode_rle(const unsigned char *src, int src_size,
|
||||||
|
unsigned char *dst, int dst_size)
|
||||||
{
|
{
|
||||||
int len, code;
|
int len, code;
|
||||||
unsigned char *dst_end = dst + dst_size;
|
unsigned char *dst_end = dst + dst_size;
|
||||||
const unsigned char *src_end = src + src_size;
|
const unsigned char *src_end = src + src_size;
|
||||||
|
|
||||||
while (src + 1 < src_end && dst < dst_end) {
|
while (src + 1 < src_end && dst < dst_end) {
|
||||||
@@ -216,7 +223,7 @@ static int cin_decode_rle(const unsigned char *src, int src_size, unsigned char
|
|||||||
av_log(NULL, AV_LOG_ERROR, "RLE overread\n");
|
av_log(NULL, AV_LOG_ERROR, "RLE overread\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
memcpy(dst, src, FFMIN(len, dst_end - dst));
|
memcpy(dst, src, FFMIN3(len, dst_end - dst, src_end - src));
|
||||||
src += len;
|
src += len;
|
||||||
}
|
}
|
||||||
dst += len;
|
dst += len;
|
||||||
@@ -228,15 +235,16 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
void *data, int *got_frame,
|
void *data, int *got_frame,
|
||||||
AVPacket *avpkt)
|
AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
CinVideoContext *cin = avctx->priv_data;
|
CinVideoContext *cin = avctx->priv_data;
|
||||||
int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size, res = 0;
|
int i, y, palette_type, palette_colors_count,
|
||||||
|
bitmap_frame_type, bitmap_frame_size, res = 0;
|
||||||
|
|
||||||
palette_type = buf[0];
|
palette_type = buf[0];
|
||||||
palette_colors_count = AV_RL16(buf+1);
|
palette_colors_count = AV_RL16(buf + 1);
|
||||||
bitmap_frame_type = buf[3];
|
bitmap_frame_type = buf[3];
|
||||||
buf += 4;
|
buf += 4;
|
||||||
|
|
||||||
bitmap_frame_size = buf_size - 4;
|
bitmap_frame_size = buf_size - 4;
|
||||||
|
|
||||||
@@ -247,46 +255,50 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
if (palette_colors_count > 256)
|
if (palette_colors_count > 256)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
for (i = 0; i < palette_colors_count; ++i) {
|
for (i = 0; i < palette_colors_count; ++i) {
|
||||||
cin->palette[i] = 0xFFU << 24 | bytestream_get_le24(&buf);
|
cin->palette[i] = 0xFFU << 24 | bytestream_get_le24(&buf);
|
||||||
bitmap_frame_size -= 3;
|
bitmap_frame_size -= 3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < palette_colors_count; ++i) {
|
for (i = 0; i < palette_colors_count; ++i) {
|
||||||
cin->palette[buf[0]] = 0xFFU << 24 | AV_RL24(buf+1);
|
cin->palette[buf[0]] = 0xFFU << 24 | AV_RL24(buf + 1);
|
||||||
buf += 4;
|
buf += 4;
|
||||||
bitmap_frame_size -= 4;
|
bitmap_frame_size -= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* note: the decoding routines below assumes that surface.width = surface.pitch */
|
bitmap_frame_size = FFMIN(cin->bitmap_size, bitmap_frame_size);
|
||||||
|
|
||||||
|
/* note: the decoding routines below assumes that
|
||||||
|
* surface.width = surface.pitch */
|
||||||
switch (bitmap_frame_type) {
|
switch (bitmap_frame_type) {
|
||||||
case 9:
|
case 9:
|
||||||
cin_decode_rle(buf, bitmap_frame_size,
|
cin_decode_rle(buf, bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
break;
|
break;
|
||||||
case 34:
|
case 34:
|
||||||
cin_decode_rle(buf, bitmap_frame_size,
|
cin_decode_rle(buf, bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
break;
|
break;
|
||||||
case 35:
|
case 35:
|
||||||
bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size,
|
bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
|
||||||
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
|
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size,
|
bitmap_frame_size = cin_decode_huffman(buf, bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_INT_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_INT_BMP],
|
||||||
|
cin->bitmap_size);
|
||||||
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
|
cin_decode_rle(cin->bitmap_table[CIN_INT_BMP], bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
cin_decode_huffman(buf, bitmap_frame_size,
|
cin_decode_huffman(buf, bitmap_frame_size,
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
break;
|
break;
|
||||||
case 38:
|
case 38:
|
||||||
res = cin_decode_lzss(buf, bitmap_frame_size,
|
res = cin_decode_lzss(buf, bitmap_frame_size,
|
||||||
@@ -302,12 +314,12 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||||
if ((res = avctx->reget_buffer(avctx, &cin->frame))) {
|
if ((res = avctx->reget_buffer(avctx, &cin->frame)) < 0) {
|
||||||
av_log(cin->avctx, AV_LOG_ERROR, "failed to allocate a frame\n");
|
av_log(cin->avctx, AV_LOG_ERROR, "failed to allocate a frame\n");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -316,10 +328,11 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
cin->frame.palette_has_changed = 1;
|
cin->frame.palette_has_changed = 1;
|
||||||
for (y = 0; y < cin->avctx->height; ++y)
|
for (y = 0; y < cin->avctx->height; ++y)
|
||||||
memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0],
|
memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0],
|
||||||
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
||||||
cin->avctx->width);
|
cin->avctx->width);
|
||||||
|
|
||||||
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_table[CIN_PRE_BMP]);
|
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP],
|
||||||
|
cin->bitmap_table[CIN_PRE_BMP]);
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
*(AVFrame *)data = cin->frame;
|
*(AVFrame *)data = cin->frame;
|
||||||
@@ -358,8 +371,8 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx)
|
|||||||
static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
|
static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
int *got_frame_ptr, AVPacket *avpkt)
|
int *got_frame_ptr, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
CinAudioContext *cin = avctx->priv_data;
|
CinAudioContext *cin = avctx->priv_data;
|
||||||
const uint8_t *buf_end = buf + avpkt->size;
|
const uint8_t *buf_end = buf + avpkt->size;
|
||||||
int16_t *samples;
|
int16_t *samples;
|
||||||
int delta, ret;
|
int delta, ret;
|
||||||
@@ -375,13 +388,13 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
delta = cin->delta;
|
delta = cin->delta;
|
||||||
if (cin->initial_decode_frame) {
|
if (cin->initial_decode_frame) {
|
||||||
cin->initial_decode_frame = 0;
|
cin->initial_decode_frame = 0;
|
||||||
delta = sign_extend(AV_RL16(buf), 16);
|
delta = sign_extend(AV_RL16(buf), 16);
|
||||||
buf += 2;
|
buf += 2;
|
||||||
*samples++ = delta;
|
*samples++ = delta;
|
||||||
}
|
}
|
||||||
while (buf < buf_end) {
|
while (buf < buf_end) {
|
||||||
delta += cinaudio_delta16_table[*buf++];
|
delta += cinaudio_delta16_table[*buf++];
|
||||||
delta = av_clip_int16(delta);
|
delta = av_clip_int16(delta);
|
||||||
*samples++ = delta;
|
*samples++ = delta;
|
||||||
}
|
}
|
||||||
cin->delta = delta;
|
cin->delta = delta;
|
||||||
@@ -392,7 +405,6 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
return avpkt->size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AVCodec ff_dsicinvideo_decoder = {
|
AVCodec ff_dsicinvideo_decoder = {
|
||||||
.name = "dsicinvideo",
|
.name = "dsicinvideo",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
|
@@ -1922,7 +1922,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
|
|||||||
|
|
||||||
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
|
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
|
||||||
long i;
|
long i;
|
||||||
for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
|
for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
|
||||||
long a = *(long*)(src+i);
|
long a = *(long*)(src+i);
|
||||||
long b = *(long*)(dst+i);
|
long b = *(long*)(dst+i);
|
||||||
*(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
|
*(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
|
||||||
@@ -1947,7 +1947,7 @@ static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
|
|||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
|
for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
|
||||||
long a = *(long*)(src1+i);
|
long a = *(long*)(src1+i);
|
||||||
long b = *(long*)(src2+i);
|
long b = *(long*)(src2+i);
|
||||||
*(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
|
*(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
|
||||||
|
@@ -350,11 +350,6 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
|
|||||||
static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5;
|
static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5;
|
||||||
static const int mb_area_start[5] = { 1, 6, 21, 43, 64 };
|
static const int mb_area_start[5] = { 1, 6, 21, 43, 64 };
|
||||||
|
|
||||||
static inline int put_bits_left(PutBitContext* s)
|
|
||||||
{
|
|
||||||
return (s->buf_end - s->buf) * 8 - put_bits_count(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CONFIG_SMALL
|
#if CONFIG_SMALL
|
||||||
/* Converts run and level (where level != 0) pair into VLC, returning bit size */
|
/* Converts run and level (where level != 0) pair into VLC, returning bit size */
|
||||||
static av_always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc)
|
static av_always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc)
|
||||||
|
@@ -255,6 +255,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
case 5:
|
case 5:
|
||||||
c->pic.key_frame = !(compr & 1);
|
c->pic.key_frame = !(compr & 1);
|
||||||
c->pic.pict_type = (compr & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
|
c->pic.pict_type = (compr & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
|
||||||
|
|
||||||
|
if (!tmpptr && !c->pic.key_frame) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
for(j = 0; j < avctx->height; j++){
|
for(j = 0; j < avctx->height; j++){
|
||||||
if((compr & 1) && tmpptr){
|
if((compr & 1) && tmpptr){
|
||||||
for(i = 0; i < avctx->width; i++)
|
for(i = 0; i < avctx->width; i++)
|
||||||
|
@@ -114,8 +114,8 @@ static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *
|
|||||||
int yoffset = ((buf[i] >> 4)) - 7;
|
int yoffset = ((buf[i] >> 4)) - 7;
|
||||||
if (s->last_frame.data[0])
|
if (s->last_frame.data[0])
|
||||||
cmv_motcomp(s->frame.data[0], s->frame.linesize[0],
|
cmv_motcomp(s->frame.data[0], s->frame.linesize[0],
|
||||||
s->last_frame.data[0], s->last_frame.linesize[0],
|
s->last_frame.data[0], s->last_frame.linesize[0],
|
||||||
x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
|
x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *
|
|||||||
|
|
||||||
static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end)
|
static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t *buf_end)
|
||||||
{
|
{
|
||||||
int pal_start, pal_count, i;
|
int pal_start, pal_count, i, fps;
|
||||||
|
|
||||||
if(buf_end - buf < 16) {
|
if(buf_end - buf < 16) {
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "truncated header\n");
|
av_log(s->avctx, AV_LOG_WARNING, "truncated header\n");
|
||||||
@@ -135,8 +135,9 @@ static void cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t
|
|||||||
if (s->avctx->width!=s->width || s->avctx->height!=s->height)
|
if (s->avctx->width!=s->width || s->avctx->height!=s->height)
|
||||||
avcodec_set_dimensions(s->avctx, s->width, s->height);
|
avcodec_set_dimensions(s->avctx, s->width, s->height);
|
||||||
|
|
||||||
s->avctx->time_base.num = 1;
|
fps = AV_RL16(&buf[10]);
|
||||||
s->avctx->time_base.den = AV_RL16(&buf[10]);
|
if (fps > 0)
|
||||||
|
s->avctx->time_base = (AVRational){ 1, fps };
|
||||||
|
|
||||||
pal_start = AV_RL16(&buf[12]);
|
pal_start = AV_RL16(&buf[12]);
|
||||||
pal_count = AV_RL16(&buf[14]);
|
pal_count = AV_RL16(&buf[14]);
|
||||||
|
@@ -447,6 +447,10 @@ static int read_extra_header(FFV1Context *f)
|
|||||||
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
|
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
|
||||||
|
|
||||||
f->version = get_symbol(c, state, 0);
|
f->version = get_symbol(c, state, 0);
|
||||||
|
if (f->version < 2) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "Invalid version in global header\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
if (f->version > 2) {
|
if (f->version > 2) {
|
||||||
c->bytestream_end -= 4;
|
c->bytestream_end -= 4;
|
||||||
f->minor_version = get_symbol(c, state, 0);
|
f->minor_version = get_symbol(c, state, 0);
|
||||||
@@ -524,6 +528,7 @@ static int read_header(FFV1Context *f)
|
|||||||
memset(state, 128, sizeof(state));
|
memset(state, 128, sizeof(state));
|
||||||
|
|
||||||
if (f->version < 2) {
|
if (f->version < 2) {
|
||||||
|
int chroma_planes, chroma_h_shift, chroma_v_shift, transparency, colorspace, bits_per_raw_sample;
|
||||||
unsigned v= get_symbol(c, state, 0);
|
unsigned v= get_symbol(c, state, 0);
|
||||||
if (v >= 2) {
|
if (v >= 2) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v);
|
av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v);
|
||||||
@@ -536,15 +541,32 @@ static int read_header(FFV1Context *f)
|
|||||||
f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
|
f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
f->colorspace = get_symbol(c, state, 0); //YUV cs type
|
colorspace = get_symbol(c, state, 0); //YUV cs type
|
||||||
|
bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample;
|
||||||
|
chroma_planes = get_rac(c, state);
|
||||||
|
chroma_h_shift = get_symbol(c, state, 0);
|
||||||
|
chroma_v_shift = get_symbol(c, state, 0);
|
||||||
|
transparency = get_rac(c, state);
|
||||||
|
|
||||||
if (f->version > 0)
|
if (f->plane_count) {
|
||||||
f->avctx->bits_per_raw_sample = get_symbol(c, state, 0);
|
if ( colorspace != f->colorspace
|
||||||
|
|| bits_per_raw_sample != f->avctx->bits_per_raw_sample
|
||||||
|
|| chroma_planes != f->chroma_planes
|
||||||
|
|| chroma_h_shift!= f->chroma_h_shift
|
||||||
|
|| chroma_v_shift!= f->chroma_v_shift
|
||||||
|
|| transparency != f->transparency) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f->colorspace = colorspace;
|
||||||
|
f->avctx->bits_per_raw_sample = bits_per_raw_sample;
|
||||||
|
f->chroma_planes = chroma_planes;
|
||||||
|
f->chroma_h_shift = chroma_h_shift;
|
||||||
|
f->chroma_v_shift = chroma_v_shift;
|
||||||
|
f->transparency = transparency;
|
||||||
|
|
||||||
f->chroma_planes = get_rac(c, state);
|
|
||||||
f->chroma_h_shift = get_symbol(c, state, 0);
|
|
||||||
f->chroma_v_shift = get_symbol(c, state, 0);
|
|
||||||
f->transparency = get_rac(c, state);
|
|
||||||
f->plane_count = 2 + f->transparency;
|
f->plane_count = 2 + f->transparency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -275,7 +275,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w,
|
|||||||
int run_mode = 0;
|
int run_mode = 0;
|
||||||
|
|
||||||
if (s->ac) {
|
if (s->ac) {
|
||||||
if (c->bytestream_end - c->bytestream < w * 20) {
|
if (c->bytestream_end - c->bytestream < w * 35) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
|
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ const int ff_flac_sample_rate_table[16] =
|
|||||||
8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
|
8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
|
||||||
0, 0, 0, 0 };
|
0, 0, 0, 0 };
|
||||||
|
|
||||||
const int16_t ff_flac_blocksize_table[16] = {
|
const int32_t ff_flac_blocksize_table[16] = {
|
||||||
0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0,
|
0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0,
|
||||||
256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
|
256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
|
||||||
};
|
};
|
||||||
|
@@ -26,6 +26,6 @@
|
|||||||
|
|
||||||
extern const int ff_flac_sample_rate_table[16];
|
extern const int ff_flac_sample_rate_table[16];
|
||||||
|
|
||||||
extern const int16_t ff_flac_blocksize_table[16];
|
extern const int32_t ff_flac_blocksize_table[16];
|
||||||
|
|
||||||
#endif /* AVCODEC_FLACDATA_H */
|
#endif /* AVCODEC_FLACDATA_H */
|
||||||
|
@@ -389,6 +389,12 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
s->diff_start = get_bits(&gb, 8);
|
s->diff_start = get_bits(&gb, 8);
|
||||||
s->diff_height = get_bits(&gb, 8);
|
s->diff_height = get_bits(&gb, 8);
|
||||||
|
if (s->diff_start + s->diff_height > cur_blk_height) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Block parameters invalid: %d + %d > %d\n",
|
||||||
|
s->diff_start, s->diff_height, cur_blk_height);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
av_log(avctx, AV_LOG_DEBUG,
|
av_log(avctx, AV_LOG_DEBUG,
|
||||||
"%dx%d diff start %d height %d\n",
|
"%dx%d diff start %d height %d\n",
|
||||||
i, j, s->diff_start, s->diff_height);
|
i, j, s->diff_start, s->diff_height);
|
||||||
|
@@ -145,6 +145,11 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
enum AVPixelFormat pix_fmt;
|
enum AVPixelFormat pix_fmt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (buf_size < 4) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Packet is too short\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
header = AV_RL32(buf);
|
header = AV_RL32(buf);
|
||||||
version = header & 0xff;
|
version = header & 0xff;
|
||||||
header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
|
header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
|
||||||
@@ -216,7 +221,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(version) {
|
switch (version) {
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
/* Fraps v0 is a reordered YUV420 */
|
/* Fraps v0 is a reordered YUV420 */
|
||||||
@@ -226,13 +231,13 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf32=(const uint32_t*)buf;
|
buf32 = (const uint32_t*)buf;
|
||||||
for(y=0; y<avctx->height/2; y++){
|
for (y = 0; y < avctx->height / 2; y++) {
|
||||||
luma1=(uint32_t*)&f->data[0][ y*2*f->linesize[0] ];
|
luma1 = (uint32_t*)&f->data[0][ y * 2 * f->linesize[0] ];
|
||||||
luma2=(uint32_t*)&f->data[0][ (y*2+1)*f->linesize[0] ];
|
luma2 = (uint32_t*)&f->data[0][ (y * 2 + 1) * f->linesize[0] ];
|
||||||
cr=(uint32_t*)&f->data[1][ y*f->linesize[1] ];
|
cr = (uint32_t*)&f->data[1][ y * f->linesize[1] ];
|
||||||
cb=(uint32_t*)&f->data[2][ y*f->linesize[2] ];
|
cb = (uint32_t*)&f->data[2][ y * f->linesize[2] ];
|
||||||
for(x=0; x<avctx->width; x+=8){
|
for(x=0; x<avctx->width; x+=8) {
|
||||||
*luma1++ = *buf32++;
|
*luma1++ = *buf32++;
|
||||||
*luma1++ = *buf32++;
|
*luma1++ = *buf32++;
|
||||||
*luma2++ = *buf32++;
|
*luma2++ = *buf32++;
|
||||||
@@ -245,10 +250,10 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
/* Fraps v1 is an upside-down BGR24 */
|
/* Fraps v1 is an upside-down BGR24 */
|
||||||
for(y=0; y<avctx->height; y++)
|
for (y = 0; y < avctx->height; y++)
|
||||||
memcpy(&f->data[0][ (avctx->height - y -1) * f->linesize[0]],
|
memcpy(&f->data[0][ (avctx->height - y - 1) * f->linesize[0]],
|
||||||
&buf[y*avctx->width*3],
|
&buf[y * avctx->width * 3],
|
||||||
3*avctx->width);
|
3 * avctx->width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
@@ -2292,7 +2292,8 @@ static int pack_bitstream(G723_1_Context *p, unsigned char *frame, int size)
|
|||||||
if (p->cur_rate == RATE_6300) {
|
if (p->cur_rate == RATE_6300) {
|
||||||
info_bits = 0;
|
info_bits = 0;
|
||||||
put_bits(&pb, 2, info_bits);
|
put_bits(&pb, 2, info_bits);
|
||||||
}
|
}else
|
||||||
|
av_assert0(0);
|
||||||
|
|
||||||
put_bits(&pb, 8, p->lsp_index[2]);
|
put_bits(&pb, 8, p->lsp_index[2]);
|
||||||
put_bits(&pb, 8, p->lsp_index[1]);
|
put_bits(&pb, 8, p->lsp_index[1]);
|
||||||
|
@@ -65,8 +65,8 @@ typedef struct GifState {
|
|||||||
int stored_img_size;
|
int stored_img_size;
|
||||||
int stored_bg_color;
|
int stored_bg_color;
|
||||||
|
|
||||||
GetByteContext gb;
|
|
||||||
/* LZW compatible decoder */
|
/* LZW compatible decoder */
|
||||||
|
GetByteContext gb;
|
||||||
LZWState *lzw;
|
LZWState *lzw;
|
||||||
|
|
||||||
/* aux buffers */
|
/* aux buffers */
|
||||||
@@ -75,6 +75,7 @@ typedef struct GifState {
|
|||||||
|
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
int keyframe;
|
int keyframe;
|
||||||
|
int keyframe_ok;
|
||||||
int trans_color; /**< color value that is used instead of transparent color */
|
int trans_color; /**< color value that is used instead of transparent color */
|
||||||
} GifState;
|
} GifState;
|
||||||
|
|
||||||
@@ -143,11 +144,11 @@ static int gif_read_image(GifState *s)
|
|||||||
if (bytestream2_get_bytes_left(&s->gb) < 9)
|
if (bytestream2_get_bytes_left(&s->gb) < 9)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
left = bytestream2_get_le16u(&s->gb);
|
left = bytestream2_get_le16u(&s->gb);
|
||||||
top = bytestream2_get_le16u(&s->gb);
|
top = bytestream2_get_le16u(&s->gb);
|
||||||
width = bytestream2_get_le16u(&s->gb);
|
width = bytestream2_get_le16u(&s->gb);
|
||||||
height = bytestream2_get_le16u(&s->gb);
|
height = bytestream2_get_le16u(&s->gb);
|
||||||
flags = bytestream2_get_byteu(&s->gb);
|
flags = bytestream2_get_byteu(&s->gb);
|
||||||
is_interleaved = flags & 0x40;
|
is_interleaved = flags & 0x40;
|
||||||
has_local_palette = flags & 0x80;
|
has_local_palette = flags & 0x80;
|
||||||
bits_per_pixel = (flags & 0x07) + 1;
|
bits_per_pixel = (flags & 0x07) + 1;
|
||||||
@@ -184,8 +185,11 @@ static int gif_read_image(GifState *s)
|
|||||||
|
|
||||||
/* verify that all the image is inside the screen dimensions */
|
/* verify that all the image is inside the screen dimensions */
|
||||||
if (left + width > s->screen_width ||
|
if (left + width > s->screen_width ||
|
||||||
top + height > s->screen_height)
|
top + height > s->screen_height ||
|
||||||
|
!width || !height) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid image dimensions.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
/* process disposal method */
|
/* process disposal method */
|
||||||
if (s->gce_prev_disposal == GCE_DISPOSAL_BACKGROUND) {
|
if (s->gce_prev_disposal == GCE_DISPOSAL_BACKGROUND) {
|
||||||
@@ -313,7 +317,7 @@ static int gif_read_extension(GifState *s)
|
|||||||
if (bytestream2_get_bytes_left(&s->gb) < 5)
|
if (bytestream2_get_bytes_left(&s->gb) < 5)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
gce_flags = bytestream2_get_byteu(&s->gb);
|
gce_flags = bytestream2_get_byteu(&s->gb);
|
||||||
bytestream2_skipu(&s->gb, 2); // delay during which the frame is shown
|
bytestream2_skipu(&s->gb, 2); // delay during which the frame is shown
|
||||||
gce_transparent_index = bytestream2_get_byteu(&s->gb);
|
gce_transparent_index = bytestream2_get_byteu(&s->gb);
|
||||||
if (gce_flags & 0x01)
|
if (gce_flags & 0x01)
|
||||||
@@ -367,7 +371,7 @@ static int gif_read_header1(GifState *s)
|
|||||||
|
|
||||||
/* read screen header */
|
/* read screen header */
|
||||||
s->transparent_color_index = -1;
|
s->transparent_color_index = -1;
|
||||||
s->screen_width = bytestream2_get_le16u(&s->gb);
|
s->screen_width = bytestream2_get_le16u(&s->gb);
|
||||||
s->screen_height = bytestream2_get_le16u(&s->gb);
|
s->screen_height = bytestream2_get_le16u(&s->gb);
|
||||||
if( (unsigned)s->screen_width > 32767
|
if( (unsigned)s->screen_width > 32767
|
||||||
|| (unsigned)s->screen_height > 32767){
|
|| (unsigned)s->screen_height > 32767){
|
||||||
@@ -410,10 +414,10 @@ static int gif_read_header1(GifState *s)
|
|||||||
|
|
||||||
static int gif_parse_next_image(GifState *s, int *got_picture)
|
static int gif_parse_next_image(GifState *s, int *got_picture)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
*got_picture = 1;
|
*got_picture = 1;
|
||||||
while (bytestream2_get_bytes_left(&s->gb)) {
|
while (bytestream2_get_bytes_left(&s->gb) > 0) {
|
||||||
int code = bytestream2_get_byte(&s->gb);
|
int code = bytestream2_get_byte(&s->gb);
|
||||||
|
int ret;
|
||||||
|
|
||||||
av_dlog(s->avctx, "code=%02x '%c'\n", code, code);
|
av_dlog(s->avctx, "code=%02x '%c'\n", code, code);
|
||||||
|
|
||||||
@@ -458,9 +462,9 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, A
|
|||||||
|
|
||||||
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
|
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
|
||||||
|
|
||||||
s->picture.pts = avpkt->pts;
|
s->picture.pts = avpkt->pts;
|
||||||
s->picture.pkt_pts = avpkt->pts;
|
s->picture.pkt_pts = avpkt->pts;
|
||||||
s->picture.pkt_dts = avpkt->dts;
|
s->picture.pkt_dts = avpkt->dts;
|
||||||
s->picture.pkt_duration = avpkt->duration;
|
s->picture.pkt_duration = avpkt->duration;
|
||||||
|
|
||||||
if (avpkt->size >= 6) {
|
if (avpkt->size >= 6) {
|
||||||
@@ -471,6 +475,8 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, A
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s->keyframe) {
|
if (s->keyframe) {
|
||||||
|
s->keyframe_ok = 0;
|
||||||
|
s->gce_prev_disposal = GCE_DISPOSAL_NONE;
|
||||||
if ((ret = gif_read_header1(s)) < 0)
|
if ((ret = gif_read_header1(s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -488,7 +494,13 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, A
|
|||||||
|
|
||||||
s->picture.pict_type = AV_PICTURE_TYPE_I;
|
s->picture.pict_type = AV_PICTURE_TYPE_I;
|
||||||
s->picture.key_frame = 1;
|
s->picture.key_frame = 1;
|
||||||
|
s->keyframe_ok = 1;
|
||||||
} else {
|
} else {
|
||||||
|
if (!s->keyframe_ok) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "cannot decode frame without keyframe\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = avctx->reget_buffer(avctx, &s->picture)) < 0) {
|
if ((ret = avctx->reget_buffer(avctx, &s->picture)) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
@@ -504,7 +516,7 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, A
|
|||||||
else if (*got_frame)
|
else if (*got_frame)
|
||||||
*picture = s->picture;
|
*picture = s->picture;
|
||||||
|
|
||||||
return avpkt->size;
|
return bytestream2_tell(&s->gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int gif_decode_close(AVCodecContext *avctx)
|
static av_cold int gif_decode_close(AVCodecContext *avctx)
|
||||||
|
@@ -291,9 +291,11 @@ static int h261_decode_mb(H261Context *h){
|
|||||||
// Read mtype
|
// Read mtype
|
||||||
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
|
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
|
||||||
if (h->mtype < 0) {
|
if (h->mtype < 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "illegal mtype %d\n", h->mtype);
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n",
|
||||||
|
h->mtype);
|
||||||
return SLICE_ERROR;
|
return SLICE_ERROR;
|
||||||
}
|
}
|
||||||
|
av_assert0(h->mtype < FF_ARRAY_ELEMS(ff_h261_mtype_map));
|
||||||
h->mtype = ff_h261_mtype_map[h->mtype];
|
h->mtype = ff_h261_mtype_map[h->mtype];
|
||||||
|
|
||||||
// Read mquant
|
// Read mquant
|
||||||
|
@@ -392,7 +392,6 @@ uint64_t time= rdtsc();
|
|||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if(s->divx_packed && s->bitstream_buffer_size){
|
if(s->divx_packed && s->bitstream_buffer_size){
|
||||||
int i;
|
int i;
|
||||||
@@ -407,16 +406,20 @@ retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder
|
if (s->bitstream_buffer_size && (s->divx_packed || buf_size < 20)) // divx 5.01+/xvid frame reorder
|
||||||
init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
|
ret = init_get_bits8(&s->gb, s->bitstream_buffer,
|
||||||
}else
|
s->bitstream_buffer_size);
|
||||||
init_get_bits(&s->gb, buf, buf_size*8);
|
else
|
||||||
s->bitstream_buffer_size=0;
|
ret = init_get_bits8(&s->gb, buf, buf_size);
|
||||||
|
|
||||||
if (!s->context_initialized) {
|
s->bitstream_buffer_size=0;
|
||||||
if ((ret = ff_MPV_common_init(s)) < 0) //we need the idct permutaton for reading a custom matrix
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (!s->context_initialized)
|
||||||
|
// we need the idct permutaton for reading a custom matrix
|
||||||
|
if ((ret = ff_MPV_common_init(s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
/* We need to set current_picture_ptr before reading the header,
|
/* We need to set current_picture_ptr before reading the header,
|
||||||
* otherwise we cannot store anyting in there */
|
* otherwise we cannot store anyting in there */
|
||||||
@@ -436,8 +439,11 @@ retry:
|
|||||||
if(s->avctx->extradata_size && s->picture_number==0){
|
if(s->avctx->extradata_size && s->picture_number==0){
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
|
|
||||||
init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
|
ret = init_get_bits8(&gb, s->avctx->extradata,
|
||||||
ret = ff_mpeg4_decode_picture_header(s, &gb);
|
s->avctx->extradata_size);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
ff_mpeg4_decode_picture_header(s, &gb);
|
||||||
}
|
}
|
||||||
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
|
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
|
||||||
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
|
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
|
||||||
@@ -597,17 +603,6 @@ retry:
|
|||||||
/* FIXME: By the way H263 decoder is evolving it should have */
|
/* FIXME: By the way H263 decoder is evolving it should have */
|
||||||
/* an H263EncContext */
|
/* an H263EncContext */
|
||||||
|
|
||||||
if ((!avctx->coded_width || !avctx->coded_height) && 0) {
|
|
||||||
ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
|
|
||||||
|
|
||||||
s->parse_context.buffer=0;
|
|
||||||
ff_MPV_common_end(s);
|
|
||||||
s->parse_context= pc;
|
|
||||||
avcodec_set_dimensions(avctx, s->width, s->height);
|
|
||||||
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->width != avctx->coded_width ||
|
if (s->width != avctx->coded_width ||
|
||||||
s->height != avctx->coded_height ||
|
s->height != avctx->coded_height ||
|
||||||
s->context_reinit) {
|
s->context_reinit) {
|
||||||
@@ -725,10 +720,10 @@ frame_end:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(startcode_found){
|
if(startcode_found){
|
||||||
av_fast_malloc(
|
av_fast_padded_mallocz(
|
||||||
&s->bitstream_buffer,
|
&s->bitstream_buffer,
|
||||||
&s->allocated_bitstream_buffer_size,
|
&s->allocated_bitstream_buffer_size,
|
||||||
buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
|
buf_size - current_pos);
|
||||||
if (!s->bitstream_buffer)
|
if (!s->bitstream_buffer)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
|
memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
|
||||||
|
@@ -67,9 +67,15 @@ static const uint8_t div6[QP_MAX_NUM + 1] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const enum AVPixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = {
|
static const enum AVPixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = {
|
||||||
|
#if CONFIG_H264_DXVA2_HWACCEL
|
||||||
AV_PIX_FMT_DXVA2_VLD,
|
AV_PIX_FMT_DXVA2_VLD,
|
||||||
|
#endif
|
||||||
|
#if CONFIG_H264_VAAPI_HWACCEL
|
||||||
AV_PIX_FMT_VAAPI_VLD,
|
AV_PIX_FMT_VAAPI_VLD,
|
||||||
|
#endif
|
||||||
|
#if CONFIG_H264_VDA_HWACCEL
|
||||||
AV_PIX_FMT_VDA_VLD,
|
AV_PIX_FMT_VDA_VLD,
|
||||||
|
#endif
|
||||||
AV_PIX_FMT_YUVJ420P,
|
AV_PIX_FMT_YUVJ420P,
|
||||||
AV_PIX_FMT_NONE
|
AV_PIX_FMT_NONE
|
||||||
};
|
};
|
||||||
@@ -135,10 +141,10 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h)
|
|||||||
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
|
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
|
||||||
{
|
{
|
||||||
MpegEncContext *const s = &h->s;
|
MpegEncContext *const s = &h->s;
|
||||||
static const int8_t top[7] = { LEFT_DC_PRED8x8, 1, -1, -1 };
|
static const int8_t top[4] = { LEFT_DC_PRED8x8, 1, -1, -1 };
|
||||||
static const int8_t left[7] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
|
static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
|
||||||
|
|
||||||
if (mode > 6U) {
|
if (mode > 3U) {
|
||||||
av_log(h->s.avctx, AV_LOG_ERROR,
|
av_log(h->s.avctx, AV_LOG_ERROR,
|
||||||
"out of range intra chroma pred mode at %d %d\n",
|
"out of range intra chroma pred mode at %d %d\n",
|
||||||
s->mb_x, s->mb_y);
|
s->mb_x, s->mb_y);
|
||||||
@@ -1331,6 +1337,8 @@ int ff_h264_frame_start(H264Context *h)
|
|||||||
int i;
|
int i;
|
||||||
const int pixel_shift = h->pixel_shift;
|
const int pixel_shift = h->pixel_shift;
|
||||||
|
|
||||||
|
h->next_output_pic = NULL;
|
||||||
|
|
||||||
if (ff_MPV_frame_start(s, s->avctx) < 0)
|
if (ff_MPV_frame_start(s, s->avctx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ff_er_frame_start(s);
|
ff_er_frame_start(s);
|
||||||
@@ -1383,8 +1391,6 @@ int ff_h264_frame_start(H264Context *h)
|
|||||||
s->current_picture_ptr->field_poc[0] =
|
s->current_picture_ptr->field_poc[0] =
|
||||||
s->current_picture_ptr->field_poc[1] = INT_MAX;
|
s->current_picture_ptr->field_poc[1] = INT_MAX;
|
||||||
|
|
||||||
h->next_output_pic = NULL;
|
|
||||||
|
|
||||||
assert(s->current_picture_ptr->long_ref == 0);
|
assert(s->current_picture_ptr->long_ref == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2170,6 +2176,7 @@ static void flush_change(H264Context *h)
|
|||||||
h->sync= 0;
|
h->sync= 0;
|
||||||
h->list_count = 0;
|
h->list_count = 0;
|
||||||
h->current_slice = 0;
|
h->current_slice = 0;
|
||||||
|
h->mmco_reset = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* forget old pics after a seek */
|
/* forget old pics after a seek */
|
||||||
@@ -2443,12 +2450,6 @@ static int h264_set_parameter_from_sps(H264Context *h)
|
|||||||
if (s->avctx->has_b_frames < 2)
|
if (s->avctx->has_b_frames < 2)
|
||||||
s->avctx->has_b_frames = !s->low_delay;
|
s->avctx->has_b_frames = !s->low_delay;
|
||||||
|
|
||||||
if (h->sps.bit_depth_luma != h->sps.bit_depth_chroma) {
|
|
||||||
av_log_missing_feature(s->avctx,
|
|
||||||
"Different bit depth between chroma and luma", 1);
|
|
||||||
return AVERROR_PATCHWELCOME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
|
if (s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
|
||||||
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
|
h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
|
||||||
if (s->avctx->codec &&
|
if (s->avctx->codec &&
|
||||||
@@ -2719,6 +2720,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
h->slice_type = slice_type;
|
h->slice_type = slice_type;
|
||||||
h->slice_type_nos = slice_type & 3;
|
h->slice_type_nos = slice_type & 3;
|
||||||
|
|
||||||
|
if (h->nal_unit_type == NAL_IDR_SLICE &&
|
||||||
|
h->slice_type_nos != AV_PICTURE_TYPE_I) {
|
||||||
|
av_log(h->s.avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
// to make a few old functions happy, it's wrong though
|
// to make a few old functions happy, it's wrong though
|
||||||
s->pict_type = h->slice_type;
|
s->pict_type = h->slice_type;
|
||||||
|
|
||||||
@@ -2920,7 +2927,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
|
assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
|
||||||
|
|
||||||
/* Mark old field/frame as completed */
|
/* Mark old field/frame as completed */
|
||||||
if (!last_pic_droppable && s0->current_picture_ptr->owner2 == s0) {
|
if (s0->current_picture_ptr->owner2 == s0) {
|
||||||
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
|
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
|
||||||
last_pic_structure == PICT_BOTTOM_FIELD);
|
last_pic_structure == PICT_BOTTOM_FIELD);
|
||||||
}
|
}
|
||||||
@@ -2929,7 +2936,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) {
|
if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) {
|
||||||
/* Previous field is unmatched. Don't display it, but let it
|
/* Previous field is unmatched. Don't display it, but let it
|
||||||
* remain for reference if marked as such. */
|
* remain for reference if marked as such. */
|
||||||
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
|
if (last_pic_structure != PICT_FRAME) {
|
||||||
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
|
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
|
||||||
last_pic_structure == PICT_TOP_FIELD);
|
last_pic_structure == PICT_TOP_FIELD);
|
||||||
}
|
}
|
||||||
@@ -2939,7 +2946,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
* different frame_nums. Consider this field first in
|
* different frame_nums. Consider this field first in
|
||||||
* pair. Throw away previous field except for reference
|
* pair. Throw away previous field except for reference
|
||||||
* purposes. */
|
* purposes. */
|
||||||
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
|
if (last_pic_structure != PICT_FRAME) {
|
||||||
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
|
ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
|
||||||
last_pic_structure == PICT_TOP_FIELD);
|
last_pic_structure == PICT_TOP_FIELD);
|
||||||
}
|
}
|
||||||
@@ -2983,8 +2990,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
if (!h->sps.gaps_in_frame_num_allowed_flag)
|
if (!h->sps.gaps_in_frame_num_allowed_flag)
|
||||||
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
|
for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
|
||||||
h->last_pocs[i] = INT_MIN;
|
h->last_pocs[i] = INT_MIN;
|
||||||
if (ff_h264_frame_start(h) < 0)
|
if (ff_h264_frame_start(h) < 0) {
|
||||||
|
s0->first_field = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
h->prev_frame_num++;
|
h->prev_frame_num++;
|
||||||
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
|
h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
|
||||||
s->current_picture_ptr->frame_num = h->prev_frame_num;
|
s->current_picture_ptr->frame_num = h->prev_frame_num;
|
||||||
@@ -3224,8 +3233,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
get_se_golomb(&s->gb); /* slice_qs_delta */
|
get_se_golomb(&s->gb); /* slice_qs_delta */
|
||||||
|
|
||||||
h->deblocking_filter = 1;
|
h->deblocking_filter = 1;
|
||||||
h->slice_alpha_c0_offset = 52;
|
h->slice_alpha_c0_offset = 0;
|
||||||
h->slice_beta_offset = 52;
|
h->slice_beta_offset = 0;
|
||||||
if (h->pps.deblocking_filter_parameters_present) {
|
if (h->pps.deblocking_filter_parameters_present) {
|
||||||
tmp = get_ue_golomb_31(&s->gb);
|
tmp = get_ue_golomb_31(&s->gb);
|
||||||
if (tmp > 2) {
|
if (tmp > 2) {
|
||||||
@@ -3238,10 +3247,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
h->deblocking_filter ^= 1; // 1<->0
|
h->deblocking_filter ^= 1; // 1<->0
|
||||||
|
|
||||||
if (h->deblocking_filter) {
|
if (h->deblocking_filter) {
|
||||||
h->slice_alpha_c0_offset += get_se_golomb(&s->gb) << 1;
|
h->slice_alpha_c0_offset = get_se_golomb(&s->gb) * 2;
|
||||||
h->slice_beta_offset += get_se_golomb(&s->gb) << 1;
|
h->slice_beta_offset = get_se_golomb(&s->gb) * 2;
|
||||||
if (h->slice_alpha_c0_offset > 104U ||
|
if (h->slice_alpha_c0_offset > 12 ||
|
||||||
h->slice_beta_offset > 104U) {
|
h->slice_alpha_c0_offset < -12 ||
|
||||||
|
h->slice_beta_offset > 12 ||
|
||||||
|
h->slice_beta_offset < -12) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR,
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
"deblocking filter parameters %d %d out of range\n",
|
"deblocking filter parameters %d %d out of range\n",
|
||||||
h->slice_alpha_c0_offset, h->slice_beta_offset);
|
h->slice_alpha_c0_offset, h->slice_beta_offset);
|
||||||
@@ -3278,7 +3289,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h->qp_thresh = 15 + 52 -
|
h->qp_thresh = 15 -
|
||||||
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
|
FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
|
||||||
FFMAX3(0,
|
FFMAX3(0,
|
||||||
h->pps.chroma_qp_index_offset[0],
|
h->pps.chroma_qp_index_offset[0],
|
||||||
@@ -3352,7 +3363,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
h->ref_count[0], h->ref_count[1],
|
h->ref_count[0], h->ref_count[1],
|
||||||
s->qscale,
|
s->qscale,
|
||||||
h->deblocking_filter,
|
h->deblocking_filter,
|
||||||
h->slice_alpha_c0_offset / 2 - 26, h->slice_beta_offset / 2 - 26,
|
h->slice_alpha_c0_offset, h->slice_beta_offset,
|
||||||
h->use_weight,
|
h->use_weight,
|
||||||
h->use_weight == 1 && h->use_weight_chroma ? "c" : "",
|
h->use_weight == 1 && h->use_weight_chroma ? "c" : "",
|
||||||
h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
|
h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
|
||||||
@@ -3905,6 +3916,8 @@ static int execute_decode_slices(H264Context *h, int context_count)
|
|||||||
H264Context *hx;
|
H264Context *hx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
av_assert0(s->mb_y < s->mb_height);
|
||||||
|
|
||||||
if (s->avctx->hwaccel ||
|
if (s->avctx->hwaccel ||
|
||||||
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
|
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -4027,7 +4040,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
|
|||||||
s->workaround_bugs |= FF_BUG_TRUNCATED;
|
s->workaround_bugs |= FF_BUG_TRUNCATED;
|
||||||
|
|
||||||
if (!(s->workaround_bugs & FF_BUG_TRUNCATED))
|
if (!(s->workaround_bugs & FF_BUG_TRUNCATED))
|
||||||
while(dst_length > 0 && ptr[dst_length - 1] == 0)
|
while (dst_length > 0 && ptr[dst_length - 1] == 0)
|
||||||
dst_length--;
|
dst_length--;
|
||||||
bit_length = !dst_length ? 0
|
bit_length = !dst_length ? 0
|
||||||
: (8 * dst_length -
|
: (8 * dst_length -
|
||||||
@@ -4180,12 +4193,24 @@ again:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NAL_DPA:
|
case NAL_DPA:
|
||||||
|
if (s->flags2 & CODEC_FLAG2_CHUNKS) {
|
||||||
|
av_log(h->s.avctx, AV_LOG_ERROR,
|
||||||
|
"Decoding in chunks is not supported for "
|
||||||
|
"partitioned slices.\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
|
||||||
init_get_bits(&hx->s.gb, ptr, bit_length);
|
init_get_bits(&hx->s.gb, ptr, bit_length);
|
||||||
hx->intra_gb_ptr =
|
hx->intra_gb_ptr =
|
||||||
hx->inter_gb_ptr = NULL;
|
hx->inter_gb_ptr = NULL;
|
||||||
|
|
||||||
if ((err = decode_slice_header(hx, h)) < 0)
|
if ((err = decode_slice_header(hx, h)) < 0) {
|
||||||
|
/* make sure data_partitioning is cleared if it was set
|
||||||
|
* before, so we don't try decoding a slice without a valid
|
||||||
|
* slice header later */
|
||||||
|
h->s.data_partitioning = 0;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
hx->s.data_partitioning = 1;
|
hx->s.data_partitioning = 1;
|
||||||
break;
|
break;
|
||||||
@@ -4255,9 +4280,10 @@ again:
|
|||||||
context_count = 0;
|
context_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
|
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
|
||||||
else if (err == 1) {
|
h->ref_count[0] = h->ref_count[1] = h->list_count = 0;
|
||||||
|
} else if (err == 1) {
|
||||||
/* Slice could not be decoded in parallel mode, copy down
|
/* Slice could not be decoded in parallel mode, copy down
|
||||||
* NAL unit stuff to context 0 and restart. Note that
|
* NAL unit stuff to context 0 and restart. Note that
|
||||||
* rbsp_buffer is not transferred, but since we no longer
|
* rbsp_buffer is not transferred, but since we no longer
|
||||||
@@ -4310,6 +4336,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
s->flags = avctx->flags;
|
s->flags = avctx->flags;
|
||||||
s->flags2 = avctx->flags2;
|
s->flags2 = avctx->flags2;
|
||||||
|
/* reset data partitioning here, to ensure GetBitContexts from previous
|
||||||
|
* packets do not get used. */
|
||||||
|
s->data_partitioning = 0;
|
||||||
|
|
||||||
/* end of stream, output what is still in the buffers */
|
/* end of stream, output what is still in the buffers */
|
||||||
if (buf_size == 0) {
|
if (buf_size == 0) {
|
||||||
|
@@ -709,7 +709,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h){
|
|||||||
down the code */
|
down the code */
|
||||||
if(h->slice_type_nos != AV_PICTURE_TYPE_I){
|
if(h->slice_type_nos != AV_PICTURE_TYPE_I){
|
||||||
if(s->mb_skip_run==-1)
|
if(s->mb_skip_run==-1)
|
||||||
s->mb_skip_run= get_ue_golomb(&s->gb);
|
s->mb_skip_run= get_ue_golomb_long(&s->gb);
|
||||||
|
|
||||||
if (s->mb_skip_run--) {
|
if (s->mb_skip_run--) {
|
||||||
if(FRAME_MBAFF && (s->mb_y&1) == 0){
|
if(FRAME_MBAFF && (s->mb_y&1) == 0){
|
||||||
@@ -771,6 +771,10 @@ decode_intra_mb:
|
|||||||
|
|
||||||
// We assume these blocks are very rare so we do not optimize it.
|
// We assume these blocks are very rare so we do not optimize it.
|
||||||
align_get_bits(&s->gb);
|
align_get_bits(&s->gb);
|
||||||
|
if (get_bits_left(&s->gb) < mb_size) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
// The pixels are stored in the same order as levels in h->mb array.
|
// The pixels are stored in the same order as levels in h->mb array.
|
||||||
for(x=0; x < mb_size; x++){
|
for(x=0; x < mb_size; x++){
|
||||||
|
@@ -251,8 +251,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
|
|||||||
int top_type= h->top_type;
|
int top_type= h->top_type;
|
||||||
|
|
||||||
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
|
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
|
||||||
int a = h->slice_alpha_c0_offset - qp_bd_offset;
|
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
|
||||||
int b = h->slice_beta_offset - qp_bd_offset;
|
int b = 52 + h->slice_beta_offset - qp_bd_offset;
|
||||||
|
|
||||||
int mb_type = s->current_picture.f.mb_type[mb_xy];
|
int mb_type = s->current_picture.f.mb_type[mb_xy];
|
||||||
int qp = s->current_picture.f.qscale_table[mb_xy];
|
int qp = s->current_picture.f.qscale_table[mb_xy];
|
||||||
@@ -712,8 +712,8 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
|
|||||||
av_unused int dir;
|
av_unused int dir;
|
||||||
int chroma = CHROMA && !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
|
int chroma = CHROMA && !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
|
||||||
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
|
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
|
||||||
int a = h->slice_alpha_c0_offset - qp_bd_offset;
|
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
|
||||||
int b = h->slice_beta_offset - qp_bd_offset;
|
int b = 52 + h->slice_beta_offset - qp_bd_offset;
|
||||||
|
|
||||||
if (FRAME_MBAFF
|
if (FRAME_MBAFF
|
||||||
// and current and left pair do not have the same interlaced type
|
// and current and left pair do not have the same interlaced type
|
||||||
|
@@ -154,7 +154,7 @@ pps:
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* prepend only to the first type 5 NAL unit of an IDR picture */
|
/* prepend only to the first type 5 NAL unit of an IDR picture */
|
||||||
if (ctx->first_idr && unit_type == 5) {
|
if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) {
|
||||||
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
|
||||||
avctx->extradata, avctx->extradata_size,
|
avctx->extradata, avctx->extradata_size,
|
||||||
buf, nal_size)) < 0)
|
buf, nal_size)) < 0)
|
||||||
|
@@ -267,7 +267,9 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
|
if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
|
||||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames);
|
av_log(h->s.avctx, AV_LOG_ERROR, "Clipping illegal num_reorder_frames %d\n",
|
||||||
|
sps->num_reorder_frames);
|
||||||
|
sps->num_reorder_frames = 16;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -63,7 +63,9 @@ static int split_field_copy(Picture *dest, Picture *src,
|
|||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel){
|
static int build_def_list(Picture *def, int def_len,
|
||||||
|
Picture **in, int len, int is_long, int sel)
|
||||||
|
{
|
||||||
int i[2]={0};
|
int i[2]={0};
|
||||||
int index=0;
|
int index=0;
|
||||||
|
|
||||||
@@ -73,10 +75,12 @@ static int build_def_list(Picture *def, Picture **in, int len, int is_long, int
|
|||||||
while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3))))
|
while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3))))
|
||||||
i[1]++;
|
i[1]++;
|
||||||
if(i[0] < len){
|
if(i[0] < len){
|
||||||
|
av_assert0(index < def_len);
|
||||||
in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num;
|
in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num;
|
||||||
split_field_copy(&def[index++], in[ i[0]++ ], sel , 1);
|
split_field_copy(&def[index++], in[ i[0]++ ], sel , 1);
|
||||||
}
|
}
|
||||||
if(i[1] < len){
|
if(i[1] < len){
|
||||||
|
av_assert0(index < def_len);
|
||||||
in[ i[1] ]->pic_id= is_long ? i[1] : in[ i[1] ]->frame_num;
|
in[ i[1] ]->pic_id= is_long ? i[1] : in[ i[1] ]->frame_num;
|
||||||
split_field_copy(&def[index++], in[ i[1]++ ], sel^3, 0);
|
split_field_copy(&def[index++], in[ i[1]++ ], sel^3, 0);
|
||||||
}
|
}
|
||||||
@@ -124,8 +128,12 @@ int ff_h264_fill_default_ref_list(H264Context *h){
|
|||||||
len= add_sorted(sorted , h->short_ref, h->short_ref_count, cur_poc, 1^list);
|
len= add_sorted(sorted , h->short_ref, h->short_ref_count, cur_poc, 1^list);
|
||||||
len+=add_sorted(sorted+len, h->short_ref, h->short_ref_count, cur_poc, 0^list);
|
len+=add_sorted(sorted+len, h->short_ref, h->short_ref_count, cur_poc, 0^list);
|
||||||
av_assert0(len<=32);
|
av_assert0(len<=32);
|
||||||
len= build_def_list(h->default_ref_list[list] , sorted , len, 0, s->picture_structure);
|
len = build_def_list(h->default_ref_list[list], FF_ARRAY_ELEMS(h->default_ref_list[0]),
|
||||||
len+=build_def_list(h->default_ref_list[list]+len, h->long_ref, 16 , 1, s->picture_structure);
|
sorted, len, 0, s->picture_structure);
|
||||||
|
len += build_def_list(h->default_ref_list[list] + len,
|
||||||
|
FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
|
||||||
|
h->long_ref, 16, 1, s->picture_structure);
|
||||||
|
|
||||||
av_assert0(len<=32);
|
av_assert0(len<=32);
|
||||||
|
|
||||||
if(len < h->ref_count[list])
|
if(len < h->ref_count[list])
|
||||||
@@ -139,8 +147,12 @@ int ff_h264_fill_default_ref_list(H264Context *h){
|
|||||||
FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]);
|
FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
len = build_def_list(h->default_ref_list[0] , h->short_ref, h->short_ref_count, 0, s->picture_structure);
|
len = build_def_list(h->default_ref_list[0], FF_ARRAY_ELEMS(h->default_ref_list[0]),
|
||||||
len+= build_def_list(h->default_ref_list[0]+len, h-> long_ref, 16 , 1, s->picture_structure);
|
h->short_ref, h->short_ref_count, 0, s->picture_structure);
|
||||||
|
len += build_def_list(h->default_ref_list[0] + len,
|
||||||
|
FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
|
||||||
|
h-> long_ref, 16, 1, s->picture_structure);
|
||||||
|
|
||||||
av_assert0(len<=32);
|
av_assert0(len<=32);
|
||||||
if(len < h->ref_count[0])
|
if(len < h->ref_count[0])
|
||||||
memset(&h->default_ref_list[0][len], 0, sizeof(Picture)*(h->ref_count[0] - len));
|
memset(&h->default_ref_list[0][len], 0, sizeof(Picture)*(h->ref_count[0] - len));
|
||||||
@@ -550,7 +562,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
|||||||
if(!pic){
|
if(!pic){
|
||||||
if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg]
|
if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg]
|
||||||
|| h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
|
|| h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
|
||||||
av_log(h->s.avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
|
av_log(h->s.avctx, h->short_ref_count ? AV_LOG_ERROR : AV_LOG_DEBUG, "mmco: unref short failure\n");
|
||||||
err = AVERROR_INVALIDDATA;
|
err = AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -687,7 +699,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
|
|||||||
print_short_term(h);
|
print_short_term(h);
|
||||||
print_long_term(h);
|
print_long_term(h);
|
||||||
|
|
||||||
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=2 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||||
s->current_picture_ptr->sync |= 1;
|
s->current_picture_ptr->sync |= 1;
|
||||||
if(!h->s.avctx->has_b_frames)
|
if(!h->s.avctx->has_b_frames)
|
||||||
h->sync = 2;
|
h->sync = 2;
|
||||||
|
@@ -63,13 +63,13 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_fo
|
|||||||
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
|
c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
|
||||||
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
|
c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
|
||||||
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
|
c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
|
||||||
if (chroma_format_idc == 1)\
|
if (chroma_format_idc <= 1)\
|
||||||
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
|
c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
|
||||||
else\
|
else\
|
||||||
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
|
c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\
|
||||||
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
|
c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
|
||||||
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
|
c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
|
||||||
if (chroma_format_idc == 1)\
|
if (chroma_format_idc <= 1)\
|
||||||
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
|
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
|
||||||
else\
|
else\
|
||||||
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
|
c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\
|
||||||
@@ -90,20 +90,20 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_fo
|
|||||||
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
|
c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
|
||||||
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
|
c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
|
||||||
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
|
c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
|
||||||
if (chroma_format_idc == 1)\
|
if (chroma_format_idc <= 1)\
|
||||||
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
|
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
|
||||||
else\
|
else\
|
||||||
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
|
c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
|
||||||
if (chroma_format_idc == 1)\
|
if (chroma_format_idc <= 1)\
|
||||||
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
|
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
|
||||||
else\
|
else\
|
||||||
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
|
c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
|
||||||
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
|
c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
|
||||||
if (chroma_format_idc == 1)\
|
if (chroma_format_idc <= 1)\
|
||||||
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
|
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
|
||||||
else\
|
else\
|
||||||
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
|
c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
|
||||||
if (chroma_format_idc == 1)\
|
if (chroma_format_idc <= 1)\
|
||||||
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
|
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
|
||||||
else\
|
else\
|
||||||
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
|
c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
|
||||||
|
@@ -480,7 +480,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
|
|||||||
h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\
|
h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\
|
||||||
h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\
|
h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\
|
||||||
\
|
\
|
||||||
if (chroma_format_idc == 1) {\
|
if (chroma_format_idc <= 1) {\
|
||||||
h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
|
h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
|
||||||
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
|
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
|
||||||
} else {\
|
} else {\
|
||||||
@@ -488,7 +488,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
|
|||||||
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\
|
h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\
|
||||||
}\
|
}\
|
||||||
if (codec_id != AV_CODEC_ID_VP8) {\
|
if (codec_id != AV_CODEC_ID_VP8) {\
|
||||||
if (chroma_format_idc == 1) {\
|
if (chroma_format_idc <= 1) {\
|
||||||
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
|
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
|
||||||
} else {\
|
} else {\
|
||||||
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\
|
h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\
|
||||||
@@ -496,7 +496,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
|
|||||||
} else\
|
} else\
|
||||||
h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
|
h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
|
||||||
if(codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8){\
|
if(codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8){\
|
||||||
if (chroma_format_idc == 1) {\
|
if (chroma_format_idc <= 1) {\
|
||||||
h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
|
h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
|
||||||
h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
|
h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
|
||||||
h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
|
h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
|
||||||
@@ -522,7 +522,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
|
|||||||
h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
|
h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
if (chroma_format_idc == 1) {\
|
if (chroma_format_idc <= 1) {\
|
||||||
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\
|
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\
|
||||||
} else {\
|
} else {\
|
||||||
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\
|
h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\
|
||||||
@@ -556,7 +556,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
|
|||||||
h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\
|
h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\
|
||||||
h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\
|
h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\
|
||||||
h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\
|
h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\
|
||||||
if (chroma_format_idc == 1) {\
|
if (chroma_format_idc <= 1) {\
|
||||||
h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
|
h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
|
||||||
h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
|
h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
|
||||||
} else {\
|
} else {\
|
||||||
|
@@ -451,6 +451,10 @@ static int bit_allocation(IMCContext *q, IMCChannel *chctx,
|
|||||||
iacc += chctx->bandWidthT[i];
|
iacc += chctx->bandWidthT[i];
|
||||||
summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
|
summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!iacc)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
chctx->bandWidthT[BANDS - 1] = 0;
|
chctx->bandWidthT[BANDS - 1] = 0;
|
||||||
summa = (summa * 0.5 - freebits) / iacc;
|
summa = (summa * 0.5 - freebits) / iacc;
|
||||||
|
|
||||||
|
@@ -226,7 +226,7 @@ static av_cold void free_frame_buffers(Indeo3DecodeContext *ctx)
|
|||||||
* @param plane pointer to the plane descriptor
|
* @param plane pointer to the plane descriptor
|
||||||
* @param cell pointer to the cell descriptor
|
* @param cell pointer to the cell descriptor
|
||||||
*/
|
*/
|
||||||
static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
|
static int copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
|
||||||
{
|
{
|
||||||
int h, w, mv_x, mv_y, offset, offset_dst;
|
int h, w, mv_x, mv_y, offset, offset_dst;
|
||||||
uint8_t *src, *dst;
|
uint8_t *src, *dst;
|
||||||
@@ -239,6 +239,16 @@ static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
|
|||||||
mv_x = cell->mv_ptr[1];
|
mv_x = cell->mv_ptr[1];
|
||||||
}else
|
}else
|
||||||
mv_x= mv_y= 0;
|
mv_x= mv_y= 0;
|
||||||
|
|
||||||
|
/* -1 because there is an extra line on top for prediction */
|
||||||
|
if ((cell->ypos << 2) + mv_y < -1 || (cell->xpos << 2) + mv_x < 0 ||
|
||||||
|
((cell->ypos + cell->height) << 2) + mv_y > plane->height ||
|
||||||
|
((cell->xpos + cell->width) << 2) + mv_x > plane->width) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR,
|
||||||
|
"Motion vectors point out of the frame.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
offset = offset_dst + mv_y * plane->pitch + mv_x;
|
offset = offset_dst + mv_y * plane->pitch + mv_x;
|
||||||
src = plane->pixels[ctx->buf_sel ^ 1] + offset;
|
src = plane->pixels[ctx->buf_sel ^ 1] + offset;
|
||||||
|
|
||||||
@@ -266,15 +276,17 @@ static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
|
|||||||
dst += 4;
|
dst += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Average 4/8 pixels at once without rounding using SWAR */
|
/* Average 4/8 pixels at once without rounding using SWAR */
|
||||||
#define AVG_32(dst, src, ref) \
|
#define AVG_32(dst, src, ref) \
|
||||||
AV_WN32A(dst, ((AV_RN32A(src) + AV_RN32A(ref)) >> 1) & 0x7F7F7F7FUL)
|
AV_WN32A(dst, ((AV_RN32(src) + AV_RN32(ref)) >> 1) & 0x7F7F7F7FUL)
|
||||||
|
|
||||||
#define AVG_64(dst, src, ref) \
|
#define AVG_64(dst, src, ref) \
|
||||||
AV_WN64A(dst, ((AV_RN64A(src) + AV_RN64A(ref)) >> 1) & 0x7F7F7F7F7F7F7F7FULL)
|
AV_WN64A(dst, ((AV_RN64(src) + AV_RN64(ref)) >> 1) & 0x7F7F7F7F7F7F7F7FULL)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -333,7 +345,7 @@ if (*data_ptr >= last_ptr) \
|
|||||||
copy_block4(dst, ref, row_offset, row_offset, 4 << v_zoom)
|
copy_block4(dst, ref, row_offset, row_offset, 4 << v_zoom)
|
||||||
|
|
||||||
#define RLE_BLOCK_COPY_8 \
|
#define RLE_BLOCK_COPY_8 \
|
||||||
pix64 = AV_RN64A(ref);\
|
pix64 = AV_RN64(ref);\
|
||||||
if (is_first_row) {/* special prediction case: top line of a cell */\
|
if (is_first_row) {/* special prediction case: top line of a cell */\
|
||||||
pix64 = replicate64(pix64);\
|
pix64 = replicate64(pix64);\
|
||||||
fill_64(dst + row_offset, pix64, 7, row_offset);\
|
fill_64(dst + row_offset, pix64, 7, row_offset);\
|
||||||
@@ -345,7 +357,7 @@ if (*data_ptr >= last_ptr) \
|
|||||||
copy_block4(dst, ref, row_offset, row_offset, num_lines << v_zoom)
|
copy_block4(dst, ref, row_offset, row_offset, num_lines << v_zoom)
|
||||||
|
|
||||||
#define RLE_LINES_COPY_M10 \
|
#define RLE_LINES_COPY_M10 \
|
||||||
pix64 = AV_RN64A(ref);\
|
pix64 = AV_RN64(ref);\
|
||||||
if (is_top_of_cell) {\
|
if (is_top_of_cell) {\
|
||||||
pix64 = replicate64(pix64);\
|
pix64 = replicate64(pix64);\
|
||||||
fill_64(dst + row_offset, pix64, (num_lines << 1) - 1, row_offset);\
|
fill_64(dst + row_offset, pix64, (num_lines << 1) - 1, row_offset);\
|
||||||
@@ -355,12 +367,12 @@ if (*data_ptr >= last_ptr) \
|
|||||||
|
|
||||||
#define APPLY_DELTA_4 \
|
#define APPLY_DELTA_4 \
|
||||||
AV_WN16A(dst + line_offset ,\
|
AV_WN16A(dst + line_offset ,\
|
||||||
(AV_RN16A(ref ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
|
(AV_RN16(ref ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
|
||||||
AV_WN16A(dst + line_offset + 2,\
|
AV_WN16A(dst + line_offset + 2,\
|
||||||
(AV_RN16A(ref + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\
|
(AV_RN16(ref + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\
|
||||||
if (mode >= 3) {\
|
if (mode >= 3) {\
|
||||||
if (is_top_of_cell && !cell->ypos) {\
|
if (is_top_of_cell && !cell->ypos) {\
|
||||||
AV_COPY32(dst, dst + row_offset);\
|
AV_COPY32U(dst, dst + row_offset);\
|
||||||
} else {\
|
} else {\
|
||||||
AVG_32(dst, ref, dst + row_offset);\
|
AVG_32(dst, ref, dst + row_offset);\
|
||||||
}\
|
}\
|
||||||
@@ -370,20 +382,20 @@ if (*data_ptr >= last_ptr) \
|
|||||||
/* apply two 32-bit VQ deltas to next even line */\
|
/* apply two 32-bit VQ deltas to next even line */\
|
||||||
if (is_top_of_cell) { \
|
if (is_top_of_cell) { \
|
||||||
AV_WN32A(dst + row_offset , \
|
AV_WN32A(dst + row_offset , \
|
||||||
(replicate32(AV_RN32A(ref )) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
(replicate32(AV_RN32(ref )) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
||||||
AV_WN32A(dst + row_offset + 4, \
|
AV_WN32A(dst + row_offset + 4, \
|
||||||
(replicate32(AV_RN32A(ref + 4)) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
(replicate32(AV_RN32(ref + 4)) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
||||||
} else { \
|
} else { \
|
||||||
AV_WN32A(dst + row_offset , \
|
AV_WN32A(dst + row_offset , \
|
||||||
(AV_RN32A(ref ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
(AV_RN32(ref ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
||||||
AV_WN32A(dst + row_offset + 4, \
|
AV_WN32A(dst + row_offset + 4, \
|
||||||
(AV_RN32A(ref + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
(AV_RN32(ref + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
||||||
} \
|
} \
|
||||||
/* odd lines are not coded but rather interpolated/replicated */\
|
/* odd lines are not coded but rather interpolated/replicated */\
|
||||||
/* first line of the cell on the top of image? - replicate */\
|
/* first line of the cell on the top of image? - replicate */\
|
||||||
/* otherwise - interpolate */\
|
/* otherwise - interpolate */\
|
||||||
if (is_top_of_cell && !cell->ypos) {\
|
if (is_top_of_cell && !cell->ypos) {\
|
||||||
AV_COPY64(dst, dst + row_offset);\
|
AV_COPY64U(dst, dst + row_offset);\
|
||||||
} else \
|
} else \
|
||||||
AVG_64(dst, ref, dst + row_offset);
|
AVG_64(dst, ref, dst + row_offset);
|
||||||
|
|
||||||
@@ -391,22 +403,22 @@ if (*data_ptr >= last_ptr) \
|
|||||||
#define APPLY_DELTA_1011_INTER \
|
#define APPLY_DELTA_1011_INTER \
|
||||||
if (mode == 10) { \
|
if (mode == 10) { \
|
||||||
AV_WN32A(dst , \
|
AV_WN32A(dst , \
|
||||||
(AV_RN32A(dst ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
(AV_RN32(dst ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
||||||
AV_WN32A(dst + 4 , \
|
AV_WN32A(dst + 4 , \
|
||||||
(AV_RN32A(dst + 4 ) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
(AV_RN32(dst + 4 ) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
||||||
AV_WN32A(dst + row_offset , \
|
AV_WN32A(dst + row_offset , \
|
||||||
(AV_RN32A(dst + row_offset ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
(AV_RN32(dst + row_offset ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
|
||||||
AV_WN32A(dst + row_offset + 4, \
|
AV_WN32A(dst + row_offset + 4, \
|
||||||
(AV_RN32A(dst + row_offset + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
(AV_RN32(dst + row_offset + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
|
||||||
} else { \
|
} else { \
|
||||||
AV_WN16A(dst , \
|
AV_WN16A(dst , \
|
||||||
(AV_RN16A(dst ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
|
(AV_RN16(dst ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
|
||||||
AV_WN16A(dst + 2 , \
|
AV_WN16A(dst + 2 , \
|
||||||
(AV_RN16A(dst + 2 ) + delta_tab->deltas[dyad2]) & 0x7F7F);\
|
(AV_RN16(dst + 2 ) + delta_tab->deltas[dyad2]) & 0x7F7F);\
|
||||||
AV_WN16A(dst + row_offset , \
|
AV_WN16A(dst + row_offset , \
|
||||||
(AV_RN16A(dst + row_offset ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
|
(AV_RN16(dst + row_offset ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
|
||||||
AV_WN16A(dst + row_offset + 2, \
|
AV_WN16A(dst + row_offset + 2, \
|
||||||
(AV_RN16A(dst + row_offset + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\
|
(AV_RN16(dst + row_offset + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -604,11 +616,23 @@ static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
} else if (mode >= 10) {
|
} else if (mode >= 10) {
|
||||||
/* for mode 10 and 11 INTER first copy the predicted cell into the current one */
|
/* for mode 10 and 11 INTER first copy the predicted cell into the current one */
|
||||||
/* so we don't need to do data copying for each RLE code later */
|
/* so we don't need to do data copying for each RLE code later */
|
||||||
copy_cell(ctx, plane, cell);
|
int ret = copy_cell(ctx, plane, cell);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
/* set the pointer to the reference pixels for modes 0-4 INTER */
|
/* set the pointer to the reference pixels for modes 0-4 INTER */
|
||||||
mv_y = cell->mv_ptr[0];
|
mv_y = cell->mv_ptr[0];
|
||||||
mv_x = cell->mv_ptr[1];
|
mv_x = cell->mv_ptr[1];
|
||||||
|
|
||||||
|
/* -1 because there is an extra line on top for prediction */
|
||||||
|
if ((cell->ypos << 2) + mv_y < -1 || (cell->xpos << 2) + mv_x < 0 ||
|
||||||
|
((cell->ypos + cell->height) << 2) + mv_y > plane->height ||
|
||||||
|
((cell->xpos + cell->width) << 2) + mv_x > plane->width) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR,
|
||||||
|
"Motion vectors point out of the frame.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
offset += mv_y * plane->pitch + mv_x;
|
offset += mv_y * plane->pitch + mv_x;
|
||||||
ref_block = plane->pixels[ctx->buf_sel ^ 1] + offset;
|
ref_block = plane->pixels[ctx->buf_sel ^ 1] + offset;
|
||||||
}
|
}
|
||||||
@@ -740,8 +764,7 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
const int depth, const int strip_width)
|
const int depth, const int strip_width)
|
||||||
{
|
{
|
||||||
Cell curr_cell;
|
Cell curr_cell;
|
||||||
int bytes_used;
|
int bytes_used, ret;
|
||||||
int mv_x, mv_y;
|
|
||||||
|
|
||||||
if (depth <= 0) {
|
if (depth <= 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Stack overflow (corrupted binary tree)!\n");
|
av_log(avctx, AV_LOG_ERROR, "Stack overflow (corrupted binary tree)!\n");
|
||||||
@@ -792,19 +815,8 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
CHECK_CELL
|
CHECK_CELL
|
||||||
if (!curr_cell.mv_ptr)
|
if (!curr_cell.mv_ptr)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
ret = copy_cell(ctx, plane, &curr_cell);
|
||||||
mv_y = curr_cell.mv_ptr[0];
|
return ret;
|
||||||
mv_x = curr_cell.mv_ptr[1];
|
|
||||||
if ( mv_x + 4*curr_cell.xpos < 0
|
|
||||||
|| mv_y + 4*curr_cell.ypos < 0
|
|
||||||
|| mv_x + 4*curr_cell.xpos + 4*curr_cell.width > plane->width
|
|
||||||
|| mv_y + 4*curr_cell.ypos + 4*curr_cell.height > plane->height) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", mv_x + 4*curr_cell.xpos, mv_y + 4*curr_cell.ypos);
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_cell(ctx, plane, &curr_cell);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INTER_DATA:
|
case INTER_DATA:
|
||||||
@@ -891,17 +903,20 @@ static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
||||||
const uint8_t *buf, int buf_size)
|
const uint8_t *buf, int buf_size)
|
||||||
{
|
{
|
||||||
const uint8_t *buf_ptr = buf, *bs_hdr;
|
GetByteContext gb;
|
||||||
|
const uint8_t *bs_hdr;
|
||||||
uint32_t frame_num, word2, check_sum, data_size;
|
uint32_t frame_num, word2, check_sum, data_size;
|
||||||
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
|
uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
|
||||||
uint16_t height, width;
|
uint16_t height, width;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
bytestream2_init(&gb, buf, buf_size);
|
||||||
|
|
||||||
/* parse and check the OS header */
|
/* parse and check the OS header */
|
||||||
frame_num = bytestream_get_le32(&buf_ptr);
|
frame_num = bytestream2_get_le32(&gb);
|
||||||
word2 = bytestream_get_le32(&buf_ptr);
|
word2 = bytestream2_get_le32(&gb);
|
||||||
check_sum = bytestream_get_le32(&buf_ptr);
|
check_sum = bytestream2_get_le32(&gb);
|
||||||
data_size = bytestream_get_le32(&buf_ptr);
|
data_size = bytestream2_get_le32(&gb);
|
||||||
|
|
||||||
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
|
if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
|
av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
|
||||||
@@ -909,29 +924,27 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* parse the bitstream header */
|
/* parse the bitstream header */
|
||||||
bs_hdr = buf_ptr;
|
bs_hdr = gb.buffer;
|
||||||
buf_size -= 16;
|
|
||||||
|
|
||||||
if (bytestream_get_le16(&buf_ptr) != 32) {
|
if (bytestream2_get_le16(&gb) != 32) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
|
av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->frame_num = frame_num;
|
ctx->frame_num = frame_num;
|
||||||
ctx->frame_flags = bytestream_get_le16(&buf_ptr);
|
ctx->frame_flags = bytestream2_get_le16(&gb);
|
||||||
ctx->data_size = (bytestream_get_le32(&buf_ptr) + 7) >> 3;
|
ctx->data_size = (bytestream2_get_le32(&gb) + 7) >> 3;
|
||||||
ctx->cb_offset = *buf_ptr++;
|
ctx->cb_offset = bytestream2_get_byte(&gb);
|
||||||
|
|
||||||
if (ctx->data_size == 16)
|
if (ctx->data_size == 16)
|
||||||
return 4;
|
return 4;
|
||||||
if (ctx->data_size > buf_size)
|
ctx->data_size = FFMIN(ctx->data_size, buf_size - 16);
|
||||||
ctx->data_size = buf_size;
|
|
||||||
|
|
||||||
buf_ptr += 3; // skip reserved byte and checksum
|
bytestream2_skip(&gb, 3); // skip reserved byte and checksum
|
||||||
|
|
||||||
/* check frame dimensions */
|
/* check frame dimensions */
|
||||||
height = bytestream_get_le16(&buf_ptr);
|
height = bytestream2_get_le16(&gb);
|
||||||
width = bytestream_get_le16(&buf_ptr);
|
width = bytestream2_get_le16(&gb);
|
||||||
if (av_image_check_size(width, height, 0, avctx))
|
if (av_image_check_size(width, height, 0, avctx))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
@@ -953,9 +966,10 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
avcodec_set_dimensions(avctx, width, height);
|
avcodec_set_dimensions(avctx, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
y_offset = bytestream_get_le32(&buf_ptr);
|
y_offset = bytestream2_get_le32(&gb);
|
||||||
v_offset = bytestream_get_le32(&buf_ptr);
|
v_offset = bytestream2_get_le32(&gb);
|
||||||
u_offset = bytestream_get_le32(&buf_ptr);
|
u_offset = bytestream2_get_le32(&gb);
|
||||||
|
bytestream2_skip(&gb, 4);
|
||||||
|
|
||||||
/* unfortunately there is no common order of planes in the buffer */
|
/* unfortunately there is no common order of planes in the buffer */
|
||||||
/* so we use that sorting algo for determining planes data sizes */
|
/* so we use that sorting algo for determining planes data sizes */
|
||||||
@@ -974,6 +988,7 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
ctx->v_data_size = ends[1] - starts[1];
|
ctx->v_data_size = ends[1] - starts[1];
|
||||||
ctx->u_data_size = ends[2] - starts[2];
|
ctx->u_data_size = ends[2] - starts[2];
|
||||||
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
|
if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
|
||||||
|
FFMIN3(y_offset, v_offset, u_offset) < gb.buffer - bs_hdr + 16 ||
|
||||||
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
|
FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
|
av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@@ -982,7 +997,7 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
|
|||||||
ctx->y_data_ptr = bs_hdr + y_offset;
|
ctx->y_data_ptr = bs_hdr + y_offset;
|
||||||
ctx->v_data_ptr = bs_hdr + v_offset;
|
ctx->v_data_ptr = bs_hdr + v_offset;
|
||||||
ctx->u_data_ptr = bs_hdr + u_offset;
|
ctx->u_data_ptr = bs_hdr + u_offset;
|
||||||
ctx->alt_quant = buf_ptr + sizeof(uint32_t);
|
ctx->alt_quant = gb.buffer;
|
||||||
|
|
||||||
if (ctx->data_size == 16) {
|
if (ctx->data_size == 16) {
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
|
av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
|
||||||
|
@@ -211,6 +211,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
|
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
|
||||||
if (ff_ivi_init_planes(ctx->planes, &pic_conf)) {
|
if (ff_ivi_init_planes(ctx->planes, &pic_conf)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
|
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
|
||||||
|
ctx->pic_conf.luma_bands = 0;
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +296,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
|
|
||||||
band->is_empty = get_bits1(&ctx->gb);
|
band->is_empty = get_bits1(&ctx->gb);
|
||||||
if (!band->is_empty) {
|
if (!band->is_empty) {
|
||||||
|
int old_blk_size = band->blk_size;
|
||||||
/* skip header size
|
/* skip header size
|
||||||
* If header size is not given, header size is 4 bytes. */
|
* If header size is not given, header size is 4 bytes. */
|
||||||
if (get_bits1(&ctx->gb))
|
if (get_bits1(&ctx->gb))
|
||||||
@@ -353,7 +355,13 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
band->inv_transform = transforms[transform_id].inv_trans;
|
band->inv_transform = transforms[transform_id].inv_trans;
|
||||||
band->dc_transform = transforms[transform_id].dc_trans;
|
band->dc_transform = transforms[transform_id].dc_trans;
|
||||||
band->is_2d_trans = transforms[transform_id].is_2d_trans;
|
band->is_2d_trans = transforms[transform_id].is_2d_trans;
|
||||||
band->transform_size= (transform_id < 10) ? 8 : 4;
|
if (transform_id < 10)
|
||||||
|
band->transform_size = 8;
|
||||||
|
else
|
||||||
|
band->transform_size = 4;
|
||||||
|
|
||||||
|
if (band->blk_size != band->transform_size)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
scan_indx = get_bits(&ctx->gb, 4);
|
scan_indx = get_bits(&ctx->gb, 4);
|
||||||
if ((scan_indx>4 && scan_indx<10) != (band->blk_size==4)) {
|
if ((scan_indx>4 && scan_indx<10) != (band->blk_size==4)) {
|
||||||
@@ -364,6 +372,12 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n");
|
av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
if (scan_indx > 4 && scan_indx < 10) {
|
||||||
|
if (band->blk_size != 4)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
} else if (band->blk_size != 8)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
band->scan = scan_index_to_tab[scan_indx];
|
band->scan = scan_index_to_tab[scan_indx];
|
||||||
band->scan_size = band->blk_size;
|
band->scan_size = band->blk_size;
|
||||||
|
|
||||||
@@ -372,11 +386,23 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
av_log(avctx, AV_LOG_ERROR, "Custom quant matrix encountered!\n");
|
av_log(avctx, AV_LOG_ERROR, "Custom quant matrix encountered!\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (quant_mat > 21) {
|
if (quant_mat >= FF_ARRAY_ELEMS(quant_index_to_tab)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix encountered!\n");
|
av_log_ask_for_sample(avctx, "Quantization matrix %d",
|
||||||
|
quant_mat);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
band->quant_mat = quant_mat;
|
band->quant_mat = quant_mat;
|
||||||
|
} else {
|
||||||
|
if (old_blk_size != band->blk_size) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"The band block size does not match the configuration "
|
||||||
|
"inherited\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
if (band->quant_mat < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Invalid quant_mat inherited\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (quant_index_to_tab[band->quant_mat] > 4 && band->blk_size == 4) {
|
if (quant_index_to_tab[band->quant_mat] > 4 && band->blk_size == 4) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix for 4x4 block encountered!\n");
|
av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix for 4x4 block encountered!\n");
|
||||||
@@ -504,8 +530,11 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (band->inherit_mv && ref_mb) {
|
if (band->inherit_mv) {
|
||||||
mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
|
/* copy mb_type from corresponding reference mb */
|
||||||
|
if (!ref_mb)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
mb->type = ref_mb->type;
|
||||||
} else if (ctx->frame_type == FRAMETYPE_INTRA ||
|
} else if (ctx->frame_type == FRAMETYPE_INTRA ||
|
||||||
ctx->frame_type == FRAMETYPE_INTRA1) {
|
ctx->frame_type == FRAMETYPE_INTRA1) {
|
||||||
mb->type = 0; /* mb_type is always INTRA for intra-frames */
|
mb->type = 0; /* mb_type is always INTRA for intra-frames */
|
||||||
@@ -528,15 +557,16 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
if (!mb->type) {
|
if (!mb->type) {
|
||||||
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
|
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
|
||||||
} else {
|
} else {
|
||||||
if (band->inherit_mv && ref_mb) {
|
if (band->inherit_mv) {
|
||||||
/* motion vector inheritance */
|
if (ref_mb)
|
||||||
if (mv_scale) {
|
/* motion vector inheritance */
|
||||||
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
|
if (mv_scale) {
|
||||||
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
|
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
|
||||||
} else {
|
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
|
||||||
mb->mv_x = ref_mb->mv_x;
|
} else {
|
||||||
mb->mv_y = ref_mb->mv_y;
|
mb->mv_x = ref_mb->mv_x;
|
||||||
}
|
mb->mv_y = ref_mb->mv_y;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* decode motion vector deltas */
|
/* decode motion vector deltas */
|
||||||
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
|
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
|
||||||
|
@@ -74,7 +74,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
|
tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
|
||||||
if (tile_size > 256) {
|
if (tile_size > 256) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
|
av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode number of wavelet bands */
|
/* decode number of wavelet bands */
|
||||||
@@ -85,7 +85,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
|
if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
|
av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
|
||||||
pic_conf.luma_bands, pic_conf.chroma_bands);
|
pic_conf.luma_bands, pic_conf.chroma_bands);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_size_indx = get_bits(&ctx->gb, 4);
|
pic_size_indx = get_bits(&ctx->gb, 4);
|
||||||
@@ -98,8 +98,8 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->gop_flags & 2) {
|
if (ctx->gop_flags & 2) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n");
|
av_log_missing_feature(avctx, "YV12 picture format", 0);
|
||||||
return -1;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
|
pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
|
||||||
@@ -113,11 +113,11 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check if picture layout was changed and reallocate buffers */
|
/* check if picture layout was changed and reallocate buffers */
|
||||||
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
|
if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf) || ctx->gop_invalid) {
|
||||||
result = ff_ivi_init_planes(ctx->planes, &pic_conf);
|
result = ff_ivi_init_planes(ctx->planes, &pic_conf);
|
||||||
if (result) {
|
if (result < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
|
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
ctx->pic_conf = pic_conf;
|
ctx->pic_conf = pic_conf;
|
||||||
ctx->is_scalable = is_scalable;
|
ctx->is_scalable = is_scalable;
|
||||||
@@ -146,51 +146,54 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (get_bits1(&ctx->gb)) {
|
if (get_bits1(&ctx->gb)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n");
|
av_log_missing_feature(avctx, "Extended transform info", 0);
|
||||||
return -1;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* select transform function and scan pattern according to plane and band number */
|
/* select transform function and scan pattern according to plane and band number */
|
||||||
switch ((p << 2) + i) {
|
switch ((p << 2) + i) {
|
||||||
case 0:
|
case 0:
|
||||||
band->inv_transform = ff_ivi_inverse_slant_8x8;
|
band->inv_transform = ff_ivi_inverse_slant_8x8;
|
||||||
band->dc_transform = ff_ivi_dc_slant_2d;
|
band->dc_transform = ff_ivi_dc_slant_2d;
|
||||||
band->scan = ff_zigzag_direct;
|
band->scan = ff_zigzag_direct;
|
||||||
band->transform_size= 8;
|
band->transform_size = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
band->inv_transform = ff_ivi_row_slant8;
|
band->inv_transform = ff_ivi_row_slant8;
|
||||||
band->dc_transform = ff_ivi_dc_row_slant;
|
band->dc_transform = ff_ivi_dc_row_slant;
|
||||||
band->scan = ff_ivi_vertical_scan_8x8;
|
band->scan = ff_ivi_vertical_scan_8x8;
|
||||||
band->transform_size= 8;
|
band->transform_size = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
band->inv_transform = ff_ivi_col_slant8;
|
band->inv_transform = ff_ivi_col_slant8;
|
||||||
band->dc_transform = ff_ivi_dc_col_slant;
|
band->dc_transform = ff_ivi_dc_col_slant;
|
||||||
band->scan = ff_ivi_horizontal_scan_8x8;
|
band->scan = ff_ivi_horizontal_scan_8x8;
|
||||||
band->transform_size= 8;
|
band->transform_size = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
band->inv_transform = ff_ivi_put_pixels_8x8;
|
band->inv_transform = ff_ivi_put_pixels_8x8;
|
||||||
band->dc_transform = ff_ivi_put_dc_pixel_8x8;
|
band->dc_transform = ff_ivi_put_dc_pixel_8x8;
|
||||||
band->scan = ff_ivi_horizontal_scan_8x8;
|
band->scan = ff_ivi_horizontal_scan_8x8;
|
||||||
band->transform_size= 8;
|
band->transform_size = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
band->inv_transform = ff_ivi_inverse_slant_4x4;
|
band->inv_transform = ff_ivi_inverse_slant_4x4;
|
||||||
band->dc_transform = ff_ivi_dc_slant_2d;
|
band->dc_transform = ff_ivi_dc_slant_2d;
|
||||||
band->scan = ff_ivi_direct_scan_4x4;
|
band->scan = ff_ivi_direct_scan_4x4;
|
||||||
band->transform_size= 4;
|
band->transform_size = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
|
band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
|
||||||
band->inv_transform == ff_ivi_inverse_slant_4x4;
|
band->inv_transform == ff_ivi_inverse_slant_4x4;
|
||||||
|
|
||||||
|
if (band->transform_size != band->blk_size)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* select dequant matrix according to plane and band number */
|
/* select dequant matrix according to plane and band number */
|
||||||
if (!p) {
|
if (!p) {
|
||||||
quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
|
quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
|
||||||
@@ -216,7 +219,7 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
|
|
||||||
if (get_bits(&ctx->gb, 2)) {
|
if (get_bits(&ctx->gb, 2)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
|
av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,17 +249,17 @@ static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
if (blk_size_changed) {
|
if (blk_size_changed) {
|
||||||
result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
|
result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
|
||||||
pic_conf.tile_height);
|
pic_conf.tile_height);
|
||||||
if (result) {
|
if (result < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Couldn't reallocate internal structures!\n");
|
"Couldn't reallocate internal structures!\n");
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->gop_flags & 8) {
|
if (ctx->gop_flags & 8) {
|
||||||
if (get_bits(&ctx->gb, 3)) {
|
if (get_bits(&ctx->gb, 3)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
|
av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_bits1(&ctx->gb))
|
if (get_bits1(&ctx->gb))
|
||||||
@@ -305,25 +308,27 @@ static inline void skip_hdr_extension(GetBitContext *gb)
|
|||||||
*/
|
*/
|
||||||
static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (get_bits(&ctx->gb, 5) != 0x1F) {
|
if (get_bits(&ctx->gb, 5) != 0x1F) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
|
av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->prev_frame_type = ctx->frame_type;
|
ctx->prev_frame_type = ctx->frame_type;
|
||||||
ctx->frame_type = get_bits(&ctx->gb, 3);
|
ctx->frame_type = get_bits(&ctx->gb, 3);
|
||||||
if (ctx->frame_type >= 5) {
|
if (ctx->frame_type >= 5) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
|
av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->frame_num = get_bits(&ctx->gb, 8);
|
ctx->frame_num = get_bits(&ctx->gb, 8);
|
||||||
|
|
||||||
if (ctx->frame_type == FRAMETYPE_INTRA) {
|
if (ctx->frame_type == FRAMETYPE_INTRA) {
|
||||||
ctx->gop_invalid = 1;
|
if ((ret = decode_gop_header(ctx, avctx)) < 0) {
|
||||||
if (decode_gop_header(ctx, avctx)) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
|
av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
ctx->gop_invalid = 1;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
ctx->gop_invalid = 0;
|
ctx->gop_invalid = 0;
|
||||||
}
|
}
|
||||||
@@ -346,8 +351,10 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
skip_hdr_extension(&ctx->gb); /* XXX: untested */
|
skip_hdr_extension(&ctx->gb); /* XXX: untested */
|
||||||
|
|
||||||
/* decode macroblock huffman codebook */
|
/* decode macroblock huffman codebook */
|
||||||
if (ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40, IVI_MB_HUFF, &ctx->mb_vlc, avctx))
|
ret = ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40,
|
||||||
return -1;
|
IVI_MB_HUFF, &ctx->mb_vlc, avctx);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
|
skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
|
||||||
}
|
}
|
||||||
@@ -369,7 +376,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
|
|||||||
static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
||||||
AVCodecContext *avctx)
|
AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
int i;
|
int i, ret;
|
||||||
uint8_t band_flags;
|
uint8_t band_flags;
|
||||||
|
|
||||||
band_flags = get_bits(&ctx->gb, 8);
|
band_flags = get_bits(&ctx->gb, 8);
|
||||||
@@ -393,7 +400,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
if (band->num_corr > 61) {
|
if (band->num_corr > 61) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
|
av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
|
||||||
band->num_corr);
|
band->num_corr);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read correction pairs */
|
/* read correction pairs */
|
||||||
@@ -405,8 +412,10 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
|
band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
|
||||||
|
|
||||||
/* decode block huffman codebook */
|
/* decode block huffman codebook */
|
||||||
if (ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF, &band->blk_vlc, avctx))
|
ret = ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF,
|
||||||
return -1;
|
&band->blk_vlc, avctx);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
band->checksum_present = get_bits1(&ctx->gb);
|
band->checksum_present = get_bits1(&ctx->gb);
|
||||||
if (band->checksum_present)
|
if (band->checksum_present)
|
||||||
@@ -473,7 +482,7 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
|
|||||||
if (get_bits1(&ctx->gb)) {
|
if (get_bits1(&ctx->gb)) {
|
||||||
if (ctx->frame_type == FRAMETYPE_INTRA) {
|
if (ctx->frame_type == FRAMETYPE_INTRA) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
|
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
mb->type = 1; /* empty macroblocks are always INTER */
|
mb->type = 1; /* empty macroblocks are always INTER */
|
||||||
mb->cbp = 0; /* all blocks are empty */
|
mb->cbp = 0; /* all blocks are empty */
|
||||||
@@ -648,7 +657,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
|
result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
|
||||||
if (result) {
|
if (result) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
|
av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->buf_switch = 0;
|
ctx->buf_switch = 0;
|
||||||
|
@@ -757,6 +757,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(IS_DIRECT(mb_type)){
|
if(IS_DIRECT(mb_type)){
|
||||||
|
if (!s->pp_time)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
|
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
|
||||||
mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
|
mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
|
||||||
}else{
|
}else{
|
||||||
|
@@ -41,6 +41,29 @@ extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tabl
|
|||||||
static VLC ivi_mb_vlc_tabs [8]; ///< static macroblock Huffman tables
|
static VLC ivi_mb_vlc_tabs [8]; ///< static macroblock Huffman tables
|
||||||
static VLC ivi_blk_vlc_tabs[8]; ///< static block Huffman tables
|
static VLC ivi_blk_vlc_tabs[8]; ///< static block Huffman tables
|
||||||
|
|
||||||
|
typedef void (*ivi_mc_func) (int16_t *buf, const int16_t *ref_buf,
|
||||||
|
uint32_t pitch, int mc_type);
|
||||||
|
|
||||||
|
static int ivi_mc(IVIBandDesc *band, ivi_mc_func mc,
|
||||||
|
int offs, int mv_x, int mv_y, int mc_type)
|
||||||
|
{
|
||||||
|
int ref_offs = offs + mv_y * band->pitch + mv_x;
|
||||||
|
int buf_size = band->pitch * band->aheight;
|
||||||
|
int min_size = band->pitch * (band->blk_size - 1) + band->blk_size;
|
||||||
|
int ref_size = (mc_type > 1) * band->pitch + (mc_type & 1);
|
||||||
|
|
||||||
|
if (offs < 0 || ref_offs < 0 || !band->ref_buf)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
if (buf_size - min_size < offs)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
if (buf_size - min_size - ref_size < ref_offs)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
mc(band->buf + offs, band->ref_buf + ref_offs, band->pitch, mc_type);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse "nbits" bits of the value "val" and return the result
|
* Reverse "nbits" bits of the value "val" and return the result
|
||||||
* in the least significant bits.
|
* in the least significant bits.
|
||||||
@@ -50,9 +73,10 @@ static uint16_t inv_bits(uint16_t val, int nbits)
|
|||||||
uint16_t res;
|
uint16_t res;
|
||||||
|
|
||||||
if (nbits <= 8) {
|
if (nbits <= 8) {
|
||||||
res = ff_reverse[val] >> (8-nbits);
|
res = ff_reverse[val] >> (8 - nbits);
|
||||||
} else
|
} else
|
||||||
res = ((ff_reverse[val & 0xFF] << 8) + (ff_reverse[val >> 8])) >> (16-nbits);
|
res = ((ff_reverse[val & 0xFF] << 8) +
|
||||||
|
(ff_reverse[val >> 8])) >> (16 - nbits);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -85,7 +109,7 @@ static int ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag)
|
|||||||
|
|
||||||
bits[pos] = i + cb->xbits[i] + not_last_row;
|
bits[pos] = i + cb->xbits[i] + not_last_row;
|
||||||
if (bits[pos] > IVI_VLC_BITS)
|
if (bits[pos] > IVI_VLC_BITS)
|
||||||
return -1; /* invalid descriptor */
|
return AVERROR_INVALIDDATA; /* invalid descriptor */
|
||||||
|
|
||||||
codewords[pos] = inv_bits((prefix | j), bits[pos]);
|
codewords[pos] = inv_bits((prefix | j), bits[pos]);
|
||||||
if (!bits[pos])
|
if (!bits[pos])
|
||||||
@@ -111,10 +135,12 @@ void ff_ivi_init_static_vlc(void)
|
|||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192;
|
ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192;
|
||||||
ivi_mb_vlc_tabs[i].table_allocated = 8192;
|
ivi_mb_vlc_tabs[i].table_allocated = 8192;
|
||||||
ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i], &ivi_mb_vlc_tabs[i], 1);
|
ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i],
|
||||||
|
&ivi_mb_vlc_tabs[i], 1);
|
||||||
ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192;
|
ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192;
|
||||||
ivi_blk_vlc_tabs[i].table_allocated = 8192;
|
ivi_blk_vlc_tabs[i].table_allocated = 8192;
|
||||||
ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &ivi_blk_vlc_tabs[i], 1);
|
ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i],
|
||||||
|
&ivi_blk_vlc_tabs[i], 1);
|
||||||
}
|
}
|
||||||
initialized_vlcs = 1;
|
initialized_vlcs = 1;
|
||||||
}
|
}
|
||||||
@@ -138,56 +164,59 @@ static void ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src)
|
|||||||
* @param[in] desc2 ptr to the 2nd descriptor to compare
|
* @param[in] desc2 ptr to the 2nd descriptor to compare
|
||||||
* @return comparison result: 0 - equal, 1 - not equal
|
* @return comparison result: 0 - equal, 1 - not equal
|
||||||
*/
|
*/
|
||||||
static int ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2)
|
static int ivi_huff_desc_cmp(const IVIHuffDesc *desc1,
|
||||||
|
const IVIHuffDesc *desc2)
|
||||||
{
|
{
|
||||||
return desc1->num_rows != desc2->num_rows
|
return desc1->num_rows != desc2->num_rows ||
|
||||||
|| memcmp(desc1->xbits, desc2->xbits, desc1->num_rows);
|
memcmp(desc1->xbits, desc2->xbits, desc1->num_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
|
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
|
||||||
IVIHuffTab *huff_tab, AVCodecContext *avctx)
|
IVIHuffTab *huff_tab, AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
int i, result;
|
int i, result;
|
||||||
IVIHuffDesc new_huff;
|
IVIHuffDesc new_huff;
|
||||||
|
|
||||||
if (!desc_coded) {
|
if (!desc_coded) {
|
||||||
/* select default table */
|
/* select default table */
|
||||||
huff_tab->tab = (which_tab) ? &ivi_blk_vlc_tabs[7]
|
huff_tab->tab = (which_tab) ? &ivi_blk_vlc_tabs[7]
|
||||||
: &ivi_mb_vlc_tabs [7];
|
: &ivi_mb_vlc_tabs [7];
|
||||||
} else {
|
return 0;
|
||||||
huff_tab->tab_sel = get_bits(gb, 3);
|
}
|
||||||
if (huff_tab->tab_sel == 7) {
|
|
||||||
/* custom huffman table (explicitly encoded) */
|
|
||||||
new_huff.num_rows = get_bits(gb, 4);
|
|
||||||
if (!new_huff.num_rows) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < new_huff.num_rows; i++)
|
huff_tab->tab_sel = get_bits(gb, 3);
|
||||||
new_huff.xbits[i] = get_bits(gb, 4);
|
if (huff_tab->tab_sel == 7) {
|
||||||
|
/* custom huffman table (explicitly encoded) */
|
||||||
/* Have we got the same custom table? Rebuild if not. */
|
new_huff.num_rows = get_bits(gb, 4);
|
||||||
if (ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc) || !huff_tab->cust_tab.table) {
|
if (!new_huff.num_rows) {
|
||||||
ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
|
av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if (huff_tab->cust_tab.table)
|
|
||||||
ff_free_vlc(&huff_tab->cust_tab);
|
|
||||||
result = ivi_create_huff_from_desc(&huff_tab->cust_desc,
|
|
||||||
&huff_tab->cust_tab, 0);
|
|
||||||
if (result) {
|
|
||||||
huff_tab->cust_desc.num_rows = 0; // reset faulty description
|
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
|
||||||
"Error while initializing custom vlc table!\n");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
huff_tab->tab = &huff_tab->cust_tab;
|
|
||||||
} else {
|
|
||||||
/* select one of predefined tables */
|
|
||||||
huff_tab->tab = (which_tab) ? &ivi_blk_vlc_tabs[huff_tab->tab_sel]
|
|
||||||
: &ivi_mb_vlc_tabs [huff_tab->tab_sel];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < new_huff.num_rows; i++)
|
||||||
|
new_huff.xbits[i] = get_bits(gb, 4);
|
||||||
|
|
||||||
|
/* Have we got the same custom table? Rebuild if not. */
|
||||||
|
if (ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc) || !huff_tab->cust_tab.table) {
|
||||||
|
ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
|
||||||
|
|
||||||
|
if (huff_tab->cust_tab.table)
|
||||||
|
ff_free_vlc(&huff_tab->cust_tab);
|
||||||
|
result = ivi_create_huff_from_desc(&huff_tab->cust_desc,
|
||||||
|
&huff_tab->cust_tab, 0);
|
||||||
|
if (result) {
|
||||||
|
// reset faulty description
|
||||||
|
huff_tab->cust_desc.num_rows = 0;
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Error while initializing custom vlc table!\n");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
huff_tab->tab = &huff_tab->cust_tab;
|
||||||
|
} else {
|
||||||
|
/* select one of predefined tables */
|
||||||
|
huff_tab->tab = (which_tab) ? &ivi_blk_vlc_tabs[huff_tab->tab_sel]
|
||||||
|
: &ivi_mb_vlc_tabs [huff_tab->tab_sel];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -216,17 +245,23 @@ static av_cold void ivi_free_buffers(IVIPlaneDesc *planes)
|
|||||||
av_freep(&planes[p].bands[b].tiles);
|
av_freep(&planes[p].bands[b].tiles);
|
||||||
}
|
}
|
||||||
av_freep(&planes[p].bands);
|
av_freep(&planes[p].bands);
|
||||||
|
planes[p].num_bands = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
||||||
{
|
{
|
||||||
int p, b;
|
int p, b;
|
||||||
uint32_t b_width, b_height, align_fac, width_aligned, height_aligned, buf_size;
|
uint32_t b_width, b_height, align_fac, width_aligned,
|
||||||
|
height_aligned, buf_size;
|
||||||
IVIBandDesc *band;
|
IVIBandDesc *band;
|
||||||
|
|
||||||
ivi_free_buffers(planes);
|
ivi_free_buffers(planes);
|
||||||
|
|
||||||
|
if (cfg->pic_width < 1 || cfg->pic_height < 1 ||
|
||||||
|
cfg->luma_bands < 1 || cfg->chroma_bands < 1)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* fill in the descriptor of the luminance plane */
|
/* fill in the descriptor of the luminance plane */
|
||||||
planes[0].width = cfg->pic_width;
|
planes[0].width = cfg->pic_width;
|
||||||
planes[0].height = cfg->pic_height;
|
planes[0].height = cfg->pic_height;
|
||||||
@@ -245,8 +280,10 @@ av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
|||||||
/* select band dimensions: if there is only one band then it
|
/* select band dimensions: if there is only one band then it
|
||||||
* has the full size, if there are several bands each of them
|
* has the full size, if there are several bands each of them
|
||||||
* has only half size */
|
* has only half size */
|
||||||
b_width = planes[p].num_bands == 1 ? planes[p].width : (planes[p].width + 1) >> 1;
|
b_width = planes[p].num_bands == 1 ? planes[p].width
|
||||||
b_height = planes[p].num_bands == 1 ? planes[p].height : (planes[p].height + 1) >> 1;
|
: (planes[p].width + 1) >> 1;
|
||||||
|
b_height = planes[p].num_bands == 1 ? planes[p].height
|
||||||
|
: (planes[p].height + 1) >> 1;
|
||||||
|
|
||||||
/* luma band buffers will be aligned on 16x16 (max macroblock size) */
|
/* luma band buffers will be aligned on 16x16 (max macroblock size) */
|
||||||
/* chroma band buffers will be aligned on 8x8 (max macroblock size) */
|
/* chroma band buffers will be aligned on 8x8 (max macroblock size) */
|
||||||
@@ -275,19 +312,56 @@ av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
|
|||||||
if (!band->bufs[2])
|
if (!band->bufs[2])
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
/* reset custom vlc */
|
||||||
planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0; /* reset custom vlc */
|
planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height)
|
static int ivi_init_tiles(IVIBandDesc *band, IVITile *ref_tile,
|
||||||
|
int p, int b, int t_height, int t_width)
|
||||||
{
|
{
|
||||||
int p, b, x, y, x_tiles, y_tiles, t_width, t_height;
|
int x, y;
|
||||||
|
IVITile *tile = band->tiles;
|
||||||
|
|
||||||
|
for (y = 0; y < band->height; y += t_height) {
|
||||||
|
for (x = 0; x < band->width; x += t_width) {
|
||||||
|
tile->xpos = x;
|
||||||
|
tile->ypos = y;
|
||||||
|
tile->mb_size = band->mb_size;
|
||||||
|
tile->width = FFMIN(band->width - x, t_width);
|
||||||
|
tile->height = FFMIN(band->height - y, t_height);
|
||||||
|
tile->is_empty = tile->data_size = 0;
|
||||||
|
/* calculate number of macroblocks */
|
||||||
|
tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
|
||||||
|
band->mb_size);
|
||||||
|
|
||||||
|
av_freep(&tile->mbs);
|
||||||
|
tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
|
||||||
|
if (!tile->mbs)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
tile->ref_mbs = 0;
|
||||||
|
if (p || b) {
|
||||||
|
if (tile->num_MBs != ref_tile->num_MBs)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
tile->ref_mbs = ref_tile->mbs;
|
||||||
|
ref_tile++;
|
||||||
|
}
|
||||||
|
tile++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes,
|
||||||
|
int tile_width, int tile_height)
|
||||||
|
{
|
||||||
|
int p, b, x_tiles, y_tiles, t_width, t_height, ret;
|
||||||
IVIBandDesc *band;
|
IVIBandDesc *band;
|
||||||
IVITile *tile, *ref_tile;
|
|
||||||
|
|
||||||
for (p = 0; p < 3; p++) {
|
for (p = 0; p < 3; p++) {
|
||||||
t_width = !p ? tile_width : (tile_width + 3) >> 2;
|
t_width = !p ? tile_width : (tile_width + 3) >> 2;
|
||||||
@@ -311,44 +385,14 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_hei
|
|||||||
if (!band->tiles)
|
if (!band->tiles)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
tile = band->tiles;
|
|
||||||
|
|
||||||
/* use the first luma band as reference for motion vectors
|
/* use the first luma band as reference for motion vectors
|
||||||
* and quant */
|
* and quant */
|
||||||
ref_tile = planes[0].bands[0].tiles;
|
ret = ivi_init_tiles(band, planes[0].bands[0].tiles,
|
||||||
|
p, b, t_height, t_width);
|
||||||
for (y = 0; y < band->height; y += t_height) {
|
if (ret < 0)
|
||||||
for (x = 0; x < band->width; x += t_width) {
|
return ret;
|
||||||
tile->xpos = x;
|
}
|
||||||
tile->ypos = y;
|
}
|
||||||
tile->mb_size = band->mb_size;
|
|
||||||
tile->width = FFMIN(band->width - x, t_width);
|
|
||||||
tile->height = FFMIN(band->height - y, t_height);
|
|
||||||
tile->is_empty = tile->data_size = 0;
|
|
||||||
/* calculate number of macroblocks */
|
|
||||||
tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
|
|
||||||
band->mb_size);
|
|
||||||
|
|
||||||
av_freep(&tile->mbs);
|
|
||||||
tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
|
|
||||||
if (!tile->mbs)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
tile->ref_mbs = 0;
|
|
||||||
if (p || b) {
|
|
||||||
if (tile->num_MBs <= ref_tile->num_MBs) {
|
|
||||||
tile->ref_mbs = ref_tile->mbs;
|
|
||||||
}else
|
|
||||||
av_log(NULL, AV_LOG_DEBUG, "Cannot use ref_tile, too few mbs\n");
|
|
||||||
ref_tile++;
|
|
||||||
}
|
|
||||||
|
|
||||||
tile++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}// for b
|
|
||||||
}// for p
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -380,6 +424,117 @@ static int ivi_dec_tile_data_size(GetBitContext *gb)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs,
|
||||||
|
int blk_size)
|
||||||
|
{
|
||||||
|
int buf_size = band->pitch * band->aheight - buf_offs;
|
||||||
|
int min_size = (blk_size - 1) * band->pitch + blk_size;
|
||||||
|
|
||||||
|
if (min_size > buf_size)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
band->dc_transform(prev_dc, band->buf + buf_offs,
|
||||||
|
band->pitch, blk_size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band,
|
||||||
|
ivi_mc_func mc, int mv_x, int mv_y,
|
||||||
|
int *prev_dc, int is_intra, int mc_type,
|
||||||
|
uint32_t quant, int offs,
|
||||||
|
AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
const uint16_t *base_tab = is_intra ? band->intra_base : band->inter_base;
|
||||||
|
RVMapDesc *rvmap = band->rv_map;
|
||||||
|
uint8_t col_flags[8];
|
||||||
|
int32_t trvec[64];
|
||||||
|
uint32_t sym = 0, lo, hi, q;
|
||||||
|
int pos, run, val;
|
||||||
|
int blk_size = band->blk_size;
|
||||||
|
int num_coeffs = blk_size * blk_size;
|
||||||
|
int col_mask = blk_size - 1;
|
||||||
|
int scan_pos = -1;
|
||||||
|
int min_size = band->pitch * (band->transform_size - 1) +
|
||||||
|
band->transform_size;
|
||||||
|
int buf_size = band->pitch * band->aheight - offs;
|
||||||
|
|
||||||
|
if (min_size > buf_size)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
if (!band->scan) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Scan pattern is not set.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* zero transform vector */
|
||||||
|
memset(trvec, 0, num_coeffs * sizeof(trvec[0]));
|
||||||
|
/* zero column flags */
|
||||||
|
memset(col_flags, 0, sizeof(col_flags));
|
||||||
|
while (scan_pos <= num_coeffs) {
|
||||||
|
sym = get_vlc2(gb, band->blk_vlc.tab->table,
|
||||||
|
IVI_VLC_BITS, 1);
|
||||||
|
if (sym == rvmap->eob_sym)
|
||||||
|
break; /* End of block */
|
||||||
|
|
||||||
|
/* Escape - run/val explicitly coded using 3 vlc codes */
|
||||||
|
if (sym == rvmap->esc_sym) {
|
||||||
|
run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
|
||||||
|
lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||||
|
hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
||||||
|
/* merge them and convert into signed val */
|
||||||
|
val = IVI_TOSIGNED((hi << 6) | lo);
|
||||||
|
} else {
|
||||||
|
if (sym >= 256U) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
run = rvmap->runtab[sym];
|
||||||
|
val = rvmap->valtab[sym];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* de-zigzag and dequantize */
|
||||||
|
scan_pos += run;
|
||||||
|
if (scan_pos >= num_coeffs || scan_pos < 0)
|
||||||
|
break;
|
||||||
|
pos = band->scan[scan_pos];
|
||||||
|
|
||||||
|
if (!val)
|
||||||
|
av_dlog(avctx, "Val = 0 encountered!\n");
|
||||||
|
|
||||||
|
q = (base_tab[pos] * quant) >> 9;
|
||||||
|
if (q > 1)
|
||||||
|
val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
|
||||||
|
trvec[pos] = val;
|
||||||
|
/* track columns containing non-zero coeffs */
|
||||||
|
col_flags[pos & col_mask] |= !!val;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scan_pos < 0 || scan_pos >= num_coeffs && sym != rvmap->eob_sym)
|
||||||
|
return AVERROR_INVALIDDATA; /* corrupt block data */
|
||||||
|
|
||||||
|
/* undoing DC coeff prediction for intra-blocks */
|
||||||
|
if (is_intra && band->is_2d_trans) {
|
||||||
|
*prev_dc += trvec[0];
|
||||||
|
trvec[0] = *prev_dc;
|
||||||
|
col_flags[0] |= !!*prev_dc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(band->transform_size > band->blk_size){
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "Too large transform\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* apply inverse transform */
|
||||||
|
band->inv_transform(trvec, band->buf + offs,
|
||||||
|
band->pitch, col_flags);
|
||||||
|
|
||||||
|
/* apply motion compensation */
|
||||||
|
if (!is_intra)
|
||||||
|
return ivi_mc(band, mc, offs, mv_x, mv_y, mc_type);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Decode block data:
|
* Decode block data:
|
||||||
* extract huffman-coded transform coefficients from the bitstream,
|
* extract huffman-coded transform coefficients from the bitstream,
|
||||||
@@ -391,27 +546,22 @@ static int ivi_dec_tile_data_size(GetBitContext *gb)
|
|||||||
* @param[in] tile pointer to the tile descriptor
|
* @param[in] tile pointer to the tile descriptor
|
||||||
* @return result code: 0 - OK, -1 = error (corrupted blocks data)
|
* @return result code: 0 - OK, -1 = error (corrupted blocks data)
|
||||||
*/
|
*/
|
||||||
static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile,
|
static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band,
|
||||||
AVCodecContext *avctx)
|
IVITile *tile, AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val,
|
int mbn, blk, num_blocks, blk_size, ret, is_intra, mc_type = 0;
|
||||||
pos, is_intra, mc_type = 0, av_uninit(mv_x), av_uninit(mv_y), col_mask;
|
int mv_x = 0, mv_y = 0;
|
||||||
uint8_t col_flags[8];
|
int32_t prev_dc;
|
||||||
int32_t prev_dc, trvec[64];
|
uint32_t cbp, quant, buf_offs;
|
||||||
uint32_t cbp, av_uninit(sym), lo, hi, quant, buf_offs, q;
|
IVIMbInfo *mb;
|
||||||
IVIMbInfo *mb;
|
ivi_mc_func mc_with_delta_func, mc_no_delta_func;
|
||||||
RVMapDesc *rvmap = band->rv_map;
|
const uint8_t *scale_tab;
|
||||||
void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
|
|
||||||
void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
|
|
||||||
const uint16_t *base_tab;
|
|
||||||
const uint8_t *scale_tab;
|
|
||||||
|
|
||||||
prev_dc = 0; /* init intra prediction for the DC coefficient */
|
|
||||||
|
|
||||||
|
/* init intra prediction for the DC coefficient */
|
||||||
|
prev_dc = 0;
|
||||||
blk_size = band->blk_size;
|
blk_size = band->blk_size;
|
||||||
col_mask = blk_size - 1; /* column mask for tracking non-zero coeffs */
|
/* number of blocks per mb */
|
||||||
num_blocks = (band->mb_size != blk_size) ? 4 : 1; /* number of blocks per mb */
|
num_blocks = (band->mb_size != blk_size) ? 4 : 1;
|
||||||
num_coeffs = blk_size * blk_size;
|
|
||||||
if (blk_size == 8) {
|
if (blk_size == 8) {
|
||||||
mc_with_delta_func = ff_ivi_mc_8x8_delta;
|
mc_with_delta_func = ff_ivi_mc_8x8_delta;
|
||||||
mc_no_delta_func = ff_ivi_mc_8x8_no_delta;
|
mc_no_delta_func = ff_ivi_mc_8x8_no_delta;
|
||||||
@@ -427,7 +577,6 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile
|
|||||||
|
|
||||||
quant = av_clip(band->glob_quant + mb->q_delta, 0, 23);
|
quant = av_clip(band->glob_quant + mb->q_delta, 0, 23);
|
||||||
|
|
||||||
base_tab = is_intra ? band->intra_base : band->inter_base;
|
|
||||||
scale_tab = is_intra ? band->intra_scale : band->inter_scale;
|
scale_tab = is_intra ? band->intra_scale : band->inter_scale;
|
||||||
if (scale_tab)
|
if (scale_tab)
|
||||||
quant = scale_tab[quant];
|
quant = scale_tab[quant];
|
||||||
@@ -448,10 +597,10 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile
|
|||||||
cx = mb->mv_x & band->is_halfpel;
|
cx = mb->mv_x & band->is_halfpel;
|
||||||
cy = mb->mv_y & band->is_halfpel;
|
cy = mb->mv_y & band->is_halfpel;
|
||||||
|
|
||||||
if ( mb->xpos + dmv_x < 0
|
if (mb->xpos + dmv_x < 0 ||
|
||||||
|| mb->xpos + dmv_x + band->mb_size + cx > band->pitch
|
mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
|
||||||
|| mb->ypos + dmv_y < 0
|
mb->ypos + dmv_y < 0 ||
|
||||||
|| mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
|
mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,83 +616,26 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cbp & 1) { /* block coded ? */
|
if (cbp & 1) { /* block coded ? */
|
||||||
if (!band->scan) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Scan pattern is not set.\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
scan_pos = -1;
|
ret = ivi_decode_coded_blocks(gb, band, mc_with_delta_func,
|
||||||
memset(trvec, 0, num_coeffs*sizeof(trvec[0])); /* zero transform vector */
|
mv_x, mv_y, &prev_dc, is_intra,
|
||||||
memset(col_flags, 0, sizeof(col_flags)); /* zero column flags */
|
mc_type, quant, buf_offs, avctx);
|
||||||
|
if (ret < 0)
|
||||||
while (scan_pos <= num_coeffs) {
|
return ret;
|
||||||
sym = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
|
||||||
if (sym == rvmap->eob_sym)
|
|
||||||
break; /* End of block */
|
|
||||||
|
|
||||||
if (sym == rvmap->esc_sym) { /* Escape - run/val explicitly coded using 3 vlc codes */
|
|
||||||
run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
|
|
||||||
lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
|
||||||
hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
|
|
||||||
val = IVI_TOSIGNED((hi << 6) | lo); /* merge them and convert into signed val */
|
|
||||||
} else {
|
|
||||||
if (sym >= 256U) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
run = rvmap->runtab[sym];
|
|
||||||
val = rvmap->valtab[sym];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* de-zigzag and dequantize */
|
|
||||||
scan_pos += run;
|
|
||||||
if (scan_pos >= (unsigned)num_coeffs)
|
|
||||||
break;
|
|
||||||
pos = band->scan[scan_pos];
|
|
||||||
|
|
||||||
if (!val)
|
|
||||||
av_dlog(avctx, "Val = 0 encountered!\n");
|
|
||||||
|
|
||||||
q = (base_tab[pos] * quant) >> 9;
|
|
||||||
if (q > 1)
|
|
||||||
val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
|
|
||||||
trvec[pos] = val;
|
|
||||||
col_flags[pos & col_mask] |= !!val; /* track columns containing non-zero coeffs */
|
|
||||||
}// while
|
|
||||||
|
|
||||||
if (scan_pos >= num_coeffs && sym != rvmap->eob_sym)
|
|
||||||
return -1; /* corrupt block data */
|
|
||||||
|
|
||||||
/* undoing DC coeff prediction for intra-blocks */
|
|
||||||
if (is_intra && band->is_2d_trans) {
|
|
||||||
prev_dc += trvec[0];
|
|
||||||
trvec[0] = prev_dc;
|
|
||||||
col_flags[0] |= !!prev_dc;
|
|
||||||
}
|
|
||||||
if(band->transform_size > band->blk_size){
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Too large transform\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
/* apply inverse transform */
|
|
||||||
band->inv_transform(trvec, band->buf + buf_offs,
|
|
||||||
band->pitch, col_flags);
|
|
||||||
|
|
||||||
/* apply motion compensation */
|
|
||||||
if (!is_intra)
|
|
||||||
mc_with_delta_func(band->buf + buf_offs,
|
|
||||||
band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
|
|
||||||
band->pitch, mc_type);
|
|
||||||
} else {
|
} else {
|
||||||
/* block not coded */
|
/* block not coded */
|
||||||
/* for intra blocks apply the dc slant transform */
|
/* for intra blocks apply the dc slant transform */
|
||||||
/* for inter - perform the motion compensation without delta */
|
/* for inter - perform the motion compensation without delta */
|
||||||
if (is_intra) {
|
if (is_intra) {
|
||||||
band->dc_transform(&prev_dc, band->buf + buf_offs,
|
ret = ivi_dc_transform(band, &prev_dc, buf_offs, blk_size);
|
||||||
band->pitch, blk_size);
|
if (ret < 0)
|
||||||
} else
|
return ret;
|
||||||
mc_no_delta_func(band->buf + buf_offs,
|
} else {
|
||||||
band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
|
ret = ivi_mc(band, mc_no_delta_func, buf_offs,
|
||||||
band->pitch, mc_type);
|
mv_x, mv_y, mc_type);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cbp >>= 1;
|
cbp >>= 1;
|
||||||
@@ -568,12 +660,11 @@ static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
|
|||||||
IVITile *tile, int32_t mv_scale)
|
IVITile *tile, int32_t mv_scale)
|
||||||
{
|
{
|
||||||
int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
|
int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
|
||||||
int offs, mb_offset, row_offset;
|
int offs, mb_offset, row_offset, ret;
|
||||||
IVIMbInfo *mb, *ref_mb;
|
IVIMbInfo *mb, *ref_mb;
|
||||||
const int16_t *src;
|
const int16_t *src;
|
||||||
int16_t *dst;
|
int16_t *dst;
|
||||||
void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,
|
ivi_mc_func mc_no_delta_func;
|
||||||
int mc_type);
|
|
||||||
|
|
||||||
if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
|
if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches "
|
av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches "
|
||||||
@@ -663,9 +754,10 @@ static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
|
|||||||
for (blk = 0; blk < num_blocks; blk++) {
|
for (blk = 0; blk < num_blocks; blk++) {
|
||||||
/* adjust block position in the buffer according with its number */
|
/* adjust block position in the buffer according with its number */
|
||||||
offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
|
offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
|
||||||
mc_no_delta_func(band->buf + offs,
|
ret = ivi_mc(band, mc_no_delta_func, offs,
|
||||||
band->ref_buf + offs + mv_y * band->pitch + mv_x,
|
mv_x, mv_y, mc_type);
|
||||||
band->pitch, mc_type);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -804,8 +896,16 @@ static int decode_band(IVI45DecContext *ctx,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
result = ivi_decode_blocks(&ctx->gb, band, tile, avctx);
|
result = ivi_decode_blocks(&ctx->gb, band, tile, avctx);
|
||||||
if (result < 0 || ((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) {
|
if (result < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Corrupted tile data encountered!\n");
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Corrupted tile data encountered!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Tile data_size mismatch!\n");
|
||||||
|
result = AVERROR_INVALIDDATA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +913,8 @@ static int decode_band(IVI45DecContext *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore the selected rvmap table by applying its corrections in reverse order */
|
/* restore the selected rvmap table by applying its corrections in
|
||||||
|
* reverse order */
|
||||||
for (i = band->num_corr-1; i >= 0; i--) {
|
for (i = band->num_corr-1; i >= 0; i--) {
|
||||||
idx1 = band->corr[i*2];
|
idx1 = band->corr[i*2];
|
||||||
idx2 = band->corr[i*2+1];
|
idx2 = band->corr[i*2+1];
|
||||||
@@ -830,7 +931,8 @@ static int decode_band(IVI45DecContext *ctx,
|
|||||||
uint16_t chksum = ivi_calc_band_checksum(band);
|
uint16_t chksum = ivi_calc_band_checksum(band);
|
||||||
if (chksum != band->checksum) {
|
if (chksum != band->checksum) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
|
"Band checksum mismatch! Plane %d, band %d, "
|
||||||
|
"received: %x, calculated: %x\n",
|
||||||
band->plane, band->band_num, band->checksum, chksum);
|
band->plane, band->band_num, band->checksum, chksum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -857,14 +959,19 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
if (result) {
|
if (result) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Error while decoding picture header: %d\n", result);
|
"Error while decoding picture header: %d\n", result);
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
if (ctx->gop_invalid)
|
if (ctx->gop_invalid)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (ctx->gop_flags & IVI5_IS_PROTECTED) {
|
if (ctx->gop_flags & IVI5_IS_PROTECTED) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Password-protected clip!\n");
|
av_log(avctx, AV_LOG_ERROR, "Password-protected clip!\n");
|
||||||
return -1;
|
return AVERROR_PATCHWELCOME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ctx->planes[0].bands) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Color planes not initialized yet\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->switch_buffers(ctx);
|
ctx->switch_buffers(ctx);
|
||||||
@@ -876,24 +983,35 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
for (p = 0; p < 3; p++) {
|
for (p = 0; p < 3; p++) {
|
||||||
for (b = 0; b < ctx->planes[p].num_bands; b++) {
|
for (b = 0; b < ctx->planes[p].num_bands; b++) {
|
||||||
result = decode_band(ctx, &ctx->planes[p].bands[b], avctx);
|
result = decode_band(ctx, &ctx->planes[p].bands[b], avctx);
|
||||||
if (result) {
|
if (result < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Error while decoding band: %d, plane: %d\n", b, p);
|
"Error while decoding band: %d, plane: %d\n", b, p);
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx->buf_invalid[ctx->dst_buf] = 0;
|
ctx->buf_invalid[ctx->dst_buf] = 0;
|
||||||
|
} else {
|
||||||
|
if (ctx->is_scalable)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
for (p = 0; p < 3; p++) {
|
||||||
|
if (!ctx->planes[p].bands[0].buf)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ctx->buf_invalid[ctx->dst_buf])
|
if (ctx->buf_invalid[ctx->dst_buf])
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//STOP_TIMER("decode_planes"); }
|
//STOP_TIMER("decode_planes"); }
|
||||||
|
|
||||||
/* If the bidirectional mode is enabled, next I and the following P frame will */
|
/* If the bidirectional mode is enabled, next I and the following P
|
||||||
/* be sent together. Unfortunately the approach below seems to be the only way */
|
* frame will be sent together. Unfortunately the approach below seems
|
||||||
/* to handle the B-frames mode. That's exactly the same Intel decoders do. */
|
* to be the only way to handle the B-frames mode.
|
||||||
if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == 0/*FRAMETYPE_INTRA*/) {
|
* That's exactly the same Intel decoders do.
|
||||||
|
*/
|
||||||
|
if (avctx->codec_id == AV_CODEC_ID_INDEO4 &&
|
||||||
|
ctx->frame_type == 0/*FRAMETYPE_INTRA*/) {
|
||||||
while (get_bits(&ctx->gb, 8)); // skip version string
|
while (get_bits(&ctx->gb, 8)); // skip version string
|
||||||
skip_bits_long(&ctx->gb, 64); // skip padding, TODO: implement correct 8-bytes alignment
|
skip_bits_long(&ctx->gb, 64); // skip padding, TODO: implement correct 8-bytes alignment
|
||||||
if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
|
if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
|
||||||
|
@@ -160,9 +160,9 @@ typedef struct IVIBandDesc {
|
|||||||
int num_tiles; ///< number of tiles in this band
|
int num_tiles; ///< number of tiles in this band
|
||||||
IVITile *tiles; ///< array of tile descriptors
|
IVITile *tiles; ///< array of tile descriptors
|
||||||
InvTransformPtr *inv_transform;
|
InvTransformPtr *inv_transform;
|
||||||
|
int transform_size;
|
||||||
DCTransformPtr *dc_transform;
|
DCTransformPtr *dc_transform;
|
||||||
int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used
|
int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used
|
||||||
int transform_size; ///< block size of the transform
|
|
||||||
int32_t checksum; ///< for debug purposes
|
int32_t checksum; ///< for debug purposes
|
||||||
int checksum_present;
|
int checksum_present;
|
||||||
int bufsize; ///< band buffer size in bytes
|
int bufsize; ///< band buffer size in bytes
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "j2k.h"
|
#include "j2k.h"
|
||||||
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
|
|
||||||
#define JP2_SIG_TYPE 0x6A502020
|
#define JP2_SIG_TYPE 0x6A502020
|
||||||
@@ -302,6 +303,10 @@ static int get_cox(J2kDecoderContext *s, J2kCodingStyle *c)
|
|||||||
c->log2_cblk_width = bytestream2_get_byteu(&s->g) + 2; // cblk width
|
c->log2_cblk_width = bytestream2_get_byteu(&s->g) + 2; // cblk width
|
||||||
c->log2_cblk_height = bytestream2_get_byteu(&s->g) + 2; // cblk height
|
c->log2_cblk_height = bytestream2_get_byteu(&s->g) + 2; // cblk height
|
||||||
|
|
||||||
|
if (c->log2_cblk_width > 6 || c->log2_cblk_height > 6) {
|
||||||
|
return AVERROR_PATCHWELCOME;
|
||||||
|
}
|
||||||
|
|
||||||
c->cblk_style = bytestream2_get_byteu(&s->g);
|
c->cblk_style = bytestream2_get_byteu(&s->g);
|
||||||
if (c->cblk_style != 0){ // cblk style
|
if (c->cblk_style != 0){ // cblk style
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style);
|
av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style);
|
||||||
@@ -719,6 +724,9 @@ static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Contex
|
|||||||
int bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style;
|
int bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style;
|
||||||
int vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style;
|
int vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style;
|
||||||
|
|
||||||
|
av_assert0(width <= J2K_MAX_CBLKW);
|
||||||
|
av_assert0(height <= J2K_MAX_CBLKH);
|
||||||
|
|
||||||
for (y = 0; y < height+2; y++)
|
for (y = 0; y < height+2; y++)
|
||||||
memset(t1->flags[y], 0, (width+2)*sizeof(int));
|
memset(t1->flags[y], 0, (width+2)*sizeof(int));
|
||||||
|
|
||||||
|
@@ -70,13 +70,13 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s)
|
|||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "palette not supported\n");
|
av_log(s->avctx, AV_LOG_ERROR, "palette not supported\n");
|
||||||
return -1;
|
return AVERROR(ENOSYS);
|
||||||
case 4:
|
case 4:
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "oversize image not supported\n");
|
av_log(s->avctx, AV_LOG_ERROR, "oversize image not supported\n");
|
||||||
return -1;
|
return AVERROR(ENOSYS);
|
||||||
default:
|
default:
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
|
av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
av_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3);
|
av_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3);
|
||||||
|
|
||||||
@@ -142,6 +142,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI
|
|||||||
ret = ret >> 1;
|
ret = ret >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(FFABS(ret) > 0xFFFF)
|
||||||
|
return -0x10000;
|
||||||
/* update state */
|
/* update state */
|
||||||
state->A[Q] += FFABS(ret) - RItype;
|
state->A[Q] += FFABS(ret) - RItype;
|
||||||
ret *= state->twonear;
|
ret *= state->twonear;
|
||||||
@@ -262,7 +264,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor
|
|||||||
int i, t = 0;
|
int i, t = 0;
|
||||||
uint8_t *zero, *last, *cur;
|
uint8_t *zero, *last, *cur;
|
||||||
JLSState *state;
|
JLSState *state;
|
||||||
int off = 0, stride = 1, width, shift;
|
int off = 0, stride = 1, width, shift, ret = 0;
|
||||||
|
|
||||||
zero = av_mallocz(s->picture.linesize[0]);
|
zero = av_mallocz(s->picture.linesize[0]);
|
||||||
last = zero;
|
last = zero;
|
||||||
@@ -294,6 +296,10 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor
|
|||||||
ilv, point_transform, s->bits, s->cur_scan);
|
ilv, point_transform, s->bits, s->cur_scan);
|
||||||
}
|
}
|
||||||
if(ilv == 0) { /* separate planes */
|
if(ilv == 0) { /* separate planes */
|
||||||
|
if (s->cur_scan > s->nb_components) {
|
||||||
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
stride = (s->nb_components > 1) ? 3 : 1;
|
stride = (s->nb_components > 1) ? 3 : 1;
|
||||||
off = av_clip(s->cur_scan - 1, 0, stride - 1);
|
off = av_clip(s->cur_scan - 1, 0, stride - 1);
|
||||||
width = s->width * stride;
|
width = s->width * stride;
|
||||||
@@ -333,11 +339,10 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor
|
|||||||
last = cur;
|
last = cur;
|
||||||
cur += s->picture.linesize[0];
|
cur += s->picture.linesize[0];
|
||||||
}
|
}
|
||||||
} else if(ilv == 2) { /* sample interleaving */
|
} else if (ilv == 2) { /* sample interleaving */
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n");
|
av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n");
|
||||||
av_free(state);
|
ret = AVERROR_PATCHWELCOME;
|
||||||
av_free(zero);
|
goto end;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shift){ /* we need to do point transform or normalize samples */
|
if(shift){ /* we need to do point transform or normalize samples */
|
||||||
@@ -365,10 +370,12 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
av_free(state);
|
av_free(state);
|
||||||
av_free(zero);
|
av_free(zero);
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "bytestream.h"
|
#include "bytestream.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "libavutil/common.h"
|
||||||
|
|
||||||
#define KMVC_KEYFRAME 0x80
|
#define KMVC_KEYFRAME 0x80
|
||||||
#define KMVC_PALETTE 0x40
|
#define KMVC_PALETTE 0x40
|
||||||
@@ -47,7 +48,7 @@ typedef struct KmvcContext {
|
|||||||
int palsize;
|
int palsize;
|
||||||
uint32_t pal[MAX_PALSIZE];
|
uint32_t pal[MAX_PALSIZE];
|
||||||
uint8_t *cur, *prev;
|
uint8_t *cur, *prev;
|
||||||
uint8_t *frm0, *frm1;
|
uint8_t frm0[320 * 200], frm1[320 * 200];
|
||||||
GetByteContext g;
|
GetByteContext g;
|
||||||
} KmvcContext;
|
} KmvcContext;
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ typedef struct BitBuf {
|
|||||||
int bitbuf;
|
int bitbuf;
|
||||||
} BitBuf;
|
} BitBuf;
|
||||||
|
|
||||||
#define BLK(data, x, y) data[(x) + (y) * 320]
|
#define BLK(data, x, y) data[av_clip((x) + (y) * 320, 0, 320 * 200 -1)]
|
||||||
|
|
||||||
#define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
|
#define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, int w, int h)
|
|||||||
val = bytestream2_get_byte(&ctx->g);
|
val = bytestream2_get_byte(&ctx->g);
|
||||||
mx = val & 0xF;
|
mx = val & 0xF;
|
||||||
my = val >> 4;
|
my = val >> 4;
|
||||||
if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 316*196) {
|
if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 320*197 - 4) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, int w, int h)
|
|||||||
val = bytestream2_get_byte(&ctx->g);
|
val = bytestream2_get_byte(&ctx->g);
|
||||||
mx = val & 0xF;
|
mx = val & 0xF;
|
||||||
my = val >> 4;
|
my = val >> 4;
|
||||||
if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 318*198) {
|
if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 320*199 - 2) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -207,7 +208,7 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h)
|
|||||||
val = bytestream2_get_byte(&ctx->g);
|
val = bytestream2_get_byte(&ctx->g);
|
||||||
mx = (val & 0xF) - 8;
|
mx = (val & 0xF) - 8;
|
||||||
my = (val >> 4) - 8;
|
my = (val >> 4) - 8;
|
||||||
if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 318*198) {
|
if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 320*197 - 4) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -232,7 +233,7 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h)
|
|||||||
val = bytestream2_get_byte(&ctx->g);
|
val = bytestream2_get_byte(&ctx->g);
|
||||||
mx = (val & 0xF) - 8;
|
mx = (val & 0xF) - 8;
|
||||||
my = (val >> 4) - 8;
|
my = (val >> 4) - 8;
|
||||||
if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 318*198) {
|
if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 320*199 - 2) {
|
||||||
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -386,8 +387,6 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->frm0 = av_mallocz(320 * 200);
|
|
||||||
c->frm1 = av_mallocz(320 * 200);
|
|
||||||
c->cur = c->frm0;
|
c->cur = c->frm0;
|
||||||
c->prev = c->frm1;
|
c->prev = c->frm1;
|
||||||
|
|
||||||
@@ -423,30 +422,12 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Uninit kmvc decoder
|
|
||||||
*/
|
|
||||||
static av_cold int decode_end(AVCodecContext * avctx)
|
|
||||||
{
|
|
||||||
KmvcContext *const c = avctx->priv_data;
|
|
||||||
|
|
||||||
av_freep(&c->frm0);
|
|
||||||
av_freep(&c->frm1);
|
|
||||||
if (c->pic.data[0])
|
|
||||||
avctx->release_buffer(avctx, &c->pic);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodec ff_kmvc_decoder = {
|
AVCodec ff_kmvc_decoder = {
|
||||||
.name = "kmvc",
|
.name = "kmvc",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_KMVC,
|
.id = AV_CODEC_ID_KMVC,
|
||||||
.priv_data_size = sizeof(KmvcContext),
|
.priv_data_size = sizeof(KmvcContext),
|
||||||
.init = decode_init,
|
.init = decode_init,
|
||||||
.close = decode_end,
|
|
||||||
.decode = decode_frame,
|
.decode = decode_frame,
|
||||||
.capabilities = CODEC_CAP_DR1,
|
.capabilities = CODEC_CAP_DR1,
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"),
|
.long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"),
|
||||||
|
@@ -53,6 +53,7 @@ typedef struct LagarithContext {
|
|||||||
int zeros; /**< number of consecutive zero bytes encountered */
|
int zeros; /**< number of consecutive zero bytes encountered */
|
||||||
int zeros_rem; /**< number of zero bytes remaining to output */
|
int zeros_rem; /**< number of zero bytes remaining to output */
|
||||||
uint8_t *rgb_planes;
|
uint8_t *rgb_planes;
|
||||||
|
int rgb_planes_allocated;
|
||||||
int rgb_stride;
|
int rgb_stride;
|
||||||
} LagarithContext;
|
} LagarithContext;
|
||||||
|
|
||||||
@@ -567,13 +568,12 @@ static int lag_decode_frame(AVCodecContext *avctx,
|
|||||||
offs[1] = offset_gu;
|
offs[1] = offset_gu;
|
||||||
offs[2] = offset_ry;
|
offs[2] = offset_ry;
|
||||||
|
|
||||||
|
l->rgb_stride = FFALIGN(avctx->width, 16);
|
||||||
|
av_fast_malloc(&l->rgb_planes, &l->rgb_planes_allocated,
|
||||||
|
l->rgb_stride * avctx->height * planes + 1);
|
||||||
if (!l->rgb_planes) {
|
if (!l->rgb_planes) {
|
||||||
l->rgb_stride = FFALIGN(avctx->width, 16);
|
av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
|
||||||
l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * 4 + 16);
|
return AVERROR(ENOMEM);
|
||||||
if (!l->rgb_planes) {
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < planes; i++)
|
for (i = 0; i < planes; i++)
|
||||||
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
|
srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;
|
||||||
|
@@ -375,7 +375,7 @@ static const AVOption libopus_options[] = {
|
|||||||
{ "voip", "Favor improved speech intelligibility", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_VOIP }, 0, 0, FLAGS, "application" },
|
{ "voip", "Favor improved speech intelligibility", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_VOIP }, 0, 0, FLAGS, "application" },
|
||||||
{ "audio", "Favor faithfulness to the input", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_AUDIO }, 0, 0, FLAGS, "application" },
|
{ "audio", "Favor faithfulness to the input", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_AUDIO }, 0, 0, FLAGS, "application" },
|
||||||
{ "lowdelay", "Restrict to only the lowest delay modes", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_RESTRICTED_LOWDELAY }, 0, 0, FLAGS, "application" },
|
{ "lowdelay", "Restrict to only the lowest delay modes", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_RESTRICTED_LOWDELAY }, 0, 0, FLAGS, "application" },
|
||||||
{ "frame_duration", "Duration of a frame in milliseconds", OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 10.0 }, 2.5, 60.0, FLAGS },
|
{ "frame_duration", "Duration of a frame in milliseconds", OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 20.0 }, 2.5, 60.0, FLAGS },
|
||||||
{ "packet_loss", "Expected packet loss percentage", OFFSET(packet_loss), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, FLAGS },
|
{ "packet_loss", "Expected packet loss percentage", OFFSET(packet_loss), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, FLAGS },
|
||||||
{ "vbr", "Variable bit rate mode", OFFSET(vbr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 2, FLAGS, "vbr" },
|
{ "vbr", "Variable bit rate mode", OFFSET(vbr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 2, FLAGS, "vbr" },
|
||||||
{ "off", "Use constant bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "vbr" },
|
{ "off", "Use constant bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "vbr" },
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "bytestream.h"
|
||||||
#include "lzw.h"
|
#include "lzw.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ static const uint16_t mask[17] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct LZWState {
|
struct LZWState {
|
||||||
const uint8_t *pbuf, *ebuf;
|
GetByteContext gb;
|
||||||
int bbits;
|
int bbits;
|
||||||
unsigned int bbuf;
|
unsigned int bbuf;
|
||||||
|
|
||||||
@@ -73,9 +74,9 @@ static int lzw_get_code(struct LZWState * s)
|
|||||||
if(s->mode == FF_LZW_GIF) {
|
if(s->mode == FF_LZW_GIF) {
|
||||||
while (s->bbits < s->cursize) {
|
while (s->bbits < s->cursize) {
|
||||||
if (!s->bs) {
|
if (!s->bs) {
|
||||||
s->bs = *s->pbuf++;
|
s->bs = bytestream2_get_byte(&s->gb);
|
||||||
}
|
}
|
||||||
s->bbuf |= (*s->pbuf++) << s->bbits;
|
s->bbuf |= bytestream2_get_byte(&s->gb) << s->bbits;
|
||||||
s->bbits += 8;
|
s->bbits += 8;
|
||||||
s->bs--;
|
s->bs--;
|
||||||
}
|
}
|
||||||
@@ -83,7 +84,7 @@ static int lzw_get_code(struct LZWState * s)
|
|||||||
s->bbuf >>= s->cursize;
|
s->bbuf >>= s->cursize;
|
||||||
} else { // TIFF
|
} else { // TIFF
|
||||||
while (s->bbits < s->cursize) {
|
while (s->bbits < s->cursize) {
|
||||||
s->bbuf = (s->bbuf << 8) | (*s->pbuf++);
|
s->bbuf = (s->bbuf << 8) | bytestream2_get_byte(&s->gb);
|
||||||
s->bbits += 8;
|
s->bbits += 8;
|
||||||
}
|
}
|
||||||
c = s->bbuf >> (s->bbits - s->cursize);
|
c = s->bbuf >> (s->bbits - s->cursize);
|
||||||
@@ -97,17 +98,12 @@ void ff_lzw_decode_tail(LZWState *p)
|
|||||||
struct LZWState *s = (struct LZWState *)p;
|
struct LZWState *s = (struct LZWState *)p;
|
||||||
|
|
||||||
if(s->mode == FF_LZW_GIF) {
|
if(s->mode == FF_LZW_GIF) {
|
||||||
while (s->bs > 0) {
|
while (s->bs > 0 && bytestream2_get_bytes_left(&s->gb)) {
|
||||||
if (s->bs >= s->ebuf - s->pbuf) {
|
bytestream2_skip(&s->gb, s->bs);
|
||||||
s->pbuf = s->ebuf;
|
s->bs = bytestream2_get_byte(&s->gb);
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
s->pbuf += s->bs;
|
|
||||||
s->bs = *s->pbuf++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
s->pbuf= s->ebuf;
|
bytestream2_skip(&s->gb, bytestream2_get_bytes_left(&s->gb));
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold void ff_lzw_decode_open(LZWState **p)
|
av_cold void ff_lzw_decode_open(LZWState **p)
|
||||||
@@ -135,8 +131,7 @@ int ff_lzw_decode_init(LZWState *p, int csize, const uint8_t *buf, int buf_size,
|
|||||||
if(csize < 1 || csize >= LZW_MAXBITS)
|
if(csize < 1 || csize >= LZW_MAXBITS)
|
||||||
return -1;
|
return -1;
|
||||||
/* read buffer */
|
/* read buffer */
|
||||||
s->pbuf = buf;
|
bytestream2_init(&s->gb, buf, buf_size);
|
||||||
s->ebuf = s->pbuf + buf_size;
|
|
||||||
s->bbuf = 0;
|
s->bbuf = 0;
|
||||||
s->bbits = 0;
|
s->bbits = 0;
|
||||||
s->bs = 0;
|
s->bs = 0;
|
||||||
@@ -186,10 +181,6 @@ int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){
|
|||||||
if ((--l) == 0)
|
if ((--l) == 0)
|
||||||
goto the_end;
|
goto the_end;
|
||||||
}
|
}
|
||||||
if (s->ebuf < s->pbuf) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "lzw overread\n");
|
|
||||||
goto the_end;
|
|
||||||
}
|
|
||||||
c = lzw_get_code(s);
|
c = lzw_get_code(s);
|
||||||
if (c == s->end_code) {
|
if (c == s->end_code) {
|
||||||
break;
|
break;
|
||||||
|
@@ -229,8 +229,8 @@ static av_cold int mace_decode_init(AVCodecContext * avctx)
|
|||||||
{
|
{
|
||||||
MACEContext *ctx = avctx->priv_data;
|
MACEContext *ctx = avctx->priv_data;
|
||||||
|
|
||||||
if (avctx->channels > 2 || avctx->channels <= 0)
|
if (avctx->channels > 2 || avctx->channels < 1)
|
||||||
return -1;
|
return AVERROR(EINVAL);
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
|
avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&ctx->frame);
|
avcodec_get_frame_defaults(&ctx->frame);
|
||||||
|
@@ -254,7 +254,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
|||||||
return -1;
|
return -1;
|
||||||
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
|
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
|
||||||
if (nb_components != s->nb_components) {
|
if (nb_components != s->nb_components) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n");
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"nb_components changing in interlaced picture\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,15 +280,18 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
|
|||||||
s->h_max = h_count[i];
|
s->h_max = h_count[i];
|
||||||
if (v_count[i] > s->v_max)
|
if (v_count[i] > s->v_max)
|
||||||
s->v_max = v_count[i];
|
s->v_max = v_count[i];
|
||||||
if (!h_count[i] || !v_count[i]) {
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
s->quant_index[i] = get_bits(&s->gb, 8);
|
s->quant_index[i] = get_bits(&s->gb, 8);
|
||||||
if (s->quant_index[i] >= 4) {
|
if (s->quant_index[i] >= 4) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "quant_index is invalid\n");
|
av_log(s->avctx, AV_LOG_ERROR, "quant_index is invalid\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
if (!h_count[i] || !v_count[i]) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"Invalid sampling factor in component %d %d:%d\n",
|
||||||
|
i, h_count[i], v_count[i]);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
|
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
|
||||||
i, h_count[i], v_count[i],
|
i, h_count[i], v_count[i],
|
||||||
s->component_id[i], s->quant_index[i]);
|
s->component_id[i], s->quant_index[i]);
|
||||||
@@ -767,6 +771,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
|
|||||||
int resync_mb_y = 0;
|
int resync_mb_y = 0;
|
||||||
int resync_mb_x = 0;
|
int resync_mb_x = 0;
|
||||||
|
|
||||||
|
if (s->nb_components != 3 && s->nb_components != 4)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
|
||||||
s->restart_count = s->restart_interval;
|
s->restart_count = s->restart_interval;
|
||||||
|
|
||||||
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
|
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
|
||||||
@@ -845,17 +855,16 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|
static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|
||||||
int point_transform)
|
int point_transform, int nb_components)
|
||||||
{
|
{
|
||||||
int i, mb_x, mb_y;
|
int i, mb_x, mb_y;
|
||||||
const int nb_components=s->nb_components;
|
|
||||||
int bits= (s->bits+7)&~7;
|
int bits= (s->bits+7)&~7;
|
||||||
int resync_mb_y = 0;
|
int resync_mb_y = 0;
|
||||||
int resync_mb_x = 0;
|
int resync_mb_x = 0;
|
||||||
|
|
||||||
point_transform += bits - s->bits;
|
point_transform += bits - s->bits;
|
||||||
|
|
||||||
av_assert0(nb_components==1 || nb_components==3);
|
av_assert0(nb_components>=1 && nb_components<=3);
|
||||||
|
|
||||||
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
|
for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
|
||||||
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
|
||||||
@@ -1124,13 +1133,14 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
|
|||||||
int last_scan = 0;
|
int last_scan = 0;
|
||||||
int16_t *quant_matrix = s->quant_matrixes[s->quant_index[c]];
|
int16_t *quant_matrix = s->quant_matrixes[s->quant_index[c]];
|
||||||
|
|
||||||
if (se > 63) {
|
av_assert0(ss>=0 && Ah>=0 && Al>=0);
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
|
if (se < ss || se > 63) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "SS/SE %d/%d is invalid\n", ss, se);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Al) {
|
if (!Al) {
|
||||||
s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
|
s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
|
||||||
last_scan = !~s->coefs_finished[c];
|
last_scan = !~s->coefs_finished[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1287,7 +1297,9 @@ next_field:
|
|||||||
if ((ret = ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform)) < 0)
|
if ((ret = ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if ((ret = ljpeg_decode_yuv_scan(s, predictor, point_transform)) < 0)
|
if ((ret = ljpeg_decode_yuv_scan(s, predictor,
|
||||||
|
point_transform,
|
||||||
|
nb_components)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1584,8 +1596,6 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
|
|||||||
int t = 0, b = 0;
|
int t = 0, b = 0;
|
||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
|
|
||||||
s->cur_scan++;
|
|
||||||
|
|
||||||
/* find marker */
|
/* find marker */
|
||||||
while (src + t < buf_end) {
|
while (src + t < buf_end) {
|
||||||
uint8_t x = src[t++];
|
uint8_t x = src[t++];
|
||||||
@@ -1633,6 +1643,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
MJpegDecodeContext *s = avctx->priv_data;
|
MJpegDecodeContext *s = avctx->priv_data;
|
||||||
const uint8_t *buf_end, *buf_ptr;
|
const uint8_t *buf_end, *buf_ptr;
|
||||||
const uint8_t *unescaped_buf_ptr;
|
const uint8_t *unescaped_buf_ptr;
|
||||||
|
int hshift, vshift;
|
||||||
int unescaped_buf_size;
|
int unescaped_buf_size;
|
||||||
int start_code;
|
int start_code;
|
||||||
int i, index;
|
int i, index;
|
||||||
@@ -1648,16 +1659,21 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
&unescaped_buf_size);
|
&unescaped_buf_size);
|
||||||
/* EOF */
|
/* EOF */
|
||||||
if (start_code < 0) {
|
if (start_code < 0) {
|
||||||
goto the_end;
|
break;
|
||||||
} else if (unescaped_buf_size > (1U<<28)) {
|
} else if (unescaped_buf_size > INT_MAX / 8) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"MJPEG packet 0x%x too big (%d/%d), corrupt data?\n",
|
||||||
start_code, unescaped_buf_size, buf_size);
|
start_code, unescaped_buf_size, buf_size);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
|
av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
|
||||||
start_code, buf_end - buf_ptr);
|
start_code, buf_end - buf_ptr);
|
||||||
|
|
||||||
init_get_bits(&s->gb, unescaped_buf_ptr, unescaped_buf_size * 8);
|
ret = init_get_bits(&s->gb, unescaped_buf_ptr,
|
||||||
|
unescaped_buf_size * 8);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
s->start_code = start_code;
|
s->start_code = start_code;
|
||||||
if (s->avctx->debug & FF_DEBUG_STARTCODE)
|
if (s->avctx->debug & FF_DEBUG_STARTCODE)
|
||||||
@@ -1675,6 +1691,13 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
mjpeg_decode_com(s);
|
mjpeg_decode_com(s);
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
|
if (!CONFIG_JPEGLS_DECODER &&
|
||||||
|
(start_code == SOF48 || start_code == LSE)) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "JPEG-LS support not enabled.\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
|
||||||
switch (start_code) {
|
switch (start_code) {
|
||||||
case SOI:
|
case SOI:
|
||||||
s->restart_interval = 0;
|
s->restart_interval = 0;
|
||||||
@@ -1758,6 +1781,7 @@ eoi_parser:
|
|||||||
|
|
||||||
goto the_end;
|
goto the_end;
|
||||||
case SOS:
|
case SOS:
|
||||||
|
s->cur_scan++;
|
||||||
if ((ret = ff_mjpeg_decode_sos(s, NULL, NULL)) < 0 &&
|
if ((ret = ff_mjpeg_decode_sos(s, NULL, NULL)) < 0 &&
|
||||||
(avctx->err_recognition & AV_EF_EXPLODE))
|
(avctx->err_recognition & AV_EF_EXPLODE))
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -1787,7 +1811,7 @@ eoi_parser:
|
|||||||
(get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb));
|
(get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s->got_picture) {
|
if (s->got_picture && s->cur_scan) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
|
av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
|
||||||
goto eoi_parser;
|
goto eoi_parser;
|
||||||
}
|
}
|
||||||
@@ -1811,6 +1835,9 @@ the_end:
|
|||||||
}
|
}
|
||||||
if (s->upscale_v) {
|
if (s->upscale_v) {
|
||||||
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]];
|
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]];
|
||||||
|
int w;
|
||||||
|
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
|
||||||
|
w = s->width >> hshift;
|
||||||
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
|
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
|
||||||
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
|
avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
|
||||||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
|
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
|
||||||
@@ -1819,16 +1846,16 @@ the_end:
|
|||||||
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[i / 2 * s->linesize[s->upscale_v]];
|
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[i / 2 * s->linesize[s->upscale_v]];
|
||||||
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(i + 1) / 2 * s->linesize[s->upscale_v]];
|
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(i + 1) / 2 * s->linesize[s->upscale_v]];
|
||||||
if (src1 == src2) {
|
if (src1 == src2) {
|
||||||
memcpy(dst, src1, s->width);
|
memcpy(dst, src1, w);
|
||||||
} else {
|
} else {
|
||||||
for (index = 0; index < s->width; index++)
|
for (index = 0; index < w; index++)
|
||||||
dst[index] = (src1[index] + src2[index]) >> 1;
|
dst[index] = (src1[index] + src2[index]) >> 1;
|
||||||
}
|
}
|
||||||
dst -= s->linesize[s->upscale_v];
|
dst -= s->linesize[s->upscale_v];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
|
if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
|
||||||
int hshift, vshift, j;
|
int j;
|
||||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
|
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
|
||||||
for (index=0; index<4; index++) {
|
for (index=0; index<4; index++) {
|
||||||
uint8_t *dst = s->picture_ptr->data[index];
|
uint8_t *dst = s->picture_ptr->data[index];
|
||||||
|
@@ -404,10 +404,10 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
|
|||||||
uint8_t checksum;
|
uint8_t checksum;
|
||||||
uint8_t lossless_check;
|
uint8_t lossless_check;
|
||||||
int start_count = get_bits_count(gbp);
|
int start_count = get_bits_count(gbp);
|
||||||
const int max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP
|
int min_channel, max_channel, max_matrix_channel;
|
||||||
? MAX_MATRIX_CHANNEL_MLP
|
const int std_max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP
|
||||||
: MAX_MATRIX_CHANNEL_TRUEHD;
|
? MAX_MATRIX_CHANNEL_MLP
|
||||||
int max_channel, min_channel, matrix_channel;
|
: MAX_MATRIX_CHANNEL_TRUEHD;
|
||||||
|
|
||||||
sync_word = get_bits(gbp, 13);
|
sync_word = get_bits(gbp, 13);
|
||||||
|
|
||||||
@@ -426,18 +426,18 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
|
|||||||
|
|
||||||
skip_bits(gbp, 16); /* Output timestamp */
|
skip_bits(gbp, 16); /* Output timestamp */
|
||||||
|
|
||||||
min_channel = get_bits(gbp, 4);
|
min_channel = get_bits(gbp, 4);
|
||||||
max_channel = get_bits(gbp, 4);
|
max_channel = get_bits(gbp, 4);
|
||||||
matrix_channel = get_bits(gbp, 4);
|
max_matrix_channel = get_bits(gbp, 4);
|
||||||
|
|
||||||
if (matrix_channel > max_matrix_channel) {
|
if (max_matrix_channel > std_max_matrix_channel) {
|
||||||
av_log(m->avctx, AV_LOG_ERROR,
|
av_log(m->avctx, AV_LOG_ERROR,
|
||||||
"Max matrix channel cannot be greater than %d.\n",
|
"Max matrix channel cannot be greater than %d.\n",
|
||||||
max_matrix_channel);
|
std_max_matrix_channel);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_channel != matrix_channel) {
|
if (max_channel != max_matrix_channel) {
|
||||||
av_log(m->avctx, AV_LOG_ERROR,
|
av_log(m->avctx, AV_LOG_ERROR,
|
||||||
"Max channel must be equal max matrix channel.\n");
|
"Max channel must be equal max matrix channel.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@@ -458,13 +458,14 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->min_channel = min_channel;
|
|
||||||
s->max_channel = max_channel;
|
|
||||||
s->max_matrix_channel = matrix_channel;
|
|
||||||
|
|
||||||
if (m->avctx->request_channels > 0
|
s->min_channel = min_channel;
|
||||||
&& s->max_channel + 1 >= m->avctx->request_channels
|
s->max_channel = max_channel;
|
||||||
&& substr < m->max_decoded_substream) {
|
s->max_matrix_channel = max_matrix_channel;
|
||||||
|
|
||||||
|
if (m->avctx->request_channels > 0 &&
|
||||||
|
m->avctx->request_channels <= s->max_channel + 1 &&
|
||||||
|
m->max_decoded_substream > substr) {
|
||||||
av_log(m->avctx, AV_LOG_DEBUG,
|
av_log(m->avctx, AV_LOG_DEBUG,
|
||||||
"Extracting %d channel downmix from substream %d. "
|
"Extracting %d channel downmix from substream %d. "
|
||||||
"Further substreams will be skipped.\n",
|
"Further substreams will be skipped.\n",
|
||||||
|
@@ -104,6 +104,9 @@ static int mm_decode_intra(MmContext * s, int half_horiz, int half_vert)
|
|||||||
if (half_horiz)
|
if (half_horiz)
|
||||||
run_length *=2;
|
run_length *=2;
|
||||||
|
|
||||||
|
if (run_length > s->avctx->width - x)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
memset(s->frame.data[0] + y*s->frame.linesize[0] + x, color, run_length);
|
memset(s->frame.data[0] + y*s->frame.linesize[0] + x, color, run_length);
|
||||||
if (half_vert)
|
if (half_vert)
|
||||||
@@ -151,6 +154,8 @@ static int mm_decode_inter(MmContext * s, int half_horiz, int half_vert)
|
|||||||
int replace_array = bytestream2_get_byte(&s->gb);
|
int replace_array = bytestream2_get_byte(&s->gb);
|
||||||
for(j=0; j<8; j++) {
|
for(j=0; j<8; j++) {
|
||||||
int replace = (replace_array >> (7-j)) & 1;
|
int replace = (replace_array >> (7-j)) & 1;
|
||||||
|
if (x + half_horiz >= s->avctx->width)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if (replace) {
|
if (replace) {
|
||||||
int color = bytestream2_get_byte(&data_ptr);
|
int color = bytestream2_get_byte(&data_ptr);
|
||||||
s->frame.data[0][y*s->frame.linesize[0] + x] = color;
|
s->frame.data[0][y*s->frame.linesize[0] + x] = color;
|
||||||
|
@@ -165,6 +165,7 @@ static int mp_get_vlc(MotionPixelsContext *mp, GetBitContext *gb)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1);
|
i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1);
|
||||||
|
i = FFMIN(i, FF_ARRAY_ELEMS(mp->codes) - 1);
|
||||||
return mp->codes[i].delta;
|
return mp->codes[i].delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,6 +81,15 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
|
|||||||
return sign_extend(val, 5 + shift);
|
return sign_extend(val, 5 + shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define check_scantable_index(ctx, x) \
|
||||||
|
do { \
|
||||||
|
if ((x) > 63) { \
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", \
|
||||||
|
ctx->mb_x, ctx->mb_y); \
|
||||||
|
return AVERROR_INVALIDDATA; \
|
||||||
|
} \
|
||||||
|
} while (0) \
|
||||||
|
|
||||||
static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
||||||
{
|
{
|
||||||
int level, dc, diff, i, j, run;
|
int level, dc, diff, i, j, run;
|
||||||
@@ -112,6 +121,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
break;
|
break;
|
||||||
} else if (level != 0) {
|
} else if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||||
level = (level - 1) | 1;
|
level = (level - 1) | 1;
|
||||||
@@ -128,6 +138,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8);
|
level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8);
|
||||||
}
|
}
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = -level;
|
level = -level;
|
||||||
@@ -139,10 +150,6 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
level = (level - 1) | 1;
|
level = (level - 1) | 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i > 63) {
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
block[j] = level;
|
block[j] = level;
|
||||||
}
|
}
|
||||||
@@ -267,6 +274,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale) >> 1;
|
level = ((level * 2 + 1) * qscale) >> 1;
|
||||||
level = (level - 1) | 1;
|
level = (level - 1) | 1;
|
||||||
@@ -283,6 +291,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
|
|||||||
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
|
level = SHOW_UBITS(re, &s->gb, 8) ; SKIP_BITS(re, &s->gb, 8);
|
||||||
}
|
}
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = -level;
|
level = -level;
|
||||||
@@ -348,6 +357,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||||
@@ -359,6 +369,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
|||||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||||
|
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||||
@@ -367,10 +378,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block
|
|||||||
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i > 63) {
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mismatch ^= level;
|
mismatch ^= level;
|
||||||
block[j] = level;
|
block[j] = level;
|
||||||
@@ -422,6 +429,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|||||||
|
|
||||||
if (level != 0) {
|
if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = ((level * 2 + 1) * qscale) >> 1;
|
level = ((level * 2 + 1) * qscale) >> 1;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||||
@@ -433,6 +441,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
|
|||||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||||
|
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = ((-level * 2 + 1) * qscale) >> 1;
|
level = ((-level * 2 + 1) * qscale) >> 1;
|
||||||
@@ -499,6 +508,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
break;
|
break;
|
||||||
} else if (level != 0) {
|
} else if (level != 0) {
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||||
@@ -509,6 +519,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
UPDATE_CACHE(re, &s->gb);
|
UPDATE_CACHE(re, &s->gb);
|
||||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||||
i += run;
|
i += run;
|
||||||
|
check_scantable_index(s, i);
|
||||||
j = scantable[i];
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = (-level * qscale * quant_matrix[j]) >> 4;
|
level = (-level * qscale * quant_matrix[j]) >> 4;
|
||||||
@@ -517,10 +528,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i > 63) {
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
mismatch ^= level;
|
mismatch ^= level;
|
||||||
block[j] = level;
|
block[j] = level;
|
||||||
@@ -540,10 +547,10 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, in
|
|||||||
*/
|
*/
|
||||||
static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
|
||||||
{
|
{
|
||||||
int level, dc, diff, j, run;
|
int level, dc, diff, i, j, run;
|
||||||
int component;
|
int component;
|
||||||
RLTable *rl;
|
RLTable *rl;
|
||||||
uint8_t * scantable = s->intra_scantable.permutated;
|
uint8_t * const scantable = s->intra_scantable.permutated;
|
||||||
const uint16_t *quant_matrix;
|
const uint16_t *quant_matrix;
|
||||||
const int qscale = s->qscale;
|
const int qscale = s->qscale;
|
||||||
|
|
||||||
@@ -562,6 +569,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
|||||||
dc += diff;
|
dc += diff;
|
||||||
s->last_dc[component] = dc;
|
s->last_dc[component] = dc;
|
||||||
block[0] = dc << (3 - s->intra_dc_precision);
|
block[0] = dc << (3 - s->intra_dc_precision);
|
||||||
|
i = 0;
|
||||||
if (s->intra_vlc_format)
|
if (s->intra_vlc_format)
|
||||||
rl = &ff_rl_mpeg2;
|
rl = &ff_rl_mpeg2;
|
||||||
else
|
else
|
||||||
@@ -577,8 +585,9 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
|||||||
if (level == 127) {
|
if (level == 127) {
|
||||||
break;
|
break;
|
||||||
} else if (level != 0) {
|
} else if (level != 0) {
|
||||||
scantable += run;
|
i += run;
|
||||||
j = *scantable;
|
check_scantable_index(s, i);
|
||||||
|
j = scantable[i];
|
||||||
level = (level * qscale * quant_matrix[j]) >> 4;
|
level = (level * qscale * quant_matrix[j]) >> 4;
|
||||||
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
|
||||||
LAST_SKIP_BITS(re, &s->gb, 1);
|
LAST_SKIP_BITS(re, &s->gb, 1);
|
||||||
@@ -587,8 +596,9 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
|||||||
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
|
run = SHOW_UBITS(re, &s->gb, 6) + 1; LAST_SKIP_BITS(re, &s->gb, 6);
|
||||||
UPDATE_CACHE(re, &s->gb);
|
UPDATE_CACHE(re, &s->gb);
|
||||||
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
|
||||||
scantable += run;
|
i += run;
|
||||||
j = *scantable;
|
check_scantable_index(s, i);
|
||||||
|
j = scantable[i];
|
||||||
if (level < 0) {
|
if (level < 0) {
|
||||||
level = (-level * qscale * quant_matrix[j]) >> 4;
|
level = (-level * qscale * quant_matrix[j]) >> 4;
|
||||||
level = -level;
|
level = -level;
|
||||||
@@ -602,7 +612,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *bloc
|
|||||||
CLOSE_READER(re, &s->gb);
|
CLOSE_READER(re, &s->gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->block_last_index[n] = scantable - s->intra_scantable.permutated;
|
s->block_last_index[n] = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1266,7 +1276,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
|
|||||||
s1->save_width != s->width ||
|
s1->save_width != s->width ||
|
||||||
s1->save_height != s->height ||
|
s1->save_height != s->height ||
|
||||||
s1->save_aspect_info != s->aspect_ratio_info ||
|
s1->save_aspect_info != s->aspect_ratio_info ||
|
||||||
s1->save_progressive_seq != s->progressive_sequence ||
|
(s1->save_progressive_seq != s->progressive_sequence && (s->height&31)) ||
|
||||||
0)
|
0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -111,6 +111,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
|
|||||||
|
|
||||||
extern uint8_t ff_mpeg4_static_rl_table_store[3][2][2*MAX_RUN + MAX_LEVEL + 3];
|
extern uint8_t ff_mpeg4_static_rl_table_store[3][2][2*MAX_RUN + MAX_LEVEL + 3];
|
||||||
|
|
||||||
|
void ff_mpeg4_init_tables(void);
|
||||||
|
|
||||||
#if 0 //3IV1 is quite rare and it slows things down a tiny bit
|
#if 0 //3IV1 is quite rare and it slows things down a tiny bit
|
||||||
#define IS_3IV1 s->codec_tag == AV_RL32("3IV1")
|
#define IS_3IV1 s->codec_tag == AV_RL32("3IV1")
|
||||||
|
@@ -48,6 +48,33 @@ static const int mb_type_b_map[4]= {
|
|||||||
MB_TYPE_L0 | MB_TYPE_16x16,
|
MB_TYPE_L0 | MB_TYPE_16x16,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
av_cold void ff_mpeg4videodec_static_init(void)
|
||||||
|
{
|
||||||
|
static int done = 0;
|
||||||
|
|
||||||
|
if (!done) {
|
||||||
|
ff_init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
|
||||||
|
ff_init_rl(&ff_rvlc_rl_inter, ff_mpeg4_static_rl_table_store[1]);
|
||||||
|
ff_init_rl(&ff_rvlc_rl_intra, ff_mpeg4_static_rl_table_store[2]);
|
||||||
|
INIT_VLC_RL(ff_mpeg4_rl_intra, 554);
|
||||||
|
INIT_VLC_RL(ff_rvlc_rl_inter, 1072);
|
||||||
|
INIT_VLC_RL(ff_rvlc_rl_intra, 1072);
|
||||||
|
INIT_VLC_STATIC(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
|
||||||
|
&ff_mpeg4_DCtab_lum[0][1], 2, 1,
|
||||||
|
&ff_mpeg4_DCtab_lum[0][0], 2, 1, 512);
|
||||||
|
INIT_VLC_STATIC(&dc_chrom, DC_VLC_BITS, 10 /* 13 */,
|
||||||
|
&ff_mpeg4_DCtab_chrom[0][1], 2, 1,
|
||||||
|
&ff_mpeg4_DCtab_chrom[0][0], 2, 1, 512);
|
||||||
|
INIT_VLC_STATIC(&sprite_trajectory, SPRITE_TRAJ_VLC_BITS, 15,
|
||||||
|
&ff_sprite_trajectory_tab[0][1], 4, 2,
|
||||||
|
&ff_sprite_trajectory_tab[0][0], 4, 2, 128);
|
||||||
|
INIT_VLC_STATIC(&mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
|
||||||
|
&ff_mb_type_b_tab[0][1], 2, 1,
|
||||||
|
&ff_mb_type_b_tab[0][0], 2, 1, 16);
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Predict the ac.
|
* Predict the ac.
|
||||||
* @param n block index (0-3 are luma, 4-5 are chroma)
|
* @param n block index (0-3 are luma, 4-5 are chroma)
|
||||||
@@ -160,7 +187,7 @@ static inline int mpeg4_is_resync(MpegEncContext *s){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
|
static int mpeg4_decode_sprite_trajectory(MpegEncContext *s, GetBitContext *gb)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int a= 2<<s->sprite_warping_accuracy;
|
int a= 2<<s->sprite_warping_accuracy;
|
||||||
@@ -176,8 +203,8 @@ static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
|
|||||||
int h= s->height;
|
int h= s->height;
|
||||||
int min_ab;
|
int min_ab;
|
||||||
|
|
||||||
if(w<=0 || h<=0)
|
if (w <= 0 || h <= 0)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
for(i=0; i<s->num_sprite_warping_points; i++){
|
for(i=0; i<s->num_sprite_warping_points; i++){
|
||||||
int length;
|
int length;
|
||||||
@@ -415,8 +442,8 @@ int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
|
|||||||
skip_bits(&s->gb, 3); /* intra dc vlc threshold */
|
skip_bits(&s->gb, 3); /* intra dc vlc threshold */
|
||||||
//FIXME don't just ignore everything
|
//FIXME don't just ignore everything
|
||||||
if(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
|
if(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
|
||||||
if(mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
|
if (mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
|
av_log(s->avctx, AV_LOG_ERROR, "untested\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2081,8 +2108,8 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(s->pict_type == AV_PICTURE_TYPE_S && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
|
if(s->pict_type == AV_PICTURE_TYPE_S && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
|
||||||
if(mpeg4_decode_sprite_trajectory(s, gb) < 0)
|
if (mpeg4_decode_sprite_trajectory(s, gb) < 0)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
|
if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
|
||||||
if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
|
if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
|
||||||
}
|
}
|
||||||
@@ -2255,32 +2282,6 @@ end:
|
|||||||
return decode_vop_header(s, gb);
|
return decode_vop_header(s, gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_cold void ff_mpeg4videodec_static_init(void) {
|
|
||||||
static int done = 0;
|
|
||||||
|
|
||||||
if (!done) {
|
|
||||||
ff_init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
|
|
||||||
ff_init_rl(&ff_rvlc_rl_inter, ff_mpeg4_static_rl_table_store[1]);
|
|
||||||
ff_init_rl(&ff_rvlc_rl_intra, ff_mpeg4_static_rl_table_store[2]);
|
|
||||||
INIT_VLC_RL(ff_mpeg4_rl_intra, 554);
|
|
||||||
INIT_VLC_RL(ff_rvlc_rl_inter, 1072);
|
|
||||||
INIT_VLC_RL(ff_rvlc_rl_intra, 1072);
|
|
||||||
INIT_VLC_STATIC(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
|
|
||||||
&ff_mpeg4_DCtab_lum[0][1], 2, 1,
|
|
||||||
&ff_mpeg4_DCtab_lum[0][0], 2, 1, 512);
|
|
||||||
INIT_VLC_STATIC(&dc_chrom, DC_VLC_BITS, 10 /* 13 */,
|
|
||||||
&ff_mpeg4_DCtab_chrom[0][1], 2, 1,
|
|
||||||
&ff_mpeg4_DCtab_chrom[0][0], 2, 1, 512);
|
|
||||||
INIT_VLC_STATIC(&sprite_trajectory, SPRITE_TRAJ_VLC_BITS, 15,
|
|
||||||
&ff_sprite_trajectory_tab[0][1], 4, 2,
|
|
||||||
&ff_sprite_trajectory_tab[0][0], 4, 2, 128);
|
|
||||||
INIT_VLC_STATIC(&mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
|
|
||||||
&ff_mb_type_b_tab[0][1], 2, 1,
|
|
||||||
&ff_mb_type_b_tab[0][0], 2, 1, 16);
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_cold int decode_init(AVCodecContext *avctx)
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
MpegEncContext *s = avctx->priv_data;
|
MpegEncContext *s = avctx->priv_data;
|
||||||
|
@@ -1965,7 +1965,8 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);
|
avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);
|
||||||
|
|
||||||
if (ch + m->nb_channels > avctx->channels || s->coff[fr] + m->nb_channels > avctx->channels) {
|
if (ch + m->nb_channels > avctx->channels ||
|
||||||
|
s->coff[fr] + m->nb_channels > avctx->channels) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "
|
av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "
|
||||||
"channel count\n");
|
"channel count\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
@@ -128,9 +128,15 @@ const enum AVPixelFormat ff_pixfmt_list_420[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[] = {
|
const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[] = {
|
||||||
|
#if CONFIG_H264_DXVA2_HWACCEL
|
||||||
AV_PIX_FMT_DXVA2_VLD,
|
AV_PIX_FMT_DXVA2_VLD,
|
||||||
|
#endif
|
||||||
|
#if CONFIG_H264_VAAPI_HWACCEL
|
||||||
AV_PIX_FMT_VAAPI_VLD,
|
AV_PIX_FMT_VAAPI_VLD,
|
||||||
|
#endif
|
||||||
|
#if CONFIG_H264_VDA_HWACCEL
|
||||||
AV_PIX_FMT_VDA_VLD,
|
AV_PIX_FMT_VDA_VLD,
|
||||||
|
#endif
|
||||||
AV_PIX_FMT_YUV420P,
|
AV_PIX_FMT_YUV420P,
|
||||||
AV_PIX_FMT_NONE
|
AV_PIX_FMT_NONE
|
||||||
};
|
};
|
||||||
@@ -888,7 +894,9 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
|
|||||||
s->flags2 = s->avctx->flags2;
|
s->flags2 = s->avctx->flags2;
|
||||||
|
|
||||||
/* set chroma shifts */
|
/* set chroma shifts */
|
||||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
|
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,
|
||||||
|
&s->chroma_x_shift,
|
||||||
|
&s->chroma_y_shift);
|
||||||
|
|
||||||
/* convert fourcc to upper case */
|
/* convert fourcc to upper case */
|
||||||
s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
|
s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
|
||||||
@@ -1460,7 +1468,11 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
s->last_picture_ptr = &s->picture[i];
|
s->last_picture_ptr = &s->picture[i];
|
||||||
|
|
||||||
s->last_picture_ptr->f.key_frame = 0;
|
s->last_picture_ptr->f.key_frame = 0;
|
||||||
|
s->last_picture_ptr->f.reference = 3;
|
||||||
|
s->last_picture_ptr->f.pict_type = AV_PICTURE_TYPE_P;
|
||||||
|
|
||||||
if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) {
|
if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) {
|
||||||
s->last_picture_ptr = NULL;
|
s->last_picture_ptr = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1486,6 +1498,9 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
s->next_picture_ptr = &s->picture[i];
|
s->next_picture_ptr = &s->picture[i];
|
||||||
s->next_picture_ptr->f.key_frame = 0;
|
s->next_picture_ptr->f.key_frame = 0;
|
||||||
|
s->next_picture_ptr->f.reference = 3;
|
||||||
|
s->next_picture_ptr->f.pict_type = AV_PICTURE_TYPE_P;
|
||||||
|
|
||||||
if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
|
if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
|
||||||
s->next_picture_ptr = NULL;
|
s->next_picture_ptr = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -2135,7 +2150,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
|
|||||||
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
|
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
|
||||||
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
|
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
|
||||||
|
|
||||||
if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) ||
|
if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
|
||||||
(unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
|
(unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
|
||||||
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y,
|
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y,
|
||||||
linesize >> field_based, 17, 17 + field_based,
|
linesize >> field_based, 17, 17 + field_based,
|
||||||
@@ -2175,11 +2190,12 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
|
|||||||
pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
|
pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
|
||||||
|
|
||||||
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
|
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
|
||||||
|
int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h;
|
||||||
uvsx = (uvsx << 2) >> lowres;
|
uvsx = (uvsx << 2) >> lowres;
|
||||||
uvsy = (uvsy << 2) >> lowres;
|
uvsy = (uvsy << 2) >> lowres;
|
||||||
if (h >> s->chroma_y_shift) {
|
if (hc) {
|
||||||
pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
|
pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy);
|
||||||
pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
|
pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME h261 lowres loop filter
|
// FIXME h261 lowres loop filter
|
||||||
|
@@ -215,7 +215,8 @@ void mpeg_motion_internal(MpegEncContext *s,
|
|||||||
{
|
{
|
||||||
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
|
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
|
||||||
int dxy, uvdxy, mx, my, src_x, src_y,
|
int dxy, uvdxy, mx, my, src_x, src_y,
|
||||||
uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize;
|
uvsrc_x, uvsrc_y, v_edge_pos;
|
||||||
|
emuedge_linesize_type uvlinesize, linesize;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if(s->quarter_sample)
|
if(s->quarter_sample)
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
#include "msrledec.h"
|
#include "msrledec.h"
|
||||||
|
#include "libavutil/imgutils.h"
|
||||||
|
|
||||||
typedef struct MsrleContext {
|
typedef struct MsrleContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
@@ -112,7 +113,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
/* FIXME how to correctly detect RLE ??? */
|
/* FIXME how to correctly detect RLE ??? */
|
||||||
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
|
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
|
||||||
int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8;
|
int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
|
||||||
uint8_t *ptr = s->frame.data[0];
|
uint8_t *ptr = s->frame.data[0];
|
||||||
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
|
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@@ -58,7 +58,7 @@ enum MSV1Mode{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define SKIP_PREFIX 0x8400
|
#define SKIP_PREFIX 0x8400
|
||||||
#define SKIPS_MAX 0x0FFF
|
#define SKIPS_MAX 0x03FF
|
||||||
#define MKRGB555(in, off) ((in[off] << 10) | (in[off + 1] << 5) | (in[off + 2]))
|
#define MKRGB555(in, off) ((in[off] << 10) | (in[off + 1] << 5) | (in[off + 2]))
|
||||||
|
|
||||||
static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 };
|
static const int remap[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 };
|
||||||
|
@@ -88,7 +88,7 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c, const uint8_t *buf,
|
|||||||
int i;
|
int i;
|
||||||
if (size < 2 * 64 * 4) {
|
if (size < 2 * 64 * 4) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n");
|
av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 64; i++, buf += 4)
|
for (i = 0; i < 64; i++, buf += 4)
|
||||||
c->lq[i] = AV_RL32(buf);
|
c->lq[i] = AV_RL32(buf);
|
||||||
@@ -114,6 +114,8 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
|
|||||||
int quality)
|
int quality)
|
||||||
{
|
{
|
||||||
NuvContext *c = avctx->priv_data;
|
NuvContext *c = avctx->priv_data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
width = FFALIGN(width, 2);
|
width = FFALIGN(width, 2);
|
||||||
height = FFALIGN(height, 2);
|
height = FFALIGN(height, 2);
|
||||||
if (quality >= 0)
|
if (quality >= 0)
|
||||||
@@ -121,9 +123,10 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
|
|||||||
if (width != c->width || height != c->height) {
|
if (width != c->width || height != c->height) {
|
||||||
// also reserve space for a possible additional header
|
// also reserve space for a possible additional header
|
||||||
int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
|
int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
|
||||||
if (av_image_check_size(height, width, 0, avctx) < 0 ||
|
if (buf_size > INT_MAX/8)
|
||||||
buf_size > INT_MAX/8)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
if ((ret = av_image_check_size(height, width, 0, avctx)) < 0)
|
||||||
|
return ret;
|
||||||
avctx->width = c->width = width;
|
avctx->width = c->width = width;
|
||||||
avctx->height = c->height = height;
|
avctx->height = c->height = height;
|
||||||
av_fast_malloc(&c->decomp_buf, &c->decomp_size,
|
av_fast_malloc(&c->decomp_buf, &c->decomp_size,
|
||||||
@@ -154,6 +157,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
int keyframe;
|
int keyframe;
|
||||||
int size_change = 0;
|
int size_change = 0;
|
||||||
int result;
|
int result;
|
||||||
|
int ret;
|
||||||
enum {
|
enum {
|
||||||
NUV_UNCOMPRESSED = '0',
|
NUV_UNCOMPRESSED = '0',
|
||||||
NUV_RTJPEG = '1',
|
NUV_RTJPEG = '1',
|
||||||
@@ -165,7 +169,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
|
|
||||||
if (buf_size < 12) {
|
if (buf_size < 12) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
|
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// codec data (rtjpeg quant tables)
|
// codec data (rtjpeg quant tables)
|
||||||
@@ -184,7 +188,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
|
|
||||||
if (buf_size < 12 || buf[0] != 'V') {
|
if (buf_size < 12 || buf[0] != 'V') {
|
||||||
av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n");
|
av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
comptype = buf[1];
|
comptype = buf[1];
|
||||||
switch (comptype) {
|
switch (comptype) {
|
||||||
@@ -204,11 +208,14 @@ retry:
|
|||||||
buf = &buf[12];
|
buf = &buf[12];
|
||||||
buf_size -= 12;
|
buf_size -= 12;
|
||||||
if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
|
if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
|
||||||
int outlen = c->decomp_size - AV_LZO_OUTPUT_PADDING, inlen = buf_size;
|
int outlen = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING);
|
||||||
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen))
|
int inlen = buf_size;
|
||||||
|
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
|
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
buf = c->decomp_buf;
|
buf = c->decomp_buf;
|
||||||
buf_size = c->decomp_size - AV_LZO_OUTPUT_PADDING - outlen;
|
buf_size = c->decomp_size - FFMAX(FF_INPUT_BUFFER_PADDING_SIZE, AV_LZO_OUTPUT_PADDING) - outlen;
|
||||||
}
|
}
|
||||||
if (c->codec_frameheader) {
|
if (c->codec_frameheader) {
|
||||||
int w, h, q;
|
int w, h, q;
|
||||||
@@ -227,10 +234,9 @@ retry:
|
|||||||
w = AV_RL16(&buf[6]);
|
w = AV_RL16(&buf[6]);
|
||||||
h = AV_RL16(&buf[8]);
|
h = AV_RL16(&buf[8]);
|
||||||
q = buf[10];
|
q = buf[10];
|
||||||
res = codec_reinit(avctx, w, h, q);
|
if ((result = codec_reinit(avctx, w, h, q)) < 0)
|
||||||
if (res < 0)
|
return result;
|
||||||
return res;
|
if (result) {
|
||||||
if (res) {
|
|
||||||
buf = avpkt->data;
|
buf = avpkt->data;
|
||||||
buf_size = avpkt->size;
|
buf_size = avpkt->size;
|
||||||
size_change = 1;
|
size_change = 1;
|
||||||
@@ -248,7 +254,7 @@ retry:
|
|||||||
result = avctx->reget_buffer(avctx, &c->pic);
|
result = avctx->reget_buffer(avctx, &c->pic);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
|
||||||
@@ -268,7 +274,9 @@ retry:
|
|||||||
}
|
}
|
||||||
case NUV_RTJPEG_IN_LZO:
|
case NUV_RTJPEG_IN_LZO:
|
||||||
case NUV_RTJPEG:
|
case NUV_RTJPEG:
|
||||||
ff_rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
|
ret = ff_rtjpeg_decode_frame_yuv420(&c->rtj, &c->pic, buf, buf_size);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
break;
|
break;
|
||||||
case NUV_BLACK:
|
case NUV_BLACK:
|
||||||
memset(c->pic.data[0], 0, c->width * c->height);
|
memset(c->pic.data[0], 0, c->width * c->height);
|
||||||
@@ -280,7 +288,7 @@ retry:
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
|
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
*picture = c->pic;
|
*picture = c->pic;
|
||||||
@@ -291,6 +299,8 @@ retry:
|
|||||||
static av_cold int decode_init(AVCodecContext *avctx)
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
NuvContext *c = avctx->priv_data;
|
NuvContext *c = avctx->priv_data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
|
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||||
c->pic.data[0] = NULL;
|
c->pic.data[0] = NULL;
|
||||||
c->decomp_buf = NULL;
|
c->decomp_buf = NULL;
|
||||||
@@ -305,8 +315,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
ff_dsputil_init(&c->dsp, avctx);
|
ff_dsputil_init(&c->dsp, avctx);
|
||||||
|
|
||||||
if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
|
if ((ret = codec_reinit(avctx, avctx->width, avctx->height, -1)) < 0)
|
||||||
return 1;
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -235,8 +235,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
|
|||||||
if(next == END_NOT_FOUND){
|
if(next == END_NOT_FOUND){
|
||||||
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
if(!new_buffer)
|
if(!new_buffer) {
|
||||||
|
pc->index = 0;
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
pc->buffer = new_buffer;
|
pc->buffer = new_buffer;
|
||||||
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
|
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
|
||||||
pc->index += *buf_size;
|
pc->index += *buf_size;
|
||||||
@@ -249,9 +251,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
|
|||||||
/* append to buffer */
|
/* append to buffer */
|
||||||
if(pc->index){
|
if(pc->index){
|
||||||
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
if(!new_buffer) {
|
||||||
if(!new_buffer)
|
pc->overread_index =
|
||||||
|
pc->index = 0;
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
pc->buffer = new_buffer;
|
pc->buffer = new_buffer;
|
||||||
if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
|
if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
|
||||||
memcpy(&pc->buffer[pc->index], *buf,
|
memcpy(&pc->buffer[pc->index], *buf,
|
||||||
|
@@ -311,7 +311,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
/* av_get_bits_per_sample returns 0 for AV_CODEC_ID_PCM_DVD */
|
/* av_get_bits_per_sample returns 0 for AV_CODEC_ID_PCM_DVD */
|
||||||
samples_per_block = 1;
|
samples_per_block = 1;
|
||||||
if (AV_CODEC_ID_PCM_DVD == avctx->codec_id) {
|
if (avctx->codec->id == AV_CODEC_ID_PCM_DVD) {
|
||||||
if (avctx->bits_per_coded_sample != 20 &&
|
if (avctx->bits_per_coded_sample != 20 &&
|
||||||
avctx->bits_per_coded_sample != 24) {
|
avctx->bits_per_coded_sample != 24) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user