mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-07 15:30:00 +01:00
Compare commits
332 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a64e9a029 | ||
|
|
59b2a9ef95 | ||
|
|
4ce6d65b6f | ||
|
|
ab4e54f6f6 | ||
|
|
18342848f7 | ||
|
|
61a51598e3 | ||
|
|
abc1fa7c5a | ||
|
|
f712d3669e | ||
|
|
ca232ff9b0 | ||
|
|
b4632cec74 | ||
|
|
454f6c622c | ||
|
|
f70ee7d14f | ||
|
|
c285db74f6 | ||
|
|
cc8d20e345 | ||
|
|
c2b72eac6c | ||
|
|
9d77a62936 | ||
|
|
f2aaee49b2 | ||
|
|
d13cf32099 | ||
|
|
5626e11bd5 | ||
|
|
8d1f38c4b1 | ||
|
|
ea7fbd0b16 | ||
|
|
b2b4df8d51 | ||
|
|
5691d9a6c1 | ||
|
|
2b8490b762 | ||
|
|
4b638ea42d | ||
|
|
4ecd718285 | ||
|
|
0607c8af2b | ||
|
|
3c385ea24c | ||
|
|
c7e9626b7b | ||
|
|
26d7253441 | ||
|
|
c75a915f66 | ||
|
|
ecd30280f5 | ||
|
|
eada99a854 | ||
|
|
9ade5b804e | ||
|
|
753f0738ca | ||
|
|
85b00d798f | ||
|
|
8d60d8bef2 | ||
|
|
53c02d04e4 | ||
|
|
90c7dfb907 | ||
|
|
424b00a300 | ||
|
|
7b38ea4003 | ||
|
|
71104f7cb0 | ||
|
|
98fe429ba5 | ||
|
|
90cf672d7a | ||
|
|
4af56488c8 | ||
|
|
4065e55759 | ||
|
|
fe97363c38 | ||
|
|
ce95904013 | ||
|
|
a61998e4f4 | ||
|
|
e5546d4871 | ||
|
|
8f7ebb88b8 | ||
|
|
e897eb108b | ||
|
|
2af3a04164 | ||
|
|
92ca3578bf | ||
|
|
1be06c8531 | ||
|
|
6011b806dd | ||
|
|
3ac85d70f0 | ||
|
|
401b3dafd9 | ||
|
|
71516ac175 | ||
|
|
0983720cf2 | ||
|
|
9e9d92bbcc | ||
|
|
3d79041f85 | ||
|
|
2c71734d9e | ||
|
|
0759bdc315 | ||
|
|
1530fbccac | ||
|
|
7f8aa37bc3 | ||
|
|
5219e20d58 | ||
|
|
8ee704c392 | ||
|
|
9060c10c65 | ||
|
|
5202621ac4 | ||
|
|
da6a8c9cfd | ||
|
|
f07cebcd91 | ||
|
|
d0ba12fa0c | ||
|
|
a58053dc24 | ||
|
|
b1a960cc83 | ||
|
|
620d80d572 | ||
|
|
e3ce3d373c | ||
|
|
f31682f2f2 | ||
|
|
fb44a3e4a3 | ||
|
|
6ee47bd008 | ||
|
|
7819750157 | ||
|
|
0d819ed318 | ||
|
|
e63346f7e8 | ||
|
|
ddcccababe | ||
|
|
b580bae53a | ||
|
|
9085cdd677 | ||
|
|
ab31a9ee4a | ||
|
|
a57d29a50c | ||
|
|
11b14d0e63 | ||
|
|
bb683ebdba | ||
|
|
b3cc4bd18f | ||
|
|
ca9d302519 | ||
|
|
e925fd215f | ||
|
|
5e01cd3b69 | ||
|
|
2256b2a3c1 | ||
|
|
89c917fcd9 | ||
|
|
8a38deb789 | ||
|
|
4fdcb1e1b7 | ||
|
|
b902ba478c | ||
|
|
f0fabcc6ed | ||
|
|
bd29764c61 | ||
|
|
d81ccf1fb2 | ||
|
|
67d20495f5 | ||
|
|
5a0a156e88 | ||
|
|
884094deba | ||
|
|
db20610c49 | ||
|
|
15a736483e | ||
|
|
c8b90c7cd5 | ||
|
|
97978b7ae8 | ||
|
|
3f2efac0fe | ||
|
|
b9058f58bd | ||
|
|
47faf347a0 | ||
|
|
3d1e4b7ca5 | ||
|
|
a2bea0df0e | ||
|
|
483b2016bb | ||
|
|
271f5d68b9 | ||
|
|
dee327b0e7 | ||
|
|
e438fd3be9 | ||
|
|
3d380ffde9 | ||
|
|
84b100396e | ||
|
|
7855083443 | ||
|
|
ca7f64e0ac | ||
|
|
2b26f8c6bf | ||
|
|
6e3697b985 | ||
|
|
c93501687c | ||
|
|
bb6f466794 | ||
|
|
08a319549a | ||
|
|
d1da1c8384 | ||
|
|
8ded3738d1 | ||
|
|
a2186a8054 | ||
|
|
a92b73da99 | ||
|
|
ab38b39059 | ||
|
|
5dde8ba59e | ||
|
|
b841869477 | ||
|
|
3488e9e269 | ||
|
|
5a8d78ab7f | ||
|
|
dea7f1c62e | ||
|
|
c7027ae738 | ||
|
|
971b13752d | ||
|
|
d0ed672484 | ||
|
|
751e684aae | ||
|
|
803ca5c349 | ||
|
|
252002aec1 | ||
|
|
d805a51713 | ||
|
|
45dd7df83b | ||
|
|
da82be0cc0 | ||
|
|
b8b77aefe8 | ||
|
|
30147f14d4 | ||
|
|
d6a705d778 | ||
|
|
e24b33cd68 | ||
|
|
6f7fd2f589 | ||
|
|
f974c54909 | ||
|
|
71b3235cea | ||
|
|
dcd1acce1a | ||
|
|
5c502e5d41 | ||
|
|
fa45feefad | ||
|
|
9f3135b30b | ||
|
|
7ba102d008 | ||
|
|
3e65caf5bc | ||
|
|
af7cbdf470 | ||
|
|
414b377462 | ||
|
|
86d4d4b011 | ||
|
|
14f31df2cc | ||
|
|
d04e78805a | ||
|
|
25c67b2165 | ||
|
|
fd8af75109 | ||
|
|
93d720b040 | ||
|
|
720e2d4143 | ||
|
|
9195ef6f65 | ||
|
|
833dce3818 | ||
|
|
a8b6721bed | ||
|
|
1fe734f4d3 | ||
|
|
311e58e478 | ||
|
|
970109deaf | ||
|
|
eff0bf7def | ||
|
|
6559bb893f | ||
|
|
14e258d847 | ||
|
|
ca47aec665 | ||
|
|
95e26d33d7 | ||
|
|
f32051cd73 | ||
|
|
c3ee5b4c36 | ||
|
|
c17fd9f9ce | ||
|
|
0f3cdddf38 | ||
|
|
a0d13f578b | ||
|
|
91e19ab930 | ||
|
|
bb4126e250 | ||
|
|
9902eef0f5 | ||
|
|
6db67ac2a4 | ||
|
|
85eeab4d22 | ||
|
|
4431ee1896 | ||
|
|
d2feaf2ba6 | ||
|
|
0f73cb454d | ||
|
|
82cfb8c2db | ||
|
|
0a55c882cb | ||
|
|
c09acf9882 | ||
|
|
a0779a2ee5 | ||
|
|
b4f90013ab | ||
|
|
3a6fbb0c8e | ||
|
|
6a782e20d7 | ||
|
|
8cea63c48a | ||
|
|
8f87e75c6c | ||
|
|
06a927a6b5 | ||
|
|
3c523bdda8 | ||
|
|
ece54c7085 | ||
|
|
7eee79ea2f | ||
|
|
458933fdb8 | ||
|
|
95d0baa952 | ||
|
|
32cff0d3f0 | ||
|
|
ddce97c7b0 | ||
|
|
26617b47fa | ||
|
|
b3fb651a8a | ||
|
|
2da5b69020 | ||
|
|
b23642aa7e | ||
|
|
eae4dfd4e8 | ||
|
|
6fb2c03e1a | ||
|
|
1d6b261a24 | ||
|
|
02f1ae5406 | ||
|
|
aaac34f5e6 | ||
|
|
7858d261aa | ||
|
|
f85c44264b | ||
|
|
025e286757 | ||
|
|
79ec45a455 | ||
|
|
09653c5444 | ||
|
|
c788713589 | ||
|
|
f637fa5d33 | ||
|
|
dc1881ee11 | ||
|
|
24187a96ee | ||
|
|
c87f3c3ab4 | ||
|
|
8f07c09b20 | ||
|
|
8e3581ab03 | ||
|
|
5d3cd041fc | ||
|
|
9865f19f15 | ||
|
|
90ed770192 | ||
|
|
f9fa321734 | ||
|
|
a0e328d28b | ||
|
|
848e5cfc0f | ||
|
|
9d8795e598 | ||
|
|
64d440a3b4 | ||
|
|
42586c8754 | ||
|
|
64d362fce7 | ||
|
|
c55a09a8b6 | ||
|
|
a94404457b | ||
|
|
364495a351 | ||
|
|
f9c872622e | ||
|
|
9f2d73168f | ||
|
|
930d035e72 | ||
|
|
875649bfae | ||
|
|
70127070dd | ||
|
|
d83ab33715 | ||
|
|
06190d75d0 | ||
|
|
c9ea1f7fc5 | ||
|
|
47de8ccf42 | ||
|
|
72c1de649a | ||
|
|
5e3e67f977 | ||
|
|
221bbd002c | ||
|
|
fffc9316da | ||
|
|
9a87ba0933 | ||
|
|
d8538a1002 | ||
|
|
6cb33e0763 | ||
|
|
2e75c45593 | ||
|
|
ba4cb43f0b | ||
|
|
dc73774792 | ||
|
|
ce11d9490c | ||
|
|
430ef8a716 | ||
|
|
627772d988 | ||
|
|
5ce57e0248 | ||
|
|
5effd65312 | ||
|
|
cb340ecd7d | ||
|
|
b88bea1d6c | ||
|
|
99036565ca | ||
|
|
fcc6460dbf | ||
|
|
1065d4197e | ||
|
|
fbb1af39e4 | ||
|
|
073bde2b1f | ||
|
|
e4bb67bc50 | ||
|
|
59549b5ab7 | ||
|
|
c0445df5b3 | ||
|
|
c77b3737b9 | ||
|
|
04d6946600 | ||
|
|
ae93d3405e | ||
|
|
054779625f | ||
|
|
e22dd7fbd0 | ||
|
|
376a9f8e6e | ||
|
|
9af68f8d1f | ||
|
|
f2361593ca | ||
|
|
96e6d4da37 | ||
|
|
735deda2cf | ||
|
|
5f64a7a625 | ||
|
|
ffd28de388 | ||
|
|
af589dd5e9 | ||
|
|
fd60aeb55b | ||
|
|
79a3f364dd | ||
|
|
33d699a4e7 | ||
|
|
f166a02b67 | ||
|
|
c5948b472b | ||
|
|
7ee5e97c46 | ||
|
|
7ef2dbd239 | ||
|
|
524d0d2cfc | ||
|
|
91f04e7410 | ||
|
|
9f7baf139f | ||
|
|
ec89046fa1 | ||
|
|
cc0dd86580 | ||
|
|
0baa0a5a02 | ||
|
|
039f6921c2 | ||
|
|
7fa6db2545 | ||
|
|
840931e766 | ||
|
|
1ce3f736d2 | ||
|
|
4d0090f90a | ||
|
|
f8d5f3dff5 | ||
|
|
298e03d102 | ||
|
|
54f3902393 | ||
|
|
3ca6253beb | ||
|
|
84df0dc40b | ||
|
|
a857811c75 | ||
|
|
3d6219b6db | ||
|
|
0a53c7016f | ||
|
|
f0dc5c0419 | ||
|
|
df8c36265a | ||
|
|
c351d8781d | ||
|
|
d553a522b9 | ||
|
|
0b6d5f27c8 | ||
|
|
9ecfd7daa3 | ||
|
|
90f1aa38b6 | ||
|
|
fc5c81ce0a | ||
|
|
e820e3a259 | ||
|
|
17911d0a96 | ||
|
|
2ed7f5a670 | ||
|
|
7c6c5767eb | ||
|
|
0ec869527c | ||
|
|
0b198e38c5 | ||
|
|
1ea3248290 | ||
|
|
bdd2db60c2 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +0,0 @@
|
|||||||
*.pnm -diff -text
|
|
||||||
tests/ref/fate/sub-scc eol=crlf
|
|
||||||
57
.gitignore
vendored
57
.gitignore
vendored
@@ -1,14 +1,11 @@
|
|||||||
*.a
|
*.a
|
||||||
*.o
|
*.o
|
||||||
*.o.*
|
|
||||||
*.d
|
*.d
|
||||||
*.def
|
*.def
|
||||||
*.dll
|
*.dll
|
||||||
*.dylib
|
*.dylib
|
||||||
*.exe
|
*.exe
|
||||||
*.exp
|
*.exp
|
||||||
*.gcda
|
|
||||||
*.gcno
|
|
||||||
*.h.c
|
*.h.c
|
||||||
*.ilk
|
*.ilk
|
||||||
*.lib
|
*.lib
|
||||||
@@ -16,11 +13,10 @@
|
|||||||
*.pdb
|
*.pdb
|
||||||
*.so
|
*.so
|
||||||
*.so.*
|
*.so.*
|
||||||
*.swp
|
|
||||||
*.ver
|
*.ver
|
||||||
|
*-example
|
||||||
|
*-test
|
||||||
*_g
|
*_g
|
||||||
\#*
|
|
||||||
.\#*
|
|
||||||
/.config
|
/.config
|
||||||
/.version
|
/.version
|
||||||
/ffmpeg
|
/ffmpeg
|
||||||
@@ -28,8 +24,47 @@
|
|||||||
/ffprobe
|
/ffprobe
|
||||||
/ffserver
|
/ffserver
|
||||||
/config.*
|
/config.*
|
||||||
/coverage.info
|
/version.h
|
||||||
/avversion.h
|
/doc/*.1
|
||||||
/lcov/
|
/doc/*.3
|
||||||
/src
|
/doc/*.html
|
||||||
/mapfile
|
/doc/*.pod
|
||||||
|
/doc/avoptions_codec.texi
|
||||||
|
/doc/avoptions_format.texi
|
||||||
|
/doc/examples/decoding_encoding
|
||||||
|
/doc/examples/demuxing
|
||||||
|
/doc/examples/filtering_audio
|
||||||
|
/doc/examples/filtering_video
|
||||||
|
/doc/examples/metadata
|
||||||
|
/doc/examples/muxing
|
||||||
|
/doc/examples/pc-uninstalled
|
||||||
|
/doc/examples/resampling_audio
|
||||||
|
/doc/examples/scaling_video
|
||||||
|
/doc/fate.txt
|
||||||
|
/doc/doxy/html/
|
||||||
|
/doc/print_options
|
||||||
|
/libavcodec/*_tablegen
|
||||||
|
/libavcodec/*_tables.c
|
||||||
|
/libavcodec/*_tables.h
|
||||||
|
/libavutil/avconfig.h
|
||||||
|
/tests/audiogen
|
||||||
|
/tests/base64
|
||||||
|
/tests/data/
|
||||||
|
/tests/rotozoom
|
||||||
|
/tests/tiny_psnr
|
||||||
|
/tests/videogen
|
||||||
|
/tests/vsynth1/
|
||||||
|
/tools/aviocat
|
||||||
|
/tools/ffbisect
|
||||||
|
/tools/bisect.need
|
||||||
|
/tools/cws2fws
|
||||||
|
/tools/fourcc2pixfmt
|
||||||
|
/tools/ffescape
|
||||||
|
/tools/ffeval
|
||||||
|
/tools/graph2dot
|
||||||
|
/tools/ismindex
|
||||||
|
/tools/pktdumper
|
||||||
|
/tools/probetest
|
||||||
|
/tools/qt-faststart
|
||||||
|
/tools/trasher
|
||||||
|
/tools/seek_print
|
||||||
|
|||||||
26
.travis.yml
26
.travis.yml
@@ -1,26 +0,0 @@
|
|||||||
language: c
|
|
||||||
sudo: false
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- yasm
|
|
||||||
- diffutils
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
- gcc
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- ffmpeg-samples
|
|
||||||
before_install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi
|
|
||||||
install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install yasm; fi
|
|
||||||
script:
|
|
||||||
- mkdir -p ffmpeg-samples
|
|
||||||
- ./configure --samples=ffmpeg-samples --cc=$CC
|
|
||||||
- make -j 8
|
|
||||||
- make fate-rsync
|
|
||||||
- make check -j 8
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# Note to Github users
|
|
||||||
Patches should be submitted to the [ffmpeg-devel mailing list](https://ffmpeg.org/mailman/listinfo/ffmpeg-devel) using `git format-patch` or `git send-email`. Github pull requests should be avoided because they are not part of our review process and **will be ignored**.
|
|
||||||
|
|
||||||
See [https://ffmpeg.org/developer.html#Contributing](https://ffmpeg.org/developer.html#Contributing) for more information.
|
|
||||||
680
Changelog
680
Changelog
@@ -1,659 +1,12 @@
|
|||||||
Entries are sorted chronologically from oldest to youngest within each release,
|
Entries are sorted chronologically from oldest to youngest within each release,
|
||||||
releases are sorted from youngest to oldest.
|
releases are sorted from youngest to oldest.
|
||||||
|
|
||||||
|
version 1.2.8:
|
||||||
version 3.3.1:
|
- proresenc_ks: fix buffer overflow
|
||||||
- libswscale/tests/swscale: Fix uninitialized variables
|
- iff: fix crash
|
||||||
- avcodec/ffv1dec: Fix runtime error: signed integer overflow: 1550964438 + 1550964438 cannot be represented in type 'int'
|
- cdgraphics: fix infinite loop
|
||||||
- avcodec/webp: Fix signedness in prefix_code check
|
- Fix Ticket3804
|
||||||
- avcodec/svq3: Fix runtime error: signed integer overflow: 169 * 12717677 cannot be represented in type 'int'
|
- Fix Ticket3208
|
||||||
- avcodec/mlpdec: Check that there is enough data for headers
|
|
||||||
- avcodec/ac3dec: Keep track of band structure
|
|
||||||
- avcodec/webp: Add missing input padding
|
|
||||||
- avcodec/aacdec_fixed: Fix runtime error: left shift of negative value -1
|
|
||||||
- avcodec/aacsbr_template: Do not change bs_num_env before its checked
|
|
||||||
- avcodec/scpr: Fix multiple runtime error: index 256 out of bounds for type 'unsigned int [256]'
|
|
||||||
- avcodec/mlp: Fix multiple runtime error: left shift of negative value -1
|
|
||||||
- avcodec/xpmdec: Fix multiple pointer/memory issues
|
|
||||||
- avcodec/vp8dsp: vp7_luma_dc_wht_c: Fix multiple runtime error: signed integer overflow: -1366381240 + -1262413604 cannot be represented in type 'int'
|
|
||||||
- avcodec/avcodec: Limit the number of side data elements per packet
|
|
||||||
- avcodec/texturedsp: Fix runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
|
|
||||||
- avcodec/g723_1dec: Fix runtime error: left shift of negative value -1
|
|
||||||
- avcodec/wmv2dsp: Fix runtime error: signed integer overflow: 181 * -17047030 cannot be represented in type 'int'
|
|
||||||
- avcodec/diracdec: Fix Assertion frame->buf[0] failed at libavcodec/decode.c:610
|
|
||||||
- avcodec/msmpeg4dec: Check for cbpy VLC errors
|
|
||||||
- avcodec/cllc: Check num_bits
|
|
||||||
- avcodec/cllc: Factor VLC_BITS/DEPTH out, do not use repeated literal numbers
|
|
||||||
- avcodec/scpr: Check y in first line loop in decompress_i()
|
|
||||||
- avcodec/dvbsubdec: Check entry_id
|
|
||||||
- avcodec/aacdec_fixed: Fix multiple shift exponent 33 is too large for 32-bit type 'int'
|
|
||||||
- avcodec/mpeg12dec: Fixes runtime error: division by zero
|
|
||||||
- avcodec/pixlet: Fix runtime error: signed integer overflow: 436207616 * -5160230545260541 cannot be represented in type 'long'
|
|
||||||
- avcodec/webp: Always set pix_fmt
|
|
||||||
- avfilter/vf_uspp: Fix currently unused input frame dimensions
|
|
||||||
- avcodec/truemotion1: Fix multiple runtime error: left shift of negative value -1
|
|
||||||
- avcodec/eatqi: Fix runtime error: signed integer overflow: 4466147 * 1075 cannot be represented in type 'int'
|
|
||||||
- avcodec/dss_sp: Fix runtime error: signed integer overflow: 2147481189 + 4096 cannot be represented in type 'int'
|
|
||||||
- avformat/wavdec: Check chunk_size
|
|
||||||
- avcodec/cavs: Check updated MV
|
|
||||||
- avcodec/y41pdec: Fix width in input buffer size check
|
|
||||||
- avcodec/svq3: Fix multiple runtime error: signed integer overflow: -237341 * 24552 cannot be represented in type 'int'
|
|
||||||
- avcodec/texturedsp: Fix runtime error: left shift of 218 by 24 places cannot be represented in type 'int'
|
|
||||||
- avcodec/lagarith: Check scale_factor
|
|
||||||
- avcodec/lagarith: Fix runtime error: left shift of negative value -1
|
|
||||||
- avcodec/takdec: Fix multiple runtime error: left shift of negative value -1
|
|
||||||
- avcodec/indeo2: Check for invalid VLCs
|
|
||||||
- avcodec/g723_1dec: Fix several integer related cases of undefined behaviour
|
|
||||||
- avcodec/htmlsubtitles: Check for string truncation and return error
|
|
||||||
- avcodec/bmvvideo: Fix runtime error: left shift of 137 by 24 places cannot be represented in type 'int'
|
|
||||||
- avcodec/dss_sp: Fix multiple runtime error: signed integer overflow: -15699 * -164039 cannot be represented in type 'int'
|
|
||||||
- avcodec/dvbsubdec: check region dimensions
|
|
||||||
- avcodec/vp8dsp: Fixes: runtime error: signed integer overflow: 1330143360 - -1023040530 cannot be represented in type 'int'
|
|
||||||
- avcodec/hqxdsp: Fix multiple runtime error: signed integer overflow: 248220 * 21407 cannot be represented in type 'int' in idct_col()
|
|
||||||
- avcodec/cavsdec: Check sym_factor
|
|
||||||
- avcodec/cdxl: Check format for BGR24
|
|
||||||
- avcodec/ffv1dec: Fix copying planes of paletted formats
|
|
||||||
- avcodec/wmv2dsp: Fix runtime error: signed integer overflow: 181 * -12156865 cannot be represented in type 'int'
|
|
||||||
- avcodec/xwddec: Check bpp more completely
|
|
||||||
- avcodec/aacdec_template: Do not decode 2nd PCE if it will lead to failure
|
|
||||||
- avcodec/s302m: Fix left shift of 8 by 28 places cannot be represented in type 'int'
|
|
||||||
- avcodec/eamad: Fix runtime error: signed integer overflow: 49674 * 49858 cannot be represented in type 'int'
|
|
||||||
- avcodec/g726: Fix runtime error: left shift of negative value -2
|
|
||||||
- avcodec/magicyuv: Check len to be supported
|
|
||||||
- avcodec/ra144: Fix runtime error: left shift of negative value -798
|
|
||||||
- avcodec/mss34dsp: Fix multiple signed integer overflow
|
|
||||||
- avcodec/targa_y216dec: Fix width type
|
|
||||||
- avcodec/texturedsp: Fix multiple runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
|
|
||||||
- avcodec/ivi_dsp: Fix multiple left shift of negative value -2
|
|
||||||
- avcodec/svq3: Fix multiple runtime error: signed integer overflow: 44161 * 61694 cannot be represented in type 'int'
|
|
||||||
- avcodec/msmpeg4dec: Correct table depth
|
|
||||||
- avcodec/dds: Fix runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
|
|
||||||
- avcodec/cdxl: Check format parameter
|
|
||||||
- avutil/softfloat: Fix overflow in av_div_sf()
|
|
||||||
- avcodec/hq_hqa: Fix runtime error: left shift of negative value -207
|
|
||||||
- avcodec/mss3: Change types in rac_get_model_sym() to match the types they are initialized from
|
|
||||||
- avcodec/shorten: Check k in get_uint()
|
|
||||||
- avcodec/webp: Fix null pointer dereference
|
|
||||||
- avcodec/dfa: Fix signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
|
|
||||||
- avcodec/g723_1: Fix multiple runtime error: left shift of negative value
|
|
||||||
- avcodec/mimic: Fix runtime error: left shift of negative value -1
|
|
||||||
- avcodec/clearvideo: Fix multiple runtime error: left shift of negative value -1024
|
|
||||||
- avcodec/fic: Fix multiple left shift of negative value -15
|
|
||||||
- avcodec/mlpdec: Fix runtime error: left shift of negative value -22
|
|
||||||
- avcodec/snowdec: Check qbias
|
|
||||||
- avutil/softfloat: Fix multiple runtime error: left shift of negative value -8
|
|
||||||
- avcodec/aacsbr_template: Do not leave bs_num_env invalid
|
|
||||||
- avcodec/mdec: Fix signed integer overflow: 28835400 * 83 cannot be represented in type 'int'
|
|
||||||
- avcodec/dfa: Fix off by 1 error
|
|
||||||
- avcodec/nellymoser: Fix multiple left shift of negative value -8591
|
|
||||||
- avcodec/cdxl: Fix signed integer overflow: 14243456 * 164 cannot be represented in type 'int'
|
|
||||||
- avcodec/g722: Fix multiple runtime error: left shift of negative value -1
|
|
||||||
- avcodec/dss_sp: Fix multiple left shift of negative value -466
|
|
||||||
- avcodec/wnv1: Fix runtime error: left shift of negative value -1
|
|
||||||
- avcodec/tiertexseqv: set the fixed dimenasions, do not depend on the demuxer doing so
|
|
||||||
- avcodec/mjpegdec: Fix runtime error: signed integer overflow: -24543 * 2031616 cannot be represented in type 'int'
|
|
||||||
- avcodec/cavsdec: Fix undefined behavior from integer overflow
|
|
||||||
- avcodec/dvdsubdec: Fix runtime error: left shift of 242 by 24 places cannot be represented in type 'int'
|
|
||||||
- libavcodec/mpeg4videodec: Convert sprite_offset to 64bit
|
|
||||||
- avcodec/pngdec: Use ff_set_dimensions()
|
|
||||||
- avcodec/msvideo1: Check buffer size before re-getting the frame
|
|
||||||
- avcodec/h264_cavlc: Fix undefined behavior on qscale overflow
|
|
||||||
- avcodec/dcadsp: Fix runtime error: signed integer overflow
|
|
||||||
- avcodec/svq3: Reject dx/dy beyond 16bit
|
|
||||||
- avcodec/svq3: Increase offsets to prevent integer overflows
|
|
||||||
- avcodec/indeo2: Check remaining bits in ir2_decode_plane()
|
|
||||||
- avcodec/vp3: Check remaining bits in unpack_dct_coeffs()
|
|
||||||
- doc/developer: Add terse documentation of assumed C implementation defined behavior
|
|
||||||
- avcodec/bmp: Use ff_set_dimensions()
|
|
||||||
- avcodec/mdec: Fix runtime error: left shift of negative value -127
|
|
||||||
- avcodec/x86/vc1dsp_init: Fix build failure with --disable-optimizations and clang
|
|
||||||
- libavcodec/exr : fix float to uint16 conversion for negative float value
|
|
||||||
- avformat/webmdashenc: Validate the 'streams' adaptation sets parameter
|
|
||||||
- avformat/webmdashenc: Require the 'adaptation_sets' option to be set
|
|
||||||
- lavfi/avfiltergraph: only return EOF in avfilter_graph_request_oldest if all sinks EOFed
|
|
||||||
- ffmpeg: check for unconnected outputs
|
|
||||||
- avformat/utils: free AVStream.codec properly in free_stream()
|
|
||||||
- avcodec/options: do a more thorough clean up in avcodec_copy_context()
|
|
||||||
- avcodec/options: factorize avcodec_copy_context() cleanup code
|
|
||||||
- ffmpeg: count packets when queued
|
|
||||||
- avformat/concatdec: fix the h264 annexb extradata check
|
|
||||||
- avcodec/dnxhd_parser: fix parsing interlaced video, simplify code
|
|
||||||
- ffmpeg; check return code of avcodec_send_frame when flushing encoders
|
|
||||||
- avcodec/g723_1dec: Fix LCG type
|
|
||||||
- avcodec/hqxdsp: Fix runtime error: signed integer overflow: -196264 * 11585 cannot be represented in type 'int'
|
|
||||||
- avcodec/ac3dec: Fix: runtime error: index -1 out of bounds for type 'INTFLOAT [2]'
|
|
||||||
- avcodec/mpeg4videodec: Clear sprite wraping on unsupported cases in VOP decode
|
|
||||||
- avcodec/pixlet: Fixes: runtime error: signed integer overflow: 9203954323419769657 + 29897660706736950 cannot be represented in type 'long'
|
|
||||||
- avcodec/dds: Fix runtime error: left shift of 210 by 24 places cannot be represented in type 'int'
|
|
||||||
- avcodec/rscc: Check pixel_size for overflow
|
|
||||||
- avcodec/fmvc: Check nb_blocks
|
|
||||||
- avcodec/cllc: Check prefix
|
|
||||||
- avcodec/webp: Factor update_canvas_size() out
|
|
||||||
- avcodec/webp: Update canvas size in vp8_lossy_decode_frame() as in vp8_lossless_decode_frame()
|
|
||||||
- avcodec/snowdec: Check width
|
|
||||||
- avcodec/flacdec: Return error code instead of 0 for failures
|
|
||||||
- avcodec/opus_silk: Fix integer overflow and out of array read
|
|
||||||
- avcodec/aacps: Fix undefined behavior
|
|
||||||
- avcodec/pixlet: Fix shift exponent 4294967268 is too large for 32-bit type 'int'
|
|
||||||
- doc/general: fix project name after 2b1a6b1ae
|
|
||||||
|
|
||||||
|
|
||||||
version 3.3:
|
|
||||||
- CrystalHD decoder moved to new decode API
|
|
||||||
- add internal ebur128 library, remove external libebur128 dependency
|
|
||||||
- Pro-MPEG CoP #3-R2 FEC protocol
|
|
||||||
- premultiply video filter
|
|
||||||
- Support for spherical videos
|
|
||||||
- configure now fails if autodetect-libraries are requested but not found
|
|
||||||
- PSD Decoder
|
|
||||||
- 16.8 floating point pcm decoder
|
|
||||||
- 24.0 floating point pcm decoder
|
|
||||||
- Apple Pixlet decoder
|
|
||||||
- QDMC audio decoder
|
|
||||||
- NewTek SpeedHQ decoder
|
|
||||||
- MIDI Sample Dump Standard demuxer
|
|
||||||
- readeia608 filter
|
|
||||||
- Sample Dump eXchange demuxer
|
|
||||||
- abitscope multimedia filter
|
|
||||||
- Scenarist Closed Captions demuxer and muxer
|
|
||||||
- threshold filter
|
|
||||||
- midequalizer filter
|
|
||||||
- Optimal Huffman tables for (M)JPEG encoding
|
|
||||||
- VAAPI-accelerated MPEG-2 and VP8 encoding
|
|
||||||
- FM Screen Capture Codec decoder
|
|
||||||
- native Opus encoder
|
|
||||||
- ScreenPressor decoder
|
|
||||||
- incomplete ClearVideo decoder
|
|
||||||
- Intel QSV video scaling and deinterlacing filters
|
|
||||||
- Support MOV with multiple sample description tables
|
|
||||||
- XPM decoder
|
|
||||||
- Removed the legacy X11 screen grabber, use XCB instead
|
|
||||||
- MPEG-7 Video Signature filter
|
|
||||||
- Removed asyncts filter (use af_aresample instead)
|
|
||||||
- Intel QSV-accelerated VP8 video decoding
|
|
||||||
|
|
||||||
|
|
||||||
version 3.2:
|
|
||||||
- libopenmpt demuxer
|
|
||||||
- tee protocol
|
|
||||||
- Changed metadata print option to accept general urls
|
|
||||||
- Alias muxer for Ogg Video (.ogv)
|
|
||||||
- VP8 in Ogg muxing
|
|
||||||
- curves filter doesn't automatically insert points at x=0 and x=1 anymore
|
|
||||||
- 16-bit support in curves filter and selectivecolor filter
|
|
||||||
- OpenH264 decoder wrapper
|
|
||||||
- MediaCodec H.264/HEVC/MPEG-4/VP8/VP9 hwaccel
|
|
||||||
- True Audio (TTA) muxer
|
|
||||||
- crystalizer audio filter
|
|
||||||
- acrusher audio filter
|
|
||||||
- bitplanenoise video filter
|
|
||||||
- floating point support in als decoder
|
|
||||||
- fifo muxer
|
|
||||||
- maskedclamp filter
|
|
||||||
- hysteresis filter
|
|
||||||
- lut2 filter
|
|
||||||
- yuvtestsrc filter
|
|
||||||
- CUDA CUVID H.263/VP8/VP9/10 bit HEVC (Dithered) Decoding
|
|
||||||
- vaguedenoiser filter
|
|
||||||
- added threads option per filter instance
|
|
||||||
- weave filter
|
|
||||||
- gblur filter
|
|
||||||
- avgblur filter
|
|
||||||
- sobel and prewitt filter
|
|
||||||
- MediaCodec HEVC/MPEG-4/VP8/VP9 decoding
|
|
||||||
- Meridian Lossless Packing (MLP) / TrueHD encoder
|
|
||||||
- Non-Local Means (nlmeans) denoising filter
|
|
||||||
- sdl2 output device and ffplay support
|
|
||||||
- sdl1 output device and sdl1 support removed
|
|
||||||
- extended mov edit list support
|
|
||||||
- libfaac encoder removed
|
|
||||||
- Matroska muxer now writes CRC32 elements by default in all Level 1 elements
|
|
||||||
- sidedata video and asidedata audio filter
|
|
||||||
- Changed mapping of rtp MIME type G726 to codec g726le.
|
|
||||||
- spec compliant VAAPI/DXVA2 VC-1 decoding of slices in frame-coded images
|
|
||||||
|
|
||||||
|
|
||||||
version 3.1:
|
|
||||||
- DXVA2-accelerated HEVC Main10 decoding
|
|
||||||
- fieldhint filter
|
|
||||||
- loop video filter and aloop audio filter
|
|
||||||
- Bob Weaver deinterlacing filter
|
|
||||||
- firequalizer filter
|
|
||||||
- datascope filter
|
|
||||||
- bench and abench filters
|
|
||||||
- ciescope filter
|
|
||||||
- protocol blacklisting API
|
|
||||||
- MediaCodec H264 decoding
|
|
||||||
- VC-2 HQ RTP payload format (draft v1) depacketizer and packetizer
|
|
||||||
- VP9 RTP payload format (draft v2) packetizer
|
|
||||||
- AudioToolbox audio decoders
|
|
||||||
- AudioToolbox audio encoders
|
|
||||||
- coreimage filter (GPU based image filtering on OSX)
|
|
||||||
- libdcadec removed
|
|
||||||
- bitstream filter for extracting DTS core
|
|
||||||
- ADPCM IMA DAT4 decoder
|
|
||||||
- musx demuxer
|
|
||||||
- aix demuxer
|
|
||||||
- remap filter
|
|
||||||
- hash and framehash muxers
|
|
||||||
- colorspace filter
|
|
||||||
- hdcd filter
|
|
||||||
- readvitc filter
|
|
||||||
- VAAPI-accelerated format conversion and scaling
|
|
||||||
- libnpp/CUDA-accelerated format conversion and scaling
|
|
||||||
- Duck TrueMotion 2.0 Real Time decoder
|
|
||||||
- Wideband Single-bit Data (WSD) demuxer
|
|
||||||
- VAAPI-accelerated H.264/HEVC/MJPEG encoding
|
|
||||||
- DTS Express (LBR) decoder
|
|
||||||
- Generic OpenMAX IL encoder with support for Raspberry Pi
|
|
||||||
- IFF ANIM demuxer & decoder
|
|
||||||
- Direct Stream Transfer (DST) decoder
|
|
||||||
- loudnorm filter
|
|
||||||
- MTAF demuxer and decoder
|
|
||||||
- MagicYUV decoder
|
|
||||||
- OpenExr improvements (tile data and B44/B44A support)
|
|
||||||
- BitJazz SheerVideo decoder
|
|
||||||
- CUDA CUVID H264/HEVC decoder
|
|
||||||
- 10-bit depth support in native utvideo decoder
|
|
||||||
- libutvideo wrapper removed
|
|
||||||
- YUY2 Lossless Codec decoder
|
|
||||||
- VideoToolbox H.264 encoder
|
|
||||||
|
|
||||||
|
|
||||||
version 3.0:
|
|
||||||
- Common Encryption (CENC) MP4 encoding and decoding support
|
|
||||||
- DXV decoding
|
|
||||||
- extrastereo filter
|
|
||||||
- ocr filter
|
|
||||||
- alimiter filter
|
|
||||||
- stereowiden filter
|
|
||||||
- stereotools filter
|
|
||||||
- rubberband filter
|
|
||||||
- tremolo filter
|
|
||||||
- agate filter
|
|
||||||
- chromakey filter
|
|
||||||
- maskedmerge filter
|
|
||||||
- Screenpresso SPV1 decoding
|
|
||||||
- chromaprint fingerprinting muxer
|
|
||||||
- ffplay dynamic volume control
|
|
||||||
- displace filter
|
|
||||||
- selectivecolor filter
|
|
||||||
- extensive native AAC encoder improvements and removal of experimental flag
|
|
||||||
- ADPCM PSX decoder
|
|
||||||
- 3dostr, dcstr, fsb, genh, vag, xvag, ads, msf, svag & vpk demuxer
|
|
||||||
- zscale filter
|
|
||||||
- wve demuxer
|
|
||||||
- zero-copy Intel QSV transcoding in ffmpeg
|
|
||||||
- shuffleframes filter
|
|
||||||
- SDX2 DPCM decoder
|
|
||||||
- vibrato filter
|
|
||||||
- innoHeim/Rsupport Screen Capture Codec decoder
|
|
||||||
- ADPCM AICA decoder
|
|
||||||
- Interplay ACM demuxer and audio decoder
|
|
||||||
- XMA1 & XMA2 decoder
|
|
||||||
- realtime filter
|
|
||||||
- anoisesrc audio filter source
|
|
||||||
- IVR demuxer
|
|
||||||
- compensationdelay filter
|
|
||||||
- acompressor filter
|
|
||||||
- support encoding 16-bit RLE SGI images
|
|
||||||
- apulsator filter
|
|
||||||
- sidechaingate audio filter
|
|
||||||
- mipsdspr1 option has been renamed to mipsdsp
|
|
||||||
- aemphasis filter
|
|
||||||
- mips32r5 option has been removed
|
|
||||||
- mips64r6 option has been removed
|
|
||||||
- DXVA2-accelerated VP9 decoding
|
|
||||||
- SOFAlizer: virtual binaural acoustics filter
|
|
||||||
- VAAPI VP9 hwaccel
|
|
||||||
- audio high-order multiband parametric equalizer
|
|
||||||
- automatic bitstream filtering
|
|
||||||
- showspectrumpic filter
|
|
||||||
- libstagefright support removed
|
|
||||||
- spectrumsynth filter
|
|
||||||
- ahistogram filter
|
|
||||||
- only seek with the right mouse button in ffplay
|
|
||||||
- toggle full screen when double-clicking with the left mouse button in ffplay
|
|
||||||
- afftfilt filter
|
|
||||||
- convolution filter
|
|
||||||
- libquvi support removed
|
|
||||||
- support for dvaudio in wav and avi
|
|
||||||
- libaacplus and libvo-aacenc support removed
|
|
||||||
- Cineform HD decoder
|
|
||||||
- new DCA decoder with full support for DTS-HD extensions
|
|
||||||
- significant performance improvements in Windows Television (WTV) demuxer
|
|
||||||
- nnedi deinterlacer
|
|
||||||
- streamselect video and astreamselect audio filter
|
|
||||||
- swaprect filter
|
|
||||||
- metadata video and ametadata audio filter
|
|
||||||
- SMPTE VC-2 HQ profile support for the Dirac decoder
|
|
||||||
- SMPTE VC-2 native encoder supporting the HQ profile
|
|
||||||
|
|
||||||
|
|
||||||
version 2.8:
|
|
||||||
- colorkey video filter
|
|
||||||
- BFSTM/BCSTM demuxer
|
|
||||||
- little-endian ADPCM_THP decoder
|
|
||||||
- Hap decoder and encoder
|
|
||||||
- DirectDraw Surface image/texture decoder
|
|
||||||
- ssim filter
|
|
||||||
- optional new ASF demuxer
|
|
||||||
- showvolume filter
|
|
||||||
- Many improvements to the JPEG 2000 decoder
|
|
||||||
- Go2Meeting decoding support
|
|
||||||
- adrawgraph audio and drawgraph video filter
|
|
||||||
- removegrain video filter
|
|
||||||
- Intel QSV-accelerated MPEG-2 video and HEVC encoding
|
|
||||||
- Intel QSV-accelerated MPEG-2 video and HEVC decoding
|
|
||||||
- Intel QSV-accelerated VC-1 video decoding
|
|
||||||
- libkvazaar HEVC encoder
|
|
||||||
- erosion, dilation, deflate and inflate video filters
|
|
||||||
- Dynamic Audio Normalizer as dynaudnorm filter
|
|
||||||
- Reverse video and areverse audio filter
|
|
||||||
- Random filter
|
|
||||||
- deband filter
|
|
||||||
- AAC fixed-point decoding
|
|
||||||
- sidechaincompress audio filter
|
|
||||||
- bitstream filter for converting HEVC from MP4 to Annex B
|
|
||||||
- acrossfade audio filter
|
|
||||||
- allyuv and allrgb video sources
|
|
||||||
- atadenoise video filter
|
|
||||||
- OS X VideoToolbox support
|
|
||||||
- aphasemeter filter
|
|
||||||
- showfreqs filter
|
|
||||||
- vectorscope filter
|
|
||||||
- waveform filter
|
|
||||||
- hstack and vstack filter
|
|
||||||
- Support DNx100 (1440x1080@8)
|
|
||||||
- VAAPI hevc hwaccel
|
|
||||||
- VDPAU hevc hwaccel
|
|
||||||
- framerate filter
|
|
||||||
- Switched default encoders for webm to VP9 and Opus
|
|
||||||
- Removed experimental flag from the JPEG 2000 encoder
|
|
||||||
|
|
||||||
|
|
||||||
version 2.7:
|
|
||||||
- FFT video filter
|
|
||||||
- TDSC decoder
|
|
||||||
- DTS lossless extension (XLL) decoding (not lossless, disabled by default)
|
|
||||||
- showwavespic filter
|
|
||||||
- DTS decoding through libdcadec
|
|
||||||
- Drop support for nvenc API before 5.0
|
|
||||||
- nvenc HEVC encoder
|
|
||||||
- Detelecine filter
|
|
||||||
- Intel QSV-accelerated H.264 encoding
|
|
||||||
- MMAL-accelerated H.264 decoding
|
|
||||||
- basic APNG encoder and muxer with default extension "apng"
|
|
||||||
- unpack DivX-style packed B-frames in MPEG-4 bitstream filter
|
|
||||||
- WebM Live Chunk Muxer
|
|
||||||
- nvenc level and tier options
|
|
||||||
- chorus filter
|
|
||||||
- Canopus HQ/HQA decoder
|
|
||||||
- Automatically rotate videos based on metadata in ffmpeg
|
|
||||||
- improved Quickdraw compatibility
|
|
||||||
- VP9 high bit-depth and extended colorspaces decoding support
|
|
||||||
- WebPAnimEncoder API when available for encoding and muxing WebP
|
|
||||||
- Direct3D11-accelerated decoding
|
|
||||||
- Support Secure Transport
|
|
||||||
- Multipart JPEG demuxer
|
|
||||||
|
|
||||||
|
|
||||||
version 2.6:
|
|
||||||
- nvenc encoder
|
|
||||||
- 10bit spp filter
|
|
||||||
- colorlevels filter
|
|
||||||
- RIFX format for *.wav files
|
|
||||||
- RTP/mpegts muxer
|
|
||||||
- non continuous cache protocol support
|
|
||||||
- tblend filter
|
|
||||||
- cropdetect support for non 8bpp, absolute (if limit >= 1) and relative (if limit < 1.0) threshold
|
|
||||||
- Camellia symmetric block cipher
|
|
||||||
- OpenH264 encoder wrapper
|
|
||||||
- VOC seeking support
|
|
||||||
- Closed caption Decoder
|
|
||||||
- fspp, uspp, pp7 MPlayer postprocessing filters ported to native filters
|
|
||||||
- showpalette filter
|
|
||||||
- Twofish symmetric block cipher
|
|
||||||
- Support DNx100 (960x720@8)
|
|
||||||
- eq2 filter ported from libmpcodecs as eq filter
|
|
||||||
- removed libmpcodecs
|
|
||||||
- Changed default DNxHD colour range in QuickTime .mov derivatives to mpeg range
|
|
||||||
- ported softpulldown filter from libmpcodecs as repeatfields filter
|
|
||||||
- dcshift filter
|
|
||||||
- RTP depacketizer for loss tolerant payload format for MP3 audio (RFC 5219)
|
|
||||||
- RTP depacketizer for AC3 payload format (RFC 4184)
|
|
||||||
- palettegen and paletteuse filters
|
|
||||||
- VP9 RTP payload format (draft 0) experimental depacketizer
|
|
||||||
- RTP depacketizer for DV (RFC 6469)
|
|
||||||
- DXVA2-accelerated HEVC decoding
|
|
||||||
- AAC ELD 480 decoding
|
|
||||||
- Intel QSV-accelerated H.264 decoding
|
|
||||||
- DSS SP decoder and DSS demuxer
|
|
||||||
- Fix stsd atom corruption in DNxHD QuickTimes
|
|
||||||
- Canopus HQX decoder
|
|
||||||
- RTP depacketization of T.140 text (RFC 4103)
|
|
||||||
- Port MIPS optimizations to 64-bit
|
|
||||||
|
|
||||||
|
|
||||||
version 2.5:
|
|
||||||
- HEVC/H.265 RTP payload format (draft v6) packetizer
|
|
||||||
- SUP/PGS subtitle demuxer
|
|
||||||
- ffprobe -show_pixel_formats option
|
|
||||||
- CAST128 symmetric block cipher, ECB mode
|
|
||||||
- STL subtitle demuxer and decoder
|
|
||||||
- libutvideo YUV 4:2:2 10bit support
|
|
||||||
- XCB-based screen-grabber
|
|
||||||
- UDP-Lite support (RFC 3828)
|
|
||||||
- xBR scaling filter
|
|
||||||
- AVFoundation screen capturing support
|
|
||||||
- ffserver supports codec private options
|
|
||||||
- creating DASH compatible fragmented MP4, MPEG-DASH segmenting muxer
|
|
||||||
- WebP muxer with animated WebP support
|
|
||||||
- zygoaudio decoding support
|
|
||||||
- APNG demuxer
|
|
||||||
- postproc visualization support
|
|
||||||
|
|
||||||
|
|
||||||
version 2.4:
|
|
||||||
- Icecast protocol
|
|
||||||
- ported lenscorrection filter from frei0r filter
|
|
||||||
- large optimizations in dctdnoiz to make it usable
|
|
||||||
- ICY metadata are now requested by default with the HTTP protocol
|
|
||||||
- support for using metadata in stream specifiers in fftools
|
|
||||||
- LZMA compression support in TIFF decoder
|
|
||||||
- H.261 RTP payload format (RFC 4587) depacketizer and experimental packetizer
|
|
||||||
- HEVC/H.265 RTP payload format (draft v6) depacketizer
|
|
||||||
- added codecview filter to visualize information exported by some codecs
|
|
||||||
- Matroska 3D support thorugh side data
|
|
||||||
- HTML generation using texi2html is deprecated in favor of makeinfo/texi2any
|
|
||||||
- silenceremove filter
|
|
||||||
|
|
||||||
|
|
||||||
version 2.3:
|
|
||||||
- AC3 fixed-point decoding
|
|
||||||
- shuffleplanes filter
|
|
||||||
- subfile protocol
|
|
||||||
- Phantom Cine demuxer
|
|
||||||
- replaygain data export
|
|
||||||
- VP7 video decoder
|
|
||||||
- Alias PIX image encoder and decoder
|
|
||||||
- Improvements to the BRender PIX image decoder
|
|
||||||
- Improvements to the XBM decoder
|
|
||||||
- QTKit input device
|
|
||||||
- improvements to OpenEXR image decoder
|
|
||||||
- support decoding 16-bit RLE SGI images
|
|
||||||
- GDI screen grabbing for Windows
|
|
||||||
- alternative rendition support for HTTP Live Streaming
|
|
||||||
- AVFoundation input device
|
|
||||||
- Direct Stream Digital (DSD) decoder
|
|
||||||
- Magic Lantern Video (MLV) demuxer
|
|
||||||
- On2 AVC (Audio for Video) decoder
|
|
||||||
- support for decoding through DXVA2 in ffmpeg
|
|
||||||
- libbs2b-based stereo-to-binaural audio filter
|
|
||||||
- libx264 reference frames count limiting depending on level
|
|
||||||
- native Opus decoder
|
|
||||||
- display matrix export and rotation API
|
|
||||||
- WebVTT encoder
|
|
||||||
- showcqt multimedia filter
|
|
||||||
- zoompan filter
|
|
||||||
- signalstats filter
|
|
||||||
- hqx filter (hq2x, hq3x, hq4x)
|
|
||||||
- flanger filter
|
|
||||||
- Image format auto-detection
|
|
||||||
- LRC demuxer and muxer
|
|
||||||
- Samba protocol (via libsmbclient)
|
|
||||||
- WebM DASH Manifest muxer
|
|
||||||
- libfribidi support in drawtext
|
|
||||||
|
|
||||||
|
|
||||||
version 2.2:
|
|
||||||
|
|
||||||
- HNM version 4 demuxer and video decoder
|
|
||||||
- Live HDS muxer
|
|
||||||
- setsar/setdar filters now support variables in ratio expressions
|
|
||||||
- elbg filter
|
|
||||||
- string validation in ffprobe
|
|
||||||
- support for decoding through VDPAU in ffmpeg (the -hwaccel option)
|
|
||||||
- complete Voxware MetaSound decoder
|
|
||||||
- remove mp3_header_compress bitstream filter
|
|
||||||
- Windows resource files for shared libraries
|
|
||||||
- aeval filter
|
|
||||||
- stereoscopic 3d metadata handling
|
|
||||||
- WebP encoding via libwebp
|
|
||||||
- ATRAC3+ decoder
|
|
||||||
- VP8 in Ogg demuxing
|
|
||||||
- side & metadata support in NUT
|
|
||||||
- framepack filter
|
|
||||||
- XYZ12 rawvideo support in NUT
|
|
||||||
- Exif metadata support in WebP decoder
|
|
||||||
- OpenGL device
|
|
||||||
- Use metadata_header_padding to control padding in ID3 tags (currently used in
|
|
||||||
MP3, AIFF, and OMA files), FLAC header, and the AVI "junk" block.
|
|
||||||
- Mirillis FIC video decoder
|
|
||||||
- Support DNx444
|
|
||||||
- libx265 encoder
|
|
||||||
- dejudder filter
|
|
||||||
- Autodetect VDA like all other hardware accelerations
|
|
||||||
- aliases and defaults for Ogg subtypes (opus, spx)
|
|
||||||
|
|
||||||
|
|
||||||
version 2.1:
|
|
||||||
|
|
||||||
- aecho filter
|
|
||||||
- perspective filter ported from libmpcodecs
|
|
||||||
- ffprobe -show_programs option
|
|
||||||
- compand filter
|
|
||||||
- RTMP seek support
|
|
||||||
- when transcoding with ffmpeg (i.e. not streamcopying), -ss is now accurate
|
|
||||||
even when used as an input option. Previous behavior can be restored with
|
|
||||||
the -noaccurate_seek option.
|
|
||||||
- ffmpeg -t option can now be used for inputs, to limit the duration of
|
|
||||||
data read from an input file
|
|
||||||
- incomplete Voxware MetaSound decoder
|
|
||||||
- read EXIF metadata from JPEG
|
|
||||||
- DVB teletext decoder
|
|
||||||
- phase filter ported from libmpcodecs
|
|
||||||
- w3fdif filter
|
|
||||||
- Opus support in Matroska
|
|
||||||
- FFV1 version 1.3 is stable and no longer experimental
|
|
||||||
- FFV1: YUVA(444,422,420) 9, 10 and 16 bit support
|
|
||||||
- changed DTS stream id in lavf mpeg ps muxer from 0x8a to 0x88, to be
|
|
||||||
more consistent with other muxers.
|
|
||||||
- adelay filter
|
|
||||||
- pullup filter ported from libmpcodecs
|
|
||||||
- ffprobe -read_intervals option
|
|
||||||
- Lossless and alpha support for WebP decoder
|
|
||||||
- Error Resilient AAC syntax (ER AAC LC) decoding
|
|
||||||
- Low Delay AAC (ER AAC LD) decoding
|
|
||||||
- mux chapters in ASF files
|
|
||||||
- SFTP protocol (via libssh)
|
|
||||||
- libx264: add ability to encode in YUVJ422P and YUVJ444P
|
|
||||||
- Fraps: use BT.709 colorspace by default for yuv, as reference fraps decoder does
|
|
||||||
- make decoding alpha optional for prores, ffv1 and vp6 by setting
|
|
||||||
the skip_alpha flag.
|
|
||||||
- ladspa wrapper filter
|
|
||||||
- native VP9 decoder
|
|
||||||
- dpx parser
|
|
||||||
- max_error_rate parameter in ffmpeg
|
|
||||||
- PulseAudio output device
|
|
||||||
- ReplayGain scanner
|
|
||||||
- Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support)
|
|
||||||
- Linux framebuffer output device
|
|
||||||
- HEVC decoder
|
|
||||||
- raw HEVC, HEVC in MOV/MP4, HEVC in Matroska, HEVC in MPEG-TS demuxing
|
|
||||||
- mergeplanes filter
|
|
||||||
|
|
||||||
|
|
||||||
version 2.0:
|
|
||||||
|
|
||||||
- curves filter
|
|
||||||
- reference-counting for AVFrame and AVPacket data
|
|
||||||
- ffmpeg now fails when input options are used for output file
|
|
||||||
or vice versa
|
|
||||||
- support for Monkey's Audio versions from 3.93
|
|
||||||
- perms and aperms filters
|
|
||||||
- audio filtering support in ffplay
|
|
||||||
- 10% faster aac encoding on x86 and MIPS
|
|
||||||
- sine audio filter source
|
|
||||||
- WebP demuxing and decoding support
|
|
||||||
- ffmpeg options -filter_script and -filter_complex_script, which allow a
|
|
||||||
filtergraph description to be read from a file
|
|
||||||
- OpenCL support
|
|
||||||
- audio phaser filter
|
|
||||||
- separatefields filter
|
|
||||||
- libquvi demuxer
|
|
||||||
- uniform options syntax across all filters
|
|
||||||
- telecine filter
|
|
||||||
- interlace filter
|
|
||||||
- smptehdbars source
|
|
||||||
- inverse telecine filters (fieldmatch and decimate)
|
|
||||||
- colorbalance filter
|
|
||||||
- colorchannelmixer filter
|
|
||||||
- The matroska demuxer can now output proper verbatim ASS packets. It will
|
|
||||||
become the default at the next libavformat major bump.
|
|
||||||
- decent native animated GIF encoding
|
|
||||||
- asetrate filter
|
|
||||||
- interleave filter
|
|
||||||
- timeline editing with filters
|
|
||||||
- vidstabdetect and vidstabtransform filters for video stabilization using
|
|
||||||
the vid.stab library
|
|
||||||
- astats filter
|
|
||||||
- trim and atrim filters
|
|
||||||
- ffmpeg -t and -ss (output-only) options are now sample-accurate when
|
|
||||||
transcoding audio
|
|
||||||
- Matroska muxer can now put the index at the beginning of the file.
|
|
||||||
- extractplanes filter
|
|
||||||
- avectorscope filter
|
|
||||||
- ADPCM DTK decoder
|
|
||||||
- ADP demuxer
|
|
||||||
- RSD demuxer
|
|
||||||
- RedSpark demuxer
|
|
||||||
- ADPCM IMA Radical decoder
|
|
||||||
- zmq filters
|
|
||||||
- DCT denoiser filter (dctdnoiz)
|
|
||||||
- Wavelet denoiser filter ported from libmpcodecs as owdenoise (formerly "ow")
|
|
||||||
- Apple Intermediate Codec decoder
|
|
||||||
- Escape 130 video decoder
|
|
||||||
- FTP protocol support
|
|
||||||
- V4L2 output device
|
|
||||||
- 3D LUT filter (lut3d)
|
|
||||||
- SMPTE 302M audio encoder
|
|
||||||
- support for slice multithreading in libavfilter
|
|
||||||
- Hald CLUT support (generation and filtering)
|
|
||||||
- VC-1 interlaced B-frame support
|
|
||||||
- support for WavPack muxing (raw and in Matroska)
|
|
||||||
- XVideo output device
|
|
||||||
- vignette filter
|
|
||||||
- True Audio (TTA) encoder
|
|
||||||
- Go2Webinar decoder
|
|
||||||
- mcdeint filter ported from libmpcodecs
|
|
||||||
- sab filter ported from libmpcodecs
|
|
||||||
- ffprobe -show_chapters option
|
|
||||||
- WavPack encoding through libwavpack
|
|
||||||
- rotate filter
|
|
||||||
- spp filter ported from libmpcodecs
|
|
||||||
- libgme support
|
|
||||||
- psnr filter
|
|
||||||
|
|
||||||
|
|
||||||
version 1.2:
|
version 1.2:
|
||||||
@@ -722,7 +75,7 @@ version 1.1:
|
|||||||
- JSON captions for TED talks decoding support
|
- JSON captions for TED talks decoding support
|
||||||
- SOX Resampler support in libswresample
|
- SOX Resampler support in libswresample
|
||||||
- aselect filter
|
- aselect filter
|
||||||
- SGI RLE 8-bit / Silicon Graphics RLE 8-bit video decoder
|
- SGI RLE 8-bit decoder
|
||||||
- Silicon Graphics Motion Video Compressor 1 & 2 decoder
|
- Silicon Graphics Motion Video Compressor 1 & 2 decoder
|
||||||
- Silicon Graphics Movie demuxer
|
- Silicon Graphics Movie demuxer
|
||||||
- apad filter
|
- apad filter
|
||||||
@@ -766,9 +119,7 @@ version 1.0:
|
|||||||
- RTMPE protocol support
|
- RTMPE protocol support
|
||||||
- RTMPTE protocol support
|
- RTMPTE protocol support
|
||||||
- showwaves and showspectrum filter
|
- showwaves and showspectrum filter
|
||||||
- LucasArts SMUSH SANM playback support
|
- LucasArts SMUSH playback support
|
||||||
- LucasArts SMUSH VIMA audio decoder (ADPCM)
|
|
||||||
- LucasArts SMUSH demuxer
|
|
||||||
- SAMI, RealText and SubViewer demuxers and decoders
|
- SAMI, RealText and SubViewer demuxers and decoders
|
||||||
- Heart Of Darkness PAF playback support
|
- Heart Of Darkness PAF playback support
|
||||||
- iec61883 device
|
- iec61883 device
|
||||||
@@ -892,7 +243,6 @@ version 0.10:
|
|||||||
- ffwavesynth decoder
|
- ffwavesynth decoder
|
||||||
- aviocat tool
|
- aviocat tool
|
||||||
- ffeval tool
|
- ffeval tool
|
||||||
- support encoding and decoding 4-channel SGI images
|
|
||||||
|
|
||||||
|
|
||||||
version 0.9:
|
version 0.9:
|
||||||
@@ -941,7 +291,7 @@ easier to use. The changes are:
|
|||||||
all the stream in the first input file, except for the second audio
|
all the stream in the first input file, except for the second audio
|
||||||
stream'.
|
stream'.
|
||||||
* There is a new option -c (or -codec) for choosing the decoder/encoder to
|
* There is a new option -c (or -codec) for choosing the decoder/encoder to
|
||||||
use, which makes it possible to precisely specify target stream(s) consistently with
|
use, which allows to precisely specify target stream(s) consistently with
|
||||||
other options. E.g. -c:v lib264 sets the codec for all video streams, -c:a:0
|
other options. E.g. -c:v lib264 sets the codec for all video streams, -c:a:0
|
||||||
libvorbis sets the codec for the first audio stream and -c copy copies all
|
libvorbis sets the codec for the first audio stream and -c copy copies all
|
||||||
the streams without reencoding. Old -vcodec/-acodec/-scodec options are now
|
the streams without reencoding. Old -vcodec/-acodec/-scodec options are now
|
||||||
@@ -1130,8 +480,8 @@ version 0.8:
|
|||||||
- showinfo filter added
|
- showinfo filter added
|
||||||
- SMPTE 302M AES3 audio decoder
|
- SMPTE 302M AES3 audio decoder
|
||||||
- Apple Core Audio Format muxer
|
- Apple Core Audio Format muxer
|
||||||
- 9 bits and 10 bits per sample support in the H.264 decoder
|
- 9bit and 10bit per sample support in the H.264 decoder
|
||||||
- 9 bits and 10 bits FFV1 encoding / decoding
|
- 9bit and 10bit FFV1 encoding / decoding
|
||||||
- split filter added
|
- split filter added
|
||||||
- select filter added
|
- select filter added
|
||||||
- sdl output device added
|
- sdl output device added
|
||||||
@@ -1193,7 +543,7 @@ version 0.6:
|
|||||||
- LPCM support in MPEG-TS (HDMV RID as found on Blu-ray disks)
|
- LPCM support in MPEG-TS (HDMV RID as found on Blu-ray disks)
|
||||||
- WMA Pro decoder
|
- WMA Pro decoder
|
||||||
- Core Audio Format demuxer
|
- Core Audio Format demuxer
|
||||||
- ATRAC1 decoder
|
- Atrac1 decoder
|
||||||
- MD STUDIO audio demuxer
|
- MD STUDIO audio demuxer
|
||||||
- RF64 support in WAV demuxer
|
- RF64 support in WAV demuxer
|
||||||
- MPEG-4 Audio Lossless Coding (ALS) decoder
|
- MPEG-4 Audio Lossless Coding (ALS) decoder
|
||||||
@@ -1293,7 +643,7 @@ version 0.5:
|
|||||||
- MXF demuxer
|
- MXF demuxer
|
||||||
- VC-1/WMV3/WMV9 video decoder
|
- VC-1/WMV3/WMV9 video decoder
|
||||||
- MacIntel support
|
- MacIntel support
|
||||||
- AviSynth support
|
- AVISynth support
|
||||||
- VMware video decoder
|
- VMware video decoder
|
||||||
- VP5 video decoder
|
- VP5 video decoder
|
||||||
- VP6 video decoder
|
- VP6 video decoder
|
||||||
@@ -1321,7 +671,7 @@ version 0.5:
|
|||||||
- Interplay C93 demuxer and video decoder
|
- Interplay C93 demuxer and video decoder
|
||||||
- Bethsoft VID demuxer and video decoder
|
- Bethsoft VID demuxer and video decoder
|
||||||
- CRYO APC demuxer
|
- CRYO APC demuxer
|
||||||
- ATRAC3 decoder
|
- Atrac3 decoder
|
||||||
- V.Flash PTX decoder
|
- V.Flash PTX decoder
|
||||||
- RoQ muxer, RoQ audio encoder
|
- RoQ muxer, RoQ audio encoder
|
||||||
- Renderware TXD demuxer and decoder
|
- Renderware TXD demuxer and decoder
|
||||||
@@ -1424,7 +774,7 @@ version 0.4.9-pre1:
|
|||||||
- rate distorted optimal lambda->qp support
|
- rate distorted optimal lambda->qp support
|
||||||
- AAC encoding with libfaac
|
- AAC encoding with libfaac
|
||||||
- Sunplus JPEG codec (SP5X) support
|
- Sunplus JPEG codec (SP5X) support
|
||||||
- use Lagrange multiplier instead of QP for ratecontrol
|
- use Lagrange multipler instead of QP for ratecontrol
|
||||||
- Theora/VP3 decoding support
|
- Theora/VP3 decoding support
|
||||||
- XA and ADX ADPCM codecs
|
- XA and ADX ADPCM codecs
|
||||||
- export MPEG-2 active display area / pan scan
|
- export MPEG-2 active display area / pan scan
|
||||||
|
|||||||
15
INSTALL
Normal file
15
INSTALL
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
1) Type './configure' to create the configuration. A list of configure
|
||||||
|
options is printed by running 'configure --help'.
|
||||||
|
|
||||||
|
'configure' can be launched from a directory different from the FFmpeg
|
||||||
|
sources to build the objects out of tree. To do this, use an absolute
|
||||||
|
path when launching 'configure', e.g. '/ffmpegdir/ffmpeg/configure'.
|
||||||
|
|
||||||
|
2) Then type 'make' to build FFmpeg. GNU Make 3.81 or later is required.
|
||||||
|
|
||||||
|
3) Type 'make install' to install all binaries and libraries you built.
|
||||||
|
|
||||||
|
NOTICE
|
||||||
|
|
||||||
|
- Non system dependencies (e.g. libx264, libvpx) are disabled by default.
|
||||||
17
INSTALL.md
17
INSTALL.md
@@ -1,17 +0,0 @@
|
|||||||
#Installing FFmpeg:
|
|
||||||
|
|
||||||
1. Type `./configure` to create the configuration. A list of configure
|
|
||||||
options is printed by running `configure --help`.
|
|
||||||
|
|
||||||
`configure` can be launched from a directory different from the FFmpeg
|
|
||||||
sources to build the objects out of tree. To do this, use an absolute
|
|
||||||
path when launching `configure`, e.g. `/ffmpegdir/ffmpeg/configure`.
|
|
||||||
|
|
||||||
2. Then type `make` to build FFmpeg. GNU Make 3.81 or later is required.
|
|
||||||
|
|
||||||
3. Type `make install` to install all binaries and libraries you built.
|
|
||||||
|
|
||||||
NOTICE
|
|
||||||
------
|
|
||||||
|
|
||||||
- Non system dependencies (e.g. libx264, libvpx) are disabled by default.
|
|
||||||
91
LICENSE
Normal file
91
LICENSE
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
FFmpeg:
|
||||||
|
|
||||||
|
Most files in FFmpeg are under the GNU Lesser General Public License version 2.1
|
||||||
|
or later (LGPL v2.1+). Read the file COPYING.LGPLv2.1 for details. Some other
|
||||||
|
files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to
|
||||||
|
FFmpeg.
|
||||||
|
|
||||||
|
Some optional parts of FFmpeg are licensed under the GNU General Public License
|
||||||
|
version 2 or later (GPL v2+). See the file COPYING.GPLv2 for details. None of
|
||||||
|
these parts are used by default, you have to explicitly pass --enable-gpl to
|
||||||
|
configure to activate them. In this case, FFmpeg's license changes to GPL v2+.
|
||||||
|
|
||||||
|
Specifically, the GPL parts of FFmpeg are
|
||||||
|
|
||||||
|
- libpostproc
|
||||||
|
- libmpcodecs
|
||||||
|
- optional x86 optimizations in the files
|
||||||
|
libavcodec/x86/idct_mmx.c
|
||||||
|
- libutvideo encoding/decoding wrappers in
|
||||||
|
libavcodec/libutvideo*.cpp
|
||||||
|
- the X11 grabber in libavdevice/x11grab.c
|
||||||
|
- the swresample test app in
|
||||||
|
libswresample/swresample-test.c
|
||||||
|
- the texi2pod.pl tool
|
||||||
|
- the following filters in libavfilter:
|
||||||
|
- f_ebur128.c
|
||||||
|
- vf_blackframe.c
|
||||||
|
- vf_boxblur.c
|
||||||
|
- vf_colormatrix.c
|
||||||
|
- vf_cropdetect.c
|
||||||
|
- vf_decimate.c
|
||||||
|
- vf_delogo.c
|
||||||
|
- vf_geq.c
|
||||||
|
- vf_histeq.c
|
||||||
|
- vf_hqdn3d.c
|
||||||
|
- vf_hue.c
|
||||||
|
- vf_kerndeint.c
|
||||||
|
- vf_mp.c
|
||||||
|
- vf_noise.c
|
||||||
|
- vf_pp.c
|
||||||
|
- vf_smartblur.c
|
||||||
|
- vf_stereo3d.c
|
||||||
|
- vf_super2xsai.c
|
||||||
|
- vf_tinterlace.c
|
||||||
|
- vf_yadif.c
|
||||||
|
- vsrc_mptestsrc.c
|
||||||
|
|
||||||
|
Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then
|
||||||
|
the configure parameter --enable-version3 will activate this licensing option
|
||||||
|
for you. Read the file COPYING.LGPLv3 or, if you have enabled GPL parts,
|
||||||
|
COPYING.GPLv3 to learn the exact legal terms that apply in this case.
|
||||||
|
|
||||||
|
There are a handful of files under other licensing terms, namely:
|
||||||
|
|
||||||
|
* The files libavcodec/jfdctfst.c, libavcodec/jfdctint_template.c and
|
||||||
|
libavcodec/jrevdct.c are taken from libjpeg, see the top of the files for
|
||||||
|
licensing details. Specifically note that you must credit the IJG in the
|
||||||
|
documentation accompanying your program if you only distribute executables.
|
||||||
|
You must also indicate any changes including additions and deletions to
|
||||||
|
those three files in the documentation.
|
||||||
|
|
||||||
|
|
||||||
|
external libraries
|
||||||
|
==================
|
||||||
|
|
||||||
|
FFmpeg can be combined with a number of external libraries, which sometimes
|
||||||
|
affect the licensing of binaries resulting from the combination.
|
||||||
|
|
||||||
|
compatible libraries
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The libcdio, libx264, libxavs and libxvid libraries are under GPL. When
|
||||||
|
combining them with FFmpeg, FFmpeg needs to be licensed as GPL as well by
|
||||||
|
passing --enable-gpl to configure.
|
||||||
|
|
||||||
|
The OpenCORE and VisualOn libraries are under the Apache License 2.0. That
|
||||||
|
license is incompatible with the LGPL v2.1 and the GPL v2, but not with
|
||||||
|
version 3 of those licenses. So to combine these libraries with FFmpeg, the
|
||||||
|
license version needs to be upgraded by passing --enable-version3 to configure.
|
||||||
|
|
||||||
|
incompatible libraries
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The Fraunhofer AAC library, FAAC and aacplus are under licenses which
|
||||||
|
are incompatible with the GPLv2 and v3. We do not know for certain if their
|
||||||
|
licenses are compatible with the LGPL.
|
||||||
|
If you wish to enable these libraries, pass --enable-nonfree to configure.
|
||||||
|
But note that if you enable any of these libraries the resulting binary will
|
||||||
|
be under a complex license mix that is more restrictive than the LGPL and that
|
||||||
|
may result in additional obligations. It is possible that these
|
||||||
|
restrictions cause the resulting binary to be unredistributeable.
|
||||||
120
LICENSE.md
120
LICENSE.md
@@ -1,120 +0,0 @@
|
|||||||
# License
|
|
||||||
|
|
||||||
Most files in FFmpeg are under the GNU Lesser General Public License version 2.1
|
|
||||||
or later (LGPL v2.1+). Read the file `COPYING.LGPLv2.1` for details. Some other
|
|
||||||
files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to
|
|
||||||
FFmpeg.
|
|
||||||
|
|
||||||
Some optional parts of FFmpeg are licensed under the GNU General Public License
|
|
||||||
version 2 or later (GPL v2+). See the file `COPYING.GPLv2` for details. None of
|
|
||||||
these parts are used by default, you have to explicitly pass `--enable-gpl` to
|
|
||||||
configure to activate them. In this case, FFmpeg's license changes to GPL v2+.
|
|
||||||
|
|
||||||
Specifically, the GPL parts of FFmpeg are:
|
|
||||||
|
|
||||||
- libpostproc
|
|
||||||
- optional x86 optimization in the files
|
|
||||||
- `libavcodec/x86/flac_dsp_gpl.asm`
|
|
||||||
- `libavcodec/x86/idct_mmx.c`
|
|
||||||
- `libavfilter/x86/vf_removegrain.asm`
|
|
||||||
- the following building and testing tools
|
|
||||||
- `compat/solaris/make_sunver.pl`
|
|
||||||
- `doc/t2h.pm`
|
|
||||||
- `doc/texi2pod.pl`
|
|
||||||
- `libswresample/swresample-test.c`
|
|
||||||
- `tests/checkasm/*`
|
|
||||||
- `tests/tiny_ssim.c`
|
|
||||||
- the following filters in libavfilter:
|
|
||||||
- `vf_blackframe.c`
|
|
||||||
- `vf_boxblur.c`
|
|
||||||
- `vf_colormatrix.c`
|
|
||||||
- `vf_cover_rect.c`
|
|
||||||
- `vf_cropdetect.c`
|
|
||||||
- `vf_delogo.c`
|
|
||||||
- `vf_eq.c`
|
|
||||||
- `vf_find_rect.c`
|
|
||||||
- `vf_fspp.c`
|
|
||||||
- `vf_geq.c`
|
|
||||||
- `vf_histeq.c`
|
|
||||||
- `vf_hqdn3d.c`
|
|
||||||
- `vf_interlace.c`
|
|
||||||
- `vf_kerndeint.c`
|
|
||||||
- `vf_mcdeint.c`
|
|
||||||
- `vf_mpdecimate.c`
|
|
||||||
- `vf_owdenoise.c`
|
|
||||||
- `vf_perspective.c`
|
|
||||||
- `vf_phase.c`
|
|
||||||
- `vf_pp.c`
|
|
||||||
- `vf_pp7.c`
|
|
||||||
- `vf_pullup.c`
|
|
||||||
- `vf_repeatfields.c`
|
|
||||||
- `vf_sab.c`
|
|
||||||
- `vf_smartblur.c`
|
|
||||||
- `vf_spp.c`
|
|
||||||
- `vf_stereo3d.c`
|
|
||||||
- `vf_super2xsai.c`
|
|
||||||
- `vf_tinterlace.c`
|
|
||||||
- `vf_uspp.c`
|
|
||||||
- `vsrc_mptestsrc.c`
|
|
||||||
|
|
||||||
Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then
|
|
||||||
the configure parameter `--enable-version3` will activate this licensing option
|
|
||||||
for you. Read the file `COPYING.LGPLv3` or, if you have enabled GPL parts,
|
|
||||||
`COPYING.GPLv3` to learn the exact legal terms that apply in this case.
|
|
||||||
|
|
||||||
There are a handful of files under other licensing terms, namely:
|
|
||||||
|
|
||||||
* The files `libavcodec/jfdctfst.c`, `libavcodec/jfdctint_template.c` and
|
|
||||||
`libavcodec/jrevdct.c` are taken from libjpeg, see the top of the files for
|
|
||||||
licensing details. Specifically note that you must credit the IJG in the
|
|
||||||
documentation accompanying your program if you only distribute executables.
|
|
||||||
You must also indicate any changes including additions and deletions to
|
|
||||||
those three files in the documentation.
|
|
||||||
* `tests/reference.pnm` is under the expat license.
|
|
||||||
|
|
||||||
|
|
||||||
## External libraries
|
|
||||||
|
|
||||||
FFmpeg can be combined with a number of external libraries, which sometimes
|
|
||||||
affect the licensing of binaries resulting from the combination.
|
|
||||||
|
|
||||||
### Compatible libraries
|
|
||||||
|
|
||||||
The following libraries are under GPL:
|
|
||||||
- frei0r
|
|
||||||
- libcdio
|
|
||||||
- librubberband
|
|
||||||
- libvidstab
|
|
||||||
- libx264
|
|
||||||
- libx265
|
|
||||||
- libxavs
|
|
||||||
- libxvid
|
|
||||||
|
|
||||||
When combining them with FFmpeg, FFmpeg needs to be licensed as GPL as well by
|
|
||||||
passing `--enable-gpl` to configure.
|
|
||||||
|
|
||||||
The OpenCORE and VisualOn libraries are under the Apache License 2.0. That
|
|
||||||
license is incompatible with the LGPL v2.1 and the GPL v2, but not with
|
|
||||||
version 3 of those licenses. So to combine these libraries with FFmpeg, the
|
|
||||||
license version needs to be upgraded by passing `--enable-version3` to configure.
|
|
||||||
|
|
||||||
### Incompatible libraries
|
|
||||||
|
|
||||||
There are certain libraries you can combine with FFmpeg whose licenses are not
|
|
||||||
compatible with the GPL and/or the LGPL. If you wish to enable these
|
|
||||||
libraries, even in circumstances that their license may be incompatible, pass
|
|
||||||
`--enable-nonfree` to configure. But note that if you enable any of these
|
|
||||||
libraries the resulting binary will be under a complex license mix that is
|
|
||||||
more restrictive than the LGPL and that may result in additional obligations.
|
|
||||||
It is possible that these restrictions cause the resulting binary to be
|
|
||||||
unredistributable.
|
|
||||||
|
|
||||||
The Fraunhofer FDK AAC and OpenSSL libraries are under licenses which are
|
|
||||||
incompatible with the GPLv2 and v3. To the best of our knowledge, they are
|
|
||||||
compatible with the LGPL.
|
|
||||||
|
|
||||||
The NVENC library, while its header file is licensed under the compatible MIT
|
|
||||||
license, requires a proprietary binary blob at run time, and is deemed to be
|
|
||||||
incompatible with the GPL. We are not certain if it is compatible with the
|
|
||||||
LGPL, but we require `--enable-nonfree` even with LGPL configurations in case
|
|
||||||
it is not.
|
|
||||||
355
MAINTAINERS
355
MAINTAINERS
@@ -7,13 +7,14 @@ FFmpeg code.
|
|||||||
Please try to keep entries where you are the maintainer up to date!
|
Please try to keep entries where you are the maintainer up to date!
|
||||||
|
|
||||||
Names in () mean that the maintainer currently has no time to maintain the code.
|
Names in () mean that the maintainer currently has no time to maintain the code.
|
||||||
A (CC <address>) after the name means that the maintainer prefers to be CC-ed on
|
A CC after the name means that the maintainer prefers to be CC-ed on patches
|
||||||
patches and related discussions.
|
and related discussions.
|
||||||
|
|
||||||
|
|
||||||
Project Leader
|
Project Leader
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
Michael Niedermayer
|
||||||
final design decisions
|
final design decisions
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ ffprobe:
|
|||||||
ffprobe.c Stefano Sabatini
|
ffprobe.c Stefano Sabatini
|
||||||
|
|
||||||
ffserver:
|
ffserver:
|
||||||
ffserver.c Reynaldo H. Verdejo Pinochet
|
ffserver.c, ffserver.h Baptiste Coudurier
|
||||||
|
|
||||||
Commandline utility code:
|
Commandline utility code:
|
||||||
cmdutils.c, cmdutils.h Michael Niedermayer
|
cmdutils.c, cmdutils.h Michael Niedermayer
|
||||||
@@ -42,25 +43,14 @@ QuickTime faststart:
|
|||||||
Miscellaneous Areas
|
Miscellaneous Areas
|
||||||
===================
|
===================
|
||||||
|
|
||||||
documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan
|
documentation Mike Melanson
|
||||||
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser, Nikolay Aleksandrov
|
website Robert Swain, Lou Logan
|
||||||
|
build system (configure,Makefiles) Diego Biurrun, Mans Rullgard
|
||||||
|
project server Árpád Gereöffy, Michael Niedermayer, Reimar Döffinger
|
||||||
|
mailinglists Michael Niedermayer, Baptiste Coudurier, Lou Logan
|
||||||
presets Robert Swain
|
presets Robert Swain
|
||||||
metadata subsystem Aurelien Jacobs
|
metadata subsystem Aurelien Jacobs
|
||||||
release management Michael Niedermayer
|
release management Michael Niedermayer
|
||||||
API tests Ludmila Glinskih
|
|
||||||
|
|
||||||
|
|
||||||
Communication
|
|
||||||
=============
|
|
||||||
|
|
||||||
website Deby Barbara Lepage
|
|
||||||
fate.ffmpeg.org Timothy Gu
|
|
||||||
Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos, Lou Logan
|
|
||||||
mailing lists Baptiste Coudurier, Lou Logan
|
|
||||||
Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser
|
|
||||||
Twitter Lou Logan, Reynaldo H. Verdejo Pinochet
|
|
||||||
Launchpad Timothy Gu
|
|
||||||
ffmpeg-security Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, Rodger Combs, wm4
|
|
||||||
|
|
||||||
|
|
||||||
libavutil
|
libavutil
|
||||||
@@ -72,25 +62,11 @@ Internal Interfaces:
|
|||||||
libavutil/common.h Michael Niedermayer
|
libavutil/common.h Michael Niedermayer
|
||||||
|
|
||||||
Other:
|
Other:
|
||||||
aes_ctr.c, aes_ctr.h Eran Kornblau
|
|
||||||
bprint Nicolas George
|
|
||||||
bswap.h
|
|
||||||
des Reimar Doeffinger
|
|
||||||
dynarray.h Nicolas George
|
|
||||||
eval.c, eval.h Michael Niedermayer
|
|
||||||
float_dsp Loren Merritt
|
|
||||||
hash Reimar Doeffinger
|
|
||||||
hwcontext_cuda* Timo Rothenpieler
|
|
||||||
intfloat* Michael Niedermayer
|
intfloat* Michael Niedermayer
|
||||||
integer.c, integer.h Michael Niedermayer
|
|
||||||
lzo Reimar Doeffinger
|
|
||||||
mathematics.c, mathematics.h Michael Niedermayer
|
|
||||||
mem.c, mem.h Michael Niedermayer
|
|
||||||
opencl.c, opencl.h Wei Gao
|
|
||||||
opt.c, opt.h Michael Niedermayer
|
|
||||||
rational.c, rational.h Michael Niedermayer
|
rational.c, rational.h Michael Niedermayer
|
||||||
rc4 Reimar Doeffinger
|
mathematics.c, mathematics.h Michael Niedermayer
|
||||||
ripemd.c, ripemd.h James Almer
|
integer.c, integer.h Michael Niedermayer
|
||||||
|
bswap.h
|
||||||
|
|
||||||
|
|
||||||
libavcodec
|
libavcodec
|
||||||
@@ -101,6 +77,10 @@ Generic Parts:
|
|||||||
avcodec.h Michael Niedermayer
|
avcodec.h Michael Niedermayer
|
||||||
utility code:
|
utility code:
|
||||||
utils.c Michael Niedermayer
|
utils.c Michael Niedermayer
|
||||||
|
mem.c Michael Niedermayer
|
||||||
|
opt.c, opt.h Michael Niedermayer
|
||||||
|
arithmetic expression evaluator:
|
||||||
|
eval.c Michael Niedermayer
|
||||||
audio and video frame extraction:
|
audio and video frame extraction:
|
||||||
parser.c Michael Niedermayer
|
parser.c Michael Niedermayer
|
||||||
bitstream reading:
|
bitstream reading:
|
||||||
@@ -116,10 +96,10 @@ Generic Parts:
|
|||||||
lzw.* Michael Niedermayer
|
lzw.* Michael Niedermayer
|
||||||
floating point AAN DCT:
|
floating point AAN DCT:
|
||||||
faandct.c, faandct.h Michael Niedermayer
|
faandct.c, faandct.h Michael Niedermayer
|
||||||
Non-power-of-two MDCT:
|
|
||||||
mdct15.c, mdct15.h Rostislav Pehlivanov
|
|
||||||
Golomb coding:
|
Golomb coding:
|
||||||
golomb.c, golomb.h Michael Niedermayer
|
golomb.c, golomb.h Michael Niedermayer
|
||||||
|
LPC:
|
||||||
|
lpc.c, lpc.h Justin Ruggles
|
||||||
motion estimation:
|
motion estimation:
|
||||||
motion* Michael Niedermayer
|
motion* Michael Niedermayer
|
||||||
rate control:
|
rate control:
|
||||||
@@ -131,95 +111,97 @@ Generic Parts:
|
|||||||
libpostproc/* Michael Niedermayer
|
libpostproc/* Michael Niedermayer
|
||||||
table generation:
|
table generation:
|
||||||
tableprint.c, tableprint.h Reimar Doeffinger
|
tableprint.c, tableprint.h Reimar Doeffinger
|
||||||
fixed point FFT:
|
|
||||||
fft* Zeljko Lukac
|
|
||||||
Text Subtitles Clément Bœsch
|
|
||||||
|
|
||||||
Codecs:
|
Codecs:
|
||||||
4xm.c Michael Niedermayer
|
4xm.c Michael Niedermayer
|
||||||
8bps.c Roberto Togni
|
8bps.c Roberto Togni
|
||||||
8svx.c Jaikrishnan Menon
|
8svx.c Jaikrishnan Menon
|
||||||
aacenc*, aaccoder.c Rostislav Pehlivanov
|
aasc.c Kostya Shishkov
|
||||||
|
ac3* Justin Ruggles
|
||||||
alacenc.c Jaikrishnan Menon
|
alacenc.c Jaikrishnan Menon
|
||||||
alsdec.c Thilo Borgmann, Umair Khan
|
alsdec.c Thilo Borgmann
|
||||||
|
apedec.c Kostya Shishkov
|
||||||
ass* Aurelien Jacobs
|
ass* Aurelien Jacobs
|
||||||
asv* Michael Niedermayer
|
asv* Michael Niedermayer
|
||||||
atrac3plus* Maxim Poliakovski
|
atrac3* Benjamin Larsson
|
||||||
audiotoolbox* Rodger Combs
|
|
||||||
bgmc.c, bgmc.h Thilo Borgmann
|
bgmc.c, bgmc.h Thilo Borgmann
|
||||||
|
bink.c Kostya Shishkov
|
||||||
binkaudio.c Peter Ross
|
binkaudio.c Peter Ross
|
||||||
|
bmp.c Mans Rullgard, Kostya Shishkov
|
||||||
cavs* Stefan Gehrer
|
cavs* Stefan Gehrer
|
||||||
cdxl.c Paul B Mahol
|
|
||||||
celp_filters.* Vitor Sessak
|
celp_filters.* Vitor Sessak
|
||||||
|
cdxl.c Paul B Mahol
|
||||||
cinepak.c Roberto Togni
|
cinepak.c Roberto Togni
|
||||||
cinepakenc.c Rl / Aetey G.T. AB
|
|
||||||
ccaption_dec.c Anshul Maheshwari, Aman Gupta
|
|
||||||
cljr Alex Beregszaszi
|
cljr Alex Beregszaszi
|
||||||
|
cllc.c Derek Buitenhuis
|
||||||
|
cook.c, cookdata.h Benjamin Larsson
|
||||||
cpia.c Stephan Hilb
|
cpia.c Stephan Hilb
|
||||||
crystalhd.c Philip Langdale
|
crystalhd.c Philip Langdale
|
||||||
cscd.c Reimar Doeffinger
|
cscd.c Reimar Doeffinger
|
||||||
cuvid.c Timo Rothenpieler
|
dca.c Kostya Shishkov, Benjamin Larsson
|
||||||
dirac* Rostislav Pehlivanov
|
|
||||||
dnxhd* Baptiste Coudurier
|
dnxhd* Baptiste Coudurier
|
||||||
dpcm.c Mike Melanson
|
dpcm.c Mike Melanson
|
||||||
dss_sp.c Oleksij Rempel
|
dxa.c Kostya Shishkov
|
||||||
dv.c Roman Shaposhnik
|
dv.c Roman Shaposhnik
|
||||||
dvbsubdec.c Anshul Maheshwari
|
|
||||||
eacmv*, eaidct*, eat* Peter Ross
|
eacmv*, eaidct*, eat* Peter Ross
|
||||||
evrc* Paul B Mahol
|
ffv1.c Michael Niedermayer
|
||||||
exif.c, exif.h Thilo Borgmann
|
|
||||||
ffv1* Michael Niedermayer
|
|
||||||
ffwavesynth.c Nicolas George
|
ffwavesynth.c Nicolas George
|
||||||
fifo.c Jan Sebechlebsky
|
flac* Justin Ruggles
|
||||||
|
flashsv* Benjamin Larsson
|
||||||
flicvideo.c Mike Melanson
|
flicvideo.c Mike Melanson
|
||||||
g722.c Martin Storsjo
|
g722.c Martin Storsjo
|
||||||
g726.c Roman Shaposhnik
|
g726.c Roman Shaposhnik
|
||||||
gifdec.c Baptiste Coudurier
|
gifdec.c Baptiste Coudurier
|
||||||
|
h264* Loren Merritt, Michael Niedermayer
|
||||||
h261* Michael Niedermayer
|
h261* Michael Niedermayer
|
||||||
h263* Michael Niedermayer
|
h263* Michael Niedermayer
|
||||||
h264* Loren Merritt, Michael Niedermayer
|
huffyuv.c Michael Niedermayer
|
||||||
hap* Tom Butterworth
|
|
||||||
huffyuv* Michael Niedermayer
|
|
||||||
idcinvideo.c Mike Melanson
|
idcinvideo.c Mike Melanson
|
||||||
|
imc* Benjamin Larsson
|
||||||
|
indeo2* Kostya Shishkov
|
||||||
|
indeo5* Kostya Shishkov
|
||||||
interplayvideo.c Mike Melanson
|
interplayvideo.c Mike Melanson
|
||||||
jni*, ffjni* Matthieu Bouron
|
ivi* Kostya Shishkov
|
||||||
jpeg2000* Nicolas Bertrand
|
jacosub* Clément Bœsch
|
||||||
|
jpeg_ls.c Kostya Shishkov
|
||||||
jvdec.c Peter Ross
|
jvdec.c Peter Ross
|
||||||
|
kmvc.c Kostya Shishkov
|
||||||
lcl*.c Roberto Togni, Reimar Doeffinger
|
lcl*.c Roberto Togni, Reimar Doeffinger
|
||||||
libcelt_dec.c Nicolas George
|
libcelt_dec.c Nicolas George
|
||||||
libdirac* David Conrad
|
|
||||||
libgsm.c Michel Bardiaux
|
libgsm.c Michel Bardiaux
|
||||||
libkvazaar.c Arttu Ylä-Outinen
|
libdirac* David Conrad
|
||||||
libopenjpeg.c Jaikrishnan Menon
|
libopenjpeg.c Jaikrishnan Menon
|
||||||
libopenjpegenc.c Michael Bradshaw
|
libopenjpegenc.c Michael Bradshaw
|
||||||
libschroedinger* David Conrad
|
libschroedinger* David Conrad
|
||||||
|
libspeexdec.c Justin Ruggles
|
||||||
libtheoraenc.c David Conrad
|
libtheoraenc.c David Conrad
|
||||||
|
libutvideo* Derek Buitenhuis
|
||||||
libvorbis.c David Conrad
|
libvorbis.c David Conrad
|
||||||
libvpx* James Zern
|
|
||||||
libxavs.c Stefan Gehrer
|
libxavs.c Stefan Gehrer
|
||||||
libzvbi-teletextdec.c Marton Balint
|
libx264.c Mans Rullgard, Jason Garrett-Glaser
|
||||||
|
loco.c Kostya Shishkov
|
||||||
lzo.h, lzo.c Reimar Doeffinger
|
lzo.h, lzo.c Reimar Doeffinger
|
||||||
mdec.c Michael Niedermayer
|
mdec.c Michael Niedermayer
|
||||||
mimic.c Ramiro Polla
|
mimic.c Ramiro Polla
|
||||||
mjpeg*.c Michael Niedermayer
|
mjpeg*.c Michael Niedermayer
|
||||||
mlp* Ramiro Polla, Jai Luthra
|
mlp* Ramiro Polla
|
||||||
mmvideo.c Peter Ross
|
mmvideo.c Peter Ross
|
||||||
|
mpc* Kostya Shishkov
|
||||||
mpeg12.c, mpeg12data.h Michael Niedermayer
|
mpeg12.c, mpeg12data.h Michael Niedermayer
|
||||||
mpegvideo.c, mpegvideo.h Michael Niedermayer
|
mpegvideo.c, mpegvideo.h Michael Niedermayer
|
||||||
mqc* Nicolas Bertrand
|
|
||||||
msmpeg4.c, msmpeg4data.h Michael Niedermayer
|
msmpeg4.c, msmpeg4data.h Michael Niedermayer
|
||||||
msrle.c Mike Melanson
|
msrle.c Mike Melanson
|
||||||
msvideo1.c Mike Melanson
|
msvideo1.c Mike Melanson
|
||||||
|
nellymoserdec.c Benjamin Larsson
|
||||||
nuv.c Reimar Doeffinger
|
nuv.c Reimar Doeffinger
|
||||||
nvenc* Timo Rothenpieler
|
|
||||||
opus* Rostislav Pehlivanov
|
|
||||||
paf.* Paul B Mahol
|
paf.* Paul B Mahol
|
||||||
pcx.c Ivo van Poorten
|
pcx.c Ivo van Poorten
|
||||||
pgssubdec.c Reimar Doeffinger
|
pgssubdec.c Reimar Doeffinger
|
||||||
ptx.c Ivo van Poorten
|
ptx.c Ivo van Poorten
|
||||||
qcelp* Reynaldo H. Verdejo Pinochet
|
qcelp* Reynaldo H. Verdejo Pinochet
|
||||||
qdm2.c, qdm2data.h Roberto Togni
|
qdm2.c, qdm2data.h Roberto Togni, Benjamin Larsson
|
||||||
qsv* Mark Thompson
|
qdrw.c Kostya Shishkov
|
||||||
|
qpeg.c Kostya Shishkov
|
||||||
qtrle.c Mike Melanson
|
qtrle.c Mike Melanson
|
||||||
ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni
|
ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni
|
||||||
resample2.c Michael Niedermayer
|
resample2.c Michael Niedermayer
|
||||||
@@ -227,50 +209,61 @@ Codecs:
|
|||||||
rpza.c Roberto Togni
|
rpza.c Roberto Togni
|
||||||
rtjpeg.c, rtjpeg.h Reimar Doeffinger
|
rtjpeg.c, rtjpeg.h Reimar Doeffinger
|
||||||
rv10.c Michael Niedermayer
|
rv10.c Michael Niedermayer
|
||||||
|
rv3* Kostya Shishkov
|
||||||
|
rv4* Kostya Shishkov
|
||||||
s3tc* Ivo van Poorten
|
s3tc* Ivo van Poorten
|
||||||
|
smacker.c Kostya Shishkov
|
||||||
smc.c Mike Melanson
|
smc.c Mike Melanson
|
||||||
smvjpegdec.c Ash Hughes
|
snow.c Michael Niedermayer, Loren Merritt
|
||||||
snow* Michael Niedermayer, Loren Merritt
|
|
||||||
sonic.c Alex Beregszaszi
|
sonic.c Alex Beregszaszi
|
||||||
srt* Aurelien Jacobs
|
srt* Aurelien Jacobs
|
||||||
sunrast.c Ivo van Poorten
|
sunrast.c Ivo van Poorten
|
||||||
svq3.c Michael Niedermayer
|
svq3.c Michael Niedermayer
|
||||||
tak* Paul B Mahol
|
tak* Paul B Mahol
|
||||||
|
targa.c Kostya Shishkov
|
||||||
|
tiff.c Kostya Shishkov
|
||||||
truemotion1* Mike Melanson
|
truemotion1* Mike Melanson
|
||||||
|
truemotion2* Kostya Shishkov
|
||||||
|
truespeech.c Kostya Shishkov
|
||||||
|
tscc.c Kostya Shishkov
|
||||||
tta.c Alex Beregszaszi, Jaikrishnan Menon
|
tta.c Alex Beregszaszi, Jaikrishnan Menon
|
||||||
ttaenc.c Paul B Mahol
|
|
||||||
txd.c Ivo van Poorten
|
txd.c Ivo van Poorten
|
||||||
vc2* Rostislav Pehlivanov
|
ulti* Kostya Shishkov
|
||||||
|
v410*.c Derek Buitenhuis
|
||||||
|
vb.c Kostya Shishkov
|
||||||
|
vble.c Derek Buitenhuis
|
||||||
|
vc1* Kostya Shishkov
|
||||||
vcr1.c Michael Niedermayer
|
vcr1.c Michael Niedermayer
|
||||||
vda_h264_dec.c Xidorn Quan
|
vda_h264_dec.c Xidorn Quan
|
||||||
videotoolboxenc.c Rick Kern
|
|
||||||
vima.c Paul B Mahol
|
vima.c Paul B Mahol
|
||||||
vorbisdec.c Denes Balatoni, David Conrad
|
vmnc.c Kostya Shishkov
|
||||||
vorbisenc.c Oded Shimon
|
vorbis_enc.c Oded Shimon
|
||||||
|
vorbis_dec.c Denes Balatoni, David Conrad
|
||||||
vp3* Mike Melanson
|
vp3* Mike Melanson
|
||||||
vp5 Aurelien Jacobs
|
vp5 Aurelien Jacobs
|
||||||
vp6 Aurelien Jacobs
|
vp6 Aurelien Jacobs
|
||||||
vp8 David Conrad, Ronald Bultje
|
vp8 David Conrad, Jason Garrett-Glaser, Ronald Bultje
|
||||||
vp9 Ronald Bultje
|
|
||||||
vqavideo.c Mike Melanson
|
vqavideo.c Mike Melanson
|
||||||
|
wavpack.c Kostya Shishkov
|
||||||
wmaprodec.c Sascha Sommer
|
wmaprodec.c Sascha Sommer
|
||||||
wmavoice.c Ronald S. Bultje
|
wmavoice.c Ronald S. Bultje
|
||||||
wmv2.c Michael Niedermayer
|
wmv2.c Michael Niedermayer
|
||||||
|
wnv1.c Kostya Shishkov
|
||||||
xan.c Mike Melanson
|
xan.c Mike Melanson
|
||||||
xbm* Paul B Mahol
|
xbm* Paul B Mahol
|
||||||
xface Stefano Sabatini
|
xl.c Kostya Shishkov
|
||||||
xvmc.c Ivan Kalvachev
|
xvmc.c Ivan Kalvachev
|
||||||
xwd* Paul B Mahol
|
xwd* Paul B Mahol
|
||||||
|
zerocodec.c Derek Buitenhuis
|
||||||
|
zmbv* Kostya Shishkov
|
||||||
|
|
||||||
Hardware acceleration:
|
Hardware acceleration:
|
||||||
crystalhd.c Philip Langdale
|
crystalhd.c Philip Langdale
|
||||||
dxva2* Hendrik Leppkes, Laurent Aimar, Steve Lhomme
|
dxva2* Laurent Aimar
|
||||||
d3d11va* Steve Lhomme
|
libstagefright.cpp Mohamed Naufal
|
||||||
mediacodec* Matthieu Bouron
|
|
||||||
vaapi* Gwenole Beauchesne
|
vaapi* Gwenole Beauchesne
|
||||||
vaapi_encode* Mark Thompson
|
vda* Sebastien Zwickert
|
||||||
vdpau* Philip Langdale, Carl Eugen Hoyos
|
vdpau* Carl Eugen Hoyos
|
||||||
videotoolbox* Rick Kern
|
|
||||||
|
|
||||||
|
|
||||||
libavdevice
|
libavdevice
|
||||||
@@ -279,22 +272,11 @@ libavdevice
|
|||||||
libavdevice/avdevice.h
|
libavdevice/avdevice.h
|
||||||
|
|
||||||
|
|
||||||
avfoundation.m Thilo Borgmann
|
|
||||||
decklink* Deti Fliegl
|
|
||||||
dshow.c Roger Pack (CC rogerdpack@gmail.com)
|
|
||||||
fbdev_enc.c Lukasz Marek
|
|
||||||
gdigrab.c Roger Pack (CC rogerdpack@gmail.com)
|
|
||||||
iec61883.c Georg Lippitsch
|
iec61883.c Georg Lippitsch
|
||||||
lavfi Stefano Sabatini
|
|
||||||
libdc1394.c Roman Shaposhnik
|
libdc1394.c Roman Shaposhnik
|
||||||
opengl_enc.c Lukasz Marek
|
v4l2.c Luca Abeni
|
||||||
pulse_audio_enc.c Lukasz Marek
|
|
||||||
qtkit.m Thilo Borgmann
|
|
||||||
sdl Stefano Sabatini
|
|
||||||
sdl2.c Josh de Kock
|
|
||||||
v4l2.c Giorgio Vazzana
|
|
||||||
vfwcap.c Ramiro Polla
|
vfwcap.c Ramiro Polla
|
||||||
xv.c Lukasz Marek
|
dshow.c Roger Pack
|
||||||
|
|
||||||
libavfilter
|
libavfilter
|
||||||
===========
|
===========
|
||||||
@@ -302,62 +284,12 @@ libavfilter
|
|||||||
Generic parts:
|
Generic parts:
|
||||||
graphdump.c Nicolas George
|
graphdump.c Nicolas George
|
||||||
|
|
||||||
motion_estimation.c Davinder Singh
|
|
||||||
|
|
||||||
Filters:
|
Filters:
|
||||||
f_drawgraph.c Paul B Mahol
|
|
||||||
af_adelay.c Paul B Mahol
|
|
||||||
af_aecho.c Paul B Mahol
|
|
||||||
af_afade.c Paul B Mahol
|
|
||||||
af_amerge.c Nicolas George
|
af_amerge.c Nicolas George
|
||||||
af_aphaser.c Paul B Mahol
|
af_astreamsync.c Nicolas George
|
||||||
af_aresample.c Michael Niedermayer
|
|
||||||
af_astats.c Paul B Mahol
|
|
||||||
af_atempo.c Pavel Koshevoy
|
af_atempo.c Pavel Koshevoy
|
||||||
af_biquads.c Paul B Mahol
|
|
||||||
af_chorus.c Paul B Mahol
|
|
||||||
af_compand.c Paul B Mahol
|
|
||||||
af_firequalizer.c Muhammad Faiz
|
|
||||||
af_hdcd.c Burt P.
|
|
||||||
af_ladspa.c Paul B Mahol
|
|
||||||
af_loudnorm.c Kyle Swanson
|
|
||||||
af_pan.c Nicolas George
|
af_pan.c Nicolas George
|
||||||
af_sidechaincompress.c Paul B Mahol
|
|
||||||
af_silenceremove.c Paul B Mahol
|
|
||||||
avf_aphasemeter.c Paul B Mahol
|
|
||||||
avf_avectorscope.c Paul B Mahol
|
|
||||||
avf_showcqt.c Muhammad Faiz
|
|
||||||
vf_blend.c Paul B Mahol
|
|
||||||
vf_chromakey.c Timo Rothenpieler
|
|
||||||
vf_colorchannelmixer.c Paul B Mahol
|
|
||||||
vf_colorbalance.c Paul B Mahol
|
|
||||||
vf_colorkey.c Timo Rothenpieler
|
|
||||||
vf_colorlevels.c Paul B Mahol
|
|
||||||
vf_coreimage.m Thilo Borgmann
|
|
||||||
vf_deband.c Paul B Mahol
|
|
||||||
vf_dejudder.c Nicholas Robbins
|
|
||||||
vf_delogo.c Jean Delvare (CC <jdelvare@suse.com>)
|
|
||||||
vf_drawbox.c/drawgrid Andrey Utkin
|
|
||||||
vf_extractplanes.c Paul B Mahol
|
|
||||||
vf_histogram.c Paul B Mahol
|
|
||||||
vf_hqx.c Clément Bœsch
|
|
||||||
vf_idet.c Pascal Massimino
|
|
||||||
vf_il.c Paul B Mahol
|
|
||||||
vf_lenscorrection.c Daniel Oberhoff
|
|
||||||
vf_mergeplanes.c Paul B Mahol
|
|
||||||
vf_mestimate.c Davinder Singh
|
|
||||||
vf_minterpolate.c Davinder Singh
|
|
||||||
vf_neighbor.c Paul B Mahol
|
|
||||||
vf_psnr.c Paul B Mahol
|
|
||||||
vf_random.c Paul B Mahol
|
|
||||||
vf_readvitc.c Tobias Rapp (CC t.rapp at noa-archive dot com)
|
|
||||||
vf_scale.c Michael Niedermayer
|
|
||||||
vf_separatefields.c Paul B Mahol
|
|
||||||
vf_ssim.c Paul B Mahol
|
|
||||||
vf_stereo3d.c Paul B Mahol
|
|
||||||
vf_telecine.c Paul B Mahol
|
|
||||||
vf_yadif.c Michael Niedermayer
|
vf_yadif.c Michael Niedermayer
|
||||||
vf_zoompan.c Paul B Mahol
|
|
||||||
|
|
||||||
Sources:
|
Sources:
|
||||||
vsrc_mandelbrot.c Michael Niedermayer
|
vsrc_mandelbrot.c Michael Niedermayer
|
||||||
@@ -370,84 +302,74 @@ Generic parts:
|
|||||||
libavformat/avformat.h Michael Niedermayer
|
libavformat/avformat.h Michael Niedermayer
|
||||||
Utility Code:
|
Utility Code:
|
||||||
libavformat/utils.c Michael Niedermayer
|
libavformat/utils.c Michael Niedermayer
|
||||||
Text Subtitles Clément Bœsch
|
|
||||||
|
|
||||||
|
|
||||||
Muxers/Demuxers:
|
Muxers/Demuxers:
|
||||||
4xm.c Mike Melanson
|
4xm.c Mike Melanson
|
||||||
aadec.c Vesselin Bontchev (vesselin.bontchev at yandex dot com)
|
|
||||||
adtsenc.c Robert Swain
|
adtsenc.c Robert Swain
|
||||||
afc.c Paul B Mahol
|
afc.c Paul B Mahol
|
||||||
aiffdec.c Baptiste Coudurier, Matthieu Bouron
|
aiff.c Baptiste Coudurier
|
||||||
aiffenc.c Baptiste Coudurier, Matthieu Bouron
|
ape.c Kostya Shishkov
|
||||||
apngdec.c Benoit Fouet
|
|
||||||
ass* Aurelien Jacobs
|
ass* Aurelien Jacobs
|
||||||
astdec.c Paul B Mahol
|
astdec.c Paul B Mahol
|
||||||
astenc.c James Almer
|
astenc.c James Almer
|
||||||
avi* Michael Niedermayer
|
avi* Michael Niedermayer
|
||||||
avisynth.c Stephen Hutchinson
|
|
||||||
avr.c Paul B Mahol
|
avr.c Paul B Mahol
|
||||||
bink.c Peter Ross
|
bink.c Peter Ross
|
||||||
boadec.c Michael Niedermayer
|
|
||||||
brstm.c Paul B Mahol
|
brstm.c Paul B Mahol
|
||||||
caf* Peter Ross
|
caf* Peter Ross
|
||||||
cdxl.c Paul B Mahol
|
cdxl.c Paul B Mahol
|
||||||
crc.c Michael Niedermayer
|
crc.c Michael Niedermayer
|
||||||
daud.c Reimar Doeffinger
|
daud.c Reimar Doeffinger
|
||||||
dss.c Oleksij Rempel
|
|
||||||
dtshddec.c Paul B Mahol
|
dtshddec.c Paul B Mahol
|
||||||
dv.c Roman Shaposhnik
|
dv.c Roman Shaposhnik
|
||||||
|
dxa.c Kostya Shishkov
|
||||||
electronicarts.c Peter Ross
|
electronicarts.c Peter Ross
|
||||||
epafdec.c Paul B Mahol
|
epafdec.c Paul B Mahol
|
||||||
ffm* Baptiste Coudurier
|
ffm* Baptiste Coudurier
|
||||||
|
flac* Justin Ruggles
|
||||||
flic.c Mike Melanson
|
flic.c Mike Melanson
|
||||||
flvdec.c Michael Niedermayer
|
flvdec.c, flvenc.c Michael Niedermayer
|
||||||
flvenc.c Michael Niedermayer, Steven Liu
|
|
||||||
gxf.c Reimar Doeffinger
|
gxf.c Reimar Doeffinger
|
||||||
gxfenc.c Baptiste Coudurier
|
gxfenc.c Baptiste Coudurier
|
||||||
hls.c Anssi Hannula
|
|
||||||
hls encryption (hlsenc.c) Christian Suloway, Steven Liu
|
|
||||||
idcin.c Mike Melanson
|
idcin.c Mike Melanson
|
||||||
idroqdec.c Mike Melanson
|
idroqdec.c Mike Melanson
|
||||||
iff.c Jaikrishnan Menon
|
iff.c Jaikrishnan Menon
|
||||||
img2*.c Michael Niedermayer
|
|
||||||
ipmovie.c Mike Melanson
|
ipmovie.c Mike Melanson
|
||||||
|
img2*.c Michael Niedermayer
|
||||||
ircam* Paul B Mahol
|
ircam* Paul B Mahol
|
||||||
iss.c Stefan Gehrer
|
iss.c Stefan Gehrer
|
||||||
|
jacosub* Clément Bœsch
|
||||||
jvdec.c Peter Ross
|
jvdec.c Peter Ross
|
||||||
libmodplug.c Clément Bœsch
|
libmodplug.c Clément Bœsch
|
||||||
libnut.c Oded Shimon
|
libnut.c Oded Shimon
|
||||||
libopenmpt.c Josh de Kock
|
|
||||||
lmlm4.c Ivo van Poorten
|
lmlm4.c Ivo van Poorten
|
||||||
lvfdec.c Paul B Mahol
|
lvfdec.c Paul B Mahol
|
||||||
lxfdec.c Tomas Härdin
|
lxfdec.c Tomas Härdin
|
||||||
matroska.c Aurelien Jacobs
|
matroska.c Aurelien Jacobs
|
||||||
matroskadec.c Aurelien Jacobs
|
matroskadec.c Aurelien Jacobs
|
||||||
matroskaenc.c David Conrad
|
matroskaenc.c David Conrad
|
||||||
matroska subtitles (matroskaenc.c) John Peebles
|
|
||||||
metadata* Aurelien Jacobs
|
metadata* Aurelien Jacobs
|
||||||
mgsts.c Paul B Mahol
|
|
||||||
microdvd* Aurelien Jacobs
|
microdvd* Aurelien Jacobs
|
||||||
|
mgsts.c Paul B Mahol
|
||||||
mm.c Peter Ross
|
mm.c Peter Ross
|
||||||
mov.c Baptiste Coudurier
|
mov.c Michael Niedermayer, Baptiste Coudurier
|
||||||
movenc.c Baptiste Coudurier, Matthieu Bouron
|
movenc.c Michael Niedermayer, Baptiste Coudurier
|
||||||
movenccenc.c Eran Kornblau
|
mpc.c Kostya Shishkov
|
||||||
mpeg.c Michael Niedermayer
|
mpeg.c Michael Niedermayer
|
||||||
mpegenc.c Michael Niedermayer
|
mpegenc.c Michael Niedermayer
|
||||||
mpegts.c Marton Balint
|
mpegts* Baptiste Coudurier
|
||||||
mpegtsenc.c Baptiste Coudurier
|
|
||||||
msnwc_tcp.c Ramiro Polla
|
msnwc_tcp.c Ramiro Polla
|
||||||
mtv.c Reynaldo H. Verdejo Pinochet
|
mtv.c Reynaldo H. Verdejo Pinochet
|
||||||
mxf* Baptiste Coudurier
|
mxf* Baptiste Coudurier
|
||||||
mxfdec.c Tomas Härdin
|
mxfdec.c Tomas Härdin
|
||||||
nistspheredec.c Paul B Mahol
|
nistspheredec.c Paul B Mahol
|
||||||
nsvdec.c Francois Revol
|
nsvdec.c Francois Revol
|
||||||
nut* Michael Niedermayer
|
nut.c Michael Niedermayer
|
||||||
nuv.c Reimar Doeffinger
|
nuv.c Reimar Doeffinger
|
||||||
oggdec.c, oggdec.h David Conrad
|
oggdec.c, oggdec.h David Conrad
|
||||||
oggenc.c Baptiste Coudurier
|
oggenc.c Baptiste Coudurier
|
||||||
oggparse*.c David Conrad
|
oggparse*.c David Conrad
|
||||||
oggparsedaala* Rostislav Pehlivanov
|
|
||||||
oma.c Maxim Poliakovski
|
oma.c Maxim Poliakovski
|
||||||
paf.c Paul B Mahol
|
paf.c Paul B Mahol
|
||||||
psxstr.c Mike Melanson
|
psxstr.c Mike Melanson
|
||||||
@@ -457,23 +379,18 @@ Muxers/Demuxers:
|
|||||||
raw.c Michael Niedermayer
|
raw.c Michael Niedermayer
|
||||||
rdt.c Ronald S. Bultje
|
rdt.c Ronald S. Bultje
|
||||||
rl2.c Sascha Sommer
|
rl2.c Sascha Sommer
|
||||||
rmdec.c, rmenc.c Ronald S. Bultje
|
rmdec.c, rmenc.c Ronald S. Bultje, Kostya Shishkov
|
||||||
|
rtmp* Kostya Shishkov
|
||||||
rtp.c, rtpenc.c Martin Storsjo
|
rtp.c, rtpenc.c Martin Storsjo
|
||||||
rtpdec_ac3.* Gilles Chanteperdrix
|
|
||||||
rtpdec_dv.* Thomas Volkert
|
|
||||||
rtpdec_h261.*, rtpenc_h261.* Thomas Volkert
|
|
||||||
rtpdec_hevc.*, rtpenc_hevc.* Thomas Volkert
|
|
||||||
rtpdec_mpa_robust.* Gilles Chanteperdrix
|
|
||||||
rtpdec_asf.* Ronald S. Bultje
|
rtpdec_asf.* Ronald S. Bultje
|
||||||
rtpdec_vc2hq.*, rtpenc_vc2hq.* Thomas Volkert
|
|
||||||
rtpdec_vp9.c Thomas Volkert
|
|
||||||
rtpenc_mpv.*, rtpenc_aac.* Martin Storsjo
|
rtpenc_mpv.*, rtpenc_aac.* Martin Storsjo
|
||||||
|
rtsp.c Luca Barbato
|
||||||
sbgdec.c Nicolas George
|
sbgdec.c Nicolas George
|
||||||
sdp.c Martin Storsjo
|
sdp.c Martin Storsjo
|
||||||
segafilm.c Mike Melanson
|
segafilm.c Mike Melanson
|
||||||
segment.c Stefano Sabatini
|
siff.c Kostya Shishkov
|
||||||
|
smacker.c Kostya Shishkov
|
||||||
smjpeg* Paul B Mahol
|
smjpeg* Paul B Mahol
|
||||||
spdif* Anssi Hannula
|
|
||||||
srtdec.c Aurelien Jacobs
|
srtdec.c Aurelien Jacobs
|
||||||
swf.c Baptiste Coudurier
|
swf.c Baptiste Coudurier
|
||||||
takdec.c Paul B Mahol
|
takdec.c Paul B Mahol
|
||||||
@@ -482,21 +399,16 @@ Muxers/Demuxers:
|
|||||||
voc.c Aurelien Jacobs
|
voc.c Aurelien Jacobs
|
||||||
wav.c Michael Niedermayer
|
wav.c Michael Niedermayer
|
||||||
wc3movie.c Mike Melanson
|
wc3movie.c Mike Melanson
|
||||||
webm dash (matroskaenc.c) Vignesh Venkatasubramanian
|
|
||||||
webvtt* Matthew J Heaney
|
|
||||||
westwood.c Mike Melanson
|
westwood.c Mike Melanson
|
||||||
wtv.c Peter Ross
|
wtv.c Peter Ross
|
||||||
|
wv.c Kostya Shishkov
|
||||||
wvenc.c Paul B Mahol
|
wvenc.c Paul B Mahol
|
||||||
|
|
||||||
Protocols:
|
Protocols:
|
||||||
async.c Zhang Rui
|
|
||||||
bluray.c Petri Hintukainen
|
bluray.c Petri Hintukainen
|
||||||
ftp.c Lukasz Marek
|
|
||||||
http.c Ronald S. Bultje
|
http.c Ronald S. Bultje
|
||||||
libssh.c Lukasz Marek
|
|
||||||
mms*.c Ronald S. Bultje
|
mms*.c Ronald S. Bultje
|
||||||
udp.c Luca Abeni
|
udp.c Luca Abeni
|
||||||
icecast.c Marvin Scholz
|
|
||||||
|
|
||||||
|
|
||||||
libswresample
|
libswresample
|
||||||
@@ -516,89 +428,56 @@ Resamplers:
|
|||||||
Operating systems / CPU architectures
|
Operating systems / CPU architectures
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
Alpha Falk Hueffner
|
Alpha Mans Rullgard, Falk Hueffner
|
||||||
MIPS Nedeljko Babic
|
ARM Mans Rullgard
|
||||||
|
AVR32 Mans Rullgard
|
||||||
|
MIPS Mans Rullgard
|
||||||
Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier
|
Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier
|
||||||
Amiga / PowerPC Colin Ward
|
Amiga / PowerPC Colin Ward
|
||||||
|
Linux / PowerPC Luca Barbato
|
||||||
Windows MinGW Alex Beregszaszi, Ramiro Polla
|
Windows MinGW Alex Beregszaszi, Ramiro Polla
|
||||||
Windows Cygwin Victor Paesa
|
Windows Cygwin Victor Paesa
|
||||||
Windows MSVC Matthew Oliver, Hendrik Leppkes
|
|
||||||
Windows ICL Matthew Oliver
|
|
||||||
ADI/Blackfin DSP Marc Hoffman
|
ADI/Blackfin DSP Marc Hoffman
|
||||||
Sparc Roman Shaposhnik
|
Sparc Roman Shaposhnik
|
||||||
OS/2 KO Myung-Hun
|
x86 Michael Niedermayer
|
||||||
|
|
||||||
|
|
||||||
Developers with git write access who are currently not maintaining any specific part
|
|
||||||
====================================================================================
|
|
||||||
Alex Converse
|
|
||||||
Andreas Cadhalpun
|
|
||||||
Anuradha Suraparaju
|
|
||||||
Ben Littler
|
|
||||||
Benjamin Larsson
|
|
||||||
Bobby Bingham
|
|
||||||
Daniel Verkamp
|
|
||||||
Derek Buitenhuis
|
|
||||||
Ganesh Ajjanagadde
|
|
||||||
Henrik Gramner
|
|
||||||
Ivan Uskov
|
|
||||||
James Darnley
|
|
||||||
Joakim Plate
|
|
||||||
Kieran Kunhya
|
|
||||||
Kirill Gavrilov
|
|
||||||
Martin Storsjö
|
|
||||||
Panagiotis Issaris
|
|
||||||
Pedro Arthur
|
|
||||||
Sebastien Zwickert
|
|
||||||
Vittorio Giovara
|
|
||||||
wm4
|
|
||||||
(this list is incomplete)
|
|
||||||
|
|
||||||
|
|
||||||
Releases
|
Releases
|
||||||
========
|
========
|
||||||
|
|
||||||
2.8 Michael Niedermayer
|
1.2 Michael Niedermayer
|
||||||
2.7 Michael Niedermayer
|
1.1 Michael Niedermayer
|
||||||
2.6 Michael Niedermayer
|
1.0 Michael Niedermayer
|
||||||
2.5 Michael Niedermayer
|
|
||||||
|
|
||||||
If you want to maintain an older release, please contact us
|
|
||||||
|
|
||||||
|
|
||||||
GnuPG Fingerprints of maintainers and contributors
|
GnuPG Fingerprints of maintainers and contributors
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
Alexander Strasser 1C96 78B7 83CB 8AA7 9AF5 D1EB A7D8 A57B A876 E58F
|
|
||||||
Anssi Hannula 1A92 FF42 2DD9 8D2E 8AF7 65A9 4278 C520 513D F3CB
|
Anssi Hannula 1A92 FF42 2DD9 8D2E 8AF7 65A9 4278 C520 513D F3CB
|
||||||
Ash Hughes 694D 43D2 D180 C7C7 6421 ABD3 A641 D0B7 623D 6029
|
Anton Khirnov 6D0C 6625 56F8 65D1 E5F5 814B B50A 1241 C067 07AB
|
||||||
Attila Kinali 11F0 F9A6 A1D2 11F6 C745 D10C 6520 BCDD F2DF E765
|
Attila Kinali 11F0 F9A6 A1D2 11F6 C745 D10C 6520 BCDD F2DF E765
|
||||||
Baptiste Coudurier 8D77 134D 20CC 9220 201F C5DB 0AC9 325C 5C1A BAAA
|
Baptiste Coudurier 8D77 134D 20CC 9220 201F C5DB 0AC9 325C 5C1A BAAA
|
||||||
Ben Littler 3EE3 3723 E560 3214 A8CD 4DEB 2CDB FCE7 768C 8D2C
|
Ben Littler 3EE3 3723 E560 3214 A8CD 4DEB 2CDB FCE7 768C 8D2C
|
||||||
Benoit Fouet B22A 4F4F 43EF 636B BB66 FCDC 0023 AE1E 2985 49C8
|
Benoit Fouet B22A 4F4F 43EF 636B BB66 FCDC 0023 AE1E 2985 49C8
|
||||||
Clément Bœsch 52D0 3A82 D445 F194 DB8B 2B16 87EE 2CB8 F4B8 FCF9
|
Bœsch Clément 52D0 3A82 D445 F194 DB8B 2B16 87EE 2CB8 F4B8 FCF9
|
||||||
Daniel Verkamp 78A6 07ED 782C 653E C628 B8B9 F0EB 8DD8 2F0E 21C7
|
Daniel Verkamp 78A6 07ED 782C 653E C628 B8B9 F0EB 8DD8 2F0E 21C7
|
||||||
FFmpeg release signing key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8
|
Diego Biurrun 8227 1E31 B6D9 4994 7427 E220 9CAE D6CC 4757 FCC5
|
||||||
Ganesh Ajjanagadde C96A 848E 97C3 CEA2 AB72 5CE4 45F9 6A2D 3C36 FB1B
|
|
||||||
Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4
|
Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4
|
||||||
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
|
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
|
||||||
Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
|
Justin Ruggles 3136 ECC0 C10D 6C04 5F43 CA29 FCBE CD2A 3787 1EBF
|
||||||
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
|
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
|
||||||
Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A
|
Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A
|
||||||
|
Luca Barbato 6677 4209 213C 8843 5B67 29E7 E84C 78C2 84E9 0E34
|
||||||
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
|
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
|
||||||
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
|
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
|
||||||
Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1
|
|
||||||
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029
|
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029
|
||||||
Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B
|
Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B
|
||||||
Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E
|
Reimar Döffinger C61D 16E5 9E2C D10C 8958 38A4 0899 A2B9 06D4 D9C7
|
||||||
Reimar Doeffinger C61D 16E5 9E2C D10C 8958 38A4 0899 A2B9 06D4 D9C7
|
|
||||||
Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4
|
Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4
|
||||||
Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A
|
Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A
|
||||||
Robert Swain EE7A 56EA 4A81 A7B5 2001 A521 67FA 362D A2FC 3E71
|
Robert Swain EE7A 56EA 4A81 A7B5 2001 A521 67FA 362D A2FC 3E71
|
||||||
Sascha Sommer 38A0 F88B 868E 9D3A 97D4 D6A0 E823 706F 1E07 0D3C
|
Sascha Sommer 38A0 F88B 868E 9D3A 97D4 D6A0 E823 706F 1E07 0D3C
|
||||||
Stefano Sabatini 0D0B AD6B 5330 BBAD D3D6 6A0C 719C 2839 FC43 2D5F
|
Stefano Sabatini 0D0B AD6B 5330 BBAD D3D6 6A0C 719C 2839 FC43 2D5F
|
||||||
Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863
|
Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863
|
||||||
Tiancheng "Timothy" Gu 9456 AFC0 814A 8139 E994 8351 7FE6 B095 B582 B0D4
|
|
||||||
Tim Nicholson 38CF DB09 3ED0 F607 8B67 6CED 0C0B FC44 8B0B FC83
|
|
||||||
Tomas Härdin A79D 4E3D F38F 763F 91F5 8B33 A01E 8AE0 41BB 2551
|
Tomas Härdin A79D 4E3D F38F 763F 91F5 8B33 A01E 8AE0 41BB 2551
|
||||||
Wei Gao 4269 7741 857A 0E60 9EC5 08D2 4744 4EFA 62C1 87B9
|
|
||||||
|
|||||||
139
Makefile
139
Makefile
@@ -4,98 +4,77 @@ include config.mak
|
|||||||
vpath %.c $(SRC_PATH)
|
vpath %.c $(SRC_PATH)
|
||||||
vpath %.cpp $(SRC_PATH)
|
vpath %.cpp $(SRC_PATH)
|
||||||
vpath %.h $(SRC_PATH)
|
vpath %.h $(SRC_PATH)
|
||||||
vpath %.inc $(SRC_PATH)
|
|
||||||
vpath %.m $(SRC_PATH)
|
|
||||||
vpath %.S $(SRC_PATH)
|
vpath %.S $(SRC_PATH)
|
||||||
vpath %.asm $(SRC_PATH)
|
vpath %.asm $(SRC_PATH)
|
||||||
vpath %.rc $(SRC_PATH)
|
|
||||||
vpath %.v $(SRC_PATH)
|
vpath %.v $(SRC_PATH)
|
||||||
vpath %.texi $(SRC_PATH)
|
vpath %.texi $(SRC_PATH)
|
||||||
vpath %/fate_config.sh.template $(SRC_PATH)
|
vpath %/fate_config.sh.template $(SRC_PATH)
|
||||||
|
|
||||||
AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
|
PROGS-$(CONFIG_FFMPEG) += ffmpeg
|
||||||
AVPROGS-$(CONFIG_FFPLAY) += ffplay
|
PROGS-$(CONFIG_FFPLAY) += ffplay
|
||||||
AVPROGS-$(CONFIG_FFPROBE) += ffprobe
|
PROGS-$(CONFIG_FFPROBE) += ffprobe
|
||||||
AVPROGS-$(CONFIG_FFSERVER) += ffserver
|
PROGS-$(CONFIG_FFSERVER) += ffserver
|
||||||
|
|
||||||
AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
|
PROGS := $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
|
||||||
INSTPROGS = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
|
INSTPROGS = $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
|
||||||
PROGS += $(AVPROGS)
|
|
||||||
|
|
||||||
AVBASENAMES = ffmpeg ffplay ffprobe ffserver
|
OBJS = cmdutils.o $(EXEOBJS)
|
||||||
ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
|
OBJS-ffmpeg = ffmpeg_opt.o ffmpeg_filter.o
|
||||||
ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
|
TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
|
||||||
|
|
||||||
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
|
|
||||||
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
|
|
||||||
|
|
||||||
OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o
|
|
||||||
OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
|
|
||||||
OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
|
|
||||||
OBJS-ffmpeg-$(CONFIG_VAAPI) += ffmpeg_vaapi.o
|
|
||||||
ifndef CONFIG_VIDEOTOOLBOX
|
|
||||||
OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
|
|
||||||
endif
|
|
||||||
OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o
|
|
||||||
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
|
|
||||||
OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
|
|
||||||
OBJS-ffserver += ffserver_config.o
|
|
||||||
|
|
||||||
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
|
|
||||||
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
|
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
|
||||||
TOOLS = qt-faststart trasher uncoded_frame
|
TOOLS = qt-faststart trasher
|
||||||
TOOLS-$(CONFIG_ZLIB) += cws2fws
|
TOOLS-$(CONFIG_ZLIB) += cws2fws
|
||||||
|
|
||||||
# $(FFLIBS-yes) needs to be in linking order
|
BASENAMES = ffmpeg ffplay ffprobe ffserver
|
||||||
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
|
ALLPROGS = $(BASENAMES:%=%$(PROGSSUF)$(EXESUF))
|
||||||
FFLIBS-$(CONFIG_AVFILTER) += avfilter
|
ALLPROGS_G = $(BASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
|
||||||
FFLIBS-$(CONFIG_AVFORMAT) += avformat
|
ALLMANPAGES = $(BASENAMES:%=%.1)
|
||||||
FFLIBS-$(CONFIG_AVCODEC) += avcodec
|
|
||||||
|
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
|
||||||
|
FFLIBS-$(CONFIG_AVFILTER) += avfilter
|
||||||
|
FFLIBS-$(CONFIG_AVFORMAT) += avformat
|
||||||
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
|
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
|
||||||
FFLIBS-$(CONFIG_POSTPROC) += postproc
|
FFLIBS-$(CONFIG_AVCODEC) += avcodec
|
||||||
FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
|
FFLIBS-$(CONFIG_POSTPROC) += postproc
|
||||||
FFLIBS-$(CONFIG_SWSCALE) += swscale
|
FFLIBS-$(CONFIG_SWRESAMPLE)+= swresample
|
||||||
|
FFLIBS-$(CONFIG_SWSCALE) += swscale
|
||||||
|
|
||||||
FFLIBS := avutil
|
FFLIBS := avutil
|
||||||
|
|
||||||
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
|
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
|
||||||
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
|
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
|
||||||
|
|
||||||
SKIPHEADERS = cmdutils_common_opts.h \
|
SKIPHEADERS = cmdutils_common_opts.h
|
||||||
compat/w32pthreads.h
|
|
||||||
|
|
||||||
include $(SRC_PATH)/common.mak
|
include $(SRC_PATH)/common.mak
|
||||||
|
|
||||||
FF_EXTRALIBS := $(FFEXTRALIBS)
|
FF_EXTRALIBS := $(FFEXTRALIBS)
|
||||||
FF_DEP_LIBS := $(DEP_LIBS)
|
FF_DEP_LIBS := $(DEP_LIBS)
|
||||||
FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
|
|
||||||
|
|
||||||
all: $(AVPROGS)
|
all: $(PROGS)
|
||||||
|
|
||||||
|
$(PROGS): %$(EXESUF): %_g$(EXESUF)
|
||||||
|
$(CP) $< $@
|
||||||
|
$(STRIP) $@
|
||||||
|
|
||||||
$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
|
$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
|
$(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS)
|
||||||
|
|
||||||
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
|
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
|
||||||
tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
|
|
||||||
tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
|
||||||
|
|
||||||
CONFIGURABLE_COMPONENTS = \
|
|
||||||
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
|
|
||||||
$(SRC_PATH)/libavcodec/bitstream_filters.c \
|
|
||||||
$(SRC_PATH)/libavformat/protocols.c \
|
|
||||||
|
|
||||||
config.h: .config
|
config.h: .config
|
||||||
.config: $(CONFIGURABLE_COMPONENTS)
|
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
|
||||||
@-tput bold 2>/dev/null
|
@-tput bold 2>/dev/null
|
||||||
@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
|
@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
|
||||||
@-tput sgr0 2>/dev/null
|
@-tput sgr0 2>/dev/null
|
||||||
|
|
||||||
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
|
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
|
||||||
HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
|
HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
|
||||||
ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
|
ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS \
|
||||||
ALTIVEC-OBJS VSX-OBJS MMX-OBJS YASM-OBJS \
|
ALTIVEC-OBJS VIS-OBJS \
|
||||||
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
|
MMX-OBJS YASM-OBJS \
|
||||||
MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
|
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS \
|
||||||
|
OBJS HOSTOBJS TESTOBJS
|
||||||
|
|
||||||
define RESET
|
define RESET
|
||||||
$(1) :=
|
$(1) :=
|
||||||
@@ -107,16 +86,13 @@ $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
|
|||||||
SUBDIR := $(1)/
|
SUBDIR := $(1)/
|
||||||
include $(SRC_PATH)/$(1)/Makefile
|
include $(SRC_PATH)/$(1)/Makefile
|
||||||
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
|
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
|
||||||
-include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
|
|
||||||
include $(SRC_PATH)/library.mak
|
include $(SRC_PATH)/library.mak
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
|
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
|
||||||
|
|
||||||
include $(SRC_PATH)/doc/Makefile
|
|
||||||
|
|
||||||
define DOPROG
|
define DOPROG
|
||||||
OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
|
OBJS-$(1) += $(1).o cmdutils.o $(EXEOBJS)
|
||||||
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
|
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
|
||||||
$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
|
$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
|
||||||
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
|
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
|
||||||
@@ -124,16 +100,10 @@ $(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
|
|||||||
-include $$(OBJS-$(1):.o=.d)
|
-include $$(OBJS-$(1):.o=.d)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
|
$(foreach P,$(PROGS-yes),$(eval $(call DOPROG,$(P))))
|
||||||
|
|
||||||
ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
|
|
||||||
|
|
||||||
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
|
|
||||||
$(CP) $< $@
|
|
||||||
$(STRIP) $@
|
|
||||||
|
|
||||||
%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
|
%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
|
$(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
|
||||||
|
|
||||||
OBJDIRS += tools
|
OBJDIRS += tools
|
||||||
|
|
||||||
@@ -145,14 +115,14 @@ GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
|
|||||||
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
|
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
|
||||||
.version: M=@
|
.version: M=@
|
||||||
|
|
||||||
libavutil/ffversion.h .version:
|
version.h .version:
|
||||||
$(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
|
$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
|
||||||
$(Q)touch .version
|
$(Q)touch .version
|
||||||
|
|
||||||
# force version.sh to run whenever version might have changed
|
# force version.sh to run whenever version might have changed
|
||||||
-include .version
|
-include .version
|
||||||
|
|
||||||
ifdef AVPROGS
|
ifdef PROGS
|
||||||
install: install-progs install-data
|
install: install-progs install-data
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -163,7 +133,7 @@ install-libs: install-libs-yes
|
|||||||
install-progs-yes:
|
install-progs-yes:
|
||||||
install-progs-$(CONFIG_SHARED): install-libs
|
install-progs-$(CONFIG_SHARED): install-libs
|
||||||
|
|
||||||
install-progs: install-progs-yes $(AVPROGS)
|
install-progs: install-progs-yes $(PROGS)
|
||||||
$(Q)mkdir -p "$(BINDIR)"
|
$(Q)mkdir -p "$(BINDIR)"
|
||||||
$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
|
$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
|
||||||
|
|
||||||
@@ -175,34 +145,37 @@ install-data: $(DATA_FILES) $(EXAMPLES_FILES)
|
|||||||
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
|
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
|
||||||
|
|
||||||
uninstall-progs:
|
uninstall-progs:
|
||||||
$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
|
$(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
|
||||||
|
|
||||||
uninstall-data:
|
uninstall-data:
|
||||||
$(RM) -r "$(DATADIR)"
|
$(RM) -r "$(DATADIR)"
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
|
$(RM) $(ALLPROGS) $(ALLPROGS_G)
|
||||||
$(RM) $(CLEANSUFFIXES)
|
$(RM) $(CLEANSUFFIXES)
|
||||||
$(RM) $(CLEANSUFFIXES:%=tools/%)
|
$(RM) $(CLEANSUFFIXES:%=tools/%)
|
||||||
$(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
|
$(RM) coverage.info
|
||||||
$(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
|
|
||||||
$(RM) $(CLEANSUFFIXES:%=compat/%)
|
|
||||||
$(RM) -r coverage-html
|
$(RM) -r coverage-html
|
||||||
$(RM) -rf coverage.info coverage.info.in lcov
|
|
||||||
|
|
||||||
distclean::
|
distclean::
|
||||||
$(RM) $(DISTCLEANSUFFIXES)
|
$(RM) $(DISTCLEANSUFFIXES)
|
||||||
$(RM) config.* .config libavutil/avconfig.h .version mapfile avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c
|
$(RM) config.* .version version.h libavutil/avconfig.h libavcodec/codec_names.h
|
||||||
ifeq ($(SRC_LINK),src)
|
|
||||||
$(RM) src
|
|
||||||
endif
|
|
||||||
$(RM) -rf doc/examples/pc-uninstalled
|
|
||||||
|
|
||||||
config:
|
config:
|
||||||
$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
|
$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
|
||||||
|
|
||||||
|
# Without the sed genthml thinks "libavutil" and "./libavutil" are two different things
|
||||||
|
coverage.info: $(wildcard *.gcda *.gcno */*.gcda */*.gcno */*/*.gcda */*/*.gcno)
|
||||||
|
$(Q)lcov -c -d . -b . | sed -e 's#/./#/#g' > $@
|
||||||
|
|
||||||
|
coverage-html: coverage.info
|
||||||
|
$(Q)mkdir -p $@
|
||||||
|
$(Q)genhtml -o $@ $<
|
||||||
|
$(Q)touch $@
|
||||||
|
|
||||||
check: all alltools examples testprogs fate
|
check: all alltools examples testprogs fate
|
||||||
|
|
||||||
|
include $(SRC_PATH)/doc/Makefile
|
||||||
include $(SRC_PATH)/tests/Makefile
|
include $(SRC_PATH)/tests/Makefile
|
||||||
|
|
||||||
$(sort $(OBJDIRS)):
|
$(sort $(OBJDIRS)):
|
||||||
|
|||||||
18
README
Normal file
18
README
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FFmpeg README
|
||||||
|
-------------
|
||||||
|
|
||||||
|
1) Documentation
|
||||||
|
----------------
|
||||||
|
|
||||||
|
* Read the documentation in the doc/ directory in git.
|
||||||
|
You can also view it online at http://ffmpeg.org/documentation.html
|
||||||
|
|
||||||
|
2) Licensing
|
||||||
|
------------
|
||||||
|
|
||||||
|
* See the LICENSE file.
|
||||||
|
|
||||||
|
3) Build and Install
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* See the INSTALL file.
|
||||||
48
README.md
48
README.md
@@ -1,48 +0,0 @@
|
|||||||
FFmpeg README
|
|
||||||
=============
|
|
||||||
|
|
||||||
FFmpeg is a collection of libraries and tools to process multimedia content
|
|
||||||
such as audio, video, subtitles and related metadata.
|
|
||||||
|
|
||||||
## Libraries
|
|
||||||
|
|
||||||
* `libavcodec` provides implementation of a wider range of codecs.
|
|
||||||
* `libavformat` implements streaming protocols, container formats and basic I/O access.
|
|
||||||
* `libavutil` includes hashers, decompressors and miscellaneous utility functions.
|
|
||||||
* `libavfilter` provides a mean to alter decoded Audio and Video through chain of filters.
|
|
||||||
* `libavdevice` provides an abstraction to access capture and playback devices.
|
|
||||||
* `libswresample` implements audio mixing and resampling routines.
|
|
||||||
* `libswscale` implements color conversion and scaling routines.
|
|
||||||
|
|
||||||
## Tools
|
|
||||||
|
|
||||||
* [ffmpeg](https://ffmpeg.org/ffmpeg.html) is a command line toolbox to
|
|
||||||
manipulate, convert and stream multimedia content.
|
|
||||||
* [ffplay](https://ffmpeg.org/ffplay.html) is a minimalistic multimedia player.
|
|
||||||
* [ffprobe](https://ffmpeg.org/ffprobe.html) is a simple analysis tool to inspect
|
|
||||||
multimedia content.
|
|
||||||
* [ffserver](https://ffmpeg.org/ffserver.html) is a multimedia streaming server
|
|
||||||
for live broadcasts.
|
|
||||||
* Additional small tools such as `aviocat`, `ismindex` and `qt-faststart`.
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
The offline documentation is available in the **doc/** directory.
|
|
||||||
|
|
||||||
The online documentation is available in the main [website](https://ffmpeg.org)
|
|
||||||
and in the [wiki](https://trac.ffmpeg.org).
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
Coding examples are available in the **doc/examples** directory.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
FFmpeg codebase is mainly LGPL-licensed with optional components licensed under
|
|
||||||
GPL. Please refer to the LICENSE file for detailed information.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Patches should be submitted to the ffmpeg-devel mailing list using
|
|
||||||
`git format-patch` or `git send-email`. Github pull requests should be
|
|
||||||
avoided because they are not part of our review process and will be ignored.
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
┌────────────────────────────────────────┐
|
|
||||||
│ RELEASE NOTES for FFmpeg 3.3 "Hilbert" │
|
|
||||||
└────────────────────────────────────────┘
|
|
||||||
|
|
||||||
The FFmpeg Project proudly presents FFmpeg 3.3 "Hilbert", about 5
|
|
||||||
months after the release of FFmpeg 3.2.
|
|
||||||
|
|
||||||
A complete Changelog is available at the root of the project, and the
|
|
||||||
complete Git history on http://source.ffmpeg.org.
|
|
||||||
|
|
||||||
We hope you will like this release as much as we enjoyed working on it, and
|
|
||||||
as usual, if you have any questions about it, or any FFmpeg related topic,
|
|
||||||
feel free to join us on the #ffmpeg IRC channel (on irc.freenode.net) or ask
|
|
||||||
on the mailing-lists.
|
|
||||||
9
arch.mak
9
arch.mak
@@ -1,17 +1,16 @@
|
|||||||
OBJS-$(HAVE_ARMV5TE) += $(ARMV5TE-OBJS) $(ARMV5TE-OBJS-yes)
|
OBJS-$(HAVE_ARMV5TE) += $(ARMV5TE-OBJS) $(ARMV5TE-OBJS-yes)
|
||||||
OBJS-$(HAVE_ARMV6) += $(ARMV6-OBJS) $(ARMV6-OBJS-yes)
|
OBJS-$(HAVE_ARMV6) += $(ARMV6-OBJS) $(ARMV6-OBJS-yes)
|
||||||
OBJS-$(HAVE_ARMV8) += $(ARMV8-OBJS) $(ARMV8-OBJS-yes)
|
|
||||||
OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes)
|
OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes)
|
||||||
OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes)
|
OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes)
|
||||||
|
|
||||||
OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes)
|
OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes)
|
||||||
OBJS-$(HAVE_MIPSDSP) += $(MIPSDSP-OBJS) $(MIPSDSP-OBJS-yes)
|
OBJS-$(HAVE_MIPS32R2) += $(MIPS32R2-OBJS) $(MIPS32R2-OBJS-yes)
|
||||||
|
OBJS-$(HAVE_MIPSDSPR1) += $(MIPSDSPR1-OBJS) $(MIPSDSPR1-OBJS-yes)
|
||||||
OBJS-$(HAVE_MIPSDSPR2) += $(MIPSDSPR2-OBJS) $(MIPSDSPR2-OBJS-yes)
|
OBJS-$(HAVE_MIPSDSPR2) += $(MIPSDSPR2-OBJS) $(MIPSDSPR2-OBJS-yes)
|
||||||
OBJS-$(HAVE_MSA) += $(MSA-OBJS) $(MSA-OBJS-yes)
|
|
||||||
OBJS-$(HAVE_MMI) += $(MMI-OBJS) $(MMI-OBJS-yes)
|
|
||||||
|
|
||||||
OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
|
OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
|
||||||
OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes)
|
|
||||||
|
OBJS-$(HAVE_VIS) += $(VIS-OBJS) $(VIS-OBJS-yes)
|
||||||
|
|
||||||
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
|
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
|
||||||
OBJS-$(HAVE_YASM) += $(YASM-OBJS) $(YASM-OBJS-yes)
|
OBJS-$(HAVE_YASM) += $(YASM-OBJS) $(YASM-OBJS-yes)
|
||||||
|
|||||||
923
cmdutils.c
923
cmdutils.c
File diff suppressed because it is too large
Load Diff
161
cmdutils.h
161
cmdutils.h
@@ -19,18 +19,17 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CMDUTILS_H
|
#ifndef FFMPEG_CMDUTILS_H
|
||||||
#define CMDUTILS_H
|
#define FFMPEG_CMDUTILS_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "libavcodec/avcodec.h"
|
#include "libavcodec/avcodec.h"
|
||||||
#include "libavfilter/avfilter.h"
|
#include "libavfilter/avfilter.h"
|
||||||
#include "libavformat/avformat.h"
|
#include "libavformat/avformat.h"
|
||||||
#include "libswscale/swscale.h"
|
#include "libswscale/swscale.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef __MINGW32__
|
||||||
#undef main /* We don't want SDL to override our main() */
|
#undef main /* We don't want SDL to override our main() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -44,27 +43,16 @@ extern const char program_name[];
|
|||||||
*/
|
*/
|
||||||
extern const int program_birth_year;
|
extern const int program_birth_year;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this year, defined by the program for show_banner()
|
||||||
|
*/
|
||||||
|
extern const int this_year;
|
||||||
|
|
||||||
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||||
extern AVFormatContext *avformat_opts;
|
extern AVFormatContext *avformat_opts;
|
||||||
extern AVDictionary *sws_dict;
|
extern struct SwsContext *sws_opts;
|
||||||
extern AVDictionary *swr_opts;
|
extern AVDictionary *swr_opts;
|
||||||
extern AVDictionary *format_opts, *codec_opts, *resample_opts;
|
extern AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||||
extern int hide_banner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a program-specific cleanup routine.
|
|
||||||
*/
|
|
||||||
void register_exit(void (*cb)(int ret));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wraps exit with a program-specific cleanup routine.
|
|
||||||
*/
|
|
||||||
void exit_program(int ret) av_noreturn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize dynamic library loading
|
|
||||||
*/
|
|
||||||
void init_dynload(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the cmdutils option system, in particular
|
* Initialize the cmdutils option system, in particular
|
||||||
@@ -83,11 +71,6 @@ void uninit_opts(void);
|
|||||||
*/
|
*/
|
||||||
void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
|
void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
|
||||||
|
|
||||||
/**
|
|
||||||
* Override the cpuflags.
|
|
||||||
*/
|
|
||||||
int opt_cpuflags(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fallback for options that are not explicitly handled, these will be
|
* Fallback for options that are not explicitly handled, these will be
|
||||||
* parsed through AVOptions.
|
* parsed through AVOptions.
|
||||||
@@ -103,14 +86,10 @@ int opt_report(const char *opt);
|
|||||||
|
|
||||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
int opt_cpuflags(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
int opt_codec_debug(void *optctx, const char *opt, const char *arg);
|
int opt_codec_debug(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
#if CONFIG_OPENCL
|
|
||||||
int opt_opencl(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
int opt_opencl_bench(void *optctx, const char *opt, const char *arg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limit the execution time.
|
* Limit the execution time.
|
||||||
*/
|
*/
|
||||||
@@ -183,8 +162,6 @@ typedef struct OptionDef {
|
|||||||
an int containing element count in the array. */
|
an int containing element count in the array. */
|
||||||
#define OPT_TIME 0x10000
|
#define OPT_TIME 0x10000
|
||||||
#define OPT_DOUBLE 0x20000
|
#define OPT_DOUBLE 0x20000
|
||||||
#define OPT_INPUT 0x40000
|
|
||||||
#define OPT_OUTPUT 0x80000
|
|
||||||
union {
|
union {
|
||||||
void *dst_ptr;
|
void *dst_ptr;
|
||||||
int (*func_arg)(void *, const char *, const char *);
|
int (*func_arg)(void *, const char *, const char *);
|
||||||
@@ -265,11 +242,6 @@ typedef struct OptionGroupDef {
|
|||||||
* are terminated by a non-option argument (e.g. ffmpeg output files)
|
* are terminated by a non-option argument (e.g. ffmpeg output files)
|
||||||
*/
|
*/
|
||||||
const char *sep;
|
const char *sep;
|
||||||
/**
|
|
||||||
* Option flags that must be set on each option that is
|
|
||||||
* applied to this group
|
|
||||||
*/
|
|
||||||
int flags;
|
|
||||||
} OptionGroupDef;
|
} OptionGroupDef;
|
||||||
|
|
||||||
typedef struct OptionGroup {
|
typedef struct OptionGroup {
|
||||||
@@ -282,7 +254,7 @@ typedef struct OptionGroup {
|
|||||||
AVDictionary *codec_opts;
|
AVDictionary *codec_opts;
|
||||||
AVDictionary *format_opts;
|
AVDictionary *format_opts;
|
||||||
AVDictionary *resample_opts;
|
AVDictionary *resample_opts;
|
||||||
AVDictionary *sws_dict;
|
struct SwsContext *sws_opts;
|
||||||
AVDictionary *swr_opts;
|
AVDictionary *swr_opts;
|
||||||
} OptionGroup;
|
} OptionGroup;
|
||||||
|
|
||||||
@@ -420,13 +392,6 @@ void show_banner(int argc, char **argv, const OptionDef *options);
|
|||||||
*/
|
*/
|
||||||
int show_version(void *optctx, const char *opt, const char *arg);
|
int show_version(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print the build configuration of the program to stdout. The contents
|
|
||||||
* depend on the definition of FFMPEG_CONFIGURATION.
|
|
||||||
* This option processing function does not utilize the arguments.
|
|
||||||
*/
|
|
||||||
int show_buildconf(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print the license of the program to stdout. The license depends on
|
* Print the license of the program to stdout. The license depends on
|
||||||
* the license of the libraries compiled into the program.
|
* the license of the libraries compiled into the program.
|
||||||
@@ -436,45 +401,10 @@ int show_license(void *optctx, const char *opt, const char *arg);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a listing containing all the formats supported by the
|
* Print a listing containing all the formats supported by the
|
||||||
* program (including devices).
|
|
||||||
* This option processing function does not utilize the arguments.
|
|
||||||
*/
|
|
||||||
int show_formats(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a listing containing all the muxers supported by the
|
|
||||||
* program (including devices).
|
|
||||||
* This option processing function does not utilize the arguments.
|
|
||||||
*/
|
|
||||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a listing containing all the demuxer supported by the
|
|
||||||
* program (including devices).
|
|
||||||
* This option processing function does not utilize the arguments.
|
|
||||||
*/
|
|
||||||
int show_demuxers(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a listing containing all the devices supported by the
|
|
||||||
* program.
|
* program.
|
||||||
* This option processing function does not utilize the arguments.
|
* This option processing function does not utilize the arguments.
|
||||||
*/
|
*/
|
||||||
int show_devices(void *optctx, const char *opt, const char *arg);
|
int show_formats(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
#if CONFIG_AVDEVICE
|
|
||||||
/**
|
|
||||||
* Print a listing containing autodetected sinks of the output device.
|
|
||||||
* Device name with options may be passed as an argument to limit results.
|
|
||||||
*/
|
|
||||||
int show_sinks(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a listing containing autodetected sources of the input device.
|
|
||||||
* Device name with options may be passed as an argument to limit results.
|
|
||||||
*/
|
|
||||||
int show_sources(void *optctx, const char *opt, const char *arg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a listing containing all the codecs supported by the
|
* Print a listing containing all the codecs supported by the
|
||||||
@@ -536,18 +466,24 @@ int show_layouts(void *optctx, const char *opt, const char *arg);
|
|||||||
*/
|
*/
|
||||||
int show_sample_fmts(void *optctx, const char *opt, const char *arg);
|
int show_sample_fmts(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a listing containing all the color names and values recognized
|
|
||||||
* by the program.
|
|
||||||
*/
|
|
||||||
int show_colors(void *optctx, const char *opt, const char *arg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a positive value if a line read from standard input
|
* Return a positive value if a line read from standard input
|
||||||
* starts with [yY], otherwise return 0.
|
* starts with [yY], otherwise return 0.
|
||||||
*/
|
*/
|
||||||
int read_yesno(void);
|
int read_yesno(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the file with name filename, and put its content in a newly
|
||||||
|
* allocated 0-terminated buffer.
|
||||||
|
*
|
||||||
|
* @param filename file to read from
|
||||||
|
* @param bufptr location where pointer to buffer is returned
|
||||||
|
* @param size location where size of buffer is returned
|
||||||
|
* @return 0 in case of success, a negative value corresponding to an
|
||||||
|
* AVERROR error code in case of failure.
|
||||||
|
*/
|
||||||
|
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a file corresponding to a preset file.
|
* Get a file corresponding to a preset file.
|
||||||
*
|
*
|
||||||
@@ -581,11 +517,52 @@ FILE *get_preset_file(char *filename, size_t filename_size,
|
|||||||
*/
|
*/
|
||||||
void *grow_array(void *array, int elem_size, int *size, int new_size);
|
void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||||
|
|
||||||
#define media_type_string av_get_media_type_string
|
|
||||||
|
|
||||||
#define GROW_ARRAY(array, nb_elems)\
|
#define GROW_ARRAY(array, nb_elems)\
|
||||||
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
||||||
|
|
||||||
|
typedef struct FrameBuffer {
|
||||||
|
uint8_t *base[4];
|
||||||
|
uint8_t *data[4];
|
||||||
|
int linesize[4];
|
||||||
|
|
||||||
|
int h, w;
|
||||||
|
enum AVPixelFormat pix_fmt;
|
||||||
|
|
||||||
|
int refcount;
|
||||||
|
struct FrameBuffer **pool; ///< head of the buffer pool
|
||||||
|
struct FrameBuffer *next;
|
||||||
|
} FrameBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a frame from the pool. This is intended to be used as a callback for
|
||||||
|
* AVCodecContext.get_buffer.
|
||||||
|
*
|
||||||
|
* @param s codec context. s->opaque must be a pointer to the head of the
|
||||||
|
* buffer pool.
|
||||||
|
* @param frame frame->opaque will be set to point to the FrameBuffer
|
||||||
|
* containing the frame data.
|
||||||
|
*/
|
||||||
|
int codec_get_buffer(AVCodecContext *s, AVFrame *frame);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback to be used for AVCodecContext.release_buffer along with
|
||||||
|
* codec_get_buffer().
|
||||||
|
*/
|
||||||
|
void codec_release_buffer(AVCodecContext *s, AVFrame *frame);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback to be used for AVFilterBuffer.free.
|
||||||
|
* @param fb buffer to free. fb->priv must be a pointer to the FrameBuffer
|
||||||
|
* containing the buffer data.
|
||||||
|
*/
|
||||||
|
void filter_release_buffer(AVFilterBuffer *fb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free all the buffers in the pool. This must be called after all the
|
||||||
|
* buffers have been released.
|
||||||
|
*/
|
||||||
|
void free_buffer_pool(FrameBuffer **pool);
|
||||||
|
|
||||||
#define GET_PIX_FMT_NAME(pix_fmt)\
|
#define GET_PIX_FMT_NAME(pix_fmt)\
|
||||||
const char *name = av_get_pix_fmt_name(pix_fmt);
|
const char *name = av_get_pix_fmt_name(pix_fmt);
|
||||||
|
|
||||||
@@ -604,6 +581,4 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
|
|||||||
char name[128];\
|
char name[128];\
|
||||||
av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
|
av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
|
||||||
|
|
||||||
double get_rotation(AVStream *st);
|
|
||||||
|
|
||||||
#endif /* CMDUTILS_H */
|
#endif /* CMDUTILS_H */
|
||||||
|
|||||||
@@ -4,11 +4,7 @@
|
|||||||
{ "help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
|
{ "help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
|
||||||
{ "-help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
|
{ "-help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
|
||||||
{ "version" , OPT_EXIT, {.func_arg = show_version}, "show version" },
|
{ "version" , OPT_EXIT, {.func_arg = show_version}, "show version" },
|
||||||
{ "buildconf" , OPT_EXIT, {.func_arg = show_buildconf}, "show build configuration" },
|
|
||||||
{ "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" },
|
{ "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" },
|
||||||
{ "muxers" , OPT_EXIT, {.func_arg = show_muxers }, "show available muxers" },
|
|
||||||
{ "demuxers" , OPT_EXIT, {.func_arg = show_demuxers }, "show available demuxers" },
|
|
||||||
{ "devices" , OPT_EXIT, {.func_arg = show_devices }, "show available devices" },
|
|
||||||
{ "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" },
|
{ "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" },
|
||||||
{ "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" },
|
{ "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" },
|
||||||
{ "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" },
|
{ "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" },
|
||||||
@@ -18,20 +14,8 @@
|
|||||||
{ "pix_fmts" , OPT_EXIT, {.func_arg = show_pix_fmts }, "show available pixel formats" },
|
{ "pix_fmts" , OPT_EXIT, {.func_arg = show_pix_fmts }, "show available pixel formats" },
|
||||||
{ "layouts" , OPT_EXIT, {.func_arg = show_layouts }, "show standard channel layouts" },
|
{ "layouts" , OPT_EXIT, {.func_arg = show_layouts }, "show standard channel layouts" },
|
||||||
{ "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" },
|
{ "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" },
|
||||||
{ "colors" , OPT_EXIT, {.func_arg = show_colors }, "show available color names" },
|
{ "loglevel" , HAS_ARG, {.func_arg = opt_loglevel}, "set libav* logging level", "loglevel" },
|
||||||
{ "loglevel" , HAS_ARG, {.func_arg = opt_loglevel}, "set logging level", "loglevel" },
|
{ "v", HAS_ARG, {.func_arg = opt_loglevel}, "set libav* logging level", "loglevel" },
|
||||||
{ "v", HAS_ARG, {.func_arg = opt_loglevel}, "set logging level", "loglevel" },
|
|
||||||
{ "report" , 0, {(void*)opt_report}, "generate a report" },
|
{ "report" , 0, {(void*)opt_report}, "generate a report" },
|
||||||
{ "max_alloc" , HAS_ARG, {.func_arg = opt_max_alloc}, "set maximum size of a single allocated block", "bytes" },
|
{ "max_alloc" , HAS_ARG, {.func_arg = opt_max_alloc}, "set maximum size of a single allocated block", "bytes" },
|
||||||
{ "cpuflags" , HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" },
|
{ "cpuflags" , HAS_ARG | OPT_EXPERT, {.func_arg = opt_cpuflags}, "force specific cpu flags", "flags" },
|
||||||
{ "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" },
|
|
||||||
#if CONFIG_OPENCL
|
|
||||||
{ "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, "run benchmark on all OpenCL devices and show results" },
|
|
||||||
{ "opencl_options", HAS_ARG, {.func_arg = opt_opencl}, "set OpenCL environment options" },
|
|
||||||
#endif
|
|
||||||
#if CONFIG_AVDEVICE
|
|
||||||
{ "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },
|
|
||||||
"list sources of the input device", "device" },
|
|
||||||
{ "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },
|
|
||||||
"list sinks of the output device", "device" },
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,283 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Lenny Wang
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "libavutil/opt.h"
|
|
||||||
#include "libavutil/time.h"
|
|
||||||
#include "libavutil/log.h"
|
|
||||||
#include "libavutil/opencl.h"
|
|
||||||
#include "libavutil/avstring.h"
|
|
||||||
#include "cmdutils.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int platform_idx;
|
|
||||||
int device_idx;
|
|
||||||
char device_name[64];
|
|
||||||
int64_t runtime;
|
|
||||||
} OpenCLDeviceBenchmark;
|
|
||||||
|
|
||||||
const char *ocl_bench_source = AV_OPENCL_KERNEL(
|
|
||||||
inline unsigned char clip_uint8(int a)
|
|
||||||
{
|
|
||||||
if (a & (~0xFF))
|
|
||||||
return (-a)>>31;
|
|
||||||
else
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
kernel void unsharp_bench(
|
|
||||||
global unsigned char *src,
|
|
||||||
global unsigned char *dst,
|
|
||||||
global int *mask,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
|
||||||
int i, j, local_idx, lc_idx, sum = 0;
|
|
||||||
int2 thread_idx, block_idx, global_idx, lm_idx;
|
|
||||||
thread_idx.x = get_local_id(0);
|
|
||||||
thread_idx.y = get_local_id(1);
|
|
||||||
block_idx.x = get_group_id(0);
|
|
||||||
block_idx.y = get_group_id(1);
|
|
||||||
global_idx.x = get_global_id(0);
|
|
||||||
global_idx.y = get_global_id(1);
|
|
||||||
local uchar data[32][32];
|
|
||||||
local int lc[128];
|
|
||||||
|
|
||||||
for (i = 0; i <= 1; i++) {
|
|
||||||
lm_idx.y = -8 + (block_idx.y + i) * 16 + thread_idx.y;
|
|
||||||
lm_idx.y = lm_idx.y < 0 ? 0 : lm_idx.y;
|
|
||||||
lm_idx.y = lm_idx.y >= height ? height - 1: lm_idx.y;
|
|
||||||
for (j = 0; j <= 1; j++) {
|
|
||||||
lm_idx.x = -8 + (block_idx.x + j) * 16 + thread_idx.x;
|
|
||||||
lm_idx.x = lm_idx.x < 0 ? 0 : lm_idx.x;
|
|
||||||
lm_idx.x = lm_idx.x >= width ? width - 1: lm_idx.x;
|
|
||||||
data[i*16 + thread_idx.y][j*16 + thread_idx.x] = src[lm_idx.y*width + lm_idx.x];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local_idx = thread_idx.y*16 + thread_idx.x;
|
|
||||||
if (local_idx < 128)
|
|
||||||
lc[local_idx] = mask[local_idx];
|
|
||||||
barrier(CLK_LOCAL_MEM_FENCE);
|
|
||||||
|
|
||||||
\n#pragma unroll\n
|
|
||||||
for (i = -4; i <= 4; i++) {
|
|
||||||
lm_idx.y = 8 + i + thread_idx.y;
|
|
||||||
\n#pragma unroll\n
|
|
||||||
for (j = -4; j <= 4; j++) {
|
|
||||||
lm_idx.x = 8 + j + thread_idx.x;
|
|
||||||
lc_idx = (i + 4)*8 + j + 4;
|
|
||||||
sum += (int)data[lm_idx.y][lm_idx.x] * lc[lc_idx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int temp = (int)data[thread_idx.y + 8][thread_idx.x + 8];
|
|
||||||
int res = temp + (((temp - (int)((sum + 1<<15) >> 16))) >> 16);
|
|
||||||
if (global_idx.x < width && global_idx.y < height)
|
|
||||||
dst[global_idx.x + global_idx.y*width] = clip_uint8(res);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
#define OCLCHECK(method, ... ) \
|
|
||||||
do { \
|
|
||||||
status = method(__VA_ARGS__); \
|
|
||||||
if (status != CL_SUCCESS) { \
|
|
||||||
av_log(NULL, AV_LOG_ERROR, # method " error '%s'\n", \
|
|
||||||
av_opencl_errstr(status)); \
|
|
||||||
ret = AVERROR_EXTERNAL; \
|
|
||||||
goto end; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define CREATEBUF(out, flags, size) \
|
|
||||||
do { \
|
|
||||||
out = clCreateBuffer(ext_opencl_env->context, flags, size, NULL, &status); \
|
|
||||||
if (status != CL_SUCCESS) { \
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Could not create OpenCL buffer\n"); \
|
|
||||||
ret = AVERROR_EXTERNAL; \
|
|
||||||
goto end; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static void fill_rand_int(int *data, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
srand(av_gettime());
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
data[i] = rand();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define OPENCL_NB_ITER 5
|
|
||||||
static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env)
|
|
||||||
{
|
|
||||||
int i, arg = 0, width = 1920, height = 1088;
|
|
||||||
int64_t start, ret = 0;
|
|
||||||
cl_int status;
|
|
||||||
size_t kernel_len;
|
|
||||||
char *inbuf;
|
|
||||||
int *mask;
|
|
||||||
int buf_size = width * height * sizeof(char);
|
|
||||||
int mask_size = sizeof(uint32_t) * 128;
|
|
||||||
|
|
||||||
cl_mem cl_mask, cl_inbuf, cl_outbuf;
|
|
||||||
cl_kernel kernel = NULL;
|
|
||||||
cl_program program = NULL;
|
|
||||||
size_t local_work_size_2d[2] = {16, 16};
|
|
||||||
size_t global_work_size_2d[2] = {(size_t)width, (size_t)height};
|
|
||||||
|
|
||||||
if (!(inbuf = av_malloc(buf_size)) || !(mask = av_malloc(mask_size))) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Out of memory\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
fill_rand_int((int*)inbuf, buf_size/4);
|
|
||||||
fill_rand_int(mask, mask_size/4);
|
|
||||||
|
|
||||||
CREATEBUF(cl_mask, CL_MEM_READ_ONLY, mask_size);
|
|
||||||
CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, buf_size);
|
|
||||||
CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, buf_size);
|
|
||||||
|
|
||||||
kernel_len = strlen(ocl_bench_source);
|
|
||||||
program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source,
|
|
||||||
&kernel_len, &status);
|
|
||||||
if (status != CL_SUCCESS || !program) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n");
|
|
||||||
ret = AVERROR_EXTERNAL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL);
|
|
||||||
if (status != CL_SUCCESS) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n");
|
|
||||||
ret = AVERROR_EXTERNAL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
kernel = clCreateKernel(program, "unsharp_bench", &status);
|
|
||||||
if (status != CL_SUCCESS) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n");
|
|
||||||
ret = AVERROR_EXTERNAL;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0,
|
|
||||||
buf_size, inbuf, 0, NULL, NULL);
|
|
||||||
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0,
|
|
||||||
mask_size, mask, 0, NULL, NULL);
|
|
||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_inbuf);
|
|
||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_outbuf);
|
|
||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_mask);
|
|
||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width);
|
|
||||||
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height);
|
|
||||||
|
|
||||||
start = av_gettime_relative();
|
|
||||||
for (i = 0; i < OPENCL_NB_ITER; i++)
|
|
||||||
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
|
|
||||||
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
|
|
||||||
clFinish(ext_opencl_env->command_queue);
|
|
||||||
ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;
|
|
||||||
end:
|
|
||||||
if (kernel)
|
|
||||||
clReleaseKernel(kernel);
|
|
||||||
if (program)
|
|
||||||
clReleaseProgram(program);
|
|
||||||
if (cl_inbuf)
|
|
||||||
clReleaseMemObject(cl_inbuf);
|
|
||||||
if (cl_outbuf)
|
|
||||||
clReleaseMemObject(cl_outbuf);
|
|
||||||
if (cl_mask)
|
|
||||||
clReleaseMemObject(cl_mask);
|
|
||||||
av_free(inbuf);
|
|
||||||
av_free(mask);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int compare_ocl_device_desc(const void *a, const void *b)
|
|
||||||
{
|
|
||||||
const OpenCLDeviceBenchmark* va = (const OpenCLDeviceBenchmark*)a;
|
|
||||||
const OpenCLDeviceBenchmark* vb = (const OpenCLDeviceBenchmark*)b;
|
|
||||||
return FFDIFFSIGN(va->runtime , vb->runtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
|
|
||||||
{
|
|
||||||
int i, j, nb_devices = 0, count = 0, ret = 0;
|
|
||||||
int64_t score = 0;
|
|
||||||
AVOpenCLDeviceList *device_list;
|
|
||||||
AVOpenCLDeviceNode *device_node = NULL;
|
|
||||||
OpenCLDeviceBenchmark *devices = NULL;
|
|
||||||
cl_platform_id platform;
|
|
||||||
|
|
||||||
ret = av_opencl_get_device_list(&device_list);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
for (i = 0; i < device_list->platform_num; i++)
|
|
||||||
nb_devices += device_list->platform_node[i]->device_num;
|
|
||||||
if (!nb_devices) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "No OpenCL device detected!\n");
|
|
||||||
av_opencl_free_device_list(&device_list);
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Could not allocate buffer\n");
|
|
||||||
av_opencl_free_device_list(&device_list);
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < device_list->platform_num; i++) {
|
|
||||||
for (j = 0; j < device_list->platform_node[i]->device_num; j++) {
|
|
||||||
device_node = device_list->platform_node[i]->device_node[j];
|
|
||||||
platform = device_list->platform_node[i]->platform_id;
|
|
||||||
score = av_opencl_benchmark(device_node, platform, run_opencl_bench);
|
|
||||||
if (score > 0) {
|
|
||||||
devices[count].platform_idx = i;
|
|
||||||
devices[count].device_idx = j;
|
|
||||||
devices[count].runtime = score;
|
|
||||||
av_strlcpy(devices[count].device_name, device_node->device_name,
|
|
||||||
sizeof(devices[count].device_name));
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qsort(devices, count, sizeof(OpenCLDeviceBenchmark), compare_ocl_device_desc);
|
|
||||||
fprintf(stderr, "platform_idx\tdevice_idx\tdevice_name\truntime\n");
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
fprintf(stdout, "%d\t%d\t%s\t%"PRId64"\n",
|
|
||||||
devices[i].platform_idx, devices[i].device_idx,
|
|
||||||
devices[i].device_name, devices[i].runtime);
|
|
||||||
|
|
||||||
av_opencl_free_device_list(&device_list);
|
|
||||||
av_free(devices);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int opt_opencl(void *optctx, const char *opt, const char *arg)
|
|
||||||
{
|
|
||||||
char *key, *value;
|
|
||||||
const char *opts = arg;
|
|
||||||
int ret = 0;
|
|
||||||
while (*opts) {
|
|
||||||
ret = av_opt_get_key_value(&opts, "=", ":", 0, &key, &value);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
ret = av_opencl_set_option(key, value);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
if (*opts)
|
|
||||||
opts++;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
74
common.mak
74
common.mak
@@ -5,20 +5,12 @@
|
|||||||
# first so "all" becomes default target
|
# first so "all" becomes default target
|
||||||
all: all-yes
|
all: all-yes
|
||||||
|
|
||||||
DEFAULT_YASMD=.dbg
|
|
||||||
|
|
||||||
ifeq ($(DBG),1)
|
|
||||||
YASMD=$(DEFAULT_YASMD)
|
|
||||||
else
|
|
||||||
YASMD=
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef SUBDIR
|
ifndef SUBDIR
|
||||||
|
|
||||||
ifndef V
|
ifndef V
|
||||||
Q = @
|
Q = @
|
||||||
ECHO = printf "$(1)\t%s\n" $(2)
|
ECHO = printf "$(1)\t%s\n" $(2)
|
||||||
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
|
BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP
|
||||||
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
|
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
|
||||||
|
|
||||||
MSG = $@
|
MSG = $@
|
||||||
@@ -32,14 +24,12 @@ endif
|
|||||||
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
|
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
|
||||||
|
|
||||||
# NASM requires -I path terminated with /
|
# NASM requires -I path terminated with /
|
||||||
IFLAGS := -I. -I$(SRC_LINK)/
|
IFLAGS := -I. -I$(SRC_PATH)/
|
||||||
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
|
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
|
||||||
CFLAGS += $(ECFLAGS)
|
CFLAGS += $(ECFLAGS)
|
||||||
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
||||||
OBJCFLAGS += $(EOBJCFLAGS)
|
|
||||||
OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
|
|
||||||
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
||||||
CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS)
|
CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
|
||||||
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
|
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
|
||||||
|
|
||||||
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
|
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
|
||||||
@@ -47,14 +37,12 @@ LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
|
|||||||
|
|
||||||
define COMPILE
|
define COMPILE
|
||||||
$(call $(1)DEP,$(1))
|
$(call $(1)DEP,$(1))
|
||||||
$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
|
$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
|
||||||
endef
|
endef
|
||||||
|
|
||||||
COMPILE_C = $(call COMPILE,CC)
|
COMPILE_C = $(call COMPILE,CC)
|
||||||
COMPILE_CXX = $(call COMPILE,CXX)
|
COMPILE_CXX = $(call COMPILE,CXX)
|
||||||
COMPILE_S = $(call COMPILE,AS)
|
COMPILE_S = $(call COMPILE,AS)
|
||||||
COMPILE_M = $(call COMPILE,OBJCC)
|
|
||||||
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(COMPILE_C)
|
$(COMPILE_C)
|
||||||
@@ -62,37 +50,22 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
|||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(COMPILE_CXX)
|
$(COMPILE_CXX)
|
||||||
|
|
||||||
%.o: %.m
|
|
||||||
$(COMPILE_M)
|
|
||||||
|
|
||||||
%.s: %.c
|
%.s: %.c
|
||||||
$(CC) $(CCFLAGS) -S -o $@ $<
|
$(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $<
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(COMPILE_S)
|
$(COMPILE_S)
|
||||||
|
|
||||||
%_host.o: %.c
|
|
||||||
$(COMPILE_HOSTC)
|
|
||||||
|
|
||||||
%$(DEFAULT_YASMD).asm: %.asm
|
|
||||||
$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.asm=.d)
|
|
||||||
$(YASM) $(YASMFLAGS) -I $(<D)/ -e $< | sed '/^%/d;/^$$/d;' > $@
|
|
||||||
|
|
||||||
%.o: %.asm
|
|
||||||
$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
|
|
||||||
$(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
|
|
||||||
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
|
|
||||||
|
|
||||||
%.o: %.rc
|
|
||||||
$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
|
|
||||||
|
|
||||||
%.i: %.c
|
%.i: %.c
|
||||||
$(CC) $(CCFLAGS) $(CC_E) $<
|
$(CC) $(CCFLAGS) $(CC_E) $<
|
||||||
|
|
||||||
%.h.c:
|
%.h.c:
|
||||||
$(Q)echo '#include "$*.h"' >$@
|
$(Q)echo '#include "$*.h"' >$@
|
||||||
|
|
||||||
%.c %.h %.ver: TAG = GEN
|
%.ver: %.v
|
||||||
|
$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
|
||||||
|
|
||||||
|
%.c %.h: TAG = GEN
|
||||||
|
|
||||||
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
||||||
%.h:
|
%.h:
|
||||||
@@ -109,17 +82,16 @@ endif
|
|||||||
include $(SRC_PATH)/arch.mak
|
include $(SRC_PATH)/arch.mak
|
||||||
|
|
||||||
OBJS += $(OBJS-yes)
|
OBJS += $(OBJS-yes)
|
||||||
SLIBOBJS += $(SLIBOBJS-yes)
|
FFLIBS := $(FFLIBS-yes) $(FFLIBS)
|
||||||
FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
|
|
||||||
TESTPROGS += $(TESTPROGS-yes)
|
TESTPROGS += $(TESTPROGS-yes)
|
||||||
|
|
||||||
LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
|
LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
|
||||||
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
|
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
|
||||||
|
|
||||||
|
EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
|
||||||
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
||||||
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
|
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
|
||||||
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
|
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
|
||||||
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
|
|
||||||
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
|
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
|
||||||
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
|
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
|
||||||
TOOLS += $(TOOLS-yes)
|
TOOLS += $(TOOLS-yes)
|
||||||
@@ -127,11 +99,8 @@ TOOLOBJS := $(TOOLS:%=tools/%.o)
|
|||||||
TOOLS := $(TOOLS:%=tools/%$(EXESUF))
|
TOOLS := $(TOOLS:%=tools/%$(EXESUF))
|
||||||
HEADERS += $(HEADERS-yes)
|
HEADERS += $(HEADERS-yes)
|
||||||
|
|
||||||
PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
|
DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
|
||||||
DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
|
|
||||||
STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
|
|
||||||
|
|
||||||
SRC_DIR := $(SRC_PATH)/lib$(NAME)
|
|
||||||
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
|
ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
|
||||||
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
|
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
|
||||||
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
|
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
|
||||||
@@ -142,29 +111,30 @@ checkheaders: $(HOBJS)
|
|||||||
alltools: $(TOOLS)
|
alltools: $(TOOLS)
|
||||||
|
|
||||||
$(HOSTOBJS): %.o: %.c
|
$(HOSTOBJS): %.o: %.c
|
||||||
$(COMPILE_HOSTC)
|
$(call COMPILE,HOSTCC)
|
||||||
|
|
||||||
$(HOSTPROGS): %$(HOSTEXESUF): %.o
|
$(HOSTPROGS): %$(HOSTEXESUF): %.o
|
||||||
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
|
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $< $(HOSTLIBS)
|
||||||
|
|
||||||
$(OBJS): | $(sort $(dir $(OBJS)))
|
$(OBJS): | $(sort $(dir $(OBJS)))
|
||||||
$(HOBJS): | $(sort $(dir $(HOBJS)))
|
$(HOBJS): | $(sort $(dir $(HOBJS)))
|
||||||
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
|
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
|
||||||
$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
|
|
||||||
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
|
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
|
||||||
$(TOOLOBJS): | tools
|
$(TOOLOBJS): | tools
|
||||||
|
|
||||||
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
|
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))
|
||||||
|
|
||||||
CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).asm
|
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
|
||||||
DISTCLEANSUFFIXES = *.pc
|
DISTCLEANSUFFIXES = *.pc
|
||||||
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
|
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
|
||||||
|
|
||||||
define RULES
|
define RULES
|
||||||
clean::
|
clean::
|
||||||
$(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
|
$(RM) $(OBJS) $(OBJS:.o=.d)
|
||||||
|
$(RM) $(HOSTPROGS)
|
||||||
|
$(RM) $(TOOLS)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(RULES))
|
$(eval $(RULES))
|
||||||
|
|
||||||
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_YASMD).d)
|
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Work around the class() function in AIX math.h clashing with
|
|
||||||
* identifiers named "class".
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_AIX_MATH_H
|
|
||||||
#define COMPAT_AIX_MATH_H
|
|
||||||
|
|
||||||
#define class class_in_math_h_causes_problems
|
|
||||||
|
|
||||||
#include_next <math.h>
|
|
||||||
|
|
||||||
#undef class
|
|
||||||
|
|
||||||
#endif /* COMPAT_AIX_MATH_H */
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* based on vlc_atomic.h from VLC
|
|
||||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_ATOMICS_DUMMY_STDATOMIC_H
|
|
||||||
#define COMPAT_ATOMICS_DUMMY_STDATOMIC_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define ATOMIC_FLAG_INIT 0
|
|
||||||
|
|
||||||
#define ATOMIC_VAR_INIT(value) (value)
|
|
||||||
|
|
||||||
#define atomic_init(obj, value) \
|
|
||||||
do { \
|
|
||||||
*(obj) = (value); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define kill_dependency(y) ((void)0)
|
|
||||||
|
|
||||||
#define atomic_thread_fence(order) \
|
|
||||||
((void)0)
|
|
||||||
|
|
||||||
#define atomic_signal_fence(order) \
|
|
||||||
((void)0)
|
|
||||||
|
|
||||||
#define atomic_is_lock_free(obj) 0
|
|
||||||
|
|
||||||
typedef intptr_t atomic_flag;
|
|
||||||
typedef intptr_t atomic_bool;
|
|
||||||
typedef intptr_t atomic_char;
|
|
||||||
typedef intptr_t atomic_schar;
|
|
||||||
typedef intptr_t atomic_uchar;
|
|
||||||
typedef intptr_t atomic_short;
|
|
||||||
typedef intptr_t atomic_ushort;
|
|
||||||
typedef intptr_t atomic_int;
|
|
||||||
typedef intptr_t atomic_uint;
|
|
||||||
typedef intptr_t atomic_long;
|
|
||||||
typedef intptr_t atomic_ulong;
|
|
||||||
typedef intptr_t atomic_llong;
|
|
||||||
typedef intptr_t atomic_ullong;
|
|
||||||
typedef intptr_t atomic_wchar_t;
|
|
||||||
typedef intptr_t atomic_int_least8_t;
|
|
||||||
typedef intptr_t atomic_uint_least8_t;
|
|
||||||
typedef intptr_t atomic_int_least16_t;
|
|
||||||
typedef intptr_t atomic_uint_least16_t;
|
|
||||||
typedef intptr_t atomic_int_least32_t;
|
|
||||||
typedef intptr_t atomic_uint_least32_t;
|
|
||||||
typedef intptr_t atomic_int_least64_t;
|
|
||||||
typedef intptr_t atomic_uint_least64_t;
|
|
||||||
typedef intptr_t atomic_int_fast8_t;
|
|
||||||
typedef intptr_t atomic_uint_fast8_t;
|
|
||||||
typedef intptr_t atomic_int_fast16_t;
|
|
||||||
typedef intptr_t atomic_uint_fast16_t;
|
|
||||||
typedef intptr_t atomic_int_fast32_t;
|
|
||||||
typedef intptr_t atomic_uint_fast32_t;
|
|
||||||
typedef intptr_t atomic_int_fast64_t;
|
|
||||||
typedef intptr_t atomic_uint_fast64_t;
|
|
||||||
typedef intptr_t atomic_intptr_t;
|
|
||||||
typedef intptr_t atomic_uintptr_t;
|
|
||||||
typedef intptr_t atomic_size_t;
|
|
||||||
typedef intptr_t atomic_ptrdiff_t;
|
|
||||||
typedef intptr_t atomic_intmax_t;
|
|
||||||
typedef intptr_t atomic_uintmax_t;
|
|
||||||
|
|
||||||
#define atomic_store(object, desired) \
|
|
||||||
do { \
|
|
||||||
*(object) = (desired); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define atomic_store_explicit(object, desired, order) \
|
|
||||||
atomic_store(object, desired)
|
|
||||||
|
|
||||||
#define atomic_load(object) \
|
|
||||||
(*(object))
|
|
||||||
|
|
||||||
#define atomic_load_explicit(object, order) \
|
|
||||||
atomic_load(object)
|
|
||||||
|
|
||||||
static inline intptr_t atomic_exchange(intptr_t *object, intptr_t desired)
|
|
||||||
{
|
|
||||||
intptr_t ret = *object;
|
|
||||||
*object = desired;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_exchange_explicit(object, desired, order) \
|
|
||||||
atomic_exchange(object, desired)
|
|
||||||
|
|
||||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
|
||||||
intptr_t desired)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
if (*object == *expected) {
|
|
||||||
*object = desired;
|
|
||||||
ret = 1;
|
|
||||||
} else {
|
|
||||||
*expected = *object;
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_weak(object, expected, desired)
|
|
||||||
|
|
||||||
#define FETCH_MODIFY(opname, op) \
|
|
||||||
static inline intptr_t atomic_fetch_ ## opname(intptr_t *object, intptr_t operand) \
|
|
||||||
{ \
|
|
||||||
intptr_t ret; \
|
|
||||||
ret = *object; \
|
|
||||||
*object = *object op operand; \
|
|
||||||
return ret; \
|
|
||||||
}
|
|
||||||
|
|
||||||
FETCH_MODIFY(add, +)
|
|
||||||
FETCH_MODIFY(sub, -)
|
|
||||||
FETCH_MODIFY(or, |)
|
|
||||||
FETCH_MODIFY(xor, ^)
|
|
||||||
FETCH_MODIFY(and, &)
|
|
||||||
|
|
||||||
#undef FETCH_MODIFY
|
|
||||||
|
|
||||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_add(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_sub(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_or(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_xor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_and(object, operand)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set(object) \
|
|
||||||
atomic_exchange(object, 1)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
|
||||||
atomic_flag_test_and_set(object)
|
|
||||||
|
|
||||||
#define atomic_flag_clear(object) \
|
|
||||||
atomic_store(object, 0)
|
|
||||||
|
|
||||||
#define atomic_flag_clear_explicit(object, order) \
|
|
||||||
atomic_flag_clear(object)
|
|
||||||
|
|
||||||
#endif /* COMPAT_ATOMICS_DUMMY_STDATOMIC_H */
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* based on vlc_atomic.h from VLC
|
|
||||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_ATOMICS_GCC_STDATOMIC_H
|
|
||||||
#define COMPAT_ATOMICS_GCC_STDATOMIC_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define ATOMIC_FLAG_INIT 0
|
|
||||||
|
|
||||||
#define ATOMIC_VAR_INIT(value) (value)
|
|
||||||
|
|
||||||
#define atomic_init(obj, value) \
|
|
||||||
do { \
|
|
||||||
*(obj) = (value); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define kill_dependency(y) ((void)0)
|
|
||||||
|
|
||||||
#define atomic_thread_fence(order) \
|
|
||||||
__sync_synchronize()
|
|
||||||
|
|
||||||
#define atomic_signal_fence(order) \
|
|
||||||
((void)0)
|
|
||||||
|
|
||||||
#define atomic_is_lock_free(obj) 0
|
|
||||||
|
|
||||||
typedef _Bool atomic_flag;
|
|
||||||
typedef _Bool atomic_bool;
|
|
||||||
typedef char atomic_char;
|
|
||||||
typedef signed char atomic_schar;
|
|
||||||
typedef unsigned char atomic_uchar;
|
|
||||||
typedef short atomic_short;
|
|
||||||
typedef unsigned short atomic_ushort;
|
|
||||||
typedef int atomic_int;
|
|
||||||
typedef unsigned int atomic_uint;
|
|
||||||
typedef long atomic_long;
|
|
||||||
typedef unsigned long atomic_ulong;
|
|
||||||
typedef long long atomic_llong;
|
|
||||||
typedef unsigned long long atomic_ullong;
|
|
||||||
typedef wchar_t atomic_wchar_t;
|
|
||||||
typedef int_least8_t atomic_int_least8_t;
|
|
||||||
typedef uint_least8_t atomic_uint_least8_t;
|
|
||||||
typedef int_least16_t atomic_int_least16_t;
|
|
||||||
typedef uint_least16_t atomic_uint_least16_t;
|
|
||||||
typedef int_least32_t atomic_int_least32_t;
|
|
||||||
typedef uint_least32_t atomic_uint_least32_t;
|
|
||||||
typedef int_least64_t atomic_int_least64_t;
|
|
||||||
typedef uint_least64_t atomic_uint_least64_t;
|
|
||||||
typedef int_fast8_t atomic_int_fast8_t;
|
|
||||||
typedef uint_fast8_t atomic_uint_fast8_t;
|
|
||||||
typedef int_fast16_t atomic_int_fast16_t;
|
|
||||||
typedef uint_fast16_t atomic_uint_fast16_t;
|
|
||||||
typedef int_fast32_t atomic_int_fast32_t;
|
|
||||||
typedef uint_fast32_t atomic_uint_fast32_t;
|
|
||||||
typedef int_fast64_t atomic_int_fast64_t;
|
|
||||||
typedef uint_fast64_t atomic_uint_fast64_t;
|
|
||||||
typedef intptr_t atomic_intptr_t;
|
|
||||||
typedef uintptr_t atomic_uintptr_t;
|
|
||||||
typedef size_t atomic_size_t;
|
|
||||||
typedef ptrdiff_t atomic_ptrdiff_t;
|
|
||||||
typedef intmax_t atomic_intmax_t;
|
|
||||||
typedef uintmax_t atomic_uintmax_t;
|
|
||||||
|
|
||||||
#define atomic_store(object, desired) \
|
|
||||||
do { \
|
|
||||||
*(object) = (desired); \
|
|
||||||
__sync_synchronize(); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define atomic_store_explicit(object, desired, order) \
|
|
||||||
atomic_store(object, desired)
|
|
||||||
|
|
||||||
#define atomic_load(object) \
|
|
||||||
(__sync_synchronize(), *(object))
|
|
||||||
|
|
||||||
#define atomic_load_explicit(object, order) \
|
|
||||||
atomic_load(object)
|
|
||||||
|
|
||||||
#define atomic_exchange(object, desired) \
|
|
||||||
({ \
|
|
||||||
__typeof__(object) _obj = (object); \
|
|
||||||
__typeof__(*object) _old; \
|
|
||||||
do \
|
|
||||||
_old = atomic_load(_obj); \
|
|
||||||
while (!__sync_bool_compare_and_swap(_obj, _old, (desired))); \
|
|
||||||
_old; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define atomic_exchange_explicit(object, desired, order) \
|
|
||||||
atomic_exchange(object, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_strong(object, expected, desired) \
|
|
||||||
({ \
|
|
||||||
__typeof__(object) _exp = (expected); \
|
|
||||||
__typeof__(*object) _old = *_exp; \
|
|
||||||
*_exp = __sync_val_compare_and_swap((object), _old, (desired)); \
|
|
||||||
*_exp == _old; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_weak(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_fetch_add(object, operand) \
|
|
||||||
__sync_fetch_and_add(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_add(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub(object, operand) \
|
|
||||||
__sync_fetch_and_sub(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_sub(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_or(object, operand) \
|
|
||||||
__sync_fetch_and_or(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_or(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor(object, operand) \
|
|
||||||
__sync_fetch_and_xor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_xor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and(object, operand) \
|
|
||||||
__sync_fetch_and_and(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_and(object, operand)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set(object) \
|
|
||||||
atomic_exchange(object, 1)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
|
||||||
atomic_flag_test_and_set(object)
|
|
||||||
|
|
||||||
#define atomic_flag_clear(object) \
|
|
||||||
atomic_store(object, 0)
|
|
||||||
|
|
||||||
#define atomic_flag_clear_explicit(object, order) \
|
|
||||||
atomic_flag_clear(object)
|
|
||||||
|
|
||||||
#endif /* COMPAT_ATOMICS_GCC_STDATOMIC_H */
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* based on vlc_atomic.h from VLC
|
|
||||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "stdatomic.h"
|
|
||||||
|
|
||||||
static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
void avpriv_atomic_lock(void)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&atomic_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void avpriv_atomic_unlock(void)
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock(&atomic_lock);
|
|
||||||
}
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* based on vlc_atomic.h from VLC
|
|
||||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_ATOMICS_PTHREAD_STDATOMIC_H
|
|
||||||
#define COMPAT_ATOMICS_PTHREAD_STDATOMIC_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define ATOMIC_FLAG_INIT 0
|
|
||||||
|
|
||||||
#define ATOMIC_VAR_INIT(value) (value)
|
|
||||||
|
|
||||||
#define atomic_init(obj, value) \
|
|
||||||
do { \
|
|
||||||
*(obj) = (value); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define kill_dependency(y) ((void)0)
|
|
||||||
|
|
||||||
#define atomic_signal_fence(order) \
|
|
||||||
((void)0)
|
|
||||||
|
|
||||||
#define atomic_is_lock_free(obj) 0
|
|
||||||
|
|
||||||
typedef intptr_t atomic_flag;
|
|
||||||
typedef intptr_t atomic_bool;
|
|
||||||
typedef intptr_t atomic_char;
|
|
||||||
typedef intptr_t atomic_schar;
|
|
||||||
typedef intptr_t atomic_uchar;
|
|
||||||
typedef intptr_t atomic_short;
|
|
||||||
typedef intptr_t atomic_ushort;
|
|
||||||
typedef intptr_t atomic_int;
|
|
||||||
typedef intptr_t atomic_uint;
|
|
||||||
typedef intptr_t atomic_long;
|
|
||||||
typedef intptr_t atomic_ulong;
|
|
||||||
typedef intptr_t atomic_llong;
|
|
||||||
typedef intptr_t atomic_ullong;
|
|
||||||
typedef intptr_t atomic_wchar_t;
|
|
||||||
typedef intptr_t atomic_int_least8_t;
|
|
||||||
typedef intptr_t atomic_uint_least8_t;
|
|
||||||
typedef intptr_t atomic_int_least16_t;
|
|
||||||
typedef intptr_t atomic_uint_least16_t;
|
|
||||||
typedef intptr_t atomic_int_least32_t;
|
|
||||||
typedef intptr_t atomic_uint_least32_t;
|
|
||||||
typedef intptr_t atomic_int_least64_t;
|
|
||||||
typedef intptr_t atomic_uint_least64_t;
|
|
||||||
typedef intptr_t atomic_int_fast8_t;
|
|
||||||
typedef intptr_t atomic_uint_fast8_t;
|
|
||||||
typedef intptr_t atomic_int_fast16_t;
|
|
||||||
typedef intptr_t atomic_uint_fast16_t;
|
|
||||||
typedef intptr_t atomic_int_fast32_t;
|
|
||||||
typedef intptr_t atomic_uint_fast32_t;
|
|
||||||
typedef intptr_t atomic_int_fast64_t;
|
|
||||||
typedef intptr_t atomic_uint_fast64_t;
|
|
||||||
typedef intptr_t atomic_intptr_t;
|
|
||||||
typedef intptr_t atomic_uintptr_t;
|
|
||||||
typedef intptr_t atomic_size_t;
|
|
||||||
typedef intptr_t atomic_ptrdiff_t;
|
|
||||||
typedef intptr_t atomic_intmax_t;
|
|
||||||
typedef intptr_t atomic_uintmax_t;
|
|
||||||
|
|
||||||
void avpriv_atomic_lock(void);
|
|
||||||
void avpriv_atomic_unlock(void);
|
|
||||||
|
|
||||||
static inline void atomic_thread_fence(int order)
|
|
||||||
{
|
|
||||||
avpriv_atomic_lock();
|
|
||||||
avpriv_atomic_unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void atomic_store(intptr_t *object, intptr_t desired)
|
|
||||||
{
|
|
||||||
avpriv_atomic_lock();
|
|
||||||
*object = desired;
|
|
||||||
avpriv_atomic_unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_store_explicit(object, desired, order) \
|
|
||||||
atomic_store(object, desired)
|
|
||||||
|
|
||||||
static inline intptr_t atomic_load(intptr_t *object)
|
|
||||||
{
|
|
||||||
intptr_t ret;
|
|
||||||
avpriv_atomic_lock();
|
|
||||||
ret = *object;
|
|
||||||
avpriv_atomic_unlock();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_load_explicit(object, order) \
|
|
||||||
atomic_load(object)
|
|
||||||
|
|
||||||
static inline intptr_t atomic_exchange(intptr_t *object, intptr_t desired)
|
|
||||||
{
|
|
||||||
intptr_t ret;
|
|
||||||
avpriv_atomic_lock();
|
|
||||||
ret = *object;
|
|
||||||
*object = desired;
|
|
||||||
avpriv_atomic_unlock();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_exchange_explicit(object, desired, order) \
|
|
||||||
atomic_exchange(object, desired)
|
|
||||||
|
|
||||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
|
||||||
intptr_t desired)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
avpriv_atomic_lock();
|
|
||||||
if (*object == *expected) {
|
|
||||||
ret = 1;
|
|
||||||
*object = desired;
|
|
||||||
} else {
|
|
||||||
ret = 0;
|
|
||||||
*expected = *object;
|
|
||||||
}
|
|
||||||
avpriv_atomic_unlock();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_weak(object, expected, desired)
|
|
||||||
|
|
||||||
#define FETCH_MODIFY(opname, op) \
|
|
||||||
static inline intptr_t atomic_fetch_ ## opname(intptr_t *object, intptr_t operand) \
|
|
||||||
{ \
|
|
||||||
intptr_t ret; \
|
|
||||||
avpriv_atomic_lock(); \
|
|
||||||
ret = *object; \
|
|
||||||
*object = *object op operand; \
|
|
||||||
avpriv_atomic_unlock(); \
|
|
||||||
return ret; \
|
|
||||||
}
|
|
||||||
|
|
||||||
FETCH_MODIFY(add, +)
|
|
||||||
FETCH_MODIFY(sub, -)
|
|
||||||
FETCH_MODIFY(or, |)
|
|
||||||
FETCH_MODIFY(xor, ^)
|
|
||||||
FETCH_MODIFY(and, &)
|
|
||||||
|
|
||||||
#undef FETCH_MODIFY
|
|
||||||
|
|
||||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_add(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_sub(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_or(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_xor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_and(object, operand)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set(object) \
|
|
||||||
atomic_exchange(object, 1)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
|
||||||
atomic_flag_test_and_set(object)
|
|
||||||
|
|
||||||
#define atomic_flag_clear(object) \
|
|
||||||
atomic_store(object, 0)
|
|
||||||
|
|
||||||
#define atomic_flag_clear_explicit(object, order) \
|
|
||||||
atomic_flag_clear(object)
|
|
||||||
|
|
||||||
#endif /* COMPAT_ATOMICS_PTHREAD_STDATOMIC_H */
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_ATOMICS_SUNCC_STDATOMIC_H
|
|
||||||
#define COMPAT_ATOMICS_SUNCC_STDATOMIC_H
|
|
||||||
|
|
||||||
#include <atomic.h>
|
|
||||||
#include <mbarrier.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define ATOMIC_FLAG_INIT 0
|
|
||||||
|
|
||||||
#define ATOMIC_VAR_INIT(value) (value)
|
|
||||||
|
|
||||||
#define atomic_init(obj, value) \
|
|
||||||
do { \
|
|
||||||
*(obj) = (value); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define kill_dependency(y) ((void)0)
|
|
||||||
|
|
||||||
#define atomic_thread_fence(order) \
|
|
||||||
__machine_rw_barrier();
|
|
||||||
|
|
||||||
#define atomic_signal_fence(order) \
|
|
||||||
((void)0)
|
|
||||||
|
|
||||||
#define atomic_is_lock_free(obj) 0
|
|
||||||
|
|
||||||
typedef intptr_t atomic_flag;
|
|
||||||
typedef intptr_t atomic_bool;
|
|
||||||
typedef intptr_t atomic_char;
|
|
||||||
typedef intptr_t atomic_schar;
|
|
||||||
typedef intptr_t atomic_uchar;
|
|
||||||
typedef intptr_t atomic_short;
|
|
||||||
typedef intptr_t atomic_ushort;
|
|
||||||
typedef intptr_t atomic_int;
|
|
||||||
typedef intptr_t atomic_uint;
|
|
||||||
typedef intptr_t atomic_long;
|
|
||||||
typedef intptr_t atomic_ulong;
|
|
||||||
typedef intptr_t atomic_llong;
|
|
||||||
typedef intptr_t atomic_ullong;
|
|
||||||
typedef intptr_t atomic_wchar_t;
|
|
||||||
typedef intptr_t atomic_int_least8_t;
|
|
||||||
typedef intptr_t atomic_uint_least8_t;
|
|
||||||
typedef intptr_t atomic_int_least16_t;
|
|
||||||
typedef intptr_t atomic_uint_least16_t;
|
|
||||||
typedef intptr_t atomic_int_least32_t;
|
|
||||||
typedef intptr_t atomic_uint_least32_t;
|
|
||||||
typedef intptr_t atomic_int_least64_t;
|
|
||||||
typedef intptr_t atomic_uint_least64_t;
|
|
||||||
typedef intptr_t atomic_int_fast8_t;
|
|
||||||
typedef intptr_t atomic_uint_fast8_t;
|
|
||||||
typedef intptr_t atomic_int_fast16_t;
|
|
||||||
typedef intptr_t atomic_uint_fast16_t;
|
|
||||||
typedef intptr_t atomic_int_fast32_t;
|
|
||||||
typedef intptr_t atomic_uint_fast32_t;
|
|
||||||
typedef intptr_t atomic_int_fast64_t;
|
|
||||||
typedef intptr_t atomic_uint_fast64_t;
|
|
||||||
typedef intptr_t atomic_intptr_t;
|
|
||||||
typedef intptr_t atomic_uintptr_t;
|
|
||||||
typedef intptr_t atomic_size_t;
|
|
||||||
typedef intptr_t atomic_ptrdiff_t;
|
|
||||||
typedef intptr_t atomic_intmax_t;
|
|
||||||
typedef intptr_t atomic_uintmax_t;
|
|
||||||
|
|
||||||
static inline void atomic_store(intptr_t *object, intptr_t desired)
|
|
||||||
{
|
|
||||||
*object = desired;
|
|
||||||
__machine_rw_barrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_store_explicit(object, desired, order) \
|
|
||||||
atomic_store(object, desired)
|
|
||||||
|
|
||||||
static inline intptr_t atomic_load(intptr_t *object)
|
|
||||||
{
|
|
||||||
__machine_rw_barrier();
|
|
||||||
return *object;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_load_explicit(object, order) \
|
|
||||||
atomic_load(object)
|
|
||||||
|
|
||||||
#define atomic_exchange(object, desired) \
|
|
||||||
atomic_swap_ptr(object, desired)
|
|
||||||
|
|
||||||
#define atomic_exchange_explicit(object, desired, order) \
|
|
||||||
atomic_exchange(object, desired)
|
|
||||||
|
|
||||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
|
||||||
intptr_t desired)
|
|
||||||
{
|
|
||||||
intptr_t old = *expected;
|
|
||||||
*expected = atomic_cas_ptr(object, old, desired);
|
|
||||||
return *expected == old;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_weak(object, expected, desired)
|
|
||||||
|
|
||||||
static inline intptr_t atomic_fetch_add(intptr_t *object, intptr_t operand)
|
|
||||||
{
|
|
||||||
return atomic_add_ptr_nv(object, operand) - operand;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_fetch_sub(object, operand) \
|
|
||||||
atomic_fetch_add(object, -(operand))
|
|
||||||
|
|
||||||
static inline intptr_t atomic_fetch_or(intptr_t *object, intptr_t operand)
|
|
||||||
{
|
|
||||||
intptr_t old;
|
|
||||||
do {
|
|
||||||
old = atomic_load(object);
|
|
||||||
} while (!atomic_compare_exchange_strong(object, old, old | operand));
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline intptr_t atomic_fetch_xor(intptr_t *object, intptr_t operand)
|
|
||||||
{
|
|
||||||
intptr_t old;
|
|
||||||
do {
|
|
||||||
old = atomic_load(object);
|
|
||||||
} while (!atomic_compare_exchange_strong(object, old, old ^ operand));
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand)
|
|
||||||
{
|
|
||||||
intptr_t old;
|
|
||||||
do {
|
|
||||||
old = atomic_load(object);
|
|
||||||
} while (!atomic_compare_exchange_strong(object, old, old & operand));
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_add(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_sub(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_or(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_xor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_and(object, operand)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set(object) \
|
|
||||||
atomic_exchange(object, 1)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
|
||||||
atomic_flag_test_and_set(object)
|
|
||||||
|
|
||||||
#define atomic_flag_clear(object) \
|
|
||||||
atomic_store(object, 0)
|
|
||||||
|
|
||||||
#define atomic_flag_clear_explicit(object, order) \
|
|
||||||
atomic_flag_clear(object)
|
|
||||||
|
|
||||||
#endif /* COMPAT_ATOMICS_SUNCC_STDATOMIC_H */
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_ATOMICS_WIN32_STDATOMIC_H
|
|
||||||
#define COMPAT_ATOMICS_WIN32_STDATOMIC_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#define ATOMIC_FLAG_INIT 0
|
|
||||||
|
|
||||||
#define ATOMIC_VAR_INIT(value) (value)
|
|
||||||
|
|
||||||
#define atomic_init(obj, value) \
|
|
||||||
do { \
|
|
||||||
*(obj) = (value); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define kill_dependency(y) ((void)0)
|
|
||||||
|
|
||||||
#define atomic_thread_fence(order) \
|
|
||||||
MemoryBarrier();
|
|
||||||
|
|
||||||
#define atomic_signal_fence(order) \
|
|
||||||
((void)0)
|
|
||||||
|
|
||||||
#define atomic_is_lock_free(obj) 0
|
|
||||||
|
|
||||||
typedef intptr_t atomic_flag;
|
|
||||||
typedef intptr_t atomic_bool;
|
|
||||||
typedef intptr_t atomic_char;
|
|
||||||
typedef intptr_t atomic_schar;
|
|
||||||
typedef intptr_t atomic_uchar;
|
|
||||||
typedef intptr_t atomic_short;
|
|
||||||
typedef intptr_t atomic_ushort;
|
|
||||||
typedef intptr_t atomic_int;
|
|
||||||
typedef intptr_t atomic_uint;
|
|
||||||
typedef intptr_t atomic_long;
|
|
||||||
typedef intptr_t atomic_ulong;
|
|
||||||
typedef intptr_t atomic_llong;
|
|
||||||
typedef intptr_t atomic_ullong;
|
|
||||||
typedef intptr_t atomic_wchar_t;
|
|
||||||
typedef intptr_t atomic_int_least8_t;
|
|
||||||
typedef intptr_t atomic_uint_least8_t;
|
|
||||||
typedef intptr_t atomic_int_least16_t;
|
|
||||||
typedef intptr_t atomic_uint_least16_t;
|
|
||||||
typedef intptr_t atomic_int_least32_t;
|
|
||||||
typedef intptr_t atomic_uint_least32_t;
|
|
||||||
typedef intptr_t atomic_int_least64_t;
|
|
||||||
typedef intptr_t atomic_uint_least64_t;
|
|
||||||
typedef intptr_t atomic_int_fast8_t;
|
|
||||||
typedef intptr_t atomic_uint_fast8_t;
|
|
||||||
typedef intptr_t atomic_int_fast16_t;
|
|
||||||
typedef intptr_t atomic_uint_fast16_t;
|
|
||||||
typedef intptr_t atomic_int_fast32_t;
|
|
||||||
typedef intptr_t atomic_uint_fast32_t;
|
|
||||||
typedef intptr_t atomic_int_fast64_t;
|
|
||||||
typedef intptr_t atomic_uint_fast64_t;
|
|
||||||
typedef intptr_t atomic_intptr_t;
|
|
||||||
typedef intptr_t atomic_uintptr_t;
|
|
||||||
typedef intptr_t atomic_size_t;
|
|
||||||
typedef intptr_t atomic_ptrdiff_t;
|
|
||||||
typedef intptr_t atomic_intmax_t;
|
|
||||||
typedef intptr_t atomic_uintmax_t;
|
|
||||||
|
|
||||||
#define atomic_store(object, desired) \
|
|
||||||
do { \
|
|
||||||
*(object) = (desired); \
|
|
||||||
MemoryBarrier(); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define atomic_store_explicit(object, desired, order) \
|
|
||||||
atomic_store(object, desired)
|
|
||||||
|
|
||||||
#define atomic_load(object) \
|
|
||||||
(MemoryBarrier(), *(object))
|
|
||||||
|
|
||||||
#define atomic_load_explicit(object, order) \
|
|
||||||
atomic_load(object)
|
|
||||||
|
|
||||||
#define atomic_exchange(object, desired) \
|
|
||||||
InterlockedExchangePointer(object, desired);
|
|
||||||
|
|
||||||
#define atomic_exchange_explicit(object, desired, order) \
|
|
||||||
atomic_exchange(object, desired)
|
|
||||||
|
|
||||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
|
||||||
intptr_t desired)
|
|
||||||
{
|
|
||||||
intptr_t old = *expected;
|
|
||||||
*expected = InterlockedCompareExchangePointer(object, desired, old);
|
|
||||||
return *expected == old;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
|
||||||
atomic_compare_exchange_strong(object, expected, desired)
|
|
||||||
|
|
||||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
|
||||||
atomic_compare_exchange_weak(object, expected, desired)
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define atomic_fetch_add(object, operand) \
|
|
||||||
InterlockedExchangeAdd64(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub(object, operand) \
|
|
||||||
InterlockedExchangeAdd64(object, -(operand))
|
|
||||||
|
|
||||||
#define atomic_fetch_or(object, operand) \
|
|
||||||
InterlockedOr64(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor(object, operand) \
|
|
||||||
InterlockedXor64(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and(object, operand) \
|
|
||||||
InterlockedAnd64(object, operand)
|
|
||||||
#else
|
|
||||||
#define atomic_fetch_add(object, operand) \
|
|
||||||
InterlockedExchangeAdd(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub(object, operand) \
|
|
||||||
InterlockedExchangeAdd(object, -(operand))
|
|
||||||
|
|
||||||
#define atomic_fetch_or(object, operand) \
|
|
||||||
InterlockedOr(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor(object, operand) \
|
|
||||||
InterlockedXor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and(object, operand) \
|
|
||||||
InterlockedAnd(object, operand)
|
|
||||||
#endif /* _WIN64 */
|
|
||||||
|
|
||||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_add(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_sub(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_or(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_xor(object, operand)
|
|
||||||
|
|
||||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
|
||||||
atomic_fetch_and(object, operand)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set(object) \
|
|
||||||
atomic_exchange(object, 1)
|
|
||||||
|
|
||||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
|
||||||
atomic_flag_test_and_set(object)
|
|
||||||
|
|
||||||
#define atomic_flag_clear(object) \
|
|
||||||
atomic_store(object, 0)
|
|
||||||
|
|
||||||
#define atomic_flag_clear_explicit(object, order) \
|
|
||||||
atomic_flag_clear(object)
|
|
||||||
|
|
||||||
#endif /* COMPAT_ATOMICS_WIN32_STDATOMIC_H */
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,62 +0,0 @@
|
|||||||
// Avisynth C Interface Version 0.20
|
|
||||||
// Copyright 2003 Kevin Atkinson
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
|
|
||||||
// http://www.gnu.org/copyleft/gpl.html .
|
|
||||||
//
|
|
||||||
// As a special exception, I give you permission to link to the
|
|
||||||
// Avisynth C interface with independent modules that communicate with
|
|
||||||
// the Avisynth C interface solely through the interfaces defined in
|
|
||||||
// avisynth_c.h, regardless of the license terms of these independent
|
|
||||||
// modules, and to copy and distribute the resulting combined work
|
|
||||||
// under terms of your choice, provided that every copy of the
|
|
||||||
// combined work is accompanied by a complete copy of the source code
|
|
||||||
// of the Avisynth C interface and Avisynth itself (with the version
|
|
||||||
// used to produce the combined work), being distributed under the
|
|
||||||
// terms of the GNU General Public License plus this exception. An
|
|
||||||
// independent module is a module which is not derived from or based
|
|
||||||
// on Avisynth C Interface, such as 3rd-party filters, import and
|
|
||||||
// export plugins, or graphical user interfaces.
|
|
||||||
|
|
||||||
#ifndef AVS_CAPI_H
|
|
||||||
#define AVS_CAPI_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
# define EXTERN_C extern "C"
|
|
||||||
#else
|
|
||||||
# define EXTERN_C
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef AVSC_USE_STDCALL
|
|
||||||
# define AVSC_CC __cdecl
|
|
||||||
#else
|
|
||||||
# define AVSC_CC __stdcall
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AVSC_INLINE static __inline
|
|
||||||
|
|
||||||
#ifdef BUILDING_AVSCORE
|
|
||||||
# define AVSC_EXPORT EXTERN_C
|
|
||||||
# define AVSC_API(ret, name) EXTERN_C __declspec(dllexport) ret AVSC_CC name
|
|
||||||
#else
|
|
||||||
# define AVSC_EXPORT EXTERN_C __declspec(dllexport)
|
|
||||||
# ifndef AVSC_NO_DECLSPEC
|
|
||||||
# define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name
|
|
||||||
# else
|
|
||||||
# define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //AVS_CAPI_H
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
// Avisynth C Interface Version 0.20
|
|
||||||
// Copyright 2003 Kevin Atkinson
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
|
|
||||||
// http://www.gnu.org/copyleft/gpl.html .
|
|
||||||
//
|
|
||||||
// As a special exception, I give you permission to link to the
|
|
||||||
// Avisynth C interface with independent modules that communicate with
|
|
||||||
// the Avisynth C interface solely through the interfaces defined in
|
|
||||||
// avisynth_c.h, regardless of the license terms of these independent
|
|
||||||
// modules, and to copy and distribute the resulting combined work
|
|
||||||
// under terms of your choice, provided that every copy of the
|
|
||||||
// combined work is accompanied by a complete copy of the source code
|
|
||||||
// of the Avisynth C interface and Avisynth itself (with the version
|
|
||||||
// used to produce the combined work), being distributed under the
|
|
||||||
// terms of the GNU General Public License plus this exception. An
|
|
||||||
// independent module is a module which is not derived from or based
|
|
||||||
// on Avisynth C Interface, such as 3rd-party filters, import and
|
|
||||||
// export plugins, or graphical user interfaces.
|
|
||||||
|
|
||||||
#ifndef AVS_CONFIG_H
|
|
||||||
#define AVS_CONFIG_H
|
|
||||||
|
|
||||||
// Undefine this to get cdecl calling convention
|
|
||||||
#define AVSC_USE_STDCALL 1
|
|
||||||
|
|
||||||
// NOTE TO PLUGIN AUTHORS:
|
|
||||||
// Because FRAME_ALIGN can be substantially higher than the alignment
|
|
||||||
// a plugin actually needs, plugins should not use FRAME_ALIGN to check for
|
|
||||||
// alignment. They should always request the exact alignment value they need.
|
|
||||||
// This is to make sure that plugins work over the widest range of AviSynth
|
|
||||||
// builds possible.
|
|
||||||
#define FRAME_ALIGN 32
|
|
||||||
|
|
||||||
#if defined(_M_AMD64) || defined(__x86_64)
|
|
||||||
# define X86_64
|
|
||||||
#elif defined(_M_IX86) || defined(__i386__)
|
|
||||||
# define X86_32
|
|
||||||
#else
|
|
||||||
# error Unsupported CPU architecture.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //AVS_CONFIG_H
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
// Avisynth C Interface Version 0.20
|
|
||||||
// Copyright 2003 Kevin Atkinson
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
|
|
||||||
// http://www.gnu.org/copyleft/gpl.html .
|
|
||||||
//
|
|
||||||
// As a special exception, I give you permission to link to the
|
|
||||||
// Avisynth C interface with independent modules that communicate with
|
|
||||||
// the Avisynth C interface solely through the interfaces defined in
|
|
||||||
// avisynth_c.h, regardless of the license terms of these independent
|
|
||||||
// modules, and to copy and distribute the resulting combined work
|
|
||||||
// under terms of your choice, provided that every copy of the
|
|
||||||
// combined work is accompanied by a complete copy of the source code
|
|
||||||
// of the Avisynth C interface and Avisynth itself (with the version
|
|
||||||
// used to produce the combined work), being distributed under the
|
|
||||||
// terms of the GNU General Public License plus this exception. An
|
|
||||||
// independent module is a module which is not derived from or based
|
|
||||||
// on Avisynth C Interface, such as 3rd-party filters, import and
|
|
||||||
// export plugins, or graphical user interfaces.
|
|
||||||
|
|
||||||
#ifndef AVS_TYPES_H
|
|
||||||
#define AVS_TYPES_H
|
|
||||||
|
|
||||||
// Define all types necessary for interfacing with avisynth.dll
|
|
||||||
|
|
||||||
// Raster types used by VirtualDub & Avisynth
|
|
||||||
typedef unsigned int Pixel32;
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
|
|
||||||
// Audio Sample information
|
|
||||||
typedef float SFLOAT;
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
typedef long long int INT64;
|
|
||||||
#else
|
|
||||||
typedef __int64 INT64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //AVS_TYPES_H
|
|
||||||
@@ -1,728 +0,0 @@
|
|||||||
// Avisynth C Interface Version 0.20
|
|
||||||
// Copyright 2003 Kevin Atkinson
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
// MA 02110-1301 USA, or visit
|
|
||||||
// http://www.gnu.org/copyleft/gpl.html .
|
|
||||||
//
|
|
||||||
// As a special exception, I give you permission to link to the
|
|
||||||
// Avisynth C interface with independent modules that communicate with
|
|
||||||
// the Avisynth C interface solely through the interfaces defined in
|
|
||||||
// avisynth_c.h, regardless of the license terms of these independent
|
|
||||||
// modules, and to copy and distribute the resulting combined work
|
|
||||||
// under terms of your choice, provided that every copy of the
|
|
||||||
// combined work is accompanied by a complete copy of the source code
|
|
||||||
// of the Avisynth C interface and Avisynth itself (with the version
|
|
||||||
// used to produce the combined work), being distributed under the
|
|
||||||
// terms of the GNU General Public License plus this exception. An
|
|
||||||
// independent module is a module which is not derived from or based
|
|
||||||
// on Avisynth C Interface, such as 3rd-party filters, import and
|
|
||||||
// export plugins, or graphical user interfaces.
|
|
||||||
|
|
||||||
#ifndef __AVXSYNTH_C__
|
|
||||||
#define __AVXSYNTH_C__
|
|
||||||
|
|
||||||
#include "windowsPorts/windows2linux.h"
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
# define EXTERN_C extern "C"
|
|
||||||
#else
|
|
||||||
# define EXTERN_C
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AVSC_USE_STDCALL 1
|
|
||||||
|
|
||||||
#ifndef AVSC_USE_STDCALL
|
|
||||||
# define AVSC_CC __cdecl
|
|
||||||
#else
|
|
||||||
# define AVSC_CC __stdcall
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AVSC_INLINE static __inline
|
|
||||||
|
|
||||||
#ifdef AVISYNTH_C_EXPORTS
|
|
||||||
# define AVSC_EXPORT EXTERN_C
|
|
||||||
# define AVSC_API(ret, name) EXTERN_C __declspec(dllexport) ret AVSC_CC name
|
|
||||||
#else
|
|
||||||
# define AVSC_EXPORT EXTERN_C __declspec(dllexport)
|
|
||||||
# ifndef AVSC_NO_DECLSPEC
|
|
||||||
# define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name
|
|
||||||
# else
|
|
||||||
# define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
typedef long long int INT64;
|
|
||||||
#else
|
|
||||||
typedef __int64 INT64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Constants
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef __AVXSYNTH_H__
|
|
||||||
enum { AVISYNTH_INTERFACE_VERSION = 3 };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum {AVS_SAMPLE_INT8 = 1<<0,
|
|
||||||
AVS_SAMPLE_INT16 = 1<<1,
|
|
||||||
AVS_SAMPLE_INT24 = 1<<2,
|
|
||||||
AVS_SAMPLE_INT32 = 1<<3,
|
|
||||||
AVS_SAMPLE_FLOAT = 1<<4};
|
|
||||||
|
|
||||||
enum {AVS_PLANAR_Y=1<<0,
|
|
||||||
AVS_PLANAR_U=1<<1,
|
|
||||||
AVS_PLANAR_V=1<<2,
|
|
||||||
AVS_PLANAR_ALIGNED=1<<3,
|
|
||||||
AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED,
|
|
||||||
AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED,
|
|
||||||
AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED};
|
|
||||||
|
|
||||||
// Colorspace properties.
|
|
||||||
enum {AVS_CS_BGR = 1<<28,
|
|
||||||
AVS_CS_YUV = 1<<29,
|
|
||||||
AVS_CS_INTERLEAVED = 1<<30,
|
|
||||||
AVS_CS_PLANAR = 1<<31};
|
|
||||||
|
|
||||||
// Specific colorformats
|
|
||||||
enum {
|
|
||||||
AVS_CS_UNKNOWN = 0,
|
|
||||||
AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
|
|
||||||
AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
|
|
||||||
AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
|
|
||||||
AVS_CS_YV12 = 1<<3 | AVS_CS_YUV | AVS_CS_PLANAR, // y-v-u, planar
|
|
||||||
AVS_CS_I420 = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR, // y-u-v, planar
|
|
||||||
AVS_CS_IYUV = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR // same as above
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
AVS_IT_BFF = 1<<0,
|
|
||||||
AVS_IT_TFF = 1<<1,
|
|
||||||
AVS_IT_FIELDBASED = 1<<2};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
AVS_FILTER_TYPE=1,
|
|
||||||
AVS_FILTER_INPUT_COLORSPACE=2,
|
|
||||||
AVS_FILTER_OUTPUT_TYPE=9,
|
|
||||||
AVS_FILTER_NAME=4,
|
|
||||||
AVS_FILTER_AUTHOR=5,
|
|
||||||
AVS_FILTER_VERSION=6,
|
|
||||||
AVS_FILTER_ARGS=7,
|
|
||||||
AVS_FILTER_ARGS_INFO=8,
|
|
||||||
AVS_FILTER_ARGS_DESCRIPTION=10,
|
|
||||||
AVS_FILTER_DESCRIPTION=11};
|
|
||||||
|
|
||||||
enum { //SUBTYPES
|
|
||||||
AVS_FILTER_TYPE_AUDIO=1,
|
|
||||||
AVS_FILTER_TYPE_VIDEO=2,
|
|
||||||
AVS_FILTER_OUTPUT_TYPE_SAME=3,
|
|
||||||
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
AVS_CACHE_NOTHING=0,
|
|
||||||
AVS_CACHE_RANGE=1,
|
|
||||||
AVS_CACHE_ALL=2,
|
|
||||||
AVS_CACHE_AUDIO=3,
|
|
||||||
AVS_CACHE_AUDIO_NONE=4,
|
|
||||||
AVS_CACHE_AUDIO_AUTO=5
|
|
||||||
};
|
|
||||||
|
|
||||||
#define AVS_FRAME_ALIGN 16
|
|
||||||
|
|
||||||
typedef struct AVS_Clip AVS_Clip;
|
|
||||||
typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// AVS_VideoInfo
|
|
||||||
//
|
|
||||||
|
|
||||||
// AVS_VideoInfo is layed out identicly to VideoInfo
|
|
||||||
typedef struct AVS_VideoInfo {
|
|
||||||
int width, height; // width=0 means no video
|
|
||||||
unsigned fps_numerator, fps_denominator;
|
|
||||||
int num_frames;
|
|
||||||
|
|
||||||
int pixel_type;
|
|
||||||
|
|
||||||
int audio_samples_per_second; // 0 means no audio
|
|
||||||
int sample_type;
|
|
||||||
INT64 num_audio_samples;
|
|
||||||
int nchannels;
|
|
||||||
|
|
||||||
// Imagetype properties
|
|
||||||
|
|
||||||
int image_type;
|
|
||||||
} AVS_VideoInfo;
|
|
||||||
|
|
||||||
// useful functions of the above
|
|
||||||
AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p)
|
|
||||||
{ return (p->width!=0); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p)
|
|
||||||
{ return (p->audio_samples_per_second!=0); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)
|
|
||||||
{ return !!(p->pixel_type&AVS_CS_BGR); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)
|
|
||||||
{ return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)
|
|
||||||
{ return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)
|
|
||||||
{ return !!(p->pixel_type&AVS_CS_YUV ); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)
|
|
||||||
{ return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo * p)
|
|
||||||
{ return ((p->pixel_type & AVS_CS_YV12) == AVS_CS_YV12)||((p->pixel_type & AVS_CS_I420) == AVS_CS_I420); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_color_space(const AVS_VideoInfo * p, int c_space)
|
|
||||||
{ return ((p->pixel_type & c_space) == c_space); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
|
|
||||||
{ return ((p->pixel_type & property)==property ); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p)
|
|
||||||
{ return !!(p->pixel_type & AVS_CS_PLANAR); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p)
|
|
||||||
{ return !!(p->image_type & AVS_IT_FIELDBASED); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p)
|
|
||||||
{ return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p)
|
|
||||||
{ return !!(p->image_type & AVS_IT_BFF); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p)
|
|
||||||
{ return !!(p->image_type & AVS_IT_TFF); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo * p)
|
|
||||||
{
|
|
||||||
switch (p->pixel_type) {
|
|
||||||
case AVS_CS_BGR24: return 24;
|
|
||||||
case AVS_CS_BGR32: return 32;
|
|
||||||
case AVS_CS_YUY2: return 16;
|
|
||||||
case AVS_CS_YV12:
|
|
||||||
case AVS_CS_I420: return 12;
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AVSC_INLINE int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels)
|
|
||||||
{ return pixels * (avs_bits_per_pixel(p)>>3); } // Will work on planar images, but will return only luma planes
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_row_size(const AVS_VideoInfo * p)
|
|
||||||
{ return avs_bytes_from_pixels(p,p->width); } // Also only returns first plane on planar images
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_bmp_size(const AVS_VideoInfo * vi)
|
|
||||||
{ if (avs_is_planar(vi)) {int p = vi->height * ((avs_row_size(vi)+3) & ~3); p+=p>>1; return p; } return vi->height * ((avs_row_size(vi)+3) & ~3); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p)
|
|
||||||
{ return p->audio_samples_per_second; }
|
|
||||||
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p)
|
|
||||||
{
|
|
||||||
switch (p->sample_type) {
|
|
||||||
case AVS_SAMPLE_INT8: return sizeof(signed char);
|
|
||||||
case AVS_SAMPLE_INT16: return sizeof(signed short);
|
|
||||||
case AVS_SAMPLE_INT24: return 3;
|
|
||||||
case AVS_SAMPLE_INT32: return sizeof(signed int);
|
|
||||||
case AVS_SAMPLE_FLOAT: return sizeof(float);
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p)
|
|
||||||
{ return p->nchannels*avs_bytes_per_channel_sample(p);}
|
|
||||||
|
|
||||||
AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames)
|
|
||||||
{ return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples)
|
|
||||||
{ return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); }
|
|
||||||
|
|
||||||
AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes)
|
|
||||||
{ return bytes / avs_bytes_per_audio_sample(p); }
|
|
||||||
|
|
||||||
AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples)
|
|
||||||
{ return samples * avs_bytes_per_audio_sample(p); }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p)
|
|
||||||
{ return p->nchannels; }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p)
|
|
||||||
{ return p->sample_type;}
|
|
||||||
|
|
||||||
// useful mutator
|
|
||||||
AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property)
|
|
||||||
{ p->image_type|=property; }
|
|
||||||
|
|
||||||
AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property)
|
|
||||||
{ p->image_type&=~property; }
|
|
||||||
|
|
||||||
AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)
|
|
||||||
{ if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }
|
|
||||||
|
|
||||||
AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)
|
|
||||||
{
|
|
||||||
unsigned x=numerator, y=denominator;
|
|
||||||
while (y) { // find gcd
|
|
||||||
unsigned t = x%y; x = y; y = t;
|
|
||||||
}
|
|
||||||
p->fps_numerator = numerator/x;
|
|
||||||
p->fps_denominator = denominator/x;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)
|
|
||||||
{
|
|
||||||
return (x->pixel_type == y->pixel_type)
|
|
||||||
|| (avs_is_yv12(x) && avs_is_yv12(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// AVS_VideoFrame
|
|
||||||
//
|
|
||||||
|
|
||||||
// VideoFrameBuffer holds information about a memory block which is used
|
|
||||||
// for video data. For efficiency, instances of this class are not deleted
|
|
||||||
// when the refcount reaches zero; instead they're stored in a linked list
|
|
||||||
// to be reused. The instances are deleted when the corresponding AVS
|
|
||||||
// file is closed.
|
|
||||||
|
|
||||||
// AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer
|
|
||||||
// DO NOT USE THIS STRUCTURE DIRECTLY
|
|
||||||
typedef struct AVS_VideoFrameBuffer {
|
|
||||||
unsigned char * data;
|
|
||||||
int data_size;
|
|
||||||
// sequence_number is incremented every time the buffer is changed, so
|
|
||||||
// that stale views can tell they're no longer valid.
|
|
||||||
long sequence_number;
|
|
||||||
|
|
||||||
long refcount;
|
|
||||||
} AVS_VideoFrameBuffer;
|
|
||||||
|
|
||||||
// VideoFrame holds a "window" into a VideoFrameBuffer.
|
|
||||||
|
|
||||||
// AVS_VideoFrame is layed out identicly to IVideoFrame
|
|
||||||
// DO NOT USE THIS STRUCTURE DIRECTLY
|
|
||||||
typedef struct AVS_VideoFrame {
|
|
||||||
int refcount;
|
|
||||||
AVS_VideoFrameBuffer * vfb;
|
|
||||||
int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture.
|
|
||||||
} AVS_VideoFrame;
|
|
||||||
|
|
||||||
// Access functions for AVS_VideoFrame
|
|
||||||
AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) {
|
|
||||||
return p->pitch;}
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame * p, int plane) {
|
|
||||||
switch (plane) {
|
|
||||||
case AVS_PLANAR_U: case AVS_PLANAR_V: return p->pitchUV;}
|
|
||||||
return p->pitch;}
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) {
|
|
||||||
return p->row_size; }
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame * p, int plane) {
|
|
||||||
int r;
|
|
||||||
switch (plane) {
|
|
||||||
case AVS_PLANAR_U: case AVS_PLANAR_V:
|
|
||||||
if (p->pitchUV) return p->row_size>>1;
|
|
||||||
else return 0;
|
|
||||||
case AVS_PLANAR_U_ALIGNED: case AVS_PLANAR_V_ALIGNED:
|
|
||||||
if (p->pitchUV) {
|
|
||||||
r = ((p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)) )>>1; // Aligned rowsize
|
|
||||||
if (r < p->pitchUV)
|
|
||||||
return r;
|
|
||||||
return p->row_size>>1;
|
|
||||||
} else return 0;
|
|
||||||
case AVS_PLANAR_Y_ALIGNED:
|
|
||||||
r = (p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)); // Aligned rowsize
|
|
||||||
if (r <= p->pitch)
|
|
||||||
return r;
|
|
||||||
return p->row_size;
|
|
||||||
}
|
|
||||||
return p->row_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) {
|
|
||||||
return p->height;}
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame * p, int plane) {
|
|
||||||
switch (plane) {
|
|
||||||
case AVS_PLANAR_U: case AVS_PLANAR_V:
|
|
||||||
if (p->pitchUV) return p->height>>1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return p->height;}
|
|
||||||
|
|
||||||
AVSC_INLINE const unsigned char* avs_get_read_ptr(const AVS_VideoFrame * p) {
|
|
||||||
return p->vfb->data + p->offset;}
|
|
||||||
|
|
||||||
AVSC_INLINE const unsigned char* avs_get_read_ptr_p(const AVS_VideoFrame * p, int plane)
|
|
||||||
{
|
|
||||||
switch (plane) {
|
|
||||||
case AVS_PLANAR_U: return p->vfb->data + p->offsetU;
|
|
||||||
case AVS_PLANAR_V: return p->vfb->data + p->offsetV;
|
|
||||||
default: return p->vfb->data + p->offset;}
|
|
||||||
}
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_is_writable(const AVS_VideoFrame * p) {
|
|
||||||
return (p->refcount == 1 && p->vfb->refcount == 1);}
|
|
||||||
|
|
||||||
AVSC_INLINE unsigned char* avs_get_write_ptr(const AVS_VideoFrame * p)
|
|
||||||
{
|
|
||||||
if (avs_is_writable(p)) {
|
|
||||||
++p->vfb->sequence_number;
|
|
||||||
return p->vfb->data + p->offset;
|
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVSC_INLINE unsigned char* avs_get_write_ptr_p(const AVS_VideoFrame * p, int plane)
|
|
||||||
{
|
|
||||||
if (plane==AVS_PLANAR_Y && avs_is_writable(p)) {
|
|
||||||
++p->vfb->sequence_number;
|
|
||||||
return p->vfb->data + p->offset;
|
|
||||||
} else if (plane==AVS_PLANAR_Y) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
switch (plane) {
|
|
||||||
case AVS_PLANAR_U: return p->vfb->data + p->offsetU;
|
|
||||||
case AVS_PLANAR_V: return p->vfb->data + p->offsetV;
|
|
||||||
default: return p->vfb->data + p->offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);
|
|
||||||
// makes a shallow copy of a video frame
|
|
||||||
AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#ifndef AVSC_NO_DECLSPEC
|
|
||||||
AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f)
|
|
||||||
{avs_release_video_frame(f);}
|
|
||||||
AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f)
|
|
||||||
{return avs_copy_video_frame(f);}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// AVS_Value
|
|
||||||
//
|
|
||||||
|
|
||||||
// Treat AVS_Value as a fat pointer. That is use avs_copy_value
|
|
||||||
// and avs_release_value appropiaty as you would if AVS_Value was
|
|
||||||
// a pointer.
|
|
||||||
|
|
||||||
// To maintain source code compatibility with future versions of the
|
|
||||||
// avisynth_c API don't use the AVS_Value directly. Use the helper
|
|
||||||
// functions below.
|
|
||||||
|
|
||||||
// AVS_Value is layed out identicly to AVSValue
|
|
||||||
typedef struct AVS_Value AVS_Value;
|
|
||||||
struct AVS_Value {
|
|
||||||
short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong
|
|
||||||
// for some function e'rror
|
|
||||||
short array_size;
|
|
||||||
union {
|
|
||||||
void * clip; // do not use directly, use avs_take_clip
|
|
||||||
char boolean;
|
|
||||||
int integer;
|
|
||||||
INT64 integer64; // match addition of __int64 to avxplugin.h
|
|
||||||
float floating_pt;
|
|
||||||
const char * string;
|
|
||||||
const AVS_Value * array;
|
|
||||||
} d;
|
|
||||||
};
|
|
||||||
|
|
||||||
// AVS_Value should be initilized with avs_void.
|
|
||||||
// Should also set to avs_void after the value is released
|
|
||||||
// with avs_copy_value. Consider it the equalvent of setting
|
|
||||||
// a pointer to NULL
|
|
||||||
static const AVS_Value avs_void = {'v'};
|
|
||||||
|
|
||||||
AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);
|
|
||||||
AVSC_API(void, avs_release_value)(AVS_Value);
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }
|
|
||||||
AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
|
|
||||||
AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }
|
|
||||||
AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }
|
|
||||||
AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }
|
|
||||||
AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }
|
|
||||||
AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }
|
|
||||||
AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
|
|
||||||
AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
AVSC_INLINE int avs_as_bool(AVS_Value v)
|
|
||||||
{ return v.d.boolean; }
|
|
||||||
AVSC_INLINE int avs_as_int(AVS_Value v)
|
|
||||||
{ return v.d.integer; }
|
|
||||||
AVSC_INLINE const char * avs_as_string(AVS_Value v)
|
|
||||||
{ return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
|
|
||||||
AVSC_INLINE double avs_as_float(AVS_Value v)
|
|
||||||
{ return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }
|
|
||||||
AVSC_INLINE const char * avs_as_error(AVS_Value v)
|
|
||||||
{ return avs_is_error(v) ? v.d.string : 0; }
|
|
||||||
AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
|
|
||||||
{ return v.d.array; }
|
|
||||||
AVSC_INLINE int avs_array_size(AVS_Value v)
|
|
||||||
{ return avs_is_array(v) ? v.array_size : 1; }
|
|
||||||
AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
|
|
||||||
{ return avs_is_array(v) ? v.d.array[index] : v; }
|
|
||||||
|
|
||||||
// only use these functions on am AVS_Value that does not already have
|
|
||||||
// an active value. Remember, treat AVS_Value as a fat pointer.
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
|
|
||||||
{ AVS_Value v = {0}; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_int(int v0)
|
|
||||||
{ AVS_Value v = {0}; v.type = 'i'; v.d.integer = v0; return v; }
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
|
|
||||||
{ AVS_Value v = {0}; v.type = 's'; v.d.string = v0; return v; }
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_float(float v0)
|
|
||||||
{ AVS_Value v = {0}; v.type = 'f'; v.d.floating_pt = v0; return v;}
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
|
|
||||||
{ AVS_Value v = {0}; v.type = 'e'; v.d.string = v0; return v; }
|
|
||||||
#ifndef AVSC_NO_DECLSPEC
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0)
|
|
||||||
{ AVS_Value v = {0}; avs_set_to_clip(&v, v0); return v; }
|
|
||||||
#endif
|
|
||||||
AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)
|
|
||||||
{ AVS_Value v = {0}; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; }
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// AVS_Clip
|
|
||||||
//
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(void, avs_release_clip)(AVS_Clip *);
|
|
||||||
AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);
|
|
||||||
|
|
||||||
AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error
|
|
||||||
|
|
||||||
AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);
|
|
||||||
|
|
||||||
AVSC_API(int, avs_get_version)(AVS_Clip *);
|
|
||||||
|
|
||||||
AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);
|
|
||||||
// The returned video frame must be released with avs_release_video_frame
|
|
||||||
|
|
||||||
AVSC_API(int, avs_get_parity)(AVS_Clip *, int n);
|
|
||||||
// return field parity if field_based, else parity of first field in frame
|
|
||||||
|
|
||||||
AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,
|
|
||||||
INT64 start, INT64 count);
|
|
||||||
// start and count are in samples
|
|
||||||
|
|
||||||
AVSC_API(int, avs_set_cache_hints)(AVS_Clip *,
|
|
||||||
int cachehints, size_t frame_range);
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
// This is the callback type used by avs_add_function
|
|
||||||
typedef AVS_Value (AVSC_CC * AVS_ApplyFunc)
|
|
||||||
(AVS_ScriptEnvironment *, AVS_Value args, void * user_data);
|
|
||||||
|
|
||||||
typedef struct AVS_FilterInfo AVS_FilterInfo;
|
|
||||||
struct AVS_FilterInfo
|
|
||||||
{
|
|
||||||
// these members should not be modified outside of the AVS_ApplyFunc callback
|
|
||||||
AVS_Clip * child;
|
|
||||||
AVS_VideoInfo vi;
|
|
||||||
AVS_ScriptEnvironment * env;
|
|
||||||
AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
|
|
||||||
int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
|
|
||||||
int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,
|
|
||||||
INT64 start, INT64 count);
|
|
||||||
int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,
|
|
||||||
int frame_range);
|
|
||||||
void (AVSC_CC * free_filter)(AVS_FilterInfo *);
|
|
||||||
|
|
||||||
// Should be set when ever there is an error to report.
|
|
||||||
// It is cleared before any of the above methods are called
|
|
||||||
const char * error;
|
|
||||||
// this is to store whatever and may be modified at will
|
|
||||||
void * user_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create a new filter
|
|
||||||
// fi is set to point to the AVS_FilterInfo so that you can
|
|
||||||
// modify it once it is initilized.
|
|
||||||
// store_child should generally be set to true. If it is not
|
|
||||||
// set than ALL methods (the function pointers) must be defined
|
|
||||||
// If it is set than you do not need to worry about freeing the child
|
|
||||||
// clip.
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
|
|
||||||
AVS_FilterInfo * * fi,
|
|
||||||
AVS_Value child, int store_child);
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// AVS_ScriptEnvironment
|
|
||||||
//
|
|
||||||
|
|
||||||
// For GetCPUFlags. These are backwards-compatible with those in VirtualDub.
|
|
||||||
enum {
|
|
||||||
/* slowest CPU to support extension */
|
|
||||||
AVS_CPU_FORCE = 0x01, // N/A
|
|
||||||
AVS_CPU_FPU = 0x02, // 386/486DX
|
|
||||||
AVS_CPU_MMX = 0x04, // P55C, K6, PII
|
|
||||||
AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon
|
|
||||||
AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP
|
|
||||||
AVS_CPU_SSE2 = 0x20, // PIV, Hammer
|
|
||||||
AVS_CPU_3DNOW = 0x40, // K6-2
|
|
||||||
AVS_CPU_3DNOW_EXT = 0x80, // Athlon
|
|
||||||
AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2,
|
|
||||||
// which only Hammer will have anyway)
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
|
|
||||||
|
|
||||||
AVSC_API(long, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
|
|
||||||
AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
|
|
||||||
|
|
||||||
AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);
|
|
||||||
AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);
|
|
||||||
|
|
||||||
AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val);
|
|
||||||
// note: val is really a va_list; I hope everyone typedefs va_list to a pointer
|
|
||||||
|
|
||||||
AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,
|
|
||||||
const char * name, const char * params,
|
|
||||||
AVS_ApplyFunc apply, void * user_data);
|
|
||||||
|
|
||||||
AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);
|
|
||||||
|
|
||||||
AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,
|
|
||||||
AVS_Value args, const char** arg_names);
|
|
||||||
// The returned value must be be released with avs_release_value
|
|
||||||
|
|
||||||
AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);
|
|
||||||
// The returned value must be be released with avs_release_value
|
|
||||||
|
|
||||||
AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);
|
|
||||||
|
|
||||||
AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);
|
|
||||||
|
|
||||||
//void avs_push_context(AVS_ScriptEnvironment *, int level=0);
|
|
||||||
//void avs_pop_context(AVS_ScriptEnvironment *);
|
|
||||||
|
|
||||||
AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,
|
|
||||||
const AVS_VideoInfo * vi, int align);
|
|
||||||
// align should be at least 16
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#ifndef AVSC_NO_DECLSPEC
|
|
||||||
AVSC_INLINE
|
|
||||||
AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env,
|
|
||||||
const AVS_VideoInfo * vi)
|
|
||||||
{return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
|
|
||||||
|
|
||||||
AVSC_INLINE
|
|
||||||
AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,
|
|
||||||
const AVS_VideoInfo * vi)
|
|
||||||
{return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
|
|
||||||
|
|
||||||
AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, unsigned char* dstp, int dst_pitch, const unsigned char* srcp, int src_pitch, int row_size, int height);
|
|
||||||
|
|
||||||
typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);
|
|
||||||
AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
|
|
||||||
|
|
||||||
AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);
|
|
||||||
// The returned video frame must be be released
|
|
||||||
|
|
||||||
AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);
|
|
||||||
|
|
||||||
AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);
|
|
||||||
|
|
||||||
// avisynth.dll exports this; it's a way to use it as a library, without
|
|
||||||
// writing an AVS script or without going through AVIFile.
|
|
||||||
AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
// this symbol is the entry point for the plugin and must
|
|
||||||
// be defined
|
|
||||||
AVSC_EXPORT
|
|
||||||
const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env);
|
|
||||||
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
|
||||||
AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);
|
|
||||||
|
|
||||||
|
|
||||||
AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV);
|
|
||||||
// The returned video frame must be be released
|
|
||||||
#if defined __cplusplus
|
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif //__AVXSYNTH_C__
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
#ifndef __DATA_TYPE_CONVERSIONS_H__
|
|
||||||
#define __DATA_TYPE_CONVERSIONS_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
namespace avxsynth {
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
typedef int64_t __int64;
|
|
||||||
typedef int32_t __int32;
|
|
||||||
#ifdef __cplusplus
|
|
||||||
typedef bool BOOL;
|
|
||||||
#else
|
|
||||||
typedef uint32_t BOOL;
|
|
||||||
#endif // __cplusplus
|
|
||||||
typedef void* HMODULE;
|
|
||||||
typedef void* LPVOID;
|
|
||||||
typedef void* PVOID;
|
|
||||||
typedef PVOID HANDLE;
|
|
||||||
typedef HANDLE HWND;
|
|
||||||
typedef HANDLE HINSTANCE;
|
|
||||||
typedef void* HDC;
|
|
||||||
typedef void* HBITMAP;
|
|
||||||
typedef void* HICON;
|
|
||||||
typedef void* HFONT;
|
|
||||||
typedef void* HGDIOBJ;
|
|
||||||
typedef void* HBRUSH;
|
|
||||||
typedef void* HMMIO;
|
|
||||||
typedef void* HACMSTREAM;
|
|
||||||
typedef void* HACMDRIVER;
|
|
||||||
typedef void* HIC;
|
|
||||||
typedef void* HACMOBJ;
|
|
||||||
typedef HACMSTREAM* LPHACMSTREAM;
|
|
||||||
typedef void* HACMDRIVERID;
|
|
||||||
typedef void* LPHACMDRIVER;
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
typedef BYTE* LPBYTE;
|
|
||||||
typedef char TCHAR;
|
|
||||||
typedef TCHAR* LPTSTR;
|
|
||||||
typedef const TCHAR* LPCTSTR;
|
|
||||||
typedef char* LPSTR;
|
|
||||||
typedef LPSTR LPOLESTR;
|
|
||||||
typedef const char* LPCSTR;
|
|
||||||
typedef LPCSTR LPCOLESTR;
|
|
||||||
typedef wchar_t WCHAR;
|
|
||||||
typedef unsigned short WORD;
|
|
||||||
typedef unsigned int UINT;
|
|
||||||
typedef UINT MMRESULT;
|
|
||||||
typedef uint32_t DWORD;
|
|
||||||
typedef DWORD COLORREF;
|
|
||||||
typedef DWORD FOURCC;
|
|
||||||
typedef DWORD HRESULT;
|
|
||||||
typedef DWORD* LPDWORD;
|
|
||||||
typedef DWORD* DWORD_PTR;
|
|
||||||
typedef int32_t LONG;
|
|
||||||
typedef int32_t* LONG_PTR;
|
|
||||||
typedef LONG_PTR LRESULT;
|
|
||||||
typedef uint32_t ULONG;
|
|
||||||
typedef uint32_t* ULONG_PTR;
|
|
||||||
//typedef __int64_t intptr_t;
|
|
||||||
typedef uint64_t _fsize_t;
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Structures
|
|
||||||
//
|
|
||||||
|
|
||||||
typedef struct _GUID {
|
|
||||||
DWORD Data1;
|
|
||||||
WORD Data2;
|
|
||||||
WORD Data3;
|
|
||||||
BYTE Data4[8];
|
|
||||||
} GUID;
|
|
||||||
|
|
||||||
typedef GUID REFIID;
|
|
||||||
typedef GUID CLSID;
|
|
||||||
typedef CLSID* LPCLSID;
|
|
||||||
typedef GUID IID;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}; // namespace avxsynth
|
|
||||||
#endif // __cplusplus
|
|
||||||
#endif // __DATA_TYPE_CONVERSIONS_H__
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
#ifndef __WINDOWS2LINUX_H__
|
|
||||||
#define __WINDOWS2LINUX_H__
|
|
||||||
|
|
||||||
/*
|
|
||||||
* LINUX SPECIFIC DEFINITIONS
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Data types conversions
|
|
||||||
//
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "basicDataTypeConversions.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
namespace avxsynth {
|
|
||||||
#endif // __cplusplus
|
|
||||||
//
|
|
||||||
// purposefully define the following MSFT definitions
|
|
||||||
// to mean nothing (as they do not mean anything on Linux)
|
|
||||||
//
|
|
||||||
#define __stdcall
|
|
||||||
#define __cdecl
|
|
||||||
#define noreturn
|
|
||||||
#define __declspec(x)
|
|
||||||
#define STDAPI extern "C" HRESULT
|
|
||||||
#define STDMETHODIMP HRESULT __stdcall
|
|
||||||
#define STDMETHODIMP_(x) x __stdcall
|
|
||||||
|
|
||||||
#define STDMETHOD(x) virtual HRESULT x
|
|
||||||
#define STDMETHOD_(a, x) virtual a x
|
|
||||||
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE true
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FALSE
|
|
||||||
#define FALSE false
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define S_OK (0x00000000)
|
|
||||||
#define S_FALSE (0x00000001)
|
|
||||||
#define E_NOINTERFACE (0X80004002)
|
|
||||||
#define E_POINTER (0x80004003)
|
|
||||||
#define E_FAIL (0x80004005)
|
|
||||||
#define E_OUTOFMEMORY (0x8007000E)
|
|
||||||
|
|
||||||
#define INVALID_HANDLE_VALUE ((HANDLE)((LONG_PTR)-1))
|
|
||||||
#define FAILED(hr) ((hr) & 0x80000000)
|
|
||||||
#define SUCCEEDED(hr) (!FAILED(hr))
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Functions
|
|
||||||
//
|
|
||||||
#define MAKEDWORD(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
|
||||||
#define MAKEWORD(a,b) (((a) << 8) | (b))
|
|
||||||
|
|
||||||
#define lstrlen strlen
|
|
||||||
#define lstrcpy strcpy
|
|
||||||
#define lstrcmpi strcasecmp
|
|
||||||
#define _stricmp strcasecmp
|
|
||||||
#define InterlockedIncrement(x) __sync_fetch_and_add((x), 1)
|
|
||||||
#define InterlockedDecrement(x) __sync_fetch_and_sub((x), 1)
|
|
||||||
// Windows uses (new, old) ordering but GCC has (old, new)
|
|
||||||
#define InterlockedCompareExchange(x,y,z) __sync_val_compare_and_swap(x,z,y)
|
|
||||||
|
|
||||||
#define UInt32x32To64(a, b) ( (uint64_t) ( ((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)) ) )
|
|
||||||
#define Int64ShrlMod32(a, b) ( (uint64_t) ( (uint64_t)(a) >> (b) ) )
|
|
||||||
#define Int32x32To64(a, b) ((__int64)(((__int64)((long)(a))) * ((long)(b))))
|
|
||||||
|
|
||||||
#define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}; // namespace avxsynth
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#endif // __WINDOWS2LINUX_H__
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* This copyright notice applies to this header file only:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use,
|
|
||||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the software, and to permit persons to whom the
|
|
||||||
* software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(AV_COMPAT_DYNLINK_CUDA_H) && !defined(CUDA_VERSION)
|
|
||||||
#define AV_COMPAT_DYNLINK_CUDA_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#define CUDA_VERSION 7050
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
||||||
#define CUDAAPI __stdcall
|
|
||||||
#else
|
|
||||||
#define CUDAAPI
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CU_CTX_SCHED_BLOCKING_SYNC 4
|
|
||||||
|
|
||||||
typedef int CUdevice;
|
|
||||||
typedef void* CUarray;
|
|
||||||
typedef void* CUcontext;
|
|
||||||
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
|
|
||||||
typedef unsigned long long CUdeviceptr;
|
|
||||||
#else
|
|
||||||
typedef unsigned int CUdeviceptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum cudaError_enum {
|
|
||||||
CUDA_SUCCESS = 0
|
|
||||||
} CUresult;
|
|
||||||
|
|
||||||
typedef enum CUmemorytype_enum {
|
|
||||||
CU_MEMORYTYPE_HOST = 1,
|
|
||||||
CU_MEMORYTYPE_DEVICE = 2
|
|
||||||
} CUmemorytype;
|
|
||||||
|
|
||||||
typedef struct CUDA_MEMCPY2D_st {
|
|
||||||
size_t srcXInBytes;
|
|
||||||
size_t srcY;
|
|
||||||
CUmemorytype srcMemoryType;
|
|
||||||
const void *srcHost;
|
|
||||||
CUdeviceptr srcDevice;
|
|
||||||
CUarray srcArray;
|
|
||||||
size_t srcPitch;
|
|
||||||
|
|
||||||
size_t dstXInBytes;
|
|
||||||
size_t dstY;
|
|
||||||
CUmemorytype dstMemoryType;
|
|
||||||
void *dstHost;
|
|
||||||
CUdeviceptr dstDevice;
|
|
||||||
CUarray dstArray;
|
|
||||||
size_t dstPitch;
|
|
||||||
|
|
||||||
size_t WidthInBytes;
|
|
||||||
size_t Height;
|
|
||||||
} CUDA_MEMCPY2D;
|
|
||||||
|
|
||||||
typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
|
|
||||||
typedef CUresult CUDAAPI tcuDeviceGetCount(int *count);
|
|
||||||
typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
|
|
||||||
typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);
|
|
||||||
typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
|
|
||||||
typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev);
|
|
||||||
typedef CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext *pctx);
|
|
||||||
typedef CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx);
|
|
||||||
typedef CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx);
|
|
||||||
typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize);
|
|
||||||
typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
|
|
||||||
typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
|
|
||||||
typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
|
|
||||||
typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,815 +0,0 @@
|
|||||||
/*
|
|
||||||
* This copyright notice applies to this header file only:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010-2016 NVIDIA Corporation
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use,
|
|
||||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the software, and to permit persons to whom the
|
|
||||||
* software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file cuviddec.h
|
|
||||||
* NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
|
|
||||||
* \date 2015-2016
|
|
||||||
* This file contains constants, structure definitions and function prototypes used for decoding.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(__CUDA_VIDEO_H__)
|
|
||||||
#define __CUDA_VIDEO_H__
|
|
||||||
|
|
||||||
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
|
|
||||||
#if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))
|
|
||||||
#define __CUVID_DEVPTR64
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
|
||||||
typedef unsigned int tcu_ulong;
|
|
||||||
#else
|
|
||||||
typedef unsigned long tcu_ulong;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void *CUvideodecoder;
|
|
||||||
typedef struct _CUcontextlock_st *CUvideoctxlock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \addtogroup VIDEO_DECODER Video Decoder
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaVideoCodec
|
|
||||||
* Video Codec Enums
|
|
||||||
*/
|
|
||||||
typedef enum cudaVideoCodec_enum {
|
|
||||||
cudaVideoCodec_MPEG1=0, /**< MPEG1 */
|
|
||||||
cudaVideoCodec_MPEG2, /**< MPEG2 */
|
|
||||||
cudaVideoCodec_MPEG4, /**< MPEG4 */
|
|
||||||
cudaVideoCodec_VC1, /**< VC1 */
|
|
||||||
cudaVideoCodec_H264, /**< H264 */
|
|
||||||
cudaVideoCodec_JPEG, /**< JPEG */
|
|
||||||
cudaVideoCodec_H264_SVC, /**< H264-SVC */
|
|
||||||
cudaVideoCodec_H264_MVC, /**< H264-MVC */
|
|
||||||
cudaVideoCodec_HEVC, /**< HEVC */
|
|
||||||
cudaVideoCodec_VP8, /**< VP8 */
|
|
||||||
cudaVideoCodec_VP9, /**< VP9 */
|
|
||||||
cudaVideoCodec_NumCodecs, /**< Max COdecs */
|
|
||||||
// Uncompressed YUV
|
|
||||||
cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), /**< Y,U,V (4:2:0) */
|
|
||||||
cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,V,U (4:2:0) */
|
|
||||||
cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,UV (4:2:0) */
|
|
||||||
cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), /**< YUYV/YUY2 (4:2:2) */
|
|
||||||
cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) /**< UYVY (4:2:2) */
|
|
||||||
} cudaVideoCodec;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaVideoSurfaceFormat
|
|
||||||
* Video Surface Formats Enums
|
|
||||||
*/
|
|
||||||
typedef enum cudaVideoSurfaceFormat_enum {
|
|
||||||
cudaVideoSurfaceFormat_NV12=0, /**< NV12 */
|
|
||||||
cudaVideoSurfaceFormat_P016=1 /**< P016 */
|
|
||||||
} cudaVideoSurfaceFormat;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaVideoDeinterlaceMode
|
|
||||||
* Deinterlacing Modes Enums
|
|
||||||
*/
|
|
||||||
typedef enum cudaVideoDeinterlaceMode_enum {
|
|
||||||
cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */
|
|
||||||
cudaVideoDeinterlaceMode_Bob, /**< Drop one field */
|
|
||||||
cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */
|
|
||||||
} cudaVideoDeinterlaceMode;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaVideoChromaFormat
|
|
||||||
* Chroma Formats Enums
|
|
||||||
*/
|
|
||||||
typedef enum cudaVideoChromaFormat_enum {
|
|
||||||
cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */
|
|
||||||
cudaVideoChromaFormat_420, /**< 4:2:0 */
|
|
||||||
cudaVideoChromaFormat_422, /**< 4:2:2 */
|
|
||||||
cudaVideoChromaFormat_444 /**< 4:4:4 */
|
|
||||||
} cudaVideoChromaFormat;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaVideoCreateFlags
|
|
||||||
* Decoder Flags Enums
|
|
||||||
*/
|
|
||||||
typedef enum cudaVideoCreateFlags_enum {
|
|
||||||
cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */
|
|
||||||
cudaVideoCreate_PreferCUDA = 0x01, /**< Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading) */
|
|
||||||
cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */
|
|
||||||
cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */
|
|
||||||
} cudaVideoCreateFlags;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDDECODECREATEINFO
|
|
||||||
* Struct used in create decoder
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDDECODECREATEINFO
|
|
||||||
{
|
|
||||||
tcu_ulong ulWidth; /**< Coded Sequence Width */
|
|
||||||
tcu_ulong ulHeight; /**< Coded Sequence Height */
|
|
||||||
tcu_ulong ulNumDecodeSurfaces; /**< Maximum number of internal decode surfaces */
|
|
||||||
cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
|
|
||||||
cudaVideoChromaFormat ChromaFormat; /**< cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported) */
|
|
||||||
tcu_ulong ulCreationFlags; /**< Decoder creation flags (cudaVideoCreateFlags_XXX) */
|
|
||||||
tcu_ulong bitDepthMinus8;
|
|
||||||
tcu_ulong Reserved1[4]; /**< Reserved for future use - set to zero */
|
|
||||||
/**
|
|
||||||
* area of the frame that should be displayed
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
short left;
|
|
||||||
short top;
|
|
||||||
short right;
|
|
||||||
short bottom;
|
|
||||||
} display_area;
|
|
||||||
|
|
||||||
cudaVideoSurfaceFormat OutputFormat; /**< cudaVideoSurfaceFormat_XXX */
|
|
||||||
cudaVideoDeinterlaceMode DeinterlaceMode; /**< cudaVideoDeinterlaceMode_XXX */
|
|
||||||
tcu_ulong ulTargetWidth; /**< Post-processed Output Width (Should be aligned to 2) */
|
|
||||||
tcu_ulong ulTargetHeight; /**< Post-processed Output Height (Should be aligbed to 2) */
|
|
||||||
tcu_ulong ulNumOutputSurfaces; /**< Maximum number of output surfaces simultaneously mapped */
|
|
||||||
CUvideoctxlock vidLock; /**< If non-NULL, context lock used for synchronizing ownership of the cuda context */
|
|
||||||
/**
|
|
||||||
* target rectangle in the output frame (for aspect ratio conversion)
|
|
||||||
* if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
short left;
|
|
||||||
short top;
|
|
||||||
short right;
|
|
||||||
short bottom;
|
|
||||||
} target_rect;
|
|
||||||
tcu_ulong Reserved2[5]; /**< Reserved for future use - set to zero */
|
|
||||||
} CUVIDDECODECREATEINFO;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDH264DPBENTRY
|
|
||||||
* H.264 DPB Entry
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDH264DPBENTRY
|
|
||||||
{
|
|
||||||
int PicIdx; /**< picture index of reference frame */
|
|
||||||
int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */
|
|
||||||
int is_long_term; /**< 0=short term reference, 1=long term reference */
|
|
||||||
int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
|
|
||||||
int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */
|
|
||||||
int FieldOrderCnt[2]; /**< field order count of top and bottom fields */
|
|
||||||
} CUVIDH264DPBENTRY;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDH264MVCEXT
|
|
||||||
* H.264 MVC Picture Parameters Ext
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDH264MVCEXT
|
|
||||||
{
|
|
||||||
int num_views_minus1;
|
|
||||||
int view_id;
|
|
||||||
unsigned char inter_view_flag;
|
|
||||||
unsigned char num_inter_view_refs_l0;
|
|
||||||
unsigned char num_inter_view_refs_l1;
|
|
||||||
unsigned char MVCReserved8Bits;
|
|
||||||
int InterViewRefsL0[16];
|
|
||||||
int InterViewRefsL1[16];
|
|
||||||
} CUVIDH264MVCEXT;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDH264SVCEXT
|
|
||||||
* H.264 SVC Picture Parameters Ext
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDH264SVCEXT
|
|
||||||
{
|
|
||||||
unsigned char profile_idc;
|
|
||||||
unsigned char level_idc;
|
|
||||||
unsigned char DQId;
|
|
||||||
unsigned char DQIdMax;
|
|
||||||
unsigned char disable_inter_layer_deblocking_filter_idc;
|
|
||||||
unsigned char ref_layer_chroma_phase_y_plus1;
|
|
||||||
signed char inter_layer_slice_alpha_c0_offset_div2;
|
|
||||||
signed char inter_layer_slice_beta_offset_div2;
|
|
||||||
|
|
||||||
unsigned short DPBEntryValidFlag;
|
|
||||||
unsigned char inter_layer_deblocking_filter_control_present_flag;
|
|
||||||
unsigned char extended_spatial_scalability_idc;
|
|
||||||
unsigned char adaptive_tcoeff_level_prediction_flag;
|
|
||||||
unsigned char slice_header_restriction_flag;
|
|
||||||
unsigned char chroma_phase_x_plus1_flag;
|
|
||||||
unsigned char chroma_phase_y_plus1;
|
|
||||||
|
|
||||||
unsigned char tcoeff_level_prediction_flag;
|
|
||||||
unsigned char constrained_intra_resampling_flag;
|
|
||||||
unsigned char ref_layer_chroma_phase_x_plus1_flag;
|
|
||||||
unsigned char store_ref_base_pic_flag;
|
|
||||||
unsigned char Reserved8BitsA;
|
|
||||||
unsigned char Reserved8BitsB;
|
|
||||||
// For the 4 scaled_ref_layer_XX fields below,
|
|
||||||
// if (extended_spatial_scalability_idc == 1), SPS field, G.7.3.2.1.4, add prefix "seq_"
|
|
||||||
// if (extended_spatial_scalability_idc == 2), SLH field, G.7.3.3.4,
|
|
||||||
short scaled_ref_layer_left_offset;
|
|
||||||
short scaled_ref_layer_top_offset;
|
|
||||||
short scaled_ref_layer_right_offset;
|
|
||||||
short scaled_ref_layer_bottom_offset;
|
|
||||||
unsigned short Reserved16Bits;
|
|
||||||
struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. Linked list ends at the target layer. */
|
|
||||||
int bRefBaseLayer; /**< whether to store ref base pic */
|
|
||||||
} CUVIDH264SVCEXT;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDH264PICPARAMS
|
|
||||||
* H.264 Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDH264PICPARAMS
|
|
||||||
{
|
|
||||||
// SPS
|
|
||||||
int log2_max_frame_num_minus4;
|
|
||||||
int pic_order_cnt_type;
|
|
||||||
int log2_max_pic_order_cnt_lsb_minus4;
|
|
||||||
int delta_pic_order_always_zero_flag;
|
|
||||||
int frame_mbs_only_flag;
|
|
||||||
int direct_8x8_inference_flag;
|
|
||||||
int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
|
|
||||||
unsigned char residual_colour_transform_flag;
|
|
||||||
unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
|
|
||||||
unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
|
|
||||||
unsigned char qpprime_y_zero_transform_bypass_flag;
|
|
||||||
// PPS
|
|
||||||
int entropy_coding_mode_flag;
|
|
||||||
int pic_order_present_flag;
|
|
||||||
int num_ref_idx_l0_active_minus1;
|
|
||||||
int num_ref_idx_l1_active_minus1;
|
|
||||||
int weighted_pred_flag;
|
|
||||||
int weighted_bipred_idc;
|
|
||||||
int pic_init_qp_minus26;
|
|
||||||
int deblocking_filter_control_present_flag;
|
|
||||||
int redundant_pic_cnt_present_flag;
|
|
||||||
int transform_8x8_mode_flag;
|
|
||||||
int MbaffFrameFlag;
|
|
||||||
int constrained_intra_pred_flag;
|
|
||||||
int chroma_qp_index_offset;
|
|
||||||
int second_chroma_qp_index_offset;
|
|
||||||
int ref_pic_flag;
|
|
||||||
int frame_num;
|
|
||||||
int CurrFieldOrderCnt[2];
|
|
||||||
// DPB
|
|
||||||
CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
|
|
||||||
// Quantization Matrices (raster-order)
|
|
||||||
unsigned char WeightScale4x4[6][16];
|
|
||||||
unsigned char WeightScale8x8[2][64];
|
|
||||||
// FMO/ASO
|
|
||||||
unsigned char fmo_aso_enable;
|
|
||||||
unsigned char num_slice_groups_minus1;
|
|
||||||
unsigned char slice_group_map_type;
|
|
||||||
signed char pic_init_qs_minus26;
|
|
||||||
unsigned int slice_group_change_rate_minus1;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
unsigned long long slice_group_map_addr;
|
|
||||||
const unsigned char *pMb2SliceGroupMap;
|
|
||||||
} fmo;
|
|
||||||
unsigned int Reserved[12];
|
|
||||||
// SVC/MVC
|
|
||||||
union
|
|
||||||
{
|
|
||||||
CUVIDH264MVCEXT mvcext;
|
|
||||||
CUVIDH264SVCEXT svcext;
|
|
||||||
} svcmvc;
|
|
||||||
} CUVIDH264PICPARAMS;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDMPEG2PICPARAMS
|
|
||||||
* MPEG-2 Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDMPEG2PICPARAMS
|
|
||||||
{
|
|
||||||
int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
|
|
||||||
int BackwardRefIdx; // Picture index of backward reference (B-frames)
|
|
||||||
int picture_coding_type;
|
|
||||||
int full_pel_forward_vector;
|
|
||||||
int full_pel_backward_vector;
|
|
||||||
int f_code[2][2];
|
|
||||||
int intra_dc_precision;
|
|
||||||
int frame_pred_frame_dct;
|
|
||||||
int concealment_motion_vectors;
|
|
||||||
int q_scale_type;
|
|
||||||
int intra_vlc_format;
|
|
||||||
int alternate_scan;
|
|
||||||
int top_field_first;
|
|
||||||
// Quantization matrices (raster order)
|
|
||||||
unsigned char QuantMatrixIntra[64];
|
|
||||||
unsigned char QuantMatrixInter[64];
|
|
||||||
} CUVIDMPEG2PICPARAMS;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// MPEG-4 Picture Parameters
|
|
||||||
//
|
|
||||||
|
|
||||||
// MPEG-4 has VOP types instead of Picture types
|
|
||||||
#define I_VOP 0
|
|
||||||
#define P_VOP 1
|
|
||||||
#define B_VOP 2
|
|
||||||
#define S_VOP 3
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDMPEG4PICPARAMS
|
|
||||||
* MPEG-4 Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDMPEG4PICPARAMS
|
|
||||||
{
|
|
||||||
int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
|
|
||||||
int BackwardRefIdx; // Picture index of backward reference (B-frames)
|
|
||||||
// VOL
|
|
||||||
int video_object_layer_width;
|
|
||||||
int video_object_layer_height;
|
|
||||||
int vop_time_increment_bitcount;
|
|
||||||
int top_field_first;
|
|
||||||
int resync_marker_disable;
|
|
||||||
int quant_type;
|
|
||||||
int quarter_sample;
|
|
||||||
int short_video_header;
|
|
||||||
int divx_flags;
|
|
||||||
// VOP
|
|
||||||
int vop_coding_type;
|
|
||||||
int vop_coded;
|
|
||||||
int vop_rounding_type;
|
|
||||||
int alternate_vertical_scan_flag;
|
|
||||||
int interlaced;
|
|
||||||
int vop_fcode_forward;
|
|
||||||
int vop_fcode_backward;
|
|
||||||
int trd[2];
|
|
||||||
int trb[2];
|
|
||||||
// Quantization matrices (raster order)
|
|
||||||
unsigned char QuantMatrixIntra[64];
|
|
||||||
unsigned char QuantMatrixInter[64];
|
|
||||||
int gmc_enabled;
|
|
||||||
} CUVIDMPEG4PICPARAMS;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDVC1PICPARAMS
|
|
||||||
* VC1 Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDVC1PICPARAMS
|
|
||||||
{
|
|
||||||
int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */
|
|
||||||
int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */
|
|
||||||
int FrameWidth; /**< Actual frame width */
|
|
||||||
int FrameHeight; /**< Actual frame height */
|
|
||||||
// PICTURE
|
|
||||||
int intra_pic_flag; /**< Set to 1 for I,BI frames */
|
|
||||||
int ref_pic_flag; /**< Set to 1 for I,P frames */
|
|
||||||
int progressive_fcm; /**< Progressive frame */
|
|
||||||
// SEQUENCE
|
|
||||||
int profile;
|
|
||||||
int postprocflag;
|
|
||||||
int pulldown;
|
|
||||||
int interlace;
|
|
||||||
int tfcntrflag;
|
|
||||||
int finterpflag;
|
|
||||||
int psf;
|
|
||||||
int multires;
|
|
||||||
int syncmarker;
|
|
||||||
int rangered;
|
|
||||||
int maxbframes;
|
|
||||||
// ENTRYPOINT
|
|
||||||
int panscan_flag;
|
|
||||||
int refdist_flag;
|
|
||||||
int extended_mv;
|
|
||||||
int dquant;
|
|
||||||
int vstransform;
|
|
||||||
int loopfilter;
|
|
||||||
int fastuvmc;
|
|
||||||
int overlap;
|
|
||||||
int quantizer;
|
|
||||||
int extended_dmv;
|
|
||||||
int range_mapy_flag;
|
|
||||||
int range_mapy;
|
|
||||||
int range_mapuv_flag;
|
|
||||||
int range_mapuv;
|
|
||||||
int rangeredfrm; // range reduction state
|
|
||||||
} CUVIDVC1PICPARAMS;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDJPEGPICPARAMS
|
|
||||||
* JPEG Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDJPEGPICPARAMS
|
|
||||||
{
|
|
||||||
int Reserved;
|
|
||||||
} CUVIDJPEGPICPARAMS;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDHEVCPICPARAMS
|
|
||||||
* HEVC Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDHEVCPICPARAMS
|
|
||||||
{
|
|
||||||
// sps
|
|
||||||
int pic_width_in_luma_samples;
|
|
||||||
int pic_height_in_luma_samples;
|
|
||||||
unsigned char log2_min_luma_coding_block_size_minus3;
|
|
||||||
unsigned char log2_diff_max_min_luma_coding_block_size;
|
|
||||||
unsigned char log2_min_transform_block_size_minus2;
|
|
||||||
unsigned char log2_diff_max_min_transform_block_size;
|
|
||||||
unsigned char pcm_enabled_flag;
|
|
||||||
unsigned char log2_min_pcm_luma_coding_block_size_minus3;
|
|
||||||
unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
|
|
||||||
unsigned char pcm_sample_bit_depth_luma_minus1;
|
|
||||||
|
|
||||||
unsigned char pcm_sample_bit_depth_chroma_minus1;
|
|
||||||
unsigned char pcm_loop_filter_disabled_flag;
|
|
||||||
unsigned char strong_intra_smoothing_enabled_flag;
|
|
||||||
unsigned char max_transform_hierarchy_depth_intra;
|
|
||||||
unsigned char max_transform_hierarchy_depth_inter;
|
|
||||||
unsigned char amp_enabled_flag;
|
|
||||||
unsigned char separate_colour_plane_flag;
|
|
||||||
unsigned char log2_max_pic_order_cnt_lsb_minus4;
|
|
||||||
|
|
||||||
unsigned char num_short_term_ref_pic_sets;
|
|
||||||
unsigned char long_term_ref_pics_present_flag;
|
|
||||||
unsigned char num_long_term_ref_pics_sps;
|
|
||||||
unsigned char sps_temporal_mvp_enabled_flag;
|
|
||||||
unsigned char sample_adaptive_offset_enabled_flag;
|
|
||||||
unsigned char scaling_list_enable_flag;
|
|
||||||
unsigned char IrapPicFlag;
|
|
||||||
unsigned char IdrPicFlag;
|
|
||||||
|
|
||||||
unsigned char bit_depth_luma_minus8;
|
|
||||||
unsigned char bit_depth_chroma_minus8;
|
|
||||||
unsigned char reserved1[14];
|
|
||||||
|
|
||||||
// pps
|
|
||||||
unsigned char dependent_slice_segments_enabled_flag;
|
|
||||||
unsigned char slice_segment_header_extension_present_flag;
|
|
||||||
unsigned char sign_data_hiding_enabled_flag;
|
|
||||||
unsigned char cu_qp_delta_enabled_flag;
|
|
||||||
unsigned char diff_cu_qp_delta_depth;
|
|
||||||
signed char init_qp_minus26;
|
|
||||||
signed char pps_cb_qp_offset;
|
|
||||||
signed char pps_cr_qp_offset;
|
|
||||||
|
|
||||||
unsigned char constrained_intra_pred_flag;
|
|
||||||
unsigned char weighted_pred_flag;
|
|
||||||
unsigned char weighted_bipred_flag;
|
|
||||||
unsigned char transform_skip_enabled_flag;
|
|
||||||
unsigned char transquant_bypass_enabled_flag;
|
|
||||||
unsigned char entropy_coding_sync_enabled_flag;
|
|
||||||
unsigned char log2_parallel_merge_level_minus2;
|
|
||||||
unsigned char num_extra_slice_header_bits;
|
|
||||||
|
|
||||||
unsigned char loop_filter_across_tiles_enabled_flag;
|
|
||||||
unsigned char loop_filter_across_slices_enabled_flag;
|
|
||||||
unsigned char output_flag_present_flag;
|
|
||||||
unsigned char num_ref_idx_l0_default_active_minus1;
|
|
||||||
unsigned char num_ref_idx_l1_default_active_minus1;
|
|
||||||
unsigned char lists_modification_present_flag;
|
|
||||||
unsigned char cabac_init_present_flag;
|
|
||||||
unsigned char pps_slice_chroma_qp_offsets_present_flag;
|
|
||||||
|
|
||||||
unsigned char deblocking_filter_override_enabled_flag;
|
|
||||||
unsigned char pps_deblocking_filter_disabled_flag;
|
|
||||||
signed char pps_beta_offset_div2;
|
|
||||||
signed char pps_tc_offset_div2;
|
|
||||||
unsigned char tiles_enabled_flag;
|
|
||||||
unsigned char uniform_spacing_flag;
|
|
||||||
unsigned char num_tile_columns_minus1;
|
|
||||||
unsigned char num_tile_rows_minus1;
|
|
||||||
|
|
||||||
unsigned short column_width_minus1[21];
|
|
||||||
unsigned short row_height_minus1[21];
|
|
||||||
unsigned int reserved3[15];
|
|
||||||
|
|
||||||
// RefPicSets
|
|
||||||
int NumBitsForShortTermRPSInSlice;
|
|
||||||
int NumDeltaPocsOfRefRpsIdx;
|
|
||||||
int NumPocTotalCurr;
|
|
||||||
int NumPocStCurrBefore;
|
|
||||||
int NumPocStCurrAfter;
|
|
||||||
int NumPocLtCurr;
|
|
||||||
int CurrPicOrderCntVal;
|
|
||||||
int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference)
|
|
||||||
int PicOrderCntVal[16]; // [refpic]
|
|
||||||
unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference
|
|
||||||
unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
|
|
||||||
unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15)
|
|
||||||
unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15)
|
|
||||||
unsigned char RefPicSetInterLayer0[8];
|
|
||||||
unsigned char RefPicSetInterLayer1[8];
|
|
||||||
unsigned int reserved4[12];
|
|
||||||
|
|
||||||
// scaling lists (diag order)
|
|
||||||
unsigned char ScalingList4x4[6][16]; // [matrixId][i]
|
|
||||||
unsigned char ScalingList8x8[6][64]; // [matrixId][i]
|
|
||||||
unsigned char ScalingList16x16[6][64]; // [matrixId][i]
|
|
||||||
unsigned char ScalingList32x32[2][64]; // [matrixId][i]
|
|
||||||
unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]
|
|
||||||
unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]
|
|
||||||
} CUVIDHEVCPICPARAMS;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDVP8PICPARAMS
|
|
||||||
* VP8 Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDVP8PICPARAMS
|
|
||||||
{
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
unsigned int first_partition_size;
|
|
||||||
//Frame Indexes
|
|
||||||
unsigned char LastRefIdx;
|
|
||||||
unsigned char GoldenRefIdx;
|
|
||||||
unsigned char AltRefIdx;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */
|
|
||||||
unsigned char version : 3;
|
|
||||||
unsigned char show_frame : 1;
|
|
||||||
unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */
|
|
||||||
unsigned char Reserved2Bits : 2;
|
|
||||||
};
|
|
||||||
unsigned char wFrameTagFlags;
|
|
||||||
} tagflags;
|
|
||||||
unsigned char Reserved1[4];
|
|
||||||
unsigned int Reserved2[3];
|
|
||||||
} CUVIDVP8PICPARAMS;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDVP9PICPARAMS
|
|
||||||
* VP9 Picture Parameters
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDVP9PICPARAMS
|
|
||||||
{
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
|
|
||||||
//Frame Indices
|
|
||||||
unsigned char LastRefIdx;
|
|
||||||
unsigned char GoldenRefIdx;
|
|
||||||
unsigned char AltRefIdx;
|
|
||||||
unsigned char colorSpace;
|
|
||||||
|
|
||||||
unsigned short profile : 3;
|
|
||||||
unsigned short frameContextIdx : 2;
|
|
||||||
unsigned short frameType : 1;
|
|
||||||
unsigned short showFrame : 1;
|
|
||||||
unsigned short errorResilient : 1;
|
|
||||||
unsigned short frameParallelDecoding : 1;
|
|
||||||
unsigned short subSamplingX : 1;
|
|
||||||
unsigned short subSamplingY : 1;
|
|
||||||
unsigned short intraOnly : 1;
|
|
||||||
unsigned short allow_high_precision_mv : 1;
|
|
||||||
unsigned short refreshEntropyProbs : 1;
|
|
||||||
unsigned short reserved2Bits : 2;
|
|
||||||
|
|
||||||
unsigned short reserved16Bits;
|
|
||||||
|
|
||||||
unsigned char refFrameSignBias[4];
|
|
||||||
|
|
||||||
unsigned char bitDepthMinus8Luma;
|
|
||||||
unsigned char bitDepthMinus8Chroma;
|
|
||||||
unsigned char loopFilterLevel;
|
|
||||||
unsigned char loopFilterSharpness;
|
|
||||||
|
|
||||||
unsigned char modeRefLfEnabled;
|
|
||||||
unsigned char log2_tile_columns;
|
|
||||||
unsigned char log2_tile_rows;
|
|
||||||
|
|
||||||
unsigned char segmentEnabled : 1;
|
|
||||||
unsigned char segmentMapUpdate : 1;
|
|
||||||
unsigned char segmentMapTemporalUpdate : 1;
|
|
||||||
unsigned char segmentFeatureMode : 1;
|
|
||||||
unsigned char reserved4Bits : 4;
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char segmentFeatureEnable[8][4];
|
|
||||||
short segmentFeatureData[8][4];
|
|
||||||
unsigned char mb_segment_tree_probs[7];
|
|
||||||
unsigned char segment_pred_probs[3];
|
|
||||||
unsigned char reservedSegment16Bits[2];
|
|
||||||
|
|
||||||
int qpYAc;
|
|
||||||
int qpYDc;
|
|
||||||
int qpChDc;
|
|
||||||
int qpChAc;
|
|
||||||
|
|
||||||
unsigned int activeRefIdx[3];
|
|
||||||
unsigned int resetFrameContext;
|
|
||||||
unsigned int mcomp_filter_type;
|
|
||||||
unsigned int mbRefLfDelta[4];
|
|
||||||
unsigned int mbModeLfDelta[2];
|
|
||||||
unsigned int frameTagSize;
|
|
||||||
unsigned int offsetToDctParts;
|
|
||||||
unsigned int reserved128Bits[4];
|
|
||||||
|
|
||||||
} CUVIDVP9PICPARAMS;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDPICPARAMS
|
|
||||||
* Picture Parameters for Decoding
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDPICPARAMS
|
|
||||||
{
|
|
||||||
int PicWidthInMbs; /**< Coded Frame Size */
|
|
||||||
int FrameHeightInMbs; /**< Coded Frame Height */
|
|
||||||
int CurrPicIdx; /**< Output index of the current picture */
|
|
||||||
int field_pic_flag; /**< 0=frame picture, 1=field picture */
|
|
||||||
int bottom_field_flag; /**< 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
|
|
||||||
int second_field; /**< Second field of a complementary field pair */
|
|
||||||
// Bitstream data
|
|
||||||
unsigned int nBitstreamDataLen; /**< Number of bytes in bitstream data buffer */
|
|
||||||
const unsigned char *pBitstreamData; /**< Ptr to bitstream data for this picture (slice-layer) */
|
|
||||||
unsigned int nNumSlices; /**< Number of slices in this picture */
|
|
||||||
const unsigned int *pSliceDataOffsets; /**< nNumSlices entries, contains offset of each slice within the bitstream data buffer */
|
|
||||||
int ref_pic_flag; /**< This picture is a reference picture */
|
|
||||||
int intra_pic_flag; /**< This picture is entirely intra coded */
|
|
||||||
unsigned int Reserved[30]; /**< Reserved for future use */
|
|
||||||
// Codec-specific data
|
|
||||||
union {
|
|
||||||
CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */
|
|
||||||
CUVIDH264PICPARAMS h264;
|
|
||||||
CUVIDVC1PICPARAMS vc1;
|
|
||||||
CUVIDMPEG4PICPARAMS mpeg4;
|
|
||||||
CUVIDJPEGPICPARAMS jpeg;
|
|
||||||
CUVIDHEVCPICPARAMS hevc;
|
|
||||||
CUVIDVP8PICPARAMS vp8;
|
|
||||||
CUVIDVP9PICPARAMS vp9;
|
|
||||||
unsigned int CodecReserved[1024];
|
|
||||||
} CodecSpecific;
|
|
||||||
} CUVIDPICPARAMS;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDPROCPARAMS
|
|
||||||
* Picture Parameters for Postprocessing
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDPROCPARAMS
|
|
||||||
{
|
|
||||||
int progressive_frame; /**< Input is progressive (deinterlace_mode will be ignored) */
|
|
||||||
int second_field; /**< Output the second field (ignored if deinterlace mode is Weave) */
|
|
||||||
int top_field_first; /**< Input frame is top field first (1st field is top, 2nd field is bottom) */
|
|
||||||
int unpaired_field; /**< Input only contains one field (2nd field is invalid) */
|
|
||||||
// The fields below are used for raw YUV input
|
|
||||||
unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
|
|
||||||
unsigned int reserved_zero; /**< Reserved (set to zero) */
|
|
||||||
unsigned long long raw_input_dptr; /**< Input CUdeviceptr for raw YUV extensions */
|
|
||||||
unsigned int raw_input_pitch; /**< pitch in bytes of raw YUV input (should be aligned appropriately) */
|
|
||||||
unsigned int raw_input_format; /**< Reserved for future use (set to zero) */
|
|
||||||
unsigned long long raw_output_dptr; /**< Reserved for future use (set to zero) */
|
|
||||||
unsigned int raw_output_pitch; /**< Reserved for future use (set to zero) */
|
|
||||||
unsigned int Reserved[48];
|
|
||||||
void *Reserved3[3];
|
|
||||||
} CUVIDPROCPARAMS;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* In order to minimize decode latencies, there should be always at least 2 pictures in the decode
|
|
||||||
* queue at any time, in order to make sure that all decode engines are always busy.
|
|
||||||
*
|
|
||||||
* Overall data flow:
|
|
||||||
* - cuvidCreateDecoder(...)
|
|
||||||
* For each picture:
|
|
||||||
* - cuvidDecodePicture(N)
|
|
||||||
* - cuvidMapVideoFrame(N-4)
|
|
||||||
* - do some processing in cuda
|
|
||||||
* - cuvidUnmapVideoFrame(N-4)
|
|
||||||
* - cuvidDecodePicture(N+1)
|
|
||||||
* - cuvidMapVideoFrame(N-3)
|
|
||||||
* ...
|
|
||||||
* - cuvidDestroyDecoder(...)
|
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
* - When the cuda context is created from a D3D device, the D3D device must also be created
|
|
||||||
* with the D3DCREATE_MULTITHREADED flag.
|
|
||||||
* - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
|
|
||||||
* - cuVidDecodePicture may block the calling thread if there are too many pictures pending
|
|
||||||
* in the decode queue
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
|
|
||||||
* Create the decoder object
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
|
|
||||||
* Destroy the decoder object
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
|
|
||||||
* Decode a single picture (field or frame)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
|
|
||||||
* Post-process and map a video frame for use in cuda
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
|
|
||||||
unsigned int *pDevPtr, unsigned int *pPitch,
|
|
||||||
CUVIDPROCPARAMS *pVPP);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
|
|
||||||
* Unmap a previously mapped video frame
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN64) || defined(_WIN64) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
|
|
||||||
* map a video frame
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
|
|
||||||
unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
|
|
||||||
* Unmap a previously mapped video frame
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
|
|
||||||
|
|
||||||
#if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
|
|
||||||
#define tcuvidMapVideoFrame tcuvidMapVideoFrame64
|
|
||||||
#define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Context-locking: to facilitate multi-threaded implementations, the following 4 functions
|
|
||||||
* provide a simple mutex-style host synchronization. If a non-NULL context is specified
|
|
||||||
* in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
|
|
||||||
* context before making any cuda calls.
|
|
||||||
* A multi-threaded application could create a lock associated with a context handle so that
|
|
||||||
* multiple threads can safely share the same cuda context:
|
|
||||||
* - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
|
|
||||||
* that can be passed to cuvidCtxLockCreate.
|
|
||||||
* - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
|
|
||||||
*
|
|
||||||
* NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
|
|
||||||
* decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
|
|
||||||
|
|
||||||
/** @} */ /* End VIDEO_DECODER */
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif // __CUDA_VIDEO_H__
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
/*
|
|
||||||
* This copyright notice applies to this header file only:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use,
|
|
||||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the software, and to permit persons to whom the
|
|
||||||
* software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AV_COMPAT_CUDA_DYNLINK_LOADER_H
|
|
||||||
#define AV_COMPAT_CUDA_DYNLINK_LOADER_H
|
|
||||||
|
|
||||||
#include "compat/cuda/dynlink_cuda.h"
|
|
||||||
#include "compat/cuda/dynlink_nvcuvid.h"
|
|
||||||
#include "compat/nvenc/nvEncodeAPI.h"
|
|
||||||
#include "compat/w32dlfcn.h"
|
|
||||||
|
|
||||||
#include "libavutil/log.h"
|
|
||||||
#include "libavutil/error.h"
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
# define LIB_HANDLE HMODULE
|
|
||||||
#else
|
|
||||||
# define LIB_HANDLE void*
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
||||||
# define CUDA_LIBNAME "nvcuda.dll"
|
|
||||||
# define NVCUVID_LIBNAME "nvcuvid.dll"
|
|
||||||
# if ARCH_X86_64
|
|
||||||
# define NVENC_LIBNAME "nvEncodeAPI64.dll"
|
|
||||||
# else
|
|
||||||
# define NVENC_LIBNAME "nvEncodeAPI.dll"
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define CUDA_LIBNAME "libcuda.so.1"
|
|
||||||
# define NVCUVID_LIBNAME "libnvcuvid.so.1"
|
|
||||||
# define NVENC_LIBNAME "libnvidia-encode.so.1"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOAD_LIBRARY(l, path) \
|
|
||||||
do { \
|
|
||||||
if (!((l) = dlopen(path, RTLD_LAZY))) { \
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", path); \
|
|
||||||
ret = AVERROR_UNKNOWN; \
|
|
||||||
goto error; \
|
|
||||||
} \
|
|
||||||
av_log(NULL, AV_LOG_TRACE, "Loaded lib: %s\n", path); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define LOAD_SYMBOL(fun, symbol) \
|
|
||||||
do { \
|
|
||||||
if (!((f->fun) = dlsym(f->lib, symbol))) { \
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
|
|
||||||
ret = AVERROR_UNKNOWN; \
|
|
||||||
goto error; \
|
|
||||||
} \
|
|
||||||
av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N) \
|
|
||||||
T *f; \
|
|
||||||
int ret; \
|
|
||||||
\
|
|
||||||
n##_free_functions(functions); \
|
|
||||||
\
|
|
||||||
f = *functions = av_mallocz(sizeof(*f)); \
|
|
||||||
if (!f) \
|
|
||||||
return AVERROR(ENOMEM); \
|
|
||||||
\
|
|
||||||
LOAD_LIBRARY(f->lib, N);
|
|
||||||
|
|
||||||
#define GENERIC_LOAD_FUNC_FINALE(n) \
|
|
||||||
return 0; \
|
|
||||||
error: \
|
|
||||||
n##_free_functions(functions); \
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
#define GENERIC_FREE_FUNC() \
|
|
||||||
if (!functions) \
|
|
||||||
return; \
|
|
||||||
if (*functions && (*functions)->lib) \
|
|
||||||
dlclose((*functions)->lib); \
|
|
||||||
av_freep(functions);
|
|
||||||
|
|
||||||
#ifdef AV_COMPAT_DYNLINK_CUDA_H
|
|
||||||
typedef struct CudaFunctions {
|
|
||||||
tcuInit *cuInit;
|
|
||||||
tcuDeviceGetCount *cuDeviceGetCount;
|
|
||||||
tcuDeviceGet *cuDeviceGet;
|
|
||||||
tcuDeviceGetName *cuDeviceGetName;
|
|
||||||
tcuDeviceComputeCapability *cuDeviceComputeCapability;
|
|
||||||
tcuCtxCreate_v2 *cuCtxCreate;
|
|
||||||
tcuCtxPushCurrent_v2 *cuCtxPushCurrent;
|
|
||||||
tcuCtxPopCurrent_v2 *cuCtxPopCurrent;
|
|
||||||
tcuCtxDestroy_v2 *cuCtxDestroy;
|
|
||||||
tcuMemAlloc_v2 *cuMemAlloc;
|
|
||||||
tcuMemFree_v2 *cuMemFree;
|
|
||||||
tcuMemcpy2D_v2 *cuMemcpy2D;
|
|
||||||
tcuGetErrorName *cuGetErrorName;
|
|
||||||
tcuGetErrorString *cuGetErrorString;
|
|
||||||
|
|
||||||
LIB_HANDLE lib;
|
|
||||||
} CudaFunctions;
|
|
||||||
#else
|
|
||||||
typedef struct CudaFunctions CudaFunctions;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct CuvidFunctions {
|
|
||||||
tcuvidCreateDecoder *cuvidCreateDecoder;
|
|
||||||
tcuvidDestroyDecoder *cuvidDestroyDecoder;
|
|
||||||
tcuvidDecodePicture *cuvidDecodePicture;
|
|
||||||
tcuvidMapVideoFrame *cuvidMapVideoFrame;
|
|
||||||
tcuvidUnmapVideoFrame *cuvidUnmapVideoFrame;
|
|
||||||
tcuvidCtxLockCreate *cuvidCtxLockCreate;
|
|
||||||
tcuvidCtxLockDestroy *cuvidCtxLockDestroy;
|
|
||||||
tcuvidCtxLock *cuvidCtxLock;
|
|
||||||
tcuvidCtxUnlock *cuvidCtxUnlock;
|
|
||||||
|
|
||||||
tcuvidCreateVideoSource *cuvidCreateVideoSource;
|
|
||||||
tcuvidCreateVideoSourceW *cuvidCreateVideoSourceW;
|
|
||||||
tcuvidDestroyVideoSource *cuvidDestroyVideoSource;
|
|
||||||
tcuvidSetVideoSourceState *cuvidSetVideoSourceState;
|
|
||||||
tcuvidGetVideoSourceState *cuvidGetVideoSourceState;
|
|
||||||
tcuvidGetSourceVideoFormat *cuvidGetSourceVideoFormat;
|
|
||||||
tcuvidGetSourceAudioFormat *cuvidGetSourceAudioFormat;
|
|
||||||
tcuvidCreateVideoParser *cuvidCreateVideoParser;
|
|
||||||
tcuvidParseVideoData *cuvidParseVideoData;
|
|
||||||
tcuvidDestroyVideoParser *cuvidDestroyVideoParser;
|
|
||||||
|
|
||||||
LIB_HANDLE lib;
|
|
||||||
} CuvidFunctions;
|
|
||||||
|
|
||||||
typedef struct NvencFunctions {
|
|
||||||
NVENCSTATUS (NVENCAPI *NvEncodeAPICreateInstance)(NV_ENCODE_API_FUNCTION_LIST *functionList);
|
|
||||||
NVENCSTATUS (NVENCAPI *NvEncodeAPIGetMaxSupportedVersion)(uint32_t* version);
|
|
||||||
|
|
||||||
LIB_HANDLE lib;
|
|
||||||
} NvencFunctions;
|
|
||||||
|
|
||||||
#ifdef AV_COMPAT_DYNLINK_CUDA_H
|
|
||||||
static inline void cuda_free_functions(CudaFunctions **functions)
|
|
||||||
{
|
|
||||||
GENERIC_FREE_FUNC();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void cuvid_free_functions(CuvidFunctions **functions)
|
|
||||||
{
|
|
||||||
GENERIC_FREE_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void nvenc_free_functions(NvencFunctions **functions)
|
|
||||||
{
|
|
||||||
GENERIC_FREE_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef AV_COMPAT_DYNLINK_CUDA_H
|
|
||||||
static inline int cuda_load_functions(CudaFunctions **functions)
|
|
||||||
{
|
|
||||||
GENERIC_LOAD_FUNC_PREAMBLE(CudaFunctions, cuda, CUDA_LIBNAME);
|
|
||||||
|
|
||||||
LOAD_SYMBOL(cuInit, "cuInit");
|
|
||||||
LOAD_SYMBOL(cuDeviceGetCount, "cuDeviceGetCount");
|
|
||||||
LOAD_SYMBOL(cuDeviceGet, "cuDeviceGet");
|
|
||||||
LOAD_SYMBOL(cuDeviceGetName, "cuDeviceGetName");
|
|
||||||
LOAD_SYMBOL(cuDeviceComputeCapability, "cuDeviceComputeCapability");
|
|
||||||
LOAD_SYMBOL(cuCtxCreate, "cuCtxCreate_v2");
|
|
||||||
LOAD_SYMBOL(cuCtxPushCurrent, "cuCtxPushCurrent_v2");
|
|
||||||
LOAD_SYMBOL(cuCtxPopCurrent, "cuCtxPopCurrent_v2");
|
|
||||||
LOAD_SYMBOL(cuCtxDestroy, "cuCtxDestroy_v2");
|
|
||||||
LOAD_SYMBOL(cuMemAlloc, "cuMemAlloc_v2");
|
|
||||||
LOAD_SYMBOL(cuMemFree, "cuMemFree_v2");
|
|
||||||
LOAD_SYMBOL(cuMemcpy2D, "cuMemcpy2D_v2");
|
|
||||||
LOAD_SYMBOL(cuGetErrorName, "cuGetErrorName");
|
|
||||||
LOAD_SYMBOL(cuGetErrorString, "cuGetErrorString");
|
|
||||||
|
|
||||||
GENERIC_LOAD_FUNC_FINALE(cuda);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline int cuvid_load_functions(CuvidFunctions **functions)
|
|
||||||
{
|
|
||||||
GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
|
|
||||||
|
|
||||||
LOAD_SYMBOL(cuvidCreateDecoder, "cuvidCreateDecoder");
|
|
||||||
LOAD_SYMBOL(cuvidDestroyDecoder, "cuvidDestroyDecoder");
|
|
||||||
LOAD_SYMBOL(cuvidDecodePicture, "cuvidDecodePicture");
|
|
||||||
#ifdef __CUVID_DEVPTR64
|
|
||||||
LOAD_SYMBOL(cuvidMapVideoFrame, "cuvidMapVideoFrame64");
|
|
||||||
LOAD_SYMBOL(cuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64");
|
|
||||||
#else
|
|
||||||
LOAD_SYMBOL(cuvidMapVideoFrame, "cuvidMapVideoFrame");
|
|
||||||
LOAD_SYMBOL(cuvidUnmapVideoFrame, "cuvidUnmapVideoFrame");
|
|
||||||
#endif
|
|
||||||
LOAD_SYMBOL(cuvidCtxLockCreate, "cuvidCtxLockCreate");
|
|
||||||
LOAD_SYMBOL(cuvidCtxLockDestroy, "cuvidCtxLockDestroy");
|
|
||||||
LOAD_SYMBOL(cuvidCtxLock, "cuvidCtxLock");
|
|
||||||
LOAD_SYMBOL(cuvidCtxUnlock, "cuvidCtxUnlock");
|
|
||||||
|
|
||||||
LOAD_SYMBOL(cuvidCreateVideoSource, "cuvidCreateVideoSource");
|
|
||||||
LOAD_SYMBOL(cuvidCreateVideoSourceW, "cuvidCreateVideoSourceW");
|
|
||||||
LOAD_SYMBOL(cuvidDestroyVideoSource, "cuvidDestroyVideoSource");
|
|
||||||
LOAD_SYMBOL(cuvidSetVideoSourceState, "cuvidSetVideoSourceState");
|
|
||||||
LOAD_SYMBOL(cuvidGetVideoSourceState, "cuvidGetVideoSourceState");
|
|
||||||
LOAD_SYMBOL(cuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat");
|
|
||||||
LOAD_SYMBOL(cuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat");
|
|
||||||
LOAD_SYMBOL(cuvidCreateVideoParser, "cuvidCreateVideoParser");
|
|
||||||
LOAD_SYMBOL(cuvidParseVideoData, "cuvidParseVideoData");
|
|
||||||
LOAD_SYMBOL(cuvidDestroyVideoParser, "cuvidDestroyVideoParser");
|
|
||||||
|
|
||||||
GENERIC_LOAD_FUNC_FINALE(cuvid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int nvenc_load_functions(NvencFunctions **functions)
|
|
||||||
{
|
|
||||||
GENERIC_LOAD_FUNC_PREAMBLE(NvencFunctions, nvenc, NVENC_LIBNAME);
|
|
||||||
|
|
||||||
LOAD_SYMBOL(NvEncodeAPICreateInstance, "NvEncodeAPICreateInstance");
|
|
||||||
LOAD_SYMBOL(NvEncodeAPIGetMaxSupportedVersion, "NvEncodeAPIGetMaxSupportedVersion");
|
|
||||||
|
|
||||||
GENERIC_LOAD_FUNC_FINALE(nvenc);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef GENERIC_LOAD_FUNC_PREAMBLE
|
|
||||||
#undef LOAD_LIBRARY
|
|
||||||
#undef LOAD_SYMBOL
|
|
||||||
#undef GENERIC_LOAD_FUNC_FINALE
|
|
||||||
#undef GENERIC_FREE_FUNC
|
|
||||||
#undef CUDA_LIBNAME
|
|
||||||
#undef NVCUVID_LIBNAME
|
|
||||||
#undef NVENC_LIBNAME
|
|
||||||
#undef LIB_HANDLE
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,316 +0,0 @@
|
|||||||
/*
|
|
||||||
* This copyright notice applies to this header file only:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010-2016 NVIDIA Corporation
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use,
|
|
||||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the software, and to permit persons to whom the
|
|
||||||
* software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file nvcuvid.h
|
|
||||||
* NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
|
|
||||||
* \date 2015-2015
|
|
||||||
* This file contains the interface constants, structure definitions and function prototypes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(__NVCUVID_H__)
|
|
||||||
#define __NVCUVID_H__
|
|
||||||
|
|
||||||
#include "compat/cuda/dynlink_cuviddec.h"
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// High-level helper APIs for video sources
|
|
||||||
//
|
|
||||||
|
|
||||||
typedef void *CUvideosource;
|
|
||||||
typedef void *CUvideoparser;
|
|
||||||
typedef long long CUvideotimestamp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \addtogroup VIDEO_PARSER Video Parser
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaVideoState
|
|
||||||
* Video Source State
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
cudaVideoState_Error = -1, /**< Error state (invalid source) */
|
|
||||||
cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */
|
|
||||||
cudaVideoState_Started = 1 /**< Source is running and delivering data */
|
|
||||||
} cudaVideoState;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum cudaAudioCodec
|
|
||||||
* Audio compression
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */
|
|
||||||
cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */
|
|
||||||
cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */
|
|
||||||
cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */
|
|
||||||
cudaAudioCodec_LPCM /**< PCM Audio */
|
|
||||||
} cudaAudioCodec;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDEOFORMAT
|
|
||||||
* Video format
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
cudaVideoCodec codec; /**< Compression format */
|
|
||||||
/**
|
|
||||||
* frame rate = numerator / denominator (for example: 30000/1001)
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
unsigned int numerator; /**< frame rate numerator (0 = unspecified or variable frame rate) */
|
|
||||||
unsigned int denominator; /**< frame rate denominator (0 = unspecified or variable frame rate) */
|
|
||||||
} frame_rate;
|
|
||||||
unsigned char progressive_sequence; /**< 0=interlaced, 1=progressive */
|
|
||||||
unsigned char bit_depth_luma_minus8; /**< high bit depth Luma */
|
|
||||||
unsigned char bit_depth_chroma_minus8; /**< high bit depth Chroma */
|
|
||||||
unsigned char reserved1; /**< Reserved for future use */
|
|
||||||
unsigned int coded_width; /**< coded frame width */
|
|
||||||
unsigned int coded_height; /**< coded frame height */
|
|
||||||
/**
|
|
||||||
* area of the frame that should be displayed
|
|
||||||
* typical example:
|
|
||||||
* coded_width = 1920, coded_height = 1088
|
|
||||||
* display_area = { 0,0,1920,1080 }
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
int left; /**< left position of display rect */
|
|
||||||
int top; /**< top position of display rect */
|
|
||||||
int right; /**< right position of display rect */
|
|
||||||
int bottom; /**< bottom position of display rect */
|
|
||||||
} display_area;
|
|
||||||
cudaVideoChromaFormat chroma_format; /**< Chroma format */
|
|
||||||
unsigned int bitrate; /**< video bitrate (bps, 0=unknown) */
|
|
||||||
/**
|
|
||||||
* Display Aspect Ratio = x:y (4:3, 16:9, etc)
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
} display_aspect_ratio;
|
|
||||||
/**
|
|
||||||
* Video Signal Description
|
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
unsigned char video_format : 3;
|
|
||||||
unsigned char video_full_range_flag : 1;
|
|
||||||
unsigned char reserved_zero_bits : 4;
|
|
||||||
unsigned char color_primaries;
|
|
||||||
unsigned char transfer_characteristics;
|
|
||||||
unsigned char matrix_coefficients;
|
|
||||||
} video_signal_description;
|
|
||||||
unsigned int seqhdr_data_length; /**< Additional bytes following (CUVIDEOFORMATEX) */
|
|
||||||
} CUVIDEOFORMAT;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDEOFORMATEX
|
|
||||||
* Video format including raw sequence header information
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
CUVIDEOFORMAT format;
|
|
||||||
unsigned char raw_seqhdr_data[1024];
|
|
||||||
} CUVIDEOFORMATEX;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUAUDIOFORMAT
|
|
||||||
* Audio Formats
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
cudaAudioCodec codec; /**< Compression format */
|
|
||||||
unsigned int channels; /**< number of audio channels */
|
|
||||||
unsigned int samplespersec; /**< sampling frequency */
|
|
||||||
unsigned int bitrate; /**< For uncompressed, can also be used to determine bits per sample */
|
|
||||||
unsigned int reserved1; /**< Reserved for future use */
|
|
||||||
unsigned int reserved2; /**< Reserved for future use */
|
|
||||||
} CUAUDIOFORMAT;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum CUvideopacketflags
|
|
||||||
* Data packet flags
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */
|
|
||||||
CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
|
|
||||||
CUVID_PKT_DISCONTINUITY = 0x04 /**< Set when a discontinuity has to be signalled */
|
|
||||||
} CUvideopacketflags;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDSOURCEDATAPACKET
|
|
||||||
* Data Packet
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDSOURCEDATAPACKET
|
|
||||||
{
|
|
||||||
tcu_ulong flags; /**< Combination of CUVID_PKT_XXX flags */
|
|
||||||
tcu_ulong payload_size; /**< number of bytes in the payload (may be zero if EOS flag is set) */
|
|
||||||
const unsigned char *payload; /**< Pointer to packet payload data (may be NULL if EOS flag is set) */
|
|
||||||
CUvideotimestamp timestamp; /**< Presentation timestamp (10MHz clock), only valid if CUVID_PKT_TIMESTAMP flag is set */
|
|
||||||
} CUVIDSOURCEDATAPACKET;
|
|
||||||
|
|
||||||
// Callback for packet delivery
|
|
||||||
typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \struct CUVIDSOURCEPARAMS
|
|
||||||
* Source Params
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDSOURCEPARAMS
|
|
||||||
{
|
|
||||||
unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
|
|
||||||
unsigned int uReserved1[7]; /**< Reserved for future use - set to zero */
|
|
||||||
void *pUserData; /**< Parameter passed in to the data handlers */
|
|
||||||
PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< Called to deliver audio packets */
|
|
||||||
PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< Called to deliver video packets */
|
|
||||||
void *pvReserved2[8]; /**< Reserved for future use - set to NULL */
|
|
||||||
} CUVIDSOURCEPARAMS;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \enum CUvideosourceformat_flags
|
|
||||||
* CUvideosourceformat_flags
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */
|
|
||||||
} CUvideosourceformat_flags;
|
|
||||||
|
|
||||||
#if !defined(__APPLE__)
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
|
|
||||||
* Create Video Source
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
|
|
||||||
* Create Video Source
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)
|
|
||||||
* Destroy Video Source
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
|
|
||||||
* Set Video Source state
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)
|
|
||||||
* Get Video Source state
|
|
||||||
*/
|
|
||||||
typedef cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
|
|
||||||
* Get Video Source Format
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
|
|
||||||
* Set Video Source state
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct CUVIDPARSERDISPINFO
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDPARSERDISPINFO
|
|
||||||
{
|
|
||||||
int picture_index; /**< */
|
|
||||||
int progressive_frame; /**< */
|
|
||||||
int top_field_first; /**< */
|
|
||||||
int repeat_first_field; /**< Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) */
|
|
||||||
CUvideotimestamp timestamp; /**< */
|
|
||||||
} CUVIDPARSERDISPINFO;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Parser callbacks
|
|
||||||
// The parser will call these synchronously from within cuvidParseVideoData(), whenever a picture is ready to
|
|
||||||
// be decoded and/or displayed.
|
|
||||||
//
|
|
||||||
typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *);
|
|
||||||
typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *);
|
|
||||||
typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \struct CUVIDPARSERPARAMS
|
|
||||||
*/
|
|
||||||
typedef struct _CUVIDPARSERPARAMS
|
|
||||||
{
|
|
||||||
cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
|
|
||||||
unsigned int ulMaxNumDecodeSurfaces; /**< Max # of decode surfaces (parser will cycle through these) */
|
|
||||||
unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
|
|
||||||
unsigned int ulErrorThreshold; /**< % Error threshold (0-100) for calling pfnDecodePicture (100=always call pfnDecodePicture even if picture bitstream is fully corrupted) */
|
|
||||||
unsigned int ulMaxDisplayDelay; /**< Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values: 2..4) */
|
|
||||||
unsigned int uReserved1[5]; /**< Reserved for future use - set to 0 */
|
|
||||||
void *pUserData; /**< User data for callbacks */
|
|
||||||
PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< Called before decoding frames and/or whenever there is a format change */
|
|
||||||
PFNVIDDECODECALLBACK pfnDecodePicture; /**< Called when a picture is ready to be decoded (decode order) */
|
|
||||||
PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< Called whenever a picture is ready to be displayed (display order) */
|
|
||||||
void *pvReserved2[7]; /**< Reserved for future use - set to NULL */
|
|
||||||
CUVIDEOFORMATEX *pExtVideoInfo; /**< [Optional] sequence header data from system layer */
|
|
||||||
} CUVIDPARSERPARAMS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)
|
|
||||||
*/
|
|
||||||
typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj);
|
|
||||||
|
|
||||||
/** @} */ /* END VIDEO_PARSER */
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif // __NVCUVID_H__
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H
|
|
||||||
#define COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H
|
|
||||||
|
|
||||||
#include <dispatch/dispatch.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#define sem_t dispatch_semaphore_t
|
|
||||||
#define sem_post(psem) dispatch_semaphore_signal(*psem)
|
|
||||||
#define sem_wait(psem) dispatch_semaphore_wait(*psem, DISPATCH_TIME_FOREVER)
|
|
||||||
#define sem_timedwait(psem, val) dispatch_semaphore_wait(*psem, dispatch_walltime(val, 0))
|
|
||||||
#define sem_destroy(psem) dispatch_release(*psem)
|
|
||||||
|
|
||||||
static inline int compat_sem_init(dispatch_semaphore_t *psem,
|
|
||||||
int unused, int val)
|
|
||||||
{
|
|
||||||
int ret = !!(*psem = dispatch_semaphore_create(val)) - 1;
|
|
||||||
if (ret < 0)
|
|
||||||
errno = ENOMEM;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define sem_init compat_sem_init
|
|
||||||
|
|
||||||
#endif /* COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H */
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Work around broken floating point limits on some systems.
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <float.h>
|
|
||||||
|
|
||||||
#ifdef FLT_MAX
|
|
||||||
#undef FLT_MAX
|
|
||||||
#define FLT_MAX 3.40282346638528859812e+38F
|
|
||||||
|
|
||||||
#undef FLT_MIN
|
|
||||||
#define FLT_MIN 1.17549435082228750797e-38F
|
|
||||||
|
|
||||||
#undef DBL_MAX
|
|
||||||
#define DBL_MAX ((double)1.79769313486231570815e+308L)
|
|
||||||
|
|
||||||
#undef DBL_MIN
|
|
||||||
#define DBL_MIN ((double)2.22507385850720138309e-308L)
|
|
||||||
#endif
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Work around broken floating point limits on some systems.
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include_next <limits.h>
|
|
||||||
#include <float.h>
|
|
||||||
@@ -38,6 +38,8 @@ static int optind = 1;
|
|||||||
static int optopt;
|
static int optopt;
|
||||||
static char *optarg;
|
static char *optarg;
|
||||||
|
|
||||||
|
#undef fprintf
|
||||||
|
|
||||||
static int getopt(int argc, char *argv[], char *opts)
|
static int getopt(int argc, char *argv[], char *opts)
|
||||||
{
|
{
|
||||||
static int sp = 1;
|
static int sp = 1;
|
||||||
@@ -54,7 +56,7 @@ static int getopt(int argc, char *argv[], char *opts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
optopt = c = argv[optind][sp];
|
optopt = c = argv[optind][sp];
|
||||||
if (c == ':' || !(cp = strchr(opts, c))) {
|
if (c == ':' || (cp = strchr(opts, c)) == NULL) {
|
||||||
fprintf(stderr, ": illegal option -- %c\n", c);
|
fprintf(stderr, ": illegal option -- %c\n", c);
|
||||||
if (argv[optind][++sp] == '\0') {
|
if (argv[optind][++sp] == '\0') {
|
||||||
optind++;
|
optind++;
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMPAT_MSVCRT_SNPRINTF_H
|
#ifndef COMPAT_SNPRINTF_H
|
||||||
#define COMPAT_MSVCRT_SNPRINTF_H
|
#define COMPAT_SNPRINTF_H
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -35,4 +35,4 @@ int avpriv_vsnprintf(char *s, size_t n, const char *fmt, va_list ap);
|
|||||||
#define _snprintf avpriv_snprintf
|
#define _snprintf avpriv_snprintf
|
||||||
#define vsnprintf avpriv_vsnprintf
|
#define vsnprintf avpriv_vsnprintf
|
||||||
|
|
||||||
#endif /* COMPAT_MSVCRT_SNPRINTF_H */
|
#endif /* COMPAT_SNPRINTF_H */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,201 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 KO Myung-Hun <komh@chollian.net>
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* os2threads to pthreads wrapper
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_OS2THREADS_H
|
|
||||||
#define COMPAT_OS2THREADS_H
|
|
||||||
|
|
||||||
#define INCL_DOS
|
|
||||||
#include <os2.h>
|
|
||||||
|
|
||||||
#undef __STRICT_ANSI__ /* for _beginthread() */
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <sys/builtin.h>
|
|
||||||
#include <sys/fmutex.h>
|
|
||||||
|
|
||||||
#include "libavutil/attributes.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
TID tid;
|
|
||||||
void *(*start_routine)(void *);
|
|
||||||
void *arg;
|
|
||||||
void *result;
|
|
||||||
} pthread_t;
|
|
||||||
|
|
||||||
typedef void pthread_attr_t;
|
|
||||||
|
|
||||||
typedef HMTX pthread_mutex_t;
|
|
||||||
typedef void pthread_mutexattr_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
HEV event_sem;
|
|
||||||
HEV ack_sem;
|
|
||||||
volatile unsigned wait_count;
|
|
||||||
} pthread_cond_t;
|
|
||||||
|
|
||||||
typedef void pthread_condattr_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
volatile int done;
|
|
||||||
_fmutex mtx;
|
|
||||||
} pthread_once_t;
|
|
||||||
|
|
||||||
#define PTHREAD_ONCE_INIT {0, _FMUTEX_INITIALIZER}
|
|
||||||
|
|
||||||
static void thread_entry(void *arg)
|
|
||||||
{
|
|
||||||
pthread_t *thread = arg;
|
|
||||||
|
|
||||||
thread->result = thread->start_routine(thread->arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_create(pthread_t *thread,
|
|
||||||
const pthread_attr_t *attr,
|
|
||||||
void *(*start_routine)(void*),
|
|
||||||
void *arg)
|
|
||||||
{
|
|
||||||
thread->start_routine = start_routine;
|
|
||||||
thread->arg = arg;
|
|
||||||
thread->result = NULL;
|
|
||||||
|
|
||||||
thread->tid = _beginthread(thread_entry, NULL, 1024 * 1024, thread);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
|
|
||||||
{
|
|
||||||
DosWaitThread(&thread.tid, DCWW_WAIT);
|
|
||||||
|
|
||||||
if (value_ptr)
|
|
||||||
*value_ptr = thread.result;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex,
|
|
||||||
const pthread_mutexattr_t *attr)
|
|
||||||
{
|
|
||||||
DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
DosCloseMutexSem(*(PHMTX)mutex);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
DosRequestMutexSem(*(PHMTX)mutex, SEM_INDEFINITE_WAIT);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
DosReleaseMutexSem(*(PHMTX)mutex);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_init(pthread_cond_t *cond,
|
|
||||||
const pthread_condattr_t *attr)
|
|
||||||
{
|
|
||||||
DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE);
|
|
||||||
DosCreateEventSem(NULL, &cond->ack_sem, DCE_POSTONE, FALSE);
|
|
||||||
|
|
||||||
cond->wait_count = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
DosCloseEventSem(cond->event_sem);
|
|
||||||
DosCloseEventSem(cond->ack_sem);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
if (!__atomic_cmpxchg32(&cond->wait_count, 0, 0)) {
|
|
||||||
DosPostEventSem(cond->event_sem);
|
|
||||||
DosWaitEventSem(cond->ack_sem, SEM_INDEFINITE_WAIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
while (!__atomic_cmpxchg32(&cond->wait_count, 0, 0))
|
|
||||||
pthread_cond_signal(cond);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond,
|
|
||||||
pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
__atomic_increment(&cond->wait_count);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(mutex);
|
|
||||||
|
|
||||||
DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT);
|
|
||||||
|
|
||||||
__atomic_decrement(&cond->wait_count);
|
|
||||||
|
|
||||||
DosPostEventSem(cond->ack_sem);
|
|
||||||
|
|
||||||
pthread_mutex_lock(mutex);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_always_inline int pthread_once(pthread_once_t *once_control,
|
|
||||||
void (*init_routine)(void))
|
|
||||||
{
|
|
||||||
if (!once_control->done)
|
|
||||||
{
|
|
||||||
_fmutex_request(&once_control->mtx, 0);
|
|
||||||
|
|
||||||
if (!once_control->done)
|
|
||||||
{
|
|
||||||
init_routine();
|
|
||||||
|
|
||||||
once_control->done = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fmutex_release(&once_control->mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* COMPAT_OS2THREADS_H */
|
|
||||||
@@ -1,352 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
# make_sunver.pl
|
|
||||||
#
|
|
||||||
# Copyright (C) 2010, 2011, 2012, 2013
|
|
||||||
# Free Software Foundation, Inc.
|
|
||||||
#
|
|
||||||
# This file is free software; you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but
|
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; see the file COPYING.GPLv3. If not see
|
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# This script takes at least two arguments, a GNU style version script and
|
|
||||||
# a list of object and archive files, and generates a corresponding Sun
|
|
||||||
# style version script as follows:
|
|
||||||
#
|
|
||||||
# Each glob pattern, C++ mangled pattern or literal in the input script is
|
|
||||||
# matched against all global symbols in the input objects, emitting those
|
|
||||||
# that matched (or nothing if no match was found).
|
|
||||||
# A comment with the original pattern and its type is left in the output
|
|
||||||
# file to make it easy to understand the matches.
|
|
||||||
#
|
|
||||||
# It uses elfdump when present (native), GNU readelf otherwise.
|
|
||||||
# It depends on the GNU version of c++filt, since it must understand the
|
|
||||||
# GNU mangling style.
|
|
||||||
|
|
||||||
use FileHandle;
|
|
||||||
use IPC::Open2;
|
|
||||||
|
|
||||||
# Enforce C locale.
|
|
||||||
$ENV{'LC_ALL'} = "C";
|
|
||||||
$ENV{'LANG'} = "C";
|
|
||||||
|
|
||||||
# Input version script, GNU style.
|
|
||||||
my $symvers = shift;
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Get all the symbols from the library, match them, and add them to a hash.
|
|
||||||
|
|
||||||
my %sym_hash = ();
|
|
||||||
|
|
||||||
# List of objects and archives to process.
|
|
||||||
my @OBJECTS = ();
|
|
||||||
|
|
||||||
# List of shared objects to omit from processing.
|
|
||||||
my @SHAREDOBJS = ();
|
|
||||||
|
|
||||||
# Filter out those input archives that have corresponding shared objects to
|
|
||||||
# avoid adding all symbols matched in the archive to the output map.
|
|
||||||
foreach $file (@ARGV) {
|
|
||||||
if (($so = $file) =~ s/\.a$/.so/ && -e $so) {
|
|
||||||
printf STDERR "omitted $file -> $so\n";
|
|
||||||
push (@SHAREDOBJS, $so);
|
|
||||||
} else {
|
|
||||||
push (@OBJECTS, $file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# We need to detect and ignore hidden symbols. Solaris nm can only detect
|
|
||||||
# this in the harder to parse default output format, and GNU nm not at all,
|
|
||||||
# so use elfdump -s in the native case and GNU readelf -s otherwise.
|
|
||||||
# GNU objdump -t cannot be used since it produces a variable number of
|
|
||||||
# columns.
|
|
||||||
|
|
||||||
# The path to elfdump.
|
|
||||||
my $elfdump = "/usr/ccs/bin/elfdump";
|
|
||||||
|
|
||||||
if (-f $elfdump) {
|
|
||||||
open ELFDUMP,$elfdump.' -s '.(join ' ',@OBJECTS).'|' or die $!;
|
|
||||||
my $skip_arsym = 0;
|
|
||||||
|
|
||||||
while (<ELFDUMP>) {
|
|
||||||
chomp;
|
|
||||||
|
|
||||||
# Ignore empty lines.
|
|
||||||
if (/^$/) {
|
|
||||||
# End of archive symbol table, stop skipping.
|
|
||||||
$skip_arsym = 0 if $skip_arsym;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Keep skipping until end of archive symbol table.
|
|
||||||
next if ($skip_arsym);
|
|
||||||
|
|
||||||
# Ignore object name header for individual objects and archives.
|
|
||||||
next if (/:$/);
|
|
||||||
|
|
||||||
# Ignore table header lines.
|
|
||||||
next if (/^Symbol Table Section:/);
|
|
||||||
next if (/index.*value.*size/);
|
|
||||||
|
|
||||||
# Start of archive symbol table: start skipping.
|
|
||||||
if (/^Symbol Table: \(archive/) {
|
|
||||||
$skip_arsym = 1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Split table.
|
|
||||||
(undef, undef, undef, undef, $bind, $oth, undef, $shndx, $name) = split;
|
|
||||||
|
|
||||||
# Error out for unknown input.
|
|
||||||
die "unknown input line:\n$_" unless defined($bind);
|
|
||||||
|
|
||||||
# Ignore local symbols.
|
|
||||||
next if ($bind eq "LOCL");
|
|
||||||
# Ignore hidden symbols.
|
|
||||||
next if ($oth eq "H");
|
|
||||||
# Ignore undefined symbols.
|
|
||||||
next if ($shndx eq "UNDEF");
|
|
||||||
# Error out for unhandled cases.
|
|
||||||
if ($bind !~ /^(GLOB|WEAK)/ or $oth ne "D") {
|
|
||||||
die "unhandled symbol:\n$_";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remember symbol.
|
|
||||||
$sym_hash{$name}++;
|
|
||||||
}
|
|
||||||
close ELFDUMP or die "$elfdump error";
|
|
||||||
} else {
|
|
||||||
open READELF, 'readelf -s -W '.(join ' ',@OBJECTS).'|' or die $!;
|
|
||||||
# Process each symbol.
|
|
||||||
while (<READELF>) {
|
|
||||||
chomp;
|
|
||||||
|
|
||||||
# Ignore empty lines.
|
|
||||||
next if (/^$/);
|
|
||||||
|
|
||||||
# Ignore object name header.
|
|
||||||
next if (/^File: .*$/);
|
|
||||||
|
|
||||||
# Ignore table header lines.
|
|
||||||
next if (/^Symbol table.*contains.*:/);
|
|
||||||
next if (/Num:.*Value.*Size/);
|
|
||||||
|
|
||||||
# Split table.
|
|
||||||
(undef, undef, undef, undef, $bind, $vis, $ndx, $name) = split;
|
|
||||||
|
|
||||||
# Error out for unknown input.
|
|
||||||
die "unknown input line:\n$_" unless defined($bind);
|
|
||||||
|
|
||||||
# Ignore local symbols.
|
|
||||||
next if ($bind eq "LOCAL");
|
|
||||||
# Ignore hidden symbols.
|
|
||||||
next if ($vis eq "HIDDEN");
|
|
||||||
# Ignore undefined symbols.
|
|
||||||
next if ($ndx eq "UND");
|
|
||||||
# Error out for unhandled cases.
|
|
||||||
if ($bind !~ /^(GLOBAL|WEAK)/ or $vis ne "DEFAULT") {
|
|
||||||
die "unhandled symbol:\n$_";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remember symbol.
|
|
||||||
$sym_hash{$name}++;
|
|
||||||
}
|
|
||||||
close READELF or die "readelf error";
|
|
||||||
}
|
|
||||||
|
|
||||||
##########
|
|
||||||
# The various types of glob patterns.
|
|
||||||
#
|
|
||||||
# A glob pattern that is to be applied to the demangled name: 'cxx'.
|
|
||||||
# A glob patterns that applies directly to the name in the .o files: 'glob'.
|
|
||||||
# This pattern is ignored; used for local variables (usually just '*'): 'ign'.
|
|
||||||
|
|
||||||
# The type of the current pattern.
|
|
||||||
my $glob = 'glob';
|
|
||||||
|
|
||||||
# We're currently inside `extern "C++"', which Sun ld doesn't understand.
|
|
||||||
my $in_extern = 0;
|
|
||||||
|
|
||||||
# The c++filt command to use. This *must* be GNU c++filt; the Sun Studio
|
|
||||||
# c++filt doesn't handle the GNU mangling style.
|
|
||||||
my $cxxfilt = $ENV{'CXXFILT'} || "c++filt";
|
|
||||||
|
|
||||||
# The current version name.
|
|
||||||
my $current_version = "";
|
|
||||||
|
|
||||||
# Was there any attempt to match a symbol to this version?
|
|
||||||
my $matches_attempted;
|
|
||||||
|
|
||||||
# The number of versions which matched this symbol.
|
|
||||||
my $matched_symbols;
|
|
||||||
|
|
||||||
open F,$symvers or die $!;
|
|
||||||
|
|
||||||
# Print information about generating this file
|
|
||||||
print "# This file was generated by make_sunver.pl. DO NOT EDIT!\n";
|
|
||||||
print "# It was generated by:\n";
|
|
||||||
printf "# %s %s %s\n", $0, $symvers, (join ' ',@ARGV);
|
|
||||||
printf "# Omitted archives with corresponding shared libraries: %s\n",
|
|
||||||
(join ' ', @SHAREDOBJS) if $#SHAREDOBJS >= 0;
|
|
||||||
print "#\n\n";
|
|
||||||
|
|
||||||
print "\$mapfile_version 2\n";
|
|
||||||
|
|
||||||
while (<F>) {
|
|
||||||
# Lines of the form '};'
|
|
||||||
if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) {
|
|
||||||
$glob = 'glob';
|
|
||||||
if ($in_extern) {
|
|
||||||
$in_extern--;
|
|
||||||
print "$1##$2\n";
|
|
||||||
} else {
|
|
||||||
print;
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Lines of the form '} SOME_VERSION_NAME_1.0;'
|
|
||||||
if (/^[ \t]*\}[ \tA-Z0-9_.a-z]+;[ \t]*$/) {
|
|
||||||
$glob = 'glob';
|
|
||||||
# We tried to match symbols agains this version, but none matched.
|
|
||||||
# Emit dummy hidden symbol to avoid marking this version WEAK.
|
|
||||||
if ($matches_attempted && $matched_symbols == 0) {
|
|
||||||
print " hidden:\n";
|
|
||||||
print " .force_WEAK_off_$current_version = DATA S0x0 V0x0;\n";
|
|
||||||
}
|
|
||||||
print; next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Comment and blank lines
|
|
||||||
if (/^[ \t]*\#/) { print; next; }
|
|
||||||
if (/^[ \t]*$/) { print; next; }
|
|
||||||
|
|
||||||
# Lines of the form '{'
|
|
||||||
if (/^([ \t]*){$/) {
|
|
||||||
if ($in_extern) {
|
|
||||||
print "$1##{\n";
|
|
||||||
} else {
|
|
||||||
print;
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Lines of the form 'SOME_VERSION_NAME_1.1 {'
|
|
||||||
if (/^([A-Z0-9_.]+)[ \t]+{$/) {
|
|
||||||
# Record version name.
|
|
||||||
$current_version = $1;
|
|
||||||
# Reset match attempts, #matched symbols for this version.
|
|
||||||
$matches_attempted = 0;
|
|
||||||
$matched_symbols = 0;
|
|
||||||
print "SYMBOL_VERSION $1 {\n";
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ignore 'global:'
|
|
||||||
if (/^[ \t]*global:$/) { print; next; }
|
|
||||||
|
|
||||||
# After 'local:', globs should be ignored, they won't be exported.
|
|
||||||
if (/^[ \t]*local:$/) {
|
|
||||||
$glob = 'ign';
|
|
||||||
print;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# After 'extern "C++"', globs are C++ patterns
|
|
||||||
if (/^([ \t]*)(extern \"C\+\+\"[ \t]*)$/) {
|
|
||||||
$in_extern++;
|
|
||||||
$glob = 'cxx';
|
|
||||||
# Need to comment, Sun ld cannot handle this.
|
|
||||||
print "$1##$2\n"; next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Chomp newline now we're done with passing through the input file.
|
|
||||||
chomp;
|
|
||||||
|
|
||||||
# Catch globs. Note that '{}' is not allowed in globs by this script,
|
|
||||||
# so only '*' and '[]' are available.
|
|
||||||
if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) {
|
|
||||||
my $ws = $1;
|
|
||||||
my $ptn = $2;
|
|
||||||
# Turn the glob into a regex by replacing '*' with '.*', '?' with '.'.
|
|
||||||
# Keep $ptn so we can still print the original form.
|
|
||||||
($pattern = $ptn) =~ s/\*/\.\*/g;
|
|
||||||
$pattern =~ s/\?/\./g;
|
|
||||||
|
|
||||||
if ($glob eq 'ign') {
|
|
||||||
# We're in a local: * section; just continue.
|
|
||||||
print "$_\n";
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print the glob commented for human readers.
|
|
||||||
print "$ws##$ptn ($glob)\n";
|
|
||||||
# We tried to match a symbol to this version.
|
|
||||||
$matches_attempted++;
|
|
||||||
|
|
||||||
if ($glob eq 'glob') {
|
|
||||||
my %ptn_syms = ();
|
|
||||||
|
|
||||||
# Match ptn against symbols in %sym_hash.
|
|
||||||
foreach my $sym (keys %sym_hash) {
|
|
||||||
# Maybe it matches one of the patterns based on the symbol in
|
|
||||||
# the .o file.
|
|
||||||
$ptn_syms{$sym}++ if ($sym =~ /^$pattern$/);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $sym (sort keys(%ptn_syms)) {
|
|
||||||
$matched_symbols++;
|
|
||||||
print "$ws$sym;\n";
|
|
||||||
}
|
|
||||||
} elsif ($glob eq 'cxx') {
|
|
||||||
my %dem_syms = ();
|
|
||||||
|
|
||||||
# Verify that we're actually using GNU c++filt. Other versions
|
|
||||||
# most likely cannot handle GNU style symbol mangling.
|
|
||||||
my $cxxout = `$cxxfilt --version 2>&1`;
|
|
||||||
$cxxout =~ m/GNU/ or die "$0 requires GNU c++filt to function";
|
|
||||||
|
|
||||||
# Talk to c++filt through a pair of file descriptors.
|
|
||||||
# Need to start a fresh instance per pattern, otherwise the
|
|
||||||
# process grows to 500+ MB.
|
|
||||||
my $pid = open2(*FILTIN, *FILTOUT, $cxxfilt) or die $!;
|
|
||||||
|
|
||||||
# Match ptn against symbols in %sym_hash.
|
|
||||||
foreach my $sym (keys %sym_hash) {
|
|
||||||
# No? Well, maybe its demangled form matches one of those
|
|
||||||
# patterns.
|
|
||||||
printf FILTOUT "%s\n",$sym;
|
|
||||||
my $dem = <FILTIN>;
|
|
||||||
chomp $dem;
|
|
||||||
$dem_syms{$sym}++ if ($dem =~ /^$pattern$/);
|
|
||||||
}
|
|
||||||
|
|
||||||
close FILTOUT or die "c++filt error";
|
|
||||||
close FILTIN or die "c++filt error";
|
|
||||||
# Need to wait for the c++filt process to avoid lots of zombies.
|
|
||||||
waitpid $pid, 0;
|
|
||||||
|
|
||||||
foreach my $sym (sort keys(%dem_syms)) {
|
|
||||||
$matched_symbols++;
|
|
||||||
print "$ws$sym;\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
# No? Well, then ignore it.
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
# Important sanity check. This script can't handle lots of formats
|
|
||||||
# that GNU ld can, so be sure to error out if one is seen!
|
|
||||||
die "strange line `$_'";
|
|
||||||
}
|
|
||||||
close F;
|
|
||||||
@@ -1,24 +1,3 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_TMS470_MATH_H
|
|
||||||
#define COMPAT_TMS470_MATH_H
|
|
||||||
|
|
||||||
#include_next <math.h>
|
#include_next <math.h>
|
||||||
|
|
||||||
#undef INFINITY
|
#undef INFINITY
|
||||||
@@ -26,5 +5,3 @@
|
|||||||
|
|
||||||
#define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 }))
|
#define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 }))
|
||||||
#define NAN (*(const float*)((const unsigned []){ 0x7fc00000 }))
|
#define NAN (*(const float*)((const unsigned []){ 0x7fc00000 }))
|
||||||
|
|
||||||
#endif /* COMPAT_TMS470_MATH_H */
|
|
||||||
|
|||||||
@@ -19,16 +19,8 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMPAT_VA_COPY_H
|
|
||||||
#define COMPAT_VA_COPY_H
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if !defined(va_copy) && defined(_MSC_VER)
|
#if !defined(va_copy) && defined(_MSC_VER)
|
||||||
#define va_copy(dst, src) ((dst) = (src))
|
#define va_copy(dst, src) ((dst) = (src))
|
||||||
#endif
|
#endif
|
||||||
#if !defined(va_copy) && defined(__GNUC__) && __GNUC__ < 3
|
|
||||||
#define va_copy(dst, src) __va_copy(dst, src)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* COMPAT_VA_COPY_H */
|
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_W32DLFCN_H
|
|
||||||
#define COMPAT_W32DLFCN_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#if _WIN32_WINNT < 0x0602
|
|
||||||
#include "libavutil/wchar_filename.h"
|
|
||||||
#endif
|
|
||||||
/**
|
|
||||||
* Safe function used to open dynamic libs. This attempts to improve program security
|
|
||||||
* by removing the current directory from the dll search path. Only dll's found in the
|
|
||||||
* executable or system directory are allowed to be loaded.
|
|
||||||
* @param name The dynamic lib name.
|
|
||||||
* @return A handle to the opened lib.
|
|
||||||
*/
|
|
||||||
static inline HMODULE win32_dlopen(const char *name)
|
|
||||||
{
|
|
||||||
#if _WIN32_WINNT < 0x0602
|
|
||||||
// Need to check if KB2533623 is available
|
|
||||||
if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) {
|
|
||||||
HMODULE module = NULL;
|
|
||||||
wchar_t *path = NULL, *name_w = NULL;
|
|
||||||
DWORD pathlen;
|
|
||||||
if (utf8towchar(name, &name_w))
|
|
||||||
goto exit;
|
|
||||||
path = (wchar_t *)av_mallocz_array(MAX_PATH, sizeof(wchar_t));
|
|
||||||
// Try local directory first
|
|
||||||
pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
|
|
||||||
pathlen = wcsrchr(path, '\\') - path;
|
|
||||||
if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
|
|
||||||
goto exit;
|
|
||||||
path[pathlen] = '\\';
|
|
||||||
wcscpy(path + pathlen + 1, name_w);
|
|
||||||
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
|
||||||
if (module == NULL) {
|
|
||||||
// Next try System32 directory
|
|
||||||
pathlen = GetSystemDirectoryW(path, MAX_PATH);
|
|
||||||
if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
|
|
||||||
goto exit;
|
|
||||||
path[pathlen] = '\\';
|
|
||||||
wcscpy(path + pathlen + 1, name_w);
|
|
||||||
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
|
||||||
}
|
|
||||||
exit:
|
|
||||||
av_free(path);
|
|
||||||
av_free(name_w);
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR
|
|
||||||
# define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
|
|
||||||
#endif
|
|
||||||
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
|
|
||||||
# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
|
|
||||||
#endif
|
|
||||||
return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
|
||||||
}
|
|
||||||
#define dlopen(name, flags) win32_dlopen(name)
|
|
||||||
#define dlclose FreeLibrary
|
|
||||||
#define dlsym GetProcAddress
|
|
||||||
#else
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* COMPAT_W32DLFCN_H */
|
|
||||||
@@ -1,418 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010-2011 x264 project
|
|
||||||
*
|
|
||||||
* Authors: Steven Walters <kemuri9@gmail.com>
|
|
||||||
* Pegasys Inc. <http://www.pegasys-inc.com>
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* w32threads to pthreads wrapper
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPAT_W32PTHREADS_H
|
|
||||||
#define COMPAT_W32PTHREADS_H
|
|
||||||
|
|
||||||
/* Build up a pthread-like API using underlying Windows API. Have only static
|
|
||||||
* methods so as to not conflict with a potentially linked in pthread-win32
|
|
||||||
* library.
|
|
||||||
* As most functions here are used without checking return values,
|
|
||||||
* only implement return values as necessary. */
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#include <process.h>
|
|
||||||
|
|
||||||
#if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
|
|
||||||
#undef MemoryBarrier
|
|
||||||
#define MemoryBarrier __sync_synchronize
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libavutil/attributes.h"
|
|
||||||
#include "libavutil/common.h"
|
|
||||||
#include "libavutil/internal.h"
|
|
||||||
#include "libavutil/mem.h"
|
|
||||||
|
|
||||||
typedef struct pthread_t {
|
|
||||||
void *handle;
|
|
||||||
void *(*func)(void* arg);
|
|
||||||
void *arg;
|
|
||||||
void *ret;
|
|
||||||
} pthread_t;
|
|
||||||
|
|
||||||
/* the conditional variable api for windows 6.0+ uses critical sections and
|
|
||||||
* not mutexes */
|
|
||||||
typedef CRITICAL_SECTION pthread_mutex_t;
|
|
||||||
|
|
||||||
/* This is the CONDITION_VARIABLE typedef for using Windows' native
|
|
||||||
* conditional variables on kernels 6.0+. */
|
|
||||||
#if HAVE_CONDITION_VARIABLE_PTR
|
|
||||||
typedef CONDITION_VARIABLE pthread_cond_t;
|
|
||||||
#else
|
|
||||||
typedef struct pthread_cond_t {
|
|
||||||
void *Ptr;
|
|
||||||
} pthread_cond_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if _WIN32_WINNT >= 0x0600
|
|
||||||
#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
|
|
||||||
#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
|
|
||||||
{
|
|
||||||
pthread_t *h = arg;
|
|
||||||
h->ret = h->func(h->arg);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
|
|
||||||
void *(*start_routine)(void*), void *arg)
|
|
||||||
{
|
|
||||||
thread->func = start_routine;
|
|
||||||
thread->arg = arg;
|
|
||||||
#if HAVE_WINRT
|
|
||||||
thread->handle = (void*)CreateThread(NULL, 0, win32thread_worker, thread,
|
|
||||||
0, NULL);
|
|
||||||
#else
|
|
||||||
thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread,
|
|
||||||
0, NULL);
|
|
||||||
#endif
|
|
||||||
return !thread->handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_join(pthread_t thread, void **value_ptr)
|
|
||||||
{
|
|
||||||
DWORD ret = WaitForSingleObject(thread.handle, INFINITE);
|
|
||||||
if (ret != WAIT_OBJECT_0) {
|
|
||||||
if (ret == WAIT_ABANDONED)
|
|
||||||
return EINVAL;
|
|
||||||
else
|
|
||||||
return EDEADLK;
|
|
||||||
}
|
|
||||||
if (value_ptr)
|
|
||||||
*value_ptr = thread.ret;
|
|
||||||
CloseHandle(thread.handle);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr)
|
|
||||||
{
|
|
||||||
InitializeCriticalSection(m);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static inline int pthread_mutex_destroy(pthread_mutex_t *m)
|
|
||||||
{
|
|
||||||
DeleteCriticalSection(m);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static inline int pthread_mutex_lock(pthread_mutex_t *m)
|
|
||||||
{
|
|
||||||
EnterCriticalSection(m);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static inline int pthread_mutex_unlock(pthread_mutex_t *m)
|
|
||||||
{
|
|
||||||
LeaveCriticalSection(m);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if _WIN32_WINNT >= 0x0600
|
|
||||||
typedef INIT_ONCE pthread_once_t;
|
|
||||||
#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
|
|
||||||
|
|
||||||
static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
|
|
||||||
{
|
|
||||||
BOOL pending = FALSE;
|
|
||||||
InitOnceBeginInitialize(once_control, 0, &pending, NULL);
|
|
||||||
if (pending)
|
|
||||||
init_routine();
|
|
||||||
InitOnceComplete(once_control, 0, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
|
|
||||||
{
|
|
||||||
InitializeConditionVariable(cond);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* native condition variables do not destroy */
|
|
||||||
static inline int pthread_cond_destroy(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int pthread_cond_broadcast(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
WakeAllConditionVariable(cond);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
SleepConditionVariableCS(cond, mutex, INFINITE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int pthread_cond_signal(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
WakeConditionVariable(cond);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // _WIN32_WINNT < 0x0600
|
|
||||||
|
|
||||||
/* atomic init state of dynamically loaded functions */
|
|
||||||
static LONG w32thread_init_state = 0;
|
|
||||||
static av_unused void w32thread_init(void);
|
|
||||||
|
|
||||||
/* for pre-Windows 6.0 platforms, define INIT_ONCE struct,
|
|
||||||
* compatible to the one used in the native API */
|
|
||||||
|
|
||||||
typedef union pthread_once_t {
|
|
||||||
void * Ptr; ///< For the Windows 6.0+ native functions
|
|
||||||
LONG state; ///< For the pre-Windows 6.0 compat code
|
|
||||||
} pthread_once_t;
|
|
||||||
|
|
||||||
#define PTHREAD_ONCE_INIT {0}
|
|
||||||
|
|
||||||
/* function pointers to init once API on windows 6.0+ kernels */
|
|
||||||
static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD dwFlags, BOOL *fPending, void **lpContext);
|
|
||||||
static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce, DWORD dwFlags, void *lpContext);
|
|
||||||
|
|
||||||
/* pre-Windows 6.0 compat using a spin-lock */
|
|
||||||
static inline void w32thread_once_fallback(LONG volatile *state, void (*init_routine)(void))
|
|
||||||
{
|
|
||||||
switch (InterlockedCompareExchange(state, 1, 0)) {
|
|
||||||
/* Initial run */
|
|
||||||
case 0:
|
|
||||||
init_routine();
|
|
||||||
InterlockedExchange(state, 2);
|
|
||||||
break;
|
|
||||||
/* Another thread is running init */
|
|
||||||
case 1:
|
|
||||||
while (1) {
|
|
||||||
MemoryBarrier();
|
|
||||||
if (*state == 2)
|
|
||||||
break;
|
|
||||||
Sleep(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* Initialization complete */
|
|
||||||
case 2:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
|
|
||||||
{
|
|
||||||
w32thread_once_fallback(&w32thread_init_state, w32thread_init);
|
|
||||||
|
|
||||||
/* Use native functions on Windows 6.0+ */
|
|
||||||
if (initonce_begin && initonce_complete) {
|
|
||||||
BOOL pending = FALSE;
|
|
||||||
initonce_begin(once_control, 0, &pending, NULL);
|
|
||||||
if (pending)
|
|
||||||
init_routine();
|
|
||||||
initonce_complete(once_control, 0, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
w32thread_once_fallback(&once_control->state, init_routine);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for pre-Windows 6.0 platforms we need to define and use our own condition
|
|
||||||
* variable and api */
|
|
||||||
|
|
||||||
typedef struct win32_cond_t {
|
|
||||||
pthread_mutex_t mtx_broadcast;
|
|
||||||
pthread_mutex_t mtx_waiter_count;
|
|
||||||
volatile int waiter_count;
|
|
||||||
HANDLE semaphore;
|
|
||||||
HANDLE waiters_done;
|
|
||||||
volatile int is_broadcast;
|
|
||||||
} win32_cond_t;
|
|
||||||
|
|
||||||
/* function pointers to conditional variable API on windows 6.0+ kernels */
|
|
||||||
static void (WINAPI *cond_broadcast)(pthread_cond_t *cond);
|
|
||||||
static void (WINAPI *cond_init)(pthread_cond_t *cond);
|
|
||||||
static void (WINAPI *cond_signal)(pthread_cond_t *cond);
|
|
||||||
static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
|
||||||
DWORD milliseconds);
|
|
||||||
|
|
||||||
static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
|
|
||||||
{
|
|
||||||
win32_cond_t *win32_cond = NULL;
|
|
||||||
|
|
||||||
w32thread_once_fallback(&w32thread_init_state, w32thread_init);
|
|
||||||
|
|
||||||
if (cond_init) {
|
|
||||||
cond_init(cond);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non native condition variables */
|
|
||||||
win32_cond = av_mallocz(sizeof(win32_cond_t));
|
|
||||||
if (!win32_cond)
|
|
||||||
return ENOMEM;
|
|
||||||
cond->Ptr = win32_cond;
|
|
||||||
win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
|
|
||||||
if (!win32_cond->semaphore)
|
|
||||||
return ENOMEM;
|
|
||||||
win32_cond->waiters_done = CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
||||||
if (!win32_cond->waiters_done)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL);
|
|
||||||
pthread_mutex_init(&win32_cond->mtx_broadcast, NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_cond_destroy(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
win32_cond_t *win32_cond = cond->Ptr;
|
|
||||||
/* native condition variables do not destroy */
|
|
||||||
if (cond_init)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* non native condition variables */
|
|
||||||
CloseHandle(win32_cond->semaphore);
|
|
||||||
CloseHandle(win32_cond->waiters_done);
|
|
||||||
pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
|
|
||||||
pthread_mutex_destroy(&win32_cond->mtx_broadcast);
|
|
||||||
av_freep(&win32_cond);
|
|
||||||
cond->Ptr = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_cond_broadcast(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
win32_cond_t *win32_cond = cond->Ptr;
|
|
||||||
int have_waiter;
|
|
||||||
|
|
||||||
if (cond_broadcast) {
|
|
||||||
cond_broadcast(cond);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non native condition variables */
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_broadcast);
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
|
||||||
have_waiter = 0;
|
|
||||||
|
|
||||||
if (win32_cond->waiter_count) {
|
|
||||||
win32_cond->is_broadcast = 1;
|
|
||||||
have_waiter = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (have_waiter) {
|
|
||||||
ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
|
||||||
WaitForSingleObject(win32_cond->waiters_done, INFINITE);
|
|
||||||
ResetEvent(win32_cond->waiters_done);
|
|
||||||
win32_cond->is_broadcast = 0;
|
|
||||||
} else
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
win32_cond_t *win32_cond = cond->Ptr;
|
|
||||||
int last_waiter;
|
|
||||||
if (cond_wait) {
|
|
||||||
cond_wait(cond, mutex, INFINITE);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non native condition variables */
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_broadcast);
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
|
||||||
win32_cond->waiter_count++;
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
|
|
||||||
|
|
||||||
// unlock the external mutex
|
|
||||||
pthread_mutex_unlock(mutex);
|
|
||||||
WaitForSingleObject(win32_cond->semaphore, INFINITE);
|
|
||||||
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
|
||||||
win32_cond->waiter_count--;
|
|
||||||
last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast;
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
|
||||||
|
|
||||||
if (last_waiter)
|
|
||||||
SetEvent(win32_cond->waiters_done);
|
|
||||||
|
|
||||||
// lock the external mutex
|
|
||||||
return pthread_mutex_lock(mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_unused int pthread_cond_signal(pthread_cond_t *cond)
|
|
||||||
{
|
|
||||||
win32_cond_t *win32_cond = cond->Ptr;
|
|
||||||
int have_waiter;
|
|
||||||
if (cond_signal) {
|
|
||||||
cond_signal(cond);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_broadcast);
|
|
||||||
|
|
||||||
/* non-native condition variables */
|
|
||||||
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
|
|
||||||
have_waiter = win32_cond->waiter_count;
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
|
|
||||||
|
|
||||||
if (have_waiter) {
|
|
||||||
ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
|
|
||||||
WaitForSingleObject(win32_cond->waiters_done, INFINITE);
|
|
||||||
ResetEvent(win32_cond->waiters_done);
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static av_unused void w32thread_init(void)
|
|
||||||
{
|
|
||||||
#if _WIN32_WINNT < 0x0600
|
|
||||||
HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll"));
|
|
||||||
/* if one is available, then they should all be available */
|
|
||||||
cond_init =
|
|
||||||
(void*)GetProcAddress(kernel_dll, "InitializeConditionVariable");
|
|
||||||
cond_broadcast =
|
|
||||||
(void*)GetProcAddress(kernel_dll, "WakeAllConditionVariable");
|
|
||||||
cond_signal =
|
|
||||||
(void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
|
|
||||||
cond_wait =
|
|
||||||
(void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
|
|
||||||
initonce_begin =
|
|
||||||
(void*)GetProcAddress(kernel_dll, "InitOnceBeginInitialize");
|
|
||||||
initonce_complete =
|
|
||||||
(void*)GetProcAddress(kernel_dll, "InitOnceComplete");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* COMPAT_W32PTHREADS_H */
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Copyright (c) 2013, Derek Buitenhuis
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
# mktemp isn't POSIX, so supply an implementation
|
|
||||||
mktemp() {
|
|
||||||
echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
|
||||||
echo "Usage: makedef <version_script> <objects>" >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
vscript=$1
|
|
||||||
shift
|
|
||||||
|
|
||||||
if [ ! -f "$vscript" ]; then
|
|
||||||
echo "Version script does not exist" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for object in "$@"; do
|
|
||||||
if [ ! -f "$object" ]; then
|
|
||||||
echo "Object does not exist: ${object}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create a lib temporarily to dump symbols from.
|
|
||||||
# It's just much easier to do it this way
|
|
||||||
libname=$(mktemp -u "library").lib
|
|
||||||
|
|
||||||
trap 'rm -f -- $libname' EXIT
|
|
||||||
|
|
||||||
lib -out:${libname} $@ >/dev/null
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
echo "Could not create temporary library." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
IFS='
|
|
||||||
'
|
|
||||||
|
|
||||||
# Determine if we're building for x86 or x86_64 and
|
|
||||||
# set the symbol prefix accordingly.
|
|
||||||
prefix=""
|
|
||||||
arch=$(dumpbin -headers ${libname} |
|
|
||||||
tr '\t' ' ' |
|
|
||||||
grep '^ \+.\+machine \+(.\+)' |
|
|
||||||
head -1 |
|
|
||||||
sed -e 's/^ \{1,\}.\{1,\} \{1,\}machine \{1,\}(\(...\)).*/\1/')
|
|
||||||
|
|
||||||
if [ "${arch}" = "x86" ]; then
|
|
||||||
prefix="_"
|
|
||||||
else
|
|
||||||
if [ "${arch}" != "ARM" ] && [ "${arch}" != "x64" ]; then
|
|
||||||
echo "Unknown machine type." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
started=0
|
|
||||||
regex="none"
|
|
||||||
|
|
||||||
for line in $(cat ${vscript} | tr '\t' ' '); do
|
|
||||||
# We only care about global symbols
|
|
||||||
echo "${line}" | grep -q '^ \+global:'
|
|
||||||
if [ $? = 0 ]; then
|
|
||||||
started=1
|
|
||||||
line=$(echo "${line}" | sed -e 's/^ \{1,\}global: *//')
|
|
||||||
else
|
|
||||||
echo "${line}" | grep -q '^ \+local:'
|
|
||||||
if [ $? = 0 ]; then
|
|
||||||
started=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${started} = 0 ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Handle multiple symbols on one line
|
|
||||||
IFS=';'
|
|
||||||
|
|
||||||
# Work around stupid expansion to filenames
|
|
||||||
line=$(echo "${line}" | sed -e 's/\*/.\\+/g')
|
|
||||||
for exp in ${line}; do
|
|
||||||
# Remove leading and trailing whitespace
|
|
||||||
exp=$(echo "${exp}" | sed -e 's/^ *//' -e 's/ *$//')
|
|
||||||
|
|
||||||
if [ "${regex}" = "none" ]; then
|
|
||||||
regex="${exp}"
|
|
||||||
else
|
|
||||||
regex="${regex};${exp}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
IFS='
|
|
||||||
'
|
|
||||||
done
|
|
||||||
|
|
||||||
dump=$(dumpbin -linkermember:1 ${libname})
|
|
||||||
|
|
||||||
rm ${libname}
|
|
||||||
|
|
||||||
IFS=';'
|
|
||||||
list=""
|
|
||||||
for exp in ${regex}; do
|
|
||||||
list="${list}"'
|
|
||||||
'$(echo "${dump}" |
|
|
||||||
sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' |
|
|
||||||
tail -n +2 |
|
|
||||||
cut -d' ' -f3 |
|
|
||||||
grep "^${exp}" |
|
|
||||||
sed -e 's/^/ /')
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "EXPORTS"
|
|
||||||
echo "${list}" | sort | uniq | tail -n +2
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
LINK_EXE_PATH=$(dirname "$(command -v cl)")/link
|
|
||||||
if [ -x "$LINK_EXE_PATH" ]; then
|
|
||||||
"$LINK_EXE_PATH" $@
|
|
||||||
else
|
|
||||||
link $@
|
|
||||||
fi
|
|
||||||
exit $?
|
|
||||||
9
doc/.gitignore
vendored
9
doc/.gitignore
vendored
@@ -1,9 +0,0 @@
|
|||||||
/*.1
|
|
||||||
/*.3
|
|
||||||
/*.html
|
|
||||||
/*.pod
|
|
||||||
/config.texi
|
|
||||||
/avoptions_codec.texi
|
|
||||||
/avoptions_format.texi
|
|
||||||
/fate.txt
|
|
||||||
/print_options
|
|
||||||
1318
doc/APIchanges
1318
doc/APIchanges
File diff suppressed because it is too large
Load Diff
2439
doc/Doxyfile
2439
doc/Doxyfile
File diff suppressed because it is too large
Load Diff
117
doc/Makefile
117
doc/Makefile
@@ -6,6 +6,7 @@ LIBRARIES-$(CONFIG_AVFORMAT) += libavformat
|
|||||||
LIBRARIES-$(CONFIG_AVDEVICE) += libavdevice
|
LIBRARIES-$(CONFIG_AVDEVICE) += libavdevice
|
||||||
LIBRARIES-$(CONFIG_AVFILTER) += libavfilter
|
LIBRARIES-$(CONFIG_AVFILTER) += libavfilter
|
||||||
|
|
||||||
|
COMPONENTS-yes = $(PROGS-yes)
|
||||||
COMPONENTS-$(CONFIG_AVUTIL) += ffmpeg-utils
|
COMPONENTS-$(CONFIG_AVUTIL) += ffmpeg-utils
|
||||||
COMPONENTS-$(CONFIG_SWSCALE) += ffmpeg-scaler
|
COMPONENTS-$(CONFIG_SWSCALE) += ffmpeg-scaler
|
||||||
COMPONENTS-$(CONFIG_SWRESAMPLE) += ffmpeg-resampler
|
COMPONENTS-$(CONFIG_SWRESAMPLE) += ffmpeg-resampler
|
||||||
@@ -14,11 +15,9 @@ COMPONENTS-$(CONFIG_AVFORMAT) += ffmpeg-formats ffmpeg-protocols
|
|||||||
COMPONENTS-$(CONFIG_AVDEVICE) += ffmpeg-devices
|
COMPONENTS-$(CONFIG_AVDEVICE) += ffmpeg-devices
|
||||||
COMPONENTS-$(CONFIG_AVFILTER) += ffmpeg-filters
|
COMPONENTS-$(CONFIG_AVFILTER) += ffmpeg-filters
|
||||||
|
|
||||||
MANPAGES1 = $(AVPROGS-yes:%=doc/%.1) $(AVPROGS-yes:%=doc/%-all.1) $(COMPONENTS-yes:%=doc/%.1)
|
MANPAGES = $(COMPONENTS-yes:%=doc/%.1) $(LIBRARIES-yes:%=doc/%.3)
|
||||||
MANPAGES3 = $(LIBRARIES-yes:%=doc/%.3)
|
PODPAGES = $(COMPONENTS-yes:%=doc/%.pod) $(LIBRARIES-yes:%=doc/%.pod)
|
||||||
MANPAGES = $(MANPAGES1) $(MANPAGES3)
|
HTMLPAGES = $(COMPONENTS-yes:%=doc/%.html) $(LIBRARIES-yes:%=doc/%.html) \
|
||||||
PODPAGES = $(AVPROGS-yes:%=doc/%.pod) $(AVPROGS-yes:%=doc/%-all.pod) $(COMPONENTS-yes:%=doc/%.pod) $(LIBRARIES-yes:%=doc/%.pod)
|
|
||||||
HTMLPAGES = $(AVPROGS-yes:%=doc/%.html) $(AVPROGS-yes:%=doc/%-all.html) $(COMPONENTS-yes:%=doc/%.html) $(LIBRARIES-yes:%=doc/%.html) \
|
|
||||||
doc/developer.html \
|
doc/developer.html \
|
||||||
doc/faq.html \
|
doc/faq.html \
|
||||||
doc/fate.html \
|
doc/fate.html \
|
||||||
@@ -36,33 +35,6 @@ DOCS-$(CONFIG_MANPAGES) += $(MANPAGES)
|
|||||||
DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES)
|
DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES)
|
||||||
DOCS = $(DOCS-yes)
|
DOCS = $(DOCS-yes)
|
||||||
|
|
||||||
DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
|
|
||||||
DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
|
|
||||||
DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
|
|
||||||
DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
|
|
||||||
DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
|
|
||||||
DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
|
|
||||||
DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
|
|
||||||
DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
|
|
||||||
DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
|
|
||||||
DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
|
|
||||||
DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
|
|
||||||
DOC_EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient
|
|
||||||
DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
|
|
||||||
DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
|
|
||||||
DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
|
|
||||||
DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing
|
|
||||||
DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
|
|
||||||
DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
|
|
||||||
DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
|
|
||||||
DOC_EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
|
|
||||||
ALL_DOC_EXAMPLES_LIST = $(DOC_EXAMPLES-) $(DOC_EXAMPLES-yes)
|
|
||||||
|
|
||||||
DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
|
|
||||||
ALL_DOC_EXAMPLES := $(ALL_DOC_EXAMPLES_LIST:%=doc/examples/%$(PROGSSUF)$(EXESUF))
|
|
||||||
ALL_DOC_EXAMPLES_G := $(ALL_DOC_EXAMPLES_LIST:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
|
|
||||||
PROGS += $(DOC_EXAMPLES)
|
|
||||||
|
|
||||||
all-$(CONFIG_DOC): doc
|
all-$(CONFIG_DOC): doc
|
||||||
|
|
||||||
doc: documentation
|
doc: documentation
|
||||||
@@ -70,9 +42,7 @@ doc: documentation
|
|||||||
apidoc: doc/doxy/html
|
apidoc: doc/doxy/html
|
||||||
documentation: $(DOCS)
|
documentation: $(DOCS)
|
||||||
|
|
||||||
examples: $(DOC_EXAMPLES)
|
TEXIDEP = awk '/^@(verbatim)?include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
|
||||||
|
|
||||||
TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
|
|
||||||
|
|
||||||
doc/%.txt: TAG = TXT
|
doc/%.txt: TAG = TXT
|
||||||
doc/%.txt: doc/%.texi
|
doc/%.txt: doc/%.texi
|
||||||
@@ -87,100 +57,45 @@ $(GENTEXI): doc/avoptions_%.texi: doc/print_options$(HOSTEXESUF)
|
|||||||
$(M)doc/print_options $* > $@
|
$(M)doc/print_options $* > $@
|
||||||
|
|
||||||
doc/%.html: TAG = HTML
|
doc/%.html: TAG = HTML
|
||||||
doc/%-all.html: TAG = HTML
|
|
||||||
|
|
||||||
ifdef HAVE_MAKEINFO_HTML
|
|
||||||
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
|
|
||||||
$(Q)$(TEXIDEP)
|
|
||||||
$(M)makeinfo --html -I doc --no-split -D config-not-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
|
|
||||||
|
|
||||||
doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
|
|
||||||
$(Q)$(TEXIDEP)
|
|
||||||
$(M)makeinfo --html -I doc --no-split -D config-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
|
|
||||||
else
|
|
||||||
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
|
doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
|
||||||
$(Q)$(TEXIDEP)
|
$(Q)$(TEXIDEP)
|
||||||
$(M)texi2html -I doc -monolithic --D=config-not-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
|
$(M)texi2html -I doc -monolithic --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
|
||||||
|
|
||||||
doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
|
|
||||||
$(Q)$(TEXIDEP)
|
|
||||||
$(M)texi2html -I doc -monolithic --D=config-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
|
|
||||||
endif
|
|
||||||
|
|
||||||
doc/%.pod: TAG = POD
|
doc/%.pod: TAG = POD
|
||||||
doc/%.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
|
doc/%.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
|
||||||
$(Q)$(TEXIDEP)
|
$(Q)$(TEXIDEP)
|
||||||
$(M)perl $(SRC_PATH)/doc/texi2pod.pl -Dconfig-not-all=yes -Idoc $< $@
|
$(M)perl $(SRC_PATH)/doc/texi2pod.pl -Idoc $< $@
|
||||||
|
|
||||||
doc/%-all.pod: TAG = POD
|
|
||||||
doc/%-all.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
|
|
||||||
$(Q)$(TEXIDEP)
|
|
||||||
$(M)perl $(SRC_PATH)/doc/texi2pod.pl -Dconfig-all=yes -Idoc $< $@
|
|
||||||
|
|
||||||
doc/%.1 doc/%.3: TAG = MAN
|
doc/%.1 doc/%.3: TAG = MAN
|
||||||
doc/%.1: doc/%.pod $(GENTEXI)
|
doc/%.1: doc/%.pod $(GENTEXI)
|
||||||
$(M)pod2man --section=1 --center=" " --release=" " --date=" " $< > $@
|
$(M)pod2man --section=1 --center=" " --release=" " $< > $@
|
||||||
doc/%.3: doc/%.pod $(GENTEXI)
|
doc/%.3: doc/%.pod $(GENTEXI)
|
||||||
$(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@
|
$(M)pod2man --section=3 --center=" " --release=" " $< > $@
|
||||||
|
|
||||||
$(DOCS) doc/doxy/html: | doc/
|
$(DOCS) doc/doxy/html: | doc/
|
||||||
$(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
|
|
||||||
OBJDIRS += doc/examples
|
|
||||||
|
|
||||||
DOXY_INPUT = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c)
|
doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(INSTHEADERS)
|
||||||
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) config.mak
|
$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $^
|
||||||
|
|
||||||
doc/doxy/html: TAG = DOXY
|
|
||||||
doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT_DEPS)
|
|
||||||
$(M)OUT_DIR=$$PWD/doc/doxy; cd $(SRC_PATH); ./doc/doxy-wrapper.sh $$OUT_DIR $< $(DOXYGEN) $(DOXY_INPUT);
|
|
||||||
|
|
||||||
install-doc: install-html install-man
|
|
||||||
|
|
||||||
install-html:
|
|
||||||
|
|
||||||
install-man:
|
install-man:
|
||||||
|
|
||||||
ifdef CONFIG_HTMLPAGES
|
|
||||||
install-progs-$(CONFIG_DOC): install-html
|
|
||||||
|
|
||||||
install-html: $(HTMLPAGES)
|
|
||||||
$(Q)mkdir -p "$(DOCDIR)"
|
|
||||||
$(INSTALL) -m 644 $(HTMLPAGES) "$(DOCDIR)"
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef CONFIG_MANPAGES
|
ifdef CONFIG_MANPAGES
|
||||||
install-progs-$(CONFIG_DOC): install-man
|
install-progs-$(CONFIG_DOC): install-man
|
||||||
|
|
||||||
install-man: $(MANPAGES)
|
install-man: $(MANPAGES)
|
||||||
$(Q)mkdir -p "$(MANDIR)/man1"
|
$(Q)mkdir -p "$(MANDIR)/man1"
|
||||||
$(INSTALL) -m 644 $(MANPAGES1) "$(MANDIR)/man1"
|
$(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
|
||||||
$(Q)mkdir -p "$(MANDIR)/man3"
|
|
||||||
$(INSTALL) -m 644 $(MANPAGES3) "$(MANDIR)/man3"
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
uninstall: uninstall-doc
|
uninstall: uninstall-man
|
||||||
|
|
||||||
uninstall-doc: uninstall-html uninstall-man
|
|
||||||
|
|
||||||
uninstall-html:
|
|
||||||
$(RM) -r "$(DOCDIR)"
|
|
||||||
|
|
||||||
uninstall-man:
|
uninstall-man:
|
||||||
$(RM) $(addprefix "$(MANDIR)/man1/",$(AVPROGS-yes:%=%.1) $(AVPROGS-yes:%=%-all.1) $(COMPONENTS-yes:%=%.1))
|
$(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
|
||||||
$(RM) $(addprefix "$(MANDIR)/man3/",$(LIBRARIES-yes:%=%.3))
|
|
||||||
|
|
||||||
clean:: docclean
|
clean:: docclean
|
||||||
|
|
||||||
distclean:: docclean
|
docclean:
|
||||||
$(RM) doc/config.texi
|
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 $(CLEANSUFFIXES:%=doc/%) doc/avoptions_*.texi
|
||||||
|
|
||||||
examplesclean:
|
|
||||||
$(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
|
|
||||||
$(RM) $(CLEANSUFFIXES:%=doc/examples/%)
|
|
||||||
|
|
||||||
docclean: examplesclean
|
|
||||||
$(RM) $(CLEANSUFFIXES:%=doc/%)
|
|
||||||
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi
|
|
||||||
$(RM) -r doc/doxy/html
|
$(RM) -r doc/doxy/html
|
||||||
|
|
||||||
-include $(wildcard $(DOCS:%=%.d))
|
-include $(wildcard $(DOCS:%=%.d))
|
||||||
|
|||||||
16
doc/RELEASE_NOTES
Normal file
16
doc/RELEASE_NOTES
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Release Notes
|
||||||
|
=============
|
||||||
|
|
||||||
|
* 1.2 "Magic" March, 2013
|
||||||
|
|
||||||
|
|
||||||
|
General notes
|
||||||
|
-------------
|
||||||
|
See the Changelog file for a list of significant changes. Note, there
|
||||||
|
are many more new features and bugfixes than whats listed there.
|
||||||
|
|
||||||
|
Bugreports against FFmpeg git master or the most recent FFmpeg release are
|
||||||
|
accepted. If you are experiencing issues with any formally released version of
|
||||||
|
FFmpeg, please try git master to check if the issue still exists. If it does,
|
||||||
|
make your report against the development code following the usual bug reporting
|
||||||
|
guidelines.
|
||||||
211
doc/avtools-common-opts.texi
Normal file
211
doc/avtools-common-opts.texi
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
All the numerical options, if not specified otherwise, accept in input
|
||||||
|
a string representing a number, which may contain one of the
|
||||||
|
SI unit prefixes, for example 'K', 'M', 'G'.
|
||||||
|
If 'i' is appended after the prefix, binary prefixes are used,
|
||||||
|
which are based on powers of 1024 instead of powers of 1000.
|
||||||
|
The 'B' postfix multiplies the value by 8, and can be
|
||||||
|
appended after a unit prefix or used alone. This allows using for
|
||||||
|
example 'KB', 'MiB', 'G' and 'B' as number postfix.
|
||||||
|
|
||||||
|
Options which do not take arguments are boolean options, and set the
|
||||||
|
corresponding value to true. They can be set to false by prefixing
|
||||||
|
with "no" the option name, for example using "-nofoo" in the
|
||||||
|
command line will set to false the boolean option with name "foo".
|
||||||
|
|
||||||
|
@anchor{Stream specifiers}
|
||||||
|
@section Stream specifiers
|
||||||
|
Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
|
||||||
|
are used to precisely specify which stream(s) does a given option belong to.
|
||||||
|
|
||||||
|
A stream specifier is a string generally appended to the option name and
|
||||||
|
separated from it by a colon. E.g. @code{-codec:a:1 ac3} option contains
|
||||||
|
@code{a:1} stream specifier, which matches the second audio stream. Therefore it
|
||||||
|
would select the ac3 codec for the second audio stream.
|
||||||
|
|
||||||
|
A stream specifier can match several streams, the option is then applied to all
|
||||||
|
of them. E.g. the stream specifier in @code{-b:a 128k} matches all audio
|
||||||
|
streams.
|
||||||
|
|
||||||
|
An empty stream specifier matches all streams, for example @code{-codec copy}
|
||||||
|
or @code{-codec: copy} would copy all the streams without reencoding.
|
||||||
|
|
||||||
|
Possible forms of stream specifiers are:
|
||||||
|
@table @option
|
||||||
|
@item @var{stream_index}
|
||||||
|
Matches the stream with this index. E.g. @code{-threads:1 4} would set the
|
||||||
|
thread count for the second stream to 4.
|
||||||
|
@item @var{stream_type}[:@var{stream_index}]
|
||||||
|
@var{stream_type} is one of: 'v' for video, 'a' for audio, 's' for subtitle,
|
||||||
|
'd' for data and 't' for attachments. If @var{stream_index} is given, then
|
||||||
|
matches stream number @var{stream_index} of this type. Otherwise matches all
|
||||||
|
streams of this type.
|
||||||
|
@item p:@var{program_id}[:@var{stream_index}]
|
||||||
|
If @var{stream_index} is given, then matches stream number @var{stream_index} in
|
||||||
|
program with id @var{program_id}. Otherwise matches all streams in this program.
|
||||||
|
@item #@var{stream_id}
|
||||||
|
Matches the stream by format-specific ID.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section Generic options
|
||||||
|
|
||||||
|
These options are shared amongst the av* tools.
|
||||||
|
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@item -L
|
||||||
|
Show license.
|
||||||
|
|
||||||
|
@item -h, -?, -help, --help [@var{arg}]
|
||||||
|
Show help. An optional parameter may be specified to print help about a specific
|
||||||
|
item.
|
||||||
|
|
||||||
|
Possible values of @var{arg} are:
|
||||||
|
@table @option
|
||||||
|
@item decoder=@var{decoder_name}
|
||||||
|
Print detailed information about the decoder named @var{decoder_name}. Use the
|
||||||
|
@option{-decoders} option to get a list of all decoders.
|
||||||
|
|
||||||
|
@item encoder=@var{encoder_name}
|
||||||
|
Print detailed information about the encoder named @var{encoder_name}. Use the
|
||||||
|
@option{-encoders} option to get a list of all encoders.
|
||||||
|
|
||||||
|
@item demuxer=@var{demuxer_name}
|
||||||
|
Print detailed information about the demuxer named @var{demuxer_name}. Use the
|
||||||
|
@option{-formats} option to get a list of all demuxers and muxers.
|
||||||
|
|
||||||
|
@item muxer=@var{muxer_name}
|
||||||
|
Print detailed information about the muxer named @var{muxer_name}. Use the
|
||||||
|
@option{-formats} option to get a list of all muxers and demuxers.
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item -version
|
||||||
|
Show version.
|
||||||
|
|
||||||
|
@item -formats
|
||||||
|
Show available formats.
|
||||||
|
|
||||||
|
The fields preceding the format names have the following meanings:
|
||||||
|
@table @samp
|
||||||
|
@item D
|
||||||
|
Decoding available
|
||||||
|
@item E
|
||||||
|
Encoding available
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item -codecs
|
||||||
|
Show all codecs known to libavcodec.
|
||||||
|
|
||||||
|
Note that the term 'codec' is used throughout this documentation as a shortcut
|
||||||
|
for what is more correctly called a media bitstream format.
|
||||||
|
|
||||||
|
@item -decoders
|
||||||
|
Show available decoders.
|
||||||
|
|
||||||
|
@item -encoders
|
||||||
|
Show all available encoders.
|
||||||
|
|
||||||
|
@item -bsfs
|
||||||
|
Show available bitstream filters.
|
||||||
|
|
||||||
|
@item -protocols
|
||||||
|
Show available protocols.
|
||||||
|
|
||||||
|
@item -filters
|
||||||
|
Show available libavfilter filters.
|
||||||
|
|
||||||
|
@item -pix_fmts
|
||||||
|
Show available pixel formats.
|
||||||
|
|
||||||
|
@item -sample_fmts
|
||||||
|
Show available sample formats.
|
||||||
|
|
||||||
|
@item -layouts
|
||||||
|
Show channel names and standard channel layouts.
|
||||||
|
|
||||||
|
@item -loglevel @var{loglevel} | -v @var{loglevel}
|
||||||
|
Set the logging level used by the library.
|
||||||
|
@var{loglevel} is a number or a string containing one of the following values:
|
||||||
|
@table @samp
|
||||||
|
@item quiet
|
||||||
|
@item panic
|
||||||
|
@item fatal
|
||||||
|
@item error
|
||||||
|
@item warning
|
||||||
|
@item info
|
||||||
|
@item verbose
|
||||||
|
@item debug
|
||||||
|
@end table
|
||||||
|
|
||||||
|
By default the program logs to stderr, if coloring is supported by the
|
||||||
|
terminal, colors are used to mark errors and warnings. Log coloring
|
||||||
|
can be disabled setting the environment variable
|
||||||
|
@env{AV_LOG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting
|
||||||
|
the environment variable @env{AV_LOG_FORCE_COLOR}.
|
||||||
|
The use of the environment variable @env{NO_COLOR} is deprecated and
|
||||||
|
will be dropped in a following FFmpeg version.
|
||||||
|
|
||||||
|
@item -report
|
||||||
|
Dump full command line and console output to a file named
|
||||||
|
@code{@var{program}-@var{YYYYMMDD}-@var{HHMMSS}.log} in the current
|
||||||
|
directory.
|
||||||
|
This file can be useful for bug reports.
|
||||||
|
It also implies @code{-loglevel verbose}.
|
||||||
|
|
||||||
|
Setting the environment variable @code{FFREPORT} to any value has the
|
||||||
|
same effect. If the value is a ':'-separated key=value sequence, these
|
||||||
|
options will affect the report; options values must be escaped if they
|
||||||
|
contain special characters or the options delimiter ':' (see the
|
||||||
|
``Quoting and escaping'' section in the ffmpeg-utils manual). The
|
||||||
|
following option is recognized:
|
||||||
|
@table @option
|
||||||
|
@item file
|
||||||
|
set the file name to use for the report; @code{%p} is expanded to the name
|
||||||
|
of the program, @code{%t} is expanded to a timestamp, @code{%%} is expanded
|
||||||
|
to a plain @code{%}
|
||||||
|
@end table
|
||||||
|
|
||||||
|
Errors in parsing the environment variable are not fatal, and will not
|
||||||
|
appear in the report.
|
||||||
|
|
||||||
|
@item -cpuflags flags (@emph{global})
|
||||||
|
Allows setting and clearing cpu flags. This option is intended
|
||||||
|
for testing. Do not use it unless you know what you're doing.
|
||||||
|
@example
|
||||||
|
ffmpeg -cpuflags -sse+mmx ...
|
||||||
|
ffmpeg -cpuflags mmx ...
|
||||||
|
ffmpeg -cpuflags 0 ...
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@section AVOptions
|
||||||
|
|
||||||
|
These options are provided directly by the libavformat, libavdevice and
|
||||||
|
libavcodec libraries. To see the list of available AVOptions, use the
|
||||||
|
@option{-help} option. They are separated into two categories:
|
||||||
|
@table @option
|
||||||
|
@item generic
|
||||||
|
These options can be set for any container, codec or device. Generic options
|
||||||
|
are listed under AVFormatContext options for containers/devices and under
|
||||||
|
AVCodecContext options for codecs.
|
||||||
|
@item private
|
||||||
|
These options are specific to the given container, device or codec. Private
|
||||||
|
options are listed under their corresponding containers/devices/codecs.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
For example to write an ID3v2.3 header instead of a default ID3v2.4 to
|
||||||
|
an MP3 file, use the @option{id3v2_version} private option of the MP3
|
||||||
|
muxer:
|
||||||
|
@example
|
||||||
|
ffmpeg -i input.flac -id3v2_version 3 out.mp3
|
||||||
|
@end example
|
||||||
|
|
||||||
|
All codec AVOptions are obviously per-stream, so the chapter on stream
|
||||||
|
specifiers applies to them
|
||||||
|
|
||||||
|
Note @option{-nooption} syntax cannot be used for boolean AVOptions,
|
||||||
|
use @option{-option 0}/@option{-option 1}.
|
||||||
|
|
||||||
|
Note2 old undocumented way of specifying per-stream AVOptions by prepending
|
||||||
|
v/a/s to the options name is now obsolete and will be removed soon.
|
||||||
36
doc/avutil.txt
Normal file
36
doc/avutil.txt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
AVUtil
|
||||||
|
======
|
||||||
|
libavutil is a small lightweight library of generally useful functions.
|
||||||
|
It is not a library for code needed by both libavcodec and libavformat.
|
||||||
|
|
||||||
|
|
||||||
|
Overview:
|
||||||
|
=========
|
||||||
|
adler32.c adler32 checksum
|
||||||
|
aes.c AES encryption and decryption
|
||||||
|
fifo.c resizeable first in first out buffer
|
||||||
|
intfloat_readwrite.c portable reading and writing of floating point values
|
||||||
|
log.c "printf" with context and level
|
||||||
|
md5.c MD5 Message-Digest Algorithm
|
||||||
|
rational.c code to perform exact calculations with rational numbers
|
||||||
|
tree.c generic AVL tree
|
||||||
|
crc.c generic CRC checksumming code
|
||||||
|
integer.c 128bit integer math
|
||||||
|
lls.c
|
||||||
|
mathematics.c greatest common divisor, integer sqrt, integer log2, ...
|
||||||
|
mem.c memory allocation routines with guaranteed alignment
|
||||||
|
|
||||||
|
Headers:
|
||||||
|
bswap.h big/little/native-endian conversion code
|
||||||
|
x86_cpu.h a few useful macros for unifying x86-64 and x86-32 code
|
||||||
|
avutil.h
|
||||||
|
common.h
|
||||||
|
intreadwrite.h reading and writing of unaligned big/little/native-endian integers
|
||||||
|
|
||||||
|
|
||||||
|
Goals:
|
||||||
|
======
|
||||||
|
* Modular (few interdependencies and the possibility of disabling individual parts during ./configure)
|
||||||
|
* Small (source and object)
|
||||||
|
* Efficient (low CPU and memory usage)
|
||||||
|
* Useful (avoid useless features almost no one needs)
|
||||||
@@ -13,84 +13,13 @@ bitstream filter using the option @code{--disable-bsf=BSF}.
|
|||||||
The option @code{-bsfs} of the ff* tools will display the list of
|
The option @code{-bsfs} of the ff* tools will display the list of
|
||||||
all the supported bitstream filters included in your build.
|
all the supported bitstream filters included in your build.
|
||||||
|
|
||||||
The ff* tools have a -bsf option applied per stream, taking a
|
Below is a description of the currently available bitstream filters.
|
||||||
comma-separated list of filters, whose parameters follow the filter
|
|
||||||
name after a '='.
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
|
|
||||||
@end example
|
|
||||||
|
|
||||||
Below is a description of the currently available bitstream filters,
|
|
||||||
with their parameters, if any.
|
|
||||||
|
|
||||||
@section aac_adtstoasc
|
@section aac_adtstoasc
|
||||||
|
|
||||||
Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration
|
|
||||||
bitstream.
|
|
||||||
|
|
||||||
This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
|
|
||||||
ADTS header and removes the ADTS header.
|
|
||||||
|
|
||||||
This filter is required for example when copying an AAC stream from a
|
|
||||||
raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or
|
|
||||||
to MOV/MP4 files and related formats such as 3GP or M4A. Please note
|
|
||||||
that it is auto-inserted for MP4A-LATM and MOV/MP4 and related formats.
|
|
||||||
|
|
||||||
@section chomp
|
@section chomp
|
||||||
|
|
||||||
Remove zero padding at the end of a packet.
|
@section dump_extradata
|
||||||
|
|
||||||
@section dca_core
|
|
||||||
|
|
||||||
Extract the core from a DCA/DTS stream, dropping extensions such as
|
|
||||||
DTS-HD.
|
|
||||||
|
|
||||||
@section dump_extra
|
|
||||||
|
|
||||||
Add extradata to the beginning of the filtered packets.
|
|
||||||
|
|
||||||
The additional argument specifies which packets should be filtered.
|
|
||||||
It accepts the values:
|
|
||||||
@table @samp
|
|
||||||
@item a
|
|
||||||
add extradata to all key packets, but only if @var{local_header} is
|
|
||||||
set in the @option{flags2} codec context field
|
|
||||||
|
|
||||||
@item k
|
|
||||||
add extradata to all key packets
|
|
||||||
|
|
||||||
@item e
|
|
||||||
add extradata to all packets
|
|
||||||
@end table
|
|
||||||
|
|
||||||
If not specified it is assumed @samp{k}.
|
|
||||||
|
|
||||||
For example the following @command{ffmpeg} command forces a global
|
|
||||||
header (thus disabling individual packet headers) in the H.264 packets
|
|
||||||
generated by the @code{libx264} encoder, but corrects them by adding
|
|
||||||
the header stored in extradata to the key packets:
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section extract_extradata
|
|
||||||
|
|
||||||
Extract the in-band extradata.
|
|
||||||
|
|
||||||
Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
|
|
||||||
or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
|
|
||||||
of the bitstream containing the coded frames) or "out of band" (e.g. on the
|
|
||||||
container level). This latter form is called "extradata" in FFmpeg terminology.
|
|
||||||
|
|
||||||
This bitstream filter detects the in-band headers and makes them available as
|
|
||||||
extradata.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item remove
|
|
||||||
When this option is enabled, the long-term headers are removed from the
|
|
||||||
bitstream after extraction.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section h264_mp4toannexb
|
@section h264_mp4toannexb
|
||||||
|
|
||||||
@@ -99,7 +28,7 @@ prefixed mode (as defined in the Annex B of the ITU-T H.264
|
|||||||
specification).
|
specification).
|
||||||
|
|
||||||
This is required by some streaming formats, typically the MPEG-2
|
This is required by some streaming formats, typically the MPEG-2
|
||||||
transport stream format (muxer @code{mpegts}).
|
transport stream format ("mpegts").
|
||||||
|
|
||||||
For example to remux an MP4 file containing an H.264 stream to mpegts
|
For example to remux an MP4 file containing an H.264 stream to mpegts
|
||||||
format with @command{ffmpeg}, you can use the command:
|
format with @command{ffmpeg}, you can use the command:
|
||||||
@@ -108,41 +37,7 @@ format with @command{ffmpeg}, you can use the command:
|
|||||||
ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
|
ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
Please note that this filter is auto-inserted for MPEG-TS (muxer
|
@section imx_dump_header
|
||||||
@code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
|
|
||||||
|
|
||||||
@section hevc_mp4toannexb
|
|
||||||
|
|
||||||
Convert an HEVC/H.265 bitstream from length prefixed mode to start code
|
|
||||||
prefixed mode (as defined in the Annex B of the ITU-T H.265
|
|
||||||
specification).
|
|
||||||
|
|
||||||
This is required by some streaming formats, typically the MPEG-2
|
|
||||||
transport stream format (muxer @code{mpegts}).
|
|
||||||
|
|
||||||
For example to remux an MP4 file containing an HEVC stream to mpegts
|
|
||||||
format with @command{ffmpeg}, you can use the command:
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
|
|
||||||
@end example
|
|
||||||
|
|
||||||
Please note that this filter is auto-inserted for MPEG-TS (muxer
|
|
||||||
@code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
|
|
||||||
@code{hevc}) output formats.
|
|
||||||
|
|
||||||
@section imxdump
|
|
||||||
|
|
||||||
Modifies the bitstream to fit in MOV and to be usable by the Final Cut
|
|
||||||
Pro decoder. This filter only applies to the mpeg2video codec, and is
|
|
||||||
likely not needed for Final Cut Pro 7 and newer with the appropriate
|
|
||||||
@option{-tag:v}.
|
|
||||||
|
|
||||||
For example, to remux 30 MB/sec NTSC IMX to MOV:
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section mjpeg2jpeg
|
@section mjpeg2jpeg
|
||||||
|
|
||||||
@@ -181,93 +76,16 @@ exiftran -i -9 frame*.jpg
|
|||||||
ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
|
ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section mjpegadump
|
@section mjpega_dump_header
|
||||||
|
|
||||||
Add an MJPEG A header to the bitstream, to enable decoding by
|
@section movsub
|
||||||
Quicktime.
|
|
||||||
|
|
||||||
@anchor{mov2textsub}
|
@section mp3_header_compress
|
||||||
@section mov2textsub
|
|
||||||
|
|
||||||
Extract a representable text file from MOV subtitles, stripping the
|
@section mp3_header_decompress
|
||||||
metadata header from each subtitle packet.
|
|
||||||
|
|
||||||
See also the @ref{text2movsub} filter.
|
|
||||||
|
|
||||||
@section mp3decomp
|
|
||||||
|
|
||||||
Decompress non-standard compressed MP3 audio headers.
|
|
||||||
|
|
||||||
@section mpeg4_unpack_bframes
|
|
||||||
|
|
||||||
Unpack DivX-style packed B-frames.
|
|
||||||
|
|
||||||
DivX-style packed B-frames are not valid MPEG-4 and were only a
|
|
||||||
workaround for the broken Video for Windows subsystem.
|
|
||||||
They use more space, can cause minor AV sync issues, require more
|
|
||||||
CPU power to decode (unless the player has some decoded picture queue
|
|
||||||
to compensate the 2,0,2,0 frame per packet style) and cause
|
|
||||||
trouble if copied into a standard container like mp4 or mpeg-ps/ts,
|
|
||||||
because MPEG-4 decoders may not be able to decode them, since they are
|
|
||||||
not valid MPEG-4.
|
|
||||||
|
|
||||||
For example to fix an AVI file containing an MPEG-4 stream with
|
|
||||||
DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section noise
|
@section noise
|
||||||
|
|
||||||
Damages the contents of packets without damaging the container. Can be
|
@section remove_extradata
|
||||||
used for fuzzing or testing error resilience/concealment.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
A numeral string, whose value is related to how often output bytes will
|
|
||||||
be modified. Therefore, values below or equal to 0 are forbidden, and
|
|
||||||
the lower the more frequent bytes will be modified, with 1 meaning
|
|
||||||
every byte is modified.
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
|
|
||||||
@end example
|
|
||||||
applies the modification to every byte.
|
|
||||||
|
|
||||||
@section remove_extra
|
|
||||||
|
|
||||||
Remove extradata from packets.
|
|
||||||
|
|
||||||
It accepts the following parameter:
|
|
||||||
@table @option
|
|
||||||
@item freq
|
|
||||||
Set which frame types to remove extradata from.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item k
|
|
||||||
Remove extradata from non-keyframes only.
|
|
||||||
|
|
||||||
@item keyframe
|
|
||||||
Remove extradata from keyframes only.
|
|
||||||
|
|
||||||
@item e, all
|
|
||||||
Remove extradata from all frames.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@anchor{text2movsub}
|
|
||||||
@section text2movsub
|
|
||||||
|
|
||||||
Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
|
|
||||||
codec) with metadata headers.
|
|
||||||
|
|
||||||
See also the @ref{mov2textsub} filter.
|
|
||||||
|
|
||||||
@section vp9_superframe
|
|
||||||
|
|
||||||
Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
|
|
||||||
fixes merging of split/segmented VP9 streams where the alt-ref frame
|
|
||||||
was split from its visible counterpart.
|
|
||||||
|
|
||||||
@c man end BITSTREAM FILTERS
|
@c man end BITSTREAM FILTERS
|
||||||
|
|||||||
5
doc/bootstrap.min.css
vendored
5
doc/bootstrap.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -7,55 +7,44 @@ V
|
|||||||
Disable the default terse mode, the full command issued by make and its
|
Disable the default terse mode, the full command issued by make and its
|
||||||
output will be shown on the screen.
|
output will be shown on the screen.
|
||||||
|
|
||||||
DBG
|
|
||||||
Preprocess x86 external assembler files to a .dbg.asm file in the object
|
|
||||||
directory, which then gets compiled. Helps in developing those assembler
|
|
||||||
files.
|
|
||||||
|
|
||||||
DESTDIR
|
DESTDIR
|
||||||
Destination directory for the install targets, useful to prepare packages
|
Destination directory for the install targets, useful to prepare packages
|
||||||
or install FFmpeg in cross-environments.
|
or install FFmpeg in cross-environments.
|
||||||
|
|
||||||
GEN
|
|
||||||
Set to ‘1’ to generate the missing or mismatched references.
|
|
||||||
|
|
||||||
Makefile targets:
|
Makefile targets:
|
||||||
|
|
||||||
all
|
all
|
||||||
Default target, builds all the libraries and the executables.
|
Default target, builds all the libraries and the executables.
|
||||||
|
|
||||||
fate
|
fate
|
||||||
Run the fate test suite, note that you must have installed it.
|
Run the fate test suite, note you must have installed it
|
||||||
|
|
||||||
fate-list
|
fate-list
|
||||||
List all fate/regression test targets.
|
Will list all fate/regression test targets
|
||||||
|
|
||||||
install
|
install
|
||||||
Install headers, libraries and programs.
|
Install headers, libraries and programs.
|
||||||
|
|
||||||
examples
|
|
||||||
Build all examples located in doc/examples.
|
|
||||||
|
|
||||||
libavformat/output-example
|
libavformat/output-example
|
||||||
Build the libavformat basic example.
|
Build the libavformat basic example.
|
||||||
|
|
||||||
libswscale/swscale-test
|
libavcodec/api-example
|
||||||
Build the swscale self-test (useful also as an example).
|
Build the libavcodec basic example.
|
||||||
|
|
||||||
config
|
libswscale/swscale-test
|
||||||
Reconfigure the project with the current configuration.
|
Build the swscale self-test (useful also as example).
|
||||||
|
|
||||||
|
|
||||||
Useful standard make commands:
|
Useful standard make commands:
|
||||||
make -t <target>
|
make -t <target>
|
||||||
Touch all files that otherwise would be built, this is useful to reduce
|
Touch all files that otherwise would be build, this is useful to reduce
|
||||||
unneeded rebuilding when changing headers, but note that you must force rebuilds
|
unneeded rebuilding when changing headers, but note you must force rebuilds
|
||||||
of files that actually need it by hand then.
|
of files that actually need it by hand then.
|
||||||
|
|
||||||
make -j<num>
|
make -j<num>
|
||||||
Rebuild with multiple jobs at the same time. Faster on multi processor systems.
|
rebuild with multiple jobs at the same time. Faster on multi processor systems
|
||||||
|
|
||||||
make -k
|
make -k
|
||||||
Continue build in case of errors, this is useful for the regression tests
|
continue build in case of errors, this is useful for the regression tests
|
||||||
sometimes but note that it will still not run all reg tests.
|
sometimes but note it will still not run all reg tests.
|
||||||
|
|
||||||
|
|||||||
1291
doc/codecs.texi
1291
doc/codecs.texi
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ You can disable all the decoders with the configure option
|
|||||||
with the options @code{--enable-decoder=@var{DECODER}} /
|
with the options @code{--enable-decoder=@var{DECODER}} /
|
||||||
@code{--disable-decoder=@var{DECODER}}.
|
@code{--disable-decoder=@var{DECODER}}.
|
||||||
|
|
||||||
The option @code{-decoders} of the ff* tools will display the list of
|
The option @code{-codecs} of the ff* tools will display the list of
|
||||||
enabled decoders.
|
enabled decoders.
|
||||||
|
|
||||||
@c man end DECODERS
|
@c man end DECODERS
|
||||||
@@ -25,13 +25,6 @@ enabled decoders.
|
|||||||
A description of some of the currently available video decoders
|
A description of some of the currently available video decoders
|
||||||
follows.
|
follows.
|
||||||
|
|
||||||
@section hevc
|
|
||||||
|
|
||||||
HEVC / H.265 decoder.
|
|
||||||
|
|
||||||
Note: the @option{skip_loop_filter} option has effect only at level
|
|
||||||
@code{all}.
|
|
||||||
|
|
||||||
@section rawvideo
|
@section rawvideo
|
||||||
|
|
||||||
Raw video decoder.
|
Raw video decoder.
|
||||||
@@ -59,54 +52,6 @@ top-field-first is assumed
|
|||||||
@chapter Audio Decoders
|
@chapter Audio Decoders
|
||||||
@c man begin AUDIO DECODERS
|
@c man begin AUDIO DECODERS
|
||||||
|
|
||||||
A description of some of the currently available audio decoders
|
|
||||||
follows.
|
|
||||||
|
|
||||||
@section ac3
|
|
||||||
|
|
||||||
AC-3 audio decoder.
|
|
||||||
|
|
||||||
This decoder implements part of ATSC A/52:2010 and ETSI TS 102 366, as well as
|
|
||||||
the undocumented RealAudio 3 (a.k.a. dnet).
|
|
||||||
|
|
||||||
@subsection AC-3 Decoder Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item -drc_scale @var{value}
|
|
||||||
Dynamic Range Scale Factor. The factor to apply to dynamic range values
|
|
||||||
from the AC-3 stream. This factor is applied exponentially.
|
|
||||||
There are 3 notable scale factor ranges:
|
|
||||||
@table @option
|
|
||||||
@item drc_scale == 0
|
|
||||||
DRC disabled. Produces full range audio.
|
|
||||||
@item 0 < drc_scale <= 1
|
|
||||||
DRC enabled. Applies a fraction of the stream DRC value.
|
|
||||||
Audio reproduction is between full range and full compression.
|
|
||||||
@item drc_scale > 1
|
|
||||||
DRC enabled. Applies drc_scale asymmetrically.
|
|
||||||
Loud sounds are fully compressed. Soft sounds are enhanced.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section flac
|
|
||||||
|
|
||||||
FLAC audio decoder.
|
|
||||||
|
|
||||||
This decoder aims to implement the complete FLAC specification from Xiph.
|
|
||||||
|
|
||||||
@subsection FLAC Decoder options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item -use_buggy_lpc
|
|
||||||
The lavc FLAC encoder used to produce buggy streams with high lpc values
|
|
||||||
(like the default value). This option makes it possible to decode such streams
|
|
||||||
correctly by using lavc's old buggy lpc logic for decoding.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section ffwavesynth
|
@section ffwavesynth
|
||||||
|
|
||||||
Internal wave synthetizer.
|
Internal wave synthetizer.
|
||||||
@@ -117,7 +62,7 @@ documented.
|
|||||||
|
|
||||||
@section libcelt
|
@section libcelt
|
||||||
|
|
||||||
libcelt decoder wrapper.
|
libcelt decoder wrapper
|
||||||
|
|
||||||
libcelt allows libavcodec to decode the Xiph CELT ultra-low delay audio codec.
|
libcelt allows libavcodec to decode the Xiph CELT ultra-low delay audio codec.
|
||||||
Requires the presence of the libcelt headers and library during configuration.
|
Requires the presence of the libcelt headers and library during configuration.
|
||||||
@@ -125,7 +70,7 @@ You need to explicitly configure the build with @code{--enable-libcelt}.
|
|||||||
|
|
||||||
@section libgsm
|
@section libgsm
|
||||||
|
|
||||||
libgsm decoder wrapper.
|
libgsm decoder wrapper
|
||||||
|
|
||||||
libgsm allows libavcodec to decode the GSM full rate audio codec. Requires
|
libgsm allows libavcodec to decode the GSM full rate audio codec. Requires
|
||||||
the presence of the libgsm headers and library during configuration. You need
|
the presence of the libgsm headers and library during configuration. You need
|
||||||
@@ -135,7 +80,7 @@ This decoder supports both the ordinary GSM and the Microsoft variant.
|
|||||||
|
|
||||||
@section libilbc
|
@section libilbc
|
||||||
|
|
||||||
libilbc decoder wrapper.
|
libilbc decoder wrapper
|
||||||
|
|
||||||
libilbc allows libavcodec to decode the Internet Low Bitrate Codec (iLBC)
|
libilbc allows libavcodec to decode the Internet Low Bitrate Codec (iLBC)
|
||||||
audio codec. Requires the presence of the libilbc headers and library during
|
audio codec. Requires the presence of the libilbc headers and library during
|
||||||
@@ -156,7 +101,7 @@ value is 0 (disabled).
|
|||||||
|
|
||||||
@section libopencore-amrnb
|
@section libopencore-amrnb
|
||||||
|
|
||||||
libopencore-amrnb decoder wrapper.
|
libopencore-amrnb decoder wrapper
|
||||||
|
|
||||||
libopencore-amrnb allows libavcodec to decode the Adaptive Multi-Rate
|
libopencore-amrnb allows libavcodec to decode the Adaptive Multi-Rate
|
||||||
Narrowband audio codec. Using it requires the presence of the
|
Narrowband audio codec. Using it requires the presence of the
|
||||||
@@ -187,33 +132,11 @@ Requires the presence of the libopus headers and library during
|
|||||||
configuration. You need to explicitly configure the build with
|
configuration. You need to explicitly configure the build with
|
||||||
@code{--enable-libopus}.
|
@code{--enable-libopus}.
|
||||||
|
|
||||||
An FFmpeg native decoder for Opus exists, so users can decode Opus
|
|
||||||
without this library.
|
|
||||||
|
|
||||||
@c man end AUDIO DECODERS
|
@c man end AUDIO DECODERS
|
||||||
|
|
||||||
@chapter Subtitles Decoders
|
@chapter Subtitles Decoders
|
||||||
@c man begin SUBTILES DECODERS
|
@c man begin SUBTILES DECODERS
|
||||||
|
|
||||||
@section dvbsub
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item compute_clut
|
|
||||||
@table @option
|
|
||||||
@item -1
|
|
||||||
Compute clut if no matching CLUT is in the stream.
|
|
||||||
@item 0
|
|
||||||
Never compute CLUT
|
|
||||||
@item 1
|
|
||||||
Always compute CLUT and override the one provided in the stream.
|
|
||||||
@end table
|
|
||||||
@item dvb_substream
|
|
||||||
Selects the dvb substream, or all substreams if -1 which is default.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section dvdsub
|
@section dvdsub
|
||||||
|
|
||||||
This codec decodes the bitmap subtitles used in DVDs; the same subtitles can
|
This codec decodes the bitmap subtitles used in DVDs; the same subtitles can
|
||||||
@@ -233,62 +156,6 @@ The format for this option is a string containing 16 24-bits hexadecimal
|
|||||||
numbers (without 0x prefix) separated by comas, for example @code{0d00ee,
|
numbers (without 0x prefix) separated by comas, for example @code{0d00ee,
|
||||||
ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1,
|
ee450d, 101010, eaeaea, 0ce60b, ec14ed, ebff0b, 0d617a, 7b7b7b, d1d1d1,
|
||||||
7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}.
|
7b2a0e, 0d950c, 0f007b, cf0dec, cfa80c, 7c127b}.
|
||||||
|
|
||||||
@item ifo_palette
|
|
||||||
Specify the IFO file from which the global palette is obtained.
|
|
||||||
(experimental)
|
|
||||||
|
|
||||||
@item forced_subs_only
|
|
||||||
Only decode subtitle entries marked as forced. Some titles have forced
|
|
||||||
and non-forced subtitles in the same track. Setting this flag to @code{1}
|
|
||||||
will only keep the forced subtitles. Default value is @code{0}.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section libzvbi-teletext
|
|
||||||
|
|
||||||
Libzvbi allows libavcodec to decode DVB teletext pages and DVB teletext
|
|
||||||
subtitles. Requires the presence of the libzvbi headers and library during
|
|
||||||
configuration. You need to explicitly configure the build with
|
|
||||||
@code{--enable-libzvbi}.
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item txt_page
|
|
||||||
List of teletext page numbers to decode. You may use the special * string to
|
|
||||||
match all pages. Pages that do not match the specified list are dropped.
|
|
||||||
Default value is *.
|
|
||||||
@item txt_chop_top
|
|
||||||
Discards the top teletext line. Default value is 1.
|
|
||||||
@item txt_format
|
|
||||||
Specifies the format of the decoded subtitles. The teletext decoder is capable
|
|
||||||
of decoding the teletext pages to bitmaps or to simple text, you should use
|
|
||||||
"bitmap" for teletext pages, because certain graphics and colors cannot be
|
|
||||||
expressed in simple text. You might use "text" for teletext based subtitles if
|
|
||||||
your application can handle simple text based subtitles. Default value is
|
|
||||||
bitmap.
|
|
||||||
@item txt_left
|
|
||||||
X offset of generated bitmaps, default is 0.
|
|
||||||
@item txt_top
|
|
||||||
Y offset of generated bitmaps, default is 0.
|
|
||||||
@item txt_chop_spaces
|
|
||||||
Chops leading and trailing spaces and removes empty lines from the generated
|
|
||||||
text. This option is useful for teletext based subtitles where empty spaces may
|
|
||||||
be present at the start or at the end of the lines or empty lines may be
|
|
||||||
present between the subtitle lines because of double-sized teletext charactes.
|
|
||||||
Default value is 1.
|
|
||||||
@item txt_duration
|
|
||||||
Sets the display duration of the decoded teletext pages or subtitles in
|
|
||||||
milliseconds. Default value is 30000 which is 30 seconds.
|
|
||||||
@item txt_transparent
|
|
||||||
Force transparent background of the generated teletext bitmaps. Default value
|
|
||||||
is 0 which means an opaque background.
|
|
||||||
@item txt_opacity
|
|
||||||
Sets the opacity (0-255) of the teletext background. If
|
|
||||||
@option{txt_transparent} is not set, it only affects characters between a start
|
|
||||||
box and an end box, typically subtitles. Default value is 0 if
|
|
||||||
@option{txt_transparent} is set, 255 otherwise.
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@c man end SUBTILES DECODERS
|
@c man end SUBTILES DECODERS
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
a.summary-letter {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #2D6198;
|
color: #2D6198;
|
||||||
}
|
}
|
||||||
@@ -17,8 +13,8 @@ a:visited {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#banner img {
|
#banner img {
|
||||||
margin-bottom: 1px;
|
padding-bottom: 1px;
|
||||||
margin-top: 5px;
|
padding-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#body {
|
#body {
|
||||||
@@ -49,16 +45,11 @@ body {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 a, h2 a, h3 a, h4 a {
|
h1, h2, h3 {
|
||||||
text-decoration: inherit;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, h2, h3, h4 {
|
|
||||||
padding-left: 0.4em;
|
padding-left: 0.4em;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding-bottom: 0.25em;
|
padding-bottom: 0.2em;
|
||||||
padding-top: 0.25em;
|
padding-top: 0.2em;
|
||||||
border: 1px solid #6A996A;
|
border: 1px solid #6A996A;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,22 +63,15 @@ h1 {
|
|||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
color: #313131;
|
color: #313131;
|
||||||
font-size: 1.0em;
|
font-size: 0.9em;
|
||||||
background-color: #ABE3AB;
|
background-color: #ABE3AB;
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
color: #313131;
|
|
||||||
font-size: 0.9em;
|
|
||||||
margin-bottom: -6px;
|
|
||||||
background-color: #BBF3BB;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
color: #313131;
|
color: #313131;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
margin-bottom: -8px;
|
margin-bottom: -8px;
|
||||||
background-color: #D1FDD1;
|
background-color: #BBF3BB;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
@chapter Demuxers
|
@chapter Demuxers
|
||||||
@c man begin DEMUXERS
|
@c man begin DEMUXERS
|
||||||
|
|
||||||
Demuxers are configured elements in FFmpeg that can read the
|
Demuxers are configured elements in FFmpeg which allow to read the
|
||||||
multimedia streams from a particular type of file.
|
multimedia streams from a particular type of file.
|
||||||
|
|
||||||
When you configure your FFmpeg build, all the supported demuxers
|
When you configure your FFmpeg build, all the supported demuxers
|
||||||
@@ -13,18 +13,11 @@ You can disable all the demuxers using the configure option
|
|||||||
the option @code{--enable-demuxer=@var{DEMUXER}}, or disable it
|
the option @code{--enable-demuxer=@var{DEMUXER}}, or disable it
|
||||||
with the option @code{--disable-demuxer=@var{DEMUXER}}.
|
with the option @code{--disable-demuxer=@var{DEMUXER}}.
|
||||||
|
|
||||||
The option @code{-demuxers} of the ff* tools will display the list of
|
The option @code{-formats} of the ff* tools will display the list of
|
||||||
enabled demuxers. Use @code{-formats} to view a combined list of
|
enabled demuxers.
|
||||||
enabled demuxers and muxers.
|
|
||||||
|
|
||||||
The description of some of the currently available demuxers follows.
|
The description of some of the currently available demuxers follows.
|
||||||
|
|
||||||
@section aa
|
|
||||||
|
|
||||||
Audible Format 2, 3, and 4 demuxer.
|
|
||||||
|
|
||||||
This demuxer is used to demux Audible Format 2, 3, and 4 (.aa) files.
|
|
||||||
|
|
||||||
@section applehttp
|
@section applehttp
|
||||||
|
|
||||||
Apple HTTP Live Streaming demuxer.
|
Apple HTTP Live Streaming demuxer.
|
||||||
@@ -36,44 +29,13 @@ the caller can decide which variant streams to actually receive.
|
|||||||
The total bitrate of the variant that the stream belongs to is
|
The total bitrate of the variant that the stream belongs to is
|
||||||
available in a metadata key named "variant_bitrate".
|
available in a metadata key named "variant_bitrate".
|
||||||
|
|
||||||
@section apng
|
|
||||||
|
|
||||||
Animated Portable Network Graphics demuxer.
|
|
||||||
|
|
||||||
This demuxer is used to demux APNG files.
|
|
||||||
All headers, but the PNG signature, up to (but not including) the first
|
|
||||||
fcTL chunk are transmitted as extradata.
|
|
||||||
Frames are then split as being all the chunks between two fcTL ones, or
|
|
||||||
between the last fcTL and IEND chunks.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item -ignore_loop @var{bool}
|
|
||||||
Ignore the loop variable in the file if set.
|
|
||||||
@item -max_fps @var{int}
|
|
||||||
Maximum framerate in frames per second (0 for no limit).
|
|
||||||
@item -default_fps @var{int}
|
|
||||||
Default framerate in frames per second when none is specified in the file
|
|
||||||
(0 meaning as fast as possible).
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section asf
|
|
||||||
|
|
||||||
Advanced Systems Format demuxer.
|
|
||||||
|
|
||||||
This demuxer is used to demux ASF files and MMS network streams.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item -no_resync_search @var{bool}
|
|
||||||
Do not try to resynchronize by looking for a certain optional start code.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@anchor{concat}
|
@anchor{concat}
|
||||||
@section concat
|
@section concat
|
||||||
|
|
||||||
Virtual concatenation script demuxer.
|
Virtual concatenation script demuxer.
|
||||||
|
|
||||||
This demuxer reads a list of files and other directives from a text file and
|
This demuxer reads a list of files and other directives from a text file and
|
||||||
demuxes them one after the other, as if all their packets had been muxed
|
demuxes them one after the other, as if all their packet had been muxed
|
||||||
together.
|
together.
|
||||||
|
|
||||||
The timestamps in the files are adjusted so that the first file starts at 0
|
The timestamps in the files are adjusted so that the first file starts at 0
|
||||||
@@ -101,14 +63,14 @@ following directive is recognized:
|
|||||||
Path to a file to read; special characters and spaces must be escaped with
|
Path to a file to read; special characters and spaces must be escaped with
|
||||||
backslash or single quotes.
|
backslash or single quotes.
|
||||||
|
|
||||||
All subsequent file-related directives apply to that file.
|
All subsequent directives apply to that file.
|
||||||
|
|
||||||
@item @code{ffconcat version 1.0}
|
@item @code{ffconcat version 1.0}
|
||||||
Identify the script type and version. It also sets the @option{safe} option
|
Identify the script type and version. It also sets the @option{safe} option
|
||||||
to 1 if it was -1.
|
to 1 if it was to its default -1.
|
||||||
|
|
||||||
To make FFmpeg recognize the format automatically, this directive must
|
To make FFmpeg recognize the format automatically, this directive must
|
||||||
appear exactly as is (no extra space or byte-order-mark) on the very first
|
appears exactly as is (no extra space or byte-order-mark) on the very first
|
||||||
line of the script.
|
line of the script.
|
||||||
|
|
||||||
@item @code{duration @var{dur}}
|
@item @code{duration @var{dur}}
|
||||||
@@ -116,66 +78,6 @@ Duration of the file. This information can be specified from the file;
|
|||||||
specifying it here may be more efficient or help if the information from the
|
specifying it here may be more efficient or help if the information from the
|
||||||
file is not available or accurate.
|
file is not available or accurate.
|
||||||
|
|
||||||
If the duration is set for all files, then it is possible to seek in the
|
|
||||||
whole concatenated video.
|
|
||||||
|
|
||||||
@item @code{inpoint @var{timestamp}}
|
|
||||||
In point of the file. When the demuxer opens the file it instantly seeks to the
|
|
||||||
specified timestamp. Seeking is done so that all streams can be presented
|
|
||||||
successfully at In point.
|
|
||||||
|
|
||||||
This directive works best with intra frame codecs, because for non-intra frame
|
|
||||||
ones you will usually get extra packets before the actual In point and the
|
|
||||||
decoded content will most likely contain frames before In point too.
|
|
||||||
|
|
||||||
For each file, packets before the file In point will have timestamps less than
|
|
||||||
the calculated start timestamp of the file (negative in case of the first
|
|
||||||
file), and the duration of the files (if not specified by the @code{duration}
|
|
||||||
directive) will be reduced based on their specified In point.
|
|
||||||
|
|
||||||
Because of potential packets before the specified In point, packet timestamps
|
|
||||||
may overlap between two concatenated files.
|
|
||||||
|
|
||||||
@item @code{outpoint @var{timestamp}}
|
|
||||||
Out point of the file. When the demuxer reaches the specified decoding
|
|
||||||
timestamp in any of the streams, it handles it as an end of file condition and
|
|
||||||
skips the current and all the remaining packets from all streams.
|
|
||||||
|
|
||||||
Out point is exclusive, which means that the demuxer will not output packets
|
|
||||||
with a decoding timestamp greater or equal to Out point.
|
|
||||||
|
|
||||||
This directive works best with intra frame codecs and formats where all streams
|
|
||||||
are tightly interleaved. For non-intra frame codecs you will usually get
|
|
||||||
additional packets with presentation timestamp after Out point therefore the
|
|
||||||
decoded content will most likely contain frames after Out point too. If your
|
|
||||||
streams are not tightly interleaved you may not get all the packets from all
|
|
||||||
streams before Out point and you may only will be able to decode the earliest
|
|
||||||
stream until Out point.
|
|
||||||
|
|
||||||
The duration of the files (if not specified by the @code{duration}
|
|
||||||
directive) will be reduced based on their specified Out point.
|
|
||||||
|
|
||||||
@item @code{file_packet_metadata @var{key=value}}
|
|
||||||
Metadata of the packets of the file. The specified metadata will be set for
|
|
||||||
each file packet. You can specify this directive multiple times to add multiple
|
|
||||||
metadata entries.
|
|
||||||
|
|
||||||
@item @code{stream}
|
|
||||||
Introduce a stream in the virtual file.
|
|
||||||
All subsequent stream-related directives apply to the last introduced
|
|
||||||
stream.
|
|
||||||
Some streams properties must be set in order to allow identifying the
|
|
||||||
matching streams in the subfiles.
|
|
||||||
If no streams are defined in the script, the streams from the first file are
|
|
||||||
copied.
|
|
||||||
|
|
||||||
@item @code{exact_stream_id @var{id}}
|
|
||||||
Set the id of the stream.
|
|
||||||
If this directive is given, the string with the corresponding id in the
|
|
||||||
subfiles will be used.
|
|
||||||
This is especially useful for MPEG-PS (VOB) files, where the order of the
|
|
||||||
streams is not reliable.
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Options
|
@subsection Options
|
||||||
@@ -193,113 +95,11 @@ component.
|
|||||||
|
|
||||||
If set to 0, any file name is accepted.
|
If set to 0, any file name is accepted.
|
||||||
|
|
||||||
The default is 1.
|
The default is -1, it is equivalent to 1 if the format was automatically
|
||||||
|
|
||||||
-1 is equivalent to 1 if the format was automatically
|
|
||||||
probed and 0 otherwise.
|
probed and 0 otherwise.
|
||||||
|
|
||||||
@item auto_convert
|
|
||||||
If set to 1, try to perform automatic conversions on packet data to make the
|
|
||||||
streams concatenable.
|
|
||||||
The default is 1.
|
|
||||||
|
|
||||||
Currently, the only conversion is adding the h264_mp4toannexb bitstream
|
|
||||||
filter to H.264 streams in MP4 format. This is necessary in particular if
|
|
||||||
there are resolution changes.
|
|
||||||
|
|
||||||
@item segment_time_metadata
|
|
||||||
If set to 1, every packet will contain the @var{lavf.concat.start_time} and the
|
|
||||||
@var{lavf.concat.duration} packet metadata values which are the start_time and
|
|
||||||
the duration of the respective file segments in the concatenated output
|
|
||||||
expressed in microseconds. The duration metadata is only set if it is known
|
|
||||||
based on the concat file.
|
|
||||||
The default is 0.
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Examples
|
|
||||||
|
|
||||||
@itemize
|
|
||||||
@item
|
|
||||||
Use absolute filenames and include some comments:
|
|
||||||
@example
|
|
||||||
# my first filename
|
|
||||||
file /mnt/share/file-1.wav
|
|
||||||
# my second filename including whitespace
|
|
||||||
file '/mnt/share/file 2.wav'
|
|
||||||
# my third filename including whitespace plus single quote
|
|
||||||
file '/mnt/share/file 3'\''.wav'
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@item
|
|
||||||
Allow for input format auto-probing, use safe filenames and set the duration of
|
|
||||||
the first file:
|
|
||||||
@example
|
|
||||||
ffconcat version 1.0
|
|
||||||
|
|
||||||
file file-1.wav
|
|
||||||
duration 20.0
|
|
||||||
|
|
||||||
file subdir/file-2.wav
|
|
||||||
@end example
|
|
||||||
@end itemize
|
|
||||||
|
|
||||||
@section flv, live_flv
|
|
||||||
|
|
||||||
Adobe Flash Video Format demuxer.
|
|
||||||
|
|
||||||
This demuxer is used to demux FLV files and RTMP network streams. In case of live network streams, if you force format, you may use live_flv option instead of flv to survive timestamp discontinuities.
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -f flv -i myfile.flv ...
|
|
||||||
ffmpeg -f live_flv -i rtmp://<any.server>/anything/key ....
|
|
||||||
@end example
|
|
||||||
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item -flv_metadata @var{bool}
|
|
||||||
Allocate the streams according to the onMetaData array content.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section gif
|
|
||||||
|
|
||||||
Animated GIF demuxer.
|
|
||||||
|
|
||||||
It accepts the following options:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item min_delay
|
|
||||||
Set the minimum valid delay between frames in hundredths of seconds.
|
|
||||||
Range is 0 to 6000. Default value is 2.
|
|
||||||
|
|
||||||
@item max_gif_delay
|
|
||||||
Set the maximum valid delay between frames in hundredth of seconds.
|
|
||||||
Range is 0 to 65535. Default value is 65535 (nearly eleven minutes),
|
|
||||||
the maximum value allowed by the specification.
|
|
||||||
|
|
||||||
@item default_delay
|
|
||||||
Set the default delay between frames in hundredths of seconds.
|
|
||||||
Range is 0 to 6000. Default value is 10.
|
|
||||||
|
|
||||||
@item ignore_loop
|
|
||||||
GIF files can contain information to loop a certain number of times (or
|
|
||||||
infinitely). If @option{ignore_loop} is set to 1, then the loop setting
|
|
||||||
from the input will be ignored and looping will not occur. If set to 0,
|
|
||||||
then looping will occur and will cycle the number of times according to
|
|
||||||
the GIF. Default value is 1.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
For example, with the overlay filter, place an infinitely looping GIF
|
|
||||||
over another video:
|
|
||||||
@example
|
|
||||||
ffmpeg -i input.mp4 -ignore_loop 0 -i input.gif -filter_complex overlay=shortest=1 out.mkv
|
|
||||||
@end example
|
|
||||||
|
|
||||||
Note that in the above example the shortest option for overlay filter is
|
|
||||||
used to end the output video at the length of the shortest input file,
|
|
||||||
which in this case is @file{input.mp4} as the GIF in this example loops
|
|
||||||
infinitely.
|
|
||||||
|
|
||||||
@section image2
|
@section image2
|
||||||
|
|
||||||
Image file demuxer.
|
Image file demuxer.
|
||||||
@@ -317,7 +117,7 @@ same for all the files in the sequence.
|
|||||||
This demuxer accepts the following options:
|
This demuxer accepts the following options:
|
||||||
@table @option
|
@table @option
|
||||||
@item framerate
|
@item framerate
|
||||||
Set the frame rate for the video stream. It defaults to 25.
|
Set the framerate for the video stream. It defaults to 25.
|
||||||
@item loop
|
@item loop
|
||||||
If set to 1, loop over the input. Default value is 0.
|
If set to 1, loop over the input. Default value is 0.
|
||||||
@item pattern_type
|
@item pattern_type
|
||||||
@@ -325,10 +125,6 @@ Select the pattern type used to interpret the provided filename.
|
|||||||
|
|
||||||
@var{pattern_type} accepts one of the following values.
|
@var{pattern_type} accepts one of the following values.
|
||||||
@table @option
|
@table @option
|
||||||
@item none
|
|
||||||
Disable pattern matching, therefore the video will only contain the specified
|
|
||||||
image. You should use this option if you do not want to create sequences from
|
|
||||||
multiple images and your filenames may contain special pattern characters.
|
|
||||||
@item sequence
|
@item sequence
|
||||||
Select a sequence pattern type, used to specify a sequence of files
|
Select a sequence pattern type, used to specify a sequence of files
|
||||||
indexed by sequential numbers.
|
indexed by sequential numbers.
|
||||||
@@ -399,12 +195,6 @@ to read from. Default value is 0.
|
|||||||
Set the index interval range to check when looking for the first image
|
Set the index interval range to check when looking for the first image
|
||||||
file in the sequence, starting from @var{start_number}. Default value
|
file in the sequence, starting from @var{start_number}. Default value
|
||||||
is 5.
|
is 5.
|
||||||
@item ts_from_file
|
|
||||||
If set to 1, will set frame timestamp to modification time of image file. Note
|
|
||||||
that monotonity of timestamps is not provided: images go in the same order as
|
|
||||||
without this option. Default value is 0.
|
|
||||||
If set to 2, will set frame timestamp to the modification time of the image file in
|
|
||||||
nanosecond precision.
|
|
||||||
@item video_size
|
@item video_size
|
||||||
Set the video size of the images to read. If not specified the video
|
Set the video size of the images to read. If not specified the video
|
||||||
size is guessed from the first image file in the sequence.
|
size is guessed from the first image file in the sequence.
|
||||||
@@ -418,126 +208,28 @@ Use @command{ffmpeg} for creating a video from the images in the file
|
|||||||
sequence @file{img-001.jpeg}, @file{img-002.jpeg}, ..., assuming an
|
sequence @file{img-001.jpeg}, @file{img-002.jpeg}, ..., assuming an
|
||||||
input frame rate of 10 frames per second:
|
input frame rate of 10 frames per second:
|
||||||
@example
|
@example
|
||||||
ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv
|
ffmpeg -i 'img-%03d.jpeg' -r 10 out.mkv
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@item
|
@item
|
||||||
As above, but start by reading from a file with index 100 in the sequence:
|
As above, but start by reading from a file with index 100 in the sequence:
|
||||||
@example
|
@example
|
||||||
ffmpeg -framerate 10 -start_number 100 -i 'img-%03d.jpeg' out.mkv
|
ffmpeg -start_number 100 -i 'img-%03d.jpeg' -r 10 out.mkv
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Read images matching the "*.png" glob pattern , that is all the files
|
Read images matching the "*.png" glob pattern , that is all the files
|
||||||
terminating with the ".png" suffix:
|
terminating with the ".png" suffix:
|
||||||
@example
|
@example
|
||||||
ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv
|
ffmpeg -pattern_type glob -i "*.png" -r 10 out.mkv
|
||||||
@end example
|
@end example
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@section libgme
|
|
||||||
|
|
||||||
The Game Music Emu library is a collection of video game music file emulators.
|
|
||||||
|
|
||||||
See @url{http://code.google.com/p/game-music-emu/} for more information.
|
|
||||||
|
|
||||||
Some files have multiple tracks. The demuxer will pick the first track by
|
|
||||||
default. The @option{track_index} option can be used to select a different
|
|
||||||
track. Track indexes start at 0. The demuxer exports the number of tracks as
|
|
||||||
@var{tracks} meta data entry.
|
|
||||||
|
|
||||||
For very large files, the @option{max_size} option may have to be adjusted.
|
|
||||||
|
|
||||||
@section libopenmpt
|
|
||||||
|
|
||||||
libopenmpt based module demuxer
|
|
||||||
|
|
||||||
See @url{https://lib.openmpt.org/libopenmpt/} for more information.
|
|
||||||
|
|
||||||
Some files have multiple subsongs (tracks) this can be set with the @option{subsong}
|
|
||||||
option.
|
|
||||||
|
|
||||||
It accepts the following options:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item subsong
|
|
||||||
Set the subsong index. This can be either 'all', 'auto', or the index of the
|
|
||||||
subsong. Subsong indexes start at 0. The default is 'auto'.
|
|
||||||
|
|
||||||
The default value is to let libopenmpt choose.
|
|
||||||
|
|
||||||
@item layout
|
|
||||||
Set the channel layout. Valid values are 1, 2, and 4 channel layouts.
|
|
||||||
The default value is STEREO.
|
|
||||||
|
|
||||||
@item sample_rate
|
|
||||||
Set the sample rate for libopenmpt to output.
|
|
||||||
Range is from 1000 to INT_MAX. The value default is 48000.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section mov/mp4/3gp/QuickTime
|
|
||||||
|
|
||||||
QuickTime / MP4 demuxer.
|
|
||||||
|
|
||||||
This demuxer accepts the following options:
|
|
||||||
@table @option
|
|
||||||
@item enable_drefs
|
|
||||||
Enable loading of external tracks, disabled by default.
|
|
||||||
Enabling this can theoretically leak information in some use cases.
|
|
||||||
|
|
||||||
@item use_absolute_path
|
|
||||||
Allows loading of external tracks via absolute paths, disabled by default.
|
|
||||||
Enabling this poses a security risk. It should only be enabled if the source
|
|
||||||
is known to be non malicious.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section mpegts
|
|
||||||
|
|
||||||
MPEG-2 transport stream demuxer.
|
|
||||||
|
|
||||||
This demuxer accepts the following options:
|
|
||||||
@table @option
|
|
||||||
@item resync_size
|
|
||||||
Set size limit for looking up a new synchronization. Default value is
|
|
||||||
65536.
|
|
||||||
|
|
||||||
@item fix_teletext_pts
|
|
||||||
Override teletext packet PTS and DTS values with the timestamps calculated
|
|
||||||
from the PCR of the first program which the teletext stream is part of and is
|
|
||||||
not discarded. Default value is 1, set this option to 0 if you want your
|
|
||||||
teletext packet PTS and DTS values untouched.
|
|
||||||
|
|
||||||
@item ts_packetsize
|
|
||||||
Output option carrying the raw packet size in bytes.
|
|
||||||
Show the detected raw packet size, cannot be set by the user.
|
|
||||||
|
|
||||||
@item scan_all_pmts
|
|
||||||
Scan and combine all PMTs. The value is an integer with value from -1
|
|
||||||
to 1 (-1 means automatic setting, 1 means enabled, 0 means
|
|
||||||
disabled). Default value is -1.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section mpjpeg
|
|
||||||
|
|
||||||
MJPEG encapsulated in multi-part MIME demuxer.
|
|
||||||
|
|
||||||
This demuxer allows reading of MJPEG, where each frame is represented as a part of
|
|
||||||
multipart/x-mixed-replace stream.
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item strict_mime_boundary
|
|
||||||
Default implementation applies a relaxed standard to multi-part MIME boundary detection,
|
|
||||||
to prevent regression with numerous existing endpoints not generating a proper MIME
|
|
||||||
MJPEG stream. Turning this option on by setting it to 1 will result in a stricter check
|
|
||||||
of the boundary value.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section rawvideo
|
@section rawvideo
|
||||||
|
|
||||||
Raw video demuxer.
|
Raw video demuxer.
|
||||||
|
|
||||||
This demuxer allows one to read raw video data. Since there is no header
|
This demuxer allows to read raw video data. Since there is no header
|
||||||
specifying the assumed video parameters, the user must specify them
|
specifying the assumed video parameters, the user must specify them
|
||||||
in order to be able to decode the data correctly.
|
in order to be able to decode the data correctly.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
\input texinfo @c -*- texinfo -*-
|
\input texinfo @c -*- texinfo -*-
|
||||||
@documentencoding UTF-8
|
|
||||||
|
|
||||||
@settitle Developer Documentation
|
@settitle Developer Documentation
|
||||||
@titlepage
|
@titlepage
|
||||||
@@ -12,30 +11,36 @@
|
|||||||
|
|
||||||
@chapter Developers Guide
|
@chapter Developers Guide
|
||||||
|
|
||||||
@section Notes for external developers
|
@section API
|
||||||
|
@itemize @bullet
|
||||||
|
@item libavcodec is the library containing the codecs (both encoding and
|
||||||
|
decoding). Look at @file{doc/examples/decoding_encoding.c} to see how to use
|
||||||
|
it.
|
||||||
|
|
||||||
This document is mostly useful for internal FFmpeg developers.
|
@item libavformat is the library containing the file format handling (mux and
|
||||||
External developers who need to use the API in their application should
|
demux code for several formats). Look at @file{ffplay.c} to use it in a
|
||||||
refer to the API doxygen documentation in the public headers, and
|
player. See @file{doc/examples/muxing.c} to use it to generate audio or video
|
||||||
check the examples in @file{doc/examples} and in the source code to
|
streams.
|
||||||
see how the public API is employed.
|
|
||||||
|
|
||||||
You can use the FFmpeg libraries in your commercial program, but you
|
@end itemize
|
||||||
are encouraged to @emph{publish any patch you make}. In this case the
|
|
||||||
best way to proceed is to send your patches to the ffmpeg-devel
|
|
||||||
mailing list following the guidelines illustrated in the remainder of
|
|
||||||
this document.
|
|
||||||
|
|
||||||
For more detailed legal information about the use of FFmpeg in
|
@section Integrating libavcodec or libavformat in your program
|
||||||
external programs read the @file{LICENSE} file in the source tree and
|
|
||||||
consult @url{https://ffmpeg.org/legal.html}.
|
You can integrate all the source code of the libraries to link them
|
||||||
|
statically to avoid any version problem. All you need is to provide a
|
||||||
|
'config.mak' and a 'config.h' in the parent directory. See the defines
|
||||||
|
generated by ./configure to understand what is needed.
|
||||||
|
|
||||||
|
You can use libavcodec or libavformat in your commercial program, but
|
||||||
|
@emph{any patch you make must be published}. The best way to proceed is
|
||||||
|
to send your patches to the FFmpeg mailing list.
|
||||||
|
|
||||||
@section Contributing
|
@section Contributing
|
||||||
|
|
||||||
There are 3 ways by which code gets into FFmpeg.
|
There are 3 ways by which code gets into ffmpeg.
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item Submitting patches to the main developer mailing list.
|
@item Submitting Patches to the main developer mailing list
|
||||||
See @ref{Submitting patches} for details.
|
see @ref{Submitting patches} for details.
|
||||||
@item Directly committing changes to the main tree.
|
@item Directly committing changes to the main tree.
|
||||||
@item Committing changes to a git clone, for example on github.com or
|
@item Committing changes to a git clone, for example on github.com or
|
||||||
gitorious.org. And asking us to merge these changes.
|
gitorious.org. And asking us to merge these changes.
|
||||||
@@ -52,22 +57,16 @@ and should try to fix issues their commit causes.
|
|||||||
@subsection Code formatting conventions
|
@subsection Code formatting conventions
|
||||||
|
|
||||||
There are the following guidelines regarding the indentation in files:
|
There are the following guidelines regarding the indentation in files:
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
Indent size is 4.
|
Indent size is 4.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
The TAB character is forbidden outside of Makefiles as is any
|
The TAB character is forbidden outside of Makefiles as is any
|
||||||
form of trailing whitespace. Commits containing either will be
|
form of trailing whitespace. Commits containing either will be
|
||||||
rejected by the git repository.
|
rejected by the git repository.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
You should try to limit your code lines to 80 characters; however, do so if
|
You should try to limit your code lines to 80 characters; however, do so if
|
||||||
and only if this improves readability.
|
and only if this improves readability.
|
||||||
|
|
||||||
@item
|
|
||||||
K&R coding style is used.
|
|
||||||
@end itemize
|
@end itemize
|
||||||
The presentation is one inspired by 'indent -i4 -kr -nut'.
|
The presentation is one inspired by 'indent -i4 -kr -nut'.
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ for markup commands, i.e. use @code{@@param} and not @code{\param}.
|
|||||||
* more text ...
|
* more text ...
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
typedef struct Foobar @{
|
typedef struct Foobar@{
|
||||||
int var1; /**< var1 description */
|
int var1; /**< var1 description */
|
||||||
int var2; ///< var2 description
|
int var2; ///< var2 description
|
||||||
/** var3 description */
|
/** var3 description */
|
||||||
@@ -118,24 +117,15 @@ int myfunc(int my_parameter)
|
|||||||
|
|
||||||
FFmpeg is programmed in the ISO C90 language with a few additional
|
FFmpeg is programmed in the ISO C90 language with a few additional
|
||||||
features from ISO C99, namely:
|
features from ISO C99, namely:
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
the @samp{inline} keyword;
|
the @samp{inline} keyword;
|
||||||
|
|
||||||
@item
|
@item
|
||||||
@samp{//} comments;
|
@samp{//} comments;
|
||||||
|
|
||||||
@item
|
@item
|
||||||
designated struct initializers (@samp{struct s x = @{ .i = 17 @};});
|
designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
|
||||||
|
|
||||||
@item
|
@item
|
||||||
compound literals (@samp{x = (struct s) @{ 17, 23 @};}).
|
compound literals (@samp{x = (struct s) @{ 17, 23 @};})
|
||||||
|
|
||||||
@item
|
|
||||||
Implementation defined behavior for signed integers is assumed to match the
|
|
||||||
expected behavior for two's complement. Non representable values in integer
|
|
||||||
casts are binary truncated. Shift right of signed values uses sign extension.
|
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
These features are supported by all compilers we care about, so we will not
|
These features are supported by all compilers we care about, so we will not
|
||||||
@@ -145,17 +135,13 @@ clarity and performance.
|
|||||||
All code must compile with recent versions of GCC and a number of other
|
All code must compile with recent versions of GCC and a number of other
|
||||||
currently supported compilers. To ensure compatibility, please do not use
|
currently supported compilers. To ensure compatibility, please do not use
|
||||||
additional C99 features or GCC extensions. Especially watch out for:
|
additional C99 features or GCC extensions. Especially watch out for:
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
mixing statements and declarations;
|
mixing statements and declarations;
|
||||||
|
|
||||||
@item
|
@item
|
||||||
@samp{long long} (use @samp{int64_t} instead);
|
@samp{long long} (use @samp{int64_t} instead);
|
||||||
|
|
||||||
@item
|
@item
|
||||||
@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
|
@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
|
||||||
|
|
||||||
@item
|
@item
|
||||||
GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
|
GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
|
||||||
@end itemize
|
@end itemize
|
||||||
@@ -164,28 +150,20 @@ GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
|
|||||||
All names should be composed with underscores (_), not CamelCase. For example,
|
All names should be composed with underscores (_), not CamelCase. For example,
|
||||||
@samp{avfilter_get_video_buffer} is an acceptable function name and
|
@samp{avfilter_get_video_buffer} is an acceptable function name and
|
||||||
@samp{AVFilterGetVideo} is not. The exception from this are type names, like
|
@samp{AVFilterGetVideo} is not. The exception from this are type names, like
|
||||||
for example structs and enums; they should always be in CamelCase.
|
for example structs and enums; they should always be in the CamelCase
|
||||||
|
|
||||||
There are the following conventions for naming variables and functions:
|
There are the following conventions for naming variables and functions:
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
For local variables no prefix is required.
|
For local variables no prefix is required.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
For file-scope variables and functions declared as @code{static}, no prefix
|
For variables and functions declared as @code{static} no prefix is required.
|
||||||
is required.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
For variables and functions visible outside of file scope, but only used
|
For variables and functions used internally by a library an @code{ff_}
|
||||||
internally by a library, an @code{ff_} prefix should be used,
|
prefix should be used, e.g. @samp{ff_w64_demuxer}.
|
||||||
e.g. @samp{ff_w64_demuxer}.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
For variables and functions visible outside of file scope, used internally
|
For variables and functions used internally across multiple libraries, use
|
||||||
across multiple libraries, use @code{avpriv_} as prefix, for example,
|
@code{avpriv_}. For example, @samp{avpriv_aac_parse_header}.
|
||||||
@samp{avpriv_aac_parse_header}.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Each library has its own prefix for public symbols, in addition to the
|
Each library has its own prefix for public symbols, in addition to the
|
||||||
commonly used @code{av_} (@code{avformat_} for libavformat,
|
commonly used @code{av_} (@code{avformat_} for libavformat,
|
||||||
@@ -205,12 +183,10 @@ are reserved at the file level and may not be used for externally visible
|
|||||||
symbols. If in doubt, just avoid names starting with @code{_} altogether.
|
symbols. If in doubt, just avoid names starting with @code{_} altogether.
|
||||||
|
|
||||||
@subsection Miscellaneous conventions
|
@subsection Miscellaneous conventions
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
fprintf and printf are forbidden in libavformat and libavcodec,
|
fprintf and printf are forbidden in libavformat and libavcodec,
|
||||||
please use av_log() instead.
|
please use av_log() instead.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Casts should be used only when necessary. Unneeded parentheses
|
Casts should be used only when necessary. Unneeded parentheses
|
||||||
should also be avoided if they don't make the code easier to understand.
|
should also be avoided if they don't make the code easier to understand.
|
||||||
@@ -236,7 +212,7 @@ autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@@<!$/
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
|
For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
|
||||||
@lisp
|
@example
|
||||||
(c-add-style "ffmpeg"
|
(c-add-style "ffmpeg"
|
||||||
'("k&r"
|
'("k&r"
|
||||||
(c-basic-offset . 4)
|
(c-basic-offset . 4)
|
||||||
@@ -247,194 +223,141 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
(setq c-default-style "ffmpeg")
|
(setq c-default-style "ffmpeg")
|
||||||
@end lisp
|
@end example
|
||||||
|
|
||||||
@section Development Policy
|
@section Development Policy
|
||||||
|
|
||||||
@subsection Patches/Committing
|
@enumerate
|
||||||
@subheading Licenses for patches must be compatible with FFmpeg.
|
@item
|
||||||
Contributions should be licensed under the
|
Contributions should be licensed under the
|
||||||
@uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1},
|
@uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1},
|
||||||
including an "or any later version" clause, or, if you prefer
|
including an "or any later version" clause, or, if you prefer
|
||||||
a gift-style license, the
|
a gift-style license, the
|
||||||
@uref{http://opensource.org/licenses/isc-license.txt, ISC} or
|
@uref{http://www.isc.org/software/license/, ISC} or
|
||||||
@uref{http://mit-license.org/, MIT} license.
|
@uref{http://mit-license.org/, MIT} license.
|
||||||
@uref{http://www.gnu.org/licenses/gpl-2.0.html, GPL 2} including
|
@uref{http://www.gnu.org/licenses/gpl-2.0.html, GPL 2} including
|
||||||
an "or any later version" clause is also acceptable, but LGPL is
|
an "or any later version" clause is also acceptable, but LGPL is
|
||||||
preferred.
|
preferred.
|
||||||
If you add a new file, give it a proper license header. Do not copy and
|
@item
|
||||||
paste it from a random place, use an existing file as template.
|
You must not commit code which breaks FFmpeg! (Meaning unfinished but
|
||||||
|
enabled code which breaks compilation or compiles but does not work or
|
||||||
|
breaks the regression tests)
|
||||||
|
You can commit unfinished stuff (for testing etc), but it must be disabled
|
||||||
|
(#ifdef etc) by default so it does not interfere with other developers'
|
||||||
|
work.
|
||||||
|
@item
|
||||||
|
The commit message should have a short first line in the form of
|
||||||
|
a @samp{topic: short description} as a header, separated by a newline
|
||||||
|
from the body consisting of an explanation of why the change is necessary.
|
||||||
|
If the commit fixes a known bug on the bug tracker, the commit message
|
||||||
|
should include its bug ID. Referring to the issue on the bug tracker does
|
||||||
|
not exempt you from writing an excerpt of the bug in the commit message.
|
||||||
|
@item
|
||||||
|
You do not have to over-test things. If it works for you, and you think it
|
||||||
|
should work for others, then commit. If your code has problems
|
||||||
|
(portability, triggers compiler bugs, unusual environment etc) they will be
|
||||||
|
reported and eventually fixed.
|
||||||
|
@item
|
||||||
|
Do not commit unrelated changes together, split them into self-contained
|
||||||
|
pieces. Also do not forget that if part B depends on part A, but A does not
|
||||||
|
depend on B, then A can and should be committed first and separate from B.
|
||||||
|
Keeping changes well split into self-contained parts makes reviewing and
|
||||||
|
understanding them on the commit log mailing list easier. This also helps
|
||||||
|
in case of debugging later on.
|
||||||
|
Also if you have doubts about splitting or not splitting, do not hesitate to
|
||||||
|
ask/discuss it on the developer mailing list.
|
||||||
|
@item
|
||||||
|
Do not change behavior of the programs (renaming options etc) or public
|
||||||
|
API or ABI without first discussing it on the ffmpeg-devel mailing list.
|
||||||
|
Do not remove functionality from the code. Just improve!
|
||||||
|
|
||||||
@subheading You must not commit code which breaks FFmpeg!
|
Note: Redundant code can be removed.
|
||||||
This means unfinished code which is enabled and breaks compilation,
|
@item
|
||||||
or compiles but does not work/breaks the regression tests. Code which
|
Do not commit changes to the build system (Makefiles, configure script)
|
||||||
is unfinished but disabled may be permitted under-circumstances, like
|
which change behavior, defaults etc, without asking first. The same
|
||||||
missing samples or an implementation with a small subset of features.
|
applies to compiler warning fixes, trivial looking fixes and to code
|
||||||
Always check the mailing list for any reviewers with issues and test
|
maintained by other developers. We usually have a reason for doing things
|
||||||
FATE before you push.
|
the way we do. Send your changes as patches to the ffmpeg-devel mailing
|
||||||
|
list, and if the code maintainers say OK, you may commit. This does not
|
||||||
|
apply to files you wrote and/or maintain.
|
||||||
|
@item
|
||||||
|
We refuse source indentation and other cosmetic changes if they are mixed
|
||||||
|
with functional changes, such commits will be rejected and removed. Every
|
||||||
|
developer has his own indentation style, you should not change it. Of course
|
||||||
|
if you (re)write something, you can use your own style, even though we would
|
||||||
|
prefer if the indentation throughout FFmpeg was consistent (Many projects
|
||||||
|
force a given indentation style - we do not.). If you really need to make
|
||||||
|
indentation changes (try to avoid this), separate them strictly from real
|
||||||
|
changes.
|
||||||
|
|
||||||
@subheading Keep the main commit message short with an extended description below.
|
NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
|
||||||
The commit message should have a short first line in the form of
|
then either do NOT change the indentation of the inner part within (do not
|
||||||
a @samp{topic: short description} as a header, separated by a newline
|
move it to the right)! or do so in a separate commit
|
||||||
from the body consisting of an explanation of why the change is necessary.
|
@item
|
||||||
If the commit fixes a known bug on the bug tracker, the commit message
|
Always fill out the commit log message. Describe in a few lines what you
|
||||||
should include its bug ID. Referring to the issue on the bug tracker does
|
changed and why. You can refer to mailing list postings if you fix a
|
||||||
not exempt you from writing an excerpt of the bug in the commit message.
|
particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
|
||||||
|
Recommended format:
|
||||||
|
area changed: Short 1 line description
|
||||||
|
|
||||||
@subheading Testing must be adequate but not excessive.
|
details describing what and why and giving references.
|
||||||
If it works for you, others, and passes FATE then it should be OK to commit
|
@item
|
||||||
it, provided it fits the other committing criteria. You should not worry about
|
Make sure the author of the commit is set correctly. (see git commit --author)
|
||||||
over-testing things. If your code has problems (portability, triggers
|
If you apply a patch, send an
|
||||||
compiler bugs, unusual environment etc) they will be reported and eventually
|
answer to ffmpeg-devel (or wherever you got the patch from) saying that
|
||||||
fixed.
|
you applied the patch.
|
||||||
|
@item
|
||||||
@subheading Do not commit unrelated changes together.
|
When applying patches that have been discussed (at length) on the mailing
|
||||||
They should be split them into self-contained pieces. Also do not forget
|
list, reference the thread in the log message.
|
||||||
that if part B depends on part A, but A does not depend on B, then A can
|
@item
|
||||||
and should be committed first and separate from B. Keeping changes well
|
Do NOT commit to code actively maintained by others without permission.
|
||||||
split into self-contained parts makes reviewing and understanding them on
|
Send a patch to ffmpeg-devel instead. If no one answers within a reasonable
|
||||||
the commit log mailing list easier. This also helps in case of debugging
|
timeframe (12h for build failures and security fixes, 3 days small changes,
|
||||||
later on.
|
1 week for big patches) then commit your patch if you think it is OK.
|
||||||
Also if you have doubts about splitting or not splitting, do not hesitate to
|
Also note, the maintainer can simply ask for more time to review!
|
||||||
ask/discuss it on the developer mailing list.
|
@item
|
||||||
|
Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
|
||||||
@subheading Ask before you change the build system (configure, etc).
|
are sent there and reviewed by all the other developers. Bugs and possible
|
||||||
Do not commit changes to the build system (Makefiles, configure script)
|
improvements or general questions regarding commits are discussed there. We
|
||||||
which change behavior, defaults etc, without asking first. The same
|
expect you to react if problems with your code are uncovered.
|
||||||
applies to compiler warning fixes, trivial looking fixes and to code
|
@item
|
||||||
maintained by other developers. We usually have a reason for doing things
|
Update the documentation if you change behavior or add features. If you are
|
||||||
the way we do. Send your changes as patches to the ffmpeg-devel mailing
|
unsure how best to do this, send a patch to ffmpeg-devel, the documentation
|
||||||
list, and if the code maintainers say OK, you may commit. This does not
|
maintainer(s) will review and commit your stuff.
|
||||||
apply to files you wrote and/or maintain.
|
@item
|
||||||
|
Try to keep important discussions and requests (also) on the public
|
||||||
@subheading Cosmetic changes should be kept in separate patches.
|
developer mailing list, so that all developers can benefit from them.
|
||||||
We refuse source indentation and other cosmetic changes if they are mixed
|
@item
|
||||||
with functional changes, such commits will be rejected and removed. Every
|
Never write to unallocated memory, never write over the end of arrays,
|
||||||
developer has his own indentation style, you should not change it. Of course
|
always check values read from some untrusted source before using them
|
||||||
if you (re)write something, you can use your own style, even though we would
|
as array index or other risky things.
|
||||||
prefer if the indentation throughout FFmpeg was consistent (Many projects
|
@item
|
||||||
force a given indentation style - we do not.). If you really need to make
|
Remember to check if you need to bump versions for the specific libav*
|
||||||
indentation changes (try to avoid this), separate them strictly from real
|
parts (libavutil, libavcodec, libavformat) you are changing. You need
|
||||||
changes.
|
to change the version integer.
|
||||||
|
Incrementing the first component means no backward compatibility to
|
||||||
NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
|
previous versions (e.g. removal of a function from the public API).
|
||||||
then either do NOT change the indentation of the inner part within (do not
|
Incrementing the second component means backward compatible change
|
||||||
move it to the right)! or do so in a separate commit
|
(e.g. addition of a function to the public API or extension of an
|
||||||
|
existing data structure).
|
||||||
@subheading Commit messages should always be filled out properly.
|
Incrementing the third component means a noteworthy binary compatible
|
||||||
Always fill out the commit log message. Describe in a few lines what you
|
change (e.g. encoder bug fix that matters for the decoder). The third
|
||||||
changed and why. You can refer to mailing list postings if you fix a
|
component always starts at 100 to distinguish FFmpeg from Libav.
|
||||||
particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
|
@item
|
||||||
Recommended format:
|
Compiler warnings indicate potential bugs or code with bad style. If a type of
|
||||||
|
warning always points to correct and clean code, that warning should
|
||||||
@example
|
be disabled, not the code changed.
|
||||||
area changed: Short 1 line description
|
Thus the remaining warnings can either be bugs or correct code.
|
||||||
|
If it is a bug, the bug has to be fixed. If it is not, the code should
|
||||||
details describing what and why and giving references.
|
be changed to not generate a warning unless that causes a slowdown
|
||||||
@end example
|
or obfuscates the code.
|
||||||
|
@item
|
||||||
@subheading Credit the author of the patch.
|
If you add a new file, give it a proper license header. Do not copy and
|
||||||
Make sure the author of the commit is set correctly. (see git commit --author)
|
paste it from a random place, use an existing file as template.
|
||||||
If you apply a patch, send an
|
@end enumerate
|
||||||
answer to ffmpeg-devel (or wherever you got the patch from) saying that
|
|
||||||
you applied the patch.
|
|
||||||
|
|
||||||
@subheading Complex patches should refer to discussion surrounding them.
|
|
||||||
When applying patches that have been discussed (at length) on the mailing
|
|
||||||
list, reference the thread in the log message.
|
|
||||||
|
|
||||||
@subheading Always wait long enough before pushing changes
|
|
||||||
Do NOT commit to code actively maintained by others without permission.
|
|
||||||
Send a patch to ffmpeg-devel. If no one answers within a reasonable
|
|
||||||
time-frame (12h for build failures and security fixes, 3 days small changes,
|
|
||||||
1 week for big patches) then commit your patch if you think it is OK.
|
|
||||||
Also note, the maintainer can simply ask for more time to review!
|
|
||||||
|
|
||||||
@subsection Code
|
|
||||||
@subheading API/ABI changes should be discussed before they are made.
|
|
||||||
Do not change behavior of the programs (renaming options etc) or public
|
|
||||||
API or ABI without first discussing it on the ffmpeg-devel mailing list.
|
|
||||||
Do not remove widely used functionality or features (redundant code can be removed).
|
|
||||||
|
|
||||||
@subheading Remember to check if you need to bump versions for libav*.
|
|
||||||
Depending on the change, you may need to change the version integer.
|
|
||||||
Incrementing the first component means no backward compatibility to
|
|
||||||
previous versions (e.g. removal of a function from the public API).
|
|
||||||
Incrementing the second component means backward compatible change
|
|
||||||
(e.g. addition of a function to the public API or extension of an
|
|
||||||
existing data structure).
|
|
||||||
Incrementing the third component means a noteworthy binary compatible
|
|
||||||
change (e.g. encoder bug fix that matters for the decoder). The third
|
|
||||||
component always starts at 100 to distinguish FFmpeg from Libav.
|
|
||||||
|
|
||||||
@subheading Warnings for correct code may be disabled if there is no other option.
|
|
||||||
Compiler warnings indicate potential bugs or code with bad style. If a type of
|
|
||||||
warning always points to correct and clean code, that warning should
|
|
||||||
be disabled, not the code changed.
|
|
||||||
Thus the remaining warnings can either be bugs or correct code.
|
|
||||||
If it is a bug, the bug has to be fixed. If it is not, the code should
|
|
||||||
be changed to not generate a warning unless that causes a slowdown
|
|
||||||
or obfuscates the code.
|
|
||||||
|
|
||||||
@subheading Check untrusted input properly.
|
|
||||||
Never write to unallocated memory, never write over the end of arrays,
|
|
||||||
always check values read from some untrusted source before using them
|
|
||||||
as array index or other risky things.
|
|
||||||
|
|
||||||
@subsection Documentation/Other
|
|
||||||
@subheading Subscribe to the ffmpeg-cvslog mailing list.
|
|
||||||
It is important to do this as the diffs of all commits are sent there and
|
|
||||||
reviewed by all the other developers. Bugs and possible improvements or
|
|
||||||
general questions regarding commits are discussed there. We expect you to
|
|
||||||
react if problems with your code are uncovered.
|
|
||||||
|
|
||||||
@subheading Keep the documentation up to date.
|
|
||||||
Update the documentation if you change behavior or add features. If you are
|
|
||||||
unsure how best to do this, send a patch to ffmpeg-devel, the documentation
|
|
||||||
maintainer(s) will review and commit your stuff.
|
|
||||||
|
|
||||||
@subheading Important discussions should be accessible to all.
|
|
||||||
Try to keep important discussions and requests (also) on the public
|
|
||||||
developer mailing list, so that all developers can benefit from them.
|
|
||||||
|
|
||||||
@subheading Check your entries in MAINTAINERS.
|
|
||||||
Make sure that no parts of the codebase that you maintain are missing from the
|
|
||||||
@file{MAINTAINERS} file. If something that you want to maintain is missing add it with
|
|
||||||
your name after it.
|
|
||||||
If at some point you no longer want to maintain some code, then please help in
|
|
||||||
finding a new maintainer and also don't forget to update the @file{MAINTAINERS} file.
|
|
||||||
|
|
||||||
We think our rules are not too hard. If you have comments, contact us.
|
We think our rules are not too hard. If you have comments, contact us.
|
||||||
|
|
||||||
@section Code of conduct
|
|
||||||
|
|
||||||
Be friendly and respectful towards others and third parties.
|
|
||||||
Treat others the way you yourself want to be treated.
|
|
||||||
|
|
||||||
Be considerate. Not everyone shares the same viewpoint and priorities as you do.
|
|
||||||
Different opinions and interpretations help the project.
|
|
||||||
Looking at issues from a different perspective assists development.
|
|
||||||
|
|
||||||
Do not assume malice for things that can be attributed to incompetence. Even if
|
|
||||||
it is malice, it's rarely good to start with that as initial assumption.
|
|
||||||
|
|
||||||
Stay friendly even if someone acts contrarily. Everyone has a bad day
|
|
||||||
once in a while.
|
|
||||||
If you yourself have a bad day or are angry then try to take a break and reply
|
|
||||||
once you are calm and without anger if you have to.
|
|
||||||
|
|
||||||
Try to help other team members and cooperate if you can.
|
|
||||||
|
|
||||||
The goal of software development is to create technical excellence, not for any
|
|
||||||
individual to be better and "win" against the others. Large software projects
|
|
||||||
are only possible and successful through teamwork.
|
|
||||||
|
|
||||||
If someone struggles do not put them down. Give them a helping hand
|
|
||||||
instead and point them in the right direction.
|
|
||||||
|
|
||||||
Finally, keep in mind the immortal words of Bill and Ted,
|
|
||||||
"Be excellent to each other."
|
|
||||||
|
|
||||||
@anchor{Submitting patches}
|
@anchor{Submitting patches}
|
||||||
@section Submitting patches
|
@section Submitting patches
|
||||||
|
|
||||||
@@ -442,7 +365,7 @@ First, read the @ref{Coding Rules} above if you did not yet, in particular
|
|||||||
the rules regarding patch submission.
|
the rules regarding patch submission.
|
||||||
|
|
||||||
When you submit your patch, please use @code{git format-patch} or
|
When you submit your patch, please use @code{git format-patch} or
|
||||||
@code{git send-email}. We cannot read other diffs :-).
|
@code{git send-email}. We cannot read other diffs :-)
|
||||||
|
|
||||||
Also please do not submit a patch which contains several unrelated changes.
|
Also please do not submit a patch which contains several unrelated changes.
|
||||||
Split it into separate, self-contained pieces. This does not mean splitting
|
Split it into separate, self-contained pieces. This does not mean splitting
|
||||||
@@ -465,15 +388,11 @@ Also please if you send several patches, send each patch as a separate mail,
|
|||||||
do not attach several unrelated patches to the same mail.
|
do not attach several unrelated patches to the same mail.
|
||||||
|
|
||||||
Patches should be posted to the
|
Patches should be posted to the
|
||||||
@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel}
|
@uref{http://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel}
|
||||||
mailing list. Use @code{git send-email} when possible since it will properly
|
mailing list. Use @code{git send-email} when possible since it will properly
|
||||||
send patches without requiring extra care. If you cannot, then send patches
|
send patches without requiring extra care. If you cannot, then send patches
|
||||||
as base64-encoded attachments, so your patch is not trashed during
|
as base64-encoded attachments, so your patch is not trashed during
|
||||||
transmission. Also ensure the correct mime type is used
|
transmission.
|
||||||
(text/x-diff or text/x-patch or at least text/plain) and that only one
|
|
||||||
patch is inline or attached per mail.
|
|
||||||
You can check @url{https://patchwork.ffmpeg.org}, if your patch does not show up, its mime type
|
|
||||||
likely was wrong.
|
|
||||||
|
|
||||||
Your patch will be reviewed on the mailing list. You will likely be asked
|
Your patch will be reviewed on the mailing list. You will likely be asked
|
||||||
to make some changes and are expected to send in an improved version that
|
to make some changes and are expected to send in an improved version that
|
||||||
@@ -489,51 +408,40 @@ send a reminder by email. Your patch should eventually be dealt with.
|
|||||||
|
|
||||||
@enumerate
|
@enumerate
|
||||||
@item
|
@item
|
||||||
Did you use av_cold for codec initialization and close functions?
|
Did you use av_cold for codec initialization and close functions?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you add a long_name under NULL_IF_CONFIG_SMALL to the AVCodec or
|
Did you add a long_name under NULL_IF_CONFIG_SMALL to the AVCodec or
|
||||||
AVInputFormat/AVOutputFormat struct?
|
AVInputFormat/AVOutputFormat struct?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you bump the minor version number (and reset the micro version
|
Did you bump the minor version number (and reset the micro version
|
||||||
number) in @file{libavcodec/version.h} or @file{libavformat/version.h}?
|
number) in @file{libavcodec/version.h} or @file{libavformat/version.h}?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you register it in @file{allcodecs.c} or @file{allformats.c}?
|
Did you register it in @file{allcodecs.c} or @file{allformats.c}?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you add the AVCodecID to @file{avcodec.h}?
|
Did you add the AVCodecID to @file{avcodec.h}?
|
||||||
When adding new codec IDs, also add an entry to the codec descriptor
|
When adding new codec IDs, also add an entry to the codec descriptor
|
||||||
list in @file{libavcodec/codec_desc.c}.
|
list in @file{libavcodec/codec_desc.c}.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If it has a FourCC, did you add it to @file{libavformat/riff.c},
|
If it has a FourCC, did you add it to @file{libavformat/riff.c},
|
||||||
even if it is only a decoder?
|
even if it is only a decoder?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you add a rule to compile the appropriate files in the Makefile?
|
Did you add a rule to compile the appropriate files in the Makefile?
|
||||||
Remember to do this even if you're just adding a format to a file that is
|
Remember to do this even if you're just adding a format to a file that is
|
||||||
already being compiled by some other rule, like a raw demuxer.
|
already being compiled by some other rule, like a raw demuxer.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you add an entry to the table of supported formats or codecs in
|
Did you add an entry to the table of supported formats or codecs in
|
||||||
@file{doc/general.texi}?
|
@file{doc/general.texi}?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you add an entry in the Changelog?
|
Did you add an entry in the Changelog?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If it depends on a parser or a library, did you add that dependency in
|
If it depends on a parser or a library, did you add that dependency in
|
||||||
configure?
|
configure?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you @code{git add} the appropriate files before committing?
|
Did you @code{git add} the appropriate files before committing?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you make sure it compiles standalone, i.e. with
|
Did you make sure it compiles standalone, i.e. with
|
||||||
@code{configure --disable-everything --enable-decoder=foo}
|
@code{configure --disable-everything --enable-decoder=foo}
|
||||||
(or @code{--enable-demuxer} or whatever your component is)?
|
(or @code{--enable-demuxer} or whatever your component is)?
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
|
|
||||||
@@ -541,113 +449,82 @@ Did you make sure it compiles standalone, i.e. with
|
|||||||
|
|
||||||
@enumerate
|
@enumerate
|
||||||
@item
|
@item
|
||||||
Does @code{make fate} pass with the patch applied?
|
Does @code{make fate} pass with the patch applied?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Was the patch generated with git format-patch or send-email?
|
Was the patch generated with git format-patch or send-email?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you sign off your patch? (git commit -s)
|
Did you sign off your patch? (git commit -s)
|
||||||
See @url{http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/SubmittingPatches} for the meaning
|
See @url{http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/SubmittingPatches} for the meaning
|
||||||
of sign off.
|
of sign off.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you provide a clear git commit log message?
|
Did you provide a clear git commit log message?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Is the patch against latest FFmpeg git master branch?
|
Is the patch against latest FFmpeg git master branch?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Are you subscribed to ffmpeg-devel?
|
Are you subscribed to ffmpeg-devel?
|
||||||
(the list is subscribers only due to spam)
|
(the list is subscribers only due to spam)
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Have you checked that the changes are minimal, so that the same cannot be
|
Have you checked that the changes are minimal, so that the same cannot be
|
||||||
achieved with a smaller patch and/or simpler final code?
|
achieved with a smaller patch and/or simpler final code?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If the change is to speed critical code, did you benchmark it?
|
If the change is to speed critical code, did you benchmark it?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If you did any benchmarks, did you provide them in the mail?
|
If you did any benchmarks, did you provide them in the mail?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Have you checked that the patch does not introduce buffer overflows or
|
Have you checked that the patch does not introduce buffer overflows or
|
||||||
other security issues?
|
other security issues?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you test your decoder or demuxer against damaged data? If no, see
|
Did you test your decoder or demuxer against damaged data? If no, see
|
||||||
tools/trasher, the noise bitstream filter, and
|
tools/trasher, the noise bitstream filter, and
|
||||||
@uref{http://caca.zoy.org/wiki/zzuf, zzuf}. Your decoder or demuxer
|
@uref{http://caca.zoy.org/wiki/zzuf, zzuf}. Your decoder or demuxer
|
||||||
should not crash, end in a (near) infinite loop, or allocate ridiculous
|
should not crash, end in a (near) infinite loop, or allocate ridiculous
|
||||||
amounts of memory when fed damaged data.
|
amounts of memory when fed damaged data.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you test your decoder or demuxer against sample files?
|
Does the patch not mix functional and cosmetic changes?
|
||||||
Samples may be obtained at @url{https://samples.ffmpeg.org}.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Does the patch not mix functional and cosmetic changes?
|
Did you add tabs or trailing whitespace to the code? Both are forbidden.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you add tabs or trailing whitespace to the code? Both are forbidden.
|
Is the patch attached to the email you send?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Is the patch attached to the email you send?
|
Is the mime type of the patch correct? It should be text/x-diff or
|
||||||
|
text/x-patch or at least text/plain and not application/octet-stream.
|
||||||
@item
|
@item
|
||||||
Is the mime type of the patch correct? It should be text/x-diff or
|
If the patch fixes a bug, did you provide a verbose analysis of the bug?
|
||||||
text/x-patch or at least text/plain and not application/octet-stream.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If the patch fixes a bug, did you provide a verbose analysis of the bug?
|
If the patch fixes a bug, did you provide enough information, including
|
||||||
|
a sample, so the bug can be reproduced and the fix can be verified?
|
||||||
|
Note please do not attach samples >100k to mails but rather provide a
|
||||||
|
URL, you can upload to ftp://upload.ffmpeg.org
|
||||||
@item
|
@item
|
||||||
If the patch fixes a bug, did you provide enough information, including
|
Did you provide a verbose summary about what the patch does change?
|
||||||
a sample, so the bug can be reproduced and the fix can be verified?
|
|
||||||
Note please do not attach samples >100k to mails but rather provide a
|
|
||||||
URL, you can upload to ftp://upload.ffmpeg.org.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you provide a verbose summary about what the patch does change?
|
Did you provide a verbose explanation why it changes things like it does?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you provide a verbose explanation why it changes things like it does?
|
Did you provide a verbose summary of the user visible advantages and
|
||||||
|
disadvantages if the patch is applied?
|
||||||
@item
|
@item
|
||||||
Did you provide a verbose summary of the user visible advantages and
|
Did you provide an example so we can verify the new feature added by the
|
||||||
disadvantages if the patch is applied?
|
patch easily?
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Did you provide an example so we can verify the new feature added by the
|
If you added a new file, did you insert a license header? It should be
|
||||||
patch easily?
|
taken from FFmpeg, not randomly copied and pasted from somewhere else.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If you added a new file, did you insert a license header? It should be
|
You should maintain alphabetical order in alphabetically ordered lists as
|
||||||
taken from FFmpeg, not randomly copied and pasted from somewhere else.
|
long as doing so does not break API/ABI compatibility.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
You should maintain alphabetical order in alphabetically ordered lists as
|
Lines with similar content should be aligned vertically when doing so
|
||||||
long as doing so does not break API/ABI compatibility.
|
improves readability.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Lines with similar content should be aligned vertically when doing so
|
Consider to add a regression test for your code.
|
||||||
improves readability.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Consider adding a regression test for your code.
|
If you added YASM code please check that things still work with --disable-yasm
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If you added YASM code please check that things still work with --disable-yasm.
|
Make sure you check the return values of function and return appropriate
|
||||||
|
error codes. Especially memory allocation functions like @code{av_malloc()}
|
||||||
|
are notoriously left unchecked, which is a serious problem.
|
||||||
@item
|
@item
|
||||||
Make sure you check the return values of function and return appropriate
|
Test your code with valgrind and or Address Sanitizer to ensure it's free
|
||||||
error codes. Especially memory allocation functions like @code{av_malloc()}
|
of leaks, out of array accesses, etc.
|
||||||
are notoriously left unchecked, which is a serious problem.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Test your code with valgrind and or Address Sanitizer to ensure it's free
|
|
||||||
of leaks, out of array accesses, etc.
|
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
@section Patch review process
|
@section Patch review process
|
||||||
@@ -676,10 +553,6 @@ not related to the comments received during review. Such patches will
|
|||||||
be rejected. Instead, submit significant changes or new features as
|
be rejected. Instead, submit significant changes or new features as
|
||||||
separate patches.
|
separate patches.
|
||||||
|
|
||||||
Everyone is welcome to review patches. Also if you are waiting for your patch
|
|
||||||
to be reviewed, please consider helping to review other patches, that is a great
|
|
||||||
way to get everyone's patches reviewed sooner.
|
|
||||||
|
|
||||||
@anchor{Regression tests}
|
@anchor{Regression tests}
|
||||||
@section Regression tests
|
@section Regression tests
|
||||||
|
|
||||||
@@ -695,153 +568,13 @@ accordingly].
|
|||||||
@subsection Adding files to the fate-suite dataset
|
@subsection Adding files to the fate-suite dataset
|
||||||
|
|
||||||
When there is no muxer or encoder available to generate test media for a
|
When there is no muxer or encoder available to generate test media for a
|
||||||
specific test then the media has to be included in the fate-suite.
|
specific test then the media has to be inlcuded in the fate-suite.
|
||||||
First please make sure that the sample file is as small as possible to test the
|
First please make sure that the sample file is as small as possible to test the
|
||||||
respective decoder or demuxer sufficiently. Large files increase network
|
respective decoder or demuxer sufficiently. Large files increase network
|
||||||
bandwidth and disk space requirements.
|
bandwidth and disk space requirements.
|
||||||
Once you have a working fate test and fate sample, provide in the commit
|
Once you have a working fate test and fate sample, provide in the commit
|
||||||
message or introductory message for the patch series that you post to
|
message or introductionary message for the patch series that you post to
|
||||||
the ffmpeg-devel mailing list, a direct link to download the sample media.
|
the ffmpeg-devel mailing list, a direct link to download the sample media.
|
||||||
|
|
||||||
@subsection Visualizing Test Coverage
|
|
||||||
|
|
||||||
The FFmpeg build system allows visualizing the test coverage in an easy
|
|
||||||
manner with the coverage tools @code{gcov}/@code{lcov}. This involves
|
|
||||||
the following steps:
|
|
||||||
|
|
||||||
@enumerate
|
|
||||||
@item
|
|
||||||
Configure to compile with instrumentation enabled:
|
|
||||||
@code{configure --toolchain=gcov}.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Run your test case, either manually or via FATE. This can be either
|
|
||||||
the full FATE regression suite, or any arbitrary invocation of any
|
|
||||||
front-end tool provided by FFmpeg, in any combination.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Run @code{make lcov} to generate coverage data in HTML format.
|
|
||||||
|
|
||||||
@item
|
|
||||||
View @code{lcov/index.html} in your preferred HTML viewer.
|
|
||||||
@end enumerate
|
|
||||||
|
|
||||||
You can use the command @code{make lcov-reset} to reset the coverage
|
|
||||||
measurements. You will need to rerun @code{make lcov} after running a
|
|
||||||
new test.
|
|
||||||
|
|
||||||
@subsection Using Valgrind
|
|
||||||
|
|
||||||
The configure script provides a shortcut for using valgrind to spot bugs
|
|
||||||
related to memory handling. Just add the option
|
|
||||||
@code{--toolchain=valgrind-memcheck} or @code{--toolchain=valgrind-massif}
|
|
||||||
to your configure line, and reasonable defaults will be set for running
|
|
||||||
FATE under the supervision of either the @strong{memcheck} or the
|
|
||||||
@strong{massif} tool of the valgrind suite.
|
|
||||||
|
|
||||||
In case you need finer control over how valgrind is invoked, use the
|
|
||||||
@code{--target-exec='valgrind <your_custom_valgrind_options>} option in
|
|
||||||
your configure line instead.
|
|
||||||
|
|
||||||
@anchor{Release process}
|
|
||||||
@section Release process
|
|
||||||
|
|
||||||
FFmpeg maintains a set of @strong{release branches}, which are the
|
|
||||||
recommended deliverable for system integrators and distributors (such as
|
|
||||||
Linux distributions, etc.). At regular times, a @strong{release
|
|
||||||
manager} prepares, tests and publishes tarballs on the
|
|
||||||
@url{https://ffmpeg.org} website.
|
|
||||||
|
|
||||||
There are two kinds of releases:
|
|
||||||
|
|
||||||
@enumerate
|
|
||||||
@item
|
|
||||||
@strong{Major releases} always include the latest and greatest
|
|
||||||
features and functionality.
|
|
||||||
|
|
||||||
@item
|
|
||||||
@strong{Point releases} are cut from @strong{release} branches,
|
|
||||||
which are named @code{release/X}, with @code{X} being the release
|
|
||||||
version number.
|
|
||||||
@end enumerate
|
|
||||||
|
|
||||||
Note that we promise to our users that shared libraries from any FFmpeg
|
|
||||||
release never break programs that have been @strong{compiled} against
|
|
||||||
previous versions of @strong{the same release series} in any case!
|
|
||||||
|
|
||||||
However, from time to time, we do make API changes that require adaptations
|
|
||||||
in applications. Such changes are only allowed in (new) major releases and
|
|
||||||
require further steps such as bumping library version numbers and/or
|
|
||||||
adjustments to the symbol versioning file. Please discuss such changes
|
|
||||||
on the @strong{ffmpeg-devel} mailing list in time to allow forward planning.
|
|
||||||
|
|
||||||
@anchor{Criteria for Point Releases}
|
|
||||||
@subsection Criteria for Point Releases
|
|
||||||
|
|
||||||
Changes that match the following criteria are valid candidates for
|
|
||||||
inclusion into a point release:
|
|
||||||
|
|
||||||
@enumerate
|
|
||||||
@item
|
|
||||||
Fixes a security issue, preferably identified by a @strong{CVE
|
|
||||||
number} issued by @url{http://cve.mitre.org/}.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Fixes a documented bug in @url{https://trac.ffmpeg.org}.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Improves the included documentation.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Retains both source code and binary compatibility with previous
|
|
||||||
point releases of the same release branch.
|
|
||||||
@end enumerate
|
|
||||||
|
|
||||||
The order for checking the rules is (1 OR 2 OR 3) AND 4.
|
|
||||||
|
|
||||||
|
|
||||||
@subsection Release Checklist
|
|
||||||
|
|
||||||
The release process involves the following steps:
|
|
||||||
|
|
||||||
@enumerate
|
|
||||||
@item
|
|
||||||
Ensure that the @file{RELEASE} file contains the version number for
|
|
||||||
the upcoming release.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Add the release at @url{https://trac.ffmpeg.org/admin/ticket/versions}.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Announce the intent to do a release to the mailing list.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Make sure all relevant security fixes have been backported. See
|
|
||||||
@url{https://ffmpeg.org/security.html}.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Ensure that the FATE regression suite still passes in the release
|
|
||||||
branch on at least @strong{i386} and @strong{amd64}
|
|
||||||
(cf. @ref{Regression tests}).
|
|
||||||
|
|
||||||
@item
|
|
||||||
Prepare the release tarballs in @code{bz2} and @code{gz} formats, and
|
|
||||||
supplementing files that contain @code{gpg} signatures
|
|
||||||
|
|
||||||
@item
|
|
||||||
Publish the tarballs at @url{https://ffmpeg.org/releases}. Create and
|
|
||||||
push an annotated tag in the form @code{nX}, with @code{X}
|
|
||||||
containing the version number.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Propose and send a patch to the @strong{ffmpeg-devel} mailing list
|
|
||||||
with a news entry for the website.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Publish the news entry.
|
|
||||||
|
|
||||||
@item
|
|
||||||
Send an announcement to the mailing list.
|
|
||||||
@end enumerate
|
|
||||||
|
|
||||||
@bye
|
@bye
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
@chapter Device Options
|
|
||||||
@c man begin DEVICE OPTIONS
|
|
||||||
|
|
||||||
The libavdevice library provides the same interface as
|
|
||||||
libavformat. Namely, an input device is considered like a demuxer, and
|
|
||||||
an output device like a muxer, and the interface and generic device
|
|
||||||
options are the same provided by libavformat (see the ffmpeg-formats
|
|
||||||
manual).
|
|
||||||
|
|
||||||
In addition each input or output device may support so-called private
|
|
||||||
options, which are specific for that component.
|
|
||||||
|
|
||||||
Options may be set by specifying -@var{option} @var{value} in the
|
|
||||||
FFmpeg tools, or by setting the value explicitly in the device
|
|
||||||
@code{AVFormatContext} options or using the @file{libavutil/opt.h} API
|
|
||||||
for programmatic use.
|
|
||||||
|
|
||||||
@c man end DEVICE OPTIONS
|
|
||||||
|
|
||||||
@ifclear config-writeonly
|
|
||||||
@include indevs.texi
|
|
||||||
@end ifclear
|
|
||||||
@ifclear config-readonly
|
|
||||||
@include outdevs.texi
|
|
||||||
@end ifclear
|
|
||||||
@@ -1,21 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
OUT_DIR="${1}"
|
SRC_PATH="${1}"
|
||||||
DOXYFILE="${2}"
|
DOXYFILE="${2}"
|
||||||
DOXYGEN="${3}"
|
|
||||||
|
|
||||||
shift 3
|
shift 2
|
||||||
|
|
||||||
if [ -e "VERSION" ]; then
|
doxygen - <<EOF
|
||||||
VERSION=`cat "VERSION"`
|
|
||||||
else
|
|
||||||
VERSION=`git describe`
|
|
||||||
fi
|
|
||||||
|
|
||||||
$DOXYGEN - <<EOF
|
|
||||||
@INCLUDE = ${DOXYFILE}
|
@INCLUDE = ${DOXYFILE}
|
||||||
INPUT = $@
|
INPUT = $@
|
||||||
HTML_TIMESTAMP = NO
|
HTML_HEADER = ${SRC_PATH}/doc/doxy/header.html
|
||||||
PROJECT_NUMBER = $VERSION
|
HTML_FOOTER = ${SRC_PATH}/doc/doxy/footer.html
|
||||||
OUTPUT_DIRECTORY = $OUT_DIR
|
HTML_STYLESHEET = ${SRC_PATH}/doc/doxy/doxy_stylesheet.css
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
1
doc/doxy/.gitignore
vendored
1
doc/doxy/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/html/
|
|
||||||
2019
doc/doxy/doxy_stylesheet.css
Normal file
2019
doc/doxy/doxy_stylesheet.css
Normal file
File diff suppressed because it is too large
Load Diff
9
doc/doxy/footer.html
Normal file
9
doc/doxy/footer.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
<footer class="footer pagination-right">
|
||||||
|
<span class="label label-info">
|
||||||
|
Generated on $datetime for $projectname by <a href="http://www.doxygen.org/index.html">doxygen</a> $doxygenversion
|
||||||
|
</span>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
16
doc/doxy/header.html
Normal file
16
doc/doxy/header.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||||
|
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||||
|
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||||
|
<link href="$relpath$doxy_stylesheet.css" rel="stylesheet" type="text/css" />
|
||||||
|
<!--Header replace -->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<!--Header replace -->
|
||||||
|
<div class="menu">
|
||||||
1667
doc/encoders.texi
1667
doc/encoders.texi
File diff suppressed because it is too large
Load Diff
@@ -76,7 +76,7 @@ EMFILE POSIX ++++++ Too many open files
|
|||||||
EMLINK POSIX ++++++ Too many links
|
EMLINK POSIX ++++++ Too many links
|
||||||
EMSGSIZE POSIX +++..+ Message too long
|
EMSGSIZE POSIX +++..+ Message too long
|
||||||
EMULTIHOP POSIX ++4... Multihop attempted
|
EMULTIHOP POSIX ++4... Multihop attempted
|
||||||
ENAMETOOLONG POSIX - ++++++ File name too long
|
ENAMETOOLONG POSIX - ++++++ Filen ame too long
|
||||||
ENAVAIL +..... No XENIX semaphores available
|
ENAVAIL +..... No XENIX semaphores available
|
||||||
ENEEDAUTH .++... Need authenticator
|
ENEEDAUTH .++... Need authenticator
|
||||||
ENETDOWN POSIX +++..+ Network is down
|
ENETDOWN POSIX +++..+ Network is down
|
||||||
|
|||||||
288
doc/eval.texi
Normal file
288
doc/eval.texi
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
@chapter Expression Evaluation
|
||||||
|
@c man begin EXPRESSION EVALUATION
|
||||||
|
|
||||||
|
When evaluating an arithmetic expression, FFmpeg uses an internal
|
||||||
|
formula evaluator, implemented through the @file{libavutil/eval.h}
|
||||||
|
interface.
|
||||||
|
|
||||||
|
An expression may contain unary, binary operators, constants, and
|
||||||
|
functions.
|
||||||
|
|
||||||
|
Two expressions @var{expr1} and @var{expr2} can be combined to form
|
||||||
|
another expression "@var{expr1};@var{expr2}".
|
||||||
|
@var{expr1} and @var{expr2} are evaluated in turn, and the new
|
||||||
|
expression evaluates to the value of @var{expr2}.
|
||||||
|
|
||||||
|
The following binary operators are available: @code{+}, @code{-},
|
||||||
|
@code{*}, @code{/}, @code{^}.
|
||||||
|
|
||||||
|
The following unary operators are available: @code{+}, @code{-}.
|
||||||
|
|
||||||
|
The following functions are available:
|
||||||
|
@table @option
|
||||||
|
@item abs(x)
|
||||||
|
Compute absolute value of @var{x}.
|
||||||
|
|
||||||
|
@item acos(x)
|
||||||
|
Compute arccosine of @var{x}.
|
||||||
|
|
||||||
|
@item asin(x)
|
||||||
|
Compute arcsine of @var{x}.
|
||||||
|
|
||||||
|
@item atan(x)
|
||||||
|
Compute arctangent of @var{x}.
|
||||||
|
|
||||||
|
@item ceil(expr)
|
||||||
|
Round the value of expression @var{expr} upwards to the nearest
|
||||||
|
integer. For example, "ceil(1.5)" is "2.0".
|
||||||
|
|
||||||
|
@item cos(x)
|
||||||
|
Compute cosine of @var{x}.
|
||||||
|
|
||||||
|
@item cosh(x)
|
||||||
|
Compute hyperbolic cosine of @var{x}.
|
||||||
|
|
||||||
|
@item eq(x, y)
|
||||||
|
Return 1 if @var{x} and @var{y} are equivalent, 0 otherwise.
|
||||||
|
|
||||||
|
@item exp(x)
|
||||||
|
Compute exponential of @var{x} (with base @code{e}, the Euler's number).
|
||||||
|
|
||||||
|
@item floor(expr)
|
||||||
|
Round the value of expression @var{expr} downwards to the nearest
|
||||||
|
integer. For example, "floor(-1.5)" is "-2.0".
|
||||||
|
|
||||||
|
@item gauss(x)
|
||||||
|
Compute Gauss function of @var{x}, corresponding to
|
||||||
|
@code{exp(-x*x/2) / sqrt(2*PI)}.
|
||||||
|
|
||||||
|
@item gcd(x, y)
|
||||||
|
Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and
|
||||||
|
@var{y} are 0 or either or both are less than zero then behavior is undefined.
|
||||||
|
|
||||||
|
@item gt(x, y)
|
||||||
|
Return 1 if @var{x} is greater than @var{y}, 0 otherwise.
|
||||||
|
|
||||||
|
@item gte(x, y)
|
||||||
|
Return 1 if @var{x} is greater than or equal to @var{y}, 0 otherwise.
|
||||||
|
|
||||||
|
@item hypot(x, y)
|
||||||
|
This function is similar to the C function with the same name; it returns
|
||||||
|
"sqrt(@var{x}*@var{x} + @var{y}*@var{y})", the length of the hypotenuse of a
|
||||||
|
right triangle with sides of length @var{x} and @var{y}, or the distance of the
|
||||||
|
point (@var{x}, @var{y}) from the origin.
|
||||||
|
|
||||||
|
@item if(x, y)
|
||||||
|
Evaluate @var{x}, and if the result is non-zero return the result of
|
||||||
|
the evaluation of @var{y}, return 0 otherwise.
|
||||||
|
|
||||||
|
@item if(x, y, z)
|
||||||
|
Evaluate @var{x}, and if the result is non-zero return the evaluation
|
||||||
|
result of @var{y}, otherwise the evaluation result of @var{z}.
|
||||||
|
|
||||||
|
@item ifnot(x, y)
|
||||||
|
Evaluate @var{x}, and if the result is zero return the result of the
|
||||||
|
evaluation of @var{y}, return 0 otherwise.
|
||||||
|
|
||||||
|
@item ifnot(x, y, z)
|
||||||
|
Evaluate @var{x}, and if the result is zero return the evaluation
|
||||||
|
result of @var{y}, otherwise the evaluation result of @var{z}.
|
||||||
|
|
||||||
|
@item isinf(x)
|
||||||
|
Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise.
|
||||||
|
|
||||||
|
@item isnan(x)
|
||||||
|
Return 1.0 if @var{x} is NAN, 0.0 otherwise.
|
||||||
|
|
||||||
|
@item ld(var)
|
||||||
|
Allow to load the value of the internal variable with number
|
||||||
|
@var{var}, which was previously stored with st(@var{var}, @var{expr}).
|
||||||
|
The function returns the loaded value.
|
||||||
|
|
||||||
|
@item log(x)
|
||||||
|
Compute natural logarithm of @var{x}.
|
||||||
|
|
||||||
|
@item lt(x, y)
|
||||||
|
Return 1 if @var{x} is lesser than @var{y}, 0 otherwise.
|
||||||
|
|
||||||
|
@item lte(x, y)
|
||||||
|
Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise.
|
||||||
|
|
||||||
|
@item max(x, y)
|
||||||
|
Return the maximum between @var{x} and @var{y}.
|
||||||
|
|
||||||
|
@item min(x, y)
|
||||||
|
Return the maximum between @var{x} and @var{y}.
|
||||||
|
|
||||||
|
@item mod(x, y)
|
||||||
|
Compute the remainder of division of @var{x} by @var{y}.
|
||||||
|
|
||||||
|
@item not(expr)
|
||||||
|
Return 1.0 if @var{expr} is zero, 0.0 otherwise.
|
||||||
|
|
||||||
|
@item pow(x, y)
|
||||||
|
Compute the power of @var{x} elevated @var{y}, it is equivalent to
|
||||||
|
"(@var{x})^(@var{y})".
|
||||||
|
|
||||||
|
@item print(t)
|
||||||
|
@item print(t, l)
|
||||||
|
Print the value of expression @var{t} with loglevel @var{l}. If
|
||||||
|
@var{l} is not specified then a default log level is used.
|
||||||
|
Returns the value of the expression printed.
|
||||||
|
|
||||||
|
Prints t with loglevel l
|
||||||
|
|
||||||
|
@item random(x)
|
||||||
|
Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the
|
||||||
|
internal variable which will be used to save the seed/state.
|
||||||
|
|
||||||
|
@item root(expr, max)
|
||||||
|
Find an input value for which the function represented by @var{expr}
|
||||||
|
with argument @var{ld(0)} is 0 in the interval 0..@var{max}.
|
||||||
|
|
||||||
|
The expression in @var{expr} must denote a continuous function or the
|
||||||
|
result is undefined.
|
||||||
|
|
||||||
|
@var{ld(0)} is used to represent the function input value, which means
|
||||||
|
that the given expression will be evaluated multiple times with
|
||||||
|
various input values that the expression can access through
|
||||||
|
@code{ld(0)}. When the expression evaluates to 0 then the
|
||||||
|
corresponding input value will be returned.
|
||||||
|
|
||||||
|
@item sin(x)
|
||||||
|
Compute sine of @var{x}.
|
||||||
|
|
||||||
|
@item sinh(x)
|
||||||
|
Compute hyperbolic sine of @var{x}.
|
||||||
|
|
||||||
|
@item sqrt(expr)
|
||||||
|
Compute the square root of @var{expr}. This is equivalent to
|
||||||
|
"(@var{expr})^.5".
|
||||||
|
|
||||||
|
@item squish(x)
|
||||||
|
Compute expression @code{1/(1 + exp(4*x))}.
|
||||||
|
|
||||||
|
@item st(var, expr)
|
||||||
|
Allow to store the value of the expression @var{expr} in an internal
|
||||||
|
variable. @var{var} specifies the number of the variable where to
|
||||||
|
store the value, and it is a value ranging from 0 to 9. The function
|
||||||
|
returns the value stored in the internal variable.
|
||||||
|
Note, Variables are currently not shared between expressions.
|
||||||
|
|
||||||
|
@item tan(x)
|
||||||
|
Compute tangent of @var{x}.
|
||||||
|
|
||||||
|
@item tanh(x)
|
||||||
|
Compute hyperbolic tangent of @var{x}.
|
||||||
|
|
||||||
|
@item taylor(expr, x)
|
||||||
|
@item taylor(expr, x, id)
|
||||||
|
Evaluate a Taylor series at @var{x}, given an expression representing
|
||||||
|
the @code{ld(id)}-th derivative of a function at 0.
|
||||||
|
|
||||||
|
When the series does not converge the result is undefined.
|
||||||
|
|
||||||
|
@var{ld(id)} is used to represent the derivative order in @var{expr},
|
||||||
|
which means that the given expression will be evaluated multiple times
|
||||||
|
with various input values that the expression can access through
|
||||||
|
@code{ld(id)}. If @var{id} is not specified then 0 is assumed.
|
||||||
|
|
||||||
|
Note, when you have the derivatives at y instead of 0,
|
||||||
|
@code{taylor(expr, x-y)} can be used.
|
||||||
|
|
||||||
|
@item time(0)
|
||||||
|
Return the current (wallclock) time in seconds.
|
||||||
|
|
||||||
|
@item trunc(expr)
|
||||||
|
Round the value of expression @var{expr} towards zero to the nearest
|
||||||
|
integer. For example, "trunc(-1.5)" is "-1.0".
|
||||||
|
|
||||||
|
@item while(cond, expr)
|
||||||
|
Evaluate expression @var{expr} while the expression @var{cond} is
|
||||||
|
non-zero, and returns the value of the last @var{expr} evaluation, or
|
||||||
|
NAN if @var{cond} was always false.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
The following constants are available:
|
||||||
|
@table @option
|
||||||
|
@item PI
|
||||||
|
area of the unit disc, approximately 3.14
|
||||||
|
@item E
|
||||||
|
exp(1) (Euler's number), approximately 2.718
|
||||||
|
@item PHI
|
||||||
|
golden ratio (1+sqrt(5))/2, approximately 1.618
|
||||||
|
@end table
|
||||||
|
|
||||||
|
Assuming that an expression is considered "true" if it has a non-zero
|
||||||
|
value, note that:
|
||||||
|
|
||||||
|
@code{*} works like AND
|
||||||
|
|
||||||
|
@code{+} works like OR
|
||||||
|
|
||||||
|
For example the construct:
|
||||||
|
@example
|
||||||
|
if (A AND B) then C
|
||||||
|
@end example
|
||||||
|
is equivalent to:
|
||||||
|
@example
|
||||||
|
if(A*B, C)
|
||||||
|
@end example
|
||||||
|
|
||||||
|
In your C code, you can extend the list of unary and binary functions,
|
||||||
|
and define recognized constants, so that they are available for your
|
||||||
|
expressions.
|
||||||
|
|
||||||
|
The evaluator also recognizes the International System unit prefixes.
|
||||||
|
If 'i' is appended after the prefix, binary prefixes are used, which
|
||||||
|
are based on powers of 1024 instead of powers of 1000.
|
||||||
|
The 'B' postfix multiplies the value by 8, and can be appended after a
|
||||||
|
unit prefix or used alone. This allows using for example 'KB', 'MiB',
|
||||||
|
'G' and 'B' as number postfix.
|
||||||
|
|
||||||
|
The list of available International System prefixes follows, with
|
||||||
|
indication of the corresponding powers of 10 and of 2.
|
||||||
|
@table @option
|
||||||
|
@item y
|
||||||
|
10^-24 / 2^-80
|
||||||
|
@item z
|
||||||
|
10^-21 / 2^-70
|
||||||
|
@item a
|
||||||
|
10^-18 / 2^-60
|
||||||
|
@item f
|
||||||
|
10^-15 / 2^-50
|
||||||
|
@item p
|
||||||
|
10^-12 / 2^-40
|
||||||
|
@item n
|
||||||
|
10^-9 / 2^-30
|
||||||
|
@item u
|
||||||
|
10^-6 / 2^-20
|
||||||
|
@item m
|
||||||
|
10^-3 / 2^-10
|
||||||
|
@item c
|
||||||
|
10^-2
|
||||||
|
@item d
|
||||||
|
10^-1
|
||||||
|
@item h
|
||||||
|
10^2
|
||||||
|
@item k
|
||||||
|
10^3 / 2^10
|
||||||
|
@item K
|
||||||
|
10^3 / 2^10
|
||||||
|
@item M
|
||||||
|
10^6 / 2^20
|
||||||
|
@item G
|
||||||
|
10^9 / 2^30
|
||||||
|
@item T
|
||||||
|
10^12 / 2^40
|
||||||
|
@item P
|
||||||
|
10^15 / 2^40
|
||||||
|
@item E
|
||||||
|
10^18 / 2^50
|
||||||
|
@item Z
|
||||||
|
10^21 / 2^60
|
||||||
|
@item Y
|
||||||
|
10^24 / 2^70
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@c man end
|
||||||
21
doc/examples/.gitignore
vendored
21
doc/examples/.gitignore
vendored
@@ -1,21 +0,0 @@
|
|||||||
/avio_dir_cmd
|
|
||||||
/avio_reading
|
|
||||||
/decode_audio
|
|
||||||
/decode_video
|
|
||||||
/demuxing_decoding
|
|
||||||
/encode_audio
|
|
||||||
/encode_video
|
|
||||||
/extract_mvs
|
|
||||||
/filter_audio
|
|
||||||
/filtering_audio
|
|
||||||
/filtering_video
|
|
||||||
/http_multiclient
|
|
||||||
/metadata
|
|
||||||
/muxing
|
|
||||||
/pc-uninstalled
|
|
||||||
/qsvdec
|
|
||||||
/remuxing
|
|
||||||
/resampling_audio
|
|
||||||
/scaling_video
|
|
||||||
/transcode_aac
|
|
||||||
/transcoding
|
|
||||||
@@ -7,36 +7,24 @@ FFMPEG_LIBS= libavdevice \
|
|||||||
libswscale \
|
libswscale \
|
||||||
libavutil \
|
libavutil \
|
||||||
|
|
||||||
CFLAGS += -Wall -g
|
CFLAGS += -Wall -O2 -g
|
||||||
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
|
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
|
||||||
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
|
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
|
||||||
|
|
||||||
EXAMPLES= avio_dir_cmd \
|
EXAMPLES= decoding_encoding \
|
||||||
avio_reading \
|
demuxing \
|
||||||
decode_audio \
|
|
||||||
decode_video \
|
|
||||||
demuxing_decoding \
|
|
||||||
encode_audio \
|
|
||||||
encode_video \
|
|
||||||
extract_mvs \
|
|
||||||
filtering_video \
|
filtering_video \
|
||||||
filtering_audio \
|
filtering_audio \
|
||||||
http_multiclient \
|
|
||||||
metadata \
|
metadata \
|
||||||
muxing \
|
muxing \
|
||||||
remuxing \
|
|
||||||
resampling_audio \
|
resampling_audio \
|
||||||
scaling_video \
|
scaling_video \
|
||||||
transcode_aac \
|
|
||||||
transcoding \
|
|
||||||
|
|
||||||
OBJS=$(addsuffix .o,$(EXAMPLES))
|
OBJS=$(addsuffix .o,$(EXAMPLES))
|
||||||
|
|
||||||
# the following examples make explicit use of the math library
|
# the following examples make explicit use of the math library
|
||||||
avcodec: LDLIBS += -lm
|
decoding_encoding: LDLIBS += -lm
|
||||||
encode_audio: LDLIBS += -lm
|
|
||||||
muxing: LDLIBS += -lm
|
muxing: LDLIBS += -lm
|
||||||
resampling_audio: LDLIBS += -lm
|
|
||||||
|
|
||||||
.phony: all clean-test clean
|
.phony: all clean-test clean
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,14 @@ Both following use cases rely on pkg-config and make, thus make sure
|
|||||||
that you have them installed and working on your system.
|
that you have them installed and working on your system.
|
||||||
|
|
||||||
|
|
||||||
Method 1: build the installed examples in a generic read/write user directory
|
1) Build the installed examples in a generic read/write user directory
|
||||||
|
|
||||||
Copy to a read/write user directory and just use "make", it will link
|
Copy to a read/write user directory and just use "make", it will link
|
||||||
to the libraries on your system, assuming the PKG_CONFIG_PATH is
|
to the libraries on your system, assuming the PKG_CONFIG_PATH is
|
||||||
correctly configured.
|
correctly configured.
|
||||||
|
|
||||||
Method 2: build the examples in-tree
|
2) Build the examples in-tree
|
||||||
|
|
||||||
Assuming you are in the source FFmpeg checkout directory, you need to build
|
Assuming you are in the source FFmpeg checkout directory, you need to build
|
||||||
FFmpeg (no need to make install in any prefix). Then just run "make examples".
|
FFmpeg (no need to make install in any prefix). Then you can go into the
|
||||||
This will build the examples using the FFmpeg build system. You can clean those
|
doc/examples and run a command such as PKG_CONFIG_PATH=pc-uninstalled make.
|
||||||
examples using "make examplesclean"
|
|
||||||
|
|
||||||
If you want to try the dedicated Makefile examples (to emulate the first
|
|
||||||
method), go into doc/examples and run a command such as
|
|
||||||
PKG_CONFIG_PATH=pc-uninstalled make.
|
|
||||||
|
|||||||
@@ -1,180 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014 Lukasz Marek
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libavformat/avio.h>
|
|
||||||
|
|
||||||
static const char *type_string(int type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case AVIO_ENTRY_DIRECTORY:
|
|
||||||
return "<DIR>";
|
|
||||||
case AVIO_ENTRY_FILE:
|
|
||||||
return "<FILE>";
|
|
||||||
case AVIO_ENTRY_BLOCK_DEVICE:
|
|
||||||
return "<BLOCK DEVICE>";
|
|
||||||
case AVIO_ENTRY_CHARACTER_DEVICE:
|
|
||||||
return "<CHARACTER DEVICE>";
|
|
||||||
case AVIO_ENTRY_NAMED_PIPE:
|
|
||||||
return "<PIPE>";
|
|
||||||
case AVIO_ENTRY_SYMBOLIC_LINK:
|
|
||||||
return "<LINK>";
|
|
||||||
case AVIO_ENTRY_SOCKET:
|
|
||||||
return "<SOCKET>";
|
|
||||||
case AVIO_ENTRY_SERVER:
|
|
||||||
return "<SERVER>";
|
|
||||||
case AVIO_ENTRY_SHARE:
|
|
||||||
return "<SHARE>";
|
|
||||||
case AVIO_ENTRY_WORKGROUP:
|
|
||||||
return "<WORKGROUP>";
|
|
||||||
case AVIO_ENTRY_UNKNOWN:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return "<UNKNOWN>";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int list_op(const char *input_dir)
|
|
||||||
{
|
|
||||||
AVIODirEntry *entry = NULL;
|
|
||||||
AVIODirContext *ctx = NULL;
|
|
||||||
int cnt, ret;
|
|
||||||
char filemode[4], uid_and_gid[20];
|
|
||||||
|
|
||||||
if ((ret = avio_open_dir(&ctx, input_dir, NULL)) < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot open directory: %s.\n", av_err2str(ret));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
cnt = 0;
|
|
||||||
for (;;) {
|
|
||||||
if ((ret = avio_read_dir(ctx, &entry)) < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot list directory: %s.\n", av_err2str(ret));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (!entry)
|
|
||||||
break;
|
|
||||||
if (entry->filemode == -1) {
|
|
||||||
snprintf(filemode, 4, "???");
|
|
||||||
} else {
|
|
||||||
snprintf(filemode, 4, "%3"PRIo64, entry->filemode);
|
|
||||||
}
|
|
||||||
snprintf(uid_and_gid, 20, "%"PRId64"(%"PRId64")", entry->user_id, entry->group_id);
|
|
||||||
if (cnt == 0)
|
|
||||||
av_log(NULL, AV_LOG_INFO, "%-9s %12s %30s %10s %s %16s %16s %16s\n",
|
|
||||||
"TYPE", "SIZE", "NAME", "UID(GID)", "UGO", "MODIFIED",
|
|
||||||
"ACCESSED", "STATUS_CHANGED");
|
|
||||||
av_log(NULL, AV_LOG_INFO, "%-9s %12"PRId64" %30s %10s %s %16"PRId64" %16"PRId64" %16"PRId64"\n",
|
|
||||||
type_string(entry->type),
|
|
||||||
entry->size,
|
|
||||||
entry->name,
|
|
||||||
uid_and_gid,
|
|
||||||
filemode,
|
|
||||||
entry->modification_timestamp,
|
|
||||||
entry->access_timestamp,
|
|
||||||
entry->status_change_timestamp);
|
|
||||||
avio_free_directory_entry(&entry);
|
|
||||||
cnt++;
|
|
||||||
};
|
|
||||||
|
|
||||||
fail:
|
|
||||||
avio_close_dir(&ctx);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int del_op(const char *url)
|
|
||||||
{
|
|
||||||
int ret = avpriv_io_delete(url);
|
|
||||||
if (ret < 0)
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot delete '%s': %s.\n", url, av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int move_op(const char *src, const char *dst)
|
|
||||||
{
|
|
||||||
int ret = avpriv_io_move(src, dst);
|
|
||||||
if (ret < 0)
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot move '%s' into '%s': %s.\n", src, dst, av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void usage(const char *program_name)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: %s OPERATION entry1 [entry2]\n"
|
|
||||||
"API example program to show how to manipulate resources "
|
|
||||||
"accessed through AVIOContext.\n"
|
|
||||||
"OPERATIONS:\n"
|
|
||||||
"list list content of the directory\n"
|
|
||||||
"move rename content in directory\n"
|
|
||||||
"del delete content in directory\n",
|
|
||||||
program_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
const char *op = NULL;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
av_log_set_level(AV_LOG_DEBUG);
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
usage(argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* register codecs and formats and other lavf/lavc components*/
|
|
||||||
av_register_all();
|
|
||||||
avformat_network_init();
|
|
||||||
|
|
||||||
op = argv[1];
|
|
||||||
if (strcmp(op, "list") == 0) {
|
|
||||||
if (argc < 3) {
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Missing argument for list operation.\n");
|
|
||||||
ret = AVERROR(EINVAL);
|
|
||||||
} else {
|
|
||||||
ret = list_op(argv[2]);
|
|
||||||
}
|
|
||||||
} else if (strcmp(op, "del") == 0) {
|
|
||||||
if (argc < 3) {
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Missing argument for del operation.\n");
|
|
||||||
ret = AVERROR(EINVAL);
|
|
||||||
} else {
|
|
||||||
ret = del_op(argv[2]);
|
|
||||||
}
|
|
||||||
} else if (strcmp(op, "move") == 0) {
|
|
||||||
if (argc < 4) {
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Missing argument for move operation.\n");
|
|
||||||
ret = AVERROR(EINVAL);
|
|
||||||
} else {
|
|
||||||
ret = move_op(argv[2], argv[3]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Invalid operation %s\n", op);
|
|
||||||
ret = AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
avformat_network_deinit();
|
|
||||||
|
|
||||||
return ret < 0 ? 1 : 0;
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014 Stefano Sabatini
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* libavformat AVIOContext API example.
|
|
||||||
*
|
|
||||||
* Make libavformat demuxer access media content through a custom
|
|
||||||
* AVIOContext read callback.
|
|
||||||
* @example avio_reading.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libavformat/avio.h>
|
|
||||||
#include <libavutil/file.h>
|
|
||||||
|
|
||||||
struct buffer_data {
|
|
||||||
uint8_t *ptr;
|
|
||||||
size_t size; ///< size left in the buffer
|
|
||||||
};
|
|
||||||
|
|
||||||
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
|
|
||||||
{
|
|
||||||
struct buffer_data *bd = (struct buffer_data *)opaque;
|
|
||||||
buf_size = FFMIN(buf_size, bd->size);
|
|
||||||
|
|
||||||
printf("ptr:%p size:%zu\n", bd->ptr, bd->size);
|
|
||||||
|
|
||||||
/* copy internal buffer data to buf */
|
|
||||||
memcpy(buf, bd->ptr, buf_size);
|
|
||||||
bd->ptr += buf_size;
|
|
||||||
bd->size -= buf_size;
|
|
||||||
|
|
||||||
return buf_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
AVFormatContext *fmt_ctx = NULL;
|
|
||||||
AVIOContext *avio_ctx = NULL;
|
|
||||||
uint8_t *buffer = NULL, *avio_ctx_buffer = NULL;
|
|
||||||
size_t buffer_size, avio_ctx_buffer_size = 4096;
|
|
||||||
char *input_filename = NULL;
|
|
||||||
int ret = 0;
|
|
||||||
struct buffer_data bd = { 0 };
|
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
fprintf(stderr, "usage: %s input_file\n"
|
|
||||||
"API example program to show how to read from a custom buffer "
|
|
||||||
"accessed through AVIOContext.\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
input_filename = argv[1];
|
|
||||||
|
|
||||||
/* register codecs and formats and other lavf/lavc components*/
|
|
||||||
av_register_all();
|
|
||||||
|
|
||||||
/* slurp file content into buffer */
|
|
||||||
ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
|
|
||||||
if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
/* fill opaque structure used by the AVIOContext read callback */
|
|
||||||
bd.ptr = buffer;
|
|
||||||
bd.size = buffer_size;
|
|
||||||
|
|
||||||
if (!(fmt_ctx = avformat_alloc_context())) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
avio_ctx_buffer = av_malloc(avio_ctx_buffer_size);
|
|
||||||
if (!avio_ctx_buffer) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,
|
|
||||||
0, &bd, &read_packet, NULL, NULL);
|
|
||||||
if (!avio_ctx) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
fmt_ctx->pb = avio_ctx;
|
|
||||||
|
|
||||||
ret = avformat_open_input(&fmt_ctx, NULL, NULL, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not open input\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avformat_find_stream_info(fmt_ctx, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not find stream information\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
av_dump_format(fmt_ctx, 0, input_filename, 0);
|
|
||||||
|
|
||||||
end:
|
|
||||||
avformat_close_input(&fmt_ctx);
|
|
||||||
/* note: the internal buffer could have changed, and be != avio_ctx_buffer */
|
|
||||||
if (avio_ctx) {
|
|
||||||
av_freep(&avio_ctx->buffer);
|
|
||||||
av_freep(&avio_ctx);
|
|
||||||
}
|
|
||||||
av_file_unmap(buffer, buffer_size);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* audio decoding with libavcodec API example
|
|
||||||
*
|
|
||||||
* @example decode_audio.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <libavutil/frame.h>
|
|
||||||
#include <libavutil/mem.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
|
|
||||||
#define AUDIO_INBUF_SIZE 20480
|
|
||||||
#define AUDIO_REFILL_THRESH 4096
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *outfilename, *filename;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
int len;
|
|
||||||
FILE *f, *outfile;
|
|
||||||
uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
|
||||||
AVPacket avpkt;
|
|
||||||
AVFrame *decoded_frame = NULL;
|
|
||||||
|
|
||||||
if (argc <= 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
filename = argv[1];
|
|
||||||
outfilename = argv[2];
|
|
||||||
|
|
||||||
/* register all the codecs */
|
|
||||||
avcodec_register_all();
|
|
||||||
|
|
||||||
av_init_packet(&avpkt);
|
|
||||||
|
|
||||||
/* find the MPEG audio decoder */
|
|
||||||
codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
|
|
||||||
if (!codec) {
|
|
||||||
fprintf(stderr, "Codec not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = avcodec_alloc_context3(codec);
|
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not allocate audio codec context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open it */
|
|
||||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not open codec\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen(filename, "rb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "Could not open %s\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
outfile = fopen(outfilename, "wb");
|
|
||||||
if (!outfile) {
|
|
||||||
av_free(c);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* decode until eof */
|
|
||||||
avpkt.data = inbuf;
|
|
||||||
avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
|
|
||||||
|
|
||||||
while (avpkt.size > 0) {
|
|
||||||
int i, ch;
|
|
||||||
int got_frame = 0;
|
|
||||||
|
|
||||||
if (!decoded_frame) {
|
|
||||||
if (!(decoded_frame = av_frame_alloc())) {
|
|
||||||
fprintf(stderr, "Could not allocate audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
|
|
||||||
if (len < 0) {
|
|
||||||
fprintf(stderr, "Error while decoding\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (got_frame) {
|
|
||||||
/* if a frame has been decoded, output it */
|
|
||||||
int data_size = av_get_bytes_per_sample(c->sample_fmt);
|
|
||||||
if (data_size < 0) {
|
|
||||||
/* This should not occur, checking just for paranoia */
|
|
||||||
fprintf(stderr, "Failed to calculate data size\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
for (i=0; i<decoded_frame->nb_samples; i++)
|
|
||||||
for (ch=0; ch<c->channels; ch++)
|
|
||||||
fwrite(decoded_frame->data[ch] + data_size*i, 1, data_size, outfile);
|
|
||||||
}
|
|
||||||
avpkt.size -= len;
|
|
||||||
avpkt.data += len;
|
|
||||||
avpkt.dts =
|
|
||||||
avpkt.pts = AV_NOPTS_VALUE;
|
|
||||||
if (avpkt.size < AUDIO_REFILL_THRESH) {
|
|
||||||
/* Refill the input buffer, to avoid trying to decode
|
|
||||||
* incomplete frames. Instead of this, one could also use
|
|
||||||
* a parser, or use a proper container format through
|
|
||||||
* libavformat. */
|
|
||||||
memmove(inbuf, avpkt.data, avpkt.size);
|
|
||||||
avpkt.data = inbuf;
|
|
||||||
len = fread(avpkt.data + avpkt.size, 1,
|
|
||||||
AUDIO_INBUF_SIZE - avpkt.size, f);
|
|
||||||
if (len > 0)
|
|
||||||
avpkt.size += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(outfile);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
av_frame_free(&decoded_frame);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* video decoding with libavcodec API example
|
|
||||||
*
|
|
||||||
* @example decode_video.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
|
|
||||||
#define INBUF_SIZE 4096
|
|
||||||
|
|
||||||
static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
|
|
||||||
char *filename)
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
f = fopen(filename,"w");
|
|
||||||
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
|
|
||||||
for (i = 0; i < ysize; i++)
|
|
||||||
fwrite(buf + i * wrap, 1, xsize, f);
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,
|
|
||||||
AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
|
|
||||||
{
|
|
||||||
int len, got_frame;
|
|
||||||
char buf[1024];
|
|
||||||
|
|
||||||
len = avcodec_decode_video2(avctx, frame, &got_frame, pkt);
|
|
||||||
if (len < 0) {
|
|
||||||
fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
if (got_frame) {
|
|
||||||
printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
/* the picture is allocated by the decoder, no need to free it */
|
|
||||||
snprintf(buf, sizeof(buf), "%s-%d", outfilename, *frame_count);
|
|
||||||
pgm_save(frame->data[0], frame->linesize[0],
|
|
||||||
frame->width, frame->height, buf);
|
|
||||||
(*frame_count)++;
|
|
||||||
}
|
|
||||||
if (pkt->data) {
|
|
||||||
pkt->size -= len;
|
|
||||||
pkt->data += len;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *filename, *outfilename;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
int frame_count;
|
|
||||||
FILE *f;
|
|
||||||
AVFrame *frame;
|
|
||||||
uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
|
||||||
AVPacket avpkt;
|
|
||||||
|
|
||||||
if (argc <= 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
filename = argv[1];
|
|
||||||
outfilename = argv[2];
|
|
||||||
|
|
||||||
avcodec_register_all();
|
|
||||||
|
|
||||||
av_init_packet(&avpkt);
|
|
||||||
|
|
||||||
/* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
|
|
||||||
memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
|
||||||
|
|
||||||
/* find the MPEG-1 video decoder */
|
|
||||||
codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
|
|
||||||
if (!codec) {
|
|
||||||
fprintf(stderr, "Codec not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = avcodec_alloc_context3(codec);
|
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not allocate video codec context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
|
|
||||||
c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
|
||||||
|
|
||||||
/* For some codecs, such as msmpeg4 and mpeg4, width and height
|
|
||||||
MUST be initialized there because this information is not
|
|
||||||
available in the bitstream. */
|
|
||||||
|
|
||||||
/* open it */
|
|
||||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not open codec\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen(filename, "rb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "Could not open %s\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
fprintf(stderr, "Could not allocate video frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_count = 0;
|
|
||||||
for (;;) {
|
|
||||||
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
|
|
||||||
if (avpkt.size == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
|
|
||||||
and this is the only method to use them because you cannot
|
|
||||||
know the compressed data size before analysing it.
|
|
||||||
|
|
||||||
BUT some other codecs (msmpeg4, mpeg4) are inherently frame
|
|
||||||
based, so you must call them with all the data for one
|
|
||||||
frame exactly. You must also initialize 'width' and
|
|
||||||
'height' before initializing them. */
|
|
||||||
|
|
||||||
/* NOTE2: some codecs allow the raw parameters (frame size,
|
|
||||||
sample rate) to be changed at any frame. We handle this, so
|
|
||||||
you should also take care of it */
|
|
||||||
|
|
||||||
/* here, we use a stream based decoder (mpeg1video), so we
|
|
||||||
feed decoder and see if it could decode a frame */
|
|
||||||
avpkt.data = inbuf;
|
|
||||||
while (avpkt.size > 0)
|
|
||||||
if (decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 0) < 0)
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some codecs, such as MPEG, transmit the I- and P-frame with a
|
|
||||||
latency of one frame. You must do the following to have a
|
|
||||||
chance to get the last frame of the video. */
|
|
||||||
avpkt.data = NULL;
|
|
||||||
avpkt.size = 0;
|
|
||||||
decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
650
doc/examples/decoding_encoding.c
Normal file
650
doc/examples/decoding_encoding.c
Normal file
@@ -0,0 +1,650 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2001 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* libavcodec API use example.
|
||||||
|
*
|
||||||
|
* Note that libavcodec only handles codecs (mpeg, mpeg4, etc...),
|
||||||
|
* not file formats (avi, vob, mp4, mov, mkv, mxf, flv, mpegts, mpegps, etc...). See library 'libavformat' for the
|
||||||
|
* format handling
|
||||||
|
* @example doc/examples/decoding_encoding.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <libavutil/opt.h>
|
||||||
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libavutil/channel_layout.h>
|
||||||
|
#include <libavutil/common.h>
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
|
#include <libavutil/mathematics.h>
|
||||||
|
#include <libavutil/samplefmt.h>
|
||||||
|
|
||||||
|
#define INBUF_SIZE 4096
|
||||||
|
#define AUDIO_INBUF_SIZE 20480
|
||||||
|
#define AUDIO_REFILL_THRESH 4096
|
||||||
|
|
||||||
|
/* check that a given sample format is supported by the encoder */
|
||||||
|
static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt)
|
||||||
|
{
|
||||||
|
const enum AVSampleFormat *p = codec->sample_fmts;
|
||||||
|
|
||||||
|
while (*p != AV_SAMPLE_FMT_NONE) {
|
||||||
|
if (*p == sample_fmt)
|
||||||
|
return 1;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* just pick the highest supported samplerate */
|
||||||
|
static int select_sample_rate(AVCodec *codec)
|
||||||
|
{
|
||||||
|
const int *p;
|
||||||
|
int best_samplerate = 0;
|
||||||
|
|
||||||
|
if (!codec->supported_samplerates)
|
||||||
|
return 44100;
|
||||||
|
|
||||||
|
p = codec->supported_samplerates;
|
||||||
|
while (*p) {
|
||||||
|
best_samplerate = FFMAX(*p, best_samplerate);
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
return best_samplerate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select layout with the highest channel count */
|
||||||
|
static int select_channel_layout(AVCodec *codec)
|
||||||
|
{
|
||||||
|
const uint64_t *p;
|
||||||
|
uint64_t best_ch_layout = 0;
|
||||||
|
int best_nb_channells = 0;
|
||||||
|
|
||||||
|
if (!codec->channel_layouts)
|
||||||
|
return AV_CH_LAYOUT_STEREO;
|
||||||
|
|
||||||
|
p = codec->channel_layouts;
|
||||||
|
while (*p) {
|
||||||
|
int nb_channels = av_get_channel_layout_nb_channels(*p);
|
||||||
|
|
||||||
|
if (nb_channels > best_nb_channells) {
|
||||||
|
best_ch_layout = *p;
|
||||||
|
best_nb_channells = nb_channels;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
return best_ch_layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Audio encoding example
|
||||||
|
*/
|
||||||
|
static void audio_encode_example(const char *filename)
|
||||||
|
{
|
||||||
|
AVCodec *codec;
|
||||||
|
AVCodecContext *c= NULL;
|
||||||
|
AVFrame *frame;
|
||||||
|
AVPacket pkt;
|
||||||
|
int i, j, k, ret, got_output;
|
||||||
|
int buffer_size;
|
||||||
|
FILE *f;
|
||||||
|
uint16_t *samples;
|
||||||
|
float t, tincr;
|
||||||
|
|
||||||
|
printf("Encode audio file %s\n", filename);
|
||||||
|
|
||||||
|
/* find the MP2 encoder */
|
||||||
|
codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
|
||||||
|
if (!codec) {
|
||||||
|
fprintf(stderr, "Codec not found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
c = avcodec_alloc_context3(codec);
|
||||||
|
if (!c) {
|
||||||
|
fprintf(stderr, "Could not allocate audio codec context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* put sample parameters */
|
||||||
|
c->bit_rate = 64000;
|
||||||
|
|
||||||
|
/* check that the encoder supports s16 pcm input */
|
||||||
|
c->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||||
|
if (!check_sample_fmt(codec, c->sample_fmt)) {
|
||||||
|
fprintf(stderr, "Encoder does not support sample format %s",
|
||||||
|
av_get_sample_fmt_name(c->sample_fmt));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select other audio parameters supported by the encoder */
|
||||||
|
c->sample_rate = select_sample_rate(codec);
|
||||||
|
c->channel_layout = select_channel_layout(codec);
|
||||||
|
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
||||||
|
|
||||||
|
/* open it */
|
||||||
|
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||||
|
fprintf(stderr, "Could not open codec\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fopen(filename, "wb");
|
||||||
|
if (!f) {
|
||||||
|
fprintf(stderr, "Could not open %s\n", filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* frame containing input raw audio */
|
||||||
|
frame = avcodec_alloc_frame();
|
||||||
|
if (!frame) {
|
||||||
|
fprintf(stderr, "Could not allocate audio frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->nb_samples = c->frame_size;
|
||||||
|
frame->format = c->sample_fmt;
|
||||||
|
frame->channel_layout = c->channel_layout;
|
||||||
|
|
||||||
|
/* the codec gives us the frame size, in samples,
|
||||||
|
* we calculate the size of the samples buffer in bytes */
|
||||||
|
buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
|
||||||
|
c->sample_fmt, 0);
|
||||||
|
samples = av_malloc(buffer_size);
|
||||||
|
if (!samples) {
|
||||||
|
fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
|
||||||
|
buffer_size);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
/* setup the data pointers in the AVFrame */
|
||||||
|
ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
|
||||||
|
(const uint8_t*)samples, buffer_size, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not setup audio frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* encode a single tone sound */
|
||||||
|
t = 0;
|
||||||
|
tincr = 2 * M_PI * 440.0 / c->sample_rate;
|
||||||
|
for(i=0;i<200;i++) {
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||||
|
pkt.size = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < c->frame_size; j++) {
|
||||||
|
samples[2*j] = (int)(sin(t) * 10000);
|
||||||
|
|
||||||
|
for (k = 1; k < c->channels; k++)
|
||||||
|
samples[2*j + k] = samples[2*j];
|
||||||
|
t += tincr;
|
||||||
|
}
|
||||||
|
/* encode the samples */
|
||||||
|
ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error encoding audio frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (got_output) {
|
||||||
|
fwrite(pkt.data, 1, pkt.size, f);
|
||||||
|
av_free_packet(&pkt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get the delayed frames */
|
||||||
|
for (got_output = 1; got_output; i++) {
|
||||||
|
ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error encoding frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (got_output) {
|
||||||
|
fwrite(pkt.data, 1, pkt.size, f);
|
||||||
|
av_free_packet(&pkt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
av_freep(&samples);
|
||||||
|
avcodec_free_frame(&frame);
|
||||||
|
avcodec_close(c);
|
||||||
|
av_free(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Audio decoding.
|
||||||
|
*/
|
||||||
|
static void audio_decode_example(const char *outfilename, const char *filename)
|
||||||
|
{
|
||||||
|
AVCodec *codec;
|
||||||
|
AVCodecContext *c= NULL;
|
||||||
|
int len;
|
||||||
|
FILE *f, *outfile;
|
||||||
|
uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||||
|
AVPacket avpkt;
|
||||||
|
AVFrame *decoded_frame = NULL;
|
||||||
|
|
||||||
|
av_init_packet(&avpkt);
|
||||||
|
|
||||||
|
printf("Decode audio file %s to %s\n", filename, outfilename);
|
||||||
|
|
||||||
|
/* find the mpeg audio decoder */
|
||||||
|
codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
|
||||||
|
if (!codec) {
|
||||||
|
fprintf(stderr, "Codec not found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
c = avcodec_alloc_context3(codec);
|
||||||
|
if (!c) {
|
||||||
|
fprintf(stderr, "Could not allocate audio codec context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open it */
|
||||||
|
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||||
|
fprintf(stderr, "Could not open codec\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fopen(filename, "rb");
|
||||||
|
if (!f) {
|
||||||
|
fprintf(stderr, "Could not open %s\n", filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
outfile = fopen(outfilename, "wb");
|
||||||
|
if (!outfile) {
|
||||||
|
av_free(c);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* decode until eof */
|
||||||
|
avpkt.data = inbuf;
|
||||||
|
avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
|
||||||
|
|
||||||
|
while (avpkt.size > 0) {
|
||||||
|
int got_frame = 0;
|
||||||
|
|
||||||
|
if (!decoded_frame) {
|
||||||
|
if (!(decoded_frame = avcodec_alloc_frame())) {
|
||||||
|
fprintf(stderr, "Could not allocate audio frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
avcodec_get_frame_defaults(decoded_frame);
|
||||||
|
|
||||||
|
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
|
||||||
|
if (len < 0) {
|
||||||
|
fprintf(stderr, "Error while decoding\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (got_frame) {
|
||||||
|
/* if a frame has been decoded, output it */
|
||||||
|
int data_size = av_samples_get_buffer_size(NULL, c->channels,
|
||||||
|
decoded_frame->nb_samples,
|
||||||
|
c->sample_fmt, 1);
|
||||||
|
fwrite(decoded_frame->data[0], 1, data_size, outfile);
|
||||||
|
}
|
||||||
|
avpkt.size -= len;
|
||||||
|
avpkt.data += len;
|
||||||
|
avpkt.dts =
|
||||||
|
avpkt.pts = AV_NOPTS_VALUE;
|
||||||
|
if (avpkt.size < AUDIO_REFILL_THRESH) {
|
||||||
|
/* Refill the input buffer, to avoid trying to decode
|
||||||
|
* incomplete frames. Instead of this, one could also use
|
||||||
|
* a parser, or use a proper container format through
|
||||||
|
* libavformat. */
|
||||||
|
memmove(inbuf, avpkt.data, avpkt.size);
|
||||||
|
avpkt.data = inbuf;
|
||||||
|
len = fread(avpkt.data + avpkt.size, 1,
|
||||||
|
AUDIO_INBUF_SIZE - avpkt.size, f);
|
||||||
|
if (len > 0)
|
||||||
|
avpkt.size += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
avcodec_close(c);
|
||||||
|
av_free(c);
|
||||||
|
avcodec_free_frame(&decoded_frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Video encoding example
|
||||||
|
*/
|
||||||
|
static void video_encode_example(const char *filename, int codec_id)
|
||||||
|
{
|
||||||
|
AVCodec *codec;
|
||||||
|
AVCodecContext *c= NULL;
|
||||||
|
int i, ret, x, y, got_output;
|
||||||
|
FILE *f;
|
||||||
|
AVFrame *frame;
|
||||||
|
AVPacket pkt;
|
||||||
|
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
||||||
|
|
||||||
|
printf("Encode video file %s\n", filename);
|
||||||
|
|
||||||
|
/* find the mpeg1 video encoder */
|
||||||
|
codec = avcodec_find_encoder(codec_id);
|
||||||
|
if (!codec) {
|
||||||
|
fprintf(stderr, "Codec not found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
c = avcodec_alloc_context3(codec);
|
||||||
|
if (!c) {
|
||||||
|
fprintf(stderr, "Could not allocate video codec context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* put sample parameters */
|
||||||
|
c->bit_rate = 400000;
|
||||||
|
/* resolution must be a multiple of two */
|
||||||
|
c->width = 352;
|
||||||
|
c->height = 288;
|
||||||
|
/* frames per second */
|
||||||
|
c->time_base= (AVRational){1,25};
|
||||||
|
c->gop_size = 10; /* emit one intra frame every ten frames */
|
||||||
|
c->max_b_frames=1;
|
||||||
|
c->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||||
|
|
||||||
|
if(codec_id == AV_CODEC_ID_H264)
|
||||||
|
av_opt_set(c->priv_data, "preset", "slow", 0);
|
||||||
|
|
||||||
|
/* open it */
|
||||||
|
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||||
|
fprintf(stderr, "Could not open codec\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fopen(filename, "wb");
|
||||||
|
if (!f) {
|
||||||
|
fprintf(stderr, "Could not open %s\n", filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = avcodec_alloc_frame();
|
||||||
|
if (!frame) {
|
||||||
|
fprintf(stderr, "Could not allocate video frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
frame->format = c->pix_fmt;
|
||||||
|
frame->width = c->width;
|
||||||
|
frame->height = c->height;
|
||||||
|
|
||||||
|
/* the image can be allocated by any means and av_image_alloc() is
|
||||||
|
* just the most convenient way if av_malloc() is to be used */
|
||||||
|
ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
|
||||||
|
c->pix_fmt, 32);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not allocate raw picture buffer\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* encode 1 second of video */
|
||||||
|
for(i=0;i<25;i++) {
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||||
|
pkt.size = 0;
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
/* prepare a dummy image */
|
||||||
|
/* Y */
|
||||||
|
for(y=0;y<c->height;y++) {
|
||||||
|
for(x=0;x<c->width;x++) {
|
||||||
|
frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cb and Cr */
|
||||||
|
for(y=0;y<c->height/2;y++) {
|
||||||
|
for(x=0;x<c->width/2;x++) {
|
||||||
|
frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
|
||||||
|
frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->pts = i;
|
||||||
|
|
||||||
|
/* encode the image */
|
||||||
|
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error encoding frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (got_output) {
|
||||||
|
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
||||||
|
fwrite(pkt.data, 1, pkt.size, f);
|
||||||
|
av_free_packet(&pkt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get the delayed frames */
|
||||||
|
for (got_output = 1; got_output; i++) {
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error encoding frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (got_output) {
|
||||||
|
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
||||||
|
fwrite(pkt.data, 1, pkt.size, f);
|
||||||
|
av_free_packet(&pkt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add sequence end code to have a real mpeg file */
|
||||||
|
fwrite(endcode, 1, sizeof(endcode), f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
avcodec_close(c);
|
||||||
|
av_free(c);
|
||||||
|
av_freep(&frame->data[0]);
|
||||||
|
avcodec_free_frame(&frame);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Video decoding example
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
|
||||||
|
char *filename)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
f=fopen(filename,"w");
|
||||||
|
fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
|
||||||
|
for(i=0;i<ysize;i++)
|
||||||
|
fwrite(buf + i * wrap,1,xsize,f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,
|
||||||
|
AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
|
||||||
|
{
|
||||||
|
int len, got_frame;
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
|
len = avcodec_decode_video2(avctx, frame, &got_frame, pkt);
|
||||||
|
if (len < 0) {
|
||||||
|
fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
if (got_frame) {
|
||||||
|
printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
/* the picture is allocated by the decoder, no need to free it */
|
||||||
|
snprintf(buf, sizeof(buf), outfilename, *frame_count);
|
||||||
|
pgm_save(frame->data[0], frame->linesize[0],
|
||||||
|
avctx->width, avctx->height, buf);
|
||||||
|
(*frame_count)++;
|
||||||
|
}
|
||||||
|
if (pkt->data) {
|
||||||
|
pkt->size -= len;
|
||||||
|
pkt->data += len;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void video_decode_example(const char *outfilename, const char *filename)
|
||||||
|
{
|
||||||
|
AVCodec *codec;
|
||||||
|
AVCodecContext *c= NULL;
|
||||||
|
int frame_count;
|
||||||
|
FILE *f;
|
||||||
|
AVFrame *frame;
|
||||||
|
uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||||
|
AVPacket avpkt;
|
||||||
|
|
||||||
|
av_init_packet(&avpkt);
|
||||||
|
|
||||||
|
/* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
|
||||||
|
memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
|
printf("Decode video file %s to %s\n", filename, outfilename);
|
||||||
|
|
||||||
|
/* find the mpeg1 video decoder */
|
||||||
|
codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
|
||||||
|
if (!codec) {
|
||||||
|
fprintf(stderr, "Codec not found\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
c = avcodec_alloc_context3(codec);
|
||||||
|
if (!c) {
|
||||||
|
fprintf(stderr, "Could not allocate video codec context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(codec->capabilities&CODEC_CAP_TRUNCATED)
|
||||||
|
c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
|
||||||
|
|
||||||
|
/* For some codecs, such as msmpeg4 and mpeg4, width and height
|
||||||
|
MUST be initialized there because this information is not
|
||||||
|
available in the bitstream. */
|
||||||
|
|
||||||
|
/* open it */
|
||||||
|
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||||
|
fprintf(stderr, "Could not open codec\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fopen(filename, "rb");
|
||||||
|
if (!f) {
|
||||||
|
fprintf(stderr, "Could not open %s\n", filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = avcodec_alloc_frame();
|
||||||
|
if (!frame) {
|
||||||
|
fprintf(stderr, "Could not allocate video frame\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_count = 0;
|
||||||
|
for(;;) {
|
||||||
|
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
|
||||||
|
if (avpkt.size == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
|
||||||
|
and this is the only method to use them because you cannot
|
||||||
|
know the compressed data size before analysing it.
|
||||||
|
|
||||||
|
BUT some other codecs (msmpeg4, mpeg4) are inherently frame
|
||||||
|
based, so you must call them with all the data for one
|
||||||
|
frame exactly. You must also initialize 'width' and
|
||||||
|
'height' before initializing them. */
|
||||||
|
|
||||||
|
/* NOTE2: some codecs allow the raw parameters (frame size,
|
||||||
|
sample rate) to be changed at any frame. We handle this, so
|
||||||
|
you should also take care of it */
|
||||||
|
|
||||||
|
/* here, we use a stream based decoder (mpeg1video), so we
|
||||||
|
feed decoder and see if it could decode a frame */
|
||||||
|
avpkt.data = inbuf;
|
||||||
|
while (avpkt.size > 0)
|
||||||
|
if (decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 0) < 0)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* some codecs, such as MPEG, transmit the I and P frame with a
|
||||||
|
latency of one frame. You must do the following to have a
|
||||||
|
chance to get the last frame of the video */
|
||||||
|
avpkt.data = NULL;
|
||||||
|
avpkt.size = 0;
|
||||||
|
decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
avcodec_close(c);
|
||||||
|
av_free(c);
|
||||||
|
avcodec_free_frame(&frame);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
const char *output_type;
|
||||||
|
|
||||||
|
/* register all the codecs */
|
||||||
|
avcodec_register_all();
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("usage: %s output_type\n"
|
||||||
|
"API example program to decode/encode a media stream with libavcodec.\n"
|
||||||
|
"This program generates a synthetic stream and encodes it to a file\n"
|
||||||
|
"named test.h264, test.mp2 or test.mpg depending on output_type.\n"
|
||||||
|
"The encoded stream is then decoded and written to a raw data output.\n"
|
||||||
|
"output_type must be choosen between 'h264', 'mp2', 'mpg'.\n",
|
||||||
|
argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
output_type = argv[1];
|
||||||
|
|
||||||
|
if (!strcmp(output_type, "h264")) {
|
||||||
|
video_encode_example("test.h264", AV_CODEC_ID_H264);
|
||||||
|
} else if (!strcmp(output_type, "mp2")) {
|
||||||
|
audio_encode_example("test.mp2");
|
||||||
|
audio_decode_example("test.sw", "test.mp2");
|
||||||
|
} else if (!strcmp(output_type, "mpg")) {
|
||||||
|
video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
|
||||||
|
video_decode_example("test%02d.pgm", "test.mpg");
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Invalid output type '%s', choose between 'h264', 'mp2', or 'mpg'\n",
|
||||||
|
output_type);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
342
doc/examples/demuxing.c
Normal file
342
doc/examples/demuxing.c
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012 Stefano Sabatini
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* libavformat demuxing API use example.
|
||||||
|
*
|
||||||
|
* Show how to use the libavformat and libavcodec API to demux and
|
||||||
|
* decode audio and video data.
|
||||||
|
* @example doc/examples/demuxing.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libavutil/imgutils.h>
|
||||||
|
#include <libavutil/samplefmt.h>
|
||||||
|
#include <libavutil/timestamp.h>
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
|
||||||
|
static AVFormatContext *fmt_ctx = NULL;
|
||||||
|
static AVCodecContext *video_dec_ctx = NULL, *audio_dec_ctx;
|
||||||
|
static AVStream *video_stream = NULL, *audio_stream = NULL;
|
||||||
|
static const char *src_filename = NULL;
|
||||||
|
static const char *video_dst_filename = NULL;
|
||||||
|
static const char *audio_dst_filename = NULL;
|
||||||
|
static FILE *video_dst_file = NULL;
|
||||||
|
static FILE *audio_dst_file = NULL;
|
||||||
|
|
||||||
|
static uint8_t *video_dst_data[4] = {NULL};
|
||||||
|
static int video_dst_linesize[4];
|
||||||
|
static int video_dst_bufsize;
|
||||||
|
|
||||||
|
static uint8_t **audio_dst_data = NULL;
|
||||||
|
static int audio_dst_linesize;
|
||||||
|
static int audio_dst_bufsize;
|
||||||
|
|
||||||
|
static int video_stream_idx = -1, audio_stream_idx = -1;
|
||||||
|
static AVFrame *frame = NULL;
|
||||||
|
static AVPacket pkt;
|
||||||
|
static int video_frame_count = 0;
|
||||||
|
static int audio_frame_count = 0;
|
||||||
|
|
||||||
|
static int decode_packet(int *got_frame, int cached)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (pkt.stream_index == video_stream_idx) {
|
||||||
|
/* decode video frame */
|
||||||
|
ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error decoding video frame\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*got_frame) {
|
||||||
|
printf("video_frame%s n:%d coded_n:%d pts:%s\n",
|
||||||
|
cached ? "(cached)" : "",
|
||||||
|
video_frame_count++, frame->coded_picture_number,
|
||||||
|
av_ts2timestr(frame->pts, &video_dec_ctx->time_base));
|
||||||
|
|
||||||
|
/* copy decoded frame to destination buffer:
|
||||||
|
* this is required since rawvideo expects non aligned data */
|
||||||
|
av_image_copy(video_dst_data, video_dst_linesize,
|
||||||
|
(const uint8_t **)(frame->data), frame->linesize,
|
||||||
|
video_dec_ctx->pix_fmt, video_dec_ctx->width, video_dec_ctx->height);
|
||||||
|
|
||||||
|
/* write to rawvideo file */
|
||||||
|
fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file);
|
||||||
|
}
|
||||||
|
} else if (pkt.stream_index == audio_stream_idx) {
|
||||||
|
/* decode audio frame */
|
||||||
|
ret = avcodec_decode_audio4(audio_dec_ctx, frame, got_frame, &pkt);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error decoding audio frame\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*got_frame) {
|
||||||
|
printf("audio_frame%s n:%d nb_samples:%d pts:%s\n",
|
||||||
|
cached ? "(cached)" : "",
|
||||||
|
audio_frame_count++, frame->nb_samples,
|
||||||
|
av_ts2timestr(frame->pts, &audio_dec_ctx->time_base));
|
||||||
|
|
||||||
|
ret = av_samples_alloc(audio_dst_data, &audio_dst_linesize, av_frame_get_channels(frame),
|
||||||
|
frame->nb_samples, frame->format, 1);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not allocate audio buffer\n");
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: extend return code of the av_samples_* functions so that this call is not needed */
|
||||||
|
audio_dst_bufsize =
|
||||||
|
av_samples_get_buffer_size(NULL, av_frame_get_channels(frame),
|
||||||
|
frame->nb_samples, frame->format, 1);
|
||||||
|
|
||||||
|
/* copy audio data to destination buffer:
|
||||||
|
* this is required since rawaudio expects non aligned data */
|
||||||
|
av_samples_copy(audio_dst_data, frame->data, 0, 0,
|
||||||
|
frame->nb_samples, av_frame_get_channels(frame), frame->format);
|
||||||
|
|
||||||
|
/* write to rawaudio file */
|
||||||
|
fwrite(audio_dst_data[0], 1, audio_dst_bufsize, audio_dst_file);
|
||||||
|
av_freep(&audio_dst_data[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int open_codec_context(int *stream_idx,
|
||||||
|
AVFormatContext *fmt_ctx, enum AVMediaType type)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
AVStream *st;
|
||||||
|
AVCodecContext *dec_ctx = NULL;
|
||||||
|
AVCodec *dec = NULL;
|
||||||
|
|
||||||
|
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
|
||||||
|
av_get_media_type_string(type), src_filename);
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
*stream_idx = ret;
|
||||||
|
st = fmt_ctx->streams[*stream_idx];
|
||||||
|
|
||||||
|
/* find decoder for the stream */
|
||||||
|
dec_ctx = st->codec;
|
||||||
|
dec = avcodec_find_decoder(dec_ctx->codec_id);
|
||||||
|
if (!dec) {
|
||||||
|
fprintf(stderr, "Failed to find %s codec\n",
|
||||||
|
av_get_media_type_string(type));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
||||||
|
fprintf(stderr, "Failed to open %s codec\n",
|
||||||
|
av_get_media_type_string(type));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_format_from_sample_fmt(const char **fmt,
|
||||||
|
enum AVSampleFormat sample_fmt)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct sample_fmt_entry {
|
||||||
|
enum AVSampleFormat sample_fmt; const char *fmt_be, *fmt_le;
|
||||||
|
} sample_fmt_entries[] = {
|
||||||
|
{ AV_SAMPLE_FMT_U8, "u8", "u8" },
|
||||||
|
{ AV_SAMPLE_FMT_S16, "s16be", "s16le" },
|
||||||
|
{ AV_SAMPLE_FMT_S32, "s32be", "s32le" },
|
||||||
|
{ AV_SAMPLE_FMT_FLT, "f32be", "f32le" },
|
||||||
|
{ AV_SAMPLE_FMT_DBL, "f64be", "f64le" },
|
||||||
|
};
|
||||||
|
*fmt = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < FF_ARRAY_ELEMS(sample_fmt_entries); i++) {
|
||||||
|
struct sample_fmt_entry *entry = &sample_fmt_entries[i];
|
||||||
|
if (sample_fmt == entry->sample_fmt) {
|
||||||
|
*fmt = AV_NE(entry->fmt_be, entry->fmt_le);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"sample format %s is not supported as output format\n",
|
||||||
|
av_get_sample_fmt_name(sample_fmt));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ret = 0, got_frame;
|
||||||
|
|
||||||
|
if (argc != 4) {
|
||||||
|
fprintf(stderr, "usage: %s input_file video_output_file audio_output_file\n"
|
||||||
|
"API example program to show how to read frames from an input file.\n"
|
||||||
|
"This program reads frames from a file, decodes them, and writes decoded\n"
|
||||||
|
"video frames to a rawvideo file named video_output_file, and decoded\n"
|
||||||
|
"audio frames to a rawaudio file named audio_output_file.\n"
|
||||||
|
"\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
src_filename = argv[1];
|
||||||
|
video_dst_filename = argv[2];
|
||||||
|
audio_dst_filename = argv[3];
|
||||||
|
|
||||||
|
/* register all formats and codecs */
|
||||||
|
av_register_all();
|
||||||
|
|
||||||
|
/* open input file, and allocate format context */
|
||||||
|
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
||||||
|
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* retrieve stream information */
|
||||||
|
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
|
||||||
|
fprintf(stderr, "Could not find stream information\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
|
||||||
|
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||||
|
video_dec_ctx = video_stream->codec;
|
||||||
|
|
||||||
|
video_dst_file = fopen(video_dst_filename, "wb");
|
||||||
|
if (!video_dst_file) {
|
||||||
|
fprintf(stderr, "Could not open destination file %s\n", video_dst_filename);
|
||||||
|
ret = 1;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate image where the decoded image will be put */
|
||||||
|
ret = av_image_alloc(video_dst_data, video_dst_linesize,
|
||||||
|
video_dec_ctx->width, video_dec_ctx->height,
|
||||||
|
video_dec_ctx->pix_fmt, 1);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not allocate raw video buffer\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
video_dst_bufsize = ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
|
||||||
|
int nb_planes;
|
||||||
|
|
||||||
|
audio_stream = fmt_ctx->streams[audio_stream_idx];
|
||||||
|
audio_dec_ctx = audio_stream->codec;
|
||||||
|
audio_dst_file = fopen(audio_dst_filename, "wb");
|
||||||
|
if (!audio_dst_file) {
|
||||||
|
fprintf(stderr, "Could not open destination file %s\n", video_dst_filename);
|
||||||
|
ret = 1;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
nb_planes = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ?
|
||||||
|
audio_dec_ctx->channels : 1;
|
||||||
|
audio_dst_data = av_mallocz(sizeof(uint8_t *) * nb_planes);
|
||||||
|
if (!audio_dst_data) {
|
||||||
|
fprintf(stderr, "Could not allocate audio data buffers\n");
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* dump input information to stderr */
|
||||||
|
av_dump_format(fmt_ctx, 0, src_filename, 0);
|
||||||
|
|
||||||
|
if (!audio_stream && !video_stream) {
|
||||||
|
fprintf(stderr, "Could not find audio or video stream in the input, aborting\n");
|
||||||
|
ret = 1;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = avcodec_alloc_frame();
|
||||||
|
if (!frame) {
|
||||||
|
fprintf(stderr, "Could not allocate frame\n");
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
pkt.data = NULL;
|
||||||
|
pkt.size = 0;
|
||||||
|
|
||||||
|
if (video_stream)
|
||||||
|
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
|
||||||
|
if (audio_stream)
|
||||||
|
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
|
||||||
|
|
||||||
|
/* read frames from the file */
|
||||||
|
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
|
||||||
|
decode_packet(&got_frame, 0);
|
||||||
|
av_free_packet(&pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flush cached frames */
|
||||||
|
pkt.data = NULL;
|
||||||
|
pkt.size = 0;
|
||||||
|
do {
|
||||||
|
decode_packet(&got_frame, 1);
|
||||||
|
} while (got_frame);
|
||||||
|
|
||||||
|
printf("Demuxing succeeded.\n");
|
||||||
|
|
||||||
|
if (video_stream) {
|
||||||
|
printf("Play the output video file with the command:\n"
|
||||||
|
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
|
||||||
|
av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height,
|
||||||
|
video_dst_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audio_stream) {
|
||||||
|
const char *fmt;
|
||||||
|
|
||||||
|
if ((ret = get_format_from_sample_fmt(&fmt, audio_dec_ctx->sample_fmt)) < 0)
|
||||||
|
goto end;
|
||||||
|
printf("Play the output audio file with the command:\n"
|
||||||
|
"ffplay -f %s -ac %d -ar %d %s\n",
|
||||||
|
fmt, audio_dec_ctx->channels, audio_dec_ctx->sample_rate,
|
||||||
|
audio_dst_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (video_dec_ctx)
|
||||||
|
avcodec_close(video_dec_ctx);
|
||||||
|
if (audio_dec_ctx)
|
||||||
|
avcodec_close(audio_dec_ctx);
|
||||||
|
avformat_close_input(&fmt_ctx);
|
||||||
|
if (video_dst_file)
|
||||||
|
fclose(video_dst_file);
|
||||||
|
if (audio_dst_file)
|
||||||
|
fclose(audio_dst_file);
|
||||||
|
av_free(frame);
|
||||||
|
av_free(video_dst_data[0]);
|
||||||
|
av_free(audio_dst_data);
|
||||||
|
|
||||||
|
return ret < 0;
|
||||||
|
}
|
||||||
@@ -1,393 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2012 Stefano Sabatini
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Demuxing and decoding example.
|
|
||||||
*
|
|
||||||
* Show how to use the libavformat and libavcodec API to demux and
|
|
||||||
* decode audio and video data.
|
|
||||||
* @example demuxing_decoding.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libavutil/imgutils.h>
|
|
||||||
#include <libavutil/samplefmt.h>
|
|
||||||
#include <libavutil/timestamp.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
|
|
||||||
static AVFormatContext *fmt_ctx = NULL;
|
|
||||||
static AVCodecContext *video_dec_ctx = NULL, *audio_dec_ctx;
|
|
||||||
static int width, height;
|
|
||||||
static enum AVPixelFormat pix_fmt;
|
|
||||||
static AVStream *video_stream = NULL, *audio_stream = NULL;
|
|
||||||
static const char *src_filename = NULL;
|
|
||||||
static const char *video_dst_filename = NULL;
|
|
||||||
static const char *audio_dst_filename = NULL;
|
|
||||||
static FILE *video_dst_file = NULL;
|
|
||||||
static FILE *audio_dst_file = NULL;
|
|
||||||
|
|
||||||
static uint8_t *video_dst_data[4] = {NULL};
|
|
||||||
static int video_dst_linesize[4];
|
|
||||||
static int video_dst_bufsize;
|
|
||||||
|
|
||||||
static int video_stream_idx = -1, audio_stream_idx = -1;
|
|
||||||
static AVFrame *frame = NULL;
|
|
||||||
static AVPacket pkt;
|
|
||||||
static int video_frame_count = 0;
|
|
||||||
static int audio_frame_count = 0;
|
|
||||||
|
|
||||||
/* Enable or disable frame reference counting. You are not supposed to support
|
|
||||||
* both paths in your application but pick the one most appropriate to your
|
|
||||||
* needs. Look for the use of refcount in this example to see what are the
|
|
||||||
* differences of API usage between them. */
|
|
||||||
static int refcount = 0;
|
|
||||||
|
|
||||||
static int decode_packet(int *got_frame, int cached)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
int decoded = pkt.size;
|
|
||||||
|
|
||||||
*got_frame = 0;
|
|
||||||
|
|
||||||
if (pkt.stream_index == video_stream_idx) {
|
|
||||||
/* decode video frame */
|
|
||||||
ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*got_frame) {
|
|
||||||
|
|
||||||
if (frame->width != width || frame->height != height ||
|
|
||||||
frame->format != pix_fmt) {
|
|
||||||
/* To handle this change, one could call av_image_alloc again and
|
|
||||||
* decode the following frames into another rawvideo file. */
|
|
||||||
fprintf(stderr, "Error: Width, height and pixel format have to be "
|
|
||||||
"constant in a rawvideo file, but the width, height or "
|
|
||||||
"pixel format of the input video changed:\n"
|
|
||||||
"old: width = %d, height = %d, format = %s\n"
|
|
||||||
"new: width = %d, height = %d, format = %s\n",
|
|
||||||
width, height, av_get_pix_fmt_name(pix_fmt),
|
|
||||||
frame->width, frame->height,
|
|
||||||
av_get_pix_fmt_name(frame->format));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("video_frame%s n:%d coded_n:%d\n",
|
|
||||||
cached ? "(cached)" : "",
|
|
||||||
video_frame_count++, frame->coded_picture_number);
|
|
||||||
|
|
||||||
/* copy decoded frame to destination buffer:
|
|
||||||
* this is required since rawvideo expects non aligned data */
|
|
||||||
av_image_copy(video_dst_data, video_dst_linesize,
|
|
||||||
(const uint8_t **)(frame->data), frame->linesize,
|
|
||||||
pix_fmt, width, height);
|
|
||||||
|
|
||||||
/* write to rawvideo file */
|
|
||||||
fwrite(video_dst_data[0], 1, video_dst_bufsize, video_dst_file);
|
|
||||||
}
|
|
||||||
} else if (pkt.stream_index == audio_stream_idx) {
|
|
||||||
/* decode audio frame */
|
|
||||||
ret = avcodec_decode_audio4(audio_dec_ctx, frame, got_frame, &pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error decoding audio frame (%s)\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/* Some audio decoders decode only part of the packet, and have to be
|
|
||||||
* called again with the remainder of the packet data.
|
|
||||||
* Sample: fate-suite/lossless-audio/luckynight-partial.shn
|
|
||||||
* Also, some decoders might over-read the packet. */
|
|
||||||
decoded = FFMIN(ret, pkt.size);
|
|
||||||
|
|
||||||
if (*got_frame) {
|
|
||||||
size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample(frame->format);
|
|
||||||
printf("audio_frame%s n:%d nb_samples:%d pts:%s\n",
|
|
||||||
cached ? "(cached)" : "",
|
|
||||||
audio_frame_count++, frame->nb_samples,
|
|
||||||
av_ts2timestr(frame->pts, &audio_dec_ctx->time_base));
|
|
||||||
|
|
||||||
/* Write the raw audio data samples of the first plane. This works
|
|
||||||
* fine for packed formats (e.g. AV_SAMPLE_FMT_S16). However,
|
|
||||||
* most audio decoders output planar audio, which uses a separate
|
|
||||||
* plane of audio samples for each channel (e.g. AV_SAMPLE_FMT_S16P).
|
|
||||||
* In other words, this code will write only the first audio channel
|
|
||||||
* in these cases.
|
|
||||||
* You should use libswresample or libavfilter to convert the frame
|
|
||||||
* to packed data. */
|
|
||||||
fwrite(frame->extended_data[0], 1, unpadded_linesize, audio_dst_file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we use frame reference counting, we own the data and need
|
|
||||||
* to de-reference it when we don't use it anymore */
|
|
||||||
if (*got_frame && refcount)
|
|
||||||
av_frame_unref(frame);
|
|
||||||
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_codec_context(int *stream_idx,
|
|
||||||
AVCodecContext **dec_ctx, AVFormatContext *fmt_ctx, enum AVMediaType type)
|
|
||||||
{
|
|
||||||
int ret, stream_index;
|
|
||||||
AVStream *st;
|
|
||||||
AVCodec *dec = NULL;
|
|
||||||
AVDictionary *opts = NULL;
|
|
||||||
|
|
||||||
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
|
|
||||||
av_get_media_type_string(type), src_filename);
|
|
||||||
return ret;
|
|
||||||
} else {
|
|
||||||
stream_index = ret;
|
|
||||||
st = fmt_ctx->streams[stream_index];
|
|
||||||
|
|
||||||
/* find decoder for the stream */
|
|
||||||
dec = avcodec_find_decoder(st->codecpar->codec_id);
|
|
||||||
if (!dec) {
|
|
||||||
fprintf(stderr, "Failed to find %s codec\n",
|
|
||||||
av_get_media_type_string(type));
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate a codec context for the decoder */
|
|
||||||
*dec_ctx = avcodec_alloc_context3(dec);
|
|
||||||
if (!*dec_ctx) {
|
|
||||||
fprintf(stderr, "Failed to allocate the %s codec context\n",
|
|
||||||
av_get_media_type_string(type));
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy codec parameters from input stream to output codec context */
|
|
||||||
if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to copy %s codec parameters to decoder context\n",
|
|
||||||
av_get_media_type_string(type));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Init the decoders, with or without reference counting */
|
|
||||||
av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0);
|
|
||||||
if ((ret = avcodec_open2(*dec_ctx, dec, &opts)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to open %s codec\n",
|
|
||||||
av_get_media_type_string(type));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
*stream_idx = stream_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_format_from_sample_fmt(const char **fmt,
|
|
||||||
enum AVSampleFormat sample_fmt)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct sample_fmt_entry {
|
|
||||||
enum AVSampleFormat sample_fmt; const char *fmt_be, *fmt_le;
|
|
||||||
} sample_fmt_entries[] = {
|
|
||||||
{ AV_SAMPLE_FMT_U8, "u8", "u8" },
|
|
||||||
{ AV_SAMPLE_FMT_S16, "s16be", "s16le" },
|
|
||||||
{ AV_SAMPLE_FMT_S32, "s32be", "s32le" },
|
|
||||||
{ AV_SAMPLE_FMT_FLT, "f32be", "f32le" },
|
|
||||||
{ AV_SAMPLE_FMT_DBL, "f64be", "f64le" },
|
|
||||||
};
|
|
||||||
*fmt = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(sample_fmt_entries); i++) {
|
|
||||||
struct sample_fmt_entry *entry = &sample_fmt_entries[i];
|
|
||||||
if (sample_fmt == entry->sample_fmt) {
|
|
||||||
*fmt = AV_NE(entry->fmt_be, entry->fmt_le);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
"sample format %s is not supported as output format\n",
|
|
||||||
av_get_sample_fmt_name(sample_fmt));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int ret = 0, got_frame;
|
|
||||||
|
|
||||||
if (argc != 4 && argc != 5) {
|
|
||||||
fprintf(stderr, "usage: %s [-refcount] input_file video_output_file audio_output_file\n"
|
|
||||||
"API example program to show how to read frames from an input file.\n"
|
|
||||||
"This program reads frames from a file, decodes them, and writes decoded\n"
|
|
||||||
"video frames to a rawvideo file named video_output_file, and decoded\n"
|
|
||||||
"audio frames to a rawaudio file named audio_output_file.\n\n"
|
|
||||||
"If the -refcount option is specified, the program use the\n"
|
|
||||||
"reference counting frame system which allows keeping a copy of\n"
|
|
||||||
"the data for longer than one decode call.\n"
|
|
||||||
"\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (argc == 5 && !strcmp(argv[1], "-refcount")) {
|
|
||||||
refcount = 1;
|
|
||||||
argv++;
|
|
||||||
}
|
|
||||||
src_filename = argv[1];
|
|
||||||
video_dst_filename = argv[2];
|
|
||||||
audio_dst_filename = argv[3];
|
|
||||||
|
|
||||||
/* register all formats and codecs */
|
|
||||||
av_register_all();
|
|
||||||
|
|
||||||
/* open input file, and allocate format context */
|
|
||||||
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* retrieve stream information */
|
|
||||||
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not find stream information\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (open_codec_context(&video_stream_idx, &video_dec_ctx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
|
|
||||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
|
||||||
|
|
||||||
video_dst_file = fopen(video_dst_filename, "wb");
|
|
||||||
if (!video_dst_file) {
|
|
||||||
fprintf(stderr, "Could not open destination file %s\n", video_dst_filename);
|
|
||||||
ret = 1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate image where the decoded image will be put */
|
|
||||||
width = video_dec_ctx->width;
|
|
||||||
height = video_dec_ctx->height;
|
|
||||||
pix_fmt = video_dec_ctx->pix_fmt;
|
|
||||||
ret = av_image_alloc(video_dst_data, video_dst_linesize,
|
|
||||||
width, height, pix_fmt, 1);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not allocate raw video buffer\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
video_dst_bufsize = ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (open_codec_context(&audio_stream_idx, &audio_dec_ctx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
|
|
||||||
audio_stream = fmt_ctx->streams[audio_stream_idx];
|
|
||||||
audio_dst_file = fopen(audio_dst_filename, "wb");
|
|
||||||
if (!audio_dst_file) {
|
|
||||||
fprintf(stderr, "Could not open destination file %s\n", audio_dst_filename);
|
|
||||||
ret = 1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dump input information to stderr */
|
|
||||||
av_dump_format(fmt_ctx, 0, src_filename, 0);
|
|
||||||
|
|
||||||
if (!audio_stream && !video_stream) {
|
|
||||||
fprintf(stderr, "Could not find audio or video stream in the input, aborting\n");
|
|
||||||
ret = 1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
fprintf(stderr, "Could not allocate frame\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
|
||||||
av_init_packet(&pkt);
|
|
||||||
pkt.data = NULL;
|
|
||||||
pkt.size = 0;
|
|
||||||
|
|
||||||
if (video_stream)
|
|
||||||
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
|
|
||||||
if (audio_stream)
|
|
||||||
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
|
|
||||||
|
|
||||||
/* read frames from the file */
|
|
||||||
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
|
|
||||||
AVPacket orig_pkt = pkt;
|
|
||||||
do {
|
|
||||||
ret = decode_packet(&got_frame, 0);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
pkt.data += ret;
|
|
||||||
pkt.size -= ret;
|
|
||||||
} while (pkt.size > 0);
|
|
||||||
av_packet_unref(&orig_pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush cached frames */
|
|
||||||
pkt.data = NULL;
|
|
||||||
pkt.size = 0;
|
|
||||||
do {
|
|
||||||
decode_packet(&got_frame, 1);
|
|
||||||
} while (got_frame);
|
|
||||||
|
|
||||||
printf("Demuxing succeeded.\n");
|
|
||||||
|
|
||||||
if (video_stream) {
|
|
||||||
printf("Play the output video file with the command:\n"
|
|
||||||
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
|
|
||||||
av_get_pix_fmt_name(pix_fmt), width, height,
|
|
||||||
video_dst_filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (audio_stream) {
|
|
||||||
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
|
|
||||||
int n_channels = audio_dec_ctx->channels;
|
|
||||||
const char *fmt;
|
|
||||||
|
|
||||||
if (av_sample_fmt_is_planar(sfmt)) {
|
|
||||||
const char *packed = av_get_sample_fmt_name(sfmt);
|
|
||||||
printf("Warning: the sample format the decoder produced is planar "
|
|
||||||
"(%s). This example will output the first channel only.\n",
|
|
||||||
packed ? packed : "?");
|
|
||||||
sfmt = av_get_packed_sample_fmt(sfmt);
|
|
||||||
n_channels = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = get_format_from_sample_fmt(&fmt, sfmt)) < 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
printf("Play the output audio file with the command:\n"
|
|
||||||
"ffplay -f %s -ac %d -ar %d %s\n",
|
|
||||||
fmt, n_channels, audio_dec_ctx->sample_rate,
|
|
||||||
audio_dst_filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
end:
|
|
||||||
avcodec_free_context(&video_dec_ctx);
|
|
||||||
avcodec_free_context(&audio_dec_ctx);
|
|
||||||
avformat_close_input(&fmt_ctx);
|
|
||||||
if (video_dst_file)
|
|
||||||
fclose(video_dst_file);
|
|
||||||
if (audio_dst_file)
|
|
||||||
fclose(audio_dst_file);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_free(video_dst_data[0]);
|
|
||||||
|
|
||||||
return ret < 0;
|
|
||||||
}
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* audio encoding with libavcodec API example.
|
|
||||||
*
|
|
||||||
* @example encode_audio.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
|
|
||||||
#include <libavutil/channel_layout.h>
|
|
||||||
#include <libavutil/common.h>
|
|
||||||
#include <libavutil/frame.h>
|
|
||||||
#include <libavutil/samplefmt.h>
|
|
||||||
|
|
||||||
/* check that a given sample format is supported by the encoder */
|
|
||||||
static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt)
|
|
||||||
{
|
|
||||||
const enum AVSampleFormat *p = codec->sample_fmts;
|
|
||||||
|
|
||||||
while (*p != AV_SAMPLE_FMT_NONE) {
|
|
||||||
if (*p == sample_fmt)
|
|
||||||
return 1;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* just pick the highest supported samplerate */
|
|
||||||
static int select_sample_rate(const AVCodec *codec)
|
|
||||||
{
|
|
||||||
const int *p;
|
|
||||||
int best_samplerate = 0;
|
|
||||||
|
|
||||||
if (!codec->supported_samplerates)
|
|
||||||
return 44100;
|
|
||||||
|
|
||||||
p = codec->supported_samplerates;
|
|
||||||
while (*p) {
|
|
||||||
if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
|
|
||||||
best_samplerate = *p;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
return best_samplerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* select layout with the highest channel count */
|
|
||||||
static int select_channel_layout(const AVCodec *codec)
|
|
||||||
{
|
|
||||||
const uint64_t *p;
|
|
||||||
uint64_t best_ch_layout = 0;
|
|
||||||
int best_nb_channels = 0;
|
|
||||||
|
|
||||||
if (!codec->channel_layouts)
|
|
||||||
return AV_CH_LAYOUT_STEREO;
|
|
||||||
|
|
||||||
p = codec->channel_layouts;
|
|
||||||
while (*p) {
|
|
||||||
int nb_channels = av_get_channel_layout_nb_channels(*p);
|
|
||||||
|
|
||||||
if (nb_channels > best_nb_channels) {
|
|
||||||
best_ch_layout = *p;
|
|
||||||
best_nb_channels = nb_channels;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
return best_ch_layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *filename;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
AVFrame *frame;
|
|
||||||
AVPacket pkt;
|
|
||||||
int i, j, k, ret, got_output;
|
|
||||||
FILE *f;
|
|
||||||
uint16_t *samples;
|
|
||||||
float t, tincr;
|
|
||||||
|
|
||||||
if (argc <= 1) {
|
|
||||||
fprintf(stderr, "Usage: %s <output file>\n", argv[0]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
filename = argv[1];
|
|
||||||
|
|
||||||
/* register all the codecs */
|
|
||||||
avcodec_register_all();
|
|
||||||
|
|
||||||
/* find the MP2 encoder */
|
|
||||||
codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
|
|
||||||
if (!codec) {
|
|
||||||
fprintf(stderr, "Codec not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = avcodec_alloc_context3(codec);
|
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not allocate audio codec context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put sample parameters */
|
|
||||||
c->bit_rate = 64000;
|
|
||||||
|
|
||||||
/* check that the encoder supports s16 pcm input */
|
|
||||||
c->sample_fmt = AV_SAMPLE_FMT_S16;
|
|
||||||
if (!check_sample_fmt(codec, c->sample_fmt)) {
|
|
||||||
fprintf(stderr, "Encoder does not support sample format %s",
|
|
||||||
av_get_sample_fmt_name(c->sample_fmt));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* select other audio parameters supported by the encoder */
|
|
||||||
c->sample_rate = select_sample_rate(codec);
|
|
||||||
c->channel_layout = select_channel_layout(codec);
|
|
||||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
|
||||||
|
|
||||||
/* open it */
|
|
||||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not open codec\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen(filename, "wb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "Could not open %s\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* frame containing input raw audio */
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
fprintf(stderr, "Could not allocate audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->nb_samples = c->frame_size;
|
|
||||||
frame->format = c->sample_fmt;
|
|
||||||
frame->channel_layout = c->channel_layout;
|
|
||||||
|
|
||||||
/* allocate the data buffers */
|
|
||||||
ret = av_frame_get_buffer(frame, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not allocate audio data buffers\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* encode a single tone sound */
|
|
||||||
t = 0;
|
|
||||||
tincr = 2 * M_PI * 440.0 / c->sample_rate;
|
|
||||||
for (i = 0; i < 200; i++) {
|
|
||||||
av_init_packet(&pkt);
|
|
||||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
|
||||||
pkt.size = 0;
|
|
||||||
|
|
||||||
/* make sure the frame is writable -- makes a copy if the encoder
|
|
||||||
* kept a reference internally */
|
|
||||||
ret = av_frame_make_writable(frame);
|
|
||||||
if (ret < 0)
|
|
||||||
exit(1);
|
|
||||||
samples = (uint16_t*)frame->data[0];
|
|
||||||
|
|
||||||
for (j = 0; j < c->frame_size; j++) {
|
|
||||||
samples[2*j] = (int)(sin(t) * 10000);
|
|
||||||
|
|
||||||
for (k = 1; k < c->channels; k++)
|
|
||||||
samples[2*j + k] = samples[2*j];
|
|
||||||
t += tincr;
|
|
||||||
}
|
|
||||||
/* encode the samples */
|
|
||||||
ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (got_output) {
|
|
||||||
fwrite(pkt.data, 1, pkt.size, f);
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the delayed frames */
|
|
||||||
for (got_output = 1; got_output; i++) {
|
|
||||||
ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (got_output) {
|
|
||||||
fwrite(pkt.data, 1, pkt.size, f);
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
av_frame_free(&frame);
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* video encoding with libavcodec API example
|
|
||||||
*
|
|
||||||
* @example encode_video.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
#include <libavutil/imgutils.h>
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *filename, *codec_name;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
int i, ret, x, y, got_output;
|
|
||||||
FILE *f;
|
|
||||||
AVFrame *frame;
|
|
||||||
AVPacket pkt;
|
|
||||||
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
|
||||||
|
|
||||||
if (argc <= 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <output file> <codec name>\n", argv[0]);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
filename = argv[1];
|
|
||||||
codec_name = argv[2];
|
|
||||||
|
|
||||||
avcodec_register_all();
|
|
||||||
|
|
||||||
/* find the mpeg1video encoder */
|
|
||||||
codec = avcodec_find_encoder_by_name(codec_name);
|
|
||||||
if (!codec) {
|
|
||||||
fprintf(stderr, "Codec not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = avcodec_alloc_context3(codec);
|
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not allocate video codec context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put sample parameters */
|
|
||||||
c->bit_rate = 400000;
|
|
||||||
/* resolution must be a multiple of two */
|
|
||||||
c->width = 352;
|
|
||||||
c->height = 288;
|
|
||||||
/* frames per second */
|
|
||||||
c->time_base = (AVRational){1, 25};
|
|
||||||
c->framerate = (AVRational){25, 1};
|
|
||||||
|
|
||||||
/* emit one intra frame every ten frames
|
|
||||||
* check frame pict_type before passing frame
|
|
||||||
* to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
|
|
||||||
* then gop_size is ignored and the output of encoder
|
|
||||||
* will always be I frame irrespective to gop_size
|
|
||||||
*/
|
|
||||||
c->gop_size = 10;
|
|
||||||
c->max_b_frames = 1;
|
|
||||||
c->pix_fmt = AV_PIX_FMT_YUV420P;
|
|
||||||
|
|
||||||
if (codec->id == AV_CODEC_ID_H264)
|
|
||||||
av_opt_set(c->priv_data, "preset", "slow", 0);
|
|
||||||
|
|
||||||
/* open it */
|
|
||||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not open codec\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen(filename, "wb");
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr, "Could not open %s\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
fprintf(stderr, "Could not allocate video frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
frame->format = c->pix_fmt;
|
|
||||||
frame->width = c->width;
|
|
||||||
frame->height = c->height;
|
|
||||||
|
|
||||||
ret = av_frame_get_buffer(frame, 32);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not allocate the video frame data\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* encode 1 second of video */
|
|
||||||
for (i = 0; i < 25; i++) {
|
|
||||||
av_init_packet(&pkt);
|
|
||||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
|
||||||
pkt.size = 0;
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
/* make sure the frame data is writable */
|
|
||||||
ret = av_frame_make_writable(frame);
|
|
||||||
if (ret < 0)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
/* prepare a dummy image */
|
|
||||||
/* Y */
|
|
||||||
for (y = 0; y < c->height; y++) {
|
|
||||||
for (x = 0; x < c->width; x++) {
|
|
||||||
frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cb and Cr */
|
|
||||||
for (y = 0; y < c->height/2; y++) {
|
|
||||||
for (x = 0; x < c->width/2; x++) {
|
|
||||||
frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
|
|
||||||
frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->pts = i;
|
|
||||||
|
|
||||||
/* encode the image */
|
|
||||||
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (got_output) {
|
|
||||||
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
|
||||||
fwrite(pkt.data, 1, pkt.size, f);
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the delayed frames */
|
|
||||||
for (got_output = 1; got_output; i++) {
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (got_output) {
|
|
||||||
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
|
||||||
fwrite(pkt.data, 1, pkt.size, f);
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add sequence end code to have a real MPEG file */
|
|
||||||
fwrite(endcode, 1, sizeof(endcode), f);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2012 Stefano Sabatini
|
|
||||||
* Copyright (c) 2014 Clément Bœsch
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libavutil/motion_vector.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
|
|
||||||
static AVFormatContext *fmt_ctx = NULL;
|
|
||||||
static AVCodecContext *video_dec_ctx = NULL;
|
|
||||||
static AVStream *video_stream = NULL;
|
|
||||||
static const char *src_filename = NULL;
|
|
||||||
|
|
||||||
static int video_stream_idx = -1;
|
|
||||||
static AVFrame *frame = NULL;
|
|
||||||
static AVPacket pkt;
|
|
||||||
static int video_frame_count = 0;
|
|
||||||
|
|
||||||
static int decode_packet(int *got_frame, int cached)
|
|
||||||
{
|
|
||||||
int decoded = pkt.size;
|
|
||||||
|
|
||||||
*got_frame = 0;
|
|
||||||
|
|
||||||
if (pkt.stream_index == video_stream_idx) {
|
|
||||||
int ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*got_frame) {
|
|
||||||
int i;
|
|
||||||
AVFrameSideData *sd;
|
|
||||||
|
|
||||||
video_frame_count++;
|
|
||||||
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);
|
|
||||||
if (sd) {
|
|
||||||
const AVMotionVector *mvs = (const AVMotionVector *)sd->data;
|
|
||||||
for (i = 0; i < sd->size / sizeof(*mvs); i++) {
|
|
||||||
const AVMotionVector *mv = &mvs[i];
|
|
||||||
printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n",
|
|
||||||
video_frame_count, mv->source,
|
|
||||||
mv->w, mv->h, mv->src_x, mv->src_y,
|
|
||||||
mv->dst_x, mv->dst_y, mv->flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return decoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
AVStream *st;
|
|
||||||
AVCodecContext *dec_ctx = NULL;
|
|
||||||
AVCodec *dec = NULL;
|
|
||||||
AVDictionary *opts = NULL;
|
|
||||||
|
|
||||||
ret = av_find_best_stream(fmt_ctx, type, -1, -1, &dec, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
|
|
||||||
av_get_media_type_string(type), src_filename);
|
|
||||||
return ret;
|
|
||||||
} else {
|
|
||||||
int stream_idx = ret;
|
|
||||||
st = fmt_ctx->streams[stream_idx];
|
|
||||||
|
|
||||||
dec_ctx = avcodec_alloc_context3(dec);
|
|
||||||
if (!dec_ctx) {
|
|
||||||
fprintf(stderr, "Failed to allocate codec\n");
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Failed to copy codec parameters to codec context\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Init the video decoder */
|
|
||||||
av_dict_set(&opts, "flags2", "+export_mvs", 0);
|
|
||||||
if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to open %s codec\n",
|
|
||||||
av_get_media_type_string(type));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
video_stream_idx = stream_idx;
|
|
||||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
|
||||||
video_dec_ctx = dec_ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int ret = 0, got_frame;
|
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <video>\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
src_filename = argv[1];
|
|
||||||
|
|
||||||
av_register_all();
|
|
||||||
|
|
||||||
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Could not find stream information\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
open_codec_context(fmt_ctx, AVMEDIA_TYPE_VIDEO);
|
|
||||||
|
|
||||||
av_dump_format(fmt_ctx, 0, src_filename, 0);
|
|
||||||
|
|
||||||
if (!video_stream) {
|
|
||||||
fprintf(stderr, "Could not find video stream in the input, aborting\n");
|
|
||||||
ret = 1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
fprintf(stderr, "Could not allocate frame\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n");
|
|
||||||
|
|
||||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
|
||||||
av_init_packet(&pkt);
|
|
||||||
pkt.data = NULL;
|
|
||||||
pkt.size = 0;
|
|
||||||
|
|
||||||
/* read frames from the file */
|
|
||||||
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
|
|
||||||
AVPacket orig_pkt = pkt;
|
|
||||||
do {
|
|
||||||
ret = decode_packet(&got_frame, 0);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
pkt.data += ret;
|
|
||||||
pkt.size -= ret;
|
|
||||||
} while (pkt.size > 0);
|
|
||||||
av_packet_unref(&orig_pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush cached frames */
|
|
||||||
pkt.data = NULL;
|
|
||||||
pkt.size = 0;
|
|
||||||
do {
|
|
||||||
decode_packet(&got_frame, 1);
|
|
||||||
} while (got_frame);
|
|
||||||
|
|
||||||
end:
|
|
||||||
avcodec_free_context(&video_dec_ctx);
|
|
||||||
avformat_close_input(&fmt_ctx);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
return ret < 0;
|
|
||||||
}
|
|
||||||
@@ -1,365 +0,0 @@
|
|||||||
/*
|
|
||||||
* copyright (c) 2013 Andrew Kelley
|
|
||||||
*
|
|
||||||
* This file is part of FFmpeg.
|
|
||||||
*
|
|
||||||
* FFmpeg is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* FFmpeg is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with FFmpeg; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* libavfilter API usage example.
|
|
||||||
*
|
|
||||||
* @example filter_audio.c
|
|
||||||
* This example will generate a sine wave audio,
|
|
||||||
* pass it through a simple filter chain, and then compute the MD5 checksum of
|
|
||||||
* the output data.
|
|
||||||
*
|
|
||||||
* The filter chain it uses is:
|
|
||||||
* (input) -> abuffer -> volume -> aformat -> abuffersink -> (output)
|
|
||||||
*
|
|
||||||
* abuffer: This provides the endpoint where you can feed the decoded samples.
|
|
||||||
* volume: In this example we hardcode it to 0.90.
|
|
||||||
* aformat: This converts the samples to the samplefreq, channel layout,
|
|
||||||
* and sample format required by the audio device.
|
|
||||||
* abuffersink: This provides the endpoint where you can read the samples after
|
|
||||||
* they have passed through the filter chain.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "libavutil/channel_layout.h"
|
|
||||||
#include "libavutil/md5.h"
|
|
||||||
#include "libavutil/mem.h"
|
|
||||||
#include "libavutil/opt.h"
|
|
||||||
#include "libavutil/samplefmt.h"
|
|
||||||
|
|
||||||
#include "libavfilter/avfilter.h"
|
|
||||||
#include "libavfilter/buffersink.h"
|
|
||||||
#include "libavfilter/buffersrc.h"
|
|
||||||
|
|
||||||
#define INPUT_SAMPLERATE 48000
|
|
||||||
#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
|
|
||||||
#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
|
|
||||||
|
|
||||||
#define VOLUME_VAL 0.90
|
|
||||||
|
|
||||||
static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
|
|
||||||
AVFilterContext **sink)
|
|
||||||
{
|
|
||||||
AVFilterGraph *filter_graph;
|
|
||||||
AVFilterContext *abuffer_ctx;
|
|
||||||
AVFilter *abuffer;
|
|
||||||
AVFilterContext *volume_ctx;
|
|
||||||
AVFilter *volume;
|
|
||||||
AVFilterContext *aformat_ctx;
|
|
||||||
AVFilter *aformat;
|
|
||||||
AVFilterContext *abuffersink_ctx;
|
|
||||||
AVFilter *abuffersink;
|
|
||||||
|
|
||||||
AVDictionary *options_dict = NULL;
|
|
||||||
uint8_t options_str[1024];
|
|
||||||
uint8_t ch_layout[64];
|
|
||||||
|
|
||||||
int err;
|
|
||||||
|
|
||||||
/* Create a new filtergraph, which will contain all the filters. */
|
|
||||||
filter_graph = avfilter_graph_alloc();
|
|
||||||
if (!filter_graph) {
|
|
||||||
fprintf(stderr, "Unable to create filter graph.\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the abuffer filter;
|
|
||||||
* it will be used for feeding the data into the graph. */
|
|
||||||
abuffer = avfilter_get_by_name("abuffer");
|
|
||||||
if (!abuffer) {
|
|
||||||
fprintf(stderr, "Could not find the abuffer filter.\n");
|
|
||||||
return AVERROR_FILTER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
abuffer_ctx = avfilter_graph_alloc_filter(filter_graph, abuffer, "src");
|
|
||||||
if (!abuffer_ctx) {
|
|
||||||
fprintf(stderr, "Could not allocate the abuffer instance.\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the filter options through the AVOptions API. */
|
|
||||||
av_get_channel_layout_string(ch_layout, sizeof(ch_layout), 0, INPUT_CHANNEL_LAYOUT);
|
|
||||||
av_opt_set (abuffer_ctx, "channel_layout", ch_layout, AV_OPT_SEARCH_CHILDREN);
|
|
||||||
av_opt_set (abuffer_ctx, "sample_fmt", av_get_sample_fmt_name(INPUT_FORMAT), AV_OPT_SEARCH_CHILDREN);
|
|
||||||
av_opt_set_q (abuffer_ctx, "time_base", (AVRational){ 1, INPUT_SAMPLERATE }, AV_OPT_SEARCH_CHILDREN);
|
|
||||||
av_opt_set_int(abuffer_ctx, "sample_rate", INPUT_SAMPLERATE, AV_OPT_SEARCH_CHILDREN);
|
|
||||||
|
|
||||||
/* Now initialize the filter; we pass NULL options, since we have already
|
|
||||||
* set all the options above. */
|
|
||||||
err = avfilter_init_str(abuffer_ctx, NULL);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Could not initialize the abuffer filter.\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create volume filter. */
|
|
||||||
volume = avfilter_get_by_name("volume");
|
|
||||||
if (!volume) {
|
|
||||||
fprintf(stderr, "Could not find the volume filter.\n");
|
|
||||||
return AVERROR_FILTER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
volume_ctx = avfilter_graph_alloc_filter(filter_graph, volume, "volume");
|
|
||||||
if (!volume_ctx) {
|
|
||||||
fprintf(stderr, "Could not allocate the volume instance.\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A different way of passing the options is as key/value pairs in a
|
|
||||||
* dictionary. */
|
|
||||||
av_dict_set(&options_dict, "volume", AV_STRINGIFY(VOLUME_VAL), 0);
|
|
||||||
err = avfilter_init_dict(volume_ctx, &options_dict);
|
|
||||||
av_dict_free(&options_dict);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Could not initialize the volume filter.\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the aformat filter;
|
|
||||||
* it ensures that the output is of the format we want. */
|
|
||||||
aformat = avfilter_get_by_name("aformat");
|
|
||||||
if (!aformat) {
|
|
||||||
fprintf(stderr, "Could not find the aformat filter.\n");
|
|
||||||
return AVERROR_FILTER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
aformat_ctx = avfilter_graph_alloc_filter(filter_graph, aformat, "aformat");
|
|
||||||
if (!aformat_ctx) {
|
|
||||||
fprintf(stderr, "Could not allocate the aformat instance.\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A third way of passing the options is in a string of the form
|
|
||||||
* key1=value1:key2=value2.... */
|
|
||||||
snprintf(options_str, sizeof(options_str),
|
|
||||||
"sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
|
|
||||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100,
|
|
||||||
(uint64_t)AV_CH_LAYOUT_STEREO);
|
|
||||||
err = avfilter_init_str(aformat_ctx, options_str);
|
|
||||||
if (err < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Could not initialize the aformat filter.\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finally create the abuffersink filter;
|
|
||||||
* it will be used to get the filtered data out of the graph. */
|
|
||||||
abuffersink = avfilter_get_by_name("abuffersink");
|
|
||||||
if (!abuffersink) {
|
|
||||||
fprintf(stderr, "Could not find the abuffersink filter.\n");
|
|
||||||
return AVERROR_FILTER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
abuffersink_ctx = avfilter_graph_alloc_filter(filter_graph, abuffersink, "sink");
|
|
||||||
if (!abuffersink_ctx) {
|
|
||||||
fprintf(stderr, "Could not allocate the abuffersink instance.\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This filter takes no options. */
|
|
||||||
err = avfilter_init_str(abuffersink_ctx, NULL);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Could not initialize the abuffersink instance.\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Connect the filters;
|
|
||||||
* in this simple case the filters just form a linear chain. */
|
|
||||||
err = avfilter_link(abuffer_ctx, 0, volume_ctx, 0);
|
|
||||||
if (err >= 0)
|
|
||||||
err = avfilter_link(volume_ctx, 0, aformat_ctx, 0);
|
|
||||||
if (err >= 0)
|
|
||||||
err = avfilter_link(aformat_ctx, 0, abuffersink_ctx, 0);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Error connecting filters\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure the graph. */
|
|
||||||
err = avfilter_graph_config(filter_graph, NULL);
|
|
||||||
if (err < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error configuring the filter graph\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
*graph = filter_graph;
|
|
||||||
*src = abuffer_ctx;
|
|
||||||
*sink = abuffersink_ctx;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Do something useful with the filtered data: this simple
|
|
||||||
* example just prints the MD5 checksum of each plane to stdout. */
|
|
||||||
static int process_output(struct AVMD5 *md5, AVFrame *frame)
|
|
||||||
{
|
|
||||||
int planar = av_sample_fmt_is_planar(frame->format);
|
|
||||||
int channels = av_get_channel_layout_nb_channels(frame->channel_layout);
|
|
||||||
int planes = planar ? channels : 1;
|
|
||||||
int bps = av_get_bytes_per_sample(frame->format);
|
|
||||||
int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (i = 0; i < planes; i++) {
|
|
||||||
uint8_t checksum[16];
|
|
||||||
|
|
||||||
av_md5_init(md5);
|
|
||||||
av_md5_sum(checksum, frame->extended_data[i], plane_size);
|
|
||||||
|
|
||||||
fprintf(stdout, "plane %d: 0x", i);
|
|
||||||
for (j = 0; j < sizeof(checksum); j++)
|
|
||||||
fprintf(stdout, "%02X", checksum[j]);
|
|
||||||
fprintf(stdout, "\n");
|
|
||||||
}
|
|
||||||
fprintf(stdout, "\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Construct a frame of audio data to be filtered;
|
|
||||||
* this simple example just synthesizes a sine wave. */
|
|
||||||
static int get_input(AVFrame *frame, int frame_num)
|
|
||||||
{
|
|
||||||
int err, i, j;
|
|
||||||
|
|
||||||
#define FRAME_SIZE 1024
|
|
||||||
|
|
||||||
/* Set up the frame properties and allocate the buffer for the data. */
|
|
||||||
frame->sample_rate = INPUT_SAMPLERATE;
|
|
||||||
frame->format = INPUT_FORMAT;
|
|
||||||
frame->channel_layout = INPUT_CHANNEL_LAYOUT;
|
|
||||||
frame->nb_samples = FRAME_SIZE;
|
|
||||||
frame->pts = frame_num * FRAME_SIZE;
|
|
||||||
|
|
||||||
err = av_frame_get_buffer(frame, 0);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
/* Fill the data for each channel. */
|
|
||||||
for (i = 0; i < 5; i++) {
|
|
||||||
float *data = (float*)frame->extended_data[i];
|
|
||||||
|
|
||||||
for (j = 0; j < frame->nb_samples; j++)
|
|
||||||
data[j] = sin(2 * M_PI * (frame_num + j) * (i + 1) / FRAME_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
struct AVMD5 *md5;
|
|
||||||
AVFilterGraph *graph;
|
|
||||||
AVFilterContext *src, *sink;
|
|
||||||
AVFrame *frame;
|
|
||||||
uint8_t errstr[1024];
|
|
||||||
float duration;
|
|
||||||
int err, nb_frames, i;
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <duration>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
duration = atof(argv[1]);
|
|
||||||
nb_frames = duration * INPUT_SAMPLERATE / FRAME_SIZE;
|
|
||||||
if (nb_frames <= 0) {
|
|
||||||
fprintf(stderr, "Invalid duration: %s\n", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
avfilter_register_all();
|
|
||||||
|
|
||||||
/* Allocate the frame we will be using to store the data. */
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
fprintf(stderr, "Error allocating the frame\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
md5 = av_md5_alloc();
|
|
||||||
if (!md5) {
|
|
||||||
fprintf(stderr, "Error allocating the MD5 context\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up the filtergraph. */
|
|
||||||
err = init_filter_graph(&graph, &src, &sink);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Unable to init filter graph:");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the main filtering loop */
|
|
||||||
for (i = 0; i < nb_frames; i++) {
|
|
||||||
/* get an input frame to be filtered */
|
|
||||||
err = get_input(frame, i);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Error generating input frame:");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send the frame to the input of the filtergraph. */
|
|
||||||
err = av_buffersrc_add_frame(src, frame);
|
|
||||||
if (err < 0) {
|
|
||||||
av_frame_unref(frame);
|
|
||||||
fprintf(stderr, "Error submitting the frame to the filtergraph:");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get all the filtered output that is available. */
|
|
||||||
while ((err = av_buffersink_get_frame(sink, frame)) >= 0) {
|
|
||||||
/* now do something with our filtered frame */
|
|
||||||
err = process_output(md5, frame);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Error processing the filtered frame:");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
av_frame_unref(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == AVERROR(EAGAIN)) {
|
|
||||||
/* Need to feed more frames in. */
|
|
||||||
continue;
|
|
||||||
} else if (err == AVERROR_EOF) {
|
|
||||||
/* Nothing more to do, finish. */
|
|
||||||
break;
|
|
||||||
} else if (err < 0) {
|
|
||||||
/* An error occurred. */
|
|
||||||
fprintf(stderr, "Error filtering the data:");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
avfilter_graph_free(&graph);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_freep(&md5);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
av_strerror(err, errstr, sizeof(errstr));
|
|
||||||
fprintf(stderr, "%s\n", errstr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* API example for audio decoding and filtering
|
* API example for audio decoding and filtering
|
||||||
* @example filtering_audio.c
|
* @example doc/examples/filtering_audio.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -33,12 +33,12 @@
|
|||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libavfilter/avfiltergraph.h>
|
#include <libavfilter/avfiltergraph.h>
|
||||||
|
#include <libavfilter/avcodec.h>
|
||||||
#include <libavfilter/buffersink.h>
|
#include <libavfilter/buffersink.h>
|
||||||
#include <libavfilter/buffersrc.h>
|
#include <libavfilter/buffersrc.h>
|
||||||
#include <libavutil/opt.h>
|
|
||||||
|
|
||||||
static const char *filter_descr = "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono";
|
const char *filter_descr = "aresample=8000,aconvert=s16:mono";
|
||||||
static const char *player = "ffplay -f s16le -ar 8000 -ac 1 -";
|
const char *player = "ffplay -f s16le -ar 8000 -ac 1 -";
|
||||||
|
|
||||||
static AVFormatContext *fmt_ctx;
|
static AVFormatContext *fmt_ctx;
|
||||||
static AVCodecContext *dec_ctx;
|
static AVCodecContext *dec_ctx;
|
||||||
@@ -65,17 +65,11 @@ static int open_input_file(const char *filename)
|
|||||||
/* select the audio stream */
|
/* select the audio stream */
|
||||||
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0);
|
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot find an audio stream in the input file\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot find a audio stream in the input file\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
audio_stream_index = ret;
|
audio_stream_index = ret;
|
||||||
|
dec_ctx = fmt_ctx->streams[audio_stream_index]->codec;
|
||||||
/* create decoding context */
|
|
||||||
dec_ctx = avcodec_alloc_context3(dec);
|
|
||||||
if (!dec_ctx)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[audio_stream_index]->codecpar);
|
|
||||||
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
|
||||||
|
|
||||||
/* init the audio decoder */
|
/* init the audio decoder */
|
||||||
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
||||||
@@ -89,22 +83,17 @@ static int open_input_file(const char *filename)
|
|||||||
static int init_filters(const char *filters_descr)
|
static int init_filters(const char *filters_descr)
|
||||||
{
|
{
|
||||||
char args[512];
|
char args[512];
|
||||||
int ret = 0;
|
int ret;
|
||||||
AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
|
AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
|
||||||
AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
|
AVFilter *abuffersink = avfilter_get_by_name("ffabuffersink");
|
||||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||||
AVFilterInOut *inputs = avfilter_inout_alloc();
|
AVFilterInOut *inputs = avfilter_inout_alloc();
|
||||||
static const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
|
const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
|
||||||
static const int64_t out_channel_layouts[] = { AV_CH_LAYOUT_MONO, -1 };
|
AVABufferSinkParams *abuffersink_params;
|
||||||
static const int out_sample_rates[] = { 8000, -1 };
|
|
||||||
const AVFilterLink *outlink;
|
const AVFilterLink *outlink;
|
||||||
AVRational time_base = fmt_ctx->streams[audio_stream_index]->time_base;
|
AVRational time_base = fmt_ctx->streams[audio_stream_index]->time_base;
|
||||||
|
|
||||||
filter_graph = avfilter_graph_alloc();
|
filter_graph = avfilter_graph_alloc();
|
||||||
if (!outputs || !inputs || !filter_graph) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* buffer audio source: the decoded frames from the decoder will be inserted here. */
|
/* buffer audio source: the decoded frames from the decoder will be inserted here. */
|
||||||
if (!dec_ctx->channel_layout)
|
if (!dec_ctx->channel_layout)
|
||||||
@@ -117,71 +106,37 @@ static int init_filters(const char *filters_descr)
|
|||||||
args, NULL, filter_graph);
|
args, NULL, filter_graph);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer source\n");
|
||||||
goto end;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buffer audio sink: to terminate the filter chain. */
|
/* buffer audio sink: to terminate the filter chain. */
|
||||||
|
abuffersink_params = av_abuffersink_params_alloc();
|
||||||
|
abuffersink_params->sample_fmts = sample_fmts;
|
||||||
ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out",
|
ret = avfilter_graph_create_filter(&buffersink_ctx, abuffersink, "out",
|
||||||
NULL, NULL, filter_graph);
|
NULL, abuffersink_params, filter_graph);
|
||||||
|
av_free(abuffersink_params);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot create audio buffer sink\n");
|
||||||
goto end;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = av_opt_set_int_list(buffersink_ctx, "sample_fmts", out_sample_fmts, -1,
|
/* Endpoints for the filter graph. */
|
||||||
AV_OPT_SEARCH_CHILDREN);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample format\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_opt_set_int_list(buffersink_ctx, "channel_layouts", out_channel_layouts, -1,
|
|
||||||
AV_OPT_SEARCH_CHILDREN);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_opt_set_int_list(buffersink_ctx, "sample_rates", out_sample_rates, -1,
|
|
||||||
AV_OPT_SEARCH_CHILDREN);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output sample rate\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the endpoints for the filter graph. The filter_graph will
|
|
||||||
* be linked to the graph described by filters_descr.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The buffer source output must be connected to the input pad of
|
|
||||||
* the first filter described by filters_descr; since the first
|
|
||||||
* filter input label is not specified, it is set to "in" by
|
|
||||||
* default.
|
|
||||||
*/
|
|
||||||
outputs->name = av_strdup("in");
|
outputs->name = av_strdup("in");
|
||||||
outputs->filter_ctx = buffersrc_ctx;
|
outputs->filter_ctx = buffersrc_ctx;
|
||||||
outputs->pad_idx = 0;
|
outputs->pad_idx = 0;
|
||||||
outputs->next = NULL;
|
outputs->next = NULL;
|
||||||
|
|
||||||
/*
|
|
||||||
* The buffer sink input must be connected to the output pad of
|
|
||||||
* the last filter described by filters_descr; since the last
|
|
||||||
* filter output label is not specified, it is set to "out" by
|
|
||||||
* default.
|
|
||||||
*/
|
|
||||||
inputs->name = av_strdup("out");
|
inputs->name = av_strdup("out");
|
||||||
inputs->filter_ctx = buffersink_ctx;
|
inputs->filter_ctx = buffersink_ctx;
|
||||||
inputs->pad_idx = 0;
|
inputs->pad_idx = 0;
|
||||||
inputs->next = NULL;
|
inputs->next = NULL;
|
||||||
|
|
||||||
if ((ret = avfilter_graph_parse_ptr(filter_graph, filters_descr,
|
if ((ret = avfilter_graph_parse(filter_graph, filters_descr,
|
||||||
&inputs, &outputs, NULL)) < 0)
|
&inputs, &outputs, NULL)) < 0)
|
||||||
goto end;
|
return ret;
|
||||||
|
|
||||||
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
||||||
goto end;
|
return ret;
|
||||||
|
|
||||||
/* Print summary of the sink buffer
|
/* Print summary of the sink buffer
|
||||||
* Note: args buffer is reused to store channel layout string */
|
* Note: args buffer is reused to store channel layout string */
|
||||||
@@ -192,17 +147,14 @@ static int init_filters(const char *filters_descr)
|
|||||||
(char *)av_x_if_null(av_get_sample_fmt_name(outlink->format), "?"),
|
(char *)av_x_if_null(av_get_sample_fmt_name(outlink->format), "?"),
|
||||||
args);
|
args);
|
||||||
|
|
||||||
end:
|
return 0;
|
||||||
avfilter_inout_free(&inputs);
|
|
||||||
avfilter_inout_free(&outputs);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_frame(const AVFrame *frame)
|
static void print_samplesref(AVFilterBufferRef *samplesref)
|
||||||
{
|
{
|
||||||
const int n = frame->nb_samples * av_get_channel_layout_nb_channels(av_frame_get_channel_layout(frame));
|
const AVFilterBufferRefAudioProps *props = samplesref->audio;
|
||||||
const uint16_t *p = (uint16_t*)frame->data[0];
|
const int n = props->nb_samples * av_get_channel_layout_nb_channels(props->channel_layout);
|
||||||
|
const uint16_t *p = (uint16_t*)samplesref->data[0];
|
||||||
const uint16_t *p_end = p + n;
|
const uint16_t *p_end = p + n;
|
||||||
|
|
||||||
while (p < p_end) {
|
while (p < p_end) {
|
||||||
@@ -217,10 +169,10 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
AVFrame *frame = av_frame_alloc();
|
AVFrame *frame = avcodec_alloc_frame();
|
||||||
AVFrame *filt_frame = av_frame_alloc();
|
int got_frame;
|
||||||
|
|
||||||
if (!frame || !filt_frame) {
|
if (!frame) {
|
||||||
perror("Could not allocate frame");
|
perror("Could not allocate frame");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -229,6 +181,7 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avcodec_register_all();
|
||||||
av_register_all();
|
av_register_all();
|
||||||
avfilter_register_all();
|
avfilter_register_all();
|
||||||
|
|
||||||
@@ -239,57 +192,53 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* read all packets */
|
/* read all packets */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
AVFilterBufferRef *samplesref;
|
||||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (packet.stream_index == audio_stream_index) {
|
if (packet.stream_index == audio_stream_index) {
|
||||||
ret = avcodec_send_packet(dec_ctx, &packet);
|
avcodec_get_frame_defaults(frame);
|
||||||
|
got_frame = 0;
|
||||||
|
ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, &packet);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
|
av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n");
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ret >= 0) {
|
if (got_frame) {
|
||||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
/* push the audio data from decoded frame into the filtergraph */
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
if (av_buffersrc_add_frame(buffersrc_ctx, frame, 0) < 0) {
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
|
||||||
break;
|
break;
|
||||||
} else if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
|
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret >= 0) {
|
/* pull filtered audio from the filtergraph */
|
||||||
/* push the audio data from decoded frame into the filtergraph */
|
while (1) {
|
||||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
ret = av_buffersink_get_buffer_ref(buffersink_ctx, &samplesref, 0);
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
|
if(ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||||
break;
|
break;
|
||||||
|
if(ret < 0)
|
||||||
|
goto end;
|
||||||
|
if (samplesref) {
|
||||||
|
print_samplesref(samplesref);
|
||||||
|
avfilter_unref_bufferp(&samplesref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pull filtered audio from the filtergraph */
|
|
||||||
while (1) {
|
|
||||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
break;
|
|
||||||
if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
print_frame(filt_frame);
|
|
||||||
av_frame_unref(filt_frame);
|
|
||||||
}
|
|
||||||
av_frame_unref(frame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_packet_unref(&packet);
|
av_free_packet(&packet);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
avfilter_graph_free(&filter_graph);
|
avfilter_graph_free(&filter_graph);
|
||||||
avcodec_free_context(&dec_ctx);
|
if (dec_ctx)
|
||||||
|
avcodec_close(dec_ctx);
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
av_frame_free(&frame);
|
av_freep(&frame);
|
||||||
av_frame_free(&filt_frame);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != AVERROR_EOF) {
|
if (ret < 0 && ret != AVERROR_EOF) {
|
||||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
char buf[1024];
|
||||||
|
av_strerror(ret, buf, sizeof(buf));
|
||||||
|
fprintf(stderr, "Error occurred: %s\n", buf);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* API example for decoding and filtering
|
* API example for decoding and filtering
|
||||||
* @example filtering_video.c
|
* @example doc/examples/filtering_video.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _XOPEN_SOURCE 600 /* for usleep */
|
#define _XOPEN_SOURCE 600 /* for usleep */
|
||||||
@@ -33,14 +33,11 @@
|
|||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libavfilter/avfiltergraph.h>
|
#include <libavfilter/avfiltergraph.h>
|
||||||
|
#include <libavfilter/avcodec.h>
|
||||||
#include <libavfilter/buffersink.h>
|
#include <libavfilter/buffersink.h>
|
||||||
#include <libavfilter/buffersrc.h>
|
#include <libavfilter/buffersrc.h>
|
||||||
#include <libavutil/opt.h>
|
|
||||||
|
|
||||||
const char *filter_descr = "scale=78:24,transpose=cclock";
|
const char *filter_descr = "scale=78:24";
|
||||||
/* other way:
|
|
||||||
scale=78:24 [scl]; [scl] transpose=cclock // assumes "[in]" and "[out]" to be input output pads respectively
|
|
||||||
*/
|
|
||||||
|
|
||||||
static AVFormatContext *fmt_ctx;
|
static AVFormatContext *fmt_ctx;
|
||||||
static AVCodecContext *dec_ctx;
|
static AVCodecContext *dec_ctx;
|
||||||
@@ -72,13 +69,7 @@ static int open_input_file(const char *filename)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
video_stream_index = ret;
|
video_stream_index = ret;
|
||||||
|
dec_ctx = fmt_ctx->streams[video_stream_index]->codec;
|
||||||
/* create decoding context */
|
|
||||||
dec_ctx = avcodec_alloc_context3(dec);
|
|
||||||
if (!dec_ctx)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[video_stream_index]->codecpar);
|
|
||||||
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
|
||||||
|
|
||||||
/* init the video decoder */
|
/* init the video decoder */
|
||||||
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
|
||||||
@@ -92,117 +83,88 @@ static int open_input_file(const char *filename)
|
|||||||
static int init_filters(const char *filters_descr)
|
static int init_filters(const char *filters_descr)
|
||||||
{
|
{
|
||||||
char args[512];
|
char args[512];
|
||||||
int ret = 0;
|
int ret;
|
||||||
AVFilter *buffersrc = avfilter_get_by_name("buffer");
|
AVFilter *buffersrc = avfilter_get_by_name("buffer");
|
||||||
AVFilter *buffersink = avfilter_get_by_name("buffersink");
|
AVFilter *buffersink = avfilter_get_by_name("ffbuffersink");
|
||||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||||
AVFilterInOut *inputs = avfilter_inout_alloc();
|
AVFilterInOut *inputs = avfilter_inout_alloc();
|
||||||
AVRational time_base = fmt_ctx->streams[video_stream_index]->time_base;
|
|
||||||
enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
|
enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
|
||||||
|
AVBufferSinkParams *buffersink_params;
|
||||||
|
|
||||||
filter_graph = avfilter_graph_alloc();
|
filter_graph = avfilter_graph_alloc();
|
||||||
if (!outputs || !inputs || !filter_graph) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* buffer video source: the decoded frames from the decoder will be inserted here. */
|
/* buffer video source: the decoded frames from the decoder will be inserted here. */
|
||||||
snprintf(args, sizeof(args),
|
snprintf(args, sizeof(args),
|
||||||
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
|
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
|
||||||
dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
|
dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
|
||||||
time_base.num, time_base.den,
|
dec_ctx->time_base.num, dec_ctx->time_base.den,
|
||||||
dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den);
|
dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den);
|
||||||
|
|
||||||
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
|
ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
|
||||||
args, NULL, filter_graph);
|
args, NULL, filter_graph);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n");
|
||||||
goto end;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buffer video sink: to terminate the filter chain. */
|
/* buffer video sink: to terminate the filter chain. */
|
||||||
|
buffersink_params = av_buffersink_params_alloc();
|
||||||
|
buffersink_params->pixel_fmts = pix_fmts;
|
||||||
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
|
ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
|
||||||
NULL, NULL, filter_graph);
|
NULL, buffersink_params, filter_graph);
|
||||||
|
av_free(buffersink_params);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n");
|
||||||
goto end;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = av_opt_set_int_list(buffersink_ctx, "pix_fmts", pix_fmts,
|
/* Endpoints for the filter graph. */
|
||||||
AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the endpoints for the filter graph. The filter_graph will
|
|
||||||
* be linked to the graph described by filters_descr.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The buffer source output must be connected to the input pad of
|
|
||||||
* the first filter described by filters_descr; since the first
|
|
||||||
* filter input label is not specified, it is set to "in" by
|
|
||||||
* default.
|
|
||||||
*/
|
|
||||||
outputs->name = av_strdup("in");
|
outputs->name = av_strdup("in");
|
||||||
outputs->filter_ctx = buffersrc_ctx;
|
outputs->filter_ctx = buffersrc_ctx;
|
||||||
outputs->pad_idx = 0;
|
outputs->pad_idx = 0;
|
||||||
outputs->next = NULL;
|
outputs->next = NULL;
|
||||||
|
|
||||||
/*
|
|
||||||
* The buffer sink input must be connected to the output pad of
|
|
||||||
* the last filter described by filters_descr; since the last
|
|
||||||
* filter output label is not specified, it is set to "out" by
|
|
||||||
* default.
|
|
||||||
*/
|
|
||||||
inputs->name = av_strdup("out");
|
inputs->name = av_strdup("out");
|
||||||
inputs->filter_ctx = buffersink_ctx;
|
inputs->filter_ctx = buffersink_ctx;
|
||||||
inputs->pad_idx = 0;
|
inputs->pad_idx = 0;
|
||||||
inputs->next = NULL;
|
inputs->next = NULL;
|
||||||
|
|
||||||
if ((ret = avfilter_graph_parse_ptr(filter_graph, filters_descr,
|
if ((ret = avfilter_graph_parse(filter_graph, filters_descr,
|
||||||
&inputs, &outputs, NULL)) < 0)
|
&inputs, &outputs, NULL)) < 0)
|
||||||
goto end;
|
return ret;
|
||||||
|
|
||||||
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0)
|
||||||
goto end;
|
return ret;
|
||||||
|
return 0;
|
||||||
end:
|
|
||||||
avfilter_inout_free(&inputs);
|
|
||||||
avfilter_inout_free(&outputs);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_frame(const AVFrame *frame, AVRational time_base)
|
static void display_picref(AVFilterBufferRef *picref, AVRational time_base)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
uint8_t *p0, *p;
|
uint8_t *p0, *p;
|
||||||
int64_t delay;
|
int64_t delay;
|
||||||
|
|
||||||
if (frame->pts != AV_NOPTS_VALUE) {
|
if (picref->pts != AV_NOPTS_VALUE) {
|
||||||
if (last_pts != AV_NOPTS_VALUE) {
|
if (last_pts != AV_NOPTS_VALUE) {
|
||||||
/* sleep roughly the right amount of time;
|
/* sleep roughly the right amount of time;
|
||||||
* usleep is in microseconds, just like AV_TIME_BASE. */
|
* usleep is in microseconds, just like AV_TIME_BASE. */
|
||||||
delay = av_rescale_q(frame->pts - last_pts,
|
delay = av_rescale_q(picref->pts - last_pts,
|
||||||
time_base, AV_TIME_BASE_Q);
|
time_base, AV_TIME_BASE_Q);
|
||||||
if (delay > 0 && delay < 1000000)
|
if (delay > 0 && delay < 1000000)
|
||||||
usleep(delay);
|
usleep(delay);
|
||||||
}
|
}
|
||||||
last_pts = frame->pts;
|
last_pts = picref->pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Trivial ASCII grayscale display. */
|
/* Trivial ASCII grayscale display. */
|
||||||
p0 = frame->data[0];
|
p0 = picref->data[0];
|
||||||
puts("\033c");
|
puts("\033c");
|
||||||
for (y = 0; y < frame->height; y++) {
|
for (y = 0; y < picref->video->h; y++) {
|
||||||
p = p0;
|
p = p0;
|
||||||
for (x = 0; x < frame->width; x++)
|
for (x = 0; x < picref->video->w; x++)
|
||||||
putchar(" .-+#"[*(p++) / 52]);
|
putchar(" .-+#"[*(p++) / 52]);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
p0 += frame->linesize[0];
|
p0 += picref->linesize[0];
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
@@ -211,10 +173,10 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
AVFrame *frame = av_frame_alloc();
|
AVFrame *frame = avcodec_alloc_frame();
|
||||||
AVFrame *filt_frame = av_frame_alloc();
|
int got_frame;
|
||||||
|
|
||||||
if (!frame || !filt_frame) {
|
if (!frame) {
|
||||||
perror("Could not allocate frame");
|
perror("Could not allocate frame");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -223,6 +185,7 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avcodec_register_all();
|
||||||
av_register_all();
|
av_register_all();
|
||||||
avfilter_register_all();
|
avfilter_register_all();
|
||||||
|
|
||||||
@@ -233,59 +196,56 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* read all packets */
|
/* read all packets */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
AVFilterBufferRef *picref;
|
||||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (packet.stream_index == video_stream_index) {
|
if (packet.stream_index == video_stream_index) {
|
||||||
ret = avcodec_send_packet(dec_ctx, &packet);
|
avcodec_get_frame_defaults(frame);
|
||||||
|
got_frame = 0;
|
||||||
|
ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, &packet);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
|
av_log(NULL, AV_LOG_ERROR, "Error decoding video\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ret >= 0) {
|
if (got_frame) {
|
||||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
|
||||||
|
/* push the decoded frame into the filtergraph */
|
||||||
|
if (av_buffersrc_add_frame(buffersrc_ctx, frame, 0) < 0) {
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
|
||||||
break;
|
break;
|
||||||
} else if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
|
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret >= 0) {
|
/* pull filtered pictures from the filtergraph */
|
||||||
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
while (1) {
|
||||||
|
ret = av_buffersink_get_buffer_ref(buffersink_ctx, &picref, 0);
|
||||||
/* push the decoded frame into the filtergraph */
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
if (ret < 0)
|
||||||
|
goto end;
|
||||||
|
|
||||||
/* pull filtered frames from the filtergraph */
|
if (picref) {
|
||||||
while (1) {
|
display_picref(picref, buffersink_ctx->inputs[0]->time_base);
|
||||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
avfilter_unref_bufferp(&picref);
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
break;
|
|
||||||
if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
|
|
||||||
av_frame_unref(filt_frame);
|
|
||||||
}
|
}
|
||||||
av_frame_unref(frame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_packet_unref(&packet);
|
av_free_packet(&packet);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
avfilter_graph_free(&filter_graph);
|
avfilter_graph_free(&filter_graph);
|
||||||
avcodec_free_context(&dec_ctx);
|
if (dec_ctx)
|
||||||
|
avcodec_close(dec_ctx);
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
av_frame_free(&frame);
|
av_freep(&frame);
|
||||||
av_frame_free(&filt_frame);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != AVERROR_EOF) {
|
if (ret < 0 && ret != AVERROR_EOF) {
|
||||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
char buf[1024];
|
||||||
|
av_strerror(ret, buf, sizeof(buf));
|
||||||
|
fprintf(stderr, "Error occurred: %s\n", buf);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,157 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 Stephan Holljes
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* libavformat multi-client network API usage example.
|
|
||||||
*
|
|
||||||
* @example http_multiclient.c
|
|
||||||
* This example will serve a file without decoding or demuxing it over http.
|
|
||||||
* Multiple clients can connect and will receive the same file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static void process_client(AVIOContext *client, const char *in_uri)
|
|
||||||
{
|
|
||||||
AVIOContext *input = NULL;
|
|
||||||
uint8_t buf[1024];
|
|
||||||
int ret, n, reply_code;
|
|
||||||
uint8_t *resource = NULL;
|
|
||||||
while ((ret = avio_handshake(client)) > 0) {
|
|
||||||
av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
|
|
||||||
// check for strlen(resource) is necessary, because av_opt_get()
|
|
||||||
// may return empty string.
|
|
||||||
if (resource && strlen(resource))
|
|
||||||
break;
|
|
||||||
av_freep(&resource);
|
|
||||||
}
|
|
||||||
if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
av_log(client, AV_LOG_TRACE, "resource=%p\n", resource);
|
|
||||||
if (resource && resource[0] == '/' && !strcmp((resource + 1), in_uri)) {
|
|
||||||
reply_code = 200;
|
|
||||||
} else {
|
|
||||||
reply_code = AVERROR_HTTP_NOT_FOUND;
|
|
||||||
}
|
|
||||||
if ((ret = av_opt_set_int(client, "reply_code", reply_code, AV_OPT_SEARCH_CHILDREN)) < 0) {
|
|
||||||
av_log(client, AV_LOG_ERROR, "Failed to set reply_code: %s.\n", av_err2str(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
av_log(client, AV_LOG_TRACE, "Set reply code to %d\n", reply_code);
|
|
||||||
|
|
||||||
while ((ret = avio_handshake(client)) > 0);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
fprintf(stderr, "Handshake performed.\n");
|
|
||||||
if (reply_code != 200)
|
|
||||||
goto end;
|
|
||||||
fprintf(stderr, "Opening input file.\n");
|
|
||||||
if ((ret = avio_open2(&input, in_uri, AVIO_FLAG_READ, NULL, NULL)) < 0) {
|
|
||||||
av_log(input, AV_LOG_ERROR, "Failed to open input: %s: %s.\n", in_uri,
|
|
||||||
av_err2str(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
for(;;) {
|
|
||||||
n = avio_read(input, buf, sizeof(buf));
|
|
||||||
if (n < 0) {
|
|
||||||
if (n == AVERROR_EOF)
|
|
||||||
break;
|
|
||||||
av_log(input, AV_LOG_ERROR, "Error reading from input: %s.\n",
|
|
||||||
av_err2str(n));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
avio_write(client, buf, n);
|
|
||||||
avio_flush(client);
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
fprintf(stderr, "Flushing client\n");
|
|
||||||
avio_flush(client);
|
|
||||||
fprintf(stderr, "Closing client\n");
|
|
||||||
avio_close(client);
|
|
||||||
fprintf(stderr, "Closing input\n");
|
|
||||||
avio_close(input);
|
|
||||||
av_freep(&resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
AVDictionary *options = NULL;
|
|
||||||
AVIOContext *client = NULL, *server = NULL;
|
|
||||||
const char *in_uri, *out_uri;
|
|
||||||
int ret, pid;
|
|
||||||
av_log_set_level(AV_LOG_TRACE);
|
|
||||||
if (argc < 3) {
|
|
||||||
printf("usage: %s input http://hostname[:port]\n"
|
|
||||||
"API example program to serve http to multiple clients.\n"
|
|
||||||
"\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
in_uri = argv[1];
|
|
||||||
out_uri = argv[2];
|
|
||||||
|
|
||||||
av_register_all();
|
|
||||||
avformat_network_init();
|
|
||||||
|
|
||||||
if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to set listen mode for server: %s\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if ((ret = avio_open2(&server, out_uri, AVIO_FLAG_WRITE, NULL, &options)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to open server: %s\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Entering main loop.\n");
|
|
||||||
for(;;) {
|
|
||||||
if ((ret = avio_accept(server, &client)) < 0)
|
|
||||||
goto end;
|
|
||||||
fprintf(stderr, "Accepted client, forking process.\n");
|
|
||||||
// XXX: Since we don't reap our children and don't ignore signals
|
|
||||||
// this produces zombie processes.
|
|
||||||
pid = fork();
|
|
||||||
if (pid < 0) {
|
|
||||||
perror("Fork failed");
|
|
||||||
ret = AVERROR(errno);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (pid == 0) {
|
|
||||||
fprintf(stderr, "In child.\n");
|
|
||||||
process_client(client, in_uri);
|
|
||||||
avio_close(server);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
if (pid > 0)
|
|
||||||
avio_close(client);
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
avio_close(server);
|
|
||||||
if (ret < 0 && ret != AVERROR_EOF) {
|
|
||||||
fprintf(stderr, "Some errors occurred: %s\n", av_err2str(ret));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Shows how the metadata API can be used in application programs.
|
* Shows how the metadata API can be used in application programs.
|
||||||
* @example metadata.c
|
* @example doc/examples/metadata.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
* @file
|
* @file
|
||||||
* libavformat API example.
|
* libavformat API example.
|
||||||
*
|
*
|
||||||
* Output a media file in any supported libavformat format. The default
|
* Output a media file in any supported libavformat format.
|
||||||
* codecs are used.
|
* The default codecs are used.
|
||||||
* @example muxing.c
|
* @example doc/examples/muxing.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -34,68 +34,31 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <libavutil/avassert.h>
|
|
||||||
#include <libavutil/channel_layout.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
#include <libavutil/mathematics.h>
|
#include <libavutil/mathematics.h>
|
||||||
#include <libavutil/timestamp.h>
|
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
#include <libswresample/swresample.h>
|
|
||||||
|
|
||||||
#define STREAM_DURATION 10.0
|
/* 5 seconds stream duration */
|
||||||
|
#define STREAM_DURATION 200.0
|
||||||
#define STREAM_FRAME_RATE 25 /* 25 images/s */
|
#define STREAM_FRAME_RATE 25 /* 25 images/s */
|
||||||
|
#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
|
||||||
#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */
|
#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */
|
||||||
|
|
||||||
#define SCALE_FLAGS SWS_BICUBIC
|
static int sws_flags = SWS_BICUBIC;
|
||||||
|
|
||||||
// a wrapper around a single output AVStream
|
/**************************************************************/
|
||||||
typedef struct OutputStream {
|
/* audio output */
|
||||||
AVStream *st;
|
|
||||||
AVCodecContext *enc;
|
|
||||||
|
|
||||||
/* pts of the next frame that will be generated */
|
static float t, tincr, tincr2;
|
||||||
int64_t next_pts;
|
static int16_t *samples;
|
||||||
int samples_count;
|
static int audio_input_frame_size;
|
||||||
|
|
||||||
AVFrame *frame;
|
|
||||||
AVFrame *tmp_frame;
|
|
||||||
|
|
||||||
float t, tincr, tincr2;
|
|
||||||
|
|
||||||
struct SwsContext *sws_ctx;
|
|
||||||
struct SwrContext *swr_ctx;
|
|
||||||
} OutputStream;
|
|
||||||
|
|
||||||
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
|
|
||||||
{
|
|
||||||
AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
|
|
||||||
|
|
||||||
printf("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
|
|
||||||
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
|
|
||||||
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
|
|
||||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
|
|
||||||
pkt->stream_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
|
|
||||||
{
|
|
||||||
/* rescale output packet timestamp values from codec to stream timebase */
|
|
||||||
av_packet_rescale_ts(pkt, *time_base, st->time_base);
|
|
||||||
pkt->stream_index = st->index;
|
|
||||||
|
|
||||||
/* Write the compressed frame to the media file. */
|
|
||||||
log_packet(fmt_ctx, pkt);
|
|
||||||
return av_interleaved_write_frame(fmt_ctx, pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add an output stream. */
|
/* Add an output stream. */
|
||||||
static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
|
||||||
AVCodec **codec,
|
enum AVCodecID codec_id)
|
||||||
enum AVCodecID codec_id)
|
|
||||||
{
|
{
|
||||||
AVCodecContext *c;
|
AVCodecContext *c;
|
||||||
int i;
|
AVStream *st;
|
||||||
|
|
||||||
/* find the encoder */
|
/* find the encoder */
|
||||||
*codec = avcodec_find_encoder(codec_id);
|
*codec = avcodec_find_encoder(codec_id);
|
||||||
@@ -105,43 +68,21 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ost->st = avformat_new_stream(oc, NULL);
|
st = avformat_new_stream(oc, *codec);
|
||||||
if (!ost->st) {
|
if (!st) {
|
||||||
fprintf(stderr, "Could not allocate stream\n");
|
fprintf(stderr, "Could not allocate stream\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
ost->st->id = oc->nb_streams-1;
|
st->id = oc->nb_streams-1;
|
||||||
c = avcodec_alloc_context3(*codec);
|
c = st->codec;
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not alloc an encoding context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
ost->enc = c;
|
|
||||||
|
|
||||||
switch ((*codec)->type) {
|
switch ((*codec)->type) {
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
c->sample_fmt = (*codec)->sample_fmts ?
|
st->id = 1;
|
||||||
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
|
c->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||||
c->bit_rate = 64000;
|
c->bit_rate = 64000;
|
||||||
c->sample_rate = 44100;
|
c->sample_rate = 44100;
|
||||||
if ((*codec)->supported_samplerates) {
|
c->channels = 2;
|
||||||
c->sample_rate = (*codec)->supported_samplerates[0];
|
|
||||||
for (i = 0; (*codec)->supported_samplerates[i]; i++) {
|
|
||||||
if ((*codec)->supported_samplerates[i] == 44100)
|
|
||||||
c->sample_rate = 44100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
|
||||||
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
|
||||||
if ((*codec)->channel_layouts) {
|
|
||||||
c->channel_layout = (*codec)->channel_layouts[0];
|
|
||||||
for (i = 0; (*codec)->channel_layouts[i]; i++) {
|
|
||||||
if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO)
|
|
||||||
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
|
||||||
ost->st->time_base = (AVRational){ 1, c->sample_rate };
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
@@ -155,13 +96,12 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
* of which frame timestamps are represented. For fixed-fps content,
|
* of which frame timestamps are represented. For fixed-fps content,
|
||||||
* timebase should be 1/framerate and timestamp increments should be
|
* timebase should be 1/framerate and timestamp increments should be
|
||||||
* identical to 1. */
|
* identical to 1. */
|
||||||
ost->st->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
|
c->time_base.den = STREAM_FRAME_RATE;
|
||||||
c->time_base = ost->st->time_base;
|
c->time_base.num = 1;
|
||||||
|
|
||||||
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
|
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
|
||||||
c->pix_fmt = STREAM_PIX_FMT;
|
c->pix_fmt = STREAM_PIX_FMT;
|
||||||
if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
/* just for testing, we also add B-frames */
|
/* just for testing, we also add B frames */
|
||||||
c->max_b_frames = 2;
|
c->max_b_frames = 2;
|
||||||
}
|
}
|
||||||
if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
||||||
@@ -178,176 +118,85 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
|
|
||||||
/* Some formats want stream headers to be separate. */
|
/* Some formats want stream headers to be separate. */
|
||||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
|
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||||
|
|
||||||
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/* audio output */
|
/* audio output */
|
||||||
|
|
||||||
static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
|
static float t, tincr, tincr2;
|
||||||
uint64_t channel_layout,
|
static int16_t *samples;
|
||||||
int sample_rate, int nb_samples)
|
static int audio_input_frame_size;
|
||||||
{
|
|
||||||
AVFrame *frame = av_frame_alloc();
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!frame) {
|
static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st)
|
||||||
fprintf(stderr, "Error allocating an audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->format = sample_fmt;
|
|
||||||
frame->channel_layout = channel_layout;
|
|
||||||
frame->sample_rate = sample_rate;
|
|
||||||
frame->nb_samples = nb_samples;
|
|
||||||
|
|
||||||
if (nb_samples) {
|
|
||||||
ret = av_frame_get_buffer(frame, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error allocating an audio buffer\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
|
|
||||||
{
|
{
|
||||||
AVCodecContext *c;
|
AVCodecContext *c;
|
||||||
int nb_samples;
|
|
||||||
int ret;
|
int ret;
|
||||||
AVDictionary *opt = NULL;
|
|
||||||
|
|
||||||
c = ost->enc;
|
c = st->codec;
|
||||||
|
|
||||||
/* open it */
|
/* open it */
|
||||||
av_dict_copy(&opt, opt_arg, 0);
|
ret = avcodec_open2(c, codec, NULL);
|
||||||
ret = avcodec_open2(c, codec, &opt);
|
|
||||||
av_dict_free(&opt);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
|
fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init signal generator */
|
/* init signal generator */
|
||||||
ost->t = 0;
|
t = 0;
|
||||||
ost->tincr = 2 * M_PI * 110.0 / c->sample_rate;
|
tincr = 2 * M_PI * 110.0 / c->sample_rate;
|
||||||
/* increment frequency by 110 Hz per second */
|
/* increment frequency by 110 Hz per second */
|
||||||
ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
|
tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
|
||||||
|
|
||||||
if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
|
if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)
|
||||||
nb_samples = 10000;
|
audio_input_frame_size = 10000;
|
||||||
else
|
else
|
||||||
nb_samples = c->frame_size;
|
audio_input_frame_size = c->frame_size;
|
||||||
|
samples = av_malloc(audio_input_frame_size *
|
||||||
ost->frame = alloc_audio_frame(c->sample_fmt, c->channel_layout,
|
av_get_bytes_per_sample(c->sample_fmt) *
|
||||||
c->sample_rate, nb_samples);
|
c->channels);
|
||||||
ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
|
if (!samples) {
|
||||||
c->sample_rate, nb_samples);
|
fprintf(stderr, "Could not allocate audio samples buffer\n");
|
||||||
|
|
||||||
/* copy the stream parameters to the muxer */
|
|
||||||
ret = avcodec_parameters_from_context(ost->st->codecpar, c);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not copy the stream parameters\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create resampler context */
|
|
||||||
ost->swr_ctx = swr_alloc();
|
|
||||||
if (!ost->swr_ctx) {
|
|
||||||
fprintf(stderr, "Could not allocate resampler context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set options */
|
|
||||||
av_opt_set_int (ost->swr_ctx, "in_channel_count", c->channels, 0);
|
|
||||||
av_opt_set_int (ost->swr_ctx, "in_sample_rate", c->sample_rate, 0);
|
|
||||||
av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
|
|
||||||
av_opt_set_int (ost->swr_ctx, "out_channel_count", c->channels, 0);
|
|
||||||
av_opt_set_int (ost->swr_ctx, "out_sample_rate", c->sample_rate, 0);
|
|
||||||
av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt", c->sample_fmt, 0);
|
|
||||||
|
|
||||||
/* initialize the resampling context */
|
|
||||||
if ((ret = swr_init(ost->swr_ctx)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to initialize the resampling context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
|
/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
|
||||||
* 'nb_channels' channels. */
|
* 'nb_channels' channels. */
|
||||||
static AVFrame *get_audio_frame(OutputStream *ost)
|
static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels)
|
||||||
{
|
{
|
||||||
AVFrame *frame = ost->tmp_frame;
|
|
||||||
int j, i, v;
|
int j, i, v;
|
||||||
int16_t *q = (int16_t*)frame->data[0];
|
int16_t *q;
|
||||||
|
|
||||||
/* check if we want to generate more frames */
|
q = samples;
|
||||||
if (av_compare_ts(ost->next_pts, ost->enc->time_base,
|
for (j = 0; j < frame_size; j++) {
|
||||||
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
v = (int)(sin(t) * 10000);
|
||||||
return NULL;
|
for (i = 0; i < nb_channels; i++)
|
||||||
|
|
||||||
for (j = 0; j <frame->nb_samples; j++) {
|
|
||||||
v = (int)(sin(ost->t) * 10000);
|
|
||||||
for (i = 0; i < ost->enc->channels; i++)
|
|
||||||
*q++ = v;
|
*q++ = v;
|
||||||
ost->t += ost->tincr;
|
t += tincr;
|
||||||
ost->tincr += ost->tincr2;
|
tincr += tincr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->pts = ost->next_pts;
|
|
||||||
ost->next_pts += frame->nb_samples;
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void write_audio_frame(AVFormatContext *oc, AVStream *st)
|
||||||
* encode one audio frame and send it to the muxer
|
|
||||||
* return 1 when encoding is finished, 0 otherwise
|
|
||||||
*/
|
|
||||||
static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
|
||||||
{
|
{
|
||||||
AVCodecContext *c;
|
AVCodecContext *c;
|
||||||
AVPacket pkt = { 0 }; // data and size must be 0;
|
AVPacket pkt = { 0 }; // data and size must be 0;
|
||||||
AVFrame *frame;
|
AVFrame *frame = avcodec_alloc_frame();
|
||||||
int ret;
|
int got_packet, ret;
|
||||||
int got_packet;
|
|
||||||
int dst_nb_samples;
|
|
||||||
|
|
||||||
av_init_packet(&pkt);
|
av_init_packet(&pkt);
|
||||||
c = ost->enc;
|
c = st->codec;
|
||||||
|
|
||||||
frame = get_audio_frame(ost);
|
get_audio_frame(samples, audio_input_frame_size, c->channels);
|
||||||
|
frame->nb_samples = audio_input_frame_size;
|
||||||
if (frame) {
|
avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
|
||||||
/* convert samples from native format to destination codec format, using the resampler */
|
(uint8_t *)samples,
|
||||||
/* compute destination number of samples */
|
audio_input_frame_size *
|
||||||
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
|
av_get_bytes_per_sample(c->sample_fmt) *
|
||||||
c->sample_rate, c->sample_rate, AV_ROUND_UP);
|
c->channels, 1);
|
||||||
av_assert0(dst_nb_samples == frame->nb_samples);
|
|
||||||
|
|
||||||
/* when we pass a frame to the encoder, it may keep a reference to it
|
|
||||||
* internally;
|
|
||||||
* make sure we do not overwrite it here
|
|
||||||
*/
|
|
||||||
ret = av_frame_make_writable(ost->frame);
|
|
||||||
if (ret < 0)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
/* convert to destination format */
|
|
||||||
ret = swr_convert(ost->swr_ctx,
|
|
||||||
ost->frame->data, dst_nb_samples,
|
|
||||||
(const uint8_t **)frame->data, frame->nb_samples);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while converting\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
frame = ost->frame;
|
|
||||||
|
|
||||||
frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
|
|
||||||
ost->samples_count += dst_nb_samples;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
|
ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -355,89 +204,79 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_packet) {
|
if (!got_packet)
|
||||||
ret = write_frame(oc, &c->time_base, ost->st, &pkt);
|
return;
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while writing audio frame: %s\n",
|
|
||||||
av_err2str(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (frame || got_packet) ? 0 : 1;
|
pkt.stream_index = st->index;
|
||||||
|
|
||||||
|
/* Write the compressed frame to the media file. */
|
||||||
|
ret = av_interleaved_write_frame(oc, &pkt);
|
||||||
|
if (ret != 0) {
|
||||||
|
fprintf(stderr, "Error while writing audio frame: %s\n",
|
||||||
|
av_err2str(ret));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
avcodec_free_frame(&frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void close_audio(AVFormatContext *oc, AVStream *st)
|
||||||
|
{
|
||||||
|
avcodec_close(st->codec);
|
||||||
|
|
||||||
|
av_free(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/* video output */
|
/* video output */
|
||||||
|
|
||||||
static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
|
static AVFrame *frame;
|
||||||
{
|
static AVPicture src_picture, dst_picture;
|
||||||
AVFrame *picture;
|
static int frame_count;
|
||||||
int ret;
|
|
||||||
|
|
||||||
picture = av_frame_alloc();
|
static void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st)
|
||||||
if (!picture)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
picture->format = pix_fmt;
|
|
||||||
picture->width = width;
|
|
||||||
picture->height = height;
|
|
||||||
|
|
||||||
/* allocate the buffers for the frame data */
|
|
||||||
ret = av_frame_get_buffer(picture, 32);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not allocate frame data.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return picture;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVCodecContext *c = ost->enc;
|
AVCodecContext *c = st->codec;
|
||||||
AVDictionary *opt = NULL;
|
|
||||||
|
|
||||||
av_dict_copy(&opt, opt_arg, 0);
|
|
||||||
|
|
||||||
/* open the codec */
|
/* open the codec */
|
||||||
ret = avcodec_open2(c, codec, &opt);
|
ret = avcodec_open2(c, codec, NULL);
|
||||||
av_dict_free(&opt);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
|
fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate and init a re-usable frame */
|
/* allocate and init a re-usable frame */
|
||||||
ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
|
frame = avcodec_alloc_frame();
|
||||||
if (!ost->frame) {
|
if (!frame) {
|
||||||
fprintf(stderr, "Could not allocate video frame\n");
|
fprintf(stderr, "Could not allocate video frame\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate the encoded raw picture. */
|
||||||
|
ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not allocate picture: %s\n", av_err2str(ret));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* If the output format is not YUV420P, then a temporary YUV420P
|
/* If the output format is not YUV420P, then a temporary YUV420P
|
||||||
* picture is needed too. It is then converted to the required
|
* picture is needed too. It is then converted to the required
|
||||||
* output format. */
|
* output format. */
|
||||||
ost->tmp_frame = NULL;
|
|
||||||
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||||
ost->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height);
|
ret = avpicture_alloc(&src_picture, AV_PIX_FMT_YUV420P, c->width, c->height);
|
||||||
if (!ost->tmp_frame) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not allocate temporary picture\n");
|
fprintf(stderr, "Could not allocate temporary picture: %s\n",
|
||||||
|
av_err2str(ret));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the stream parameters to the muxer */
|
/* copy data and linesize picture pointers to frame */
|
||||||
ret = avcodec_parameters_from_context(ost->st->codecpar, c);
|
*((AVPicture *)frame) = dst_picture;
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not copy the stream parameters\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare a dummy image. */
|
/* Prepare a dummy image. */
|
||||||
static void fill_yuv_image(AVFrame *pict, int frame_index,
|
static void fill_yuv_image(AVPicture *pict, int frame_index,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
int x, y, i;
|
int x, y, i;
|
||||||
@@ -458,94 +297,91 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AVFrame *get_video_frame(OutputStream *ost)
|
static void write_video_frame(AVFormatContext *oc, AVStream *st)
|
||||||
{
|
|
||||||
AVCodecContext *c = ost->enc;
|
|
||||||
|
|
||||||
/* check if we want to generate more frames */
|
|
||||||
if (av_compare_ts(ost->next_pts, c->time_base,
|
|
||||||
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* when we pass a frame to the encoder, it may keep a reference to it
|
|
||||||
* internally; make sure we do not overwrite it here */
|
|
||||||
if (av_frame_make_writable(ost->frame) < 0)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
|
||||||
/* as we only generate a YUV420P picture, we must convert it
|
|
||||||
* to the codec pixel format if needed */
|
|
||||||
if (!ost->sws_ctx) {
|
|
||||||
ost->sws_ctx = sws_getContext(c->width, c->height,
|
|
||||||
AV_PIX_FMT_YUV420P,
|
|
||||||
c->width, c->height,
|
|
||||||
c->pix_fmt,
|
|
||||||
SCALE_FLAGS, NULL, NULL, NULL);
|
|
||||||
if (!ost->sws_ctx) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Could not initialize the conversion context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fill_yuv_image(ost->tmp_frame, ost->next_pts, c->width, c->height);
|
|
||||||
sws_scale(ost->sws_ctx,
|
|
||||||
(const uint8_t * const *)ost->tmp_frame->data, ost->tmp_frame->linesize,
|
|
||||||
0, c->height, ost->frame->data, ost->frame->linesize);
|
|
||||||
} else {
|
|
||||||
fill_yuv_image(ost->frame, ost->next_pts, c->width, c->height);
|
|
||||||
}
|
|
||||||
|
|
||||||
ost->frame->pts = ost->next_pts++;
|
|
||||||
|
|
||||||
return ost->frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* encode one video frame and send it to the muxer
|
|
||||||
* return 1 when encoding is finished, 0 otherwise
|
|
||||||
*/
|
|
||||||
static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVCodecContext *c;
|
static struct SwsContext *sws_ctx;
|
||||||
AVFrame *frame;
|
AVCodecContext *c = st->codec;
|
||||||
int got_packet = 0;
|
|
||||||
AVPacket pkt = { 0 };
|
|
||||||
|
|
||||||
c = ost->enc;
|
if (frame_count >= STREAM_NB_FRAMES) {
|
||||||
|
/* No more frames to compress. The codec has a latency of a few
|
||||||
frame = get_video_frame(ost);
|
* frames if using B-frames, so we get the last frames by
|
||||||
|
* passing the same picture again. */
|
||||||
av_init_packet(&pkt);
|
|
||||||
|
|
||||||
/* encode the image */
|
|
||||||
ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (got_packet) {
|
|
||||||
ret = write_frame(oc, &c->time_base, ost->st, &pkt);
|
|
||||||
} else {
|
} else {
|
||||||
ret = 0;
|
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||||
|
/* as we only generate a YUV420P picture, we must convert it
|
||||||
|
* to the codec pixel format if needed */
|
||||||
|
if (!sws_ctx) {
|
||||||
|
sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P,
|
||||||
|
c->width, c->height, c->pix_fmt,
|
||||||
|
sws_flags, NULL, NULL, NULL);
|
||||||
|
if (!sws_ctx) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Could not initialize the conversion context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fill_yuv_image(&src_picture, frame_count, c->width, c->height);
|
||||||
|
sws_scale(sws_ctx,
|
||||||
|
(const uint8_t * const *)src_picture.data, src_picture.linesize,
|
||||||
|
0, c->height, dst_picture.data, dst_picture.linesize);
|
||||||
|
} else {
|
||||||
|
fill_yuv_image(&dst_picture, frame_count, c->width, c->height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (oc->oformat->flags & AVFMT_RAWPICTURE) {
|
||||||
|
/* Raw video case - directly store the picture in the packet */
|
||||||
|
AVPacket pkt;
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
|
||||||
|
pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
pkt.stream_index = st->index;
|
||||||
|
pkt.data = dst_picture.data[0];
|
||||||
|
pkt.size = sizeof(AVPicture);
|
||||||
|
|
||||||
|
ret = av_interleaved_write_frame(oc, &pkt);
|
||||||
|
} else {
|
||||||
|
/* encode the image */
|
||||||
|
AVPacket pkt;
|
||||||
|
int got_output;
|
||||||
|
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||||
|
pkt.size = 0;
|
||||||
|
|
||||||
|
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If size is zero, it means the image was buffered. */
|
||||||
|
if (got_output) {
|
||||||
|
if (c->coded_frame->key_frame)
|
||||||
|
pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
||||||
|
pkt.stream_index = st->index;
|
||||||
|
|
||||||
|
/* Write the compressed frame to the media file. */
|
||||||
|
ret = av_interleaved_write_frame(oc, &pkt);
|
||||||
|
} else {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
|
fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
frame_count++;
|
||||||
return (frame || got_packet) ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_stream(AVFormatContext *oc, OutputStream *ost)
|
static void close_video(AVFormatContext *oc, AVStream *st)
|
||||||
{
|
{
|
||||||
avcodec_free_context(&ost->enc);
|
avcodec_close(st->codec);
|
||||||
av_frame_free(&ost->frame);
|
av_free(src_picture.data[0]);
|
||||||
av_frame_free(&ost->tmp_frame);
|
av_free(dst_picture.data[0]);
|
||||||
sws_freeContext(ost->sws_ctx);
|
av_free(frame);
|
||||||
swr_free(&ost->swr_ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
@@ -553,21 +389,18 @@ static void close_stream(AVFormatContext *oc, OutputStream *ost)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
OutputStream video_st = { 0 }, audio_st = { 0 };
|
|
||||||
const char *filename;
|
const char *filename;
|
||||||
AVOutputFormat *fmt;
|
AVOutputFormat *fmt;
|
||||||
AVFormatContext *oc;
|
AVFormatContext *oc;
|
||||||
|
AVStream *audio_st, *video_st;
|
||||||
AVCodec *audio_codec, *video_codec;
|
AVCodec *audio_codec, *video_codec;
|
||||||
|
double audio_pts, video_pts;
|
||||||
int ret;
|
int ret;
|
||||||
int have_video = 0, have_audio = 0;
|
|
||||||
int encode_video = 0, encode_audio = 0;
|
|
||||||
AVDictionary *opt = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Initialize libavcodec, and register all codecs and formats. */
|
/* Initialize libavcodec, and register all codecs and formats. */
|
||||||
av_register_all();
|
av_register_all();
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc != 2) {
|
||||||
printf("usage: %s output_file\n"
|
printf("usage: %s output_file\n"
|
||||||
"API example program to output a media file with libavformat.\n"
|
"API example program to output a media file with libavformat.\n"
|
||||||
"This program generates a synthetic audio and video stream, encodes and\n"
|
"This program generates a synthetic audio and video stream, encodes and\n"
|
||||||
@@ -579,10 +412,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename = argv[1];
|
filename = argv[1];
|
||||||
for (i = 2; i+1 < argc; i+=2) {
|
|
||||||
if (!strcmp(argv[i], "-flags") || !strcmp(argv[i], "-fflags"))
|
|
||||||
av_dict_set(&opt, argv[i]+1, argv[i+1], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate the output media context */
|
/* allocate the output media context */
|
||||||
avformat_alloc_output_context2(&oc, NULL, NULL, filename);
|
avformat_alloc_output_context2(&oc, NULL, NULL, filename);
|
||||||
@@ -590,31 +419,29 @@ int main(int argc, char **argv)
|
|||||||
printf("Could not deduce output format from file extension: using MPEG.\n");
|
printf("Could not deduce output format from file extension: using MPEG.\n");
|
||||||
avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
|
avformat_alloc_output_context2(&oc, NULL, "mpeg", filename);
|
||||||
}
|
}
|
||||||
if (!oc)
|
if (!oc) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
fmt = oc->oformat;
|
fmt = oc->oformat;
|
||||||
|
|
||||||
/* Add the audio and video streams using the default format codecs
|
/* Add the audio and video streams using the default format codecs
|
||||||
* and initialize the codecs. */
|
* and initialize the codecs. */
|
||||||
|
video_st = NULL;
|
||||||
|
audio_st = NULL;
|
||||||
|
|
||||||
if (fmt->video_codec != AV_CODEC_ID_NONE) {
|
if (fmt->video_codec != AV_CODEC_ID_NONE) {
|
||||||
add_stream(&video_st, oc, &video_codec, fmt->video_codec);
|
video_st = add_stream(oc, &video_codec, fmt->video_codec);
|
||||||
have_video = 1;
|
|
||||||
encode_video = 1;
|
|
||||||
}
|
}
|
||||||
if (fmt->audio_codec != AV_CODEC_ID_NONE) {
|
if (fmt->audio_codec != AV_CODEC_ID_NONE) {
|
||||||
add_stream(&audio_st, oc, &audio_codec, fmt->audio_codec);
|
audio_st = add_stream(oc, &audio_codec, fmt->audio_codec);
|
||||||
have_audio = 1;
|
|
||||||
encode_audio = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that all the parameters are set, we can open the audio and
|
/* Now that all the parameters are set, we can open the audio and
|
||||||
* video codecs and allocate the necessary encode buffers. */
|
* video codecs and allocate the necessary encode buffers. */
|
||||||
if (have_video)
|
if (video_st)
|
||||||
open_video(oc, video_codec, &video_st, opt);
|
open_video(oc, video_codec, video_st);
|
||||||
|
if (audio_st)
|
||||||
if (have_audio)
|
open_audio(oc, audio_codec, audio_st);
|
||||||
open_audio(oc, audio_codec, &audio_st, opt);
|
|
||||||
|
|
||||||
av_dump_format(oc, 0, filename, 1);
|
av_dump_format(oc, 0, filename, 1);
|
||||||
|
|
||||||
@@ -629,21 +456,38 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write the stream header, if any. */
|
/* Write the stream header, if any. */
|
||||||
ret = avformat_write_header(oc, &opt);
|
ret = avformat_write_header(oc, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Error occurred when opening output file: %s\n",
|
fprintf(stderr, "Error occurred when opening output file: %s\n",
|
||||||
av_err2str(ret));
|
av_err2str(ret));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (encode_video || encode_audio) {
|
if (frame)
|
||||||
/* select the stream to encode */
|
frame->pts = 0;
|
||||||
if (encode_video &&
|
for (;;) {
|
||||||
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.enc->time_base,
|
/* Compute current audio and video time. */
|
||||||
audio_st.next_pts, audio_st.enc->time_base) <= 0)) {
|
if (audio_st)
|
||||||
encode_video = !write_video_frame(oc, &video_st);
|
audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
|
||||||
|
else
|
||||||
|
audio_pts = 0.0;
|
||||||
|
|
||||||
|
if (video_st)
|
||||||
|
video_pts = (double)video_st->pts.val * video_st->time_base.num /
|
||||||
|
video_st->time_base.den;
|
||||||
|
else
|
||||||
|
video_pts = 0.0;
|
||||||
|
|
||||||
|
if ((!audio_st || audio_pts >= STREAM_DURATION) &&
|
||||||
|
(!video_st || video_pts >= STREAM_DURATION))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* write interleaved audio and video frames */
|
||||||
|
if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {
|
||||||
|
write_audio_frame(oc, audio_st);
|
||||||
} else {
|
} else {
|
||||||
encode_audio = !write_audio_frame(oc, &audio_st);
|
write_video_frame(oc, video_st);
|
||||||
|
frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,14 +498,14 @@ int main(int argc, char **argv)
|
|||||||
av_write_trailer(oc);
|
av_write_trailer(oc);
|
||||||
|
|
||||||
/* Close each codec. */
|
/* Close each codec. */
|
||||||
if (have_video)
|
if (video_st)
|
||||||
close_stream(oc, &video_st);
|
close_video(oc, video_st);
|
||||||
if (have_audio)
|
if (audio_st)
|
||||||
close_stream(oc, &audio_st);
|
close_audio(oc, audio_st);
|
||||||
|
|
||||||
if (!(fmt->flags & AVFMT_NOFILE))
|
if (!(fmt->flags & AVFMT_NOFILE))
|
||||||
/* Close the output file. */
|
/* Close the output file. */
|
||||||
avio_closep(&oc->pb);
|
avio_close(oc->pb);
|
||||||
|
|
||||||
/* free the stream */
|
/* free the stream */
|
||||||
avformat_free_context(oc);
|
avformat_free_context(oc);
|
||||||
|
|||||||
@@ -1,487 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 Anton Khirnov
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Intel QSV-accelerated H.264 decoding example.
|
|
||||||
*
|
|
||||||
* @example qsvdec.c
|
|
||||||
* This example shows how to do QSV-accelerated H.264 decoding with output
|
|
||||||
* frames in the VA-API video surfaces.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <mfx/mfxvideo.h>
|
|
||||||
|
|
||||||
#include <va/va.h>
|
|
||||||
#include <va/va_x11.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
|
|
||||||
#include "libavformat/avformat.h"
|
|
||||||
#include "libavformat/avio.h"
|
|
||||||
|
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
#include "libavcodec/qsv.h"
|
|
||||||
|
|
||||||
#include "libavutil/error.h"
|
|
||||||
#include "libavutil/mem.h"
|
|
||||||
|
|
||||||
typedef struct DecodeContext {
|
|
||||||
mfxSession mfx_session;
|
|
||||||
VADisplay va_dpy;
|
|
||||||
|
|
||||||
VASurfaceID *surfaces;
|
|
||||||
mfxMemId *surface_ids;
|
|
||||||
int *surface_used;
|
|
||||||
int nb_surfaces;
|
|
||||||
|
|
||||||
mfxFrameInfo frame_info;
|
|
||||||
} DecodeContext;
|
|
||||||
|
|
||||||
static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
|
|
||||||
mfxFrameAllocResponse *resp)
|
|
||||||
{
|
|
||||||
DecodeContext *decode = pthis;
|
|
||||||
int err, i;
|
|
||||||
|
|
||||||
if (decode->surfaces) {
|
|
||||||
fprintf(stderr, "Multiple allocation requests.\n");
|
|
||||||
return MFX_ERR_MEMORY_ALLOC;
|
|
||||||
}
|
|
||||||
if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)) {
|
|
||||||
fprintf(stderr, "Unsupported surface type: %d\n", req->Type);
|
|
||||||
return MFX_ERR_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
if (req->Info.BitDepthLuma != 8 || req->Info.BitDepthChroma != 8 ||
|
|
||||||
req->Info.Shift || req->Info.FourCC != MFX_FOURCC_NV12 ||
|
|
||||||
req->Info.ChromaFormat != MFX_CHROMAFORMAT_YUV420) {
|
|
||||||
fprintf(stderr, "Unsupported surface properties.\n");
|
|
||||||
return MFX_ERR_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
decode->surfaces = av_malloc_array (req->NumFrameSuggested, sizeof(*decode->surfaces));
|
|
||||||
decode->surface_ids = av_malloc_array (req->NumFrameSuggested, sizeof(*decode->surface_ids));
|
|
||||||
decode->surface_used = av_mallocz_array(req->NumFrameSuggested, sizeof(*decode->surface_used));
|
|
||||||
if (!decode->surfaces || !decode->surface_ids || !decode->surface_used)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = vaCreateSurfaces(decode->va_dpy, VA_RT_FORMAT_YUV420,
|
|
||||||
req->Info.Width, req->Info.Height,
|
|
||||||
decode->surfaces, req->NumFrameSuggested,
|
|
||||||
NULL, 0);
|
|
||||||
if (err != VA_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Error allocating VA surfaces\n");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
decode->nb_surfaces = req->NumFrameSuggested;
|
|
||||||
|
|
||||||
for (i = 0; i < decode->nb_surfaces; i++)
|
|
||||||
decode->surface_ids[i] = &decode->surfaces[i];
|
|
||||||
|
|
||||||
resp->mids = decode->surface_ids;
|
|
||||||
resp->NumFrameActual = decode->nb_surfaces;
|
|
||||||
|
|
||||||
decode->frame_info = req->Info;
|
|
||||||
|
|
||||||
return MFX_ERR_NONE;
|
|
||||||
fail:
|
|
||||||
av_freep(&decode->surfaces);
|
|
||||||
av_freep(&decode->surface_ids);
|
|
||||||
av_freep(&decode->surface_used);
|
|
||||||
|
|
||||||
return MFX_ERR_MEMORY_ALLOC;
|
|
||||||
}
|
|
||||||
|
|
||||||
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
|
|
||||||
{
|
|
||||||
return MFX_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
|
|
||||||
{
|
|
||||||
return MFX_ERR_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
|
|
||||||
{
|
|
||||||
return MFX_ERR_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
|
|
||||||
{
|
|
||||||
*hdl = mid;
|
|
||||||
return MFX_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void free_surfaces(DecodeContext *decode)
|
|
||||||
{
|
|
||||||
if (decode->surfaces)
|
|
||||||
vaDestroySurfaces(decode->va_dpy, decode->surfaces, decode->nb_surfaces);
|
|
||||||
av_freep(&decode->surfaces);
|
|
||||||
av_freep(&decode->surface_ids);
|
|
||||||
av_freep(&decode->surface_used);
|
|
||||||
decode->nb_surfaces = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void free_buffer(void *opaque, uint8_t *data)
|
|
||||||
{
|
|
||||||
int *used = opaque;
|
|
||||||
*used = 0;
|
|
||||||
av_freep(&data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
|
||||||
{
|
|
||||||
DecodeContext *decode = avctx->opaque;
|
|
||||||
|
|
||||||
mfxFrameSurface1 *surf;
|
|
||||||
AVBufferRef *surf_buf;
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
for (idx = 0; idx < decode->nb_surfaces; idx++) {
|
|
||||||
if (!decode->surface_used[idx])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (idx == decode->nb_surfaces) {
|
|
||||||
fprintf(stderr, "No free surfaces\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
surf = av_mallocz(sizeof(*surf));
|
|
||||||
if (!surf)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
surf_buf = av_buffer_create((uint8_t*)surf, sizeof(*surf), free_buffer,
|
|
||||||
&decode->surface_used[idx], AV_BUFFER_FLAG_READONLY);
|
|
||||||
if (!surf_buf) {
|
|
||||||
av_freep(&surf);
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
surf->Info = decode->frame_info;
|
|
||||||
surf->Data.MemId = &decode->surfaces[idx];
|
|
||||||
|
|
||||||
frame->buf[0] = surf_buf;
|
|
||||||
frame->data[3] = (uint8_t*)surf;
|
|
||||||
|
|
||||||
decode->surface_used[idx] = 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts)
|
|
||||||
{
|
|
||||||
while (*pix_fmts != AV_PIX_FMT_NONE) {
|
|
||||||
if (*pix_fmts == AV_PIX_FMT_QSV) {
|
|
||||||
if (!avctx->hwaccel_context) {
|
|
||||||
DecodeContext *decode = avctx->opaque;
|
|
||||||
AVQSVContext *qsv = av_qsv_alloc_context();
|
|
||||||
if (!qsv)
|
|
||||||
return AV_PIX_FMT_NONE;
|
|
||||||
|
|
||||||
qsv->session = decode->mfx_session;
|
|
||||||
qsv->iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
|
|
||||||
|
|
||||||
avctx->hwaccel_context = qsv;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AV_PIX_FMT_QSV;
|
|
||||||
}
|
|
||||||
|
|
||||||
pix_fmts++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "The QSV pixel format not offered in get_format()\n");
|
|
||||||
|
|
||||||
return AV_PIX_FMT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx,
|
|
||||||
AVFrame *frame, AVPacket *pkt,
|
|
||||||
AVIOContext *output_ctx)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
int got_frame = 1;
|
|
||||||
|
|
||||||
while (pkt->size > 0 || (!pkt->data && got_frame)) {
|
|
||||||
ret = avcodec_decode_video2(decoder_ctx, frame, &got_frame, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt->data += ret;
|
|
||||||
pkt->size -= ret;
|
|
||||||
|
|
||||||
/* A real program would do something useful with the decoded frame here.
|
|
||||||
* We just retrieve the raw data and write it to a file, which is rather
|
|
||||||
* useless but pedagogic. */
|
|
||||||
if (got_frame) {
|
|
||||||
mfxFrameSurface1 *surf = (mfxFrameSurface1*)frame->data[3];
|
|
||||||
VASurfaceID surface = *(VASurfaceID*)surf->Data.MemId;
|
|
||||||
|
|
||||||
VAImageFormat img_fmt = {
|
|
||||||
.fourcc = VA_FOURCC_NV12,
|
|
||||||
.byte_order = VA_LSB_FIRST,
|
|
||||||
.bits_per_pixel = 8,
|
|
||||||
.depth = 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
VAImage img;
|
|
||||||
|
|
||||||
VAStatus err;
|
|
||||||
uint8_t *data;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
img.buf = VA_INVALID_ID;
|
|
||||||
img.image_id = VA_INVALID_ID;
|
|
||||||
|
|
||||||
err = vaCreateImage(decode->va_dpy, &img_fmt,
|
|
||||||
frame->width, frame->height, &img);
|
|
||||||
if (err != VA_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Error creating an image: %s\n",
|
|
||||||
vaErrorStr(err));
|
|
||||||
ret = AVERROR_UNKNOWN;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = vaGetImage(decode->va_dpy, surface, 0, 0,
|
|
||||||
frame->width, frame->height,
|
|
||||||
img.image_id);
|
|
||||||
if (err != VA_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Error getting an image: %s\n",
|
|
||||||
vaErrorStr(err));
|
|
||||||
ret = AVERROR_UNKNOWN;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = vaMapBuffer(decode->va_dpy, img.buf, (void**)&data);
|
|
||||||
if (err != VA_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Error mapping the image buffer: %s\n",
|
|
||||||
vaErrorStr(err));
|
|
||||||
ret = AVERROR_UNKNOWN;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < img.num_planes; i++)
|
|
||||||
for (j = 0; j < (img.height >> (i > 0)); j++)
|
|
||||||
avio_write(output_ctx, data + img.offsets[i] + j * img.pitches[i], img.width);
|
|
||||||
|
|
||||||
fail:
|
|
||||||
if (img.buf != VA_INVALID_ID)
|
|
||||||
vaUnmapBuffer(decode->va_dpy, img.buf);
|
|
||||||
if (img.image_id != VA_INVALID_ID)
|
|
||||||
vaDestroyImage(decode->va_dpy, img.image_id);
|
|
||||||
av_frame_unref(frame);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
AVFormatContext *input_ctx = NULL;
|
|
||||||
AVStream *video_st = NULL;
|
|
||||||
AVCodecContext *decoder_ctx = NULL;
|
|
||||||
const AVCodec *decoder;
|
|
||||||
|
|
||||||
AVPacket pkt = { 0 };
|
|
||||||
AVFrame *frame = NULL;
|
|
||||||
|
|
||||||
DecodeContext decode = { NULL };
|
|
||||||
|
|
||||||
Display *dpy = NULL;
|
|
||||||
int va_ver_major, va_ver_minor;
|
|
||||||
|
|
||||||
mfxIMPL mfx_impl = MFX_IMPL_AUTO_ANY;
|
|
||||||
mfxVersion mfx_ver = { { 1, 1 } };
|
|
||||||
|
|
||||||
mfxFrameAllocator frame_allocator = {
|
|
||||||
.pthis = &decode,
|
|
||||||
.Alloc = frame_alloc,
|
|
||||||
.Lock = frame_lock,
|
|
||||||
.Unlock = frame_unlock,
|
|
||||||
.GetHDL = frame_get_hdl,
|
|
||||||
.Free = frame_free,
|
|
||||||
};
|
|
||||||
|
|
||||||
AVIOContext *output_ctx = NULL;
|
|
||||||
|
|
||||||
int ret, i, err;
|
|
||||||
|
|
||||||
av_register_all();
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open the input file */
|
|
||||||
ret = avformat_open_input(&input_ctx, argv[1], NULL, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Cannot open input file '%s': ", argv[1]);
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* find the first H.264 video stream */
|
|
||||||
for (i = 0; i < input_ctx->nb_streams; i++) {
|
|
||||||
AVStream *st = input_ctx->streams[i];
|
|
||||||
|
|
||||||
if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !video_st)
|
|
||||||
video_st = st;
|
|
||||||
else
|
|
||||||
st->discard = AVDISCARD_ALL;
|
|
||||||
}
|
|
||||||
if (!video_st) {
|
|
||||||
fprintf(stderr, "No H.264 video stream in the input file\n");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize VA-API */
|
|
||||||
dpy = XOpenDisplay(NULL);
|
|
||||||
if (!dpy) {
|
|
||||||
fprintf(stderr, "Cannot open the X display\n");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
decode.va_dpy = vaGetDisplay(dpy);
|
|
||||||
if (!decode.va_dpy) {
|
|
||||||
fprintf(stderr, "Cannot open the VA display\n");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = vaInitialize(decode.va_dpy, &va_ver_major, &va_ver_minor);
|
|
||||||
if (err != VA_STATUS_SUCCESS) {
|
|
||||||
fprintf(stderr, "Cannot initialize VA: %s\n", vaErrorStr(err));
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Initialized VA v%d.%d\n", va_ver_major, va_ver_minor);
|
|
||||||
|
|
||||||
/* initialize an MFX session */
|
|
||||||
err = MFXInit(mfx_impl, &mfx_ver, &decode.mfx_session);
|
|
||||||
if (err != MFX_ERR_NONE) {
|
|
||||||
fprintf(stderr, "Error initializing an MFX session\n");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
MFXVideoCORE_SetHandle(decode.mfx_session, MFX_HANDLE_VA_DISPLAY, decode.va_dpy);
|
|
||||||
MFXVideoCORE_SetFrameAllocator(decode.mfx_session, &frame_allocator);
|
|
||||||
|
|
||||||
/* initialize the decoder */
|
|
||||||
decoder = avcodec_find_decoder_by_name("h264_qsv");
|
|
||||||
if (!decoder) {
|
|
||||||
fprintf(stderr, "The QSV decoder is not present in libavcodec\n");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
decoder_ctx = avcodec_alloc_context3(decoder);
|
|
||||||
if (!decoder_ctx) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
decoder_ctx->codec_id = AV_CODEC_ID_H264;
|
|
||||||
if (video_st->codecpar->extradata_size) {
|
|
||||||
decoder_ctx->extradata = av_mallocz(video_st->codecpar->extradata_size +
|
|
||||||
AV_INPUT_BUFFER_PADDING_SIZE);
|
|
||||||
if (!decoder_ctx->extradata) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
memcpy(decoder_ctx->extradata, video_st->codecpar->extradata,
|
|
||||||
video_st->codecpar->extradata_size);
|
|
||||||
decoder_ctx->extradata_size = video_st->codecpar->extradata_size;
|
|
||||||
}
|
|
||||||
decoder_ctx->refcounted_frames = 1;
|
|
||||||
|
|
||||||
decoder_ctx->opaque = &decode;
|
|
||||||
decoder_ctx->get_buffer2 = get_buffer;
|
|
||||||
decoder_ctx->get_format = get_format;
|
|
||||||
|
|
||||||
ret = avcodec_open2(decoder_ctx, NULL, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error opening the decoder: ");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open the output stream */
|
|
||||||
ret = avio_open(&output_ctx, argv[2], AVIO_FLAG_WRITE);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error opening the output context: ");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
if (!frame) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* actual decoding */
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = av_read_frame(input_ctx, &pkt);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (pkt.stream_index == video_st->index)
|
|
||||||
ret = decode_packet(&decode, decoder_ctx, frame, &pkt, output_ctx);
|
|
||||||
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush the decoder */
|
|
||||||
pkt.data = NULL;
|
|
||||||
pkt.size = 0;
|
|
||||||
ret = decode_packet(&decode, decoder_ctx, frame, &pkt, output_ctx);
|
|
||||||
|
|
||||||
finish:
|
|
||||||
if (ret < 0) {
|
|
||||||
char buf[1024];
|
|
||||||
av_strerror(ret, buf, sizeof(buf));
|
|
||||||
fprintf(stderr, "%s\n", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
avformat_close_input(&input_ctx);
|
|
||||||
|
|
||||||
av_frame_free(&frame);
|
|
||||||
|
|
||||||
if (decoder_ctx)
|
|
||||||
av_freep(&decoder_ctx->hwaccel_context);
|
|
||||||
avcodec_free_context(&decoder_ctx);
|
|
||||||
|
|
||||||
free_surfaces(&decode);
|
|
||||||
|
|
||||||
if (decode.mfx_session)
|
|
||||||
MFXClose(decode.mfx_session);
|
|
||||||
if (decode.va_dpy)
|
|
||||||
vaTerminate(decode.va_dpy);
|
|
||||||
if (dpy)
|
|
||||||
XCloseDisplay(dpy);
|
|
||||||
|
|
||||||
avio_close(output_ctx);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013 Stefano Sabatini
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* libavformat/libavcodec demuxing and muxing API example.
|
|
||||||
*
|
|
||||||
* Remux streams from one container format to another.
|
|
||||||
* @example remuxing.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libavutil/timestamp.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
|
|
||||||
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, const char *tag)
|
|
||||||
{
|
|
||||||
AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
|
|
||||||
|
|
||||||
printf("%s: pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
|
|
||||||
tag,
|
|
||||||
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
|
|
||||||
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
|
|
||||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
|
|
||||||
pkt->stream_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
AVOutputFormat *ofmt = NULL;
|
|
||||||
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
|
|
||||||
AVPacket pkt;
|
|
||||||
const char *in_filename, *out_filename;
|
|
||||||
int ret, i;
|
|
||||||
int stream_index = 0;
|
|
||||||
int *stream_mapping = NULL;
|
|
||||||
int stream_mapping_size = 0;
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
printf("usage: %s input output\n"
|
|
||||||
"API example program to remux a media file with libavformat and libavcodec.\n"
|
|
||||||
"The output format is guessed according to the file extension.\n"
|
|
||||||
"\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
in_filename = argv[1];
|
|
||||||
out_filename = argv[2];
|
|
||||||
|
|
||||||
av_register_all();
|
|
||||||
|
|
||||||
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
|
|
||||||
fprintf(stderr, "Could not open input file '%s'", in_filename);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to retrieve input stream information");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
av_dump_format(ifmt_ctx, 0, in_filename, 0);
|
|
||||||
|
|
||||||
avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename);
|
|
||||||
if (!ofmt_ctx) {
|
|
||||||
fprintf(stderr, "Could not create output context\n");
|
|
||||||
ret = AVERROR_UNKNOWN;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream_mapping_size = ifmt_ctx->nb_streams;
|
|
||||||
stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
|
|
||||||
if (!stream_mapping) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ofmt = ofmt_ctx->oformat;
|
|
||||||
|
|
||||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
|
||||||
AVStream *out_stream;
|
|
||||||
AVStream *in_stream = ifmt_ctx->streams[i];
|
|
||||||
AVCodecParameters *in_codecpar = in_stream->codecpar;
|
|
||||||
|
|
||||||
if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO &&
|
|
||||||
in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO &&
|
|
||||||
in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
|
|
||||||
stream_mapping[i] = -1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream_mapping[i] = stream_index++;
|
|
||||||
|
|
||||||
out_stream = avformat_new_stream(ofmt_ctx, NULL);
|
|
||||||
if (!out_stream) {
|
|
||||||
fprintf(stderr, "Failed allocating output stream\n");
|
|
||||||
ret = AVERROR_UNKNOWN;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Failed to copy codec parameters\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
out_stream->codecpar->codec_tag = 0;
|
|
||||||
}
|
|
||||||
av_dump_format(ofmt_ctx, 0, out_filename, 1);
|
|
||||||
|
|
||||||
if (!(ofmt->flags & AVFMT_NOFILE)) {
|
|
||||||
ret = avio_open(&ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not open output file '%s'", out_filename);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avformat_write_header(ofmt_ctx, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error occurred when opening output file\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
AVStream *in_stream, *out_stream;
|
|
||||||
|
|
||||||
ret = av_read_frame(ifmt_ctx, &pkt);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
in_stream = ifmt_ctx->streams[pkt.stream_index];
|
|
||||||
if (pkt.stream_index >= stream_mapping_size ||
|
|
||||||
stream_mapping[pkt.stream_index] < 0) {
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt.stream_index = stream_mapping[pkt.stream_index];
|
|
||||||
out_stream = ofmt_ctx->streams[pkt.stream_index];
|
|
||||||
log_packet(ifmt_ctx, &pkt, "in");
|
|
||||||
|
|
||||||
/* copy packet */
|
|
||||||
pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
|
||||||
pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
|
||||||
pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
|
|
||||||
pkt.pos = -1;
|
|
||||||
log_packet(ofmt_ctx, &pkt, "out");
|
|
||||||
|
|
||||||
ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error muxing packet\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
av_packet_unref(&pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
av_write_trailer(ofmt_ctx);
|
|
||||||
end:
|
|
||||||
|
|
||||||
avformat_close_input(&ifmt_ctx);
|
|
||||||
|
|
||||||
/* close output */
|
|
||||||
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
|
|
||||||
avio_closep(&ofmt_ctx->pb);
|
|
||||||
avformat_free_context(ofmt_ctx);
|
|
||||||
|
|
||||||
av_freep(&stream_mapping);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != AVERROR_EOF) {
|
|
||||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @example resampling_audio.c
|
* @example doc/examples/resampling_audio.c
|
||||||
* libswresample API use example.
|
* libswresample API use example.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ static int get_format_from_sample_fmt(const char **fmt,
|
|||||||
/**
|
/**
|
||||||
* Fill dst buffer with nb_samples, generated starting from t.
|
* Fill dst buffer with nb_samples, generated starting from t.
|
||||||
*/
|
*/
|
||||||
static void fill_samples(double *dst, int nb_samples, int nb_channels, int sample_rate, double *t)
|
void fill_samples(double *dst, int nb_samples, int nb_channels, int sample_rate, double *t)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
double tincr = 1.0 / sample_rate, *dstp = dst;
|
double tincr = 1.0 / sample_rate, *dstp = dst;
|
||||||
@@ -78,6 +78,18 @@ static void fill_samples(double *dst, int nb_samples, int nb_channels, int sampl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int alloc_samples_array_and_data(uint8_t ***data, int *linesize, int nb_channels,
|
||||||
|
int nb_samples, enum AVSampleFormat sample_fmt, int align)
|
||||||
|
{
|
||||||
|
int nb_planes = av_sample_fmt_is_planar(sample_fmt) ? nb_channels : 1;
|
||||||
|
|
||||||
|
*data = av_malloc(sizeof(*data) * nb_planes);
|
||||||
|
if (!*data)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
return av_samples_alloc(*data, linesize, nb_channels,
|
||||||
|
nb_samples, sample_fmt, align);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int64_t src_ch_layout = AV_CH_LAYOUT_STEREO, dst_ch_layout = AV_CH_LAYOUT_SURROUND;
|
int64_t src_ch_layout = AV_CH_LAYOUT_STEREO, dst_ch_layout = AV_CH_LAYOUT_SURROUND;
|
||||||
@@ -137,8 +149,8 @@ int main(int argc, char **argv)
|
|||||||
/* allocate source and destination samples buffers */
|
/* allocate source and destination samples buffers */
|
||||||
|
|
||||||
src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout);
|
src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout);
|
||||||
ret = av_samples_alloc_array_and_samples(&src_data, &src_linesize, src_nb_channels,
|
ret = alloc_samples_array_and_data(&src_data, &src_linesize, src_nb_channels,
|
||||||
src_nb_samples, src_sample_fmt, 0);
|
src_nb_samples, src_sample_fmt, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not allocate source samples\n");
|
fprintf(stderr, "Could not allocate source samples\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -152,8 +164,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* buffer is going to be directly written to a rawaudio file, no alignment */
|
/* buffer is going to be directly written to a rawaudio file, no alignment */
|
||||||
dst_nb_channels = av_get_channel_layout_nb_channels(dst_ch_layout);
|
dst_nb_channels = av_get_channel_layout_nb_channels(dst_ch_layout);
|
||||||
ret = av_samples_alloc_array_and_samples(&dst_data, &dst_linesize, dst_nb_channels,
|
ret = alloc_samples_array_and_data(&dst_data, &dst_linesize, dst_nb_channels,
|
||||||
dst_nb_samples, dst_sample_fmt, 0);
|
dst_nb_samples, dst_sample_fmt, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not allocate destination samples\n");
|
fprintf(stderr, "Could not allocate destination samples\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -168,7 +180,7 @@ int main(int argc, char **argv)
|
|||||||
dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, src_rate) +
|
dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, src_rate) +
|
||||||
src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
|
src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
|
||||||
if (dst_nb_samples > max_dst_nb_samples) {
|
if (dst_nb_samples > max_dst_nb_samples) {
|
||||||
av_freep(&dst_data[0]);
|
av_free(dst_data[0]);
|
||||||
ret = av_samples_alloc(dst_data, &dst_linesize, dst_nb_channels,
|
ret = av_samples_alloc(dst_data, &dst_linesize, dst_nb_channels,
|
||||||
dst_nb_samples, dst_sample_fmt, 1);
|
dst_nb_samples, dst_sample_fmt, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -184,10 +196,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
dst_bufsize = av_samples_get_buffer_size(&dst_linesize, dst_nb_channels,
|
dst_bufsize = av_samples_get_buffer_size(&dst_linesize, dst_nb_channels,
|
||||||
ret, dst_sample_fmt, 1);
|
ret, dst_sample_fmt, 1);
|
||||||
if (dst_bufsize < 0) {
|
|
||||||
fprintf(stderr, "Could not get sample buffer size\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
printf("t:%f in:%d out:%d\n", t, src_nb_samples, ret);
|
printf("t:%f in:%d out:%d\n", t, src_nb_samples, ret);
|
||||||
fwrite(dst_data[0], 1, dst_bufsize, dst_file);
|
fwrite(dst_data[0], 1, dst_bufsize, dst_file);
|
||||||
} while (t < 10);
|
} while (t < 10);
|
||||||
@@ -199,7 +207,8 @@ int main(int argc, char **argv)
|
|||||||
fmt, dst_ch_layout, dst_nb_channels, dst_rate, dst_filename);
|
fmt, dst_ch_layout, dst_nb_channels, dst_rate, dst_filename);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
fclose(dst_file);
|
if (dst_file)
|
||||||
|
fclose(dst_file);
|
||||||
|
|
||||||
if (src_data)
|
if (src_data)
|
||||||
av_freep(&src_data[0]);
|
av_freep(&src_data[0]);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user