Compare commits
562 Commits
n2.4.9
...
release/2.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a9a5f5b388 | ||
![]() |
00c016a5f7 | ||
![]() |
65f4425ad5 | ||
![]() |
d9593e0751 | ||
![]() |
fde9b80c17 | ||
![]() |
32ba667dc7 | ||
![]() |
2061298438 | ||
![]() |
50ac23fd7f | ||
![]() |
01fa1dc229 | ||
![]() |
f3dfb14f6c | ||
![]() |
b0d9042f9d | ||
![]() |
c83569e5f1 | ||
![]() |
52fa2a2f60 | ||
![]() |
ada778c700 | ||
![]() |
e0537e49a4 | ||
![]() |
a444857db3 | ||
![]() |
c77d226f71 | ||
![]() |
819889e737 | ||
![]() |
68f89b8264 | ||
![]() |
e7cb5d41d1 | ||
![]() |
84981c8a87 | ||
![]() |
ac323fa463 | ||
![]() |
0397e998b3 | ||
![]() |
60201e27ef | ||
![]() |
be7dc34bcf | ||
![]() |
fb5f3241e4 | ||
![]() |
3144044e01 | ||
![]() |
89b83042a9 | ||
![]() |
bb95df33a0 | ||
![]() |
3339bae219 | ||
![]() |
0b5405c443 | ||
![]() |
74e714f815 | ||
![]() |
d18f8959b3 | ||
![]() |
455bc87c8f | ||
![]() |
bfd65092a2 | ||
![]() |
307c5cb9d4 | ||
![]() |
49ff079f0c | ||
![]() |
1317854136 | ||
![]() |
11752d17b8 | ||
![]() |
12e005f7e7 | ||
![]() |
38c8264d19 | ||
![]() |
a43f9e6895 | ||
![]() |
ba7ccddb82 | ||
![]() |
dcf23f1297 | ||
![]() |
44d447f31c | ||
![]() |
99a6924983 | ||
![]() |
09a5a754fe | ||
![]() |
5628a54062 | ||
![]() |
e4f32ef806 | ||
![]() |
5da5e47a17 | ||
![]() |
5922e5a84e | ||
![]() |
f000df4ce2 | ||
![]() |
88f2d31d4e | ||
![]() |
eface550b9 | ||
![]() |
2aa21e8d95 | ||
![]() |
95d9260177 | ||
![]() |
560b389538 | ||
![]() |
436f530a51 | ||
![]() |
0b25a4d253 | ||
![]() |
41dffa883a | ||
![]() |
fa5ec2c354 | ||
![]() |
907d7d972a | ||
![]() |
9a52cbdb00 | ||
![]() |
61d5ec7c32 | ||
![]() |
3f5a283174 | ||
![]() |
66a1ed96bf | ||
![]() |
0b84dbeca9 | ||
![]() |
803db3b6fe | ||
![]() |
6e43bb2dc2 | ||
![]() |
3f30c49f7e | ||
![]() |
dc2d15360c | ||
![]() |
86c024ea9e | ||
![]() |
0b0a8cd133 | ||
![]() |
dfc3cd73ff | ||
![]() |
8a9d5a8140 | ||
![]() |
81196b6d60 | ||
![]() |
cd74b344c2 | ||
![]() |
b49f8de4ec | ||
![]() |
11141fb9ff | ||
![]() |
c417b7b566 | ||
![]() |
41ca0489ba | ||
![]() |
232b1f83de | ||
![]() |
7afb16c9a1 | ||
![]() |
a79e5c994c | ||
![]() |
1a8f9f0e58 | ||
![]() |
91ced1608c | ||
![]() |
d0da72ebb0 | ||
![]() |
b62a3478e9 | ||
![]() |
d005972995 | ||
![]() |
94ebfef2fb | ||
![]() |
f8b6ba5574 | ||
![]() |
3b17f32ec3 | ||
![]() |
1480d9b3d3 | ||
![]() |
1aea2213a6 | ||
![]() |
6ab48096f5 | ||
![]() |
6c67cc2ad1 | ||
![]() |
cab9306040 | ||
![]() |
01e2e746ba | ||
![]() |
17ecc8a771 | ||
![]() |
07a55344e6 | ||
![]() |
813054c4bd | ||
![]() |
b844584c10 | ||
![]() |
a6ba4c1116 | ||
![]() |
af0544ca3d | ||
![]() |
55b75ece70 | ||
![]() |
28f303542e | ||
![]() |
6e7f183ae6 | ||
![]() |
37723e0d0c | ||
![]() |
5feffd6268 | ||
![]() |
6862970dbf | ||
![]() |
633ce6baaa | ||
![]() |
201d626bb9 | ||
![]() |
364bdddaad | ||
![]() |
e651a2f88c | ||
![]() |
7c54f14168 | ||
![]() |
d00e2fa284 | ||
![]() |
9d156e24d7 | ||
![]() |
ccca7ae8c6 | ||
![]() |
5a98a00001 | ||
![]() |
f04b323a46 | ||
![]() |
e4fddd18e7 | ||
![]() |
36ac584548 | ||
![]() |
fa0194e9ca | ||
![]() |
83700aced1 | ||
![]() |
ac1905cd5b | ||
![]() |
13d4d8a9c6 | ||
![]() |
71d0cfff15 | ||
![]() |
6832b1fde7 | ||
![]() |
0bdbf1aba3 | ||
![]() |
19475c0d74 | ||
![]() |
bfdf15943d | ||
![]() |
fbc998ce3f | ||
![]() |
41802887eb | ||
![]() |
c27539cd1e | ||
![]() |
67e2394cc6 | ||
![]() |
a736171b69 | ||
![]() |
823a9177a3 | ||
![]() |
01c83f4cb1 | ||
![]() |
d3853ad11f | ||
![]() |
b188ff5e18 | ||
![]() |
7bd8ea83a0 | ||
![]() |
84bc2cea23 | ||
![]() |
9dc6a7f13a | ||
![]() |
35819400e7 | ||
![]() |
ac499d8142 | ||
![]() |
9354c47d2e | ||
![]() |
07a37001a3 | ||
![]() |
ba99e90357 | ||
![]() |
96981b092c | ||
![]() |
b4c4f9dba6 | ||
![]() |
df1ea139b4 | ||
![]() |
844f7f78aa | ||
![]() |
059762d9da | ||
![]() |
68b6a5efbf | ||
![]() |
56c5e009a1 | ||
![]() |
80ba4b5d45 | ||
![]() |
8240fa5701 | ||
![]() |
bf5df31b4f | ||
![]() |
ea1d0bc029 | ||
![]() |
27172a5ca3 | ||
![]() |
e4f0f854c4 | ||
![]() |
35cfb99c15 | ||
![]() |
6212758c07 | ||
![]() |
ef8fbb4878 | ||
![]() |
431d66b1d5 | ||
![]() |
126ee72e47 | ||
![]() |
b4ce4f94e7 | ||
![]() |
51c32a535b | ||
![]() |
c4034e4e19 | ||
![]() |
d3e19509cf | ||
![]() |
58e673b9a3 | ||
![]() |
de259f32ac | ||
![]() |
1987afe5a0 | ||
![]() |
4352a971af | ||
![]() |
bc0a6add0a | ||
![]() |
3467dfed6b | ||
![]() |
ffd5ccee5d | ||
![]() |
a4b6d5574f | ||
![]() |
a2619a0a36 | ||
![]() |
8c5c45b9e1 | ||
![]() |
dc2f4b7267 | ||
![]() |
824f29e4fb | ||
![]() |
917946e1c9 | ||
![]() |
95fa91d975 | ||
![]() |
a90ed80d05 | ||
![]() |
3fd2ff1b4f | ||
![]() |
11313263ab | ||
![]() |
f335275c50 | ||
![]() |
ea61dfe0ab | ||
![]() |
21808e2181 | ||
![]() |
bf2605c356 | ||
![]() |
c10c71452f | ||
![]() |
05d7e92e4f | ||
![]() |
96357894ff | ||
![]() |
4841b2759f | ||
![]() |
5d852f338d | ||
![]() |
ceb9d67a0a | ||
![]() |
ce9d497755 | ||
![]() |
b5298c464f | ||
![]() |
9ec550c364 | ||
![]() |
23a22b0da9 | ||
![]() |
d61a325a68 | ||
![]() |
c658f6c34d | ||
![]() |
8dd6075a7f | ||
![]() |
9c61b44941 | ||
![]() |
dc319a52f9 | ||
![]() |
77367f2728 | ||
![]() |
34ef754854 | ||
![]() |
84487650e2 | ||
![]() |
5ecc4a644a | ||
![]() |
36ec1c2c55 | ||
![]() |
5e4a821b8a | ||
![]() |
5bd45a1b27 | ||
![]() |
cd190f0c3f | ||
![]() |
31f5d5f690 | ||
![]() |
7644b29222 | ||
![]() |
f7086be79a | ||
![]() |
72f0d13802 | ||
![]() |
255ebf3aff | ||
![]() |
cb10e05ff0 | ||
![]() |
17f30ab6a1 | ||
![]() |
8c8950f982 | ||
![]() |
0f8863df86 | ||
![]() |
cb8f645faf | ||
![]() |
6ab793c2b9 | ||
![]() |
80b6632b36 | ||
![]() |
656bf0ca79 | ||
![]() |
407982b8f9 | ||
![]() |
92096acc0a | ||
![]() |
e1ed566c1c | ||
![]() |
c9da441eb4 | ||
![]() |
f405267493 | ||
![]() |
f7ed48938a | ||
![]() |
150ae7692e | ||
![]() |
7d69132775 | ||
![]() |
72149fcb1b | ||
![]() |
ded44bda27 | ||
![]() |
384be84bbe | ||
![]() |
f99675627d | ||
![]() |
d5eca1651f | ||
![]() |
712b8e7128 | ||
![]() |
2d0b2db27e | ||
![]() |
fc82ba06ee | ||
![]() |
64908f70e4 | ||
![]() |
6f6b1d0ddb | ||
![]() |
aa09543659 | ||
![]() |
eb1e5cf818 | ||
![]() |
b7638af942 | ||
![]() |
0bb71a85c3 | ||
![]() |
5302fa522b | ||
![]() |
27375c25d9 | ||
![]() |
ab6dd7fea9 | ||
![]() |
969d8b9d60 | ||
![]() |
31b1589097 | ||
![]() |
97ccf31ece | ||
![]() |
0f09436a43 | ||
![]() |
e7873dfcca | ||
![]() |
9790ed63fc | ||
![]() |
0e3a1d60d3 | ||
![]() |
a45a665991 | ||
![]() |
c2c922460a | ||
![]() |
d192ff0ece | ||
![]() |
4d1346d46a | ||
![]() |
66a9c50d42 | ||
![]() |
3065919b65 | ||
![]() |
f1feb7e388 | ||
![]() |
ccbcb17960 | ||
![]() |
a71b4209c2 | ||
![]() |
60ed439334 | ||
![]() |
76838fb171 | ||
![]() |
e3b6e23a0f | ||
![]() |
6a51bd7360 | ||
![]() |
2572372f90 | ||
![]() |
2a543e58ec | ||
![]() |
aaf6ddfa4d | ||
![]() |
2b45eab4c9 | ||
![]() |
d89e5b20f2 | ||
![]() |
ac182d6d8b | ||
![]() |
9cde200ba7 | ||
![]() |
df208d6ab9 | ||
![]() |
4eb0b6c590 | ||
![]() |
90a384cde1 | ||
![]() |
af109ff125 | ||
![]() |
ec2ce83913 | ||
![]() |
1d91251370 | ||
![]() |
861e453996 | ||
![]() |
5228655438 | ||
![]() |
d2e3afbbd1 | ||
![]() |
c33770e74b | ||
![]() |
9c358c6e3b | ||
![]() |
26d72b3df0 | ||
![]() |
6729193886 | ||
![]() |
9d8e231459 | ||
![]() |
15871a90aa | ||
![]() |
37f854f5b9 | ||
![]() |
9c83914a1f | ||
![]() |
861732246f | ||
![]() |
46b64d9818 | ||
![]() |
c5085a0301 | ||
![]() |
4c9c76af85 | ||
![]() |
e4f9a5efa1 | ||
![]() |
61e5001b26 | ||
![]() |
380587cc34 | ||
![]() |
998b5ac3a0 | ||
![]() |
b8f6069bf3 | ||
![]() |
2b5b21dbac | ||
![]() |
4201c74545 | ||
![]() |
946810d1da | ||
![]() |
f3802aa325 | ||
![]() |
c5606c04cf | ||
![]() |
39256e54d1 | ||
![]() |
992cdbc56a | ||
![]() |
e8bb67c2a9 | ||
![]() |
60e2f9bf8b | ||
![]() |
bdba204bd0 | ||
![]() |
be4d4a61b5 | ||
![]() |
83f58778cb | ||
![]() |
c5a2c26c55 | ||
![]() |
03c5ccb4ee | ||
![]() |
172a5cab87 | ||
![]() |
8d6de87709 | ||
![]() |
af04f0d1ce | ||
![]() |
116b959565 | ||
![]() |
7269ab10c5 | ||
![]() |
caeed48982 | ||
![]() |
353f79defc | ||
![]() |
92d336670f | ||
![]() |
3c880d2765 | ||
![]() |
63dcf7c77c | ||
![]() |
610a064607 | ||
![]() |
65c915d0c3 | ||
![]() |
8c8db86c0d | ||
![]() |
44799d269f | ||
![]() |
3c8a12be2f | ||
![]() |
0c5f166e6f | ||
![]() |
5a45c644e8 | ||
![]() |
02d46127f5 | ||
![]() |
2e99fab15c | ||
![]() |
9098da0329 | ||
![]() |
db53b2b2c0 | ||
![]() |
c7a854af19 | ||
![]() |
3e73bea05f | ||
![]() |
3712b398e9 | ||
![]() |
4362a222e2 | ||
![]() |
a9753049b5 | ||
![]() |
910fd77967 | ||
![]() |
d87ac93bca | ||
![]() |
96603d5753 | ||
![]() |
c7c724056e | ||
![]() |
d3139c9733 | ||
![]() |
0909b8acf8 | ||
![]() |
2368d08e70 | ||
![]() |
ea7ccf3748 | ||
![]() |
846a9c67ff | ||
![]() |
c8d363a359 | ||
![]() |
d0d441b350 | ||
![]() |
6341a7006d | ||
![]() |
7034e808f6 | ||
![]() |
ce5d9a2b4b | ||
![]() |
aa672f5e6a | ||
![]() |
b959e6393e | ||
![]() |
69f99f80d1 | ||
![]() |
e7b7e69416 | ||
![]() |
9330bcff9b | ||
![]() |
9fb364babd | ||
![]() |
d79419d0f9 | ||
![]() |
ebc490e744 | ||
![]() |
ab1c7113f9 | ||
![]() |
10a30e4de5 | ||
![]() |
9368b91834 | ||
![]() |
f22e88c177 | ||
![]() |
e266fcf083 | ||
![]() |
c9b961748f | ||
![]() |
a94f367424 | ||
![]() |
18eac12c6d | ||
![]() |
4cc18ee5da | ||
![]() |
f8985cb9d9 | ||
![]() |
656770e2aa | ||
![]() |
4a28a3ddc4 | ||
![]() |
f91ef98c9d | ||
![]() |
a644272a4a | ||
![]() |
325feb8e0d | ||
![]() |
8c6a976fee | ||
![]() |
ac38860ec9 | ||
![]() |
d0e0329e9d | ||
![]() |
9ca79d2849 | ||
![]() |
c5a2a65e1e | ||
![]() |
a8ed3685e1 | ||
![]() |
32262ca7d7 | ||
![]() |
5f56e495ae | ||
![]() |
fedbba5ea0 | ||
![]() |
d35916f6ea | ||
![]() |
94e2673f4e | ||
![]() |
23ae7bfb4e | ||
![]() |
9e8464e81b | ||
![]() |
c9a8dfa5ae | ||
![]() |
e6299a4cf9 | ||
![]() |
ee3822af63 | ||
![]() |
fc5261c219 | ||
![]() |
30a94f1159 | ||
![]() |
9d83cff1f1 | ||
![]() |
756cd1a305 | ||
![]() |
83dc8f044d | ||
![]() |
2c5c6affb1 | ||
![]() |
f4e051680e | ||
![]() |
2f4b781e4d | ||
![]() |
0d45e821dc | ||
![]() |
eda6effcab | ||
![]() |
45900618ae | ||
![]() |
16e49d85b6 | ||
![]() |
bfdfeadf11 | ||
![]() |
7ae6229b97 | ||
![]() |
2156d9bd7d | ||
![]() |
0a055cc62e | ||
![]() |
c8d43c22db | ||
![]() |
d9b7557732 | ||
![]() |
15d7b7d7cc | ||
![]() |
29353dd3f8 | ||
![]() |
b336daa952 | ||
![]() |
a0aa5c34a9 | ||
![]() |
d63476347a | ||
![]() |
39545c5482 | ||
![]() |
e43805d401 | ||
![]() |
ea21b7b68c | ||
![]() |
738a2a04b6 | ||
![]() |
706dca18d0 | ||
![]() |
b3c3dc54a5 | ||
![]() |
b6af89be6a | ||
![]() |
57824d1ba6 | ||
![]() |
cd753ee36b | ||
![]() |
aaaafc300d | ||
![]() |
6da213ce20 | ||
![]() |
763a808c96 | ||
![]() |
4f3b0afaa2 | ||
![]() |
050d8d727a | ||
![]() |
6fb0f37def | ||
![]() |
70028e917c | ||
![]() |
6ce835d77f | ||
![]() |
d45a724192 | ||
![]() |
a48440d857 | ||
![]() |
de14fe7e29 | ||
![]() |
580d3ef6fe | ||
![]() |
2864c987d8 | ||
![]() |
d1a9195863 | ||
![]() |
898ab02557 | ||
![]() |
69aa3d5b88 | ||
![]() |
dcecca0758 | ||
![]() |
413065aff4 | ||
![]() |
c094aec76e | ||
![]() |
5e21989de4 | ||
![]() |
908b951b4e | ||
![]() |
4b0cecb457 | ||
![]() |
3dae9d13e5 | ||
![]() |
9189a0a71b | ||
![]() |
4b25b5a8a3 | ||
![]() |
4c3cd88144 | ||
![]() |
4d70639d53 | ||
![]() |
a6ba0f7be9 | ||
![]() |
89205b637e | ||
![]() |
88058b4650 | ||
![]() |
ca22a2dec5 | ||
![]() |
d058583510 | ||
![]() |
e0c3c612eb | ||
![]() |
4d4a10cfa1 | ||
![]() |
ce675bd54a | ||
![]() |
965eb42be0 | ||
![]() |
d2578f8152 | ||
![]() |
31c52cd442 | ||
![]() |
fa220e7307 | ||
![]() |
304260a572 | ||
![]() |
ed621efb36 | ||
![]() |
9f864bd324 | ||
![]() |
117728cf8f | ||
![]() |
caf7db0c35 | ||
![]() |
09965ae7d8 | ||
![]() |
f448478a31 | ||
![]() |
82ec6183bc | ||
![]() |
345e2a2b43 | ||
![]() |
7442aa20fa | ||
![]() |
9918296a2d | ||
![]() |
4d373ee8e4 | ||
![]() |
6133f450bb | ||
![]() |
8a9f4f8800 | ||
![]() |
9ebe344166 | ||
![]() |
badb8e15ac | ||
![]() |
48c192c48c | ||
![]() |
dbb4ff6851 | ||
![]() |
8c53cacbfd | ||
![]() |
dcb91e3dfe | ||
![]() |
bfe4aa892a | ||
![]() |
1dcf9de6e9 | ||
![]() |
2fe67ddb24 | ||
![]() |
b7cb77a322 | ||
![]() |
2d7f20d2bb | ||
![]() |
3976c50fc1 | ||
![]() |
572ccbd299 | ||
![]() |
dcf0f82d08 | ||
![]() |
061e948153 | ||
![]() |
08808084f6 | ||
![]() |
e779595dca | ||
![]() |
cf6cf50ac6 | ||
![]() |
1ecd1b4aee | ||
![]() |
04a4c4144a | ||
![]() |
73aa4518ee | ||
![]() |
aee36a7d16 | ||
![]() |
d86930b8ff | ||
![]() |
95b5496dce | ||
![]() |
3ffd1c2e40 | ||
![]() |
2d16a88a9c | ||
![]() |
edc6f3da0e | ||
![]() |
8763aca389 | ||
![]() |
b962157ce3 | ||
![]() |
8c79730a8e | ||
![]() |
b432043d55 | ||
![]() |
94c3f8165c | ||
![]() |
f27895db0f | ||
![]() |
c3f9628407 | ||
![]() |
7eec11463f | ||
![]() |
0d32483a11 | ||
![]() |
85ea846580 | ||
![]() |
5b52b4962e | ||
![]() |
69a283e0d2 | ||
![]() |
624b83b3ef | ||
![]() |
e8304f4ee0 | ||
![]() |
cbcc18bd9f | ||
![]() |
c765b64641 | ||
![]() |
1141a18e89 | ||
![]() |
12c2d2ed46 | ||
![]() |
88e368d5a7 | ||
![]() |
ad19cb3ca7 | ||
![]() |
bc04a3a489 | ||
![]() |
cfcb22a77b | ||
![]() |
838a453e39 | ||
![]() |
1a676881ca | ||
![]() |
c2ae9f75d7 | ||
![]() |
31647c5a46 | ||
![]() |
9422cd85a0 | ||
![]() |
87c416d93a | ||
![]() |
607e5038a9 | ||
![]() |
a289b0b91a | ||
![]() |
842def7d78 | ||
![]() |
c38af02626 | ||
![]() |
7ce0f4ea3b | ||
![]() |
3193b85be3 | ||
![]() |
5c8845a554 | ||
![]() |
e5e048bbf7 | ||
![]() |
b276b913a1 | ||
![]() |
d89e14bf54 | ||
![]() |
4b846f0ccf | ||
![]() |
425517eecb | ||
![]() |
bc89c2902b | ||
![]() |
1497633924 | ||
![]() |
f167511753 | ||
![]() |
8c00647982 | ||
![]() |
e40d01f45d | ||
![]() |
51d1e79cc1 | ||
![]() |
807d85400c | ||
![]() |
5c1e9d3722 | ||
![]() |
b56e9beeb8 | ||
![]() |
d8be5bda1b | ||
![]() |
1cd5797f8e | ||
![]() |
35a7b73590 |
@@ -14,7 +14,6 @@ patches and related discussions.
|
|||||||
Project Leader
|
Project Leader
|
||||||
==============
|
==============
|
||||||
|
|
||||||
Michael Niedermayer
|
|
||||||
final design decisions
|
final design decisions
|
||||||
|
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ struct SwsContext *sws_opts;
|
|||||||
AVDictionary *swr_opts;
|
AVDictionary *swr_opts;
|
||||||
AVDictionary *format_opts, *codec_opts, *resample_opts;
|
AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||||
|
|
||||||
const int this_year = 2013;
|
const int this_year = 2015;
|
||||||
|
|
||||||
static FILE *report_file;
|
static FILE *report_file;
|
||||||
|
|
||||||
|
63
configure
vendored
63
configure
vendored
@@ -105,6 +105,7 @@ Configuration options:
|
|||||||
--disable-all disable building components, libraries and programs
|
--disable-all disable building components, libraries and programs
|
||||||
--enable-incompatible-libav-abi enable incompatible Libav fork ABI [no]
|
--enable-incompatible-libav-abi enable incompatible Libav fork ABI [no]
|
||||||
--enable-incompatible-fork-abi enable incompatible Libav fork ABI (deprecated) [no]
|
--enable-incompatible-fork-abi enable incompatible Libav fork ABI (deprecated) [no]
|
||||||
|
--enable-raise-major increase major version numbers in sonames [no]
|
||||||
|
|
||||||
Program options:
|
Program options:
|
||||||
--disable-programs do not build command line programs
|
--disable-programs do not build command line programs
|
||||||
@@ -728,6 +729,10 @@ add_ldflags(){
|
|||||||
append LDFLAGS $($ldflags_filter "$@")
|
append LDFLAGS $($ldflags_filter "$@")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_stripflags(){
|
||||||
|
append ASMSTRIPFLAGS "$@"
|
||||||
|
}
|
||||||
|
|
||||||
add_extralibs(){
|
add_extralibs(){
|
||||||
prepend extralibs $($ldflags_filter "$@")
|
prepend extralibs $($ldflags_filter "$@")
|
||||||
}
|
}
|
||||||
@@ -885,6 +890,20 @@ check_ldflags(){
|
|||||||
test_ldflags "$@" && add_ldflags "$@"
|
test_ldflags "$@" && add_ldflags "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_stripflags(){
|
||||||
|
log test_stripflags "$@"
|
||||||
|
# call check_cc to get a fresh TMPO
|
||||||
|
check_cc <<EOF
|
||||||
|
int main(void) { return 0; }
|
||||||
|
EOF
|
||||||
|
check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
|
||||||
|
}
|
||||||
|
|
||||||
|
check_stripflags(){
|
||||||
|
log check_stripflags "$@"
|
||||||
|
test_stripflags "$@" && add_stripflags "$@"
|
||||||
|
}
|
||||||
|
|
||||||
check_header(){
|
check_header(){
|
||||||
log check_header "$@"
|
log check_header "$@"
|
||||||
header=$1
|
header=$1
|
||||||
@@ -1102,6 +1121,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
|
||||||
}
|
}
|
||||||
@@ -1280,6 +1319,7 @@ CONFIG_LIST="
|
|||||||
network
|
network
|
||||||
nonfree
|
nonfree
|
||||||
pic
|
pic
|
||||||
|
raise_major
|
||||||
rdft
|
rdft
|
||||||
runtime_cpudetect
|
runtime_cpudetect
|
||||||
safe_bitstream_reader
|
safe_bitstream_reader
|
||||||
@@ -1426,6 +1466,7 @@ HAVE_LIST="
|
|||||||
alsa_asoundlib_h
|
alsa_asoundlib_h
|
||||||
altivec_h
|
altivec_h
|
||||||
arpa_inet_h
|
arpa_inet_h
|
||||||
|
as_object_arch
|
||||||
asm_mod_q
|
asm_mod_q
|
||||||
asm_mod_y
|
asm_mod_y
|
||||||
asm_types_h
|
asm_types_h
|
||||||
@@ -1996,6 +2037,7 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
|
|||||||
|
|
||||||
# parsers
|
# parsers
|
||||||
h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
|
h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
|
||||||
|
hevc_parser_select="hevc_decoder"
|
||||||
mpeg4video_parser_select="error_resilience mpegvideo"
|
mpeg4video_parser_select="error_resilience mpegvideo"
|
||||||
mpegvideo_parser_select="error_resilience mpegvideo"
|
mpegvideo_parser_select="error_resilience mpegvideo"
|
||||||
vc1_parser_select="mpegvideo"
|
vc1_parser_select="mpegvideo"
|
||||||
@@ -2878,7 +2920,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"
|
||||||
@@ -3921,6 +3965,11 @@ EOF
|
|||||||
|
|
||||||
[ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
|
[ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
|
||||||
|
|
||||||
|
# llvm's integrated assembler supports .object_arch from llvm 3.5
|
||||||
|
[ "$objformat" = elf ] && check_as <<EOF && enable as_object_arch
|
||||||
|
.object_arch armv4
|
||||||
|
EOF
|
||||||
|
|
||||||
elif enabled mips; then
|
elif enabled mips; then
|
||||||
|
|
||||||
check_inline_asm loongson '"dmult.g $1, $2, $3"'
|
check_inline_asm loongson '"dmult.g $1, $2, $3"'
|
||||||
@@ -4049,6 +4098,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
check_ldflags -Wl,--as-needed
|
check_ldflags -Wl,--as-needed
|
||||||
|
check_ldflags -Wl,-z,noexecstack
|
||||||
|
|
||||||
if check_func dlopen; then
|
if check_func dlopen; then
|
||||||
ldl=
|
ldl=
|
||||||
@@ -4231,7 +4281,7 @@ enabled ladspa && { check_header ladspa.h || die "ERROR: ladspa.h hea
|
|||||||
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."; }
|
||||||
@@ -4240,7 +4290,7 @@ enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersio
|
|||||||
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 libgme && require libgme gme/gme.h gme_new_emu -lgme -lstdc++
|
enabled libgme && require libgme gme/gme.h gme_new_emu -lgme -lstdc++
|
||||||
enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
|
enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
|
||||||
check_lib "${gsm_hdr}" gsm_create -lgsm && break;
|
check_lib "${gsm_hdr}" gsm_create -lgsm && break;
|
||||||
@@ -4436,6 +4486,10 @@ check_ldflags -Wl,--warn-common
|
|||||||
check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
|
check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
|
||||||
test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
|
test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
|
||||||
|
|
||||||
|
# add some strip flags
|
||||||
|
# -wN '..@*' is more selective than -x, but not available everywhere.
|
||||||
|
check_stripflags -wN \'..@*\' || check_stripflags -x
|
||||||
|
|
||||||
enabled xmm_clobber_test &&
|
enabled xmm_clobber_test &&
|
||||||
check_ldflags -Wl,--wrap,avcodec_open2 \
|
check_ldflags -Wl,--wrap,avcodec_open2 \
|
||||||
-Wl,--wrap,avcodec_decode_audio4 \
|
-Wl,--wrap,avcodec_decode_audio4 \
|
||||||
@@ -4786,6 +4840,7 @@ LD_PATH=$LD_PATH
|
|||||||
DLLTOOL=$dlltool
|
DLLTOOL=$dlltool
|
||||||
LDFLAGS=$LDFLAGS
|
LDFLAGS=$LDFLAGS
|
||||||
SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
|
SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
|
||||||
|
ASMSTRIPFLAGS=$ASMSTRIPFLAGS
|
||||||
YASMFLAGS=$YASMFLAGS
|
YASMFLAGS=$YASMFLAGS
|
||||||
BUILDSUF=$build_suffix
|
BUILDSUF=$build_suffix
|
||||||
PROGSSUF=$progs_suffix
|
PROGSSUF=$progs_suffix
|
||||||
@@ -4849,6 +4904,7 @@ get_version(){
|
|||||||
name=$(toupper $lcname)
|
name=$(toupper $lcname)
|
||||||
file=$source_path/$lcname/version.h
|
file=$source_path/$lcname/version.h
|
||||||
eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
|
eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
|
||||||
|
enabled raise_major && eval ${name}_VERSION_MAJOR=$((${name}_VERSION_MAJOR+100))
|
||||||
eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
|
eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
|
||||||
eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
|
eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
|
||||||
eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
|
eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
|
||||||
@@ -4888,6 +4944,7 @@ enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
|
|||||||
|
|
||||||
|
|
||||||
mkdir -p doc
|
mkdir -p doc
|
||||||
|
mkdir -p tests
|
||||||
echo "@c auto-generated by configure" > doc/config.texi
|
echo "@c auto-generated by configure" > doc/config.texi
|
||||||
|
|
||||||
print_config ARCH_ "$config_files" $ARCH_LIST
|
print_config ARCH_ "$config_files" $ARCH_LIST
|
||||||
|
@@ -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 =
|
PROJECT_NUMBER = 2.1.8
|
||||||
|
|
||||||
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
|
# With the PROJECT_LOGO tag one can specify a 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
|
||||||
|
@@ -786,7 +786,7 @@ 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
|
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.
|
frame sizes achieve lower latency but less quality at a given bitrate.
|
||||||
Sizes greater than 20ms are only interesting at fairly low bitrates.
|
Sizes greater than 20ms are only interesting at fairly low bitrates.
|
||||||
The default of FFmpeg is 10ms, but is 20ms in @command{opusenc}.
|
The default is 20ms.
|
||||||
|
|
||||||
@item packet_loss (@emph{expect-loss})
|
@item packet_loss (@emph{expect-loss})
|
||||||
Set expected packet loss percentage. The default is 0.
|
Set expected packet loss percentage. The default is 0.
|
||||||
|
@@ -3656,7 +3656,7 @@ within the parameter list.
|
|||||||
@item
|
@item
|
||||||
Show the text at the center of the video frame:
|
Show the text at the center of the video frame:
|
||||||
@example
|
@example
|
||||||
drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
|
drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2"
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@item
|
@item
|
||||||
@@ -6422,9 +6422,11 @@ The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
|
|||||||
load and make pullup usable in realtime on slow machines.
|
load and make pullup usable in realtime on slow machines.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
For example to inverse telecined NTSC input:
|
For best results (without duplicated frames in the output file) it is
|
||||||
|
necessary to change the output frame rate. For example, to inverse
|
||||||
|
telecine NTSC input:
|
||||||
@example
|
@example
|
||||||
pullup,fps=24000/1001
|
ffmpeg -i input -vf pullup -r 24000/1001 ...
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section removelogo
|
@section removelogo
|
||||||
|
@@ -35,7 +35,7 @@ Select nearest neighbor rescaling algorithm.
|
|||||||
@item area
|
@item area
|
||||||
Select averaging area rescaling algorithm.
|
Select averaging area rescaling algorithm.
|
||||||
|
|
||||||
@item bicubiclin
|
@item bicublin
|
||||||
Select bicubic scaling algorithm for the luma component, bilinear for
|
Select bicubic scaling algorithm for the luma component, bilinear for
|
||||||
chroma components.
|
chroma components.
|
||||||
|
|
||||||
|
@@ -858,7 +858,7 @@ Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise.
|
|||||||
Return the maximum between @var{x} and @var{y}.
|
Return the maximum between @var{x} and @var{y}.
|
||||||
|
|
||||||
@item min(x, y)
|
@item min(x, y)
|
||||||
Return the maximum between @var{x} and @var{y}.
|
Return the minimum between @var{x} and @var{y}.
|
||||||
|
|
||||||
@item mod(x, y)
|
@item mod(x, y)
|
||||||
Compute the remainder of division of @var{x} by @var{y}.
|
Compute the remainder of division of @var{x} by @var{y}.
|
||||||
|
31
ffmpeg.c
31
ffmpeg.c
@@ -319,7 +319,7 @@ sigterm_handler(int sig)
|
|||||||
received_nb_signals++;
|
received_nb_signals++;
|
||||||
term_exit();
|
term_exit();
|
||||||
if(received_nb_signals > 3)
|
if(received_nb_signals > 3)
|
||||||
exit_program(123);
|
exit(123);
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_init(void)
|
void term_init(void)
|
||||||
@@ -349,7 +349,6 @@ void term_init(void)
|
|||||||
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
|
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
avformat_network_deinit();
|
|
||||||
|
|
||||||
signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
|
signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
|
||||||
signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
|
signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
|
||||||
@@ -817,10 +816,26 @@ static void do_video_out(AVFormatContext *s,
|
|||||||
nb_frames = 1;
|
nb_frames = 1;
|
||||||
|
|
||||||
format_video_sync = video_sync_method;
|
format_video_sync = video_sync_method;
|
||||||
if (format_video_sync == VSYNC_AUTO)
|
if (format_video_sync == VSYNC_AUTO) {
|
||||||
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
|
format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
|
||||||
|
if ( ist
|
||||||
|
&& format_video_sync == VSYNC_CFR
|
||||||
|
&& input_files[ist->file_index]->ctx->nb_streams == 1
|
||||||
|
&& input_files[ist->file_index]->input_ts_offset == 0) {
|
||||||
|
format_video_sync = VSYNC_VSCFR;
|
||||||
|
}
|
||||||
|
if (format_video_sync == VSYNC_CFR && copy_ts) {
|
||||||
|
format_video_sync = VSYNC_VSCFR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (format_video_sync) {
|
switch (format_video_sync) {
|
||||||
|
case VSYNC_VSCFR:
|
||||||
|
if (ost->frame_number == 0 && delta - duration >= 0.5) {
|
||||||
|
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta - duration));
|
||||||
|
delta = duration;
|
||||||
|
ost->sync_opts = lrint(sync_ipts);
|
||||||
|
}
|
||||||
case VSYNC_CFR:
|
case VSYNC_CFR:
|
||||||
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
|
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
|
||||||
if (delta < -1.1)
|
if (delta < -1.1)
|
||||||
@@ -1467,7 +1482,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
|||||||
&& ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO
|
&& ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO
|
||||||
&& ost->st->codec->codec_id != AV_CODEC_ID_VC1
|
&& ost->st->codec->codec_id != AV_CODEC_ID_VC1
|
||||||
) {
|
) {
|
||||||
if (av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY)) {
|
if (av_parser_change(av_stream_get_parser(ist->st), ost->st->codec, &opkt.data, &opkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY)) {
|
||||||
opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0);
|
opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0);
|
||||||
if (!opkt.buf)
|
if (!opkt.buf)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
@@ -1867,7 +1882,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
|
|||||||
if (avpkt.duration) {
|
if (avpkt.duration) {
|
||||||
duration = av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
|
duration = av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
|
||||||
} else if(ist->st->codec->time_base.num != 0 && ist->st->codec->time_base.den != 0) {
|
} else if(ist->st->codec->time_base.num != 0 && ist->st->codec->time_base.den != 0) {
|
||||||
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
|
int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict+1 : ist->st->codec->ticks_per_frame;
|
||||||
duration = ((int64_t)AV_TIME_BASE *
|
duration = ((int64_t)AV_TIME_BASE *
|
||||||
ist->st->codec->time_base.num * ticks) /
|
ist->st->codec->time_base.num * ticks) /
|
||||||
ist->st->codec->time_base.den;
|
ist->st->codec->time_base.den;
|
||||||
@@ -1924,7 +1939,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
|
|||||||
} else if (pkt->duration) {
|
} else if (pkt->duration) {
|
||||||
ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
|
ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
|
||||||
} else if(ist->st->codec->time_base.num != 0) {
|
} else if(ist->st->codec->time_base.num != 0) {
|
||||||
int ticks= ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->st->codec->ticks_per_frame;
|
int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->st->codec->ticks_per_frame;
|
||||||
ist->next_dts += ((int64_t)AV_TIME_BASE *
|
ist->next_dts += ((int64_t)AV_TIME_BASE *
|
||||||
ist->st->codec->time_base.num * ticks) /
|
ist->st->codec->time_base.num * ticks) /
|
||||||
ist->st->codec->time_base.den;
|
ist->st->codec->time_base.den;
|
||||||
@@ -2101,7 +2116,7 @@ static int transcode_init(void)
|
|||||||
AVCodecContext *codec;
|
AVCodecContext *codec;
|
||||||
OutputStream *ost;
|
OutputStream *ost;
|
||||||
InputStream *ist;
|
InputStream *ist;
|
||||||
char error[1024];
|
char error[1024] = {0};
|
||||||
int want_sdp = 1;
|
int want_sdp = 1;
|
||||||
|
|
||||||
for (i = 0; i < nb_filtergraphs; i++) {
|
for (i = 0; i < nb_filtergraphs; i++) {
|
||||||
@@ -2357,7 +2372,7 @@ static int transcode_init(void)
|
|||||||
if (ost->filter && !(codec->time_base.num && codec->time_base.den))
|
if (ost->filter && !(codec->time_base.num && codec->time_base.den))
|
||||||
codec->time_base = ost->filter->filter->inputs[0]->time_base;
|
codec->time_base = ost->filter->filter->inputs[0]->time_base;
|
||||||
if ( av_q2d(codec->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH
|
if ( av_q2d(codec->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH
|
||||||
&& (video_sync_method == VSYNC_CFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){
|
&& (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){
|
||||||
av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n"
|
av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n"
|
||||||
"Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
|
"Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
|
||||||
}
|
}
|
||||||
|
2
ffmpeg.h
2
ffmpeg.h
@@ -51,6 +51,7 @@
|
|||||||
#define VSYNC_PASSTHROUGH 0
|
#define VSYNC_PASSTHROUGH 0
|
||||||
#define VSYNC_CFR 1
|
#define VSYNC_CFR 1
|
||||||
#define VSYNC_VFR 2
|
#define VSYNC_VFR 2
|
||||||
|
#define VSYNC_VSCFR 0xfe
|
||||||
#define VSYNC_DROP 0xff
|
#define VSYNC_DROP 0xff
|
||||||
|
|
||||||
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
|
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
|
||||||
@@ -281,6 +282,7 @@ typedef struct InputFile {
|
|||||||
int eof_reached; /* true if eof reached */
|
int eof_reached; /* true if eof reached */
|
||||||
int eagain; /* true if last read attempt returned EAGAIN */
|
int eagain; /* true if last read attempt returned EAGAIN */
|
||||||
int ist_index; /* index of first stream in input_streams */
|
int ist_index; /* index of first stream in input_streams */
|
||||||
|
int64_t input_ts_offset;
|
||||||
int64_t ts_offset;
|
int64_t ts_offset;
|
||||||
int64_t last_ts;
|
int64_t last_ts;
|
||||||
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
|
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
|
||||||
|
@@ -42,12 +42,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++) {
|
||||||
|
@@ -852,6 +852,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
|||||||
f->ist_index = nb_input_streams - ic->nb_streams;
|
f->ist_index = nb_input_streams - ic->nb_streams;
|
||||||
f->start_time = o->start_time;
|
f->start_time = o->start_time;
|
||||||
f->recording_time = o->recording_time;
|
f->recording_time = o->recording_time;
|
||||||
|
f->input_ts_offset = o->input_ts_offset;
|
||||||
f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
|
f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
|
||||||
f->nb_streams = ic->nb_streams;
|
f->nb_streams = ic->nb_streams;
|
||||||
f->rate_emu = o->rate_emu;
|
f->rate_emu = o->rate_emu;
|
||||||
@@ -1689,7 +1690,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
/* pick the "best" stream of each type */
|
/* pick the "best" stream of each type */
|
||||||
|
|
||||||
/* video: highest resolution */
|
/* video: highest resolution */
|
||||||
if (!o->video_disable && oc->oformat->video_codec != AV_CODEC_ID_NONE) {
|
if (!o->video_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) {
|
||||||
int area = 0, idx = -1;
|
int area = 0, idx = -1;
|
||||||
int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
|
int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
|
||||||
for (i = 0; i < nb_input_streams; i++) {
|
for (i = 0; i < nb_input_streams; i++) {
|
||||||
@@ -1711,7 +1712,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* audio: most channels */
|
/* audio: most channels */
|
||||||
if (!o->audio_disable && oc->oformat->audio_codec != AV_CODEC_ID_NONE) {
|
if (!o->audio_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) {
|
||||||
int channels = 0, idx = -1;
|
int channels = 0, idx = -1;
|
||||||
for (i = 0; i < nb_input_streams; i++) {
|
for (i = 0; i < nb_input_streams; i++) {
|
||||||
ist = input_streams[i];
|
ist = input_streams[i];
|
||||||
@@ -1727,7 +1728,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
|
|
||||||
/* subtitles: pick first */
|
/* subtitles: pick first */
|
||||||
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
|
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
|
||||||
if (!o->subtitle_disable && (oc->oformat->subtitle_codec != AV_CODEC_ID_NONE || subtitle_codec_name)) {
|
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
|
||||||
for (i = 0; i < nb_input_streams; i++)
|
for (i = 0; i < nb_input_streams; i++)
|
||||||
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||||
new_subtitle_stream(o, oc, i);
|
new_subtitle_stream(o, oc, i);
|
||||||
|
36
ffprobe.c
36
ffprobe.c
@@ -183,6 +183,7 @@ static const char unit_hertz_str[] = "Hz" ;
|
|||||||
static const char unit_byte_str[] = "byte" ;
|
static const char unit_byte_str[] = "byte" ;
|
||||||
static const char unit_bit_per_second_str[] = "bit/s";
|
static const char unit_bit_per_second_str[] = "bit/s";
|
||||||
|
|
||||||
|
static int nb_streams;
|
||||||
static uint64_t *nb_streams_packets;
|
static uint64_t *nb_streams_packets;
|
||||||
static uint64_t *nb_streams_frames;
|
static uint64_t *nb_streams_frames;
|
||||||
static int *selected_streams;
|
static int *selected_streams;
|
||||||
@@ -238,6 +239,7 @@ static char *value_string(char *buf, int buf_size, struct unit_value uv)
|
|||||||
vald /= pow(10, index * 3);
|
vald /= pow(10, index * 3);
|
||||||
prefix_string = decimal_unit_prefixes[index];
|
prefix_string = decimal_unit_prefixes[index];
|
||||||
}
|
}
|
||||||
|
vali = vald;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_float || (use_value_prefix && vald != (long long int)vald))
|
if (show_float || (use_value_prefix && vald != (long long int)vald))
|
||||||
@@ -1455,6 +1457,14 @@ static void writer_register_all(void)
|
|||||||
#define print_section_header(s) writer_print_section_header(w, s)
|
#define print_section_header(s) writer_print_section_header(w, s)
|
||||||
#define print_section_footer(s) writer_print_section_footer(w, s)
|
#define print_section_footer(s) writer_print_section_footer(w, s)
|
||||||
|
|
||||||
|
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
|
||||||
|
{ \
|
||||||
|
ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
|
||||||
|
if (ret < 0) \
|
||||||
|
goto end; \
|
||||||
|
memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
|
||||||
|
}
|
||||||
|
|
||||||
static inline void show_tags(WriterContext *wctx, AVDictionary *tags, int section_id)
|
static inline void show_tags(WriterContext *wctx, AVDictionary *tags, int section_id)
|
||||||
{
|
{
|
||||||
AVDictionaryEntry *tag = NULL;
|
AVDictionaryEntry *tag = NULL;
|
||||||
@@ -1580,7 +1590,6 @@ static av_always_inline int process_frame(WriterContext *w,
|
|||||||
AVCodecContext *dec_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
|
AVCodecContext *dec_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
|
||||||
int ret = 0, got_frame = 0;
|
int ret = 0, got_frame = 0;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(frame);
|
|
||||||
if (dec_ctx->codec) {
|
if (dec_ctx->codec) {
|
||||||
switch (dec_ctx->codec_type) {
|
switch (dec_ctx->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
@@ -1634,7 +1643,7 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
|
|||||||
const ReadInterval *interval, int64_t *cur_ts)
|
const ReadInterval *interval, int64_t *cur_ts)
|
||||||
{
|
{
|
||||||
AVPacket pkt, pkt1;
|
AVPacket pkt, pkt1;
|
||||||
AVFrame frame;
|
AVFrame *frame = NULL;
|
||||||
int ret = 0, i = 0, frame_count = 0;
|
int ret = 0, i = 0, frame_count = 0;
|
||||||
int64_t start = -INT64_MAX, end = interval->end;
|
int64_t start = -INT64_MAX, end = interval->end;
|
||||||
int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
|
int has_start = 0, has_end = interval->has_end && !interval->end_is_offset;
|
||||||
@@ -1668,7 +1677,18 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame = av_frame_alloc();
|
||||||
|
if (!frame) {
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
while (!av_read_frame(fmt_ctx, &pkt)) {
|
while (!av_read_frame(fmt_ctx, &pkt)) {
|
||||||
|
if (fmt_ctx->nb_streams > nb_streams) {
|
||||||
|
REALLOCZ_ARRAY_STREAM(nb_streams_frames, nb_streams, fmt_ctx->nb_streams);
|
||||||
|
REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);
|
||||||
|
REALLOCZ_ARRAY_STREAM(selected_streams, nb_streams, fmt_ctx->nb_streams);
|
||||||
|
nb_streams = fmt_ctx->nb_streams;
|
||||||
|
}
|
||||||
if (selected_streams[pkt.stream_index]) {
|
if (selected_streams[pkt.stream_index]) {
|
||||||
AVRational tb = fmt_ctx->streams[pkt.stream_index]->time_base;
|
AVRational tb = fmt_ctx->streams[pkt.stream_index]->time_base;
|
||||||
|
|
||||||
@@ -1700,7 +1720,7 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
|
|||||||
}
|
}
|
||||||
if (do_read_frames) {
|
if (do_read_frames) {
|
||||||
pkt1 = pkt;
|
pkt1 = pkt;
|
||||||
while (pkt1.size && process_frame(w, fmt_ctx, &frame, &pkt1) > 0);
|
while (pkt1.size && process_frame(w, fmt_ctx, frame, &pkt1) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_free_packet(&pkt);
|
av_free_packet(&pkt);
|
||||||
@@ -1712,10 +1732,11 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
|
|||||||
for (i = 0; i < fmt_ctx->nb_streams; i++) {
|
for (i = 0; i < fmt_ctx->nb_streams; i++) {
|
||||||
pkt.stream_index = i;
|
pkt.stream_index = i;
|
||||||
if (do_read_frames)
|
if (do_read_frames)
|
||||||
while (process_frame(w, fmt_ctx, &frame, &pkt) > 0);
|
while (process_frame(w, fmt_ctx, frame, &pkt) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
av_frame_free(&frame);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
|
av_log(NULL, AV_LOG_ERROR, "Could not read packets in interval ");
|
||||||
log_read_interval(interval, NULL, AV_LOG_ERROR);
|
log_read_interval(interval, NULL, AV_LOG_ERROR);
|
||||||
@@ -2111,9 +2132,10 @@ static int probe_file(WriterContext *wctx, const char *filename)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
nb_streams_frames = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));
|
nb_streams = fmt_ctx->nb_streams;
|
||||||
nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));
|
REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,fmt_ctx->nb_streams);
|
||||||
selected_streams = av_calloc(fmt_ctx->nb_streams, sizeof(*selected_streams));
|
REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,fmt_ctx->nb_streams);
|
||||||
|
REALLOCZ_ARRAY_STREAM(selected_streams,0,fmt_ctx->nb_streams);
|
||||||
|
|
||||||
for (i = 0; i < fmt_ctx->nb_streams; i++) {
|
for (i = 0; i < fmt_ctx->nb_streams; i++) {
|
||||||
if (stream_specifier) {
|
if (stream_specifier) {
|
||||||
|
@@ -2972,6 +2972,8 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
|
|||||||
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
|
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
*pbuffer = NULL;
|
||||||
|
|
||||||
avc = avformat_alloc_context();
|
avc = avformat_alloc_context();
|
||||||
if (avc == NULL || !rtp_format) {
|
if (avc == NULL || !rtp_format) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -3008,7 +3010,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
|
|||||||
av_free(avc);
|
av_free(avc);
|
||||||
av_free(avs);
|
av_free(avs);
|
||||||
|
|
||||||
return strlen(*pbuffer);
|
return *pbuffer ? strlen(*pbuffer) : AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtsp_cmd_options(HTTPContext *c, const char *url)
|
static void rtsp_cmd_options(HTTPContext *c, const char *url)
|
||||||
|
@@ -38,15 +38,15 @@ static av_cold int zero12v_decode_init(AVCodecContext *avctx)
|
|||||||
static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
|
static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
int *got_frame, AVPacket *avpkt)
|
int *got_frame, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
int line = 0, ret;
|
int line, ret;
|
||||||
const int width = avctx->width;
|
const int width = avctx->width;
|
||||||
AVFrame *pic = data;
|
AVFrame *pic = data;
|
||||||
uint16_t *y, *u, *v;
|
uint16_t *y, *u, *v;
|
||||||
const uint8_t *line_end, *src = avpkt->data;
|
const uint8_t *line_end, *src = avpkt->data;
|
||||||
int stride = avctx->width * 8 / 3;
|
int stride = avctx->width * 8 / 3;
|
||||||
|
|
||||||
if (width == 1) {
|
if (width <= 1 || avctx->height <= 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Width 1 not supported.\n");
|
av_log(avctx, AV_LOG_ERROR, "Dimensions %dx%d not supported.\n", width, avctx->height);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,45 +67,45 @@ static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
pic->pict_type = AV_PICTURE_TYPE_I;
|
pic->pict_type = AV_PICTURE_TYPE_I;
|
||||||
pic->key_frame = 1;
|
pic->key_frame = 1;
|
||||||
|
|
||||||
y = (uint16_t *)pic->data[0];
|
|
||||||
u = (uint16_t *)pic->data[1];
|
|
||||||
v = (uint16_t *)pic->data[2];
|
|
||||||
line_end = avpkt->data + stride;
|
line_end = avpkt->data + stride;
|
||||||
|
for (line = 0; line < avctx->height; line++) {
|
||||||
|
uint16_t y_temp[6] = {0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000};
|
||||||
|
uint16_t u_temp[3] = {0x8000, 0x8000, 0x8000};
|
||||||
|
uint16_t v_temp[3] = {0x8000, 0x8000, 0x8000};
|
||||||
|
int x;
|
||||||
|
y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]);
|
||||||
|
u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
||||||
|
v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
||||||
|
|
||||||
while (line++ < avctx->height) {
|
for (x = 0; x < width; x += 6) {
|
||||||
while (1) {
|
uint32_t t;
|
||||||
uint32_t t = AV_RL32(src);
|
|
||||||
|
if (width - x < 6 || line_end - src < 16) {
|
||||||
|
y = y_temp;
|
||||||
|
u = u_temp;
|
||||||
|
v = v_temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line_end - src < 4)
|
||||||
|
break;
|
||||||
|
|
||||||
|
t = AV_RL32(src);
|
||||||
src += 4;
|
src += 4;
|
||||||
*u++ = t << 6 & 0xFFC0;
|
*u++ = t << 6 & 0xFFC0;
|
||||||
*y++ = t >> 4 & 0xFFC0;
|
*y++ = t >> 4 & 0xFFC0;
|
||||||
*v++ = t >> 14 & 0xFFC0;
|
*v++ = t >> 14 & 0xFFC0;
|
||||||
|
|
||||||
if (src >= line_end - 1) {
|
if (line_end - src < 4)
|
||||||
*y = 0x80;
|
|
||||||
src++;
|
|
||||||
line_end += stride;
|
|
||||||
y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]);
|
|
||||||
u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
|
||||||
v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
t = AV_RL32(src);
|
t = AV_RL32(src);
|
||||||
src += 4;
|
src += 4;
|
||||||
*y++ = t << 6 & 0xFFC0;
|
*y++ = t << 6 & 0xFFC0;
|
||||||
*u++ = t >> 4 & 0xFFC0;
|
*u++ = t >> 4 & 0xFFC0;
|
||||||
*y++ = t >> 14 & 0xFFC0;
|
*y++ = t >> 14 & 0xFFC0;
|
||||||
if (src >= line_end - 2) {
|
|
||||||
if (!(width & 1)) {
|
if (line_end - src < 4)
|
||||||
*y = 0x80;
|
|
||||||
src += 2;
|
|
||||||
}
|
|
||||||
line_end += stride;
|
|
||||||
y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]);
|
|
||||||
u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
|
||||||
v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
t = AV_RL32(src);
|
t = AV_RL32(src);
|
||||||
src += 4;
|
src += 4;
|
||||||
@@ -113,15 +113,8 @@ static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
*y++ = t >> 4 & 0xFFC0;
|
*y++ = t >> 4 & 0xFFC0;
|
||||||
*u++ = t >> 14 & 0xFFC0;
|
*u++ = t >> 14 & 0xFFC0;
|
||||||
|
|
||||||
if (src >= line_end - 1) {
|
if (line_end - src < 4)
|
||||||
*y = 0x80;
|
|
||||||
src++;
|
|
||||||
line_end += stride;
|
|
||||||
y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]);
|
|
||||||
u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
|
||||||
v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
t = AV_RL32(src);
|
t = AV_RL32(src);
|
||||||
src += 4;
|
src += 4;
|
||||||
@@ -129,18 +122,21 @@ static int zero12v_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
*v++ = t >> 4 & 0xFFC0;
|
*v++ = t >> 4 & 0xFFC0;
|
||||||
*y++ = t >> 14 & 0xFFC0;
|
*y++ = t >> 14 & 0xFFC0;
|
||||||
|
|
||||||
if (src >= line_end - 2) {
|
if (width - x < 6)
|
||||||
if (width & 1) {
|
|
||||||
*y = 0x80;
|
|
||||||
src += 2;
|
|
||||||
}
|
|
||||||
line_end += stride;
|
|
||||||
y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]);
|
|
||||||
u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
|
||||||
v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x < width) {
|
||||||
|
y = x + (uint16_t *)(pic->data[0] + line * pic->linesize[0]);
|
||||||
|
u = x/2 + (uint16_t *)(pic->data[1] + line * pic->linesize[1]);
|
||||||
|
v = x/2 + (uint16_t *)(pic->data[2] + line * pic->linesize[2]);
|
||||||
|
memcpy(y, y_temp, sizeof(*y) * (width - x));
|
||||||
|
memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2);
|
||||||
|
memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line_end += stride;
|
||||||
|
src = line_end - stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
|
@@ -331,22 +331,22 @@ OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
|
|||||||
OBJS-$(CONFIG_PAF_VIDEO_DECODER) += paf.o
|
OBJS-$(CONFIG_PAF_VIDEO_DECODER) += paf.o
|
||||||
OBJS-$(CONFIG_PAF_AUDIO_DECODER) += paf.o
|
OBJS-$(CONFIG_PAF_AUDIO_DECODER) += paf.o
|
||||||
OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
|
OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
|
||||||
OBJS-$(CONFIG_PAM_ENCODER) += pamenc.o pnm.o
|
OBJS-$(CONFIG_PAM_ENCODER) += pamenc.o
|
||||||
OBJS-$(CONFIG_PBM_DECODER) += pnmdec.o pnm.o
|
OBJS-$(CONFIG_PBM_DECODER) += pnmdec.o pnm.o
|
||||||
OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o pnm.o
|
OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o
|
||||||
OBJS-$(CONFIG_PCX_DECODER) += pcx.o
|
OBJS-$(CONFIG_PCX_DECODER) += pcx.o
|
||||||
OBJS-$(CONFIG_PCX_ENCODER) += pcxenc.o
|
OBJS-$(CONFIG_PCX_ENCODER) += pcxenc.o
|
||||||
OBJS-$(CONFIG_PGM_DECODER) += pnmdec.o pnm.o
|
OBJS-$(CONFIG_PGM_DECODER) += pnmdec.o pnm.o
|
||||||
OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o pnm.o
|
OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o
|
||||||
OBJS-$(CONFIG_PGMYUV_DECODER) += pnmdec.o pnm.o
|
OBJS-$(CONFIG_PGMYUV_DECODER) += pnmdec.o pnm.o
|
||||||
OBJS-$(CONFIG_PGMYUV_ENCODER) += pnmenc.o pnm.o
|
OBJS-$(CONFIG_PGMYUV_ENCODER) += pnmenc.o
|
||||||
OBJS-$(CONFIG_PGSSUB_DECODER) += pgssubdec.o
|
OBJS-$(CONFIG_PGSSUB_DECODER) += pgssubdec.o
|
||||||
OBJS-$(CONFIG_PICTOR_DECODER) += pictordec.o cga_data.o
|
OBJS-$(CONFIG_PICTOR_DECODER) += pictordec.o cga_data.o
|
||||||
OBJS-$(CONFIG_PJS_DECODER) += textdec.o ass.o
|
OBJS-$(CONFIG_PJS_DECODER) += textdec.o ass.o
|
||||||
OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o pngdsp.o
|
OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o pngdsp.o
|
||||||
OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o
|
OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o
|
||||||
OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o
|
OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o
|
||||||
OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o
|
OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o
|
||||||
OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o
|
OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o
|
||||||
OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdata.o
|
OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdata.o
|
||||||
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o
|
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o
|
||||||
|
@@ -40,9 +40,6 @@
|
|||||||
#define C64YRES 200
|
#define C64YRES 200
|
||||||
|
|
||||||
typedef struct A64Context {
|
typedef struct A64Context {
|
||||||
/* general variables */
|
|
||||||
AVFrame picture;
|
|
||||||
|
|
||||||
/* variables for multicolor modes */
|
/* variables for multicolor modes */
|
||||||
AVLFG randctx;
|
AVLFG randctx;
|
||||||
int mc_lifetime;
|
int mc_lifetime;
|
||||||
@@ -81,9 +78,13 @@ static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
|
|||||||
for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
|
for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
|
||||||
for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {
|
for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {
|
||||||
if(x < width && y < height) {
|
if(x < width && y < height) {
|
||||||
|
if (x + 1 < width) {
|
||||||
/* build average over 2 pixels */
|
/* build average over 2 pixels */
|
||||||
luma = (src[(x + 0 + y * p->linesize[0])] +
|
luma = (src[(x + 0 + y * p->linesize[0])] +
|
||||||
src[(x + 1 + y * p->linesize[0])]) / 2;
|
src[(x + 1 + y * p->linesize[0])]) / 2;
|
||||||
|
} else {
|
||||||
|
luma = src[(x + y * p->linesize[0])];
|
||||||
|
}
|
||||||
/* write blocks as linear data now so they are suitable for elbg */
|
/* write blocks as linear data now so they are suitable for elbg */
|
||||||
dest[0] = luma;
|
dest[0] = luma;
|
||||||
}
|
}
|
||||||
@@ -189,6 +190,7 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset,
|
|||||||
static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
|
static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
A64Context *c = avctx->priv_data;
|
A64Context *c = avctx->priv_data;
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
av_free(c->mc_meta_charset);
|
av_free(c->mc_meta_charset);
|
||||||
av_free(c->mc_best_cb);
|
av_free(c->mc_best_cb);
|
||||||
av_free(c->mc_charset);
|
av_free(c->mc_charset);
|
||||||
@@ -240,8 +242,12 @@ static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
|
|||||||
AV_WB32(avctx->extradata, c->mc_lifetime);
|
AV_WB32(avctx->extradata, c->mc_lifetime);
|
||||||
AV_WB32(avctx->extradata + 16, INTERLACED);
|
AV_WB32(avctx->extradata + 16, INTERLACED);
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&c->picture);
|
avctx->coded_frame = av_frame_alloc();
|
||||||
avctx->coded_frame = &c->picture;
|
if (!avctx->coded_frame) {
|
||||||
|
a64multi_close_encoder(avctx);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
avctx->coded_frame->key_frame = 1;
|
avctx->coded_frame->key_frame = 1;
|
||||||
if (!avctx->codec_tag)
|
if (!avctx->codec_tag)
|
||||||
@@ -271,7 +277,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
const AVFrame *pict, int *got_packet)
|
const AVFrame *pict, int *got_packet)
|
||||||
{
|
{
|
||||||
A64Context *c = avctx->priv_data;
|
A64Context *c = avctx->priv_data;
|
||||||
AVFrame *const p = &c->picture;
|
AVFrame *const p = avctx->coded_frame;
|
||||||
|
|
||||||
int frame;
|
int frame;
|
||||||
int x, y;
|
int x, y;
|
||||||
@@ -315,7 +321,9 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
} else {
|
} else {
|
||||||
/* fill up mc_meta_charset with data until lifetime exceeds */
|
/* fill up mc_meta_charset with data until lifetime exceeds */
|
||||||
if (c->mc_frame_counter < c->mc_lifetime) {
|
if (c->mc_frame_counter < c->mc_lifetime) {
|
||||||
*p = *pict;
|
ret = av_frame_ref(p, pict);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
p->pict_type = AV_PICTURE_TYPE_I;
|
||||||
p->key_frame = 1;
|
p->key_frame = 1;
|
||||||
to_meta_with_crop(avctx, p, meta + 32000 * c->mc_frame_counter);
|
to_meta_with_crop(avctx, p, meta + 32000 * c->mc_frame_counter);
|
||||||
@@ -332,8 +340,8 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
req_size = 0;
|
req_size = 0;
|
||||||
/* any frames to encode? */
|
/* any frames to encode? */
|
||||||
if (c->mc_lifetime) {
|
if (c->mc_lifetime) {
|
||||||
req_size = charset_size + c->mc_lifetime*(screen_size + colram_size);
|
int alloc_size = charset_size + c->mc_lifetime*(screen_size + colram_size);
|
||||||
if ((ret = ff_alloc_packet2(avctx, pkt, req_size)) < 0)
|
if ((ret = ff_alloc_packet2(avctx, pkt, alloc_size)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
buf = pkt->data;
|
buf = pkt->data;
|
||||||
|
|
||||||
@@ -350,6 +358,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
/* advance pointers */
|
/* advance pointers */
|
||||||
buf += charset_size;
|
buf += charset_size;
|
||||||
charset += charset_size;
|
charset += charset_size;
|
||||||
|
req_size += charset_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write x frames to buf */
|
/* write x frames to buf */
|
||||||
|
@@ -81,7 +81,7 @@ enum BandType {
|
|||||||
INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions.
|
INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions.
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
|
#define IS_CODEBOOK_UNSIGNED(x) (((x) - 1) & 10)
|
||||||
|
|
||||||
enum ChannelPosition {
|
enum ChannelPosition {
|
||||||
AAC_CHANNEL_OFF = 0,
|
AAC_CHANNEL_OFF = 0,
|
||||||
|
@@ -34,7 +34,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
|
|||||||
int size;
|
int size;
|
||||||
union {
|
union {
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
uint8_t u8[8];
|
uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||||
} tmp;
|
} tmp;
|
||||||
|
|
||||||
tmp.u64 = av_be2ne64(state);
|
tmp.u64 = av_be2ne64(state);
|
||||||
|
@@ -194,6 +194,9 @@ static int frame_configure_elements(AVCodecContext *avctx)
|
|||||||
|
|
||||||
/* get output buffer */
|
/* get output buffer */
|
||||||
av_frame_unref(ac->frame);
|
av_frame_unref(ac->frame);
|
||||||
|
if (!avctx->channels)
|
||||||
|
return 1;
|
||||||
|
|
||||||
ac->frame->nb_samples = 2048;
|
ac->frame->nb_samples = 2048;
|
||||||
if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0)
|
if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -420,7 +423,7 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
|
|||||||
* Save current output configuration if and only if it has been locked.
|
* Save current output configuration if and only if it has been locked.
|
||||||
*/
|
*/
|
||||||
static void push_output_configuration(AACContext *ac) {
|
static void push_output_configuration(AACContext *ac) {
|
||||||
if (ac->oc[1].status == OC_LOCKED) {
|
if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) {
|
||||||
ac->oc[0] = ac->oc[1];
|
ac->oc[0] = ac->oc[1];
|
||||||
}
|
}
|
||||||
ac->oc[1].status = OC_NONE;
|
ac->oc[1].status = OC_NONE;
|
||||||
@@ -857,7 +860,7 @@ static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
|
|||||||
if (len == 15 + 255)
|
if (len == 15 + 255)
|
||||||
len += get_bits(gb, 16);
|
len += get_bits(gb, 16);
|
||||||
if (get_bits_left(gb) < len * 8 + 4) {
|
if (get_bits_left(gb) < len * 8 + 4) {
|
||||||
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
|
av_log(avctx, AV_LOG_ERROR, overread_err);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
skip_bits_long(gb, 8 * len);
|
skip_bits_long(gb, 8 * len);
|
||||||
@@ -1402,12 +1405,12 @@ static int decode_pulses(Pulse *pulse, GetBitContext *gb,
|
|||||||
return -1;
|
return -1;
|
||||||
pulse->pos[0] = swb_offset[pulse_swb];
|
pulse->pos[0] = swb_offset[pulse_swb];
|
||||||
pulse->pos[0] += get_bits(gb, 5);
|
pulse->pos[0] += get_bits(gb, 5);
|
||||||
if (pulse->pos[0] > 1023)
|
if (pulse->pos[0] >= swb_offset[num_swb])
|
||||||
return -1;
|
return -1;
|
||||||
pulse->amp[0] = get_bits(gb, 4);
|
pulse->amp[0] = get_bits(gb, 4);
|
||||||
for (i = 1; i < pulse->num_pulse; i++) {
|
for (i = 1; i < pulse->num_pulse; i++) {
|
||||||
pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];
|
pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];
|
||||||
if (pulse->pos[i] > 1023)
|
if (pulse->pos[i] >= swb_offset[num_swb])
|
||||||
return -1;
|
return -1;
|
||||||
pulse->amp[i] = get_bits(gb, 4);
|
pulse->amp[i] = get_bits(gb, 4);
|
||||||
}
|
}
|
||||||
|
@@ -165,7 +165,7 @@ static void put_audio_specific_config(AVCodecContext *avctx)
|
|||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
AACEncContext *s = avctx->priv_data;
|
AACEncContext *s = avctx->priv_data;
|
||||||
|
|
||||||
init_put_bits(&pb, avctx->extradata, avctx->extradata_size*8);
|
init_put_bits(&pb, avctx->extradata, avctx->extradata_size);
|
||||||
put_bits(&pb, 5, 2); //object type - AAC-LC
|
put_bits(&pb, 5, 2); //object type - AAC-LC
|
||||||
put_bits(&pb, 4, s->samplerate_index); //sample rate index
|
put_bits(&pb, 4, s->samplerate_index); //sample rate index
|
||||||
put_bits(&pb, 4, s->channels);
|
put_bits(&pb, 4, s->channels);
|
||||||
|
@@ -727,7 +727,10 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
|
|||||||
if (active_lines > 0.0f)
|
if (active_lines > 0.0f)
|
||||||
band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction);
|
band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction);
|
||||||
pe += calc_pe_3gpp(band);
|
pe += calc_pe_3gpp(band);
|
||||||
|
if (band->thr > 0.0f)
|
||||||
band->norm_fac = band->active_lines / band->thr;
|
band->norm_fac = band->active_lines / band->thr;
|
||||||
|
else
|
||||||
|
band->norm_fac = 0.0f;
|
||||||
norm_fac += band->norm_fac;
|
norm_fac += band->norm_fac;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -137,7 +137,7 @@ static int aasc_decode_frame(AVCodecContext *avctx,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* report that the buffer was completely consumed */
|
/* report that the buffer was completely consumed */
|
||||||
return buf_size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int aasc_decode_end(AVCodecContext *avctx)
|
static av_cold int aasc_decode_end(AVCodecContext *avctx)
|
||||||
|
@@ -131,6 +131,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
|
|||||||
int band_start, band_end, begin, end1;
|
int band_start, band_end, begin, end1;
|
||||||
int lowcomp, fastleak, slowleak;
|
int lowcomp, fastleak, slowleak;
|
||||||
|
|
||||||
|
if (end <= 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* excitation function */
|
/* excitation function */
|
||||||
band_start = ff_ac3_bin_to_band_tab[start];
|
band_start = ff_ac3_bin_to_band_tab[start];
|
||||||
band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
|
band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
|
||||||
|
@@ -147,7 +147,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
|
|||||||
int err;
|
int err;
|
||||||
union {
|
union {
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
uint8_t u8[8];
|
uint8_t u8[8 + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||||
} tmp = { av_be2ne64(state) };
|
} tmp = { av_be2ne64(state) };
|
||||||
AC3HeaderInfo hdr;
|
AC3HeaderInfo hdr;
|
||||||
GetBitContext gbc;
|
GetBitContext gbc;
|
||||||
|
@@ -488,6 +488,10 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma
|
|||||||
break;
|
break;
|
||||||
default: /* 6 to 15 */
|
default: /* 6 to 15 */
|
||||||
/* Shift mantissa and sign-extend it. */
|
/* Shift mantissa and sign-extend it. */
|
||||||
|
if (bap > 15) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "bap %d is invalid in plain AC-3\n", bap);
|
||||||
|
bap = 15;
|
||||||
|
}
|
||||||
mantissa = get_sbits(gbc, quantization_tab[bap]);
|
mantissa = get_sbits(gbc, quantization_tab[bap]);
|
||||||
mantissa <<= 24 - quantization_tab[bap];
|
mantissa <<= 24 - quantization_tab[bap];
|
||||||
break;
|
break;
|
||||||
|
@@ -260,7 +260,7 @@ static void apply_channel_coupling(AC3EncodeContext *s)
|
|||||||
energy_cpl = energy[blk][CPL_CH][bnd];
|
energy_cpl = energy[blk][CPL_CH][bnd];
|
||||||
energy_ch = energy[blk][ch][bnd];
|
energy_ch = energy[blk][ch][bnd];
|
||||||
blk1 = blk+1;
|
blk1 = blk+1;
|
||||||
while (!s->blocks[blk1].new_cpl_coords[ch] && blk1 < s->num_blocks) {
|
while (blk1 < s->num_blocks && !s->blocks[blk1].new_cpl_coords[ch]) {
|
||||||
if (s->blocks[blk1].cpl_in_use) {
|
if (s->blocks[blk1].cpl_in_use) {
|
||||||
energy_cpl += energy[blk1][CPL_CH][bnd];
|
energy_cpl += energy[blk1][CPL_CH][bnd];
|
||||||
energy_ch += energy[blk1][ch][bnd];
|
energy_ch += energy[blk1][ch][bnd];
|
||||||
|
@@ -471,9 +471,11 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_
|
|||||||
* @param[out] coded_samples set to the number of samples as coded in the
|
* @param[out] coded_samples set to the number of samples as coded in the
|
||||||
* packet, or 0 if the codec does not encode the
|
* packet, or 0 if the codec does not encode the
|
||||||
* number of samples in each frame.
|
* number of samples in each frame.
|
||||||
|
* @param[out] approx_nb_samples set to non-zero if the number of samples
|
||||||
|
* returned is an approximation.
|
||||||
*/
|
*/
|
||||||
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
||||||
int buf_size, int *coded_samples)
|
int buf_size, int *coded_samples, int *approx_nb_samples)
|
||||||
{
|
{
|
||||||
ADPCMDecodeContext *s = avctx->priv_data;
|
ADPCMDecodeContext *s = avctx->priv_data;
|
||||||
int nb_samples = 0;
|
int nb_samples = 0;
|
||||||
@@ -482,6 +484,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
|||||||
int header_size;
|
int header_size;
|
||||||
|
|
||||||
*coded_samples = 0;
|
*coded_samples = 0;
|
||||||
|
*approx_nb_samples = 0;
|
||||||
|
|
||||||
if(ch <= 0)
|
if(ch <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -552,10 +555,12 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
|
|||||||
case AV_CODEC_ID_ADPCM_EA_R2:
|
case AV_CODEC_ID_ADPCM_EA_R2:
|
||||||
header_size = 4 + 5 * ch;
|
header_size = 4 + 5 * ch;
|
||||||
*coded_samples = bytestream2_get_le32(gb);
|
*coded_samples = bytestream2_get_le32(gb);
|
||||||
|
*approx_nb_samples = 1;
|
||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_ADPCM_EA_R3:
|
case AV_CODEC_ID_ADPCM_EA_R3:
|
||||||
header_size = 4 + 5 * ch;
|
header_size = 4 + 5 * ch;
|
||||||
*coded_samples = bytestream2_get_be32(gb);
|
*coded_samples = bytestream2_get_be32(gb);
|
||||||
|
*approx_nb_samples = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*coded_samples -= *coded_samples % 28;
|
*coded_samples -= *coded_samples % 28;
|
||||||
@@ -663,11 +668,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
int16_t **samples_p;
|
int16_t **samples_p;
|
||||||
int st; /* stereo */
|
int st; /* stereo */
|
||||||
int count1, count2;
|
int count1, count2;
|
||||||
int nb_samples, coded_samples, ret;
|
int nb_samples, coded_samples, approx_nb_samples, ret;
|
||||||
GetByteContext gb;
|
GetByteContext gb;
|
||||||
|
|
||||||
bytestream2_init(&gb, buf, buf_size);
|
bytestream2_init(&gb, buf, buf_size);
|
||||||
nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples);
|
nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples, &approx_nb_samples);
|
||||||
if (nb_samples <= 0) {
|
if (nb_samples <= 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
|
av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@@ -683,7 +688,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
/* use coded_samples when applicable */
|
/* use coded_samples when applicable */
|
||||||
/* it is always <= nb_samples, so the output buffer will be large enough */
|
/* it is always <= nb_samples, so the output buffer will be large enough */
|
||||||
if (coded_samples) {
|
if (coded_samples) {
|
||||||
if (coded_samples != nb_samples)
|
if (!approx_nb_samples && coded_samples != nb_samples)
|
||||||
av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
|
av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
|
||||||
frame->nb_samples = nb_samples = coded_samples;
|
frame->nb_samples = nb_samples = coded_samples;
|
||||||
}
|
}
|
||||||
@@ -917,6 +922,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
*samples++ = c->status[0].predictor + c->status[1].predictor;
|
*samples++ = c->status[0].predictor + c->status[1].predictor;
|
||||||
*samples++ = c->status[0].predictor - c->status[1].predictor;
|
*samples++ = c->status[0].predictor - c->status[1].predictor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((bytestream2_tell(&gb) & 1))
|
||||||
|
bytestream2_skip(&gb, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AV_CODEC_ID_ADPCM_IMA_ISS:
|
case AV_CODEC_ID_ADPCM_IMA_ISS:
|
||||||
|
@@ -541,7 +541,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
case AV_CODEC_ID_ADPCM_IMA_QT:
|
case AV_CODEC_ID_ADPCM_IMA_QT:
|
||||||
{
|
{
|
||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
init_put_bits(&pb, dst, pkt_size * 8);
|
init_put_bits(&pb, dst, pkt_size);
|
||||||
|
|
||||||
for (ch = 0; ch < avctx->channels; ch++) {
|
for (ch = 0; ch < avctx->channels; ch++) {
|
||||||
ADPCMChannelStatus *status = &c->status[ch];
|
ADPCMChannelStatus *status = &c->status[ch];
|
||||||
@@ -549,10 +549,11 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
put_bits(&pb, 7, status->step_index);
|
put_bits(&pb, 7, status->step_index);
|
||||||
if (avctx->trellis > 0) {
|
if (avctx->trellis > 0) {
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
adpcm_compress_trellis(avctx, &samples_p[ch][1], buf, status,
|
adpcm_compress_trellis(avctx, &samples_p[ch][0], buf, status,
|
||||||
64, 1);
|
64, 1);
|
||||||
for (i = 0; i < 64; i++)
|
for (i = 0; i < 64; i++)
|
||||||
put_bits(&pb, 4, buf[i ^ 1]);
|
put_bits(&pb, 4, buf[i ^ 1]);
|
||||||
|
status->prev_sample = status->predictor;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 64; i += 2) {
|
for (i = 0; i < 64; i += 2) {
|
||||||
int t1, t2;
|
int t1, t2;
|
||||||
@@ -570,7 +571,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
case AV_CODEC_ID_ADPCM_SWF:
|
case AV_CODEC_ID_ADPCM_SWF:
|
||||||
{
|
{
|
||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
init_put_bits(&pb, dst, pkt_size * 8);
|
init_put_bits(&pb, dst, pkt_size);
|
||||||
|
|
||||||
n = frame->nb_samples - 1;
|
n = frame->nb_samples - 1;
|
||||||
|
|
||||||
|
@@ -150,6 +150,7 @@ typedef struct AICContext {
|
|||||||
int16_t *data_ptr[NUM_BANDS];
|
int16_t *data_ptr[NUM_BANDS];
|
||||||
|
|
||||||
DECLARE_ALIGNED(16, int16_t, block)[64];
|
DECLARE_ALIGNED(16, int16_t, block)[64];
|
||||||
|
DECLARE_ALIGNED(16, uint8_t, quant_matrix)[64];
|
||||||
} AICContext;
|
} AICContext;
|
||||||
|
|
||||||
static int aic_decode_header(AICContext *ctx, const uint8_t *src, int size)
|
static int aic_decode_header(AICContext *ctx, const uint8_t *src, int size)
|
||||||
@@ -285,7 +286,7 @@ static void recombine_block_il(int16_t *dst, const uint8_t *scan,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unquant_block(int16_t *block, int q)
|
static void unquant_block(int16_t *block, int q, uint8_t *quant_matrix)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -293,7 +294,7 @@ static void unquant_block(int16_t *block, int q)
|
|||||||
int val = (uint16_t)block[i];
|
int val = (uint16_t)block[i];
|
||||||
int sign = val & 1;
|
int sign = val & 1;
|
||||||
|
|
||||||
block[i] = (((val >> 1) ^ -sign) * q * aic_quant_matrix[i] >> 4)
|
block[i] = (((val >> 1) ^ -sign) * q * quant_matrix[i] >> 4)
|
||||||
+ sign;
|
+ sign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,7 +335,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
|
|||||||
else
|
else
|
||||||
recombine_block_il(ctx->block, ctx->scantable.permutated,
|
recombine_block_il(ctx->block, ctx->scantable.permutated,
|
||||||
&base_y, &ext_y, blk);
|
&base_y, &ext_y, blk);
|
||||||
unquant_block(ctx->block, ctx->quant);
|
unquant_block(ctx->block, ctx->quant, ctx->quant_matrix);
|
||||||
ctx->dsp.idct(ctx->block);
|
ctx->dsp.idct(ctx->block);
|
||||||
|
|
||||||
if (!ctx->interlaced) {
|
if (!ctx->interlaced) {
|
||||||
@@ -352,7 +353,7 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y,
|
|||||||
for (blk = 0; blk < 2; blk++) {
|
for (blk = 0; blk < 2; blk++) {
|
||||||
recombine_block(ctx->block, ctx->scantable.permutated,
|
recombine_block(ctx->block, ctx->scantable.permutated,
|
||||||
&base_c, &ext_c);
|
&base_c, &ext_c);
|
||||||
unquant_block(ctx->block, ctx->quant);
|
unquant_block(ctx->block, ctx->quant, ctx->quant_matrix);
|
||||||
ctx->dsp.idct(ctx->block);
|
ctx->dsp.idct(ctx->block);
|
||||||
ctx->dsp.put_signed_pixels_clamped(ctx->block, C[blk],
|
ctx->dsp.put_signed_pixels_clamped(ctx->block, C[blk],
|
||||||
ctx->frame->linesize[blk + 1]);
|
ctx->frame->linesize[blk + 1]);
|
||||||
@@ -430,12 +431,14 @@ static av_cold int aic_decode_init(AVCodecContext *avctx)
|
|||||||
for (i = 0; i < 64; i++)
|
for (i = 0; i < 64; i++)
|
||||||
scan[i] = i;
|
scan[i] = i;
|
||||||
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, scan);
|
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, scan);
|
||||||
|
for (i = 0; i < 64; i++)
|
||||||
|
ctx->quant_matrix[ctx->dsp.idct_permutation[i]] = aic_quant_matrix[i];
|
||||||
|
|
||||||
ctx->mb_width = FFALIGN(avctx->width, 16) >> 4;
|
ctx->mb_width = FFALIGN(avctx->width, 16) >> 4;
|
||||||
ctx->mb_height = FFALIGN(avctx->height, 16) >> 4;
|
ctx->mb_height = FFALIGN(avctx->height, 16) >> 4;
|
||||||
|
|
||||||
ctx->num_x_slices = 16;
|
ctx->num_x_slices = (ctx->mb_width + 15) >> 4;
|
||||||
ctx->slice_width = ctx->mb_width / 16;
|
ctx->slice_width = 16;
|
||||||
for (i = 1; i < 32; i++) {
|
for (i = 1; i < 32; i++) {
|
||||||
if (!(ctx->mb_width % i) && (ctx->mb_width / i < 32)) {
|
if (!(ctx->mb_width % i) && (ctx->mb_width / i < 32)) {
|
||||||
ctx->slice_width = ctx->mb_width / i;
|
ctx->slice_width = ctx->mb_width / i;
|
||||||
|
@@ -311,6 +311,11 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
|
|||||||
int lpc_quant[2];
|
int lpc_quant[2];
|
||||||
int rice_history_mult[2];
|
int rice_history_mult[2];
|
||||||
|
|
||||||
|
if (!alac->rice_limit) {
|
||||||
|
avpriv_request_sample(alac->avctx, "Compression with rice limit 0");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
|
||||||
decorr_shift = get_bits(&alac->gb, 8);
|
decorr_shift = get_bits(&alac->gb, 8);
|
||||||
decorr_left_weight = get_bits(&alac->gb, 8);
|
decorr_left_weight = get_bits(&alac->gb, 8);
|
||||||
|
|
||||||
@@ -490,6 +495,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
avpkt->size * 8 - get_bits_count(&alac->gb));
|
avpkt->size * 8 - get_bits_count(&alac->gb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alac->channels == ch)
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
|
|
||||||
return avpkt->size;
|
return avpkt->size;
|
||||||
|
@@ -280,7 +280,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
uint64_t ht_size;
|
uint64_t ht_size;
|
||||||
int i, config_offset;
|
int i, config_offset;
|
||||||
MPEG4AudioConfig m4ac;
|
MPEG4AudioConfig m4ac = {0};
|
||||||
ALSSpecificConfig *sconf = &ctx->sconf;
|
ALSSpecificConfig *sconf = &ctx->sconf;
|
||||||
AVCodecContext *avctx = ctx->avctx;
|
AVCodecContext *avctx = ctx->avctx;
|
||||||
uint32_t als_id, header_size, trailer_size;
|
uint32_t als_id, header_size, trailer_size;
|
||||||
@@ -355,11 +355,15 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
|
|||||||
|
|
||||||
ctx->cs_switch = 1;
|
ctx->cs_switch = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < avctx->channels; i++) {
|
||||||
|
sconf->chan_pos[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < avctx->channels; i++) {
|
for (i = 0; i < avctx->channels; i++) {
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
idx = get_bits(&gb, chan_pos_bits);
|
idx = get_bits(&gb, chan_pos_bits);
|
||||||
if (idx >= avctx->channels) {
|
if (idx >= avctx->channels || sconf->chan_pos[idx] != -1) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n");
|
av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n");
|
||||||
ctx->cs_switch = 0;
|
ctx->cs_switch = 0;
|
||||||
break;
|
break;
|
||||||
@@ -676,7 +680,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
|||||||
|
|
||||||
|
|
||||||
if (!sconf->rlslms) {
|
if (!sconf->rlslms) {
|
||||||
if (sconf->adapt_order) {
|
if (sconf->adapt_order && sconf->max_order) {
|
||||||
int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
|
int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
|
||||||
2, sconf->max_order + 1));
|
2, sconf->max_order + 1));
|
||||||
*bd->opt_order = get_bits(gb, opt_order_length);
|
*bd->opt_order = get_bits(gb, opt_order_length);
|
||||||
@@ -688,7 +692,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
|||||||
} else {
|
} else {
|
||||||
*bd->opt_order = sconf->max_order;
|
*bd->opt_order = sconf->max_order;
|
||||||
}
|
}
|
||||||
|
if (*bd->opt_order > bd->block_length) {
|
||||||
|
*bd->opt_order = bd->block_length;
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Predictor order too large.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
opt_order = *bd->opt_order;
|
opt_order = *bd->opt_order;
|
||||||
|
|
||||||
if (opt_order) {
|
if (opt_order) {
|
||||||
@@ -1234,6 +1242,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
|||||||
ALSChannelData *ch = cd[c];
|
ALSChannelData *ch = cd[c];
|
||||||
unsigned int dep = 0;
|
unsigned int dep = 0;
|
||||||
unsigned int channels = ctx->avctx->channels;
|
unsigned int channels = ctx->avctx->channels;
|
||||||
|
unsigned int channel_size = ctx->sconf.frame_length + ctx->sconf.max_order;
|
||||||
|
|
||||||
if (reverted[c])
|
if (reverted[c])
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1265,9 +1274,9 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
|||||||
|
|
||||||
dep = 0;
|
dep = 0;
|
||||||
while (!ch[dep].stop_flag) {
|
while (!ch[dep].stop_flag) {
|
||||||
unsigned int smp;
|
ptrdiff_t smp;
|
||||||
unsigned int begin = 1;
|
ptrdiff_t begin = 1;
|
||||||
unsigned int end = bd->block_length - 1;
|
ptrdiff_t end = bd->block_length - 1;
|
||||||
int64_t y;
|
int64_t y;
|
||||||
int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;
|
int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;
|
||||||
|
|
||||||
@@ -1276,11 +1285,28 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
|||||||
|
|
||||||
if (ch[dep].time_diff_sign) {
|
if (ch[dep].time_diff_sign) {
|
||||||
t = -t;
|
t = -t;
|
||||||
|
if (begin < t) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR, "begin %td smaller than time diff index %d.\n", begin, t);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
begin -= t;
|
begin -= t;
|
||||||
} else {
|
} else {
|
||||||
|
if (end < t) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR, "end %td smaller than time diff index %d.\n", end, t);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
end -= t;
|
end -= t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FFMIN(begin - 1, begin - 1 + t) < ctx->raw_buffer - master ||
|
||||||
|
FFMAX(end + 1, end + 1 + t) > ctx->raw_buffer + channels * channel_size - master) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR,
|
||||||
|
"sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
|
||||||
|
master + FFMIN(begin - 1, begin - 1 + t), master + FFMAX(end + 1, end + 1 + t),
|
||||||
|
ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
for (smp = begin; smp < end; smp++) {
|
for (smp = begin; smp < end; smp++) {
|
||||||
y = (1 << 6) +
|
y = (1 << 6) +
|
||||||
MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
|
MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
|
||||||
@@ -1293,6 +1319,16 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
|
|||||||
bd->raw_samples[smp] += y >> 7;
|
bd->raw_samples[smp] += y >> 7;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (begin - 1 < ctx->raw_buffer - master ||
|
||||||
|
end + 1 > ctx->raw_buffer + channels * channel_size - master) {
|
||||||
|
av_log(ctx->avctx, AV_LOG_ERROR,
|
||||||
|
"sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
|
||||||
|
master + begin - 1, master + end + 1,
|
||||||
|
ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
for (smp = begin; smp < end; smp++) {
|
for (smp = begin; smp < end; smp++) {
|
||||||
y = (1 << 6) +
|
y = (1 << 6) +
|
||||||
MUL64(ch[dep].weighting[0], master[smp - 1]) +
|
MUL64(ch[dep].weighting[0], master[smp - 1]) +
|
||||||
@@ -1711,9 +1747,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
// allocate and assign channel data buffer for mcc mode
|
// allocate and assign channel data buffer for mcc mode
|
||||||
if (sconf->mc_coding) {
|
if (sconf->mc_coding) {
|
||||||
ctx->chan_data_buffer = av_malloc(sizeof(*ctx->chan_data_buffer) *
|
ctx->chan_data_buffer = av_mallocz(sizeof(*ctx->chan_data_buffer) *
|
||||||
num_buffers * num_buffers);
|
num_buffers * num_buffers);
|
||||||
ctx->chan_data = av_malloc(sizeof(*ctx->chan_data) *
|
ctx->chan_data = av_mallocz(sizeof(*ctx->chan_data) *
|
||||||
num_buffers);
|
num_buffers);
|
||||||
ctx->reverted_channels = av_malloc(sizeof(*ctx->reverted_channels) *
|
ctx->reverted_channels = av_malloc(sizeof(*ctx->reverted_channels) *
|
||||||
num_buffers);
|
num_buffers);
|
||||||
|
@@ -417,7 +417,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 ';':
|
||||||
|
@@ -598,15 +598,19 @@ static void decode_array_0000(APEContext *ctx, GetBitContext *gb,
|
|||||||
int ksummax, ksummin;
|
int ksummax, ksummin;
|
||||||
|
|
||||||
rice->ksum = 0;
|
rice->ksum = 0;
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < FFMIN(blockstodecode, 5); i++) {
|
||||||
out[i] = get_rice_ook(&ctx->gb, 10);
|
out[i] = get_rice_ook(&ctx->gb, 10);
|
||||||
rice->ksum += out[i];
|
rice->ksum += out[i];
|
||||||
}
|
}
|
||||||
rice->k = av_log2(rice->ksum / 10) + 1;
|
rice->k = av_log2(rice->ksum / 10) + 1;
|
||||||
for (; i < 64; i++) {
|
if (rice->k >= 24)
|
||||||
|
return;
|
||||||
|
for (; i < FFMIN(blockstodecode, 64); i++) {
|
||||||
out[i] = get_rice_ook(&ctx->gb, rice->k);
|
out[i] = get_rice_ook(&ctx->gb, rice->k);
|
||||||
rice->ksum += out[i];
|
rice->ksum += out[i];
|
||||||
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
|
rice->k = av_log2(rice->ksum / ((i + 1) * 2)) + 1;
|
||||||
|
if (rice->k >= 24)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
ksummax = 1 << rice->k + 7;
|
ksummax = 1 << rice->k + 7;
|
||||||
ksummin = rice->k ? (1 << rice->k + 6) : 0;
|
ksummin = rice->k ? (1 << rice->k + 6) : 0;
|
||||||
@@ -1467,13 +1471,13 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
|
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
s->samples = nblocks;
|
|
||||||
|
|
||||||
/* Initialize the frame decoder */
|
/* Initialize the frame decoder */
|
||||||
if (init_frame_decoder(s) < 0) {
|
if (init_frame_decoder(s) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
|
av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
s->samples = nblocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->data) {
|
if (!s->data) {
|
||||||
|
@@ -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]
|
||||||
|
@@ -89,6 +89,5 @@ av_cold void ff_asv_common_init(AVCodecContext *avctx) {
|
|||||||
a->mb_width2 = (avctx->width + 0) / 16;
|
a->mb_width2 = (avctx->width + 0) / 16;
|
||||||
a->mb_height2 = (avctx->height + 0) / 16;
|
a->mb_height2 = (avctx->height + 0) / 16;
|
||||||
|
|
||||||
avctx->coded_frame= &a->picture;
|
|
||||||
a->avctx= avctx;
|
a->avctx= avctx;
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,6 @@
|
|||||||
typedef struct ASV1Context{
|
typedef struct ASV1Context{
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
DSPContext dsp;
|
DSPContext dsp;
|
||||||
AVFrame picture;
|
|
||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
ScanTable scantable;
|
ScanTable scantable;
|
||||||
|
@@ -148,14 +148,16 @@ static inline int encode_mb(ASV1Context *a, int16_t block[6][64]){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){
|
static inline void dct_get(ASV1Context *a, const AVFrame *frame,
|
||||||
|
int mb_x, int mb_y)
|
||||||
|
{
|
||||||
int16_t (*block)[64]= a->block;
|
int16_t (*block)[64]= a->block;
|
||||||
int linesize= a->picture.linesize[0];
|
int linesize = frame->linesize[0];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
uint8_t *ptr_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16;
|
uint8_t *ptr_y = frame->data[0] + (mb_y * 16* linesize ) + mb_x * 16;
|
||||||
uint8_t *ptr_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8;
|
uint8_t *ptr_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;
|
||||||
uint8_t *ptr_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8;
|
uint8_t *ptr_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;
|
||||||
|
|
||||||
a->dsp.get_pixels(block[0], ptr_y , linesize);
|
a->dsp.get_pixels(block[0], ptr_y , linesize);
|
||||||
a->dsp.get_pixels(block[1], ptr_y + 8, linesize);
|
a->dsp.get_pixels(block[1], ptr_y + 8, linesize);
|
||||||
@@ -165,8 +167,8 @@ static inline void dct_get(ASV1Context *a, int mb_x, int mb_y){
|
|||||||
a->dsp.fdct(block[i]);
|
a->dsp.fdct(block[i]);
|
||||||
|
|
||||||
if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
|
if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
|
||||||
a->dsp.get_pixels(block[4], ptr_cb, a->picture.linesize[1]);
|
a->dsp.get_pixels(block[4], ptr_cb, frame->linesize[1]);
|
||||||
a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]);
|
a->dsp.get_pixels(block[5], ptr_cr, frame->linesize[2]);
|
||||||
for(i=4; i<6; i++)
|
for(i=4; i<6; i++)
|
||||||
a->dsp.fdct(block[i]);
|
a->dsp.fdct(block[i]);
|
||||||
}
|
}
|
||||||
@@ -176,7 +178,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
const AVFrame *pict, int *got_packet)
|
const AVFrame *pict, int *got_packet)
|
||||||
{
|
{
|
||||||
ASV1Context * const a = avctx->priv_data;
|
ASV1Context * const a = avctx->priv_data;
|
||||||
AVFrame * const p= &a->picture;
|
|
||||||
int size, ret;
|
int size, ret;
|
||||||
int mb_x, mb_y;
|
int mb_x, mb_y;
|
||||||
|
|
||||||
@@ -186,13 +187,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
init_put_bits(&a->pb, pkt->data, pkt->size);
|
init_put_bits(&a->pb, pkt->data, pkt->size);
|
||||||
|
|
||||||
*p = *pict;
|
|
||||||
p->pict_type= AV_PICTURE_TYPE_I;
|
|
||||||
p->key_frame= 1;
|
|
||||||
|
|
||||||
for(mb_y=0; mb_y<a->mb_height2; mb_y++){
|
for(mb_y=0; mb_y<a->mb_height2; mb_y++){
|
||||||
for(mb_x=0; mb_x<a->mb_width2; mb_x++){
|
for(mb_x=0; mb_x<a->mb_width2; mb_x++){
|
||||||
dct_get(a, mb_x, mb_y);
|
dct_get(a, pict, mb_x, mb_y);
|
||||||
encode_mb(a, a->block);
|
encode_mb(a, a->block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +197,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
if(a->mb_width2 != a->mb_width){
|
if(a->mb_width2 != a->mb_width){
|
||||||
mb_x= a->mb_width2;
|
mb_x= a->mb_width2;
|
||||||
for(mb_y=0; mb_y<a->mb_height2; mb_y++){
|
for(mb_y=0; mb_y<a->mb_height2; mb_y++){
|
||||||
dct_get(a, mb_x, mb_y);
|
dct_get(a, pict, mb_x, mb_y);
|
||||||
encode_mb(a, a->block);
|
encode_mb(a, a->block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,7 +205,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
if(a->mb_height2 != a->mb_height){
|
if(a->mb_height2 != a->mb_height){
|
||||||
mb_y= a->mb_height2;
|
mb_y= a->mb_height2;
|
||||||
for(mb_x=0; mb_x<a->mb_width; mb_x++){
|
for(mb_x=0; mb_x<a->mb_width; mb_x++){
|
||||||
dct_get(a, mb_x, mb_y);
|
dct_get(a, pict, mb_x, mb_y);
|
||||||
encode_mb(a, a->block);
|
encode_mb(a, a->block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,6 +237,12 @@ static av_cold int encode_init(AVCodecContext *avctx){
|
|||||||
int i;
|
int i;
|
||||||
const int scale= avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
|
const int scale= avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
|
||||||
|
|
||||||
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
avctx->coded_frame->key_frame = 1;
|
||||||
|
|
||||||
ff_asv_common_init(avctx);
|
ff_asv_common_init(avctx);
|
||||||
|
|
||||||
if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
|
if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
|
||||||
|
@@ -380,7 +380,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
int av_packet_split_side_data(AVPacket *pkt){
|
int av_packet_split_side_data(AVPacket *pkt){
|
||||||
if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
|
if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
|
||||||
int i;
|
int i;
|
||||||
unsigned int size, orig_pktsize = pkt->size;
|
unsigned int size;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
|
||||||
p = pkt->data + pkt->size - 8 - 5;
|
p = pkt->data + pkt->size - 8 - 5;
|
||||||
@@ -413,13 +413,6 @@ int av_packet_split_side_data(AVPacket *pkt){
|
|||||||
p-= size+5;
|
p-= size+5;
|
||||||
}
|
}
|
||||||
pkt->size -= 8;
|
pkt->size -= 8;
|
||||||
/* FFMIN() prevents overflow in case the packet wasn't allocated with
|
|
||||||
* proper padding.
|
|
||||||
* If the side data is smaller than the buffer padding size, the
|
|
||||||
* remaining bytes should have already been filled with zeros by the
|
|
||||||
* original packet allocation anyway. */
|
|
||||||
memset(pkt->data + pkt->size, 0,
|
|
||||||
FFMIN(orig_pktsize - pkt->size, FF_INPUT_BUFFER_PADDING_SIZE));
|
|
||||||
pkt->side_data_elems = i+1;
|
pkt->side_data_elems = i+1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVFrame picture;
|
AVFrame *frame;
|
||||||
} AvsContext;
|
} AvsContext;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -52,7 +52,7 @@ avs_decode_frame(AVCodecContext * avctx,
|
|||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
AvsContext *const avs = avctx->priv_data;
|
AvsContext *const avs = avctx->priv_data;
|
||||||
AVFrame *picture = data;
|
AVFrame *picture = data;
|
||||||
AVFrame *const p = &avs->picture;
|
AVFrame *const p = avs->frame;
|
||||||
const uint8_t *table, *vect;
|
const uint8_t *table, *vect;
|
||||||
uint8_t *out;
|
uint8_t *out;
|
||||||
int i, j, x, y, stride, ret, vect_w = 3, vect_h = 3;
|
int i, j, x, y, stride, ret, vect_w = 3, vect_h = 3;
|
||||||
@@ -65,8 +65,8 @@ avs_decode_frame(AVCodecContext * avctx,
|
|||||||
p->pict_type = AV_PICTURE_TYPE_P;
|
p->pict_type = AV_PICTURE_TYPE_P;
|
||||||
p->key_frame = 0;
|
p->key_frame = 0;
|
||||||
|
|
||||||
out = avs->picture.data[0];
|
out = p->data[0];
|
||||||
stride = avs->picture.linesize[0];
|
stride = p->linesize[0];
|
||||||
|
|
||||||
if (buf_end - buf < 4)
|
if (buf_end - buf < 4)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@@ -76,7 +76,7 @@ avs_decode_frame(AVCodecContext * avctx,
|
|||||||
|
|
||||||
if (type == AVS_PALETTE) {
|
if (type == AVS_PALETTE) {
|
||||||
int first, last;
|
int first, last;
|
||||||
uint32_t *pal = (uint32_t *) avs->picture.data[1];
|
uint32_t *pal = (uint32_t *) p->data[1];
|
||||||
|
|
||||||
first = AV_RL16(buf);
|
first = AV_RL16(buf);
|
||||||
last = first + AV_RL16(buf + 2);
|
last = first + AV_RL16(buf + 2);
|
||||||
@@ -149,7 +149,7 @@ avs_decode_frame(AVCodecContext * avctx,
|
|||||||
align_get_bits(&change_map);
|
align_get_bits(&change_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = av_frame_ref(picture, &avs->picture)) < 0)
|
if ((ret = av_frame_ref(picture, p)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
|
|
||||||
@@ -159,16 +159,21 @@ avs_decode_frame(AVCodecContext * avctx,
|
|||||||
static av_cold int avs_decode_init(AVCodecContext * avctx)
|
static av_cold int avs_decode_init(AVCodecContext * avctx)
|
||||||
{
|
{
|
||||||
AvsContext *s = avctx->priv_data;
|
AvsContext *s = avctx->priv_data;
|
||||||
|
|
||||||
|
s->frame = av_frame_alloc();
|
||||||
|
if (!s->frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
avcodec_set_dimensions(avctx, 318, 198);
|
avcodec_set_dimensions(avctx, 318, 198);
|
||||||
avcodec_get_frame_defaults(&s->picture);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int avs_decode_end(AVCodecContext *avctx)
|
static av_cold int avs_decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
AvsContext *s = avctx->priv_data;
|
AvsContext *s = avctx->priv_data;
|
||||||
av_frame_unref(&s->picture);
|
av_frame_free(&s->frame);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,21 +34,25 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct BethsoftvidContext {
|
typedef struct BethsoftvidContext {
|
||||||
AVFrame frame;
|
AVFrame *frame;
|
||||||
GetByteContext g;
|
GetByteContext g;
|
||||||
} BethsoftvidContext;
|
} BethsoftvidContext;
|
||||||
|
|
||||||
static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx)
|
static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
BethsoftvidContext *vid = avctx->priv_data;
|
BethsoftvidContext *vid = avctx->priv_data;
|
||||||
avcodec_get_frame_defaults(&vid->frame);
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
|
|
||||||
|
vid->frame = av_frame_alloc();
|
||||||
|
if (!vid->frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_palette(BethsoftvidContext *ctx)
|
static int set_palette(BethsoftvidContext *ctx)
|
||||||
{
|
{
|
||||||
uint32_t *palette = (uint32_t *)ctx->frame.data[1];
|
uint32_t *palette = (uint32_t *)ctx->frame->data[1];
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
if (bytestream2_get_bytes_left(&ctx->g) < 256*3)
|
if (bytestream2_get_bytes_left(&ctx->g) < 256*3)
|
||||||
@@ -58,7 +62,7 @@ static int set_palette(BethsoftvidContext *ctx)
|
|||||||
palette[a] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->g) * 4;
|
palette[a] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->g) * 4;
|
||||||
palette[a] |= palette[a] >> 6 & 0x30303;
|
palette[a] |= palette[a] >> 6 & 0x30303;
|
||||||
}
|
}
|
||||||
ctx->frame.palette_has_changed = 1;
|
ctx->frame->palette_has_changed = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +79,9 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
|
|||||||
int code, ret;
|
int code, ret;
|
||||||
int yoffset;
|
int yoffset;
|
||||||
|
|
||||||
if ((ret = ff_reget_buffer(avctx, &vid->frame)) < 0)
|
if ((ret = ff_reget_buffer(avctx, vid->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
wrap_to_next_line = vid->frame.linesize[0] - avctx->width;
|
wrap_to_next_line = vid->frame->linesize[0] - avctx->width;
|
||||||
|
|
||||||
if (avpkt->side_data_elems > 0 &&
|
if (avpkt->side_data_elems > 0 &&
|
||||||
avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) {
|
avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) {
|
||||||
@@ -88,8 +92,8 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytestream2_init(&vid->g, avpkt->data, avpkt->size);
|
bytestream2_init(&vid->g, avpkt->data, avpkt->size);
|
||||||
dst = vid->frame.data[0];
|
dst = vid->frame->data[0];
|
||||||
frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height;
|
frame_end = vid->frame->data[0] + vid->frame->linesize[0] * avctx->height;
|
||||||
|
|
||||||
switch(block_type = bytestream2_get_byte(&vid->g)){
|
switch(block_type = bytestream2_get_byte(&vid->g)){
|
||||||
case PALETTE_BLOCK: {
|
case PALETTE_BLOCK: {
|
||||||
@@ -104,7 +108,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
|
|||||||
yoffset = bytestream2_get_le16(&vid->g);
|
yoffset = bytestream2_get_le16(&vid->g);
|
||||||
if(yoffset >= avctx->height)
|
if(yoffset >= avctx->height)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
dst += vid->frame.linesize[0] * yoffset;
|
dst += vid->frame->linesize[0] * yoffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// main code
|
// main code
|
||||||
@@ -134,7 +138,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
|
||||||
if ((ret = av_frame_ref(data, &vid->frame)) < 0)
|
if ((ret = av_frame_ref(data, vid->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@@ -145,7 +149,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
|
|||||||
static av_cold int bethsoftvid_decode_end(AVCodecContext *avctx)
|
static av_cold int bethsoftvid_decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
BethsoftvidContext * vid = avctx->priv_data;
|
BethsoftvidContext * vid = avctx->priv_data;
|
||||||
av_frame_unref(&vid->frame);
|
av_frame_free(&vid->frame);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -120,6 +120,7 @@ typedef struct BinkContext {
|
|||||||
int version; ///< internal Bink file version
|
int version; ///< internal Bink file version
|
||||||
int has_alpha;
|
int has_alpha;
|
||||||
int swap_planes;
|
int swap_planes;
|
||||||
|
unsigned frame_num;
|
||||||
|
|
||||||
Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types
|
Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types
|
||||||
Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type
|
Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type
|
||||||
@@ -1206,6 +1207,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
if (c->version >= 'i')
|
if (c->version >= 'i')
|
||||||
skip_bits_long(&gb, 32);
|
skip_bits_long(&gb, 32);
|
||||||
|
|
||||||
|
c->frame_num++;
|
||||||
|
|
||||||
for (plane = 0; plane < 3; plane++) {
|
for (plane = 0; plane < 3; plane++) {
|
||||||
plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
|
plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3);
|
||||||
|
|
||||||
@@ -1214,7 +1217,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if ((ret = binkb_decode_plane(c, frame, &gb, plane_idx,
|
if ((ret = binkb_decode_plane(c, frame, &gb, plane_idx,
|
||||||
!avctx->frame_number, !!plane)) < 0)
|
c->frame_num == 1, !!plane)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (get_bits_count(&gb) >= bits_count)
|
if (get_bits_count(&gb) >= bits_count)
|
||||||
@@ -1332,6 +1335,13 @@ static av_cold int decode_end(AVCodecContext *avctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void flush(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
BinkContext * const c = avctx->priv_data;
|
||||||
|
|
||||||
|
c->frame_num = 0;
|
||||||
|
}
|
||||||
|
|
||||||
AVCodec ff_bink_decoder = {
|
AVCodec ff_bink_decoder = {
|
||||||
.name = "binkvideo",
|
.name = "binkvideo",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Bink video"),
|
.long_name = NULL_IF_CONFIG_SMALL("Bink video"),
|
||||||
@@ -1341,5 +1351,6 @@ AVCodec ff_bink_decoder = {
|
|||||||
.init = decode_init,
|
.init = decode_init,
|
||||||
.close = decode_end,
|
.close = decode_end,
|
||||||
.decode = decode_frame,
|
.decode = decode_frame,
|
||||||
|
.flush = flush,
|
||||||
.capabilities = CODEC_CAP_DR1,
|
.capabilities = CODEC_CAP_DR1,
|
||||||
};
|
};
|
||||||
|
@@ -60,22 +60,26 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
const AVFrame *pict, int *got_packet)
|
const AVFrame *pict, int *got_packet)
|
||||||
{
|
{
|
||||||
|
const AVFrame * const p = pict;
|
||||||
int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret;
|
int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret;
|
||||||
const uint32_t *pal = NULL;
|
const uint32_t *pal = NULL;
|
||||||
uint32_t palette256[256];
|
uint32_t palette256[256];
|
||||||
int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
|
int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
|
||||||
int bit_count = avctx->bits_per_coded_sample;
|
int bit_count = avctx->bits_per_coded_sample;
|
||||||
uint8_t *ptr, *buf;
|
uint8_t *ptr, *buf;
|
||||||
AVFrame * const p = (AVFrame *)pict;
|
|
||||||
|
|
||||||
p->pict_type= AV_PICTURE_TYPE_I;
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
p->key_frame= 1;
|
avctx->coded_frame->key_frame = 1;
|
||||||
switch (avctx->pix_fmt) {
|
switch (avctx->pix_fmt) {
|
||||||
case AV_PIX_FMT_RGB444:
|
case AV_PIX_FMT_RGB444:
|
||||||
compression = BMP_BITFIELDS;
|
compression = BMP_BITFIELDS;
|
||||||
@@ -159,6 +163,12 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_cold int bmp_encode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
AVCodec ff_bmp_encoder = {
|
AVCodec ff_bmp_encoder = {
|
||||||
.name = "bmp",
|
.name = "bmp",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"),
|
.long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"),
|
||||||
@@ -166,6 +176,7 @@ AVCodec ff_bmp_encoder = {
|
|||||||
.id = AV_CODEC_ID_BMP,
|
.id = AV_CODEC_ID_BMP,
|
||||||
.init = bmp_encode_init,
|
.init = bmp_encode_init,
|
||||||
.encode2 = bmp_encode_frame,
|
.encode2 = bmp_encode_frame,
|
||||||
|
.close = bmp_encode_close,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]){
|
.pix_fmts = (const enum AVPixelFormat[]){
|
||||||
AV_PIX_FMT_BGRA, AV_PIX_FMT_BGR24,
|
AV_PIX_FMT_BGRA, AV_PIX_FMT_BGR24,
|
||||||
AV_PIX_FMT_RGB565, AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444,
|
AV_PIX_FMT_RGB565, AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444,
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVFrame pictures[2];
|
AVFrame *pictures[2];
|
||||||
int currentpic;
|
int currentpic;
|
||||||
} C93DecoderContext;
|
} C93DecoderContext;
|
||||||
|
|
||||||
@@ -46,21 +46,27 @@ typedef enum {
|
|||||||
#define C93_HAS_PALETTE 0x01
|
#define C93_HAS_PALETTE 0x01
|
||||||
#define C93_FIRST_FRAME 0x02
|
#define C93_FIRST_FRAME 0x02
|
||||||
|
|
||||||
static av_cold int decode_init(AVCodecContext *avctx)
|
|
||||||
{
|
|
||||||
C93DecoderContext *s = avctx->priv_data;
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
|
||||||
avcodec_get_frame_defaults(&s->pictures[0]);
|
|
||||||
avcodec_get_frame_defaults(&s->pictures[1]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_cold int decode_end(AVCodecContext *avctx)
|
static av_cold int decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
C93DecoderContext * const c93 = avctx->priv_data;
|
C93DecoderContext * const c93 = avctx->priv_data;
|
||||||
|
|
||||||
av_frame_unref(&c93->pictures[0]);
|
av_frame_free(&c93->pictures[0]);
|
||||||
av_frame_unref(&c93->pictures[1]);
|
av_frame_free(&c93->pictures[1]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_cold int decode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
C93DecoderContext *s = avctx->priv_data;
|
||||||
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
|
|
||||||
|
s->pictures[0] = av_frame_alloc();
|
||||||
|
s->pictures[1] = av_frame_alloc();
|
||||||
|
if (!s->pictures[0] || !s->pictures[1]) {
|
||||||
|
decode_end(avctx);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -121,8 +127,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
C93DecoderContext * const c93 = avctx->priv_data;
|
C93DecoderContext * const c93 = avctx->priv_data;
|
||||||
AVFrame * const newpic = &c93->pictures[c93->currentpic];
|
AVFrame * const newpic = c93->pictures[c93->currentpic];
|
||||||
AVFrame * const oldpic = &c93->pictures[c93->currentpic^1];
|
AVFrame * const oldpic = c93->pictures[c93->currentpic^1];
|
||||||
GetByteContext gb;
|
GetByteContext gb;
|
||||||
uint8_t *out;
|
uint8_t *out;
|
||||||
int stride, ret, i, x, y, b, bt = 0;
|
int stride, ret, i, x, y, b, bt = 0;
|
||||||
|
@@ -301,7 +301,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")
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,9 @@ static void refill(CABACContext *c){
|
|||||||
c->low+= c->bytestream[0]<<1;
|
c->low+= c->bytestream[0]<<1;
|
||||||
#endif
|
#endif
|
||||||
c->low -= CABAC_MASK;
|
c->low -= CABAC_MASK;
|
||||||
|
#if !UNCHECKED_BITSTREAM_READER
|
||||||
|
if (c->bytestream < c->bytestream_end)
|
||||||
|
#endif
|
||||||
c->bytestream += CABAC_BITS / 8;
|
c->bytestream += CABAC_BITS / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +79,9 @@ static void refill2(CABACContext *c){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
c->low += x<<i;
|
c->low += x<<i;
|
||||||
|
#if !UNCHECKED_BITSTREAM_READER
|
||||||
|
if (c->bytestream < c->bytestream_end)
|
||||||
|
#endif
|
||||||
c->bytestream += CABAC_BITS/8;
|
c->bytestream += CABAC_BITS/8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -214,6 +214,7 @@ typedef struct AVSContext {
|
|||||||
int luma_scan[4];
|
int luma_scan[4];
|
||||||
int qp;
|
int qp;
|
||||||
int qp_fixed;
|
int qp_fixed;
|
||||||
|
int pic_qp_fixed;
|
||||||
int cbp;
|
int cbp;
|
||||||
ScanTable scantable;
|
ScanTable scantable;
|
||||||
|
|
||||||
|
@@ -900,7 +900,7 @@ static inline int decode_slice_header(AVSContext *h, GetBitContext *gb)
|
|||||||
|
|
||||||
/* mark top macroblocks as unavailable */
|
/* mark top macroblocks as unavailable */
|
||||||
h->flags &= ~(B_AVAIL | C_AVAIL);
|
h->flags &= ~(B_AVAIL | C_AVAIL);
|
||||||
if ((h->mby == 0) && (!h->qp_fixed)) {
|
if (!h->pic_qp_fixed) {
|
||||||
h->qp_fixed = get_bits1(gb);
|
h->qp_fixed = get_bits1(gb);
|
||||||
h->qp = get_bits(gb, 6);
|
h->qp = get_bits(gb, 6);
|
||||||
}
|
}
|
||||||
@@ -1023,6 +1023,7 @@ static int decode_pic(AVSContext *h)
|
|||||||
skip_bits1(&h->gb); //advanced_pred_mode_disable
|
skip_bits1(&h->gb); //advanced_pred_mode_disable
|
||||||
skip_bits1(&h->gb); //top_field_first
|
skip_bits1(&h->gb); //top_field_first
|
||||||
skip_bits1(&h->gb); //repeat_first_field
|
skip_bits1(&h->gb); //repeat_first_field
|
||||||
|
h->pic_qp_fixed =
|
||||||
h->qp_fixed = get_bits1(&h->gb);
|
h->qp_fixed = get_bits1(&h->gb);
|
||||||
h->qp = get_bits(&h->gb, 6);
|
h->qp = get_bits(&h->gb, 6);
|
||||||
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
|
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {
|
||||||
|
@@ -353,10 +353,9 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
|||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
} else {
|
} else {
|
||||||
*got_frame = 0;
|
*got_frame = 0;
|
||||||
buf_size = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf_size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int cdg_decode_end(AVCodecContext *avctx)
|
static av_cold int cdg_decode_end(AVCodecContext *avctx)
|
||||||
|
@@ -135,7 +135,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip,
|
|||||||
const uint8_t *eod = (data + size);
|
const uint8_t *eod = (data + size);
|
||||||
uint32_t flag, mask;
|
uint32_t flag, mask;
|
||||||
uint8_t *cb0, *cb1, *cb2, *cb3;
|
uint8_t *cb0, *cb1, *cb2, *cb3;
|
||||||
unsigned int x, y;
|
int x, y;
|
||||||
char *ip0, *ip1, *ip2, *ip3;
|
char *ip0, *ip1, *ip2, *ip3;
|
||||||
|
|
||||||
flag = 0;
|
flag = 0;
|
||||||
|
@@ -99,16 +99,21 @@ AVCodec ff_cljr_decoder = {
|
|||||||
#if CONFIG_CLJR_ENCODER
|
#if CONFIG_CLJR_ENCODER
|
||||||
typedef struct CLJRContext {
|
typedef struct CLJRContext {
|
||||||
AVClass *avclass;
|
AVClass *avclass;
|
||||||
AVFrame picture;
|
|
||||||
int dither_type;
|
int dither_type;
|
||||||
} CLJRContext;
|
} CLJRContext;
|
||||||
|
|
||||||
static av_cold int encode_init(AVCodecContext *avctx)
|
static av_cold int encode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
CLJRContext * const a = avctx->priv_data;
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
avctx->coded_frame = &a->picture;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_cold int encode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +188,7 @@ AVCodec ff_cljr_encoder = {
|
|||||||
.priv_data_size = sizeof(CLJRContext),
|
.priv_data_size = sizeof(CLJRContext),
|
||||||
.init = encode_init,
|
.init = encode_init,
|
||||||
.encode2 = encode_frame,
|
.encode2 = encode_frame,
|
||||||
|
.close = encode_close,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P,
|
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P,
|
||||||
AV_PIX_FMT_NONE },
|
AV_PIX_FMT_NONE },
|
||||||
.priv_class = &cljr_class,
|
.priv_class = &cljr_class,
|
||||||
|
@@ -1217,8 +1217,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
q->num_subpackets++;
|
q->num_subpackets++;
|
||||||
s++;
|
s++;
|
||||||
if (s > MAX_SUBPACKETS) {
|
if (s > FFMIN(MAX_SUBPACKETS, avctx->block_align)) {
|
||||||
avpriv_request_sample(avctx, "subpackets > %d", MAX_SUBPACKETS);
|
avpriv_request_sample(avctx, "subpackets > %d", FFMIN(MAX_SUBPACKETS, avctx->block_align));
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
@@ -170,6 +171,10 @@ static inline int dirac_get_arith_uint(DiracArith *c, int follow_ctx, int data_c
|
|||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
while (!dirac_get_arith_bit(c, follow_ctx)) {
|
while (!dirac_get_arith_bit(c, follow_ctx)) {
|
||||||
|
if (ret >= 0x40000000) {
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "dirac_get_arith_uint overflow\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
ret <<= 1;
|
ret <<= 1;
|
||||||
ret += dirac_get_arith_bit(c, data_ctx);
|
ret += dirac_get_arith_bit(c, data_ctx);
|
||||||
follow_ctx = ff_dirac_next_ctx[follow_ctx];
|
follow_ctx = ff_dirac_next_ctx[follow_ctx];
|
||||||
|
@@ -80,7 +80,7 @@
|
|||||||
#define DIVRNDUP(a, b) (((a) + (b) - 1) / (b))
|
#define DIVRNDUP(a, b) (((a) + (b) - 1) / (b))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVFrame avframe;
|
AVFrame *avframe;
|
||||||
int interpolated[3]; /* 1 if hpel[] is valid */
|
int interpolated[3]; /* 1 if hpel[] is valid */
|
||||||
uint8_t *hpel[3][4];
|
uint8_t *hpel[3][4];
|
||||||
uint8_t *hpel_base[3][4];
|
uint8_t *hpel_base[3][4];
|
||||||
@@ -201,6 +201,7 @@ typedef struct DiracContext {
|
|||||||
|
|
||||||
uint16_t *mctmp; /* buffer holding the MC data multipled by OBMC weights */
|
uint16_t *mctmp; /* buffer holding the MC data multipled by OBMC weights */
|
||||||
uint8_t *mcscratch;
|
uint8_t *mcscratch;
|
||||||
|
int buffer_stride;
|
||||||
|
|
||||||
DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE];
|
DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE];
|
||||||
|
|
||||||
@@ -291,7 +292,7 @@ static DiracFrame *remove_frame(DiracFrame *framelist[], int picnum)
|
|||||||
int i, remove_idx = -1;
|
int i, remove_idx = -1;
|
||||||
|
|
||||||
for (i = 0; framelist[i]; i++)
|
for (i = 0; framelist[i]; i++)
|
||||||
if (framelist[i]->avframe.display_picture_number == picnum) {
|
if (framelist[i]->avframe->display_picture_number == picnum) {
|
||||||
remove_pic = framelist[i];
|
remove_pic = framelist[i];
|
||||||
remove_idx = i;
|
remove_idx = i;
|
||||||
}
|
}
|
||||||
@@ -343,29 +344,51 @@ static int alloc_sequence_buffers(DiracContext *s)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = s->source.width;
|
|
||||||
h = s->source.height;
|
|
||||||
|
|
||||||
/* fixme: allocate using real stride here */
|
/* fixme: allocate using real stride here */
|
||||||
s->sbsplit = av_malloc(sbwidth * sbheight);
|
s->sbsplit = av_malloc_array(sbwidth, sbheight);
|
||||||
s->blmotion = av_malloc(sbwidth * sbheight * 16 * sizeof(*s->blmotion));
|
s->blmotion = av_malloc_array(sbwidth, sbheight * 16 * sizeof(*s->blmotion));
|
||||||
s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
|
|
||||||
|
|
||||||
s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
if (!s->sbsplit || !s->blmotion)
|
||||||
s->mcscratch = av_malloc((w+64)*MAX_BLOCKSIZE);
|
|
||||||
|
|
||||||
if (!s->sbsplit || !s->blmotion || !s->mctmp || !s->mcscratch)
|
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int alloc_buffers(DiracContext *s, int stride)
|
||||||
|
{
|
||||||
|
int w = s->source.width;
|
||||||
|
int h = s->source.height;
|
||||||
|
|
||||||
|
av_assert0(stride >= w);
|
||||||
|
stride += 64;
|
||||||
|
|
||||||
|
if (s->buffer_stride >= stride)
|
||||||
|
return 0;
|
||||||
|
s->buffer_stride = 0;
|
||||||
|
|
||||||
|
av_freep(&s->edge_emu_buffer_base);
|
||||||
|
memset(s->edge_emu_buffer, 0, sizeof(s->edge_emu_buffer));
|
||||||
|
av_freep(&s->mctmp);
|
||||||
|
av_freep(&s->mcscratch);
|
||||||
|
|
||||||
|
s->edge_emu_buffer_base = av_malloc_array(stride, MAX_BLOCKSIZE);
|
||||||
|
|
||||||
|
s->mctmp = av_malloc_array((stride+MAX_BLOCKSIZE), (h+MAX_BLOCKSIZE) * sizeof(*s->mctmp));
|
||||||
|
s->mcscratch = av_malloc_array(stride, MAX_BLOCKSIZE);
|
||||||
|
|
||||||
|
if (!s->edge_emu_buffer_base || !s->mctmp || !s->mcscratch)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
s->buffer_stride = stride;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void free_sequence_buffers(DiracContext *s)
|
static void free_sequence_buffers(DiracContext *s)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
for (i = 0; i < MAX_FRAMES; i++) {
|
for (i = 0; i < MAX_FRAMES; i++) {
|
||||||
if (s->all_frames[i].avframe.data[0]) {
|
if (s->all_frames[i].avframe->data[0]) {
|
||||||
av_frame_unref(&s->all_frames[i].avframe);
|
av_frame_unref(s->all_frames[i].avframe);
|
||||||
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
|
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +405,7 @@ static void free_sequence_buffers(DiracContext *s)
|
|||||||
av_freep(&s->plane[i].idwt_tmp);
|
av_freep(&s->plane[i].idwt_tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s->buffer_stride = 0;
|
||||||
av_freep(&s->sbsplit);
|
av_freep(&s->sbsplit);
|
||||||
av_freep(&s->blmotion);
|
av_freep(&s->blmotion);
|
||||||
av_freep(&s->edge_emu_buffer_base);
|
av_freep(&s->edge_emu_buffer_base);
|
||||||
@@ -393,6 +417,8 @@ static void free_sequence_buffers(DiracContext *s)
|
|||||||
static av_cold int dirac_decode_init(AVCodecContext *avctx)
|
static av_cold int dirac_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
DiracContext *s = avctx->priv_data;
|
DiracContext *s = avctx->priv_data;
|
||||||
|
int i;
|
||||||
|
|
||||||
s->avctx = avctx;
|
s->avctx = avctx;
|
||||||
s->frame_number = -1;
|
s->frame_number = -1;
|
||||||
|
|
||||||
@@ -404,6 +430,15 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx)
|
|||||||
ff_dsputil_init(&s->dsp, avctx);
|
ff_dsputil_init(&s->dsp, avctx);
|
||||||
ff_diracdsp_init(&s->diracdsp);
|
ff_diracdsp_init(&s->diracdsp);
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_FRAMES; i++) {
|
||||||
|
s->all_frames[i].avframe = av_frame_alloc();
|
||||||
|
if (!s->all_frames[i].avframe) {
|
||||||
|
while (i > 0)
|
||||||
|
av_frame_free(&s->all_frames[--i].avframe);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +452,13 @@ static void dirac_decode_flush(AVCodecContext *avctx)
|
|||||||
|
|
||||||
static av_cold int dirac_decode_end(AVCodecContext *avctx)
|
static av_cold int dirac_decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
|
DiracContext *s = avctx->priv_data;
|
||||||
|
int i;
|
||||||
|
|
||||||
dirac_decode_flush(avctx);
|
dirac_decode_flush(avctx);
|
||||||
|
for (i = 0; i < MAX_FRAMES; i++)
|
||||||
|
av_frame_free(&s->all_frames[i].avframe);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,10 +615,10 @@ static av_always_inline void decode_subband_internal(DiracContext *s, SubBand *b
|
|||||||
|
|
||||||
top = 0;
|
top = 0;
|
||||||
for (cb_y = 0; cb_y < cb_height; cb_y++) {
|
for (cb_y = 0; cb_y < cb_height; cb_y++) {
|
||||||
bottom = (b->height * (cb_y+1)) / cb_height;
|
bottom = (b->height * (cb_y+1LL)) / cb_height;
|
||||||
left = 0;
|
left = 0;
|
||||||
for (cb_x = 0; cb_x < cb_width; cb_x++) {
|
for (cb_x = 0; cb_x < cb_width; cb_x++) {
|
||||||
right = (b->width * (cb_x+1)) / cb_width;
|
right = (b->width * (cb_x+1LL)) / cb_width;
|
||||||
codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith);
|
codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith);
|
||||||
left = right;
|
left = right;
|
||||||
}
|
}
|
||||||
@@ -966,8 +1007,8 @@ static int dirac_unpack_idwt_params(DiracContext *s)
|
|||||||
/* Codeblock parameters (core syntax only) */
|
/* Codeblock parameters (core syntax only) */
|
||||||
if (get_bits1(gb)) {
|
if (get_bits1(gb)) {
|
||||||
for (i = 0; i <= s->wavelet_depth; i++) {
|
for (i = 0; i <= s->wavelet_depth; i++) {
|
||||||
CHECKEDREAD(s->codeblock[i].width , tmp < 1, "codeblock width invalid\n")
|
CHECKEDREAD(s->codeblock[i].width , tmp < 1 || tmp > (s->avctx->width >>s->wavelet_depth-i), "codeblock width invalid\n")
|
||||||
CHECKEDREAD(s->codeblock[i].height, tmp < 1, "codeblock height invalid\n")
|
CHECKEDREAD(s->codeblock[i].height, tmp < 1 || tmp > (s->avctx->height>>s->wavelet_depth-i), "codeblock height invalid\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECKEDREAD(s->codeblock_mode, tmp > 1, "unknown codeblock mode\n")
|
CHECKEDREAD(s->codeblock_mode, tmp > 1, "unknown codeblock mode\n")
|
||||||
@@ -1343,8 +1384,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 */
|
||||||
@@ -1519,8 +1560,8 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
|
|||||||
just use 8 for everything for the moment */
|
just use 8 for everything for the moment */
|
||||||
int i, edge = EDGE_WIDTH/2;
|
int i, edge = EDGE_WIDTH/2;
|
||||||
|
|
||||||
ref->hpel[plane][0] = ref->avframe.data[plane];
|
ref->hpel[plane][0] = ref->avframe->data[plane];
|
||||||
s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */
|
s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */
|
||||||
|
|
||||||
/* no need for hpel if we only have fpel vectors */
|
/* no need for hpel if we only have fpel vectors */
|
||||||
if (!s->mv_precision)
|
if (!s->mv_precision)
|
||||||
@@ -1528,18 +1569,18 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
|
|||||||
|
|
||||||
for (i = 1; i < 4; i++) {
|
for (i = 1; i < 4; i++) {
|
||||||
if (!ref->hpel_base[plane][i])
|
if (!ref->hpel_base[plane][i])
|
||||||
ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe.linesize[plane] + 32);
|
ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe->linesize[plane] + 32);
|
||||||
/* we need to be 16-byte aligned even for chroma */
|
/* we need to be 16-byte aligned even for chroma */
|
||||||
ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe.linesize[plane] + 16;
|
ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe->linesize[plane] + 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ref->interpolated[plane]) {
|
if (!ref->interpolated[plane]) {
|
||||||
s->diracdsp.dirac_hpel_filter(ref->hpel[plane][1], ref->hpel[plane][2],
|
s->diracdsp.dirac_hpel_filter(ref->hpel[plane][1], ref->hpel[plane][2],
|
||||||
ref->hpel[plane][3], ref->hpel[plane][0],
|
ref->hpel[plane][3], ref->hpel[plane][0],
|
||||||
ref->avframe.linesize[plane], width, height);
|
ref->avframe->linesize[plane], width, height);
|
||||||
s->dsp.draw_edges(ref->hpel[plane][1], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
s->dsp.draw_edges(ref->hpel[plane][1], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
||||||
s->dsp.draw_edges(ref->hpel[plane][2], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
s->dsp.draw_edges(ref->hpel[plane][2], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
||||||
s->dsp.draw_edges(ref->hpel[plane][3], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
s->dsp.draw_edges(ref->hpel[plane][3], ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM);
|
||||||
}
|
}
|
||||||
ref->interpolated[plane] = 1;
|
ref->interpolated[plane] = 1;
|
||||||
}
|
}
|
||||||
@@ -1565,7 +1606,7 @@ static int dirac_decode_frame_internal(DiracContext *s)
|
|||||||
|
|
||||||
for (comp = 0; comp < 3; comp++) {
|
for (comp = 0; comp < 3; comp++) {
|
||||||
Plane *p = &s->plane[comp];
|
Plane *p = &s->plane[comp];
|
||||||
uint8_t *frame = s->current_picture->avframe.data[comp];
|
uint8_t *frame = s->current_picture->avframe->data[comp];
|
||||||
|
|
||||||
/* FIXME: small resolutions */
|
/* FIXME: small resolutions */
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
@@ -1640,7 +1681,7 @@ static int dirac_decode_picture_header(DiracContext *s)
|
|||||||
GetBitContext *gb = &s->gb;
|
GetBitContext *gb = &s->gb;
|
||||||
|
|
||||||
/* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
|
/* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
|
||||||
picnum = s->current_picture->avframe.display_picture_number = get_bits_long(gb, 32);
|
picnum = s->current_picture->avframe->display_picture_number = get_bits_long(gb, 32);
|
||||||
|
|
||||||
|
|
||||||
av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
|
av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
|
||||||
@@ -1659,9 +1700,9 @@ static int dirac_decode_picture_header(DiracContext *s)
|
|||||||
/* Jordi: this is needed if the referenced picture hasn't yet arrived */
|
/* Jordi: this is needed if the referenced picture hasn't yet arrived */
|
||||||
for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
|
for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
|
||||||
if (s->ref_frames[j]
|
if (s->ref_frames[j]
|
||||||
&& FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum) < refdist) {
|
&& FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum) < refdist) {
|
||||||
s->ref_pics[i] = s->ref_frames[j];
|
s->ref_pics[i] = s->ref_frames[j];
|
||||||
refdist = FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum);
|
refdist = FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->ref_pics[i] || refdist)
|
if (!s->ref_pics[i] || refdist)
|
||||||
@@ -1670,21 +1711,21 @@ static int dirac_decode_picture_header(DiracContext *s)
|
|||||||
/* if there were no references at all, allocate one */
|
/* if there were no references at all, allocate one */
|
||||||
if (!s->ref_pics[i])
|
if (!s->ref_pics[i])
|
||||||
for (j = 0; j < MAX_FRAMES; j++)
|
for (j = 0; j < MAX_FRAMES; j++)
|
||||||
if (!s->all_frames[j].avframe.data[0]) {
|
if (!s->all_frames[j].avframe->data[0]) {
|
||||||
s->ref_pics[i] = &s->all_frames[j];
|
s->ref_pics[i] = &s->all_frames[j];
|
||||||
ff_get_buffer(s->avctx, &s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
|
ff_get_buffer(s->avctx, s->ref_pics[i]->avframe, AV_GET_BUFFER_FLAG_REF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retire the reference frames that are not used anymore */
|
/* retire the reference frames that are not used anymore */
|
||||||
if (s->current_picture->avframe.reference) {
|
if (s->current_picture->avframe->reference) {
|
||||||
retire = picnum + dirac_get_se_golomb(gb);
|
retire = picnum + dirac_get_se_golomb(gb);
|
||||||
if (retire != picnum) {
|
if (retire != picnum) {
|
||||||
DiracFrame *retire_pic = remove_frame(s->ref_frames, retire);
|
DiracFrame *retire_pic = remove_frame(s->ref_frames, retire);
|
||||||
|
|
||||||
if (retire_pic)
|
if (retire_pic)
|
||||||
retire_pic->avframe.reference &= DELAYED_PIC_REF;
|
retire_pic->avframe->reference &= DELAYED_PIC_REF;
|
||||||
else
|
else
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "Frame to retire not found\n");
|
av_log(s->avctx, AV_LOG_DEBUG, "Frame to retire not found\n");
|
||||||
}
|
}
|
||||||
@@ -1692,7 +1733,7 @@ static int dirac_decode_picture_header(DiracContext *s)
|
|||||||
/* if reference array is full, remove the oldest as per the spec */
|
/* if reference array is full, remove the oldest as per the spec */
|
||||||
while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) {
|
while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
|
av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
|
||||||
remove_frame(s->ref_frames, s->ref_frames[0]->avframe.display_picture_number)->avframe.reference &= DELAYED_PIC_REF;
|
remove_frame(s->ref_frames, s->ref_frames[0]->avframe->display_picture_number)->avframe->reference &= DELAYED_PIC_REF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1717,7 +1758,7 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
|
|||||||
|
|
||||||
/* find frame with lowest picture number */
|
/* find frame with lowest picture number */
|
||||||
for (i = 1; s->delay_frames[i]; i++)
|
for (i = 1; s->delay_frames[i]; i++)
|
||||||
if (s->delay_frames[i]->avframe.display_picture_number < out->avframe.display_picture_number) {
|
if (s->delay_frames[i]->avframe->display_picture_number < out->avframe->display_picture_number) {
|
||||||
out = s->delay_frames[i];
|
out = s->delay_frames[i];
|
||||||
out_idx = i;
|
out_idx = i;
|
||||||
}
|
}
|
||||||
@@ -1726,9 +1767,9 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *got_frame)
|
|||||||
s->delay_frames[i] = s->delay_frames[i+1];
|
s->delay_frames[i] = s->delay_frames[i+1];
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
out->avframe.reference ^= DELAYED_PIC_REF;
|
out->avframe->reference ^= DELAYED_PIC_REF;
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
if((ret = av_frame_ref(picture, &out->avframe)) < 0)
|
if((ret = av_frame_ref(picture, out->avframe)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1790,14 +1831,14 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
|
|||||||
|
|
||||||
/* find an unused frame */
|
/* find an unused frame */
|
||||||
for (i = 0; i < MAX_FRAMES; i++)
|
for (i = 0; i < MAX_FRAMES; i++)
|
||||||
if (s->all_frames[i].avframe.data[0] == NULL)
|
if (s->all_frames[i].avframe->data[0] == NULL)
|
||||||
pic = &s->all_frames[i];
|
pic = &s->all_frames[i];
|
||||||
if (!pic) {
|
if (!pic) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "framelist full\n");
|
av_log(avctx, AV_LOG_ERROR, "framelist full\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&pic->avframe);
|
av_frame_unref(pic->avframe);
|
||||||
|
|
||||||
/* [DIRAC_STD] Defined in 9.6.1 ... */
|
/* [DIRAC_STD] Defined in 9.6.1 ... */
|
||||||
tmp = parse_code & 0x03; /* [DIRAC_STD] num_refs() */
|
tmp = parse_code & 0x03; /* [DIRAC_STD] num_refs() */
|
||||||
@@ -1808,16 +1849,19 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
|
|||||||
s->num_refs = tmp;
|
s->num_refs = tmp;
|
||||||
s->is_arith = (parse_code & 0x48) == 0x08; /* [DIRAC_STD] using_ac() */
|
s->is_arith = (parse_code & 0x48) == 0x08; /* [DIRAC_STD] using_ac() */
|
||||||
s->low_delay = (parse_code & 0x88) == 0x88; /* [DIRAC_STD] is_low_delay() */
|
s->low_delay = (parse_code & 0x88) == 0x88; /* [DIRAC_STD] is_low_delay() */
|
||||||
pic->avframe.reference = (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */
|
pic->avframe->reference = (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */
|
||||||
pic->avframe.key_frame = s->num_refs == 0; /* [DIRAC_STD] is_intra() */
|
pic->avframe->key_frame = s->num_refs == 0; /* [DIRAC_STD] is_intra() */
|
||||||
pic->avframe.pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
|
pic->avframe->pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */
|
||||||
|
|
||||||
if ((ret = ff_get_buffer(avctx, &pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
|
if ((ret = ff_get_buffer(avctx, pic->avframe, (parse_code & 0x0C) == 0x0C ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
s->current_picture = pic;
|
s->current_picture = pic;
|
||||||
s->plane[0].stride = pic->avframe.linesize[0];
|
s->plane[0].stride = pic->avframe->linesize[0];
|
||||||
s->plane[1].stride = pic->avframe.linesize[1];
|
s->plane[1].stride = pic->avframe->linesize[1];
|
||||||
s->plane[2].stride = pic->avframe.linesize[2];
|
s->plane[2].stride = pic->avframe->linesize[2];
|
||||||
|
|
||||||
|
if (alloc_buffers(s, FFMAX3(FFABS(s->plane[0].stride), FFABS(s->plane[1].stride), FFABS(s->plane[2].stride))) < 0)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
/* [DIRAC_STD] 11.1 Picture parse. picture_parse() */
|
/* [DIRAC_STD] 11.1 Picture parse. picture_parse() */
|
||||||
if (dirac_decode_picture_header(s))
|
if (dirac_decode_picture_header(s))
|
||||||
@@ -1833,7 +1877,7 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
|
|||||||
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
|
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
DiracContext *s = avctx->priv_data;
|
DiracContext *s = avctx->priv_data;
|
||||||
DiracFrame *picture = data;
|
AVFrame *picture = data;
|
||||||
uint8_t *buf = pkt->data;
|
uint8_t *buf = pkt->data;
|
||||||
int buf_size = pkt->size;
|
int buf_size = pkt->size;
|
||||||
int i, data_unit_size, buf_idx = 0;
|
int i, data_unit_size, buf_idx = 0;
|
||||||
@@ -1841,8 +1885,8 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
|
|
||||||
/* release unused frames */
|
/* release unused frames */
|
||||||
for (i = 0; i < MAX_FRAMES; i++)
|
for (i = 0; i < MAX_FRAMES; i++)
|
||||||
if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) {
|
if (s->all_frames[i].avframe->data[0] && !s->all_frames[i].avframe->reference) {
|
||||||
av_frame_unref(&s->all_frames[i].avframe);
|
av_frame_unref(s->all_frames[i].avframe);
|
||||||
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
|
memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1887,40 +1931,40 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
if (!s->current_picture)
|
if (!s->current_picture)
|
||||||
return buf_size;
|
return buf_size;
|
||||||
|
|
||||||
if (s->current_picture->avframe.display_picture_number > s->frame_number) {
|
if (s->current_picture->avframe->display_picture_number > s->frame_number) {
|
||||||
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
|
DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number);
|
||||||
|
|
||||||
s->current_picture->avframe.reference |= DELAYED_PIC_REF;
|
s->current_picture->avframe->reference |= DELAYED_PIC_REF;
|
||||||
|
|
||||||
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
|
if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
|
||||||
int min_num = s->delay_frames[0]->avframe.display_picture_number;
|
int min_num = s->delay_frames[0]->avframe->display_picture_number;
|
||||||
/* Too many delayed frames, so we display the frame with the lowest pts */
|
/* Too many delayed frames, so we display the frame with the lowest pts */
|
||||||
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
|
av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
|
||||||
delayed_frame = s->delay_frames[0];
|
delayed_frame = s->delay_frames[0];
|
||||||
|
|
||||||
for (i = 1; s->delay_frames[i]; i++)
|
for (i = 1; s->delay_frames[i]; i++)
|
||||||
if (s->delay_frames[i]->avframe.display_picture_number < min_num)
|
if (s->delay_frames[i]->avframe->display_picture_number < min_num)
|
||||||
min_num = s->delay_frames[i]->avframe.display_picture_number;
|
min_num = s->delay_frames[i]->avframe->display_picture_number;
|
||||||
|
|
||||||
delayed_frame = remove_frame(s->delay_frames, min_num);
|
delayed_frame = remove_frame(s->delay_frames, min_num);
|
||||||
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
|
add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delayed_frame) {
|
if (delayed_frame) {
|
||||||
delayed_frame->avframe.reference ^= DELAYED_PIC_REF;
|
delayed_frame->avframe->reference ^= DELAYED_PIC_REF;
|
||||||
if((ret=av_frame_ref(data, &delayed_frame->avframe)) < 0)
|
if((ret=av_frame_ref(data, delayed_frame->avframe)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
}
|
}
|
||||||
} else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
|
} else if (s->current_picture->avframe->display_picture_number == s->frame_number) {
|
||||||
/* The right frame at the right time :-) */
|
/* The right frame at the right time :-) */
|
||||||
if((ret=av_frame_ref(data, &s->current_picture->avframe)) < 0)
|
if((ret=av_frame_ref(data, s->current_picture->avframe)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*got_frame)
|
if (*got_frame)
|
||||||
s->frame_number = picture->avframe.display_picture_number + 1;
|
s->frame_number = picture->display_picture_number + 1;
|
||||||
|
|
||||||
return buf_idx;
|
return buf_idx;
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ typedef struct DNXHDContext {
|
|||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int64_t cid; ///< compression id
|
int64_t cid; ///< compression id
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
|
enum AVPixelFormat pix_fmt;
|
||||||
unsigned int mb_width, mb_height;
|
unsigned int mb_width, mb_height;
|
||||||
uint32_t mb_scan_index[68]; /* max for 1080p */
|
uint32_t mb_scan_index[68]; /* max for 1080p */
|
||||||
int cur_field; ///< current interlaced field
|
int cur_field; ///< current interlaced field
|
||||||
@@ -128,7 +129,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
|
|||||||
av_dlog(ctx->avctx, "width %d, height %d\n", ctx->width, ctx->height);
|
av_dlog(ctx->avctx, "width %d, height %d\n", ctx->width, ctx->height);
|
||||||
|
|
||||||
if (buf[0x21] & 0x40) {
|
if (buf[0x21] & 0x40) {
|
||||||
ctx->avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
|
ctx->pix_fmt = AV_PIX_FMT_YUV422P10;
|
||||||
ctx->avctx->bits_per_raw_sample = 10;
|
ctx->avctx->bits_per_raw_sample = 10;
|
||||||
if (ctx->bit_depth != 10) {
|
if (ctx->bit_depth != 10) {
|
||||||
ff_dsputil_init(&ctx->dsp, ctx->avctx);
|
ff_dsputil_init(&ctx->dsp, ctx->avctx);
|
||||||
@@ -136,7 +137,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
|
|||||||
ctx->decode_dct_block = dnxhd_decode_dct_block_10;
|
ctx->decode_dct_block = dnxhd_decode_dct_block_10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
|
ctx->pix_fmt = AV_PIX_FMT_YUV422P;
|
||||||
ctx->avctx->bits_per_raw_sample = 8;
|
ctx->avctx->bits_per_raw_sample = 8;
|
||||||
if (ctx->bit_depth != 8) {
|
if (ctx->bit_depth != 8) {
|
||||||
ff_dsputil_init(&ctx->dsp, ctx->avctx);
|
ff_dsputil_init(&ctx->dsp, ctx->avctx);
|
||||||
@@ -311,7 +312,7 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, int x, int
|
|||||||
dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1));
|
dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1));
|
||||||
dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1));
|
dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1));
|
||||||
|
|
||||||
if (ctx->cur_field) {
|
if (frame->interlaced_frame && ctx->cur_field) {
|
||||||
dest_y += frame->linesize[0];
|
dest_y += frame->linesize[0];
|
||||||
dest_u += frame->linesize[1];
|
dest_u += frame->linesize[1];
|
||||||
dest_v += frame->linesize[2];
|
dest_v += frame->linesize[2];
|
||||||
@@ -376,9 +377,15 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
avctx->width, avctx->height, ctx->width, ctx->height);
|
avctx->width, avctx->height, ctx->width, ctx->height);
|
||||||
first_field = 1;
|
first_field = 1;
|
||||||
}
|
}
|
||||||
|
if (avctx->pix_fmt != AV_PIX_FMT_NONE && avctx->pix_fmt != ctx->pix_fmt) {
|
||||||
|
av_log(avctx, AV_LOG_WARNING, "pix_fmt changed: %s -> %s\n",
|
||||||
|
av_get_pix_fmt_name(avctx->pix_fmt), av_get_pix_fmt_name(ctx->pix_fmt));
|
||||||
|
first_field = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (av_image_check_size(ctx->width, ctx->height, 0, avctx))
|
if (av_image_check_size(ctx->width, ctx->height, 0, avctx))
|
||||||
return -1;
|
return -1;
|
||||||
|
avctx->pix_fmt = ctx->pix_fmt;
|
||||||
avcodec_set_dimensions(avctx, ctx->width, ctx->height);
|
avcodec_set_dimensions(avctx, ctx->width, ctx->height);
|
||||||
|
|
||||||
if (first_field) {
|
if (first_field) {
|
||||||
|
@@ -235,7 +235,7 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias)
|
|||||||
|
|
||||||
static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx)
|
static av_cold 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);
|
||||||
|
|
||||||
@@ -329,9 +329,12 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
|
|||||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits, ctx->m.mb_num *sizeof(uint16_t), fail);
|
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_bits, ctx->m.mb_num *sizeof(uint16_t), fail);
|
||||||
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t), fail);
|
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, ctx->m.mb_num *sizeof(uint8_t), fail);
|
||||||
|
|
||||||
ctx->frame.key_frame = 1;
|
avctx->coded_frame = av_frame_alloc();
|
||||||
ctx->frame.pict_type = AV_PICTURE_TYPE_I;
|
if (!avctx->coded_frame)
|
||||||
ctx->m.avctx->coded_frame = &ctx->frame;
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
avctx->coded_frame->key_frame = 1;
|
||||||
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
|
||||||
if (avctx->thread_count > MAX_THREADS) {
|
if (avctx->thread_count > MAX_THREADS) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "too many threads\n");
|
av_log(avctx, AV_LOG_ERROR, "too many threads\n");
|
||||||
@@ -922,19 +925,14 @@ static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
ctx->frame.data[i] = frame->data[i];
|
|
||||||
ctx->frame.linesize[i] = frame->linesize[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ctx->m.avctx->thread_count; i++) {
|
for (i = 0; i < ctx->m.avctx->thread_count; i++) {
|
||||||
ctx->thread[i]->m.linesize = ctx->frame.linesize[0]<<ctx->interlaced;
|
ctx->thread[i]->m.linesize = frame->linesize[0] << ctx->interlaced;
|
||||||
ctx->thread[i]->m.uvlinesize = ctx->frame.linesize[1]<<ctx->interlaced;
|
ctx->thread[i]->m.uvlinesize = frame->linesize[1] << ctx->interlaced;
|
||||||
ctx->thread[i]->dct_y_offset = ctx->m.linesize *8;
|
ctx->thread[i]->dct_y_offset = ctx->m.linesize *8;
|
||||||
ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8;
|
ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->frame.interlaced_frame = frame->interlaced_frame;
|
ctx->m.avctx->coded_frame->interlaced_frame = frame->interlaced_frame;
|
||||||
ctx->cur_field = frame->interlaced_frame && !frame->top_field_first;
|
ctx->cur_field = frame->interlaced_frame && !frame->top_field_first;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,9 +952,9 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
encode_coding_unit:
|
encode_coding_unit:
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
ctx->src[i] = ctx->frame.data[i];
|
ctx->src[i] = frame->data[i];
|
||||||
if (ctx->interlaced && ctx->cur_field)
|
if (ctx->interlaced && ctx->cur_field)
|
||||||
ctx->src[i] += ctx->frame.linesize[i];
|
ctx->src[i] += frame->linesize[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
dnxhd_write_header(avctx, buf);
|
dnxhd_write_header(avctx, buf);
|
||||||
@@ -994,7 +992,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
goto encode_coding_unit;
|
goto encode_coding_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->frame.quality = ctx->qscale*FF_QP2LAMBDA;
|
avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA;
|
||||||
|
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
@@ -1027,6 +1025,8 @@ static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
|
|||||||
for (i = 1; i < avctx->thread_count; i++)
|
for (i = 1; i < avctx->thread_count; i++)
|
||||||
av_freep(&ctx->thread[i]);
|
av_freep(&ctx->thread[i]);
|
||||||
|
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,7 +43,6 @@ typedef struct DNXHDEncContext {
|
|||||||
AVClass *class;
|
AVClass *class;
|
||||||
MpegEncContext m; ///< Used for quantization dsp functions
|
MpegEncContext m; ///< Used for quantization dsp functions
|
||||||
|
|
||||||
AVFrame frame;
|
|
||||||
int cid;
|
int cid;
|
||||||
const CIDEntry *cid_table;
|
const CIDEntry *cid_table;
|
||||||
uint8_t *msip; ///< Macroblock Scan Indexes Payload
|
uint8_t *msip; ///< Macroblock Scan Indexes Payload
|
||||||
|
@@ -39,7 +39,7 @@ typedef enum CinVideoBitmapIndex {
|
|||||||
|
|
||||||
typedef struct CinVideoContext {
|
typedef struct CinVideoContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame frame;
|
AVFrame *frame;
|
||||||
unsigned int bitmap_size;
|
unsigned int bitmap_size;
|
||||||
uint32_t palette[256];
|
uint32_t palette[256];
|
||||||
uint8_t *bitmap_table[3];
|
uint8_t *bitmap_table[3];
|
||||||
@@ -118,7 +118,9 @@ static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
|
|||||||
cin->avctx = avctx;
|
cin->avctx = avctx;
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&cin->frame);
|
cin->frame = av_frame_alloc();
|
||||||
|
if (!cin->frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
cin->bitmap_size = avctx->width * avctx->height;
|
cin->bitmap_size = avctx->width * avctx->height;
|
||||||
if (allocate_buffers(cin))
|
if (allocate_buffers(cin))
|
||||||
@@ -315,20 +317,20 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = ff_reget_buffer(avctx, &cin->frame)) < 0)
|
if ((res = ff_reget_buffer(avctx, cin->frame)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette));
|
memcpy(cin->frame->data[1], cin->palette, sizeof(cin->palette));
|
||||||
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],
|
FFSWAP(uint8_t *, cin->bitmap_table[CIN_CUR_BMP],
|
||||||
cin->bitmap_table[CIN_PRE_BMP]);
|
cin->bitmap_table[CIN_PRE_BMP]);
|
||||||
|
|
||||||
if ((res = av_frame_ref(data, &cin->frame)) < 0)
|
if ((res = av_frame_ref(data, cin->frame)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@@ -340,7 +342,7 @@ static av_cold int cinvideo_decode_end(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
CinVideoContext *cin = avctx->priv_data;
|
CinVideoContext *cin = avctx->priv_data;
|
||||||
|
|
||||||
av_frame_unref(&cin->frame);
|
av_frame_free(&cin->frame);
|
||||||
|
|
||||||
destroy_buffers(cin);
|
destroy_buffers(cin);
|
||||||
|
|
||||||
|
@@ -320,8 +320,6 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx)
|
|||||||
}else
|
}else
|
||||||
memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64);
|
memcpy(s->dv_zigzag[1], ff_zigzag248_direct, 64);
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&s->picture);
|
|
||||||
avctx->coded_frame = &s->picture;
|
|
||||||
s->avctx = avctx;
|
s->avctx = avctx;
|
||||||
avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
|
avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
|
||||||
|
|
||||||
@@ -342,6 +340,10 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
|
|||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
dv_vlc_map_tableinit();
|
dv_vlc_map_tableinit();
|
||||||
|
|
||||||
return ff_dvvideo_init(avctx);
|
return ff_dvvideo_init(avctx);
|
||||||
@@ -687,12 +689,12 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
|
|||||||
if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P) ||
|
if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P) ||
|
||||||
(s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
|
(s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
|
||||||
(s->sys->height >= 720 && mb_y != 134)) {
|
(s->sys->height >= 720 && mb_y != 134)) {
|
||||||
y_stride = s->picture.linesize[0] << 3;
|
y_stride = s->frame->linesize[0] << 3;
|
||||||
} else {
|
} else {
|
||||||
y_stride = 16;
|
y_stride = 16;
|
||||||
}
|
}
|
||||||
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << 3);
|
y_ptr = s->frame->data[0] + ((mb_y * s->frame->linesize[0] + mb_x) << 3);
|
||||||
linesize = s->picture.linesize[0];
|
linesize = s->frame->linesize[0];
|
||||||
|
|
||||||
if (s->sys->video_stype == 4) { /* SD 422 */
|
if (s->sys->video_stype == 4) { /* SD 422 */
|
||||||
vs_bit_size +=
|
vs_bit_size +=
|
||||||
@@ -710,12 +712,12 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
|
|||||||
enc_blk += 4;
|
enc_blk += 4;
|
||||||
|
|
||||||
/* initializing chrominance blocks */
|
/* initializing chrominance blocks */
|
||||||
c_offset = (((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->picture.linesize[1] +
|
c_offset = (((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] +
|
||||||
(mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) << 3);
|
(mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) << 3);
|
||||||
for (j = 2; j; j--) {
|
for (j = 2; j; j--) {
|
||||||
uint8_t *c_ptr = s->picture.data[j] + c_offset;
|
uint8_t *c_ptr = s->frame->data[j] + c_offset;
|
||||||
linesize = s->picture.linesize[j];
|
linesize = s->frame->linesize[j];
|
||||||
y_stride = (mb_y == 134) ? 8 : (s->picture.linesize[j] << 3);
|
y_stride = (mb_y == 134) ? 8 : (s->frame->linesize[j] << 3);
|
||||||
if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
|
if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
|
||||||
uint8_t* d;
|
uint8_t* d;
|
||||||
uint8_t* b = scratch;
|
uint8_t* b = scratch;
|
||||||
@@ -814,7 +816,7 @@ static inline int dv_write_pack(enum dv_pack_type pack_id, DVVideoContext *c,
|
|||||||
* compression scheme (if any).
|
* compression scheme (if any).
|
||||||
*/
|
*/
|
||||||
int apt = (c->sys->pix_fmt == AV_PIX_FMT_YUV420P ? 0 : 1);
|
int apt = (c->sys->pix_fmt == AV_PIX_FMT_YUV420P ? 0 : 1);
|
||||||
int fs = c->picture.top_field_first ? 0x00 : 0x40;
|
int fs = c->frame->top_field_first ? 0x00 : 0x40;
|
||||||
|
|
||||||
uint8_t aspect = 0;
|
uint8_t aspect = 0;
|
||||||
if ((int)(av_q2d(c->avctx->sample_aspect_ratio) * c->avctx->width / c->avctx->height * 10) >= 17) /* 16:9 */
|
if ((int)(av_q2d(c->avctx->sample_aspect_ratio) * c->avctx->width / c->avctx->height * 10) >= 17) /* 16:9 */
|
||||||
@@ -964,9 +966,9 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
c->pix_fmt = s->sys->pix_fmt;
|
c->pix_fmt = s->sys->pix_fmt;
|
||||||
s->picture = *frame;
|
s->frame = frame;
|
||||||
s->picture.key_frame = 1;
|
c->coded_frame->key_frame = 1;
|
||||||
s->picture.pict_type = AV_PICTURE_TYPE_I;
|
c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
|
||||||
s->buf = pkt->data;
|
s->buf = pkt->data;
|
||||||
c->execute(c, dv_encode_video_segment, s->sys->work_chunks, NULL,
|
c->execute(c, dv_encode_video_segment, s->sys->work_chunks, NULL,
|
||||||
@@ -982,6 +984,12 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dvvideo_encode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
AVCodec ff_dvvideo_encoder = {
|
AVCodec ff_dvvideo_encoder = {
|
||||||
.name = "dvvideo",
|
.name = "dvvideo",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
|
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
|
||||||
@@ -990,6 +998,7 @@ AVCodec ff_dvvideo_encoder = {
|
|||||||
.priv_data_size = sizeof(DVVideoContext),
|
.priv_data_size = sizeof(DVVideoContext),
|
||||||
.init = dvvideo_init_encoder,
|
.init = dvvideo_init_encoder,
|
||||||
.encode2 = dvvideo_encode_frame,
|
.encode2 = dvvideo_encode_frame,
|
||||||
|
.close = dvvideo_encode_close,
|
||||||
.capabilities = CODEC_CAP_SLICE_THREADS,
|
.capabilities = CODEC_CAP_SLICE_THREADS,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||||
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
|
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
typedef struct DVVideoContext {
|
typedef struct DVVideoContext {
|
||||||
const DVprofile *sys;
|
const DVprofile *sys;
|
||||||
AVFrame picture;
|
AVFrame *frame;
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
|
@@ -258,12 +258,12 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
|
|||||||
if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P) ||
|
if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P) ||
|
||||||
(s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
|
(s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||
|
||||||
(s->sys->height >= 720 && mb_y != 134)) {
|
(s->sys->height >= 720 && mb_y != 134)) {
|
||||||
y_stride = (s->picture.linesize[0] << ((!is_field_mode[mb_index]) * log2_blocksize));
|
y_stride = (s->frame->linesize[0] << ((!is_field_mode[mb_index]) * log2_blocksize));
|
||||||
} else {
|
} else {
|
||||||
y_stride = (2 << log2_blocksize);
|
y_stride = (2 << log2_blocksize);
|
||||||
}
|
}
|
||||||
y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x) << log2_blocksize);
|
y_ptr = s->frame->data[0] + ((mb_y * s->frame->linesize[0] + mb_x) << log2_blocksize);
|
||||||
linesize = s->picture.linesize[0] << is_field_mode[mb_index];
|
linesize = s->frame->linesize[0] << is_field_mode[mb_index];
|
||||||
mb[0] .idct_put(y_ptr , linesize, block + 0*64);
|
mb[0] .idct_put(y_ptr , linesize, block + 0*64);
|
||||||
if (s->sys->video_stype == 4) { /* SD 422 */
|
if (s->sys->video_stype == 4) { /* SD 422 */
|
||||||
mb[2].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 2*64);
|
mb[2].idct_put(y_ptr + (1 << log2_blocksize) , linesize, block + 2*64);
|
||||||
@@ -276,19 +276,19 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
|
|||||||
block += 4*64;
|
block += 4*64;
|
||||||
|
|
||||||
/* idct_put'ting chrominance */
|
/* idct_put'ting chrominance */
|
||||||
c_offset = (((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->picture.linesize[1] +
|
c_offset = (((mb_y >> (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] +
|
||||||
(mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);
|
(mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);
|
||||||
for (j = 2; j; j--) {
|
for (j = 2; j; j--) {
|
||||||
uint8_t *c_ptr = s->picture.data[j] + c_offset;
|
uint8_t *c_ptr = s->frame->data[j] + c_offset;
|
||||||
if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
|
if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
|
||||||
uint64_t aligned_pixels[64/8];
|
uint64_t aligned_pixels[64/8];
|
||||||
uint8_t *pixels = (uint8_t*)aligned_pixels;
|
uint8_t *pixels = (uint8_t*)aligned_pixels;
|
||||||
uint8_t *c_ptr1, *ptr1;
|
uint8_t *c_ptr1, *ptr1;
|
||||||
int x, y;
|
int x, y;
|
||||||
mb->idct_put(pixels, 8, block);
|
mb->idct_put(pixels, 8, block);
|
||||||
for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->picture.linesize[j], pixels += 8) {
|
for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->frame->linesize[j], pixels += 8) {
|
||||||
ptr1 = pixels + ((1 << (log2_blocksize))>>1);
|
ptr1 = pixels + ((1 << (log2_blocksize))>>1);
|
||||||
c_ptr1 = c_ptr + (s->picture.linesize[j] << log2_blocksize);
|
c_ptr1 = c_ptr + (s->frame->linesize[j] << log2_blocksize);
|
||||||
for (x = 0; x < (1 << FFMAX(log2_blocksize - 1, 0)); x++) {
|
for (x = 0; x < (1 << FFMAX(log2_blocksize - 1, 0)); x++) {
|
||||||
c_ptr[x] = pixels[x];
|
c_ptr[x] = pixels[x];
|
||||||
c_ptr1[x] = ptr1[x];
|
c_ptr1[x] = ptr1[x];
|
||||||
@@ -297,8 +297,8 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
|
|||||||
block += 64; mb++;
|
block += 64; mb++;
|
||||||
} else {
|
} else {
|
||||||
y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
|
y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
|
||||||
s->picture.linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
|
s->frame->linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
|
||||||
linesize = s->picture.linesize[j] << is_field_mode[mb_index];
|
linesize = s->frame->linesize[j] << is_field_mode[mb_index];
|
||||||
(mb++)-> idct_put(c_ptr , linesize, block); block += 64;
|
(mb++)-> idct_put(c_ptr , linesize, block); block += 64;
|
||||||
if (s->sys->bpm == 8) {
|
if (s->sys->bpm == 8) {
|
||||||
(mb++)->idct_put(c_ptr + y_stride, linesize, block); block += 64;
|
(mb++)->idct_put(c_ptr + y_stride, linesize, block); block += 64;
|
||||||
@@ -327,15 +327,16 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
return -1; /* NOTE: we only accept several full frames */
|
return -1; /* NOTE: we only accept several full frames */
|
||||||
}
|
}
|
||||||
|
|
||||||
s->picture.key_frame = 1;
|
s->frame = data;
|
||||||
s->picture.pict_type = AV_PICTURE_TYPE_I;
|
s->frame->key_frame = 1;
|
||||||
|
s->frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
avctx->pix_fmt = s->sys->pix_fmt;
|
avctx->pix_fmt = s->sys->pix_fmt;
|
||||||
avctx->time_base = s->sys->time_base;
|
avctx->time_base = s->sys->time_base;
|
||||||
avcodec_set_dimensions(avctx, s->sys->width, s->sys->height);
|
avcodec_set_dimensions(avctx, s->sys->width, s->sys->height);
|
||||||
if ((ret = ff_get_buffer(avctx, &s->picture, 0)) < 0)
|
if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
s->picture.interlaced_frame = 1;
|
s->frame->interlaced_frame = 1;
|
||||||
s->picture.top_field_first = 0;
|
s->frame->top_field_first = 0;
|
||||||
|
|
||||||
/* Determine the codec's sample_aspect ratio and field order from the packet */
|
/* Determine the codec's sample_aspect ratio and field order from the packet */
|
||||||
vsc_pack = buf + 80*5 + 48 + 5;
|
vsc_pack = buf + 80*5 + 48 + 5;
|
||||||
@@ -343,7 +344,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
apt = buf[4] & 0x07;
|
apt = buf[4] & 0x07;
|
||||||
is16_9 = (vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07);
|
is16_9 = (vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07);
|
||||||
avctx->sample_aspect_ratio = s->sys->sar[is16_9];
|
avctx->sample_aspect_ratio = s->sys->sar[is16_9];
|
||||||
s->picture.top_field_first = !(vsc_pack[3] & 0x40);
|
s->frame->top_field_first = !(vsc_pack[3] & 0x40);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->buf = buf;
|
s->buf = buf;
|
||||||
@@ -354,20 +355,10 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
/* return image */
|
/* return image */
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
av_frame_move_ref(data, &s->picture);
|
|
||||||
|
|
||||||
return s->sys->frame_size;
|
return s->sys->frame_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dvvideo_close(AVCodecContext *c)
|
|
||||||
{
|
|
||||||
DVVideoContext *s = c->priv_data;
|
|
||||||
|
|
||||||
av_frame_unref(&s->picture);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodec ff_dvvideo_decoder = {
|
AVCodec ff_dvvideo_decoder = {
|
||||||
.name = "dvvideo",
|
.name = "dvvideo",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
|
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
|
||||||
@@ -375,7 +366,6 @@ AVCodec ff_dvvideo_decoder = {
|
|||||||
.id = AV_CODEC_ID_DVVIDEO,
|
.id = AV_CODEC_ID_DVVIDEO,
|
||||||
.priv_data_size = sizeof(DVVideoContext),
|
.priv_data_size = sizeof(DVVideoContext),
|
||||||
.init = ff_dvvideo_init,
|
.init = ff_dvvideo_init,
|
||||||
.close = dvvideo_close,
|
|
||||||
.decode = dvvideo_decode_frame,
|
.decode = dvvideo_decode_frame,
|
||||||
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
|
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
|
||||||
.max_lowres = 3,
|
.max_lowres = 3,
|
||||||
|
@@ -45,8 +45,11 @@ static int dvdsub_parse(AVCodecParserContext *s,
|
|||||||
DVDSubParseContext *pc = s->priv_data;
|
DVDSubParseContext *pc = s->priv_data;
|
||||||
|
|
||||||
if (pc->packet_index == 0) {
|
if (pc->packet_index == 0) {
|
||||||
if (buf_size < 2)
|
if (buf_size < 2 || AV_RB16(buf) && buf_size < 6) {
|
||||||
return 0;
|
if (buf_size)
|
||||||
|
av_log(avctx, AV_LOG_DEBUG, "Parser input %d too small\n", buf_size);
|
||||||
|
return buf_size;
|
||||||
|
}
|
||||||
pc->packet_len = AV_RB16(buf);
|
pc->packet_len = AV_RB16(buf);
|
||||||
if (pc->packet_len == 0) /* HD-DVD subpicture packet */
|
if (pc->packet_len == 0) /* HD-DVD subpicture packet */
|
||||||
pc->packet_len = AV_RB32(buf+2);
|
pc->packet_len = AV_RB32(buf+2);
|
||||||
|
@@ -35,7 +35,7 @@ typedef struct DVDSubContext
|
|||||||
int has_palette;
|
int has_palette;
|
||||||
uint8_t colormap[4];
|
uint8_t colormap[4];
|
||||||
uint8_t alpha[256];
|
uint8_t alpha[256];
|
||||||
uint8_t *buf;
|
uint8_t buf[0x10000];
|
||||||
int buf_size;
|
int buf_size;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int sub_id;
|
int sub_id;
|
||||||
@@ -103,6 +103,12 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
|
|||||||
int x, y, len, color;
|
int x, y, len, color;
|
||||||
uint8_t *d;
|
uint8_t *d;
|
||||||
|
|
||||||
|
if (start >= buf_size)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (w <= 0 || h <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
bit_len = (buf_size - start) * 8;
|
bit_len = (buf_size - start) * 8;
|
||||||
init_get_bits(&gb, buf + start, bit_len);
|
init_get_bits(&gb, buf + start, bit_len);
|
||||||
|
|
||||||
@@ -354,10 +360,12 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
|
|||||||
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
|
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
|
||||||
sub_header->num_rects = 1;
|
sub_header->num_rects = 1;
|
||||||
sub_header->rects[0]->pict.data[0] = bitmap;
|
sub_header->rects[0]->pict.data[0] = bitmap;
|
||||||
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
|
if (decode_rle(bitmap, w * 2, w, (h + 1) / 2,
|
||||||
buf, offset1, buf_size, is_8bit);
|
buf, offset1, buf_size, is_8bit) < 0)
|
||||||
decode_rle(bitmap + w, w * 2, w, h / 2,
|
goto fail;
|
||||||
buf, offset2, buf_size, is_8bit);
|
if (decode_rle(bitmap + w, w * 2, w, h / 2,
|
||||||
|
buf, offset2, buf_size, is_8bit) < 0)
|
||||||
|
goto fail;
|
||||||
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
|
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
|
||||||
if (is_8bit) {
|
if (is_8bit) {
|
||||||
if (yuv_palette == 0)
|
if (yuv_palette == 0)
|
||||||
@@ -495,15 +503,11 @@ static int append_to_cached_buf(AVCodecContext *avctx,
|
|||||||
{
|
{
|
||||||
DVDSubContext *ctx = avctx->priv_data;
|
DVDSubContext *ctx = avctx->priv_data;
|
||||||
|
|
||||||
if (ctx->buf_size > 0xffff - buf_size) {
|
if (ctx->buf_size >= sizeof(ctx->buf) - buf_size) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "
|
av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "
|
||||||
"too large SPU packets aborted.\n");
|
"too large SPU packets aborted.\n");
|
||||||
av_freep(&ctx->buf);
|
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size);
|
|
||||||
if (!ctx->buf)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
memcpy(ctx->buf + ctx->buf_size, buf, buf_size);
|
memcpy(ctx->buf + ctx->buf_size, buf, buf_size);
|
||||||
ctx->buf_size += buf_size;
|
ctx->buf_size += buf_size;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -519,7 +523,7 @@ static int dvdsub_decode(AVCodecContext *avctx,
|
|||||||
AVSubtitle *sub = data;
|
AVSubtitle *sub = data;
|
||||||
int is_menu;
|
int is_menu;
|
||||||
|
|
||||||
if (ctx->buf) {
|
if (ctx->buf_size) {
|
||||||
int ret = append_to_cached_buf(avctx, buf, buf_size);
|
int ret = append_to_cached_buf(avctx, buf, buf_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
*data_size = 0;
|
*data_size = 0;
|
||||||
@@ -557,7 +561,6 @@ static int dvdsub_decode(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
av_freep(&ctx->buf);
|
|
||||||
ctx->buf_size = 0;
|
ctx->buf_size = 0;
|
||||||
*data_size = 1;
|
*data_size = 1;
|
||||||
return buf_size;
|
return buf_size;
|
||||||
@@ -635,7 +638,6 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
|
|||||||
static av_cold int dvdsub_close(AVCodecContext *avctx)
|
static av_cold int dvdsub_close(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
DVDSubContext *ctx = avctx->priv_data;
|
DVDSubContext *ctx = avctx->priv_data;
|
||||||
av_freep(&ctx->buf);
|
|
||||||
ctx->buf_size = 0;
|
ctx->buf_size = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -321,12 +321,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
DxaDecContext * const c = avctx->priv_data;
|
DxaDecContext * const c = avctx->priv_data;
|
||||||
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
if (avctx->width%4 || avctx->height%4) {
|
||||||
|
avpriv_request_sample(avctx, "dimensions are not a multiple of 4");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
c->prev = av_frame_alloc();
|
c->prev = av_frame_alloc();
|
||||||
if (!c->prev)
|
if (!c->prev)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
|
|
||||||
c->dsize = avctx->width * avctx->height * 2;
|
c->dsize = avctx->width * avctx->height * 2;
|
||||||
c->decomp_buf = av_malloc(c->dsize);
|
c->decomp_buf = av_malloc(c->dsize);
|
||||||
if (!c->decomp_buf) {
|
if (!c->decomp_buf) {
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
typedef struct MadContext {
|
typedef struct MadContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
DSPContext dsp;
|
DSPContext dsp;
|
||||||
AVFrame last_frame;
|
AVFrame *last_frame;
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
void *bitstream_buf;
|
void *bitstream_buf;
|
||||||
unsigned int bitstream_buf_size;
|
unsigned int bitstream_buf_size;
|
||||||
@@ -65,6 +65,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
ff_init_scantable_permutation(s->dsp.idct_permutation, FF_NO_IDCT_PERM);
|
ff_init_scantable_permutation(s->dsp.idct_permutation, FF_NO_IDCT_PERM);
|
||||||
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
|
ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
|
||||||
ff_mpeg12_init_vlcs();
|
ff_mpeg12_init_vlcs();
|
||||||
|
|
||||||
|
s->last_frame = av_frame_alloc();
|
||||||
|
if (!s->last_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,22 +87,22 @@ static inline void comp_block(MadContext *t, AVFrame *frame,
|
|||||||
int j, int mv_x, int mv_y, int add)
|
int j, int mv_x, int mv_y, int add)
|
||||||
{
|
{
|
||||||
if (j < 4) {
|
if (j < 4) {
|
||||||
unsigned offset = (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x;
|
unsigned offset = (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame->linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x;
|
||||||
if (offset >= (t->avctx->height - 7) * t->last_frame.linesize[0] - 7)
|
if (offset >= (t->avctx->height - 7) * t->last_frame->linesize[0] - 7)
|
||||||
return;
|
return;
|
||||||
comp(frame->data[0] + (mb_y*16 + ((j&2)<<2))*frame->linesize[0] + mb_x*16 + ((j&1)<<3),
|
comp(frame->data[0] + (mb_y*16 + ((j&2)<<2))*frame->linesize[0] + mb_x*16 + ((j&1)<<3),
|
||||||
frame->linesize[0],
|
frame->linesize[0],
|
||||||
t->last_frame.data[0] + offset,
|
t->last_frame->data[0] + offset,
|
||||||
t->last_frame.linesize[0], add);
|
t->last_frame->linesize[0], add);
|
||||||
} else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) {
|
} else if (!(t->avctx->flags & CODEC_FLAG_GRAY)) {
|
||||||
int index = j - 3;
|
int index = j - 3;
|
||||||
unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2);
|
unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame->linesize[index] + mb_x * 8 + (mv_x/2);
|
||||||
if (offset >= (t->avctx->height/2 - 7) * t->last_frame.linesize[index] - 7)
|
if (offset >= (t->avctx->height/2 - 7) * t->last_frame->linesize[index] - 7)
|
||||||
return;
|
return;
|
||||||
comp(frame->data[index] + (mb_y*8)*frame->linesize[index] + mb_x * 8,
|
comp(frame->data[index] + (mb_y*8)*frame->linesize[index] + mb_x * 8,
|
||||||
frame->linesize[index],
|
frame->linesize[index],
|
||||||
t->last_frame.data[index] + offset,
|
t->last_frame->data[index] + offset,
|
||||||
t->last_frame.linesize[index], add);
|
t->last_frame->linesize[index], add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +210,7 @@ static int decode_mb(MadContext *s, AVFrame *frame, int inter)
|
|||||||
for (j=0; j<6; j++) {
|
for (j=0; j<6; j++) {
|
||||||
if (mv_map & (1<<j)) { // mv_x and mv_y are guarded by mv_map
|
if (mv_map & (1<<j)) { // mv_x and mv_y are guarded by mv_map
|
||||||
int add = 2*decode_motion(&s->gb);
|
int add = 2*decode_motion(&s->gb);
|
||||||
if (s->last_frame.data[0])
|
if (s->last_frame->data[0])
|
||||||
comp_block(s, frame, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
|
comp_block(s, frame, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
|
||||||
} else {
|
} else {
|
||||||
s->dsp.clear_block(s->block);
|
s->dsp.clear_block(s->block);
|
||||||
@@ -263,28 +268,28 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (avctx->width != width || avctx->height != height) {
|
if (avctx->width != width || avctx->height != height) {
|
||||||
|
av_frame_unref(s->last_frame);
|
||||||
if((width * height)/2048*7 > buf_end-buf)
|
if((width * height)/2048*7 > buf_end-buf)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
if ((ret = av_image_check_size(width, height, 0, avctx)) < 0)
|
if ((ret = av_image_check_size(width, height, 0, avctx)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
avcodec_set_dimensions(avctx, width, height);
|
avcodec_set_dimensions(avctx, width, height);
|
||||||
av_frame_unref(&s->last_frame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
|
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (inter && !s->last_frame.data[0]) {
|
if (inter && !s->last_frame->data[0]) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "Missing reference frame.\n");
|
av_log(avctx, AV_LOG_WARNING, "Missing reference frame.\n");
|
||||||
ret = ff_get_buffer(avctx, &s->last_frame, AV_GET_BUFFER_FLAG_REF);
|
ret = ff_get_buffer(avctx, s->last_frame, AV_GET_BUFFER_FLAG_REF);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
memset(s->last_frame.data[0], 0, s->last_frame.height *
|
memset(s->last_frame->data[0], 0, s->last_frame->height *
|
||||||
s->last_frame.linesize[0]);
|
s->last_frame->linesize[0]);
|
||||||
memset(s->last_frame.data[1], 0x80, s->last_frame.height / 2 *
|
memset(s->last_frame->data[1], 0x80, s->last_frame->height / 2 *
|
||||||
s->last_frame.linesize[1]);
|
s->last_frame->linesize[1]);
|
||||||
memset(s->last_frame.data[2], 0x80, s->last_frame.height / 2 *
|
memset(s->last_frame->data[2], 0x80, s->last_frame->height / 2 *
|
||||||
s->last_frame.linesize[2]);
|
s->last_frame->linesize[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,
|
av_fast_padded_malloc(&s->bitstream_buf, &s->bitstream_buf_size,
|
||||||
@@ -303,8 +308,8 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
|
|
||||||
if (chunk_type != MADe_TAG) {
|
if (chunk_type != MADe_TAG) {
|
||||||
av_frame_unref(&s->last_frame);
|
av_frame_unref(s->last_frame);
|
||||||
if ((ret = av_frame_ref(&s->last_frame, frame)) < 0)
|
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +319,7 @@ static int decode_frame(AVCodecContext *avctx,
|
|||||||
static av_cold int decode_end(AVCodecContext *avctx)
|
static av_cold int decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
MadContext *t = avctx->priv_data;
|
MadContext *t = avctx->priv_data;
|
||||||
av_frame_unref(&t->last_frame);
|
av_frame_free(&t->last_frame);
|
||||||
av_free(t->bitstream_buf);
|
av_free(t->bitstream_buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
typedef struct TgvContext {
|
typedef struct TgvContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame last_frame;
|
AVFrame *last_frame;
|
||||||
uint8_t *frame_buffer;
|
uint8_t *frame_buffer;
|
||||||
int width,height;
|
int width,height;
|
||||||
uint32_t palette[AVPALETTE_COUNT];
|
uint32_t palette[AVPALETTE_COUNT];
|
||||||
@@ -57,7 +57,11 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx)
|
|||||||
s->avctx = avctx;
|
s->avctx = avctx;
|
||||||
avctx->time_base = (AVRational){1, 15};
|
avctx->time_base = (AVRational){1, 15};
|
||||||
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
avctx->pix_fmt = AV_PIX_FMT_PAL8;
|
||||||
avcodec_get_frame_defaults(&s->last_frame);
|
|
||||||
|
s->last_frame = av_frame_alloc();
|
||||||
|
if (!s->last_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,8 +236,8 @@ static int tgv_decode_inter(TgvContext *s, AVFrame *frame,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
src = s->last_frame.data[0] + mx + my * s->last_frame.linesize[0];
|
src = s->last_frame->data[0] + mx + my * s->last_frame->linesize[0];
|
||||||
src_stride = s->last_frame.linesize[0];
|
src_stride = s->last_frame->linesize[0];
|
||||||
} else {
|
} else {
|
||||||
int offset = vector - num_mvs;
|
int offset = vector - num_mvs;
|
||||||
if (offset < num_blocks_raw)
|
if (offset < num_blocks_raw)
|
||||||
@@ -283,7 +287,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
|||||||
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);
|
||||||
av_freep(&s->frame_buffer);
|
av_freep(&s->frame_buffer);
|
||||||
av_frame_unref(&s->last_frame);
|
av_frame_unref(s->last_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
pal_count = AV_RL16(&buf[6]);
|
pal_count = AV_RL16(&buf[6]);
|
||||||
@@ -320,7 +324,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
|||||||
s->frame_buffer + y * s->width,
|
s->frame_buffer + y * s->width,
|
||||||
s->width);
|
s->width);
|
||||||
} else {
|
} else {
|
||||||
if (!s->last_frame.data[0]) {
|
if (!s->last_frame->data[0]) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n");
|
av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n");
|
||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
@@ -332,8 +336,8 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
av_frame_unref(&s->last_frame);
|
av_frame_unref(s->last_frame);
|
||||||
if ((ret = av_frame_ref(&s->last_frame, frame)) < 0)
|
if ((ret = av_frame_ref(s->last_frame, frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@@ -344,7 +348,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
|||||||
static av_cold int tgv_decode_end(AVCodecContext *avctx)
|
static av_cold int tgv_decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
TgvContext *s = avctx->priv_data;
|
TgvContext *s = avctx->priv_data;
|
||||||
av_frame_unref(&s->last_frame);
|
av_frame_free(&s->last_frame);
|
||||||
av_freep(&s->frame_buffer);
|
av_freep(&s->frame_buffer);
|
||||||
av_free(s->mv_codebook);
|
av_free(s->mv_codebook);
|
||||||
av_free(s->block_codebook);
|
av_free(s->block_codebook);
|
||||||
|
@@ -762,6 +762,17 @@ void ff_er_frame_start(ERContext *s)
|
|||||||
s->error_occurred = 0;
|
s->error_occurred = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int er_supported(ERContext *s)
|
||||||
|
{
|
||||||
|
if(s->avctx->hwaccel ||
|
||||||
|
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
|
||||||
|
!s->cur_pic ||
|
||||||
|
s->cur_pic->field_picture
|
||||||
|
)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a slice.
|
* Add a slice.
|
||||||
* @param endx x component of the last macroblock, can be -1
|
* @param endx x component of the last macroblock, can be -1
|
||||||
@@ -828,7 +839,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
|
|||||||
s->error_status_table[start_xy] |= VP_START;
|
s->error_status_table[start_xy] |= VP_START;
|
||||||
|
|
||||||
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
|
if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
|
||||||
s->avctx->skip_top * s->mb_width < start_i) {
|
er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {
|
||||||
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
|
int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
|
||||||
|
|
||||||
prev_status &= ~ VP_START;
|
prev_status &= ~ VP_START;
|
||||||
@@ -853,9 +864,7 @@ void ff_er_frame_end(ERContext *s)
|
|||||||
* though it should not crash if enabled. */
|
* though it should not crash if enabled. */
|
||||||
if (!s->avctx->error_concealment || s->error_count == 0 ||
|
if (!s->avctx->error_concealment || s->error_count == 0 ||
|
||||||
s->avctx->lowres ||
|
s->avctx->lowres ||
|
||||||
s->avctx->hwaccel ||
|
!er_supported(s) ||
|
||||||
s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
|
|
||||||
!s->cur_pic || s->cur_pic->field_picture ||
|
|
||||||
s->error_count == 3 * s->mb_width *
|
s->error_count == 3 * s->mb_width *
|
||||||
(s->avctx->skip_top + s->avctx->skip_bottom)) {
|
(s->avctx->skip_top + s->avctx->skip_bottom)) {
|
||||||
return;
|
return;
|
||||||
|
@@ -42,7 +42,7 @@ typedef struct CodeBook {
|
|||||||
} CodeBook;
|
} CodeBook;
|
||||||
|
|
||||||
typedef struct Escape124Context {
|
typedef struct Escape124Context {
|
||||||
AVFrame frame;
|
AVFrame *frame;
|
||||||
|
|
||||||
unsigned num_superblocks;
|
unsigned num_superblocks;
|
||||||
|
|
||||||
@@ -58,12 +58,15 @@ static av_cold int escape124_decode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
Escape124Context *s = avctx->priv_data;
|
Escape124Context *s = avctx->priv_data;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&s->frame);
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_RGB555;
|
avctx->pix_fmt = AV_PIX_FMT_RGB555;
|
||||||
|
|
||||||
s->num_superblocks = ((unsigned)avctx->width / 8) *
|
s->num_superblocks = ((unsigned)avctx->width / 8) *
|
||||||
((unsigned)avctx->height / 8);
|
((unsigned)avctx->height / 8);
|
||||||
|
|
||||||
|
s->frame = av_frame_alloc();
|
||||||
|
if (!s->frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +78,7 @@ static av_cold int escape124_decode_close(AVCodecContext *avctx)
|
|||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
av_free(s->codebooks[i].blocks);
|
av_free(s->codebooks[i].blocks);
|
||||||
|
|
||||||
av_frame_unref(&s->frame);
|
av_frame_free(&s->frame);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -227,13 +230,13 @@ static int escape124_decode_frame(AVCodecContext *avctx,
|
|||||||
// Leave last frame unchanged
|
// Leave last frame unchanged
|
||||||
// FIXME: Is this necessary? I haven't seen it in any real samples
|
// FIXME: Is this necessary? I haven't seen it in any real samples
|
||||||
if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
|
if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
|
||||||
if (!s->frame.data[0])
|
if (!s->frame->data[0])
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n");
|
av_log(avctx, AV_LOG_DEBUG, "Skipping frame\n");
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
if ((ret = av_frame_ref(frame, &s->frame)) < 0)
|
if ((ret = av_frame_ref(frame, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return frame_size;
|
return frame_size;
|
||||||
@@ -272,8 +275,8 @@ static int escape124_decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
new_frame_data = (uint16_t*)frame->data[0];
|
new_frame_data = (uint16_t*)frame->data[0];
|
||||||
new_stride = frame->linesize[0] / 2;
|
new_stride = frame->linesize[0] / 2;
|
||||||
old_frame_data = (uint16_t*)s->frame.data[0];
|
old_frame_data = (uint16_t*)s->frame->data[0];
|
||||||
old_stride = s->frame.linesize[0] / 2;
|
old_stride = s->frame->linesize[0] / 2;
|
||||||
|
|
||||||
for (superblock_index = 0; superblock_index < s->num_superblocks;
|
for (superblock_index = 0; superblock_index < s->num_superblocks;
|
||||||
superblock_index++) {
|
superblock_index++) {
|
||||||
@@ -350,8 +353,8 @@ static int escape124_decode_frame(AVCodecContext *avctx,
|
|||||||
"Escape sizes: %i, %i, %i\n",
|
"Escape sizes: %i, %i, %i\n",
|
||||||
frame_size, buf_size, get_bits_count(&gb) / 8);
|
frame_size, buf_size, get_bits_count(&gb) / 8);
|
||||||
|
|
||||||
av_frame_unref(&s->frame);
|
av_frame_unref(s->frame);
|
||||||
if ((ret = av_frame_ref(&s->frame, frame)) < 0)
|
if ((ret = av_frame_ref(s->frame, frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
|
@@ -251,7 +251,7 @@ static void put_line(uint8_t *dst, int size, int width, const int *runs)
|
|||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
int run, mode = ~0, pix_left = width, run_idx = 0;
|
int run, mode = ~0, pix_left = width, run_idx = 0;
|
||||||
|
|
||||||
init_put_bits(&pb, dst, size * 8);
|
init_put_bits(&pb, dst, size);
|
||||||
while (pix_left > 0) {
|
while (pix_left > 0) {
|
||||||
run = runs[run_idx++];
|
run = runs[run_idx++];
|
||||||
mode = ~mode;
|
mode = ~mode;
|
||||||
|
@@ -53,6 +53,7 @@ av_cold int ffv1_common_init(AVCodecContext *avctx)
|
|||||||
s->last_picture.f = av_frame_alloc();
|
s->last_picture.f = av_frame_alloc();
|
||||||
if (!s->picture.f || !s->last_picture.f)
|
if (!s->picture.f || !s->last_picture.f)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ff_dsputil_init(&s->dsp, avctx);
|
ff_dsputil_init(&s->dsp, avctx);
|
||||||
|
|
||||||
s->width = avctx->width;
|
s->width = avctx->width;
|
||||||
@@ -102,7 +103,7 @@ av_cold int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
|
|||||||
av_cold int ffv1_init_slices_state(FFV1Context *f)
|
av_cold int ffv1_init_slices_state(FFV1Context *f)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
for (i = 0; i < f->slice_count; i++) {
|
for (i = 0; i < f->max_slice_count; i++) {
|
||||||
FFV1Context *fs = f->slice_context[i];
|
FFV1Context *fs = f->slice_context[i];
|
||||||
if ((ret = ffv1_init_slice_state(f, fs)) < 0)
|
if ((ret = ffv1_init_slice_state(f, fs)) < 0)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -114,10 +115,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
f->slice_count = f->num_h_slices * f->num_v_slices;
|
f->max_slice_count = f->num_h_slices * f->num_v_slices;
|
||||||
av_assert0(f->slice_count > 0);
|
av_assert0(f->max_slice_count > 0);
|
||||||
|
|
||||||
for (i = 0; i < f->slice_count; i++) {
|
for (i = 0; i < f->max_slice_count; i++) {
|
||||||
FFV1Context *fs = av_mallocz(sizeof(*fs));
|
FFV1Context *fs = av_mallocz(sizeof(*fs));
|
||||||
int sx = i % f->num_h_slices;
|
int sx = i % f->num_h_slices;
|
||||||
int sy = i / f->num_h_slices;
|
int sy = i / f->num_h_slices;
|
||||||
@@ -202,7 +203,7 @@ av_cold int ffv1_close(AVCodecContext *avctx)
|
|||||||
ff_thread_release_buffer(avctx, &s->last_picture);
|
ff_thread_release_buffer(avctx, &s->last_picture);
|
||||||
av_frame_free(&s->last_picture.f);
|
av_frame_free(&s->last_picture.f);
|
||||||
|
|
||||||
for (j = 0; j < s->slice_count; j++) {
|
for (j = 0; j < s->max_slice_count; j++) {
|
||||||
FFV1Context *fs = s->slice_context[j];
|
FFV1Context *fs = s->slice_context[j];
|
||||||
for (i = 0; i < s->plane_count; i++) {
|
for (i = 0; i < s->plane_count; i++) {
|
||||||
PlaneContext *p = &fs->plane[i];
|
PlaneContext *p = &fs->plane[i];
|
||||||
@@ -216,14 +217,14 @@ av_cold int ffv1_close(AVCodecContext *avctx)
|
|||||||
av_freep(&avctx->stats_out);
|
av_freep(&avctx->stats_out);
|
||||||
for (j = 0; j < s->quant_table_count; j++) {
|
for (j = 0; j < s->quant_table_count; j++) {
|
||||||
av_freep(&s->initial_states[j]);
|
av_freep(&s->initial_states[j]);
|
||||||
for (i = 0; i < s->slice_count; i++) {
|
for (i = 0; i < s->max_slice_count; i++) {
|
||||||
FFV1Context *sf = s->slice_context[i];
|
FFV1Context *sf = s->slice_context[i];
|
||||||
av_freep(&sf->rc_stat2[j]);
|
av_freep(&sf->rc_stat2[j]);
|
||||||
}
|
}
|
||||||
av_freep(&s->rc_stat2[j]);
|
av_freep(&s->rc_stat2[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < s->slice_count; i++)
|
for (i = 0; i < s->max_slice_count; i++)
|
||||||
av_freep(&s->slice_context[i]);
|
av_freep(&s->slice_context[i]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -122,6 +122,7 @@ typedef struct FFV1Context {
|
|||||||
|
|
||||||
struct FFV1Context *slice_context[MAX_SLICES];
|
struct FFV1Context *slice_context[MAX_SLICES];
|
||||||
int slice_count;
|
int slice_count;
|
||||||
|
int max_slice_count;
|
||||||
int num_v_slices;
|
int num_v_slices;
|
||||||
int num_h_slices;
|
int num_h_slices;
|
||||||
int slice_width;
|
int slice_width;
|
||||||
|
@@ -533,8 +533,11 @@ static int read_extra_header(FFV1Context *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
f->quant_table_count = get_symbol(c, state, 0);
|
f->quant_table_count = get_symbol(c, state, 0);
|
||||||
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES)
|
if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) {
|
||||||
|
av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);
|
||||||
|
f->quant_table_count = 0;
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < f->quant_table_count; i++) {
|
for (i = 0; i < f->quant_table_count; i++) {
|
||||||
f->context_count[i] = read_quant_tables(c, f->quant_tables[i]);
|
f->context_count[i] = read_quant_tables(c, f->quant_tables[i]);
|
||||||
@@ -737,6 +740,7 @@ static int read_header(FFV1Context *f)
|
|||||||
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
|
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
f->slice_count = f->max_slice_count;
|
||||||
} else if (f->version < 3) {
|
} else if (f->version < 3) {
|
||||||
f->slice_count = get_symbol(c, state, 0);
|
f->slice_count = get_symbol(c, state, 0);
|
||||||
} else {
|
} else {
|
||||||
@@ -751,8 +755,8 @@ static int read_header(FFV1Context *f)
|
|||||||
p -= size + trailer;
|
p -= size + trailer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0) {
|
if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0 || f->slice_count > f->max_slice_count) {
|
||||||
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n", f->slice_count);
|
av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid (max=%d)\n", f->slice_count, f->max_slice_count);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,12 +942,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
|
|||||||
uint8_t *dst[4];
|
uint8_t *dst[4];
|
||||||
ff_thread_await_progress(&f->last_picture, INT_MAX, 0);
|
ff_thread_await_progress(&f->last_picture, INT_MAX, 0);
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
int sh = (j==1 || j==2) ? f->chroma_h_shift : 0;
|
int sh = (j == 1 || j == 2) ? f->chroma_h_shift : 0;
|
||||||
int sv = (j==1 || j==2) ? f->chroma_v_shift : 0;
|
int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0;
|
||||||
dst[j] = p->data[j] + p->linesize[j]*
|
dst[j] = p->data[j] + p->linesize[j] *
|
||||||
(fs->slice_y>>sv) + (fs->slice_x>>sh);
|
(fs->slice_y >> sv) + (fs->slice_x >> sh);
|
||||||
src[j] = f->last_picture.f->data[j] + f->last_picture.f->linesize[j]*
|
src[j] = f->last_picture.f->data[j] + f->last_picture.f->linesize[j] *
|
||||||
(fs->slice_y>>sv) + (fs->slice_x>>sh);
|
(fs->slice_y >> sv) + (fs->slice_x >> sh);
|
||||||
}
|
}
|
||||||
av_image_copy(dst, p->linesize, (const uint8_t **)src,
|
av_image_copy(dst, p->linesize, (const uint8_t **)src,
|
||||||
f->last_picture.f->linesize,
|
f->last_picture.f->linesize,
|
||||||
@@ -975,6 +979,7 @@ static int init_thread_copy(AVCodecContext *avctx)
|
|||||||
f->picture.f = NULL;
|
f->picture.f = NULL;
|
||||||
f->last_picture.f = NULL;
|
f->last_picture.f = NULL;
|
||||||
f->sample_buffer = NULL;
|
f->sample_buffer = NULL;
|
||||||
|
f->max_slice_count = 0;
|
||||||
f->slice_count = 0;
|
f->slice_count = 0;
|
||||||
|
|
||||||
for (i = 0; i < f->quant_table_count; i++) {
|
for (i = 0; i < f->quant_table_count; i++) {
|
||||||
@@ -1045,7 +1050,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
|
|||||||
av_assert0(!fdst->sample_buffer);
|
av_assert0(!fdst->sample_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_assert1(fdst->slice_count == fsrc->slice_count);
|
av_assert1(fdst->max_slice_count == fsrc->max_slice_count);
|
||||||
|
|
||||||
|
|
||||||
ff_thread_release_buffer(dst, &fdst->picture);
|
ff_thread_release_buffer(dst, &fdst->picture);
|
||||||
|
@@ -771,6 +771,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
s->colorspace = 1;
|
s->colorspace = 1;
|
||||||
s->chroma_planes = 1;
|
s->chroma_planes = 1;
|
||||||
s->version = FFMAX(s->version, 1);
|
s->version = FFMAX(s->version, 1);
|
||||||
|
if (!s->ac) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample of more than 8 needs -coder 1 currently\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "format not supported\n");
|
av_log(avctx, AV_LOG_ERROR, "format not supported\n");
|
||||||
@@ -826,6 +830,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
if ((ret = ffv1_allocate_initial_states(s)) < 0)
|
if ((ret = ffv1_allocate_initial_states(s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
|
||||||
if (!s->transparency)
|
if (!s->transparency)
|
||||||
s->plane_count = 2;
|
s->plane_count = 2;
|
||||||
if (!s->chroma_planes && s->version > 3)
|
if (!s->chroma_planes && s->version > 3)
|
||||||
@@ -937,6 +947,7 @@ slices_ok:
|
|||||||
|
|
||||||
if ((ret = ffv1_init_slice_contexts(s)) < 0)
|
if ((ret = ffv1_init_slice_contexts(s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
s->slice_count = s->max_slice_count;
|
||||||
if ((ret = ffv1_init_slices_state(s)) < 0)
|
if ((ret = ffv1_init_slices_state(s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -946,7 +957,7 @@ slices_ok:
|
|||||||
if (!avctx->stats_out)
|
if (!avctx->stats_out)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
for (i = 0; i < s->quant_table_count; i++)
|
for (i = 0; i < s->quant_table_count; i++)
|
||||||
for (j = 0; j < s->slice_count; j++) {
|
for (j = 0; j < s->max_slice_count; j++) {
|
||||||
FFV1Context *sf = s->slice_context[j];
|
FFV1Context *sf = s->slice_context[j];
|
||||||
av_assert0(!sf->rc_stat2[i]);
|
av_assert0(!sf->rc_stat2[i]);
|
||||||
sf->rc_stat2[i] = av_mallocz(s->context_count[i] *
|
sf->rc_stat2[i] = av_mallocz(s->context_count[i] *
|
||||||
@@ -996,7 +1007,7 @@ static int encode_slice(AVCodecContext *c, void *arg)
|
|||||||
int height = fs->slice_height;
|
int height = fs->slice_height;
|
||||||
int x = fs->slice_x;
|
int x = fs->slice_x;
|
||||||
int y = fs->slice_y;
|
int y = fs->slice_y;
|
||||||
AVFrame *const p = f->picture.f;
|
const AVFrame *const p = f->picture.f;
|
||||||
const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step_minus1 + 1;
|
const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step_minus1 + 1;
|
||||||
int ret;
|
int ret;
|
||||||
RangeCoder c_bak = fs->c;
|
RangeCoder c_bak = fs->c;
|
||||||
@@ -1004,7 +1015,7 @@ static int encode_slice(AVCodecContext *c, void *arg)
|
|||||||
fs->slice_coding_mode = 0;
|
fs->slice_coding_mode = 0;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (p->key_frame)
|
if (c->coded_frame->key_frame)
|
||||||
ffv1_clear_slice_state(f, fs);
|
ffv1_clear_slice_state(f, fs);
|
||||||
if (f->version > 2) {
|
if (f->version > 2) {
|
||||||
encode_slice_header(f, fs);
|
encode_slice_header(f, fs);
|
||||||
@@ -1080,16 +1091,16 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
av_frame_unref(p);
|
av_frame_unref(p);
|
||||||
if ((ret = av_frame_ref(p, pict)) < 0)
|
if ((ret = av_frame_ref(p, pict)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
|
||||||
if (avctx->gop_size == 0 || f->picture_number % avctx->gop_size == 0) {
|
if (avctx->gop_size == 0 || f->picture_number % avctx->gop_size == 0) {
|
||||||
put_rac(c, &keystate, 1);
|
put_rac(c, &keystate, 1);
|
||||||
p->key_frame = 1;
|
avctx->coded_frame->key_frame = 1;
|
||||||
f->gob_count++;
|
f->gob_count++;
|
||||||
write_header(f);
|
write_header(f);
|
||||||
} else {
|
} else {
|
||||||
put_rac(c, &keystate, 0);
|
put_rac(c, &keystate, 0);
|
||||||
p->key_frame = 0;
|
avctx->coded_frame->key_frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->ac > 1) {
|
if (f->ac > 1) {
|
||||||
@@ -1184,12 +1195,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
f->picture_number++;
|
f->picture_number++;
|
||||||
pkt->size = buf_p - pkt->data;
|
pkt->size = buf_p - pkt->data;
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY * p->key_frame;
|
pkt->flags |= AV_PKT_FLAG_KEY * avctx->coded_frame->key_frame;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_cold int encode_close(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
ffv1_close(avctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define OFFSET(x) offsetof(FFV1Context, x)
|
#define OFFSET(x) offsetof(FFV1Context, x)
|
||||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
@@ -1217,7 +1235,7 @@ AVCodec ff_ffv1_encoder = {
|
|||||||
.priv_data_size = sizeof(FFV1Context),
|
.priv_data_size = sizeof(FFV1Context),
|
||||||
.init = encode_init,
|
.init = encode_init,
|
||||||
.encode2 = encode_frame,
|
.encode2 = encode_frame,
|
||||||
.close = ffv1_close,
|
.close = encode_close,
|
||||||
.capabilities = CODEC_CAP_SLICE_THREADS,
|
.capabilities = CODEC_CAP_SLICE_THREADS,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||||
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV444P,
|
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV444P,
|
||||||
|
@@ -93,7 +93,6 @@ struct wavesynth_context {
|
|||||||
int64_t cur_ts;
|
int64_t cur_ts;
|
||||||
int64_t next_ts;
|
int64_t next_ts;
|
||||||
int32_t *sin;
|
int32_t *sin;
|
||||||
AVFrame frame;
|
|
||||||
struct ws_interval *inter;
|
struct ws_interval *inter;
|
||||||
uint32_t dither_state;
|
uint32_t dither_state;
|
||||||
uint32_t pink_state;
|
uint32_t pink_state;
|
||||||
@@ -341,8 +340,6 @@ static av_cold int wavesynth_init(AVCodecContext *avc)
|
|||||||
ws->pink_need += ws->inter[i].type == WS_NOISE;
|
ws->pink_need += ws->inter[i].type == WS_NOISE;
|
||||||
ws->pink_state = MKTAG('P','I','N','K');
|
ws->pink_state = MKTAG('P','I','N','K');
|
||||||
ws->pink_pos = PINK_UNIT;
|
ws->pink_pos = PINK_UNIT;
|
||||||
avcodec_get_frame_defaults(&ws->frame);
|
|
||||||
avc->coded_frame = &ws->frame;
|
|
||||||
wavesynth_seek(ws, 0);
|
wavesynth_seek(ws, 0);
|
||||||
avc->sample_fmt = AV_SAMPLE_FMT_S16;
|
avc->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -428,6 +425,7 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
|
|||||||
AVPacket *packet)
|
AVPacket *packet)
|
||||||
{
|
{
|
||||||
struct wavesynth_context *ws = avc->priv_data;
|
struct wavesynth_context *ws = avc->priv_data;
|
||||||
|
AVFrame *frame = rframe;
|
||||||
int64_t ts;
|
int64_t ts;
|
||||||
int duration;
|
int duration;
|
||||||
int s, c, r;
|
int s, c, r;
|
||||||
@@ -443,11 +441,11 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
|
|||||||
duration = AV_RL32(packet->data + 8);
|
duration = AV_RL32(packet->data + 8);
|
||||||
if (duration <= 0)
|
if (duration <= 0)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
ws->frame.nb_samples = duration;
|
frame->nb_samples = duration;
|
||||||
r = ff_get_buffer(avc, &ws->frame, 0);
|
r = ff_get_buffer(avc, frame, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
pcm = (int16_t *)ws->frame.data[0];
|
pcm = (int16_t *)frame->data[0];
|
||||||
for (s = 0; s < duration; s++, ts++) {
|
for (s = 0; s < duration; s++, ts++) {
|
||||||
memset(channels, 0, avc->channels * sizeof(*channels));
|
memset(channels, 0, avc->channels * sizeof(*channels));
|
||||||
if (ts >= ws->next_ts)
|
if (ts >= ws->next_ts)
|
||||||
@@ -458,7 +456,6 @@ static int wavesynth_decode(AVCodecContext *avc, void *rframe, int *rgot_frame,
|
|||||||
}
|
}
|
||||||
ws->cur_ts += duration;
|
ws->cur_ts += duration;
|
||||||
*rgot_frame = 1;
|
*rgot_frame = 1;
|
||||||
*(AVFrame *)rframe = ws->frame;
|
|
||||||
return packet->size;
|
return packet->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -685,7 +685,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
handle_error:
|
handle_error:
|
||||||
*poutbuf = NULL;
|
*poutbuf = NULL;
|
||||||
*poutbuf_size = 0;
|
*poutbuf_size = 0;
|
||||||
return read_end - buf;
|
return buf_size ? read_end - buf : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int flac_parse_init(AVCodecParserContext *c)
|
static av_cold int flac_parse_init(AVCodecParserContext *c)
|
||||||
|
@@ -465,10 +465,10 @@ static int decode_frame(FLACContext *s)
|
|||||||
ret = allocate_buffers(s);
|
ret = allocate_buffers(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
|
|
||||||
s->got_streaminfo = 1;
|
s->got_streaminfo = 1;
|
||||||
dump_headers(s->avctx, (FLACStreaminfo *)s);
|
dump_headers(s->avctx, (FLACStreaminfo *)s);
|
||||||
}
|
}
|
||||||
|
ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
|
||||||
|
|
||||||
// dump_headers(s->avctx, (FLACStreaminfo *)s);
|
// dump_headers(s->avctx, (FLACStreaminfo *)s);
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ typedef struct BlockInfo {
|
|||||||
|
|
||||||
typedef struct FlashSVContext {
|
typedef struct FlashSVContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame frame;
|
AVFrame *frame;
|
||||||
int image_width, image_height;
|
int image_width, image_height;
|
||||||
int block_width, block_height;
|
int block_width, block_height;
|
||||||
uint8_t *tmpblock;
|
uint8_t *tmpblock;
|
||||||
@@ -100,6 +100,19 @@ static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
|
|||||||
return sptr - orig_src;
|
return sptr - orig_src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_cold int flashsv_decode_end(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
FlashSVContext *s = avctx->priv_data;
|
||||||
|
inflateEnd(&s->zstream);
|
||||||
|
/* release the frame if needed */
|
||||||
|
av_frame_free(&s->frame);
|
||||||
|
|
||||||
|
/* free the tmpblock */
|
||||||
|
av_freep(&s->tmpblock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static av_cold int flashsv_decode_init(AVCodecContext *avctx)
|
static av_cold int flashsv_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
FlashSVContext *s = avctx->priv_data;
|
FlashSVContext *s = avctx->priv_data;
|
||||||
@@ -115,7 +128,12 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
avctx->pix_fmt = AV_PIX_FMT_BGR24;
|
avctx->pix_fmt = AV_PIX_FMT_BGR24;
|
||||||
avcodec_get_frame_defaults(&s->frame);
|
|
||||||
|
s->frame = av_frame_alloc();
|
||||||
|
if (!s->frame) {
|
||||||
|
flashsv_decode_end(avctx);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -205,18 +223,18 @@ static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
/* Flash Screen Video stores the image upside down, so copy
|
/* Flash Screen Video stores the image upside down, so copy
|
||||||
* lines to destination in reverse order. */
|
* lines to destination in reverse order. */
|
||||||
for (k = 1; k <= s->diff_height; k++) {
|
for (k = 1; k <= s->diff_height; k++) {
|
||||||
memcpy(s->frame.data[0] + x_pos * 3 +
|
memcpy(s->frame->data[0] + x_pos * 3 +
|
||||||
(s->image_height - y_pos - s->diff_start - k) * s->frame.linesize[0],
|
(s->image_height - y_pos - s->diff_start - k) * s->frame->linesize[0],
|
||||||
line, width * 3);
|
line, width * 3);
|
||||||
/* advance source pointer to next line */
|
/* advance source pointer to next line */
|
||||||
line += width * 3;
|
line += width * 3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* hybrid 15-bit/palette mode */
|
/* hybrid 15-bit/palette mode */
|
||||||
decode_hybrid(s->tmpblock, s->frame.data[0],
|
decode_hybrid(s->tmpblock, s->frame->data[0],
|
||||||
s->image_height - (y_pos + 1 + s->diff_start + s->diff_height),
|
s->image_height - (y_pos + 1 + s->diff_start + s->diff_height),
|
||||||
x_pos, s->diff_height, width,
|
x_pos, s->diff_height, width,
|
||||||
s->frame.linesize[0], s->pal);
|
s->frame->linesize[0], s->pal);
|
||||||
}
|
}
|
||||||
skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */
|
skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */
|
||||||
return 0;
|
return 0;
|
||||||
@@ -337,7 +355,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
s->image_width, s->image_height, s->block_width, s->block_height,
|
s->image_width, s->image_height, s->block_width, s->block_height,
|
||||||
h_blocks, v_blocks, h_part, v_part);
|
h_blocks, v_blocks, h_part, v_part);
|
||||||
|
|
||||||
if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
|
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* loop over all block columns */
|
/* loop over all block columns */
|
||||||
@@ -362,7 +380,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
s->diff_height = cur_blk_height;
|
s->diff_height = cur_blk_height;
|
||||||
|
|
||||||
if (8 * size > get_bits_left(&gb)) {
|
if (8 * size > get_bits_left(&gb)) {
|
||||||
av_frame_unref(&s->frame);
|
av_frame_unref(s->frame);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,11 +436,11 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
if (has_diff) {
|
if (has_diff) {
|
||||||
int k;
|
int k;
|
||||||
int off = (s->image_height - y_pos - 1) * s->frame.linesize[0];
|
int off = (s->image_height - y_pos - 1) * s->frame->linesize[0];
|
||||||
|
|
||||||
for (k = 0; k < cur_blk_height; k++)
|
for (k = 0; k < cur_blk_height; k++)
|
||||||
memcpy(s->frame.data[0] + off - k*s->frame.linesize[0] + x_pos*3,
|
memcpy(s->frame->data[0] + off - k*s->frame->linesize[0] + x_pos*3,
|
||||||
s->keyframe + off - k*s->frame.linesize[0] + x_pos*3,
|
s->keyframe + off - k*s->frame->linesize[0] + x_pos*3,
|
||||||
cur_blk_width * 3);
|
cur_blk_width * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,16 +457,16 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
if (s->is_keyframe && s->ver == 2) {
|
if (s->is_keyframe && s->ver == 2) {
|
||||||
if (!s->keyframe) {
|
if (!s->keyframe) {
|
||||||
s->keyframe = av_malloc(s->frame.linesize[0] * avctx->height);
|
s->keyframe = av_malloc(s->frame->linesize[0] * avctx->height);
|
||||||
if (!s->keyframe) {
|
if (!s->keyframe) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n");
|
av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n");
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(s->keyframe, s->frame.data[0], s->frame.linesize[0] * avctx->height);
|
memcpy(s->keyframe, s->frame->data[0], s->frame->linesize[0] * avctx->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = av_frame_ref(data, &s->frame)) < 0)
|
if ((ret = av_frame_ref(data, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@@ -461,21 +479,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static av_cold int flashsv_decode_end(AVCodecContext *avctx)
|
|
||||||
{
|
|
||||||
FlashSVContext *s = avctx->priv_data;
|
|
||||||
inflateEnd(&s->zstream);
|
|
||||||
/* release the frame if needed */
|
|
||||||
av_frame_unref(&s->frame);
|
|
||||||
|
|
||||||
/* free the tmpblock */
|
|
||||||
av_free(s->tmpblock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_FLASHSV_DECODER
|
#if CONFIG_FLASHSV_DECODER
|
||||||
AVCodec ff_flashsv_decoder = {
|
AVCodec ff_flashsv_decoder = {
|
||||||
.name = "flashsv",
|
.name = "flashsv",
|
||||||
|
@@ -87,7 +87,6 @@ typedef struct FlashSV2Context {
|
|||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
uint8_t *current_frame;
|
uint8_t *current_frame;
|
||||||
uint8_t *key_frame;
|
uint8_t *key_frame;
|
||||||
AVFrame frame;
|
|
||||||
uint8_t *encbuffer;
|
uint8_t *encbuffer;
|
||||||
uint8_t *keybuffer;
|
uint8_t *keybuffer;
|
||||||
uint8_t *databuffer;
|
uint8_t *databuffer;
|
||||||
@@ -288,7 +287,7 @@ static int write_header(FlashSV2Context * s, uint8_t * buf, int buf_size)
|
|||||||
if (buf_size < 5)
|
if (buf_size < 5)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
init_put_bits(&pb, buf, buf_size * 8);
|
init_put_bits(&pb, buf, buf_size);
|
||||||
|
|
||||||
put_bits(&pb, 4, (s->block_width >> 4) - 1);
|
put_bits(&pb, 4, (s->block_width >> 4) - 1);
|
||||||
put_bits(&pb, 12, s->image_width);
|
put_bits(&pb, 12, s->image_width);
|
||||||
@@ -849,15 +848,12 @@ static int reconfigure_at_keyframe(FlashSV2Context * s, const uint8_t * image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
const AVFrame *pict, int *got_packet)
|
const AVFrame *p, int *got_packet)
|
||||||
{
|
{
|
||||||
FlashSV2Context *const s = avctx->priv_data;
|
FlashSV2Context *const s = avctx->priv_data;
|
||||||
AVFrame *const p = &s->frame;
|
|
||||||
int res;
|
int res;
|
||||||
int keyframe = 0;
|
int keyframe = 0;
|
||||||
|
|
||||||
*p = *pict;
|
|
||||||
|
|
||||||
if ((res = ff_alloc_packet2(avctx, pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0)
|
if ((res = ff_alloc_packet2(avctx, pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@@ -891,18 +887,11 @@ static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
if (keyframe) {
|
if (keyframe) {
|
||||||
new_key_frame(s);
|
new_key_frame(s);
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
|
||||||
p->key_frame = 1;
|
|
||||||
s->last_key_frame = avctx->frame_number;
|
s->last_key_frame = avctx->frame_number;
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number);
|
av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n", avctx->frame_number);
|
||||||
} else {
|
|
||||||
p->pict_type = AV_PICTURE_TYPE_P;
|
|
||||||
p->key_frame = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
avctx->coded_frame = p;
|
|
||||||
|
|
||||||
pkt->size = res;
|
pkt->size = res;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
|
|
||||||
|
@@ -57,7 +57,6 @@
|
|||||||
typedef struct FlashSVContext {
|
typedef struct FlashSVContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
uint8_t *previous_frame;
|
uint8_t *previous_frame;
|
||||||
AVFrame frame;
|
|
||||||
int image_width, image_height;
|
int image_width, image_height;
|
||||||
int block_width, block_height;
|
int block_width, block_height;
|
||||||
uint8_t *tmpblock;
|
uint8_t *tmpblock;
|
||||||
@@ -89,6 +88,21 @@ static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_cold int flashsv_encode_end(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
FlashSVContext *s = avctx->priv_data;
|
||||||
|
|
||||||
|
deflateEnd(&s->zstream);
|
||||||
|
|
||||||
|
av_free(s->encbuffer);
|
||||||
|
av_free(s->previous_frame);
|
||||||
|
av_free(s->tmpblock);
|
||||||
|
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static av_cold int flashsv_encode_init(AVCodecContext *avctx)
|
static av_cold int flashsv_encode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
FlashSVContext *s = avctx->priv_data;
|
FlashSVContext *s = avctx->priv_data;
|
||||||
@@ -117,11 +131,17 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame) {
|
||||||
|
flashsv_encode_end(avctx);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf,
|
static int encode_bitstream(FlashSVContext *s, const AVFrame *p, uint8_t *buf,
|
||||||
int buf_size, int block_width, int block_height,
|
int buf_size, int block_width, int block_height,
|
||||||
uint8_t *previous_frame, int *I_frame)
|
uint8_t *previous_frame, int *I_frame)
|
||||||
{
|
{
|
||||||
@@ -131,7 +151,7 @@ static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf,
|
|||||||
int buf_pos, res;
|
int buf_pos, res;
|
||||||
int pred_blocks = 0;
|
int pred_blocks = 0;
|
||||||
|
|
||||||
init_put_bits(&pb, buf, buf_size * 8);
|
init_put_bits(&pb, buf, buf_size);
|
||||||
|
|
||||||
put_bits(&pb, 4, block_width / 16 - 1);
|
put_bits(&pb, 4, block_width / 16 - 1);
|
||||||
put_bits(&pb, 12, s->image_width);
|
put_bits(&pb, 12, s->image_width);
|
||||||
@@ -199,14 +219,12 @@ static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
const AVFrame *pict, int *got_packet)
|
const AVFrame *pict, int *got_packet)
|
||||||
{
|
{
|
||||||
FlashSVContext * const s = avctx->priv_data;
|
FlashSVContext * const s = avctx->priv_data;
|
||||||
AVFrame * const p = &s->frame;
|
const AVFrame * const p = pict;
|
||||||
uint8_t *pfptr;
|
uint8_t *pfptr;
|
||||||
int res;
|
int res;
|
||||||
int I_frame = 0;
|
int I_frame = 0;
|
||||||
int opt_w = 4, opt_h = 4;
|
int opt_w = 4, opt_h = 4;
|
||||||
|
|
||||||
*p = *pict;
|
|
||||||
|
|
||||||
/* First frame needs to be a keyframe */
|
/* First frame needs to be a keyframe */
|
||||||
if (avctx->frame_number == 0) {
|
if (avctx->frame_number == 0) {
|
||||||
s->previous_frame = av_mallocz(FFABS(p->linesize[0]) * s->image_height);
|
s->previous_frame = av_mallocz(FFABS(p->linesize[0]) * s->image_height);
|
||||||
@@ -244,37 +262,22 @@ static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
//mark the frame type so the muxer can mux it correctly
|
//mark the frame type so the muxer can mux it correctly
|
||||||
if (I_frame) {
|
if (I_frame) {
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
p->key_frame = 1;
|
avctx->coded_frame->key_frame = 1;
|
||||||
s->last_key_frame = avctx->frame_number;
|
s->last_key_frame = avctx->frame_number;
|
||||||
av_dlog(avctx, "Inserting keyframe at frame %d\n", avctx->frame_number);
|
av_dlog(avctx, "Inserting keyframe at frame %d\n", avctx->frame_number);
|
||||||
} else {
|
} else {
|
||||||
p->pict_type = AV_PICTURE_TYPE_P;
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
|
||||||
p->key_frame = 0;
|
avctx->coded_frame->key_frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
avctx->coded_frame = p;
|
if (avctx->coded_frame->key_frame)
|
||||||
|
|
||||||
if (p->key_frame)
|
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int flashsv_encode_end(AVCodecContext *avctx)
|
|
||||||
{
|
|
||||||
FlashSVContext *s = avctx->priv_data;
|
|
||||||
|
|
||||||
deflateEnd(&s->zstream);
|
|
||||||
|
|
||||||
av_free(s->encbuffer);
|
|
||||||
av_free(s->previous_frame);
|
|
||||||
av_free(s->tmpblock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodec ff_flashsv_encoder = {
|
AVCodec ff_flashsv_encoder = {
|
||||||
.name = "flashsv",
|
.name = "flashsv",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video"),
|
.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video"),
|
||||||
|
@@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
typedef struct FlicDecodeContext {
|
typedef struct FlicDecodeContext {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame frame;
|
AVFrame *frame;
|
||||||
|
|
||||||
unsigned int palette[256];
|
unsigned int palette[256];
|
||||||
int new_palette;
|
int new_palette;
|
||||||
@@ -141,7 +141,10 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&s->frame);
|
s->frame = av_frame_alloc();
|
||||||
|
if (!s->frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
s->new_palette = 0;
|
s->new_palette = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -185,11 +188,11 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
|
|
||||||
bytestream2_init(&g2, buf, buf_size);
|
bytestream2_init(&g2, buf, buf_size);
|
||||||
|
|
||||||
if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
|
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
pixels = s->frame.data[0];
|
pixels = s->frame->data[0];
|
||||||
pixel_limit = s->avctx->height * s->frame.linesize[0];
|
pixel_limit = s->avctx->height * s->frame->linesize[0];
|
||||||
if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE))
|
if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
frame_size = bytestream2_get_le32(&g2);
|
frame_size = bytestream2_get_le32(&g2);
|
||||||
@@ -273,12 +276,12 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
if ((line_packets & 0xC000) == 0xC000) {
|
if ((line_packets & 0xC000) == 0xC000) {
|
||||||
// line skip opcode
|
// line skip opcode
|
||||||
line_packets = -line_packets;
|
line_packets = -line_packets;
|
||||||
y_ptr += line_packets * s->frame.linesize[0];
|
y_ptr += line_packets * s->frame->linesize[0];
|
||||||
} else if ((line_packets & 0xC000) == 0x4000) {
|
} else if ((line_packets & 0xC000) == 0x4000) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
|
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
|
||||||
} else if ((line_packets & 0xC000) == 0x8000) {
|
} else if ((line_packets & 0xC000) == 0x8000) {
|
||||||
// "last byte" opcode
|
// "last byte" opcode
|
||||||
pixel_ptr= y_ptr + s->frame.linesize[0] - 1;
|
pixel_ptr= y_ptr + s->frame->linesize[0] - 1;
|
||||||
CHECK_PIXEL_PTR(0);
|
CHECK_PIXEL_PTR(0);
|
||||||
pixels[pixel_ptr] = line_packets & 0xff;
|
pixels[pixel_ptr] = line_packets & 0xff;
|
||||||
} else {
|
} else {
|
||||||
@@ -313,7 +316,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y_ptr += s->frame.linesize[0];
|
y_ptr += s->frame->linesize[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -322,7 +325,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
/* line compressed */
|
/* line compressed */
|
||||||
starting_line = bytestream2_get_le16(&g2);
|
starting_line = bytestream2_get_le16(&g2);
|
||||||
y_ptr = 0;
|
y_ptr = 0;
|
||||||
y_ptr += starting_line * s->frame.linesize[0];
|
y_ptr += starting_line * s->frame->linesize[0];
|
||||||
|
|
||||||
compressed_lines = bytestream2_get_le16(&g2);
|
compressed_lines = bytestream2_get_le16(&g2);
|
||||||
while (compressed_lines > 0) {
|
while (compressed_lines > 0) {
|
||||||
@@ -359,7 +362,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y_ptr += s->frame.linesize[0];
|
y_ptr += s->frame->linesize[0];
|
||||||
compressed_lines--;
|
compressed_lines--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -367,7 +370,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
case FLI_BLACK:
|
case FLI_BLACK:
|
||||||
/* set the whole frame to color 0 (which is usually black) */
|
/* set the whole frame to color 0 (which is usually black) */
|
||||||
memset(pixels, 0,
|
memset(pixels, 0,
|
||||||
s->frame.linesize[0] * s->avctx->height);
|
s->frame->linesize[0] * s->avctx->height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLI_BRUN:
|
case FLI_BRUN:
|
||||||
@@ -414,7 +417,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y_ptr += s->frame.linesize[0];
|
y_ptr += s->frame->linesize[0];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -425,8 +428,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
"has incorrect size, skipping chunk\n", chunk_size - 6);
|
"has incorrect size, skipping chunk\n", chunk_size - 6);
|
||||||
bytestream2_skip(&g2, chunk_size - 6);
|
bytestream2_skip(&g2, chunk_size - 6);
|
||||||
} else {
|
} else {
|
||||||
for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height;
|
for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
|
||||||
y_ptr += s->frame.linesize[0]) {
|
y_ptr += s->frame->linesize[0]) {
|
||||||
bytestream2_get_buffer(&g2, &pixels[y_ptr],
|
bytestream2_get_buffer(&g2, &pixels[y_ptr],
|
||||||
s->avctx->width);
|
s->avctx->width);
|
||||||
}
|
}
|
||||||
@@ -457,13 +460,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
|||||||
buf_size - bytestream2_get_bytes_left(&g2));
|
buf_size - bytestream2_get_bytes_left(&g2));
|
||||||
|
|
||||||
/* make the palette available on the way out */
|
/* make the palette available on the way out */
|
||||||
memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
|
memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE);
|
||||||
if (s->new_palette) {
|
if (s->new_palette) {
|
||||||
s->frame.palette_has_changed = 1;
|
s->frame->palette_has_changed = 1;
|
||||||
s->new_palette = 0;
|
s->new_palette = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = av_frame_ref(data, &s->frame)) < 0)
|
if ((ret = av_frame_ref(data, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@@ -504,11 +507,11 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
|
|
||||||
bytestream2_init(&g2, buf, buf_size);
|
bytestream2_init(&g2, buf, buf_size);
|
||||||
|
|
||||||
if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
|
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
pixels = s->frame.data[0];
|
pixels = s->frame->data[0];
|
||||||
pixel_limit = s->avctx->height * s->frame.linesize[0];
|
pixel_limit = s->avctx->height * s->frame->linesize[0];
|
||||||
|
|
||||||
frame_size = bytestream2_get_le32(&g2);
|
frame_size = bytestream2_get_le32(&g2);
|
||||||
bytestream2_skip(&g2, 2); /* skip the magic number */
|
bytestream2_skip(&g2, 2); /* skip the magic number */
|
||||||
@@ -556,7 +559,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
line_packets = bytestream2_get_le16(&g2);
|
line_packets = bytestream2_get_le16(&g2);
|
||||||
if (line_packets < 0) {
|
if (line_packets < 0) {
|
||||||
line_packets = -line_packets;
|
line_packets = -line_packets;
|
||||||
y_ptr += line_packets * s->frame.linesize[0];
|
y_ptr += line_packets * s->frame->linesize[0];
|
||||||
} else {
|
} else {
|
||||||
compressed_lines--;
|
compressed_lines--;
|
||||||
pixel_ptr = y_ptr;
|
pixel_ptr = y_ptr;
|
||||||
@@ -589,7 +592,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y_ptr += s->frame.linesize[0];
|
y_ptr += s->frame->linesize[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -602,7 +605,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
case FLI_BLACK:
|
case FLI_BLACK:
|
||||||
/* set the whole frame to 0x0000 which is black in both 15Bpp and 16Bpp modes. */
|
/* set the whole frame to 0x0000 which is black in both 15Bpp and 16Bpp modes. */
|
||||||
memset(pixels, 0x0000,
|
memset(pixels, 0x0000,
|
||||||
s->frame.linesize[0] * s->avctx->height);
|
s->frame->linesize[0] * s->avctx->height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLI_BRUN:
|
case FLI_BRUN:
|
||||||
@@ -657,7 +660,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
pixel_ptr += 2;
|
pixel_ptr += 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
y_ptr += s->frame.linesize[0];
|
y_ptr += s->frame->linesize[0];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -701,7 +704,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y_ptr += s->frame.linesize[0];
|
y_ptr += s->frame->linesize[0];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -714,8 +717,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
bytestream2_skip(&g2, chunk_size - 6);
|
bytestream2_skip(&g2, chunk_size - 6);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height;
|
for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
|
||||||
y_ptr += s->frame.linesize[0]) {
|
y_ptr += s->frame->linesize[0]) {
|
||||||
|
|
||||||
pixel_countdown = s->avctx->width;
|
pixel_countdown = s->avctx->width;
|
||||||
pixel_ptr = 0;
|
pixel_ptr = 0;
|
||||||
@@ -748,7 +751,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
|||||||
av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \
|
av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \
|
||||||
"and final chunk ptr = %d\n", buf_size, bytestream2_tell(&g2));
|
"and final chunk ptr = %d\n", buf_size, bytestream2_tell(&g2));
|
||||||
|
|
||||||
if ((ret = av_frame_ref(data, &s->frame)) < 0)
|
if ((ret = av_frame_ref(data, s->frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@@ -797,7 +800,7 @@ static av_cold int flic_decode_end(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
FlicDecodeContext *s = avctx->priv_data;
|
FlicDecodeContext *s = avctx->priv_data;
|
||||||
|
|
||||||
av_frame_unref(&s->frame);
|
av_frame_free(&s->frame);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -375,6 +375,8 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
|
|||||||
src += 3;
|
src += 3;
|
||||||
}
|
}
|
||||||
npal = *src++ + 1;
|
npal = *src++ + 1;
|
||||||
|
if (src_end - src < npal * 3)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
memcpy(pal, src, npal * 3); src += npal * 3;
|
memcpy(pal, src, npal * 3); src += npal * 3;
|
||||||
if (sub_type != 2) {
|
if (sub_type != 2) {
|
||||||
for (i = 0; i < npal; i++) {
|
for (i = 0; i < npal; i++) {
|
||||||
@@ -490,7 +492,7 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
|
|||||||
cursor_hot_y = bytestream2_get_byte(gb);
|
cursor_hot_y = bytestream2_get_byte(gb);
|
||||||
cursor_fmt = bytestream2_get_byte(gb);
|
cursor_fmt = bytestream2_get_byte(gb);
|
||||||
|
|
||||||
cursor_stride = FFALIGN(cursor_w, c->cursor_fmt==1 ? 32 : 1) * 4;
|
cursor_stride = FFALIGN(cursor_w, cursor_fmt==1 ? 32 : 1) * 4;
|
||||||
|
|
||||||
if (cursor_w < 1 || cursor_w > 256 ||
|
if (cursor_w < 1 || cursor_w > 256 ||
|
||||||
cursor_h < 1 || cursor_h > 256) {
|
cursor_h < 1 || cursor_h > 256) {
|
||||||
@@ -707,11 +709,15 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Unknown compression method %d\n",
|
"Unknown compression method %d\n",
|
||||||
c->compression);
|
c->compression);
|
||||||
return AVERROR_PATCHWELCOME;
|
ret = AVERROR_PATCHWELCOME;
|
||||||
|
goto header_fail;
|
||||||
}
|
}
|
||||||
c->tile_width = bytestream2_get_be32(&bc);
|
c->tile_width = bytestream2_get_be32(&bc);
|
||||||
c->tile_height = bytestream2_get_be32(&bc);
|
c->tile_height = bytestream2_get_be32(&bc);
|
||||||
if (!c->tile_width || !c->tile_height) {
|
if (c->tile_width <= 0 || c->tile_height <= 0 ||
|
||||||
|
((c->tile_width | c->tile_height) & 0xF) ||
|
||||||
|
c->tile_width * 4LL * c->tile_height >= INT_MAX
|
||||||
|
) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Invalid tile dimensions %dx%d\n",
|
"Invalid tile dimensions %dx%d\n",
|
||||||
c->tile_width, c->tile_height);
|
c->tile_width, c->tile_height);
|
||||||
|
@@ -2285,7 +2285,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]);
|
||||||
|
@@ -216,6 +216,13 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
|
|||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avctx->coded_frame = av_frame_alloc();
|
||||||
|
if (!avctx->coded_frame)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
avctx->coded_frame->key_frame = 1;
|
||||||
|
|
||||||
s->lzw = av_mallocz(ff_lzw_encode_state_size);
|
s->lzw = av_mallocz(ff_lzw_encode_state_size);
|
||||||
s->buf = av_malloc(avctx->width*avctx->height*2);
|
s->buf = av_malloc(avctx->width*avctx->height*2);
|
||||||
s->tmpl = av_malloc(avctx->width);
|
s->tmpl = av_malloc(avctx->width);
|
||||||
@@ -232,7 +239,6 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
const AVFrame *pict, int *got_packet)
|
const AVFrame *pict, int *got_packet)
|
||||||
{
|
{
|
||||||
GIFContext *s = avctx->priv_data;
|
GIFContext *s = avctx->priv_data;
|
||||||
AVFrame *const p = (AVFrame *)pict;
|
|
||||||
uint8_t *outbuf_ptr, *end;
|
uint8_t *outbuf_ptr, *end;
|
||||||
const uint32_t *palette = NULL;
|
const uint32_t *palette = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -242,15 +248,12 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
outbuf_ptr = pkt->data;
|
outbuf_ptr = pkt->data;
|
||||||
end = pkt->data + pkt->size;
|
end = pkt->data + pkt->size;
|
||||||
|
|
||||||
p->pict_type = AV_PICTURE_TYPE_I;
|
|
||||||
p->key_frame = 1;
|
|
||||||
|
|
||||||
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
|
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
|
||||||
uint8_t *pal_exdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
|
uint8_t *pal_exdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
|
||||||
if (!pal_exdata)
|
if (!pal_exdata)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
memcpy(pal_exdata, p->data[1], AVPALETTE_SIZE);
|
memcpy(pal_exdata, pict->data[1], AVPALETTE_SIZE);
|
||||||
palette = (uint32_t*)p->data[1];
|
palette = (uint32_t*)pict->data[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
gif_image_write_image(avctx, &outbuf_ptr, end, palette,
|
gif_image_write_image(avctx, &outbuf_ptr, end, palette,
|
||||||
@@ -276,6 +279,8 @@ static int gif_encode_close(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
GIFContext *s = avctx->priv_data;
|
GIFContext *s = avctx->priv_data;
|
||||||
|
|
||||||
|
av_frame_free(&avctx->coded_frame);
|
||||||
|
|
||||||
av_freep(&s->lzw);
|
av_freep(&s->lzw);
|
||||||
av_freep(&s->buf);
|
av_freep(&s->buf);
|
||||||
av_frame_free(&s->last_frame);
|
av_frame_free(&s->last_frame);
|
||||||
|
@@ -251,26 +251,21 @@ static int gif_read_image(GifState *s, AVFrame *frame)
|
|||||||
case 1:
|
case 1:
|
||||||
y1 += 8;
|
y1 += 8;
|
||||||
ptr += linesize * 8;
|
ptr += linesize * 8;
|
||||||
if (y1 >= height) {
|
|
||||||
y1 = pass ? 2 : 4;
|
|
||||||
ptr = ptr1 + linesize * y1;
|
|
||||||
pass++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
y1 += 4;
|
y1 += 4;
|
||||||
ptr += linesize * 4;
|
ptr += linesize * 4;
|
||||||
if (y1 >= height) {
|
|
||||||
y1 = 1;
|
|
||||||
ptr = ptr1 + linesize;
|
|
||||||
pass++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
y1 += 2;
|
y1 += 2;
|
||||||
ptr += linesize * 2;
|
ptr += linesize * 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
while (y1 >= height) {
|
||||||
|
y1 = 4 >> pass;
|
||||||
|
ptr = ptr1 + linesize * y1;
|
||||||
|
pass++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ptr += linesize;
|
ptr += linesize;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EXTEND(i) (i << 3 | i & 7)
|
#define EXTEND(i) ((i) << 3 | (i) & 7)
|
||||||
init_put_bits(&pb, temp, SIZE);
|
init_put_bits(&pb, temp, SIZE);
|
||||||
for (i = 0; i < COUNT; i++)
|
for (i = 0; i < COUNT; i++)
|
||||||
set_ue_golomb(&pb, EXTEND(i));
|
set_ue_golomb(&pb, EXTEND(i));
|
||||||
|
@@ -755,10 +755,9 @@ frame_end:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (startcode_found) {
|
if (startcode_found) {
|
||||||
av_fast_malloc(&s->bitstream_buffer,
|
av_fast_padded_mallocz(&s->bitstream_buffer,
|
||||||
&s->allocated_bitstream_buffer_size,
|
&s->allocated_bitstream_buffer_size,
|
||||||
buf_size - current_pos +
|
buf_size - current_pos);
|
||||||
FF_INPUT_BUFFER_PADDING_SIZE);
|
|
||||||
if (!s->bitstream_buffer)
|
if (!s->bitstream_buffer)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
memcpy(s->bitstream_buffer, buf + current_pos,
|
memcpy(s->bitstream_buffer, buf + current_pos,
|
||||||
|
@@ -452,6 +452,18 @@ static int alloc_picture(H264Context *h, Picture *pic)
|
|||||||
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
|
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!h->avctx->hwaccel && CONFIG_GRAY && h->flags & CODEC_FLAG_GRAY && pic->f.data[2]) {
|
||||||
|
int h_chroma_shift, v_chroma_shift;
|
||||||
|
av_pix_fmt_get_chroma_sub_sample(pic->f.format,
|
||||||
|
&h_chroma_shift, &v_chroma_shift);
|
||||||
|
|
||||||
|
for(i=0; i<FF_CEIL_RSHIFT(h->avctx->height, v_chroma_shift); i++) {
|
||||||
|
memset(pic->f.data[1] + pic->f.linesize[1]*i,
|
||||||
|
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||||
|
memset(pic->f.data[2] + pic->f.linesize[2]*i,
|
||||||
|
0x80, FF_CEIL_RSHIFT(h->avctx->width, h_chroma_shift));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!h->qscale_table_pool) {
|
if (!h->qscale_table_pool) {
|
||||||
ret = init_table_pools(h);
|
ret = init_table_pools(h);
|
||||||
@@ -586,18 +598,18 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
|
|||||||
|
|
||||||
if ((h->left_samples_available & 0x8080) != 0x8080) {
|
if ((h->left_samples_available & 0x8080) != 0x8080) {
|
||||||
mode = left[mode];
|
mode = left[mode];
|
||||||
if (is_chroma && (h->left_samples_available & 0x8080)) {
|
|
||||||
// mad cow disease mode, aka MBAFF + constrained_intra_pred
|
|
||||||
mode = ALZHEIMER_DC_L0T_PRED8x8 +
|
|
||||||
(!(h->left_samples_available & 0x8000)) +
|
|
||||||
2 * (mode == DC_128_PRED8x8);
|
|
||||||
}
|
|
||||||
if (mode < 0) {
|
if (mode < 0) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR,
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
"left block unavailable for requested intra mode at %d %d\n",
|
"left block unavailable for requested intra mode at %d %d\n",
|
||||||
h->mb_x, h->mb_y);
|
h->mb_x, h->mb_y);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
if (is_chroma && (h->left_samples_available & 0x8080)) {
|
||||||
|
// mad cow disease mode, aka MBAFF + constrained_intra_pred
|
||||||
|
mode = ALZHEIMER_DC_L0T_PRED8x8 +
|
||||||
|
(!(h->left_samples_available & 0x8000)) +
|
||||||
|
2 * (mode == DC_128_PRED8x8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mode;
|
return mode;
|
||||||
@@ -619,7 +631,7 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
|
|||||||
|
|
||||||
#define STARTCODE_TEST \
|
#define STARTCODE_TEST \
|
||||||
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
|
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
|
||||||
if (src[i + 2] != 3) { \
|
if (src[i + 2] != 3 && src[i + 2] != 0) { \
|
||||||
/* startcode, so we must be past the end */ \
|
/* startcode, so we must be past the end */ \
|
||||||
length = i; \
|
length = i; \
|
||||||
} \
|
} \
|
||||||
@@ -692,7 +704,7 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
|
|||||||
if (src[si + 2] > 3) {
|
if (src[si + 2] > 3) {
|
||||||
dst[di++] = src[si++];
|
dst[di++] = src[si++];
|
||||||
dst[di++] = src[si++];
|
dst[di++] = src[si++];
|
||||||
} else if (src[si] == 0 && src[si + 1] == 0) {
|
} else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) {
|
||||||
if (src[si + 2] == 3) { // escape
|
if (src[si + 2] == 3) { // escape
|
||||||
dst[di++] = 0;
|
dst[di++] = 0;
|
||||||
dst[di++] = 0;
|
dst[di++] = 0;
|
||||||
@@ -1219,6 +1231,7 @@ static void free_tables(H264Context *h, int free_rbsp)
|
|||||||
av_buffer_pool_uninit(&h->ref_index_pool);
|
av_buffer_pool_uninit(&h->ref_index_pool);
|
||||||
|
|
||||||
if (free_rbsp && h->DPB) {
|
if (free_rbsp && h->DPB) {
|
||||||
|
memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
|
||||||
for (i = 0; i < MAX_PICTURE_COUNT; i++)
|
for (i = 0; i < MAX_PICTURE_COUNT; i++)
|
||||||
unref_picture(h, &h->DPB[i]);
|
unref_picture(h, &h->DPB[i]);
|
||||||
av_freep(&h->DPB);
|
av_freep(&h->DPB);
|
||||||
@@ -1686,6 +1699,7 @@ static int decode_init_thread_copy(AVCodecContext *avctx)
|
|||||||
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
|
memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
|
||||||
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
|
memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
|
||||||
|
|
||||||
|
h->avctx = avctx;
|
||||||
h->rbsp_buffer[0] = NULL;
|
h->rbsp_buffer[0] = NULL;
|
||||||
h->rbsp_buffer[1] = NULL;
|
h->rbsp_buffer[1] = NULL;
|
||||||
h->rbsp_buffer_size[0] = 0;
|
h->rbsp_buffer_size[0] = 0;
|
||||||
@@ -1787,6 +1801,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
|
|||||||
memset(&h->mb, 0, sizeof(h->mb));
|
memset(&h->mb, 0, sizeof(h->mb));
|
||||||
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
|
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
|
||||||
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
|
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
|
||||||
|
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
|
||||||
|
|
||||||
h->avctx = dst;
|
h->avctx = dst;
|
||||||
h->DPB = NULL;
|
h->DPB = NULL;
|
||||||
@@ -1794,6 +1809,17 @@ static int decode_update_thread_context(AVCodecContext *dst,
|
|||||||
h->mb_type_pool = NULL;
|
h->mb_type_pool = NULL;
|
||||||
h->ref_index_pool = NULL;
|
h->ref_index_pool = NULL;
|
||||||
h->motion_val_pool = NULL;
|
h->motion_val_pool = NULL;
|
||||||
|
h->intra4x4_pred_mode= NULL;
|
||||||
|
h->non_zero_count = NULL;
|
||||||
|
h->slice_table_base = NULL;
|
||||||
|
h->slice_table = NULL;
|
||||||
|
h->cbp_table = NULL;
|
||||||
|
h->chroma_pred_mode_table = NULL;
|
||||||
|
memset(h->mvd_table, 0, sizeof(h->mvd_table));
|
||||||
|
h->direct_table = NULL;
|
||||||
|
h->list_counts = NULL;
|
||||||
|
h->mb2b_xy = NULL;
|
||||||
|
h->mb2br_xy = NULL;
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
h->rbsp_buffer[i] = NULL;
|
h->rbsp_buffer[i] = NULL;
|
||||||
h->rbsp_buffer_size[i] = 0;
|
h->rbsp_buffer_size[i] = 0;
|
||||||
@@ -1839,7 +1865,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
|
|||||||
|
|
||||||
for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
|
for (i = 0; h->DPB && i < MAX_PICTURE_COUNT; i++) {
|
||||||
unref_picture(h, &h->DPB[i]);
|
unref_picture(h, &h->DPB[i]);
|
||||||
if (h1->DPB[i].f.data[0] &&
|
if (h1->DPB && h1->DPB[i].f.data[0] &&
|
||||||
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
|
(ret = ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1957,6 +1983,10 @@ static int h264_frame_start(H264Context *h)
|
|||||||
|
|
||||||
h->cur_pic_ptr = pic;
|
h->cur_pic_ptr = pic;
|
||||||
unref_picture(h, &h->cur_pic);
|
unref_picture(h, &h->cur_pic);
|
||||||
|
if (CONFIG_ERROR_RESILIENCE) {
|
||||||
|
h->er.cur_pic = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
|
if ((ret = ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -2612,6 +2642,16 @@ int ff_pred_weight_table(H264Context *h)
|
|||||||
h->luma_log2_weight_denom = get_ue_golomb(&h->gb);
|
h->luma_log2_weight_denom = get_ue_golomb(&h->gb);
|
||||||
if (h->sps.chroma_format_idc)
|
if (h->sps.chroma_format_idc)
|
||||||
h->chroma_log2_weight_denom = get_ue_golomb(&h->gb);
|
h->chroma_log2_weight_denom = get_ue_golomb(&h->gb);
|
||||||
|
|
||||||
|
if (h->luma_log2_weight_denom > 7U) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", h->luma_log2_weight_denom);
|
||||||
|
h->luma_log2_weight_denom = 0;
|
||||||
|
}
|
||||||
|
if (h->chroma_log2_weight_denom > 7U) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", h->chroma_log2_weight_denom);
|
||||||
|
h->chroma_log2_weight_denom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
luma_def = 1 << h->luma_log2_weight_denom;
|
luma_def = 1 << h->luma_log2_weight_denom;
|
||||||
chroma_def = 1 << h->chroma_log2_weight_denom;
|
chroma_def = 1 << h->chroma_log2_weight_denom;
|
||||||
|
|
||||||
@@ -3354,6 +3394,17 @@ int ff_set_ref_count(H264Context *h)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
|
||||||
|
{
|
||||||
|
switch (a) {
|
||||||
|
case AV_PIX_FMT_YUVJ420P: return AV_PIX_FMT_YUV420P;
|
||||||
|
case AV_PIX_FMT_YUVJ422P: return AV_PIX_FMT_YUV422P;
|
||||||
|
case AV_PIX_FMT_YUVJ444P: return AV_PIX_FMT_YUV444P;
|
||||||
|
default:
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode a slice header.
|
* Decode a slice header.
|
||||||
* This will also call ff_MPV_common_init() and frame_start() as needed.
|
* This will also call ff_MPV_common_init() and frame_start() as needed.
|
||||||
@@ -3374,6 +3425,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
int must_reinit;
|
int must_reinit;
|
||||||
int needs_reinit = 0;
|
int needs_reinit = 0;
|
||||||
int field_pic_flag, bottom_field_flag;
|
int field_pic_flag, bottom_field_flag;
|
||||||
|
int first_slice = h == h0 && !h0->current_slice;
|
||||||
|
int frame_num, picture_structure, droppable;
|
||||||
|
PPS *pps;
|
||||||
|
|
||||||
h->me.qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
|
h->me.qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
|
||||||
h->me.qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
|
h->me.qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
|
||||||
@@ -3426,20 +3480,33 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
pps_id);
|
pps_id);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
h->pps = *h0->pps_buffers[pps_id];
|
if (h0->au_pps_id >= 0 && pps_id != h0->au_pps_id) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
|
"PPS change from %d to %d forbidden\n",
|
||||||
|
h0->au_pps_id, pps_id);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
if (!h0->sps_buffers[h->pps.sps_id]) {
|
pps = h0->pps_buffers[pps_id];
|
||||||
|
|
||||||
|
if (!h0->sps_buffers[pps->sps_id]) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR,
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
"non-existing SPS %u referenced\n",
|
"non-existing SPS %u referenced\n",
|
||||||
h->pps.sps_id);
|
h->pps.sps_id);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
if (first_slice)
|
||||||
|
h->pps = *h0->pps_buffers[pps_id];
|
||||||
|
|
||||||
if (h->pps.sps_id != h->current_sps_id ||
|
if (pps->sps_id != h->current_sps_id ||
|
||||||
h0->sps_buffers[h->pps.sps_id]->new) {
|
h0->sps_buffers[pps->sps_id]->new) {
|
||||||
h0->sps_buffers[h->pps.sps_id]->new = 0;
|
|
||||||
|
if (!first_slice) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
|
"SPS changed in the middle of the frame\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
h->current_sps_id = h->pps.sps_id;
|
|
||||||
h->sps = *h0->sps_buffers[h->pps.sps_id];
|
h->sps = *h0->sps_buffers[h->pps.sps_id];
|
||||||
|
|
||||||
if (h->mb_width != h->sps.mb_width ||
|
if (h->mb_width != h->sps.mb_width ||
|
||||||
@@ -3468,11 +3535,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
|| 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height
|
|| 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != h->avctx->coded_height
|
||||||
|| h->avctx->bits_per_raw_sample != h->sps.bit_depth_luma
|
|| h->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
|
||||||
|| av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio)
|
|
||||||
|| h->mb_width != h->sps.mb_width
|
|| h->mb_width != h->sps.mb_width
|
||||||
|| h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
|
|| h->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag)
|
||||||
));
|
));
|
||||||
if (h0->avctx->pix_fmt != get_pixel_format(h0, 0))
|
if (non_j_pixfmt(h0->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h0, 0)))
|
||||||
|
must_reinit = 1;
|
||||||
|
|
||||||
|
if (first_slice && av_cmp_q(h->sps.sar, h->avctx->sample_aspect_ratio))
|
||||||
must_reinit = 1;
|
must_reinit = 1;
|
||||||
|
|
||||||
h->mb_width = h->sps.mb_width;
|
h->mb_width = h->sps.mb_width;
|
||||||
@@ -3547,44 +3616,48 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h == h0 && h->dequant_coeff_pps != pps_id) {
|
if (first_slice && h->dequant_coeff_pps != pps_id) {
|
||||||
h->dequant_coeff_pps = pps_id;
|
h->dequant_coeff_pps = pps_id;
|
||||||
init_dequant_tables(h);
|
init_dequant_tables(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
|
frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
|
||||||
|
if (!first_slice) {
|
||||||
|
if (h0->frame_num != frame_num) {
|
||||||
|
av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n",
|
||||||
|
h0->frame_num, frame_num);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h->mb_mbaff = 0;
|
h->mb_mbaff = 0;
|
||||||
h->mb_aff_frame = 0;
|
h->mb_aff_frame = 0;
|
||||||
last_pic_structure = h0->picture_structure;
|
last_pic_structure = h0->picture_structure;
|
||||||
last_pic_droppable = h0->droppable;
|
last_pic_droppable = h0->droppable;
|
||||||
h->droppable = h->nal_ref_idc == 0;
|
droppable = h->nal_ref_idc == 0;
|
||||||
if (h->sps.frame_mbs_only_flag) {
|
if (h->sps.frame_mbs_only_flag) {
|
||||||
h->picture_structure = PICT_FRAME;
|
picture_structure = PICT_FRAME;
|
||||||
} else {
|
} else {
|
||||||
if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
|
if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
|
av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
field_pic_flag = get_bits1(&h->gb);
|
field_pic_flag = get_bits1(&h->gb);
|
||||||
|
|
||||||
if (field_pic_flag) {
|
if (field_pic_flag) {
|
||||||
bottom_field_flag = get_bits1(&h->gb);
|
bottom_field_flag = get_bits1(&h->gb);
|
||||||
h->picture_structure = PICT_TOP_FIELD + bottom_field_flag;
|
picture_structure = PICT_TOP_FIELD + bottom_field_flag;
|
||||||
} else {
|
} else {
|
||||||
h->picture_structure = PICT_FRAME;
|
picture_structure = PICT_FRAME;
|
||||||
h->mb_aff_frame = h->sps.mb_aff;
|
h->mb_aff_frame = h->sps.mb_aff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h->mb_field_decoding_flag = h->picture_structure != PICT_FRAME;
|
if (h0->current_slice) {
|
||||||
|
if (last_pic_structure != picture_structure ||
|
||||||
if (h0->current_slice != 0) {
|
last_pic_droppable != droppable) {
|
||||||
if (last_pic_structure != h->picture_structure ||
|
|
||||||
last_pic_droppable != h->droppable) {
|
|
||||||
av_log(h->avctx, AV_LOG_ERROR,
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
"Changing field mode (%d -> %d) between slices is not allowed\n",
|
"Changing field mode (%d -> %d) between slices is not allowed\n",
|
||||||
last_pic_structure, h->picture_structure);
|
last_pic_structure, h->picture_structure);
|
||||||
h->picture_structure = last_pic_structure;
|
|
||||||
h->droppable = last_pic_droppable;
|
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
} else if (!h0->cur_pic_ptr) {
|
} else if (!h0->cur_pic_ptr) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR,
|
av_log(h->avctx, AV_LOG_ERROR,
|
||||||
@@ -3592,10 +3665,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
h0->current_slice + 1);
|
h0->current_slice + 1);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
h->picture_structure = picture_structure;
|
||||||
|
h->droppable = droppable;
|
||||||
|
h->frame_num = frame_num;
|
||||||
|
h->mb_field_decoding_flag = picture_structure != PICT_FRAME;
|
||||||
|
|
||||||
|
if (h0->current_slice == 0) {
|
||||||
/* Shorten frame num gaps so we don't have to allocate reference
|
/* Shorten frame num gaps so we don't have to allocate reference
|
||||||
* frames just to throw them away */
|
* frames just to throw them away */
|
||||||
if (h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0) {
|
if (h->frame_num != h->prev_frame_num) {
|
||||||
int unwrap_prev_frame_num = h->prev_frame_num;
|
int unwrap_prev_frame_num = h->prev_frame_num;
|
||||||
int max_frame_num = 1 << h->sps.log2_max_frame_num;
|
int max_frame_num = 1 << h->sps.log2_max_frame_num;
|
||||||
|
|
||||||
@@ -3668,7 +3748,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0 && !h0->first_field &&
|
while (h->frame_num != h->prev_frame_num && !h0->first_field &&
|
||||||
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
|
h->frame_num != (h->prev_frame_num + 1) % (1 << h->sps.log2_max_frame_num)) {
|
||||||
Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
|
Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
|
||||||
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
|
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
|
||||||
@@ -3924,8 +4004,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
if (h->deblocking_filter) {
|
if (h->deblocking_filter) {
|
||||||
h->slice_alpha_c0_offset += get_se_golomb(&h->gb) << 1;
|
h->slice_alpha_c0_offset += get_se_golomb(&h->gb) << 1;
|
||||||
h->slice_beta_offset += get_se_golomb(&h->gb) << 1;
|
h->slice_beta_offset += get_se_golomb(&h->gb) << 1;
|
||||||
if (h->slice_alpha_c0_offset > 104U ||
|
if (h->slice_alpha_c0_offset < 52 - 12 || h->slice_alpha_c0_offset > 52 + 12 ||
|
||||||
h->slice_beta_offset > 104U) {
|
h->slice_beta_offset < 52 - 12 || h->slice_beta_offset > 52 + 12) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR,
|
av_log(h->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);
|
||||||
@@ -4018,6 +4098,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
|
|||||||
if (h->ref_count[0]) h->er.last_pic = &h->ref_list[0][0];
|
if (h->ref_count[0]) h->er.last_pic = &h->ref_list[0][0];
|
||||||
if (h->ref_count[1]) h->er.next_pic = &h->ref_list[1][0];
|
if (h->ref_count[1]) h->er.next_pic = &h->ref_list[1][0];
|
||||||
h->er.ref_count = h->ref_count[0];
|
h->er.ref_count = h->ref_count[0];
|
||||||
|
h0->au_pps_id = pps_id;
|
||||||
|
h->sps.new =
|
||||||
|
h0->sps_buffers[h->pps.sps_id]->new = 0;
|
||||||
|
h->current_sps_id = h->pps.sps_id;
|
||||||
|
|
||||||
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
|
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
|
||||||
av_log(h->avctx, AV_LOG_DEBUG,
|
av_log(h->avctx, AV_LOG_DEBUG,
|
||||||
@@ -4601,6 +4685,8 @@ static int execute_decode_slices(H264Context *h, int context_count)
|
|||||||
H264Context *hx;
|
H264Context *hx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
av_assert0(h->mb_y < h->mb_height);
|
||||||
|
|
||||||
if (h->avctx->hwaccel ||
|
if (h->avctx->hwaccel ||
|
||||||
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
|
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -4782,6 +4868,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
|
if ( !(avctx->active_thread_type & FF_THREAD_FRAME)
|
||||||
|
|| nals_needed >= nal_index)
|
||||||
|
h->au_pps_id = -1;
|
||||||
/* Ignore per frame NAL unit type during extradata
|
/* Ignore per frame NAL unit type during extradata
|
||||||
* parsing. Decoding slices is not possible in codec init
|
* parsing. Decoding slices is not possible in codec init
|
||||||
* with frame-mt */
|
* with frame-mt */
|
||||||
@@ -4814,6 +4903,7 @@ again:
|
|||||||
if(!idr_cleared)
|
if(!idr_cleared)
|
||||||
idr(h); // FIXME ensure we don't lose some frames if there is reordering
|
idr(h); // FIXME ensure we don't lose some frames if there is reordering
|
||||||
idr_cleared = 1;
|
idr_cleared = 1;
|
||||||
|
h->has_recovery_point = 1;
|
||||||
case NAL_SLICE:
|
case NAL_SLICE:
|
||||||
init_get_bits(&hx->gb, ptr, bit_length);
|
init_get_bits(&hx->gb, ptr, bit_length);
|
||||||
hx->intra_gb_ptr =
|
hx->intra_gb_ptr =
|
||||||
@@ -5004,6 +5094,7 @@ static int get_consumed_bytes(int pos, int buf_size)
|
|||||||
static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
|
static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
|
||||||
{
|
{
|
||||||
AVFrame *src = &srcp->f;
|
AVFrame *src = &srcp->f;
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src->format);
|
||||||
int i;
|
int i;
|
||||||
int ret = av_frame_ref(dst, src);
|
int ret = av_frame_ref(dst, src);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -5014,9 +5105,9 @@ static int output_frame(H264Context *h, AVFrame *dst, Picture *srcp)
|
|||||||
if (!srcp->crop)
|
if (!srcp->crop)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < desc->nb_components; i++) {
|
||||||
int hshift = (i > 0) ? h->chroma_x_shift : 0;
|
int hshift = (i > 0) ? desc->log2_chroma_w : 0;
|
||||||
int vshift = (i > 0) ? h->chroma_y_shift : 0;
|
int vshift = (i > 0) ? desc->log2_chroma_h : 0;
|
||||||
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
|
int off = ((srcp->crop_left >> hshift) << h->pixel_shift) +
|
||||||
(srcp->crop_top >> vshift) * dst->linesize[i];
|
(srcp->crop_top >> vshift) * dst->linesize[i];
|
||||||
dst->data[i] += off;
|
dst->data[i] += off;
|
||||||
|
@@ -61,10 +61,10 @@
|
|||||||
#define MAX_SLICES 16
|
#define MAX_SLICES 16
|
||||||
|
|
||||||
#ifdef ALLOW_INTERLACE
|
#ifdef ALLOW_INTERLACE
|
||||||
#define MB_MBAFF(h) h->mb_mbaff
|
#define MB_MBAFF(h) (h)->mb_mbaff
|
||||||
#define MB_FIELD(h) h->mb_field_decoding_flag
|
#define MB_FIELD(h) (h)->mb_field_decoding_flag
|
||||||
#define FRAME_MBAFF(h) h->mb_aff_frame
|
#define FRAME_MBAFF(h) (h)->mb_aff_frame
|
||||||
#define FIELD_PICTURE(h) (h->picture_structure != PICT_FRAME)
|
#define FIELD_PICTURE(h) ((h)->picture_structure != PICT_FRAME)
|
||||||
#define LEFT_MBS 2
|
#define LEFT_MBS 2
|
||||||
#define LTOP 0
|
#define LTOP 0
|
||||||
#define LBOT 1
|
#define LBOT 1
|
||||||
@@ -84,12 +84,12 @@
|
|||||||
#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
|
#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
|
||||||
|
|
||||||
#ifndef CABAC
|
#ifndef CABAC
|
||||||
#define CABAC(h) h->pps.cabac
|
#define CABAC(h) (h)->pps.cabac
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CHROMA(h) (h->sps.chroma_format_idc)
|
#define CHROMA(h) ((h)->sps.chroma_format_idc)
|
||||||
#define CHROMA422(h) (h->sps.chroma_format_idc == 2)
|
#define CHROMA422(h) ((h)->sps.chroma_format_idc == 2)
|
||||||
#define CHROMA444(h) (h->sps.chroma_format_idc == 3)
|
#define CHROMA444(h) ((h)->sps.chroma_format_idc == 3)
|
||||||
|
|
||||||
#define EXTENDED_SAR 255
|
#define EXTENDED_SAR 255
|
||||||
|
|
||||||
@@ -284,6 +284,7 @@ typedef struct MMCO {
|
|||||||
* H264Context
|
* H264Context
|
||||||
*/
|
*/
|
||||||
typedef struct H264Context {
|
typedef struct H264Context {
|
||||||
|
AVClass *av_class;
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
VideoDSPContext vdsp;
|
VideoDSPContext vdsp;
|
||||||
H264DSPContext h264dsp;
|
H264DSPContext h264dsp;
|
||||||
@@ -390,6 +391,8 @@ typedef struct H264Context {
|
|||||||
*/
|
*/
|
||||||
PPS pps; // FIXME move to Picture perhaps? (->no) do we need that?
|
PPS pps; // FIXME move to Picture perhaps? (->no) do we need that?
|
||||||
|
|
||||||
|
int au_pps_id; ///< pps_id of current access unit
|
||||||
|
|
||||||
uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down?
|
uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down?
|
||||||
uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
|
uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
|
||||||
uint32_t(*dequant4_coeff[6])[16];
|
uint32_t(*dequant4_coeff[6])[16];
|
||||||
@@ -656,6 +659,8 @@ typedef struct H264Context {
|
|||||||
|
|
||||||
FPA sei_fpa;
|
FPA sei_fpa;
|
||||||
|
|
||||||
|
int has_recovery_point;
|
||||||
|
|
||||||
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
|
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
|
||||||
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
|
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
|
||||||
|
|
||||||
|
@@ -1279,7 +1279,7 @@ void ff_h264_init_cabac_states(H264Context *h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int decode_cabac_field_decoding_flag(H264Context *h) {
|
static int decode_cabac_field_decoding_flag(H264Context *h) {
|
||||||
const long mbb_xy = h->mb_xy - 2L*h->mb_stride;
|
const int mbb_xy = h->mb_xy - 2*h->mb_stride;
|
||||||
|
|
||||||
unsigned long ctx = 0;
|
unsigned long ctx = 0;
|
||||||
|
|
||||||
|
@@ -174,11 +174,11 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
|
|||||||
buf += ctx->length_size;
|
buf += ctx->length_size;
|
||||||
unit_type = *buf & 0x1f;
|
unit_type = *buf & 0x1f;
|
||||||
|
|
||||||
if (buf + nal_size > buf_end || nal_size < 0)
|
if (nal_size > buf_end - buf || nal_size < 0)
|
||||||
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)
|
||||||
|
@@ -376,7 +376,9 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
|
|||||||
}
|
}
|
||||||
sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8;
|
sps->bit_depth_luma = get_ue_golomb(&h->gb) + 8;
|
||||||
sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;
|
sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;
|
||||||
if (sps->bit_depth_luma > 14U || sps->bit_depth_chroma > 14U || sps->bit_depth_luma != sps->bit_depth_chroma) {
|
if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 ||
|
||||||
|
sps->bit_depth_chroma < 8 || sps->bit_depth_chroma > 14 ||
|
||||||
|
sps->bit_depth_luma != sps->bit_depth_chroma) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
|
av_log(h->avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
|
||||||
sps->bit_depth_luma, sps->bit_depth_chroma);
|
sps->bit_depth_luma, sps->bit_depth_chroma);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@@ -562,6 +562,7 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
|
|||||||
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
||||||
{
|
{
|
||||||
int i, av_uninit(j);
|
int i, av_uninit(j);
|
||||||
|
int pps_count;
|
||||||
int current_ref_assigned = 0, err = 0;
|
int current_ref_assigned = 0, err = 0;
|
||||||
Picture *av_uninit(pic);
|
Picture *av_uninit(pic);
|
||||||
|
|
||||||
@@ -680,7 +681,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
|
|||||||
*/
|
*/
|
||||||
if (h->short_ref_count && h->short_ref[0] == h->cur_pic_ptr) {
|
if (h->short_ref_count && h->short_ref[0] == h->cur_pic_ptr) {
|
||||||
/* Just mark the second field valid */
|
/* Just mark the second field valid */
|
||||||
h->cur_pic_ptr->reference = PICT_FRAME;
|
h->cur_pic_ptr->reference |= h->picture_structure;
|
||||||
} else if (h->cur_pic_ptr->long_ref) {
|
} else if (h->cur_pic_ptr->long_ref) {
|
||||||
av_log(h->avctx, AV_LOG_ERROR, "illegal short term reference "
|
av_log(h->avctx, AV_LOG_ERROR, "illegal short term reference "
|
||||||
"assignment for second field "
|
"assignment for second field "
|
||||||
@@ -732,7 +733,15 @@ 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]<=2 + (h->picture_structure != PICT_FRAME) && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
pps_count = 0;
|
||||||
|
for (i = 0; i < FF_ARRAY_ELEMS(h->pps_buffers); i++)
|
||||||
|
pps_count += !!h->pps_buffers[i];
|
||||||
|
|
||||||
|
if ( err >= 0
|
||||||
|
&& h->long_ref_count==0
|
||||||
|
&& (h->short_ref_count<=2 || h->pps.ref_count[0] <= 1 && h->pps.ref_count[1] <= 1 && pps_count == 1)
|
||||||
|
&& h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point)
|
||||||
|
&& h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
|
||||||
h->cur_pic_ptr->sync |= 1;
|
h->cur_pic_ptr->sync |= 1;
|
||||||
if(!h->avctx->has_b_frames)
|
if(!h->avctx->has_b_frames)
|
||||||
h->sync = 2;
|
h->sync = 2;
|
||||||
|
@@ -184,6 +184,8 @@ static int decode_recovery_point(H264Context *h)
|
|||||||
if (h->avctx->debug & FF_DEBUG_PICT_INFO)
|
if (h->avctx->debug & FF_DEBUG_PICT_INFO)
|
||||||
av_log(h->avctx, AV_LOG_DEBUG, "sei_recovery_frame_cnt: %d\n", h->sei_recovery_frame_cnt);
|
av_log(h->avctx, AV_LOG_DEBUG, "sei_recovery_frame_cnt: %d\n", h->sei_recovery_frame_cnt);
|
||||||
|
|
||||||
|
h->has_recovery_point = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,24 +105,26 @@ static int pic_arrays_init(HEVCContext *s)
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s->skip_flag = av_malloc(pic_size_in_ctb);
|
s->skip_flag = av_malloc(pic_size_in_ctb);
|
||||||
s->tab_ct_depth = av_malloc(s->sps->min_cb_height * s->sps->min_cb_width);
|
s->tab_ct_depth = av_malloc_array(s->sps->min_cb_height, s->sps->min_cb_width);
|
||||||
if (!s->skip_flag || !s->tab_ct_depth)
|
if (!s->skip_flag || !s->tab_ct_depth)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s->tab_ipm = av_malloc(pic_size_in_min_pu);
|
s->tab_ipm = av_mallocz(pic_size_in_min_pu);
|
||||||
s->cbf_luma = av_malloc(pic_width_in_min_tu * pic_height_in_min_tu);
|
s->cbf_luma = av_malloc_array(pic_width_in_min_tu, pic_height_in_min_tu);
|
||||||
s->is_pcm = av_malloc(pic_size_in_min_pu);
|
s->is_pcm = av_malloc(pic_size_in_min_pu);
|
||||||
if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
|
if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s->filter_slice_edges = av_malloc(ctb_count);
|
s->filter_slice_edges = av_mallocz(ctb_count);
|
||||||
s->tab_slice_address = av_malloc(pic_size_in_ctb * sizeof(*s->tab_slice_address));
|
s->tab_slice_address = av_malloc_array(pic_size_in_ctb,
|
||||||
s->qp_y_tab = av_malloc(pic_size_in_ctb * sizeof(*s->qp_y_tab));
|
sizeof(*s->tab_slice_address));
|
||||||
|
s->qp_y_tab = av_malloc_array(pic_size_in_ctb,
|
||||||
|
sizeof(*s->qp_y_tab));
|
||||||
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
|
if (!s->qp_y_tab || !s->filter_slice_edges || !s->tab_slice_address)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s->horizontal_bs = av_mallocz(2 * s->bs_width * (s->bs_height + 1));
|
s->horizontal_bs = av_mallocz_array(2 * s->bs_width, (s->bs_height + 1));
|
||||||
s->vertical_bs = av_mallocz(2 * s->bs_width * (s->bs_height + 1));
|
s->vertical_bs = av_mallocz_array(2 * s->bs_width, (s->bs_height + 1));
|
||||||
if (!s->horizontal_bs || !s->vertical_bs)
|
if (!s->horizontal_bs || !s->vertical_bs)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -599,9 +601,14 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
av_freep(&sh->entry_point_offset);
|
av_freep(&sh->entry_point_offset);
|
||||||
av_freep(&sh->offset);
|
av_freep(&sh->offset);
|
||||||
av_freep(&sh->size);
|
av_freep(&sh->size);
|
||||||
sh->entry_point_offset = av_malloc(sh->num_entry_point_offsets * sizeof(int));
|
sh->entry_point_offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
|
||||||
sh->offset = av_malloc(sh->num_entry_point_offsets * sizeof(int));
|
sh->offset = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
|
||||||
sh->size = av_malloc(sh->num_entry_point_offsets * sizeof(int));
|
sh->size = av_malloc_array(sh->num_entry_point_offsets, sizeof(int));
|
||||||
|
if (!sh->entry_point_offset || !sh->offset || !sh->size) {
|
||||||
|
sh->num_entry_point_offsets = 0;
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
for (i = 0; i < sh->num_entry_point_offsets; i++) {
|
for (i = 0; i < sh->num_entry_point_offsets; i++) {
|
||||||
int val = 0;
|
int val = 0;
|
||||||
for (j = 0; j < segments; j++) {
|
for (j = 0; j < segments; j++) {
|
||||||
@@ -630,14 +637,24 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inferred parameters
|
// Inferred parameters
|
||||||
sh->slice_qp = 26 + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
|
sh->slice_qp = 26U + s->pps->pic_init_qp_minus26 + sh->slice_qp_delta;
|
||||||
|
if (sh->slice_qp > 51 ||
|
||||||
|
sh->slice_qp < -s->sps->qp_bd_offset) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"The slice_qp %d is outside the valid range "
|
||||||
|
"[%d, 51].\n",
|
||||||
|
sh->slice_qp,
|
||||||
|
-s->sps->qp_bd_offset);
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
|
sh->slice_ctb_addr_rs = sh->slice_segment_addr;
|
||||||
|
|
||||||
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
|
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
|
||||||
|
|
||||||
if (!s->pps->cu_qp_delta_enabled_flag)
|
if (!s->pps->cu_qp_delta_enabled_flag)
|
||||||
s->HEVClc->qp_y = ((s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset) %
|
s->HEVClc->qp_y = FFUMOD(s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset,
|
||||||
(52 + s->sps->qp_bd_offset)) - s->sps->qp_bd_offset;
|
52 + s->sps->qp_bd_offset) - s->sps->qp_bd_offset;
|
||||||
|
|
||||||
s->slice_initialized = 1;
|
s->slice_initialized = 1;
|
||||||
|
|
||||||
@@ -728,8 +745,7 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
|
|||||||
#undef SET_SAO
|
#undef SET_SAO
|
||||||
#undef CTB
|
#undef CTB
|
||||||
|
|
||||||
|
static int hls_transform_unit(HEVCContext *s, int x0, int y0,
|
||||||
static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
|
||||||
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||||
int log2_cb_size, int log2_trafo_size,
|
int log2_cb_size, int log2_trafo_size,
|
||||||
int trafo_depth, int blk_idx)
|
int trafo_depth, int blk_idx)
|
||||||
@@ -766,6 +782,18 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
|||||||
if (ff_hevc_cu_qp_delta_sign_flag(s) == 1)
|
if (ff_hevc_cu_qp_delta_sign_flag(s) == 1)
|
||||||
lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta;
|
lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta;
|
||||||
lc->tu.is_cu_qp_delta_coded = 1;
|
lc->tu.is_cu_qp_delta_coded = 1;
|
||||||
|
|
||||||
|
if (lc->tu.cu_qp_delta < -(26 + s->sps->qp_bd_offset / 2) ||
|
||||||
|
lc->tu.cu_qp_delta > (25 + s->sps->qp_bd_offset / 2)) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"The cu_qp_delta %d is outside the valid range "
|
||||||
|
"[%d, %d].\n",
|
||||||
|
lc->tu.cu_qp_delta,
|
||||||
|
-(26 + s->sps->qp_bd_offset / 2),
|
||||||
|
(25 + s->sps->qp_bd_offset / 2));
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
ff_hevc_set_qPy(s, x0, y0, cb_xBase, cb_yBase, log2_cb_size);
|
ff_hevc_set_qPy(s, x0, y0, cb_xBase, cb_yBase, log2_cb_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,6 +829,7 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
|
|||||||
ff_hevc_hls_residual_coding(s, xBase, yBase, log2_trafo_size, scan_idx_c, 2);
|
ff_hevc_hls_residual_coding(s, xBase, yBase, log2_trafo_size, scan_idx_c, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||||
@@ -818,13 +847,14 @@ static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_si
|
|||||||
s->is_pcm[i + j * min_pu_width] = 2;
|
s->is_pcm[i + j * min_pu_width] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
static int hls_transform_tree(HEVCContext *s, int x0, int y0,
|
||||||
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
int xBase, int yBase, int cb_xBase, int cb_yBase,
|
||||||
int log2_cb_size, int log2_trafo_size,
|
int log2_cb_size, int log2_trafo_size,
|
||||||
int trafo_depth, int blk_idx)
|
int trafo_depth, int blk_idx)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
uint8_t split_transform_flag;
|
uint8_t split_transform_flag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (trafo_depth > 0 && log2_trafo_size == 2) {
|
if (trafo_depth > 0 && log2_trafo_size == 2) {
|
||||||
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
|
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) =
|
||||||
@@ -877,14 +907,26 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
|||||||
int x1 = x0 + ((1 << log2_trafo_size) >> 1);
|
int x1 = x0 + ((1 << log2_trafo_size) >> 1);
|
||||||
int y1 = y0 + ((1 << log2_trafo_size) >> 1);
|
int y1 = y0 + ((1 << log2_trafo_size) >> 1);
|
||||||
|
|
||||||
hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
ret = hls_transform_tree(s, x0, y0, x0, y0, cb_xBase, cb_yBase,
|
||||||
log2_trafo_size - 1, trafo_depth + 1, 0);
|
log2_cb_size, log2_trafo_size - 1,
|
||||||
hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
trafo_depth + 1, 0);
|
||||||
log2_trafo_size - 1, trafo_depth + 1, 1);
|
if (ret < 0)
|
||||||
hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
return ret;
|
||||||
log2_trafo_size - 1, trafo_depth + 1, 2);
|
ret = hls_transform_tree(s, x1, y0, x0, y0, cb_xBase, cb_yBase,
|
||||||
hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase, log2_cb_size,
|
log2_cb_size, log2_trafo_size - 1,
|
||||||
log2_trafo_size - 1, trafo_depth + 1, 3);
|
trafo_depth + 1, 1);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
ret = hls_transform_tree(s, x0, y1, x0, y0, cb_xBase, cb_yBase,
|
||||||
|
log2_cb_size, log2_trafo_size - 1,
|
||||||
|
trafo_depth + 1, 2);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
ret = hls_transform_tree(s, x1, y1, x0, y0, cb_xBase, cb_yBase,
|
||||||
|
log2_cb_size, log2_trafo_size - 1,
|
||||||
|
trafo_depth + 1, 3);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
int min_tu_size = 1 << s->sps->log2_min_tb_size;
|
int min_tu_size = 1 << s->sps->log2_min_tb_size;
|
||||||
int log2_min_tu_size = s->sps->log2_min_tb_size;
|
int log2_min_tu_size = s->sps->log2_min_tb_size;
|
||||||
@@ -896,9 +938,11 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
|||||||
lc->tt.cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth);
|
lc->tt.cbf_luma = ff_hevc_cbf_luma_decode(s, trafo_depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
|
ret = hls_transform_unit(s, x0, y0, xBase, yBase, cb_xBase, cb_yBase,
|
||||||
log2_cb_size, log2_trafo_size, trafo_depth, blk_idx);
|
log2_cb_size, log2_trafo_size, trafo_depth,
|
||||||
|
blk_idx);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
// TODO: store cbf_luma somewhere else
|
// TODO: store cbf_luma somewhere else
|
||||||
if (lc->tt.cbf_luma) {
|
if (lc->tt.cbf_luma) {
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -917,6 +961,7 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
|
|||||||
set_deblocking_bypass(s, x0, y0, log2_trafo_size);
|
set_deblocking_bypass(s, x0, y0, log2_trafo_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
static int hls_pcm_sample(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
||||||
@@ -1505,7 +1550,8 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
int min_cb_width = s->sps->min_cb_width;
|
int min_cb_width = s->sps->min_cb_width;
|
||||||
int x_cb = x0 >> log2_min_cb_size;
|
int x_cb = x0 >> log2_min_cb_size;
|
||||||
int y_cb = y0 >> log2_min_cb_size;
|
int y_cb = y0 >> log2_min_cb_size;
|
||||||
int x, y;
|
int x, y, ret;
|
||||||
|
int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1;
|
||||||
|
|
||||||
lc->cu.x = x0;
|
lc->cu.x = x0;
|
||||||
lc->cu.y = y0;
|
lc->cu.y = y0;
|
||||||
@@ -1562,7 +1608,6 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s);
|
lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s);
|
||||||
}
|
}
|
||||||
if (lc->cu.pcm_flag) {
|
if (lc->cu.pcm_flag) {
|
||||||
int ret;
|
|
||||||
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
|
intra_prediction_unit_default_value(s, x0, y0, log2_cb_size);
|
||||||
ret = hls_pcm_sample(s, x0, y0, log2_cb_size);
|
ret = hls_pcm_sample(s, x0, y0, log2_cb_size);
|
||||||
if (s->sps->pcm.loop_filter_disable_flag)
|
if (s->sps->pcm.loop_filter_disable_flag)
|
||||||
@@ -1621,8 +1666,11 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
|
lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?
|
||||||
s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
|
s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :
|
||||||
s->sps->max_transform_hierarchy_depth_inter;
|
s->sps->max_transform_hierarchy_depth_inter;
|
||||||
hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size,
|
ret = hls_transform_tree(s, x0, y0, x0, y0, x0, y0,
|
||||||
|
log2_cb_size,
|
||||||
log2_cb_size, 0, 0);
|
log2_cb_size, 0, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if (!s->sh.disable_deblocking_filter_flag)
|
if (!s->sh.disable_deblocking_filter_flag)
|
||||||
ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size,
|
ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size,
|
||||||
@@ -1641,6 +1689,11 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
|
|||||||
x += min_cb_width;
|
x += min_cb_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
|
||||||
|
((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0) {
|
||||||
|
lc->qPy_pred = lc->qp_y;
|
||||||
|
}
|
||||||
|
|
||||||
set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth);
|
set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1652,6 +1705,7 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
|
|||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
const int cb_size = 1 << log2_cb_size;
|
const int cb_size = 1 << log2_cb_size;
|
||||||
int ret;
|
int ret;
|
||||||
|
int qp_block_mask = (1<<(s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth)) - 1;
|
||||||
|
|
||||||
lc->ct.depth = cb_depth;
|
lc->ct.depth = cb_depth;
|
||||||
if ((x0 + cb_size <= s->sps->width) &&
|
if ((x0 + cb_size <= s->sps->width) &&
|
||||||
@@ -1679,14 +1733,27 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
|
|||||||
if (more_data < 0)
|
if (more_data < 0)
|
||||||
return more_data;
|
return more_data;
|
||||||
|
|
||||||
if (more_data && x1 < s->sps->width)
|
if (more_data && x1 < s->sps->width) {
|
||||||
more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1);
|
more_data = hls_coding_quadtree(s, x1, y0, log2_cb_size - 1, cb_depth + 1);
|
||||||
if (more_data && y1 < s->sps->height)
|
if (more_data < 0)
|
||||||
|
return more_data;
|
||||||
|
}
|
||||||
|
if (more_data && y1 < s->sps->height) {
|
||||||
more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1);
|
more_data = hls_coding_quadtree(s, x0, y1, log2_cb_size - 1, cb_depth + 1);
|
||||||
|
if (more_data < 0)
|
||||||
|
return more_data;
|
||||||
|
}
|
||||||
if (more_data && x1 < s->sps->width &&
|
if (more_data && x1 < s->sps->width &&
|
||||||
y1 < s->sps->height) {
|
y1 < s->sps->height) {
|
||||||
return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
|
more_data = hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
|
||||||
|
if (more_data < 0)
|
||||||
|
return more_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(((x0 + (1<<log2_cb_size)) & qp_block_mask) == 0 &&
|
||||||
|
((y0 + (1<<log2_cb_size)) & qp_block_mask) == 0)
|
||||||
|
lc->qPy_pred = lc->qp_y;
|
||||||
|
|
||||||
if (more_data)
|
if (more_data)
|
||||||
return ((x1 + cb_size_split) < s->sps->width ||
|
return ((x1 + cb_size_split) < s->sps->width ||
|
||||||
(y1 + cb_size_split) < s->sps->height);
|
(y1 + cb_size_split) < s->sps->height);
|
||||||
@@ -1775,6 +1842,19 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
|
|||||||
int y_ctb = 0;
|
int y_ctb = 0;
|
||||||
int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
|
int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
|
||||||
|
|
||||||
|
if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s->sh.dependent_slice_segment_flag) {
|
||||||
|
int prev_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
|
||||||
|
if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (more_data && ctb_addr_ts < s->sps->ctb_size) {
|
while (more_data && ctb_addr_ts < s->sps->ctb_size) {
|
||||||
int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
|
int ctb_addr_rs = s->pps->ctb_addr_ts_to_rs[ctb_addr_ts];
|
||||||
|
|
||||||
@@ -1791,8 +1871,11 @@ static int hls_decode_entry(AVCodecContext *avctxt, void *isFilterThread)
|
|||||||
s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
|
s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag;
|
||||||
|
|
||||||
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
|
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
|
||||||
if (more_data < 0)
|
if (more_data < 0) {
|
||||||
|
s->tab_slice_address[ctb_addr_rs] = -1;
|
||||||
return more_data;
|
return more_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ctb_addr_ts++;
|
ctb_addr_ts++;
|
||||||
ff_hevc_save_states(s, ctb_addr_ts);
|
ff_hevc_save_states(s, ctb_addr_ts);
|
||||||
@@ -1858,8 +1941,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
|
|||||||
hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size);
|
hls_sao_param(s, x_ctb >> s->sps->log2_ctb_size, y_ctb >> s->sps->log2_ctb_size);
|
||||||
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
|
more_data = hls_coding_quadtree(s, x_ctb, y_ctb, s->sps->log2_ctb_size, 0);
|
||||||
|
|
||||||
if (more_data < 0)
|
if (more_data < 0) {
|
||||||
|
s->tab_slice_address[ctb_addr_rs] = -1;
|
||||||
return more_data;
|
return more_data;
|
||||||
|
}
|
||||||
|
|
||||||
ctb_addr_ts++;
|
ctb_addr_ts++;
|
||||||
|
|
||||||
@@ -1893,8 +1978,8 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *input_ctb_row, int
|
|||||||
static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
|
static int hls_slice_data_wpp(HEVCContext *s, const uint8_t *nal, int length)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
int *ret = av_malloc((s->sh.num_entry_point_offsets + 1) * sizeof(int));
|
int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
|
||||||
int *arg = av_malloc((s->sh.num_entry_point_offsets + 1) * sizeof(int));
|
int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));
|
||||||
int offset;
|
int offset;
|
||||||
int startheader, cmpt = 0;
|
int startheader, cmpt = 0;
|
||||||
int i, j, res = 0;
|
int i, j, res = 0;
|
||||||
@@ -2024,12 +2109,15 @@ static void restore_tqb_pixels(HEVCContext *s)
|
|||||||
static int hevc_frame_start(HEVCContext *s)
|
static int hevc_frame_start(HEVCContext *s)
|
||||||
{
|
{
|
||||||
HEVCLocalContext *lc = s->HEVClc;
|
HEVCLocalContext *lc = s->HEVClc;
|
||||||
|
int pic_size_in_ctb = ((s->sps->width >> s->sps->log2_min_cb_size) + 1) *
|
||||||
|
((s->sps->height >> s->sps->log2_min_cb_size) + 1);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
||||||
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
|
||||||
memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height);
|
memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height);
|
||||||
memset(s->is_pcm, 0, s->sps->min_pu_width * s->sps->min_pu_height);
|
memset(s->is_pcm, 0, s->sps->min_pu_width * s->sps->min_pu_height);
|
||||||
|
memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address));
|
||||||
|
|
||||||
lc->start_of_tiles_x = 0;
|
lc->start_of_tiles_x = 0;
|
||||||
s->is_decoded = 0;
|
s->is_decoded = 0;
|
||||||
@@ -2060,6 +2148,7 @@ static int hevc_frame_start(HEVCContext *s)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
if (!s->avctx->hwaccel)
|
||||||
ff_thread_finish_setup(s->avctx);
|
ff_thread_finish_setup(s->avctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2584,6 +2673,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
|
|||||||
|
|
||||||
pic_arrays_free(s);
|
pic_arrays_free(s);
|
||||||
|
|
||||||
|
if (lc)
|
||||||
av_freep(&lc->edge_emu_buffer);
|
av_freep(&lc->edge_emu_buffer);
|
||||||
av_freep(&s->md5_ctx);
|
av_freep(&s->md5_ctx);
|
||||||
|
|
||||||
@@ -2611,6 +2701,8 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
|
|||||||
for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
|
for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
|
||||||
av_buffer_unref(&s->pps_list[i]);
|
av_buffer_unref(&s->pps_list[i]);
|
||||||
|
|
||||||
|
av_buffer_unref(&s->current_sps);
|
||||||
|
|
||||||
av_freep(&s->sh.entry_point_offset);
|
av_freep(&s->sh.entry_point_offset);
|
||||||
av_freep(&s->sh.offset);
|
av_freep(&s->sh.offset);
|
||||||
av_freep(&s->sh.size);
|
av_freep(&s->sh.size);
|
||||||
@@ -2624,6 +2716,8 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
|
|||||||
av_freep(&s->sList[i]);
|
av_freep(&s->sList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (s->HEVClc == s->HEVClcList[0])
|
||||||
|
s->HEVClc = NULL;
|
||||||
av_freep(&s->HEVClcList[0]);
|
av_freep(&s->HEVClcList[0]);
|
||||||
|
|
||||||
for (i = 0; i < s->nals_allocated; i++)
|
for (i = 0; i < s->nals_allocated; i++)
|
||||||
@@ -2722,6 +2816,13 @@ static int hevc_update_thread_context(AVCodecContext *dst,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_buffer_unref(&s->current_sps);
|
||||||
|
if (s0->current_sps) {
|
||||||
|
s->current_sps = av_buffer_ref(s0->current_sps);
|
||||||
|
if (!s->current_sps)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
s->seq_decode = s0->seq_decode;
|
s->seq_decode = s0->seq_decode;
|
||||||
s->seq_output = s0->seq_output;
|
s->seq_output = s0->seq_output;
|
||||||
s->pocTid0 = s0->pocTid0;
|
s->pocTid0 = s0->pocTid0;
|
||||||
|
@@ -280,10 +280,10 @@ typedef struct RefPicListTab {
|
|||||||
} RefPicListTab;
|
} RefPicListTab;
|
||||||
|
|
||||||
typedef struct HEVCWindow {
|
typedef struct HEVCWindow {
|
||||||
int left_offset;
|
unsigned int left_offset;
|
||||||
int right_offset;
|
unsigned int right_offset;
|
||||||
int top_offset;
|
unsigned int top_offset;
|
||||||
int bottom_offset;
|
unsigned int bottom_offset;
|
||||||
} HEVCWindow;
|
} HEVCWindow;
|
||||||
|
|
||||||
typedef struct VUI {
|
typedef struct VUI {
|
||||||
@@ -373,7 +373,7 @@ typedef struct ScalingList {
|
|||||||
} ScalingList;
|
} ScalingList;
|
||||||
|
|
||||||
typedef struct HEVCSPS {
|
typedef struct HEVCSPS {
|
||||||
int vps_id;
|
unsigned vps_id;
|
||||||
int chroma_format_idc;
|
int chroma_format_idc;
|
||||||
uint8_t separate_colour_plane_flag;
|
uint8_t separate_colour_plane_flag;
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ typedef struct HEVCSPS {
|
|||||||
} HEVCSPS;
|
} HEVCSPS;
|
||||||
|
|
||||||
typedef struct HEVCPPS {
|
typedef struct HEVCPPS {
|
||||||
int sps_id; ///< seq_parameter_set_id
|
unsigned sps_id; ///< seq_parameter_set_id
|
||||||
|
|
||||||
uint8_t sign_data_hiding_flag;
|
uint8_t sign_data_hiding_flag;
|
||||||
|
|
||||||
@@ -733,6 +733,8 @@ typedef struct HEVCLocalContext {
|
|||||||
int8_t qp_y;
|
int8_t qp_y;
|
||||||
int8_t curr_qp_y;
|
int8_t curr_qp_y;
|
||||||
|
|
||||||
|
int qPy_pred;
|
||||||
|
|
||||||
TransformUnit tu;
|
TransformUnit tu;
|
||||||
|
|
||||||
uint8_t ctb_left_flag;
|
uint8_t ctb_left_flag;
|
||||||
@@ -784,6 +786,8 @@ typedef struct HEVCContext {
|
|||||||
AVBufferRef *sps_list[MAX_SPS_COUNT];
|
AVBufferRef *sps_list[MAX_SPS_COUNT];
|
||||||
AVBufferRef *pps_list[MAX_PPS_COUNT];
|
AVBufferRef *pps_list[MAX_PPS_COUNT];
|
||||||
|
|
||||||
|
AVBufferRef *current_sps;
|
||||||
|
|
||||||
AVBufferPool *tab_mvf_pool;
|
AVBufferPool *tab_mvf_pool;
|
||||||
AVBufferPool *rpl_tab_pool;
|
AVBufferPool *rpl_tab_pool;
|
||||||
|
|
||||||
|
@@ -93,45 +93,7 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, in
|
|||||||
lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded;
|
lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded;
|
||||||
qPy_pred = s->sh.slice_qp;
|
qPy_pred = s->sh.slice_qp;
|
||||||
} else {
|
} else {
|
||||||
qPy_pred = lc->qp_y;
|
qPy_pred = lc->qPy_pred;
|
||||||
if (log2_cb_size < s->sps->log2_ctb_size - s->pps->diff_cu_qp_delta_depth) {
|
|
||||||
static const int offsetX[8][8] = {
|
|
||||||
{-1, 1, 3, 1, 7, 1, 3, 1},
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0},
|
|
||||||
{ 1, 3, 1, 3, 1, 3, 1, 3},
|
|
||||||
{ 2, 2, 2, 2, 2, 2, 2, 2},
|
|
||||||
{ 3, 5, 7, 5, 3, 5, 7, 5},
|
|
||||||
{ 4, 4, 4, 4, 4, 4, 4, 4},
|
|
||||||
{ 5, 7, 5, 7, 5, 7, 5, 7},
|
|
||||||
{ 6, 6, 6, 6, 6, 6, 6, 6}
|
|
||||||
};
|
|
||||||
static const int offsetY[8][8] = {
|
|
||||||
{ 7, 0, 1, 2, 3, 4, 5, 6},
|
|
||||||
{ 0, 1, 2, 3, 4, 5, 6, 7},
|
|
||||||
{ 1, 0, 3, 2, 5, 4, 7, 6},
|
|
||||||
{ 0, 1, 2, 3, 4, 5, 6, 7},
|
|
||||||
{ 3, 0, 1, 2, 7, 4, 5, 6},
|
|
||||||
{ 0, 1, 2, 3, 4, 5, 6, 7},
|
|
||||||
{ 1, 0, 3, 2, 5, 4, 7, 6},
|
|
||||||
{ 0, 1, 2, 3, 4, 5, 6, 7}
|
|
||||||
};
|
|
||||||
int xC0b = (xC - (xC & ctb_size_mask)) >> s->sps->log2_min_cb_size;
|
|
||||||
int yC0b = (yC - (yC & ctb_size_mask)) >> s->sps->log2_min_cb_size;
|
|
||||||
int idxX = (xQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;
|
|
||||||
int idxY = (yQgBase & ctb_size_mask) >> s->sps->log2_min_cb_size;
|
|
||||||
int idx_mask = ctb_size_mask >> s->sps->log2_min_cb_size;
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
x = FFMIN(xC0b + offsetX[idxX][idxY], min_cb_width - 1);
|
|
||||||
y = FFMIN(yC0b + (offsetY[idxX][idxY] & idx_mask), min_cb_height - 1);
|
|
||||||
|
|
||||||
if (xC0b == (lc->start_of_tiles_x >> s->sps->log2_min_cb_size) &&
|
|
||||||
offsetX[idxX][idxY] == -1) {
|
|
||||||
x = (lc->end_of_tiles_x >> s->sps->log2_min_cb_size) - 1;
|
|
||||||
y = yC0b - 1;
|
|
||||||
}
|
|
||||||
qPy_pred = s->qp_y_tab[y * min_cb_width + x];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// qPy_a
|
// qPy_a
|
||||||
@@ -155,7 +117,8 @@ void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int l
|
|||||||
|
|
||||||
if (s->HEVClc->tu.cu_qp_delta != 0) {
|
if (s->HEVClc->tu.cu_qp_delta != 0) {
|
||||||
int off = s->sps->qp_bd_offset;
|
int off = s->sps->qp_bd_offset;
|
||||||
s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off;
|
s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off,
|
||||||
|
52 + off) - off;
|
||||||
} else
|
} else
|
||||||
s->HEVClc->qp_y = qp_y;
|
s->HEVClc->qp_y = qp_y;
|
||||||
}
|
}
|
||||||
|
@@ -329,6 +329,9 @@ static void hevc_close(AVCodecParserContext *s)
|
|||||||
for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++)
|
for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++)
|
||||||
av_buffer_unref(&h->pps_list[i]);
|
av_buffer_unref(&h->pps_list[i]);
|
||||||
|
|
||||||
|
av_buffer_unref(&h->current_sps);
|
||||||
|
h->sps = NULL;
|
||||||
|
|
||||||
for (i = 0; i < h->nals_allocated; i++)
|
for (i = 0; i < h->nals_allocated; i++)
|
||||||
av_freep(&h->nals[i].rbsp_buffer);
|
av_freep(&h->nals[i].rbsp_buffer);
|
||||||
av_freep(&h->nals);
|
av_freep(&h->nals);
|
||||||
|
@@ -489,8 +489,8 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
|
|||||||
|
|
||||||
vui->vui_timing_info_present_flag = get_bits1(gb);
|
vui->vui_timing_info_present_flag = get_bits1(gb);
|
||||||
if (vui->vui_timing_info_present_flag) {
|
if (vui->vui_timing_info_present_flag) {
|
||||||
vui->vui_num_units_in_tick = get_bits(gb, 32);
|
vui->vui_num_units_in_tick = get_bits_long(gb, 32);
|
||||||
vui->vui_time_scale = get_bits(gb, 32);
|
vui->vui_time_scale = get_bits_long(gb, 32);
|
||||||
vui->vui_poc_proportional_to_timing_flag = get_bits1(gb);
|
vui->vui_poc_proportional_to_timing_flag = get_bits1(gb);
|
||||||
if (vui->vui_poc_proportional_to_timing_flag)
|
if (vui->vui_poc_proportional_to_timing_flag)
|
||||||
vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
|
vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
|
||||||
@@ -621,6 +621,12 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!s->vps_list[sps->vps_id]) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "VPS does not exist \n");
|
||||||
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
sps->max_sub_layers = get_bits(gb, 3) + 1;
|
sps->max_sub_layers = get_bits(gb, 3) + 1;
|
||||||
if (sps->max_sub_layers > MAX_SUB_LAYERS) {
|
if (sps->max_sub_layers > MAX_SUB_LAYERS) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
|
av_log(s->avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
|
||||||
@@ -762,11 +768,30 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
|||||||
log2_diff_max_min_transform_block_size = get_ue_golomb_long(gb);
|
log2_diff_max_min_transform_block_size = get_ue_golomb_long(gb);
|
||||||
sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size + sps->log2_min_tb_size;
|
sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size + sps->log2_min_tb_size;
|
||||||
|
|
||||||
if (sps->log2_min_tb_size >= sps->log2_min_cb_size) {
|
if (sps->log2_min_cb_size < 3 || sps->log2_min_cb_size > 30) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_min_cb_size", sps->log2_min_cb_size);
|
||||||
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sps->log2_diff_max_min_coding_block_size > 30) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_coding_block_size", sps->log2_diff_max_min_coding_block_size);
|
||||||
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sps->log2_min_tb_size >= sps->log2_min_cb_size || sps->log2_min_tb_size < 2) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size");
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size");
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size);
|
||||||
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
sps->max_transform_hierarchy_depth_inter = get_ue_golomb_long(gb);
|
sps->max_transform_hierarchy_depth_inter = get_ue_golomb_long(gb);
|
||||||
sps->max_transform_hierarchy_depth_intra = get_ue_golomb_long(gb);
|
sps->max_transform_hierarchy_depth_intra = get_ue_golomb_long(gb);
|
||||||
|
|
||||||
@@ -818,6 +843,11 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
|||||||
sps->long_term_ref_pics_present_flag = get_bits1(gb);
|
sps->long_term_ref_pics_present_flag = get_bits1(gb);
|
||||||
if (sps->long_term_ref_pics_present_flag) {
|
if (sps->long_term_ref_pics_present_flag) {
|
||||||
sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
|
sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
|
||||||
|
if (sps->num_long_term_ref_pics_sps > 31U) {
|
||||||
|
av_log(0, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out of range.\n",
|
||||||
|
sps->num_long_term_ref_pics_sps);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
|
for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
|
||||||
sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb);
|
sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb);
|
||||||
sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);
|
sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);
|
||||||
@@ -849,7 +879,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
|||||||
(sps->output_window.left_offset + sps->output_window.right_offset);
|
(sps->output_window.left_offset + sps->output_window.right_offset);
|
||||||
sps->output_height = sps->height -
|
sps->output_height = sps->height -
|
||||||
(sps->output_window.top_offset + sps->output_window.bottom_offset);
|
(sps->output_window.top_offset + sps->output_window.bottom_offset);
|
||||||
if (sps->output_width <= 0 || sps->output_height <= 0) {
|
if (sps->width <= sps->output_window.left_offset + (int64_t)sps->output_window.right_offset ||
|
||||||
|
sps->height <= sps->output_window.top_offset + (int64_t)sps->output_window.bottom_offset) {
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "Invalid visible frame dimensions: %dx%d.\n",
|
av_log(s->avctx, AV_LOG_WARNING, "Invalid visible frame dimensions: %dx%d.\n",
|
||||||
sps->output_width, sps->output_height);
|
sps->output_width, sps->output_height);
|
||||||
if (s->avctx->err_recognition & AV_EF_EXPLODE) {
|
if (s->avctx->err_recognition & AV_EF_EXPLODE) {
|
||||||
@@ -857,10 +888,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "Displaying the whole video surface.\n");
|
av_log(s->avctx, AV_LOG_WARNING, "Displaying the whole video surface.\n");
|
||||||
sps->pic_conf_win.left_offset =
|
memset(&sps->pic_conf_win, 0, sizeof(sps->pic_conf_win));
|
||||||
sps->pic_conf_win.right_offset =
|
memset(&sps->output_window, 0, sizeof(sps->output_window));
|
||||||
sps->pic_conf_win.top_offset =
|
|
||||||
sps->pic_conf_win.bottom_offset = 0;
|
|
||||||
sps->output_width = sps->width;
|
sps->output_width = sps->width;
|
||||||
sps->output_height = sps->height;
|
sps->output_height = sps->height;
|
||||||
}
|
}
|
||||||
@@ -928,6 +957,12 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
|
|||||||
if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == sps_id)
|
if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == sps_id)
|
||||||
av_buffer_unref(&s->pps_list[i]);
|
av_buffer_unref(&s->pps_list[i]);
|
||||||
}
|
}
|
||||||
|
if (s->sps_list[sps_id] && s->sps == (HEVCSPS*)s->sps_list[sps_id]->data) {
|
||||||
|
av_buffer_unref(&s->current_sps);
|
||||||
|
s->current_sps = av_buffer_ref(s->sps_list[sps_id]);
|
||||||
|
if (!s->current_sps)
|
||||||
|
s->sps = NULL;
|
||||||
|
}
|
||||||
av_buffer_unref(&s->sps_list[sps_id]);
|
av_buffer_unref(&s->sps_list[sps_id]);
|
||||||
s->sps_list[sps_id] = sps_buf;
|
s->sps_list[sps_id] = sps_buf;
|
||||||
}
|
}
|
||||||
@@ -1032,6 +1067,14 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
|
|||||||
if (pps->cu_qp_delta_enabled_flag)
|
if (pps->cu_qp_delta_enabled_flag)
|
||||||
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
|
pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb);
|
||||||
|
|
||||||
|
if (pps->diff_cu_qp_delta_depth < 0 ||
|
||||||
|
pps->diff_cu_qp_delta_depth > sps->log2_diff_max_min_coding_block_size) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR, "diff_cu_qp_delta_depth %d is invalid\n",
|
||||||
|
pps->diff_cu_qp_delta_depth);
|
||||||
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
pps->cb_qp_offset = get_se_golomb(gb);
|
pps->cb_qp_offset = get_se_golomb(gb);
|
||||||
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
|
if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
|
av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n",
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user