mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-07 15:30:00 +01:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d005e2ecce | ||
|
|
57bdb3f3dd | ||
|
|
5e34dded10 | ||
|
|
45ca270ec9 | ||
|
|
ca2ccd85d7 | ||
|
|
437f6fb488 | ||
|
|
f913da3e15 | ||
|
|
ed9c6529f0 | ||
|
|
aa40bbb492 | ||
|
|
8e276fc96a | ||
|
|
4a4e30a6d8 | ||
|
|
1c733a440a | ||
|
|
5c3bc127ca | ||
|
|
be94d15a03 | ||
|
|
9c57328b81 | ||
|
|
6952f6f39b | ||
|
|
6359be6751 | ||
|
|
beb55b3981 | ||
|
|
80aec733ad | ||
|
|
77bb6b5bcc | ||
|
|
f68395f7fc | ||
|
|
eefb6b654d | ||
|
|
d18d48def6 | ||
|
|
8df77c3758 | ||
|
|
08f56b846c | ||
|
|
f903147f2d | ||
|
|
9a840d5e17 | ||
|
|
9e43d92d6a | ||
|
|
e13e928baa | ||
|
|
d3bfb66a66 | ||
|
|
17a6ca7d31 | ||
|
|
8a20224059 | ||
|
|
29ee8b72c4 | ||
|
|
25864cf562 | ||
|
|
f74206cb40 | ||
|
|
148d9cd122 | ||
|
|
bc259185cb | ||
|
|
3b6bde3b3d | ||
|
|
4f187f0af1 | ||
|
|
10c2d22ba1 | ||
|
|
35738e5898 | ||
|
|
59d98fc050 | ||
|
|
60bfa9154d | ||
|
|
9794727ccd | ||
|
|
b88de7b31a | ||
|
|
11420649d0 | ||
|
|
dbf5d7e5cd | ||
|
|
6badd558ce | ||
|
|
a1fe3b4150 | ||
|
|
c5129da726 | ||
|
|
fc57959fd5 | ||
|
|
83956309cc | ||
|
|
ed15be7519 | ||
|
|
6928193493 | ||
|
|
a72b7286e6 | ||
|
|
901e275697 | ||
|
|
7a6b5d7a86 | ||
|
|
fdfe94f4b1 | ||
|
|
b63ec0cb0f | ||
|
|
2eb72d5bdc | ||
|
|
638c3aca64 | ||
|
|
76d59f1b34 | ||
|
|
aa0a8ef50e | ||
|
|
d6173ae341 | ||
|
|
3ed27832e7 | ||
|
|
594b1fa961 | ||
|
|
7a1262fca3 | ||
|
|
6d2219e9f9 | ||
|
|
7c2d152f56 | ||
|
|
1f58590e1e | ||
|
|
64bbbcd7b0 | ||
|
|
de9d3f22f0 | ||
|
|
ea5bb5613f | ||
|
|
c61ac696e5 | ||
|
|
6a250c858e | ||
|
|
5411040802 | ||
|
|
ab1ea597bd | ||
|
|
ee606fd031 | ||
|
|
2f71aeb301 | ||
|
|
65259b4d68 | ||
|
|
8f53d32dfb | ||
|
|
fcc6568a10 | ||
|
|
489d066d49 | ||
|
|
9cb45f6ad2 | ||
|
|
0f04e2741e | ||
|
|
84642ec879 | ||
|
|
bef4d9bf87 | ||
|
|
bc4f6ae88e | ||
|
|
2678b25099 | ||
|
|
e322496054 | ||
|
|
7fa72ff19c |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +0,0 @@
|
|||||||
*.pnm -diff -text
|
|
||||||
tests/ref/fate/sub-scc eol=crlf
|
|
||||||
75
.gitignore
vendored
75
.gitignore
vendored
@@ -1,6 +1,5 @@
|
|||||||
*.a
|
*.a
|
||||||
*.o
|
*.o
|
||||||
*.o.*
|
|
||||||
*.d
|
*.d
|
||||||
*.def
|
*.def
|
||||||
*.dll
|
*.dll
|
||||||
@@ -18,26 +17,70 @@
|
|||||||
*.so.*
|
*.so.*
|
||||||
*.swp
|
*.swp
|
||||||
*.ver
|
*.ver
|
||||||
*.version
|
*-example
|
||||||
*.metal.air
|
*-test
|
||||||
*.metallib
|
|
||||||
*.metallib.c
|
|
||||||
*.ptx
|
|
||||||
*.ptx.c
|
|
||||||
*.ptx.gz
|
|
||||||
*_g
|
*_g
|
||||||
\#*
|
|
||||||
.\#*
|
|
||||||
/.config
|
/.config
|
||||||
/.version
|
/.version
|
||||||
/ffmpeg
|
/ffmpeg
|
||||||
/ffplay
|
/ffplay
|
||||||
/ffprobe
|
/ffprobe
|
||||||
/config.asm
|
/ffserver
|
||||||
/config.h
|
/config.*
|
||||||
/config_components.h
|
|
||||||
/coverage.info
|
/coverage.info
|
||||||
|
/doc/*.1
|
||||||
|
/doc/*.3
|
||||||
|
/doc/*.html
|
||||||
|
/doc/*.pod
|
||||||
|
/doc/config.texi
|
||||||
|
/doc/avoptions_codec.texi
|
||||||
|
/doc/avoptions_format.texi
|
||||||
|
/doc/doxy/html/
|
||||||
|
/doc/examples/avio_reading
|
||||||
|
/doc/examples/decoding_encoding
|
||||||
|
/doc/examples/demuxing_decoding
|
||||||
|
/doc/examples/filter_audio
|
||||||
|
/doc/examples/filtering_audio
|
||||||
|
/doc/examples/filtering_video
|
||||||
|
/doc/examples/metadata
|
||||||
|
/doc/examples/muxing
|
||||||
|
/doc/examples/pc-uninstalled
|
||||||
|
/doc/examples/remuxing
|
||||||
|
/doc/examples/resampling_audio
|
||||||
|
/doc/examples/scaling_video
|
||||||
|
/doc/examples/transcode_aac
|
||||||
|
/doc/examples/transcoding
|
||||||
|
/doc/fate.txt
|
||||||
|
/doc/print_options
|
||||||
/lcov/
|
/lcov/
|
||||||
/src
|
/libavcodec/*_tablegen
|
||||||
/mapfile
|
/libavcodec/*_tables.c
|
||||||
/tools/python/__pycache__/
|
/libavcodec/*_tables.h
|
||||||
|
/libavutil/avconfig.h
|
||||||
|
/libavutil/ffversion.h
|
||||||
|
/tests/audiogen
|
||||||
|
/tests/base64
|
||||||
|
/tests/data/
|
||||||
|
/tests/rotozoom
|
||||||
|
/tests/tiny_psnr
|
||||||
|
/tests/tiny_ssim
|
||||||
|
/tests/videogen
|
||||||
|
/tests/vsynth1/
|
||||||
|
/tools/aviocat
|
||||||
|
/tools/ffbisect
|
||||||
|
/tools/bisect.need
|
||||||
|
/tools/crypto_bench
|
||||||
|
/tools/cws2fws
|
||||||
|
/tools/fourcc2pixfmt
|
||||||
|
/tools/ffescape
|
||||||
|
/tools/ffeval
|
||||||
|
/tools/ffhash
|
||||||
|
/tools/graph2dot
|
||||||
|
/tools/ismindex
|
||||||
|
/tools/pktdumper
|
||||||
|
/tools/probetest
|
||||||
|
/tools/qt-faststart
|
||||||
|
/tools/trasher
|
||||||
|
/tools/seek_print
|
||||||
|
/tools/uncoded_frame
|
||||||
|
/tools/zmqsend
|
||||||
|
|||||||
25
.mailmap
25
.mailmap
@@ -1,25 +0,0 @@
|
|||||||
<james.darnley@gmail.com> <jdarnley@obe.tv>
|
|
||||||
<jeebjp@gmail.com> <jan.ekstrom@aminocom.com>
|
|
||||||
<sw@jkqxz.net> <mrt@jkqxz.net>
|
|
||||||
<u@pkh.me> <cboesch@gopro.com>
|
|
||||||
<zhilizhao@tencent.com> <quinkblack@foxmail.com>
|
|
||||||
<zhilizhao@tencent.com> <wantlamy@gmail.com>
|
|
||||||
<modmaker@google.com> <modmaker-at-google.com@ffmpeg.org>
|
|
||||||
<stebbins@jetheaddev.com> <jstebbins@jetheaddev.com>
|
|
||||||
<barryjzhao@tencent.com> <mypopydev@gmail.com>
|
|
||||||
<barryjzhao@tencent.com> <jun.zhao@intel.com>
|
|
||||||
<josh@itanimul.li> <joshdk@obe.tv>
|
|
||||||
<michael@niedermayer.cc> <michaelni@gmx.at>
|
|
||||||
<linjie.justin.fu@gmail.com> <linjie.fu@intel.com>
|
|
||||||
<linjie.justin.fu@gmail.com> <fulinjie@zju.edu.cn>
|
|
||||||
<ceffmpeg@gmail.com> <cehoyos@ag.or.at>
|
|
||||||
<ceffmpeg@gmail.com> <cehoyos@rainbow.studorg.tuwien.ac.at>
|
|
||||||
<ffmpeg@gyani.pro> <gyandoshi@gmail.com>
|
|
||||||
<atomnuker@gmail.com> <rpehlivanov@obe.tv>
|
|
||||||
<lizhong1008@gmail.com> <zhong.li@intel.com>
|
|
||||||
<lizhong1008@gmail.com> <zhongli_dev@126.com>
|
|
||||||
<andreas.rheinhardt@gmail.com> <andreas.rheinhardt@googlemail.com>
|
|
||||||
rcombs <rcombs@rcombs.me> <rodger.combs@gmail.com>
|
|
||||||
<thilo.borgmann@mail.de> <thilo.borgmann@googlemail.com>
|
|
||||||
<liuqi05@kuaishou.com> <lq@chinaffmpeg.org>
|
|
||||||
<ruiling.song83@gmail.com> <ruiling.song@intel.com>
|
|
||||||
30
.travis.yml
30
.travis.yml
@@ -1,30 +0,0 @@
|
|||||||
language: c
|
|
||||||
sudo: false
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- nasm
|
|
||||||
- diffutils
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
- gcc
|
|
||||||
matrix:
|
|
||||||
exclude:
|
|
||||||
- os: osx
|
|
||||||
compiler: gcc
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- ffmpeg-samples
|
|
||||||
before_install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi
|
|
||||||
install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install nasm; 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.
|
|
||||||
785
Changelog
785
Changelog
@@ -1,761 +1,29 @@
|
|||||||
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 5.1:
|
version 2.3.3:
|
||||||
- add ipfs/ipns protocol support
|
- h264: fix grayscale only decoding with weighted prediction
|
||||||
- dialogue enhance audio filter
|
- mjpegdec: support AV_PIX_FMT_YUV420P16 with upscale_h
|
||||||
- dropped obsolete XvMC hwaccel
|
- proresenc_ks: fix buffer overflow
|
||||||
- pcm-bluray encoder
|
- matroskadec: fix crash
|
||||||
- DFPWM audio encoder/decoder and raw muxer/demuxer
|
|
||||||
- SITI filter
|
|
||||||
- Vizrt Binary Image encoder/decoder
|
|
||||||
- avsynctest source filter
|
|
||||||
- feedback video filter
|
|
||||||
- pixelize video filter
|
|
||||||
- colormap video filter
|
|
||||||
- colorchart video source filter
|
|
||||||
- multiply video filter
|
|
||||||
- PGS subtitle frame merge bitstream filter
|
|
||||||
- blurdetect filter
|
|
||||||
- tiltshelf audio filter
|
|
||||||
- QOI image format support
|
|
||||||
- ffprobe -o option
|
|
||||||
- virtualbass audio filter
|
|
||||||
- VDPAU AV1 hwaccel
|
|
||||||
- PHM image format support
|
|
||||||
- remap_opencl filter
|
|
||||||
- added chromakey_cuda filter
|
|
||||||
|
|
||||||
|
version 2.3.2:
|
||||||
|
- snow: fix null pointer dereference
|
||||||
|
- huffyucdec: fix overread
|
||||||
|
- vc1dec: fix crash
|
||||||
|
- iff: fix out of array access
|
||||||
|
- matroskaenc: fix assertion failure
|
||||||
|
- cdgraphics: fix infinite loop
|
||||||
|
- dvdsub_parser: fix infinite loop
|
||||||
|
- mpeg12dec: support decoding some broken files
|
||||||
|
- v4l2enc: fix crash
|
||||||
|
- h264_parser: fix handling huge resolutions
|
||||||
|
- h264_mp4toannexb_bsf: multiple bugfixes
|
||||||
|
|
||||||
version 5.0:
|
version 2.3.1:
|
||||||
- ADPCM IMA Westwood encoder
|
- public AVDCT API/ABI for DCT functions
|
||||||
- Westwood AUD muxer
|
- g2meet: allow size changes within original sizes
|
||||||
- ADPCM IMA Acorn Replay decoder
|
- dv: improved error resilience, fixing Ticket2340 and Ticket2341
|
||||||
- Argonaut Games CVG demuxer
|
|
||||||
- Argonaut Games CVG muxer
|
|
||||||
- Concatf protocol
|
|
||||||
- afwtdn audio filter
|
|
||||||
- audio and video segment filters
|
|
||||||
- Apple Graphics (SMC) encoder
|
|
||||||
- hsvkey and hsvhold video filters
|
|
||||||
- adecorrelate audio filter
|
|
||||||
- atilt audio filter
|
|
||||||
- grayworld video filter
|
|
||||||
- AV1 Low overhead bitstream format muxer
|
|
||||||
- swscale slice threading
|
|
||||||
- MSN Siren decoder
|
|
||||||
- scharr video filter
|
|
||||||
- apsyclip audio filter
|
|
||||||
- morpho video filter
|
|
||||||
- amr parser
|
|
||||||
- (a)latency filters
|
|
||||||
- GEM Raster image decoder
|
|
||||||
- asdr audio filter
|
|
||||||
- speex decoder
|
|
||||||
- limitdiff video filter
|
|
||||||
- xcorrelate video filter
|
|
||||||
- varblur video filter
|
|
||||||
- huesaturation video filter
|
|
||||||
- colorspectrum source video filter
|
|
||||||
- RTP packetizer for uncompressed video (RFC 4175)
|
|
||||||
- bitpacked encoder
|
|
||||||
- VideoToolbox VP9 hwaccel
|
|
||||||
- VideoToolbox ProRes hwaccel
|
|
||||||
- support loongarch.
|
|
||||||
- aspectralstats audio filter
|
|
||||||
- adynamicsmooth audio filter
|
|
||||||
- libplacebo filter
|
|
||||||
- vflip_vulkan, hflip_vulkan and flip_vulkan filters
|
|
||||||
- adynamicequalizer audio filter
|
|
||||||
- yadif_videotoolbox filter
|
|
||||||
- VideoToolbox ProRes encoder
|
|
||||||
- anlmf audio filter
|
|
||||||
- IMF demuxer (experimental)
|
|
||||||
|
|
||||||
|
|
||||||
version 4.4:
|
|
||||||
- AudioToolbox output device
|
|
||||||
- MacCaption demuxer
|
|
||||||
- PGX decoder
|
|
||||||
- chromanr video filter
|
|
||||||
- VDPAU accelerated HEVC 10/12bit decoding
|
|
||||||
- ADPCM IMA Ubisoft APM encoder
|
|
||||||
- Rayman 2 APM muxer
|
|
||||||
- AV1 encoding support SVT-AV1
|
|
||||||
- Cineform HD encoder
|
|
||||||
- ADPCM Argonaut Games encoder
|
|
||||||
- Argonaut Games ASF muxer
|
|
||||||
- AV1 Low overhead bitstream format demuxer
|
|
||||||
- RPZA video encoder
|
|
||||||
- ADPCM IMA MOFLEX decoder
|
|
||||||
- MobiClip FastAudio decoder
|
|
||||||
- MobiClip video decoder
|
|
||||||
- MOFLEX demuxer
|
|
||||||
- MODS demuxer
|
|
||||||
- PhotoCD decoder
|
|
||||||
- MCA demuxer
|
|
||||||
- AV1 decoder (Hardware acceleration used only)
|
|
||||||
- SVS demuxer
|
|
||||||
- Argonaut Games BRP demuxer
|
|
||||||
- DAT demuxer
|
|
||||||
- aax demuxer
|
|
||||||
- IPU decoder, parser and demuxer
|
|
||||||
- Intel QSV-accelerated AV1 decoding
|
|
||||||
- Argonaut Games Video decoder
|
|
||||||
- libwavpack encoder removed
|
|
||||||
- ACE demuxer
|
|
||||||
- AVS3 demuxer
|
|
||||||
- AVS3 video decoder via libuavs3d
|
|
||||||
- Cintel RAW decoder
|
|
||||||
- VDPAU accelerated VP9 10/12bit decoding
|
|
||||||
- afreqshift and aphaseshift filters
|
|
||||||
- High Voltage Software ADPCM encoder
|
|
||||||
- LEGO Racers ALP (.tun & .pcm) muxer
|
|
||||||
- AV1 VAAPI decoder
|
|
||||||
- adenorm filter
|
|
||||||
- ADPCM IMA AMV encoder
|
|
||||||
- AMV muxer
|
|
||||||
- NVDEC AV1 hwaccel
|
|
||||||
- DXVA2/D3D11VA hardware accelerated AV1 decoding
|
|
||||||
- speechnorm filter
|
|
||||||
- SpeedHQ encoder
|
|
||||||
- asupercut filter
|
|
||||||
- asubcut filter
|
|
||||||
- Microsoft Paint (MSP) version 2 decoder
|
|
||||||
- Microsoft Paint (MSP) demuxer
|
|
||||||
- AV1 monochrome encoding support via libaom >= 2.0.1
|
|
||||||
- asuperpass and asuperstop filter
|
|
||||||
- shufflepixels filter
|
|
||||||
- tmidequalizer filter
|
|
||||||
- estdif filter
|
|
||||||
- epx filter
|
|
||||||
- Dolby E parser
|
|
||||||
- shear filter
|
|
||||||
- kirsch filter
|
|
||||||
- colortemperature filter
|
|
||||||
- colorcontrast filter
|
|
||||||
- PFM encoder
|
|
||||||
- colorcorrect filter
|
|
||||||
- binka demuxer
|
|
||||||
- XBM parser
|
|
||||||
- xbm_pipe demuxer
|
|
||||||
- colorize filter
|
|
||||||
- CRI parser
|
|
||||||
- aexciter audio filter
|
|
||||||
- exposure video filter
|
|
||||||
- monochrome video filter
|
|
||||||
- setts bitstream filter
|
|
||||||
- vif video filter
|
|
||||||
- OpenEXR image encoder
|
|
||||||
- Simbiosis IMX decoder
|
|
||||||
- Simbiosis IMX demuxer
|
|
||||||
- Digital Pictures SGA demuxer and decoders
|
|
||||||
- TTML subtitle encoder and muxer
|
|
||||||
- identity video filter
|
|
||||||
- msad video filter
|
|
||||||
- gophers protocol
|
|
||||||
- RIST protocol via librist
|
|
||||||
|
|
||||||
|
|
||||||
version 4.3:
|
|
||||||
- v360 filter
|
|
||||||
- Intel QSV-accelerated MJPEG decoding
|
|
||||||
- Intel QSV-accelerated VP9 decoding
|
|
||||||
- Support for TrueHD in mp4
|
|
||||||
- Support AMD AMF encoder on Linux (via Vulkan)
|
|
||||||
- IMM5 video decoder
|
|
||||||
- ZeroMQ protocol
|
|
||||||
- support Sipro ACELP.KELVIN decoding
|
|
||||||
- streamhash muxer
|
|
||||||
- sierpinski video source
|
|
||||||
- scroll video filter
|
|
||||||
- photosensitivity filter
|
|
||||||
- anlms filter
|
|
||||||
- arnndn filter
|
|
||||||
- bilateral filter
|
|
||||||
- maskedmin and maskedmax filters
|
|
||||||
- VDPAU VP9 hwaccel
|
|
||||||
- median filter
|
|
||||||
- QSV-accelerated VP9 encoding
|
|
||||||
- AV1 encoding support via librav1e
|
|
||||||
- AV1 frame merge bitstream filter
|
|
||||||
- AV1 Annex B demuxer
|
|
||||||
- axcorrelate filter
|
|
||||||
- mvdv decoder
|
|
||||||
- mvha decoder
|
|
||||||
- MPEG-H 3D Audio support in mp4
|
|
||||||
- thistogram filter
|
|
||||||
- freezeframes filter
|
|
||||||
- Argonaut Games ADPCM decoder
|
|
||||||
- Argonaut Games ASF demuxer
|
|
||||||
- xfade video filter
|
|
||||||
- xfade_opencl filter
|
|
||||||
- afirsrc audio filter source
|
|
||||||
- pad_opencl filter
|
|
||||||
- Simon & Schuster Interactive ADPCM decoder
|
|
||||||
- Real War KVAG demuxer
|
|
||||||
- CDToons video decoder
|
|
||||||
- siren audio decoder
|
|
||||||
- Rayman 2 ADPCM decoder
|
|
||||||
- Rayman 2 APM demuxer
|
|
||||||
- cas video filter
|
|
||||||
- High Voltage Software ADPCM decoder
|
|
||||||
- LEGO Racers ALP (.tun & .pcm) demuxer
|
|
||||||
- AMQP 0-9-1 protocol (RabbitMQ)
|
|
||||||
- Vulkan support
|
|
||||||
- avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters
|
|
||||||
- ADPCM IMA MTF decoder
|
|
||||||
- FWSE demuxer
|
|
||||||
- DERF DPCM decoder
|
|
||||||
- DERF demuxer
|
|
||||||
- CRI HCA decoder
|
|
||||||
- CRI HCA demuxer
|
|
||||||
- overlay_cuda filter
|
|
||||||
- switch from AvxSynth to AviSynth+ on Linux
|
|
||||||
- mv30 decoder
|
|
||||||
- Expanded styling support for 3GPP Timed Text Subtitles (movtext)
|
|
||||||
- WebP parser
|
|
||||||
- tmedian filter
|
|
||||||
- maskedthreshold filter
|
|
||||||
- Support for muxing pcm and pgs in m2ts
|
|
||||||
- Cunning Developments ADPCM decoder
|
|
||||||
- asubboost filter
|
|
||||||
- Pro Pinball Series Soundbank demuxer
|
|
||||||
- pcm_rechunk bitstream filter
|
|
||||||
- scdet filter
|
|
||||||
- NotchLC decoder
|
|
||||||
- gradients source video filter
|
|
||||||
- MediaFoundation encoder wrapper
|
|
||||||
- untile filter
|
|
||||||
- Simon & Schuster Interactive ADPCM encoder
|
|
||||||
- PFM decoder
|
|
||||||
- dblur video filter
|
|
||||||
- Real War KVAG muxer
|
|
||||||
|
|
||||||
|
|
||||||
version 4.2:
|
|
||||||
- tpad filter
|
|
||||||
- AV1 decoding support through libdav1d
|
|
||||||
- dedot filter
|
|
||||||
- chromashift and rgbashift filters
|
|
||||||
- freezedetect filter
|
|
||||||
- truehd_core bitstream filter
|
|
||||||
- dhav demuxer
|
|
||||||
- PCM-DVD encoder
|
|
||||||
- GIF parser
|
|
||||||
- vividas demuxer
|
|
||||||
- hymt decoder
|
|
||||||
- anlmdn filter
|
|
||||||
- maskfun filter
|
|
||||||
- hcom demuxer and decoder
|
|
||||||
- ARBC decoder
|
|
||||||
- libaribb24 based ARIB STD-B24 caption support (profiles A and C)
|
|
||||||
- Support decoding of HEVC 4:4:4 content in nvdec and cuviddec
|
|
||||||
- removed libndi-newtek
|
|
||||||
- agm decoder
|
|
||||||
- KUX demuxer
|
|
||||||
- AV1 frame split bitstream filter
|
|
||||||
- lscr decoder
|
|
||||||
- lagfun filter
|
|
||||||
- asoftclip filter
|
|
||||||
- Support decoding of HEVC 4:4:4 content in vdpau
|
|
||||||
- colorhold filter
|
|
||||||
- xmedian filter
|
|
||||||
- asr filter
|
|
||||||
- showspatial multimedia filter
|
|
||||||
- VP4 video decoder
|
|
||||||
- IFV demuxer
|
|
||||||
- derain filter
|
|
||||||
- deesser filter
|
|
||||||
- mov muxer writes tracks with unspecified language instead of English by default
|
|
||||||
- add support for using clang to compile CUDA kernels
|
|
||||||
|
|
||||||
|
|
||||||
version 4.1:
|
|
||||||
- deblock filter
|
|
||||||
- tmix filter
|
|
||||||
- amplify filter
|
|
||||||
- fftdnoiz filter
|
|
||||||
- aderivative and aintegral audio filters
|
|
||||||
- pal75bars and pal100bars video filter sources
|
|
||||||
- support mbedTLS based TLS
|
|
||||||
- adeclick filter
|
|
||||||
- adeclip filter
|
|
||||||
- libtensorflow backend for DNN based filters like srcnn
|
|
||||||
- vc1 decoder is now bit-exact
|
|
||||||
- ATRAC9 decoder
|
|
||||||
- lensfun wrapper filter
|
|
||||||
- colorconstancy filter
|
|
||||||
- AVS2 video decoder via libdavs2
|
|
||||||
- IMM4 video decoder
|
|
||||||
- Brooktree ProSumer video decoder
|
|
||||||
- MatchWare Screen Capture Codec decoder
|
|
||||||
- WinCam Motion Video decoder
|
|
||||||
- 1D LUT filter (lut1d)
|
|
||||||
- RemotelyAnywhere Screen Capture decoder
|
|
||||||
- cue and acue filters
|
|
||||||
- support for AV1 in MP4
|
|
||||||
- transpose_npp filter
|
|
||||||
- AVS2 video encoder via libxavs2
|
|
||||||
- amultiply filter
|
|
||||||
- Block-Matching 3d (bm3d) denoising filter
|
|
||||||
- acrossover filter
|
|
||||||
- ilbc decoder
|
|
||||||
- audio denoiser as afftdn filter
|
|
||||||
- AV1 parser
|
|
||||||
- SER demuxer
|
|
||||||
- sinc audio filter source
|
|
||||||
- chromahold filter
|
|
||||||
- setparams filter
|
|
||||||
- vibrance filter
|
|
||||||
- decoding S12M timecode in h264
|
|
||||||
- xstack filter
|
|
||||||
- pcm vidc decoder and encoder
|
|
||||||
- (a)graphmonitor filter
|
|
||||||
- yadif_cuda filter
|
|
||||||
|
|
||||||
|
|
||||||
version 4.0:
|
|
||||||
- Bitstream filters for editing metadata in H.264, HEVC and MPEG-2 streams
|
|
||||||
- Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
|
|
||||||
requires 2.1 (or later) and pkg-config.
|
|
||||||
- VDA dropped (use VideoToolbox instead)
|
|
||||||
- MagicYUV encoder
|
|
||||||
- Raw AMR-NB and AMR-WB demuxers
|
|
||||||
- TiVo ty/ty+ demuxer
|
|
||||||
- Intel QSV-accelerated MJPEG encoding
|
|
||||||
- PCE support for extended channel layouts in the AAC encoder
|
|
||||||
- native aptX and aptX HD encoder and decoder
|
|
||||||
- Raw aptX and aptX HD muxer and demuxer
|
|
||||||
- NVIDIA NVDEC-accelerated H.264, HEVC, MJPEG, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding
|
|
||||||
- Intel QSV-accelerated overlay filter
|
|
||||||
- mcompand audio filter
|
|
||||||
- acontrast audio filter
|
|
||||||
- OpenCL overlay filter
|
|
||||||
- video mix filter
|
|
||||||
- video normalize filter
|
|
||||||
- audio lv2 wrapper filter
|
|
||||||
- VAAPI MJPEG and VP8 decoding
|
|
||||||
- AMD AMF H.264 and HEVC encoders
|
|
||||||
- video fillborders filter
|
|
||||||
- video setrange filter
|
|
||||||
- nsp demuxer
|
|
||||||
- support LibreSSL (via libtls)
|
|
||||||
- AVX-512/ZMM support added
|
|
||||||
- Dropped support for building for Windows XP. The minimum supported Windows
|
|
||||||
version is Windows Vista.
|
|
||||||
- deconvolve video filter
|
|
||||||
- entropy video filter
|
|
||||||
- hilbert audio filter source
|
|
||||||
- aiir audio filter
|
|
||||||
- aiff: add support for CD-ROM XA ADPCM
|
|
||||||
- Removed the ffserver program
|
|
||||||
- Removed the ffmenc and ffmdec muxer and demuxer
|
|
||||||
- VideoToolbox HEVC encoder and hwaccel
|
|
||||||
- VAAPI-accelerated ProcAmp (color balance), denoise and sharpness filters
|
|
||||||
- Add android_camera indev
|
|
||||||
- codec2 en/decoding via libcodec2
|
|
||||||
- muxer/demuxer for raw codec2 files and .c2 files
|
|
||||||
- Moved nvidia codec headers into an external repository.
|
|
||||||
They can be found at http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git
|
|
||||||
- native SBC encoder and decoder
|
|
||||||
- drmeter audio filter
|
|
||||||
- hapqa_extract bitstream filter
|
|
||||||
- filter_units bitstream filter
|
|
||||||
- AV1 Support through libaom
|
|
||||||
- E-AC-3 dependent frames support
|
|
||||||
- bitstream filter for extracting E-AC-3 core
|
|
||||||
- Haivision SRT protocol via libsrt
|
|
||||||
- segafilm muxer
|
|
||||||
- vfrdet filter
|
|
||||||
- SRCNN filter
|
|
||||||
|
|
||||||
|
|
||||||
version 3.4:
|
|
||||||
- deflicker video filter
|
|
||||||
- doubleweave video filter
|
|
||||||
- lumakey video filter
|
|
||||||
- pixscope video filter
|
|
||||||
- oscilloscope video filter
|
|
||||||
- config.log and other configuration files moved into ffbuild/ directory
|
|
||||||
- update cuvid/nvenc headers to Video Codec SDK 8.0.14
|
|
||||||
- afir audio filter
|
|
||||||
- scale_cuda CUDA based video scale filter
|
|
||||||
- librsvg support for svg rasterization
|
|
||||||
- crossfeed audio filter
|
|
||||||
- spec compliant VP9 muxing support in MP4
|
|
||||||
- remove the libnut muxer/demuxer wrappers
|
|
||||||
- remove the libschroedinger encoder/decoder wrappers
|
|
||||||
- surround audio filter
|
|
||||||
- sofalizer filter switched to libmysofa
|
|
||||||
- Gremlin Digital Video demuxer and decoder
|
|
||||||
- headphone audio filter
|
|
||||||
- superequalizer audio filter
|
|
||||||
- roberts video filter
|
|
||||||
- The x86 assembler default switched from yasm to nasm, pass
|
|
||||||
--x86asmexe=yasm to configure to restore the old behavior.
|
|
||||||
- additional frame format support for Interplay MVE movies
|
|
||||||
- support for decoding through D3D11VA in ffmpeg
|
|
||||||
- limiter video filter
|
|
||||||
- libvmaf video filter
|
|
||||||
- Dolby E decoder and SMPTE 337M demuxer
|
|
||||||
- unpremultiply video filter
|
|
||||||
- tlut2 video filter
|
|
||||||
- floodfill video filter
|
|
||||||
- pseudocolor video filter
|
|
||||||
- raw G.726 muxer and demuxer, left- and right-justified
|
|
||||||
- NewTek NDI input/output device
|
|
||||||
- Some video filters with several inputs now use a common set of options:
|
|
||||||
blend, libvmaf, lut3d, overlay, psnr, ssim.
|
|
||||||
They must always be used by name.
|
|
||||||
- FITS demuxer and decoder
|
|
||||||
- FITS muxer and encoder
|
|
||||||
- add --disable-autodetect build switch
|
|
||||||
- drop deprecated qtkit input device (use avfoundation instead)
|
|
||||||
- despill video filter
|
|
||||||
- haas audio filter
|
|
||||||
- SUP/PGS subtitle muxer
|
|
||||||
- convolve video filter
|
|
||||||
- VP9 tile threading support
|
|
||||||
- KMS screen grabber
|
|
||||||
- CUDA thumbnail filter
|
|
||||||
- V4L2 mem2mem HW assisted codecs
|
|
||||||
- Rockchip MPP hardware decoding
|
|
||||||
- vmafmotion video filter
|
|
||||||
- use MIME type "G726" for little-endian G.726, "AAL2-G726" for big-endian G.726
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
- VAAPI-accelerated deinterlacing
|
|
||||||
|
|
||||||
|
|
||||||
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:
|
version 2.3:
|
||||||
- AC3 fixed-point decoding
|
- AC3 fixed-point decoding
|
||||||
@@ -780,7 +48,7 @@ version 2.3:
|
|||||||
- libbs2b-based stereo-to-binaural audio filter
|
- libbs2b-based stereo-to-binaural audio filter
|
||||||
- libx264 reference frames count limiting depending on level
|
- libx264 reference frames count limiting depending on level
|
||||||
- native Opus decoder
|
- native Opus decoder
|
||||||
- display matrix export and rotation API
|
- display matrix export and rotation api
|
||||||
- WebVTT encoder
|
- WebVTT encoder
|
||||||
- showcqt multimedia filter
|
- showcqt multimedia filter
|
||||||
- zoompan filter
|
- zoompan filter
|
||||||
@@ -822,7 +90,6 @@ version 2.2:
|
|||||||
- libx265 encoder
|
- libx265 encoder
|
||||||
- dejudder filter
|
- dejudder filter
|
||||||
- Autodetect VDA like all other hardware accelerations
|
- Autodetect VDA like all other hardware accelerations
|
||||||
- aliases and defaults for Ogg subtypes (opus, spx)
|
|
||||||
|
|
||||||
|
|
||||||
version 2.1:
|
version 2.1:
|
||||||
@@ -1229,7 +496,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
|
||||||
@@ -1418,8 +685,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
|
||||||
@@ -1712,7 +979,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
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
## Installing FFmpeg
|
#Installing FFmpeg:
|
||||||
|
|
||||||
1. Type `./configure` to create the configuration. A list of configure
|
1. Type `./configure` to create the configuration. A list of configure
|
||||||
options is printed by running `configure --help`.
|
options is printed by running `configure --help`.
|
||||||
|
|||||||
166
LICENSE.md
166
LICENSE.md
@@ -1,129 +1,103 @@
|
|||||||
# License
|
#FFmpeg:
|
||||||
|
|
||||||
Most files in FFmpeg are under the GNU Lesser General Public License version 2.1
|
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
|
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
|
files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to
|
||||||
FFmpeg.
|
FFmpeg.
|
||||||
|
|
||||||
Some optional parts of FFmpeg are licensed under the GNU General Public License
|
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
|
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
|
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+.
|
configure to activate them. In this case, FFmpeg's license changes to GPL v2+.
|
||||||
|
|
||||||
Specifically, the GPL parts of FFmpeg are:
|
Specifically, the GPL parts of FFmpeg are:
|
||||||
|
|
||||||
- libpostproc
|
- libpostproc
|
||||||
- optional x86 optimization in the files
|
- libmpcodecs
|
||||||
- `libavcodec/x86/flac_dsp_gpl.asm`
|
- optional x86 optimizations in the files
|
||||||
- `libavcodec/x86/idct_mmx.c`
|
libavcodec/x86/idct_mmx.c
|
||||||
- `libavfilter/x86/vf_removegrain.asm`
|
- libutvideo encoding/decoding wrappers in
|
||||||
- the following building and testing tools
|
libavcodec/libutvideo*.cpp
|
||||||
- `compat/solaris/make_sunver.pl`
|
- the X11 grabber in libavdevice/x11grab.c
|
||||||
- `doc/t2h.pm`
|
- the swresample test app in
|
||||||
- `doc/texi2pod.pl`
|
libswresample/swresample-test.c
|
||||||
- `libswresample/tests/swresample.c`
|
- the texi2pod.pl tool
|
||||||
- `tests/checkasm/*`
|
|
||||||
- `tests/tiny_ssim.c`
|
|
||||||
- the following filters in libavfilter:
|
- the following filters in libavfilter:
|
||||||
- `signature_lookup.c`
|
- f_ebur128.c
|
||||||
- `vf_blackframe.c`
|
- vf_blackframe.c
|
||||||
- `vf_boxblur.c`
|
- vf_boxblur.c
|
||||||
- `vf_colormatrix.c`
|
- vf_colormatrix.c
|
||||||
- `vf_cover_rect.c`
|
- vf_cropdetect.c
|
||||||
- `vf_cropdetect.c`
|
- vf_decimate.c
|
||||||
- `vf_delogo.c`
|
- vf_delogo.c
|
||||||
- `vf_eq.c`
|
- vf_geq.c
|
||||||
- `vf_find_rect.c`
|
- vf_histeq.c
|
||||||
- `vf_fspp.c`
|
- vf_hqdn3d.c
|
||||||
- `vf_histeq.c`
|
- vf_kerndeint.c
|
||||||
- `vf_hqdn3d.c`
|
- vf_mcdeint.c
|
||||||
- `vf_kerndeint.c`
|
- vf_mp.c
|
||||||
- `vf_lensfun.c` (GPL version 3 or later)
|
- vf_owdenoise.c
|
||||||
- `vf_mcdeint.c`
|
- vf_perspective.c
|
||||||
- `vf_mpdecimate.c`
|
- vf_phase.c
|
||||||
- `vf_nnedi.c`
|
- vf_pp.c
|
||||||
- `vf_owdenoise.c`
|
- vf_pullup.c
|
||||||
- `vf_perspective.c`
|
- vf_sab.c
|
||||||
- `vf_phase.c`
|
- vf_smartblur.c
|
||||||
- `vf_pp.c`
|
- vf_spp.c
|
||||||
- `vf_pp7.c`
|
- vf_stereo3d.c
|
||||||
- `vf_pullup.c`
|
- vf_super2xsai.c
|
||||||
- `vf_repeatfields.c`
|
- vf_tinterlace.c
|
||||||
- `vf_sab.c`
|
- vsrc_mptestsrc.c
|
||||||
- `vf_signature.c`
|
|
||||||
- `vf_smartblur.c`
|
|
||||||
- `vf_spp.c`
|
|
||||||
- `vf_stereo3d.c`
|
|
||||||
- `vf_super2xsai.c`
|
|
||||||
- `vf_tinterlace.c`
|
|
||||||
- `vf_uspp.c`
|
|
||||||
- `vf_vaguedenoiser.c`
|
|
||||||
- `vsrc_mptestsrc.c`
|
|
||||||
|
|
||||||
Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then
|
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
|
the configure parameter --enable-version3 will activate this licensing option
|
||||||
for you. Read the file `COPYING.LGPLv3` or, if you have enabled GPL parts,
|
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.
|
COPYING.GPLv3 to learn the exact legal terms that apply in this case.
|
||||||
|
|
||||||
There are a handful of files under other licensing terms, namely:
|
There are a handful of files under other licensing terms, namely:
|
||||||
|
|
||||||
* The files `libavcodec/jfdctfst.c`, `libavcodec/jfdctint_template.c` and
|
* The files libavcodec/jfdctfst.c, libavcodec/jfdctint_template.c and
|
||||||
`libavcodec/jrevdct.c` are taken from libjpeg, see the top of the files for
|
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
|
licensing details. Specifically note that you must credit the IJG in the
|
||||||
documentation accompanying your program if you only distribute executables.
|
documentation accompanying your program if you only distribute executables.
|
||||||
You must also indicate any changes including additions and deletions to
|
You must also indicate any changes including additions and deletions to
|
||||||
those three files in the documentation.
|
those three files in the documentation.
|
||||||
* `tests/reference.pnm` is under the expat license.
|
|
||||||
|
|
||||||
|
|
||||||
## External libraries
|
external libraries
|
||||||
|
==================
|
||||||
|
|
||||||
FFmpeg can be combined with a number of external libraries, which sometimes
|
FFmpeg can be combined with a number of external libraries, which sometimes
|
||||||
affect the licensing of binaries resulting from the combination.
|
affect the licensing of binaries resulting from the combination.
|
||||||
|
|
||||||
### Compatible libraries
|
compatible libraries
|
||||||
|
--------------------
|
||||||
The following libraries are under GPL version 2:
|
|
||||||
- avisynth
|
|
||||||
- frei0r
|
|
||||||
- libcdio
|
|
||||||
- libdavs2
|
|
||||||
- librubberband
|
|
||||||
- libvidstab
|
|
||||||
- libx264
|
|
||||||
- libx265
|
|
||||||
- libxavs
|
|
||||||
- libxavs2
|
|
||||||
- libxvid
|
|
||||||
|
|
||||||
|
The following libraries are under GPL:
|
||||||
|
- frei0r
|
||||||
|
- libcdio
|
||||||
|
- libutvideo
|
||||||
|
- libvidstab
|
||||||
|
- libx264
|
||||||
|
- libx265
|
||||||
|
- libxavs
|
||||||
|
- libxvid
|
||||||
When combining them with FFmpeg, FFmpeg needs to be licensed as GPL as well by
|
When combining them with FFmpeg, FFmpeg needs to be licensed as GPL as well by
|
||||||
passing `--enable-gpl` to configure.
|
passing --enable-gpl to configure.
|
||||||
|
|
||||||
The following libraries are under LGPL version 3:
|
The OpenCORE and VisualOn libraries are under the Apache License 2.0. That
|
||||||
- gmp
|
license is incompatible with the LGPL v2.1 and the GPL v2, but not with
|
||||||
- libaribb24
|
|
||||||
- liblensfun
|
|
||||||
|
|
||||||
When combining them with FFmpeg, use the configure option `--enable-version3` to
|
|
||||||
upgrade FFmpeg to the LGPL v3.
|
|
||||||
|
|
||||||
The VMAF, mbedTLS, RK MPI, 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
|
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.
|
license version needs to be upgraded by passing --enable-version3 to configure.
|
||||||
|
|
||||||
The smbclient library is under the GPL v3, to combine it with FFmpeg,
|
incompatible libraries
|
||||||
the options `--enable-gpl` and `--enable-version3` have to be passed to
|
----------------------
|
||||||
configure to upgrade FFmpeg to the GPL v3.
|
|
||||||
|
|
||||||
### 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
|
||||||
There are certain libraries you can combine with FFmpeg whose licenses are not
|
licenses are compatible with the LGPL.
|
||||||
compatible with the GPL and/or the LGPL. If you wish to enable these
|
If you wish to enable these libraries, pass --enable-nonfree to configure.
|
||||||
libraries, even in circumstances that their license may be incompatible, pass
|
But note that if you enable any of these libraries the resulting binary will
|
||||||
`--enable-nonfree` to configure. This will cause the resulting binary to be
|
be under a complex license mix that is more restrictive than the LGPL and that
|
||||||
unredistributable.
|
may result in additional obligations. It is possible that these
|
||||||
|
restrictions cause the resulting binary to be unredistributeable.
|
||||||
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.
|
|
||||||
|
|||||||
318
MAINTAINERS
318
MAINTAINERS
@@ -14,6 +14,7 @@ patches and related discussions.
|
|||||||
Project Leader
|
Project Leader
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
Michael Niedermayer
|
||||||
final design decisions
|
final design decisions
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +30,9 @@ ffplay:
|
|||||||
ffprobe:
|
ffprobe:
|
||||||
ffprobe.c Stefano Sabatini
|
ffprobe.c Stefano Sabatini
|
||||||
|
|
||||||
|
ffserver:
|
||||||
|
ffserver.c Reynaldo H. Verdejo Pinochet
|
||||||
|
|
||||||
Commandline utility code:
|
Commandline utility code:
|
||||||
cmdutils.c, cmdutils.h Michael Niedermayer
|
cmdutils.c, cmdutils.h Michael Niedermayer
|
||||||
|
|
||||||
@@ -39,25 +43,24 @@ QuickTime faststart:
|
|||||||
Miscellaneous Areas
|
Miscellaneous Areas
|
||||||
===================
|
===================
|
||||||
|
|
||||||
documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Gyan Doshi
|
documentation Stefano Sabatini, Mike Melanson, Timothy Gu
|
||||||
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser, Nikolay Aleksandrov
|
build system (configure, makefiles) Diego Biurrun, Mans Rullgard
|
||||||
|
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser
|
||||||
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
|
Communication
|
||||||
=============
|
=============
|
||||||
|
|
||||||
website Deby Barbara Lepage
|
website Robert Swain
|
||||||
fate.ffmpeg.org Timothy Gu
|
fate.ffmpeg.org Timothy Gu
|
||||||
Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos
|
Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos, Lou Logan
|
||||||
Patchwork Andriy Gelman
|
mailing lists Michael Niedermayer, Baptiste Coudurier, Lou Logan
|
||||||
mailing lists Baptiste Coudurier
|
Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser
|
||||||
Twitter Reynaldo H. Verdejo Pinochet
|
Twitter Lou Logan
|
||||||
Launchpad Timothy Gu
|
Launchpad Timothy Gu
|
||||||
ffmpeg-security Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, rcombs, wm4
|
|
||||||
|
|
||||||
|
|
||||||
libavutil
|
libavutil
|
||||||
@@ -69,7 +72,6 @@ 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
|
bprint Nicolas George
|
||||||
bswap.h
|
bswap.h
|
||||||
des Reimar Doeffinger
|
des Reimar Doeffinger
|
||||||
@@ -77,8 +79,6 @@ Other:
|
|||||||
eval.c, eval.h Michael Niedermayer
|
eval.c, eval.h Michael Niedermayer
|
||||||
float_dsp Loren Merritt
|
float_dsp Loren Merritt
|
||||||
hash Reimar Doeffinger
|
hash Reimar Doeffinger
|
||||||
hwcontext_cuda* Timo Rothenpieler
|
|
||||||
hwcontext_vulkan* Lynne
|
|
||||||
intfloat* Michael Niedermayer
|
intfloat* Michael Niedermayer
|
||||||
integer.c, integer.h Michael Niedermayer
|
integer.c, integer.h Michael Niedermayer
|
||||||
lzo Reimar Doeffinger
|
lzo Reimar Doeffinger
|
||||||
@@ -89,7 +89,7 @@ Other:
|
|||||||
rational.c, rational.h Michael Niedermayer
|
rational.c, rational.h Michael Niedermayer
|
||||||
rc4 Reimar Doeffinger
|
rc4 Reimar Doeffinger
|
||||||
ripemd.c, ripemd.h James Almer
|
ripemd.c, ripemd.h James Almer
|
||||||
tx* Lynne
|
timecode Clément Bœsch
|
||||||
|
|
||||||
|
|
||||||
libavcodec
|
libavcodec
|
||||||
@@ -115,14 +115,15 @@ 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:
|
||||||
ratecontrol.c Michael Niedermayer
|
ratecontrol.c Michael Niedermayer
|
||||||
|
libxvid_rc.c Michael Niedermayer
|
||||||
simple IDCT:
|
simple IDCT:
|
||||||
simple_idct.c, simple_idct.h Michael Niedermayer
|
simple_idct.c, simple_idct.h Michael Niedermayer
|
||||||
postprocessing:
|
postprocessing:
|
||||||
@@ -137,44 +138,43 @@ 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
|
||||||
adpcm.c Zane van Iperen
|
ac3* Justin Ruggles
|
||||||
alacenc.c Jaikrishnan Menon
|
alacenc.c Jaikrishnan Menon
|
||||||
alsdec.c Thilo Borgmann, Umair Khan
|
alsdec.c Thilo Borgmann
|
||||||
aptx.c Aurelien Jacobs
|
apedec.c Kostya Shishkov
|
||||||
ass* Aurelien Jacobs
|
ass* Aurelien Jacobs
|
||||||
asv* Michael Niedermayer
|
asv* Michael Niedermayer
|
||||||
|
atrac3* Benjamin Larsson
|
||||||
atrac3plus* Maxim Poliakovski
|
atrac3plus* Maxim Poliakovski
|
||||||
audiotoolbox* rcombs
|
|
||||||
avs2* Huiwen Ren
|
|
||||||
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
|
cdxl.c Paul B Mahol
|
||||||
celp_filters.* Vitor Sessak
|
celp_filters.* Vitor Sessak
|
||||||
cinepak.c Roberto Togni
|
cinepak.c Roberto Togni
|
||||||
cinepakenc.c Rl / Aetey G.T. AB
|
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
|
||||||
cuviddec.c Timo Rothenpieler
|
dca.c Kostya Shishkov, Benjamin Larsson
|
||||||
dca* foo86
|
|
||||||
dfpwm* Jack Bruienne
|
|
||||||
dirac* Rostislav Pehlivanov
|
|
||||||
dnxhd* Baptiste Coudurier
|
dnxhd* Baptiste Coudurier
|
||||||
dolby_e* foo86
|
|
||||||
dpcm.c Mike Melanson
|
dpcm.c Mike Melanson
|
||||||
dss_sp.c Oleksij Rempel
|
|
||||||
dv.c Roman Shaposhnik
|
dv.c Roman Shaposhnik
|
||||||
dvbsubdec.c Anshul Maheshwari
|
dvbsubdec.c Anshul Maheshwari
|
||||||
|
dxa.c Kostya Shishkov
|
||||||
eacmv*, eaidct*, eat* Peter Ross
|
eacmv*, eaidct*, eat* Peter Ross
|
||||||
evrc* Paul B Mahol
|
|
||||||
exif.c, exif.h Thilo Borgmann
|
exif.c, exif.h Thilo Borgmann
|
||||||
ffv1* Michael Niedermayer
|
ffv1* Michael Niedermayer
|
||||||
ffwavesynth.c Nicolas George
|
ffwavesynth.c Nicolas George
|
||||||
fifo.c Jan Sebechlebsky
|
fic.c Derek Buitenhuis
|
||||||
|
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
|
||||||
@@ -182,53 +182,58 @@ Codecs:
|
|||||||
h261* Michael Niedermayer
|
h261* Michael Niedermayer
|
||||||
h263* Michael Niedermayer
|
h263* Michael Niedermayer
|
||||||
h264* Loren Merritt, Michael Niedermayer
|
h264* Loren Merritt, Michael Niedermayer
|
||||||
hap* Tom Butterworth
|
huffyuv* Michael Niedermayer, Christophe Gisquet
|
||||||
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
|
||||||
|
jacosub* Clément Bœsch
|
||||||
jpeg2000* Nicolas Bertrand
|
jpeg2000* Nicolas Bertrand
|
||||||
|
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
|
||||||
libcodec2.c Tomas Härdin
|
|
||||||
libdirac* David Conrad
|
libdirac* David Conrad
|
||||||
libdavs2.c Huiwen Ren
|
|
||||||
libjxl*.c, libjxl.h Leo Izen
|
|
||||||
libgsm.c Michel Bardiaux
|
libgsm.c Michel Bardiaux
|
||||||
libkvazaar.c Arttu Ylä-Outinen
|
|
||||||
libopenh264enc.c Martin Storsjo, Linjie Fu
|
|
||||||
libopenjpeg.c Jaikrishnan Menon
|
libopenjpeg.c Jaikrishnan Menon
|
||||||
libopenjpegenc.c Michael Bradshaw
|
libopenjpegenc.c Michael Bradshaw
|
||||||
|
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
|
libvpx* James Zern
|
||||||
|
libx264.c Mans Rullgard, Jason Garrett-Glaser
|
||||||
|
libx265.c Derek Buitenhuis
|
||||||
libxavs.c Stefan Gehrer
|
libxavs.c Stefan Gehrer
|
||||||
libxavs2.c Huiwen Ren
|
|
||||||
libzvbi-teletextdec.c Marton Balint
|
libzvbi-teletextdec.c Marton Balint
|
||||||
|
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
|
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
|
||||||
nvdec*, nvenc* Timo Rothenpieler
|
|
||||||
omx.c Martin Storsjo, Aman Gupta
|
|
||||||
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, Zhong Li, Haihao Xiang
|
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
|
||||||
@@ -236,49 +241,65 @@ 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, Christophe Gisquet
|
||||||
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* Michael Niedermayer, Loren Merritt
|
snow* Michael Niedermayer, Loren Merritt
|
||||||
sonic.c Alex Beregszaszi
|
sonic.c Alex Beregszaszi
|
||||||
speedhq.c Steinar H. Gunderson
|
|
||||||
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
|
ttaenc.c Paul B Mahol
|
||||||
txd.c Ivo van Poorten
|
txd.c Ivo van Poorten
|
||||||
v4l2_* Jorge Ramirez-Ortiz
|
ulti* Kostya Shishkov
|
||||||
vc2* Rostislav Pehlivanov
|
v410*.c Derek Buitenhuis
|
||||||
|
vb.c Kostya Shishkov
|
||||||
|
vble.c Derek Buitenhuis
|
||||||
|
vc1* Kostya Shishkov, Christophe Gisquet
|
||||||
vcr1.c Michael Niedermayer
|
vcr1.c Michael Niedermayer
|
||||||
videotoolboxenc.c Rick Kern, Aman Gupta
|
vda_h264_dec.c Xidorn Quan
|
||||||
vima.c Paul B Mahol
|
vima.c Paul B Mahol
|
||||||
|
vmnc.c Kostya Shishkov
|
||||||
vorbisdec.c Denes Balatoni, David Conrad
|
vorbisdec.c Denes Balatoni, David Conrad
|
||||||
vorbisenc.c Oded Shimon
|
vorbisenc.c Oded Shimon
|
||||||
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
|
vp9 Ronald Bultje, Clément Bœsch
|
||||||
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
|
xface Stefano Sabatini
|
||||||
|
xl.c Kostya Shishkov
|
||||||
|
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, Aman Gupta
|
vaapi* Gwenole Beauchesne
|
||||||
vaapi* Haihao Xiang
|
vda* Sebastien Zwickert
|
||||||
vaapi_encode* Mark Thompson, Haihao Xiang
|
vdpau* Carl Eugen Hoyos
|
||||||
vdpau* Philip Langdale, Carl Eugen Hoyos
|
|
||||||
videotoolbox* Rick Kern, Aman Gupta
|
|
||||||
|
|
||||||
|
|
||||||
libavdevice
|
libavdevice
|
||||||
@@ -288,8 +309,6 @@ libavdevice
|
|||||||
|
|
||||||
|
|
||||||
avfoundation.m Thilo Borgmann
|
avfoundation.m Thilo Borgmann
|
||||||
android_camera.c Felix Matouschek
|
|
||||||
decklink* Marton Balint
|
|
||||||
dshow.c Roger Pack (CC rogerdpack@gmail.com)
|
dshow.c Roger Pack (CC rogerdpack@gmail.com)
|
||||||
fbdev_enc.c Lukasz Marek
|
fbdev_enc.c Lukasz Marek
|
||||||
gdigrab.c Roger Pack (CC rogerdpack@gmail.com)
|
gdigrab.c Roger Pack (CC rogerdpack@gmail.com)
|
||||||
@@ -298,9 +317,9 @@ libavdevice
|
|||||||
libdc1394.c Roman Shaposhnik
|
libdc1394.c Roman Shaposhnik
|
||||||
opengl_enc.c Lukasz Marek
|
opengl_enc.c Lukasz Marek
|
||||||
pulse_audio_enc.c Lukasz Marek
|
pulse_audio_enc.c Lukasz Marek
|
||||||
|
qtkit.m Thilo Borgmann
|
||||||
sdl Stefano Sabatini
|
sdl Stefano Sabatini
|
||||||
sdl2.c Josh de Kock
|
v4l2.c Luca Abeni
|
||||||
v4l2.c Giorgio Vazzana
|
|
||||||
vfwcap.c Ramiro Polla
|
vfwcap.c Ramiro Polla
|
||||||
xv.c Lukasz Marek
|
xv.c Lukasz Marek
|
||||||
|
|
||||||
@@ -310,10 +329,7 @@ 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_adelay.c Paul B Mahol
|
||||||
af_aecho.c Paul B Mahol
|
af_aecho.c Paul B Mahol
|
||||||
af_afade.c Paul B Mahol
|
af_afade.c Paul B Mahol
|
||||||
@@ -321,62 +337,34 @@ Filters:
|
|||||||
af_aphaser.c Paul B Mahol
|
af_aphaser.c Paul B Mahol
|
||||||
af_aresample.c Michael Niedermayer
|
af_aresample.c Michael Niedermayer
|
||||||
af_astats.c Paul B Mahol
|
af_astats.c Paul B Mahol
|
||||||
|
af_astreamsync.c Nicolas George
|
||||||
af_atempo.c Pavel Koshevoy
|
af_atempo.c Pavel Koshevoy
|
||||||
af_biquads.c Paul B Mahol
|
af_biquads.c Paul B Mahol
|
||||||
af_chorus.c Paul B Mahol
|
|
||||||
af_compand.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_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_avectorscope.c Paul B Mahol
|
||||||
avf_showcqt.c Muhammad Faiz
|
avf_showcqt.c Muhammad Faiz
|
||||||
vf_blend.c Paul B Mahol
|
vf_blend.c Paul B Mahol
|
||||||
vf_bwdif Thomas Mundt (CC <thomas.mundt@hr.de>)
|
|
||||||
vf_chromakey.c Timo Rothenpieler
|
|
||||||
vf_colorchannelmixer.c Paul B Mahol
|
|
||||||
vf_colorconstancy.c Mina Sami (CC <minas.gorgy@gmail.com>)
|
|
||||||
vf_colorbalance.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_dejudder.c Nicholas Robbins
|
||||||
vf_delogo.c Jean Delvare (CC <jdelvare@suse.com>)
|
vf_delogo.c Jean Delvare (CC <khali@linux-fr.org>)
|
||||||
vf_drawbox.c/drawgrid Andrey Utkin
|
vf_drawbox.c/drawgrid Andrey Utkin
|
||||||
vf_extractplanes.c Paul B Mahol
|
vf_extractplanes.c Paul B Mahol
|
||||||
vf_histogram.c Paul B Mahol
|
vf_histogram.c Paul B Mahol
|
||||||
vf_hqx.c Clément Bœsch
|
vf_hqx.c Clément Bœsch
|
||||||
vf_idet.c Pascal Massimino
|
|
||||||
vf_il.c Paul B Mahol
|
vf_il.c Paul B Mahol
|
||||||
vf_(t)interlace Thomas Mundt (CC <thomas.mundt@hr.de>)
|
|
||||||
vf_lenscorrection.c Daniel Oberhoff
|
|
||||||
vf_libplacebo.c Niklas Haas
|
|
||||||
vf_mergeplanes.c Paul B Mahol
|
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_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_scale.c Michael Niedermayer
|
||||||
vf_separatefields.c Paul B Mahol
|
vf_separatefields.c Paul B Mahol
|
||||||
vf_ssim.c Paul B Mahol
|
|
||||||
vf_stereo3d.c Paul B Mahol
|
vf_stereo3d.c Paul B Mahol
|
||||||
vf_telecine.c Paul B Mahol
|
vf_telecine.c Paul B Mahol
|
||||||
vf_tonemap_opencl.c Ruiling Song
|
|
||||||
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
|
||||||
|
|
||||||
dnn Yejun Guo
|
|
||||||
|
|
||||||
libavformat
|
libavformat
|
||||||
===========
|
===========
|
||||||
|
|
||||||
@@ -385,53 +373,39 @@ 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
|
aiffdec.c Baptiste Coudurier, Matthieu Bouron
|
||||||
aiffenc.c Baptiste Coudurier, Matthieu Bouron
|
aiffenc.c Baptiste Coudurier, Matthieu Bouron
|
||||||
alp.c Zane van Iperen
|
ape.c Kostya Shishkov
|
||||||
amvenc.c Zane van Iperen
|
|
||||||
apm.c Zane van Iperen
|
|
||||||
apngdec.c Benoit Fouet
|
|
||||||
argo_asf.c Zane van Iperen
|
|
||||||
argo_brp.c Zane van Iperen
|
|
||||||
argo_cvg.c Zane van Iperen
|
|
||||||
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
|
avisynth.c AvxSynth Team (avxsynth.testing at gmail dot com)
|
||||||
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
|
||||||
codec2.c Tomas Härdin
|
|
||||||
crc.c Michael Niedermayer
|
crc.c Michael Niedermayer
|
||||||
dashdec.c Steven Liu
|
|
||||||
dashenc.c Karthick Jeyapal
|
|
||||||
daud.c Reimar Doeffinger
|
daud.c Reimar Doeffinger
|
||||||
dfpwmdec.c Jack Bruienne
|
|
||||||
dss.c Oleksij Rempel
|
|
||||||
dtsdec.c foo86
|
|
||||||
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
|
||||||
hlsenc.c Christian Suloway, Steven Liu
|
hls.c Anssi Hannula
|
||||||
idcin.c Mike Melanson
|
idcin.c Mike Melanson
|
||||||
idroqdec.c Mike Melanson
|
idroqdec.c Mike Melanson
|
||||||
iff.c Jaikrishnan Menon
|
iff.c Jaikrishnan Menon
|
||||||
@@ -439,32 +413,32 @@ Muxers/Demuxers:
|
|||||||
ipmovie.c Mike Melanson
|
ipmovie.c Mike Melanson
|
||||||
ircam* Paul B Mahol
|
ircam* Paul B Mahol
|
||||||
iss.c Stefan Gehrer
|
iss.c Stefan Gehrer
|
||||||
jpegxl_probe.* Leo Izen
|
jacosub* Clément Bœsch
|
||||||
jvdec.c Peter Ross
|
jvdec.c Peter Ross
|
||||||
kvag.c Zane van Iperen
|
|
||||||
libmodplug.c Clément Bœsch
|
libmodplug.c Clément Bœsch
|
||||||
libopenmpt.c Josh de Kock
|
libnut.c Oded Shimon
|
||||||
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, Andreas Rheinhardt
|
matroska.c Aurelien Jacobs
|
||||||
matroskadec.c Aurelien Jacobs, Andreas Rheinhardt
|
matroskadec.c Aurelien Jacobs
|
||||||
matroskaenc.c David Conrad, Andreas Rheinhardt
|
matroskaenc.c David Conrad
|
||||||
matroska subtitles (matroskaenc.c) John Peebles
|
matroska subtitles (matroskaenc.c) John Peebles
|
||||||
metadata* Aurelien Jacobs
|
metadata* Aurelien Jacobs
|
||||||
mgsts.c Paul B Mahol
|
mgsts.c Paul B Mahol
|
||||||
microdvd* Aurelien Jacobs
|
microdvd* Aurelien Jacobs
|
||||||
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 Baptiste Coudurier, Matthieu Bouron
|
||||||
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.c Marton Balint
|
||||||
mpegtsenc.c 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, Tomas Härdin
|
mxf* Baptiste Coudurier
|
||||||
|
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* Michael Niedermayer
|
||||||
@@ -474,7 +448,6 @@ Muxers/Demuxers:
|
|||||||
oggparse*.c David Conrad
|
oggparse*.c David Conrad
|
||||||
oma.c Maxim Poliakovski
|
oma.c Maxim Poliakovski
|
||||||
paf.c Paul B Mahol
|
paf.c Paul B Mahol
|
||||||
pp_bnk.c Zane van Iperen
|
|
||||||
psxstr.c Mike Melanson
|
psxstr.c Mike Melanson
|
||||||
pva.c Ivo van Poorten
|
pva.c Ivo van Poorten
|
||||||
pvfdec.c Paul B Mahol
|
pvfdec.c Paul B Mahol
|
||||||
@@ -482,22 +455,17 @@ 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
|
||||||
s337m.c foo86
|
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
|
spdif* Anssi Hannula
|
||||||
srtdec.c Aurelien Jacobs
|
srtdec.c Aurelien Jacobs
|
||||||
@@ -512,19 +480,16 @@ Muxers/Demuxers:
|
|||||||
webvtt* Matthew J Heaney
|
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
|
ftp.c Lukasz Marek
|
||||||
http.c Ronald S. Bultje
|
http.c Ronald S. Bultje
|
||||||
libsrt.c Zhao Zhili
|
|
||||||
libssh.c Lukasz Marek
|
libssh.c Lukasz Marek
|
||||||
libzmq.c Andriy Gelman
|
|
||||||
mms*.c Ronald S. Bultje
|
mms*.c Ronald S. Bultje
|
||||||
udp.c Luca Abeni
|
udp.c Luca Abeni
|
||||||
icecast.c Marvin Scholz
|
|
||||||
|
|
||||||
|
|
||||||
libswresample
|
libswresample
|
||||||
@@ -544,69 +509,38 @@ Resamplers:
|
|||||||
Operating systems / CPU architectures
|
Operating systems / CPU architectures
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
Alpha Falk Hueffner
|
Alpha Mans Rullgard, Falk Hueffner
|
||||||
MIPS Manojkumar Bhosale, Shiyou Yin
|
ARM Mans Rullgard
|
||||||
LoongArch Shiyou Yin
|
AVR32 Mans Rullgard
|
||||||
|
MIPS Mans Rullgard, Nedeljko Babic
|
||||||
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 Lauri Kasanen
|
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 MSVC Matthew Oliver
|
||||||
Windows ICL Matthew Oliver
|
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
|
|
||||||
Jan Ekström
|
|
||||||
Joakim Plate
|
|
||||||
Jun Zhao
|
|
||||||
Kieran Kunhya
|
|
||||||
Kirill Gavrilov
|
|
||||||
Limin Wang
|
|
||||||
Martin Storsjö
|
|
||||||
Panagiotis Issaris
|
|
||||||
Pedro Arthur
|
|
||||||
Sebastien Zwickert
|
|
||||||
Vittorio Giovara
|
|
||||||
wm4
|
|
||||||
(this list is incomplete)
|
|
||||||
|
|
||||||
|
|
||||||
Releases
|
Releases
|
||||||
========
|
========
|
||||||
|
|
||||||
2.8 Michael Niedermayer
|
2.3 Michael Niedermayer
|
||||||
2.7 Michael Niedermayer
|
2.2 Michael Niedermayer
|
||||||
2.6 Michael Niedermayer
|
1.2 Michael Niedermayer
|
||||||
2.5 Michael Niedermayer
|
|
||||||
|
|
||||||
If you want to maintain an older release, please contact us
|
If you want to maintain an older release, please contact us
|
||||||
|
|
||||||
|
|
||||||
GnuPG Fingerprints and IRC nicknames of maintainers and contributors
|
GnuPG Fingerprints of maintainers and contributors
|
||||||
====================================================================
|
==================================================
|
||||||
|
|
||||||
IRC nicknames are in parentheses. These apply
|
|
||||||
to the IRC channels listed on the website.
|
|
||||||
|
|
||||||
Alexander Strasser 1C96 78B7 83CB 8AA7 9AF5 D1EB A7D8 A57B A876 E58F
|
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
|
||||||
|
Anton Khirnov 6D0C 6625 56F8 65D1 E5F5 814B B50A 1241 C067 07AB
|
||||||
Ash Hughes 694D 43D2 D180 C7C7 6421 ABD3 A641 D0B7 623D 6029
|
Ash Hughes 694D 43D2 D180 C7C7 6421 ABD3 A641 D0B7 623D 6029
|
||||||
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
|
||||||
@@ -614,35 +548,27 @@ 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
|
Clément Bœsch 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
|
||||||
|
Diego Biurrun 8227 1E31 B6D9 4994 7427 E220 9CAE D6CC 4757 FCC5
|
||||||
FFmpeg release signing key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8
|
FFmpeg release signing key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8
|
||||||
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
|
||||||
Haihao Xiang (haihao) 1F0C 31E8 B4FE F7A4 4DC1 DC99 E0F5 76D4 76FC 437F
|
|
||||||
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
|
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
|
||||||
James Almer 7751 2E8C FD94 A169 57E6 9A7A 1463 01AD 7376 59E0
|
|
||||||
Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
|
Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
|
||||||
Leo Izen (thebombzen) B6FD 3CFC 7ACF 83FC 9137 6945 5A71 C331 FD2F A19A
|
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
|
||||||
Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464
|
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
|
||||||
Niklas Haas (haasn) 1DDB 8076 B14D 5B48 32FC 99D9 EB52 DA9C 02BA 6FB4
|
|
||||||
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
|
|
||||||
Ramiro Polla 7859 C65B 751B 1179 792E DAE8 8E95 8B2F 9B6C 5700
|
|
||||||
Reimar Doeffinger 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
|
||||||
Steinar H. Gunderson C2E9 004F F028 C18E 4EAD DB83 7F61 7561 7797 8F76
|
|
||||||
Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863
|
Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863
|
||||||
Thilo Borgmann (thilo) CE1D B7F4 4D20 FC3A DD9F FE5A 257C 5B8F 1D20 B92F
|
|
||||||
Tiancheng "Timothy" Gu 9456 AFC0 814A 8139 E994 8351 7FE6 B095 B582 B0D4
|
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
|
Tim Nicholson 38CF DB09 3ED0 F607 8B67 6CED 0C0B FC44 8B0B FC83
|
||||||
Tomas Härdin (thardin) 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
|
Wei Gao 4269 7741 857A 0E60 9EC5 08D2 4744 4EFA 62C1 87B9
|
||||||
Zane van Iperen (zane) 61AE D40F 368B 6F26 9DAE 3892 6861 6B2D 8AC4 DCC5
|
|
||||||
|
|||||||
179
Makefile
179
Makefile
@@ -1,31 +1,49 @@
|
|||||||
MAIN_MAKEFILE=1
|
MAIN_MAKEFILE=1
|
||||||
include ffbuild/config.mak
|
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 %.m $(SRC_PATH)
|
||||||
vpath %.S $(SRC_PATH)
|
vpath %.S $(SRC_PATH)
|
||||||
vpath %.asm $(SRC_PATH)
|
vpath %.asm $(SRC_PATH)
|
||||||
vpath %.rc $(SRC_PATH)
|
vpath %.rc $(SRC_PATH)
|
||||||
vpath %.v $(SRC_PATH)
|
vpath %.v $(SRC_PATH)
|
||||||
vpath %.texi $(SRC_PATH)
|
vpath %.texi $(SRC_PATH)
|
||||||
vpath %.cu $(SRC_PATH)
|
|
||||||
vpath %.ptx $(SRC_PATH)
|
|
||||||
vpath %.metal $(SRC_PATH)
|
|
||||||
vpath %/fate_config.sh.template $(SRC_PATH)
|
vpath %/fate_config.sh.template $(SRC_PATH)
|
||||||
|
|
||||||
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
|
AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
|
||||||
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
|
AVPROGS-$(CONFIG_FFPLAY) += ffplay
|
||||||
|
AVPROGS-$(CONFIG_FFPROBE) += ffprobe
|
||||||
|
AVPROGS-$(CONFIG_FFSERVER) += ffserver
|
||||||
|
|
||||||
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale swresample
|
AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
|
||||||
|
INSTPROGS = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
|
||||||
|
PROGS += $(AVPROGS)
|
||||||
|
|
||||||
|
AVBASENAMES = ffmpeg ffplay ffprobe ffserver
|
||||||
|
ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
|
||||||
|
ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
|
||||||
|
|
||||||
|
$(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-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
|
||||||
|
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
|
||||||
|
OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_vda.o
|
||||||
|
|
||||||
|
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
|
||||||
|
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
|
||||||
|
TOOLS = qt-faststart trasher uncoded_frame
|
||||||
|
TOOLS-$(CONFIG_ZLIB) += cws2fws
|
||||||
|
|
||||||
# $(FFLIBS-yes) needs to be in linking order
|
# $(FFLIBS-yes) needs to be in linking order
|
||||||
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
|
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
|
||||||
FFLIBS-$(CONFIG_AVFILTER) += avfilter
|
FFLIBS-$(CONFIG_AVFILTER) += avfilter
|
||||||
FFLIBS-$(CONFIG_AVFORMAT) += avformat
|
FFLIBS-$(CONFIG_AVFORMAT) += avformat
|
||||||
FFLIBS-$(CONFIG_AVCODEC) += avcodec
|
FFLIBS-$(CONFIG_AVCODEC) += avcodec
|
||||||
|
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
|
||||||
FFLIBS-$(CONFIG_POSTPROC) += postproc
|
FFLIBS-$(CONFIG_POSTPROC) += postproc
|
||||||
FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
|
FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
|
||||||
FFLIBS-$(CONFIG_SWSCALE) += swscale
|
FFLIBS-$(CONFIG_SWSCALE) += swscale
|
||||||
@@ -33,68 +51,36 @@ 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
|
||||||
|
|
||||||
SKIPHEADERS = compat/w32pthreads.h
|
SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
|
||||||
|
|
||||||
# first so "all" becomes default target
|
include $(SRC_PATH)/common.mak
|
||||||
all: all-yes
|
|
||||||
|
|
||||||
include $(SRC_PATH)/tools/Makefile
|
|
||||||
include $(SRC_PATH)/ffbuild/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)
|
|
||||||
|
|
||||||
$(TOOLS): %$(EXESUF): %.o
|
all: $(AVPROGS)
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS)
|
|
||||||
|
|
||||||
target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
|
$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
|
$(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS)
|
||||||
|
|
||||||
tools/target_bsf_%_fuzzer$(EXESUF): tools/target_bsf_%_fuzzer.o $(FF_DEP_LIBS)
|
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
|
|
||||||
|
|
||||||
target_dem_%_fuzzer$(EXESUF): target_dem_%_fuzzer.o $(FF_DEP_LIBS)
|
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
|
|
||||||
|
|
||||||
tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS)
|
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
|
|
||||||
|
|
||||||
tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS)
|
|
||||||
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
|
|
||||||
|
|
||||||
|
|
||||||
tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
|
||||||
tools/enum_options$(EXESUF): $(FF_DEP_LIBS)
|
|
||||||
tools/scale_slice_test$(EXESUF): $(FF_DEP_LIBS)
|
|
||||||
tools/scale_slice_test$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
|
||||||
tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
|
||||||
tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
|
tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
|
||||||
tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
||||||
tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
|
|
||||||
tools/target_dem_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
|
|
||||||
|
|
||||||
CONFIGURABLE_COMPONENTS = \
|
config.h: .config
|
||||||
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
|
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
|
||||||
$(SRC_PATH)/libavcodec/bitstream_filters.c \
|
|
||||||
$(SRC_PATH)/libavcodec/hwaccels.h \
|
|
||||||
$(SRC_PATH)/libavcodec/parsers.c \
|
|
||||||
$(SRC_PATH)/libavformat/protocols.c \
|
|
||||||
|
|
||||||
config_components.h: ffbuild/.config
|
|
||||||
ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
|
|
||||||
@-tput bold 2>/dev/null
|
@-tput bold 2>/dev/null
|
||||||
@-printf '\nWARNING: $(?) newer than config_components.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 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 ARMV8-OBJS VFP-OBJS NEON-OBJS \
|
||||||
ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \
|
ALTIVEC-OBJS MMX-OBJS YASM-OBJS \
|
||||||
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
|
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS \
|
||||||
MMI-OBJS LSX-OBJS LASX-OBJS OBJS SLIBOBJS SHLIBOBJS \
|
OBJS SLIBOBJS HOSTOBJS TESTOBJS
|
||||||
STLIBOBJS HOSTOBJS TESTOBJS
|
|
||||||
|
|
||||||
define RESET
|
define RESET
|
||||||
$(1) :=
|
$(1) :=
|
||||||
@@ -106,34 +92,41 @@ $(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)/ffbuild/library.mak
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
|
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
|
||||||
|
|
||||||
include $(SRC_PATH)/fftools/Makefile
|
|
||||||
include $(SRC_PATH)/doc/Makefile
|
include $(SRC_PATH)/doc/Makefile
|
||||||
include $(SRC_PATH)/doc/examples/Makefile
|
|
||||||
|
|
||||||
$(ALLFFLIBS:%=lib%/version.o): libavutil/ffversion.h
|
define DOPROG
|
||||||
|
OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
|
||||||
|
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
|
||||||
|
$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
|
||||||
|
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
|
||||||
|
$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
|
||||||
|
-include $$(OBJS-$(1):.o=.d)
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
|
||||||
|
|
||||||
|
ffprobe.o cmdutils.o : libavutil/ffversion.h
|
||||||
|
|
||||||
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
|
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
|
||||||
ifeq ($(STRIPTYPE),direct)
|
|
||||||
$(STRIP) -o $@ $<
|
|
||||||
else
|
|
||||||
$(RM) $@
|
|
||||||
$(CP) $< $@
|
$(CP) $< $@
|
||||||
$(STRIP) $@
|
$(STRIP) $@
|
||||||
endif
|
|
||||||
|
|
||||||
%$(PROGSSUF)_g$(EXESUF): $(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)
|
||||||
|
|
||||||
VERSION_SH = $(SRC_PATH)/ffbuild/version.sh
|
OBJDIRS += tools
|
||||||
|
|
||||||
|
-include $(wildcard tools/*.d)
|
||||||
|
|
||||||
|
VERSION_SH = $(SRC_PATH)/version.sh
|
||||||
GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
|
GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
|
||||||
|
|
||||||
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) ffbuild/config.mak
|
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
|
||||||
.version: M=@
|
.version: M=@
|
||||||
|
|
||||||
libavutil/ffversion.h .version:
|
libavutil/ffversion.h .version:
|
||||||
@@ -143,47 +136,53 @@ libavutil/ffversion.h .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
|
||||||
|
install: install-progs install-data
|
||||||
|
endif
|
||||||
|
|
||||||
install: install-libs install-headers
|
install: install-libs install-headers
|
||||||
|
|
||||||
install-libs: install-libs-yes
|
install-libs: install-libs-yes
|
||||||
|
|
||||||
install-data: $(DATA_FILES)
|
install-progs-yes:
|
||||||
$(Q)mkdir -p "$(DATADIR)"
|
install-progs-$(CONFIG_SHARED): install-libs
|
||||||
$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
|
|
||||||
|
|
||||||
uninstall: uninstall-data uninstall-headers uninstall-libs uninstall-pkgconfig
|
install-progs: install-progs-yes $(AVPROGS)
|
||||||
|
$(Q)mkdir -p "$(BINDIR)"
|
||||||
|
$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
|
||||||
|
|
||||||
|
install-data: $(DATA_FILES) $(EXAMPLES_FILES)
|
||||||
|
$(Q)mkdir -p "$(DATADIR)/examples"
|
||||||
|
$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
|
||||||
|
$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
|
||||||
|
|
||||||
|
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
|
||||||
|
|
||||||
|
uninstall-progs:
|
||||||
|
$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
|
||||||
|
|
||||||
uninstall-data:
|
uninstall-data:
|
||||||
$(RM) -r "$(DATADIR)"
|
$(RM) -r "$(DATADIR)"
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
|
$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
|
||||||
$(RM) $(CLEANSUFFIXES)
|
$(RM) $(CLEANSUFFIXES)
|
||||||
$(RM) $(addprefix compat/,$(CLEANSUFFIXES)) $(addprefix compat/*/,$(CLEANSUFFIXES)) $(addprefix compat/*/*/,$(CLEANSUFFIXES))
|
$(RM) $(CLEANSUFFIXES:%=tools/%)
|
||||||
$(RM) -r coverage-html
|
$(RM) -r coverage-html
|
||||||
$(RM) -rf coverage.info coverage.info.in lcov
|
$(RM) -rf coverage.info lcov
|
||||||
|
|
||||||
distclean:: clean
|
distclean::
|
||||||
$(RM) .version config.asm config.h config_components.h mapfile \
|
$(RM) $(DISTCLEANSUFFIXES)
|
||||||
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
|
$(RM) config.* .config libavutil/avconfig.h .version version.h libavutil/ffversion.h libavcodec/codec_names.h
|
||||||
version.h libavutil/ffversion.h libavcodec/codec_names.h \
|
|
||||||
libavcodec/bsf_list.c libavformat/protocol_list.c \
|
|
||||||
libavcodec/codec_list.c libavcodec/parser_list.c \
|
|
||||||
libavfilter/filter_list.c libavdevice/indev_list.c libavdevice/outdev_list.c \
|
|
||||||
libavformat/muxer_list.c libavformat/demuxer_list.c
|
|
||||||
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)
|
||||||
|
|
||||||
build: all alltools examples testprogs
|
|
||||||
check: all alltools examples testprogs fate
|
check: all alltools examples testprogs fate
|
||||||
|
|
||||||
include $(SRC_PATH)/tests/Makefile
|
include $(SRC_PATH)/tests/Makefile
|
||||||
|
|
||||||
$(sort $(OUTDIRS)):
|
$(sort $(OBJDIRS)):
|
||||||
$(Q)mkdir -p $@
|
$(Q)mkdir -p $@
|
||||||
|
|
||||||
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
||||||
@@ -194,5 +193,5 @@ $(sort $(OUTDIRS)):
|
|||||||
# so this saves some time on slow systems.
|
# so this saves some time on slow systems.
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
||||||
.PHONY: all all-yes alltools build check config testprogs
|
.PHONY: all all-yes alltools check *clean config install*
|
||||||
.PHONY: *clean install* uninstall*
|
.PHONY: testprogs uninstall*
|
||||||
|
|||||||
47
README.md
47
README.md
@@ -1,46 +1,19 @@
|
|||||||
FFmpeg README
|
FFmpeg README
|
||||||
=============
|
=============
|
||||||
|
|
||||||
FFmpeg is a collection of libraries and tools to process multimedia content
|
1) Documentation
|
||||||
such as audio, video, subtitles and related metadata.
|
----------------
|
||||||
|
|
||||||
## Libraries
|
* Read the documentation in the doc/ directory in git.
|
||||||
|
|
||||||
* `libavcodec` provides implementation of a wider range of codecs.
|
You can also view it online at http://ffmpeg.org/documentation.html
|
||||||
* `libavformat` implements streaming protocols, container formats and basic I/O access.
|
|
||||||
* `libavutil` includes hashers, decompressors and miscellaneous utility functions.
|
|
||||||
* `libavfilter` provides means to alter decoded audio and video through a directed graph of connected 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
|
2) Licensing
|
||||||
|
------------
|
||||||
|
|
||||||
* [ffmpeg](https://ffmpeg.org/ffmpeg.html) is a command line toolbox to
|
* See the LICENSE file.
|
||||||
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.
|
|
||||||
* Additional small tools such as `aviocat`, `ismindex` and `qt-faststart`.
|
|
||||||
|
|
||||||
## Documentation
|
3) Build and Install
|
||||||
|
--------------------
|
||||||
|
|
||||||
The offline documentation is available in the **doc/** directory.
|
* See the INSTALL file.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|||||||
177
RELEASE_NOTES
Normal file
177
RELEASE_NOTES
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
┌───────────────────────────────────────────┐
|
||||||
|
│ RELEASE NOTES for FFmpeg 2.3 "Mandelbrot" │
|
||||||
|
└───────────────────────────────────────────┘
|
||||||
|
|
||||||
|
The FFmpeg Project proudly presents FFmpeg 2.3 "Mandelbrot", a major
|
||||||
|
release with all the great features committed during the three-month period
|
||||||
|
since the release of FFmpeg 2.2.
|
||||||
|
|
||||||
|
In this release, there are lots of internal overhauls that make FFmpeg a
|
||||||
|
more accessible project for new developers. Many important new
|
||||||
|
optimizations and features like QTKit and AVFoundation input devices are
|
||||||
|
committed. Contributions done by Libav such as a new native Opus decoder
|
||||||
|
are also merged.
|
||||||
|
|
||||||
|
Because of the increasing difficulty to maintain and lack of maintainers,
|
||||||
|
we are very sorry to say that we have removed all Blackfin and SPARC
|
||||||
|
architecture assembly optimizations with the cleanups done. If you are
|
||||||
|
interested in maintaining optimization for these two architecture, feel
|
||||||
|
free to contact us and we will restore the code!
|
||||||
|
|
||||||
|
Oh, and since this release, this modern-looking release note is provided in
|
||||||
|
addition to the old-style Changelog file, to make it easier for you to
|
||||||
|
focus on the most important features in this release.
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ * API Information │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
FFmpeg 2.3 is completely source-compatible to the FFmpeg 2.2 series. There
|
||||||
|
are however some API deprecations that you need to take care of. Use `git
|
||||||
|
diff n2.2 n2.3 doc/APIchanges` to show the list of added and deprecated
|
||||||
|
APIs. FFmpeg 2.3 includes the following library versions:
|
||||||
|
|
||||||
|
• libavutil 52.92.100
|
||||||
|
• libavcodec 55.69.100
|
||||||
|
• libavformat 55.48.100
|
||||||
|
• libavdevice 55.13.102
|
||||||
|
• libavfilter 4.11.100
|
||||||
|
• libswscale 2. 6.100
|
||||||
|
• libswresample 0.19.100
|
||||||
|
• libpostproc 52. 3.100
|
||||||
|
|
||||||
|
Please refer to the doc/APIChanges file for more information.
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ New Optimization │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
We are excited to announce that we have committed new x86 assembly
|
||||||
|
optimization for HEVC, and FFmpeg's audio resampler libswresample. ARM
|
||||||
|
users will get a boost in MLP/TrueHD decoding thanks to new optimization.
|
||||||
|
Decoding Huffyuv also got a major boost from optimization on the C code.
|
||||||
|
|
||||||
|
Of special interest for Microsoft Visual Studio users, we have also
|
||||||
|
converted some preexisting x86 assembly to NASM/Yasm format compatible
|
||||||
|
with MSVC setup, especially in the area of audio resampling.
|
||||||
|
|
||||||
|
Another major feature in this release is the introduction of AArch64
|
||||||
|
(ARMv8) assembly optimization. AArch64 is another name for the first
|
||||||
|
64-bit ARM architecture, used by Apple A7 SoC inside iPhone 5S. Some
|
||||||
|
32-bit ARM assembly has already been ported to AArch64, but more work is
|
||||||
|
underway.
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ Native Opus decoder │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
Opus is an open audio format jointly developed by Xiph.Org, Mozilla,
|
||||||
|
Skype/Microsoft, and Broadcom. It combines the features of the Skype Cilk
|
||||||
|
speech codec and the Xiph.Org CELT music codec into one low-latency
|
||||||
|
codec. Decoding Opus is already possible since FFmpeg 1.0 using the
|
||||||
|
libopus library, but the new Opus native decoder brings a higher level of
|
||||||
|
stability and speed.
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ QTKit and AVFoundation │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
For OS X users, the new QTKit and AVFoundation devices allow you to use
|
||||||
|
the integrated camera on Macs. AVFoundation is a newer API only available
|
||||||
|
on OS X 10.7 "Lion" or newer. For users with older OS X systems, the
|
||||||
|
QTKit device using the older OS X API is for you.
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ API Additions │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
In this release, stream side data are introduced as AVStream.side_data as
|
||||||
|
a way to store miscellaneous stream-wide information. The format is
|
||||||
|
similar to the previously anonymous structure AVPacket.side_data (now
|
||||||
|
named as AVPacketSideData). With this change, audio ReplayGain
|
||||||
|
information and video rotation matrix are now exported through this API,
|
||||||
|
if available in the demuxer.
|
||||||
|
|
||||||
|
We also have improved libswresample's Doxygen API documentation, so new
|
||||||
|
developers wishing to use FFmpeg's excellent libraries can get started
|
||||||
|
more easily and faster.
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ Last But Not Least │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
Other interesting new features including hqx video filter, a pixel art
|
||||||
|
scaling filter; a fixed-point AC-3 decoder contributed by Imagination
|
||||||
|
Technologies; an On2 TrueMotion VP7 video decoder; an HTML5 WebVTT
|
||||||
|
subtitle encoder that allows creation of WebVTT from any text-based
|
||||||
|
subtitles; and an 1-bit Direct Stream Digital audio decoder.
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ ★ List of New Features │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ Command line tools │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
• Support for decoding through DXVA2 in ffmpeg
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ libavcodec │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
• AC3 fixed-point decoding
|
||||||
|
• VP7 video decoder
|
||||||
|
• Alias PIX image encoder and decoder
|
||||||
|
• Improvements to the BRender PIX image decoder
|
||||||
|
• Improvements to the XBM decoder
|
||||||
|
• Improvements to OpenEXR image decoder
|
||||||
|
• Support decoding 16-bit RLE SGI images
|
||||||
|
• Direct Stream Digital (DSD) decoder
|
||||||
|
• On2 AVC (Audio for Video) decoder
|
||||||
|
• Native Opus decoder
|
||||||
|
• WebVTT encoder
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ libavdevice │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
• QTKit input device
|
||||||
|
• GDI screen grabbing for Windows
|
||||||
|
• AVFoundation input device
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ libavformat │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
• subfile protocol
|
||||||
|
• Phantom Cine demuxer
|
||||||
|
• Alternative rendition support for HTTP Live Streaming
|
||||||
|
• Magic Lantern Video (MLV) demuxer
|
||||||
|
• Image format auto-detection
|
||||||
|
• LRC lyric file demuxer and muxer
|
||||||
|
• Samba protocol (via libsmbclient)
|
||||||
|
• WebM DASH Manifest muxer
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ libavfilter │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
• shuffleplanes filter
|
||||||
|
• libbs2b-based stereo-to-binaural audio filter
|
||||||
|
• showcqt multimedia filter
|
||||||
|
• zoompan filter
|
||||||
|
• signalstats filter
|
||||||
|
• hqx filter (hq2x, hq3x, hq4x)
|
||||||
|
• flanger filter
|
||||||
|
• libfribidi support in drawtext
|
||||||
|
|
||||||
|
┌────────────────────────────┐
|
||||||
|
│ ⚠ Behaviour changes │
|
||||||
|
└────────────────────────────┘
|
||||||
|
|
||||||
|
• libx264 reference frames count is now limited depending on level chosen
|
||||||
|
• Because of the new image format auto-detection feature, you don't need to
|
||||||
|
specify image format when decoding an image with no extension.
|
||||||
15
arch.mak
Normal file
15
arch.mak
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
OBJS-$(HAVE_ARMV5TE) += $(ARMV5TE-OBJS) $(ARMV5TE-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_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes)
|
||||||
|
|
||||||
|
OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-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_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
|
||||||
|
|
||||||
|
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
|
||||||
|
OBJS-$(HAVE_YASM) += $(YASM-OBJS) $(YASM-OBJS-yes)
|
||||||
2052
cmdutils.c
Normal file
2052
cmdutils.c
Normal file
File diff suppressed because it is too large
Load Diff
586
cmdutils.h
Normal file
586
cmdutils.h
Normal file
@@ -0,0 +1,586 @@
|
|||||||
|
/*
|
||||||
|
* Various utilities for command line tools
|
||||||
|
* copyright (c) 2003 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* 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 FFMPEG_CMDUTILS_H
|
||||||
|
#define FFMPEG_CMDUTILS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "libavcodec/avcodec.h"
|
||||||
|
#include "libavfilter/avfilter.h"
|
||||||
|
#include "libavformat/avformat.h"
|
||||||
|
#include "libswscale/swscale.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#undef main /* We don't want SDL to override our main() */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* program name, defined by the program for show_version().
|
||||||
|
*/
|
||||||
|
extern const char program_name[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* program birth year, defined by the program for show_banner()
|
||||||
|
*/
|
||||||
|
extern const int program_birth_year;
|
||||||
|
|
||||||
|
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||||
|
extern AVFormatContext *avformat_opts;
|
||||||
|
extern struct SwsContext *sws_opts;
|
||||||
|
extern AVDictionary *swr_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 the cmdutils option system, in particular
|
||||||
|
* allocate the *_opts contexts.
|
||||||
|
*/
|
||||||
|
void init_opts(void);
|
||||||
|
/**
|
||||||
|
* Uninitialize the cmdutils option system, in particular
|
||||||
|
* free the *_opts contexts and their contents.
|
||||||
|
*/
|
||||||
|
void uninit_opts(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trivial log callback.
|
||||||
|
* Only suitable for opt_help and similar since it lacks prefix handling.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* parsed through AVOptions.
|
||||||
|
*/
|
||||||
|
int opt_default(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the libav* libraries log level.
|
||||||
|
*/
|
||||||
|
int opt_loglevel(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
int opt_report(const char *opt);
|
||||||
|
|
||||||
|
int opt_max_alloc(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.
|
||||||
|
*/
|
||||||
|
int opt_timelimit(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a string and return its corresponding value as a double.
|
||||||
|
* Exit from the application if the string cannot be correctly
|
||||||
|
* parsed or the corresponding value is invalid.
|
||||||
|
*
|
||||||
|
* @param context the context of the value to be set (e.g. the
|
||||||
|
* corresponding command line option name)
|
||||||
|
* @param numstr the string to be parsed
|
||||||
|
* @param type the type (OPT_INT64 or OPT_FLOAT) as which the
|
||||||
|
* string should be parsed
|
||||||
|
* @param min the minimum valid accepted value
|
||||||
|
* @param max the maximum valid accepted value
|
||||||
|
*/
|
||||||
|
double parse_number_or_die(const char *context, const char *numstr, int type,
|
||||||
|
double min, double max);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a string specifying a time and return its corresponding
|
||||||
|
* value as a number of microseconds. Exit from the application if
|
||||||
|
* the string cannot be correctly parsed.
|
||||||
|
*
|
||||||
|
* @param context the context of the value to be set (e.g. the
|
||||||
|
* corresponding command line option name)
|
||||||
|
* @param timestr the string to be parsed
|
||||||
|
* @param is_duration a flag which tells how to interpret timestr, if
|
||||||
|
* not zero timestr is interpreted as a duration, otherwise as a
|
||||||
|
* date
|
||||||
|
*
|
||||||
|
* @see av_parse_time()
|
||||||
|
*/
|
||||||
|
int64_t parse_time_or_die(const char *context, const char *timestr,
|
||||||
|
int is_duration);
|
||||||
|
|
||||||
|
typedef struct SpecifierOpt {
|
||||||
|
char *specifier; /**< stream/chapter/program/... specifier */
|
||||||
|
union {
|
||||||
|
uint8_t *str;
|
||||||
|
int i;
|
||||||
|
int64_t i64;
|
||||||
|
float f;
|
||||||
|
double dbl;
|
||||||
|
} u;
|
||||||
|
} SpecifierOpt;
|
||||||
|
|
||||||
|
typedef struct OptionDef {
|
||||||
|
const char *name;
|
||||||
|
int flags;
|
||||||
|
#define HAS_ARG 0x0001
|
||||||
|
#define OPT_BOOL 0x0002
|
||||||
|
#define OPT_EXPERT 0x0004
|
||||||
|
#define OPT_STRING 0x0008
|
||||||
|
#define OPT_VIDEO 0x0010
|
||||||
|
#define OPT_AUDIO 0x0020
|
||||||
|
#define OPT_INT 0x0080
|
||||||
|
#define OPT_FLOAT 0x0100
|
||||||
|
#define OPT_SUBTITLE 0x0200
|
||||||
|
#define OPT_INT64 0x0400
|
||||||
|
#define OPT_EXIT 0x0800
|
||||||
|
#define OPT_DATA 0x1000
|
||||||
|
#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only).
|
||||||
|
implied by OPT_OFFSET or OPT_SPEC */
|
||||||
|
#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */
|
||||||
|
#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
|
||||||
|
Implies OPT_OFFSET. Next element after the offset is
|
||||||
|
an int containing element count in the array. */
|
||||||
|
#define OPT_TIME 0x10000
|
||||||
|
#define OPT_DOUBLE 0x20000
|
||||||
|
#define OPT_INPUT 0x40000
|
||||||
|
#define OPT_OUTPUT 0x80000
|
||||||
|
union {
|
||||||
|
void *dst_ptr;
|
||||||
|
int (*func_arg)(void *, const char *, const char *);
|
||||||
|
size_t off;
|
||||||
|
} u;
|
||||||
|
const char *help;
|
||||||
|
const char *argname;
|
||||||
|
} OptionDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print help for all options matching specified flags.
|
||||||
|
*
|
||||||
|
* @param options a list of options
|
||||||
|
* @param msg title of this group. Only printed if at least one option matches.
|
||||||
|
* @param req_flags print only options which have all those flags set.
|
||||||
|
* @param rej_flags don't print options which have any of those flags set.
|
||||||
|
* @param alt_flags print only options that have at least one of those flags set
|
||||||
|
*/
|
||||||
|
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||||
|
int rej_flags, int alt_flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show help for all options with given flags in class and all its
|
||||||
|
* children.
|
||||||
|
*/
|
||||||
|
void show_help_children(const AVClass *class, int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-fftool specific help handler. Implemented in each
|
||||||
|
* fftool, called by show_help().
|
||||||
|
*/
|
||||||
|
void show_help_default(const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic -h handler common to all fftools.
|
||||||
|
*/
|
||||||
|
int show_help(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the command line arguments.
|
||||||
|
*
|
||||||
|
* @param optctx an opaque options context
|
||||||
|
* @param argc number of command line arguments
|
||||||
|
* @param argv values of command line arguments
|
||||||
|
* @param options Array with the definitions required to interpret every
|
||||||
|
* option of the form: -option_name [argument]
|
||||||
|
* @param parse_arg_function Name of the function called to process every
|
||||||
|
* argument without a leading option name flag. NULL if such arguments do
|
||||||
|
* not have to be processed.
|
||||||
|
*/
|
||||||
|
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
|
||||||
|
void (* parse_arg_function)(void *optctx, const char*));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse one given option.
|
||||||
|
*
|
||||||
|
* @return on success 1 if arg was consumed, 0 otherwise; negative number on error
|
||||||
|
*/
|
||||||
|
int parse_option(void *optctx, const char *opt, const char *arg,
|
||||||
|
const OptionDef *options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An option extracted from the commandline.
|
||||||
|
* Cannot use AVDictionary because of options like -map which can be
|
||||||
|
* used multiple times.
|
||||||
|
*/
|
||||||
|
typedef struct Option {
|
||||||
|
const OptionDef *opt;
|
||||||
|
const char *key;
|
||||||
|
const char *val;
|
||||||
|
} Option;
|
||||||
|
|
||||||
|
typedef struct OptionGroupDef {
|
||||||
|
/**< group name */
|
||||||
|
const char *name;
|
||||||
|
/**
|
||||||
|
* Option to be used as group separator. Can be NULL for groups which
|
||||||
|
* are terminated by a non-option argument (e.g. ffmpeg output files)
|
||||||
|
*/
|
||||||
|
const char *sep;
|
||||||
|
/**
|
||||||
|
* Option flags that must be set on each option that is
|
||||||
|
* applied to this group
|
||||||
|
*/
|
||||||
|
int flags;
|
||||||
|
} OptionGroupDef;
|
||||||
|
|
||||||
|
typedef struct OptionGroup {
|
||||||
|
const OptionGroupDef *group_def;
|
||||||
|
const char *arg;
|
||||||
|
|
||||||
|
Option *opts;
|
||||||
|
int nb_opts;
|
||||||
|
|
||||||
|
AVDictionary *codec_opts;
|
||||||
|
AVDictionary *format_opts;
|
||||||
|
AVDictionary *resample_opts;
|
||||||
|
struct SwsContext *sws_opts;
|
||||||
|
AVDictionary *swr_opts;
|
||||||
|
} OptionGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of option groups that all have the same group type
|
||||||
|
* (e.g. input files or output files)
|
||||||
|
*/
|
||||||
|
typedef struct OptionGroupList {
|
||||||
|
const OptionGroupDef *group_def;
|
||||||
|
|
||||||
|
OptionGroup *groups;
|
||||||
|
int nb_groups;
|
||||||
|
} OptionGroupList;
|
||||||
|
|
||||||
|
typedef struct OptionParseContext {
|
||||||
|
OptionGroup global_opts;
|
||||||
|
|
||||||
|
OptionGroupList *groups;
|
||||||
|
int nb_groups;
|
||||||
|
|
||||||
|
/* parsing state */
|
||||||
|
OptionGroup cur_group;
|
||||||
|
} OptionParseContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse an options group and write results into optctx.
|
||||||
|
*
|
||||||
|
* @param optctx an app-specific options context. NULL for global options group
|
||||||
|
*/
|
||||||
|
int parse_optgroup(void *optctx, OptionGroup *g);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split the commandline into an intermediate form convenient for further
|
||||||
|
* processing.
|
||||||
|
*
|
||||||
|
* The commandline is assumed to be composed of options which either belong to a
|
||||||
|
* group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global
|
||||||
|
* (everything else).
|
||||||
|
*
|
||||||
|
* A group (defined by an OptionGroupDef struct) is a sequence of options
|
||||||
|
* terminated by either a group separator option (e.g. -i) or a parameter that
|
||||||
|
* is not an option (doesn't start with -). A group without a separator option
|
||||||
|
* must always be first in the supplied groups list.
|
||||||
|
*
|
||||||
|
* All options within the same group are stored in one OptionGroup struct in an
|
||||||
|
* OptionGroupList, all groups with the same group definition are stored in one
|
||||||
|
* OptionGroupList in OptionParseContext.groups. The order of group lists is the
|
||||||
|
* same as the order of group definitions.
|
||||||
|
*/
|
||||||
|
int split_commandline(OptionParseContext *octx, int argc, char *argv[],
|
||||||
|
const OptionDef *options,
|
||||||
|
const OptionGroupDef *groups, int nb_groups);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free all allocated memory in an OptionParseContext.
|
||||||
|
*/
|
||||||
|
void uninit_parse_context(OptionParseContext *octx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the '-loglevel' option in the command line args and apply it.
|
||||||
|
*/
|
||||||
|
void parse_loglevel(int argc, char **argv, const OptionDef *options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return index of option opt in argv or 0 if not found.
|
||||||
|
*/
|
||||||
|
int locate_option(int argc, char **argv, const OptionDef *options,
|
||||||
|
const char *optname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given stream matches a stream specifier.
|
||||||
|
*
|
||||||
|
* @param s Corresponding format context.
|
||||||
|
* @param st Stream from s to be checked.
|
||||||
|
* @param spec A stream specifier of the [v|a|s|d]:[\<stream index\>] form.
|
||||||
|
*
|
||||||
|
* @return 1 if the stream matches, 0 if it doesn't, <0 on error
|
||||||
|
*/
|
||||||
|
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter out options for given codec.
|
||||||
|
*
|
||||||
|
* Create a new options dictionary containing only the options from
|
||||||
|
* opts which apply to the codec with ID codec_id.
|
||||||
|
*
|
||||||
|
* @param opts dictionary to place options in
|
||||||
|
* @param codec_id ID of the codec that should be filtered for
|
||||||
|
* @param s Corresponding format context.
|
||||||
|
* @param st A stream from s for which the options should be filtered.
|
||||||
|
* @param codec The particular codec for which the options should be filtered.
|
||||||
|
* If null, the default one is looked up according to the codec id.
|
||||||
|
* @return a pointer to the created dictionary
|
||||||
|
*/
|
||||||
|
AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
|
||||||
|
AVFormatContext *s, AVStream *st, AVCodec *codec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup AVCodecContext options for avformat_find_stream_info().
|
||||||
|
*
|
||||||
|
* Create an array of dictionaries, one dictionary for each stream
|
||||||
|
* contained in s.
|
||||||
|
* Each dictionary will contain the options from codec_opts which can
|
||||||
|
* be applied to the corresponding stream codec context.
|
||||||
|
*
|
||||||
|
* @return pointer to the created array of dictionaries, NULL if it
|
||||||
|
* cannot be created
|
||||||
|
*/
|
||||||
|
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
||||||
|
AVDictionary *codec_opts);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print an error message to stderr, indicating filename and a human
|
||||||
|
* readable description of the error code err.
|
||||||
|
*
|
||||||
|
* If strerror_r() is not available the use of this function in a
|
||||||
|
* multithreaded application may be unsafe.
|
||||||
|
*
|
||||||
|
* @see av_strerror()
|
||||||
|
*/
|
||||||
|
void print_error(const char *filename, int err);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the program banner to stderr. The banner contents depend on the
|
||||||
|
* current version of the repository and of the libav* libraries used by
|
||||||
|
* the program.
|
||||||
|
*/
|
||||||
|
void show_banner(int argc, char **argv, const OptionDef *options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the version of the program to stdout. The version message
|
||||||
|
* depends on the current versions of the repository and of the libav*
|
||||||
|
* libraries.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* the license of the libraries compiled into the program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_license(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 devices supported by the
|
||||||
|
* program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_devices(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the codecs supported by the
|
||||||
|
* program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_codecs(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the decoders supported by the
|
||||||
|
* program.
|
||||||
|
*/
|
||||||
|
int show_decoders(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the encoders supported by the
|
||||||
|
* program.
|
||||||
|
*/
|
||||||
|
int show_encoders(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the filters supported by the
|
||||||
|
* program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_filters(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the bit stream filters supported by the
|
||||||
|
* program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_bsfs(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the protocols supported by the
|
||||||
|
* program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_protocols(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the pixel formats supported by the
|
||||||
|
* program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_pix_fmts(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the standard channel layouts supported by
|
||||||
|
* the program.
|
||||||
|
* This option processing function does not utilize the arguments.
|
||||||
|
*/
|
||||||
|
int show_layouts(void *optctx, const char *opt, const char *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a listing containing all the sample formats supported by the
|
||||||
|
* program.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
* starts with [yY], otherwise return 0.
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* If is_path is non-zero, look for the file in the path preset_name.
|
||||||
|
* Otherwise search for a file named arg.ffpreset in the directories
|
||||||
|
* $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined
|
||||||
|
* at configuration time or in a "ffpresets" folder along the executable
|
||||||
|
* on win32, in that order. If no such file is found and
|
||||||
|
* codec_name is defined, then search for a file named
|
||||||
|
* codec_name-preset_name.avpreset in the above-mentioned directories.
|
||||||
|
*
|
||||||
|
* @param filename buffer where the name of the found filename is written
|
||||||
|
* @param filename_size size in bytes of the filename buffer
|
||||||
|
* @param preset_name name of the preset to search
|
||||||
|
* @param is_path tell if preset_name is a filename path
|
||||||
|
* @param codec_name name of the codec for which to look for the
|
||||||
|
* preset, may be NULL
|
||||||
|
*/
|
||||||
|
FILE *get_preset_file(char *filename, size_t filename_size,
|
||||||
|
const char *preset_name, int is_path, const char *codec_name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Realloc array to hold new_size elements of elem_size.
|
||||||
|
* Calls exit() on failure.
|
||||||
|
*
|
||||||
|
* @param array array to reallocate
|
||||||
|
* @param elem_size size in bytes of each element
|
||||||
|
* @param size new element count will be written here
|
||||||
|
* @param new_size number of elements to place in reallocated array
|
||||||
|
* @return reallocated array
|
||||||
|
*/
|
||||||
|
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)\
|
||||||
|
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
||||||
|
|
||||||
|
#define GET_PIX_FMT_NAME(pix_fmt)\
|
||||||
|
const char *name = av_get_pix_fmt_name(pix_fmt);
|
||||||
|
|
||||||
|
#define GET_SAMPLE_FMT_NAME(sample_fmt)\
|
||||||
|
const char *name = av_get_sample_fmt_name(sample_fmt)
|
||||||
|
|
||||||
|
#define GET_SAMPLE_RATE_NAME(rate)\
|
||||||
|
char name[16];\
|
||||||
|
snprintf(name, sizeof(name), "%d", rate);
|
||||||
|
|
||||||
|
#define GET_CH_LAYOUT_NAME(ch_layout)\
|
||||||
|
char name[16];\
|
||||||
|
snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
|
||||||
|
|
||||||
|
#define GET_CH_LAYOUT_DESC(ch_layout)\
|
||||||
|
char name[128];\
|
||||||
|
av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
|
||||||
|
|
||||||
|
#endif /* CMDUTILS_H */
|
||||||
29
cmdutils_common_opts.h
Normal file
29
cmdutils_common_opts.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{ "L" , OPT_EXIT, {.func_arg = show_license}, "show license" },
|
||||||
|
{ "h" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" },
|
||||||
|
{ "?" , 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" },
|
||||||
|
{ "buildconf" , OPT_EXIT, {.func_arg = show_buildconf}, "show build configuration" },
|
||||||
|
{ "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" },
|
||||||
|
{ "devices" , OPT_EXIT, {.func_arg = show_devices }, "show available devices" },
|
||||||
|
{ "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" },
|
||||||
|
{ "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" },
|
||||||
|
{ "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" },
|
||||||
|
{ "bsfs" , OPT_EXIT, {.func_arg = show_bsfs }, "show available bit stream filters" },
|
||||||
|
{ "protocols" , OPT_EXIT, {.func_arg = show_protocols}, "show available protocols" },
|
||||||
|
{ "filters" , OPT_EXIT, {.func_arg = show_filters }, "show available filters" },
|
||||||
|
{ "pix_fmts" , OPT_EXIT, {.func_arg = show_pix_fmts }, "show available pixel formats" },
|
||||||
|
{ "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" },
|
||||||
|
{ "colors" , OPT_EXIT, {.func_arg = show_colors }, "show available color names" },
|
||||||
|
{ "loglevel" , HAS_ARG, {.func_arg = opt_loglevel}, "set logging level", "loglevel" },
|
||||||
|
{ "v", HAS_ARG, {.func_arg = opt_loglevel}, "set logging level", "loglevel" },
|
||||||
|
{ "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" },
|
||||||
|
{ "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
|
||||||
274
cmdutils_opencl.c
Normal file
274
cmdutils_opencl.c
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
/*
|
||||||
|
* 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 "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)
|
||||||
|
{
|
||||||
|
return ((OpenCLDeviceBenchmark*)a)->runtime - ((OpenCLDeviceBenchmark*)b)->runtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
|
||||||
|
{
|
||||||
|
int i, j, nb_devices = 0, count = 0;
|
||||||
|
int64_t score = 0;
|
||||||
|
AVOpenCLDeviceList *device_list;
|
||||||
|
AVOpenCLDeviceNode *device_node = NULL;
|
||||||
|
OpenCLDeviceBenchmark *devices = NULL;
|
||||||
|
cl_platform_id platform;
|
||||||
|
|
||||||
|
av_opencl_get_device_list(&device_list);
|
||||||
|
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");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) {
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "Could not allocate buffer\n");
|
||||||
|
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;
|
||||||
|
strcpy(devices[count].device_name, device_node->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;
|
||||||
|
}
|
||||||
154
common.mak
Normal file
154
common.mak
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
#
|
||||||
|
# common bits used by all libraries
|
||||||
|
#
|
||||||
|
|
||||||
|
# first so "all" becomes default target
|
||||||
|
all: all-yes
|
||||||
|
|
||||||
|
ifndef SUBDIR
|
||||||
|
|
||||||
|
ifndef V
|
||||||
|
Q = @
|
||||||
|
ECHO = printf "$(1)\t%s\n" $(2)
|
||||||
|
BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
|
||||||
|
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
|
||||||
|
|
||||||
|
MSG = $@
|
||||||
|
M = @$(call ECHO,$(TAG),$@);
|
||||||
|
$(foreach VAR,$(BRIEF), \
|
||||||
|
$(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
|
||||||
|
$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
|
||||||
|
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
|
||||||
|
|
||||||
|
# NASM requires -I path terminated with /
|
||||||
|
IFLAGS := -I. -I$(SRC_PATH)/
|
||||||
|
CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
|
||||||
|
CFLAGS += $(ECFLAGS)
|
||||||
|
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
||||||
|
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
||||||
|
CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
|
||||||
|
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
|
||||||
|
|
||||||
|
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
|
||||||
|
LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
|
||||||
|
|
||||||
|
define COMPILE
|
||||||
|
$(call $(1)DEP,$(1))
|
||||||
|
$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
|
||||||
|
endef
|
||||||
|
|
||||||
|
COMPILE_C = $(call COMPILE,CC)
|
||||||
|
COMPILE_CXX = $(call COMPILE,CXX)
|
||||||
|
COMPILE_S = $(call COMPILE,AS)
|
||||||
|
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(COMPILE_C)
|
||||||
|
|
||||||
|
%.o: %.cpp
|
||||||
|
$(COMPILE_CXX)
|
||||||
|
|
||||||
|
%.o: %.m
|
||||||
|
$(COMPILE_C)
|
||||||
|
|
||||||
|
%.s: %.c
|
||||||
|
$(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $<
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(COMPILE_S)
|
||||||
|
|
||||||
|
%_host.o: %.c
|
||||||
|
$(COMPILE_HOSTC)
|
||||||
|
|
||||||
|
%.o: %.rc
|
||||||
|
$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
|
||||||
|
|
||||||
|
%.i: %.c
|
||||||
|
$(CC) $(CCFLAGS) $(CC_E) $<
|
||||||
|
|
||||||
|
%.h.c:
|
||||||
|
$(Q)echo '#include "$*.h"' >$@
|
||||||
|
|
||||||
|
%.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
|
||||||
|
%.h:
|
||||||
|
@:
|
||||||
|
|
||||||
|
# Disable suffix rules. Most of the builtin rules are suffix rules,
|
||||||
|
# so this saves some time on slow systems.
|
||||||
|
.SUFFIXES:
|
||||||
|
|
||||||
|
# Do not delete intermediate files from chains of implicit rules
|
||||||
|
$(OBJS):
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(SRC_PATH)/arch.mak
|
||||||
|
|
||||||
|
OBJS += $(OBJS-yes)
|
||||||
|
SLIBOBJS += $(SLIBOBJS-yes)
|
||||||
|
FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
|
||||||
|
TESTPROGS += $(TESTPROGS-yes)
|
||||||
|
|
||||||
|
LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
|
||||||
|
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
|
||||||
|
|
||||||
|
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
||||||
|
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
|
||||||
|
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
|
||||||
|
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
|
||||||
|
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
|
||||||
|
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
|
||||||
|
TOOLS += $(TOOLS-yes)
|
||||||
|
TOOLOBJS := $(TOOLS:%=tools/%.o)
|
||||||
|
TOOLS := $(TOOLS:%=tools/%$(EXESUF))
|
||||||
|
HEADERS += $(HEADERS-yes)
|
||||||
|
|
||||||
|
PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME))
|
||||||
|
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))
|
||||||
|
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
|
||||||
|
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
|
||||||
|
HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
|
||||||
|
checkheaders: $(HOBJS)
|
||||||
|
.SECONDARY: $(HOBJS:.o=.c)
|
||||||
|
|
||||||
|
alltools: $(TOOLS)
|
||||||
|
|
||||||
|
$(HOSTOBJS): %.o: %.c
|
||||||
|
$(COMPILE_HOSTC)
|
||||||
|
|
||||||
|
$(HOSTPROGS): %$(HOSTEXESUF): %.o
|
||||||
|
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
|
||||||
|
|
||||||
|
$(OBJS): | $(sort $(dir $(OBJS)))
|
||||||
|
$(HOBJS): | $(sort $(dir $(HOBJS)))
|
||||||
|
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
|
||||||
|
$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
|
||||||
|
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
|
||||||
|
$(TOOLOBJS): | tools
|
||||||
|
|
||||||
|
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
|
||||||
|
|
||||||
|
CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
|
||||||
|
DISTCLEANSUFFIXES = *.pc
|
||||||
|
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
|
||||||
|
|
||||||
|
define RULES
|
||||||
|
clean::
|
||||||
|
$(RM) $(OBJS) $(OBJS:.o=.d)
|
||||||
|
$(RM) $(HOSTPROGS)
|
||||||
|
$(RM) $(TOOLS)
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(RULES))
|
||||||
|
|
||||||
|
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d))
|
||||||
@@ -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_AIX_MATH_H
|
#ifndef FFMPEG_COMPAT_AIX_MATH_H
|
||||||
#define COMPAT_AIX_MATH_H
|
#define FFMPEG_COMPAT_AIX_MATH_H
|
||||||
|
|
||||||
#define class class_in_math_h_causes_problems
|
#define class class_in_math_h_causes_problems
|
||||||
|
|
||||||
@@ -28,4 +28,4 @@
|
|||||||
|
|
||||||
#undef class
|
#undef class
|
||||||
|
|
||||||
#endif /* COMPAT_AIX_MATH_H */
|
#endif /* FFMPEG_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 = (intptr_t)atomic_cas_ptr(object, (void *)old, (void *)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,181 +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
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#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((PVOID volatile *)object, (PVOID)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 = (intptr_t)InterlockedCompareExchangePointer(
|
|
||||||
(PVOID *)object, (PVOID)desired, (PVOID)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 */
|
|
||||||
880
compat/avisynth/avisynth_c.h
Normal file
880
compat/avisynth/avisynth_c.h
Normal file
@@ -0,0 +1,880 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// NOTE: this is a partial update of the Avisynth C interface to recognize
|
||||||
|
// new color spaces added in Avisynth 2.60. By no means is this document
|
||||||
|
// completely Avisynth 2.60 compliant.
|
||||||
|
|
||||||
|
#ifndef __AVISYNTH_C__
|
||||||
|
#define __AVISYNTH_C__
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
#ifdef __GNUC__
|
||||||
|
typedef long long int INT64;
|
||||||
|
#else
|
||||||
|
typedef __int64 INT64;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Constants
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __AVISYNTH_H__
|
||||||
|
enum { AVISYNTH_INTERFACE_VERSION = 4 };
|
||||||
|
#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,
|
||||||
|
AVS_PLANAR_A=1<<4,
|
||||||
|
AVS_PLANAR_R=1<<5,
|
||||||
|
AVS_PLANAR_G=1<<6,
|
||||||
|
AVS_PLANAR_B=1<<7,
|
||||||
|
AVS_PLANAR_A_ALIGNED=AVS_PLANAR_A|AVS_PLANAR_ALIGNED,
|
||||||
|
AVS_PLANAR_R_ALIGNED=AVS_PLANAR_R|AVS_PLANAR_ALIGNED,
|
||||||
|
AVS_PLANAR_G_ALIGNED=AVS_PLANAR_G|AVS_PLANAR_ALIGNED,
|
||||||
|
AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|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,
|
||||||
|
|
||||||
|
AVS_CS_SHIFT_SUB_WIDTH = 0,
|
||||||
|
AVS_CS_SHIFT_SUB_HEIGHT = 1 << 3,
|
||||||
|
AVS_CS_SHIFT_SAMPLE_BITS = 1 << 4,
|
||||||
|
|
||||||
|
AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,
|
||||||
|
AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24
|
||||||
|
AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
|
||||||
|
AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
|
||||||
|
|
||||||
|
AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
|
||||||
|
AVS_CS_UPLANEFIRST = 1 << 4, // I420
|
||||||
|
|
||||||
|
AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,
|
||||||
|
AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
|
||||||
|
AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
|
||||||
|
AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9
|
||||||
|
|
||||||
|
AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||||
|
AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||||
|
AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||||
|
AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||||
|
|
||||||
|
AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK,
|
||||||
|
AVS_CS_PLANAR_FILTER = ~( AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST )};
|
||||||
|
|
||||||
|
// 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 Reserved
|
||||||
|
// AVS_CS_I420 = 1<<4 Reserved
|
||||||
|
AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED,
|
||||||
|
|
||||||
|
AVS_CS_YV24 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // YVU 4:4:4 planar
|
||||||
|
AVS_CS_YV16 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:2 planar
|
||||||
|
AVS_CS_YV12 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:0 planar
|
||||||
|
AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YUV 4:2:0 planar
|
||||||
|
AVS_CS_IYUV = AVS_CS_I420,
|
||||||
|
AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:1 planar
|
||||||
|
AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:0 planar
|
||||||
|
AVS_CS_Y8 = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 // Y 4:0:0 planar
|
||||||
|
};
|
||||||
|
|
||||||
|
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_yv24(const AVS_VideoInfo * p)
|
||||||
|
{ return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV24 & AVS_CS_PLANAR_FILTER); }
|
||||||
|
|
||||||
|
AVSC_INLINE int avs_is_yv16(const AVS_VideoInfo * p)
|
||||||
|
{ return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV16 & AVS_CS_PLANAR_FILTER); }
|
||||||
|
|
||||||
|
AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo * p)
|
||||||
|
{ return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV12 & AVS_CS_PLANAR_FILTER); }
|
||||||
|
|
||||||
|
AVSC_INLINE int avs_is_yv411(const AVS_VideoInfo * p)
|
||||||
|
{ return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_YV411 & AVS_CS_PLANAR_FILTER); }
|
||||||
|
|
||||||
|
AVSC_INLINE int avs_is_y8(const AVS_VideoInfo * p)
|
||||||
|
{ return (p->pixel_type & AVS_CS_PLANAR_MASK) == (AVS_CS_Y8 & AVS_CS_PLANAR_FILTER); }
|
||||||
|
|
||||||
|
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_color_space(const AVS_VideoInfo * p, int c_space)
|
||||||
|
{ return avs_is_planar(p) ? ((p->pixel_type & AVS_CS_PLANAR_MASK) == (c_space & AVS_CS_PLANAR_FILTER)) : ((p->pixel_type & c_space) == c_space); }
|
||||||
|
|
||||||
|
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 {
|
||||||
|
BYTE * 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.
|
||||||
|
volatile long sequence_number;
|
||||||
|
|
||||||
|
volatile 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 {
|
||||||
|
volatile long refcount;
|
||||||
|
AVS_VideoFrameBuffer * vfb;
|
||||||
|
int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture.
|
||||||
|
int row_sizeUV, heightUV;
|
||||||
|
} 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_sizeUV;
|
||||||
|
else return 0;
|
||||||
|
case AVS_PLANAR_U_ALIGNED: case AVS_PLANAR_V_ALIGNED:
|
||||||
|
if (p->pitchUV) {
|
||||||
|
r = (p->row_sizeUV+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)); // Aligned rowsize
|
||||||
|
if (r < p->pitchUV)
|
||||||
|
return r;
|
||||||
|
return p->row_sizeUV;
|
||||||
|
} 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->heightUV;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return p->height;}
|
||||||
|
|
||||||
|
AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) {
|
||||||
|
return p->vfb->data + p->offset;}
|
||||||
|
|
||||||
|
AVSC_INLINE const BYTE* 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 BYTE* 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 BYTE* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 *);
|
||||||
|
|
||||||
|
#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;
|
||||||
|
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'; }
|
||||||
|
|
||||||
|
AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
|
||||||
|
AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);
|
||||||
|
|
||||||
|
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 an 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; 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; v.type = 'i'; v.d.integer = v0; return v; }
|
||||||
|
AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
|
||||||
|
{ AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
|
||||||
|
AVSC_INLINE AVS_Value avs_new_value_float(float v0)
|
||||||
|
{ AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
|
||||||
|
AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
|
||||||
|
{ AVS_Value v; 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; 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; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; }
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// AVS_Clip
|
||||||
|
//
|
||||||
|
|
||||||
|
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, int frame_range);
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
|
||||||
|
AVS_FilterInfo * * fi,
|
||||||
|
AVS_Value child, int store_child);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice
|
||||||
|
AVS_CPUF_SSSE3 = 0x200, // Core 2
|
||||||
|
AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield
|
||||||
|
AVS_CPUF_SSE4_1 = 0x400,
|
||||||
|
AVS_CPUF_SSE4_2 = 0x800, // Nehalem
|
||||||
|
};
|
||||||
|
|
||||||
|
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, void* 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
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
||||||
|
AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
|
||||||
|
|
||||||
|
AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* 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);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#ifdef AVSC_NO_DECLSPEC
|
||||||
|
// use LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)
|
||||||
|
/*
|
||||||
|
The following functions needs to have been declared, probably from windows.h
|
||||||
|
|
||||||
|
void* malloc(size_t)
|
||||||
|
void free(void*);
|
||||||
|
|
||||||
|
HMODULE LoadLibrary(const char*);
|
||||||
|
void* GetProcAddress(HMODULE, const char*);
|
||||||
|
FreeLibrary(HMODULE);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct AVS_Library AVS_Library;
|
||||||
|
|
||||||
|
#define AVSC_DECLARE_FUNC(name) name##_func name
|
||||||
|
|
||||||
|
struct AVS_Library {
|
||||||
|
HMODULE handle;
|
||||||
|
|
||||||
|
AVSC_DECLARE_FUNC(avs_add_function);
|
||||||
|
AVSC_DECLARE_FUNC(avs_at_exit);
|
||||||
|
AVSC_DECLARE_FUNC(avs_bit_blt);
|
||||||
|
AVSC_DECLARE_FUNC(avs_check_version);
|
||||||
|
AVSC_DECLARE_FUNC(avs_clip_get_error);
|
||||||
|
AVSC_DECLARE_FUNC(avs_copy_clip);
|
||||||
|
AVSC_DECLARE_FUNC(avs_copy_value);
|
||||||
|
AVSC_DECLARE_FUNC(avs_copy_video_frame);
|
||||||
|
AVSC_DECLARE_FUNC(avs_create_script_environment);
|
||||||
|
AVSC_DECLARE_FUNC(avs_delete_script_environment);
|
||||||
|
AVSC_DECLARE_FUNC(avs_function_exists);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_audio);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_cpu_flags);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_error);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_frame);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_parity);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_var);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_version);
|
||||||
|
AVSC_DECLARE_FUNC(avs_get_video_info);
|
||||||
|
AVSC_DECLARE_FUNC(avs_invoke);
|
||||||
|
AVSC_DECLARE_FUNC(avs_make_writable);
|
||||||
|
AVSC_DECLARE_FUNC(avs_new_c_filter);
|
||||||
|
AVSC_DECLARE_FUNC(avs_new_video_frame_a);
|
||||||
|
AVSC_DECLARE_FUNC(avs_release_clip);
|
||||||
|
AVSC_DECLARE_FUNC(avs_release_value);
|
||||||
|
AVSC_DECLARE_FUNC(avs_release_video_frame);
|
||||||
|
AVSC_DECLARE_FUNC(avs_save_string);
|
||||||
|
AVSC_DECLARE_FUNC(avs_set_cache_hints);
|
||||||
|
AVSC_DECLARE_FUNC(avs_set_global_var);
|
||||||
|
AVSC_DECLARE_FUNC(avs_set_memory_max);
|
||||||
|
AVSC_DECLARE_FUNC(avs_set_to_clip);
|
||||||
|
AVSC_DECLARE_FUNC(avs_set_var);
|
||||||
|
AVSC_DECLARE_FUNC(avs_set_working_dir);
|
||||||
|
AVSC_DECLARE_FUNC(avs_sprintf);
|
||||||
|
AVSC_DECLARE_FUNC(avs_subframe);
|
||||||
|
AVSC_DECLARE_FUNC(avs_subframe_planar);
|
||||||
|
AVSC_DECLARE_FUNC(avs_take_clip);
|
||||||
|
AVSC_DECLARE_FUNC(avs_vsprintf);
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef AVSC_DECLARE_FUNC
|
||||||
|
|
||||||
|
|
||||||
|
AVSC_INLINE AVS_Library * avs_load_library() {
|
||||||
|
AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));
|
||||||
|
if (library == NULL)
|
||||||
|
return NULL;
|
||||||
|
library->handle = LoadLibrary("avisynth");
|
||||||
|
if (library->handle == NULL)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
#define __AVSC_STRINGIFY(x) #x
|
||||||
|
#define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)
|
||||||
|
#define AVSC_LOAD_FUNC(name) {\
|
||||||
|
library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
|
||||||
|
if (library->name == NULL)\
|
||||||
|
goto fail;\
|
||||||
|
}
|
||||||
|
|
||||||
|
AVSC_LOAD_FUNC(avs_add_function);
|
||||||
|
AVSC_LOAD_FUNC(avs_at_exit);
|
||||||
|
AVSC_LOAD_FUNC(avs_bit_blt);
|
||||||
|
AVSC_LOAD_FUNC(avs_check_version);
|
||||||
|
AVSC_LOAD_FUNC(avs_clip_get_error);
|
||||||
|
AVSC_LOAD_FUNC(avs_copy_clip);
|
||||||
|
AVSC_LOAD_FUNC(avs_copy_value);
|
||||||
|
AVSC_LOAD_FUNC(avs_copy_video_frame);
|
||||||
|
AVSC_LOAD_FUNC(avs_create_script_environment);
|
||||||
|
AVSC_LOAD_FUNC(avs_delete_script_environment);
|
||||||
|
AVSC_LOAD_FUNC(avs_function_exists);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_audio);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_cpu_flags);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_error);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_frame);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_parity);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_var);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_version);
|
||||||
|
AVSC_LOAD_FUNC(avs_get_video_info);
|
||||||
|
AVSC_LOAD_FUNC(avs_invoke);
|
||||||
|
AVSC_LOAD_FUNC(avs_make_writable);
|
||||||
|
AVSC_LOAD_FUNC(avs_new_c_filter);
|
||||||
|
AVSC_LOAD_FUNC(avs_new_video_frame_a);
|
||||||
|
AVSC_LOAD_FUNC(avs_release_clip);
|
||||||
|
AVSC_LOAD_FUNC(avs_release_value);
|
||||||
|
AVSC_LOAD_FUNC(avs_release_video_frame);
|
||||||
|
AVSC_LOAD_FUNC(avs_save_string);
|
||||||
|
AVSC_LOAD_FUNC(avs_set_cache_hints);
|
||||||
|
AVSC_LOAD_FUNC(avs_set_global_var);
|
||||||
|
AVSC_LOAD_FUNC(avs_set_memory_max);
|
||||||
|
AVSC_LOAD_FUNC(avs_set_to_clip);
|
||||||
|
AVSC_LOAD_FUNC(avs_set_var);
|
||||||
|
AVSC_LOAD_FUNC(avs_set_working_dir);
|
||||||
|
AVSC_LOAD_FUNC(avs_sprintf);
|
||||||
|
AVSC_LOAD_FUNC(avs_subframe);
|
||||||
|
AVSC_LOAD_FUNC(avs_subframe_planar);
|
||||||
|
AVSC_LOAD_FUNC(avs_take_clip);
|
||||||
|
AVSC_LOAD_FUNC(avs_vsprintf);
|
||||||
|
|
||||||
|
#undef __AVSC_STRINGIFY
|
||||||
|
#undef AVSC_STRINGIFY
|
||||||
|
#undef AVSC_LOAD_FUNC
|
||||||
|
|
||||||
|
return library;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
free(library);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVSC_INLINE void avs_free_library(AVS_Library *library) {
|
||||||
|
if (library == NULL)
|
||||||
|
return;
|
||||||
|
FreeLibrary(library->handle);
|
||||||
|
free(library);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
68
compat/avisynth/avisynth_c_25.h
Normal file
68
compat/avisynth/avisynth_c_25.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
// Copyright (c) 2011 FFmpegSource Project
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
/* these are defines/functions that are used and were changed in the switch to 2.6
|
||||||
|
* and are needed to maintain full compatility with 2.5 */
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AVS_CS_YV12_25 = 1<<3 | AVS_CS_YUV | AVS_CS_PLANAR, // y-v-u, planar
|
||||||
|
AVS_CS_I420_25 = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR, // y-u-v, planar
|
||||||
|
};
|
||||||
|
|
||||||
|
AVSC_INLINE int avs_get_height_p_25(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 int avs_get_row_size_p_25(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_is_yv12_25(const AVS_VideoInfo * p)
|
||||||
|
{ return ((p->pixel_type & AVS_CS_YV12_25) == AVS_CS_YV12_25)||((p->pixel_type & AVS_CS_I420_25) == AVS_CS_I420_25); }
|
||||||
728
compat/avisynth/avxsynth_c.h
Normal file
728
compat/avisynth/avxsynth_c.h
Normal file
@@ -0,0 +1,728 @@
|
|||||||
|
// 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; 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; v.type = 'i'; v.d.integer = v0; return v; }
|
||||||
|
AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
|
||||||
|
{ AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
|
||||||
|
AVSC_INLINE AVS_Value avs_new_value_float(float v0)
|
||||||
|
{ AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
|
||||||
|
AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
|
||||||
|
{ AVS_Value v; 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; 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; 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__
|
||||||
85
compat/avisynth/windowsPorts/basicDataTypeConversions.h
Normal file
85
compat/avisynth/windowsPorts/basicDataTypeConversions.h
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#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__
|
||||||
77
compat/avisynth/windowsPorts/windows2linux.h
Normal file
77
compat/avisynth/windowsPorts/windows2linux.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#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,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minimum CUDA compatibility definitions header
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 rcombs
|
|
||||||
*
|
|
||||||
* 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_CUDA_CUDA_RUNTIME_H
|
|
||||||
#define COMPAT_CUDA_CUDA_RUNTIME_H
|
|
||||||
|
|
||||||
// Common macros
|
|
||||||
#define __global__ __attribute__((global))
|
|
||||||
#define __device__ __attribute__((device))
|
|
||||||
#define __device_builtin__ __attribute__((device_builtin))
|
|
||||||
#define __align__(N) __attribute__((aligned(N)))
|
|
||||||
#define __inline__ __inline__ __attribute__((always_inline))
|
|
||||||
|
|
||||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
|
||||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#define abs(x) ((x) < 0 ? -(x) : (x))
|
|
||||||
|
|
||||||
#define atomicAdd(a, b) (__atomic_fetch_add(a, b, __ATOMIC_SEQ_CST))
|
|
||||||
|
|
||||||
// Basic typedefs
|
|
||||||
typedef __device_builtin__ unsigned long long cudaTextureObject_t;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(2) uchar2
|
|
||||||
{
|
|
||||||
unsigned char x, y;
|
|
||||||
} uchar2;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(4) ushort2
|
|
||||||
{
|
|
||||||
unsigned short x, y;
|
|
||||||
} ushort2;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(8) float2
|
|
||||||
{
|
|
||||||
float x, y;
|
|
||||||
} float2;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(8) int2
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
} int2;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ uint3
|
|
||||||
{
|
|
||||||
unsigned int x, y, z;
|
|
||||||
} uint3;
|
|
||||||
|
|
||||||
typedef struct uint3 dim3;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(4) uchar4
|
|
||||||
{
|
|
||||||
unsigned char x, y, z, w;
|
|
||||||
} uchar4;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(8) ushort4
|
|
||||||
{
|
|
||||||
unsigned short x, y, z, w;
|
|
||||||
} ushort4;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(16) int4
|
|
||||||
{
|
|
||||||
int x, y, z, w;
|
|
||||||
} int4;
|
|
||||||
|
|
||||||
typedef struct __device_builtin__ __align__(16) float4
|
|
||||||
{
|
|
||||||
float x, y, z, w;
|
|
||||||
} float4;
|
|
||||||
|
|
||||||
// Accessors for special registers
|
|
||||||
#define GETCOMP(reg, comp) \
|
|
||||||
asm("mov.u32 %0, %%" #reg "." #comp ";" : "=r"(tmp)); \
|
|
||||||
ret.comp = tmp;
|
|
||||||
|
|
||||||
#define GET(name, reg) static inline __device__ uint3 name() {\
|
|
||||||
uint3 ret; \
|
|
||||||
unsigned tmp; \
|
|
||||||
GETCOMP(reg, x) \
|
|
||||||
GETCOMP(reg, y) \
|
|
||||||
GETCOMP(reg, z) \
|
|
||||||
return ret; \
|
|
||||||
}
|
|
||||||
|
|
||||||
GET(getBlockIdx, ctaid)
|
|
||||||
GET(getBlockDim, ntid)
|
|
||||||
GET(getThreadIdx, tid)
|
|
||||||
|
|
||||||
// Instead of externs for these registers, we turn access to them into calls into trivial ASM
|
|
||||||
#define blockIdx (getBlockIdx())
|
|
||||||
#define blockDim (getBlockDim())
|
|
||||||
#define threadIdx (getThreadIdx())
|
|
||||||
|
|
||||||
// Basic initializers (simple macros rather than inline functions)
|
|
||||||
#define make_int2(a, b) ((int2){.x = a, .y = b})
|
|
||||||
#define make_uchar2(a, b) ((uchar2){.x = a, .y = b})
|
|
||||||
#define make_ushort2(a, b) ((ushort2){.x = a, .y = b})
|
|
||||||
#define make_float2(a, b) ((float2){.x = a, .y = b})
|
|
||||||
#define make_int4(a, b, c, d) ((int4){.x = a, .y = b, .z = c, .w = d})
|
|
||||||
#define make_uchar4(a, b, c, d) ((uchar4){.x = a, .y = b, .z = c, .w = d})
|
|
||||||
#define make_ushort4(a, b, c, d) ((ushort4){.x = a, .y = b, .z = c, .w = d})
|
|
||||||
#define make_float4(a, b, c, d) ((float4){.x = a, .y = b, .z = c, .w = d})
|
|
||||||
|
|
||||||
// Conversions from the tex instruction's 4-register output to various types
|
|
||||||
#define TEX2D(type, ret) static inline __device__ void conv(type* out, unsigned a, unsigned b, unsigned c, unsigned d) {*out = (ret);}
|
|
||||||
|
|
||||||
TEX2D(unsigned char, a & 0xFF)
|
|
||||||
TEX2D(unsigned short, a & 0xFFFF)
|
|
||||||
TEX2D(float, a)
|
|
||||||
TEX2D(uchar2, make_uchar2(a & 0xFF, b & 0xFF))
|
|
||||||
TEX2D(ushort2, make_ushort2(a & 0xFFFF, b & 0xFFFF))
|
|
||||||
TEX2D(float2, make_float2(a, b))
|
|
||||||
TEX2D(uchar4, make_uchar4(a & 0xFF, b & 0xFF, c & 0xFF, d & 0xFF))
|
|
||||||
TEX2D(ushort4, make_ushort4(a & 0xFFFF, b & 0xFFFF, c & 0xFFFF, d & 0xFFFF))
|
|
||||||
TEX2D(float4, make_float4(a, b, c, d))
|
|
||||||
|
|
||||||
// Template calling tex instruction and converting the output to the selected type
|
|
||||||
template<typename T>
|
|
||||||
inline __device__ T tex2D(cudaTextureObject_t texObject, float x, float y)
|
|
||||||
{
|
|
||||||
T ret;
|
|
||||||
unsigned ret1, ret2, ret3, ret4;
|
|
||||||
asm("tex.2d.v4.u32.f32 {%0, %1, %2, %3}, [%4, {%5, %6}];" :
|
|
||||||
"=r"(ret1), "=r"(ret2), "=r"(ret3), "=r"(ret4) :
|
|
||||||
"l"(texObject), "f"(x), "f"(y));
|
|
||||||
conv(&ret, ret1, ret2, ret3, ret4);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline __device__ float4 tex2D<float4>(cudaTextureObject_t texObject, float x, float y)
|
|
||||||
{
|
|
||||||
float4 ret;
|
|
||||||
asm("tex.2d.v4.f32.f32 {%0, %1, %2, %3}, [%4, {%5, %6}];" :
|
|
||||||
"=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) :
|
|
||||||
"l"(texObject), "f"(x), "f"(y));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline __device__ float tex2D<float>(cudaTextureObject_t texObject, float x, float y)
|
|
||||||
{
|
|
||||||
return tex2D<float4>(texObject, x, y).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline __device__ float2 tex2D<float2>(cudaTextureObject_t texObject, float x, float y)
|
|
||||||
{
|
|
||||||
float4 ret = tex2D<float4>(texObject, x, y);
|
|
||||||
return make_float2(ret.x, ret.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Math helper functions
|
|
||||||
static inline __device__ float floorf(float a) { return __builtin_floorf(a); }
|
|
||||||
static inline __device__ float floor(float a) { return __builtin_floorf(a); }
|
|
||||||
static inline __device__ double floor(double a) { return __builtin_floor(a); }
|
|
||||||
static inline __device__ float ceilf(float a) { return __builtin_ceilf(a); }
|
|
||||||
static inline __device__ float ceil(float a) { return __builtin_ceilf(a); }
|
|
||||||
static inline __device__ double ceil(double a) { return __builtin_ceil(a); }
|
|
||||||
static inline __device__ float truncf(float a) { return __builtin_truncf(a); }
|
|
||||||
static inline __device__ float trunc(float a) { return __builtin_truncf(a); }
|
|
||||||
static inline __device__ double trunc(double a) { return __builtin_trunc(a); }
|
|
||||||
static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); }
|
|
||||||
static inline __device__ float fabs(float a) { return __builtin_fabsf(a); }
|
|
||||||
static inline __device__ double fabs(double a) { return __builtin_fabs(a); }
|
|
||||||
static inline __device__ float sqrtf(float a) { return __builtin_sqrtf(a); }
|
|
||||||
|
|
||||||
static inline __device__ float __saturatef(float a) { return __nvvm_saturate_f(a); }
|
|
||||||
static inline __device__ float __sinf(float a) { return __nvvm_sin_approx_f(a); }
|
|
||||||
static inline __device__ float __cosf(float a) { return __nvvm_cos_approx_f(a); }
|
|
||||||
static inline __device__ float __expf(float a) { return __nvvm_ex2_approx_f(a * (float)__builtin_log2(__builtin_exp(1))); }
|
|
||||||
|
|
||||||
#endif /* COMPAT_CUDA_CUDA_RUNTIME_H */
|
|
||||||
@@ -1,33 +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_CUDA_DYNLINK_LOADER_H
|
|
||||||
#define COMPAT_CUDA_DYNLINK_LOADER_H
|
|
||||||
|
|
||||||
#include "libavutil/log.h"
|
|
||||||
#include "compat/w32dlfcn.h"
|
|
||||||
|
|
||||||
#define FFNV_LOAD_FUNC(path) dlopen((path), RTLD_LAZY)
|
|
||||||
#define FFNV_SYM_FUNC(lib, sym) dlsym((lib), (sym))
|
|
||||||
#define FFNV_FREE_FUNC(lib) dlclose(lib)
|
|
||||||
#define FFNV_LOG_FUNC(logctx, msg, ...) av_log(logctx, AV_LOG_ERROR, msg, __VA_ARGS__)
|
|
||||||
#define FFNV_DEBUG_LOG_FUNC(logctx, msg, ...) av_log(logctx, AV_LOG_DEBUG, msg, __VA_ARGS__)
|
|
||||||
|
|
||||||
#include <ffnvcodec/dynlink_loader.h>
|
|
||||||
|
|
||||||
#endif /* COMPAT_CUDA_DYNLINK_LOADER_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,47 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define FUN(name, type, op) \
|
|
||||||
type name(type x, type y) \
|
|
||||||
{ \
|
|
||||||
if (fpclassify(x) == FP_NAN) return y; \
|
|
||||||
if (fpclassify(y) == FP_NAN) return x; \
|
|
||||||
return x op y ? x : y; \
|
|
||||||
}
|
|
||||||
|
|
||||||
FUN(fmin, double, <)
|
|
||||||
FUN(fmax, double, >)
|
|
||||||
FUN(fminf, float, <)
|
|
||||||
FUN(fmaxf, float, >)
|
|
||||||
|
|
||||||
long double fmodl(long double x, long double y)
|
|
||||||
{
|
|
||||||
return fmod(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
long double scalbnl(long double x, int exp)
|
|
||||||
{
|
|
||||||
return scalbn(x, exp);
|
|
||||||
}
|
|
||||||
|
|
||||||
long double copysignl(long double x, long double y)
|
|
||||||
{
|
|
||||||
return copysign(x, y);
|
|
||||||
}
|
|
||||||
@@ -1,25 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
double fmin(double, double);
|
|
||||||
double fmax(double, double);
|
|
||||||
float fminf(float, float);
|
|
||||||
float fmaxf(float, float);
|
|
||||||
long double fmodl(long double, long double);
|
|
||||||
long double scalbnl(long double, int);
|
|
||||||
long double copysignl(long double, long double);
|
|
||||||
@@ -54,7 +54,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++;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ int avpriv_vsnprintf(char *s, size_t n, const char *fmt,
|
|||||||
* recommends to provide _snprintf/_vsnprintf() a buffer size that
|
* recommends to provide _snprintf/_vsnprintf() a buffer size that
|
||||||
* is one less than the actual buffer, and zero it before calling
|
* is one less than the actual buffer, and zero it before calling
|
||||||
* _snprintf/_vsnprintf() to workaround this problem.
|
* _snprintf/_vsnprintf() to workaround this problem.
|
||||||
* See https://web.archive.org/web/20151214111935/http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */
|
* See http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */
|
||||||
memset(s, 0, n);
|
memset(s, 0, n);
|
||||||
va_copy(ap_copy, ap);
|
va_copy(ap_copy, ap);
|
||||||
ret = _vsnprintf(s, n - 1, fmt, ap_copy);
|
ret = _vsnprintf(s, n - 1, fmt, ap_copy);
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2017 KO Myung-Hun <komh@chollian.net>
|
* Copyright (c) 2011 KO Myung-Hun <komh@chollian.net>
|
||||||
*
|
*
|
||||||
* This file is part of FFmpeg.
|
* This file is part of FFmpeg.
|
||||||
*
|
*
|
||||||
@@ -23,118 +23,96 @@
|
|||||||
* os2threads to pthreads wrapper
|
* os2threads to pthreads wrapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMPAT_OS2THREADS_H
|
#ifndef AVCODEC_OS2PTHREADS_H
|
||||||
#define COMPAT_OS2THREADS_H
|
#define AVCODEC_OS2PTHREADS_H
|
||||||
|
|
||||||
#define INCL_DOS
|
#define INCL_DOS
|
||||||
#define INCL_DOSERRORS
|
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
|
|
||||||
#undef __STRICT_ANSI__ /* for _beginthread() */
|
#undef __STRICT_ANSI__ /* for _beginthread() */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <sys/builtin.h>
|
#include "libavutil/mem.h"
|
||||||
#include <sys/fmutex.h>
|
|
||||||
|
|
||||||
#include "libavutil/attributes.h"
|
|
||||||
#include "libavutil/common.h"
|
|
||||||
#include "libavutil/time.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
TID tid;
|
|
||||||
void *(*start_routine)(void *);
|
|
||||||
void *arg;
|
|
||||||
void *result;
|
|
||||||
} pthread_t;
|
|
||||||
|
|
||||||
|
typedef TID pthread_t;
|
||||||
typedef void pthread_attr_t;
|
typedef void pthread_attr_t;
|
||||||
|
|
||||||
typedef _fmutex pthread_mutex_t;
|
typedef HMTX pthread_mutex_t;
|
||||||
typedef void pthread_mutexattr_t;
|
typedef void pthread_mutexattr_t;
|
||||||
|
|
||||||
#define PTHREAD_MUTEX_INITIALIZER _FMUTEX_INITIALIZER
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
HEV event_sem;
|
HEV event_sem;
|
||||||
HEV ack_sem;
|
int wait_count;
|
||||||
volatile unsigned wait_count;
|
|
||||||
} pthread_cond_t;
|
} pthread_cond_t;
|
||||||
|
|
||||||
typedef void pthread_condattr_t;
|
typedef void pthread_condattr_t;
|
||||||
|
|
||||||
typedef struct {
|
struct thread_arg {
|
||||||
volatile int done;
|
void *(*start_routine)(void *);
|
||||||
_fmutex mtx;
|
void *arg;
|
||||||
} pthread_once_t;
|
};
|
||||||
|
|
||||||
#define PTHREAD_ONCE_INIT {0, _FMUTEX_INITIALIZER}
|
|
||||||
|
|
||||||
static void thread_entry(void *arg)
|
static void thread_entry(void *arg)
|
||||||
{
|
{
|
||||||
pthread_t *thread = arg;
|
struct thread_arg *thread_arg = arg;
|
||||||
|
|
||||||
thread->result = thread->start_routine(thread->arg);
|
thread_arg->start_routine(thread_arg->arg);
|
||||||
|
|
||||||
|
av_free(thread_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_create(pthread_t *thread,
|
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
|
||||||
const pthread_attr_t *attr,
|
|
||||||
void *(*start_routine)(void*),
|
|
||||||
void *arg)
|
|
||||||
{
|
{
|
||||||
thread->start_routine = start_routine;
|
struct thread_arg *thread_arg;
|
||||||
thread->arg = arg;
|
|
||||||
thread->result = NULL;
|
|
||||||
|
|
||||||
thread->tid = _beginthread(thread_entry, NULL, 1024 * 1024, thread);
|
thread_arg = av_mallocz(sizeof(struct thread_arg));
|
||||||
|
|
||||||
|
thread_arg->start_routine = start_routine;
|
||||||
|
thread_arg->arg = arg;
|
||||||
|
|
||||||
|
*thread = _beginthread(thread_entry, NULL, 256 * 1024, thread_arg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
|
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
|
||||||
{
|
{
|
||||||
DosWaitThread(&thread.tid, DCWW_WAIT);
|
DosWaitThread((PTID)&thread, DCWW_WAIT);
|
||||||
|
|
||||||
if (value_ptr)
|
|
||||||
*value_ptr = thread.result;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex,
|
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
|
||||||
const pthread_mutexattr_t *attr)
|
|
||||||
{
|
{
|
||||||
_fmutex_create(mutex, 0);
|
DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
_fmutex_close(mutex);
|
DosCloseMutexSem(*(PHMTX)mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
|
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
_fmutex_request(mutex, 0);
|
DosRequestMutexSem(*(PHMTX)mutex, SEM_INDEFINITE_WAIT);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
_fmutex_release(mutex);
|
DosReleaseMutexSem(*(PHMTX)mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_init(pthread_cond_t *cond,
|
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
|
||||||
const pthread_condattr_t *attr)
|
|
||||||
{
|
{
|
||||||
DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE);
|
DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE);
|
||||||
DosCreateEventSem(NULL, &cond->ack_sem, DCE_POSTONE, FALSE);
|
|
||||||
|
|
||||||
cond->wait_count = 0;
|
cond->wait_count = 0;
|
||||||
|
|
||||||
@@ -144,16 +122,16 @@ static av_always_inline int pthread_cond_init(pthread_cond_t *cond,
|
|||||||
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
|
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
DosCloseEventSem(cond->event_sem);
|
DosCloseEventSem(cond->event_sem);
|
||||||
DosCloseEventSem(cond->ack_sem);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
|
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
if (!__atomic_cmpxchg32(&cond->wait_count, 0, 0)) {
|
if (cond->wait_count > 0) {
|
||||||
DosPostEventSem(cond->event_sem);
|
DosPostEventSem(cond->event_sem);
|
||||||
DosWaitEventSem(cond->ack_sem, SEM_INDEFINITE_WAIT);
|
|
||||||
|
cond->wait_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -161,69 +139,26 @@ static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
|
|||||||
|
|
||||||
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
|
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
while (!__atomic_cmpxchg32(&cond->wait_count, 0, 0))
|
while (cond->wait_count > 0) {
|
||||||
pthread_cond_signal(cond);
|
DosPostEventSem(cond->event_sem);
|
||||||
|
|
||||||
|
cond->wait_count--;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_cond_timedwait(pthread_cond_t *cond,
|
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
||||||
pthread_mutex_t *mutex,
|
|
||||||
const struct timespec *abstime)
|
|
||||||
{
|
{
|
||||||
int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000;
|
cond->wait_count++;
|
||||||
ULONG t = av_clip64(abs_milli - av_gettime() / 1000, 0, ULONG_MAX);
|
|
||||||
|
|
||||||
__atomic_increment(&cond->wait_count);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(mutex);
|
|
||||||
|
|
||||||
APIRET ret = DosWaitEventSem(cond->event_sem, t);
|
|
||||||
|
|
||||||
__atomic_decrement(&cond->wait_count);
|
|
||||||
|
|
||||||
DosPostEventSem(cond->ack_sem);
|
|
||||||
|
|
||||||
pthread_mutex_lock(mutex);
|
|
||||||
|
|
||||||
return (ret == ERROR_TIMEOUT) ? ETIMEDOUT : 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);
|
pthread_mutex_unlock(mutex);
|
||||||
|
|
||||||
DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT);
|
DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT);
|
||||||
|
|
||||||
__atomic_decrement(&cond->wait_count);
|
|
||||||
|
|
||||||
DosPostEventSem(cond->ack_sem);
|
|
||||||
|
|
||||||
pthread_mutex_lock(mutex);
|
pthread_mutex_lock(mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_always_inline int pthread_once(pthread_once_t *once_control,
|
#endif /* AVCODEC_OS2PTHREADS_H */
|
||||||
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 */
|
|
||||||
|
|||||||
10
compat/plan9/head
Executable file
10
compat/plan9/head
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
n=10
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
-n) n=$2; shift 2 ;;
|
||||||
|
-n*) n=${1#-n}; shift ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exec sed ${n}q "$@"
|
||||||
34
compat/plan9/main.c
Normal file
34
compat/plan9/main.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
int plan9_main(int argc, char **argv);
|
||||||
|
|
||||||
|
#undef main
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* The setfcr() function in lib9 is broken, must use asm. */
|
||||||
|
#ifdef __i386
|
||||||
|
short fcr;
|
||||||
|
__asm__ volatile ("fstcw %0 \n"
|
||||||
|
"or $63, %0 \n"
|
||||||
|
"fldcw %0 \n"
|
||||||
|
: "=m"(fcr));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return plan9_main(argc, argv);
|
||||||
|
}
|
||||||
2
compat/plan9/printf
Executable file
2
compat/plan9/printf
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exec awk "BEGIN { for (i = 2; i < ARGC; i++) printf \"$1\", ARGV[i] }" "$@"
|
||||||
@@ -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;
|
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
|
|
||||||
static const char *check_nan_suffix(const char *s)
|
static char *check_nan_suffix(char *s)
|
||||||
{
|
{
|
||||||
const char *start = s;
|
char *start = s;
|
||||||
|
|
||||||
if (*s++ != '(')
|
if (*s++ != '(')
|
||||||
return start;
|
return start;
|
||||||
@@ -44,7 +44,7 @@ double strtod(const char *, char **);
|
|||||||
|
|
||||||
double avpriv_strtod(const char *nptr, char **endptr)
|
double avpriv_strtod(const char *nptr, char **endptr)
|
||||||
{
|
{
|
||||||
const char *end;
|
char *end;
|
||||||
double res;
|
double res;
|
||||||
|
|
||||||
/* Skip leading spaces */
|
/* Skip leading spaces */
|
||||||
@@ -81,13 +81,13 @@ double avpriv_strtod(const char *nptr, char **endptr)
|
|||||||
!av_strncasecmp(nptr, "+0x", 3)) {
|
!av_strncasecmp(nptr, "+0x", 3)) {
|
||||||
/* FIXME this doesn't handle exponents, non-integers (float/double)
|
/* FIXME this doesn't handle exponents, non-integers (float/double)
|
||||||
* and numbers too large for long long */
|
* and numbers too large for long long */
|
||||||
res = strtoll(nptr, (char **)&end, 16);
|
res = strtoll(nptr, &end, 16);
|
||||||
} else {
|
} else {
|
||||||
res = strtod(nptr, (char **)&end);
|
res = strtod(nptr, &end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endptr)
|
if (endptr)
|
||||||
*endptr = (char *)end;
|
*endptr = end;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
30
compat/tms470/math.h
Normal file
30
compat/tms470/math.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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 FFMPEG_COMPAT_TMS470_MATH_H
|
||||||
|
#define FFMPEG_COMPAT_TMS470_MATH_H
|
||||||
|
|
||||||
|
#include_next <math.h>
|
||||||
|
|
||||||
|
#undef INFINITY
|
||||||
|
#undef NAN
|
||||||
|
|
||||||
|
#define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 }))
|
||||||
|
#define NAN (*(const float*)((const unsigned []){ 0x7fc00000 }))
|
||||||
|
|
||||||
|
#endif /* FFMPEG_COMPAT_TMS470_MATH_H */
|
||||||
@@ -19,9 +19,6 @@
|
|||||||
* 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)
|
||||||
@@ -30,5 +27,3 @@
|
|||||||
#if !defined(va_copy) && defined(__GNUC__) && __GNUC__ < 3
|
#if !defined(va_copy) && defined(__GNUC__) && __GNUC__ < 3
|
||||||
#define va_copy(dst, src) __va_copy(dst, src)
|
#define va_copy(dst, src) __va_copy(dst, src)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* COMPAT_VA_COPY_H */
|
|
||||||
|
|||||||
@@ -1,150 +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 <stdint.h>
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "libavutil/macros.h"
|
|
||||||
#include "libavutil/wchar_filename.h"
|
|
||||||
|
|
||||||
static inline wchar_t *get_module_filename(HMODULE module)
|
|
||||||
{
|
|
||||||
wchar_t *path = NULL, *new_path;
|
|
||||||
DWORD path_size = 0, path_len;
|
|
||||||
|
|
||||||
do {
|
|
||||||
path_size = path_size ? FFMIN(2 * path_size, INT16_MAX + 1) : MAX_PATH;
|
|
||||||
new_path = av_realloc_array(path, path_size, sizeof *path);
|
|
||||||
if (!new_path) {
|
|
||||||
av_free(path);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
path = new_path;
|
|
||||||
// Returns path_size in case of insufficient buffer.
|
|
||||||
// Whether the error is set or not and whether the output
|
|
||||||
// is null-terminated or not depends on the version of Windows.
|
|
||||||
path_len = GetModuleFileNameW(module, path, path_size);
|
|
||||||
} while (path_len && path_size <= INT16_MAX && path_size <= path_len);
|
|
||||||
|
|
||||||
if (!path_len) {
|
|
||||||
av_free(path);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
{
|
|
||||||
wchar_t *name_w;
|
|
||||||
HMODULE module = NULL;
|
|
||||||
if (utf8towchar(name, &name_w))
|
|
||||||
name_w = NULL;
|
|
||||||
#if _WIN32_WINNT < 0x0602
|
|
||||||
// On Win7 and earlier we check if KB2533623 is available
|
|
||||||
if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) {
|
|
||||||
wchar_t *path = NULL, *new_path;
|
|
||||||
DWORD pathlen, pathsize, namelen;
|
|
||||||
if (!name_w)
|
|
||||||
goto exit;
|
|
||||||
namelen = wcslen(name_w);
|
|
||||||
// Try local directory first
|
|
||||||
path = get_module_filename(NULL);
|
|
||||||
if (!path)
|
|
||||||
goto exit;
|
|
||||||
new_path = wcsrchr(path, '\\');
|
|
||||||
if (!new_path)
|
|
||||||
goto exit;
|
|
||||||
pathlen = new_path - path;
|
|
||||||
pathsize = pathlen + namelen + 2;
|
|
||||||
new_path = av_realloc_array(path, pathsize, sizeof *path);
|
|
||||||
if (!new_path)
|
|
||||||
goto exit;
|
|
||||||
path = new_path;
|
|
||||||
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, pathsize);
|
|
||||||
if (!pathlen)
|
|
||||||
goto exit;
|
|
||||||
// Buffer is not enough in two cases:
|
|
||||||
// 1. system directory + \ + module name
|
|
||||||
// 2. system directory even without the module name.
|
|
||||||
if (pathlen + namelen + 2 > pathsize) {
|
|
||||||
pathsize = pathlen + namelen + 2;
|
|
||||||
new_path = av_realloc_array(path, pathsize, sizeof *path);
|
|
||||||
if (!new_path)
|
|
||||||
goto exit;
|
|
||||||
path = new_path;
|
|
||||||
// Query again to handle the case #2.
|
|
||||||
pathlen = GetSystemDirectoryW(path, pathsize);
|
|
||||||
if (!pathlen)
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
path[pathlen] = L'\\';
|
|
||||||
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
|
|
||||||
#if HAVE_WINRT
|
|
||||||
if (!name_w)
|
|
||||||
return NULL;
|
|
||||||
module = LoadPackagedLibrary(name_w, 0);
|
|
||||||
#else
|
|
||||||
#define LOAD_FLAGS (LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32)
|
|
||||||
/* filename may be be in CP_ACP */
|
|
||||||
if (!name_w)
|
|
||||||
return LoadLibraryExA(name, NULL, LOAD_FLAGS);
|
|
||||||
module = LoadLibraryExW(name_w, NULL, LOAD_FLAGS);
|
|
||||||
#undef LOAD_FLAGS
|
|
||||||
#endif
|
|
||||||
av_free(name_w);
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
#define dlopen(name, flags) win32_dlopen(name)
|
|
||||||
#define dlclose FreeLibrary
|
|
||||||
#define dlsym GetProcAddress
|
|
||||||
#else
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* COMPAT_W32DLFCN_H */
|
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
* w32threads to pthreads wrapper
|
* w32threads to pthreads wrapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMPAT_W32PTHREADS_H
|
#ifndef FFMPEG_COMPAT_W32PTHREADS_H
|
||||||
#define COMPAT_W32PTHREADS_H
|
#define FFMPEG_COMPAT_W32PTHREADS_H
|
||||||
|
|
||||||
/* Build up a pthread-like API using underlying Windows API. Have only static
|
/* 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
|
* methods so as to not conflict with a potentially linked in pthread-win32
|
||||||
@@ -38,13 +38,10 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "libavutil/attributes.h"
|
|
||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
#include "libavutil/internal.h"
|
#include "libavutil/internal.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "libavutil/time.h"
|
|
||||||
|
|
||||||
typedef struct pthread_t {
|
typedef struct pthread_t {
|
||||||
void *handle;
|
void *handle;
|
||||||
@@ -53,139 +50,234 @@ typedef struct pthread_t {
|
|||||||
void *ret;
|
void *ret;
|
||||||
} pthread_t;
|
} pthread_t;
|
||||||
|
|
||||||
/* use light weight mutex/condition variable API for Windows Vista and later */
|
/* the conditional variable api for windows 6.0+ uses critical sections and
|
||||||
typedef SRWLOCK pthread_mutex_t;
|
* not mutexes */
|
||||||
typedef CONDITION_VARIABLE pthread_cond_t;
|
typedef CRITICAL_SECTION pthread_mutex_t;
|
||||||
|
|
||||||
#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT
|
/* This is the CONDITIONAL_VARIABLE typedef for using Window's native
|
||||||
#define PTHREAD_COND_INITIALIZER CONDITION_VARIABLE_INIT
|
* conditional variables on kernels 6.0+.
|
||||||
|
* MinGW does not currently have this typedef. */
|
||||||
|
typedef struct pthread_cond_t {
|
||||||
|
void *ptr;
|
||||||
|
} pthread_cond_t;
|
||||||
|
|
||||||
#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
|
/* function pointers to conditional variable API on windows 6.0+ kernels */
|
||||||
#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
|
#if _WIN32_WINNT < 0x0600
|
||||||
|
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);
|
||||||
|
#else
|
||||||
|
#define cond_init InitializeConditionVariable
|
||||||
|
#define cond_broadcast WakeAllConditionVariable
|
||||||
|
#define cond_signal WakeConditionVariable
|
||||||
|
#define cond_wait SleepConditionVariableCS
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PTHREAD_CANCEL_ENABLE 1
|
static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
|
||||||
#define PTHREAD_CANCEL_DISABLE 0
|
|
||||||
|
|
||||||
static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
|
|
||||||
{
|
{
|
||||||
pthread_t *h = (pthread_t*)arg;
|
pthread_t *h = arg;
|
||||||
h->ret = h->func(h->arg);
|
h->ret = h->func(h->arg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
|
static int pthread_create(pthread_t *thread, const void *unused_attr,
|
||||||
void *(*start_routine)(void*), void *arg)
|
void *(*start_routine)(void*), void *arg)
|
||||||
{
|
{
|
||||||
thread->func = start_routine;
|
thread->func = start_routine;
|
||||||
thread->arg = arg;
|
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,
|
thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread,
|
||||||
0, NULL);
|
0, NULL);
|
||||||
#endif
|
|
||||||
return !thread->handle;
|
return !thread->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_unused int pthread_join(pthread_t thread, void **value_ptr)
|
static void pthread_join(pthread_t thread, void **value_ptr)
|
||||||
{
|
{
|
||||||
DWORD ret = WaitForSingleObject(thread.handle, INFINITE);
|
DWORD ret = WaitForSingleObject(thread.handle, INFINITE);
|
||||||
if (ret != WAIT_OBJECT_0) {
|
if (ret != WAIT_OBJECT_0)
|
||||||
if (ret == WAIT_ABANDONED)
|
return;
|
||||||
return EINVAL;
|
|
||||||
else
|
|
||||||
return EDEADLK;
|
|
||||||
}
|
|
||||||
if (value_ptr)
|
if (value_ptr)
|
||||||
*value_ptr = thread.ret;
|
*value_ptr = thread.ret;
|
||||||
CloseHandle(thread.handle);
|
CloseHandle(thread.handle);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr)
|
static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr)
|
||||||
{
|
{
|
||||||
InitializeSRWLock(m);
|
InitializeCriticalSection(m);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int pthread_mutex_destroy(pthread_mutex_t *m)
|
static inline int pthread_mutex_destroy(pthread_mutex_t *m)
|
||||||
{
|
{
|
||||||
/* Unlocked SWR locks use no resources */
|
DeleteCriticalSection(m);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int pthread_mutex_lock(pthread_mutex_t *m)
|
static inline int pthread_mutex_lock(pthread_mutex_t *m)
|
||||||
{
|
{
|
||||||
AcquireSRWLockExclusive(m);
|
EnterCriticalSection(m);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int pthread_mutex_unlock(pthread_mutex_t *m)
|
static inline int pthread_mutex_unlock(pthread_mutex_t *m)
|
||||||
{
|
{
|
||||||
ReleaseSRWLockExclusive(m);
|
LeaveCriticalSection(m);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef INIT_ONCE pthread_once_t;
|
/* for pre-Windows 6.0 platforms we need to define and use our own condition
|
||||||
#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
|
* 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;
|
||||||
|
|
||||||
static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
|
static int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
|
||||||
{
|
{
|
||||||
BOOL pending = FALSE;
|
win32_cond_t *win32_cond = NULL;
|
||||||
InitOnceBeginInitialize(once_control, 0, &pending, NULL);
|
if (cond_init) {
|
||||||
if (pending)
|
cond_init(cond);
|
||||||
init_routine();
|
return 0;
|
||||||
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)
|
|
||||||
{
|
|
||||||
SleepConditionVariableSRW(cond, mutex, INFINITE, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
|
||||||
const struct timespec *abstime)
|
|
||||||
{
|
|
||||||
int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000;
|
|
||||||
DWORD t = av_clip64(abs_milli - av_gettime() / 1000, 0, UINT32_MAX);
|
|
||||||
|
|
||||||
if (!SleepConditionVariableSRW(cond, mutex, t, 0)) {
|
|
||||||
DWORD err = GetLastError();
|
|
||||||
if (err == ERROR_TIMEOUT)
|
|
||||||
return ETIMEDOUT;
|
|
||||||
else
|
|
||||||
return EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_signal(pthread_cond_t *cond)
|
static void pthread_cond_destroy(pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
WakeConditionVariable(cond);
|
win32_cond_t *win32_cond = cond->ptr;
|
||||||
return 0;
|
/* native condition variables do not destroy */
|
||||||
|
if (cond_init)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_setcancelstate(int state, int *oldstate)
|
static void pthread_cond_broadcast(pthread_cond_t *cond)
|
||||||
{
|
{
|
||||||
return 0;
|
win32_cond_t *win32_cond = cond->ptr;
|
||||||
|
int have_waiter;
|
||||||
|
|
||||||
|
if (cond_broadcast) {
|
||||||
|
cond_broadcast(cond);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* COMPAT_W32PTHREADS_H */
|
static 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 void pthread_cond_signal(pthread_cond_t *cond)
|
||||||
|
{
|
||||||
|
win32_cond_t *win32_cond = cond->ptr;
|
||||||
|
int have_waiter;
|
||||||
|
if (cond_signal) {
|
||||||
|
cond_signal(cond);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
static 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");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FFMPEG_COMPAT_W32PTHREADS_H */
|
||||||
|
|||||||
@@ -45,11 +45,7 @@ libname=$(mktemp -u "library").lib
|
|||||||
|
|
||||||
trap 'rm -f -- $libname' EXIT
|
trap 'rm -f -- $libname' EXIT
|
||||||
|
|
||||||
if [ -n "$AR" ]; then
|
lib -out:${libname} $@ >/dev/null
|
||||||
$AR rcs ${libname} $@ >/dev/null
|
|
||||||
else
|
|
||||||
lib.exe -out:${libname} $@ >/dev/null
|
|
||||||
fi
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo "Could not create temporary library." >&2
|
echo "Could not create temporary library." >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -58,7 +54,23 @@ fi
|
|||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
|
|
||||||
prefix="$EXTERN_PREFIX"
|
# 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
|
started=0
|
||||||
regex="none"
|
regex="none"
|
||||||
@@ -100,19 +112,7 @@ for line in $(cat ${vscript} | tr '\t' ' '); do
|
|||||||
'
|
'
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$NM" ]; then
|
dump=$(dumpbin -linkermember:1 ${libname})
|
||||||
# Use eval, since NM="nm -g"
|
|
||||||
dump=$(eval "$NM --defined-only -g ${libname}" |
|
|
||||||
grep -v : |
|
|
||||||
grep -v ^$ |
|
|
||||||
cut -d' ' -f3 |
|
|
||||||
sed -e "s/^${prefix}//")
|
|
||||||
else
|
|
||||||
dump=$(dumpbin.exe -linkermember:1 ${libname} |
|
|
||||||
sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' |
|
|
||||||
tail -n +2 |
|
|
||||||
cut -d' ' -f3)
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm ${libname}
|
rm ${libname}
|
||||||
|
|
||||||
@@ -121,6 +121,9 @@ list=""
|
|||||||
for exp in ${regex}; do
|
for exp in ${regex}; do
|
||||||
list="${list}"'
|
list="${list}"'
|
||||||
'$(echo "${dump}" |
|
'$(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}" |
|
grep "^${exp}" |
|
||||||
sed -e 's/^/ /')
|
sed -e 's/^/ /')
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -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.exe $@
|
|
||||||
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
|
|
||||||
1644
doc/APIchanges
1644
doc/APIchanges
File diff suppressed because it is too large
Load Diff
2423
doc/Doxyfile
2423
doc/Doxyfile
File diff suppressed because it is too large
Load Diff
58
doc/Makefile
58
doc/Makefile
@@ -24,12 +24,8 @@ HTMLPAGES = $(AVPROGS-yes:%=doc/%.html) $(AVPROGS-yes:%=doc/%-all.html) $(COMP
|
|||||||
doc/fate.html \
|
doc/fate.html \
|
||||||
doc/general.html \
|
doc/general.html \
|
||||||
doc/git-howto.html \
|
doc/git-howto.html \
|
||||||
doc/mailing-list-faq.html \
|
|
||||||
doc/nut.html \
|
doc/nut.html \
|
||||||
doc/platform.html \
|
doc/platform.html \
|
||||||
$(SRC_PATH)/doc/bootstrap.min.css \
|
|
||||||
$(SRC_PATH)/doc/style.min.css \
|
|
||||||
$(SRC_PATH)/doc/default.css \
|
|
||||||
|
|
||||||
TXTPAGES = doc/fate.txt \
|
TXTPAGES = doc/fate.txt \
|
||||||
|
|
||||||
@@ -40,6 +36,26 @@ DOCS-$(CONFIG_MANPAGES) += $(MANPAGES)
|
|||||||
DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES)
|
DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES)
|
||||||
DOCS = $(DOCS-yes)
|
DOCS = $(DOCS-yes)
|
||||||
|
|
||||||
|
DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
|
||||||
|
DOC_EXAMPLES-$(CONFIG_AVCODEC_EXAMPLE) += avcodec
|
||||||
|
DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
|
||||||
|
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_METADATA_EXAMPLE) += metadata
|
||||||
|
DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
|
||||||
|
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
|
||||||
@@ -47,6 +63,8 @@ doc: documentation
|
|||||||
apidoc: doc/doxy/html
|
apidoc: doc/doxy/html
|
||||||
documentation: $(DOCS)
|
documentation: $(DOCS)
|
||||||
|
|
||||||
|
examples: $(DOC_EXAMPLES)
|
||||||
|
|
||||||
TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
|
TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
|
||||||
|
|
||||||
doc/%.txt: TAG = TXT
|
doc/%.txt: TAG = TXT
|
||||||
@@ -62,25 +80,14 @@ $(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 --D=config-not-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
|
||||||
|
|
||||||
|
doc/%-all.html: TAG = HTML
|
||||||
doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
|
doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
|
||||||
$(Q)$(TEXIDEP)
|
$(Q)$(TEXIDEP)
|
||||||
$(M)texi2html -I doc -monolithic --D=config-all --init-file $(SRC_PATH)/doc/t2h.init --output $@ $<
|
$(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)
|
||||||
@@ -94,18 +101,19 @@ doc/%-all.pod: doc/%.texi $(SRC_PATH)/doc/texi2pod.pl $(GENTEXI)
|
|||||||
|
|
||||||
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)
|
DOXY_INPUT = $(addprefix $(SRC_PATH)/, $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c))
|
||||||
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) ffbuild/config.mak
|
|
||||||
|
|
||||||
doc/doxy/html: TAG = DOXY
|
doc/doxy/html: TAG = DOXY
|
||||||
doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT_DEPS)
|
doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT)
|
||||||
$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $$PWD/doc/doxy $(SRC_PATH) doc/Doxyfile $(DOXYGEN) $(DOXY_INPUT);
|
$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $< $(DOXYGEN) $(DOXY_INPUT)
|
||||||
|
|
||||||
install-doc: install-html install-man
|
install-doc: install-html install-man
|
||||||
|
|
||||||
@@ -147,7 +155,11 @@ clean:: docclean
|
|||||||
distclean:: docclean
|
distclean:: docclean
|
||||||
$(RM) doc/config.texi
|
$(RM) doc/config.texi
|
||||||
|
|
||||||
docclean::
|
examplesclean:
|
||||||
|
$(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
|
||||||
|
$(RM) $(CLEANSUFFIXES:%=doc/examples/%)
|
||||||
|
|
||||||
|
docclean: examplesclean
|
||||||
$(RM) $(CLEANSUFFIXES:%=doc/%)
|
$(RM) $(CLEANSUFFIXES:%=doc/%)
|
||||||
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi
|
$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi
|
||||||
$(RM) -r doc/doxy/html
|
$(RM) -r doc/doxy/html
|
||||||
|
|||||||
@@ -13,114 +13,40 @@ 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
|
Convert MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration
|
||||||
bitstream.
|
bitstream filter.
|
||||||
|
|
||||||
This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
|
This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
|
||||||
ADTS header and removes the ADTS header.
|
ADTS header and removes the ADTS header.
|
||||||
|
|
||||||
This filter is required for example when copying an AAC stream from a
|
This is required for example when copying an AAC stream from a raw
|
||||||
raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or
|
ADTS AAC container to a FLV or a MOV/MP4 file.
|
||||||
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 av1_metadata
|
|
||||||
|
|
||||||
Modify metadata embedded in an AV1 stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item td
|
|
||||||
Insert or remove temporal delimiter OBUs in all temporal units of the
|
|
||||||
stream.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item insert
|
|
||||||
Insert a TD at the beginning of every TU which does not already have one.
|
|
||||||
@item remove
|
|
||||||
Remove the TD from the beginning of every TU which has one.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item color_primaries
|
|
||||||
@item transfer_characteristics
|
|
||||||
@item matrix_coefficients
|
|
||||||
Set the color description fields in the stream (see AV1 section 6.4.2).
|
|
||||||
|
|
||||||
@item color_range
|
|
||||||
Set the color range in the stream (see AV1 section 6.4.2; note that
|
|
||||||
this cannot be set for streams using BT.709 primaries, sRGB transfer
|
|
||||||
characteristic and identity (RGB) matrix coefficients).
|
|
||||||
@table @samp
|
|
||||||
@item tv
|
|
||||||
Limited range.
|
|
||||||
@item pc
|
|
||||||
Full range.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item chroma_sample_position
|
|
||||||
Set the chroma sample location in the stream (see AV1 section 6.4.2).
|
|
||||||
This can only be set for 4:2:0 streams.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item vertical
|
|
||||||
Left position (matching the default in MPEG-2 and H.264).
|
|
||||||
@item colocated
|
|
||||||
Top-left position.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item tick_rate
|
|
||||||
Set the tick rate (@emph{time_scale / num_units_in_display_tick}) in
|
|
||||||
the timing info in the sequence header.
|
|
||||||
@item num_ticks_per_picture
|
|
||||||
Set the number of ticks in each picture, to indicate that the stream
|
|
||||||
has a fixed framerate. Ignored if @option{tick_rate} is not also set.
|
|
||||||
|
|
||||||
@item delete_padding
|
|
||||||
Deletes Padding OBUs.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section chomp
|
@section chomp
|
||||||
|
|
||||||
Remove zero padding at the end of a packet.
|
Remove zero padding at the end of a packet.
|
||||||
|
|
||||||
@section dca_core
|
|
||||||
|
|
||||||
Extract the core from a DCA/DTS stream, dropping extensions such as
|
|
||||||
DTS-HD.
|
|
||||||
|
|
||||||
@section dump_extra
|
@section dump_extra
|
||||||
|
|
||||||
Add extradata to the beginning of the filtered packets except when
|
Add extradata to the beginning of the filtered packets.
|
||||||
said packets already exactly begin with the extradata that is intended
|
|
||||||
to be added.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item freq
|
|
||||||
The additional argument specifies which packets should be filtered.
|
The additional argument specifies which packets should be filtered.
|
||||||
It accepts the values:
|
It accepts the values:
|
||||||
@table @samp
|
@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
|
@item k
|
||||||
@item keyframe
|
|
||||||
add extradata to all key packets
|
add extradata to all key packets
|
||||||
|
|
||||||
@item e
|
@item e
|
||||||
@item all
|
|
||||||
add extradata to all packets
|
add extradata to all packets
|
||||||
@end table
|
@end table
|
||||||
@end table
|
|
||||||
|
|
||||||
If not specified it is assumed @samp{k}.
|
If not specified it is assumed @samp{k}.
|
||||||
|
|
||||||
@@ -132,231 +58,6 @@ the header stored in extradata to the key packets:
|
|||||||
ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
|
ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section dv_error_marker
|
|
||||||
|
|
||||||
Blocks in DV which are marked as damaged are replaced by blocks of the specified color.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item color
|
|
||||||
The color to replace damaged blocks by
|
|
||||||
@item sta
|
|
||||||
A 16 bit mask which specifies which of the 16 possible error status values are
|
|
||||||
to be replaced by colored blocks. 0xFFFE is the default which replaces all non 0
|
|
||||||
error status values.
|
|
||||||
@table @samp
|
|
||||||
@item ok
|
|
||||||
No error, no concealment
|
|
||||||
@item err
|
|
||||||
Error, No concealment
|
|
||||||
@item res
|
|
||||||
Reserved
|
|
||||||
@item notok
|
|
||||||
Error or concealment
|
|
||||||
@item notres
|
|
||||||
Not reserved
|
|
||||||
@item Aa, Ba, Ca, Ab, Bb, Cb, A, B, C, a, b, erri, erru
|
|
||||||
The specific error status code
|
|
||||||
@end table
|
|
||||||
see page 44-46 or section 5.5 of
|
|
||||||
@url{http://web.archive.org/web/20060927044735/http://www.smpte.org/smpte_store/standards/pdf/s314m.pdf}
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section eac3_core
|
|
||||||
|
|
||||||
Extract the core from a E-AC-3 stream, dropping extra channels.
|
|
||||||
|
|
||||||
@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 filter_units
|
|
||||||
|
|
||||||
Remove units with types in or not in a given set from the stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item pass_types
|
|
||||||
List of unit types or ranges of unit types to pass through while removing
|
|
||||||
all others. This is specified as a '|'-separated list of unit type values
|
|
||||||
or ranges of values with '-'.
|
|
||||||
|
|
||||||
@item remove_types
|
|
||||||
Identical to @option{pass_types}, except the units in the given set
|
|
||||||
removed and all others passed through.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Extradata is unchanged by this transformation, but note that if the stream
|
|
||||||
contains inline parameter sets then the output may be unusable if they are
|
|
||||||
removed.
|
|
||||||
|
|
||||||
For example, to remove all non-VCL NAL units from an H.264 stream:
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=pass_types=1-5' OUTPUT
|
|
||||||
@end example
|
|
||||||
|
|
||||||
To remove all AUDs, SEI and filler from an H.265 stream:
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section hapqa_extract
|
|
||||||
|
|
||||||
Extract Rgb or Alpha part of an HAPQA file, without recompression, in order to create an HAPQ or an HAPAlphaOnly file.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item texture
|
|
||||||
Specifies the texture to keep.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item color
|
|
||||||
@item alpha
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Convert HAPQA to HAPQ
|
|
||||||
@example
|
|
||||||
ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=color -tag:v HapY -metadata:s:v:0 encoder="HAPQ" hapq_file.mov
|
|
||||||
@end example
|
|
||||||
|
|
||||||
Convert HAPQA to HAPAlphaOnly
|
|
||||||
@example
|
|
||||||
ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=alpha -tag:v HapA -metadata:s:v:0 encoder="HAPAlpha Only" hapalphaonly_file.mov
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section h264_metadata
|
|
||||||
|
|
||||||
Modify metadata embedded in an H.264 stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item aud
|
|
||||||
Insert or remove AUD NAL units in all access units of the stream.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item pass
|
|
||||||
@item insert
|
|
||||||
@item remove
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Default is pass.
|
|
||||||
|
|
||||||
@item sample_aspect_ratio
|
|
||||||
Set the sample aspect ratio of the stream in the VUI parameters.
|
|
||||||
See H.264 table E-1.
|
|
||||||
|
|
||||||
@item overscan_appropriate_flag
|
|
||||||
Set whether the stream is suitable for display using overscan
|
|
||||||
or not (see H.264 section E.2.1).
|
|
||||||
|
|
||||||
@item video_format
|
|
||||||
@item video_full_range_flag
|
|
||||||
Set the video format in the stream (see H.264 section E.2.1 and
|
|
||||||
table E-2).
|
|
||||||
|
|
||||||
@item colour_primaries
|
|
||||||
@item transfer_characteristics
|
|
||||||
@item matrix_coefficients
|
|
||||||
Set the colour description in the stream (see H.264 section E.2.1
|
|
||||||
and tables E-3, E-4 and E-5).
|
|
||||||
|
|
||||||
@item chroma_sample_loc_type
|
|
||||||
Set the chroma sample location in the stream (see H.264 section
|
|
||||||
E.2.1 and figure E-1).
|
|
||||||
|
|
||||||
@item tick_rate
|
|
||||||
Set the tick rate (time_scale / num_units_in_tick) in the VUI
|
|
||||||
parameters. This is the smallest time unit representable in the
|
|
||||||
stream, and in many cases represents the field rate of the stream
|
|
||||||
(double the frame rate).
|
|
||||||
@item fixed_frame_rate_flag
|
|
||||||
Set whether the stream has fixed framerate - typically this indicates
|
|
||||||
that the framerate is exactly half the tick rate, but the exact
|
|
||||||
meaning is dependent on interlacing and the picture structure (see
|
|
||||||
H.264 section E.2.1 and table E-6).
|
|
||||||
@item zero_new_constraint_set_flags
|
|
||||||
Zero constraint_set4_flag and constraint_set5_flag in the SPS. These
|
|
||||||
bits were reserved in a previous version of the H.264 spec, and thus
|
|
||||||
some hardware decoders require these to be zero. The result of zeroing
|
|
||||||
this is still a valid bitstream.
|
|
||||||
|
|
||||||
@item crop_left
|
|
||||||
@item crop_right
|
|
||||||
@item crop_top
|
|
||||||
@item crop_bottom
|
|
||||||
Set the frame cropping offsets in the SPS. These values will replace
|
|
||||||
the current ones if the stream is already cropped.
|
|
||||||
|
|
||||||
These fields are set in pixels. Note that some sizes may not be
|
|
||||||
representable if the chroma is subsampled or the stream is interlaced
|
|
||||||
(see H.264 section 7.4.2.1.1).
|
|
||||||
|
|
||||||
@item sei_user_data
|
|
||||||
Insert a string as SEI unregistered user data. The argument must
|
|
||||||
be of the form @emph{UUID+string}, where the UUID is as hex digits
|
|
||||||
possibly separated by hyphens, and the string can be anything.
|
|
||||||
|
|
||||||
For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
|
|
||||||
insert the string ``hello'' associated with the given UUID.
|
|
||||||
|
|
||||||
@item delete_filler
|
|
||||||
Deletes both filler NAL units and filler SEI messages.
|
|
||||||
|
|
||||||
@item display_orientation
|
|
||||||
Insert, extract or remove Display orientation SEI messages.
|
|
||||||
See H.264 section D.1.27 and D.2.27 for syntax and semantics.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item pass
|
|
||||||
@item insert
|
|
||||||
@item remove
|
|
||||||
@item extract
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Default is pass.
|
|
||||||
|
|
||||||
Insert mode works in conjunction with @code{rotate} and @code{flip} options.
|
|
||||||
Any pre-existing Display orientation messages will be removed in insert or remove mode.
|
|
||||||
Extract mode attaches the display matrix to the packet as side data.
|
|
||||||
|
|
||||||
@item rotate
|
|
||||||
Set rotation in display orientation SEI (anticlockwise angle in degrees).
|
|
||||||
Range is -360 to +360. Default is NaN.
|
|
||||||
|
|
||||||
@item flip
|
|
||||||
Set flip in display orientation SEI.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item horizontal
|
|
||||||
@item vertical
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Default is unset.
|
|
||||||
|
|
||||||
@item level
|
|
||||||
Set the level in the SPS. Refer to H.264 section A.3 and tables A-1
|
|
||||||
to A-5.
|
|
||||||
|
|
||||||
The argument must be the name of a level (for example, @samp{4.2}), a
|
|
||||||
level_idc value (for example, @samp{42}), or the special name @samp{auto}
|
|
||||||
indicating that the filter should attempt to guess the level from the
|
|
||||||
input stream properties.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section h264_mp4toannexb
|
@section h264_mp4toannexb
|
||||||
|
|
||||||
Convert an H.264 bitstream from length prefixed mode to start code
|
Convert an H.264 bitstream from length prefixed mode to start code
|
||||||
@@ -364,7 +65,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:
|
||||||
@@ -373,101 +74,6 @@ 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
|
|
||||||
@code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
|
|
||||||
|
|
||||||
@section h264_redundant_pps
|
|
||||||
|
|
||||||
This applies a specific fixup to some Blu-ray streams which contain
|
|
||||||
redundant PPSs modifying irrelevant parameters of the stream which
|
|
||||||
confuse other transformations which require correct extradata.
|
|
||||||
|
|
||||||
A new single global PPS is created, and all of the redundant PPSs
|
|
||||||
within the stream are removed.
|
|
||||||
|
|
||||||
@section hevc_metadata
|
|
||||||
|
|
||||||
Modify metadata embedded in an HEVC stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item aud
|
|
||||||
Insert or remove AUD NAL units in all access units of the stream.
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item insert
|
|
||||||
@item remove
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item sample_aspect_ratio
|
|
||||||
Set the sample aspect ratio in the stream in the VUI parameters.
|
|
||||||
|
|
||||||
@item video_format
|
|
||||||
@item video_full_range_flag
|
|
||||||
Set the video format in the stream (see H.265 section E.3.1 and
|
|
||||||
table E.2).
|
|
||||||
|
|
||||||
@item colour_primaries
|
|
||||||
@item transfer_characteristics
|
|
||||||
@item matrix_coefficients
|
|
||||||
Set the colour description in the stream (see H.265 section E.3.1
|
|
||||||
and tables E.3, E.4 and E.5).
|
|
||||||
|
|
||||||
@item chroma_sample_loc_type
|
|
||||||
Set the chroma sample location in the stream (see H.265 section
|
|
||||||
E.3.1 and figure E.1).
|
|
||||||
|
|
||||||
@item tick_rate
|
|
||||||
Set the tick rate in the VPS and VUI parameters (time_scale /
|
|
||||||
num_units_in_tick). Combined with @option{num_ticks_poc_diff_one}, this can
|
|
||||||
set a constant framerate in the stream. Note that it is likely to be
|
|
||||||
overridden by container parameters when the stream is in a container.
|
|
||||||
|
|
||||||
@item num_ticks_poc_diff_one
|
|
||||||
Set poc_proportional_to_timing_flag in VPS and VUI and use this value
|
|
||||||
to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
|
|
||||||
E.3.1). Ignored if @option{tick_rate} is not also set.
|
|
||||||
|
|
||||||
@item crop_left
|
|
||||||
@item crop_right
|
|
||||||
@item crop_top
|
|
||||||
@item crop_bottom
|
|
||||||
Set the conformance window cropping offsets in the SPS. These values
|
|
||||||
will replace the current ones if the stream is already cropped.
|
|
||||||
|
|
||||||
These fields are set in pixels. Note that some sizes may not be
|
|
||||||
representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
|
|
||||||
|
|
||||||
@item level
|
|
||||||
Set the level in the VPS and SPS. See H.265 section A.4 and tables
|
|
||||||
A.6 and A.7.
|
|
||||||
|
|
||||||
The argument must be the name of a level (for example, @samp{5.1}), a
|
|
||||||
@emph{general_level_idc} value (for example, @samp{153} for level 5.1),
|
|
||||||
or the special name @samp{auto} indicating that the filter should
|
|
||||||
attempt to guess the level from the input stream properties.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@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
|
@section imxdump
|
||||||
|
|
||||||
Modifies the bitstream to fit in MOV and to be usable by the Final Cut
|
Modifies the bitstream to fit in MOV and to be usable by the Final Cut
|
||||||
@@ -518,435 +124,21 @@ 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_decompress
|
||||||
@section mov2textsub
|
|
||||||
|
|
||||||
Extract a representable text file from MOV subtitles, stripping the
|
|
||||||
metadata header from each subtitle packet.
|
|
||||||
|
|
||||||
See also the @ref{text2movsub} filter.
|
|
||||||
|
|
||||||
@section mp3decomp
|
|
||||||
|
|
||||||
Decompress non-standard compressed MP3 audio headers.
|
|
||||||
|
|
||||||
@section mpeg2_metadata
|
|
||||||
|
|
||||||
Modify metadata embedded in an MPEG-2 stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item display_aspect_ratio
|
|
||||||
Set the display aspect ratio in the stream.
|
|
||||||
|
|
||||||
The following fixed values are supported:
|
|
||||||
@table @option
|
|
||||||
@item 4/3
|
|
||||||
@item 16/9
|
|
||||||
@item 221/100
|
|
||||||
@end table
|
|
||||||
Any other value will result in square pixels being signalled instead
|
|
||||||
(see H.262 section 6.3.3 and table 6-3).
|
|
||||||
|
|
||||||
@item frame_rate
|
|
||||||
Set the frame rate in the stream. This is constructed from a table
|
|
||||||
of known values combined with a small multiplier and divisor - if
|
|
||||||
the supplied value is not exactly representable, the nearest
|
|
||||||
representable value will be used instead (see H.262 section 6.3.3
|
|
||||||
and table 6-4).
|
|
||||||
|
|
||||||
@item video_format
|
|
||||||
Set the video format in the stream (see H.262 section 6.3.6 and
|
|
||||||
table 6-6).
|
|
||||||
|
|
||||||
@item colour_primaries
|
|
||||||
@item transfer_characteristics
|
|
||||||
@item matrix_coefficients
|
|
||||||
Set the colour description in the stream (see H.262 section 6.3.6
|
|
||||||
and tables 6-7, 6-8 and 6-9).
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@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 or simply drops them without damaging the
|
Damages the contents of packets without damaging the container. Can be
|
||||||
container. Can be used for fuzzing or testing error resilience/concealment.
|
used for fuzzing or testing error resilience/concealment.
|
||||||
|
|
||||||
Parameters:
|
|
||||||
@table @option
|
|
||||||
@item amount
|
|
||||||
Accepts an expression whose evaluation per-packet determines how often bytes in that
|
|
||||||
packet will be modified. A value below 0 will result in a variable frequency.
|
|
||||||
Default is 0 which results in no modification. However, if neither amount nor drop is specified,
|
|
||||||
amount will be set to @var{-1}. See below for accepted variables.
|
|
||||||
@item drop
|
|
||||||
Accepts an expression evaluated per-packet whose value determines whether that packet is dropped.
|
|
||||||
Evaluation to a positive value results in the packet being dropped. Evaluation to a negative
|
|
||||||
value results in a variable chance of it being dropped, roughly inverse in proportion to the magnitude
|
|
||||||
of the value. Default is 0 which results in no drops. See below for accepted variables.
|
|
||||||
@item dropamount
|
|
||||||
Accepts a non-negative integer, which assigns a variable chance of it being dropped, roughly inverse
|
|
||||||
in proportion to the value. Default is 0 which results in no drops. This option is kept for backwards
|
|
||||||
compatibility and is equivalent to setting drop to a negative value with the same magnitude
|
|
||||||
i.e. @code{dropamount=4} is the same as @code{drop=-4}. Ignored if drop is also specified.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Both @code{amount} and @code{drop} accept expressions containing the following variables:
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item n
|
|
||||||
The index of the packet, starting from zero.
|
|
||||||
@item tb
|
|
||||||
The timebase for packet timestamps.
|
|
||||||
@item pts
|
|
||||||
Packet presentation timestamp.
|
|
||||||
@item dts
|
|
||||||
Packet decoding timestamp.
|
|
||||||
@item nopts
|
|
||||||
Constant representing AV_NOPTS_VALUE.
|
|
||||||
@item startpts
|
|
||||||
First non-AV_NOPTS_VALUE PTS seen in the stream.
|
|
||||||
@item startdts
|
|
||||||
First non-AV_NOPTS_VALUE DTS seen in the stream.
|
|
||||||
@item duration
|
|
||||||
@itemx d
|
|
||||||
Packet duration, in timebase units.
|
|
||||||
@item pos
|
|
||||||
Packet position in input; may be -1 when unknown or not set.
|
|
||||||
@item size
|
|
||||||
Packet size, in bytes.
|
|
||||||
@item key
|
|
||||||
Whether packet is marked as a keyframe.
|
|
||||||
@item state
|
|
||||||
A pseudo random integer, primarily derived from the content of packet payload.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@subsection Examples
|
|
||||||
Apply modification to every byte but don't drop any packets.
|
|
||||||
@example
|
@example
|
||||||
ffmpeg -i INPUT -c copy -bsf noise=1 output.mkv
|
ffmpeg -i INPUT -c copy -bsf noise output.mkv
|
||||||
@end example
|
|
||||||
|
|
||||||
Drop every video packet not marked as a keyframe after timestamp 30s but do not
|
|
||||||
modify any of the remaining packets.
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c copy -bsf:v noise=drop='gt(t\,30)*not(key)' output.mkv
|
|
||||||
@end example
|
|
||||||
|
|
||||||
Drop one second of audio every 10 seconds and add some random noise to the rest.
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c copy -bsf:a noise=amount=-1:drop='between(mod(t\,10)\,9\,10)' output.mkv
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section null
|
|
||||||
This bitstream filter passes the packets through unchanged.
|
|
||||||
|
|
||||||
@section pcm_rechunk
|
|
||||||
|
|
||||||
Repacketize PCM audio to a fixed number of samples per packet or a fixed packet
|
|
||||||
rate per second. This is similar to the @ref{asetnsamples,,asetnsamples audio
|
|
||||||
filter,ffmpeg-filters} but works on audio packets instead of audio frames.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item nb_out_samples, n
|
|
||||||
Set the number of samples per each output audio packet. The number is intended
|
|
||||||
as the number of samples @emph{per each channel}. Default value is 1024.
|
|
||||||
|
|
||||||
@item pad, p
|
|
||||||
If set to 1, the filter will pad the last audio packet with silence, so that it
|
|
||||||
will contain the same number of samples (or roughly the same number of samples,
|
|
||||||
see @option{frame_rate}) as the previous ones. Default value is 1.
|
|
||||||
|
|
||||||
@item frame_rate, r
|
|
||||||
This option makes the filter output a fixed number of packets per second instead
|
|
||||||
of a fixed number of samples per packet. If the audio sample rate is not
|
|
||||||
divisible by the frame rate then the number of samples will not be constant but
|
|
||||||
will vary slightly so that each packet will start as close to the frame
|
|
||||||
boundary as possible. Using this option has precedence over @option{nb_out_samples}.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
You can generate the well known 1602-1601-1602-1601-1602 pattern of 48kHz audio
|
|
||||||
for NTSC frame rate using the @option{frame_rate} option.
|
|
||||||
@example
|
|
||||||
ffmpeg -f lavfi -i sine=r=48000:d=1 -c pcm_s16le -bsf pcm_rechunk=r=30000/1001 -f framecrc -
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section pgs_frame_merge
|
|
||||||
|
|
||||||
Merge a sequence of PGS Subtitle segments ending with an "end of display set"
|
|
||||||
segment into a single packet.
|
|
||||||
|
|
||||||
This is required by some containers that support PGS subtitles
|
|
||||||
(muxer @code{matroska}).
|
|
||||||
|
|
||||||
@section prores_metadata
|
|
||||||
|
|
||||||
Modify color property metadata embedded in prores stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item color_primaries
|
|
||||||
Set the color primaries.
|
|
||||||
Available values are:
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item auto
|
|
||||||
Keep the same color primaries property (default).
|
|
||||||
|
|
||||||
@item unknown
|
|
||||||
@item bt709
|
|
||||||
@item bt470bg
|
|
||||||
BT601 625
|
|
||||||
|
|
||||||
@item smpte170m
|
|
||||||
BT601 525
|
|
||||||
|
|
||||||
@item bt2020
|
|
||||||
@item smpte431
|
|
||||||
DCI P3
|
|
||||||
|
|
||||||
@item smpte432
|
|
||||||
P3 D65
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item transfer_characteristics
|
|
||||||
Set the color transfer.
|
|
||||||
Available values are:
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item auto
|
|
||||||
Keep the same transfer characteristics property (default).
|
|
||||||
|
|
||||||
@item unknown
|
|
||||||
@item bt709
|
|
||||||
BT 601, BT 709, BT 2020
|
|
||||||
@item smpte2084
|
|
||||||
SMPTE ST 2084
|
|
||||||
@item arib-std-b67
|
|
||||||
ARIB STD-B67
|
|
||||||
@end table
|
|
||||||
|
|
||||||
|
|
||||||
@item matrix_coefficients
|
|
||||||
Set the matrix coefficient.
|
|
||||||
Available values are:
|
|
||||||
|
|
||||||
@table @samp
|
|
||||||
@item auto
|
|
||||||
Keep the same colorspace property (default).
|
|
||||||
|
|
||||||
@item unknown
|
|
||||||
@item bt709
|
|
||||||
@item smpte170m
|
|
||||||
BT 601
|
|
||||||
|
|
||||||
@item bt2020nc
|
|
||||||
@end table
|
|
||||||
@end table
|
|
||||||
|
|
||||||
Set Rec709 colorspace for each frame of the file
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt709:color_trc=bt709:colorspace=bt709 output.mov
|
|
||||||
@end example
|
|
||||||
|
|
||||||
Set Hybrid Log-Gamma parameters for each frame of the file
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt2020:color_trc=arib-std-b67:colorspace=bt2020nc output.mov
|
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section remove_extra
|
@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
|
|
||||||
|
|
||||||
@section setts
|
|
||||||
Set PTS and DTS in packets.
|
|
||||||
|
|
||||||
It accepts the following parameters:
|
|
||||||
@table @option
|
|
||||||
@item ts
|
|
||||||
@item pts
|
|
||||||
@item dts
|
|
||||||
Set expressions for PTS, DTS or both.
|
|
||||||
@item duration
|
|
||||||
Set expression for duration.
|
|
||||||
@item time_base
|
|
||||||
Set output time base.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
The expressions are evaluated through the eval API and can contain the following
|
|
||||||
constants:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item N
|
|
||||||
The count of the input packet. Starting from 0.
|
|
||||||
|
|
||||||
@item TS
|
|
||||||
The demux timestamp in input in case of @code{ts} or @code{dts} option or presentation
|
|
||||||
timestamp in case of @code{pts} option.
|
|
||||||
|
|
||||||
@item POS
|
|
||||||
The original position in the file of the packet, or undefined if undefined
|
|
||||||
for the current packet
|
|
||||||
|
|
||||||
@item DTS
|
|
||||||
The demux timestamp in input.
|
|
||||||
|
|
||||||
@item PTS
|
|
||||||
The presentation timestamp in input.
|
|
||||||
|
|
||||||
@item DURATION
|
|
||||||
The duration in input.
|
|
||||||
|
|
||||||
@item STARTDTS
|
|
||||||
The DTS of the first packet.
|
|
||||||
|
|
||||||
@item STARTPTS
|
|
||||||
The PTS of the first packet.
|
|
||||||
|
|
||||||
@item PREV_INDTS
|
|
||||||
The previous input DTS.
|
|
||||||
|
|
||||||
@item PREV_INPTS
|
|
||||||
The previous input PTS.
|
|
||||||
|
|
||||||
@item PREV_INDURATION
|
|
||||||
The previous input duration.
|
|
||||||
|
|
||||||
@item PREV_OUTDTS
|
|
||||||
The previous output DTS.
|
|
||||||
|
|
||||||
@item PREV_OUTPTS
|
|
||||||
The previous output PTS.
|
|
||||||
|
|
||||||
@item PREV_OUTDURATION
|
|
||||||
The previous output duration.
|
|
||||||
|
|
||||||
@item NEXT_DTS
|
|
||||||
The next input DTS.
|
|
||||||
|
|
||||||
@item NEXT_PTS
|
|
||||||
The next input PTS.
|
|
||||||
|
|
||||||
@item NEXT_DURATION
|
|
||||||
The next input duration.
|
|
||||||
|
|
||||||
@item TB
|
|
||||||
The timebase of stream packet belongs.
|
|
||||||
|
|
||||||
@item TB_OUT
|
|
||||||
The output timebase.
|
|
||||||
|
|
||||||
@item SR
|
|
||||||
The sample rate of stream packet belongs.
|
|
||||||
|
|
||||||
@item NOPTS
|
|
||||||
The AV_NOPTS_VALUE constant.
|
|
||||||
@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 trace_headers
|
|
||||||
|
|
||||||
Log trace output containing all syntax elements in the coded stream
|
|
||||||
headers (everything above the level of individual coded blocks).
|
|
||||||
This can be useful for debugging low-level stream issues.
|
|
||||||
|
|
||||||
Supports AV1, H.264, H.265, (M)JPEG, MPEG-2 and VP9, but depending
|
|
||||||
on the build only a subset of these may be available.
|
|
||||||
|
|
||||||
@section truehd_core
|
|
||||||
|
|
||||||
Extract the core from a TrueHD stream, dropping ATMOS data.
|
|
||||||
|
|
||||||
@section vp9_metadata
|
|
||||||
|
|
||||||
Modify metadata embedded in a VP9 stream.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item color_space
|
|
||||||
Set the color space value in the frame header. Note that any frame
|
|
||||||
set to RGB will be implicitly set to PC range and that RGB is
|
|
||||||
incompatible with profiles 0 and 2.
|
|
||||||
@table @samp
|
|
||||||
@item unknown
|
|
||||||
@item bt601
|
|
||||||
@item bt709
|
|
||||||
@item smpte170
|
|
||||||
@item smpte240
|
|
||||||
@item bt2020
|
|
||||||
@item rgb
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item color_range
|
|
||||||
Set the color range value in the frame header. Note that any value
|
|
||||||
imposed by the color space will take precedence over this value.
|
|
||||||
@table @samp
|
|
||||||
@item tv
|
|
||||||
@item pc
|
|
||||||
@end table
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@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.
|
|
||||||
|
|
||||||
@section vp9_superframe_split
|
|
||||||
|
|
||||||
Split VP9 superframes into single frames.
|
|
||||||
|
|
||||||
@section vp9_raw_reorder
|
|
||||||
|
|
||||||
Given a VP9 stream with correct timestamps but possibly out of order,
|
|
||||||
insert additional show-existing-frame packets to correct the ordering.
|
|
||||||
|
|
||||||
@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,28 +7,20 @@ 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.
|
||||||
@@ -36,31 +28,29 @@ install
|
|||||||
examples
|
examples
|
||||||
Build all examples located in doc/examples.
|
Build all examples located in doc/examples.
|
||||||
|
|
||||||
checkheaders
|
libavformat/output-example
|
||||||
Check headers dependencies.
|
Build the libavformat basic example.
|
||||||
|
|
||||||
alltools
|
libavcodec/api-example
|
||||||
Build all tools in tools directory.
|
Build the libavcodec basic example.
|
||||||
|
|
||||||
|
libswscale/swscale-test
|
||||||
|
Build the swscale self-test (useful also as example).
|
||||||
|
|
||||||
config
|
config
|
||||||
Reconfigure the project with the current configuration.
|
Reconfigure the project with current configuration.
|
||||||
|
|
||||||
tools/target_dec_<decoder>_fuzzer
|
|
||||||
Build fuzzer to fuzz the specified decoder.
|
|
||||||
|
|
||||||
tools/target_bsf_<filter>_fuzzer
|
|
||||||
Build fuzzer to fuzz the specified bitstream filter.
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
558
doc/codecs.texi
558
doc/codecs.texi
@@ -7,7 +7,7 @@ all the encoders and decoders. In addition each codec may support
|
|||||||
so-called private options, which are specific for a given codec.
|
so-called private options, which are specific for a given codec.
|
||||||
|
|
||||||
Sometimes, a global option may only affect a specific kind of codec,
|
Sometimes, a global option may only affect a specific kind of codec,
|
||||||
and may be nonsensical or ignored by another, so you need to be aware
|
and may be unsensical or ignored by another, so you need to be aware
|
||||||
of the meaning of the specified options. Also some options are
|
of the meaning of the specified options. Also some options are
|
||||||
meant only for decoding or encoding.
|
meant only for decoding or encoding.
|
||||||
|
|
||||||
@@ -44,20 +44,26 @@ Use 1/4 pel motion compensation.
|
|||||||
Use loop filter.
|
Use loop filter.
|
||||||
@item qscale
|
@item qscale
|
||||||
Use fixed qscale.
|
Use fixed qscale.
|
||||||
|
@item gmc
|
||||||
|
Use gmc.
|
||||||
|
@item mv0
|
||||||
|
Always try a mb with mv=<0,0>.
|
||||||
|
@item input_preserved
|
||||||
|
|
||||||
@item pass1
|
@item pass1
|
||||||
Use internal 2pass ratecontrol in first pass mode.
|
Use internal 2pass ratecontrol in first pass mode.
|
||||||
@item pass2
|
@item pass2
|
||||||
Use internal 2pass ratecontrol in second pass mode.
|
Use internal 2pass ratecontrol in second pass mode.
|
||||||
@item gray
|
@item gray
|
||||||
Only decode/encode grayscale.
|
Only decode/encode grayscale.
|
||||||
|
@item emu_edge
|
||||||
|
Do not draw edges.
|
||||||
@item psnr
|
@item psnr
|
||||||
Set error[?] variables during encoding.
|
Set error[?] variables during encoding.
|
||||||
@item truncated
|
@item truncated
|
||||||
Input bitstream might be randomly truncated.
|
|
||||||
@item drop_changed
|
|
||||||
Don't output frames whose parameters differ from first decoded frame in stream.
|
|
||||||
Error AVERROR_INPUT_CHANGED is returned when a frame is dropped.
|
|
||||||
|
|
||||||
|
@item naq
|
||||||
|
Normalize adaptive quantization.
|
||||||
@item ildct
|
@item ildct
|
||||||
Use interlaced DCT.
|
Use interlaced DCT.
|
||||||
@item low_delay
|
@item low_delay
|
||||||
@@ -65,19 +71,53 @@ Force low delay.
|
|||||||
@item global_header
|
@item global_header
|
||||||
Place global headers in extradata instead of every keyframe.
|
Place global headers in extradata instead of every keyframe.
|
||||||
@item bitexact
|
@item bitexact
|
||||||
Only write platform-, build- and time-independent data. (except (I)DCT).
|
Use only bitexact stuff (except (I)DCT).
|
||||||
This ensures that file and data checksums are reproducible and match between
|
|
||||||
platforms. Its primary use is for regression testing.
|
|
||||||
@item aic
|
@item aic
|
||||||
Apply H263 advanced intra coding / mpeg4 ac prediction.
|
Apply H263 advanced intra coding / mpeg4 ac prediction.
|
||||||
|
@item cbp
|
||||||
|
Deprecated, use mpegvideo private options instead.
|
||||||
|
@item qprd
|
||||||
|
Deprecated, use mpegvideo private options instead.
|
||||||
@item ilme
|
@item ilme
|
||||||
Apply interlaced motion estimation.
|
Apply interlaced motion estimation.
|
||||||
@item cgop
|
@item cgop
|
||||||
Use closed gop.
|
Use closed gop.
|
||||||
@item output_corrupt
|
|
||||||
Output even potentially corrupted frames.
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item me_method @var{integer} (@emph{encoding,video})
|
||||||
|
Set motion estimation method.
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
@table @samp
|
||||||
|
@item zero
|
||||||
|
zero motion estimation (fastest)
|
||||||
|
@item full
|
||||||
|
full motion estimation (slowest)
|
||||||
|
@item epzs
|
||||||
|
EPZS motion estimation (default)
|
||||||
|
@item esa
|
||||||
|
esa motion estimation (alias for full)
|
||||||
|
@item tesa
|
||||||
|
tesa motion estimation
|
||||||
|
@item dia
|
||||||
|
dia motion estimation (alias for epzs)
|
||||||
|
@item log
|
||||||
|
log motion estimation
|
||||||
|
@item phods
|
||||||
|
phods motion estimation
|
||||||
|
@item x1
|
||||||
|
X1 motion estimation
|
||||||
|
@item hex
|
||||||
|
hex motion estimation
|
||||||
|
@item umh
|
||||||
|
umh motion estimation
|
||||||
|
@item iter
|
||||||
|
iter motion estimation
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item extradata_size @var{integer}
|
||||||
|
Set extradata size.
|
||||||
|
|
||||||
@item time_base @var{rational number}
|
@item time_base @var{rational number}
|
||||||
Set codec time base.
|
Set codec time base.
|
||||||
|
|
||||||
@@ -87,7 +127,7 @@ should be @code{1 / frame_rate} and timestamp increments should be
|
|||||||
identically 1.
|
identically 1.
|
||||||
|
|
||||||
@item g @var{integer} (@emph{encoding,video})
|
@item g @var{integer} (@emph{encoding,video})
|
||||||
Set the group of picture (GOP) size. Default value is 12.
|
Set the group of picture size. Default value is 12.
|
||||||
|
|
||||||
@item ar @var{integer} (@emph{decoding/encoding,audio})
|
@item ar @var{integer} (@emph{decoding/encoding,audio})
|
||||||
Set audio sampling rate (in Hz).
|
Set audio sampling rate (in Hz).
|
||||||
@@ -96,8 +136,7 @@ Set audio sampling rate (in Hz).
|
|||||||
Set number of audio channels.
|
Set number of audio channels.
|
||||||
|
|
||||||
@item cutoff @var{integer} (@emph{encoding,audio})
|
@item cutoff @var{integer} (@emph{encoding,audio})
|
||||||
Set cutoff bandwidth. (Supported only by selected encoders, see
|
Set cutoff bandwidth.
|
||||||
their respective documentation sections.)
|
|
||||||
|
|
||||||
@item frame_size @var{integer} (@emph{encoding,audio})
|
@item frame_size @var{integer} (@emph{encoding,audio})
|
||||||
Set audio frame size.
|
Set audio frame size.
|
||||||
@@ -144,6 +183,24 @@ Default value is 0.
|
|||||||
@item b_qfactor @var{float} (@emph{encoding,video})
|
@item b_qfactor @var{float} (@emph{encoding,video})
|
||||||
Set qp factor between P and B frames.
|
Set qp factor between P and B frames.
|
||||||
|
|
||||||
|
@item rc_strategy @var{integer} (@emph{encoding,video})
|
||||||
|
Set ratecontrol method.
|
||||||
|
|
||||||
|
@item b_strategy @var{integer} (@emph{encoding,video})
|
||||||
|
Set strategy to choose between I/P/B-frames.
|
||||||
|
|
||||||
|
@item ps @var{integer} (@emph{encoding,video})
|
||||||
|
Set RTP payload size in bytes.
|
||||||
|
|
||||||
|
@item mv_bits @var{integer}
|
||||||
|
@item header_bits @var{integer}
|
||||||
|
@item i_tex_bits @var{integer}
|
||||||
|
@item p_tex_bits @var{integer}
|
||||||
|
@item i_count @var{integer}
|
||||||
|
@item p_count @var{integer}
|
||||||
|
@item skip_count @var{integer}
|
||||||
|
@item misc_bits @var{integer}
|
||||||
|
@item frame_bits @var{integer}
|
||||||
@item codec_tag @var{integer}
|
@item codec_tag @var{integer}
|
||||||
@item bug @var{flags} (@emph{decoding,video})
|
@item bug @var{flags} (@emph{decoding,video})
|
||||||
Workaround not auto detected encoder bugs.
|
Workaround not auto detected encoder bugs.
|
||||||
@@ -152,6 +209,8 @@ Possible values:
|
|||||||
@table @samp
|
@table @samp
|
||||||
@item autodetect
|
@item autodetect
|
||||||
|
|
||||||
|
@item old_msmpeg4
|
||||||
|
some old lavc generated msmpeg4v3 files (no autodetection)
|
||||||
@item xvid_ilace
|
@item xvid_ilace
|
||||||
Xvid interlacing bug (autodetected if fourcc==XVIX)
|
Xvid interlacing bug (autodetected if fourcc==XVIX)
|
||||||
@item ump4
|
@item ump4
|
||||||
@@ -160,6 +219,8 @@ Xvid interlacing bug (autodetected if fourcc==XVIX)
|
|||||||
padding bug (autodetected)
|
padding bug (autodetected)
|
||||||
@item amv
|
@item amv
|
||||||
|
|
||||||
|
@item ac_vlc
|
||||||
|
illegal vlc bug (autodetected per fourcc)
|
||||||
@item qpel_chroma
|
@item qpel_chroma
|
||||||
|
|
||||||
@item std_qpel
|
@item std_qpel
|
||||||
@@ -180,13 +241,21 @@ Workaround various bugs in microsoft broken decoders.
|
|||||||
trancated frames
|
trancated frames
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item lelim @var{integer} (@emph{encoding,video})
|
||||||
|
Set single coefficient elimination threshold for luminance (negative
|
||||||
|
values also consider DC coefficient).
|
||||||
|
|
||||||
|
@item celim @var{integer} (@emph{encoding,video})
|
||||||
|
Set single coefficient elimination threshold for chrominance (negative
|
||||||
|
values also consider dc coefficient)
|
||||||
|
|
||||||
@item strict @var{integer} (@emph{decoding/encoding,audio,video})
|
@item strict @var{integer} (@emph{decoding/encoding,audio,video})
|
||||||
Specify how strictly to follow the standards.
|
Specify how strictly to follow the standards.
|
||||||
|
|
||||||
Possible values:
|
Possible values:
|
||||||
@table @samp
|
@table @samp
|
||||||
@item very
|
@item very
|
||||||
strictly conform to an older more strict version of the spec or reference software
|
strictly conform to a older more strict version of the spec or reference software
|
||||||
@item strict
|
@item strict
|
||||||
strictly conform to all the things in the spec no matter what consequences
|
strictly conform to all the things in the spec no matter what consequences
|
||||||
@item normal
|
@item normal
|
||||||
@@ -233,8 +302,29 @@ consider things that a sane encoder should not do as an error
|
|||||||
|
|
||||||
@item block_align @var{integer}
|
@item block_align @var{integer}
|
||||||
|
|
||||||
|
@item mpeg_quant @var{integer} (@emph{encoding,video})
|
||||||
|
Use MPEG quantizers instead of H.263.
|
||||||
|
|
||||||
|
@item qsquish @var{float} (@emph{encoding,video})
|
||||||
|
How to keep quantizer between qmin and qmax (0 = clip, 1 = use
|
||||||
|
differentiable function).
|
||||||
|
|
||||||
|
@item rc_qmod_amp @var{float} (@emph{encoding,video})
|
||||||
|
Set experimental quantizer modulation.
|
||||||
|
|
||||||
|
@item rc_qmod_freq @var{integer} (@emph{encoding,video})
|
||||||
|
Set experimental quantizer modulation.
|
||||||
|
|
||||||
@item rc_override_count @var{integer}
|
@item rc_override_count @var{integer}
|
||||||
|
|
||||||
|
@item rc_eq @var{string} (@emph{encoding,video})
|
||||||
|
Set rate control equation. When computing the expression, besides the
|
||||||
|
standard functions defined in the section 'Expression Evaluation', the
|
||||||
|
following functions are available: bits2qp(bits), qp2bits(qp). Also
|
||||||
|
the following constants are available: iTex pTex tex mv fCode iCount
|
||||||
|
mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex
|
||||||
|
avgTex.
|
||||||
|
|
||||||
@item maxrate @var{integer} (@emph{encoding,audio,video})
|
@item maxrate @var{integer} (@emph{encoding,audio,video})
|
||||||
Set max bitrate tolerance (in bits/s). Requires bufsize to be set.
|
Set max bitrate tolerance (in bits/s). Requires bufsize to be set.
|
||||||
|
|
||||||
@@ -245,12 +335,18 @@ encode. It is of little use elsewise.
|
|||||||
@item bufsize @var{integer} (@emph{encoding,audio,video})
|
@item bufsize @var{integer} (@emph{encoding,audio,video})
|
||||||
Set ratecontrol buffer size (in bits).
|
Set ratecontrol buffer size (in bits).
|
||||||
|
|
||||||
|
@item rc_buf_aggressivity @var{float} (@emph{encoding,video})
|
||||||
|
Currently useless.
|
||||||
|
|
||||||
@item i_qfactor @var{float} (@emph{encoding,video})
|
@item i_qfactor @var{float} (@emph{encoding,video})
|
||||||
Set QP factor between P and I frames.
|
Set QP factor between P and I frames.
|
||||||
|
|
||||||
@item i_qoffset @var{float} (@emph{encoding,video})
|
@item i_qoffset @var{float} (@emph{encoding,video})
|
||||||
Set QP offset between P and I frames.
|
Set QP offset between P and I frames.
|
||||||
|
|
||||||
|
@item rc_init_cplx @var{float} (@emph{encoding,video})
|
||||||
|
Set initial complexity for 1-pass encoding.
|
||||||
|
|
||||||
@item dct @var{integer} (@emph{encoding,video})
|
@item dct @var{integer} (@emph{encoding,video})
|
||||||
Set DCT algorithm.
|
Set DCT algorithm.
|
||||||
|
|
||||||
@@ -315,7 +411,11 @@ Automatically pick a IDCT compatible with the simple one
|
|||||||
|
|
||||||
@item simpleneon
|
@item simpleneon
|
||||||
|
|
||||||
@item xvid
|
@item simplealpha
|
||||||
|
|
||||||
|
@item ipp
|
||||||
|
|
||||||
|
@item xvidmmx
|
||||||
|
|
||||||
@item faani
|
@item faani
|
||||||
floating point AAN IDCT
|
floating point AAN IDCT
|
||||||
@@ -338,12 +438,22 @@ favor predicting from the previous frame instead of the current
|
|||||||
|
|
||||||
@item bits_per_coded_sample @var{integer}
|
@item bits_per_coded_sample @var{integer}
|
||||||
|
|
||||||
|
@item pred @var{integer} (@emph{encoding,video})
|
||||||
|
Set prediction method.
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
@table @samp
|
||||||
|
@item left
|
||||||
|
|
||||||
|
@item plane
|
||||||
|
|
||||||
|
@item median
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@item aspect @var{rational number} (@emph{encoding,video})
|
@item aspect @var{rational number} (@emph{encoding,video})
|
||||||
Set sample aspect ratio.
|
Set sample aspect ratio.
|
||||||
|
|
||||||
@item sar @var{rational number} (@emph{encoding,video})
|
|
||||||
Set sample aspect ratio. Alias to @var{aspect}.
|
|
||||||
|
|
||||||
@item debug @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
|
@item debug @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
|
||||||
Print specific debug info.
|
Print specific debug info.
|
||||||
|
|
||||||
@@ -359,27 +469,43 @@ rate control
|
|||||||
macroblock (MB) type
|
macroblock (MB) type
|
||||||
@item qp
|
@item qp
|
||||||
per-block quantization parameter (QP)
|
per-block quantization parameter (QP)
|
||||||
|
@item mv
|
||||||
|
motion vector
|
||||||
@item dct_coeff
|
@item dct_coeff
|
||||||
|
|
||||||
@item green_metadata
|
|
||||||
display complexity metadata for the upcoming frame, GoP or for a given duration.
|
|
||||||
|
|
||||||
@item skip
|
@item skip
|
||||||
|
|
||||||
@item startcode
|
@item startcode
|
||||||
|
|
||||||
|
@item pts
|
||||||
|
|
||||||
@item er
|
@item er
|
||||||
error recognition
|
error recognition
|
||||||
@item mmco
|
@item mmco
|
||||||
memory management control operations (H.264)
|
memory management control operations (H.264)
|
||||||
@item bugs
|
@item bugs
|
||||||
|
|
||||||
|
@item vis_qp
|
||||||
|
visualize quantization parameter (QP), lower QP are tinted greener
|
||||||
|
@item vis_mb_type
|
||||||
|
visualize block types
|
||||||
@item buffers
|
@item buffers
|
||||||
picture buffer allocations
|
picture buffer allocations
|
||||||
@item thread_ops
|
@item thread_ops
|
||||||
threading operations
|
threading operations
|
||||||
@item nomc
|
@end table
|
||||||
skip motion compensation
|
|
||||||
|
@item vismv @var{integer} (@emph{decoding,video})
|
||||||
|
Visualize motion vectors (MVs).
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
@table @samp
|
||||||
|
@item pf
|
||||||
|
forward predicted MVs of P-frames
|
||||||
|
@item bf
|
||||||
|
forward predicted MVs of B-frames
|
||||||
|
@item bb
|
||||||
|
backward predicted MVs of B-frames
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@item cmp @var{integer} (@emph{encoding,video})
|
@item cmp @var{integer} (@emph{encoding,video})
|
||||||
@@ -532,28 +658,13 @@ noise preserving sum of squared differences
|
|||||||
|
|
||||||
@item dia_size @var{integer} (@emph{encoding,video})
|
@item dia_size @var{integer} (@emph{encoding,video})
|
||||||
Set diamond type & size for motion estimation.
|
Set diamond type & size for motion estimation.
|
||||||
@table @samp
|
|
||||||
@item (1024, INT_MAX)
|
|
||||||
full motion estimation(slowest)
|
|
||||||
@item (768, 1024]
|
|
||||||
umh motion estimation
|
|
||||||
@item (512, 768]
|
|
||||||
hex motion estimation
|
|
||||||
@item (256, 512]
|
|
||||||
l2s diamond motion estimation
|
|
||||||
@item [2,256]
|
|
||||||
var diamond motion estimation
|
|
||||||
@item (-1, 2)
|
|
||||||
small diamond motion estimation
|
|
||||||
@item -1
|
|
||||||
funny diamond motion estimation
|
|
||||||
@item (INT_MIN, -1)
|
|
||||||
sab diamond motion estimation
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item last_pred @var{integer} (@emph{encoding,video})
|
@item last_pred @var{integer} (@emph{encoding,video})
|
||||||
Set amount of motion predictors from the previous frame.
|
Set amount of motion predictors from the previous frame.
|
||||||
|
|
||||||
|
@item preme @var{integer} (@emph{encoding,video})
|
||||||
|
Set pre motion estimation.
|
||||||
|
|
||||||
@item precmp @var{integer} (@emph{encoding,video})
|
@item precmp @var{integer} (@emph{encoding,video})
|
||||||
Set pre motion estimation compare function.
|
Set pre motion estimation compare function.
|
||||||
|
|
||||||
@@ -597,13 +708,44 @@ Set diamond type & size for motion estimation pre-pass.
|
|||||||
@item subq @var{integer} (@emph{encoding,video})
|
@item subq @var{integer} (@emph{encoding,video})
|
||||||
Set sub pel motion estimation quality.
|
Set sub pel motion estimation quality.
|
||||||
|
|
||||||
|
@item dtg_active_format @var{integer}
|
||||||
|
|
||||||
@item me_range @var{integer} (@emph{encoding,video})
|
@item me_range @var{integer} (@emph{encoding,video})
|
||||||
Set limit motion vectors range (1023 for DivX player).
|
Set limit motion vectors range (1023 for DivX player).
|
||||||
|
|
||||||
|
@item ibias @var{integer} (@emph{encoding,video})
|
||||||
|
Set intra quant bias.
|
||||||
|
|
||||||
|
@item pbias @var{integer} (@emph{encoding,video})
|
||||||
|
Set inter quant bias.
|
||||||
|
|
||||||
|
@item color_table_id @var{integer}
|
||||||
|
|
||||||
@item global_quality @var{integer} (@emph{encoding,audio,video})
|
@item global_quality @var{integer} (@emph{encoding,audio,video})
|
||||||
|
|
||||||
|
@item coder @var{integer} (@emph{encoding,video})
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
@table @samp
|
||||||
|
@item vlc
|
||||||
|
variable length coder / huffman coder
|
||||||
|
@item ac
|
||||||
|
arithmetic coder
|
||||||
|
@item raw
|
||||||
|
raw (no encoding)
|
||||||
|
@item rle
|
||||||
|
run-length coder
|
||||||
|
@item deflate
|
||||||
|
deflate-based coder
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item context @var{integer} (@emph{encoding,video})
|
||||||
|
Set context model.
|
||||||
|
|
||||||
@item slice_flags @var{integer}
|
@item slice_flags @var{integer}
|
||||||
|
|
||||||
|
@item xvmc_acceleration @var{integer}
|
||||||
|
|
||||||
@item mbd @var{integer} (@emph{encoding,video})
|
@item mbd @var{integer} (@emph{encoding,video})
|
||||||
Set macroblock decision algorithm (high quality mode).
|
Set macroblock decision algorithm (high quality mode).
|
||||||
|
|
||||||
@@ -617,16 +759,32 @@ use fewest bits
|
|||||||
use best rate distortion
|
use best rate distortion
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item stream_codec_tag @var{integer}
|
||||||
|
|
||||||
|
@item sc_threshold @var{integer} (@emph{encoding,video})
|
||||||
|
Set scene change threshold.
|
||||||
|
|
||||||
|
@item lmin @var{integer} (@emph{encoding,video})
|
||||||
|
Set min lagrange factor (VBR).
|
||||||
|
|
||||||
|
@item lmax @var{integer} (@emph{encoding,video})
|
||||||
|
Set max lagrange factor (VBR).
|
||||||
|
|
||||||
|
@item nr @var{integer} (@emph{encoding,video})
|
||||||
|
Set noise reduction.
|
||||||
|
|
||||||
@item rc_init_occupancy @var{integer} (@emph{encoding,video})
|
@item rc_init_occupancy @var{integer} (@emph{encoding,video})
|
||||||
Set number of bits which should be loaded into the rc buffer before
|
Set number of bits which should be loaded into the rc buffer before
|
||||||
decoding starts.
|
decoding starts.
|
||||||
|
|
||||||
@item flags2 @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
|
@item flags2 @var{flags} (@emph{decoding/encoding,audio,video})
|
||||||
|
|
||||||
Possible values:
|
Possible values:
|
||||||
@table @samp
|
@table @samp
|
||||||
@item fast
|
@item fast
|
||||||
Allow non spec compliant speedup tricks.
|
Allow non spec compliant speedup tricks.
|
||||||
|
@item sgop
|
||||||
|
Deprecated, use mpegvideo private options instead.
|
||||||
@item noout
|
@item noout
|
||||||
Skip bitstream encoding.
|
Skip bitstream encoding.
|
||||||
@item ignorecrop
|
@item ignorecrop
|
||||||
@@ -637,44 +795,28 @@ Place global headers at every keyframe instead of in extradata.
|
|||||||
Frame data might be split into multiple chunks.
|
Frame data might be split into multiple chunks.
|
||||||
@item showall
|
@item showall
|
||||||
Show all frames before the first keyframe.
|
Show all frames before the first keyframe.
|
||||||
@item export_mvs
|
@item skiprd
|
||||||
Export motion vectors into frame side-data (see @code{AV_FRAME_DATA_MOTION_VECTORS})
|
Deprecated, use mpegvideo private options instead.
|
||||||
for codecs that support it. See also @file{doc/examples/export_mvs.c}.
|
|
||||||
@item skip_manual
|
|
||||||
Do not skip samples and export skip information as frame side data.
|
|
||||||
@item ass_ro_flush_noop
|
|
||||||
Do not reset ASS ReadOrder field on flush.
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@item export_side_data @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
|
@item error @var{integer} (@emph{encoding,video})
|
||||||
|
|
||||||
Possible values:
|
@item qns @var{integer} (@emph{encoding,video})
|
||||||
@table @samp
|
Deprecated, use mpegvideo private options instead.
|
||||||
@item mvs
|
|
||||||
Export motion vectors into frame side-data (see @code{AV_FRAME_DATA_MOTION_VECTORS})
|
|
||||||
for codecs that support it. See also @file{doc/examples/export_mvs.c}.
|
|
||||||
@item prft
|
|
||||||
Export encoder Producer Reference Time into packet side-data (see @code{AV_PKT_DATA_PRFT})
|
|
||||||
for codecs that support it.
|
|
||||||
@item venc_params
|
|
||||||
Export video encoding parameters through frame side data (see @code{AV_FRAME_DATA_VIDEO_ENC_PARAMS})
|
|
||||||
for codecs that support it. At present, those are H.264 and VP9.
|
|
||||||
@item film_grain
|
|
||||||
Export film grain parameters through frame side data (see @code{AV_FRAME_DATA_FILM_GRAIN_PARAMS}).
|
|
||||||
Supported at present by AV1 decoders.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item threads @var{integer} (@emph{decoding/encoding,video})
|
@item threads @var{integer} (@emph{decoding/encoding,video})
|
||||||
Set the number of threads to be used, in case the selected codec
|
|
||||||
implementation supports multi-threading.
|
|
||||||
|
|
||||||
Possible values:
|
Possible values:
|
||||||
@table @samp
|
@table @samp
|
||||||
@item auto, 0
|
@item auto
|
||||||
automatically select the number of threads to set
|
detect a good number of threads
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
Default value is @samp{auto}.
|
@item me_threshold @var{integer} (@emph{encoding,video})
|
||||||
|
Set motion estimation threshold.
|
||||||
|
|
||||||
|
@item mb_threshold @var{integer} (@emph{encoding,video})
|
||||||
|
Set macroblock threshold.
|
||||||
|
|
||||||
@item dc @var{integer} (@emph{encoding,video})
|
@item dc @var{integer} (@emph{encoding,video})
|
||||||
Set intra_dc_precision.
|
Set intra_dc_precision.
|
||||||
@@ -690,8 +832,41 @@ Set number of macroblock rows at the bottom which are skipped.
|
|||||||
|
|
||||||
@item profile @var{integer} (@emph{encoding,audio,video})
|
@item profile @var{integer} (@emph{encoding,audio,video})
|
||||||
|
|
||||||
Set encoder codec profile. Default value is @samp{unknown}. Encoder specific
|
Possible values:
|
||||||
profiles are documented in the relevant encoder documentation.
|
@table @samp
|
||||||
|
@item unknown
|
||||||
|
|
||||||
|
@item aac_main
|
||||||
|
|
||||||
|
@item aac_low
|
||||||
|
|
||||||
|
@item aac_ssr
|
||||||
|
|
||||||
|
@item aac_ltp
|
||||||
|
|
||||||
|
@item aac_he
|
||||||
|
|
||||||
|
@item aac_he_v2
|
||||||
|
|
||||||
|
@item aac_ld
|
||||||
|
|
||||||
|
@item aac_eld
|
||||||
|
|
||||||
|
@item mpeg2_aac_low
|
||||||
|
|
||||||
|
@item mpeg2_aac_he
|
||||||
|
|
||||||
|
@item dts
|
||||||
|
|
||||||
|
@item dts_es
|
||||||
|
|
||||||
|
@item dts_96_24
|
||||||
|
|
||||||
|
@item dts_hd_hra
|
||||||
|
|
||||||
|
@item dts_hd_ma
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
@item level @var{integer} (@emph{encoding,audio,video})
|
@item level @var{integer} (@emph{encoding,audio,video})
|
||||||
|
|
||||||
@@ -704,12 +879,67 @@ Possible values:
|
|||||||
@item lowres @var{integer} (@emph{decoding,audio,video})
|
@item lowres @var{integer} (@emph{decoding,audio,video})
|
||||||
Decode at 1= 1/2, 2=1/4, 3=1/8 resolutions.
|
Decode at 1= 1/2, 2=1/4, 3=1/8 resolutions.
|
||||||
|
|
||||||
|
@item skip_threshold @var{integer} (@emph{encoding,video})
|
||||||
|
Set frame skip threshold.
|
||||||
|
|
||||||
|
@item skip_factor @var{integer} (@emph{encoding,video})
|
||||||
|
Set frame skip factor.
|
||||||
|
|
||||||
|
@item skip_exp @var{integer} (@emph{encoding,video})
|
||||||
|
Set frame skip exponent.
|
||||||
|
Negative values behave identical to the corresponding positive ones, except
|
||||||
|
that the score is normalized.
|
||||||
|
Positive values exist primarily for compatibility reasons and are not so useful.
|
||||||
|
|
||||||
|
@item skipcmp @var{integer} (@emph{encoding,video})
|
||||||
|
Set frame skip compare function.
|
||||||
|
|
||||||
|
Possible values:
|
||||||
|
@table @samp
|
||||||
|
@item sad
|
||||||
|
sum of absolute differences, fast (default)
|
||||||
|
@item sse
|
||||||
|
sum of squared errors
|
||||||
|
@item satd
|
||||||
|
sum of absolute Hadamard transformed differences
|
||||||
|
@item dct
|
||||||
|
sum of absolute DCT transformed differences
|
||||||
|
@item psnr
|
||||||
|
sum of squared quantization errors (avoid, low quality)
|
||||||
|
@item bit
|
||||||
|
number of bits needed for the block
|
||||||
|
@item rd
|
||||||
|
rate distortion optimal, slow
|
||||||
|
@item zero
|
||||||
|
0
|
||||||
|
@item vsad
|
||||||
|
sum of absolute vertical differences
|
||||||
|
@item vsse
|
||||||
|
sum of squared vertical differences
|
||||||
|
@item nsse
|
||||||
|
noise preserving sum of squared differences
|
||||||
|
@item w53
|
||||||
|
5/3 wavelet, only used in snow
|
||||||
|
@item w97
|
||||||
|
9/7 wavelet, only used in snow
|
||||||
|
@item dctmax
|
||||||
|
|
||||||
|
@item chroma
|
||||||
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@item border_mask @var{float} (@emph{encoding,video})
|
||||||
|
Increase the quantizer for macroblocks close to borders.
|
||||||
|
|
||||||
@item mblmin @var{integer} (@emph{encoding,video})
|
@item mblmin @var{integer} (@emph{encoding,video})
|
||||||
Set min macroblock lagrange factor (VBR).
|
Set min macroblock lagrange factor (VBR).
|
||||||
|
|
||||||
@item mblmax @var{integer} (@emph{encoding,video})
|
@item mblmax @var{integer} (@emph{encoding,video})
|
||||||
Set max macroblock lagrange factor (VBR).
|
Set max macroblock lagrange factor (VBR).
|
||||||
|
|
||||||
|
@item mepc @var{integer} (@emph{encoding,video})
|
||||||
|
Set motion estimation bitrate penalty compensation (1.0 = 256).
|
||||||
|
|
||||||
@item skip_loop_filter @var{integer} (@emph{decoding,video})
|
@item skip_loop_filter @var{integer} (@emph{decoding,video})
|
||||||
@item skip_idct @var{integer} (@emph{decoding,video})
|
@item skip_idct @var{integer} (@emph{decoding,video})
|
||||||
@item skip_frame @var{integer} (@emph{decoding,video})
|
@item skip_frame @var{integer} (@emph{decoding,video})
|
||||||
@@ -737,9 +967,6 @@ Discard all bidirectional frames.
|
|||||||
@item nokey
|
@item nokey
|
||||||
Discard all frames excepts keyframes.
|
Discard all frames excepts keyframes.
|
||||||
|
|
||||||
@item nointra
|
|
||||||
Discard all frames except I frames.
|
|
||||||
|
|
||||||
@item all
|
@item all
|
||||||
Discard all frames.
|
Discard all frames.
|
||||||
@end table
|
@end table
|
||||||
@@ -749,17 +976,38 @@ Default value is @samp{default}.
|
|||||||
@item bidir_refine @var{integer} (@emph{encoding,video})
|
@item bidir_refine @var{integer} (@emph{encoding,video})
|
||||||
Refine the two motion vectors used in bidirectional macroblocks.
|
Refine the two motion vectors used in bidirectional macroblocks.
|
||||||
|
|
||||||
|
@item brd_scale @var{integer} (@emph{encoding,video})
|
||||||
|
Downscale frames for dynamic B-frame decision.
|
||||||
|
|
||||||
@item keyint_min @var{integer} (@emph{encoding,video})
|
@item keyint_min @var{integer} (@emph{encoding,video})
|
||||||
Set minimum interval between IDR-frames.
|
Set minimum interval between IDR-frames.
|
||||||
|
|
||||||
@item refs @var{integer} (@emph{encoding,video})
|
@item refs @var{integer} (@emph{encoding,video})
|
||||||
Set reference frames to consider for motion compensation.
|
Set reference frames to consider for motion compensation.
|
||||||
|
|
||||||
|
@item chromaoffset @var{integer} (@emph{encoding,video})
|
||||||
|
Set chroma qp offset from luma.
|
||||||
|
|
||||||
@item trellis @var{integer} (@emph{encoding,audio,video})
|
@item trellis @var{integer} (@emph{encoding,audio,video})
|
||||||
Set rate-distortion optimal quantization.
|
Set rate-distortion optimal quantization.
|
||||||
|
|
||||||
|
@item sc_factor @var{integer} (@emph{encoding,video})
|
||||||
|
Set value multiplied by qscale for each frame and added to
|
||||||
|
scene_change_score.
|
||||||
|
|
||||||
@item mv0_threshold @var{integer} (@emph{encoding,video})
|
@item mv0_threshold @var{integer} (@emph{encoding,video})
|
||||||
|
@item b_sensitivity @var{integer} (@emph{encoding,video})
|
||||||
|
Adjust sensitivity of b_frame_strategy 1.
|
||||||
|
|
||||||
@item compression_level @var{integer} (@emph{encoding,audio,video})
|
@item compression_level @var{integer} (@emph{encoding,audio,video})
|
||||||
|
@item min_prediction_order @var{integer} (@emph{encoding,audio})
|
||||||
|
@item max_prediction_order @var{integer} (@emph{encoding,audio})
|
||||||
|
@item timecode_frame_start @var{integer} (@emph{encoding,video})
|
||||||
|
Set GOP timecode frame start number, in non drop frame format.
|
||||||
|
|
||||||
|
@item request_channels @var{integer} (@emph{decoding,audio})
|
||||||
|
Set desired number of audio channels.
|
||||||
|
|
||||||
@item bits_per_raw_sample @var{integer}
|
@item bits_per_raw_sample @var{integer}
|
||||||
@item channel_layout @var{integer} (@emph{decoding/encoding,audio})
|
@item channel_layout @var{integer} (@emph{decoding/encoding,audio})
|
||||||
|
|
||||||
@@ -774,142 +1022,11 @@ Possible values:
|
|||||||
@item rc_max_vbv_use @var{float} (@emph{encoding,video})
|
@item rc_max_vbv_use @var{float} (@emph{encoding,video})
|
||||||
@item rc_min_vbv_use @var{float} (@emph{encoding,video})
|
@item rc_min_vbv_use @var{float} (@emph{encoding,video})
|
||||||
@item ticks_per_frame @var{integer} (@emph{decoding/encoding,audio,video})
|
@item ticks_per_frame @var{integer} (@emph{decoding/encoding,audio,video})
|
||||||
|
|
||||||
@item color_primaries @var{integer} (@emph{decoding/encoding,video})
|
@item color_primaries @var{integer} (@emph{decoding/encoding,video})
|
||||||
Possible values:
|
|
||||||
@table @samp
|
|
||||||
@item bt709
|
|
||||||
BT.709
|
|
||||||
@item bt470m
|
|
||||||
BT.470 M
|
|
||||||
@item bt470bg
|
|
||||||
BT.470 BG
|
|
||||||
@item smpte170m
|
|
||||||
SMPTE 170 M
|
|
||||||
@item smpte240m
|
|
||||||
SMPTE 240 M
|
|
||||||
@item film
|
|
||||||
Film
|
|
||||||
@item bt2020
|
|
||||||
BT.2020
|
|
||||||
@item smpte428
|
|
||||||
@item smpte428_1
|
|
||||||
SMPTE ST 428-1
|
|
||||||
@item smpte431
|
|
||||||
SMPTE 431-2
|
|
||||||
@item smpte432
|
|
||||||
SMPTE 432-1
|
|
||||||
@item jedec-p22
|
|
||||||
JEDEC P22
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item color_trc @var{integer} (@emph{decoding/encoding,video})
|
@item color_trc @var{integer} (@emph{decoding/encoding,video})
|
||||||
Possible values:
|
|
||||||
@table @samp
|
|
||||||
@item bt709
|
|
||||||
BT.709
|
|
||||||
@item gamma22
|
|
||||||
BT.470 M
|
|
||||||
@item gamma28
|
|
||||||
BT.470 BG
|
|
||||||
@item smpte170m
|
|
||||||
SMPTE 170 M
|
|
||||||
@item smpte240m
|
|
||||||
SMPTE 240 M
|
|
||||||
@item linear
|
|
||||||
Linear
|
|
||||||
@item log
|
|
||||||
@item log100
|
|
||||||
Log
|
|
||||||
@item log_sqrt
|
|
||||||
@item log316
|
|
||||||
Log square root
|
|
||||||
@item iec61966_2_4
|
|
||||||
@item iec61966-2-4
|
|
||||||
IEC 61966-2-4
|
|
||||||
@item bt1361
|
|
||||||
@item bt1361e
|
|
||||||
BT.1361
|
|
||||||
@item iec61966_2_1
|
|
||||||
@item iec61966-2-1
|
|
||||||
IEC 61966-2-1
|
|
||||||
@item bt2020_10
|
|
||||||
@item bt2020_10bit
|
|
||||||
BT.2020 - 10 bit
|
|
||||||
@item bt2020_12
|
|
||||||
@item bt2020_12bit
|
|
||||||
BT.2020 - 12 bit
|
|
||||||
@item smpte2084
|
|
||||||
SMPTE ST 2084
|
|
||||||
@item smpte428
|
|
||||||
@item smpte428_1
|
|
||||||
SMPTE ST 428-1
|
|
||||||
@item arib-std-b67
|
|
||||||
ARIB STD-B67
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item colorspace @var{integer} (@emph{decoding/encoding,video})
|
@item colorspace @var{integer} (@emph{decoding/encoding,video})
|
||||||
Possible values:
|
|
||||||
@table @samp
|
|
||||||
@item rgb
|
|
||||||
RGB
|
|
||||||
@item bt709
|
|
||||||
BT.709
|
|
||||||
@item fcc
|
|
||||||
FCC
|
|
||||||
@item bt470bg
|
|
||||||
BT.470 BG
|
|
||||||
@item smpte170m
|
|
||||||
SMPTE 170 M
|
|
||||||
@item smpte240m
|
|
||||||
SMPTE 240 M
|
|
||||||
@item ycocg
|
|
||||||
YCOCG
|
|
||||||
@item bt2020nc
|
|
||||||
@item bt2020_ncl
|
|
||||||
BT.2020 NCL
|
|
||||||
@item bt2020c
|
|
||||||
@item bt2020_cl
|
|
||||||
BT.2020 CL
|
|
||||||
@item smpte2085
|
|
||||||
SMPTE 2085
|
|
||||||
@item chroma-derived-nc
|
|
||||||
Chroma-derived NCL
|
|
||||||
@item chroma-derived-c
|
|
||||||
Chroma-derived CL
|
|
||||||
@item ictcp
|
|
||||||
ICtCp
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item color_range @var{integer} (@emph{decoding/encoding,video})
|
@item color_range @var{integer} (@emph{decoding/encoding,video})
|
||||||
If used as input parameter, it serves as a hint to the decoder, which
|
|
||||||
color_range the input has.
|
|
||||||
Possible values:
|
|
||||||
@table @samp
|
|
||||||
@item tv
|
|
||||||
@item mpeg
|
|
||||||
MPEG (219*2^(n-8))
|
|
||||||
@item pc
|
|
||||||
@item jpeg
|
|
||||||
JPEG (2^n-1)
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item chroma_sample_location @var{integer} (@emph{decoding/encoding,video})
|
@item chroma_sample_location @var{integer} (@emph{decoding/encoding,video})
|
||||||
Possible values:
|
|
||||||
@table @samp
|
|
||||||
@item left
|
|
||||||
|
|
||||||
@item center
|
|
||||||
|
|
||||||
@item topleft
|
|
||||||
|
|
||||||
@item top
|
|
||||||
|
|
||||||
@item bottomleft
|
|
||||||
|
|
||||||
@item bottom
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item log_level_offset @var{integer}
|
@item log_level_offset @var{integer}
|
||||||
Set the log level offset.
|
Set the log level offset.
|
||||||
@@ -988,37 +1105,10 @@ Interlaced video, top coded first, bottom displayed first
|
|||||||
Interlaced video, bottom coded first, top displayed first
|
Interlaced video, bottom coded first, top displayed first
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@item skip_alpha @var{bool} (@emph{decoding,video})
|
@item skip_alpha @var{integer} (@emph{decoding,video})
|
||||||
Set to 1 to disable processing alpha (transparency). This works like the
|
Set to 1 to disable processing alpha (transparency). This works like the
|
||||||
@samp{gray} flag in the @option{flags} option which skips chroma information
|
@samp{gray} flag in the @option{flags} option which skips chroma information
|
||||||
instead of alpha. Default is 0.
|
instead of alpha. Default is 0.
|
||||||
|
|
||||||
@item codec_whitelist @var{list} (@emph{input})
|
|
||||||
"," separated list of allowed decoders. By default all are allowed.
|
|
||||||
|
|
||||||
@item dump_separator @var{string} (@emph{input})
|
|
||||||
Separator used to separate the fields printed on the command line about the
|
|
||||||
Stream parameters.
|
|
||||||
For example, to separate the fields with newlines and indentation:
|
|
||||||
@example
|
|
||||||
ffprobe -dump_separator "
|
|
||||||
" -i ~/videos/matrixbench_mpeg2.mpg
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@item max_pixels @var{integer} (@emph{decoding/encoding,video})
|
|
||||||
Maximum number of pixels per image. This value can be used to avoid out of
|
|
||||||
memory failures due to large images.
|
|
||||||
|
|
||||||
@item apply_cropping @var{bool} (@emph{decoding,video})
|
|
||||||
Enable cropping if cropping parameters are multiples of the required
|
|
||||||
alignment for the left and top parameters. If the alignment is not met the
|
|
||||||
cropping will be partially applied to maintain alignment.
|
|
||||||
Default is 1 (enabled).
|
|
||||||
Note: The required alignment depends on if @code{AV_CODEC_FLAG_UNALIGNED} is set and the
|
|
||||||
CPU. @code{AV_CODEC_FLAG_UNALIGNED} cannot be changed from the command line. Also hardware
|
|
||||||
decoders will not apply left/top Cropping.
|
|
||||||
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@c man end CODEC OPTIONS
|
@c man end CODEC OPTIONS
|
||||||
|
|||||||
@@ -25,19 +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 av1
|
|
||||||
|
|
||||||
AOMedia Video 1 (AV1) decoder.
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item operating_point
|
|
||||||
Select an operating point of a scalable AV1 bitstream (0 - 31). Default is 0.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section rawvideo
|
@section rawvideo
|
||||||
|
|
||||||
Raw video decoder.
|
Raw video decoder.
|
||||||
@@ -60,129 +47,6 @@ top-field-first is assumed
|
|||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@section libdav1d
|
|
||||||
|
|
||||||
dav1d AV1 decoder.
|
|
||||||
|
|
||||||
libdav1d allows libavcodec to decode the AOMedia Video 1 (AV1) codec.
|
|
||||||
Requires the presence of the libdav1d headers and library during configuration.
|
|
||||||
You need to explicitly configure the build with @code{--enable-libdav1d}.
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
The following options are supported by the libdav1d wrapper.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item framethreads
|
|
||||||
Set amount of frame threads to use during decoding. The default value is 0 (autodetect).
|
|
||||||
This option is deprecated for libdav1d >= 1.0 and will be removed in the future. Use the
|
|
||||||
global option @code{threads} instead.
|
|
||||||
|
|
||||||
@item tilethreads
|
|
||||||
Set amount of tile threads to use during decoding. The default value is 0 (autodetect).
|
|
||||||
This option is deprecated for libdav1d >= 1.0 and will be removed in the future. Use the
|
|
||||||
global option @code{threads} instead.
|
|
||||||
|
|
||||||
@item filmgrain
|
|
||||||
Apply film grain to the decoded video if present in the bitstream. Defaults to the
|
|
||||||
internal default of the library.
|
|
||||||
This option is deprecated and will be removed in the future. See the global option
|
|
||||||
@code{export_side_data} to export Film Grain parameters instead of applying it.
|
|
||||||
|
|
||||||
@item oppoint
|
|
||||||
Select an operating point of a scalable AV1 bitstream (0 - 31). Defaults to the
|
|
||||||
internal default of the library.
|
|
||||||
|
|
||||||
@item alllayers
|
|
||||||
Output all spatial layers of a scalable AV1 bitstream. The default value is false.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section libdavs2
|
|
||||||
|
|
||||||
AVS2-P2/IEEE1857.4 video decoder wrapper.
|
|
||||||
|
|
||||||
This decoder allows libavcodec to decode AVS2 streams with davs2 library.
|
|
||||||
|
|
||||||
@c man end VIDEO DECODERS
|
|
||||||
|
|
||||||
@section libuavs3d
|
|
||||||
|
|
||||||
AVS3-P2/IEEE1857.10 video decoder.
|
|
||||||
|
|
||||||
libuavs3d allows libavcodec to decode AVS3 streams.
|
|
||||||
Requires the presence of the libuavs3d headers and library during configuration.
|
|
||||||
You need to explicitly configure the build with @code{--enable-libuavs3d}.
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
The following option is supported by the libuavs3d wrapper.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item frame_threads
|
|
||||||
Set amount of frame threads to use during decoding. The default value is 0 (autodetect).
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section QSV Decoders
|
|
||||||
|
|
||||||
The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC,
|
|
||||||
JPEG/MJPEG, VP8, VP9, AV1).
|
|
||||||
|
|
||||||
@subsection Common Options
|
|
||||||
|
|
||||||
The following options are supported by all qsv decoders.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item @var{async_depth}
|
|
||||||
Internal parallelization depth, the higher the value the higher the latency.
|
|
||||||
|
|
||||||
@item @var{gpu_copy}
|
|
||||||
A GPU-accelerated copy between video and system memory
|
|
||||||
@table @samp
|
|
||||||
@item default
|
|
||||||
@item on
|
|
||||||
@item off
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@subsection HEVC Options
|
|
||||||
Extra options for hevc_qsv.
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item @var{load_plugin}
|
|
||||||
A user plugin to load in an internal session
|
|
||||||
@table @samp
|
|
||||||
@item none
|
|
||||||
@item hevc_sw
|
|
||||||
@item hevc_hw
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item @var{load_plugins}
|
|
||||||
A :-separate list of hexadecimal plugin UIDs to load in an internal session
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section v210
|
|
||||||
|
|
||||||
Uncompressed 4:2:2 10-bit decoder.
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item custom_stride
|
|
||||||
Set the line size of the v210 data in bytes. The default value is 0
|
|
||||||
(autodetect). You can use the special -1 value for a strideless v210 as seen in
|
|
||||||
BOXX files.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@c man end VIDEO DECODERS
|
@c man end VIDEO DECODERS
|
||||||
|
|
||||||
@chapter Audio Decoders
|
@chapter Audio Decoders
|
||||||
@@ -204,7 +68,7 @@ the undocumented RealAudio 3 (a.k.a. dnet).
|
|||||||
|
|
||||||
@item -drc_scale @var{value}
|
@item -drc_scale @var{value}
|
||||||
Dynamic Range Scale Factor. The factor to apply to dynamic range values
|
Dynamic Range Scale Factor. The factor to apply to dynamic range values
|
||||||
from the AC-3 stream. This factor is applied exponentially. The default value is 1.
|
from the AC-3 stream. This factor is applied exponentially.
|
||||||
There are 3 notable scale factor ranges:
|
There are 3 notable scale factor ranges:
|
||||||
@table @option
|
@table @option
|
||||||
@item drc_scale == 0
|
@item drc_scale == 0
|
||||||
@@ -219,26 +83,9 @@ 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 synthesizer.
|
Internal wave synthetizer.
|
||||||
|
|
||||||
This decoder generates wave patterns according to predefined sequences. Its
|
This decoder generates wave patterns according to predefined sequences. Its
|
||||||
use is purely internal and the format of the data it accepts is not publicly
|
use is purely internal and the format of the data it accepts is not publicly
|
||||||
@@ -316,60 +163,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 libaribb24
|
|
||||||
|
|
||||||
ARIB STD-B24 caption decoder.
|
|
||||||
|
|
||||||
Implements profiles A and C of the ARIB STD-B24 standard.
|
|
||||||
|
|
||||||
@subsection libaribb24 Decoder Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item -aribb24-base-path @var{path}
|
|
||||||
Sets the base path for the libaribb24 library. This is utilized for reading of
|
|
||||||
configuration files (for custom unicode conversions), and for dumping of
|
|
||||||
non-text symbols as images under that location.
|
|
||||||
|
|
||||||
Unset by default.
|
|
||||||
|
|
||||||
@item -aribb24-skip-ruby-text @var{boolean}
|
|
||||||
Tells the decoder wrapper to skip text blocks that contain half-height ruby
|
|
||||||
text.
|
|
||||||
|
|
||||||
Enabled by default.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section dvbsub
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item compute_clut
|
|
||||||
@table @option
|
|
||||||
@item -2
|
|
||||||
Compute clut once if no matching CLUT is in the stream.
|
|
||||||
@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
|
||||||
@@ -386,18 +184,9 @@ palette is stored in the IFO file, and therefore not available when reading
|
|||||||
from dumped VOB files.
|
from dumped VOB files.
|
||||||
|
|
||||||
The format for this option is a string containing 16 24-bits hexadecimal
|
The format for this option is a string containing 16 24-bits hexadecimal
|
||||||
numbers (without 0x prefix) separated by commas, 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
|
@end table
|
||||||
|
|
||||||
@section libzvbi-teletext
|
@section libzvbi-teletext
|
||||||
@@ -411,30 +200,18 @@ configuration. You need to explicitly configure the build with
|
|||||||
|
|
||||||
@table @option
|
@table @option
|
||||||
@item txt_page
|
@item txt_page
|
||||||
List of teletext page numbers to decode. Pages that do not match the specified
|
List of teletext page numbers to decode. You may use the special * string to
|
||||||
list are dropped. You may use the special @code{*} string to match all pages,
|
match all pages. Pages that do not match the specified list are dropped.
|
||||||
or @code{subtitle} to match all subtitle pages.
|
|
||||||
Default value is *.
|
Default value is *.
|
||||||
@item txt_default_region
|
|
||||||
Set default character set used for decoding, a value between 0 and 87 (see
|
|
||||||
ETS 300 706, Section 15, Table 32). Default value is -1, which does not
|
|
||||||
override the libzvbi default. This option is needed for some legacy level 1.0
|
|
||||||
transmissions which cannot signal the proper charset.
|
|
||||||
@item txt_chop_top
|
@item txt_chop_top
|
||||||
Discards the top teletext line. Default value is 1.
|
Discards the top teletext line. Default value is 1.
|
||||||
@item txt_format
|
@item txt_format
|
||||||
Specifies the format of the decoded subtitles.
|
Specifies the format of the decoded subtitles. The teletext decoder is capable
|
||||||
@table @option
|
of decoding the teletext pages to bitmaps or to simple text, you should use
|
||||||
@item bitmap
|
"bitmap" for teletext pages, because certain graphics and colors cannot be
|
||||||
The default format, you should use this for teletext pages, because certain
|
expressed in simple text. You might use "text" for teletext based subtitles if
|
||||||
graphics and colors cannot be expressed in simple text or even ASS.
|
your application can handle simple text based subtitles. Default value is
|
||||||
@item text
|
bitmap.
|
||||||
Simple text based output without formatting.
|
|
||||||
@item ass
|
|
||||||
Formatted ASS output, subtitle pages and teletext pages are returned in
|
|
||||||
different styles, subtitle pages are stripped down to text, but an effort is
|
|
||||||
made to keep the text alignment and the formatting.
|
|
||||||
@end table
|
|
||||||
@item txt_left
|
@item txt_left
|
||||||
X offset of generated bitmaps, default is 0.
|
X offset of generated bitmaps, default is 0.
|
||||||
@item txt_top
|
@item txt_top
|
||||||
@@ -443,21 +220,14 @@ Y offset of generated bitmaps, default is 0.
|
|||||||
Chops leading and trailing spaces and removes empty lines from the generated
|
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
|
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
|
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 characters.
|
present between the subtitle lines because of double-sized teletext charactes.
|
||||||
Default value is 1.
|
Default value is 1.
|
||||||
@item txt_duration
|
@item txt_duration
|
||||||
Sets the display duration of the decoded teletext pages or subtitles in
|
Sets the display duration of the decoded teletext pages or subtitles in
|
||||||
milliseconds. Default value is -1 which means infinity or until the next
|
miliseconds. Default value is 30000 which is 30 seconds.
|
||||||
subtitle event comes.
|
|
||||||
@item txt_transparent
|
@item txt_transparent
|
||||||
Force transparent background of the generated teletext bitmaps. Default value
|
Force transparent background of the generated teletext bitmaps. Default value
|
||||||
is 0 which means an opaque background.
|
is 0 which means an opaque (black) 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
|
||||||
|
|||||||
@@ -13,47 +13,21 @@ 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
|
@section applehttp
|
||||||
|
|
||||||
Audible Format 2, 3, and 4 demuxer.
|
Apple HTTP Live Streaming demuxer.
|
||||||
|
|
||||||
This demuxer is used to demux Audible Format 2, 3, and 4 (.aa) files.
|
This demuxer presents all AVStreams from all variant streams.
|
||||||
|
The id field is set to the bitrate variant index number. By setting
|
||||||
@section aac
|
the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay),
|
||||||
|
the caller can decide which variant streams to actually receive.
|
||||||
Raw Audio Data Transport Stream AAC demuxer.
|
The total bitrate of the variant that the stream belongs to is
|
||||||
|
available in a metadata key named "variant_bitrate".
|
||||||
This demuxer is used to demux an ADTS input containing a single AAC stream
|
|
||||||
alongwith any ID3v1/2 or APE tags in it.
|
|
||||||
|
|
||||||
@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. Default is enabled.
|
|
||||||
|
|
||||||
@item -max_fps @var{int}
|
|
||||||
Maximum framerate in frames per second. Default of 0 imposes 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). Default is 15.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section asf
|
@section asf
|
||||||
|
|
||||||
@@ -72,7 +46,7 @@ Do not try to resynchronize by looking for a certain optional start code.
|
|||||||
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
|
||||||
@@ -103,10 +77,11 @@ backslash or single quotes.
|
|||||||
All subsequent file-related directives apply to that file.
|
All subsequent file-related directives apply to that file.
|
||||||
|
|
||||||
@item @code{ffconcat version 1.0}
|
@item @code{ffconcat version 1.0}
|
||||||
Identify the script type and version.
|
Identify the script type and version. It also sets the @option{safe} option
|
||||||
|
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}}
|
||||||
@@ -117,57 +92,6 @@ file is not available or accurate.
|
|||||||
If the duration is set for all files, then it is possible to seek in the
|
If the duration is set for all files, then it is possible to seek in the
|
||||||
whole concatenated video.
|
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.
|
|
||||||
This directive is deprecated, use @code{file_packet_meta} instead.
|
|
||||||
|
|
||||||
@item @code{file_packet_meta @var{key} @var{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{option @var{key} @var{value}}
|
|
||||||
Option to access, open and probe the file.
|
|
||||||
Can be present multiple times.
|
|
||||||
|
|
||||||
@item @code{stream}
|
@item @code{stream}
|
||||||
Introduce a stream in the virtual file.
|
Introduce a stream in the virtual file.
|
||||||
All subsequent stream-related directives apply to the last introduced
|
All subsequent stream-related directives apply to the last introduced
|
||||||
@@ -184,20 +108,6 @@ subfiles will be used.
|
|||||||
This is especially useful for MPEG-PS (VOB) files, where the order of the
|
This is especially useful for MPEG-PS (VOB) files, where the order of the
|
||||||
streams is not reliable.
|
streams is not reliable.
|
||||||
|
|
||||||
@item @code{stream_meta @var{key} @var{value}}
|
|
||||||
Metadata for the stream.
|
|
||||||
Can be present multiple times.
|
|
||||||
|
|
||||||
@item @code{stream_codec @var{value}}
|
|
||||||
Codec for the stream.
|
|
||||||
|
|
||||||
@item @code{stream_extradata @var{hex_string}}
|
|
||||||
Extradata for the string, encoded in hexadecimal.
|
|
||||||
|
|
||||||
@item @code{chapter @var{id} @var{start} @var{end}}
|
|
||||||
Add a chapter. @var{id} is an unique identifier, possibly small and
|
|
||||||
consecutive.
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Options
|
@subsection Options
|
||||||
@@ -207,8 +117,7 @@ This demuxer accepts the following option:
|
|||||||
@table @option
|
@table @option
|
||||||
|
|
||||||
@item safe
|
@item safe
|
||||||
If set to 1, reject unsafe file paths and directives.
|
If set to 1, reject unsafe file paths. A file path is considered safe if it
|
||||||
A file path is considered safe if it
|
|
||||||
does not contain a protocol specification and is relative and all components
|
does not contain a protocol specification and is relative and all components
|
||||||
only contain characters from the portable character set (letters, digits,
|
only contain characters from the portable character set (letters, digits,
|
||||||
period, underscore and hyphen) and have no period at the beginning of a
|
period, underscore and hyphen) and have no period at the beginning of a
|
||||||
@@ -216,192 +125,54 @@ 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
|
||||||
|
probed and 0 otherwise.
|
||||||
|
|
||||||
@item auto_convert
|
@item auto_convert
|
||||||
If set to 1, try to perform automatic conversions on packet data to make the
|
If set to 1, try to perform automatic conversions on packet data to make the
|
||||||
streams concatenable.
|
streams concatenable.
|
||||||
The default is 1.
|
|
||||||
|
|
||||||
Currently, the only conversion is adding the h264_mp4toannexb bitstream
|
Currently, the only conversion is adding the h264_mp4toannexb bitstream
|
||||||
filter to H.264 streams in MP4 format. This is necessary in particular if
|
filter to H.264 streams in MP4 format. This is necessary in particular if
|
||||||
there are resolution changes.
|
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
|
@section flv
|
||||||
|
|
||||||
@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 dash
|
|
||||||
|
|
||||||
Dynamic Adaptive Streaming over HTTP demuxer.
|
|
||||||
|
|
||||||
This demuxer presents all AVStreams found in the manifest.
|
|
||||||
By setting the discard flags on AVStreams the caller can decide
|
|
||||||
which streams to actually receive.
|
|
||||||
Each stream mirrors the @code{id} and @code{bandwidth} properties from the
|
|
||||||
@code{<Representation>} as metadata keys named "id" and "variant_bitrate" respectively.
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
This demuxer accepts the following option:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item cenc_decryption_key
|
|
||||||
16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section imf
|
|
||||||
|
|
||||||
Interoperable Master Format demuxer.
|
|
||||||
|
|
||||||
This demuxer presents audio and video streams found in an IMF Composition.
|
|
||||||
|
|
||||||
@section flv, live_flv, kux
|
|
||||||
|
|
||||||
Adobe Flash Video Format demuxer.
|
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.
|
This demuxer is used to demux FLV files and RTMP network streams.
|
||||||
KUX is a flv variant used on the Youku platform.
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -f flv -i myfile.flv ...
|
|
||||||
ffmpeg -f live_flv -i rtmp://<any.server>/anything/key ....
|
|
||||||
@end example
|
|
||||||
|
|
||||||
|
|
||||||
@table @option
|
@table @option
|
||||||
@item -flv_metadata @var{bool}
|
@item -flv_metadata @var{bool}
|
||||||
Allocate the streams according to the onMetaData array content.
|
Allocate the streams according to the onMetaData array content.
|
||||||
|
|
||||||
@item -flv_ignore_prevtag @var{bool}
|
|
||||||
Ignore the size of previous tag value.
|
|
||||||
|
|
||||||
@item -flv_full_metadata @var{bool}
|
|
||||||
Output all context of the onMetadata.
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@section gif
|
@section libgme
|
||||||
|
|
||||||
Animated GIF demuxer.
|
The Game Music Emu library is a collection of video game music file emulators.
|
||||||
|
|
||||||
It accepts the following options:
|
See @url{http://code.google.com/p/game-music-emu/} for more information.
|
||||||
|
|
||||||
@table @option
|
Some files have multiple tracks. The demuxer will pick the first track by
|
||||||
@item min_delay
|
default. The @option{track_index} option can be used to select a different
|
||||||
Set the minimum valid delay between frames in hundredths of seconds.
|
track. Track indexes start at 0. The demuxer exports the number of tracks as
|
||||||
Range is 0 to 6000. Default value is 2.
|
@var{tracks} meta data entry.
|
||||||
|
|
||||||
@item max_gif_delay
|
For very large files, the @option{max_size} option may have to be adjusted.
|
||||||
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
|
@section libquvi
|
||||||
Set the default delay between frames in hundredths of seconds.
|
|
||||||
Range is 0 to 6000. Default value is 10.
|
|
||||||
|
|
||||||
@item ignore_loop
|
Play media from Internet services using the quvi project.
|
||||||
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
|
The demuxer accepts a @option{format} option to request a specific quality. It
|
||||||
over another video:
|
is by default set to @var{best}.
|
||||||
@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
|
See @url{http://quvi.sourceforge.net/} for more information.
|
||||||
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 hls
|
FFmpeg needs to be built with @code{--enable-libquvi} for this demuxer to be
|
||||||
|
enabled.
|
||||||
HLS demuxer
|
|
||||||
|
|
||||||
Apple HTTP Live Streaming demuxer.
|
|
||||||
|
|
||||||
This demuxer presents all AVStreams from all variant streams.
|
|
||||||
The id field is set to the bitrate variant index number. By setting
|
|
||||||
the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay),
|
|
||||||
the caller can decide which variant streams to actually receive.
|
|
||||||
The total bitrate of the variant that the stream belongs to is
|
|
||||||
available in a metadata key named "variant_bitrate".
|
|
||||||
|
|
||||||
It accepts the following options:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item live_start_index
|
|
||||||
segment index to start live streams at (negative values are from the end).
|
|
||||||
|
|
||||||
@item prefer_x_start
|
|
||||||
prefer to use #EXT-X-START if it's in playlist instead of live_start_index.
|
|
||||||
|
|
||||||
@item allowed_extensions
|
|
||||||
',' separated list of file extensions that hls is allowed to access.
|
|
||||||
|
|
||||||
@item max_reload
|
|
||||||
Maximum number of times a insufficient list is attempted to be reloaded.
|
|
||||||
Default value is 1000.
|
|
||||||
|
|
||||||
@item m3u8_hold_counters
|
|
||||||
The maximum number of times to load m3u8 when it refreshes without new segments.
|
|
||||||
Default value is 1000.
|
|
||||||
|
|
||||||
@item http_persistent
|
|
||||||
Use persistent HTTP connections. Applicable only for HTTP streams.
|
|
||||||
Enabled by default.
|
|
||||||
|
|
||||||
@item http_multiple
|
|
||||||
Use multiple HTTP connections for downloading HTTP segments.
|
|
||||||
Enabled by default for HTTP/1.1 servers.
|
|
||||||
|
|
||||||
@item http_seekable
|
|
||||||
Use HTTP partial requests for downloading HTTP segments.
|
|
||||||
0 = disable, 1 = enable, -1 = auto, Default is auto.
|
|
||||||
|
|
||||||
@item seg_format_options
|
|
||||||
Set options for the demuxer of media segments using a list of key=value pairs separated by @code{:}.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section image2
|
@section image2
|
||||||
|
|
||||||
@@ -428,10 +199,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.
|
||||||
@@ -511,17 +278,6 @@ 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.
|
||||||
@item export_path_metadata
|
|
||||||
If set to 1, will add two extra fields to the metadata found in input, making them
|
|
||||||
also available for other filters (see @var{drawtext} filter for examples). Default
|
|
||||||
value is 0. The extra fields are described below:
|
|
||||||
@table @option
|
|
||||||
@item lavf.image2dec.source_path
|
|
||||||
Corresponds to the full path to the input file being read.
|
|
||||||
@item lavf.image2dec.source_basename
|
|
||||||
Corresponds to the name of the file being read.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Examples
|
@subsection Examples
|
||||||
@@ -549,265 +305,17 @@ ffmpeg -framerate 10 -pattern_type glob -i "*.png" 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{https://bitbucket.org/mpyne/game-music-emu/overview} for more information.
|
|
||||||
|
|
||||||
It accepts the following options:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
|
|
||||||
@item track_index
|
|
||||||
Set the index of which track to demux. The demuxer can only export one track.
|
|
||||||
Track indexes start at 0. Default is to pick the first track. Number of tracks
|
|
||||||
is exported as @var{tracks} metadata entry.
|
|
||||||
|
|
||||||
@item sample_rate
|
|
||||||
Set the sampling rate of the exported track. Range is 1000 to 999999. Default is 44100.
|
|
||||||
|
|
||||||
@item max_size @emph{(bytes)}
|
|
||||||
The demuxer buffers the entire file into memory. Adjust this value to set the maximum buffer size,
|
|
||||||
which in turn, acts as a ceiling for the size of files that can be read.
|
|
||||||
Default is 50 MiB.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@section libmodplug
|
|
||||||
|
|
||||||
ModPlug based module demuxer
|
|
||||||
|
|
||||||
See @url{https://github.com/Konstanty/libmodplug}
|
|
||||||
|
|
||||||
It will export one 2-channel 16-bit 44.1 kHz audio stream.
|
|
||||||
Optionally, a @code{pal8} 16-color video stream can be exported with or without printed metadata.
|
|
||||||
|
|
||||||
It accepts the following options:
|
|
||||||
|
|
||||||
@table @option
|
|
||||||
@item noise_reduction
|
|
||||||
Apply a simple low-pass filter. Can be 1 (on) or 0 (off). Default is 0.
|
|
||||||
|
|
||||||
@item reverb_depth
|
|
||||||
Set amount of reverb. Range 0-100. Default is 0.
|
|
||||||
|
|
||||||
@item reverb_delay
|
|
||||||
Set delay in ms, clamped to 40-250 ms. Default is 0.
|
|
||||||
|
|
||||||
@item bass_amount
|
|
||||||
Apply bass expansion a.k.a. XBass or megabass. Range is 0 (quiet) to 100 (loud). Default is 0.
|
|
||||||
|
|
||||||
@item bass_range
|
|
||||||
Set cutoff i.e. upper-bound for bass frequencies. Range is 10-100 Hz. Default is 0.
|
|
||||||
|
|
||||||
@item surround_depth
|
|
||||||
Apply a Dolby Pro-Logic surround effect. Range is 0 (quiet) to 100 (heavy). Default is 0.
|
|
||||||
|
|
||||||
@item surround_delay
|
|
||||||
Set surround delay in ms, clamped to 5-40 ms. Default is 0.
|
|
||||||
|
|
||||||
@item max_size
|
|
||||||
The demuxer buffers the entire file into memory. Adjust this value to set the maximum buffer size,
|
|
||||||
which in turn, acts as a ceiling for the size of files that can be read. Range is 0 to 100 MiB.
|
|
||||||
0 removes buffer size limit (not recommended). Default is 5 MiB.
|
|
||||||
|
|
||||||
@item video_stream_expr
|
|
||||||
String which is evaluated using the eval API to assign colors to the generated video stream.
|
|
||||||
Variables which can be used are @code{x}, @code{y}, @code{w}, @code{h}, @code{t}, @code{speed},
|
|
||||||
@code{tempo}, @code{order}, @code{pattern} and @code{row}.
|
|
||||||
|
|
||||||
@item video_stream
|
|
||||||
Generate video stream. Can be 1 (on) or 0 (off). Default is 0.
|
|
||||||
|
|
||||||
@item video_stream_w
|
|
||||||
Set video frame width in 'chars' where one char indicates 8 pixels. Range is 20-512. Default is 30.
|
|
||||||
|
|
||||||
@item video_stream_h
|
|
||||||
Set video frame height in 'chars' where one char indicates 8 pixels. Range is 20-512. Default is 30.
|
|
||||||
|
|
||||||
@item video_stream_ptxt
|
|
||||||
Print metadata on video stream. Includes @code{speed}, @code{tempo}, @code{order}, @code{pattern},
|
|
||||||
@code{row} and @code{ts} (time in ms). Can be 1 (on) or 0 (off). Default is 1.
|
|
||||||
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
|
|
||||||
|
|
||||||
Registered extensions: mov, mp4, m4a, 3gp, 3g2, mj2, psp, m4b, ism, ismv, isma, f4v
|
|
||||||
|
|
||||||
@subsection Options
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
@item seek_streams_individually
|
|
||||||
When seeking, identify the closest point in each stream individually and demux packets in
|
|
||||||
that stream from identified point. This can lead to a different sequence of packets compared
|
|
||||||
to demuxing linearly from the beginning. Default is true.
|
|
||||||
|
|
||||||
@item ignore_editlist
|
|
||||||
Ignore any edit list atoms. The demuxer, by default, modifies the stream index to reflect the
|
|
||||||
timeline described by the edit list. Default is false.
|
|
||||||
|
|
||||||
@item advanced_editlist
|
|
||||||
Modify the stream index to reflect the timeline described by the edit list. @code{ignore_editlist}
|
|
||||||
must be set to false for this option to be effective.
|
|
||||||
If both @code{ignore_editlist} and this option are set to false, then only the
|
|
||||||
start of the stream index is modified to reflect initial dwell time or starting timestamp
|
|
||||||
described by the edit list. Default is true.
|
|
||||||
|
|
||||||
@item ignore_chapters
|
|
||||||
Don't parse chapters. This includes GoPro 'HiLight' tags/moments. Note that chapters are
|
|
||||||
only parsed when input is seekable. Default is false.
|
|
||||||
|
|
||||||
@item use_mfra_for
|
|
||||||
For seekable fragmented input, set fragment's starting timestamp from media fragment random access box, if present.
|
|
||||||
|
|
||||||
Following options are available:
|
|
||||||
@table @samp
|
|
||||||
@item auto
|
|
||||||
Auto-detect whether to set mfra timestamps as PTS or DTS @emph{(default)}
|
|
||||||
|
|
||||||
@item dts
|
|
||||||
Set mfra timestamps as DTS
|
|
||||||
|
|
||||||
@item pts
|
|
||||||
Set mfra timestamps as PTS
|
|
||||||
|
|
||||||
@item 0
|
|
||||||
Don't use mfra box to set timestamps
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@item use_tfdt
|
|
||||||
For fragmented input, set fragment's starting timestamp to @code{baseMediaDecodeTime} from the @code{tfdt} box.
|
|
||||||
Default is enabled, which will prefer to use the @code{tfdt} box to set DTS. Disable to use the @code{earliest_presentation_time} from the @code{sidx} box.
|
|
||||||
In either case, the timestamp from the @code{mfra} box will be used if it's available and @code{use_mfra_for} is
|
|
||||||
set to pts or dts.
|
|
||||||
|
|
||||||
@item export_all
|
|
||||||
Export unrecognized boxes within the @var{udta} box as metadata entries. The first four
|
|
||||||
characters of the box type are set as the key. Default is false.
|
|
||||||
|
|
||||||
@item export_xmp
|
|
||||||
Export entire contents of @var{XMP_} box and @var{uuid} box as a string with key @code{xmp}. Note that
|
|
||||||
if @code{export_all} is set and this option isn't, the contents of @var{XMP_} box are still exported
|
|
||||||
but with key @code{XMP_}. Default is false.
|
|
||||||
|
|
||||||
@item activation_bytes
|
|
||||||
4-byte key required to decrypt Audible AAX and AAX+ files. See Audible AAX subsection below.
|
|
||||||
|
|
||||||
@item audible_fixed_key
|
|
||||||
Fixed key used for handling Audible AAX/AAX+ files. It has been pre-set so should not be necessary to
|
|
||||||
specify.
|
|
||||||
|
|
||||||
@item decryption_key
|
|
||||||
16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
|
|
||||||
|
|
||||||
@item max_stts_delta
|
|
||||||
Very high sample deltas written in a trak's stts box may occasionally be intended but usually they are written in
|
|
||||||
error or used to store a negative value for dts correction when treated as signed 32-bit integers. This option lets
|
|
||||||
the user set an upper limit, beyond which the delta is clamped to 1. Values greater than the limit if negative when
|
|
||||||
cast to int32 are used to adjust onward dts.
|
|
||||||
|
|
||||||
Unit is the track time scale. Range is 0 to UINT_MAX. Default is @code{UINT_MAX - 48000*10} which allows upto
|
|
||||||
a 10 second dts correction for 48 kHz audio streams while accommodating 99.9% of @code{uint32} range.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@subsection Audible AAX
|
|
||||||
|
|
||||||
Audible AAX files are encrypted M4B files, and they can be decrypted by specifying a 4 byte activation secret.
|
|
||||||
@example
|
|
||||||
ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section mpegts
|
@section mpegts
|
||||||
|
|
||||||
MPEG-2 transport stream demuxer.
|
MPEG-2 transport stream demuxer.
|
||||||
|
|
||||||
This demuxer accepts the following options:
|
|
||||||
@table @option
|
@table @option
|
||||||
@item resync_size
|
|
||||||
Set size limit for looking up a new synchronization. Default value is
|
|
||||||
65536.
|
|
||||||
|
|
||||||
@item skip_unknown_pmt
|
|
||||||
Skip PMTs for programs not defined in the PAT. Default value is 0.
|
|
||||||
|
|
||||||
@item fix_teletext_pts
|
@item fix_teletext_pts
|
||||||
Override teletext packet PTS and DTS values with the timestamps calculated
|
Overrides 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
|
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
|
not discarded. Default value is 1, set this option to 0 if you want your
|
||||||
teletext packet PTS and DTS values untouched.
|
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.
|
|
||||||
|
|
||||||
@item merge_pmt_versions
|
|
||||||
Re-use existing streams when a PMT's version is updated and elementary
|
|
||||||
streams move to different PIDs. Default value is 0.
|
|
||||||
|
|
||||||
@item max_packet_size
|
|
||||||
Set maximum size, in bytes, of packet emitted by the demuxer. Payloads above this size
|
|
||||||
are split across multiple packets. Range is 1 to INT_MAX/2. Default is 204800 bytes.
|
|
||||||
@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
|
@end table
|
||||||
|
|
||||||
@section rawvideo
|
@section rawvideo
|
||||||
@@ -890,20 +398,4 @@ Example: convert the captions to a format most players understand:
|
|||||||
ffmpeg -i http://www.ted.com/talks/subtitles/id/1/lang/en talk1-en.srt
|
ffmpeg -i http://www.ted.com/talks/subtitles/id/1/lang/en talk1-en.srt
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section vapoursynth
|
|
||||||
|
|
||||||
Vapoursynth wrapper.
|
|
||||||
|
|
||||||
Due to security concerns, Vapoursynth scripts will not
|
|
||||||
be autodetected so the input format has to be forced. For ff* CLI tools,
|
|
||||||
add @code{-f vapoursynth} before the input @code{-i yourscript.vpy}.
|
|
||||||
|
|
||||||
This demuxer accepts the following option:
|
|
||||||
@table @option
|
|
||||||
@item max_script_size
|
|
||||||
The demuxer buffers the entire script into memory. Adjust this value to set the maximum buffer size,
|
|
||||||
which in turn, acts as a ceiling for the size of scripts that can be read.
|
|
||||||
Default is 1 MiB.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@c man end DEMUXERS
|
@c man end DEMUXERS
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
# FFmpeg project
|
|
||||||
|
|
||||||
## Organisation
|
|
||||||
|
|
||||||
The FFmpeg project is organized through a community working on global consensus.
|
|
||||||
|
|
||||||
Decisions are taken by the ensemble of active members, through voting and
|
|
||||||
are aided by two committees.
|
|
||||||
|
|
||||||
## General Assembly
|
|
||||||
|
|
||||||
The ensemble of active members is called the General Assembly (GA).
|
|
||||||
|
|
||||||
The General Assembly is sovereign and legitimate for all its decisions
|
|
||||||
regarding the FFmpeg project.
|
|
||||||
|
|
||||||
The General Assembly is made up of active contributors.
|
|
||||||
|
|
||||||
Contributors are considered "active contributors" if they have pushed more
|
|
||||||
than 20 patches in the last 36 months in the main FFmpeg repository, or
|
|
||||||
if they have been voted in by the GA.
|
|
||||||
|
|
||||||
Additional members are added to the General Assembly through a vote after
|
|
||||||
proposal by a member of the General Assembly.
|
|
||||||
They are part of the GA for two years, after which they need a confirmation by
|
|
||||||
the GA.
|
|
||||||
|
|
||||||
## Voting
|
|
||||||
|
|
||||||
Voting is done using a ranked voting system, currently running on https://vote.ffmpeg.org/ .
|
|
||||||
|
|
||||||
Majority vote means more than 50% of the expressed ballots.
|
|
||||||
|
|
||||||
## Technical Committee
|
|
||||||
|
|
||||||
The Technical Committee (TC) is here to arbitrate and make decisions when
|
|
||||||
technical conflicts occur in the project.
|
|
||||||
They will consider the merits of all the positions, judge them and make a
|
|
||||||
decision.
|
|
||||||
|
|
||||||
The TC resolves technical conflicts but is not a technical steering committee.
|
|
||||||
|
|
||||||
Decisions by the TC are binding for all the contributors.
|
|
||||||
|
|
||||||
Decisions made by the TC can be re-opened after 1 year or by a majority vote
|
|
||||||
of the General Assembly, requested by one of the member of the GA.
|
|
||||||
|
|
||||||
The TC is elected by the General Assembly for a duration of 1 year, and
|
|
||||||
is composed of 5 members.
|
|
||||||
Members can be re-elected if they wish. A majority vote in the General Assembly
|
|
||||||
can trigger a new election of the TC.
|
|
||||||
|
|
||||||
The members of the TC can be elected from outside of the GA.
|
|
||||||
Candidates for election can either be suggested or self-nominated.
|
|
||||||
|
|
||||||
The conflict resolution process is detailed in the [resolution process](resolution_process.md) document.
|
|
||||||
|
|
||||||
## Community committee
|
|
||||||
|
|
||||||
The Community Committee (CC) is here to arbitrage and make decisions when
|
|
||||||
inter-personal conflicts occur in the project. It will decide quickly and
|
|
||||||
take actions, for the sake of the project.
|
|
||||||
|
|
||||||
The CC can remove privileges of offending members, including removal of
|
|
||||||
commit access and temporary ban from the community.
|
|
||||||
|
|
||||||
Decisions made by the CC can be re-opened after 1 year or by a majority vote
|
|
||||||
of the General Assembly. Indefinite bans from the community must be confirmed
|
|
||||||
by the General Assembly, in a majority vote.
|
|
||||||
|
|
||||||
The CC is elected by the General Assembly for a duration of 1 year, and is
|
|
||||||
composed of 5 members.
|
|
||||||
Members can be re-elected if they wish. A majority vote in the General Assembly
|
|
||||||
can trigger a new election of the CC.
|
|
||||||
|
|
||||||
The members of the CC can be elected from outside of the GA.
|
|
||||||
Candidates for election can either be suggested or self-nominated.
|
|
||||||
|
|
||||||
The CC is governed by and responsible for enforcing the Code of Conduct.
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
# Technical Committee
|
|
||||||
|
|
||||||
_This document only makes sense with the rules from [the community document](community)_.
|
|
||||||
|
|
||||||
The Technical Committee (**TC**) is here to arbitrate and make decisions when
|
|
||||||
technical conflicts occur in the project.
|
|
||||||
|
|
||||||
The TC main role is to resolve technical conflicts.
|
|
||||||
It is therefore not a technical steering committee, but it is understood that
|
|
||||||
some decisions might impact the future of the project.
|
|
||||||
|
|
||||||
# Process
|
|
||||||
|
|
||||||
## Seizing
|
|
||||||
|
|
||||||
The TC can take possession of any technical matter that it sees fit.
|
|
||||||
|
|
||||||
To involve the TC in a matter, email tc@ or CC them on an ongoing discussion.
|
|
||||||
|
|
||||||
As members of TC are developers, they also can email tc@ to raise an issue.
|
|
||||||
|
|
||||||
## Announcement
|
|
||||||
|
|
||||||
The TC, once seized, must announce itself on the main mailing list, with a _[TC]_ tag.
|
|
||||||
|
|
||||||
The TC has 2 modes of operation: a RFC one and an internal one.
|
|
||||||
|
|
||||||
If the TC thinks it needs the input from the larger community, the TC can call
|
|
||||||
for a RFC. Else, it can decide by itself.
|
|
||||||
|
|
||||||
If the disagreement involves a member of the TC, that member should recuse
|
|
||||||
themselves from the decision.
|
|
||||||
|
|
||||||
The decision to use a RFC process or an internal discussion is a discretionary
|
|
||||||
decision of the TC.
|
|
||||||
|
|
||||||
The TC can also reject a seizure for a few reasons such as:
|
|
||||||
the matter was not discussed enough previously; it lacks expertise to reach a
|
|
||||||
beneficial decision on the matter; or the matter is too trivial.
|
|
||||||
|
|
||||||
### RFC call
|
|
||||||
|
|
||||||
In the RFC mode, one person from the TC posts on the mailing list the
|
|
||||||
technical question and will request input from the community.
|
|
||||||
|
|
||||||
The mail will have the following specification:
|
|
||||||
* a precise title
|
|
||||||
* a specific tag [TC RFC]
|
|
||||||
* a top-level email
|
|
||||||
* contain a precise question that does not exceed 100 words and that is answerable by developers
|
|
||||||
* may have an extra description, or a link to a previous discussion, if deemed necessary,
|
|
||||||
* contain a precise end date for the answers.
|
|
||||||
|
|
||||||
The answers from the community must be on the main mailing list and must have
|
|
||||||
the following specification:
|
|
||||||
* keep the tag and the title unchanged
|
|
||||||
* limited to 400 words
|
|
||||||
* a first-level, answering directly to the main email
|
|
||||||
* answering to the question.
|
|
||||||
|
|
||||||
Further replies to answers are permitted, as long as they conform to the
|
|
||||||
community standards of politeness, they are limited to 100 words, and are not
|
|
||||||
nested more than once. (max-depth=2)
|
|
||||||
|
|
||||||
After the end-date, mails on the thread will be ignored.
|
|
||||||
|
|
||||||
Violations of those rules will be escalated through the Community Committee.
|
|
||||||
|
|
||||||
After all the emails are in, the TC has 96 hours to give its final decision.
|
|
||||||
Exceptionally, the TC can request an extra delay, that will be notified on the
|
|
||||||
mailing list.
|
|
||||||
|
|
||||||
### Within TC
|
|
||||||
|
|
||||||
In the internal case, the TC has 96 hours to give its final decision.
|
|
||||||
Exceptionally, the TC can request an extra delay.
|
|
||||||
|
|
||||||
|
|
||||||
## Decisions
|
|
||||||
|
|
||||||
The decisions from the TC will be sent on the mailing list, with the _[TC]_ tag.
|
|
||||||
|
|
||||||
Internally, the TC should take decisions with a majority, or using
|
|
||||||
ranked-choice voting.
|
|
||||||
|
|
||||||
The decision from the TC should be published with a summary of the reasons that
|
|
||||||
lead to this decision.
|
|
||||||
|
|
||||||
The decisions from the TC are final, until the matters are reopened after
|
|
||||||
no less than one year.
|
|
||||||
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
\input texinfo @c -*- texinfo -*-
|
\input texinfo @c -*- texinfo -*-
|
||||||
@documentencoding UTF-8
|
|
||||||
|
|
||||||
@settitle Developer Documentation
|
@settitle Developer Documentation
|
||||||
@titlepage
|
@titlepage
|
||||||
@@ -10,7 +9,9 @@
|
|||||||
|
|
||||||
@contents
|
@contents
|
||||||
|
|
||||||
@chapter Notes for external developers
|
@chapter Developers Guide
|
||||||
|
|
||||||
|
@section Notes for external developers
|
||||||
|
|
||||||
This document is mostly useful for internal FFmpeg developers.
|
This document is mostly useful for internal FFmpeg developers.
|
||||||
External developers who need to use the API in their application should
|
External developers who need to use the API in their application should
|
||||||
@@ -26,15 +27,17 @@ this document.
|
|||||||
|
|
||||||
For more detailed legal information about the use of FFmpeg in
|
For more detailed legal information about the use of FFmpeg in
|
||||||
external programs read the @file{LICENSE} file in the source tree and
|
external programs read the @file{LICENSE} file in the source tree and
|
||||||
consult @url{https://ffmpeg.org/legal.html}.
|
consult @url{http://ffmpeg.org/legal.html}.
|
||||||
|
|
||||||
@chapter Contributing
|
@section Contributing
|
||||||
|
|
||||||
There are 2 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 ffmpeg-devel 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
|
||||||
|
gitorious.org. And asking us to merge these changes.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
Whichever way, changes should be reviewed by the maintainer of the code
|
Whichever way, changes should be reviewed by the maintainer of the code
|
||||||
@@ -43,9 +46,9 @@ The developer making the commit and the author are responsible for their changes
|
|||||||
and should try to fix issues their commit causes.
|
and should try to fix issues their commit causes.
|
||||||
|
|
||||||
@anchor{Coding Rules}
|
@anchor{Coding Rules}
|
||||||
@chapter Coding Rules
|
@section Coding Rules
|
||||||
|
|
||||||
@section 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:
|
||||||
|
|
||||||
@@ -61,16 +64,13 @@ 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'.
|
||||||
|
|
||||||
The main priority in FFmpeg is simplicity and small code size in order to
|
The main priority in FFmpeg is simplicity and small code size in order to
|
||||||
minimize the bug count.
|
minimize the bug count.
|
||||||
|
|
||||||
@section Comments
|
@subsection Comments
|
||||||
Use the JavaDoc/Doxygen format (see examples below) so that code documentation
|
Use the JavaDoc/Doxygen format (see examples below) so that code documentation
|
||||||
can be generated automatically. All nontrivial functions should have a comment
|
can be generated automatically. All nontrivial functions should have a comment
|
||||||
above them explaining what the function does, even if it is just one sentence.
|
above them explaining what the function does, even if it is just one sentence.
|
||||||
@@ -110,7 +110,7 @@ int myfunc(int my_parameter)
|
|||||||
...
|
...
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section C language features
|
@subsection C language features
|
||||||
|
|
||||||
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:
|
||||||
@@ -123,21 +123,10 @@ the @samp{inline} keyword;
|
|||||||
@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
|
|
||||||
for loops with variable definition (@samp{for (int i = 0; i < 8; i++)});
|
|
||||||
|
|
||||||
@item
|
|
||||||
Variadic macros (@samp{#define ARRAY(nb, ...) (int[nb + 1])@{ nb, __VA_ARGS__ @}});
|
|
||||||
|
|
||||||
@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
|
||||||
@@ -162,11 +151,11 @@ mixing statements and declarations;
|
|||||||
GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
|
GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@section Naming conventions
|
@subsection Naming conventions
|
||||||
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:
|
||||||
|
|
||||||
@@ -186,7 +175,7 @@ e.g. @samp{ff_w64_demuxer}.
|
|||||||
@item
|
@item
|
||||||
For variables and functions visible outside of file scope, used internally
|
For variables and functions visible outside of file scope, used internally
|
||||||
across multiple libraries, use @code{avpriv_} as prefix, for example,
|
across multiple libraries, use @code{avpriv_} as prefix, for example,
|
||||||
@samp{avpriv_report_missing_feature}.
|
@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
|
||||||
@@ -206,7 +195,7 @@ letter as they are reserved by the C standard. Names starting with @code{_}
|
|||||||
are reserved at the file level and may not be used for externally visible
|
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.
|
||||||
|
|
||||||
@section Miscellaneous conventions
|
@subsection Miscellaneous conventions
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
@@ -218,7 +207,7 @@ 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.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@section Editor configuration
|
@subsection Editor configuration
|
||||||
In order to configure Vim to follow FFmpeg formatting conventions, paste
|
In order to configure Vim to follow FFmpeg formatting conventions, paste
|
||||||
the following snippet into your @file{.vimrc}:
|
the following snippet into your @file{.vimrc}:
|
||||||
@example
|
@example
|
||||||
@@ -238,7 +227,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)
|
||||||
@@ -249,12 +238,12 @@ 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
|
||||||
|
|
||||||
@chapter Development Policy
|
@section Development Policy
|
||||||
|
|
||||||
@section 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
|
||||||
@@ -267,15 +256,15 @@ preferred.
|
|||||||
If you add a new file, give it a proper license header. Do not copy and
|
If you add a new file, give it a proper license header. Do not copy and
|
||||||
paste it from a random place, use an existing file as template.
|
paste it from a random place, use an existing file as template.
|
||||||
|
|
||||||
@subheading You must not commit code which breaks FFmpeg!
|
@item
|
||||||
This means unfinished code which is enabled and breaks compilation,
|
You must not commit code which breaks FFmpeg! (Meaning unfinished but
|
||||||
or compiles but does not work/breaks the regression tests. Code which
|
enabled code which breaks compilation or compiles but does not work or
|
||||||
is unfinished but disabled may be permitted under-circumstances, like
|
breaks the regression tests)
|
||||||
missing samples or an implementation with a small subset of features.
|
You can commit unfinished stuff (for testing etc), but it must be disabled
|
||||||
Always check the mailing list for any reviewers with issues and test
|
(#ifdef etc) by default so it does not interfere with other developers'
|
||||||
FATE before you push.
|
work.
|
||||||
|
|
||||||
@subheading Keep the main commit message short with an extended description below.
|
@item
|
||||||
The commit message should have a short first line in the form of
|
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
|
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.
|
from the body consisting of an explanation of why the change is necessary.
|
||||||
@@ -283,24 +272,30 @@ 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
|
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.
|
not exempt you from writing an excerpt of the bug in the commit message.
|
||||||
|
|
||||||
@subheading Testing must be adequate but not excessive.
|
@item
|
||||||
If it works for you, others, and passes FATE then it should be OK to commit
|
You do not have to over-test things. If it works for you, and you think it
|
||||||
it, provided it fits the other committing criteria. You should not worry about
|
should work for others, then commit. If your code has problems
|
||||||
over-testing things. If your code has problems (portability, triggers
|
(portability, triggers compiler bugs, unusual environment etc) they will be
|
||||||
compiler bugs, unusual environment etc) they will be reported and eventually
|
reported and eventually fixed.
|
||||||
fixed.
|
|
||||||
|
|
||||||
@subheading Do not commit unrelated changes together.
|
@item
|
||||||
They should be split them into self-contained pieces. Also do not forget
|
Do not commit unrelated changes together, split them into self-contained
|
||||||
that if part B depends on part A, but A does not depend on B, then A can
|
pieces. Also do not forget that if part B depends on part A, but A does not
|
||||||
and should be committed first and separate from B. Keeping changes well
|
depend on B, then A can and should be committed first and separate from B.
|
||||||
split into self-contained parts makes reviewing and understanding them on
|
Keeping changes well split into self-contained parts makes reviewing and
|
||||||
the commit log mailing list easier. This also helps in case of debugging
|
understanding them on the commit log mailing list easier. This also helps
|
||||||
later on.
|
in case of debugging later on.
|
||||||
Also if you have doubts about splitting or not splitting, do not hesitate to
|
Also if you have doubts about splitting or not splitting, do not hesitate to
|
||||||
ask/discuss it on the developer mailing list.
|
ask/discuss it on the developer mailing list.
|
||||||
|
|
||||||
@subheading Ask before you change the build system (configure, etc).
|
@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!
|
||||||
|
|
||||||
|
Note: Redundant code can be removed.
|
||||||
|
|
||||||
|
@item
|
||||||
Do not commit changes to the build system (Makefiles, configure script)
|
Do not commit changes to the build system (Makefiles, configure script)
|
||||||
which change behavior, defaults etc, without asking first. The same
|
which change behavior, defaults etc, without asking first. The same
|
||||||
applies to compiler warning fixes, trivial looking fixes and to code
|
applies to compiler warning fixes, trivial looking fixes and to code
|
||||||
@@ -309,7 +304,7 @@ 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
|
list, and if the code maintainers say OK, you may commit. This does not
|
||||||
apply to files you wrote and/or maintain.
|
apply to files you wrote and/or maintain.
|
||||||
|
|
||||||
@subheading Cosmetic changes should be kept in separate patches.
|
@item
|
||||||
We refuse source indentation and other cosmetic changes if they are mixed
|
We refuse source indentation and other cosmetic changes if they are mixed
|
||||||
with functional changes, such commits will be rejected and removed. Every
|
with functional changes, such commits will be rejected and removed. Every
|
||||||
developer has his own indentation style, you should not change it. Of course
|
developer has his own indentation style, you should not change it. Of course
|
||||||
@@ -323,43 +318,56 @@ NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
|
|||||||
then either do NOT change the indentation of the inner part within (do not
|
then either do NOT change the indentation of the inner part within (do not
|
||||||
move it to the right)! or do so in a separate commit
|
move it to the right)! or do so in a separate commit
|
||||||
|
|
||||||
@subheading Commit messages should always be filled out properly.
|
@item
|
||||||
Always fill out the commit log message. Describe in a few lines what you
|
Always fill out the commit log message. Describe in a few lines what you
|
||||||
changed and why. You can refer to mailing list postings if you fix a
|
changed and why. You can refer to mailing list postings if you fix a
|
||||||
particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
|
particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
|
||||||
Recommended format:
|
Recommended format:
|
||||||
|
|
||||||
@example
|
|
||||||
area changed: Short 1 line description
|
area changed: Short 1 line description
|
||||||
|
|
||||||
details describing what and why and giving references.
|
details describing what and why and giving references.
|
||||||
@end example
|
|
||||||
|
|
||||||
@subheading Credit the author of the patch.
|
@item
|
||||||
Make sure the author of the commit is set correctly. (see git commit --author)
|
Make sure the author of the commit is set correctly. (see git commit --author)
|
||||||
If you apply a patch, send an
|
If you apply a patch, send an
|
||||||
answer to ffmpeg-devel (or wherever you got the patch from) saying that
|
answer to ffmpeg-devel (or wherever you got the patch from) saying that
|
||||||
you applied the patch.
|
you applied the patch.
|
||||||
|
|
||||||
@subheading Complex patches should refer to discussion surrounding them.
|
@item
|
||||||
When applying patches that have been discussed (at length) on the mailing
|
When applying patches that have been discussed (at length) on the mailing
|
||||||
list, reference the thread in the log message.
|
list, reference the thread in the log message.
|
||||||
|
|
||||||
@subheading Always wait long enough before pushing changes
|
@item
|
||||||
Do NOT commit to code actively maintained by others without permission.
|
Do NOT commit to code actively maintained by others without permission.
|
||||||
Send a patch to ffmpeg-devel. If no one answers within a reasonable
|
Send a patch to ffmpeg-devel instead. If no one answers within a reasonable
|
||||||
time-frame (12h for build failures and security fixes, 3 days small changes,
|
timeframe (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.
|
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!
|
Also note, the maintainer can simply ask for more time to review!
|
||||||
|
|
||||||
@section Code
|
@item
|
||||||
@subheading API/ABI changes should be discussed before they are made.
|
Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
|
||||||
Do not change behavior of the programs (renaming options etc) or public
|
are sent there and reviewed by all the other developers. Bugs and possible
|
||||||
API or ABI without first discussing it on the ffmpeg-devel mailing list.
|
improvements or general questions regarding commits are discussed there. We
|
||||||
Do not remove widely used functionality or features (redundant code can be removed).
|
expect you to react if problems with your code are uncovered.
|
||||||
|
|
||||||
@subheading Remember to check if you need to bump versions for libav*.
|
@item
|
||||||
Depending on the change, you may need to change the version integer.
|
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.
|
||||||
|
|
||||||
|
@item
|
||||||
|
Try to keep important discussions and requests (also) on the public
|
||||||
|
developer mailing list, so that all developers can benefit from them.
|
||||||
|
|
||||||
|
@item
|
||||||
|
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.
|
||||||
|
|
||||||
|
@item
|
||||||
|
Remember to check if you need to bump versions for the specific libav*
|
||||||
|
parts (libavutil, libavcodec, libavformat) you are changing. You need
|
||||||
|
to change the version integer.
|
||||||
Incrementing the first component means no backward compatibility to
|
Incrementing the first component means no backward compatibility to
|
||||||
previous versions (e.g. removal of a function from the public API).
|
previous versions (e.g. removal of a function from the public API).
|
||||||
Incrementing the second component means backward compatible change
|
Incrementing the second component means backward compatible change
|
||||||
@@ -369,7 +377,7 @@ Incrementing the third component means a noteworthy binary compatible
|
|||||||
change (e.g. encoder bug fix that matters for the decoder). The third
|
change (e.g. encoder bug fix that matters for the decoder). The third
|
||||||
component always starts at 100 to distinguish FFmpeg from Libav.
|
component always starts at 100 to distinguish FFmpeg from Libav.
|
||||||
|
|
||||||
@subheading Warnings for correct code may be disabled if there is no other option.
|
@item
|
||||||
Compiler warnings indicate potential bugs or code with bad style. If a type of
|
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
|
warning always points to correct and clean code, that warning should
|
||||||
be disabled, not the code changed.
|
be disabled, not the code changed.
|
||||||
@@ -378,90 +386,24 @@ 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
|
be changed to not generate a warning unless that causes a slowdown
|
||||||
or obfuscates the code.
|
or obfuscates the code.
|
||||||
|
|
||||||
@subheading Check untrusted input properly.
|
@item
|
||||||
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.
|
|
||||||
|
|
||||||
@section Documentation/Other
|
|
||||||
@subheading Subscribe to the ffmpeg-devel mailing list.
|
|
||||||
It is important to be subscribed to the
|
|
||||||
@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel}
|
|
||||||
mailing list. Almost any non-trivial patch is to be sent there for review.
|
|
||||||
Other developers may have comments about your contribution. We expect you see
|
|
||||||
those comments, and to improve it if requested. (N.B. Experienced committers
|
|
||||||
have other channels, and may sometimes skip review for trivial fixes.) Also,
|
|
||||||
discussion here about bug fixes and FFmpeg improvements by other developers may
|
|
||||||
be helpful information for you. Finally, by being a list subscriber, your
|
|
||||||
contribution will be posted immediately to the list, without the moderation
|
|
||||||
hold which messages from non-subscribers experience.
|
|
||||||
|
|
||||||
However, it is more important to the project that we receive your patch than
|
|
||||||
that you be subscribed to the ffmpeg-devel list. If you have a patch, and don't
|
|
||||||
want to subscribe and discuss the patch, then please do send it to the list
|
|
||||||
anyway.
|
|
||||||
|
|
||||||
@subheading Subscribe to the ffmpeg-cvslog mailing list.
|
|
||||||
Diffs of all commits are sent to the
|
|
||||||
@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog, ffmpeg-cvslog}
|
|
||||||
mailing list. Some developers read this list to review all code base changes
|
|
||||||
from all sources. Subscribing to this list is not mandatory.
|
|
||||||
|
|
||||||
@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
|
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
|
@file{MAINTAINERS} file. If something that you want to maintain is missing add it with
|
||||||
your name after it.
|
your name after it.
|
||||||
If at some point you no longer want to maintain some code, then please help in
|
If at some point you no longer want to maintain some code, then please help
|
||||||
finding a new maintainer and also don't forget to update the @file{MAINTAINERS} file.
|
finding a new maintainer and also don't forget updating the @file{MAINTAINERS} file.
|
||||||
|
@end enumerate
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@chapter 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}
|
||||||
@chapter Submitting patches
|
@section Submitting patches
|
||||||
|
|
||||||
First, read the @ref{Coding Rules} above if you did not yet, in particular
|
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
|
||||||
@@ -484,32 +426,12 @@ 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.
|
|
||||||
|
|
||||||
@subheading Sending patches from email clients
|
|
||||||
Using @code{git send-email} might not be desirable for everyone. The
|
|
||||||
following trick allows to send patches via email clients in a safe
|
|
||||||
way. It has been tested with Outlook and Thunderbird (with X-Unsent
|
|
||||||
extension) and might work with other applications.
|
|
||||||
|
|
||||||
Create your patch like this:
|
|
||||||
|
|
||||||
@verbatim
|
|
||||||
git format-patch -s -o "outputfolder" --add-header "X-Unsent: 1" --suffix .eml --to ffmpeg-devel@ffmpeg.org -1 1a2b3c4d
|
|
||||||
@end verbatim
|
|
||||||
|
|
||||||
Now you'll just need to open the eml file with the email application
|
|
||||||
and execute 'Send'.
|
|
||||||
|
|
||||||
@subheading Reviews
|
|
||||||
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
|
||||||
incorporates the requests from the review. This process may go through
|
incorporates the requests from the review. This process may go through
|
||||||
@@ -520,7 +442,7 @@ Give us a few days to react. But if some time passes without reaction,
|
|||||||
send a reminder by email. Your patch should eventually be dealt with.
|
send a reminder by email. Your patch should eventually be dealt with.
|
||||||
|
|
||||||
|
|
||||||
@chapter New codecs or formats checklist
|
@section New codecs or formats checklist
|
||||||
|
|
||||||
@enumerate
|
@enumerate
|
||||||
@item
|
@item
|
||||||
@@ -572,7 +494,7 @@ Did you make sure it compiles standalone, i.e. with
|
|||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
|
|
||||||
@chapter Patch submission checklist
|
@section patch submission checklist
|
||||||
|
|
||||||
@enumerate
|
@enumerate
|
||||||
@item
|
@item
|
||||||
@@ -582,9 +504,9 @@ Does @code{make fate} pass with the patch applied?
|
|||||||
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? (@code{git commit -s})
|
Did you sign off your patch? (git commit -s)
|
||||||
See @uref{https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/process/submitting-patches.rst, Sign your work} 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 @dfn{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?
|
||||||
@@ -617,10 +539,6 @@ tools/trasher, the noise bitstream filter, and
|
|||||||
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
|
|
||||||
Did you test your decoder or demuxer against sample files?
|
|
||||||
Samples may be obtained at @url{https://samples.ffmpeg.org}.
|
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Does the patch not mix functional and cosmetic changes?
|
Does the patch not mix functional and cosmetic changes?
|
||||||
|
|
||||||
@@ -641,7 +559,7 @@ 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
|
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?
|
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
|
Note please do not attach samples >100k to mails but rather provide a
|
||||||
URL, you can upload to @url{https://streams.videolan.org/upload/}.
|
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 summary about what the patch does change?
|
||||||
@@ -670,10 +588,10 @@ Lines with similar content should be aligned vertically when doing so
|
|||||||
improves readability.
|
improves readability.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Consider adding a regression test for your code.
|
Consider to add a regression test for your code.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
If you added YASM code please check that things still work with --disable-yasm.
|
If you added YASM code please check that things still work with --disable-yasm
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Make sure you check the return values of function and return appropriate
|
Make sure you check the return values of function and return appropriate
|
||||||
@@ -685,7 +603,7 @@ Test your code with valgrind and or Address Sanitizer to ensure it's free
|
|||||||
of leaks, out of array accesses, etc.
|
of leaks, out of array accesses, etc.
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
@chapter Patch review process
|
@section Patch review process
|
||||||
|
|
||||||
All patches posted to ffmpeg-devel will be reviewed, unless they contain a
|
All patches posted to ffmpeg-devel will be reviewed, unless they contain a
|
||||||
clear note that the patch is not for the git master branch.
|
clear note that the patch is not for the git master branch.
|
||||||
@@ -711,12 +629,8 @@ 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}
|
||||||
@chapter Regression tests
|
@section Regression tests
|
||||||
|
|
||||||
Before submitting a patch (or committing to the repository), you should at least
|
Before submitting a patch (or committing to the repository), you should at least
|
||||||
test that you did not break anything.
|
test that you did not break anything.
|
||||||
@@ -727,18 +641,19 @@ Running 'make fate' accomplishes this, please see @url{fate.html} for details.
|
|||||||
this case, the reference results of the regression tests shall be modified
|
this case, the reference results of the regression tests shall be modified
|
||||||
accordingly].
|
accordingly].
|
||||||
|
|
||||||
@section 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.
|
||||||
|
|
||||||
@section Visualizing Test Coverage
|
|
||||||
|
@subsection Visualizing Test Coverage
|
||||||
|
|
||||||
The FFmpeg build system allows visualizing the test coverage in an easy
|
The FFmpeg build system allows visualizing the test coverage in an easy
|
||||||
manner with the coverage tools @code{gcov}/@code{lcov}. This involves
|
manner with the coverage tools @code{gcov}/@code{lcov}. This involves
|
||||||
@@ -765,7 +680,7 @@ 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
|
measurements. You will need to rerun @code{make lcov} after running a
|
||||||
new test.
|
new test.
|
||||||
|
|
||||||
@section Using Valgrind
|
@subsection Using Valgrind
|
||||||
|
|
||||||
The configure script provides a shortcut for using valgrind to spot bugs
|
The configure script provides a shortcut for using valgrind to spot bugs
|
||||||
related to memory handling. Just add the option
|
related to memory handling. Just add the option
|
||||||
@@ -779,13 +694,13 @@ In case you need finer control over how valgrind is invoked, use the
|
|||||||
your configure line instead.
|
your configure line instead.
|
||||||
|
|
||||||
@anchor{Release process}
|
@anchor{Release process}
|
||||||
@chapter Release process
|
@section Release process
|
||||||
|
|
||||||
FFmpeg maintains a set of @strong{release branches}, which are the
|
FFmpeg maintains a set of @strong{release branches}, which are the
|
||||||
recommended deliverable for system integrators and distributors (such as
|
recommended deliverable for system integrators and distributors (such as
|
||||||
Linux distributions, etc.). At regular times, a @strong{release
|
Linux distributions, etc.). At regular times, a @strong{release
|
||||||
manager} prepares, tests and publishes tarballs on the
|
manager} prepares, tests and publishes tarballs on the
|
||||||
@url{https://ffmpeg.org} website.
|
@url{http://ffmpeg.org} website.
|
||||||
|
|
||||||
There are two kinds of releases:
|
There are two kinds of releases:
|
||||||
|
|
||||||
@@ -811,7 +726,7 @@ adjustments to the symbol versioning file. Please discuss such changes
|
|||||||
on the @strong{ffmpeg-devel} mailing list in time to allow forward planning.
|
on the @strong{ffmpeg-devel} mailing list in time to allow forward planning.
|
||||||
|
|
||||||
@anchor{Criteria for Point Releases}
|
@anchor{Criteria for Point Releases}
|
||||||
@section Criteria for Point Releases
|
@subsection Criteria for Point Releases
|
||||||
|
|
||||||
Changes that match the following criteria are valid candidates for
|
Changes that match the following criteria are valid candidates for
|
||||||
inclusion into a point release:
|
inclusion into a point release:
|
||||||
@@ -835,7 +750,7 @@ point releases of the same release branch.
|
|||||||
The order for checking the rules is (1 OR 2 OR 3) AND 4.
|
The order for checking the rules is (1 OR 2 OR 3) AND 4.
|
||||||
|
|
||||||
|
|
||||||
@section Release Checklist
|
@subsection Release Checklist
|
||||||
|
|
||||||
The release process involves the following steps:
|
The release process involves the following steps:
|
||||||
|
|
||||||
@@ -864,7 +779,7 @@ Prepare the release tarballs in @code{bz2} and @code{gz} formats, and
|
|||||||
supplementing files that contain @code{gpg} signatures
|
supplementing files that contain @code{gpg} signatures
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Publish the tarballs at @url{https://ffmpeg.org/releases}. Create and
|
Publish the tarballs at @url{http://ffmpeg.org/releases}. Create and
|
||||||
push an annotated tag in the form @code{nX}, with @code{X}
|
push an annotated tag in the form @code{nX}, with @code{X}
|
||||||
containing the version number.
|
containing the version number.
|
||||||
|
|
||||||
@@ -876,7 +791,7 @@ with a news entry for the website.
|
|||||||
Publish the news entry.
|
Publish the news entry.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Send an announcement to the mailing list.
|
Send announcement to the mailing list.
|
||||||
@end enumerate
|
@end enumerate
|
||||||
|
|
||||||
@bye
|
@bye
|
||||||
|
|||||||
@@ -1,24 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
OUT_DIR="${1}"
|
SRC_PATH="${1}"
|
||||||
SRC_DIR="${2}"
|
DOXYFILE="${2}"
|
||||||
DOXYFILE="${3}"
|
DOXYGEN="${3}"
|
||||||
DOXYGEN="${4}"
|
|
||||||
|
|
||||||
shift 4
|
shift 3
|
||||||
|
|
||||||
cd ${SRC_DIR}
|
|
||||||
|
|
||||||
if [ -e "VERSION" ]; then
|
|
||||||
VERSION=`cat "VERSION"`
|
|
||||||
else
|
|
||||||
VERSION=`git describe`
|
|
||||||
fi
|
|
||||||
|
|
||||||
$DOXYGEN - <<EOF
|
$DOXYGEN - <<EOF
|
||||||
@INCLUDE = ${DOXYFILE}
|
@INCLUDE = ${DOXYFILE}
|
||||||
INPUT = $@
|
INPUT = $@
|
||||||
HTML_TIMESTAMP = NO
|
EXAMPLE_PATH = ${SRC_PATH}/doc/examples
|
||||||
PROJECT_NUMBER = $VERSION
|
|
||||||
OUTPUT_DIRECTORY = $OUT_DIR
|
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
1
doc/doxy/.gitignore
vendored
1
doc/doxy/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/html/
|
|
||||||
2573
doc/encoders.texi
2573
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
|
||||||
|
|||||||
24
doc/examples/.gitignore
vendored
24
doc/examples/.gitignore
vendored
@@ -1,24 +0,0 @@
|
|||||||
/avio_list_dir
|
|
||||||
/avio_reading
|
|
||||||
/decode_audio
|
|
||||||
/decode_video
|
|
||||||
/demuxing_decoding
|
|
||||||
/encode_audio
|
|
||||||
/encode_video
|
|
||||||
/extract_mvs
|
|
||||||
/filter_audio
|
|
||||||
/filtering_audio
|
|
||||||
/filtering_video
|
|
||||||
/http_multiclient
|
|
||||||
/hw_decode
|
|
||||||
/metadata
|
|
||||||
/muxing
|
|
||||||
/pc-uninstalled
|
|
||||||
/qsvdec
|
|
||||||
/remuxing
|
|
||||||
/resampling_audio
|
|
||||||
/scaling_video
|
|
||||||
/transcode_aac
|
|
||||||
/transcoding
|
|
||||||
/vaapi_encode
|
|
||||||
/vaapi_transcode
|
|
||||||
@@ -1,64 +1,42 @@
|
|||||||
EXAMPLES-$(CONFIG_AVIO_LIST_DIR_EXAMPLE) += avio_list_dir
|
# use pkg-config for getting CFLAGS and LDLIBS
|
||||||
EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
|
FFMPEG_LIBS= libavdevice \
|
||||||
EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
|
libavformat \
|
||||||
EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
|
libavfilter \
|
||||||
EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
|
libavcodec \
|
||||||
EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
|
libswresample \
|
||||||
EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
|
libswscale \
|
||||||
EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
|
libavutil \
|
||||||
EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
|
|
||||||
EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
|
|
||||||
EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
|
|
||||||
EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient
|
|
||||||
EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += hw_decode
|
|
||||||
EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
|
|
||||||
EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
|
|
||||||
EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
|
|
||||||
EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing
|
|
||||||
EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
|
|
||||||
EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
|
|
||||||
EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
|
|
||||||
EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
|
|
||||||
EXAMPLES-$(CONFIG_VAAPI_ENCODE_EXAMPLE) += vaapi_encode
|
|
||||||
EXAMPLES-$(CONFIG_VAAPI_TRANSCODE_EXAMPLE) += vaapi_transcode
|
|
||||||
|
|
||||||
EXAMPLES := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
|
CFLAGS += -Wall -g
|
||||||
EXAMPLES_G := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
|
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
|
||||||
ALL_EXAMPLES := $(EXAMPLES) $(EXAMPLES-:%=doc/examples/%$(PROGSSUF)$(EXESUF))
|
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
|
||||||
ALL_EXAMPLES_G := $(EXAMPLES_G) $(EXAMPLES-:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
|
|
||||||
PROGS += $(EXAMPLES)
|
|
||||||
|
|
||||||
EXAMPLE_MAKEFILE := $(SRC_PATH)/doc/examples/Makefile
|
EXAMPLES= avio_reading \
|
||||||
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/README $(EXAMPLE_MAKEFILE)
|
decoding_encoding \
|
||||||
|
demuxing_decoding \
|
||||||
|
filtering_video \
|
||||||
|
filtering_audio \
|
||||||
|
metadata \
|
||||||
|
muxing \
|
||||||
|
remuxing \
|
||||||
|
resampling_audio \
|
||||||
|
scaling_video \
|
||||||
|
transcode_aac \
|
||||||
|
transcoding \
|
||||||
|
|
||||||
$(foreach P,$(EXAMPLES),$(eval OBJS-$(P:%$(PROGSSUF)$(EXESUF)=%) = $(P:%$(PROGSSUF)$(EXESUF)=%).o))
|
OBJS=$(addsuffix .o,$(EXAMPLES))
|
||||||
$(EXAMPLES_G): %$(PROGSSUF)_g$(EXESUF): %.o
|
|
||||||
|
|
||||||
examples: $(EXAMPLES)
|
# the following examples make explicit use of the math library
|
||||||
|
avcodec: LDLIBS += -lm
|
||||||
|
muxing: LDLIBS += -lm
|
||||||
|
resampling_audio: LDLIBS += -lm
|
||||||
|
|
||||||
$(EXAMPLES:%$(PROGSSUF)$(EXESUF)=%.o): | doc/examples
|
.phony: all clean-test clean
|
||||||
OUTDIRS += doc/examples
|
|
||||||
|
|
||||||
DOXY_INPUT += $(EXAMPLES:%$(PROGSSUF)$(EXESUF)=%.c)
|
all: $(OBJS) $(EXAMPLES)
|
||||||
|
|
||||||
install: install-examples
|
clean-test:
|
||||||
|
$(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg
|
||||||
|
|
||||||
install-examples: $(EXAMPLES_FILES)
|
clean: clean-test
|
||||||
$(Q)mkdir -p "$(DATADIR)/examples"
|
$(RM) $(EXAMPLES) $(OBJS)
|
||||||
$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
|
|
||||||
$(INSTALL) -m 644 $(EXAMPLE_MAKEFILE:%=%.example) "$(DATADIR)/examples/Makefile"
|
|
||||||
|
|
||||||
uninstall: uninstall-examples
|
|
||||||
|
|
||||||
uninstall-examples:
|
|
||||||
$(RM) -r "$(DATADIR)/examples"
|
|
||||||
|
|
||||||
examplesclean:
|
|
||||||
$(RM) $(ALL_EXAMPLES) $(ALL_EXAMPLES_G)
|
|
||||||
$(RM) $(CLEANSUFFIXES:%=doc/examples/%)
|
|
||||||
|
|
||||||
docclean:: examplesclean
|
|
||||||
|
|
||||||
-include $(wildcard $(EXAMPLES:%$(PROGSSUF)$(EXESUF)=%.d))
|
|
||||||
|
|
||||||
.PHONY: examples
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
# use pkg-config for getting CFLAGS and LDLIBS
|
|
||||||
FFMPEG_LIBS= libavdevice \
|
|
||||||
libavformat \
|
|
||||||
libavfilter \
|
|
||||||
libavcodec \
|
|
||||||
libswresample \
|
|
||||||
libswscale \
|
|
||||||
libavutil \
|
|
||||||
|
|
||||||
CFLAGS += -Wall -g
|
|
||||||
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
|
|
||||||
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
|
|
||||||
|
|
||||||
EXAMPLES= avio_list_dir \
|
|
||||||
avio_reading \
|
|
||||||
decode_audio \
|
|
||||||
decode_video \
|
|
||||||
demuxing_decoding \
|
|
||||||
encode_audio \
|
|
||||||
encode_video \
|
|
||||||
extract_mvs \
|
|
||||||
filtering_video \
|
|
||||||
filtering_audio \
|
|
||||||
http_multiclient \
|
|
||||||
hw_decode \
|
|
||||||
metadata \
|
|
||||||
muxing \
|
|
||||||
remuxing \
|
|
||||||
resampling_audio \
|
|
||||||
scaling_video \
|
|
||||||
transcode_aac \
|
|
||||||
transcoding \
|
|
||||||
|
|
||||||
OBJS=$(addsuffix .o,$(EXAMPLES))
|
|
||||||
|
|
||||||
# the following examples make explicit use of the math library
|
|
||||||
avcodec: LDLIBS += -lm
|
|
||||||
encode_audio: LDLIBS += -lm
|
|
||||||
muxing: LDLIBS += -lm
|
|
||||||
resampling_audio: LDLIBS += -lm
|
|
||||||
|
|
||||||
.phony: all clean-test clean
|
|
||||||
|
|
||||||
all: $(OBJS) $(EXAMPLES)
|
|
||||||
|
|
||||||
clean-test:
|
|
||||||
$(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg
|
|
||||||
|
|
||||||
clean: clean-test
|
|
||||||
$(RM) $(EXAMPLES) $(OBJS)
|
|
||||||
@@ -1,130 +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 void usage(const char *program_name)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "usage: %s input_dir\n"
|
|
||||||
"API example program to show how to list files in directory "
|
|
||||||
"accessed through AVIOContext.\n", program_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
av_log_set_level(AV_LOG_DEBUG);
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
usage(argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
avformat_network_init();
|
|
||||||
|
|
||||||
ret = list_op(argv[1]);
|
|
||||||
|
|
||||||
avformat_network_deinit();
|
|
||||||
|
|
||||||
return ret < 0 ? 1 : 0;
|
|
||||||
}
|
|
||||||
@@ -44,8 +44,6 @@ static int read_packet(void *opaque, uint8_t *buf, int buf_size)
|
|||||||
struct buffer_data *bd = (struct buffer_data *)opaque;
|
struct buffer_data *bd = (struct buffer_data *)opaque;
|
||||||
buf_size = FFMIN(buf_size, bd->size);
|
buf_size = FFMIN(buf_size, bd->size);
|
||||||
|
|
||||||
if (!buf_size)
|
|
||||||
return AVERROR_EOF;
|
|
||||||
printf("ptr:%p size:%zu\n", bd->ptr, bd->size);
|
printf("ptr:%p size:%zu\n", bd->ptr, bd->size);
|
||||||
|
|
||||||
/* copy internal buffer data to buf */
|
/* copy internal buffer data to buf */
|
||||||
@@ -74,6 +72,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
input_filename = argv[1];
|
input_filename = argv[1];
|
||||||
|
|
||||||
|
/* register codecs and formats and other lavf/lavc components*/
|
||||||
|
av_register_all();
|
||||||
|
|
||||||
/* slurp file content into buffer */
|
/* slurp file content into buffer */
|
||||||
ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
|
ret = av_file_map(input_filename, &buffer, &buffer_size, 0, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -117,12 +118,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
|
|
||||||
/* note: the internal buffer could have changed, and be != avio_ctx_buffer */
|
/* note: the internal buffer could have changed, and be != avio_ctx_buffer */
|
||||||
if (avio_ctx)
|
if (avio_ctx) {
|
||||||
av_freep(&avio_ctx->buffer);
|
av_freep(&avio_ctx->buffer);
|
||||||
avio_context_free(&avio_ctx);
|
av_freep(&avio_ctx);
|
||||||
|
}
|
||||||
av_file_unmap(buffer, buffer_size);
|
av_file_unmap(buffer, buffer_size);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|||||||
@@ -1,236 +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
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame,
|
|
||||||
FILE *outfile)
|
|
||||||
{
|
|
||||||
int i, ch;
|
|
||||||
int ret, data_size;
|
|
||||||
|
|
||||||
/* send the packet with the compressed data to the decoder */
|
|
||||||
ret = avcodec_send_packet(dec_ctx, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error submitting the packet to the decoder\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* read all the output frames (in general there may be any number of them */
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
return;
|
|
||||||
else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
data_size = av_get_bytes_per_sample(dec_ctx->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 < frame->nb_samples; i++)
|
|
||||||
for (ch = 0; ch < dec_ctx->ch_layout.nb_channels; ch++)
|
|
||||||
fwrite(frame->data[ch] + data_size*i, 1, data_size, outfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *outfilename, *filename;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
AVCodecParserContext *parser = NULL;
|
|
||||||
int len, ret;
|
|
||||||
FILE *f, *outfile;
|
|
||||||
uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
|
||||||
uint8_t *data;
|
|
||||||
size_t data_size;
|
|
||||||
AVPacket *pkt;
|
|
||||||
AVFrame *decoded_frame = NULL;
|
|
||||||
enum AVSampleFormat sfmt;
|
|
||||||
int n_channels = 0;
|
|
||||||
const char *fmt;
|
|
||||||
|
|
||||||
if (argc <= 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
filename = argv[1];
|
|
||||||
outfilename = argv[2];
|
|
||||||
|
|
||||||
pkt = av_packet_alloc();
|
|
||||||
|
|
||||||
/* find the MPEG audio decoder */
|
|
||||||
codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
|
|
||||||
if (!codec) {
|
|
||||||
fprintf(stderr, "Codec not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser = av_parser_init(codec->id);
|
|
||||||
if (!parser) {
|
|
||||||
fprintf(stderr, "Parser 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 */
|
|
||||||
data = inbuf;
|
|
||||||
data_size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
|
|
||||||
|
|
||||||
while (data_size > 0) {
|
|
||||||
if (!decoded_frame) {
|
|
||||||
if (!(decoded_frame = av_frame_alloc())) {
|
|
||||||
fprintf(stderr, "Could not allocate audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size,
|
|
||||||
data, data_size,
|
|
||||||
AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while parsing\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
data += ret;
|
|
||||||
data_size -= ret;
|
|
||||||
|
|
||||||
if (pkt->size)
|
|
||||||
decode(c, pkt, decoded_frame, outfile);
|
|
||||||
|
|
||||||
if (data_size < AUDIO_REFILL_THRESH) {
|
|
||||||
memmove(inbuf, data, data_size);
|
|
||||||
data = inbuf;
|
|
||||||
len = fread(data + data_size, 1,
|
|
||||||
AUDIO_INBUF_SIZE - data_size, f);
|
|
||||||
if (len > 0)
|
|
||||||
data_size += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush the decoder */
|
|
||||||
pkt->data = NULL;
|
|
||||||
pkt->size = 0;
|
|
||||||
decode(c, pkt, decoded_frame, outfile);
|
|
||||||
|
|
||||||
/* print output pcm infomations, because there have no metadata of pcm */
|
|
||||||
sfmt = c->sample_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 = c->ch_layout.nb_channels;
|
|
||||||
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, c->sample_rate,
|
|
||||||
outfilename);
|
|
||||||
end:
|
|
||||||
fclose(outfile);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
av_parser_close(parser);
|
|
||||||
av_frame_free(&decoded_frame);
|
|
||||||
av_packet_free(&pkt);
|
|
||||||
|
|
||||||
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 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,"wb");
|
|
||||||
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 void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,
|
|
||||||
const char *filename)
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = avcodec_send_packet(dec_ctx, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error sending a packet for decoding\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
return;
|
|
||||||
else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("saving frame %3d\n", dec_ctx->frame_number);
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
/* the picture is allocated by the decoder. no need to
|
|
||||||
free it */
|
|
||||||
snprintf(buf, sizeof(buf), "%s-%d", filename, dec_ctx->frame_number);
|
|
||||||
pgm_save(frame->data[0], frame->linesize[0],
|
|
||||||
frame->width, frame->height, buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *filename, *outfilename;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecParserContext *parser;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
FILE *f;
|
|
||||||
AVFrame *frame;
|
|
||||||
uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
|
||||||
uint8_t *data;
|
|
||||||
size_t data_size;
|
|
||||||
int ret;
|
|
||||||
int eof;
|
|
||||||
AVPacket *pkt;
|
|
||||||
|
|
||||||
if (argc <= 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <input file> <output file>\n"
|
|
||||||
"And check your input file is encoded by mpeg1video please.\n", argv[0]);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
filename = argv[1];
|
|
||||||
outfilename = argv[2];
|
|
||||||
|
|
||||||
pkt = av_packet_alloc();
|
|
||||||
if (!pkt)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser = av_parser_init(codec->id);
|
|
||||||
if (!parser) {
|
|
||||||
fprintf(stderr, "parser not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = avcodec_alloc_context3(codec);
|
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not allocate video codec context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
/* read raw data from the input file */
|
|
||||||
data_size = fread(inbuf, 1, INBUF_SIZE, f);
|
|
||||||
if (ferror(f))
|
|
||||||
break;
|
|
||||||
eof = !data_size;
|
|
||||||
|
|
||||||
/* use the parser to split the data into frames */
|
|
||||||
data = inbuf;
|
|
||||||
while (data_size > 0 || eof) {
|
|
||||||
ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size,
|
|
||||||
data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while parsing\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
data += ret;
|
|
||||||
data_size -= ret;
|
|
||||||
|
|
||||||
if (pkt->size)
|
|
||||||
decode(c, frame, pkt, outfilename);
|
|
||||||
else if (eof)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (!eof);
|
|
||||||
|
|
||||||
/* flush the decoder */
|
|
||||||
decode(c, frame, NULL, outfilename);
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
av_parser_close(parser);
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_packet_free(&pkt);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
664
doc/examples/decoding_encoding.c
Normal file
664
doc/examples/decoding_encoding.c
Normal file
@@ -0,0 +1,664 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @example decoding_encoding.c
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 = 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;
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
if (buffer_size < 0) {
|
||||||
|
fprintf(stderr, "Could not get sample buffer size\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
av_frame_free(&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 = 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_samples_get_buffer_size(NULL, c->channels,
|
||||||
|
decoded_frame->nb_samples,
|
||||||
|
c->sample_fmt, 1);
|
||||||
|
if (data_size < 0) {
|
||||||
|
/* This should not occur, checking just for paranoia */
|
||||||
|
fprintf(stderr, "Failed to calculate data size\n");
|
||||||
|
exit(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);
|
||||||
|
av_frame_free(&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};
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
/* 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]);
|
||||||
|
av_frame_free(&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 = 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_close(c);
|
||||||
|
av_free(c);
|
||||||
|
av_frame_free(&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 chosen 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;
|
||||||
|
}
|
||||||
@@ -32,13 +32,10 @@
|
|||||||
#include <libavutil/imgutils.h>
|
#include <libavutil/imgutils.h>
|
||||||
#include <libavutil/samplefmt.h>
|
#include <libavutil/samplefmt.h>
|
||||||
#include <libavutil/timestamp.h>
|
#include <libavutil/timestamp.h>
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
|
|
||||||
static AVFormatContext *fmt_ctx = NULL;
|
static AVFormatContext *fmt_ctx = NULL;
|
||||||
static AVCodecContext *video_dec_ctx = NULL, *audio_dec_ctx;
|
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 AVStream *video_stream = NULL, *audio_stream = NULL;
|
||||||
static const char *src_filename = NULL;
|
static const char *src_filename = NULL;
|
||||||
static const char *video_dst_filename = NULL;
|
static const char *video_dst_filename = NULL;
|
||||||
@@ -52,105 +49,100 @@ static int video_dst_bufsize;
|
|||||||
|
|
||||||
static int video_stream_idx = -1, audio_stream_idx = -1;
|
static int video_stream_idx = -1, audio_stream_idx = -1;
|
||||||
static AVFrame *frame = NULL;
|
static AVFrame *frame = NULL;
|
||||||
static AVPacket *pkt = NULL;
|
static AVPacket pkt;
|
||||||
static int video_frame_count = 0;
|
static int video_frame_count = 0;
|
||||||
static int audio_frame_count = 0;
|
static int audio_frame_count = 0;
|
||||||
|
|
||||||
static int output_video_frame(AVFrame *frame)
|
/* The different ways of decoding and managing data memory. You are not
|
||||||
{
|
* supposed to support all the modes in your application but pick the one most
|
||||||
if (frame->width != width || frame->height != height ||
|
* appropriate to your needs. Look for the use of api_mode in this example to
|
||||||
frame->format != pix_fmt) {
|
* see what are the differences of API usage between them */
|
||||||
/* To handle this change, one could call av_image_alloc again and
|
enum {
|
||||||
* decode the following frames into another rawvideo file. */
|
API_MODE_OLD = 0, /* old method, deprecated */
|
||||||
fprintf(stderr, "Error: Width, height and pixel format have to be "
|
API_MODE_NEW_API_REF_COUNT = 1, /* new method, using the frame reference counting */
|
||||||
"constant in a rawvideo file, but the width, height or "
|
API_MODE_NEW_API_NO_REF_COUNT = 2, /* new method, without reference counting */
|
||||||
"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 n:%d coded_n:%d\n",
|
static int api_mode = API_MODE_OLD;
|
||||||
video_frame_count++, frame->coded_picture_number);
|
|
||||||
|
|
||||||
/* copy decoded frame to destination buffer:
|
static int decode_packet(int *got_frame, int cached)
|
||||||
* 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);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int output_audio_frame(AVFrame *frame)
|
|
||||||
{
|
|
||||||
size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample(frame->format);
|
|
||||||
printf("audio_frame n:%d nb_samples:%d pts:%s\n",
|
|
||||||
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);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int decode_packet(AVCodecContext *dec, const AVPacket *pkt)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int decoded = pkt.size;
|
||||||
|
|
||||||
// submit the packet to the decoder
|
*got_frame = 0;
|
||||||
ret = avcodec_send_packet(dec, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error submitting a packet for decoding (%s)\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get all the available frames from the decoder
|
if (pkt.stream_index == video_stream_idx) {
|
||||||
while (ret >= 0) {
|
/* decode video frame */
|
||||||
ret = avcodec_receive_frame(dec, frame);
|
ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
// those two return values are special and mean there is no output
|
fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
|
||||||
// frame available, but there were no errors during decoding
|
|
||||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
fprintf(stderr, "Error during decoding (%s)\n", av_err2str(ret));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the frame data to output file
|
if (*got_frame) {
|
||||||
if (dec->codec->type == AVMEDIA_TYPE_VIDEO)
|
printf("video_frame%s n:%d coded_n:%d pts:%s\n",
|
||||||
ret = output_video_frame(frame);
|
cached ? "(cached)" : "",
|
||||||
else
|
video_frame_count++, frame->coded_picture_number,
|
||||||
ret = output_audio_frame(frame);
|
av_ts2timestr(frame->pts, &video_dec_ctx->time_base));
|
||||||
|
|
||||||
av_frame_unref(frame);
|
/* copy decoded frame to destination buffer:
|
||||||
if (ret < 0)
|
* 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 (%s)\n", av_err2str(ret));
|
||||||
return 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
/* If we use the new API with reference counting, we own the data and need
|
||||||
|
* to de-reference it when we don't use it anymore */
|
||||||
|
if (*got_frame && api_mode == API_MODE_NEW_API_REF_COUNT)
|
||||||
|
av_frame_unref(frame);
|
||||||
|
|
||||||
|
return decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int open_codec_context(int *stream_idx,
|
static int open_codec_context(int *stream_idx,
|
||||||
AVCodecContext **dec_ctx, AVFormatContext *fmt_ctx, enum AVMediaType type)
|
AVFormatContext *fmt_ctx, enum AVMediaType type)
|
||||||
{
|
{
|
||||||
int ret, stream_index;
|
int ret;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
const AVCodec *dec = NULL;
|
AVCodecContext *dec_ctx = NULL;
|
||||||
|
AVCodec *dec = NULL;
|
||||||
|
AVDictionary *opts = NULL;
|
||||||
|
|
||||||
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
|
ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -158,39 +150,26 @@ static int open_codec_context(int *stream_idx,
|
|||||||
av_get_media_type_string(type), src_filename);
|
av_get_media_type_string(type), src_filename);
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
stream_index = ret;
|
*stream_idx = ret;
|
||||||
st = fmt_ctx->streams[stream_index];
|
st = fmt_ctx->streams[*stream_idx];
|
||||||
|
|
||||||
/* find decoder for the stream */
|
/* find decoder for the stream */
|
||||||
dec = avcodec_find_decoder(st->codecpar->codec_id);
|
dec_ctx = st->codec;
|
||||||
|
dec = avcodec_find_decoder(dec_ctx->codec_id);
|
||||||
if (!dec) {
|
if (!dec) {
|
||||||
fprintf(stderr, "Failed to find %s codec\n",
|
fprintf(stderr, "Failed to find %s codec\n",
|
||||||
av_get_media_type_string(type));
|
av_get_media_type_string(type));
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a codec context for the decoder */
|
/* Init the decoders, with or without reference counting */
|
||||||
*dec_ctx = avcodec_alloc_context3(dec);
|
if (api_mode == API_MODE_NEW_API_REF_COUNT)
|
||||||
if (!*dec_ctx) {
|
av_dict_set(&opts, "refcounted_frames", "1", 0);
|
||||||
fprintf(stderr, "Failed to allocate the %s codec context\n",
|
if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) {
|
||||||
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 */
|
|
||||||
if ((ret = avcodec_open2(*dec_ctx, dec, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to open %s codec\n",
|
fprintf(stderr, "Failed to open %s codec\n",
|
||||||
av_get_media_type_string(type));
|
av_get_media_type_string(type));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
*stream_idx = stream_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -227,21 +206,40 @@ static int get_format_from_sample_fmt(const char **fmt,
|
|||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0, got_frame;
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4 && argc != 5) {
|
||||||
fprintf(stderr, "usage: %s input_file video_output_file audio_output_file\n"
|
fprintf(stderr, "usage: %s [-refcount=<old|new_norefcount|new_refcount>] "
|
||||||
|
"input_file video_output_file audio_output_file\n"
|
||||||
"API example program to show how to read frames from an input 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"
|
"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"
|
"video frames to a rawvideo file named video_output_file, and decoded\n"
|
||||||
"audio frames to a rawaudio file named audio_output_file.\n",
|
"audio frames to a rawaudio file named audio_output_file.\n\n"
|
||||||
argv[0]);
|
"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. If unset, it's using\n"
|
||||||
|
"the classic old method.\n"
|
||||||
|
"\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
if (argc == 5) {
|
||||||
|
const char *mode = argv[1] + strlen("-refcount=");
|
||||||
|
if (!strcmp(mode, "old")) api_mode = API_MODE_OLD;
|
||||||
|
else if (!strcmp(mode, "new_norefcount")) api_mode = API_MODE_NEW_API_NO_REF_COUNT;
|
||||||
|
else if (!strcmp(mode, "new_refcount")) api_mode = API_MODE_NEW_API_REF_COUNT;
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "unknow mode '%s'\n", mode);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
src_filename = argv[1];
|
src_filename = argv[1];
|
||||||
video_dst_filename = argv[2];
|
video_dst_filename = argv[2];
|
||||||
audio_dst_filename = argv[3];
|
audio_dst_filename = argv[3];
|
||||||
|
|
||||||
|
/* register all formats and codecs */
|
||||||
|
av_register_all();
|
||||||
|
|
||||||
/* open input file, and allocate format context */
|
/* open input file, and allocate format context */
|
||||||
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
||||||
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
fprintf(stderr, "Could not open source file %s\n", src_filename);
|
||||||
@@ -254,8 +252,9 @@ int main (int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open_codec_context(&video_stream_idx, &video_dec_ctx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
|
if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
|
||||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||||
|
video_dec_ctx = video_stream->codec;
|
||||||
|
|
||||||
video_dst_file = fopen(video_dst_filename, "wb");
|
video_dst_file = fopen(video_dst_filename, "wb");
|
||||||
if (!video_dst_file) {
|
if (!video_dst_file) {
|
||||||
@@ -265,11 +264,9 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate image where the decoded image will be put */
|
/* 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,
|
ret = av_image_alloc(video_dst_data, video_dst_linesize,
|
||||||
width, height, pix_fmt, 1);
|
video_dec_ctx->width, video_dec_ctx->height,
|
||||||
|
video_dec_ctx->pix_fmt, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not allocate raw video buffer\n");
|
fprintf(stderr, "Could not allocate raw video buffer\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -277,8 +274,9 @@ int main (int argc, char **argv)
|
|||||||
video_dst_bufsize = ret;
|
video_dst_bufsize = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open_codec_context(&audio_stream_idx, &audio_dec_ctx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
|
if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) {
|
||||||
audio_stream = fmt_ctx->streams[audio_stream_idx];
|
audio_stream = fmt_ctx->streams[audio_stream_idx];
|
||||||
|
audio_dec_ctx = audio_stream->codec;
|
||||||
audio_dst_file = fopen(audio_dst_filename, "wb");
|
audio_dst_file = fopen(audio_dst_filename, "wb");
|
||||||
if (!audio_dst_file) {
|
if (!audio_dst_file) {
|
||||||
fprintf(stderr, "Could not open destination file %s\n", audio_dst_filename);
|
fprintf(stderr, "Could not open destination file %s\n", audio_dst_filename);
|
||||||
@@ -296,19 +294,22 @@ int main (int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
/* When using the new API, you need to use the libavutil/frame.h API, while
|
||||||
|
* the classic frame management is available in libavcodec */
|
||||||
|
if (api_mode == API_MODE_OLD)
|
||||||
|
frame = avcodec_alloc_frame();
|
||||||
|
else
|
||||||
|
frame = av_frame_alloc();
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
fprintf(stderr, "Could not allocate frame\n");
|
fprintf(stderr, "Could not allocate frame\n");
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt = av_packet_alloc();
|
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||||
if (!pkt) {
|
av_init_packet(&pkt);
|
||||||
fprintf(stderr, "Could not allocate packet\n");
|
pkt.data = NULL;
|
||||||
ret = AVERROR(ENOMEM);
|
pkt.size = 0;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (video_stream)
|
if (video_stream)
|
||||||
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
|
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
|
||||||
@@ -316,36 +317,37 @@ int main (int argc, char **argv)
|
|||||||
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
|
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);
|
||||||
|
|
||||||
/* read frames from the file */
|
/* read frames from the file */
|
||||||
while (av_read_frame(fmt_ctx, pkt) >= 0) {
|
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
|
||||||
// check if the packet belongs to a stream we are interested in, otherwise
|
AVPacket orig_pkt = pkt;
|
||||||
// skip it
|
do {
|
||||||
if (pkt->stream_index == video_stream_idx)
|
ret = decode_packet(&got_frame, 0);
|
||||||
ret = decode_packet(video_dec_ctx, pkt);
|
if (ret < 0)
|
||||||
else if (pkt->stream_index == audio_stream_idx)
|
break;
|
||||||
ret = decode_packet(audio_dec_ctx, pkt);
|
pkt.data += ret;
|
||||||
av_packet_unref(pkt);
|
pkt.size -= ret;
|
||||||
if (ret < 0)
|
} while (pkt.size > 0);
|
||||||
break;
|
av_free_packet(&orig_pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush the decoders */
|
/* flush cached frames */
|
||||||
if (video_dec_ctx)
|
pkt.data = NULL;
|
||||||
decode_packet(video_dec_ctx, NULL);
|
pkt.size = 0;
|
||||||
if (audio_dec_ctx)
|
do {
|
||||||
decode_packet(audio_dec_ctx, NULL);
|
decode_packet(&got_frame, 1);
|
||||||
|
} while (got_frame);
|
||||||
|
|
||||||
printf("Demuxing succeeded.\n");
|
printf("Demuxing succeeded.\n");
|
||||||
|
|
||||||
if (video_stream) {
|
if (video_stream) {
|
||||||
printf("Play the output video file with the command:\n"
|
printf("Play the output video file with the command:\n"
|
||||||
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
|
"ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n",
|
||||||
av_get_pix_fmt_name(pix_fmt), width, height,
|
av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height,
|
||||||
video_dst_filename);
|
video_dst_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio_stream) {
|
if (audio_stream) {
|
||||||
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
|
enum AVSampleFormat sfmt = audio_dec_ctx->sample_fmt;
|
||||||
int n_channels = audio_dec_ctx->ch_layout.nb_channels;
|
int n_channels = audio_dec_ctx->channels;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
|
|
||||||
if (av_sample_fmt_is_planar(sfmt)) {
|
if (av_sample_fmt_is_planar(sfmt)) {
|
||||||
@@ -367,15 +369,17 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
avcodec_free_context(&video_dec_ctx);
|
avcodec_close(video_dec_ctx);
|
||||||
avcodec_free_context(&audio_dec_ctx);
|
avcodec_close(audio_dec_ctx);
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
if (video_dst_file)
|
if (video_dst_file)
|
||||||
fclose(video_dst_file);
|
fclose(video_dst_file);
|
||||||
if (audio_dst_file)
|
if (audio_dst_file)
|
||||||
fclose(audio_dst_file);
|
fclose(audio_dst_file);
|
||||||
av_packet_free(&pkt);
|
if (api_mode == API_MODE_OLD)
|
||||||
av_frame_free(&frame);
|
avcodec_free_frame(&frame);
|
||||||
|
else
|
||||||
|
av_frame_free(&frame);
|
||||||
av_free(video_dst_data[0]);
|
av_free(video_dst_data[0]);
|
||||||
|
|
||||||
return ret < 0;
|
return ret < 0;
|
||||||
|
|||||||
@@ -1,240 +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, AVChannelLayout *dst)
|
|
||||||
{
|
|
||||||
const AVChannelLayout *p, *best_ch_layout;
|
|
||||||
int best_nb_channels = 0;
|
|
||||||
|
|
||||||
if (!codec->ch_layouts)
|
|
||||||
return av_channel_layout_copy(dst, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
|
|
||||||
|
|
||||||
p = codec->ch_layouts;
|
|
||||||
while (p->nb_channels) {
|
|
||||||
int nb_channels = p->nb_channels;
|
|
||||||
|
|
||||||
if (nb_channels > best_nb_channels) {
|
|
||||||
best_ch_layout = p;
|
|
||||||
best_nb_channels = nb_channels;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
return av_channel_layout_copy(dst, best_ch_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt,
|
|
||||||
FILE *output)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* send the frame for encoding */
|
|
||||||
ret = avcodec_send_frame(ctx, frame);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error sending the frame to the encoder\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* read all the available output packets (in general there may be any
|
|
||||||
* number of them */
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_packet(ctx, pkt);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
return;
|
|
||||||
else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fwrite(pkt->data, 1, pkt->size, output);
|
|
||||||
av_packet_unref(pkt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *filename;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
AVFrame *frame;
|
|
||||||
AVPacket *pkt;
|
|
||||||
int i, j, k, ret;
|
|
||||||
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];
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
ret = select_channel_layout(codec, &c->ch_layout);
|
|
||||||
if (ret < 0)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* packet for holding encoded output */
|
|
||||||
pkt = av_packet_alloc();
|
|
||||||
if (!pkt) {
|
|
||||||
fprintf(stderr, "could not allocate the packet\n");
|
|
||||||
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;
|
|
||||||
ret = av_channel_layout_copy(&frame->ch_layout, &c->ch_layout);
|
|
||||||
if (ret < 0)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
/* 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++) {
|
|
||||||
/* 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->ch_layout.nb_channels; k++)
|
|
||||||
samples[2*j + k] = samples[2*j];
|
|
||||||
t += tincr;
|
|
||||||
}
|
|
||||||
encode(c, frame, pkt, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush the encoder */
|
|
||||||
encode(c, NULL, pkt, f);
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_packet_free(&pkt);
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,216 +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>
|
|
||||||
|
|
||||||
static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,
|
|
||||||
FILE *outfile)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* send the frame to the encoder */
|
|
||||||
if (frame)
|
|
||||||
printf("Send frame %3"PRId64"\n", frame->pts);
|
|
||||||
|
|
||||||
ret = avcodec_send_frame(enc_ctx, frame);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error sending a frame for encoding\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_packet(enc_ctx, pkt);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
return;
|
|
||||||
else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during encoding\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);
|
|
||||||
fwrite(pkt->data, 1, pkt->size, outfile);
|
|
||||||
av_packet_unref(pkt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const char *filename, *codec_name;
|
|
||||||
const AVCodec *codec;
|
|
||||||
AVCodecContext *c= NULL;
|
|
||||||
int i, ret, x, y;
|
|
||||||
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];
|
|
||||||
|
|
||||||
/* find the mpeg1video encoder */
|
|
||||||
codec = avcodec_find_encoder_by_name(codec_name);
|
|
||||||
if (!codec) {
|
|
||||||
fprintf(stderr, "Codec '%s' not found\n", codec_name);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = avcodec_alloc_context3(codec);
|
|
||||||
if (!c) {
|
|
||||||
fprintf(stderr, "Could not allocate video codec context\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt = av_packet_alloc();
|
|
||||||
if (!pkt)
|
|
||||||
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 */
|
|
||||||
ret = avcodec_open2(c, codec, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));
|
|
||||||
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, 0);
|
|
||||||
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++) {
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
/* Make sure the frame data is writable.
|
|
||||||
On the first round, the frame is fresh from av_frame_get_buffer()
|
|
||||||
and therefore we know it is writable.
|
|
||||||
But on the next rounds, encode() will have called
|
|
||||||
avcodec_send_frame(), and the codec may have kept a reference to
|
|
||||||
the frame in its internal structures, that makes the frame
|
|
||||||
unwritable.
|
|
||||||
av_frame_make_writable() checks that and allocates a new buffer
|
|
||||||
for the frame only if necessary.
|
|
||||||
*/
|
|
||||||
ret = av_frame_make_writable(frame);
|
|
||||||
if (ret < 0)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
/* Prepare a dummy image.
|
|
||||||
In real code, this is where you would have your own logic for
|
|
||||||
filling the frame. FFmpeg does not care what you put in the
|
|
||||||
frame.
|
|
||||||
*/
|
|
||||||
/* 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 */
|
|
||||||
encode(c, frame, pkt, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush the encoder */
|
|
||||||
encode(c, NULL, pkt, f);
|
|
||||||
|
|
||||||
/* Add sequence end code to have a real MPEG file.
|
|
||||||
It makes only sense because this tiny examples writes packets
|
|
||||||
directly. This is called "elementary stream" and only works for some
|
|
||||||
codecs. To create a valid file, you usually need to write packets
|
|
||||||
into a proper file format or protocol; see muxing.c.
|
|
||||||
*/
|
|
||||||
if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)
|
|
||||||
fwrite(endcode, 1, sizeof(endcode), f);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
avcodec_free_context(&c);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_packet_free(&pkt);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,189 +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 <libavcodec/avcodec.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 int video_frame_count = 0;
|
|
||||||
|
|
||||||
static int decode_packet(const AVPacket *pkt)
|
|
||||||
{
|
|
||||||
int ret = avcodec_send_packet(video_dec_ctx, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_frame(video_dec_ctx, frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
|
||||||
break;
|
|
||||||
} else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while receiving a frame from the decoder: %s\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret >= 0) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
av_frame_unref(frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
AVStream *st;
|
|
||||||
AVCodecContext *dec_ctx = NULL;
|
|
||||||
const 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);
|
|
||||||
ret = avcodec_open2(dec_ctx, dec, &opts);
|
|
||||||
av_dict_free(&opts);
|
|
||||||
if (ret < 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;
|
|
||||||
AVPacket *pkt = NULL;
|
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <video>\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
src_filename = argv[1];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt = av_packet_alloc();
|
|
||||||
if (!pkt) {
|
|
||||||
fprintf(stderr, "Could not allocate AVPacket\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n");
|
|
||||||
|
|
||||||
/* read frames from the file */
|
|
||||||
while (av_read_frame(fmt_ctx, pkt) >= 0) {
|
|
||||||
if (pkt->stream_index == video_stream_idx)
|
|
||||||
ret = decode_packet(pkt);
|
|
||||||
av_packet_unref(pkt);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush cached frames */
|
|
||||||
decode_packet(NULL);
|
|
||||||
|
|
||||||
end:
|
|
||||||
avcodec_free_context(&video_dec_ctx);
|
|
||||||
avformat_close_input(&fmt_ctx);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_packet_free(&pkt);
|
|
||||||
return ret < 0;
|
|
||||||
}
|
|
||||||
@@ -45,7 +45,6 @@
|
|||||||
|
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/md5.h"
|
#include "libavutil/md5.h"
|
||||||
#include "libavutil/mem.h"
|
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/samplefmt.h"
|
#include "libavutil/samplefmt.h"
|
||||||
|
|
||||||
@@ -55,7 +54,7 @@
|
|||||||
|
|
||||||
#define INPUT_SAMPLERATE 48000
|
#define INPUT_SAMPLERATE 48000
|
||||||
#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
|
#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
|
||||||
#define INPUT_CHANNEL_LAYOUT (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0
|
#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
|
||||||
|
|
||||||
#define VOLUME_VAL 0.90
|
#define VOLUME_VAL 0.90
|
||||||
|
|
||||||
@@ -64,13 +63,13 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
|
|||||||
{
|
{
|
||||||
AVFilterGraph *filter_graph;
|
AVFilterGraph *filter_graph;
|
||||||
AVFilterContext *abuffer_ctx;
|
AVFilterContext *abuffer_ctx;
|
||||||
const AVFilter *abuffer;
|
AVFilter *abuffer;
|
||||||
AVFilterContext *volume_ctx;
|
AVFilterContext *volume_ctx;
|
||||||
const AVFilter *volume;
|
AVFilter *volume;
|
||||||
AVFilterContext *aformat_ctx;
|
AVFilterContext *aformat_ctx;
|
||||||
const AVFilter *aformat;
|
AVFilter *aformat;
|
||||||
AVFilterContext *abuffersink_ctx;
|
AVFilterContext *abuffersink_ctx;
|
||||||
const AVFilter *abuffersink;
|
AVFilter *abuffersink;
|
||||||
|
|
||||||
AVDictionary *options_dict = NULL;
|
AVDictionary *options_dict = NULL;
|
||||||
uint8_t options_str[1024];
|
uint8_t options_str[1024];
|
||||||
@@ -100,7 +99,7 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set the filter options through the AVOptions API. */
|
/* Set the filter options through the AVOptions API. */
|
||||||
av_channel_layout_describe(&INPUT_CHANNEL_LAYOUT, ch_layout, sizeof(ch_layout));
|
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, "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 (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_q (abuffer_ctx, "time_base", (AVRational){ 1, INPUT_SAMPLERATE }, AV_OPT_SEARCH_CHILDREN);
|
||||||
@@ -154,8 +153,9 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
|
|||||||
/* A third way of passing the options is in a string of the form
|
/* A third way of passing the options is in a string of the form
|
||||||
* key1=value1:key2=value2.... */
|
* key1=value1:key2=value2.... */
|
||||||
snprintf(options_str, sizeof(options_str),
|
snprintf(options_str, sizeof(options_str),
|
||||||
"sample_fmts=%s:sample_rates=%d:channel_layouts=stereo",
|
"sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
|
||||||
av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100);
|
av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100,
|
||||||
|
(uint64_t)AV_CH_LAYOUT_STEREO);
|
||||||
err = avfilter_init_str(aformat_ctx, options_str);
|
err = avfilter_init_str(aformat_ctx, options_str);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Could not initialize the aformat filter.\n");
|
av_log(NULL, AV_LOG_ERROR, "Could not initialize the aformat filter.\n");
|
||||||
@@ -214,7 +214,7 @@ static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
|
|||||||
static int process_output(struct AVMD5 *md5, AVFrame *frame)
|
static int process_output(struct AVMD5 *md5, AVFrame *frame)
|
||||||
{
|
{
|
||||||
int planar = av_sample_fmt_is_planar(frame->format);
|
int planar = av_sample_fmt_is_planar(frame->format);
|
||||||
int channels = frame->ch_layout.nb_channels;
|
int channels = av_get_channel_layout_nb_channels(frame->channel_layout);
|
||||||
int planes = planar ? channels : 1;
|
int planes = planar ? channels : 1;
|
||||||
int bps = av_get_bytes_per_sample(frame->format);
|
int bps = av_get_bytes_per_sample(frame->format);
|
||||||
int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
|
int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
|
||||||
@@ -247,7 +247,7 @@ static int get_input(AVFrame *frame, int frame_num)
|
|||||||
/* Set up the frame properties and allocate the buffer for the data. */
|
/* Set up the frame properties and allocate the buffer for the data. */
|
||||||
frame->sample_rate = INPUT_SAMPLERATE;
|
frame->sample_rate = INPUT_SAMPLERATE;
|
||||||
frame->format = INPUT_FORMAT;
|
frame->format = INPUT_FORMAT;
|
||||||
av_channel_layout_copy(&frame->ch_layout, &INPUT_CHANNEL_LAYOUT);
|
frame->channel_layout = INPUT_CHANNEL_LAYOUT;
|
||||||
frame->nb_samples = FRAME_SIZE;
|
frame->nb_samples = FRAME_SIZE;
|
||||||
frame->pts = frame_num * FRAME_SIZE;
|
frame->pts = frame_num * FRAME_SIZE;
|
||||||
|
|
||||||
@@ -288,6 +288,8 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avfilter_register_all();
|
||||||
|
|
||||||
/* Allocate the frame we will be using to store the data. */
|
/* Allocate the frame we will be using to store the data. */
|
||||||
frame = av_frame_alloc();
|
frame = av_frame_alloc();
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
|
|||||||
@@ -32,9 +32,10 @@
|
|||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.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/channel_layout.h>
|
|
||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
|
|
||||||
static const char *filter_descr = "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono";
|
static const char *filter_descr = "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono";
|
||||||
@@ -49,8 +50,8 @@ static int audio_stream_index = -1;
|
|||||||
|
|
||||||
static int open_input_file(const char *filename)
|
static int open_input_file(const char *filename)
|
||||||
{
|
{
|
||||||
const AVCodec *dec;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
AVCodec *dec;
|
||||||
|
|
||||||
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
|
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
||||||
@@ -65,16 +66,12 @@ 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 */
|
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
||||||
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);
|
|
||||||
|
|
||||||
/* 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,11 +86,12 @@ static int init_filters(const char *filters_descr)
|
|||||||
{
|
{
|
||||||
char args[512];
|
char args[512];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
|
AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
|
||||||
const AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
|
AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
|
||||||
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 };
|
static const enum AVSampleFormat out_sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
|
||||||
|
static const int64_t out_channel_layouts[] = { AV_CH_LAYOUT_MONO, -1 };
|
||||||
static const int out_sample_rates[] = { 8000, -1 };
|
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;
|
||||||
@@ -105,13 +103,12 @@ static int init_filters(const char *filters_descr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 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->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
|
if (!dec_ctx->channel_layout)
|
||||||
av_channel_layout_default(&dec_ctx->ch_layout, dec_ctx->ch_layout.nb_channels);
|
dec_ctx->channel_layout = av_get_default_channel_layout(dec_ctx->channels);
|
||||||
ret = snprintf(args, sizeof(args),
|
snprintf(args, sizeof(args),
|
||||||
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=",
|
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64,
|
||||||
time_base.num, time_base.den, dec_ctx->sample_rate,
|
time_base.num, time_base.den, dec_ctx->sample_rate,
|
||||||
av_get_sample_fmt_name(dec_ctx->sample_fmt));
|
av_get_sample_fmt_name(dec_ctx->sample_fmt), dec_ctx->channel_layout);
|
||||||
av_channel_layout_describe(&dec_ctx->ch_layout, args + ret, sizeof(args) - ret);
|
|
||||||
ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in",
|
ret = avfilter_graph_create_filter(&buffersrc_ctx, abuffersrc, "in",
|
||||||
args, NULL, filter_graph);
|
args, NULL, filter_graph);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -134,7 +131,7 @@ static int init_filters(const char *filters_descr)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = av_opt_set(buffersink_ctx, "ch_layouts", "mono",
|
ret = av_opt_set_int_list(buffersink_ctx, "channel_layouts", out_channel_layouts, -1,
|
||||||
AV_OPT_SEARCH_CHILDREN);
|
AV_OPT_SEARCH_CHILDREN);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
||||||
@@ -148,28 +145,12 @@ static int init_filters(const char *filters_descr)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Endpoints for the filter graph. */
|
||||||
* 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;
|
||||||
@@ -185,7 +166,7 @@ static int init_filters(const char *filters_descr)
|
|||||||
/* 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 */
|
||||||
outlink = buffersink_ctx->inputs[0];
|
outlink = buffersink_ctx->inputs[0];
|
||||||
av_channel_layout_describe(&outlink->ch_layout, args, sizeof(args));
|
av_get_channel_layout_string(args, sizeof(args), -1, outlink->channel_layout);
|
||||||
av_log(NULL, AV_LOG_INFO, "Output: srate:%dHz fmt:%s chlayout:%s\n",
|
av_log(NULL, AV_LOG_INFO, "Output: srate:%dHz fmt:%s chlayout:%s\n",
|
||||||
(int)outlink->sample_rate,
|
(int)outlink->sample_rate,
|
||||||
(char *)av_x_if_null(av_get_sample_fmt_name(outlink->format), "?"),
|
(char *)av_x_if_null(av_get_sample_fmt_name(outlink->format), "?"),
|
||||||
@@ -200,7 +181,7 @@ end:
|
|||||||
|
|
||||||
static void print_frame(const AVFrame *frame)
|
static void print_frame(const AVFrame *frame)
|
||||||
{
|
{
|
||||||
const int n = frame->nb_samples * frame->ch_layout.nb_channels;
|
const int n = frame->nb_samples * av_get_channel_layout_nb_channels(av_frame_get_channel_layout(frame));
|
||||||
const uint16_t *p = (uint16_t*)frame->data[0];
|
const uint16_t *p = (uint16_t*)frame->data[0];
|
||||||
const uint16_t *p_end = p + n;
|
const uint16_t *p_end = p + n;
|
||||||
|
|
||||||
@@ -215,12 +196,13 @@ static void print_frame(const AVFrame *frame)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket *packet = av_packet_alloc();
|
AVPacket packet0, packet;
|
||||||
AVFrame *frame = av_frame_alloc();
|
AVFrame *frame = av_frame_alloc();
|
||||||
AVFrame *filt_frame = av_frame_alloc();
|
AVFrame *filt_frame = av_frame_alloc();
|
||||||
|
int got_frame;
|
||||||
|
|
||||||
if (!packet || !frame || !filt_frame) {
|
if (!frame || !filt_frame) {
|
||||||
fprintf(stderr, "Could not allocate frame or packet\n");
|
perror("Could not allocate frame");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
@@ -228,60 +210,64 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_register_all();
|
||||||
|
avfilter_register_all();
|
||||||
|
|
||||||
if ((ret = open_input_file(argv[1])) < 0)
|
if ((ret = open_input_file(argv[1])) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if ((ret = init_filters(filter_descr)) < 0)
|
if ((ret = init_filters(filter_descr)) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/* read all packets */
|
/* read all packets */
|
||||||
|
packet0.data = NULL;
|
||||||
|
packet.data = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((ret = av_read_frame(fmt_ctx, packet)) < 0)
|
if (!packet0.data) {
|
||||||
break;
|
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||||
|
|
||||||
if (packet->stream_index == audio_stream_index) {
|
|
||||||
ret = avcodec_send_packet(dec_ctx, packet);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
packet0 = packet;
|
||||||
|
}
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
if (packet.stream_index == audio_stream_index) {
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
got_frame = 0;
|
||||||
break;
|
ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, &packet);
|
||||||
} else if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
|
av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n");
|
||||||
goto end;
|
continue;
|
||||||
}
|
}
|
||||||
|
packet.size -= ret;
|
||||||
if (ret >= 0) {
|
packet.data += ret;
|
||||||
/* push the audio data from decoded frame into the filtergraph */
|
|
||||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
if (got_frame) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
|
/* push the audio data from decoded frame into the filtergraph */
|
||||||
break;
|
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, 0) < 0) {
|
||||||
}
|
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
|
||||||
|
break;
|
||||||
/* pull filtered audio from the filtergraph */
|
}
|
||||||
while (1) {
|
|
||||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
/* pull filtered audio from the filtergraph */
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
while (1) {
|
||||||
break;
|
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||||
if (ret < 0)
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||||
goto end;
|
break;
|
||||||
print_frame(filt_frame);
|
if (ret < 0)
|
||||||
av_frame_unref(filt_frame);
|
goto end;
|
||||||
}
|
print_frame(filt_frame);
|
||||||
av_frame_unref(frame);
|
av_frame_unref(filt_frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (packet.size <= 0)
|
||||||
|
av_free_packet(&packet0);
|
||||||
|
} else {
|
||||||
|
/* discard non-wanted packets */
|
||||||
|
av_free_packet(&packet0);
|
||||||
}
|
}
|
||||||
av_packet_unref(packet);
|
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
avfilter_graph_free(&filter_graph);
|
avfilter_graph_free(&filter_graph);
|
||||||
avcodec_free_context(&dec_ctx);
|
avcodec_close(dec_ctx);
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
av_packet_free(&packet);
|
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
av_frame_free(&filt_frame);
|
av_frame_free(&filt_frame);
|
||||||
|
|
||||||
|
|||||||
@@ -29,19 +29,16 @@
|
|||||||
|
|
||||||
#define _XOPEN_SOURCE 600 /* for usleep */
|
#define _XOPEN_SOURCE 600 /* for usleep */
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.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>
|
#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;
|
||||||
@@ -53,8 +50,8 @@ static int64_t last_pts = AV_NOPTS_VALUE;
|
|||||||
|
|
||||||
static int open_input_file(const char *filename)
|
static int open_input_file(const char *filename)
|
||||||
{
|
{
|
||||||
const AVCodec *dec;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
AVCodec *dec;
|
||||||
|
|
||||||
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
|
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
|
||||||
@@ -73,12 +70,8 @@ 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 */
|
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
||||||
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);
|
|
||||||
|
|
||||||
/* 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) {
|
||||||
@@ -93,11 +86,10 @@ static int init_filters(const char *filters_descr)
|
|||||||
{
|
{
|
||||||
char args[512];
|
char args[512];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const AVFilter *buffersrc = avfilter_get_by_name("buffer");
|
AVFilter *buffersrc = avfilter_get_by_name("buffer");
|
||||||
const AVFilter *buffersink = avfilter_get_by_name("buffersink");
|
AVFilter *buffersink = avfilter_get_by_name("buffersink");
|
||||||
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 };
|
||||||
|
|
||||||
filter_graph = avfilter_graph_alloc();
|
filter_graph = avfilter_graph_alloc();
|
||||||
@@ -110,7 +102,7 @@ static int init_filters(const char *filters_descr)
|
|||||||
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",
|
||||||
@@ -135,28 +127,12 @@ static int init_filters(const char *filters_descr)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Endpoints for the filter graph. */
|
||||||
* 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;
|
||||||
@@ -210,22 +186,22 @@ static void display_frame(const AVFrame *frame, AVRational time_base)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket *packet;
|
AVPacket packet;
|
||||||
AVFrame *frame;
|
AVFrame *frame = av_frame_alloc();
|
||||||
AVFrame *filt_frame;
|
AVFrame *filt_frame = av_frame_alloc();
|
||||||
|
int got_frame;
|
||||||
|
|
||||||
|
if (!frame || !filt_frame) {
|
||||||
|
perror("Could not allocate frame");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "Usage: %s file\n", argv[0]);
|
fprintf(stderr, "Usage: %s file\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
av_register_all();
|
||||||
filt_frame = av_frame_alloc();
|
avfilter_register_all();
|
||||||
packet = av_packet_alloc();
|
|
||||||
if (!frame || !filt_frame || !packet) {
|
|
||||||
fprintf(stderr, "Could not allocate frame or packet\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = open_input_file(argv[1])) < 0)
|
if ((ret = open_input_file(argv[1])) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
@@ -234,26 +210,19 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* read all packets */
|
/* read all packets */
|
||||||
while (1) {
|
while (1) {
|
||||||
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);
|
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) {
|
|
||||||
break;
|
|
||||||
} else if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->pts = frame->best_effort_timestamp;
|
|
||||||
|
|
||||||
/* push the decoded frame into the filtergraph */
|
/* push the decoded frame into the filtergraph */
|
||||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
||||||
@@ -274,15 +243,14 @@ int main(int argc, char **argv)
|
|||||||
av_frame_unref(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);
|
avcodec_close(dec_ctx);
|
||||||
avformat_close_input(&fmt_ctx);
|
avformat_close_input(&fmt_ctx);
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
av_frame_free(&filt_frame);
|
av_frame_free(&filt_frame);
|
||||||
av_packet_free(&packet);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != AVERROR_EOF) {
|
if (ret < 0 && ret != AVERROR_EOF) {
|
||||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||||
|
|||||||
@@ -1,156 +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];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,256 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017 Jun Zhao
|
|
||||||
* Copyright (c) 2017 Kaixuan Liu
|
|
||||||
*
|
|
||||||
* HW Acceleration API (video decoding) decode sample
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* HW-Accelerated decoding example.
|
|
||||||
*
|
|
||||||
* @example hw_decode.c
|
|
||||||
* This example shows how to do HW-accelerated decoding with output
|
|
||||||
* frames from the HW video surfaces.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libavutil/pixdesc.h>
|
|
||||||
#include <libavutil/hwcontext.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
#include <libavutil/avassert.h>
|
|
||||||
#include <libavutil/imgutils.h>
|
|
||||||
|
|
||||||
static AVBufferRef *hw_device_ctx = NULL;
|
|
||||||
static enum AVPixelFormat hw_pix_fmt;
|
|
||||||
static FILE *output_file = NULL;
|
|
||||||
|
|
||||||
static int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type)
|
|
||||||
{
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if ((err = av_hwdevice_ctx_create(&hw_device_ctx, type,
|
|
||||||
NULL, NULL, 0)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to create specified HW device.\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,
|
|
||||||
const enum AVPixelFormat *pix_fmts)
|
|
||||||
{
|
|
||||||
const enum AVPixelFormat *p;
|
|
||||||
|
|
||||||
for (p = pix_fmts; *p != -1; p++) {
|
|
||||||
if (*p == hw_pix_fmt)
|
|
||||||
return *p;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "Failed to get HW surface format.\n");
|
|
||||||
return AV_PIX_FMT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int decode_write(AVCodecContext *avctx, AVPacket *packet)
|
|
||||||
{
|
|
||||||
AVFrame *frame = NULL, *sw_frame = NULL;
|
|
||||||
AVFrame *tmp_frame = NULL;
|
|
||||||
uint8_t *buffer = NULL;
|
|
||||||
int size;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
ret = avcodec_send_packet(avctx, packet);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if (!(frame = av_frame_alloc()) || !(sw_frame = av_frame_alloc())) {
|
|
||||||
fprintf(stderr, "Can not alloc frame\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avcodec_receive_frame(avctx, frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_frame_free(&sw_frame);
|
|
||||||
return 0;
|
|
||||||
} else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while decoding\n");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame->format == hw_pix_fmt) {
|
|
||||||
/* retrieve data from GPU to CPU */
|
|
||||||
if ((ret = av_hwframe_transfer_data(sw_frame, frame, 0)) < 0) {
|
|
||||||
fprintf(stderr, "Error transferring the data to system memory\n");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
tmp_frame = sw_frame;
|
|
||||||
} else
|
|
||||||
tmp_frame = frame;
|
|
||||||
|
|
||||||
size = av_image_get_buffer_size(tmp_frame->format, tmp_frame->width,
|
|
||||||
tmp_frame->height, 1);
|
|
||||||
buffer = av_malloc(size);
|
|
||||||
if (!buffer) {
|
|
||||||
fprintf(stderr, "Can not alloc buffer\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
ret = av_image_copy_to_buffer(buffer, size,
|
|
||||||
(const uint8_t * const *)tmp_frame->data,
|
|
||||||
(const int *)tmp_frame->linesize, tmp_frame->format,
|
|
||||||
tmp_frame->width, tmp_frame->height, 1);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Can not copy image to buffer\n");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = fwrite(buffer, 1, size, output_file)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to dump raw data.\n");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
fail:
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_frame_free(&sw_frame);
|
|
||||||
av_freep(&buffer);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
AVFormatContext *input_ctx = NULL;
|
|
||||||
int video_stream, ret;
|
|
||||||
AVStream *video = NULL;
|
|
||||||
AVCodecContext *decoder_ctx = NULL;
|
|
||||||
const AVCodec *decoder = NULL;
|
|
||||||
AVPacket *packet = NULL;
|
|
||||||
enum AVHWDeviceType type;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (argc < 4) {
|
|
||||||
fprintf(stderr, "Usage: %s <device type> <input file> <output file>\n", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = av_hwdevice_find_type_by_name(argv[1]);
|
|
||||||
if (type == AV_HWDEVICE_TYPE_NONE) {
|
|
||||||
fprintf(stderr, "Device type %s is not supported.\n", argv[1]);
|
|
||||||
fprintf(stderr, "Available device types:");
|
|
||||||
while((type = av_hwdevice_iterate_types(type)) != AV_HWDEVICE_TYPE_NONE)
|
|
||||||
fprintf(stderr, " %s", av_hwdevice_get_type_name(type));
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
packet = av_packet_alloc();
|
|
||||||
if (!packet) {
|
|
||||||
fprintf(stderr, "Failed to allocate AVPacket\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open the input file */
|
|
||||||
if (avformat_open_input(&input_ctx, argv[2], NULL, NULL) != 0) {
|
|
||||||
fprintf(stderr, "Cannot open input file '%s'\n", argv[2]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avformat_find_stream_info(input_ctx, NULL) < 0) {
|
|
||||||
fprintf(stderr, "Cannot find input stream information.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* find the video stream information */
|
|
||||||
ret = av_find_best_stream(input_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &decoder, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Cannot find a video stream in the input file\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
video_stream = ret;
|
|
||||||
|
|
||||||
for (i = 0;; i++) {
|
|
||||||
const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
|
|
||||||
if (!config) {
|
|
||||||
fprintf(stderr, "Decoder %s does not support device type %s.\n",
|
|
||||||
decoder->name, av_hwdevice_get_type_name(type));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX &&
|
|
||||||
config->device_type == type) {
|
|
||||||
hw_pix_fmt = config->pix_fmt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(decoder_ctx = avcodec_alloc_context3(decoder)))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
video = input_ctx->streams[video_stream];
|
|
||||||
if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
decoder_ctx->get_format = get_hw_format;
|
|
||||||
|
|
||||||
if (hw_decoder_init(decoder_ctx, type) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((ret = avcodec_open2(decoder_ctx, decoder, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to open codec for stream #%u\n", video_stream);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open the file to dump raw data */
|
|
||||||
output_file = fopen(argv[3], "w+b");
|
|
||||||
|
|
||||||
/* actual decoding and dump the raw data */
|
|
||||||
while (ret >= 0) {
|
|
||||||
if ((ret = av_read_frame(input_ctx, packet)) < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (video_stream == packet->stream_index)
|
|
||||||
ret = decode_write(decoder_ctx, packet);
|
|
||||||
|
|
||||||
av_packet_unref(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush the decoder */
|
|
||||||
ret = decode_write(decoder_ctx, NULL);
|
|
||||||
|
|
||||||
if (output_file)
|
|
||||||
fclose(output_file);
|
|
||||||
av_packet_free(&packet);
|
|
||||||
avcodec_free_context(&decoder_ctx);
|
|
||||||
avformat_close_input(&input_ctx);
|
|
||||||
av_buffer_unref(&hw_device_ctx);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
AVFormatContext *fmt_ctx = NULL;
|
AVFormatContext *fmt_ctx = NULL;
|
||||||
const AVDictionaryEntry *tag = NULL;
|
AVDictionaryEntry *tag = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
@@ -44,14 +44,10 @@ int main (int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_register_all();
|
||||||
if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL)))
|
if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
|
while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
|
||||||
printf("%s=%s\n", tag->key, tag->value);
|
printf("%s=%s\n", tag->key, tag->value);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
#include <libavutil/mathematics.h>
|
#include <libavutil/mathematics.h>
|
||||||
#include <libavutil/timestamp.h>
|
#include <libavutil/timestamp.h>
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
@@ -53,21 +52,16 @@
|
|||||||
// a wrapper around a single output AVStream
|
// a wrapper around a single output AVStream
|
||||||
typedef struct OutputStream {
|
typedef struct OutputStream {
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
AVCodecContext *enc;
|
|
||||||
|
|
||||||
/* pts of the next frame that will be generated */
|
/* pts of the next frame that will be generated */
|
||||||
int64_t next_pts;
|
int64_t next_pts;
|
||||||
int samples_count;
|
|
||||||
|
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
AVFrame *tmp_frame;
|
AVFrame *tmp_frame;
|
||||||
|
|
||||||
AVPacket *tmp_pkt;
|
|
||||||
|
|
||||||
float t, tincr, tincr2;
|
float t, tincr, tincr2;
|
||||||
|
|
||||||
struct SwsContext *sws_ctx;
|
struct SwsContext *sws_ctx;
|
||||||
struct SwrContext *swr_ctx;
|
|
||||||
} OutputStream;
|
} OutputStream;
|
||||||
|
|
||||||
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
|
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
|
||||||
@@ -81,54 +75,23 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
|
|||||||
pkt->stream_index);
|
pkt->stream_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_frame(AVFormatContext *fmt_ctx, AVCodecContext *c,
|
static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
|
||||||
AVStream *st, AVFrame *frame, AVPacket *pkt)
|
|
||||||
{
|
{
|
||||||
int ret;
|
/* 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;
|
||||||
|
|
||||||
// send the frame to the encoder
|
/* Write the compressed frame to the media file. */
|
||||||
ret = avcodec_send_frame(c, frame);
|
log_packet(fmt_ctx, pkt);
|
||||||
if (ret < 0) {
|
return av_interleaved_write_frame(fmt_ctx, pkt);
|
||||||
fprintf(stderr, "Error sending a frame to the encoder: %s\n",
|
|
||||||
av_err2str(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ret >= 0) {
|
|
||||||
ret = avcodec_receive_packet(c, pkt);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
break;
|
|
||||||
else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error encoding a frame: %s\n", av_err2str(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* rescale output packet timestamp values from codec to stream timebase */
|
|
||||||
av_packet_rescale_ts(pkt, c->time_base, st->time_base);
|
|
||||||
pkt->stream_index = st->index;
|
|
||||||
|
|
||||||
/* Write the compressed frame to the media file. */
|
|
||||||
log_packet(fmt_ctx, pkt);
|
|
||||||
ret = av_interleaved_write_frame(fmt_ctx, pkt);
|
|
||||||
/* pkt is now blank (av_interleaved_write_frame() takes ownership of
|
|
||||||
* its contents and resets pkt), so that no unreferencing is necessary.
|
|
||||||
* This would be different if one used av_write_frame(). */
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while writing output packet: %s\n", av_err2str(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret == AVERROR_EOF ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add an output stream. */
|
/* Add an output stream. */
|
||||||
static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
||||||
const AVCodec **codec,
|
AVCodec **codec,
|
||||||
enum AVCodecID codec_id)
|
enum AVCodecID codec_id)
|
||||||
{
|
{
|
||||||
AVCodecContext *c;
|
AVCodecContext *c;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* find the encoder */
|
/* find the encoder */
|
||||||
*codec = avcodec_find_encoder(codec_id);
|
*codec = avcodec_find_encoder(codec_id);
|
||||||
@@ -138,24 +101,13 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ost->tmp_pkt = av_packet_alloc();
|
ost->st = avformat_new_stream(oc, *codec);
|
||||||
if (!ost->tmp_pkt) {
|
|
||||||
fprintf(stderr, "Could not allocate AVPacket\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ost->st = avformat_new_stream(oc, NULL);
|
|
||||||
if (!ost->st) {
|
if (!ost->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;
|
ost->st->id = oc->nb_streams-1;
|
||||||
c = avcodec_alloc_context3(*codec);
|
c = ost->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:
|
||||||
@@ -163,15 +115,8 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
|
(*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
|
||||||
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];
|
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
for (i = 0; (*codec)->supported_samplerates[i]; i++) {
|
|
||||||
if ((*codec)->supported_samplerates[i] == 44100)
|
|
||||||
c->sample_rate = 44100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
av_channel_layout_copy(&c->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
|
|
||||||
ost->st->time_base = (AVRational){ 1, c->sample_rate };
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
@@ -185,13 +130,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) {
|
||||||
@@ -200,7 +144,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
|||||||
* the motion of the chroma plane does not match the luma plane. */
|
* the motion of the chroma plane does not match the luma plane. */
|
||||||
c->mb_decision = 2;
|
c->mb_decision = 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -208,54 +152,25 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/* audio output */
|
/* audio output */
|
||||||
|
|
||||||
static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
|
int samples_count;
|
||||||
const AVChannelLayout *channel_layout,
|
|
||||||
int sample_rate, int nb_samples)
|
|
||||||
{
|
|
||||||
AVFrame *frame = av_frame_alloc();
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!frame) {
|
struct SwrContext *swr_ctx = NULL;
|
||||||
fprintf(stderr, "Error allocating an audio frame\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->format = sample_fmt;
|
static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost)
|
||||||
av_channel_layout_copy(&frame->ch_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, const 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 = ost->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);
|
||||||
@@ -267,41 +182,59 @@ static void open_audio(AVFormatContext *oc, const AVCodec *codec,
|
|||||||
/* 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;
|
ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;
|
||||||
|
|
||||||
if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
|
ost->frame = av_frame_alloc();
|
||||||
nb_samples = 10000;
|
if (!ost->frame)
|
||||||
else
|
|
||||||
nb_samples = c->frame_size;
|
|
||||||
|
|
||||||
ost->frame = alloc_audio_frame(c->sample_fmt, &c->ch_layout,
|
|
||||||
c->sample_rate, nb_samples);
|
|
||||||
ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, &c->ch_layout,
|
|
||||||
c->sample_rate, nb_samples);
|
|
||||||
|
|
||||||
/* 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);
|
||||||
}
|
|
||||||
|
ost->frame->sample_rate = c->sample_rate;
|
||||||
|
ost->frame->format = AV_SAMPLE_FMT_S16;
|
||||||
|
ost->frame->channel_layout = c->channel_layout;
|
||||||
|
|
||||||
|
if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)
|
||||||
|
ost->frame->nb_samples = 10000;
|
||||||
|
else
|
||||||
|
ost->frame->nb_samples = c->frame_size;
|
||||||
|
|
||||||
|
ost->tmp_frame = av_frame_alloc();
|
||||||
|
if (!ost->frame)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
ost->tmp_frame->sample_rate = c->sample_rate;
|
||||||
|
ost->tmp_frame->format = c->sample_fmt;
|
||||||
|
ost->tmp_frame->channel_layout = c->channel_layout;
|
||||||
|
ost->tmp_frame->nb_samples = ost->frame->nb_samples;
|
||||||
|
|
||||||
/* create resampler context */
|
/* create resampler context */
|
||||||
ost->swr_ctx = swr_alloc();
|
if (c->sample_fmt != AV_SAMPLE_FMT_S16) {
|
||||||
if (!ost->swr_ctx) {
|
swr_ctx = swr_alloc();
|
||||||
fprintf(stderr, "Could not allocate resampler context\n");
|
if (!swr_ctx) {
|
||||||
exit(1);
|
fprintf(stderr, "Could not allocate resampler context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set options */
|
||||||
|
av_opt_set_int (swr_ctx, "in_channel_count", c->channels, 0);
|
||||||
|
av_opt_set_int (swr_ctx, "in_sample_rate", c->sample_rate, 0);
|
||||||
|
av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
|
||||||
|
av_opt_set_int (swr_ctx, "out_channel_count", c->channels, 0);
|
||||||
|
av_opt_set_int (swr_ctx, "out_sample_rate", c->sample_rate, 0);
|
||||||
|
av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", c->sample_fmt, 0);
|
||||||
|
|
||||||
|
/* initialize the resampling context */
|
||||||
|
if ((ret = swr_init(swr_ctx)) < 0) {
|
||||||
|
fprintf(stderr, "Failed to initialize the resampling context\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set options */
|
ret = av_frame_get_buffer(ost->frame, 0);
|
||||||
av_opt_set_chlayout (ost->swr_ctx, "in_chlayout", &c->ch_layout, 0);
|
if (ret < 0) {
|
||||||
av_opt_set_int (ost->swr_ctx, "in_sample_rate", c->sample_rate, 0);
|
fprintf(stderr, "Could not allocate an audio frame.\n");
|
||||||
av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
|
exit(1);
|
||||||
av_opt_set_chlayout (ost->swr_ctx, "out_chlayout", &c->ch_layout, 0);
|
}
|
||||||
av_opt_set_int (ost->swr_ctx, "out_sample_rate", c->sample_rate, 0);
|
ret = av_frame_get_buffer(ost->tmp_frame, 0);
|
||||||
av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt", c->sample_fmt, 0);
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Could not allocate an audio frame.\n");
|
||||||
/* initialize the resampling context */
|
|
||||||
if ((ret = swr_init(ost->swr_ctx)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to initialize the resampling context\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -310,27 +243,34 @@ static void open_audio(AVFormatContext *oc, const AVCodec *codec,
|
|||||||
* 'nb_channels' channels. */
|
* 'nb_channels' channels. */
|
||||||
static AVFrame *get_audio_frame(OutputStream *ost)
|
static AVFrame *get_audio_frame(OutputStream *ost)
|
||||||
{
|
{
|
||||||
AVFrame *frame = ost->tmp_frame;
|
int j, i, v, ret;
|
||||||
int j, i, v;
|
int16_t *q = (int16_t*)ost->frame->data[0];
|
||||||
int16_t *q = (int16_t*)frame->data[0];
|
|
||||||
|
|
||||||
/* check if we want to generate more frames */
|
/* check if we want to generate more frames */
|
||||||
if (av_compare_ts(ost->next_pts, ost->enc->time_base,
|
if (av_compare_ts(ost->next_pts, ost->st->codec->time_base,
|
||||||
STREAM_DURATION, (AVRational){ 1, 1 }) > 0)
|
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (j = 0; j <frame->nb_samples; j++) {
|
/* 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);
|
||||||
|
|
||||||
|
for (j = 0; j < ost->frame->nb_samples; j++) {
|
||||||
v = (int)(sin(ost->t) * 10000);
|
v = (int)(sin(ost->t) * 10000);
|
||||||
for (i = 0; i < ost->enc->ch_layout.nb_channels; i++)
|
for (i = 0; i < ost->st->codec->channels; i++)
|
||||||
*q++ = v;
|
*q++ = v;
|
||||||
ost->t += ost->tincr;
|
ost->t += ost->tincr;
|
||||||
ost->tincr += ost->tincr2;
|
ost->tincr += ost->tincr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->pts = ost->next_pts;
|
ost->frame->pts = ost->next_pts;
|
||||||
ost->next_pts += frame->nb_samples;
|
ost->next_pts += ost->frame->nb_samples;
|
||||||
|
|
||||||
return frame;
|
return ost->frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -340,44 +280,58 @@ static AVFrame *get_audio_frame(OutputStream *ost)
|
|||||||
static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
||||||
{
|
{
|
||||||
AVCodecContext *c;
|
AVCodecContext *c;
|
||||||
|
AVPacket pkt = { 0 }; // data and size must be 0;
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
int ret;
|
int ret;
|
||||||
|
int got_packet;
|
||||||
int dst_nb_samples;
|
int dst_nb_samples;
|
||||||
|
|
||||||
c = ost->enc;
|
av_init_packet(&pkt);
|
||||||
|
c = ost->st->codec;
|
||||||
|
|
||||||
frame = get_audio_frame(ost);
|
frame = get_audio_frame(ost);
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
/* convert samples from native format to destination codec format, using the resampler */
|
/* convert samples from native format to destination codec format, using the resampler */
|
||||||
/* compute destination number of samples */
|
if (swr_ctx) {
|
||||||
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
|
/* compute destination number of samples */
|
||||||
c->sample_rate, c->sample_rate, AV_ROUND_UP);
|
dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, c->sample_rate) + frame->nb_samples,
|
||||||
av_assert0(dst_nb_samples == frame->nb_samples);
|
c->sample_rate, c->sample_rate, AV_ROUND_UP);
|
||||||
|
av_assert0(dst_nb_samples == frame->nb_samples);
|
||||||
|
|
||||||
/* when we pass a frame to the encoder, it may keep a reference to it
|
/* convert to destination format */
|
||||||
* internally;
|
ret = swr_convert(swr_ctx,
|
||||||
* make sure we do not overwrite it here
|
ost->tmp_frame->data, dst_nb_samples,
|
||||||
*/
|
(const uint8_t **)frame->data, frame->nb_samples);
|
||||||
ret = av_frame_make_writable(ost->frame);
|
if (ret < 0) {
|
||||||
if (ret < 0)
|
fprintf(stderr, "Error while converting\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
}
|
||||||
/* convert to destination format */
|
frame = ost->tmp_frame;
|
||||||
ret = swr_convert(ost->swr_ctx,
|
} else {
|
||||||
ost->frame->data, dst_nb_samples,
|
dst_nb_samples = frame->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);
|
frame->pts = av_rescale_q(samples_count, (AVRational){1, c->sample_rate}, c->time_base);
|
||||||
ost->samples_count += dst_nb_samples;
|
samples_count += dst_nb_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
return write_frame(oc, c, ost->st, frame, ost->tmp_pkt);
|
ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (got_packet) {
|
||||||
|
ret = write_frame(oc, &c->time_base, ost->st, &pkt);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error while writing audio frame: %s\n",
|
||||||
|
av_err2str(ret));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (frame || got_packet) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
@@ -397,7 +351,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
|
|||||||
picture->height = height;
|
picture->height = height;
|
||||||
|
|
||||||
/* allocate the buffers for the frame data */
|
/* allocate the buffers for the frame data */
|
||||||
ret = av_frame_get_buffer(picture, 0);
|
ret = av_frame_get_buffer(picture, 32);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not allocate frame data.\n");
|
fprintf(stderr, "Could not allocate frame data.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -406,18 +360,13 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
|
|||||||
return picture;
|
return picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void open_video(AVFormatContext *oc, const AVCodec *codec,
|
static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost)
|
||||||
OutputStream *ost, AVDictionary *opt_arg)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVCodecContext *c = ost->enc;
|
AVCodecContext *c = ost->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);
|
||||||
@@ -441,20 +390,21 @@ static void open_video(AVFormatContext *oc, const AVCodec *codec,
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare a dummy image. */
|
/* Prepare a dummy image. */
|
||||||
static void fill_yuv_image(AVFrame *pict, int frame_index,
|
static void fill_yuv_image(AVFrame *pict, int frame_index,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
int x, y, i;
|
int x, y, i, ret;
|
||||||
|
|
||||||
|
/* 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(pict);
|
||||||
|
if (ret < 0)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
i = frame_index;
|
i = frame_index;
|
||||||
|
|
||||||
@@ -474,18 +424,13 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
|
|||||||
|
|
||||||
static AVFrame *get_video_frame(OutputStream *ost)
|
static AVFrame *get_video_frame(OutputStream *ost)
|
||||||
{
|
{
|
||||||
AVCodecContext *c = ost->enc;
|
AVCodecContext *c = ost->st->codec;
|
||||||
|
|
||||||
/* check if we want to generate more frames */
|
/* check if we want to generate more frames */
|
||||||
if (av_compare_ts(ost->next_pts, c->time_base,
|
if (av_compare_ts(ost->next_pts, ost->st->codec->time_base,
|
||||||
STREAM_DURATION, (AVRational){ 1, 1 }) > 0)
|
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
|
||||||
return NULL;
|
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) {
|
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||||
/* as we only generate a YUV420P picture, we must convert it
|
/* as we only generate a YUV420P picture, we must convert it
|
||||||
* to the codec pixel format if needed */
|
* to the codec pixel format if needed */
|
||||||
@@ -502,9 +447,9 @@ static AVFrame *get_video_frame(OutputStream *ost)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fill_yuv_image(ost->tmp_frame, ost->next_pts, c->width, c->height);
|
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,
|
sws_scale(ost->sws_ctx,
|
||||||
ost->tmp_frame->linesize, 0, c->height, ost->frame->data,
|
(const uint8_t * const *)ost->tmp_frame->data, ost->tmp_frame->linesize,
|
||||||
ost->frame->linesize);
|
0, c->height, ost->frame->data, ost->frame->linesize);
|
||||||
} else {
|
} else {
|
||||||
fill_yuv_image(ost->frame, ost->next_pts, c->width, c->height);
|
fill_yuv_image(ost->frame, ost->next_pts, c->width, c->height);
|
||||||
}
|
}
|
||||||
@@ -520,17 +465,64 @@ static AVFrame *get_video_frame(OutputStream *ost)
|
|||||||
*/
|
*/
|
||||||
static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
|
static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
|
||||||
{
|
{
|
||||||
return write_frame(oc, ost->enc, ost->st, get_video_frame(ost), ost->tmp_pkt);
|
int ret;
|
||||||
|
AVCodecContext *c;
|
||||||
|
AVFrame *frame;
|
||||||
|
int got_packet = 0;
|
||||||
|
|
||||||
|
c = ost->st->codec;
|
||||||
|
|
||||||
|
frame = get_video_frame(ost);
|
||||||
|
|
||||||
|
if (oc->oformat->flags & AVFMT_RAWPICTURE) {
|
||||||
|
/* a hack to avoid data copy with some raw video muxers */
|
||||||
|
AVPacket pkt;
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
|
||||||
|
if (!frame)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
pkt.stream_index = ost->st->index;
|
||||||
|
pkt.data = (uint8_t *)frame;
|
||||||
|
pkt.size = sizeof(AVPicture);
|
||||||
|
|
||||||
|
pkt.pts = pkt.dts = frame->pts;
|
||||||
|
av_packet_rescale_ts(&pkt, c->time_base, ost->st->time_base);
|
||||||
|
|
||||||
|
ret = av_interleaved_write_frame(oc, &pkt);
|
||||||
|
} else {
|
||||||
|
AVPacket pkt = { 0 };
|
||||||
|
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 {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (frame || got_packet) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_stream(AVFormatContext *oc, OutputStream *ost)
|
static void close_stream(AVFormatContext *oc, OutputStream *ost)
|
||||||
{
|
{
|
||||||
avcodec_free_context(&ost->enc);
|
avcodec_close(ost->st->codec);
|
||||||
av_frame_free(&ost->frame);
|
av_frame_free(&ost->frame);
|
||||||
av_frame_free(&ost->tmp_frame);
|
av_frame_free(&ost->tmp_frame);
|
||||||
av_packet_free(&ost->tmp_pkt);
|
|
||||||
sws_freeContext(ost->sws_ctx);
|
sws_freeContext(ost->sws_ctx);
|
||||||
swr_free(&ost->swr_ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
@@ -539,17 +531,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 };
|
OutputStream video_st = { 0 }, audio_st = { 0 };
|
||||||
const AVOutputFormat *fmt;
|
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
AVOutputFormat *fmt;
|
||||||
AVFormatContext *oc;
|
AVFormatContext *oc;
|
||||||
const AVCodec *audio_codec, *video_codec;
|
AVCodec *audio_codec, *video_codec;
|
||||||
int ret;
|
int ret;
|
||||||
int have_video = 0, have_audio = 0;
|
int have_video = 0, have_audio = 0;
|
||||||
int encode_video = 0, encode_audio = 0;
|
int encode_video = 0, encode_audio = 0;
|
||||||
AVDictionary *opt = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (argc < 2) {
|
/* Initialize libavcodec, and register all codecs and formats. */
|
||||||
|
av_register_all();
|
||||||
|
|
||||||
|
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"
|
||||||
@@ -561,10 +554,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);
|
||||||
@@ -593,10 +582,10 @@ int main(int argc, char **argv)
|
|||||||
/* 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 (have_video)
|
||||||
open_video(oc, video_codec, &video_st, opt);
|
open_video(oc, video_codec, &video_st);
|
||||||
|
|
||||||
if (have_audio)
|
if (have_audio)
|
||||||
open_audio(oc, audio_codec, &audio_st, opt);
|
open_audio(oc, audio_codec, &audio_st);
|
||||||
|
|
||||||
av_dump_format(oc, 0, filename, 1);
|
av_dump_format(oc, 0, filename, 1);
|
||||||
|
|
||||||
@@ -611,7 +600,7 @@ 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));
|
||||||
@@ -621,14 +610,18 @@ int main(int argc, char **argv)
|
|||||||
while (encode_video || encode_audio) {
|
while (encode_video || encode_audio) {
|
||||||
/* select the stream to encode */
|
/* select the stream to encode */
|
||||||
if (encode_video &&
|
if (encode_video &&
|
||||||
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.enc->time_base,
|
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.st->codec->time_base,
|
||||||
audio_st.next_pts, audio_st.enc->time_base) <= 0)) {
|
audio_st.next_pts, audio_st.st->codec->time_base) <= 0)) {
|
||||||
encode_video = !write_video_frame(oc, &video_st);
|
encode_video = !write_video_frame(oc, &video_st);
|
||||||
} else {
|
} else {
|
||||||
encode_audio = !write_audio_frame(oc, &audio_st);
|
encode_audio = !write_audio_frame(oc, &audio_st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Write the trailer, if any. The trailer must be written before you
|
||||||
|
* close the CodecContexts open when you wrote the header; otherwise
|
||||||
|
* av_write_trailer() may try to use memory that was freed on
|
||||||
|
* av_codec_close(). */
|
||||||
av_write_trailer(oc);
|
av_write_trailer(oc);
|
||||||
|
|
||||||
/* Close each codec. */
|
/* Close each codec. */
|
||||||
@@ -639,7 +632,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
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,244 +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 GPU video surfaces.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "libavformat/avformat.h"
|
|
||||||
#include "libavformat/avio.h"
|
|
||||||
|
|
||||||
#include "libavcodec/avcodec.h"
|
|
||||||
|
|
||||||
#include "libavutil/buffer.h"
|
|
||||||
#include "libavutil/error.h"
|
|
||||||
#include "libavutil/hwcontext.h"
|
|
||||||
#include "libavutil/hwcontext_qsv.h"
|
|
||||||
#include "libavutil/mem.h"
|
|
||||||
|
|
||||||
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) {
|
|
||||||
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(AVCodecContext *decoder_ctx,
|
|
||||||
AVFrame *frame, AVFrame *sw_frame,
|
|
||||||
AVPacket *pkt, AVIOContext *output_ctx)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
ret = avcodec_send_packet(decoder_ctx, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ret >= 0) {
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
ret = avcodec_receive_frame(decoder_ctx, frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
|
||||||
break;
|
|
||||||
else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding\n");
|
|
||||||
return 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. */
|
|
||||||
ret = av_hwframe_transfer_data(sw_frame, frame, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error transferring the data to system memory\n");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(sw_frame->data) && sw_frame->data[i]; i++)
|
|
||||||
for (j = 0; j < (sw_frame->height >> (i > 0)); j++)
|
|
||||||
avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], sw_frame->width);
|
|
||||||
|
|
||||||
fail:
|
|
||||||
av_frame_unref(sw_frame);
|
|
||||||
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 = NULL;
|
|
||||||
AVFrame *frame = NULL, *sw_frame = NULL;
|
|
||||||
|
|
||||||
AVIOContext *output_ctx = NULL;
|
|
||||||
|
|
||||||
int ret, i;
|
|
||||||
|
|
||||||
AVBufferRef *device_ref = NULL;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open the hardware device */
|
|
||||||
ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_QSV,
|
|
||||||
"auto", NULL, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Cannot open the hardware device\n");
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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->hw_device_ctx = av_buffer_ref(device_ref);
|
|
||||||
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();
|
|
||||||
sw_frame = av_frame_alloc();
|
|
||||||
pkt = av_packet_alloc();
|
|
||||||
if (!frame || !sw_frame || !pkt) {
|
|
||||||
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(decoder_ctx, frame, sw_frame, pkt, output_ctx);
|
|
||||||
|
|
||||||
av_packet_unref(pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush the decoder */
|
|
||||||
ret = decode_packet(decoder_ctx, frame, sw_frame, NULL, 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);
|
|
||||||
av_frame_free(&sw_frame);
|
|
||||||
av_packet_free(&pkt);
|
|
||||||
|
|
||||||
avcodec_free_context(&decoder_ctx);
|
|
||||||
|
|
||||||
av_buffer_unref(&device_ref);
|
|
||||||
|
|
||||||
avio_close(output_ctx);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -45,14 +45,11 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, cons
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const AVOutputFormat *ofmt = NULL;
|
AVOutputFormat *ofmt = NULL;
|
||||||
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
|
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
|
||||||
AVPacket *pkt = NULL;
|
AVPacket pkt;
|
||||||
const char *in_filename, *out_filename;
|
const char *in_filename, *out_filename;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
int stream_index = 0;
|
|
||||||
int *stream_mapping = NULL;
|
|
||||||
int stream_mapping_size = 0;
|
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf("usage: %s input output\n"
|
printf("usage: %s input output\n"
|
||||||
@@ -65,11 +62,7 @@ int main(int argc, char **argv)
|
|||||||
in_filename = argv[1];
|
in_filename = argv[1];
|
||||||
out_filename = argv[2];
|
out_filename = argv[2];
|
||||||
|
|
||||||
pkt = av_packet_alloc();
|
av_register_all();
|
||||||
if (!pkt) {
|
|
||||||
fprintf(stderr, "Could not allocate AVPacket\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
|
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
|
||||||
fprintf(stderr, "Could not open input file '%s'", in_filename);
|
fprintf(stderr, "Could not open input file '%s'", in_filename);
|
||||||
@@ -90,42 +83,25 @@ int main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_mapping_size = ifmt_ctx->nb_streams;
|
|
||||||
stream_mapping = av_calloc(stream_mapping_size, sizeof(*stream_mapping));
|
|
||||||
if (!stream_mapping) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ofmt = ofmt_ctx->oformat;
|
ofmt = ofmt_ctx->oformat;
|
||||||
|
|
||||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||||
AVStream *out_stream;
|
|
||||||
AVStream *in_stream = ifmt_ctx->streams[i];
|
AVStream *in_stream = ifmt_ctx->streams[i];
|
||||||
AVCodecParameters *in_codecpar = in_stream->codecpar;
|
AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);
|
||||||
|
|
||||||
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) {
|
if (!out_stream) {
|
||||||
fprintf(stderr, "Failed allocating output stream\n");
|
fprintf(stderr, "Failed allocating output stream\n");
|
||||||
ret = AVERROR_UNKNOWN;
|
ret = AVERROR_UNKNOWN;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
|
ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Failed to copy codec parameters\n");
|
fprintf(stderr, "Failed to copy context from input to output stream codec context\n");
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
out_stream->codecpar->codec_tag = 0;
|
out_stream->codec->codec_tag = 0;
|
||||||
|
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
|
out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||||
}
|
}
|
||||||
av_dump_format(ofmt_ctx, 0, out_filename, 1);
|
av_dump_format(ofmt_ctx, 0, out_filename, 1);
|
||||||
|
|
||||||
@@ -146,49 +122,40 @@ int main(int argc, char **argv)
|
|||||||
while (1) {
|
while (1) {
|
||||||
AVStream *in_stream, *out_stream;
|
AVStream *in_stream, *out_stream;
|
||||||
|
|
||||||
ret = av_read_frame(ifmt_ctx, pkt);
|
ret = av_read_frame(ifmt_ctx, &pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
in_stream = ifmt_ctx->streams[pkt->stream_index];
|
in_stream = ifmt_ctx->streams[pkt.stream_index];
|
||||||
if (pkt->stream_index >= stream_mapping_size ||
|
out_stream = ofmt_ctx->streams[pkt.stream_index];
|
||||||
stream_mapping[pkt->stream_index] < 0) {
|
|
||||||
av_packet_unref(pkt);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt->stream_index = stream_mapping[pkt->stream_index];
|
log_packet(ifmt_ctx, &pkt, "in");
|
||||||
out_stream = ofmt_ctx->streams[pkt->stream_index];
|
|
||||||
log_packet(ifmt_ctx, pkt, "in");
|
|
||||||
|
|
||||||
/* copy packet */
|
/* copy packet */
|
||||||
av_packet_rescale_ts(pkt, in_stream->time_base, out_stream->time_base);
|
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->pos = -1;
|
pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
log_packet(ofmt_ctx, pkt, "out");
|
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);
|
ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
|
||||||
/* pkt is now blank (av_interleaved_write_frame() takes ownership of
|
|
||||||
* its contents and resets pkt), so that no unreferencing is necessary.
|
|
||||||
* This would be different if one used av_write_frame(). */
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Error muxing packet\n");
|
fprintf(stderr, "Error muxing packet\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
av_free_packet(&pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_write_trailer(ofmt_ctx);
|
av_write_trailer(ofmt_ctx);
|
||||||
end:
|
end:
|
||||||
av_packet_free(&pkt);
|
|
||||||
|
|
||||||
avformat_close_input(&ifmt_ctx);
|
avformat_close_input(&ifmt_ctx);
|
||||||
|
|
||||||
/* close output */
|
/* close output */
|
||||||
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
|
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
|
||||||
avio_closep(&ofmt_ctx->pb);
|
avio_close(ofmt_ctx->pb);
|
||||||
avformat_free_context(ofmt_ctx);
|
avformat_free_context(ofmt_ctx);
|
||||||
|
|
||||||
av_freep(&stream_mapping);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != AVERROR_EOF) {
|
if (ret < 0 && ret != AVERROR_EOF) {
|
||||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ static void fill_samples(double *dst, int nb_samples, int nb_channels, int sampl
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
AVChannelLayout src_ch_layout = AV_CHANNEL_LAYOUT_STEREO, dst_ch_layout = AV_CHANNEL_LAYOUT_SURROUND;
|
int64_t src_ch_layout = AV_CH_LAYOUT_STEREO, dst_ch_layout = AV_CH_LAYOUT_SURROUND;
|
||||||
int src_rate = 48000, dst_rate = 44100;
|
int src_rate = 48000, dst_rate = 44100;
|
||||||
uint8_t **src_data = NULL, **dst_data = NULL;
|
uint8_t **src_data = NULL, **dst_data = NULL;
|
||||||
int src_nb_channels = 0, dst_nb_channels = 0;
|
int src_nb_channels = 0, dst_nb_channels = 0;
|
||||||
@@ -92,7 +92,6 @@ int main(int argc, char **argv)
|
|||||||
int dst_bufsize;
|
int dst_bufsize;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
struct SwrContext *swr_ctx;
|
struct SwrContext *swr_ctx;
|
||||||
char buf[64];
|
|
||||||
double t;
|
double t;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -121,11 +120,11 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set options */
|
/* set options */
|
||||||
av_opt_set_chlayout(swr_ctx, "in_chlayout", &src_ch_layout, 0);
|
av_opt_set_int(swr_ctx, "in_channel_layout", src_ch_layout, 0);
|
||||||
av_opt_set_int(swr_ctx, "in_sample_rate", src_rate, 0);
|
av_opt_set_int(swr_ctx, "in_sample_rate", src_rate, 0);
|
||||||
av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", src_sample_fmt, 0);
|
av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", src_sample_fmt, 0);
|
||||||
|
|
||||||
av_opt_set_chlayout(swr_ctx, "out_chlayout", &dst_ch_layout, 0);
|
av_opt_set_int(swr_ctx, "out_channel_layout", dst_ch_layout, 0);
|
||||||
av_opt_set_int(swr_ctx, "out_sample_rate", dst_rate, 0);
|
av_opt_set_int(swr_ctx, "out_sample_rate", dst_rate, 0);
|
||||||
av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", dst_sample_fmt, 0);
|
av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", dst_sample_fmt, 0);
|
||||||
|
|
||||||
@@ -137,7 +136,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* allocate source and destination samples buffers */
|
/* allocate source and destination samples buffers */
|
||||||
|
|
||||||
src_nb_channels = src_ch_layout.nb_channels;
|
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 = av_samples_alloc_array_and_samples(&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) {
|
||||||
@@ -152,7 +151,7 @@ int main(int argc, char **argv)
|
|||||||
av_rescale_rnd(src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
|
av_rescale_rnd(src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
|
||||||
|
|
||||||
/* 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 = dst_ch_layout.nb_channels;
|
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 = av_samples_alloc_array_and_samples(&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) {
|
||||||
@@ -195,13 +194,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if ((ret = get_format_from_sample_fmt(&fmt, dst_sample_fmt)) < 0)
|
if ((ret = get_format_from_sample_fmt(&fmt, dst_sample_fmt)) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
av_channel_layout_describe(&dst_ch_layout, buf, sizeof(buf));
|
|
||||||
fprintf(stderr, "Resampling succeeded. Play the output file with the command:\n"
|
fprintf(stderr, "Resampling succeeded. Play the output file with the command:\n"
|
||||||
"ffplay -f %s -channel_layout %s -channels %d -ar %d %s\n",
|
"ffplay -f %s -channel_layout %"PRId64" -channels %d -ar %d %s\n",
|
||||||
fmt, buf, 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]);
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ int main(int argc, char **argv)
|
|||||||
av_get_pix_fmt_name(dst_pix_fmt), dst_w, dst_h, dst_filename);
|
av_get_pix_fmt_name(dst_pix_fmt), dst_w, dst_h, dst_filename);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
fclose(dst_file);
|
if (dst_file)
|
||||||
|
fclose(dst_file);
|
||||||
av_freep(&src_data[0]);
|
av_freep(&src_data[0]);
|
||||||
av_freep(&dst_data[0]);
|
av_freep(&dst_data[0]);
|
||||||
sws_freeContext(sws_ctx);
|
sws_freeContext(sws_ctx);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,9 +30,10 @@
|
|||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.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/channel_layout.h>
|
|
||||||
#include <libavutil/opt.h>
|
#include <libavutil/opt.h>
|
||||||
#include <libavutil/pixdesc.h>
|
#include <libavutil/pixdesc.h>
|
||||||
|
|
||||||
@@ -42,20 +43,9 @@ typedef struct FilteringContext {
|
|||||||
AVFilterContext *buffersink_ctx;
|
AVFilterContext *buffersink_ctx;
|
||||||
AVFilterContext *buffersrc_ctx;
|
AVFilterContext *buffersrc_ctx;
|
||||||
AVFilterGraph *filter_graph;
|
AVFilterGraph *filter_graph;
|
||||||
|
|
||||||
AVPacket *enc_pkt;
|
|
||||||
AVFrame *filtered_frame;
|
|
||||||
} FilteringContext;
|
} FilteringContext;
|
||||||
static FilteringContext *filter_ctx;
|
static FilteringContext *filter_ctx;
|
||||||
|
|
||||||
typedef struct StreamContext {
|
|
||||||
AVCodecContext *dec_ctx;
|
|
||||||
AVCodecContext *enc_ctx;
|
|
||||||
|
|
||||||
AVFrame *dec_frame;
|
|
||||||
} StreamContext;
|
|
||||||
static StreamContext *stream_ctx;
|
|
||||||
|
|
||||||
static int open_input_file(const char *filename)
|
static int open_input_file(const char *filename)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -72,46 +62,22 @@ static int open_input_file(const char *filename)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_ctx = av_calloc(ifmt_ctx->nb_streams, sizeof(*stream_ctx));
|
|
||||||
if (!stream_ctx)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||||
AVStream *stream = ifmt_ctx->streams[i];
|
AVStream *stream;
|
||||||
const AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id);
|
|
||||||
AVCodecContext *codec_ctx;
|
AVCodecContext *codec_ctx;
|
||||||
if (!dec) {
|
stream = ifmt_ctx->streams[i];
|
||||||
av_log(NULL, AV_LOG_ERROR, "Failed to find decoder for stream #%u\n", i);
|
codec_ctx = stream->codec;
|
||||||
return AVERROR_DECODER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
codec_ctx = avcodec_alloc_context3(dec);
|
|
||||||
if (!codec_ctx) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Failed to allocate the decoder context for stream #%u\n", i);
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
ret = avcodec_parameters_to_context(codec_ctx, stream->codecpar);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Failed to copy decoder parameters to input decoder context "
|
|
||||||
"for stream #%u\n", i);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/* Reencode video & audio and remux subtitles etc. */
|
/* Reencode video & audio and remux subtitles etc. */
|
||||||
if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
||||||
|| codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
|| codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
|
|
||||||
codec_ctx->framerate = av_guess_frame_rate(ifmt_ctx, stream, NULL);
|
|
||||||
/* Open decoder */
|
/* Open decoder */
|
||||||
ret = avcodec_open2(codec_ctx, dec, NULL);
|
ret = avcodec_open2(codec_ctx,
|
||||||
|
avcodec_find_decoder(codec_ctx->codec_id), NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
|
av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream_ctx[i].dec_ctx = codec_ctx;
|
|
||||||
|
|
||||||
stream_ctx[i].dec_frame = av_frame_alloc();
|
|
||||||
if (!stream_ctx[i].dec_frame)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
av_dump_format(ifmt_ctx, 0, filename, 0);
|
av_dump_format(ifmt_ctx, 0, filename, 0);
|
||||||
@@ -123,7 +89,7 @@ static int open_output_file(const char *filename)
|
|||||||
AVStream *out_stream;
|
AVStream *out_stream;
|
||||||
AVStream *in_stream;
|
AVStream *in_stream;
|
||||||
AVCodecContext *dec_ctx, *enc_ctx;
|
AVCodecContext *dec_ctx, *enc_ctx;
|
||||||
const AVCodec *encoder;
|
AVCodec *encoder;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -143,21 +109,13 @@ static int open_output_file(const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
in_stream = ifmt_ctx->streams[i];
|
in_stream = ifmt_ctx->streams[i];
|
||||||
dec_ctx = stream_ctx[i].dec_ctx;
|
dec_ctx = in_stream->codec;
|
||||||
|
enc_ctx = out_stream->codec;
|
||||||
|
|
||||||
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
||||||
|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
/* in this example, we choose transcoding to same codec */
|
/* in this example, we choose transcoding to same codec */
|
||||||
encoder = avcodec_find_encoder(dec_ctx->codec_id);
|
encoder = avcodec_find_encoder(dec_ctx->codec_id);
|
||||||
if (!encoder) {
|
|
||||||
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
enc_ctx = avcodec_alloc_context3(encoder);
|
|
||||||
if (!enc_ctx) {
|
|
||||||
av_log(NULL, AV_LOG_FATAL, "Failed to allocate the encoder context\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In this example, we transcode to same properties (picture size,
|
/* In this example, we transcode to same properties (picture size,
|
||||||
* sample rate etc.). These properties can be changed for output
|
* sample rate etc.). These properties can be changed for output
|
||||||
@@ -167,52 +125,40 @@ static int open_output_file(const char *filename)
|
|||||||
enc_ctx->width = dec_ctx->width;
|
enc_ctx->width = dec_ctx->width;
|
||||||
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
|
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
|
||||||
/* take first format from list of supported formats */
|
/* take first format from list of supported formats */
|
||||||
if (encoder->pix_fmts)
|
enc_ctx->pix_fmt = encoder->pix_fmts[0];
|
||||||
enc_ctx->pix_fmt = encoder->pix_fmts[0];
|
|
||||||
else
|
|
||||||
enc_ctx->pix_fmt = dec_ctx->pix_fmt;
|
|
||||||
/* video time_base can be set to whatever is handy and supported by encoder */
|
/* video time_base can be set to whatever is handy and supported by encoder */
|
||||||
enc_ctx->time_base = av_inv_q(dec_ctx->framerate);
|
enc_ctx->time_base = dec_ctx->time_base;
|
||||||
} else {
|
} else {
|
||||||
enc_ctx->sample_rate = dec_ctx->sample_rate;
|
enc_ctx->sample_rate = dec_ctx->sample_rate;
|
||||||
ret = av_channel_layout_copy(&enc_ctx->ch_layout, &dec_ctx->ch_layout);
|
enc_ctx->channel_layout = dec_ctx->channel_layout;
|
||||||
if (ret < 0)
|
enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout);
|
||||||
return ret;
|
|
||||||
/* take first format from list of supported formats */
|
/* take first format from list of supported formats */
|
||||||
enc_ctx->sample_fmt = encoder->sample_fmts[0];
|
enc_ctx->sample_fmt = encoder->sample_fmts[0];
|
||||||
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
|
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
|
||||||
enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
|
||||||
|
|
||||||
/* Third parameter can be used to pass settings to encoder */
|
/* Third parameter can be used to pass settings to encoder */
|
||||||
ret = avcodec_open2(enc_ctx, encoder, NULL);
|
ret = avcodec_open2(enc_ctx, encoder, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i);
|
av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = avcodec_parameters_from_context(out_stream->codecpar, enc_ctx);
|
|
||||||
if (ret < 0) {
|
|
||||||
av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", i);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
out_stream->time_base = enc_ctx->time_base;
|
|
||||||
stream_ctx[i].enc_ctx = enc_ctx;
|
|
||||||
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_UNKNOWN) {
|
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_UNKNOWN) {
|
||||||
av_log(NULL, AV_LOG_FATAL, "Elementary stream #%d is of unknown type, cannot proceed\n", i);
|
av_log(NULL, AV_LOG_FATAL, "Elementary stream #%d is of unknown type, cannot proceed\n", i);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
} else {
|
} else {
|
||||||
/* if this stream must be remuxed */
|
/* if this stream must be remuxed */
|
||||||
ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar);
|
ret = avcodec_copy_context(ofmt_ctx->streams[i]->codec,
|
||||||
|
ifmt_ctx->streams[i]->codec);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Copying parameters for stream #%u failed\n", i);
|
av_log(NULL, AV_LOG_ERROR, "Copying stream context failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
out_stream->time_base = in_stream->time_base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||||
|
enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||||
|
|
||||||
}
|
}
|
||||||
av_dump_format(ofmt_ctx, 0, filename, 1);
|
av_dump_format(ofmt_ctx, 0, filename, 1);
|
||||||
|
|
||||||
@@ -239,8 +185,8 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
|
|||||||
{
|
{
|
||||||
char args[512];
|
char args[512];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const AVFilter *buffersrc = NULL;
|
AVFilter *buffersrc = NULL;
|
||||||
const AVFilter *buffersink = NULL;
|
AVFilter *buffersink = NULL;
|
||||||
AVFilterContext *buffersrc_ctx = NULL;
|
AVFilterContext *buffersrc_ctx = NULL;
|
||||||
AVFilterContext *buffersink_ctx = NULL;
|
AVFilterContext *buffersink_ctx = NULL;
|
||||||
AVFilterInOut *outputs = avfilter_inout_alloc();
|
AVFilterInOut *outputs = avfilter_inout_alloc();
|
||||||
@@ -290,7 +236,6 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
} else if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
char buf[64];
|
|
||||||
buffersrc = avfilter_get_by_name("abuffer");
|
buffersrc = avfilter_get_by_name("abuffer");
|
||||||
buffersink = avfilter_get_by_name("abuffersink");
|
buffersink = avfilter_get_by_name("abuffersink");
|
||||||
if (!buffersrc || !buffersink) {
|
if (!buffersrc || !buffersink) {
|
||||||
@@ -299,14 +244,14 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dec_ctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
|
if (!dec_ctx->channel_layout)
|
||||||
av_channel_layout_default(&dec_ctx->ch_layout, dec_ctx->ch_layout.nb_channels);
|
dec_ctx->channel_layout =
|
||||||
av_channel_layout_describe(&dec_ctx->ch_layout, buf, sizeof(buf));
|
av_get_default_channel_layout(dec_ctx->channels);
|
||||||
snprintf(args, sizeof(args),
|
snprintf(args, sizeof(args),
|
||||||
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=%s",
|
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64,
|
||||||
dec_ctx->time_base.num, dec_ctx->time_base.den, dec_ctx->sample_rate,
|
dec_ctx->time_base.num, dec_ctx->time_base.den, dec_ctx->sample_rate,
|
||||||
av_get_sample_fmt_name(dec_ctx->sample_fmt),
|
av_get_sample_fmt_name(dec_ctx->sample_fmt),
|
||||||
buf);
|
dec_ctx->channel_layout);
|
||||||
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) {
|
||||||
@@ -329,9 +274,9 @@ static int init_filter(FilteringContext* fctx, AVCodecContext *dec_ctx,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_channel_layout_describe(&enc_ctx->ch_layout, buf, sizeof(buf));
|
ret = av_opt_set_bin(buffersink_ctx, "channel_layouts",
|
||||||
ret = av_opt_set(buffersink_ctx, "ch_layouts",
|
(uint8_t*)&enc_ctx->channel_layout,
|
||||||
buf, AV_OPT_SEARCH_CHILDREN);
|
sizeof(enc_ctx->channel_layout), AV_OPT_SEARCH_CHILDREN);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
av_log(NULL, AV_LOG_ERROR, "Cannot set output channel layout\n");
|
||||||
goto end;
|
goto end;
|
||||||
@@ -397,76 +342,75 @@ static int init_filters(void)
|
|||||||
filter_ctx[i].buffersrc_ctx = NULL;
|
filter_ctx[i].buffersrc_ctx = NULL;
|
||||||
filter_ctx[i].buffersink_ctx = NULL;
|
filter_ctx[i].buffersink_ctx = NULL;
|
||||||
filter_ctx[i].filter_graph = NULL;
|
filter_ctx[i].filter_graph = NULL;
|
||||||
if (!(ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
|
if (!(ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO
|
||||||
|| ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO))
|
|| ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
if (ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
|
if (ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||||
filter_spec = "null"; /* passthrough (dummy) filter for video */
|
filter_spec = "null"; /* passthrough (dummy) filter for video */
|
||||||
else
|
else
|
||||||
filter_spec = "anull"; /* passthrough (dummy) filter for audio */
|
filter_spec = "anull"; /* passthrough (dummy) filter for audio */
|
||||||
ret = init_filter(&filter_ctx[i], stream_ctx[i].dec_ctx,
|
ret = init_filter(&filter_ctx[i], ifmt_ctx->streams[i]->codec,
|
||||||
stream_ctx[i].enc_ctx, filter_spec);
|
ofmt_ctx->streams[i]->codec, filter_spec);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
filter_ctx[i].enc_pkt = av_packet_alloc();
|
|
||||||
if (!filter_ctx[i].enc_pkt)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
filter_ctx[i].filtered_frame = av_frame_alloc();
|
|
||||||
if (!filter_ctx[i].filtered_frame)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int encode_write_frame(unsigned int stream_index, int flush)
|
static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, int *got_frame) {
|
||||||
{
|
|
||||||
StreamContext *stream = &stream_ctx[stream_index];
|
|
||||||
FilteringContext *filter = &filter_ctx[stream_index];
|
|
||||||
AVFrame *filt_frame = flush ? NULL : filter->filtered_frame;
|
|
||||||
AVPacket *enc_pkt = filter->enc_pkt;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
int got_frame_local;
|
||||||
|
AVPacket enc_pkt;
|
||||||
|
int (*enc_func)(AVCodecContext *, AVPacket *, const AVFrame *, int *) =
|
||||||
|
(ifmt_ctx->streams[stream_index]->codec->codec_type ==
|
||||||
|
AVMEDIA_TYPE_VIDEO) ? avcodec_encode_video2 : avcodec_encode_audio2;
|
||||||
|
|
||||||
|
if (!got_frame)
|
||||||
|
got_frame = &got_frame_local;
|
||||||
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
|
av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
|
||||||
/* encode filtered frame */
|
/* encode filtered frame */
|
||||||
av_packet_unref(enc_pkt);
|
enc_pkt.data = NULL;
|
||||||
|
enc_pkt.size = 0;
|
||||||
ret = avcodec_send_frame(stream->enc_ctx, filt_frame);
|
av_init_packet(&enc_pkt);
|
||||||
|
ret = enc_func(ofmt_ctx->streams[stream_index]->codec, &enc_pkt,
|
||||||
|
filt_frame, got_frame);
|
||||||
|
av_frame_free(&filt_frame);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
if (!(*got_frame))
|
||||||
|
return 0;
|
||||||
|
|
||||||
while (ret >= 0) {
|
/* prepare packet for muxing */
|
||||||
ret = avcodec_receive_packet(stream->enc_ctx, enc_pkt);
|
enc_pkt.stream_index = stream_index;
|
||||||
|
enc_pkt.dts = av_rescale_q_rnd(enc_pkt.dts,
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
ofmt_ctx->streams[stream_index]->codec->time_base,
|
||||||
return 0;
|
ofmt_ctx->streams[stream_index]->time_base,
|
||||||
|
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
/* prepare packet for muxing */
|
enc_pkt.pts = av_rescale_q_rnd(enc_pkt.pts,
|
||||||
enc_pkt->stream_index = stream_index;
|
ofmt_ctx->streams[stream_index]->codec->time_base,
|
||||||
av_packet_rescale_ts(enc_pkt,
|
ofmt_ctx->streams[stream_index]->time_base,
|
||||||
stream->enc_ctx->time_base,
|
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
ofmt_ctx->streams[stream_index]->time_base);
|
enc_pkt.duration = av_rescale_q(enc_pkt.duration,
|
||||||
|
ofmt_ctx->streams[stream_index]->codec->time_base,
|
||||||
av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
|
ofmt_ctx->streams[stream_index]->time_base);
|
||||||
/* mux encoded frame */
|
|
||||||
ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
|
||||||
|
/* mux encoded frame */
|
||||||
|
ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
|
static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
|
||||||
{
|
{
|
||||||
FilteringContext *filter = &filter_ctx[stream_index];
|
|
||||||
int ret;
|
int ret;
|
||||||
|
AVFrame *filt_frame;
|
||||||
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
|
av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
|
||||||
/* push the decoded frame into the filtergraph */
|
/* push the decoded frame into the filtergraph */
|
||||||
ret = av_buffersrc_add_frame_flags(filter->buffersrc_ctx,
|
ret = av_buffersrc_add_frame_flags(filter_ctx[stream_index].buffersrc_ctx,
|
||||||
frame, 0);
|
frame, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
|
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
|
||||||
@@ -475,9 +419,14 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
|
|||||||
|
|
||||||
/* pull filtered frames from the filtergraph */
|
/* pull filtered frames from the filtergraph */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
filt_frame = av_frame_alloc();
|
||||||
|
if (!filt_frame) {
|
||||||
|
ret = AVERROR(ENOMEM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n");
|
av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n");
|
||||||
ret = av_buffersink_get_frame(filter->buffersink_ctx,
|
ret = av_buffersink_get_frame(filter_ctx[stream_index].buffersink_ctx,
|
||||||
filter->filtered_frame);
|
filt_frame);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* if no more frames for output - returns AVERROR(EAGAIN)
|
/* if no more frames for output - returns AVERROR(EAGAIN)
|
||||||
* if flushed and no more frames for output - returns AVERROR_EOF
|
* if flushed and no more frames for output - returns AVERROR_EOF
|
||||||
@@ -485,12 +434,12 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
|
|||||||
*/
|
*/
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
av_frame_free(&filt_frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE;
|
filt_frame->pict_type = AV_PICTURE_TYPE_NONE;
|
||||||
ret = encode_write_frame(stream_index, 0);
|
ret = encode_write_frame(filt_frame, stream_index, NULL);
|
||||||
av_frame_unref(filter->filtered_frame);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -500,80 +449,109 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
|
|||||||
|
|
||||||
static int flush_encoder(unsigned int stream_index)
|
static int flush_encoder(unsigned int stream_index)
|
||||||
{
|
{
|
||||||
if (!(stream_ctx[stream_index].enc_ctx->codec->capabilities &
|
int ret;
|
||||||
AV_CODEC_CAP_DELAY))
|
int got_frame;
|
||||||
|
|
||||||
|
if (!(ofmt_ctx->streams[stream_index]->codec->codec->capabilities &
|
||||||
|
CODEC_CAP_DELAY))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
|
while (1) {
|
||||||
return encode_write_frame(stream_index, 1);
|
av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
|
||||||
|
ret = encode_write_frame(NULL, stream_index, &got_frame);
|
||||||
|
if (ret < 0)
|
||||||
|
break;
|
||||||
|
if (!got_frame)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
AVPacket *packet = NULL;
|
AVPacket packet = { .data = NULL, .size = 0 };
|
||||||
|
AVFrame *frame = NULL;
|
||||||
|
enum AVMediaType type;
|
||||||
unsigned int stream_index;
|
unsigned int stream_index;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int got_frame;
|
||||||
|
int (*dec_func)(AVCodecContext *, AVFrame *, int *, const AVPacket *);
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Usage: %s <input file> <output file>\n", argv[0]);
|
av_log(NULL, AV_LOG_ERROR, "Usage: %s <input file> <output file>\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_register_all();
|
||||||
|
avfilter_register_all();
|
||||||
|
|
||||||
if ((ret = open_input_file(argv[1])) < 0)
|
if ((ret = open_input_file(argv[1])) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if ((ret = open_output_file(argv[2])) < 0)
|
if ((ret = open_output_file(argv[2])) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if ((ret = init_filters()) < 0)
|
if ((ret = init_filters()) < 0)
|
||||||
goto end;
|
goto end;
|
||||||
if (!(packet = av_packet_alloc()))
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
/* read all packets */
|
/* read all packets */
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((ret = av_read_frame(ifmt_ctx, packet)) < 0)
|
if ((ret = av_read_frame(ifmt_ctx, &packet)) < 0)
|
||||||
break;
|
break;
|
||||||
stream_index = packet->stream_index;
|
stream_index = packet.stream_index;
|
||||||
|
type = ifmt_ctx->streams[packet.stream_index]->codec->codec_type;
|
||||||
av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n",
|
av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n",
|
||||||
stream_index);
|
stream_index);
|
||||||
|
|
||||||
if (filter_ctx[stream_index].filter_graph) {
|
if (filter_ctx[stream_index].filter_graph) {
|
||||||
StreamContext *stream = &stream_ctx[stream_index];
|
|
||||||
|
|
||||||
av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n");
|
av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n");
|
||||||
|
frame = av_frame_alloc();
|
||||||
av_packet_rescale_ts(packet,
|
if (!frame) {
|
||||||
ifmt_ctx->streams[stream_index]->time_base,
|
ret = AVERROR(ENOMEM);
|
||||||
stream->dec_ctx->time_base);
|
break;
|
||||||
ret = avcodec_send_packet(stream->dec_ctx, packet);
|
}
|
||||||
|
packet.dts = av_rescale_q_rnd(packet.dts,
|
||||||
|
ifmt_ctx->streams[stream_index]->time_base,
|
||||||
|
ifmt_ctx->streams[stream_index]->codec->time_base,
|
||||||
|
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
|
packet.pts = av_rescale_q_rnd(packet.pts,
|
||||||
|
ifmt_ctx->streams[stream_index]->time_base,
|
||||||
|
ifmt_ctx->streams[stream_index]->codec->time_base,
|
||||||
|
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
|
dec_func = (type == AVMEDIA_TYPE_VIDEO) ? avcodec_decode_video2 :
|
||||||
|
avcodec_decode_audio4;
|
||||||
|
ret = dec_func(ifmt_ctx->streams[stream_index]->codec, frame,
|
||||||
|
&got_frame, &packet);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
av_frame_free(&frame);
|
||||||
av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
|
av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ret >= 0) {
|
if (got_frame) {
|
||||||
ret = avcodec_receive_frame(stream->dec_ctx, stream->dec_frame);
|
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
||||||
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
|
ret = filter_encode_write_frame(frame, stream_index);
|
||||||
break;
|
av_frame_free(&frame);
|
||||||
else if (ret < 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
stream->dec_frame->pts = stream->dec_frame->best_effort_timestamp;
|
|
||||||
ret = filter_encode_write_frame(stream->dec_frame, stream_index);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
} else {
|
||||||
|
av_frame_free(&frame);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* remux this frame without reencoding */
|
/* remux this frame without reencoding */
|
||||||
av_packet_rescale_ts(packet,
|
packet.dts = av_rescale_q_rnd(packet.dts,
|
||||||
ifmt_ctx->streams[stream_index]->time_base,
|
ifmt_ctx->streams[stream_index]->time_base,
|
||||||
ofmt_ctx->streams[stream_index]->time_base);
|
ofmt_ctx->streams[stream_index]->time_base,
|
||||||
|
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
|
packet.pts = av_rescale_q_rnd(packet.pts,
|
||||||
|
ifmt_ctx->streams[stream_index]->time_base,
|
||||||
|
ofmt_ctx->streams[stream_index]->time_base,
|
||||||
|
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||||
|
|
||||||
ret = av_interleaved_write_frame(ofmt_ctx, packet);
|
ret = av_interleaved_write_frame(ofmt_ctx, &packet);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
av_packet_unref(packet);
|
av_free_packet(&packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush filters and encoders */
|
/* flush filters and encoders */
|
||||||
@@ -597,24 +575,19 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
av_write_trailer(ofmt_ctx);
|
av_write_trailer(ofmt_ctx);
|
||||||
end:
|
end:
|
||||||
av_packet_free(&packet);
|
av_free_packet(&packet);
|
||||||
|
av_frame_free(&frame);
|
||||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||||
avcodec_free_context(&stream_ctx[i].dec_ctx);
|
avcodec_close(ifmt_ctx->streams[i]->codec);
|
||||||
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && stream_ctx[i].enc_ctx)
|
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && ofmt_ctx->streams[i]->codec)
|
||||||
avcodec_free_context(&stream_ctx[i].enc_ctx);
|
avcodec_close(ofmt_ctx->streams[i]->codec);
|
||||||
if (filter_ctx && filter_ctx[i].filter_graph) {
|
if (filter_ctx && filter_ctx[i].filter_graph)
|
||||||
avfilter_graph_free(&filter_ctx[i].filter_graph);
|
avfilter_graph_free(&filter_ctx[i].filter_graph);
|
||||||
av_packet_free(&filter_ctx[i].enc_pkt);
|
|
||||||
av_frame_free(&filter_ctx[i].filtered_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
av_frame_free(&stream_ctx[i].dec_frame);
|
|
||||||
}
|
}
|
||||||
av_free(filter_ctx);
|
av_free(filter_ctx);
|
||||||
av_free(stream_ctx);
|
|
||||||
avformat_close_input(&ifmt_ctx);
|
avformat_close_input(&ifmt_ctx);
|
||||||
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
|
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
|
||||||
avio_closep(&ofmt_ctx->pb);
|
avio_close(ofmt_ctx->pb);
|
||||||
avformat_free_context(ofmt_ctx);
|
avformat_free_context(ofmt_ctx);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
@@ -1,224 +0,0 @@
|
|||||||
/*
|
|
||||||
* Video Acceleration API (video encoding) encode sample
|
|
||||||
*
|
|
||||||
* 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 VAAPI-accelerated encoding example.
|
|
||||||
*
|
|
||||||
* @example vaapi_encode.c
|
|
||||||
* This example shows how to do VAAPI-accelerated encoding. now only support NV12
|
|
||||||
* raw file, usage like: vaapi_encode 1920 1080 input.yuv output.h264
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavutil/pixdesc.h>
|
|
||||||
#include <libavutil/hwcontext.h>
|
|
||||||
|
|
||||||
static int width, height;
|
|
||||||
static AVBufferRef *hw_device_ctx = NULL;
|
|
||||||
|
|
||||||
static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx)
|
|
||||||
{
|
|
||||||
AVBufferRef *hw_frames_ref;
|
|
||||||
AVHWFramesContext *frames_ctx = NULL;
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if (!(hw_frames_ref = av_hwframe_ctx_alloc(hw_device_ctx))) {
|
|
||||||
fprintf(stderr, "Failed to create VAAPI frame context.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
frames_ctx = (AVHWFramesContext *)(hw_frames_ref->data);
|
|
||||||
frames_ctx->format = AV_PIX_FMT_VAAPI;
|
|
||||||
frames_ctx->sw_format = AV_PIX_FMT_NV12;
|
|
||||||
frames_ctx->width = width;
|
|
||||||
frames_ctx->height = height;
|
|
||||||
frames_ctx->initial_pool_size = 20;
|
|
||||||
if ((err = av_hwframe_ctx_init(hw_frames_ref)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to initialize VAAPI frame context."
|
|
||||||
"Error code: %s\n",av_err2str(err));
|
|
||||||
av_buffer_unref(&hw_frames_ref);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ref);
|
|
||||||
if (!ctx->hw_frames_ctx)
|
|
||||||
err = AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
av_buffer_unref(&hw_frames_ref);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
AVPacket *enc_pkt;
|
|
||||||
|
|
||||||
if (!(enc_pkt = av_packet_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
if ((ret = avcodec_send_frame(avctx, frame)) < 0) {
|
|
||||||
fprintf(stderr, "Error code: %s\n", av_err2str(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
while (1) {
|
|
||||||
ret = avcodec_receive_packet(avctx, enc_pkt);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
|
|
||||||
enc_pkt->stream_index = 0;
|
|
||||||
ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout);
|
|
||||||
av_packet_unref(enc_pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
end:
|
|
||||||
av_packet_free(&enc_pkt);
|
|
||||||
ret = ((ret == AVERROR(EAGAIN)) ? 0 : -1);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int size, err;
|
|
||||||
FILE *fin = NULL, *fout = NULL;
|
|
||||||
AVFrame *sw_frame = NULL, *hw_frame = NULL;
|
|
||||||
AVCodecContext *avctx = NULL;
|
|
||||||
const AVCodec *codec = NULL;
|
|
||||||
const char *enc_name = "h264_vaapi";
|
|
||||||
|
|
||||||
if (argc < 5) {
|
|
||||||
fprintf(stderr, "Usage: %s <width> <height> <input file> <output file>\n", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
width = atoi(argv[1]);
|
|
||||||
height = atoi(argv[2]);
|
|
||||||
size = width * height;
|
|
||||||
|
|
||||||
if (!(fin = fopen(argv[3], "r"))) {
|
|
||||||
fprintf(stderr, "Fail to open input file : %s\n", strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!(fout = fopen(argv[4], "w+b"))) {
|
|
||||||
fprintf(stderr, "Fail to open output file : %s\n", strerror(errno));
|
|
||||||
err = -1;
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
|
|
||||||
NULL, NULL, 0);
|
|
||||||
if (err < 0) {
|
|
||||||
fprintf(stderr, "Failed to create a VAAPI device. Error code: %s\n", av_err2str(err));
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(codec = avcodec_find_encoder_by_name(enc_name))) {
|
|
||||||
fprintf(stderr, "Could not find encoder.\n");
|
|
||||||
err = -1;
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(avctx = avcodec_alloc_context3(codec))) {
|
|
||||||
err = AVERROR(ENOMEM);
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
avctx->width = width;
|
|
||||||
avctx->height = height;
|
|
||||||
avctx->time_base = (AVRational){1, 25};
|
|
||||||
avctx->framerate = (AVRational){25, 1};
|
|
||||||
avctx->sample_aspect_ratio = (AVRational){1, 1};
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_VAAPI;
|
|
||||||
|
|
||||||
/* set hw_frames_ctx for encoder's AVCodecContext */
|
|
||||||
if ((err = set_hwframe_ctx(avctx, hw_device_ctx)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to set hwframe context.\n");
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((err = avcodec_open2(avctx, codec, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Cannot open video encoder codec. Error code: %s\n", av_err2str(err));
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if (!(sw_frame = av_frame_alloc())) {
|
|
||||||
err = AVERROR(ENOMEM);
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
/* read data into software frame, and transfer them into hw frame */
|
|
||||||
sw_frame->width = width;
|
|
||||||
sw_frame->height = height;
|
|
||||||
sw_frame->format = AV_PIX_FMT_NV12;
|
|
||||||
if ((err = av_frame_get_buffer(sw_frame, 0)) < 0)
|
|
||||||
goto close;
|
|
||||||
if ((err = fread((uint8_t*)(sw_frame->data[0]), size, 1, fin)) <= 0)
|
|
||||||
break;
|
|
||||||
if ((err = fread((uint8_t*)(sw_frame->data[1]), size/2, 1, fin)) <= 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!(hw_frame = av_frame_alloc())) {
|
|
||||||
err = AVERROR(ENOMEM);
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
if ((err = av_hwframe_get_buffer(avctx->hw_frames_ctx, hw_frame, 0)) < 0) {
|
|
||||||
fprintf(stderr, "Error code: %s.\n", av_err2str(err));
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
if (!hw_frame->hw_frames_ctx) {
|
|
||||||
err = AVERROR(ENOMEM);
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
if ((err = av_hwframe_transfer_data(hw_frame, sw_frame, 0)) < 0) {
|
|
||||||
fprintf(stderr, "Error while transferring frame data to surface."
|
|
||||||
"Error code: %s.\n", av_err2str(err));
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((err = (encode_write(avctx, hw_frame, fout))) < 0) {
|
|
||||||
fprintf(stderr, "Failed to encode.\n");
|
|
||||||
goto close;
|
|
||||||
}
|
|
||||||
av_frame_free(&hw_frame);
|
|
||||||
av_frame_free(&sw_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush encoder */
|
|
||||||
err = encode_write(avctx, NULL, fout);
|
|
||||||
if (err == AVERROR_EOF)
|
|
||||||
err = 0;
|
|
||||||
|
|
||||||
close:
|
|
||||||
if (fin)
|
|
||||||
fclose(fin);
|
|
||||||
if (fout)
|
|
||||||
fclose(fout);
|
|
||||||
av_frame_free(&sw_frame);
|
|
||||||
av_frame_free(&hw_frame);
|
|
||||||
avcodec_free_context(&avctx);
|
|
||||||
av_buffer_unref(&hw_device_ctx);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
@@ -1,308 +0,0 @@
|
|||||||
/*
|
|
||||||
* Video Acceleration API (video transcoding) transcode sample
|
|
||||||
*
|
|
||||||
* 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 VAAPI-accelerated transcoding example.
|
|
||||||
*
|
|
||||||
* @example vaapi_transcode.c
|
|
||||||
* This example shows how to do VAAPI-accelerated transcoding.
|
|
||||||
* Usage: vaapi_transcode input_stream codec output_stream
|
|
||||||
* e.g: - vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
|
|
||||||
* - vaapi_transcode input.mp4 vp9_vaapi output_vp9.ivf
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <libavutil/hwcontext.h>
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
|
|
||||||
static AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
|
|
||||||
static AVBufferRef *hw_device_ctx = NULL;
|
|
||||||
static AVCodecContext *decoder_ctx = NULL, *encoder_ctx = NULL;
|
|
||||||
static int video_stream = -1;
|
|
||||||
static AVStream *ost;
|
|
||||||
static int initialized = 0;
|
|
||||||
|
|
||||||
static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
|
|
||||||
const enum AVPixelFormat *pix_fmts)
|
|
||||||
{
|
|
||||||
const enum AVPixelFormat *p;
|
|
||||||
|
|
||||||
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
|
|
||||||
if (*p == AV_PIX_FMT_VAAPI)
|
|
||||||
return *p;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "Unable to decode this file using VA-API.\n");
|
|
||||||
return AV_PIX_FMT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_input_file(const char *filename)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
const AVCodec *decoder = NULL;
|
|
||||||
AVStream *video = NULL;
|
|
||||||
|
|
||||||
if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Cannot open input file '%s', Error code: %s\n",
|
|
||||||
filename, av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Cannot find input stream information. Error code: %s\n",
|
|
||||||
av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_find_best_stream(ifmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &decoder, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Cannot find a video stream in the input file. "
|
|
||||||
"Error code: %s\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
video_stream = ret;
|
|
||||||
|
|
||||||
if (!(decoder_ctx = avcodec_alloc_context3(decoder)))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
video = ifmt_ctx->streams[video_stream];
|
|
||||||
if ((ret = avcodec_parameters_to_context(decoder_ctx, video->codecpar)) < 0) {
|
|
||||||
fprintf(stderr, "avcodec_parameters_to_context error. Error code: %s\n",
|
|
||||||
av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
decoder_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
|
|
||||||
if (!decoder_ctx->hw_device_ctx) {
|
|
||||||
fprintf(stderr, "A hardware device reference create failed.\n");
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
decoder_ctx->get_format = get_vaapi_format;
|
|
||||||
|
|
||||||
if ((ret = avcodec_open2(decoder_ctx, decoder, NULL)) < 0)
|
|
||||||
fprintf(stderr, "Failed to open codec for decoding. Error code: %s\n",
|
|
||||||
av_err2str(ret));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int encode_write(AVPacket *enc_pkt, AVFrame *frame)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
av_packet_unref(enc_pkt);
|
|
||||||
|
|
||||||
if ((ret = avcodec_send_frame(encoder_ctx, frame)) < 0) {
|
|
||||||
fprintf(stderr, "Error during encoding. Error code: %s\n", av_err2str(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
while (1) {
|
|
||||||
ret = avcodec_receive_packet(encoder_ctx, enc_pkt);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
|
|
||||||
enc_pkt->stream_index = 0;
|
|
||||||
av_packet_rescale_ts(enc_pkt, ifmt_ctx->streams[video_stream]->time_base,
|
|
||||||
ofmt_ctx->streams[0]->time_base);
|
|
||||||
ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during writing data to output file. "
|
|
||||||
"Error code: %s\n", av_err2str(ret));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (ret == AVERROR_EOF)
|
|
||||||
return 0;
|
|
||||||
ret = ((ret == AVERROR(EAGAIN)) ? 0:-1);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dec_enc(AVPacket *pkt, const AVCodec *enc_codec)
|
|
||||||
{
|
|
||||||
AVFrame *frame;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
ret = avcodec_send_packet(decoder_ctx, pkt);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error during decoding. Error code: %s\n", av_err2str(ret));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ret >= 0) {
|
|
||||||
if (!(frame = av_frame_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ret = avcodec_receive_frame(decoder_ctx, frame);
|
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
|
||||||
av_frame_free(&frame);
|
|
||||||
return 0;
|
|
||||||
} else if (ret < 0) {
|
|
||||||
fprintf(stderr, "Error while decoding. Error code: %s\n", av_err2str(ret));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!initialized) {
|
|
||||||
/* we need to ref hw_frames_ctx of decoder to initialize encoder's codec.
|
|
||||||
Only after we get a decoded frame, can we obtain its hw_frames_ctx */
|
|
||||||
encoder_ctx->hw_frames_ctx = av_buffer_ref(decoder_ctx->hw_frames_ctx);
|
|
||||||
if (!encoder_ctx->hw_frames_ctx) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
/* set AVCodecContext Parameters for encoder, here we keep them stay
|
|
||||||
* the same as decoder.
|
|
||||||
* xxx: now the sample can't handle resolution change case.
|
|
||||||
*/
|
|
||||||
encoder_ctx->time_base = av_inv_q(decoder_ctx->framerate);
|
|
||||||
encoder_ctx->pix_fmt = AV_PIX_FMT_VAAPI;
|
|
||||||
encoder_ctx->width = decoder_ctx->width;
|
|
||||||
encoder_ctx->height = decoder_ctx->height;
|
|
||||||
|
|
||||||
if ((ret = avcodec_open2(encoder_ctx, enc_codec, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Failed to open encode codec. Error code: %s\n",
|
|
||||||
av_err2str(ret));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ost = avformat_new_stream(ofmt_ctx, enc_codec))) {
|
|
||||||
fprintf(stderr, "Failed to allocate stream for output format.\n");
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
ost->time_base = encoder_ctx->time_base;
|
|
||||||
ret = avcodec_parameters_from_context(ost->codecpar, encoder_ctx);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Failed to copy the stream parameters. "
|
|
||||||
"Error code: %s\n", av_err2str(ret));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write the stream header */
|
|
||||||
if ((ret = avformat_write_header(ofmt_ctx, NULL)) < 0) {
|
|
||||||
fprintf(stderr, "Error while writing stream header. "
|
|
||||||
"Error code: %s\n", av_err2str(ret));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = encode_write(pkt, frame)) < 0)
|
|
||||||
fprintf(stderr, "Error during encoding and writing.\n");
|
|
||||||
|
|
||||||
fail:
|
|
||||||
av_frame_free(&frame);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
const AVCodec *enc_codec;
|
|
||||||
int ret = 0;
|
|
||||||
AVPacket *dec_pkt;
|
|
||||||
|
|
||||||
if (argc != 4) {
|
|
||||||
fprintf(stderr, "Usage: %s <input file> <encode codec> <output file>\n"
|
|
||||||
"The output format is guessed according to the file extension.\n"
|
|
||||||
"\n", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, NULL, NULL, 0);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Failed to create a VAAPI device. Error code: %s\n", av_err2str(ret));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dec_pkt = av_packet_alloc();
|
|
||||||
if (!dec_pkt) {
|
|
||||||
fprintf(stderr, "Failed to allocate decode packet\n");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = open_input_file(argv[1])) < 0)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
if (!(enc_codec = avcodec_find_encoder_by_name(argv[2]))) {
|
|
||||||
fprintf(stderr, "Could not find encoder '%s'\n", argv[2]);
|
|
||||||
ret = -1;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = (avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, argv[3]))) < 0) {
|
|
||||||
fprintf(stderr, "Failed to deduce output format from file extension. Error code: "
|
|
||||||
"%s\n", av_err2str(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(encoder_ctx = avcodec_alloc_context3(enc_codec))) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = avio_open(&ofmt_ctx->pb, argv[3], AVIO_FLAG_WRITE);
|
|
||||||
if (ret < 0) {
|
|
||||||
fprintf(stderr, "Cannot open output file. "
|
|
||||||
"Error code: %s\n", av_err2str(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* read all packets and only transcoding video */
|
|
||||||
while (ret >= 0) {
|
|
||||||
if ((ret = av_read_frame(ifmt_ctx, dec_pkt)) < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (video_stream == dec_pkt->stream_index)
|
|
||||||
ret = dec_enc(dec_pkt, enc_codec);
|
|
||||||
|
|
||||||
av_packet_unref(dec_pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flush decoder */
|
|
||||||
av_packet_unref(dec_pkt);
|
|
||||||
ret = dec_enc(dec_pkt, enc_codec);
|
|
||||||
|
|
||||||
/* flush encoder */
|
|
||||||
ret = encode_write(dec_pkt, NULL);
|
|
||||||
|
|
||||||
/* write the trailer for output stream */
|
|
||||||
av_write_trailer(ofmt_ctx);
|
|
||||||
|
|
||||||
end:
|
|
||||||
avformat_close_input(&ifmt_ctx);
|
|
||||||
avformat_close_input(&ofmt_ctx);
|
|
||||||
avcodec_free_context(&decoder_ctx);
|
|
||||||
avcodec_free_context(&encoder_ctx);
|
|
||||||
av_buffer_unref(&hw_device_ctx);
|
|
||||||
av_packet_free(&dec_pkt);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
184
doc/faq.texi
184
doc/faq.texi
@@ -1,5 +1,4 @@
|
|||||||
\input texinfo @c -*- texinfo -*-
|
\input texinfo @c -*- texinfo -*-
|
||||||
@documentencoding UTF-8
|
|
||||||
|
|
||||||
@settitle FFmpeg FAQ
|
@settitle FFmpeg FAQ
|
||||||
@titlepage
|
@titlepage
|
||||||
@@ -76,7 +75,7 @@ the gcc developers. Note that we will not add workarounds for gcc bugs.
|
|||||||
|
|
||||||
Also note that (some of) the gcc developers believe this is not a bug or
|
Also note that (some of) the gcc developers believe this is not a bug or
|
||||||
not a bug they should fix:
|
not a bug they should fix:
|
||||||
@url{https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203}.
|
@url{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203}.
|
||||||
Then again, some of them do not know the difference between an undecidable
|
Then again, some of them do not know the difference between an undecidable
|
||||||
problem and an NP-hard problem...
|
problem and an NP-hard problem...
|
||||||
|
|
||||||
@@ -91,63 +90,13 @@ To build FFmpeg, you need to install the development package. It is usually
|
|||||||
called @file{libfoo-dev} or @file{libfoo-devel}. You can remove it after the
|
called @file{libfoo-dev} or @file{libfoo-devel}. You can remove it after the
|
||||||
build is finished, but be sure to keep the main package.
|
build is finished, but be sure to keep the main package.
|
||||||
|
|
||||||
@section How do I make @command{pkg-config} find my libraries?
|
|
||||||
|
|
||||||
Somewhere along with your libraries, there is a @file{.pc} file (or several)
|
|
||||||
in a @file{pkgconfig} directory. You need to set environment variables to
|
|
||||||
point @command{pkg-config} to these files.
|
|
||||||
|
|
||||||
If you need to @emph{add} directories to @command{pkg-config}'s search list
|
|
||||||
(typical use case: library installed separately), add it to
|
|
||||||
@code{$PKG_CONFIG_PATH}:
|
|
||||||
|
|
||||||
@example
|
|
||||||
export PKG_CONFIG_PATH=/opt/x264/lib/pkgconfig:/opt/opus/lib/pkgconfig
|
|
||||||
@end example
|
|
||||||
|
|
||||||
If you need to @emph{replace} @command{pkg-config}'s search list
|
|
||||||
(typical use case: cross-compiling), set it in
|
|
||||||
@code{$PKG_CONFIG_LIBDIR}:
|
|
||||||
|
|
||||||
@example
|
|
||||||
export PKG_CONFIG_LIBDIR=/home/me/cross/usr/lib/pkgconfig:/home/me/cross/usr/local/lib/pkgconfig
|
|
||||||
@end example
|
|
||||||
|
|
||||||
If you need to know the library's internal dependencies (typical use: static
|
|
||||||
linking), add the @code{--static} option to @command{pkg-config}:
|
|
||||||
|
|
||||||
@example
|
|
||||||
./configure --pkg-config-flags=--static
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section How do I use @command{pkg-config} when cross-compiling?
|
|
||||||
|
|
||||||
The best way is to install @command{pkg-config} in your cross-compilation
|
|
||||||
environment. It will automatically use the cross-compilation libraries.
|
|
||||||
|
|
||||||
You can also use @command{pkg-config} from the host environment by
|
|
||||||
specifying explicitly @code{--pkg-config=pkg-config} to @command{configure}.
|
|
||||||
In that case, you must point @command{pkg-config} to the correct directories
|
|
||||||
using the @code{PKG_CONFIG_LIBDIR}, as explained in the previous entry.
|
|
||||||
|
|
||||||
As an intermediate solution, you can place in your cross-compilation
|
|
||||||
environment a script that calls the host @command{pkg-config} with
|
|
||||||
@code{PKG_CONFIG_LIBDIR} set. That script can look like that:
|
|
||||||
|
|
||||||
@example
|
|
||||||
#!/bin/sh
|
|
||||||
PKG_CONFIG_LIBDIR=/path/to/cross/lib/pkgconfig
|
|
||||||
export PKG_CONFIG_LIBDIR
|
|
||||||
exec /usr/bin/pkg-config "$@@"
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@chapter Usage
|
@chapter Usage
|
||||||
|
|
||||||
@section ffmpeg does not work; what is wrong?
|
@section ffmpeg does not work; what is wrong?
|
||||||
|
|
||||||
Try a @code{make distclean} in the ffmpeg source directory before the build.
|
Try a @code{make distclean} in the ffmpeg source directory before the build.
|
||||||
If this does not help see
|
If this does not help see
|
||||||
(@url{https://ffmpeg.org/bugreports.html}).
|
(@url{http://ffmpeg.org/bugreports.html}).
|
||||||
|
|
||||||
@section How do I encode single pictures into movies?
|
@section How do I encode single pictures into movies?
|
||||||
|
|
||||||
@@ -257,13 +206,13 @@ default.
|
|||||||
@section Which are good parameters for encoding high quality MPEG-4?
|
@section Which are good parameters for encoding high quality MPEG-4?
|
||||||
|
|
||||||
'-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2',
|
'-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2',
|
||||||
things to try: '-bf 2', '-mpv_flags qp_rd', '-mpv_flags mv0', '-mpv_flags skip_rd'.
|
things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd'.
|
||||||
|
|
||||||
@section Which are good parameters for encoding high quality MPEG-1/MPEG-2?
|
@section Which are good parameters for encoding high quality MPEG-1/MPEG-2?
|
||||||
|
|
||||||
'-mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2'
|
'-mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2'
|
||||||
but beware the '-g 100' might cause problems with some decoders.
|
but beware the '-g 100' might cause problems with some decoders.
|
||||||
Things to try: '-bf 2', '-mpv_flags qp_rd', '-mpv_flags mv0', '-mpv_flags skip_rd'.
|
Things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd.
|
||||||
|
|
||||||
@section Interlaced video looks very bad when encoded with ffmpeg, what is wrong?
|
@section Interlaced video looks very bad when encoded with ffmpeg, what is wrong?
|
||||||
|
|
||||||
@@ -311,18 +260,18 @@ invoking ffmpeg with several @option{-i} options.
|
|||||||
For audio, to put all channels together in a single stream (example: two
|
For audio, to put all channels together in a single stream (example: two
|
||||||
mono streams into one stereo stream): this is sometimes called to
|
mono streams into one stereo stream): this is sometimes called to
|
||||||
@emph{merge} them, and can be done using the
|
@emph{merge} them, and can be done using the
|
||||||
@url{ffmpeg-filters.html#amerge, @code{amerge}} filter.
|
@url{http://ffmpeg.org/ffmpeg-filters.html#amerge, @code{amerge}} filter.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
For audio, to play one on top of the other: this is called to @emph{mix}
|
For audio, to play one on top of the other: this is called to @emph{mix}
|
||||||
them, and can be done by first merging them into a single stream and then
|
them, and can be done by first merging them into a single stream and then
|
||||||
using the @url{ffmpeg-filters.html#pan, @code{pan}} filter to mix
|
using the @url{http://ffmpeg.org/ffmpeg-filters.html#pan, @code{pan}} filter to mix
|
||||||
the channels at will.
|
the channels at will.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
For video, to display both together, side by side or one on top of a part of
|
For video, to display both together, side by side or one on top of a part of
|
||||||
the other; it can be done using the
|
the other; it can be done using the
|
||||||
@url{ffmpeg-filters.html#overlay, @code{overlay}} video filter.
|
@url{http://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video filter.
|
||||||
|
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@@ -333,23 +282,23 @@ There are several solutions, depending on the exact circumstances.
|
|||||||
|
|
||||||
@subsection Concatenating using the concat @emph{filter}
|
@subsection Concatenating using the concat @emph{filter}
|
||||||
|
|
||||||
FFmpeg has a @url{ffmpeg-filters.html#concat,
|
FFmpeg has a @url{http://ffmpeg.org/ffmpeg-filters.html#concat,
|
||||||
@code{concat}} filter designed specifically for that, with examples in the
|
@code{concat}} filter designed specifically for that, with examples in the
|
||||||
documentation. This operation is recommended if you need to re-encode.
|
documentation. This operation is recommended if you need to re-encode.
|
||||||
|
|
||||||
@subsection Concatenating using the concat @emph{demuxer}
|
@subsection Concatenating using the concat @emph{demuxer}
|
||||||
|
|
||||||
FFmpeg has a @url{ffmpeg-formats.html#concat,
|
FFmpeg has a @url{http://www.ffmpeg.org/ffmpeg-formats.html#concat,
|
||||||
@code{concat}} demuxer which you can use when you want to avoid a re-encode and
|
@code{concat}} demuxer which you can use when you want to avoid a re-encode and
|
||||||
your format doesn't support file level concatenation.
|
your format doesn't support file level concatenation.
|
||||||
|
|
||||||
@subsection Concatenating using the concat @emph{protocol} (file level)
|
@subsection Concatenating using the concat @emph{protocol} (file level)
|
||||||
|
|
||||||
FFmpeg has a @url{ffmpeg-protocols.html#concat,
|
FFmpeg has a @url{http://ffmpeg.org/ffmpeg-protocols.html#concat,
|
||||||
@code{concat}} protocol designed specifically for that, with examples in the
|
@code{concat}} protocol designed specifically for that, with examples in the
|
||||||
documentation.
|
documentation.
|
||||||
|
|
||||||
A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow one to concatenate
|
A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow to concatenate
|
||||||
video by merely concatenating the files containing them.
|
video by merely concatenating the files containing them.
|
||||||
|
|
||||||
Hence you may concatenate your multimedia files by first transcoding them to
|
Hence you may concatenate your multimedia files by first transcoding them to
|
||||||
@@ -385,7 +334,7 @@ mkfifo intermediate2.mpg
|
|||||||
ffmpeg -i input1.avi -qscale:v 1 -y intermediate1.mpg < /dev/null &
|
ffmpeg -i input1.avi -qscale:v 1 -y intermediate1.mpg < /dev/null &
|
||||||
ffmpeg -i input2.avi -qscale:v 1 -y intermediate2.mpg < /dev/null &
|
ffmpeg -i input2.avi -qscale:v 1 -y intermediate2.mpg < /dev/null &
|
||||||
cat intermediate1.mpg intermediate2.mpg |\
|
cat intermediate1.mpg intermediate2.mpg |\
|
||||||
ffmpeg -f mpeg -i - -c:v mpeg4 -c:a libmp3lame output.avi
|
ffmpeg -f mpeg -i - -c:v mpeg4 -acodec libmp3lame output.avi
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@subsection Concatenating using raw audio and video
|
@subsection Concatenating using raw audio and video
|
||||||
@@ -407,13 +356,13 @@ mkfifo temp2.a
|
|||||||
mkfifo temp2.v
|
mkfifo temp2.v
|
||||||
mkfifo all.a
|
mkfifo all.a
|
||||||
mkfifo all.v
|
mkfifo all.v
|
||||||
ffmpeg -i input1.flv -vn -f u16le -c:a pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
|
ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
|
||||||
ffmpeg -i input2.flv -vn -f u16le -c:a pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
|
ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
|
||||||
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
|
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
|
||||||
@{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; @} &
|
@{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; @} &
|
||||||
cat temp1.a temp2.a > all.a &
|
cat temp1.a temp2.a > all.a &
|
||||||
cat temp1.v temp2.v > all.v &
|
cat temp1.v temp2.v > all.v &
|
||||||
ffmpeg -f u16le -c:a pcm_s16le -ac 2 -ar 44100 -i all.a \
|
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
|
||||||
-f yuv4mpegpipe -i all.v \
|
-f yuv4mpegpipe -i all.v \
|
||||||
-y output.flv
|
-y output.flv
|
||||||
rm temp[12].[av] all.[av]
|
rm temp[12].[av] all.[av]
|
||||||
@@ -467,105 +416,6 @@ point acceptable for your tastes. The most common options to do that are
|
|||||||
@option{-qscale} and @option{-qmax}, but you should peruse the documentation
|
@option{-qscale} and @option{-qmax}, but you should peruse the documentation
|
||||||
of the encoder you chose.
|
of the encoder you chose.
|
||||||
|
|
||||||
@section I have a stretched video, why does scaling does not fix it?
|
|
||||||
|
|
||||||
A lot of video codecs and formats can store the @emph{aspect ratio} of the
|
|
||||||
video: this is the ratio between the width and the height of either the full
|
|
||||||
image (DAR, display aspect ratio) or individual pixels (SAR, sample aspect
|
|
||||||
ratio). For example, EGA screens at resolution 640×350 had 4:3 DAR and 35:48
|
|
||||||
SAR.
|
|
||||||
|
|
||||||
Most still image processing work with square pixels, i.e. 1:1 SAR, but a lot
|
|
||||||
of video standards, especially from the analogic-numeric transition era, use
|
|
||||||
non-square pixels.
|
|
||||||
|
|
||||||
Most processing filters in FFmpeg handle the aspect ratio to avoid
|
|
||||||
stretching the image: cropping adjusts the DAR to keep the SAR constant,
|
|
||||||
scaling adjusts the SAR to keep the DAR constant.
|
|
||||||
|
|
||||||
If you want to stretch, or “unstretch”, the image, you need to override the
|
|
||||||
information with the
|
|
||||||
@url{ffmpeg-filters.html#setdar_002c-setsar, @code{setdar or setsar filters}}.
|
|
||||||
|
|
||||||
Do not forget to examine carefully the original video to check whether the
|
|
||||||
stretching comes from the image or from the aspect ratio information.
|
|
||||||
|
|
||||||
For example, to fix a badly encoded EGA capture, use the following commands,
|
|
||||||
either the first one to upscale to square pixels or the second one to set
|
|
||||||
the correct aspect ratio or the third one to avoid transcoding (may not work
|
|
||||||
depending on the format / codec / player / phase of the moon):
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i ega_screen.nut -vf scale=640:480,setsar=1 ega_screen_scaled.nut
|
|
||||||
ffmpeg -i ega_screen.nut -vf setdar=4/3 ega_screen_anamorphic.nut
|
|
||||||
ffmpeg -i ega_screen.nut -aspect 4/3 -c copy ega_screen_overridden.nut
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@anchor{background task}
|
|
||||||
@section How do I run ffmpeg as a background task?
|
|
||||||
|
|
||||||
ffmpeg normally checks the console input, for entries like "q" to stop
|
|
||||||
and "?" to give help, while performing operations. ffmpeg does not have a way of
|
|
||||||
detecting when it is running as a background task.
|
|
||||||
When it checks the console input, that can cause the process running ffmpeg
|
|
||||||
in the background to suspend.
|
|
||||||
|
|
||||||
To prevent those input checks, allowing ffmpeg to run as a background task,
|
|
||||||
use the @url{ffmpeg.html#stdin-option, @code{-nostdin} option}
|
|
||||||
in the ffmpeg invocation. This is effective whether you run ffmpeg in a shell
|
|
||||||
or invoke ffmpeg in its own process via an operating system API.
|
|
||||||
|
|
||||||
As an alternative, when you are running ffmpeg in a shell, you can redirect
|
|
||||||
standard input to @code{/dev/null} (on Linux and macOS)
|
|
||||||
or @code{NUL} (on Windows). You can do this redirect either
|
|
||||||
on the ffmpeg invocation, or from a shell script which calls ffmpeg.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -nostdin -i INPUT OUTPUT
|
|
||||||
@end example
|
|
||||||
|
|
||||||
or (on Linux, macOS, and other UNIX-like shells):
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT OUTPUT </dev/null
|
|
||||||
@end example
|
|
||||||
|
|
||||||
or (on Windows):
|
|
||||||
|
|
||||||
@example
|
|
||||||
ffmpeg -i INPUT OUTPUT <NUL
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@section How do I prevent ffmpeg from suspending with a message like @emph{suspended (tty output)}?
|
|
||||||
|
|
||||||
If you run ffmpeg in the background, you may find that its process suspends.
|
|
||||||
There may be a message like @emph{suspended (tty output)}. The question is how
|
|
||||||
to prevent the process from being suspended.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
@example
|
|
||||||
% ffmpeg -i INPUT OUTPUT &> ~/tmp/log.txt &
|
|
||||||
[1] 93352
|
|
||||||
%
|
|
||||||
[1] + suspended (tty output) ffmpeg -i INPUT OUTPUT &>
|
|
||||||
@end example
|
|
||||||
|
|
||||||
The message "tty output" notwithstanding, the problem here is that
|
|
||||||
ffmpeg normally checks the console input when it runs. The operating system
|
|
||||||
detects this, and suspends the process until you can bring it to the
|
|
||||||
foreground and attend to it.
|
|
||||||
|
|
||||||
The solution is to use the right techniques to tell ffmpeg not to consult
|
|
||||||
console input. You can use the
|
|
||||||
@url{ffmpeg.html#stdin-option, @code{-nostdin} option},
|
|
||||||
or redirect standard input with @code{< /dev/null}.
|
|
||||||
See FAQ
|
|
||||||
@ref{background task, @emph{How do I run ffmpeg as a background task?}}
|
|
||||||
for details.
|
|
||||||
|
|
||||||
@chapter Development
|
@chapter Development
|
||||||
|
|
||||||
@section Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat?
|
@section Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat?
|
||||||
@@ -601,7 +451,7 @@ No. These tools are too bloated and they complicate the build.
|
|||||||
FFmpeg is already organized in a highly modular manner and does not need to
|
FFmpeg is already organized in a highly modular manner and does not need to
|
||||||
be rewritten in a formal object language. Further, many of the developers
|
be rewritten in a formal object language. Further, many of the developers
|
||||||
favor straight C; it works for them. For more arguments on this matter,
|
favor straight C; it works for them. For more arguments on this matter,
|
||||||
read @uref{https://web.archive.org/web/20111004021423/http://kernel.org/pub/linux/docs/lkml/#s15, "Programming Religion"}.
|
read @uref{http://www.tux.org/lkml/#s15, "Programming Religion"}.
|
||||||
|
|
||||||
@section Why are the ffmpeg programs devoid of debugging symbols?
|
@section Why are the ffmpeg programs devoid of debugging symbols?
|
||||||
|
|
||||||
@@ -654,7 +504,7 @@ see @file{libavformat/aviobuf.c} in FFmpeg and @file{libmpdemux/demux_lavf.c} in
|
|||||||
|
|
||||||
@section Where is the documentation about ffv1, msmpeg4, asv1, 4xm?
|
@section Where is the documentation about ffv1, msmpeg4, asv1, 4xm?
|
||||||
|
|
||||||
see @url{https://www.ffmpeg.org/~michael/}
|
see @url{http://www.ffmpeg.org/~michael/}
|
||||||
|
|
||||||
@section How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?
|
@section How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?
|
||||||
|
|
||||||
|
|||||||
116
doc/fate.texi
116
doc/fate.texi
@@ -1,5 +1,4 @@
|
|||||||
\input texinfo @c -*- texinfo -*-
|
\input texinfo @c -*- texinfo -*-
|
||||||
@documentencoding UTF-8
|
|
||||||
|
|
||||||
@settitle FFmpeg Automated Testing Environment
|
@settitle FFmpeg Automated Testing Environment
|
||||||
@titlepage
|
@titlepage
|
||||||
@@ -13,36 +12,36 @@
|
|||||||
|
|
||||||
@chapter Introduction
|
@chapter Introduction
|
||||||
|
|
||||||
FATE is an extended regression suite on the client-side and a means
|
FATE is an extended regression suite on the client-side and a means
|
||||||
for results aggregation and presentation on the server-side.
|
for results aggregation and presentation on the server-side.
|
||||||
|
|
||||||
The first part of this document explains how you can use FATE from
|
The first part of this document explains how you can use FATE from
|
||||||
your FFmpeg source directory to test your ffmpeg binary. The second
|
your FFmpeg source directory to test your ffmpeg binary. The second
|
||||||
part describes how you can run FATE to submit the results to FFmpeg's
|
part describes how you can run FATE to submit the results to FFmpeg's
|
||||||
FATE server.
|
FATE server.
|
||||||
|
|
||||||
In any way you can have a look at the publicly viewable FATE results
|
In any way you can have a look at the publicly viewable FATE results
|
||||||
by visiting this website:
|
by visiting this website:
|
||||||
|
|
||||||
@url{http://fate.ffmpeg.org/}
|
@url{http://fate.ffmpeg.org/}
|
||||||
|
|
||||||
This is especially recommended for all people contributing source
|
This is especially recommended for all people contributing source
|
||||||
code to FFmpeg, as it can be seen if some test on some platform broke
|
code to FFmpeg, as it can be seen if some test on some platform broke
|
||||||
with their recent contribution. This usually happens on the platforms
|
with their recent contribution. This usually happens on the platforms
|
||||||
the developers could not test on.
|
the developers could not test on.
|
||||||
|
|
||||||
The second part of this document describes how you can run FATE to
|
The second part of this document describes how you can run FATE to
|
||||||
submit your results to FFmpeg's FATE server. If you want to submit your
|
submit your results to FFmpeg's FATE server. If you want to submit your
|
||||||
results be sure to check that your combination of CPU, OS and compiler
|
results be sure to check that your combination of CPU, OS and compiler
|
||||||
is not already listed on the above mentioned website.
|
is not already listed on the above mentioned website.
|
||||||
|
|
||||||
In the third part you can find a comprehensive listing of FATE makefile
|
In the third part you can find a comprehensive listing of FATE makefile
|
||||||
targets and variables.
|
targets and variables.
|
||||||
|
|
||||||
|
|
||||||
@chapter Using FATE from your FFmpeg source directory
|
@chapter Using FATE from your FFmpeg source directory
|
||||||
|
|
||||||
If you want to run FATE on your machine you need to have the samples
|
If you want to run FATE on your machine you need to have the samples
|
||||||
in place. You can get the samples via the build target fate-rsync.
|
in place. You can get the samples via the build target fate-rsync.
|
||||||
Use this command from the top-level source directory:
|
Use this command from the top-level source directory:
|
||||||
|
|
||||||
@@ -51,11 +50,11 @@ make fate-rsync SAMPLES=fate-suite/
|
|||||||
make fate SAMPLES=fate-suite/
|
make fate SAMPLES=fate-suite/
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
The above commands set the samples location by passing a makefile
|
The above commands set the samples location by passing a makefile
|
||||||
variable via command line. It is also possible to set the samples
|
variable via command line. It is also possible to set the samples
|
||||||
location at source configuration time by invoking configure with
|
location at source configuration time by invoking configure with
|
||||||
@option{--samples=<path to the samples directory>}. Afterwards you can
|
`--samples=<path to the samples directory>'. Afterwards you can
|
||||||
invoke the makefile targets without setting the @var{SAMPLES} makefile
|
invoke the makefile targets without setting the SAMPLES makefile
|
||||||
variable. This is illustrated by the following commands:
|
variable. This is illustrated by the following commands:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
@@ -64,7 +63,7 @@ make fate-rsync
|
|||||||
make fate
|
make fate
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
Yet another way to tell FATE about the location of the sample
|
Yet another way to tell FATE about the location of the sample
|
||||||
directory is by making sure the environment variable FATE_SAMPLES
|
directory is by making sure the environment variable FATE_SAMPLES
|
||||||
contains the path to your samples directory. This can be achieved
|
contains the path to your samples directory. This can be achieved
|
||||||
by e.g. putting that variable in your shell profile or by setting
|
by e.g. putting that variable in your shell profile or by setting
|
||||||
@@ -79,28 +78,13 @@ Do not put a '~' character in the samples path to indicate a home
|
|||||||
directory. Because of shell nuances, this will cause FATE to fail.
|
directory. Because of shell nuances, this will cause FATE to fail.
|
||||||
@end float
|
@end float
|
||||||
|
|
||||||
To get the complete list of tests, run the command:
|
|
||||||
@example
|
|
||||||
make fate-list
|
|
||||||
@end example
|
|
||||||
|
|
||||||
You can specify a subset of tests to run by specifying the
|
|
||||||
corresponding elements from the list with the @code{fate-} prefix,
|
|
||||||
e.g. as in:
|
|
||||||
@example
|
|
||||||
make fate-ffprobe_compact fate-ffprobe_xml
|
|
||||||
@end example
|
|
||||||
|
|
||||||
This makes it easier to run a few tests in case of failure without
|
|
||||||
running the complete test suite.
|
|
||||||
|
|
||||||
To use a custom wrapper to run the test, pass @option{--target-exec} to
|
To use a custom wrapper to run the test, pass @option{--target-exec} to
|
||||||
@command{configure} or set the @var{TARGET_EXEC} Make variable.
|
@command{configure} or set the @var{TARGET_EXEC} Make variable.
|
||||||
|
|
||||||
|
|
||||||
@chapter Submitting the results to the FFmpeg result aggregation server
|
@chapter Submitting the results to the FFmpeg result aggregation server
|
||||||
|
|
||||||
To submit your results to the server you should run fate through the
|
To submit your results to the server you should run fate through the
|
||||||
shell script @file{tests/fate.sh} from the FFmpeg sources. This script needs
|
shell script @file{tests/fate.sh} from the FFmpeg sources. This script needs
|
||||||
to be invoked with a configuration file as its first argument.
|
to be invoked with a configuration file as its first argument.
|
||||||
|
|
||||||
@@ -108,23 +92,23 @@ to be invoked with a configuration file as its first argument.
|
|||||||
tests/fate.sh /path/to/fate_config
|
tests/fate.sh /path/to/fate_config
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
A configuration file template with comments describing the individual
|
A configuration file template with comments describing the individual
|
||||||
configuration variables can be found at @file{doc/fate_config.sh.template}.
|
configuration variables can be found at @file{doc/fate_config.sh.template}.
|
||||||
|
|
||||||
@ifhtml
|
@ifhtml
|
||||||
The mentioned configuration template is also available here:
|
The mentioned configuration template is also available here:
|
||||||
@verbatiminclude fate_config.sh.template
|
@verbatiminclude fate_config.sh.template
|
||||||
@end ifhtml
|
@end ifhtml
|
||||||
|
|
||||||
Create a configuration that suits your needs, based on the configuration
|
Create a configuration that suits your needs, based on the configuration
|
||||||
template. The @env{slot} configuration variable can be any string that is not
|
template. The `slot' configuration variable can be any string that is not
|
||||||
yet used, but it is suggested that you name it adhering to the following
|
yet used, but it is suggested that you name it adhering to the following
|
||||||
pattern @samp{@var{arch}-@var{os}-@var{compiler}-@var{compiler version}}. The
|
pattern <arch>-<os>-<compiler>-<compiler version>. The configuration file
|
||||||
configuration file itself will be sourced in a shell script, therefore all
|
itself will be sourced in a shell script, therefore all shell features may
|
||||||
shell features may be used. This enables you to setup the environment as you
|
be used. This enables you to setup the environment as you need it for your
|
||||||
need it for your build.
|
build.
|
||||||
|
|
||||||
For your first test runs the @env{fate_recv} variable should be empty or
|
For your first test runs the `fate_recv' variable should be empty or
|
||||||
commented out. This will run everything as normal except that it will omit
|
commented out. This will run everything as normal except that it will omit
|
||||||
the submission of the results to the server. The following files should be
|
the submission of the results to the server. The following files should be
|
||||||
present in $workdir as specified in the configuration file:
|
present in $workdir as specified in the configuration file:
|
||||||
@@ -137,57 +121,31 @@ present in $workdir as specified in the configuration file:
|
|||||||
@item version
|
@item version
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
When you have everything working properly you can create an SSH key pair
|
When you have everything working properly you can create an SSH key pair
|
||||||
and send the public key to the FATE server administrator who can be contacted
|
and send the public key to the FATE server administrator who can be contacted
|
||||||
at the email address @email{fate-admin@@ffmpeg.org}.
|
at the email address @email{fate-admin@@ffmpeg.org}.
|
||||||
|
|
||||||
Configure your SSH client to use public key authentication with that key
|
Configure your SSH client to use public key authentication with that key
|
||||||
when connecting to the FATE server. Also do not forget to check the identity
|
when connecting to the FATE server. Also do not forget to check the identity
|
||||||
of the server and to accept its host key. This can usually be achieved by
|
of the server and to accept its host key. This can usually be achieved by
|
||||||
running your SSH client manually and killing it after you accepted the key.
|
running your SSH client manually and killing it after you accepted the key.
|
||||||
The FATE server's fingerprint is:
|
The FATE server's fingerprint is:
|
||||||
|
|
||||||
@table @samp
|
@table @option
|
||||||
@item RSA
|
@item RSA
|
||||||
d3:f1:83:97:a4:75:2b:a6:fb:d6:e8:aa:81:93:97:51
|
d3:f1:83:97:a4:75:2b:a6:fb:d6:e8:aa:81:93:97:51
|
||||||
@item ECDSA
|
@item ECDSA
|
||||||
76:9f:68:32:04:1e:d5:d4:ec:47:3f:dc:fc:18:17:86
|
76:9f:68:32:04:1e:d5:d4:ec:47:3f:dc:fc:18:17:86
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
If you have problems connecting to the FATE server, it may help to try out
|
If you have problems connecting to the FATE server, it may help to try out
|
||||||
the @command{ssh} command with one or more @option{-v} options. You should
|
the @command{ssh} command with one or more @option{-v} options. You should
|
||||||
get detailed output concerning your SSH configuration and the authentication
|
get detailed output concerning your SSH configuration and the authentication
|
||||||
process.
|
process.
|
||||||
|
|
||||||
The only thing left is to automate the execution of the fate.sh script and
|
The only thing left is to automate the execution of the fate.sh script and
|
||||||
the synchronisation of the samples directory.
|
the synchronisation of the samples directory.
|
||||||
|
|
||||||
@chapter Uploading new samples to the fate suite
|
|
||||||
|
|
||||||
If you need a sample uploaded send a mail to samples-request.
|
|
||||||
|
|
||||||
This is for developers who have an account on the fate suite server.
|
|
||||||
If you upload new samples, please make sure they are as small as possible,
|
|
||||||
space on each client, network bandwidth and so on benefit from smaller test cases.
|
|
||||||
Also keep in mind older checkouts use existing sample files, that means in
|
|
||||||
practice generally do not replace, remove or overwrite files as it likely would
|
|
||||||
break older checkouts or releases.
|
|
||||||
Also all needed samples for a commit should be uploaded, ideally 24
|
|
||||||
hours, before the push.
|
|
||||||
If you need an account for frequently uploading samples or you wish to help
|
|
||||||
others by doing that send a mail to ffmpeg-devel.
|
|
||||||
|
|
||||||
@example
|
|
||||||
#First update your local samples copy:
|
|
||||||
rsync -vauL --chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X fate-suite.ffmpeg.org:/home/samples/fate-suite/ ~/fate-suite
|
|
||||||
|
|
||||||
#Then do a dry run checking what would be uploaded:
|
|
||||||
rsync -vanL --no-g --chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X ~/fate-suite/ fate-suite.ffmpeg.org:/home/samples/fate-suite
|
|
||||||
|
|
||||||
#Upload the files:
|
|
||||||
rsync -vaL --no-g --chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X ~/fate-suite/ fate-suite.ffmpeg.org:/home/samples/fate-suite
|
|
||||||
@end example
|
|
||||||
|
|
||||||
|
|
||||||
@chapter FATE makefile targets and variables
|
@chapter FATE makefile targets and variables
|
||||||
|
|
||||||
@@ -206,7 +164,7 @@ Run the FATE test suite (requires the fate-suite dataset).
|
|||||||
|
|
||||||
@section Makefile variables
|
@section Makefile variables
|
||||||
|
|
||||||
@table @env
|
@table @option
|
||||||
@item V
|
@item V
|
||||||
Verbosity level, can be set to 0, 1 or 2.
|
Verbosity level, can be set to 0, 1 or 2.
|
||||||
@itemize
|
@itemize
|
||||||
@@ -224,30 +182,20 @@ Specify how many threads to use while running regression tests, it is
|
|||||||
quite useful to detect thread-related regressions.
|
quite useful to detect thread-related regressions.
|
||||||
|
|
||||||
@item THREAD_TYPE
|
@item THREAD_TYPE
|
||||||
Specify which threading strategy test, either @samp{slice} or @samp{frame},
|
Specify which threading strategy test, either @var{slice} or @var{frame},
|
||||||
by default @samp{slice+frame}
|
by default @var{slice+frame}
|
||||||
|
|
||||||
@item CPUFLAGS
|
@item CPUFLAGS
|
||||||
Specify CPU flags.
|
Specify CPU flags.
|
||||||
|
|
||||||
@item TARGET_EXEC
|
@item TARGET_EXEC
|
||||||
Specify or override the wrapper used to run the tests.
|
Specify or override the wrapper used to run the tests.
|
||||||
The @env{TARGET_EXEC} option provides a way to run FATE wrapped in
|
The @var{TARGET_EXEC} option provides a way to run FATE wrapped in
|
||||||
@command{valgrind}, @command{qemu-user} or @command{wine} or on remote targets
|
@command{valgrind}, @command{qemu-user} or @command{wine} or on remote targets
|
||||||
through @command{ssh}.
|
through @command{ssh}.
|
||||||
|
|
||||||
@item GEN
|
@item GEN
|
||||||
Set to @samp{1} to generate the missing or mismatched references.
|
Set to @var{1} to generate the missing or mismatched references.
|
||||||
|
|
||||||
@item HWACCEL
|
|
||||||
Specify which hardware acceleration to use while running regression tests,
|
|
||||||
by default @samp{none} is used.
|
|
||||||
|
|
||||||
@item KEEP
|
|
||||||
Set to @samp{1} to keep temp files generated by fate test(s) when test is successful.
|
|
||||||
Default is @samp{0}, which removes these files. Files are always kept when a test
|
|
||||||
fails.
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@section Examples
|
@section Examples
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
slot= # some unique identifier
|
slot= # some unique identifier
|
||||||
repo=git://source.ffmpeg.org/ffmpeg.git # the source repository
|
repo=git://source.ffmpeg.org/ffmpeg.git # the source repository
|
||||||
#branch=release/2.6 # the branch to test
|
|
||||||
samples= # path to samples directory
|
samples= # path to samples directory
|
||||||
workdir= # directory in which to do all the work
|
workdir= # directory in which to do all the work
|
||||||
#fate_recv="ssh -T fate@fate.ffmpeg.org" # command to submit report
|
#fate_recv="ssh -T fate@fate.ffmpeg.org" # command to submit report
|
||||||
comment= # optional description
|
comment= # optional description
|
||||||
build_only= # set to "yes" for a compile-only instance that skips tests
|
build_only= # set to "yes" for a compile-only instance that skips tests
|
||||||
ignore_tests=
|
|
||||||
|
|
||||||
# the following are optional and map to configure options
|
# the following are optional and map to configure options
|
||||||
arch=
|
arch=
|
||||||
@@ -27,7 +25,5 @@ extra_conf= # extra configure options not covered above
|
|||||||
|
|
||||||
#make= # name of GNU make if not 'make'
|
#make= # name of GNU make if not 'make'
|
||||||
makeopts= # extra options passed to 'make'
|
makeopts= # extra options passed to 'make'
|
||||||
#makeopts_fate= # extra options passed to 'make' when running tests,
|
|
||||||
# defaulting to makeopts above if this is not set
|
|
||||||
#tar= # command to create a tar archive from its arguments on stdout,
|
#tar= # command to create a tar archive from its arguments on stdout,
|
||||||
# defaults to 'tar c'
|
# defaults to 'tar c'
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
\input texinfo @c -*- texinfo -*-
|
\input texinfo @c -*- texinfo -*-
|
||||||
@documentencoding UTF-8
|
|
||||||
|
|
||||||
@settitle FFmpeg Bitstream Filters Documentation
|
@settitle FFmpeg Bitstream Filters Documentation
|
||||||
@titlepage
|
@titlepage
|
||||||
@@ -26,12 +25,12 @@ bitstream level modifications without performing decoding.
|
|||||||
@chapter See Also
|
@chapter See Also
|
||||||
|
|
||||||
@ifhtml
|
@ifhtml
|
||||||
@url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
|
@url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe}, @url{ffserver.html,ffserver},
|
||||||
@url{libavcodec.html,libavcodec}
|
@url{libavcodec.html,libavcodec}
|
||||||
@end ifhtml
|
@end ifhtml
|
||||||
|
|
||||||
@ifnothtml
|
@ifnothtml
|
||||||
ffmpeg(1), ffplay(1), ffprobe(1), libavcodec(3)
|
ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavcodec(3)
|
||||||
@end ifnothtml
|
@end ifnothtml
|
||||||
|
|
||||||
@include authors.texi
|
@include authors.texi
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user