Compare commits

..

74 Commits

Author SHA1 Message Date
Michael Niedermayer
c66f4d1ae6 Changelog: Fix minor formating inconsistency
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-28 03:03:39 +02:00
Michael Niedermayer
ad559492dc update for 3.0.2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-28 01:40:54 +02:00
Michael Niedermayer
8d0cfa68b9 avcodec/ttaenc: Reallocate packet if its too small
Fixes assertion failure
Fixes Ticket5394

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 005c61c6b8)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-26 19:49:09 +02:00
Shivraj Patil
83eaaae005 configure: build fix for P5600 with mips code restructuring
Note:- backporting commit 15ef98afd1 from head

Signed-off-by: Shivraj Patil <shivraj.patil@imgtec.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-26 12:27:49 +02:00
Vicente Olivert Riera
a5638dbfba mips: add support for R6
Note:- backporting commit ad16eff64b from head

Understanding the mips32r6 and mips64r6 ISAs in the configure script is
not enough. In order to have full support for MIPS R6 in FFmpeg we need
to be able to build it, and for that we need to make sure we don't use
incompatible assembler code which makes the build fail. Ifdefing the
offending code is sufficient to fix the problem.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-26 12:27:39 +02:00
Jan Ekström
666754c665 pgssubdec: fix subpicture output colorspace and range
Functionality used before didn't widen the values from limited to
full range. Additionally, now the decoder uses BT.709 where it
should be used according to the video resolution.

Default for not yet set colorimetry is BT.709 due to most observed
HDMV content being HD.

BT.709 coefficients were gathered from the first two parts of BT.709
to BT.2020 conversion guide in ARIB STD-B62 (Pt. 1, Chapter 6.2.2).
They were additionally confirmed by manually calculating values.

Fixes #4637
(cherry picked from commit 9779b62624)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-26 02:47:09 +02:00
Michael Niedermayer
4c896d6bd4 avcodec/ac3dec: Reset SPX when switching from EAC3 to AC3
Fixes Ticket5319

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9ac154d1fa)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-25 04:27:29 +02:00
Michael Niedermayer
f2e9e4757f avfilter/vf_drawtext: Check return code of load_glyph()
Fixes segfault
Fixes Ticket5347

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2e67a99fbc)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-24 12:41:09 +02:00
Michael Niedermayer
512c064cd9 avformat/mux: Check that deinit is set before calling it
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c84ba07db4)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-24 12:40:58 +02:00
Paul B Mahol
7626fb6cbf avcodec/takdec: add code that got somehow lost in process of REing
Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit 38797a8033)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-21 14:13:38 +02:00
Paul B Mahol
6fdd122b11 avcodec/apedec: fix decoding of stereo files with one channel full of silence
Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit 9149e9c0ba)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-21 14:12:45 +02:00
Michael Niedermayer
264c9fe6aa avcodec/avpacket: Fix off by 5 error
Fixes out of array read
Fixes: mozilla bug 1266129
Found-by: Tyson Smith
Tested-by: Tyson Smith
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9f36ea57ae)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-21 00:54:00 +02:00
Ivan
76573c5239 avcodec/h264: Fix for H.264 configuration parsing
Sometimes video fails to decode if H.264 configuration changes mid stream.
The reason is that configuration parser assumes that nal_ref_idc is equal to 11b
while actually some codecs but 01b there. The H.264 spec is somewhat
vague about this but it looks like it allows any non-zero nal_ref_idc for sps/pps.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3a727606c4)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-17 02:40:53 +02:00
Michael Niedermayer
14fdebc4ff avcodec/bmp_parser: Ensure remaining_size is not too small in startcode packet crossing corner case
Fixes Ticket 5438

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8e26bdd59b)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-14 15:29:25 +02:00
Michael Niedermayer
325d0b64d5 avcodec/pngdec: Fix alpha detection with skip_frame
Fixes Ticket4816

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d433623fba)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-09 01:12:32 +02:00
Michael Niedermayer
6103a8453f Changelog: Make formating consistent
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-04 22:45:14 +02:00
Marios Titas
47f0d80ee0 avfilter/src_movie: fix how we check for overflows with seek_point
Currently, if the movie source filter is used and a seek_point is
specified on a file that has a negative start time, ffmpeg will fail.

An easy way to reproduce this is as follows:
$ ffmpeg -vsync passthrough -filter_complex 'color=d=10,setpts=PTS-1/TB' test.mp4
$ ffmpeg -filter_complex 'movie=filename=test.mp4:seek_point=2' -f null -

The problem is caused by checking for int64_t overflow the wrong way.
In general, to check whether a + b overflows, it is not enough to do:
    a > INT64_MAX - b
because b might be negative; the correct way is:
    b > 0 && > a > INT64_MAX - b

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c1f9734f97)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-03 01:55:24 +02:00
Aaron Boxer
5d79566ab3 avcodec/j2kenc: Add attribution to OpenJPEG project:
http://ghostscript.com/~tor/gs-browse/gs/openjpeg/libopenjpeg/t1.c

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b6b4b0a65e)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-01 17:35:50 +02:00
Michael Niedermayer
fda00aa774 doc/Doxyfile: update for 3.0.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-29 04:25:48 +02:00
Michael Niedermayer
9b1b674ebe Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-29 04:23:42 +02:00
Michael Niedermayer
00b54d4625 avcodec/diracdec: check bitstream size related fields for overflows
Fixes segfault
Fixes Ticket5333

Regression since bfc8a4dabe
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8f2a1990c0)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-29 03:25:15 +02:00
Michael Niedermayer
26d29f0c3d avcodec/h264_slice: Check PPS more extensively when its not copied
Fixes Ticket5371
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c50be7a52b)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-29 03:25:15 +02:00
James Almer
7b1e020fc5 avformat/svag: fix division by zero
Fixes ticket #5386

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit d5a3578350)
2016-03-28 19:10:34 -03:00
Rostislav Pehlivanov
3d9ebfd272 Changelog: update for 3.0.1's vc2enc fixes
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-03-28 17:04:23 +01:00
Rostislav Pehlivanov
f01919b57a vc2enc: correctly zero out coefficient array padding
Credit for figuring this out goes to James Darnley.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
(cherry picked from commit 3ef10406e1)
2016-03-28 17:02:05 +01:00
Rostislav Pehlivanov
6cb5bbc660 Changelog: update for 3.0.1's aacenc optimizations
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-03-28 16:59:14 +01:00
Ganesh Ajjanagadde
f281cb4ea9 lavc/aacenc_utils: replace powf(x,y) by expf(logf(x), y)
This is ~2x faster for y not an integer on Haswell+GCC, and should
generally be faster due to the fact that anyway powf essentially does
this under the hood. Made an inline function in lavu/internal.h for this
purpose.

Note that there are some accuracy differences, that should generally be
negligible. In particular, FATE still passes on this platform.

Results in ~ 7% speedup in aac encoding with -march=native, Haswell+GCC.
before:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac  6.05s user 0.06s system 104% cpu 5.821 total

after:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac  5.67s user 0.03s system 105% cpu 5.416 total

This is also faster than an alternative approach that pulls in powf, gets rid of
the crufty NaN checks and other special cases, exploits knowledge about the intervals, etc.
This of course does not exclude smarter approaches; just suggests that
there would need to be significant work on this front of lower utility than
searches for hotspots elsewhere.

Reviewed-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
(cherry picked from commit bccc81dfa0)
2016-03-28 16:57:41 +01:00
Reimar Döffinger
b176ab0556 aacenc_utils: Use temporary variable.
This ensures gcc does not create unnecessary
loads or stores and possibly even does not vectorize
the negation.
Speeds up mp3 to aac transcoding with default settings
by 10% when using "gcc (Debian 5.3.1-10) 5.3.1 20160224".

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
(cherry picked from commit b60dfae7af)
2016-03-28 16:56:27 +01:00
Reimar Döffinger
1cbe4ff2ac aacenc: avoid double in quantize_bands.
I cannot see any point whatsoever to use
double here instead of float, the results
are likely identical in all cases..
Using float allows for much more
efficient use of SIMD.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
(cherry picked from commit 0a04c2885f)
2016-03-28 16:56:11 +01:00
Ganesh Ajjanagadde
7c2576e15d lavc/aacenc_utils: replace sqrtf(Q*sqrtf(Q)) by precomputed value
It makes no sense whatsoever to do this at each function call; we
already have a table for this.

Yields a 2x improvement in find_min_book (x86-64, Haswell+GCC):
ffmpeg -i sin.flac -acodec aac -y sin.aac
find_min_book
old
    605 decicycles in find_min_book, 8388453 runs,    155 skips.9x
    606 decicycles in find_min_book,16776912 runs,    304 skips.9x
    607 decicycles in find_min_book,33553819 runs,    613 skips.2x
    607 decicycles in find_min_book,67107668 runs,   1196 skips.3x
    607 decicycles in find_min_book,134215360 runs,   2368 skips3x

new
    359 decicycles in find_min_book, 8388552 runs,     56 skips.3x
    360 decicycles in find_min_book,16777112 runs,    104 skips.1x
    361 decicycles in find_min_book,33554218 runs,    214 skips.4x
    361 decicycles in find_min_book,67108381 runs,    483 skips.5x
    361 decicycles in find_min_book,134216725 runs,   1003 skips5x

and more importantly a non-negligible speedup (~ 8%) to overall AAC encoding:
old:
ffmpeg -i sin.flac -acodec aac -strict -2 -y sin_new.aac  6.82s user 0.03s system 104% cpu 6.565 total
new:
ffmpeg -i sin.flac -acodec aac -strict -2 -y sin_old.aac  6.24s user 0.03s system 104% cpu 5.993 total

This also improves accuracy of the expression by ~ 2 ulp in some cases.

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
(cherry picked from commit bd9c58756a)
2016-03-28 16:55:59 +01:00
Michael Niedermayer
526c7b2186 Update for 3.0.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 22:37:41 +01:00
Michael Niedermayer
2d0e415482 avcodec/libutvideodec: copy frame so it has reference counters when refcounted_frames is set
Reviewed-by: maintainer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0cd9ff4e3a)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:48 +01:00
Ico Doornekamp
daa6dc0a3b avformat/rtpdec_jpeg: fix low contrast image on low quality setting
Original mail and my own followup on ffmpeg-user earlier today:

I have a device sending out a MJPEG/RTP stream on a low quality setting.
Decoding and displaying the video with libavformat results in a washed
out, low contrast, greyish image. Playing the same stream with VLC results
in proper color representation.

Screenshots for comparison:

  http://zevv.nl/div/libav/shot-ffplay.jpg
  http://zevv.nl/div/libav/shot-vlc.jpg

A pcap capture of a few seconds of video and SDP file for playing the
stream are available at

  http://zevv.nl/div/libav/mjpeg.pcap
  http://zevv.nl/div/libav/mjpeg.sdp

I believe the problem might be in the calculation of the quantization
tables in the function create_default_qtables(), the attached patch
solves the issue for me.

The problem is that the argument 'q' is of the type uint8_t. According to the
JPEG standard, if 1 <= q <= 50, the scale factor 'S' should be 5000 / Q.
Because the create_default_qtables() reuses the variable 'q' to store the
result of this calculation, for small values of q < 19, q wil subsequently
overflow and give wrong results in the calculated quantization tables. The
patch below uses a new variable 'S' (same name as in RFC2435) with the proper
range to store the result of the division.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e3e6a2cff4)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:48 +01:00
Michael Niedermayer
6e5648ad42 avformat/mpegtsenc: Fix used service
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 26811fd946)

Conflicts:

	libavformat/version.h
2016-03-26 21:52:48 +01:00
Michael Niedermayer
e15a48d35a avformat/mpegtsenc: Keep track of the program for each service
Simplifies code

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 50d017a281)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:48 +01:00
Michael Niedermayer
0fae52d7e3 avformat/file: Add crypto to default whitelist
Fixes Ticket5287

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit efa98cdc2f)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
50a639a62a avcodec/mjpegenc_common: Store approximate aspect if exact cannot be stored
Fixes Ticket5244

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 068026b0f7)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Mark Thompson
d6adcab842 lavc/hevc: Allow arbitrary garbage in bytestream as long as at least one NAL unit is found.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fbec157ea0)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
bf80b1d88d avcodec/resample: Remove disabled and faulty code
Fixes Ticket5345

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 50ef7361cb)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Luca Barbato
53fffc9fc4 indeo2: Fix banding artefacts
Rename luma table to delta table and change how it is used.

CC: libav-stable@libav.org
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Diego Biurrun <diego@biurrun.de>
(cherry picked from commit f8c34f4b8d)
(cherry picked from commit 73f3c8f73e)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Luca Barbato
b0e836466f indeo2data: K&R formatting cosmetics
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Diego Biurrun <diego@biurrun.de>
(cherry picked from commit d4066a7024)
(cherry picked from commit 522ab0b9a9)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
e158936712 avformat/hlsenc: Fix passing options, regression since bc9a5965c8
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b2ab3398f5)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
c8977ec6e9 avutil/random_seed: Add the runtime in cycles of the main loop to the entropy pool
This should theoretically improve the randomness slightly

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2540d884f3)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Martin Cracauer
934bc32acc avutil/channel_layout: AV_CH_LAYOUT_6POINT1_BACK not reachable in parsing
Trying to make heads and tails out of DTS 6.1 I can across this typo.

I also noticed that this wiki page is incorrect or misleading, the
channel order for 6.1 given does not match the source code.  At the
least it should be clarified that the layout given does not apply to
DTS.  https://trac.ffmpeg.org/wiki/AudioChannelManipulation

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 73d1398f0c)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
64f2b48be0 avformat/concatdec: set safe mode to enabled instead of auto
This is safer, as a selected demuxer could still mean that it was auto-detected
by a user application

Reviewed-previously-by: Nicolas George <george@nsup.org>
Reviewed-previously-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 689211d572)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
756f4b586a avformat/utils: fix dts from pts code in compute_pkt_fields() during ascending delay
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit de1de49324)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Boris Nagels
56c4dca5ae avformat/rtpenc: Fix integer overflow in NTP_TO_RTP_FORMAT
RTCP synchronization packet was broken since commit in ffmpeg version > 2.8.3
(commit: e04b039b15) Since this commit (2e814d0329)
"rtpenc: Simplify code by introducing a macro for rescaling NTP timestamps", NTP_TO_RTP_FORMAT
uses av_rescale_rnd() function to add the data to the packet.

This causes an overflow in the av_rescale_rnd() function and it will return INT64_MIN.
Causing the NTP stamp in the RTCP packet to have an invalid value.

Github: Closes #182

Reverting commit '2e814d0329aded98c811d0502839618f08642685' solves the problem.
(cherry picked from commit 1109ed7973)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
foo86
da6ccfe18e avcodec/dca: clear X96 channels if nothing was decoded
The first X96 channel set can have more channels than core, causing X96
decoding to be skipped. Clear the number of decoded X96 channels to zero
in this rudimentary case.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit db44b59980)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
27a61302b7 fate/aac: Increase fuzz from of fate-aac-pns-encode from 72 to 74 for Loongson
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c78a726717)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
b4be953c55 avformat/cache: Fix memleak of tree entries
Found-by: jamrial

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 554f6e930c)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Rodger Combs
3b179b6302 lavf/mov: downgrade sidx errors to non-fatal warnings; fixes trac #5216
(cherry picked from commit 22dbc1caaf)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Rodger Combs
bf8f2fae2a lavf/mov: fix sidx with edit lists
(cherry picked from commit 3617e69d50)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
0d7343f8dd avcodec/mjpegdec: Fix decoding slightly odd progressive jpeg
Fixes: ebd58db6-dc86-11e5-91c2-59daeddf50c7.jpg

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c6f4720b86)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
fb8676eb1c swscale/utils: Fix chrSrcHSubSample for GBRAP16
Fixes part of Ticket5264

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 67e5bd0c50)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
ca5c639446 swscale/input: Fix GBRAP16 input
Fixes part of Ticket5264

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit df36257a53)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
bd79dbfa2b avutil/pixdesc: Make get_color_type() aware of CIE XYZ formats
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1ec7a70380)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
c4765a41b9 avcodec/h264: Execute error concealment before marking the frame as done.
Fixes race condition causing artifacts
Fixes Ticket4122

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 98a0053d0f)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
be5acd6cb1 swscale/x86/output: Fix yuv2planeX_16* with unaligned destination
Reviewed-by: BBB
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f6492a2ea8)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
Michael Niedermayer
c3e7a7ef3f swscale/x86/output: Move code into yuv2planeX_mainloop
Reviewed-by: BBB
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d07f6e5f1c)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:47 +01:00
KO Myung-Hun
9e4d297ba7 MAINTAINERS: add myself as an OS/2 maintainer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 346ec91764)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-26 21:52:46 +01:00
James Almer
373bc77a35 libwebpenc_animencoder: print library messages in verbose log levels
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit f875ba4873)
2016-03-17 12:57:00 -03:00
James Almer
20d89a3a32 libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct
This zeroes the WebPAnimEncoderOptions.verbose field, silencing library info messages
printed to stderr.

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 626b6b769c)
2016-03-17 12:56:30 -03:00
Hendrik Leppkes
ee7c347935 configure: check for SEC_I_CONTEXT_EXPIRED before enabling SChannel
Fixes build on mingw32, which lacks this constant.
2016-03-16 15:32:50 +01:00
Carl Eugen Hoyos
9da31a0373 lavf/http: Add httpproxy to the default protocol whitelist.
(cherry picked from commit 58fa694978)
2016-03-14 16:39:05 +01:00
Paul B Mahol
eb46065f4a doc/utils: fix typo for min() description
Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit bdf474bcff)
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
2016-03-02 16:43:57 -08:00
Oliver Collyer
b80083a5c1 ffserver&ffm: Fixed issues preventing ffserver write_index and files_size from being set correctly which was breaking ffserver streaming.
I discovered that ffserver streaming was broken (it seems like it has been since 20th November) and I opened a ticket for this (https://trac.ffmpeg.org/ticket/5250 <https://trac.ffmpeg.org/ticket/5250>).

I spent yesterday learning git bisect (with the kind help of cehoyos) to painstakingly track down the cause. This was made more difficult due to the presence of a segfault in ffserver during the period where the bug was introduced so I first had to identify when and how that was fixed and then retrospectively apply that fix again for each step of the second git bisect to find the actual bug.

Anyway, the fruits of my labour are the innocent looking patch below to correct a couple of typos and define a valid range for two variables.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a2f8beef2d)
2016-02-23 15:58:42 +01:00
Carl Eugen Hoyos
449ff0e3fd postproc: fix unaligned access
Based on 59074310 by Andreas Cadhalpun.
Fixes ticket #5259.
(cherry picked from commit 2aa21eec1a)
2016-02-23 15:58:07 +01:00
Rostislav Pehlivanov
0aa2fbddb1 vc2enc: fix use of uninitialized variables in the rate control system
Fixes: CID1352550
Fixes: CID1352549

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
(cherry picked from commit 7cdea450c6)
2016-02-15 15:36:59 +00:00
Michael Niedermayer
c40983a6f6 fate/source-check.sh: Use "git show" instead of git --version to test for git
This fixes fate with non git source trees

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 295de3efc5)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-15 03:51:39 +01:00
Michael Niedermayer
bd0497b28b avcodec/cfhd: Temporary disable frame threading until related bugs have been fixed
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-15 03:12:13 +01:00
James Almer
4d95207938 x86: use the new helper macros where useful
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 70d685a77f)
2016-02-14 20:04:19 -03:00
James Almer
1e8a75fae4 x86: add some more helper macros to check for slow cpuflags
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 73a4589d4b)
2016-02-14 20:04:06 -03:00
Rostislav Pehlivanov
380980e0d2 Changelog: add entries for the SMPTE VC-2 decoder and encoder
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-02-14 22:12:06 +00:00
Michael Niedermayer
1fd8eb4d4f Basic updates for 3.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-14 23:03:41 +01:00
5001 changed files with 137438 additions and 399810 deletions

1
.gitattributes vendored
View File

@@ -1,2 +1 @@
*.pnm -diff -text *.pnm -diff -text
tests/ref/fate/sub-scc eol=crlf

71
.gitignore vendored
View File

@@ -18,9 +18,8 @@
*.so.* *.so.*
*.swp *.swp
*.ver *.ver
*.version *-example
*.ptx *-test
*.ptx.c
*_g *_g
\#* \#*
.\#* .\#*
@@ -29,10 +28,70 @@
/ffmpeg /ffmpeg
/ffplay /ffplay
/ffprobe /ffprobe
/config.asm /ffserver
/config.h /config.*
/coverage.info /coverage.info
/avversion.h /avversion.h
/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_dir_cmd
/doc/examples/avio_reading
/doc/examples/decoding_encoding
/doc/examples/demuxing_decoding
/doc/examples/extract_mvs
/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/
/libavcodec/*_tablegen
/libavcodec/*_tables.c
/libavcodec/*_tables.h
/libavutil/avconfig.h
/libavutil/ffversion.h
/src /src
/mapfile /tests/audiogen
/tests/base64
/tests/checkasm/checkasm
/tests/data/
/tests/pixfmts.mak
/tests/rotozoom
/tests/test_copy.ffmeta
/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/sidxindex
/tools/trasher
/tools/seek_print
/tools/uncoded_frame
/tools/zmqsend

View File

@@ -6,22 +6,18 @@ os:
addons: addons:
apt: apt:
packages: packages:
- nasm - yasm
- diffutils - diffutils
compiler: compiler:
- clang - clang
- gcc - gcc
matrix:
exclude:
- os: osx
compiler: gcc
cache: cache:
directories: directories:
- ffmpeg-samples - ffmpeg-samples
before_install: before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi
install: install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install nasm; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install yasm; fi
script: script:
- mkdir -p ffmpeg-samples - mkdir -p ffmpeg-samples
- ./configure --samples=ffmpeg-samples --cc=$CC - ./configure --samples=ffmpeg-samples --cc=$CC

View File

@@ -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.

447
Changelog
View File

@@ -1,392 +1,67 @@
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 4.0.2:
- avcodec/dvdsub_parser: Allocate input padding
- avcodec/dvdsub_parser: Init output buf/size
- avcodec/dirac_dwt_template: Fix signedness regression in interleave()
- avformat/mov: Simplify last element computation in mov_estimate_video_delay()
- avformat/mov: Break out of inner loop early in mov_estimate_video_delay()
- avformat/mov: Eliminate variable buf_size from mov_estimate_video_delay()
- avformat/mov: remove modulo operations from mov_estimate_video_delay()
- avformat/movenc: Write version 2 of audio atom if channels is not known
- swresample/arm: rename labels to fix xcode build error
- avformat/movenc: Check input sample count
- avcodec/mjpegdec: Check for odd progressive RGB
- avcodec/vp8_parser: Do not leave data/size uninitialized
- avformat/mms: Add missing chunksize check
- avformat/pva: Check for EOF before retrying in read_part_of_packet()
- avformat/rmdec: Do not pass mime type in rm_read_multi() to ff_rm_read_mdpr_codecdata()
- avformat/asfdec_o: Check size_bmp more fully
- avformat/mxfdec: Fix av_log context
- avcodec/mpeg4videodec: Check for bitstream end in read_quant_matrix_ext()
- avcodec/indeo4: Check for end of bitstream in decode_mb_info()
- avcodec/ac3dec: Check channel_map index
- avcodec/mpeg4videodec: Remove use of FF_PROFILE_MPEG4_SIMPLE_STUDIO as indicator of studio profile
- avcodec/shorten: Fix undefined addition in shorten_decode_frame()
- avcodec/shorten: Fix undefined integer overflow
- avcodec/jpeg2000dec: Fixes invalid shifts in jpeg2000_decode_packets_po_iteration()
- avcodec/jpeg2000dec: Check that there are enough bytes for all tiles
- avformat/movenc: Use mov->fc consistently for av_log()
- avcodec/mpeg4videodec: Check read profile before setting it
- avformat/movenc: Do not pass AVCodecParameters in avpriv_request_sample
- avcodec/ac3_parser: Check init_get_bits8() for failure
- avformat/movenc: Check that frame_types other than EAC3_FRAME_TYPE_INDEPENDENT have a supported substream id
- avcodec/dpx: Check elements in 12bps planar path
- avcodec/escape124: Fix spelling errors in comment
- avcodec/ra144: Fix integer overflow in ff_eval_refl()
- avcodec/cscd: Check output buffer size for lzo.
- avcodec/escape124: Check buf_size against num_superblocks
- avcodec/h264_parser: Reduce needed history for parsing mb index
- avcodec/magicyuv: Check bits left in flags&1 branch
- avcodec/mjpegdec: Check for end of bitstream in ljpeg_decode_rgb_scan()
- ffmpeg: fix -stream_loop with multiple inputs
- ffmpeg: factorize input thread creation and destruction
- avformat/mpegts: parse large PMTs with multiple tables
- Revert "avcodec/mediacodecdec: wait on first frame after input buffers are full"
- avcodec/videotoolboxenc: fix invalid session on iOS
- avcodec/videotoolboxenc: split initialization
- avcodec/videotoolboxenc: fix mutex/cond leak in error path
version 4.0.1: version 3.0.2:
- avcodec/aacdec_fixed: Fix undefined integer overflow in apply_independent_coupling_fixed() - avcodec/ttaenc: Reallocate packet if its too small
- avcodec/dirac_dwt_template: Fix undefined behavior in interleave() - configure: build fix for P5600 with mips code restructuring
- avutil/common: Fix undefined behavior in av_clip_uintp2_c() - mips: add support for R6
- fftools/ffmpeg: Fallback to duration if sample rate is unavailable - pgssubdec: fix subpicture output colorspace and range
- avformat/mov: Only set pkt->duration to non negative values - avcodec/ac3dec: Reset SPX when switching from EAC3 to AC3
- avcodec/mpeg4videodec: Clear bits_per_raw_sample if it has originated from a previous instance - avfilter/vf_drawtext: Check return code of load_glyph()
- avformat/movenc: fix recognization of cover image streams - avformat/mux: Check that deinit is set before calling it
- avformat/movenc: properly handle cover image codecs - avcodec/takdec: add code that got somehow lost in process of REing
- avcodec/h264_slice: Fix overflow in recovery_frame computation - avcodec/apedec: fix decoding of stereo files with one channel full of silence
- avcodec/h264_ps: Move MAX_LOG2_MAX_FRAME_NUM to header so it can be used in h264_sei - avcodec/avpacket: Fix off by 5 error
- avcodec/h264_mc_template: Only prefetch motion if the list is used. - avcodec/h264: Fix for H.264 configuration parsing
- avcodec/xwddec: Use ff_set_dimensions() - avcodec/bmp_parser: Ensure remaining_size is not too small in startcode packet crossing corner case
- avcodec/wavpack: Fix overflow in adding tail - avcodec/pngdec: Fix alpha detection with skip_frame
- avcodec/shorten: Fix multiple integer overflows - Changelog: Make formating consistent
- avcodec/shorten: Fix undefined shift in fix_bitshift() - avfilter/src_movie: fix how we check for overflows with seek_point
- avcodec/shorten: Fix a negative left shift in shorten_decode_frame() - avcodec/j2kenc: Add attribution to OpenJPEG project:
- avcodec/shorten: Sanity check nmeans
- avcodec/shorten: Check non COMM chunk len before skip in decode_aiff_header()
- avcodec/mjpegdec: Fix integer overflow in ljpeg_decode_rgb_scan()
- avcodec/truemotion2: Fix overflow in tm2_apply_deltas()
- avcodec/opus_silk: Change silk_lsf2lpc() slightly toward silk/NLSF2A.c
- avcodec/amrwbdec: Fix division by 0 in find_hb_gain()
- avcodec/h263dec: Reinitialize idct context if it has not been setup for the active profile
- avcodec/idctdsp: Clear idct/idct_add for studio profile
- avformat/mov: replace a value error by clipping into valid range in mov_read_stsc()
- avformat/bintext: Reduce detection for random .bin files as it more likely is not a multimedia related file
- avformat/mov: Break out early if chunk_count is 0 in mov_build_index()
- avcodec/fic: Avoid some magic numbers related to cursors
- avcodec/mpeg4video: Detect reference studio streams as studio streams
- avcodec/mpeg4videodec: Do not corrupt bits_per_raw_sample
- avcodec/mpeg4videode: Eliminate out of loop VOP startcode reading for studio profile
- avcodec/g2meet: ask for sample with overflowing RGB
- avcodec/idctdsp: Transmit studio_profile to init instead of using AVCodecContext profile
- avcodec/ac3dec: Check that the number of channels with dependant streams is valid
- avcodec/ac3dec: Fix null pointer dereference in ac3_decode_frame()
- avcodec/aacdec_fixed: use 64bit to avoid overflow in rounding in apply_dependent_coupling_fixed()
- oavcodec/aacpsdsp_template: Use unsigned for hs0X to prevent undefined behavior
- avcodec/g723_1dec: Clip bits2 in both directions
- avcodec/mpeg4videoenc: Use 64 bit for times in mpeg4_encode_gop_header()
- avcodec/mlpdec: Only change noise_type if the related fields are valid
- indeo4: Decode all or nothing of a band header.
- avcodec/ac3dec: Use frame_size if superframe_size is 0
- avformat/mov: Only fail for STCO/STSC contradictions if both exist
- avcodec/dirac_dwt: Fix integer overflow in COMPOSE_DD97iH0 / COMPOSE_DD137iL0
- avcodec/fic: Check available input space for cursor
- avcodec/mpeg4videodec: Check bps (VOL header) before VOP for studio profile
- avcodec/g2meet: Check RGB upper limit
- avcodec/jpeg2000dec: Fix undefined shift in the jpeg2000_decode_packets_po_iteration() CPRL case
- avcodec/jpeg2000dec: Skip init for component in CPRL if nothing is to be done
- avcodec/g2meet: Change order of operations to avoid undefined behavior
- avcodec/flac_parser: Fix infinite loop
- avcodec/mpeg4videodec: Split decode_studio_vol_header() out of decode_studiovisualobject()
- avcodec/mpeg4videodec: Move decode_studiovisualobject() parsing in the branch for visual object parsing
- avcodec/mpeg4video_parser: Avoid litteral 0x1B6, use named constant instead
- avcodec/mpeg4video_parser: Fix incorrect spliting of MPEG-4 studio frames
- avformat/m4vdec: Use the same constant names as libavcodec
- avformat/m4vdec: Fix detection of raw MPEG-4 ES Studio
- avcodec/wavpack: Fix integer overflow in DEC_MED() / INC_MED()
- avcodec/wavpack: Fix integer overflow in wv_unpack_stereo()
- avcodec/error_resilience: Fix integer overflow in filter181()
- avcodec/h263dec: Check slice_ret in mspeg4 slice loop
- avcodec/elsdec: Fix memleaks
- avcodec/vc1_block: simplify ac_val computation
- avcodec/ffv1enc: Check that the crc + version combination is supported
- configure: The eac3_core bitstream filter needs the ac3 parser.
- configure: fix arm inline asm checks
- lavf/libssh: translate a read of 0 to EOF
- ffprobe: fix SEGV when new streams are added
- avformat/mpegts: fix incorrect indentation
- avformat/mpegts: initialize section_buf to fix valgrind test failure
- avformat/mpegts: reindent after last change
- avformat/mpegts: parse sections with multiple tables
- avformat/mpegts: clean up whitespace
- avformat/mpegts: use MAX_SECTION_SIZE instead of hardcoded value
- avformat/mpegts: skip non-PMT tids earlier
- avcodec/mediacodecdec: add workaround for buggy amlogic mpeg2 decoder
- avcodec/mediacodecdec: wait on first frame after input buffers are full
- avcodec/mediacodecdec: restructure mediacodec_receive_frame
- avcodec/mediacodec_wrapper: add helper to fetch SDK_INT
- avcodec/mediacodecdec: refactor pts handling
- avcodec/mediacodecdec: use AV_TIME_BASE_Q
- avcodec/mediacodecdec: clarify delay_flush specific code
- avcodec/videotoolbox: fix decoding of some HEVC videos
- avcodec/hevc: remove videotoolbox hack
- avcodec/videotoolbox: split h264/hevc callbacks
- avcodec/videotoolbox: cleanups
- avcodec/videotoolbox: fix kVTCouldNotFindVideoDecoderErr trying to decode HEVC on iOS
- avcodec/videotoolbox: improve logging of decoder errors
- avcodec/xwddec: fix palette alpha
- avformat/webm_chunk: always use a static buffer for get_chunk_filename
- configure: fix configure check for lilv-0
- avcodec/nvdec_hevc: fix scaling lists
- avcodec/hevcdec: make ff_hevc_frame_nb_refs take a const pointer
- lavf/bluray: translate a read of 0 to EOF
- lavf/dashenc: don't call flush_init_segment before avformat_write_header
- avdevice/decklink_dec: unref packets on avpacket_queue_put error
- avcodec/hnm4video: fix palette alpha
- avcodec/anm: fix palette alpha
- avformat/qtpalette: parse color table according to the QuickTime file format specs
- ffplay: Fix realloc_texture when input texture is NULL.
- hwcontext_vaapi: Fix compilation with libva versions < 1.4.0
- lavf/qsv: clone the frame which may be managed by framework
- lavf: make overlay_qsv work based on framesync
- avformat/segafilm - revert keyframe detection
- avformat/utils: refactor upstream_stream_timings
- avformat/utils: ignore outlier durations on subtitle/data streams as well
version 4.0: version 3.0.1:
- Bitstream filters for editing metadata in H.264, HEVC and MPEG-2 streams - avcodec/libutvideodec: copy frame so it has reference counters when refcounted_frames is set
- Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now - avformat/rtpdec_jpeg: fix low contrast image on low quality setting
requires 2.1 (or later) and pkg-config. - avformat/mpegtsenc: Fix used service
- VDA dropped (use VideoToolbox instead) - avformat/mpegtsenc: Keep track of the program for each service
- MagicYUV encoder - avformat/file: Add crypto to default whitelist
- Raw AMR-NB and AMR-WB demuxers - avcodec/mjpegenc_common: Store approximate aspect if exact cannot be stored
- TiVo ty/ty+ demuxer - lavc/hevc: Allow arbitrary garbage in bytestream as long as at least one NAL unit is found.
- Intel QSV-accelerated MJPEG encoding - avcodec/resample: Remove disabled and faulty code
- PCE support for extended channel layouts in the AAC encoder - indeo2: Fix banding artefacts
- native aptX and aptX HD encoder and decoder - indeo2data: K&R formatting cosmetics
- Raw aptX and aptX HD muxer and demuxer - avformat/hlsenc: Fix passing options, regression since bc9a5965c815cf7fd998d8ce14a18b8e861dd9ce
- NVIDIA NVDEC-accelerated H.264, HEVC, MJPEG, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding - avutil/random_seed: Add the runtime in cycles of the main loop to the entropy pool
- Intel QSV-accelerated overlay filter - avutil/channel_layout: AV_CH_LAYOUT_6POINT1_BACK not reachable in parsing
- mcompand audio filter - avformat/concatdec: set safe mode to enabled instead of auto
- acontrast audio filter - avformat/utils: fix dts from pts code in compute_pkt_fields() during ascending delay
- OpenCL overlay filter - avformat/rtpenc: Fix integer overflow in NTP_TO_RTP_FORMAT
- video mix filter - avcodec/dca: clear X96 channels if nothing was decoded
- video normalize filter - fate/aac: Increase fuzz from of fate-aac-pns-encode from 72 to 74 for Loongson
- audio lv2 wrapper filter - avformat/cache: Fix memleak of tree entries
- VAAPI MJPEG and VP8 decoding - lavf/mov: downgrade sidx errors to non-fatal warnings; fixes trac #5216
- AMD AMF H.264 and HEVC encoders - lavf/mov: fix sidx with edit lists
- video fillborders filter - avcodec/mjpegdec: Fix decoding slightly odd progressive jpeg
- video setrange filter - swscale/utils: Fix chrSrcHSubSample for GBRAP16
- nsp demuxer - swscale/input: Fix GBRAP16 input
- support LibreSSL (via libtls) - avutil/pixdesc: Make get_color_type() aware of CIE XYZ formats
- AVX-512/ZMM support added - avcodec/h264: Execute error concealment before marking the frame as done.
- Dropped support for building for Windows XP. The minimum supported Windows - swscale/x86/output: Fix yuv2planeX_16* with unaligned destination
version is Windows Vista. - swscale/x86/output: Move code into yuv2planeX_mainloop
- deconvolve video filter - MAINTAINERS: add myself as an OS/2 maintainer
- entropy video filter - libwebpenc_animencoder: print library messages in verbose log levels
- hilbert audio filter source - libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct
- aiir audio filter - configure: check for SEC_I_CONTEXT_EXPIRED before enabling SChannel
- aiff: add support for CD-ROM XA ADPCM - lavf/http: Add httpproxy to the default protocol whitelist.
- Removed the ffserver program - doc/utils: fix typo for min() description
- Removed the ffmenc and ffmdec muxer and demuxer - ffserver&ffm: Fixed issues preventing ffserver write_index and files_size from being set correctly which was breaking ffserver streaming.
- VideoToolbox HEVC encoder and hwaccel - postproc: fix unaligned access
- VAAPI-accelerated ProcAmp (color balance), denoise and sharpness filters - vc2enc: fix use of uninitialized variables in the rate control system, correctly zero out coefficient array padding
- Add android_camera indev - aacenc: optimize encoding speed
- codec2 en/decoding via libcodec2 - avcodec/diracdec: check bitstream size related fields for overflows
- muxer/demuxer for raw codec2 files and .c2 files - avcodec/h264_slice: Check PPS more extensively when its not copied
- 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
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: version 3.0:
@@ -1259,8 +934,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
@@ -1553,7 +1228,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

View File

@@ -1,4 +1,4 @@
# 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
@@ -13,18 +13,18 @@ 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 - optional x86 optimizations in the files
- `libavcodec/x86/flac_dsp_gpl.asm` - `libavcodec/x86/flac_dsp_gpl.asm`
- `libavcodec/x86/idct_mmx.c` - `libavcodec/x86/idct_mmx.c`
- `libavfilter/x86/vf_removegrain.asm` - `libavfilter/x86/vf_removegrain.asm`
- the following building and testing tools - libutvideo encoding/decoding wrappers in
- `compat/solaris/make_sunver.pl` `libavcodec/libutvideo*.cpp`
- `doc/t2h.pm` - the X11 grabber in `libavdevice/x11grab.c`
- `doc/texi2pod.pl` - the swresample test app in
- `libswresample/swresample-test.c` `libswresample/swresample-test.c`
- `tests/checkasm/*` - the `texi2pod.pl` tool
- `tests/tiny_ssim.c`
- the following filters in libavfilter: - the following filters in libavfilter:
- `f_ebur128.c`
- `vf_blackframe.c` - `vf_blackframe.c`
- `vf_boxblur.c` - `vf_boxblur.c`
- `vf_colormatrix.c` - `vf_colormatrix.c`
@@ -47,9 +47,9 @@ Specifically, the GPL parts of FFmpeg are:
- `vf_pp.c` - `vf_pp.c`
- `vf_pp7.c` - `vf_pp7.c`
- `vf_pullup.c` - `vf_pullup.c`
- `vf_repeatfields.c`
- `vf_sab.c` - `vf_sab.c`
- `vf_smartblur.c` - `vf_smartblur.c`
- `vf_repeatfields.c`
- `vf_spp.c` - `vf_spp.c`
- `vf_stereo3d.c` - `vf_stereo3d.c`
- `vf_super2xsai.c` - `vf_super2xsai.c`
@@ -73,17 +73,20 @@ There are a handful of files under other licensing terms, namely:
* `tests/reference.pnm` is under the expat license. * `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: The following libraries are under GPL:
- frei0r - frei0r
- libcdio - libcdio
- librubberband - librubberband
- libutvideo
- libvidstab - libvidstab
- libx264 - libx264
- libx265 - libx265
@@ -98,23 +101,14 @@ 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.
### Incompatible libraries incompatible libraries
----------------------
There are certain libraries you can combine with FFmpeg whose licenses are not The Fraunhofer AAC library and FAAC are under licenses which
compatible with the GPL and/or the LGPL. If you wish to enable these are incompatible with the GPLv2 and v3. We do not know for certain if their
libraries, even in circumstances that their license may be incompatible, pass licenses are compatible with the LGPL.
`--enable-nonfree` to configure. But note that if you enable any of these If you wish to enable these libraries, pass `--enable-nonfree` to configure.
libraries the resulting binary will be under a complex license mix that is But note that if you enable any of these libraries the resulting binary will
more restrictive than the LGPL and that may result in additional obligations. be under a complex license mix that is more restrictive than the LGPL and that
It is possible that these restrictions cause the resulting binary to be may result in additional obligations. It is possible that these
unredistributable. 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.
The NVENC library, while its header file is licensed under the compatible MIT
license, requires a proprietary binary blob at run time, and is deemed to be
incompatible with the GPL. We are not certain if it is compatible with the
LGPL, but we require `--enable-nonfree` even with LGPL configurations in case
it is not.

View File

@@ -29,6 +29,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,12 +42,12 @@ QuickTime faststart:
Miscellaneous Areas Miscellaneous Areas
=================== ===================
documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan, Gyan Doshi documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan
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, Lou Logan
presets Robert Swain presets Robert Swain
metadata subsystem Aurelien Jacobs metadata subsystem Aurelien Jacobs
release management Michael Niedermayer release management Michael Niedermayer
API tests Ludmila Glinskih
Communication Communication
@@ -53,11 +56,10 @@ Communication
website Deby Barbara Lepage website Deby Barbara Lepage
fate.ffmpeg.org Timothy Gu fate.ffmpeg.org Timothy Gu
Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos, Lou Logan Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos, Lou Logan
mailing lists Baptiste Coudurier, Lou Logan mailing lists Michael Niedermayer, Baptiste Coudurier, Lou Logan
Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser
Twitter Lou Logan, Reynaldo H. Verdejo Pinochet Twitter Lou Logan, Reynaldo H. Verdejo Pinochet
Launchpad Timothy Gu Launchpad Timothy Gu
ffmpeg-security Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, Rodger Combs, wm4
libavutil libavutil
@@ -77,7 +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
intfloat* Michael Niedermayer intfloat* Michael Niedermayer
integer.c, integer.h Michael Niedermayer integer.c, integer.h Michael Niedermayer
lzo Reimar Doeffinger lzo Reimar Doeffinger
@@ -88,6 +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
timecode Clément Bœsch
libavcodec libavcodec
@@ -113,10 +115,10 @@ Generic Parts:
lzw.* Michael Niedermayer lzw.* Michael Niedermayer
floating point AAN DCT: floating point AAN DCT:
faandct.c, faandct.h Michael Niedermayer faandct.c, faandct.h Michael Niedermayer
Non-power-of-two MDCT:
mdct15.c, mdct15.h Rostislav Pehlivanov
Golomb coding: Golomb coding:
golomb.c, golomb.h Michael Niedermayer golomb.c, golomb.h Michael Niedermayer
LPC:
lpc.c, lpc.h Justin Ruggles
motion estimation: motion estimation:
motion* Michael Niedermayer motion* Michael Niedermayer
rate control: rate control:
@@ -137,41 +139,47 @@ Codecs:
8bps.c Roberto Togni 8bps.c Roberto Togni
8svx.c Jaikrishnan Menon 8svx.c Jaikrishnan Menon
aacenc*, aaccoder.c Rostislav Pehlivanov aacenc*, aaccoder.c Rostislav Pehlivanov
aasc.c Kostya Shishkov
ac3* Justin Ruggles
alacenc.c Jaikrishnan Menon alacenc.c Jaikrishnan Menon
alsdec.c Thilo Borgmann, Umair Khan alsdec.c Thilo Borgmann
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* Rodger Combs
bgmc.c, bgmc.h Thilo Borgmann bgmc.c, bgmc.h Thilo Borgmann
bink.c Kostya Shishkov
binkaudio.c Peter Ross binkaudio.c Peter Ross
bmp.c Mans Rullgard, Kostya Shishkov
cavs* Stefan Gehrer cavs* Stefan Gehrer
cdxl.c Paul B Mahol 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 ccaption_dec.c Anshul Maheshwari
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
dirac* Rostislav Pehlivanov 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 dss_sp.c Oleksij Rempel, Michael Niedermayer
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 evrc* Paul B Mahol
exif.c, exif.h Thilo Borgmann exif.c, exif.h Thilo Borgmann
exr.c Martin Vignali
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
@@ -180,47 +188,61 @@ Codecs:
h263* Michael Niedermayer h263* Michael Niedermayer
h264* Loren Merritt, Michael Niedermayer h264* Loren Merritt, Michael Niedermayer
hap* Tom Butterworth hap* Tom Butterworth
huffyuv* Michael Niedermayer huffyuv* Michael Niedermayer, Christophe Gisquet
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
libgsm.c Michel Bardiaux libgsm.c Michel Bardiaux
libkvazaar.c Arttu Ylä-Outinen libkvazaar.c Arttu Ylä-Outinen
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* Carl Eugen Hoyos
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
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 nvenc.c Timo Rothenpieler
opus* Rostislav Pehlivanov
paf.* Paul B Mahol paf.* Paul B Mahol
pcx.c Ivo van Poorten pcx.c Ivo van Poorten
pgssubdec.c Reimar Doeffinger pgssubdec.c Reimar Doeffinger
ptx.c Ivo van Poorten ptx.c Ivo van Poorten
qcelp* Reynaldo H. Verdejo Pinochet qcelp* Reynaldo H. Verdejo Pinochet
qdm2.c, qdm2data.h Roberto Togni qdm2.c, qdm2data.h Roberto Togni, Benjamin Larsson
qsv* Mark Thompson qdrw.c Kostya Shishkov
qpeg.c Kostya Shishkov
qsv* Ivan Uskov
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
@@ -228,51 +250,66 @@ 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 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
v410*.c Derek Buitenhuis
vb.c Kostya Shishkov
vble.c Derek Buitenhuis
vc1* Kostya Shishkov, Christophe Gisquet
vc2* Rostislav Pehlivanov vc2* Rostislav Pehlivanov
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 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* Hendrik Leppkes, Laurent Aimar
d3d11va* Steve Lhomme
mediacodec* Matthieu Bouron, Aman Gupta
vaapi* Gwenole Beauchesne vaapi* Gwenole Beauchesne
vaapi_encode* Mark Thompson vda* Sebastien Zwickert
vdpau* Philip Langdale, Carl Eugen Hoyos vdpau* Philip Langdale, Carl Eugen Hoyos
videotoolbox* Rick Kern, Aman Gupta videotoolbox* Sebastien Zwickert
libavdevice libavdevice
@@ -282,8 +319,7 @@ libavdevice
avfoundation.m Thilo Borgmann avfoundation.m Thilo Borgmann
android_camera.c Felix Matouschek decklink* Deti Fliegl
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)
@@ -292,8 +328,8 @@ 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 Giorgio Vazzana v4l2.c Giorgio Vazzana
vfwcap.c Ramiro Polla vfwcap.c Ramiro Polla
xv.c Lukasz Marek xv.c Lukasz Marek
@@ -304,8 +340,6 @@ 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 f_drawgraph.c Paul B Mahol
af_adelay.c Paul B Mahol af_adelay.c Paul B Mahol
@@ -319,10 +353,7 @@ Filters:
af_biquads.c Paul B Mahol af_biquads.c Paul B Mahol
af_chorus.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_sidechaincompress.c Paul B Mahol
af_silenceremove.c Paul B Mahol af_silenceremove.c Paul B Mahol
@@ -330,13 +361,11 @@ Filters:
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_chromakey.c Timo Rothenpieler
vf_colorchannelmixer.c Paul B Mahol vf_colorchannelmixer.c Paul B Mahol
vf_colorbalance.c Paul B Mahol vf_colorbalance.c Paul B Mahol
vf_colorkey.c Timo Rothenpieler vf_colorkey.c Timo Rothenpieler
vf_colorlevels.c Paul B Mahol vf_colorlevels.c Paul B Mahol
vf_coreimage.m Thilo Borgmann
vf_deband.c Paul B Mahol 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 <jdelvare@suse.com>)
@@ -346,15 +375,11 @@ Filters:
vf_hqx.c Clément Bœsch vf_hqx.c Clément Bœsch
vf_idet.c Pascal Massimino 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_lenscorrection.c Daniel Oberhoff
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_neighbor.c Paul B Mahol
vf_psnr.c Paul B Mahol vf_psnr.c Paul B Mahol
vf_random.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_ssim.c Paul B Mahol
@@ -374,7 +399,6 @@ 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:
@@ -384,37 +408,34 @@ Muxers/Demuxers:
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
ape.c Kostya Shishkov
apngdec.c Benoit Fouet apngdec.c Benoit Fouet
ass* Aurelien Jacobs ass* Aurelien Jacobs
astdec.c Paul B Mahol astdec.c Paul B Mahol
astenc.c James Almer astenc.c James Almer
avi* Michael Niedermayer avi* Michael Niedermayer
avisynth.c Stephen Hutchinson 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
dss.c Oleksij Rempel dss.c Oleksij Rempel, Michael Niedermayer
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
hls.c Anssi Hannula hls.c Anssi Hannula
hlsenc.c Christian Suloway, Steven Liu hls encryption (hlsenc.c) Christian Suloway
idcin.c Mike Melanson idcin.c Mike Melanson
idroqdec.c Mike Melanson idroqdec.c Mike Melanson
iff.c Jaikrishnan Menon iff.c Jaikrishnan Menon
@@ -422,9 +443,10 @@ 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
jacosub* Clément Bœsch
jvdec.c Peter Ross jvdec.c Peter Ross
libmodplug.c Clément Bœsch libmodplug.c Clément Bœsch
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
@@ -436,9 +458,10 @@ Muxers/Demuxers:
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 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
@@ -446,6 +469,7 @@ Muxers/Demuxers:
msnwc_tcp.c Ramiro Polla msnwc_tcp.c Ramiro Polla
mtv.c Reynaldo H. Verdejo Pinochet mtv.c Reynaldo H. Verdejo Pinochet
mxf* Baptiste Coudurier mxf* Baptiste Coudurier
mxfdec.c Tomas Härdin
nistspheredec.c Paul B Mahol nistspheredec.c Paul B Mahol
nsvdec.c Francois Revol nsvdec.c Francois Revol
nut* Michael Niedermayer nut* Michael Niedermayer
@@ -463,7 +487,8 @@ 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_ac3.* Gilles Chanteperdrix
rtpdec_dv.* Thomas Volkert rtpdec_dv.* Thomas Volkert
@@ -471,14 +496,15 @@ Muxers/Demuxers:
rtpdec_hevc.*, rtpenc_hevc.* Thomas Volkert rtpdec_hevc.*, rtpenc_hevc.* Thomas Volkert
rtpdec_mpa_robust.* Gilles Chanteperdrix 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 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 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
@@ -493,6 +519,7 @@ 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:
@@ -523,47 +550,23 @@ Resamplers:
Operating systems / CPU architectures Operating systems / CPU architectures
===================================== =====================================
Alpha Falk Hueffner Alpha Mans Rullgard, Falk Hueffner
MIPS Manojkumar Bhosale ARM Mans Rullgard
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 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, Hendrik Leppkes
Windows ICL Matthew Oliver Windows ICL Matthew Oliver
ADI/Blackfin DSP Marc Hoffman ADI/Blackfin DSP Marc Hoffman
Sparc Roman Shaposhnik Sparc Roman Shaposhnik
x86 Michael Niedermayer
OS/2 KO Myung-Hun OS/2 KO Myung-Hun
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
Martin Storsjö
Panagiotis Issaris
Pedro Arthur
Sebastien Zwickert
Vittorio Giovara
wm4
(this list is incomplete)
Releases Releases
======== ========
@@ -571,6 +574,7 @@ Releases
2.7 Michael Niedermayer 2.7 Michael Niedermayer
2.6 Michael Niedermayer 2.6 Michael Niedermayer
2.5 Michael Niedermayer 2.5 Michael Niedermayer
2.4 Michael Niedermayer
If you want to maintain an older release, please contact us If you want to maintain an older release, please contact us
@@ -580,6 +584,7 @@ GnuPG Fingerprints of maintainers and contributors
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
@@ -587,17 +592,18 @@ 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 Ganesh Ajjanagadde C96A 848E 97C3 CEA2 AB72 5CE4 45F9 6A2D 3C36 FB1B
Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4 Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368 Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
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
Justin Ruggles 3136 ECC0 C10D 6C04 5F43 CA29 FCBE CD2A 3787 1EBF
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A
Luca Barbato 6677 4209 213C 8843 5B67 29E7 E84C 78C2 84E9 0E34
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029
Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B
Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E
@@ -607,7 +613,6 @@ 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
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

140
Makefile
View File

@@ -1,5 +1,5 @@
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)
@@ -11,12 +11,38 @@ 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 %/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
AVPROGS-$(CONFIG_FFPLAY) += ffplay
AVPROGS-$(CONFIG_FFPROBE) += ffprobe
AVPROGS-$(CONFIG_FFSERVER) += ffserver
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
ifndef CONFIG_VIDEOTOOLBOX
OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
endif
OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
OBJS-ffserver += ffserver_config.o
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options 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
@@ -31,45 +57,35 @@ 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) 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) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
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)
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)/libavformat/protocols.c \
config.h: ffbuild/.config
ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
@-tput bold 2>/dev/null @-tput bold 2>/dev/null
@-printf '\nWARNING: $(?) newer than config.h, rerun configure\n\n' @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
@-tput sgr0 2>/dev/null @-tput sgr0 2>/dev/null
SUBDIR_VARS := CLEANFILES 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 MIPSDSP-OBJS MSA-OBJS \
MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
@@ -84,32 +100,41 @@ 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)/$(1)/$(INTRINSICS)/Makefile
include $(SRC_PATH)/ffbuild/library.mak include $(SRC_PATH)/library.mak
endef endef
$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D)))) $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
include $(SRC_PATH)/fftools/Makefile
include $(SRC_PATH)/doc/Makefile include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/doc/examples/Makefile
libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h 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 libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF) $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
ifeq ($(STRIPTYPE),direct)
$(STRIP) -o $@ $<
else
$(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) $(LDEXEFLAGS) $(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:
@@ -119,32 +144,44 @@ 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)) $(RM) $(CLEANSUFFIXES:%=tools/%)
$(RM) -r coverage-html $(RM) -r coverage-html
$(RM) -rf coverage.info coverage.info.in lcov $(RM) -rf coverage.info coverage.info.in lcov
distclean:: clean distclean::
$(RM) .version avversion.h config.asm config.h mapfile \ $(RM) $(DISTCLEANSUFFIXES)
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \ $(RM) config.* .config libavutil/avconfig.h .version avversion.h 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 \
libavformat/muxer_list.c libavformat/demuxer_list.c
ifeq ($(SRC_LINK),src) ifeq ($(SRC_LINK),src)
$(RM) src $(RM) src
endif endif
@@ -153,7 +190,6 @@ endif
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
@@ -169,5 +205,5 @@ $(sort $(OBJDIRS)):
# 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*

View File

@@ -21,6 +21,8 @@ such as audio, video, subtitles and related metadata.
* [ffplay](https://ffmpeg.org/ffplay.html) is a minimalistic multimedia player. * [ffplay](https://ffmpeg.org/ffplay.html) is a minimalistic multimedia player.
* [ffprobe](https://ffmpeg.org/ffprobe.html) is a simple analysis tool to inspect * [ffprobe](https://ffmpeg.org/ffprobe.html) is a simple analysis tool to inspect
multimedia content. multimedia content.
* [ffserver](https://ffmpeg.org/ffserver.html) is a multimedia streaming server
for live broadcasts.
* Additional small tools such as `aviocat`, `ismindex` and `qt-faststart`. * Additional small tools such as `aviocat`, `ismindex` and `qt-faststart`.
## Documentation ## Documentation
@@ -43,4 +45,5 @@ GPL. Please refer to the LICENSE file for detailed information.
Patches should be submitted to the ffmpeg-devel mailing list using Patches should be submitted to the ffmpeg-devel mailing list using
`git format-patch` or `git send-email`. Github pull requests should be `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. avoided because they are not part of our review process. Few developers
follow pull requests so they will likely be ignored.

View File

@@ -1 +1 @@
4.0.2 3.0.2

View File

@@ -1,13 +1,13 @@
┌───────────────────────────────────┐ ┌─────────────────────────────────────────
│ RELEASE NOTES for FFmpeg 4.0 "Wu" │ │ RELEASE NOTES for FFmpeg 3.0 "Einstein" │
└───────────────────────────────────┘ └─────────────────────────────────────────
The FFmpeg Project proudly presents FFmpeg 4.0 "Wu", about 6 The FFmpeg Project proudly presents FFmpeg 3.0 "Einstein", about 5
months after the release of FFmpeg 3.4. months after the release of FFmpeg 2.8.
A complete Changelog is available at the root of the project, and the A complete Changelog is available at the root of the project, and the
complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git complete Git history on http://source.ffmpeg.org.
We hope you will like this release as much as we enjoyed working on it, and We hope you will like this release as much as we enjoyed working on it, and
as usual, if you have any questions about it, or any FFmpeg related topic, as usual, if you have any questions about it, or any FFmpeg related topic,

View File

@@ -14,4 +14,4 @@ OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes) OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes)
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes) OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
OBJS-$(HAVE_X86ASM) += $(X86ASM-OBJS) $(X86ASM-OBJS-yes) OBJS-$(HAVE_YASM) += $(YASM-OBJS) $(YASM-OBJS-yes)

View File

@@ -38,7 +38,6 @@
#include "libswscale/swscale.h" #include "libswscale/swscale.h"
#include "libswresample/swresample.h" #include "libswresample/swresample.h"
#include "libpostproc/postprocess.h" #include "libpostproc/postprocess.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h" #include "libavutil/avassert.h"
#include "libavutil/avstring.h" #include "libavutil/avstring.h"
#include "libavutil/bprint.h" #include "libavutil/bprint.h"
@@ -62,9 +61,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#ifdef _WIN32
#include <windows.h>
#endif
static int init_report(const char *env); static int init_report(const char *env);
@@ -76,12 +72,6 @@ static FILE *report_file;
static int report_file_level = AV_LOG_DEBUG; static int report_file_level = AV_LOG_DEBUG;
int hide_banner = 0; int hide_banner = 0;
enum show_muxdemuxers {
SHOW_DEFAULT,
SHOW_DEMUXERS,
SHOW_MUXERS,
};
void init_opts(void) void init_opts(void)
{ {
av_dict_set(&sws_dict, "flags", "bicubic", 0); av_dict_set(&sws_dict, "flags", "bicubic", 0);
@@ -117,15 +107,6 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v
} }
} }
void init_dynload(void)
{
#ifdef _WIN32
/* Calling SetDllDirectory with the empty string (but not NULL) removes the
* current working directory from the DLL search path as a security pre-caution. */
SetDllDirectory("");
#endif
}
static void (*program_exit)(int ret); static void (*program_exit)(int ret);
void register_exit(void (*cb)(int ret)) void register_exit(void (*cb)(int ret))
@@ -232,6 +213,7 @@ static const OptionDef *find_option(const OptionDef *po, const char *name)
* by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while * by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while
* it doesn't provide the actual command line via GetCommandLineW(). */ * it doesn't provide the actual command line via GetCommandLineW(). */
#if HAVE_COMMANDLINETOARGVW && defined(_WIN32) #if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
#include <windows.h>
#include <shellapi.h> #include <shellapi.h>
/* Will be leaked on exit */ /* Will be leaked on exit */
static char** win32_argv_utf8 = NULL; static char** win32_argv_utf8 = NULL;
@@ -881,54 +863,28 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
{ "debug" , AV_LOG_DEBUG }, { "debug" , AV_LOG_DEBUG },
{ "trace" , AV_LOG_TRACE }, { "trace" , AV_LOG_TRACE },
}; };
const char *token;
char *tail; char *tail;
int flags = av_log_get_flags(); int level;
int level = av_log_get_level(); int flags;
int cmd, i = 0; int i;
av_assert0(arg); flags = av_log_get_flags();
while (*arg) { tail = strstr(arg, "repeat");
token = arg; if (tail)
if (*token == '+' || *token == '-') { flags &= ~AV_LOG_SKIP_REPEATED;
cmd = *token++; else
} else { flags |= AV_LOG_SKIP_REPEATED;
cmd = 0;
} av_log_set_flags(flags);
if (!i && !cmd) { if (tail == arg)
flags = 0; /* missing relative prefix, build absolute value */ arg += 6 + (arg[6]=='+');
} if(tail && !*arg)
if (!strncmp(token, "repeat", 6)) { return 0;
if (cmd == '-') {
flags |= AV_LOG_SKIP_REPEATED;
} else {
flags &= ~AV_LOG_SKIP_REPEATED;
}
arg = token + 6;
} else if (!strncmp(token, "level", 5)) {
if (cmd == '-') {
flags &= ~AV_LOG_PRINT_LEVEL;
} else {
flags |= AV_LOG_PRINT_LEVEL;
}
arg = token + 5;
} else {
break;
}
i++;
}
if (!*arg) {
goto end;
} else if (*arg == '+') {
arg++;
} else if (!i) {
flags = av_log_get_flags(); /* level value without prefix, reset flags */
}
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
if (!strcmp(log_levels[i].name, arg)) { if (!strcmp(log_levels[i].name, arg)) {
level = log_levels[i].level; av_log_set_level(log_levels[i].level);
goto end; return 0;
} }
} }
@@ -940,9 +896,6 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
exit_program(1); exit_program(1);
} }
end:
av_log_set_flags(flags);
av_log_set_level(level); av_log_set_level(level);
return 0; return 0;
} }
@@ -1286,12 +1239,10 @@ static int is_device(const AVClass *avclass)
return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category); return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
} }
static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers) static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only)
{ {
void *ifmt_opaque = NULL; AVInputFormat *ifmt = NULL;
const AVInputFormat *ifmt = NULL; AVOutputFormat *ofmt = NULL;
void *ofmt_opaque = NULL;
const AVOutputFormat *ofmt = NULL;
const char *last_name; const char *last_name;
int is_dev; int is_dev;
@@ -1306,35 +1257,29 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
const char *name = NULL; const char *name = NULL;
const char *long_name = NULL; const char *long_name = NULL;
if (muxdemuxers !=SHOW_DEMUXERS) { while ((ofmt = av_oformat_next(ofmt))) {
ofmt_opaque = NULL; is_dev = is_device(ofmt->priv_class);
while ((ofmt = av_muxer_iterate(&ofmt_opaque))) { if (!is_dev && device_only)
is_dev = is_device(ofmt->priv_class); continue;
if (!is_dev && device_only) if ((!name || strcmp(ofmt->name, name) < 0) &&
continue; strcmp(ofmt->name, last_name) > 0) {
if ((!name || strcmp(ofmt->name, name) < 0) && name = ofmt->name;
strcmp(ofmt->name, last_name) > 0) { long_name = ofmt->long_name;
name = ofmt->name; encode = 1;
long_name = ofmt->long_name;
encode = 1;
}
} }
} }
if (muxdemuxers != SHOW_MUXERS) { while ((ifmt = av_iformat_next(ifmt))) {
ifmt_opaque = NULL; is_dev = is_device(ifmt->priv_class);
while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) { if (!is_dev && device_only)
is_dev = is_device(ifmt->priv_class); continue;
if (!is_dev && device_only) if ((!name || strcmp(ifmt->name, name) < 0) &&
continue; strcmp(ifmt->name, last_name) > 0) {
if ((!name || strcmp(ifmt->name, name) < 0) && name = ifmt->name;
strcmp(ifmt->name, last_name) > 0) { long_name = ifmt->long_name;
name = ifmt->name; encode = 0;
long_name = ifmt->long_name;
encode = 0;
}
if (name && strcmp(ifmt->name, name) == 0)
decode = 1;
} }
if (name && strcmp(ifmt->name, name) == 0)
decode = 1;
} }
if (!name) if (!name)
break; break;
@@ -1351,22 +1296,12 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
int show_formats(void *optctx, const char *opt, const char *arg) int show_formats(void *optctx, const char *opt, const char *arg)
{ {
return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT); return show_formats_devices(optctx, opt, arg, 0);
}
int show_muxers(void *optctx, const char *opt, const char *arg)
{
return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
}
int show_demuxers(void *optctx, const char *opt, const char *arg)
{
return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
} }
int show_devices(void *optctx, const char *opt, const char *arg) int show_devices(void *optctx, const char *opt, const char *arg)
{ {
return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT); return show_formats_devices(optctx, opt, arg, 1);
} }
#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
@@ -1632,11 +1567,10 @@ int show_encoders(void *optctx, const char *opt, const char *arg)
int show_bsfs(void *optctx, const char *opt, const char *arg) int show_bsfs(void *optctx, const char *opt, const char *arg)
{ {
const AVBitStreamFilter *bsf = NULL; AVBitStreamFilter *bsf = NULL;
void *opaque = NULL;
printf("Bitstream filters:\n"); printf("Bitstream filters:\n");
while ((bsf = av_bsf_iterate(&opaque))) while ((bsf = av_bitstream_filter_next(bsf)))
printf("%s\n", bsf->name); printf("%s\n", bsf->name);
printf("\n"); printf("\n");
return 0; return 0;
@@ -1662,7 +1596,6 @@ int show_filters(void *optctx, const char *opt, const char *arg)
#if CONFIG_AVFILTER #if CONFIG_AVFILTER
const AVFilter *filter = NULL; const AVFilter *filter = NULL;
char descr[64], *descr_cur; char descr[64], *descr_cur;
void *opaque = NULL;
int i, j; int i, j;
const AVFilterPad *pad; const AVFilterPad *pad;
@@ -1674,7 +1607,7 @@ int show_filters(void *optctx, const char *opt, const char *arg)
" V = Video input/output\n" " V = Video input/output\n"
" N = Dynamic number and/or type of input/output\n" " N = Dynamic number and/or type of input/output\n"
" | = Source or sink filter\n"); " | = Source or sink filter\n");
while ((filter = av_filter_iterate(&opaque))) { while ((filter = avfilter_next(filter))) {
descr_cur = descr; descr_cur = descr;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (i) { if (i) {
@@ -1737,7 +1670,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
#endif #endif
while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) { while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc); enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
printf("%c%c%c%c%c %-16s %d %2d\n", printf("%c%c%c%c%c %-16s %d %2d\n",
sws_isSupportedInput (pix_fmt) ? 'I' : '.', sws_isSupportedInput (pix_fmt) ? 'I' : '.',
sws_isSupportedOutput(pix_fmt) ? 'O' : '.', sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
@@ -1931,22 +1864,6 @@ static void show_help_filter(const char *name)
} }
#endif #endif
static void show_help_bsf(const char *name)
{
const AVBitStreamFilter *bsf = av_bsf_get_by_name(name);
if (!bsf) {
av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name);
return;
}
printf("Bit stream filter %s\n", bsf->name);
PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs",
AV_CODEC_ID_NONE, GET_CODEC_NAME);
if (bsf->priv_class)
show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM);
}
int show_help(void *optctx, const char *opt, const char *arg) int show_help(void *optctx, const char *opt, const char *arg)
{ {
char *topic, *par; char *topic, *par;
@@ -1973,8 +1890,6 @@ int show_help(void *optctx, const char *opt, const char *arg)
} else if (!strcmp(topic, "filter")) { } else if (!strcmp(topic, "filter")) {
show_help_filter(par); show_help_filter(par);
#endif #endif
} else if (!strcmp(topic, "bsf")) {
show_help_bsf(par);
} else { } else {
show_help_default(topic, par); show_help_default(topic, par);
} }
@@ -2066,7 +1981,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
codec = s->oformat ? avcodec_find_encoder(codec_id) codec = s->oformat ? avcodec_find_encoder(codec_id)
: avcodec_find_decoder(codec_id); : avcodec_find_decoder(codec_id);
switch (st->codecpar->codec_type) { switch (st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
prefix = 'v'; prefix = 'v';
flags |= AV_OPT_FLAG_VIDEO_PARAM; flags |= AV_OPT_FLAG_VIDEO_PARAM;
@@ -2124,7 +2039,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
return NULL; return NULL;
} }
for (i = 0; i < s->nb_streams; i++) for (i = 0; i < s->nb_streams; i++)
opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id,
s, s->streams[i], NULL); s, s->streams[i], NULL);
return opts; return opts;
} }
@@ -2150,10 +2065,18 @@ void *grow_array(void *array, int elem_size, int *size, int new_size)
double get_rotation(AVStream *st) double get_rotation(AVStream *st)
{ {
AVDictionaryEntry *rotate_tag = av_dict_get(st->metadata, "rotate", NULL, 0);
uint8_t* displaymatrix = av_stream_get_side_data(st, uint8_t* displaymatrix = av_stream_get_side_data(st,
AV_PKT_DATA_DISPLAYMATRIX, NULL); AV_PKT_DATA_DISPLAYMATRIX, NULL);
double theta = 0; double theta = 0;
if (displaymatrix)
if (rotate_tag && *rotate_tag->value && strcmp(rotate_tag->value, "0")) {
char *tail;
theta = av_strtod(rotate_tag->value, &tail);
if (*tail)
theta = 0;
}
if (displaymatrix && !theta)
theta = -av_display_rotation_get((int32_t*) displaymatrix); theta = -av_display_rotation_get((int32_t*) displaymatrix);
theta -= 360*floor(theta/360 + 0.9/360); theta -= 360*floor(theta/360 + 0.9/360);
@@ -2176,7 +2099,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL); return AVERROR(EINVAL);
printf("Auto-detected sources for %s:\n", fmt->name); printf("Audo-detected sources for %s:\n", fmt->name);
if (!fmt->get_device_list) { if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS); ret = AVERROR(ENOSYS);
printf("Cannot list sources. Not implemented.\n"); printf("Cannot list sources. Not implemented.\n");
@@ -2206,7 +2129,7 @@ static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL); return AVERROR(EINVAL);
printf("Auto-detected sinks for %s:\n", fmt->name); printf("Audo-detected sinks for %s:\n", fmt->name);
if (!fmt->get_device_list) { if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS); ret = AVERROR(ENOSYS);
printf("Cannot list sinks. Not implemented.\n"); printf("Cannot list sinks. Not implemented.\n");

View File

@@ -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 FFTOOLS_CMDUTILS_H #ifndef CMDUTILS_H
#define FFTOOLS_CMDUTILS_H #define CMDUTILS_H
#include <stdint.h> #include <stdint.h>
@@ -61,11 +61,6 @@ void register_exit(void (*cb)(int ret));
*/ */
void exit_program(int ret) av_noreturn; void exit_program(int ret) av_noreturn;
/**
* Initialize dynamic library loading
*/
void init_dynload(void);
/** /**
* Initialize the cmdutils option system, in particular * Initialize the cmdutils option system, in particular
* allocate the *_opts contexts. * allocate the *_opts contexts.
@@ -105,6 +100,12 @@ int opt_max_alloc(void *optctx, const char *opt, const char *arg);
int opt_codec_debug(void *optctx, const char *opt, const char *arg); int opt_codec_debug(void *optctx, const char *opt, const char *arg);
#if CONFIG_OPENCL
int opt_opencl(void *optctx, const char *opt, const char *arg);
int opt_opencl_bench(void *optctx, const char *opt, const char *arg);
#endif
/** /**
* Limit the execution time. * Limit the execution time.
*/ */
@@ -149,7 +150,6 @@ typedef struct SpecifierOpt {
uint8_t *str; uint8_t *str;
int i; int i;
int64_t i64; int64_t i64;
uint64_t ui64;
float f; float f;
double dbl; double dbl;
} u; } u;
@@ -201,47 +201,6 @@ typedef struct OptionDef {
void show_help_options(const OptionDef *options, const char *msg, int req_flags, void show_help_options(const OptionDef *options, const char *msg, int req_flags,
int rej_flags, int alt_flags); int rej_flags, int alt_flags);
#if CONFIG_AVDEVICE
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
{ "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \
"list sources of the input device", "device" }, \
{ "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \
"list sinks of the output device", "device" }, \
#else
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE
#endif
#define CMDUTILS_COMMON_OPTIONS \
{ "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" }, \
{ "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \
{ "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \
{ "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \
{ "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \
{ "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" }, \
CMDUTILS_COMMON_OPTIONS_AVDEVICE \
/** /**
* Show help for all options with given flags in class and all its * Show help for all options with given flags in class and all its
* children. * children.
@@ -477,20 +436,6 @@ int show_license(void *optctx, const char *opt, const char *arg);
*/ */
int show_formats(void *optctx, const char *opt, const char *arg); int show_formats(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the muxers supported by the
* program (including devices).
* This option processing function does not utilize the arguments.
*/
int show_muxers(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the demuxer supported by the
* program (including devices).
* This option processing function does not utilize the arguments.
*/
int show_demuxers(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the devices supported by the * Print a listing containing all the devices supported by the
* program. * program.
@@ -500,13 +445,13 @@ int show_devices(void *optctx, const char *opt, const char *arg);
#if CONFIG_AVDEVICE #if CONFIG_AVDEVICE
/** /**
* Print a listing containing autodetected sinks of the output device. * Print a listing containing audodetected sinks of the output device.
* Device name with options may be passed as an argument to limit results. * Device name with options may be passed as an argument to limit results.
*/ */
int show_sinks(void *optctx, const char *opt, const char *arg); int show_sinks(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing autodetected sources of the input device. * Print a listing containing audodetected sources of the input device.
* Device name with options may be passed as an argument to limit results. * Device name with options may be passed as an argument to limit results.
*/ */
int show_sources(void *optctx, const char *opt, const char *arg); int show_sources(void *optctx, const char *opt, const char *arg);
@@ -625,9 +570,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
#define GET_PIX_FMT_NAME(pix_fmt)\ #define GET_PIX_FMT_NAME(pix_fmt)\
const char *name = av_get_pix_fmt_name(pix_fmt); const char *name = av_get_pix_fmt_name(pix_fmt);
#define GET_CODEC_NAME(id)\
const char *name = avcodec_descriptor_get(id)->name;
#define GET_SAMPLE_FMT_NAME(sample_fmt)\ #define GET_SAMPLE_FMT_NAME(sample_fmt)\
const char *name = av_get_sample_fmt_name(sample_fmt) const char *name = av_get_sample_fmt_name(sample_fmt)
@@ -645,4 +587,4 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
double get_rotation(AVStream *st); double get_rotation(AVStream *st);
#endif /* FFTOOLS_CMDUTILS_H */ #endif /* CMDUTILS_H */

35
cmdutils_common_opts.h Normal file
View File

@@ -0,0 +1,35 @@
{ "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
#if CONFIG_AVDEVICE
{ "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },
"list sources of the input device", "device" },
{ "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },
"list sinks of the output device", "device" },
#endif

278
cmdutils_opencl.c Normal file
View File

@@ -0,0 +1,278 @@
/*
* Copyright (C) 2013 Lenny Wang
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/log.h"
#include "libavutil/opencl.h"
#include "libavutil/avstring.h"
#include "cmdutils.h"
typedef struct {
int platform_idx;
int device_idx;
char device_name[64];
int64_t runtime;
} OpenCLDeviceBenchmark;
const char *ocl_bench_source = AV_OPENCL_KERNEL(
inline unsigned char clip_uint8(int a)
{
if (a & (~0xFF))
return (-a)>>31;
else
return a;
}
kernel void unsharp_bench(
global unsigned char *src,
global unsigned char *dst,
global int *mask,
int width,
int height)
{
int i, j, local_idx, lc_idx, sum = 0;
int2 thread_idx, block_idx, global_idx, lm_idx;
thread_idx.x = get_local_id(0);
thread_idx.y = get_local_id(1);
block_idx.x = get_group_id(0);
block_idx.y = get_group_id(1);
global_idx.x = get_global_id(0);
global_idx.y = get_global_id(1);
local uchar data[32][32];
local int lc[128];
for (i = 0; i <= 1; i++) {
lm_idx.y = -8 + (block_idx.y + i) * 16 + thread_idx.y;
lm_idx.y = lm_idx.y < 0 ? 0 : lm_idx.y;
lm_idx.y = lm_idx.y >= height ? height - 1: lm_idx.y;
for (j = 0; j <= 1; j++) {
lm_idx.x = -8 + (block_idx.x + j) * 16 + thread_idx.x;
lm_idx.x = lm_idx.x < 0 ? 0 : lm_idx.x;
lm_idx.x = lm_idx.x >= width ? width - 1: lm_idx.x;
data[i*16 + thread_idx.y][j*16 + thread_idx.x] = src[lm_idx.y*width + lm_idx.x];
}
}
local_idx = thread_idx.y*16 + thread_idx.x;
if (local_idx < 128)
lc[local_idx] = mask[local_idx];
barrier(CLK_LOCAL_MEM_FENCE);
\n#pragma unroll\n
for (i = -4; i <= 4; i++) {
lm_idx.y = 8 + i + thread_idx.y;
\n#pragma unroll\n
for (j = -4; j <= 4; j++) {
lm_idx.x = 8 + j + thread_idx.x;
lc_idx = (i + 4)*8 + j + 4;
sum += (int)data[lm_idx.y][lm_idx.x] * lc[lc_idx];
}
}
int temp = (int)data[thread_idx.y + 8][thread_idx.x + 8];
int res = temp + (((temp - (int)((sum + 1<<15) >> 16))) >> 16);
if (global_idx.x < width && global_idx.y < height)
dst[global_idx.x + global_idx.y*width] = clip_uint8(res);
}
);
#define OCLCHECK(method, ... ) \
do { \
status = method(__VA_ARGS__); \
if (status != CL_SUCCESS) { \
av_log(NULL, AV_LOG_ERROR, # method " error '%s'\n", \
av_opencl_errstr(status)); \
ret = AVERROR_EXTERNAL; \
goto end; \
} \
} while (0)
#define CREATEBUF(out, flags, size) \
do { \
out = clCreateBuffer(ext_opencl_env->context, flags, size, NULL, &status); \
if (status != CL_SUCCESS) { \
av_log(NULL, AV_LOG_ERROR, "Could not create OpenCL buffer\n"); \
ret = AVERROR_EXTERNAL; \
goto end; \
} \
} while (0)
static void fill_rand_int(int *data, int n)
{
int i;
srand(av_gettime());
for (i = 0; i < n; i++)
data[i] = rand();
}
#define OPENCL_NB_ITER 5
static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env)
{
int i, arg = 0, width = 1920, height = 1088;
int64_t start, ret = 0;
cl_int status;
size_t kernel_len;
char *inbuf;
int *mask;
int buf_size = width * height * sizeof(char);
int mask_size = sizeof(uint32_t) * 128;
cl_mem cl_mask, cl_inbuf, cl_outbuf;
cl_kernel kernel = NULL;
cl_program program = NULL;
size_t local_work_size_2d[2] = {16, 16};
size_t global_work_size_2d[2] = {(size_t)width, (size_t)height};
if (!(inbuf = av_malloc(buf_size)) || !(mask = av_malloc(mask_size))) {
av_log(NULL, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
goto end;
}
fill_rand_int((int*)inbuf, buf_size/4);
fill_rand_int(mask, mask_size/4);
CREATEBUF(cl_mask, CL_MEM_READ_ONLY, mask_size);
CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, buf_size);
CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, buf_size);
kernel_len = strlen(ocl_bench_source);
program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source,
&kernel_len, &status);
if (status != CL_SUCCESS || !program) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n");
ret = AVERROR_EXTERNAL;
goto end;
}
kernel = clCreateKernel(program, "unsharp_bench", &status);
if (status != CL_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n");
ret = AVERROR_EXTERNAL;
goto end;
}
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0,
buf_size, inbuf, 0, NULL, NULL);
OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0,
mask_size, mask, 0, NULL, NULL);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_inbuf);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_outbuf);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_mask);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width);
OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height);
start = av_gettime_relative();
for (i = 0; i < OPENCL_NB_ITER; i++)
OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL,
global_work_size_2d, local_work_size_2d, 0, NULL, NULL);
clFinish(ext_opencl_env->command_queue);
ret = (av_gettime_relative() - start)/OPENCL_NB_ITER;
end:
if (kernel)
clReleaseKernel(kernel);
if (program)
clReleaseProgram(program);
if (cl_inbuf)
clReleaseMemObject(cl_inbuf);
if (cl_outbuf)
clReleaseMemObject(cl_outbuf);
if (cl_mask)
clReleaseMemObject(cl_mask);
av_free(inbuf);
av_free(mask);
return ret;
}
static int compare_ocl_device_desc(const void *a, const void *b)
{
const OpenCLDeviceBenchmark* va = (const OpenCLDeviceBenchmark*)a;
const OpenCLDeviceBenchmark* vb = (const OpenCLDeviceBenchmark*)b;
return FFDIFFSIGN(va->runtime , vb->runtime);
}
int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
{
int i, j, nb_devices = 0, count = 0;
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;
av_strlcpy(devices[count].device_name, device_node->device_name,
sizeof(devices[count].device_name));
count++;
}
}
}
qsort(devices, count, sizeof(OpenCLDeviceBenchmark), compare_ocl_device_desc);
fprintf(stderr, "platform_idx\tdevice_idx\tdevice_name\truntime\n");
for (i = 0; i < count; i++)
fprintf(stdout, "%d\t%d\t%s\t%"PRId64"\n",
devices[i].platform_idx, devices[i].device_idx,
devices[i].device_name, devices[i].runtime);
av_opencl_free_device_list(&device_list);
av_free(devices);
return 0;
}
int opt_opencl(void *optctx, const char *opt, const char *arg)
{
char *key, *value;
const char *opts = arg;
int ret = 0;
while (*opts) {
ret = av_opt_get_key_value(&opts, "=", ":", 0, &key, &value);
if (ret < 0)
return ret;
ret = av_opencl_set_option(key, value);
if (ret < 0)
return ret;
if (*opts)
opts++;
}
return ret;
}

View File

@@ -2,12 +2,15 @@
# common bits used by all libraries # common bits used by all libraries
# #
DEFAULT_X86ASMD=.dbg # first so "all" becomes default target
all: all-yes
DEFAULT_YASMD=.dbg
ifeq ($(DBG),1) ifeq ($(DBG),1)
X86ASMD=$(DEFAULT_X86ASMD) YASMD=$(DEFAULT_YASMD)
else else
X86ASMD= YASMD=
endif endif
ifndef SUBDIR ifndef SUBDIR
@@ -15,8 +18,8 @@ ifndef SUBDIR
ifndef V ifndef V
Q = @ Q = @
ECHO = printf "$(1)\t%s\n" $(2) ECHO = printf "$(1)\t%s\n" $(2)
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
MSG = $@ MSG = $@
M = @$(call ECHO,$(TAG),$@); M = @$(call ECHO,$(TAG),$@);
@@ -36,9 +39,8 @@ CCFLAGS = $(CPPFLAGS) $(CFLAGS)
OBJCFLAGS += $(EOBJCFLAGS) OBJCFLAGS += $(EOBJCFLAGS)
OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS) OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
ASFLAGS := $(CPPFLAGS) $(ASFLAGS) ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
X86ASMFLAGS += $(IFLAGS:%=%/) -I$(<D)/ -Pconfig.asm YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
NVCCFLAGS += -ptx
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS) HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS) LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
@@ -52,9 +54,7 @@ COMPILE_C = $(call COMPILE,CC)
COMPILE_CXX = $(call COMPILE,CXX) COMPILE_CXX = $(call COMPILE,CXX)
COMPILE_S = $(call COMPILE,AS) COMPILE_S = $(call COMPILE,AS)
COMPILE_M = $(call COMPILE,OBJCC) COMPILE_M = $(call COMPILE,OBJCC)
COMPILE_X86ASM = $(call COMPILE,X86ASM)
COMPILE_HOSTC = $(call COMPILE,HOSTCC) COMPILE_HOSTC = $(call COMPILE,HOSTCC)
COMPILE_NVCC = $(call COMPILE,NVCC)
%.o: %.c %.o: %.c
$(COMPILE_C) $(COMPILE_C)
@@ -74,14 +74,6 @@ COMPILE_NVCC = $(call COMPILE,NVCC)
%_host.o: %.c %_host.o: %.c
$(COMPILE_HOSTC) $(COMPILE_HOSTC)
%$(DEFAULT_X86ASMD).asm: %.asm
$(DEPX86ASM) $(X86ASMFLAGS) -M -o $@ $< > $(@:.asm=.d)
$(X86ASM) $(X86ASMFLAGS) -e $< | sed '/^%/d;/^$$/d;' > $@
%.o: %.asm
$(COMPILE_X86ASM)
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
%.o: %.rc %.o: %.rc
$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $< $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
@@ -91,13 +83,12 @@ COMPILE_NVCC = $(call COMPILE,NVCC)
%.h.c: %.h.c:
$(Q)echo '#include "$*.h"' >$@ $(Q)echo '#include "$*.h"' >$@
%.ptx: %.cu %.ver: %.v
$(COMPILE_NVCC) $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\
/' -e 's/; /;\
/g' > $@
%.ptx.c: %.ptx %.c %.h: TAG = GEN
$(Q)sh $(SRC_PATH)/compat/cuda/ptx2c.sh $@ $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
%.c %.h %.pc %.ver %.version: TAG = GEN
# Dummy rule to stop make trying to rebuild removed or renamed headers # Dummy rule to stop make trying to rebuild removed or renamed headers
%.h: %.h:
@@ -111,7 +102,7 @@ COMPILE_NVCC = $(call COMPILE,NVCC)
$(OBJS): $(OBJS):
endif endif
include $(SRC_PATH)/ffbuild/arch.mak include $(SRC_PATH)/arch.mak
OBJS += $(OBJS-yes) OBJS += $(OBJS-yes)
SLIBOBJS += $(SLIBOBJS-yes) SLIBOBJS += $(SLIBOBJS-yes)
@@ -119,12 +110,12 @@ FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes) TESTPROGS += $(TESTPROGS-yes)
LDLIBS = $(FFLIBS:%=%$(BUILDSUF)) LDLIBS = $(FFLIBS:%=%$(BUILDSUF))
FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) $(FFLIBS:%=EXTRALIBS-%),$($(lib))) $(EXTRALIBS) FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
OBJS := $(sort $(OBJS:%=$(SUBDIR)%)) OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%)) SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o) TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF)) TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o) HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF)) HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
TOOLS += $(TOOLS-yes) TOOLS += $(TOOLS-yes)
@@ -141,10 +132,8 @@ ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o)) HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
PTXOBJS = $(filter %.ptx.o,$(OBJS))
$(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
checkheaders: $(HOBJS) checkheaders: $(HOBJS)
.SECONDARY: $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=) .SECONDARY: $(HOBJS:.o=.c)
alltools: $(TOOLS) alltools: $(TOOLS)
@@ -152,7 +141,7 @@ $(HOSTOBJS): %.o: %.c
$(COMPILE_HOSTC) $(COMPILE_HOSTC)
$(HOSTPROGS): %$(HOSTEXESUF): %.o $(HOSTPROGS): %$(HOSTEXESUF): %.o
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS) $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
$(OBJS): | $(sort $(dir $(OBJS))) $(OBJS): | $(sort $(dir $(OBJS)))
$(HOBJS): | $(sort $(dir $(HOBJS))) $(HOBJS): | $(sort $(dir $(HOBJS)))
@@ -163,14 +152,17 @@ $(TOOLOBJS): | tools
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS)) OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.pc *.ptx *.ptx.c *.ver *.version *$(DEFAULT_X86ASMD).asm *~ CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ver-sol2 *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm
DISTCLEANSUFFIXES = *.pc
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
define RULES define RULES
clean:: clean::
$(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS) $(RM) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=$(DEFAULT_YASMD).d)
$(RM) $(HOSTPROGS)
$(RM) $(TOOLS)
endef endef
$(eval $(RULES)) $(eval $(RULES))
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d) -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_YASMD).d)

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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(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)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 */

View File

@@ -75,149 +75,54 @@ enum {AVS_PLANAR_Y=1<<0,
AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED}; AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED};
// Colorspace properties. // Colorspace properties.
enum { enum {AVS_CS_BGR = 1<<28,
AVS_CS_YUVA = 1 << 27, AVS_CS_YUV = 1<<29,
AVS_CS_BGR = 1 << 28, AVS_CS_INTERLEAVED = 1<<30,
AVS_CS_YUV = 1 << 29, AVS_CS_PLANAR = 1<<31,
AVS_CS_INTERLEAVED = 1 << 30,
AVS_CS_PLANAR = 1 << 31,
AVS_CS_SHIFT_SUB_WIDTH = 0, AVS_CS_SHIFT_SUB_WIDTH = 0,
AVS_CS_SHIFT_SUB_HEIGHT = 8, AVS_CS_SHIFT_SUB_HEIGHT = 8,
AVS_CS_SHIFT_SAMPLE_BITS = 16, AVS_CS_SHIFT_SAMPLE_BITS = 16,
AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, 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_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_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_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
AVS_CS_UPLANEFIRST = 1 << 4, // I420 AVS_CS_UPLANEFIRST = 1 << 4, // I420
AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, 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_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_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 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_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS, AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,
AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS, AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,
AVS_CS_SAMPLE_BITS_14 = 7 << 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_YUVA | 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),
AVS_CS_RGB_TYPE = 1 << 0,
AVS_CS_RGBA_TYPE = 1 << 1,
AVS_CS_GENERIC_YUV420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0 planar
AVS_CS_GENERIC_YUV422 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2 planar
AVS_CS_GENERIC_YUV444 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // 4:4:4 planar
AVS_CS_GENERIC_Y = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV, // Y only (4:0:0)
AVS_CS_GENERIC_RGBP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE, // planar RGB
AVS_CS_GENERIC_RGBAP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE, // planar RGBA
AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0:A planar
AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2:A planar
AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1 }; // 4:4:4:A planar
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 // Specific colorformats
enum { enum {
AVS_CS_UNKNOWN = 0, AVS_CS_UNKNOWN = 0,
AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | 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_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
// AVS_CS_YV12 = 1<<3 Reserved // AVS_CS_YV12 = 1<<3 Reserved
// AVS_CS_I420 = 1<<4 Reserved // AVS_CS_I420 = 1<<4 Reserved
AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED, AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED,
AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YVU 4:4:4 planar 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_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YVU 4:2:2 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_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YVU 4:2:0 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_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_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_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_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_GENERIC_Y | AVS_CS_SAMPLE_BITS_8, // Y 4:0:0 planar AVS_CS_Y8 = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 // Y 4:0:0 planar
//-------------------------
// AVS16: new planar constants go live! Experimental PF 160613
// 10-12-14 bit + planar RGB + BRG48/64 160725
AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples
AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples
AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples
AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples
AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples
AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples
AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples
AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples
AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples
AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples
AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples
AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples
AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples
AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples
AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples
AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples
// 32 bit samples (float)
AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32, // YUV 4:4:4 32bit samples
AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:2 32bit samples
AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:0 32bit samples
AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples
// RGB packed
AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 3x16 bit
AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 4x16 bit
// no packed 32 bit (float) support for these legacy types
// RGB planar
AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples
AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples
AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples
AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples
AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples
AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples
// RGBA planar
AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples
AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples
AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples
AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples
AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples
AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples
// Planar YUVA
AVS_CS_YUVA444 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:4:4 8bit samples
AVS_CS_YUVA422 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:2 8bit samples
AVS_CS_YUVA420 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:0 8bit samples
AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples
AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples
AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples
AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples
AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples
AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples
AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples
AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples
AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples
AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples
AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples
AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples
AVS_CS_YUVA444PS = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:4:4 32bit samples
AVS_CS_YUVA422PS = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:2 32bit samples
AVS_CS_YUVA420PS = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:0 32bit samples
}; };
enum { enum {
@@ -342,10 +247,10 @@ AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)
{ return !!(p->pixel_type&AVS_CS_BGR); } { return !!(p->pixel_type&AVS_CS_BGR); }
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p) AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)
{ return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } { return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties
AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p) AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)
{ return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } { return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; }
AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)
{ return !!(p->pixel_type&AVS_CS_YUV ); } { return !!(p->pixel_type&AVS_CS_YUV ); }
@@ -353,10 +258,6 @@ AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)
AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)
{ return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p);
@@ -367,38 +268,6 @@ AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p);
AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p);
AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property) AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
{ return ((p->image_type & property)==property ); } { return ((p->image_type & property)==property ); }
@@ -496,12 +365,6 @@ AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)
} }
#endif #endif
AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p);
AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p);
AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p);
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
// AVS_VideoFrame // AVS_VideoFrame
@@ -665,7 +528,7 @@ AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0)
{ AVS_Value v; avs_set_to_clip(&v, v0); return v; } { AVS_Value v; avs_set_to_clip(&v, v0); return v; }
#endif #endif
AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) 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 = (short)size; return v; } { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
@@ -898,28 +761,11 @@ struct AVS_Library {
AVSC_DECLARE_FUNC(avs_vsprintf); AVSC_DECLARE_FUNC(avs_vsprintf);
AVSC_DECLARE_FUNC(avs_get_error); AVSC_DECLARE_FUNC(avs_get_error);
AVSC_DECLARE_FUNC(avs_is_rgb48);
AVSC_DECLARE_FUNC(avs_is_rgb64);
AVSC_DECLARE_FUNC(avs_is_yv24); AVSC_DECLARE_FUNC(avs_is_yv24);
AVSC_DECLARE_FUNC(avs_is_yv16); AVSC_DECLARE_FUNC(avs_is_yv16);
AVSC_DECLARE_FUNC(avs_is_yv12); AVSC_DECLARE_FUNC(avs_is_yv12);
AVSC_DECLARE_FUNC(avs_is_yv411); AVSC_DECLARE_FUNC(avs_is_yv411);
AVSC_DECLARE_FUNC(avs_is_y8); AVSC_DECLARE_FUNC(avs_is_y8);
AVSC_DECLARE_FUNC(avs_is_yuv444p16);
AVSC_DECLARE_FUNC(avs_is_yuv422p16);
AVSC_DECLARE_FUNC(avs_is_yuv420p16);
AVSC_DECLARE_FUNC(avs_is_y16);
AVSC_DECLARE_FUNC(avs_is_yuv444ps);
AVSC_DECLARE_FUNC(avs_is_yuv422ps);
AVSC_DECLARE_FUNC(avs_is_yuv420ps);
AVSC_DECLARE_FUNC(avs_is_y32);
AVSC_DECLARE_FUNC(avs_is_444);
AVSC_DECLARE_FUNC(avs_is_422);
AVSC_DECLARE_FUNC(avs_is_420);
AVSC_DECLARE_FUNC(avs_is_y);
AVSC_DECLARE_FUNC(avs_is_yuva);
AVSC_DECLARE_FUNC(avs_is_planar_rgb);
AVSC_DECLARE_FUNC(avs_is_planar_rgba);
AVSC_DECLARE_FUNC(avs_is_color_space); AVSC_DECLARE_FUNC(avs_is_color_space);
AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling); AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);
@@ -934,11 +780,6 @@ struct AVS_Library {
AVSC_DECLARE_FUNC(avs_get_read_ptr_p); AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
AVSC_DECLARE_FUNC(avs_is_writable); AVSC_DECLARE_FUNC(avs_is_writable);
AVSC_DECLARE_FUNC(avs_get_write_ptr_p); AVSC_DECLARE_FUNC(avs_get_write_ptr_p);
AVSC_DECLARE_FUNC(avs_num_components);
AVSC_DECLARE_FUNC(avs_component_size);
AVSC_DECLARE_FUNC(avs_bits_per_component);
}; };
#undef AVSC_DECLARE_FUNC #undef AVSC_DECLARE_FUNC
@@ -999,28 +840,11 @@ AVSC_INLINE AVS_Library * avs_load_library() {
AVSC_LOAD_FUNC(avs_vsprintf); AVSC_LOAD_FUNC(avs_vsprintf);
AVSC_LOAD_FUNC(avs_get_error); AVSC_LOAD_FUNC(avs_get_error);
AVSC_LOAD_FUNC(avs_is_rgb48);
AVSC_LOAD_FUNC(avs_is_rgb64);
AVSC_LOAD_FUNC(avs_is_yv24); AVSC_LOAD_FUNC(avs_is_yv24);
AVSC_LOAD_FUNC(avs_is_yv16); AVSC_LOAD_FUNC(avs_is_yv16);
AVSC_LOAD_FUNC(avs_is_yv12); AVSC_LOAD_FUNC(avs_is_yv12);
AVSC_LOAD_FUNC(avs_is_yv411); AVSC_LOAD_FUNC(avs_is_yv411);
AVSC_LOAD_FUNC(avs_is_y8); AVSC_LOAD_FUNC(avs_is_y8);
AVSC_LOAD_FUNC(avs_is_yuv444p16);
AVSC_LOAD_FUNC(avs_is_yuv422p16);
AVSC_LOAD_FUNC(avs_is_yuv420p16);
AVSC_LOAD_FUNC(avs_is_y16);
AVSC_LOAD_FUNC(avs_is_yuv444ps);
AVSC_LOAD_FUNC(avs_is_yuv422ps);
AVSC_LOAD_FUNC(avs_is_yuv420ps);
AVSC_LOAD_FUNC(avs_is_y32);
AVSC_LOAD_FUNC(avs_is_444);
AVSC_LOAD_FUNC(avs_is_422);
AVSC_LOAD_FUNC(avs_is_420);
AVSC_LOAD_FUNC(avs_is_y);
AVSC_LOAD_FUNC(avs_is_yuva);
AVSC_LOAD_FUNC(avs_is_planar_rgb);
AVSC_LOAD_FUNC(avs_is_planar_rgba);
AVSC_LOAD_FUNC(avs_is_color_space); AVSC_LOAD_FUNC(avs_is_color_space);
AVSC_LOAD_FUNC(avs_get_plane_width_subsampling); AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);
@@ -1036,12 +860,6 @@ AVSC_INLINE AVS_Library * avs_load_library() {
AVSC_LOAD_FUNC(avs_is_writable); AVSC_LOAD_FUNC(avs_is_writable);
AVSC_LOAD_FUNC(avs_get_write_ptr_p); AVSC_LOAD_FUNC(avs_get_write_ptr_p);
AVSC_LOAD_FUNC(avs_num_components);
AVSC_LOAD_FUNC(avs_component_size);
AVSC_LOAD_FUNC(avs_bits_per_component);
#undef __AVSC_STRINGIFY #undef __AVSC_STRINGIFY
#undef AVSC_STRINGIFY #undef AVSC_STRINGIFY
#undef AVSC_LOAD_FUNC #undef AVSC_LOAD_FUNC

View File

@@ -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 AV_COMPAT_CUDA_DYNLINK_LOADER_H
#define AV_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

View File

@@ -1,36 +0,0 @@
#!/bin/sh
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
#
# 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.
set -e
OUT="$1"
IN="$2"
NAME="$(basename "$IN" | sed 's/\..*//')"
printf "const char %s_ptx[] = \\" "$NAME" > "$OUT"
while read LINE
do
printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT"
done < "$IN"
printf ";\n" >> "$OUT"
exit 0

View File

@@ -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 */

View File

@@ -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.
* *
@@ -46,11 +46,9 @@ typedef struct {
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; HEV ack_sem;
@@ -100,28 +98,28 @@ static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
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;
} }

10
compat/plan9/head Executable file
View 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 "$@"

View File

@@ -1,7 +1,4 @@
/* /*
* NewTek NDI common code
* Copyright (c) 2017 Maksym Veremeyenko
*
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
* FFmpeg is free software; you can redistribute it and/or * FFmpeg is free software; you can redistribute it and/or
@@ -19,12 +16,19 @@
* 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 AVDEVICE_LIBNDI_NEWTEK_COMMON_H int plan9_main(int argc, char **argv);
#define AVDEVICE_LIBNDI_NEWTEK_COMMON_H
#include <Processing.NDI.Lib.h>
#define NDI_TIME_BASE 10000000
#define NDI_TIME_BASE_Q (AVRational){1, NDI_TIME_BASE}
#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 #endif
return plan9_main(argc, argv);
}

2
compat/plan9/printf Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
exec awk "BEGIN { for (i = 2; i < ARGC; i++) printf \"$1\", ARGV[i] }" "$@"

View File

@@ -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;
} }

View File

@@ -1,6 +1,4 @@
/* /*
* Copyright (c) 2017 Google Inc.
*
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
* FFmpeg is free software; you can redistribute it and/or * FFmpeg is free software; you can redistribute it and/or
@@ -18,12 +16,15 @@
* 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 AVCODEC_ARM_VP9DSP_INIT_H #ifndef COMPAT_TMS470_MATH_H
#define AVCODEC_ARM_VP9DSP_INIT_H #define COMPAT_TMS470_MATH_H
#include "libavcodec/vp9dsp.h" #include_next <math.h>
void ff_vp9dsp_init_10bpp_arm(VP9DSPContext *dsp); #undef INFINITY
void ff_vp9dsp_init_12bpp_arm(VP9DSPContext *dsp); #undef NAN
#endif /* AVCODEC_ARM_VP9DSP_INIT_H */ #define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 }))
#define NAN (*(const float*)((const unsigned []){ 0x7fc00000 }))
#endif /* COMPAT_TMS470_MATH_H */

View File

@@ -1,94 +0,0 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef COMPAT_W32DLFCN_H
#define COMPAT_W32DLFCN_H
#ifdef _WIN32
#include <windows.h>
#include "config.h"
#if (_WIN32_WINNT < 0x0602) || HAVE_WINRT
#include "libavutil/wchar_filename.h"
#endif
/**
* Safe function used to open dynamic libs. This attempts to improve program security
* by removing the current directory from the dll search path. Only dll's found in the
* executable or system directory are allowed to be loaded.
* @param name The dynamic lib name.
* @return A handle to the opened lib.
*/
static inline HMODULE win32_dlopen(const char *name)
{
#if _WIN32_WINNT < 0x0602
// Need to check if KB2533623 is available
if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) {
HMODULE module = NULL;
wchar_t *path = NULL, *name_w = NULL;
DWORD pathlen;
if (utf8towchar(name, &name_w))
goto exit;
path = (wchar_t *)av_mallocz_array(MAX_PATH, sizeof(wchar_t));
// Try local directory first
pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
pathlen = wcsrchr(path, '\\') - path;
if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
goto exit;
path[pathlen] = '\\';
wcscpy(path + pathlen + 1, name_w);
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (module == NULL) {
// Next try System32 directory
pathlen = GetSystemDirectoryW(path, MAX_PATH);
if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
goto exit;
path[pathlen] = '\\';
wcscpy(path + pathlen + 1, name_w);
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
exit:
av_free(path);
av_free(name_w);
return module;
}
#endif
#ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR
# define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
#endif
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif
#if HAVE_WINRT
wchar_t *name_w = NULL;
int ret;
if (utf8towchar(name, &name_w))
return NULL;
ret = LoadPackagedLibrary(name_w, 0);
av_free(name_w);
return ret;
#else
return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
#endif
}
#define dlopen(name, flags) win32_dlopen(name)
#define dlclose FreeLibrary
#define dlsym GetProcAddress
#else
#include <dlfcn.h>
#endif
#endif /* COMPAT_W32DLFCN_H */

View File

@@ -39,6 +39,11 @@
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>
#if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
#undef MemoryBarrier
#define MemoryBarrier __sync_synchronize
#endif
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/internal.h" #include "libavutil/internal.h"
@@ -51,19 +56,28 @@ 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 CRITICAL_SECTION pthread_mutex_t;
/* This is the CONDITION_VARIABLE typedef for using Windows' native
* conditional variables on kernels 6.0+. */
#if HAVE_CONDITION_VARIABLE_PTR
typedef CONDITION_VARIABLE pthread_cond_t; typedef CONDITION_VARIABLE pthread_cond_t;
#else
typedef struct pthread_cond_t {
void *Ptr;
} pthread_cond_t;
#endif
#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT #if _WIN32_WINNT >= 0x0600
#define PTHREAD_COND_INITIALIZER CONDITION_VARIABLE_INIT
#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
#define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE) #define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE)
#endif
static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg) 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;
} }
@@ -100,25 +114,26 @@ static av_unused int pthread_join(pthread_t thread, void **value_ptr)
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;
} }
#if _WIN32_WINNT >= 0x0600
typedef INIT_ONCE pthread_once_t; typedef INIT_ONCE pthread_once_t;
#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT #define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
@@ -152,7 +167,7 @@ static inline int pthread_cond_broadcast(pthread_cond_t *cond)
static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{ {
SleepConditionVariableSRW(cond, mutex, INFINITE, 0); SleepConditionVariableCS(cond, mutex, INFINITE);
return 0; return 0;
} }
@@ -162,4 +177,242 @@ static inline int pthread_cond_signal(pthread_cond_t *cond)
return 0; return 0;
} }
#else // _WIN32_WINNT < 0x0600
/* atomic init state of dynamically loaded functions */
static LONG w32thread_init_state = 0;
static av_unused void w32thread_init(void);
/* for pre-Windows 6.0 platforms, define INIT_ONCE struct,
* compatible to the one used in the native API */
typedef union pthread_once_t {
void * Ptr; ///< For the Windows 6.0+ native functions
LONG state; ///< For the pre-Windows 6.0 compat code
} pthread_once_t;
#define PTHREAD_ONCE_INIT {0}
/* function pointers to init once API on windows 6.0+ kernels */
static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD dwFlags, BOOL *fPending, void **lpContext);
static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce, DWORD dwFlags, void *lpContext);
/* pre-Windows 6.0 compat using a spin-lock */
static inline void w32thread_once_fallback(LONG volatile *state, void (*init_routine)(void))
{
switch (InterlockedCompareExchange(state, 1, 0)) {
/* Initial run */
case 0:
init_routine();
InterlockedExchange(state, 2);
break;
/* Another thread is running init */
case 1:
while (1) {
MemoryBarrier();
if (*state == 2)
break;
Sleep(0);
}
break;
/* Initialization complete */
case 2:
break;
}
}
static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
{
w32thread_once_fallback(&w32thread_init_state, w32thread_init);
/* Use native functions on Windows 6.0+ */
if (initonce_begin && initonce_complete) {
BOOL pending = FALSE;
initonce_begin(once_control, 0, &pending, NULL);
if (pending)
init_routine();
initonce_complete(once_control, 0, NULL);
return 0;
}
w32thread_once_fallback(&once_control->state, init_routine);
return 0;
}
/* for pre-Windows 6.0 platforms we need to define and use our own condition
* variable and api */
typedef struct win32_cond_t {
pthread_mutex_t mtx_broadcast;
pthread_mutex_t mtx_waiter_count;
volatile int waiter_count;
HANDLE semaphore;
HANDLE waiters_done;
volatile int is_broadcast;
} win32_cond_t;
/* function pointers to conditional variable API on windows 6.0+ kernels */
static void (WINAPI *cond_broadcast)(pthread_cond_t *cond);
static void (WINAPI *cond_init)(pthread_cond_t *cond);
static void (WINAPI *cond_signal)(pthread_cond_t *cond);
static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex,
DWORD milliseconds);
static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
{
win32_cond_t *win32_cond = NULL;
w32thread_once_fallback(&w32thread_init_state, w32thread_init);
if (cond_init) {
cond_init(cond);
return 0;
}
/* non native condition variables */
win32_cond = av_mallocz(sizeof(win32_cond_t));
if (!win32_cond)
return ENOMEM;
cond->Ptr = win32_cond;
win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
if (!win32_cond->semaphore)
return ENOMEM;
win32_cond->waiters_done = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!win32_cond->waiters_done)
return ENOMEM;
pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL);
pthread_mutex_init(&win32_cond->mtx_broadcast, NULL);
return 0;
}
static av_unused int pthread_cond_destroy(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->Ptr;
/* native condition variables do not destroy */
if (cond_init)
return 0;
/* non native condition variables */
CloseHandle(win32_cond->semaphore);
CloseHandle(win32_cond->waiters_done);
pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
pthread_mutex_destroy(&win32_cond->mtx_broadcast);
av_freep(&win32_cond);
cond->Ptr = NULL;
return 0;
}
static av_unused int pthread_cond_broadcast(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->Ptr;
int have_waiter;
if (cond_broadcast) {
cond_broadcast(cond);
return 0;
}
/* non native condition variables */
pthread_mutex_lock(&win32_cond->mtx_broadcast);
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
have_waiter = 0;
if (win32_cond->waiter_count) {
win32_cond->is_broadcast = 1;
have_waiter = 1;
}
if (have_waiter) {
ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
WaitForSingleObject(win32_cond->waiters_done, INFINITE);
ResetEvent(win32_cond->waiters_done);
win32_cond->is_broadcast = 0;
} else
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
return 0;
}
static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
win32_cond_t *win32_cond = cond->Ptr;
int last_waiter;
if (cond_wait) {
cond_wait(cond, mutex, INFINITE);
return 0;
}
/* non native condition variables */
pthread_mutex_lock(&win32_cond->mtx_broadcast);
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
win32_cond->waiter_count++;
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
// unlock the external mutex
pthread_mutex_unlock(mutex);
WaitForSingleObject(win32_cond->semaphore, INFINITE);
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
win32_cond->waiter_count--;
last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast;
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
if (last_waiter)
SetEvent(win32_cond->waiters_done);
// lock the external mutex
return pthread_mutex_lock(mutex);
}
static av_unused int pthread_cond_signal(pthread_cond_t *cond)
{
win32_cond_t *win32_cond = cond->Ptr;
int have_waiter;
if (cond_signal) {
cond_signal(cond);
return 0;
}
pthread_mutex_lock(&win32_cond->mtx_broadcast);
/* non-native condition variables */
pthread_mutex_lock(&win32_cond->mtx_waiter_count);
have_waiter = win32_cond->waiter_count;
pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
if (have_waiter) {
ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
WaitForSingleObject(win32_cond->waiters_done, INFINITE);
ResetEvent(win32_cond->waiters_done);
}
pthread_mutex_unlock(&win32_cond->mtx_broadcast);
return 0;
}
#endif
static av_unused void w32thread_init(void)
{
#if _WIN32_WINNT < 0x0600
HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll"));
/* if one is available, then they should all be available */
cond_init =
(void*)GetProcAddress(kernel_dll, "InitializeConditionVariable");
cond_broadcast =
(void*)GetProcAddress(kernel_dll, "WakeAllConditionVariable");
cond_signal =
(void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
cond_wait =
(void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
initonce_begin =
(void*)GetProcAddress(kernel_dll, "InitOnceBeginInitialize");
initonce_complete =
(void*)GetProcAddress(kernel_dll, "InitOnceComplete");
#endif
}
#endif /* COMPAT_W32PTHREADS_H */ #endif /* COMPAT_W32PTHREADS_H */

View File

@@ -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 -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 -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

3757
configure vendored

File diff suppressed because it is too large Load Diff

9
doc/.gitignore vendored
View File

@@ -1,9 +0,0 @@
/*.1
/*.3
/*.html
/*.pod
/config.texi
/avoptions_codec.texi
/avoptions_format.texi
/fate.txt
/print_options

View File

@@ -2,575 +2,19 @@ Never assume the API of libav* to be stable unless at least 1 month has passed
since the last major version increase or the API was added. since the last major version increase or the API was added.
The last version increases were: The last version increases were:
libavcodec: 2017-10-21 libavcodec: 2015-08-28
libavdevice: 2017-10-21 libavdevice: 2015-08-28
libavfilter: 2017-10-21 libavfilter: 2015-08-28
libavformat: 2017-10-21 libavformat: 2015-08-28
libavresample: 2017-10-21 libavresample: 2015-08-28
libpostproc: 2017-10-21 libpostproc: 2015-08-28
libswresample: 2017-10-21 libswresample: 2015-08-28
libswscale: 2017-10-21 libswscale: 2015-08-28
libavutil: 2017-10-21 libavutil: 2015-08-28
API changes, most recent first: API changes, most recent first:
-------- 8< --------- FFmpeg 4.0 was cut here -------- 8< ---------
2018-04-03 - d6fc031caf - lavu 56.13.100 - pixdesc.h
Deprecate AV_PIX_FMT_FLAG_PSEUDOPAL and make allocating a pseudo palette
optional for API users (see AV_PIX_FMT_FLAG_PSEUDOPAL doxygen for details).
2018-04-01 - 860086ee16 - lavc 58.17.100 - avcodec.h
Add av_packet_make_refcounted().
2018-04-01 - f1805d160d - lavfi 7.14.100 - avfilter.h
Deprecate use of avfilter_register(), avfilter_register_all(),
avfilter_next(). Add av_filter_iterate().
2018-03-25 - b7d0d912ef - lavc 58.16.100 - avcodec.h
Add FF_SUB_CHARENC_MODE_IGNORE.
2018-03-23 - db2a7c947e - lavu 56.12.100 - encryption_info.h
Add AVEncryptionInitInfo and AVEncryptionInfo structures to hold new side-data
for encryption info.
2018-03-21 - f14ca60001 - lavc 58.15.100 - avcodec.h
Add av_packet_make_writable().
2018-03-18 - 4b86ac27a0 - lavu 56.11.100 - frame.h
Add AV_FRAME_DATA_QP_TABLE_PROPERTIES and AV_FRAME_DATA_QP_TABLE_DATA.
2018-03-15 - e0e72539cf - lavu 56.10.100 - opt.h
Add AV_OPT_FLAG_BSF_PARAM
2018-03-07 - 950170bd3b - lavu 56.9.100 - crc.h
Add AV_CRC_8_EBU crc variant.
2018-03-07 - 2a0eb86857 - lavc 58.14.100 - mediacodec.h
Change the default behavior of avcodec_flush() on mediacodec
video decoders. To restore the previous behavior, use the new
delay_flush=1 option.
2018-03-01 - 6731f60598 - lavu 56.8.100 - frame.h
Add av_frame_new_side_data_from_buf().
2018-02-15 - 8a8d0b319a
Change av_ripemd_update(), av_murmur3_update() and av_hash_update() length
parameter type to size_t at next major bump.
2018-02-12 - bcab11a1a2 - lavfi 7.12.100 - avfilter.h
Add AVFilterContext.extra_hw_frames.
2018-02-12 - d23fff0d8a - lavc 58.11.100 - avcodec.h
Add AVCodecContext.extra_hw_frames.
2018-02-06 - 0694d87024 - lavf 58.9.100 - avformat.h
Deprecate use of av_register_input_format(), av_register_output_format(),
av_register_all(), av_iformat_next(), av_oformat_next().
Add av_demuxer_iterate(), and av_muxer_iterate().
2018-02-06 - 36c85d6e77 - lavc 58.10.100 - avcodec.h
Deprecate use of avcodec_register(), avcodec_register_all(),
av_codec_next(), av_register_codec_parser(), and av_parser_next().
Add av_codec_iterate() and av_parser_iterate().
2018-02-04 - ff46124b0d - lavf 58.8.100 - avformat.h
Deprecate the current names of the RTSP "timeout", "stimeout", "user-agent"
options. Introduce "listen_timeout" as replacement for the current "timeout"
option, and "user_agent" as replacement for "user-agent". Once the deprecation
is over, the old "timeout" option will be removed, and "stimeout" will be
renamed to "stimeout" (the "timeout" option will essentially change semantics).
2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
Deprecate AVFormatContext filename field which had limited length, use the
new dynamically allocated url field instead.
2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
Add url field to AVFormatContext and add ff_format_set_url helper function.
2018-01-27 - 6194d7e564 - lavf 58.6.100 - avformat.h
Add AVFMTCTX_UNSEEKABLE (for HLS demuxer).
2018-01-23 - 9f07cf7c00 - lavu 56.9.100 - aes_ctr.h
Add method to set the 16-byte IV.
2018-01-16 - 631c56a8e4 - lavf 58.5.100 - avformat.h
Explicitly make avformat_network_init() and avformat_network_deinit() optional.
If these are not called, network initialization and deinitialization is
automatic, and unlike in older versions, fully supported, unless libavformat
is linked to ancient GnuTLS and OpenSSL.
2018-01-16 - 6512ff72f9 - lavf 58.4.100 - avformat.h
Deprecate AVStream.recommended_encoder_configuration. It was useful only for
FFserver, which has been removed.
2018-01-05 - 798dcf2432 - lavfi 7.11.101 - avfilter.h
Deprecate avfilter_link_get_channels(). Use av_buffersink_get_channels().
2017-01-04 - c29038f304 - lavr 4.0.0 - avresample.h
Deprecate the entire library. Merged years ago to provide compatibility
with Libav, it remained unmaintained by the FFmpeg project and duplicated
functionality provided by libswresample.
In order to improve consistency and reduce attack surface, it has been deprecated.
Users of this library are asked to migrate to libswresample, which, as well as
providing more functionality, is faster and has higher accuracy.
2017-12-26 - a04c2c707d - lavc 58.9.100 - avcodec.h
Deprecate av_lockmgr_register(). You need to build FFmpeg with threading
support enabled to get basic thread-safety (which is the default build
configuration).
2017-12-24 - 8b81eabe57 - lavu 56.7.100 - cpu.h
AVX-512 flags added.
2017-12-16 - 8bf4e6d3ce - lavc 58.8.100 - avcodec.h
The MediaCodec decoders now support AVCodecContext.hw_device_ctx.
2017-12-16 - e4d9f05ca7 - lavu 56.6.100 - hwcontext.h hwcontext_mediacodec.h
Add AV_HWDEVICE_TYPE_MEDIACODEC and a new installed header with
MediaCodec-specific hwcontext definitions.
2017-12-14 - b945fed629 - lavc 58.7.100 - avcodec.h
Add AV_CODEC_CAP_HARDWARE, AV_CODEC_CAP_HYBRID, and AVCodec.wrapper_name,
and mark all AVCodecs accordingly.
2017-11-29 - d268094f88 - lavu 56.4.100 / 56.7.0 - stereo3d.h
Add view field to AVStereo3D structure and AVStereo3DView enum.
2017-11-26 - 3a71bcc213 - lavc 58.6.100 - avcodec.h
Add const to AVCodecContext.hwaccel.
2017-11-26 - 3536a3efb9 - lavc 58.5.100 - avcodec.h
Deprecate user visibility of the AVHWAccel structure and the functions
av_register_hwaccel() and av_hwaccel_next().
2017-11-26 - 24cc0a53e9 - lavc 58.4.100 - avcodec.h
Add AVCodecHWConfig and avcodec_get_hw_config().
2017-11-22 - 3650cb2dfa - lavu 56.3.100 - opencl.h
Remove experimental OpenCL API (av_opencl_*).
2017-11-22 - b25d8ef0a7 - lavu 56.2.100 - hwcontext.h hwcontext_opencl.h
Add AV_HWDEVICE_TYPE_OPENCL and a new installed header with
OpenCL-specific hwcontext definitions.
2017-11-22 - a050f56c09 - lavu 56.1.100 - pixfmt.h
Add AV_PIX_FMT_OPENCL.
2017-11-11 - 48e4eda11d - lavc 58.3.100 - avcodec.h
Add avcodec_get_hw_frames_parameters().
-------- 8< --------- FFmpeg 3.4 was cut here -------- 8< ---------
2017-09-28 - b6cf66ae1c - lavc 57.106.104 - avcodec.h
Add AV_PKT_DATA_A53_CC packet side data, to export closed captions
2017-09-27 - 7aa6b8a68f - lavu 55.77.101 / lavu 55.31.1 - frame.h
Allow passing the value of 0 (meaning "automatic") as the required alignment
to av_frame_get_buffer().
2017-09-27 - 522f877086 - lavu 55.77.100 / lavu 55.31.0 - cpu.h
Add av_cpu_max_align() for querying maximum required data alignment.
2017-09-26 - b1cf151c4d - lavc 57.106.102 - avcodec.h
Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
(avcodec_send_packet/avcodec_receive_frame) always work with reference
counted frames.
2017-09-21 - 6f15f1cdc8 - lavu 55.76.100 / 56.6.0 - pixdesc.h
Add av_color_range_from_name(), av_color_primaries_from_name(),
av_color_transfer_from_name(), av_color_space_from_name(), and
av_chroma_location_from_name().
2017-09-13 - 82342cead1 - lavc 57.106.100 - avcodec.h
Add AV_PKT_FLAG_TRUSTED.
2017-09-13 - 9cb23cd9fe - lavu 55.75.100 - hwcontext.h hwcontext_drm.h
Add AV_HWDEVICE_TYPE_DRM and implementation.
2017-09-08 - 5ba2aef6ec - lavfi 6.103.100 - buffersrc.h
Add av_buffersrc_close().
2017-09-04 - 6cadbb16e9 - lavc 57.105.100 - avcodec.h
Add AV_HWACCEL_CODEC_CAP_EXPERIMENTAL, replacing the deprecated
HWACCEL_CODEC_CAP_EXPERIMENTAL flag.
2017-09-01 - 5d76674756 - lavf 57.81.100 - avio.h
Add avio_read_partial().
2017-09-01 - xxxxxxx - lavf 57.80.100 / 57.11.0 - avio.h
Add avio_context_free(). From now on it must be used for freeing AVIOContext.
2017-08-08 - 1460408703 - lavu 55.74.100 - pixdesc.h
Add AV_PIX_FMT_FLAG_FLOAT pixel format flag.
2017-08-08 - 463b81de2b - lavu 55.72.100 - imgutils.h
Add av_image_fill_black().
2017-08-08 - caa12027ba - lavu 55.71.100 - frame.h
Add av_frame_apply_cropping().
2017-07-25 - 24de4fddca - lavu 55.69.100 - frame.h
Add AV_FRAME_DATA_ICC_PROFILE side data type.
2017-06-27 - 70143a3954 - lavc 57.100.100 - avcodec.h
DXVA2 and D3D11 hardware accelerated decoding now supports the new hwaccel API,
which can create the decoder context and allocate hardware frame automatically.
See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx. For D3D11,
the new AV_PIX_FMT_D3D11 pixfmt must be used with the new API.
2017-06-27 - 3303511f33 - lavu 56.67.100 - hwcontext.h
Add AV_HWDEVICE_TYPE_D3D11VA and AV_PIX_FMT_D3D11.
2017-06-24 - 09891c5391 - lavf 57.75.100 - avio.h
Add AVIO_DATA_MARKER_FLUSH_POINT to signal preferred flush points to aviobuf.
2017-06-14 - d59c6a3aeb - lavu 55.66.100 - hwcontext.h
av_hwframe_ctx_create_derived() now takes some AV_HWFRAME_MAP_* combination
as its flags argument (which was previously unused).
2017-06-14 - 49ae8a5e87 - lavc 57.99.100 - avcodec.h
Add AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH.
2017-06-14 - 0b1794a43e - lavu 55.65.100 - hwcontext.h
Add AV_HWDEVICE_TYPE_NONE, av_hwdevice_find_type_by_name(),
av_hwdevice_get_type_name() and av_hwdevice_iterate_types().
2017-06-14 - b22172f6f3 - lavu 55.64.100 - hwcontext.h
Add av_hwdevice_ctx_create_derived().
2017-05-15 - 532b23f079 - lavc 57.96.100 - avcodec.h
VideoToolbox hardware-accelerated decoding now supports the new hwaccel API,
which can create the decoder context and allocate hardware frames automatically.
See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx.
2017-05-15 - 532b23f079 - lavu 57.63.100 - hwcontext.h
Add AV_HWDEVICE_TYPE_VIDEOTOOLBOX and implementation.
2017-05-08 - f089e02fa2 - lavc 57.95.100 / 57.31.0 - avcodec.h
Add AVCodecContext.apply_cropping to control whether cropping
is handled by libavcodec or the caller.
2017-05-08 - a47bd5d77e - lavu 55.62.100 / 55.30.0 - frame.h
Add AVFrame.crop_left/right/top/bottom fields for attaching cropping
information to video frames.
2017-xx-xx - xxxxxxxxxx
Change av_sha_update(), av_sha512_update() and av_md5_sum()/av_md5_update() length
parameter type to size_t at next major bump.
2017-05-05 - c0f17a905f - lavc 57.94.100 - avcodec.h
The cuvid decoders now support AVCodecContext.hw_device_ctx, which removes
the requirement to set an incomplete AVCodecContext.hw_frames_ctx only to
set the Cuda device handle.
2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h
Add av_strireplace().
2016-04-06 - 157e57a181 - lavc 57.92.100 - avcodec.h
Add AV_PKT_DATA_CONTENT_LIGHT_LEVEL packet side data.
2016-04-06 - b378f5bd64 - lavu 55.60.100 - mastering_display_metadata.h
Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, av_content_light_metadata_alloc()
and av_content_light_metadata_create_side_data() API, and AVContentLightMetadata
type to export content light level video properties.
2017-03-31 - 9033e8723c - lavu 55.57.100 - spherical.h
Add av_spherical_projection_name().
Add av_spherical_from_name().
2017-03-30 - 4cda23f1f1 - lavu 55.53.100 / 55.27.0 - hwcontext.h
Add av_hwframe_map() and associated AV_HWFRAME_MAP_* flags.
Add av_hwframe_ctx_create_derived().
2017-03-29 - bfdcdd6d82 - lavu 55.52.100 - avutil.h
add av_fourcc_make_string() function and av_fourcc2str() macro to replace
av_get_codec_tag_string() from lavc.
2017-03-27 - ddef3d902f - lavf 57.68.100 - avformat.h
Deprecate that demuxers export the stream rotation angle in AVStream.metadata
(via an entry named "rotate"). Use av_stream_get_side_data() with
AV_PKT_DATA_DISPLAYMATRIX instead, and read the rotation angle with
av_display_rotation_get(). The same is done for muxing. Instead of adding a
"rotate" entry to AVStream.metadata, AV_PKT_DATA_DISPLAYMATRIX side data has
to be added to the AVStream.
2017-03-23 - 7e4ba776a2 - lavc 57.85.101 - avcodec.h
vdpau hardware accelerated decoding now supports the new hwaccel API, which
can create the decoder context and allocate hardware frame automatically.
See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx.
2017-03-23 - 156bd8278f - lavc 57.85.100 - avcodec.h
Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at
a later point.
2017-03-21 - fc9f14c7de - lavf 57.67.100 / 57.08.0 - avio.h
Add AVIO_SEEKABLE_TIME flag.
2017-03-21 - d682ae70b4 - lavf 57.66.105, lavc 57.83.101 - avformat.h, avcodec.h
Deprecate AVFMT_FLAG_KEEP_SIDE_DATA. It will be ignored after the next major
bump, and libavformat will behave as if it were always set.
Deprecate av_packet_merge_side_data() and av_packet_split_side_data().
2016-03-20 - 8200b16a9c - lavu 55.50.100 / 55.21.0 - imgutils.h
Add av_image_copy_uc_from(), a version of av_image_copy() for copying
from GPU mapped memory.
2017-03-20 - 9c2436e - lavu 55.49.100 - pixdesc.h
Add AV_PIX_FMT_FLAG_BAYER pixel format flag.
2017-03-18 - 3796fb2692 - lavfi 6.77.100 - avfilter.h
Deprecate AVFilterGraph.resample_lavr_opts
It's never been used by avfilter nor passed to anything.
2017-02-10 - 1b7ffddb3a - lavu 55.48.100 / 55.33.0 - spherical.h
Add AV_SPHERICAL_EQUIRECTANGULAR_TILE, av_spherical_tile_bounds(),
and projection-specific properties (bound_left, bound_top, bound_right,
bound_bottom, padding) to AVSphericalMapping.
2017-03-02 - ade7c1a232 - lavc 57.81.104 - videotoolbox.h
AVVideotoolboxContext.cv_pix_fmt_type can now be set to 0 to output the
native decoder format. (The default value is not changed.)
2017-03-02 - 554bc4eea8 - lavu 55.47.101, lavc 57.81.102, lavf 57.66.103
Remove requirement to use AVOption or accessors to access certain fields
in AVFrame, AVCodecContext, and AVFormatContext that were previously
documented as "no direct access" allowed.
2017-02-13 - c1a5fca06f - lavc 57.80.100 - avcodec.h
Add AVCodecContext.hw_device_ctx.
2017-02-11 - e3af49b14b - lavu 55.47.100 - frame.h
Add AVFrame.opaque_ref.
2017-01-31 - 2eab48177d - lavu 55.46.100 / 55.20.0 - cpu.h
Add AV_CPU_FLAG_SSSE3SLOW.
2017-01-24 - c4618f842a - lavu 55.45.100 - channel_layout.h
Add av_get_extended_channel_layout()
2017-01-22 - 76c5a69e26 - lavu 55.44.100 - lfg.h
Add av_lfg_init_from_data().
2017-01-17 - 2a4a8653b6 - lavc 57.74.100 - vaapi.h
Deprecate struct vaapi_context and the vaapi.h installed header.
Callers should set AVCodecContext.hw_frames_ctx instead.
2017-01-12 - dbe9dbed31 - lavfi 6.69.100 - buffersink.h
Add av_buffersink_get_*() functions.
2017-01-06 - 9488032e10 - lavf 57.62.100 - avio.h
Add avio_get_dyn_buf()
2016-12-10 - f542b152aa - lavu 55.43.100 - imgutils.h
Add av_image_check_size2()
2016-12-07 - e7a6f8c972 - lavc 57.67.100 / 57.29.0 - avcodec.h
Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
information from containers.
2016-12-07 - 8f58ecc344 - lavu 55.42.100 / 55.30.0 - spherical.h
Add AV_FRAME_DATA_SPHERICAL value, av_spherical_alloc() API and
AVSphericalMapping type to export and describe spherical video properties.
2016-11-18 - 2ab50647ff - lavf 57.58.100 - avformat.h
Add av_stream_add_side_data().
2016-11-13 - 775a8477b7 - lavu 55.39.100 - hwcontext_vaapi.h
Add AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE.
2016-11-13 - a8d51bb424 - lavu 55.38.100 - hwcontext_vaapi.h
Add driver quirks field to VAAPI-specific hwdevice and enum with
members AV_VAAPI_DRIVER_QUIRK_* to represent its values.
2016-11-10 - 638b216d4f - lavu 55.36.100 - pixfmt.h
Add AV_PIX_FMT_GRAY12(LE/BE).
-------- 8< --------- FFmpeg 3.2 was cut here -------- 8< ---------
2016-10-24 - 73ead47 - lavf 57.55.100 - avformat.h
Add AV_DISPOSITION_TIMED_THUMBNAILS
2016-10-24 - a246fef - lavf 57.54.100 - avformat.h
Add avformat_init_output() and AVSTREAM_INIT_IN_ macros
2016-10-22 - f5495c9 - lavu 55.33.100 - avassert.h
Add av_assert0_fpu() / av_assert2_fpu()
2016-10-07 - 3f9137c / 32c8359 - lavc 57.61.100 / 57.24.0 - avcodec.h
Decoders now export the frame timestamp as AVFrame.pts. It was
previously exported as AVFrame.pkt_pts, which is now deprecated.
Note: When decoding, AVFrame.pts uses the stream/packet timebase,
and not the codec timebase.
2016-09-28 - eba0414 - lavu 55.32.100 / 55.16.0 - hwcontext.h hwcontext_qsv.h
Add AV_HWDEVICE_TYPE_QSV and a new installed header with QSV-specific
hwcontext definitions.
2016-09-26 - 32c25f0 - lavc 57.59.100 / 57.23.0 - avcodec.h
AVCodecContext.hw_frames_ctx now may be used by decoders.
2016-09-27 - f0b6f72 - lavf 57.51.100 - avformat.h
Add av_stream_get_codec_timebase()
2016-09-27 - 23c0779 - lswr 2.2.100 - swresample.h
Add swr_build_matrix().
2016-09-23 - 30d3e36 - lavc 57.58.100 - avcodec.h
Add AV_CODEC_CAP_AVOID_PROBING codec capability flag.
2016-09-14 - ae1dd0c - lavf 57.49.100 - avformat.h
Add avformat_transfer_internal_stream_timing_info helper to help with stream
copy.
2016-08-29 - 4493390 - lavfi 6.58.100 - avfilter.h
Add AVFilterContext.nb_threads.
2016-08-15 - c3c4c72 - lavc 57.53.100 - avcodec.h
Add trailing_padding to AVCodecContext to match the corresponding
field in AVCodecParameters.
2016-08-15 - b746ed7 - lavc 57.52.100 - avcodec.h
Add a new API for chained BSF filters and passthrough (null) BSF --
av_bsf_list_alloc(), av_bsf_list_free(), av_bsf_list_append(),
av_bsf_list_append2(), av_bsf_list_finalize(), av_bsf_list_parse_str()
and av_bsf_get_null_filter().
2016-08-04 - 82a33c8 - lavf 57.46.100 - avformat.h
Add av_get_frame_filename2()
2016-07-09 - 775389f / 90f469a - lavc 57.50.100 / 57.20.0 - avcodec.h
Add FF_PROFILE_H264_MULTIVIEW_HIGH and FF_PROFILE_H264_STEREO_HIGH.
2016-06-30 - c1c7e0ab - lavf 57.41.100 - avformat.h
Moved codecpar field from AVStream to the end of the struct, so that
the following private fields are in the same location as in FFmpeg 3.0 (lavf 57.25.100).
2016-06-30 - 042fb69d - lavu 55.28.100 - frame.h
Moved hw_frames_ctx field from AVFrame to the end of the struct, so that
the following private fields are in the same location as in FFmpeg 3.0 (lavu 55.17.103).
2016-06-29 - 1a751455 - lavfi 6.47.100 - avfilter.h
Fix accidental ABI breakage in AVFilterContext.
ABI was broken in 8688d3a, lavfi 6.42.100 and released as ffmpeg 3.1.
Because of this, ffmpeg and ffplay built against lavfi>=6.42.100 will not be
compatible with lavfi>=6.47.100. Potentially also affects other users of
libavfilter if they are using one of the affected fields.
-------- 8< --------- FFmpeg 3.1 was cut here -------- 8< ---------
2016-06-26 - 481f320 / 1c9e861 - lavu 55.27.100 / 55.13.0 - hwcontext.h
Add av_hwdevice_ctx_create().
2016-06-26 - b95534b / e47b8bb - lavc 57.48.101 / 57.19.1 - avcodec.h
Adjust values for JPEG 2000 profiles.
2016-06-23 - 5d75e46 / db7968b - lavf 57.40.100 / 57.7.0 - avio.h
Add AVIODataMarkerType, write_data_type, ignore_boundary_point and
avio_write_marker.
2016-06-23 - abb3cc4 / 0c4468d - lavu 55.26.100 / 55.12.0 - opt.h
Add av_stereo3d_type_name() and av_stereo3d_from_name().
2016-06-22 - 3689efe / c46db38 - lavu 55.25.100 / 55.11.0 - hwcontext_dxva2.h
Add new installed header with DXVA2-specific hwcontext definitions.
2016-04-27 - fb91871 - lavu 55.23.100 - log.h
Add a new function av_log_format_line2() which returns number of bytes
written to the target buffer.
2016-04-21 - 7fc329e - lavc 57.37.100 - avcodec.h
Add a new audio/video encoding and decoding API with decoupled input
and output -- avcodec_send_packet(), avcodec_receive_frame(),
avcodec_send_frame() and avcodec_receive_packet().
2016-04-17 - af9cac1 / 33d1898 - lavc 57.35.100 / 57.15.0 - avcodec.h
Add a new bitstream filtering API working with AVPackets.
Deprecate the old bitstream filtering API.
2016-04-14 - 8688d3a / 07a844f - lavfi 6.42.100 / 6.3.0 - avfilter.h
Add AVFilterContext.hw_device_ctx.
2016-04-14 - 28abb21 / 551c677 - lavu 55.22.100 / 55.9.0 - hwcontext_vaapi.h
Add new installed header with VAAPI-specific hwcontext definitions.
2016-04-14 - afccfaf / b1f01e8 - lavu 55.21.100 / 55.7.0 - hwcontext.h
Add AVHWFramesConstraints and associated API.
2016-04-11 - 6f69f7a / 9200514 - lavf 57.33.100 / 57.5.0 - avformat.h
Add AVStream.codecpar, deprecate AVStream.codec.
2016-04-02 - e8a9b64 - lavu 55.20.100 - base64.h
Add AV_BASE64_DECODE_SIZE(x) macro.
2016-xx-xx - lavc 57.33.100 / 57.14.0 - avcodec.h
f9b1cf1 / 998e1b8 - Add AVCodecParameters and its related API.
e6053b3 / a806834 - Add av_get_audio_frame_duration2().
2016-03-11 - 6d8ab35 - lavf/lavc 57.28.101
Add requirement to bitstream filtering API that returned packets with
size == 0 and side_data_elems == 0 are to be skipped by the caller.
2016-03-04 - 9362973 - lavf 57.28.100
Add protocol blacklisting API
2016-02-28 - 4dd4d53 - lavc 57.27.101
Validate AVFrame returned by get_buffer2 to have required
planes not NULL and unused planes set to NULL as crashes
and buffer overflow are possible with certain streams if
that is not the case.
2016-02-26 - 30e7685 - lavc 57.27.100 - avcodec.h
"flags2" decoding option now allows the flag "ass_ro_flush_noop" preventing
the reset of the ASS ReadOrder field on flush. This affects the content of
AVSubtitles.rects[N]->ass when "sub_text_format" is set to "ass" (see
previous entry).
2016-02-26 - 2941282 - lavc 57.26.100 - avcodec.h
Add a "sub_text_format" subtitles decoding option allowing the values "ass"
(recommended) and "ass_with_timings" (not recommended, deprecated, default).
The default value for this option will change to "ass" at the next major
libavcodec version bump.
The current default is "ass_with_timings" for compatibility. This means that
all subtitles text decoders currently still output ASS with timings printed
as strings in the AVSubtitles.rects[N]->ass fields.
Setting "sub_text_format" to "ass" allows a better timing accuracy (ASS
timing is limited to a 1/100 time base, so this is relevant for any subtitles
format needing a bigger one), ease timing adjustments, and prevents the need
of removing the timing from the decoded string yourself. This form is also
known as "the Matroska form". The timing information (start time, duration)
can be found in the AVSubtitles fields.
2016-02-24 - 7e49cdd / 7b3214d0 - lavc 57.25.100 / 57.13.0 - avcodec.h
Add AVCodecContext.hw_frames_ctx.
2016-02-24 - 1042402 / b3dd30d - lavfi 6.36.100 / 6.2.0 - avfilter.h
avfilter.h - Add AVFilterLink.hw_frames_ctx.
buffersrc.h - Add AVBufferSrcParameters and functions for handling it.
2016-02-23 - 14f7a3d - lavc 57.25.100
Add AV_PKT_DATA_MPEGTS_STREAM_ID for exporting the MPEGTS stream ID.
2016-02-18 - 08acab8 - lavu 55.18.100 - audio_fifo.h
Add av_audio_fifo_peek_at().
2016-xx-xx - lavu 55.18.100 / 55.6.0
26abd51 / 721a4ef buffer.h - Add av_buffer_pool_init2().
1a70878 / 89923e4 hwcontext.h - Add a new installed header hwcontext.h with a new API
for handling hwaccel frames.
6992276 / ad884d1 hwcontext_cuda.h - Add a new installed header hwcontext_cuda.h with
CUDA-specific hwcontext definitions.
d779d8d / a001ce3 hwcontext_vdpau.h - Add a new installed header hwcontext_vdpau.h with
VDPAU-specific hwcontext definitions.
63c3e35 / 7bc780c pixfmt.h - Add AV_PIX_FMT_CUDA.
-------- 8< --------- FFmpeg 3.0 was cut here -------- 8< --------- -------- 8< --------- FFmpeg 3.0 was cut here -------- 8< ---------
2016-02-10 - bc9a596 / 9f61abc - lavf 57.25.100 / 57.3.0 - avformat.h 2016-02-10 - bc9a596 / 9f61abc - lavf 57.25.100 / 57.3.0 - avformat.h
@@ -889,7 +333,7 @@ API changes, most recent first:
Add av_opt_get_dict_val/set_dict_val with AV_OPT_TYPE_DICT to support Add av_opt_get_dict_val/set_dict_val with AV_OPT_TYPE_DICT to support
dictionary types being set as options. dictionary types being set as options.
2014-08-13 - afbd4b7e09 - lavf 56.01.0 - avformat.h 2014-08-13 - afbd4b8 - lavf 56.01.0 - avformat.h
Add AVFormatContext.event_flags and AVStream.event_flags for signaling to Add AVFormatContext.event_flags and AVStream.event_flags for signaling to
the user when events happen in the file/stream. the user when events happen in the file/stream.
@@ -906,7 +350,7 @@ API changes, most recent first:
2014-08-08 - 5c3c671 - lavf 55.53.100 - avio.h 2014-08-08 - 5c3c671 - lavf 55.53.100 - avio.h
Add avio_feof() and deprecate url_feof(). Add avio_feof() and deprecate url_feof().
2014-08-07 - bb789016d4 - lsws 2.1.3 - swscale.h 2014-08-07 - bb78903 - lsws 2.1.3 - swscale.h
sws_getContext is not going to be removed in the future. sws_getContext is not going to be removed in the future.
2014-08-07 - a561662 / ad1ee5f - lavc 55.73.101 / 55.57.3 - avcodec.h 2014-08-07 - a561662 / ad1ee5f - lavc 55.73.101 / 55.57.3 - avcodec.h
@@ -1640,7 +1084,7 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0
* base -- is now stored in AVBufferRef * base -- is now stored in AVBufferRef
* reference, type, buffer_hints -- are unnecessary in the new API * reference, type, buffer_hints -- are unnecessary in the new API
* hwaccel_picture_private, owner, thread_opaque -- should not * hwaccel_picture_private, owner, thread_opaque -- should not
have been accessed from outside of lavc have been acessed from outside of lavc
* qscale_table, qstride, qscale_type, mbskip_table, motion_val, * qscale_table, qstride, qscale_type, mbskip_table, motion_val,
mb_type, dct_coeff, ref_index -- mpegvideo-specific tables, mb_type, dct_coeff, ref_index -- mpegvideo-specific tables,
which are not exported anymore. which are not exported anymore.

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,6 @@ 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 \
@@ -37,6 +36,30 @@ DOCS-$(CONFIG_MANPAGES) += $(MANPAGES)
DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES) DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES)
DOCS = $(DOCS-yes) DOCS = $(DOCS-yes)
DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
DOC_EXAMPLES-$(CONFIG_AVCODEC_EXAMPLE) += avcodec
DOC_EXAMPLES-$(CONFIG_DECODING_ENCODING_EXAMPLE) += decoding_encoding
DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing
DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio
DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video
DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
DOC_EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding
ALL_DOC_EXAMPLES_LIST = $(DOC_EXAMPLES-) $(DOC_EXAMPLES-yes)
DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
ALL_DOC_EXAMPLES := $(ALL_DOC_EXAMPLES_LIST:%=doc/examples/%$(PROGSSUF)$(EXESUF))
ALL_DOC_EXAMPLES_G := $(ALL_DOC_EXAMPLES_LIST:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
PROGS += $(DOC_EXAMPLES)
all-$(CONFIG_DOC): doc all-$(CONFIG_DOC): doc
doc: documentation doc: documentation
@@ -44,6 +67,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
@@ -96,9 +121,11 @@ doc/%.3: doc/%.pod $(GENTEXI)
$(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@ $(M)pod2man --section=3 --center=" " --release=" " --date=" " $< > $@
$(DOCS) doc/doxy/html: | doc/ $(DOCS) doc/doxy/html: | doc/
$(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
OBJDIRS += doc/examples
DOXY_INPUT = $(INSTHEADERS) DOXY_INPUT = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c)
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) ffbuild/config.mak DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT))
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_DEPS)
@@ -144,7 +171,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

View File

@@ -18,7 +18,7 @@ comma-separated list of filters, whose parameters follow the filter
name after a '='. name after a '='.
@example @example
ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1/opt2=str2][,filter2] OUTPUT
@end example @end example
Below is a description of the currently available bitstream filters, Below is a description of the currently available bitstream filters,
@@ -26,46 +26,38 @@ 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 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. Add extradata to the beginning of the filtered packets.
@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{e}. If not specified it is assumed @samp{k}.
For example the following @command{ffmpeg} command forces a global For example the following @command{ffmpeg} command forces a global
header (thus disabling individual packet headers) in the H.264 packets header (thus disabling individual packet headers) in the H.264 packets
@@ -75,148 +67,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 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 insert
@item remove
@end table
@item sample_aspect_ratio
Set the sample aspect ratio of the stream in the VUI parameters.
@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 (num_units_in_tick / time_scale) 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 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.
@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
@@ -224,7 +74,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:
@@ -233,92 +83,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 (num_units_in_tick /
time_scale). 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).
@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
@@ -369,58 +133,11 @@ 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 @section mpeg4_unpack_bframes
@@ -444,82 +161,20 @@ ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
@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: Parameters:
@table @option
@item amount
A numeral string, whose value is related to how often output bytes will A numeral string, whose value is related to how often output bytes will
be modified. Therefore, values below or equal to 0 are forbidden, and be modified. Therefore, values below or equal to 0 are forbidden, and
the lower the more frequent bytes will be modified, with 1 meaning the lower the more frequent bytes will be modified, with 1 meaning
every byte is modified. every byte is modified.
@item dropamount
A numeral string, whose value is related to how often packets will be dropped.
Therefore, values below or equal to 0 are forbidden, and the lower the more
frequent packets will be dropped, with 1 meaning every packet is dropped.
@end table
The following example applies the modification to every byte but does not drop
any packets.
@example @example
ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
@end example @end example
applies the modification to every byte.
@section null
This bitstream filter passes the packets through unchanged.
@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
@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 H.264, H.265 and MPEG-2.
@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

View File

@@ -39,15 +39,15 @@ examples
libavformat/output-example libavformat/output-example
Build the libavformat basic example. Build the libavformat basic example.
libavcodec/api-example
Build the libavcodec basic example.
libswscale/swscale-test libswscale/swscale-test
Build the swscale self-test (useful also as an example). Build the swscale self-test (useful also as an example).
config config
Reconfigure the project with the current configuration. Reconfigure the project with the current configuration.
tools/target_dec_<decoder>_fuzzer
Build fuzzer to fuzz the specified decoder.
Useful standard make commands: Useful standard make commands:
make -t <target> make -t <target>

View File

@@ -44,6 +44,12 @@ 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
@@ -56,6 +62,8 @@ Do not draw edges.
Set error[?] variables during encoding. Set error[?] variables during encoding.
@item truncated @item truncated
@item naq
Normalize adaptive quantization.
@item ildct @item ildct
Use interlaced DCT. Use interlaced DCT.
@item low_delay @item low_delay
@@ -130,8 +138,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.
@@ -250,7 +257,7 @@ 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
@@ -449,9 +456,6 @@ Possible values:
@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.
@@ -467,6 +471,8 @@ 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 @item green_metadata
@@ -476,12 +482,18 @@ display complexity metadata for the upcoming frame, GoP or for a given duration.
@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
@@ -490,6 +502,21 @@ threading operations
skip motion compensation skip motion compensation
@end table @end table
@item vismv @var{integer} (@emph{decoding,video})
Visualize motion vectors (MVs).
This option is deprecated, see the codecview filter instead.
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
@item cmp @var{integer} (@emph{encoding,video}) @item cmp @var{integer} (@emph{encoding,video})
Set full pel me compare function. Set full pel me compare function.
@@ -726,6 +753,8 @@ 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).
@@ -1017,136 +1046,15 @@ 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
@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 If used as input parameter, it serves as a hint to the decoder, which
color_range the input has. 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.
@@ -1225,13 +1133,13 @@ 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}) @item codec_whitelist @var{list} (@emph{input})
"," separated list of allowed decoders. By default all are allowed. "," separated List of allowed decoders. By default all are allowed.
@item dump_separator @var{string} (@emph{input}) @item dump_separator @var{string} (@emph{input})
Separator used to separate the fields printed on the command line about the Separator used to separate the fields printed on the command line about the
@@ -1242,20 +1150,6 @@ ffprobe -dump_separator "
" -i ~/videos/matrixbench_mpeg2.mpg " -i ~/videos/matrixbench_mpeg2.mpg
@end example @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

View File

@@ -25,6 +25,13 @@ enabled decoders.
A description of some of the currently available video decoders A description of some of the currently available video decoders
follows. follows.
@section hevc
HEVC / H.265 decoder.
Note: the @option{skip_loop_filter} option has effect only at level
@code{all}.
@section rawvideo @section rawvideo
Raw video decoder. Raw video decoder.
@@ -102,7 +109,7 @@ correctly by using lavc's old buggy lpc logic for decoding.
@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
@@ -268,11 +275,11 @@ 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 30000 which is 30 seconds. miliseconds. Default value is 30000 which is 30 seconds.
@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 background.

View File

@@ -13,9 +13,8 @@ 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.
@@ -73,7 +72,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
@@ -108,7 +107,7 @@ Identify the script type and version. It also sets the @option{safe} option
to 1 if it was -1. to 1 if it was -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}}
@@ -244,33 +243,30 @@ file subdir/file-2.wav
@end example @end example
@end itemize @end itemize
@section dash @section flv
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.
@section flv, live_flv
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.
@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.
@end table @end table
@section libgme
The Game Music Emu library is a collection of video game music file emulators.
See @url{http://code.google.com/p/game-music-emu/} for more information.
Some files have multiple tracks. The demuxer will pick the first track by
default. The @option{track_index} option can be used to select a different
track. Track indexes start at 0. The demuxer exports the number of tracks as
@var{tracks} meta data entry.
For very large files, the @option{max_size} option may have to be adjusted.
@section gif @section gif
Animated GIF demuxer. Animated GIF demuxer.
@@ -310,32 +306,6 @@ 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 which in this case is @file{input.mp4} as the GIF in this example loops
infinitely. infinitely.
@section hls
HLS demuxer
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 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 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.
@end table
@section image2 @section image2
Image file demuxer. Image file demuxer.
@@ -471,49 +441,9 @@ ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv
@end example @end example
@end itemize @end itemize
@section libgme @section mov/mp4/3gp/Quicktme
The Game Music Emu library is a collection of video game music file emulators. Quicktime / MP4 demuxer.
See @url{http://code.google.com/p/game-music-emu/} for more information.
Some files have multiple tracks. The demuxer will pick the first track by
default. The @option{track_index} option can be used to select a different
track. Track indexes start at 0. The demuxer exports the number of tracks as
@var{tracks} meta data entry.
For very large files, the @option{max_size} option may have to be adjusted.
@section libopenmpt
libopenmpt based module demuxer
See @url{https://lib.openmpt.org/libopenmpt/} for more information.
Some files have multiple subsongs (tracks) this can be set with the @option{subsong}
option.
It accepts the following options:
@table @option
@item subsong
Set the subsong index. This can be either 'all', 'auto', or the index of the
subsong. Subsong indexes start at 0. The default is 'auto'.
The default value is to let libopenmpt choose.
@item layout
Set the channel layout. Valid values are 1, 2, and 4 channel layouts.
The default value is STEREO.
@item sample_rate
Set the sample rate for libopenmpt to output.
Range is from 1000 to INT_MAX. The value default is 48000.
@end table
@section mov/mp4/3gp/QuickTime
QuickTime / MP4 demuxer.
This demuxer accepts the following options: This demuxer accepts the following options:
@table @option @table @option

View File

@@ -10,7 +10,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
@@ -28,13 +30,15 @@ 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{https://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 +47,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:
@@ -70,7 +74,7 @@ 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 +114,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:
@@ -127,11 +131,6 @@ designated struct initializers (@samp{struct s x = @{ .i = 17 @};});
@item @item
compound literals (@samp{x = (struct s) @{ 17, 23 @};}). compound literals (@samp{x = (struct s) @{ 17, 23 @};}).
@item
Implementation defined behavior for signed integers is assumed to match the
expected behavior for two's complement. Non representable values in integer
casts are binary truncated. Shift right of signed values uses sign extension.
@end itemize @end itemize
These features are supported by all compilers we care about, so we will not These features are supported by all compilers we care about, so we will not
@@ -156,7 +155,7 @@ 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
@@ -180,7 +179,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
@@ -200,7 +199,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
@@ -212,7 +211,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
@@ -245,10 +244,10 @@ 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 lisp
@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
@@ -261,15 +260,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.
@@ -277,24 +276,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
@@ -303,7 +308,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
@@ -317,7 +322,7 @@ 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.
@@ -329,31 +334,47 @@ area changed: Short 1 line description
details describing what and why and giving references. details describing what and why and giving references.
@end example @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
@@ -363,7 +384,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.
@@ -372,84 +393,18 @@ 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 in
finding a new maintainer and also don't forget to update the @file{MAINTAINERS} file. finding a new maintainer and also don't forget to update 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.
@@ -482,11 +437,7 @@ Patches should be posted to the
mailing list. Use @code{git send-email} when possible since it will properly mailing list. Use @code{git send-email} when possible since it will properly
send patches without requiring extra care. If you cannot, then send patches send patches without requiring extra care. If you cannot, then send patches
as base64-encoded attachments, so your patch is not trashed during as base64-encoded attachments, so your patch is not trashed during
transmission. Also ensure the correct mime type is used transmission.
(text/x-diff or text/x-patch or at least text/plain) and that only one
patch is inline or attached per mail.
You can check @url{https://patchwork.ffmpeg.org}, if your patch does not show up, its mime type
likely was wrong.
Your patch will be reviewed on the mailing list. You will likely be asked Your patch will be reviewed on the mailing list. You will likely be asked
to make some changes and are expected to send in an improved version that to make some changes and are expected to send in an improved version that
@@ -498,7 +449,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
@@ -550,7 +501,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
@@ -560,9 +511,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?
@@ -663,7 +614,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.
@@ -694,7 +645,7 @@ to be reviewed, please consider helping to review other patches, that is a great
way to get everyone's patches reviewed sooner. 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.
@@ -705,7 +656,7 @@ 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 included in the fate-suite.
@@ -716,7 +667,7 @@ 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 introductory 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
@@ -743,7 +694,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
@@ -757,7 +708,7 @@ 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
@@ -789,7 +740,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:
@@ -813,7 +764,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:

1
doc/doxy/.gitignore vendored
View File

@@ -1 +0,0 @@
/html/

View File

@@ -61,9 +61,9 @@ Two loop searching (TLS) method.
This method first sets quantizers depending on band thresholds and then tries This method first sets quantizers depending on band thresholds and then tries
to find an optimal combination by adding or subtracting a specific value from to find an optimal combination by adding or subtracting a specific value from
all quantizers and adjusting some individual quantizer a little. Will tune all quantizers and adjusting some individual quantizer a little.
itself based on whether @option{aac_is}, @option{aac_ms} and @option{aac_pns} Will tune itself based on whether aac_is/aac_ms/aac_pns are enabled.
are enabled. This is the default choice for a coder.
@item anmr @item anmr
Average noise to mask ratio (ANMR) trellis-based solution. Average noise to mask ratio (ANMR) trellis-based solution.
@@ -76,27 +76,27 @@ Not currently recommended.
@item fast @item fast
Constant quantizer method. Constant quantizer method.
Uses a cheaper version of twoloop algorithm that doesn't try to do as many This method sets a constant quantizer for all bands. This is the fastest of all
clever adjustments. Worse with low bitrates (less than 64kbps), but is better the methods and has no rate control or support for @option{aac_is} or
and much faster at higher bitrates. @option{aac_pns}.
This is the default choice for a coder Not recommended.
@end table @end table
@item aac_ms @item aac_ms
Sets mid/side coding mode. The default value of "auto" will automatically use Sets mid/side coding mode. The default value of auto will automatically use
M/S with bands which will benefit from such coding. Can be forced for all bands M/S with bands which will benefit from such coding. Can be forced for all bands
using the value "enable", which is mainly useful for debugging or disabled using using the value "enable", which is mainly useful for debugging or disabled using
"disable". "disable".
@item aac_is @item aac_is
Sets intensity stereo coding tool usage. By default, it's enabled and will Sets intensity stereo coding tool usage. By default, it's enabled and will
automatically toggle IS for similar pairs of stereo bands if it's beneficial. automatically toggle IS for similar pairs of stereo bands if it's benefitial.
Can be disabled for debugging by setting the value to "disable". Can be disabled for debugging by setting the value to "disable".
@item aac_pns @item aac_pns
Uses perceptual noise substitution to replace low entropy high frequency bands Uses perceptual noise substitution to replace low entropy high frequency bands
with imperceptible white noise during the decoding process. By default, it's with imperceivable white noise during the decoding process. By default, it's
enabled, but can be disabled for debugging purposes by using "disable". enabled, but can be disabled for debugging purposes by using "disable".
@item aac_tns @item aac_tns
@@ -130,20 +130,20 @@ The default, AAC "Low-complexity" profile. Is the most compatible and produces
decent quality. decent quality.
@item mpeg2_aac_low @item mpeg2_aac_low
Equivalent to @code{-profile:a aac_low -aac_pns 0}. PNS was introduced with the Equivalent to -profile:a aac_low -aac_pns 0. PNS was introduced with the MPEG4
MPEG4 specifications. specifications.
@item aac_ltp @item aac_ltp
Long term prediction profile, is enabled by and will enable the @option{aac_ltp} Long term prediction profile, is enabled by and will enable the aac_ltp option.
option. Introduced in MPEG4. Introduced in MPEG4.
@item aac_main @item aac_main
Main-type prediction profile, is enabled by and will enable the @option{aac_pred} Main-type prediction profile, is enabled by and will enable the aac_pred option.
option. Introduced in MPEG2. Introduced in MPEG2.
@end table
If this option is unspecified it is set to @samp{aac_low}. If this option is unspecified it is set to @samp{aac_low}.
@end table @end table
@end table
@section ac3 and ac3_fixed @section ac3 and ac3_fixed
@@ -487,10 +487,6 @@ is an optional AC-3 feature that increases quality by selectively encoding
the left/right channels as mid/side. This option is enabled by default, and it the left/right channels as mid/side. This option is enabled by default, and it
is highly recommended that it be left as enabled except for testing purposes. is highly recommended that it be left as enabled except for testing purposes.
@item cutoff @var{frequency}
Set lowpass cutoff frequency. If unspecified, the encoder selects a default
determined by various other encoding parameters.
@end table @end table
@subsection Floating-Point-Only AC-3 Encoding Options @subsection Floating-Point-Only AC-3 Encoding Options
@@ -548,8 +544,7 @@ The following options are supported by FFmpeg's flac encoder.
@table @option @table @option
@item compression_level @item compression_level
Sets the compression level, which chooses defaults for many other options Sets the compression level, which chooses defaults for many other options
if they are not set explicitly. Valid values are from 0 to 12, 5 is the if they are not set explicitly.
default.
@item frame_size @item frame_size
Sets the size of the frames in samples per channel. Sets the size of the frames in samples per channel.
@@ -598,7 +593,7 @@ Channel mode
@item auto @item auto
The mode is chosen automatically for each frame The mode is chosen automatically for each frame
@item indep @item indep
Channels are independently coded Chanels are independently coded
@item left_side @item left_side
@item right_side @item right_side
@item mid_side @item mid_side
@@ -616,27 +611,111 @@ and slightly improves compression.
@end table @end table
@anchor{opusenc} @anchor{libfaac}
@section opus @section libfaac
Opus encoder. libfaac AAC (Advanced Audio Coding) encoder wrapper.
This is a native FFmpeg encoder for the Opus format. Currently its in development and This encoder is of much lower quality and is more unstable than any other AAC
only implements the CELT part of the codec. Its quality is usually worse and at best encoders, so it's highly recommended to instead use other encoders, like
is equal to the libopus encoder. @ref{aacenc,,the native FFmpeg AAC encoder}.
This encoder also requires the presence of the libfaac headers and library
during configuration. You need to explicitly configure the build with
@code{--enable-libfaac --enable-nonfree}.
@subsection Options @subsection Options
@table @option The following shared FFmpeg codec options are recognized.
@item b
Set bit rate in bits/s. If unspecified it uses the number of channels and the layout
to make a good guess.
@item opus_delay The following options are supported by the libfaac wrapper. The
Sets the maximum delay in milliseconds. Lower delays than 20ms will very quickly @command{faac}-equivalent of the options are listed in parentheses.
decrease quality.
@table @option
@item b (@emph{-b})
Set bit rate in bits/s for ABR (Average Bit Rate) mode. If the bit rate
is not explicitly specified, it is automatically set to a suitable
value depending on the selected profile. @command{faac} bitrate is
expressed in kilobits/s.
Note that libfaac does not support CBR (Constant Bit Rate) but only
ABR (Average Bit Rate).
If VBR mode is enabled this option is ignored.
@item ar (@emph{-R})
Set audio sampling rate (in Hz).
@item ac (@emph{-c})
Set the number of audio channels.
@item cutoff (@emph{-C})
Set cutoff frequency. If not specified (or explicitly set to 0) it
will use a value automatically computed by the library. Default value
is 0.
@item profile
Set audio profile.
The following profiles are recognized:
@table @samp
@item aac_main
Main AAC (Main)
@item aac_low
Low Complexity AAC (LC)
@item aac_ssr
Scalable Sample Rate (SSR)
@item aac_ltp
Long Term Prediction (LTP)
@end table @end table
If not specified it is set to @samp{aac_low}.
@item flags +qscale
Set constant quality VBR (Variable Bit Rate) mode.
@item global_quality
Set quality in VBR mode as an integer number of lambda units.
Only relevant when VBR mode is enabled with @code{flags +qscale}. The
value is converted to QP units by dividing it by @code{FF_QP2LAMBDA},
and used to set the quality value used by libfaac. A reasonable range
for the option value in QP units is [10-500], the higher the value the
higher the quality.
@item q (@emph{-q})
Enable VBR mode when set to a non-negative value, and set constant
quality value as a double floating point value in QP units.
The value sets the quality value used by libfaac. A reasonable range
for the option value is [10-500], the higher the value the higher the
quality.
This option is valid only using the @command{ffmpeg} command-line
tool. For library interface users, use @option{global_quality}.
@end table
@subsection Examples
@itemize
@item
Use @command{ffmpeg} to convert an audio file to ABR 128 kbps AAC in an M4A (MP4)
container:
@example
ffmpeg -i input.wav -codec:a libfaac -b:a 128k -output.m4a
@end example
@item
Use @command{ffmpeg} to convert an audio file to VBR AAC, using the
LTP AAC profile:
@example
ffmpeg -i input.wav -c:a libfaac -profile:a aac_ltp -q:a 100 output.m4a
@end example
@end itemize
@anchor{libfdk-aac-enc} @anchor{libfdk-aac-enc}
@section libfdk_aac @section libfdk_aac
@@ -842,10 +921,6 @@ Set algorithm quality. Valid arguments are integers in the 0-9 range,
with 0 meaning highest quality but slowest, and 9 meaning fastest with 0 meaning highest quality but slowest, and 9 meaning fastest
while producing the worst quality. while producing the worst quality.
@item cutoff (@emph{--lowpass})
Set lowpass cutoff frequency. If unspecified, the encoder dynamically
adjusts the cutoff.
@item reservoir @item reservoir
Enable use of bit reservoir when set to 1. Default value is 1. LAME Enable use of bit reservoir when set to 1. Default value is 1. LAME
has this enabled by default, but can be overridden by use has this enabled by default, but can be overridden by use
@@ -899,95 +974,6 @@ default value is 0 (disabled).
@end table @end table
@section libopus
libopus Opus Interactive Audio Codec encoder wrapper.
Requires the presence of the libopus headers and library during
configuration. You need to explicitly configure the build with
@code{--enable-libopus}.
@subsection Option Mapping
Most libopus options are modelled after the @command{opusenc} utility from
opus-tools. The following is an option mapping chart describing options
supported by the libopus wrapper, and their @command{opusenc}-equivalent
in parentheses.
@table @option
@item b (@emph{bitrate})
Set the bit rate in bits/s. FFmpeg's @option{b} option is
expressed in bits/s, while @command{opusenc}'s @option{bitrate} in
kilobits/s.
@item vbr (@emph{vbr}, @emph{hard-cbr}, and @emph{cvbr})
Set VBR mode. The FFmpeg @option{vbr} option has the following
valid arguments, with the @command{opusenc} equivalent options
in parentheses:
@table @samp
@item off (@emph{hard-cbr})
Use constant bit rate encoding.
@item on (@emph{vbr})
Use variable bit rate encoding (the default).
@item constrained (@emph{cvbr})
Use constrained variable bit rate encoding.
@end table
@item compression_level (@emph{comp})
Set encoding algorithm complexity. Valid options are integers in
the 0-10 range. 0 gives the fastest encodes but lower quality, while 10
gives the highest quality but slowest encoding. The default is 10.
@item frame_duration (@emph{framesize})
Set maximum frame size, or duration of a frame in milliseconds. The
argument must be exactly the following: 2.5, 5, 10, 20, 40, 60. Smaller
frame sizes achieve lower latency but less quality at a given bitrate.
Sizes greater than 20ms are only interesting at fairly low bitrates.
The default is 20ms.
@item packet_loss (@emph{expect-loss})
Set expected packet loss percentage. The default is 0.
@item application (N.A.)
Set intended application type. Valid options are listed below:
@table @samp
@item voip
Favor improved speech intelligibility.
@item audio
Favor faithfulness to the input (the default).
@item lowdelay
Restrict to only the lowest delay modes.
@end table
@item cutoff (N.A.)
Set cutoff bandwidth in Hz. The argument must be exactly one of the
following: 4000, 6000, 8000, 12000, or 20000, corresponding to
narrowband, mediumband, wideband, super wideband, and fullband
respectively. The default is 0 (cutoff disabled).
@item mapping_family (@emph{mapping_family})
Set channel mapping family to be used by the encoder. The default value of -1
uses mapping family 0 for mono and stereo inputs, and mapping family 1
otherwise. The default also disables the surround masking and LFE bandwidth
optimzations in libopus, and requires that the input contains 8 channels or
fewer.
Other values include 0 for mono and stereo, 1 for surround sound with masking
and LFE bandwidth optimizations, and 255 for independent streams with an
unspecified channel layout.
@item apply_phase_inv (N.A.) (requires libopus >= 1.2)
If set to 0, disables the use of phase inversion for intensity stereo,
improving the quality of mono downmixes, but slightly reducing normal stereo
quality. The default is 1 (phase inversion enabled).
@end table
@anchor{libshine} @anchor{libshine}
@section libshine @section libshine
@@ -1127,6 +1113,79 @@ default value is 0 (disabled).
@end table @end table
@section libopus
libopus Opus Interactive Audio Codec encoder wrapper.
Requires the presence of the libopus headers and library during
configuration. You need to explicitly configure the build with
@code{--enable-libopus}.
@subsection Option Mapping
Most libopus options are modelled after the @command{opusenc} utility from
opus-tools. The following is an option mapping chart describing options
supported by the libopus wrapper, and their @command{opusenc}-equivalent
in parentheses.
@table @option
@item b (@emph{bitrate})
Set the bit rate in bits/s. FFmpeg's @option{b} option is
expressed in bits/s, while @command{opusenc}'s @option{bitrate} in
kilobits/s.
@item vbr (@emph{vbr}, @emph{hard-cbr}, and @emph{cvbr})
Set VBR mode. The FFmpeg @option{vbr} option has the following
valid arguments, with the @command{opusenc} equivalent options
in parentheses:
@table @samp
@item off (@emph{hard-cbr})
Use constant bit rate encoding.
@item on (@emph{vbr})
Use variable bit rate encoding (the default).
@item constrained (@emph{cvbr})
Use constrained variable bit rate encoding.
@end table
@item compression_level (@emph{comp})
Set encoding algorithm complexity. Valid options are integers in
the 0-10 range. 0 gives the fastest encodes but lower quality, while 10
gives the highest quality but slowest encoding. The default is 10.
@item frame_duration (@emph{framesize})
Set maximum frame size, or duration of a frame in milliseconds. The
argument must be exactly the following: 2.5, 5, 10, 20, 40, 60. Smaller
frame sizes achieve lower latency but less quality at a given bitrate.
Sizes greater than 20ms are only interesting at fairly low bitrates.
The default is 20ms.
@item packet_loss (@emph{expect-loss})
Set expected packet loss percentage. The default is 0.
@item application (N.A.)
Set intended application type. Valid options are listed below:
@table @samp
@item voip
Favor improved speech intelligibility.
@item audio
Favor faithfulness to the input (the default).
@item lowdelay
Restrict to only the lowest delay modes.
@end table
@item cutoff (N.A.)
Set cutoff bandwidth in Hz. The argument must be exactly one of the
following: 4000, 6000, 8000, 12000, or 20000, corresponding to
narrowband, mediumband, wideband, super wideband, and fullband
respectively. The default is 0 (cutoff disabled).
@end table
@section libvorbis @section libvorbis
libvorbis encoder wrapper. libvorbis encoder wrapper.
@@ -1226,27 +1285,6 @@ Same as @samp{3}, but with extra processing enabled.
@end table @end table
@end table @end table
@anchor{mjpegenc}
@section mjpeg
Motion JPEG encoder.
@subsection Options
@table @option
@item huffman
Set the huffman encoding strategy. Possible values:
@table @samp
@item default
Use the default huffman tables. This is the default strategy.
@item optimal
Compute and use optimal huffman tables.
@end table
@end table
@anchor{wavpackenc} @anchor{wavpackenc}
@section wavpack @section wavpack
@@ -1316,81 +1354,6 @@ disabled
A description of some of the currently available video encoders A description of some of the currently available video encoders
follows. follows.
@section Hap
Vidvox Hap video encoder.
@subsection Options
@table @option
@item format @var{integer}
Specifies the Hap format to encode.
@table @option
@item hap
@item hap_alpha
@item hap_q
@end table
Default value is @option{hap}.
@item chunks @var{integer}
Specifies the number of chunks to split frames into, between 1 and 64. This
permits multithreaded decoding of large frames, potentially at the cost of
data-rate. The encoder may modify this value to divide frames evenly.
Default value is @var{1}.
@item compressor @var{integer}
Specifies the second-stage compressor to use. If set to @option{none},
@option{chunks} will be limited to 1, as chunked uncompressed frames offer no
benefit.
@table @option
@item none
@item snappy
@end table
Default value is @option{snappy}.
@end table
@section jpeg2000
The native jpeg 2000 encoder is lossy by default, the @code{-q:v}
option can be used to set the encoding quality. Lossless encoding
can be selected with @code{-pred 1}.
@subsection Options
@table @option
@item format
Can be set to either @code{j2k} or @code{jp2} (the default) that
makes it possible to store non-rgb pix_fmts.
@end table
@section libkvazaar
Kvazaar H.265/HEVC encoder.
Requires the presence of the libkvazaar headers and library during
configuration. You need to explicitly configure the build with
@option{--enable-libkvazaar}.
@subsection Options
@table @option
@item b
Set target video bitrate in bit/s and enable rate control.
@item kvazaar-params
Set kvazaar parameters as a list of @var{name}=@var{value} pairs separated
by commas (,). See kvazaar documentation for a list of options.
@end table
@section libopenh264 @section libopenh264
Cisco libopenh264 H.264/MPEG-4 AVC encoder wrapper. Cisco libopenh264 H.264/MPEG-4 AVC encoder wrapper.
@@ -1427,7 +1390,7 @@ is 0. This is only used when @option{slice_mode} is set to
@samp{fixed}. @samp{fixed}.
@item slice_mode @item slice_mode
Set slice mode. Can assume one of the following possible values: Set slice mode. Can assume one of the follwing possible values:
@table @samp @table @samp
@item fixed @item fixed
@@ -1457,6 +1420,30 @@ Set maximum NAL size in bytes.
Allow skipping frames to hit the target bitrate if set to 1. Allow skipping frames to hit the target bitrate if set to 1.
@end table @end table
@section jpeg2000
The native jpeg 2000 encoder is lossy by default, the @code{-q:v}
option can be used to set the encoding quality. Lossless encoding
can be selected with @code{-pred 1}.
@subsection Options
@table @option
@item format
Can be set to either @code{j2k} or @code{jp2} (the default) that
makes it possible to store non-rgb pix_fmts.
@end table
@section snow
@subsection Options
@table @option
@item iterative_dia_size
dia size for the iterative motion estimation
@end table
@section libtheora @section libtheora
libtheora Theora encoder wrapper. libtheora Theora encoder wrapper.
@@ -1670,7 +1657,7 @@ option to 2.
Enable frame parallel decodability features. Enable frame parallel decodability features.
@item aq-mode @item aq-mode
Set adaptive quantization mode (0: off (default), 1: variance 2: complexity, 3: Set adaptive quantization mode (0: off (default), 1: variance 2: complexity, 3:
cyclic refresh, 4: equator360). cyclic refresh).
@item colorspace @emph{color-space} @item colorspace @emph{color-space}
Set input color space. The VP9 bitstream supports signaling the following Set input color space. The VP9 bitstream supports signaling the following
colorspaces: colorspaces:
@@ -1683,15 +1670,6 @@ colorspaces:
@item @samp{smpte240m} @emph{smpte240} @item @samp{smpte240m} @emph{smpte240}
@item @samp{bt2020_ncl} @emph{bt2020} @item @samp{bt2020_ncl} @emph{bt2020}
@end table @end table
@item row-mt @var{boolean}
Enable row based multi-threading.
@item tune-content
Set content type: default (0), screen (1), film (2).
@item corpus-complexity
Corpus VBR mode is a variant of standard VBR where the complexity distribution
midpoint is passed in rather than calculated for a specific clip or chunk.
The valid range is [0, 10000]. 0 (default) uses standard VBR.
@end table @end table
@end table @end table
@@ -1699,6 +1677,7 @@ The valid range is [0, 10000]. 0 (default) uses standard VBR.
For more information about libvpx see: For more information about libvpx see:
@url{http://www.webmproject.org/} @url{http://www.webmproject.org/}
@section libwebp @section libwebp
libwebp WebP Image encoder wrapper libwebp WebP Image encoder wrapper
@@ -1804,7 +1783,7 @@ the documentation of the undocumented generic options, see
@ref{codec-options,,the Codec Options chapter}. @ref{codec-options,,the Codec Options chapter}.
To get a more accurate and extensive documentation of the libx264 To get a more accurate and extensive documentation of the libx264
options, invoke the command @command{x264 --fullhelp} or consult options, invoke the command @command{x264 --full-help} or consult
the libx264 documentation. the libx264 documentation.
@table @option @table @option
@@ -1865,10 +1844,6 @@ Exhaustive search.
Hadamard exhaustive search (slowest). Hadamard exhaustive search (slowest).
@end table @end table
@item forced-idr
Normally, when forcing a I-frame type, the encoder can select any type
of I-frame. This option forces it to choose an IDR-frame.
@item subq (@emph{subme}) @item subq (@emph{subme})
Sub-pixel motion estimation method. Sub-pixel motion estimation method.
@@ -1891,7 +1866,7 @@ Enable CAVLC and disable CABAC. It generates the same effect as
@end table @end table
@item cmp @item cmp
Set full pixel motion estimation comparison algorithm. Possible values: Set full pixel motion estimation comparation algorithm. Possible values:
@table @samp @table @samp
@item chroma @item chroma
@@ -2117,12 +2092,12 @@ is kept undocumented for some reason.
For example to specify libx264 encoding options with @command{ffmpeg}: For example to specify libx264 encoding options with @command{ffmpeg}:
@example @example
ffmpeg -i foo.mpg -c:v libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
@end example @end example
@item a53cc @var{boolean} @item a53cc @var{boolean}
Import closed captions (which must be ATSC compatible format) into output. Import closed captions (which must be ATSC compatible format) into output.
Only the mpeg2 and h264 decoders provide these. Default is 1 (on). Only the mpeg2 and h264 decoders provide these. Default is 0 (off).
@item x264-params (N.A.) @item x264-params (N.A.)
Override the x264 configuration using a :-separated list of key=value Override the x264 configuration using a :-separated list of key=value
@@ -2159,16 +2134,6 @@ Set the x265 preset.
@item tune @item tune
Set the x265 tune parameter. Set the x265 tune parameter.
@item profile
Set profile restrictions.
@item crf
Set the quality for constant quality mode.
@item forced-idr
Normally, when forcing a I-frame type, the encoder can select any type
of I-frame. This option forces it to choose an IDR-frame.
@item x265-params @item x265-params
Set x265 options using a list of @var{key}=@var{value} couples separated Set x265 options using a list of @var{key}=@var{value} couples separated
by ":". See @command{x265 --help} for a list of options. by ":". See @command{x265 --help} for a list of options.
@@ -2365,11 +2330,6 @@ Never write it.
@itemx always @itemx always
Always write it. Always write it.
@end table @end table
@item video_format @var{integer}
Specifies the video_format written into the sequence display extension
indicating the source of the video pictures. The default is @samp{unspecified},
can be @samp{component}, @samp{pal}, @samp{ntsc}, @samp{secam} or @samp{mac}.
For maximum compatibility, use @samp{component}.
@end table @end table
@section png @section png
@@ -2403,7 +2363,6 @@ Select the ProRes profile to encode
@item standard @item standard
@item hq @item hq
@item 4444 @item 4444
@item 4444xq
@end table @end table
@item quant_mat @var{integer} @item quant_mat @var{integer}
@@ -2453,6 +2412,27 @@ Setting a higher @option{bits_per_mb} limit will improve the speed.
For the fastest encoding speed set the @option{qscale} parameter (4 is the For the fastest encoding speed set the @option{qscale} parameter (4 is the
recommended value) and do not set a size constraint. recommended value) and do not set a size constraint.
@section libkvazaar
Kvazaar H.265/HEVC encoder.
Requires the presence of the libkvazaar headers and library during
configuration. You need to explicitly configure the build with
@option{--enable-libkvazaar}.
@subsection Options
@table @option
@item b
Set target video bitrate in bit/s and enable rate control.
@item kvazaar-params
Set kvazaar parameters as a list of @var{name}=@var{value} pairs separated
by commas (,). See kvazaar documentation for a list of options.
@end table
@section QSV encoders @section QSV encoders
The family of Intel QuickSync Video encoders (MPEG-2, H.264 and HEVC) The family of Intel QuickSync Video encoders (MPEG-2, H.264 and HEVC)
@@ -2541,126 +2521,6 @@ encoder use CAVLC instead of CABAC.
@end itemize @end itemize
@section snow
@subsection Options
@table @option
@item iterative_dia_size
dia size for the iterative motion estimation
@end table
@section VAAPI encoders
Wrappers for hardware encoders accessible via VAAPI.
These encoders only accept input in VAAPI hardware surfaces. If you have input
in software frames, use the @option{hwupload} filter to upload them to the GPU.
The following standard libavcodec options are used:
@itemize
@item
@option{g} / @option{gop_size}
@item
@option{bf} / @option{max_b_frames}
@item
@option{profile}
@item
@option{level}
@item
@option{b} / @option{bit_rate}
@item
@option{maxrate} / @option{rc_max_rate}
@item
@option{bufsize} / @option{rc_buffer_size}
@item
@option{rc_init_occupancy} / @option{rc_initial_buffer_occupancy}
@item
@option{compression_level}
Speed / quality tradeoff: higher values are faster / worse quality.
@item
@option{q} / @option{global_quality}
Size / quality tradeoff: higher values are smaller / worse quality.
@item
@option{qmin}
(only: @option{qmax} is not supported)
@item
@option{i_qfactor} / @option{i_quant_factor}
@item
@option{i_qoffset} / @option{i_quant_offset}
@item
@option{b_qfactor} / @option{b_quant_factor}
@item
@option{b_qoffset} / @option{b_quant_offset}
@end itemize
@table @option
@item h264_vaapi
@option{profile} sets the value of @emph{profile_idc} and the @emph{constraint_set*_flag}s.
@option{level} sets the value of @emph{level_idc}.
@table @option
@item low_power
Use low-power encoding mode.
@item coder
Set entropy encoder (default is @emph{cabac}). Possible values:
@table @samp
@item ac
@item cabac
Use CABAC.
@item vlc
@item cavlc
Use CAVLC.
@end table
@end table
@item hevc_vaapi
@option{profile} and @option{level} set the values of
@emph{general_profile_idc} and @emph{general_level_idc} respectively.
@item mjpeg_vaapi
Always encodes using the standard quantisation and huffman tables -
@option{global_quality} scales the standard quantisation table (range 1-100).
@item mpeg2_vaapi
@option{profile} and @option{level} set the value of @emph{profile_and_level_indication}.
No rate control is supported.
@item vp8_vaapi
B-frames are not supported.
@option{global_quality} sets the @emph{q_idx} used for non-key frames (range 0-127).
@table @option
@item loop_filter_level
@item loop_filter_sharpness
Manually set the loop filter parameters.
@end table
@item vp9_vaapi
@option{global_quality} sets the @emph{q_idx} used for P-frames (range 0-255).
@table @option
@item loop_filter_level
@item loop_filter_sharpness
Manually set the loop filter parameters.
@end table
B-frames are supported, but the output stream is always in encode order rather than display
order. If B-frames are enabled, it may be necessary to use the @option{vp9_raw_reorder}
bitstream filter to modify the output stream to display frames in the correct order.
Only normal frames are produced - the @option{vp9_superframe} bitstream filter may be
required to produce a stream usable with all decoders.
@end table
@section vc2 @section vc2
SMPTE VC-2 (previously BBC Dirac Pro). This codec was primarily aimed at SMPTE VC-2 (previously BBC Dirac Pro). This codec was primarily aimed at

View File

@@ -1,22 +0,0 @@
/avio_dir_cmd
/avio_reading
/decode_audio
/decode_video
/demuxing_decoding
/encode_audio
/encode_video
/extract_mvs
/filter_audio
/filtering_audio
/filtering_video
/http_multiclient
/hw_decode
/metadata
/muxing
/pc-uninstalled
/qsvdec
/remuxing
/resampling_audio
/scaling_video
/transcode_aac
/transcoding

View File

@@ -1,64 +1,46 @@
EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd # 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_dir_cmd \
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/README $(EXAMPLE_MAKEFILE) avio_reading \
decoding_encoding \
demuxing_decoding \
extract_mvs \
filtering_video \
filtering_audio \
http_multiclient \
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
decoding_encoding: LDLIBS += -lm
muxing: LDLIBS += -lm
resampling_audio: LDLIBS += -lm
$(EXAMPLES:%$(PROGSSUF)$(EXESUF)=%.o): | doc/examples .phony: all clean-test clean
OBJDIRS += 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

View File

@@ -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_dir_cmd \
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)

View File

@@ -143,6 +143,8 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* register codecs and formats and other lavf/lavc components*/
av_register_all();
avformat_network_init(); avformat_network_init();
op = argv[1]; op = argv[1];

View File

@@ -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)

View File

@@ -1,184 +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 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->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;
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);
fclose(outfile);
fclose(f);
avcodec_free_context(&c);
av_parser_close(parser);
av_frame_free(&decoded_frame);
av_packet_free(&pkt);
return 0;
}

View File

@@ -1,186 +0,0 @@
/*
* Copyright (c) 2001 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* video decoding with libavcodec API example
*
* @example decode_video.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#define INBUF_SIZE 4096
static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
char *filename)
{
FILE *f;
int i;
f = fopen(filename,"w");
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
for (i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f);
fclose(f);
}
static 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;
AVPacket *pkt;
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();
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);
}
while (!feof(f)) {
/* read raw data from the input file */
data_size = fread(inbuf, 1, INBUF_SIZE, f);
if (!data_size)
break;
/* use the parser to split the data into frames */
data = inbuf;
while (data_size > 0) {
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);
}
}
/* 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;
}

View File

@@ -0,0 +1,665 @@
/*
* 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_packet_unref(&pkt);
}
}
/* get the delayed frames */
for (got_output = 1; got_output; i++) {
ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
fwrite(pkt.data, 1, pkt.size, f);
av_packet_unref(&pkt);
}
}
fclose(f);
av_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 + AV_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 i, ch;
int got_frame = 0;
if (!decoded_frame) {
if (!(decoded_frame = av_frame_alloc())) {
fprintf(stderr, "Could not allocate audio frame\n");
exit(1);
}
}
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
if (len < 0) {
fprintf(stderr, "Error while decoding\n");
exit(1);
}
if (got_frame) {
/* if a frame has been decoded, output it */
int data_size = av_get_bytes_per_sample(c->sample_fmt);
if (data_size < 0) {
/* This should not occur, checking just for paranoia */
fprintf(stderr, "Failed to calculate data size\n");
exit(1);
}
for (i=0; i<decoded_frame->nb_samples; i++)
for (ch=0; ch<c->channels; ch++)
fwrite(decoded_frame->data[ch] + data_size*i, 1, data_size, outfile);
}
avpkt.size -= len;
avpkt.data += len;
avpkt.dts =
avpkt.pts = AV_NOPTS_VALUE;
if (avpkt.size < AUDIO_REFILL_THRESH) {
/* Refill the input buffer, to avoid trying to decode
* incomplete frames. Instead of this, one could also use
* a parser, or use a proper container format through
* libavformat. */
memmove(inbuf, avpkt.data, avpkt.size);
avpkt.data = inbuf;
len = fread(avpkt.data + avpkt.size, 1,
AUDIO_INBUF_SIZE - avpkt.size, f);
if (len > 0)
avpkt.size += len;
}
}
fclose(outfile);
fclose(f);
avcodec_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_packet_unref(&pkt);
}
}
/* get the delayed frames */
for (got_output = 1; got_output; i++) {
fflush(stdout);
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_packet_unref(&pkt);
}
}
/* add sequence end code to have a real mpeg file */
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
avcodec_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],
frame->width, frame->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 + AV_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, AV_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 & AV_CODEC_CAP_TRUNCATED)
c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames
/* For some codecs, such as msmpeg4 and mpeg4, width and height
MUST be initialized there because this information is not
available in the bitstream. */
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
f = fopen(filename, "rb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
}
frame_count = 0;
for (;;) {
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
if (avpkt.size == 0)
break;
/* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
and this is the only method to use them because you cannot
know the compressed data size before analysing it.
BUT some other codecs (msmpeg4, mpeg4) are inherently frame
based, so you must call them with all the data for one
frame exactly. You must also initialize 'width' and
'height' before initializing them. */
/* NOTE2: some codecs allow the raw parameters (frame size,
sample rate) to be changed at any frame. We handle this, so
you should also take care of it */
/* here, we use a stream based decoder (mpeg1video), so we
feed decoder and see if it could decode a frame */
avpkt.data = inbuf;
while (avpkt.size > 0)
if (decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 0) < 0)
exit(1);
}
/* some codecs, such as MPEG, transmit the I and P frame with a
latency of one frame. You must do the following to have a
chance to get the last frame of the video */
avpkt.data = NULL;
avpkt.size = 0;
decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);
fclose(f);
avcodec_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.pcm", "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;
}

View File

@@ -93,9 +93,10 @@ static int decode_packet(int *got_frame, int cached)
return -1; return -1;
} }
printf("video_frame%s n:%d coded_n:%d\n", printf("video_frame%s n:%d coded_n:%d pts:%s\n",
cached ? "(cached)" : "", cached ? "(cached)" : "",
video_frame_count++, frame->coded_picture_number); video_frame_count++, frame->coded_picture_number,
av_ts2timestr(frame->pts, &video_dec_ctx->time_base));
/* copy decoded frame to destination buffer: /* copy decoded frame to destination buffer:
* this is required since rawvideo expects non aligned data */ * this is required since rawvideo expects non aligned data */
@@ -147,10 +148,11 @@ static int decode_packet(int *got_frame, int cached)
} }
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, stream_index;
AVStream *st; AVStream *st;
AVCodecContext *dec_ctx = NULL;
AVCodec *dec = NULL; AVCodec *dec = NULL;
AVDictionary *opts = NULL; AVDictionary *opts = NULL;
@@ -164,31 +166,17 @@ static int open_codec_context(int *stream_idx,
st = fmt_ctx->streams[stream_index]; st = fmt_ctx->streams[stream_index];
/* 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 */
*dec_ctx = avcodec_alloc_context3(dec);
if (!*dec_ctx) {
fprintf(stderr, "Failed to allocate the %s codec context\n",
av_get_media_type_string(type));
return AVERROR(ENOMEM);
}
/* Copy codec parameters from input stream to output codec context */
if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) < 0) {
fprintf(stderr, "Failed to copy %s codec parameters to decoder context\n",
av_get_media_type_string(type));
return ret;
}
/* Init the decoders, with or without reference counting */ /* Init the decoders, with or without reference counting */
av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0); av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0);
if ((ret = avcodec_open2(*dec_ctx, dec, &opts)) < 0) { if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 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;
@@ -252,6 +240,9 @@ int main (int argc, char **argv)
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);
@@ -264,8 +255,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) {
@@ -287,8 +279,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);
@@ -376,8 +369,8 @@ 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);

View File

@@ -1,238 +0,0 @@
/*
* Copyright (c) 2001 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* audio encoding with libavcodec API example.
*
* @example encode_audio.c
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/frame.h>
#include <libavutil/samplefmt.h>
/* check that a given sample format is supported by the encoder */
static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt)
{
const enum AVSampleFormat *p = codec->sample_fmts;
while (*p != AV_SAMPLE_FMT_NONE) {
if (*p == sample_fmt)
return 1;
p++;
}
return 0;
}
/* just pick the highest supported samplerate */
static int select_sample_rate(const AVCodec *codec)
{
const int *p;
int best_samplerate = 0;
if (!codec->supported_samplerates)
return 44100;
p = codec->supported_samplerates;
while (*p) {
if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
best_samplerate = *p;
p++;
}
return best_samplerate;
}
/* select layout with the highest channel count */
static int select_channel_layout(const AVCodec *codec)
{
const uint64_t *p;
uint64_t best_ch_layout = 0;
int best_nb_channels = 0;
if (!codec->channel_layouts)
return AV_CH_LAYOUT_STEREO;
p = codec->channel_layouts;
while (*p) {
int nb_channels = av_get_channel_layout_nb_channels(*p);
if (nb_channels > best_nb_channels) {
best_ch_layout = *p;
best_nb_channels = nb_channels;
}
p++;
}
return best_ch_layout;
}
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);
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);
}
/* 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;
frame->channel_layout = c->channel_layout;
/* allocate the data buffers */
ret = av_frame_get_buffer(frame, 0);
if (ret < 0) {
fprintf(stderr, "Could not allocate audio data buffers\n");
exit(1);
}
/* encode a single tone sound */
t = 0;
tincr = 2 * M_PI * 440.0 / c->sample_rate;
for (i = 0; i < 200; i++) {
/* make sure the frame is writable -- makes a copy if the encoder
* kept a reference internally */
ret = av_frame_make_writable(frame);
if (ret < 0)
exit(1);
samples = (uint16_t*)frame->data[0];
for (j = 0; j < c->frame_size; j++) {
samples[2*j] = (int)(sin(t) * 10000);
for (k = 1; k < c->channels; k++)
samples[2*j + k] = samples[2*j];
t += tincr;
}
encode(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;
}

View File

@@ -1,197 +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, 32);
if (ret < 0) {
fprintf(stderr, "Could not allocate the video frame data\n");
exit(1);
}
/* encode 1 second of video */
for (i = 0; i < 25; i++) {
fflush(stdout);
/* make sure the frame data is writable */
ret = av_frame_make_writable(frame);
if (ret < 0)
exit(1);
/* prepare a dummy image */
/* Y */
for (y = 0; y < c->height; y++) {
for (x = 0; x < c->width; x++) {
frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
}
}
/* Cb and Cr */
for (y = 0; y < c->height/2; y++) {
for (x = 0; x < c->width/2; x++) {
frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
}
}
frame->pts = i;
/* encode the image */
encode(c, frame, pkt, f);
}
/* flush the encoder */
encode(c, NULL, pkt, f);
/* add sequence end code to have a real MPEG file */
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
avcodec_free_context(&c);
av_frame_free(&frame);
av_packet_free(&pkt);
return 0;
}

View File

@@ -31,26 +31,23 @@ static const char *src_filename = NULL;
static int video_stream_idx = -1; static int video_stream_idx = -1;
static AVFrame *frame = NULL; static AVFrame *frame = NULL;
static AVPacket pkt;
static int video_frame_count = 0; static int video_frame_count = 0;
static int decode_packet(const AVPacket *pkt) static int decode_packet(int *got_frame, int cached)
{ {
int ret = avcodec_send_packet(video_dec_ctx, pkt); int decoded = pkt.size;
if (ret < 0) {
fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret));
return ret;
}
while (ret >= 0) { *got_frame = 0;
ret = avcodec_receive_frame(video_dec_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { if (pkt.stream_index == video_stream_idx) {
break; int ret = avcodec_decode_video2(video_dec_ctx, frame, got_frame, &pkt);
} else if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error while receiving a frame from the decoder: %s\n", av_err2str(ret)); fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
return ret; return ret;
} }
if (ret >= 0) { if (*got_frame) {
int i; int i;
AVFrameSideData *sd; AVFrameSideData *sd;
@@ -61,19 +58,19 @@ static int decode_packet(const AVPacket *pkt)
for (i = 0; i < sd->size / sizeof(*mvs); i++) { for (i = 0; i < sd->size / sizeof(*mvs); i++) {
const AVMotionVector *mv = &mvs[i]; const AVMotionVector *mv = &mvs[i];
printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n",
video_frame_count, mv->source, video_frame_count, mv->source,
mv->w, mv->h, mv->src_x, mv->src_y, mv->w, mv->h, mv->src_x, mv->src_y,
mv->dst_x, mv->dst_y, mv->flags); mv->dst_x, mv->dst_y, mv->flags);
} }
} }
av_frame_unref(frame);
} }
} }
return 0; return decoded;
} }
static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type) static int open_codec_context(int *stream_idx,
AVFormatContext *fmt_ctx, enum AVMediaType type)
{ {
int ret; int ret;
AVStream *st; AVStream *st;
@@ -81,27 +78,24 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
AVCodec *dec = NULL; AVCodec *dec = NULL;
AVDictionary *opts = NULL; AVDictionary *opts = NULL;
ret = av_find_best_stream(fmt_ctx, type, -1, -1, &dec, 0); ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Could not find %s stream in input file '%s'\n", fprintf(stderr, "Could not find %s stream in input file '%s'\n",
av_get_media_type_string(type), src_filename); av_get_media_type_string(type), src_filename);
return ret; return ret;
} else { } else {
int stream_idx = ret; *stream_idx = ret;
st = fmt_ctx->streams[stream_idx]; st = fmt_ctx->streams[*stream_idx];
dec_ctx = avcodec_alloc_context3(dec); /* find decoder for the stream */
if (!dec_ctx) { dec_ctx = st->codec;
fprintf(stderr, "Failed to allocate codec\n"); dec = avcodec_find_decoder(dec_ctx->codec_id);
if (!dec) {
fprintf(stderr, "Failed to find %s codec\n",
av_get_media_type_string(type));
return AVERROR(EINVAL); 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 */ /* Init the video decoder */
av_dict_set(&opts, "flags2", "+export_mvs", 0); av_dict_set(&opts, "flags2", "+export_mvs", 0);
if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) { if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) {
@@ -109,10 +103,6 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
av_get_media_type_string(type)); av_get_media_type_string(type));
return ret; return ret;
} }
video_stream_idx = stream_idx;
video_stream = fmt_ctx->streams[video_stream_idx];
video_dec_ctx = dec_ctx;
} }
return 0; return 0;
@@ -120,8 +110,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret = 0; int ret = 0, got_frame;
AVPacket pkt = { 0 };
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "Usage: %s <video>\n", argv[0]); fprintf(stderr, "Usage: %s <video>\n", argv[0]);
@@ -129,6 +118,8 @@ int main(int argc, char **argv)
} }
src_filename = argv[1]; src_filename = argv[1];
av_register_all();
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);
exit(1); exit(1);
@@ -139,7 +130,10 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
open_codec_context(fmt_ctx, AVMEDIA_TYPE_VIDEO); if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
video_stream = fmt_ctx->streams[video_stream_idx];
video_dec_ctx = video_stream->codec;
}
av_dump_format(fmt_ctx, 0, src_filename, 0); av_dump_format(fmt_ctx, 0, src_filename, 0);
@@ -158,20 +152,33 @@ int main(int argc, char **argv)
printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n"); printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n");
/* initialize packet, set data to NULL, let the demuxer fill it */
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
/* read frames from the file */ /* read frames from the file */
while (av_read_frame(fmt_ctx, &pkt) >= 0) { while (av_read_frame(fmt_ctx, &pkt) >= 0) {
if (pkt.stream_index == video_stream_idx) AVPacket orig_pkt = pkt;
ret = decode_packet(&pkt); do {
av_packet_unref(&pkt); ret = decode_packet(&got_frame, 0);
if (ret < 0) if (ret < 0)
break; break;
pkt.data += ret;
pkt.size -= ret;
} while (pkt.size > 0);
av_packet_unref(&orig_pkt);
} }
/* flush cached frames */ /* flush cached frames */
decode_packet(NULL); pkt.data = NULL;
pkt.size = 0;
do {
decode_packet(&got_frame, 1);
} while (got_frame);
end: end:
avcodec_free_context(&video_dec_ctx); avcodec_close(video_dec_ctx);
avformat_close_input(&fmt_ctx); avformat_close_input(&fmt_ctx);
av_frame_free(&frame); av_frame_free(&frame);
return ret < 0; return ret < 0;

View File

@@ -64,13 +64,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];
@@ -289,6 +289,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) {

View File

@@ -32,6 +32,7 @@
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.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>
@@ -64,16 +65,11 @@ static int open_input_file(const char *filename)
/* select the audio stream */ /* select the audio stream */
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0); ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0);
if (ret < 0) { if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot find an audio stream in the input file\n"); av_log(NULL, AV_LOG_ERROR, "Cannot find a audio stream in the input file\n");
return ret; return ret;
} }
audio_stream_index = ret; audio_stream_index = ret;
dec_ctx = fmt_ctx->streams[audio_stream_index]->codec;
/* create decoding context */
dec_ctx = avcodec_alloc_context3(dec);
if (!dec_ctx)
return AVERROR(ENOMEM);
avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[audio_stream_index]->codecpar);
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0); av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
/* init the audio decoder */ /* init the audio decoder */
@@ -89,8 +85,8 @@ 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 };
@@ -200,7 +196,7 @@ end:
static void print_frame(const AVFrame *frame) static void print_frame(const AVFrame *frame)
{ {
const int n = frame->nb_samples * av_get_channel_layout_nb_channels(frame->channel_layout); 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,9 +211,10 @@ 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; 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 (!frame || !filt_frame) { if (!frame || !filt_frame) {
perror("Could not allocate frame"); perror("Could not allocate frame");
@@ -228,58 +225,63 @@ 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)
break;
packet0 = packet;
}
if (packet.stream_index == audio_stream_index) { if (packet.stream_index == audio_stream_index) {
ret = avcodec_send_packet(dec_ctx, &packet); got_frame = 0;
ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, &packet);
if (ret < 0) { if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n"); av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n");
break; continue;
} }
packet.size -= ret;
packet.data += ret;
while (ret >= 0) { if (got_frame) {
ret = avcodec_receive_frame(dec_ctx, frame); /* push the audio data from decoded frame into the filtergraph */
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, 0) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
break; break;
} else if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
goto end;
} }
if (ret >= 0) { /* pull filtered audio from the filtergraph */
/* push the audio data from decoded frame into the filtergraph */ while (1) {
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) { ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n"); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
break; break;
} if (ret < 0)
goto end;
/* pull filtered audio from the filtergraph */ print_frame(filt_frame);
while (1) { av_frame_unref(filt_frame);
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
break;
if (ret < 0)
goto end;
print_frame(filt_frame);
av_frame_unref(filt_frame);
}
av_frame_unref(frame);
} }
} }
if (packet.size <= 0)
av_packet_unref(&packet0);
} else {
/* discard non-wanted packets */
av_packet_unref(&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_frame_free(&frame); av_frame_free(&frame);
av_frame_free(&filt_frame); av_frame_free(&filt_frame);

View File

@@ -32,6 +32,7 @@
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.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>
@@ -71,12 +72,7 @@ static int open_input_file(const char *filename)
return ret; return ret;
} }
video_stream_index = ret; video_stream_index = ret;
dec_ctx = fmt_ctx->streams[video_stream_index]->codec;
/* create decoding context */
dec_ctx = avcodec_alloc_context3(dec);
if (!dec_ctx)
return AVERROR(ENOMEM);
avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[video_stream_index]->codecpar);
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0); av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
/* init the video decoder */ /* init the video decoder */
@@ -92,8 +88,8 @@ 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; AVRational time_base = fmt_ctx->streams[video_stream_index]->time_base;
@@ -212,6 +208,7 @@ int main(int argc, char **argv)
AVPacket packet; AVPacket 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 (!frame || !filt_frame) { if (!frame || !filt_frame) {
perror("Could not allocate frame"); perror("Could not allocate frame");
@@ -222,6 +219,9 @@ 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)
@@ -233,49 +233,40 @@ int main(int argc, char **argv)
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) {
/* push the decoded frame into the filtergraph */
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
break; break;
} else if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
goto end;
} }
if (ret >= 0) { /* pull filtered frames from the filtergraph */
frame->pts = frame->best_effort_timestamp; while (1) {
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
/* push the decoded frame into the filtergraph */ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
break; break;
} if (ret < 0)
goto end;
/* pull filtered frames from the filtergraph */ display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
while (1) { av_frame_unref(filt_frame);
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
break;
if (ret < 0)
goto end;
display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
av_frame_unref(filt_frame);
}
av_frame_unref(frame);
} }
av_frame_unref(frame);
} }
} }
av_packet_unref(&packet); 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_frame_free(&frame); av_frame_free(&frame);
av_frame_free(&filt_frame); av_frame_free(&filt_frame);

View File

@@ -33,19 +33,18 @@
#include <libavutil/opt.h> #include <libavutil/opt.h>
#include <unistd.h> #include <unistd.h>
static void process_client(AVIOContext *client, const char *in_uri) void process_client(AVIOContext *client, const char *in_uri)
{ {
AVIOContext *input = NULL; AVIOContext *input = NULL;
uint8_t buf[1024]; uint8_t buf[1024];
int ret, n, reply_code; int ret, n, reply_code;
uint8_t *resource = NULL; char *resource = NULL;
while ((ret = avio_handshake(client)) > 0) { while ((ret = avio_handshake(client)) > 0) {
av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource); av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
// check for strlen(resource) is necessary, because av_opt_get() // check for strlen(resource) is necessary, because av_opt_get()
// may return empty string. // may return empty string.
if (resource && strlen(resource)) if (resource && strlen(resource))
break; break;
av_freep(&resource);
} }
if (ret < 0) if (ret < 0)
goto end; goto end;
@@ -94,16 +93,15 @@ end:
avio_close(client); avio_close(client);
fprintf(stderr, "Closing input\n"); fprintf(stderr, "Closing input\n");
avio_close(input); avio_close(input);
av_freep(&resource);
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
av_log_set_level(AV_LOG_TRACE);
AVDictionary *options = NULL; AVDictionary *options = NULL;
AVIOContext *client = NULL, *server = NULL; AVIOContext *client = NULL, *server = NULL;
const char *in_uri, *out_uri; const char *in_uri, *out_uri;
int ret, pid; int ret, pid;
av_log_set_level(AV_LOG_TRACE);
if (argc < 3) { if (argc < 3) {
printf("usage: %s input http://hostname[:port]\n" printf("usage: %s input http://hostname[:port]\n"
"API example program to serve http to multiple clients.\n" "API example program to serve http to multiple clients.\n"
@@ -114,6 +112,7 @@ int main(int argc, char **argv)
in_uri = argv[1]; in_uri = argv[1];
out_uri = argv[2]; out_uri = argv[2];
av_register_all();
avformat_network_init(); avformat_network_init();
if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) { if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) {

View File

@@ -1,251 +0,0 @@
/*
* Copyright (c) 2017 Jun Zhao
* Copyright (c) 2017 Kaixuan Liu
*
* HW Acceleration API (video decoding) decode sample
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* 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;
AVCodec *decoder = NULL;
AVPacket packet;
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;
}
/* 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;
av_opt_set_int(decoder_ctx, "refcounted_frames", 1, 0);
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+");
/* 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 */
packet.data = NULL;
packet.size = 0;
ret = decode_write(decoder_ctx, &packet);
av_packet_unref(&packet);
if (output_file)
fclose(output_file);
avcodec_free_context(&decoder_ctx);
avformat_close_input(&input_ctx);
av_buffer_unref(&hw_device_ctx);
return 0;
}

View File

@@ -44,6 +44,7 @@ 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;

View File

@@ -52,7 +52,6 @@
// 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;
@@ -105,18 +104,13 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
exit(1); exit(1);
} }
ost->st = avformat_new_stream(oc, NULL); ost->st = avformat_new_stream(oc, *codec);
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:
@@ -161,7 +155,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
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) {
@@ -219,7 +213,7 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
int ret; int ret;
AVDictionary *opt = NULL; AVDictionary *opt = NULL;
c = ost->enc; c = ost->st->codec;
/* open it */ /* open it */
av_dict_copy(&opt, opt_arg, 0); av_dict_copy(&opt, opt_arg, 0);
@@ -246,13 +240,6 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout, ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
c->sample_rate, nb_samples); 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);
}
/* create resampler context */ /* create resampler context */
ost->swr_ctx = swr_alloc(); ost->swr_ctx = swr_alloc();
if (!ost->swr_ctx) { if (!ost->swr_ctx) {
@@ -284,13 +271,13 @@ static AVFrame *get_audio_frame(OutputStream *ost)
int16_t *q = (int16_t*)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++) { for (j = 0; j <frame->nb_samples; j++) {
v = (int)(sin(ost->t) * 10000); v = (int)(sin(ost->t) * 10000);
for (i = 0; i < ost->enc->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;
@@ -316,7 +303,7 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
int dst_nb_samples; int dst_nb_samples;
av_init_packet(&pkt); av_init_packet(&pkt);
c = ost->enc; c = ost->st->codec;
frame = get_audio_frame(ost); frame = get_audio_frame(ost);
@@ -335,15 +322,15 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
if (ret < 0) if (ret < 0)
exit(1); exit(1);
/* convert to destination format */ /* convert to destination format */
ret = swr_convert(ost->swr_ctx, ret = swr_convert(ost->swr_ctx,
ost->frame->data, dst_nb_samples, ost->frame->data, dst_nb_samples,
(const uint8_t **)frame->data, frame->nb_samples); (const uint8_t **)frame->data, frame->nb_samples);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error while converting\n"); fprintf(stderr, "Error while converting\n");
exit(1); exit(1);
} }
frame = ost->frame; frame = ost->frame;
frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base); frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
ost->samples_count += dst_nb_samples; ost->samples_count += dst_nb_samples;
@@ -396,7 +383,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg) static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
{ {
int ret; int ret;
AVCodecContext *c = ost->enc; AVCodecContext *c = ost->st->codec;
AVDictionary *opt = NULL; AVDictionary *opt = NULL;
av_dict_copy(&opt, opt_arg, 0); av_dict_copy(&opt, opt_arg, 0);
@@ -427,20 +414,21 @@ static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
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;
@@ -460,18 +448,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 */
@@ -488,9 +471,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);
} }
@@ -512,7 +495,7 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
int got_packet = 0; int got_packet = 0;
AVPacket pkt = { 0 }; AVPacket pkt = { 0 };
c = ost->enc; c = ost->st->codec;
frame = get_video_frame(ost); frame = get_video_frame(ost);
@@ -541,7 +524,7 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
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);
sws_freeContext(ost->sws_ctx); sws_freeContext(ost->sws_ctx);
@@ -562,7 +545,9 @@ int main(int argc, char **argv)
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; AVDictionary *opt = NULL;
int i;
/* Initialize libavcodec, and register all codecs and formats. */
av_register_all();
if (argc < 2) { if (argc < 2) {
printf("usage: %s output_file\n" printf("usage: %s output_file\n"
@@ -576,9 +561,8 @@ int main(int argc, char **argv)
} }
filename = argv[1]; filename = argv[1];
for (i = 2; i+1 < argc; i+=2) { if (argc > 3 && !strcmp(argv[2], "-flags")) {
if (!strcmp(argv[i], "-flags") || !strcmp(argv[i], "-fflags")) av_dict_set(&opt, argv[2]+1, argv[3], 0);
av_dict_set(&opt, argv[i]+1, argv[i+1], 0);
} }
/* allocate the output media context */ /* allocate the output media context */
@@ -636,8 +620,8 @@ 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);

View File

@@ -26,55 +26,185 @@
* *
* @example qsvdec.c * @example qsvdec.c
* This example shows how to do QSV-accelerated H.264 decoding with output * This example shows how to do QSV-accelerated H.264 decoding with output
* frames in the GPU video surfaces. * frames in the VA-API video surfaces.
*/ */
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <mfx/mfxvideo.h>
#include <va/va.h>
#include <va/va_x11.h>
#include <X11/Xlib.h>
#include "libavformat/avformat.h" #include "libavformat/avformat.h"
#include "libavformat/avio.h" #include "libavformat/avio.h"
#include "libavcodec/avcodec.h" #include "libavcodec/avcodec.h"
#include "libavcodec/qsv.h"
#include "libavutil/buffer.h"
#include "libavutil/error.h" #include "libavutil/error.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_qsv.h"
#include "libavutil/mem.h" #include "libavutil/mem.h"
typedef struct DecodeContext { typedef struct DecodeContext {
AVBufferRef *hw_device_ref; mfxSession mfx_session;
VADisplay va_dpy;
VASurfaceID *surfaces;
mfxMemId *surface_ids;
int *surface_used;
int nb_surfaces;
mfxFrameInfo frame_info;
} DecodeContext; } DecodeContext;
static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
mfxFrameAllocResponse *resp)
{
DecodeContext *decode = pthis;
int err, i;
if (decode->surfaces) {
fprintf(stderr, "Multiple allocation requests.\n");
return MFX_ERR_MEMORY_ALLOC;
}
if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)) {
fprintf(stderr, "Unsupported surface type: %d\n", req->Type);
return MFX_ERR_UNSUPPORTED;
}
if (req->Info.BitDepthLuma != 8 || req->Info.BitDepthChroma != 8 ||
req->Info.Shift || req->Info.FourCC != MFX_FOURCC_NV12 ||
req->Info.ChromaFormat != MFX_CHROMAFORMAT_YUV420) {
fprintf(stderr, "Unsupported surface properties.\n");
return MFX_ERR_UNSUPPORTED;
}
decode->surfaces = av_malloc_array (req->NumFrameSuggested, sizeof(*decode->surfaces));
decode->surface_ids = av_malloc_array (req->NumFrameSuggested, sizeof(*decode->surface_ids));
decode->surface_used = av_mallocz_array(req->NumFrameSuggested, sizeof(*decode->surface_used));
if (!decode->surfaces || !decode->surface_ids || !decode->surface_used)
goto fail;
err = vaCreateSurfaces(decode->va_dpy, VA_RT_FORMAT_YUV420,
req->Info.Width, req->Info.Height,
decode->surfaces, req->NumFrameSuggested,
NULL, 0);
if (err != VA_STATUS_SUCCESS) {
fprintf(stderr, "Error allocating VA surfaces\n");
goto fail;
}
decode->nb_surfaces = req->NumFrameSuggested;
for (i = 0; i < decode->nb_surfaces; i++)
decode->surface_ids[i] = &decode->surfaces[i];
resp->mids = decode->surface_ids;
resp->NumFrameActual = decode->nb_surfaces;
decode->frame_info = req->Info;
return MFX_ERR_NONE;
fail:
av_freep(&decode->surfaces);
av_freep(&decode->surface_ids);
av_freep(&decode->surface_used);
return MFX_ERR_MEMORY_ALLOC;
}
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
{
return MFX_ERR_NONE;
}
static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
{
return MFX_ERR_UNSUPPORTED;
}
static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
{
return MFX_ERR_UNSUPPORTED;
}
static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
{
*hdl = mid;
return MFX_ERR_NONE;
}
static void free_surfaces(DecodeContext *decode)
{
if (decode->surfaces)
vaDestroySurfaces(decode->va_dpy, decode->surfaces, decode->nb_surfaces);
av_freep(&decode->surfaces);
av_freep(&decode->surface_ids);
av_freep(&decode->surface_used);
decode->nb_surfaces = 0;
}
static void free_buffer(void *opaque, uint8_t *data)
{
int *used = opaque;
*used = 0;
av_freep(&data);
}
static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
DecodeContext *decode = avctx->opaque;
mfxFrameSurface1 *surf;
AVBufferRef *surf_buf;
int idx;
for (idx = 0; idx < decode->nb_surfaces; idx++) {
if (!decode->surface_used[idx])
break;
}
if (idx == decode->nb_surfaces) {
fprintf(stderr, "No free surfaces\n");
return AVERROR(ENOMEM);
}
surf = av_mallocz(sizeof(*surf));
if (!surf)
return AVERROR(ENOMEM);
surf_buf = av_buffer_create((uint8_t*)surf, sizeof(*surf), free_buffer,
&decode->surface_used[idx], AV_BUFFER_FLAG_READONLY);
if (!surf_buf) {
av_freep(&surf);
return AVERROR(ENOMEM);
}
surf->Info = decode->frame_info;
surf->Data.MemId = &decode->surfaces[idx];
frame->buf[0] = surf_buf;
frame->data[3] = (uint8_t*)surf;
decode->surface_used[idx] = 1;
return 0;
}
static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts)
{ {
while (*pix_fmts != AV_PIX_FMT_NONE) { while (*pix_fmts != AV_PIX_FMT_NONE) {
if (*pix_fmts == AV_PIX_FMT_QSV) { if (*pix_fmts == AV_PIX_FMT_QSV) {
DecodeContext *decode = avctx->opaque; if (!avctx->hwaccel_context) {
AVHWFramesContext *frames_ctx; DecodeContext *decode = avctx->opaque;
AVQSVFramesContext *frames_hwctx; AVQSVContext *qsv = av_qsv_alloc_context();
int ret; if (!qsv)
return AV_PIX_FMT_NONE;
/* create a pool of surfaces to be used by the decoder */ qsv->session = decode->mfx_session;
avctx->hw_frames_ctx = av_hwframe_ctx_alloc(decode->hw_device_ref); qsv->iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
if (!avctx->hw_frames_ctx)
return AV_PIX_FMT_NONE;
frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
frames_hwctx = frames_ctx->hwctx;
frames_ctx->format = AV_PIX_FMT_QSV; avctx->hwaccel_context = qsv;
frames_ctx->sw_format = avctx->sw_pix_fmt; }
frames_ctx->width = FFALIGN(avctx->coded_width, 32);
frames_ctx->height = FFALIGN(avctx->coded_height, 32);
frames_ctx->initial_pool_size = 32;
frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
ret = av_hwframe_ctx_init(avctx->hw_frames_ctx);
if (ret < 0)
return AV_PIX_FMT_NONE;
return AV_PIX_FMT_QSV; return AV_PIX_FMT_QSV;
} }
@@ -88,47 +218,86 @@ static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts)
} }
static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx, static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx,
AVFrame *frame, AVFrame *sw_frame, AVFrame *frame, AVPacket *pkt,
AVPacket *pkt, AVIOContext *output_ctx) AVIOContext *output_ctx)
{ {
int ret = 0; int ret = 0;
int got_frame = 1;
ret = avcodec_send_packet(decoder_ctx, pkt); while (pkt->size > 0 || (!pkt->data && got_frame)) {
if (ret < 0) { ret = avcodec_decode_video2(decoder_ctx, frame, &got_frame, pkt);
fprintf(stderr, "Error during decoding\n"); if (ret < 0) {
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"); fprintf(stderr, "Error during decoding\n");
return ret; return ret;
} }
pkt->data += ret;
pkt->size -= ret;
/* A real program would do something useful with the decoded frame here. /* 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 * We just retrieve the raw data and write it to a file, which is rather
* useless but pedagogic. */ * useless but pedagogic. */
ret = av_hwframe_transfer_data(sw_frame, frame, 0); if (got_frame) {
if (ret < 0) { mfxFrameSurface1 *surf = (mfxFrameSurface1*)frame->data[3];
fprintf(stderr, "Error transferring the data to system memory\n"); VASurfaceID surface = *(VASurfaceID*)surf->Data.MemId;
goto fail;
}
for (i = 0; i < FF_ARRAY_ELEMS(sw_frame->data) && sw_frame->data[i]; i++) VAImageFormat img_fmt = {
for (j = 0; j < (sw_frame->height >> (i > 0)); j++) .fourcc = VA_FOURCC_NV12,
avio_write(output_ctx, sw_frame->data[i] + j * sw_frame->linesize[i], sw_frame->width); .byte_order = VA_LSB_FIRST,
.bits_per_pixel = 8,
.depth = 8,
};
VAImage img;
VAStatus err;
uint8_t *data;
int i, j;
img.buf = VA_INVALID_ID;
img.image_id = VA_INVALID_ID;
err = vaCreateImage(decode->va_dpy, &img_fmt,
frame->width, frame->height, &img);
if (err != VA_STATUS_SUCCESS) {
fprintf(stderr, "Error creating an image: %s\n",
vaErrorStr(err));
ret = AVERROR_UNKNOWN;
goto fail;
}
err = vaGetImage(decode->va_dpy, surface, 0, 0,
frame->width, frame->height,
img.image_id);
if (err != VA_STATUS_SUCCESS) {
fprintf(stderr, "Error getting an image: %s\n",
vaErrorStr(err));
ret = AVERROR_UNKNOWN;
goto fail;
}
err = vaMapBuffer(decode->va_dpy, img.buf, (void**)&data);
if (err != VA_STATUS_SUCCESS) {
fprintf(stderr, "Error mapping the image buffer: %s\n",
vaErrorStr(err));
ret = AVERROR_UNKNOWN;
goto fail;
}
for (i = 0; i < img.num_planes; i++)
for (j = 0; j < (img.height >> (i > 0)); j++)
avio_write(output_ctx, data + img.offsets[i] + j * img.pitches[i], img.width);
fail: fail:
av_frame_unref(sw_frame); if (img.buf != VA_INVALID_ID)
av_frame_unref(frame); vaUnmapBuffer(decode->va_dpy, img.buf);
if (img.image_id != VA_INVALID_ID)
vaDestroyImage(decode->va_dpy, img.image_id);
av_frame_unref(frame);
if (ret < 0) if (ret < 0)
return ret; return ret;
}
} }
return 0; return 0;
@@ -142,13 +311,30 @@ int main(int argc, char **argv)
const AVCodec *decoder; const AVCodec *decoder;
AVPacket pkt = { 0 }; AVPacket pkt = { 0 };
AVFrame *frame = NULL, *sw_frame = NULL; AVFrame *frame = NULL;
DecodeContext decode = { NULL }; DecodeContext decode = { NULL };
Display *dpy = NULL;
int va_ver_major, va_ver_minor;
mfxIMPL mfx_impl = MFX_IMPL_AUTO_ANY;
mfxVersion mfx_ver = { { 1, 1 } };
mfxFrameAllocator frame_allocator = {
.pthis = &decode,
.Alloc = frame_alloc,
.Lock = frame_lock,
.Unlock = frame_unlock,
.GetHDL = frame_get_hdl,
.Free = frame_free,
};
AVIOContext *output_ctx = NULL; AVIOContext *output_ctx = NULL;
int ret, i; int ret, i, err;
av_register_all();
if (argc < 3) { if (argc < 3) {
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]); fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
@@ -166,7 +352,7 @@ int main(int argc, char **argv)
for (i = 0; i < input_ctx->nb_streams; i++) { for (i = 0; i < input_ctx->nb_streams; i++) {
AVStream *st = input_ctx->streams[i]; AVStream *st = input_ctx->streams[i];
if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !video_st) if (st->codec->codec_id == AV_CODEC_ID_H264 && !video_st)
video_st = st; video_st = st;
else else
st->discard = AVDISCARD_ALL; st->discard = AVDISCARD_ALL;
@@ -176,13 +362,34 @@ int main(int argc, char **argv)
goto finish; goto finish;
} }
/* open the hardware device */ /* initialize VA-API */
ret = av_hwdevice_ctx_create(&decode.hw_device_ref, AV_HWDEVICE_TYPE_QSV, dpy = XOpenDisplay(NULL);
"auto", NULL, 0); if (!dpy) {
if (ret < 0) { fprintf(stderr, "Cannot open the X display\n");
fprintf(stderr, "Cannot open the hardware device\n");
goto finish; goto finish;
} }
decode.va_dpy = vaGetDisplay(dpy);
if (!decode.va_dpy) {
fprintf(stderr, "Cannot open the VA display\n");
goto finish;
}
err = vaInitialize(decode.va_dpy, &va_ver_major, &va_ver_minor);
if (err != VA_STATUS_SUCCESS) {
fprintf(stderr, "Cannot initialize VA: %s\n", vaErrorStr(err));
goto finish;
}
fprintf(stderr, "Initialized VA v%d.%d\n", va_ver_major, va_ver_minor);
/* initialize an MFX session */
err = MFXInit(mfx_impl, &mfx_ver, &decode.mfx_session);
if (err != MFX_ERR_NONE) {
fprintf(stderr, "Error initializing an MFX session\n");
goto finish;
}
MFXVideoCORE_SetHandle(decode.mfx_session, MFX_HANDLE_VA_DISPLAY, decode.va_dpy);
MFXVideoCORE_SetFrameAllocator(decode.mfx_session, &frame_allocator);
/* initialize the decoder */ /* initialize the decoder */
decoder = avcodec_find_decoder_by_name("h264_qsv"); decoder = avcodec_find_decoder_by_name("h264_qsv");
@@ -197,19 +404,21 @@ int main(int argc, char **argv)
goto finish; goto finish;
} }
decoder_ctx->codec_id = AV_CODEC_ID_H264; decoder_ctx->codec_id = AV_CODEC_ID_H264;
if (video_st->codecpar->extradata_size) { if (video_st->codec->extradata_size) {
decoder_ctx->extradata = av_mallocz(video_st->codecpar->extradata_size + decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE); AV_INPUT_BUFFER_PADDING_SIZE);
if (!decoder_ctx->extradata) { if (!decoder_ctx->extradata) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto finish; goto finish;
} }
memcpy(decoder_ctx->extradata, video_st->codecpar->extradata, memcpy(decoder_ctx->extradata, video_st->codec->extradata,
video_st->codecpar->extradata_size); video_st->codec->extradata_size);
decoder_ctx->extradata_size = video_st->codecpar->extradata_size; decoder_ctx->extradata_size = video_st->codec->extradata_size;
} }
decoder_ctx->refcounted_frames = 1;
decoder_ctx->opaque = &decode; decoder_ctx->opaque = &decode;
decoder_ctx->get_buffer2 = get_buffer;
decoder_ctx->get_format = get_format; decoder_ctx->get_format = get_format;
ret = avcodec_open2(decoder_ctx, NULL, NULL); ret = avcodec_open2(decoder_ctx, NULL, NULL);
@@ -225,9 +434,8 @@ int main(int argc, char **argv)
goto finish; goto finish;
} }
frame = av_frame_alloc(); frame = av_frame_alloc();
sw_frame = av_frame_alloc(); if (!frame) {
if (!frame || !sw_frame) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto finish; goto finish;
} }
@@ -239,7 +447,7 @@ int main(int argc, char **argv)
break; break;
if (pkt.stream_index == video_st->index) if (pkt.stream_index == video_st->index)
ret = decode_packet(&decode, decoder_ctx, frame, sw_frame, &pkt, output_ctx); ret = decode_packet(&decode, decoder_ctx, frame, &pkt, output_ctx);
av_packet_unref(&pkt); av_packet_unref(&pkt);
} }
@@ -247,7 +455,7 @@ int main(int argc, char **argv)
/* flush the decoder */ /* flush the decoder */
pkt.data = NULL; pkt.data = NULL;
pkt.size = 0; pkt.size = 0;
ret = decode_packet(&decode, decoder_ctx, frame, sw_frame, &pkt, output_ctx); ret = decode_packet(&decode, decoder_ctx, frame, &pkt, output_ctx);
finish: finish:
if (ret < 0) { if (ret < 0) {
@@ -259,11 +467,19 @@ finish:
avformat_close_input(&input_ctx); avformat_close_input(&input_ctx);
av_frame_free(&frame); av_frame_free(&frame);
av_frame_free(&sw_frame);
if (decoder_ctx)
av_freep(&decoder_ctx->hwaccel_context);
avcodec_free_context(&decoder_ctx); avcodec_free_context(&decoder_ctx);
av_buffer_unref(&decode.hw_device_ref); free_surfaces(&decode);
if (decode.mfx_session)
MFXClose(decode.mfx_session);
if (decode.va_dpy)
vaTerminate(decode.va_dpy);
if (dpy)
XCloseDisplay(dpy);
avio_close(output_ctx); avio_close(output_ctx);

View File

@@ -50,9 +50,6 @@ int main(int argc, char **argv)
AVPacket pkt; 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,6 +62,8 @@ int main(int argc, char **argv)
in_filename = argv[1]; in_filename = argv[1];
out_filename = argv[2]; out_filename = argv[2];
av_register_all();
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);
goto end; goto end;
@@ -84,42 +83,25 @@ int main(int argc, char **argv)
goto end; goto end;
} }
stream_mapping_size = ifmt_ctx->nb_streams;
stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
if (!stream_mapping) {
ret = AVERROR(ENOMEM);
goto end;
}
ofmt = ofmt_ctx->oformat; 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 |= AV_CODEC_FLAG_GLOBAL_HEADER;
} }
av_dump_format(ofmt_ctx, 0, out_filename, 1); av_dump_format(ofmt_ctx, 0, out_filename, 1);
@@ -145,14 +127,8 @@ int main(int argc, char **argv)
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 ||
stream_mapping[pkt.stream_index] < 0) {
av_packet_unref(&pkt);
continue;
}
pkt.stream_index = stream_mapping[pkt.stream_index];
out_stream = ofmt_ctx->streams[pkt.stream_index]; out_stream = ofmt_ctx->streams[pkt.stream_index];
log_packet(ifmt_ctx, &pkt, "in"); log_packet(ifmt_ctx, &pkt, "in");
/* copy packet */ /* copy packet */
@@ -180,8 +156,6 @@ end:
avio_closep(&ofmt_ctx->pb); avio_closep(&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;

File diff suppressed because it is too large Load Diff

View File

@@ -30,6 +30,7 @@
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libavfilter/avfiltergraph.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>
@@ -44,12 +45,6 @@ typedef struct FilteringContext {
} FilteringContext; } FilteringContext;
static FilteringContext *filter_ctx; static FilteringContext *filter_ctx;
typedef struct StreamContext {
AVCodecContext *dec_ctx;
AVCodecContext *enc_ctx;
} 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;
@@ -66,42 +61,22 @@ static int open_input_file(const char *filename)
return ret; return ret;
} }
stream_ctx = av_mallocz_array(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;
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;
} }
av_dump_format(ifmt_ctx, 0, filename, 0); av_dump_format(ifmt_ctx, 0, filename, 0);
@@ -133,7 +108,8 @@ 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) {
@@ -143,11 +119,6 @@ static int open_output_file(const char *filename)
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n"); av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
return AVERROR_INVALIDDATA; 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
@@ -157,12 +128,9 @@ 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;
enc_ctx->channel_layout = dec_ctx->channel_layout; enc_ctx->channel_layout = dec_ctx->channel_layout;
@@ -178,29 +146,22 @@ static int open_output_file(const char *filename)
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;
}
if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
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 |= AV_CODEC_FLAG_GLOBAL_HEADER;
} }
av_dump_format(ofmt_ctx, 0, filename, 1); av_dump_format(ofmt_ctx, 0, filename, 1);
@@ -227,8 +188,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();
@@ -384,17 +345,17 @@ 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;
} }
@@ -406,7 +367,7 @@ static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, in
int got_frame_local; int got_frame_local;
AVPacket enc_pkt; AVPacket enc_pkt;
int (*enc_func)(AVCodecContext *, AVPacket *, const AVFrame *, int *) = int (*enc_func)(AVCodecContext *, AVPacket *, const AVFrame *, int *) =
(ifmt_ctx->streams[stream_index]->codecpar->codec_type == (ifmt_ctx->streams[stream_index]->codec->codec_type ==
AVMEDIA_TYPE_VIDEO) ? avcodec_encode_video2 : avcodec_encode_audio2; AVMEDIA_TYPE_VIDEO) ? avcodec_encode_video2 : avcodec_encode_audio2;
if (!got_frame) if (!got_frame)
@@ -417,7 +378,7 @@ static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, in
enc_pkt.data = NULL; enc_pkt.data = NULL;
enc_pkt.size = 0; enc_pkt.size = 0;
av_init_packet(&enc_pkt); av_init_packet(&enc_pkt);
ret = enc_func(stream_ctx[stream_index].enc_ctx, &enc_pkt, ret = enc_func(ofmt_ctx->streams[stream_index]->codec, &enc_pkt,
filt_frame, got_frame); filt_frame, got_frame);
av_frame_free(&filt_frame); av_frame_free(&filt_frame);
if (ret < 0) if (ret < 0)
@@ -428,7 +389,7 @@ static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, in
/* prepare packet for muxing */ /* prepare packet for muxing */
enc_pkt.stream_index = stream_index; enc_pkt.stream_index = stream_index;
av_packet_rescale_ts(&enc_pkt, av_packet_rescale_ts(&enc_pkt,
stream_ctx[stream_index].enc_ctx->time_base, ofmt_ctx->streams[stream_index]->codec->time_base,
ofmt_ctx->streams[stream_index]->time_base); ofmt_ctx->streams[stream_index]->time_base);
av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n"); av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
@@ -486,7 +447,7 @@ static int flush_encoder(unsigned int stream_index)
int ret; int ret;
int got_frame; int got_frame;
if (!(stream_ctx[stream_index].enc_ctx->codec->capabilities & if (!(ofmt_ctx->streams[stream_index]->codec->codec->capabilities &
AV_CODEC_CAP_DELAY)) AV_CODEC_CAP_DELAY))
return 0; return 0;
@@ -517,6 +478,9 @@ int main(int argc, char **argv)
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)
@@ -529,7 +493,7 @@ int main(int argc, char **argv)
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]->codecpar->codec_type; 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);
@@ -542,10 +506,10 @@ int main(int argc, char **argv)
} }
av_packet_rescale_ts(&packet, av_packet_rescale_ts(&packet,
ifmt_ctx->streams[stream_index]->time_base, ifmt_ctx->streams[stream_index]->time_base,
stream_ctx[stream_index].dec_ctx->time_base); ifmt_ctx->streams[stream_index]->codec->time_base);
dec_func = (type == AVMEDIA_TYPE_VIDEO) ? avcodec_decode_video2 : dec_func = (type == AVMEDIA_TYPE_VIDEO) ? avcodec_decode_video2 :
avcodec_decode_audio4; avcodec_decode_audio4;
ret = dec_func(stream_ctx[stream_index].dec_ctx, frame, ret = dec_func(ifmt_ctx->streams[stream_index]->codec, frame,
&got_frame, &packet); &got_frame, &packet);
if (ret < 0) { if (ret < 0) {
av_frame_free(&frame); av_frame_free(&frame);
@@ -554,7 +518,7 @@ int main(int argc, char **argv)
} }
if (got_frame) { if (got_frame) {
frame->pts = frame->best_effort_timestamp; frame->pts = av_frame_get_best_effort_timestamp(frame);
ret = filter_encode_write_frame(frame, stream_index); ret = filter_encode_write_frame(frame, stream_index);
av_frame_free(&frame); av_frame_free(&frame);
if (ret < 0) if (ret < 0)
@@ -599,14 +563,13 @@ end:
av_packet_unref(&packet); av_packet_unref(&packet);
av_frame_free(&frame); 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_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_closep(&ofmt_ctx->pb);

View File

@@ -1,222 +0,0 @@
/*
* Video Acceleration API (video encoding) encode sample
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* 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;
av_init_packet(&enc_pkt);
enc_pkt.data = NULL;
enc_pkt.size = 0;
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:
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;
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, 32)) < 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;
}

View File

@@ -1,304 +0,0 @@
/*
* Video Acceleration API (video transcoding) transcode sample
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* 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;
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(AVFrame *frame)
{
int ret = 0;
AVPacket enc_pkt;
av_init_packet(&enc_pkt);
enc_pkt.data = NULL;
enc_pkt.size = 0;
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, 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 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(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)
{
int ret = 0;
AVPacket dec_pkt;
AVCodec *enc_codec;
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;
}
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 */
dec_pkt.data = NULL;
dec_pkt.size = 0;
ret = dec_enc(&dec_pkt, enc_codec);
av_packet_unref(&dec_pkt);
/* flush encoder */
ret = encode_write(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);
return ret;
}

View File

@@ -311,18 +311,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{https://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{https://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{https://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video filter.
@end itemize @end itemize
@@ -333,19 +333,19 @@ 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{https://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{https://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{https://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.
@@ -385,7 +385,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 +407,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]
@@ -485,7 +485,7 @@ scaling adjusts the SAR to keep the DAR constant.
If you want to stretch, or “unstretch”, the image, you need to override the If you want to stretch, or “unstretch”, the image, you need to override the
information with the information with the
@url{ffmpeg-filters.html#setdar_002c-setsar, @code{setdar or setsar filters}}. @url{https://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar, @code{setdar or setsar filters}}.
Do not forget to examine carefully the original video to check whether the Do not forget to examine carefully the original video to check whether the
stretching comes from the image or from the aspect ratio information. stretching comes from the image or from the aspect ratio information.
@@ -501,71 +501,6 @@ 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 ffmpeg -i ega_screen.nut -aspect 4/3 -c copy ega_screen_overridden.nut
@end example @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 Mac OS)
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, Mac OS, 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?

View File

@@ -147,26 +147,6 @@ 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
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.
@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
@@ -217,11 +197,6 @@ through @command{ssh}.
@item GEN @item GEN
Set to @samp{1} to generate the missing or mismatched references. Set to @samp{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.
@end table @end table
@section Examples @section Examples

View File

@@ -6,7 +6,6 @@ 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 +26,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'

View File

@@ -26,12 +26,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

View File

@@ -23,12 +23,12 @@ the libavcodec library.
@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

View File

@@ -23,12 +23,12 @@ libavdevice library.
@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{libavdevice.html,libavdevice} @url{libavdevice.html,libavdevice}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libavdevice(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavdevice(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -23,12 +23,12 @@ libavfilter library.
@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{libavfilter.html,libavfilter} @url{libavfilter.html,libavfilter}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libavfilter(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavfilter(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -23,12 +23,12 @@ provided by the libavformat library.
@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{libavformat.html,libavformat} @url{libavformat.html,libavformat}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libavformat(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavformat(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -23,12 +23,12 @@ libavformat library.
@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{libavformat.html,libavformat} @url{libavformat.html,libavformat}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libavformat(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavformat(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -25,12 +25,12 @@ and convert audio format and packing layout.
@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{libswresample.html,libswresample} @url{libswresample.html,libswresample}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libswresample(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libswresample(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -24,12 +24,12 @@ image rescaling and pixel format conversion.
@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{libswscale.html,libswscale} @url{libswscale.html,libswscale}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libswscale(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libswscale(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -23,12 +23,12 @@ by the libavutil library.
@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{libavutil.html,libavutil} @url{libavutil.html,libavutil}
@end ifhtml @end ifhtml
@ifnothtml @ifnothtml
ffmpeg(1), ffplay(1), ffprobe(1), libavutil(3) ffmpeg(1), ffplay(1), ffprobe(1), ffserver(1), libavutil(3)
@end ifnothtml @end ifnothtml
@include authors.texi @include authors.texi

View File

@@ -12,7 +12,7 @@
@chapter Synopsis @chapter Synopsis
ffmpeg [@var{global_options}] @{[@var{input_file_options}] -i @file{input_url}@} ... @{[@var{output_file_options}] @file{output_url}@} ... ffmpeg [@var{global_options}] @{[@var{input_file_options}] -i @file{input_file}@} ... @{[@var{output_file_options}] @file{output_file}@} ...
@chapter Description @chapter Description
@c man begin DESCRIPTION @c man begin DESCRIPTION
@@ -24,10 +24,10 @@ rates and resize video on the fly with a high quality polyphase filter.
@command{ffmpeg} reads from an arbitrary number of input "files" (which can be regular @command{ffmpeg} reads from an arbitrary number of input "files" (which can be regular
files, pipes, network streams, grabbing devices, etc.), specified by the files, pipes, network streams, grabbing devices, etc.), specified by the
@code{-i} option, and writes to an arbitrary number of output "files", which are @code{-i} option, and writes to an arbitrary number of output "files", which are
specified by a plain output url. Anything found on the command line which specified by a plain output filename. Anything found on the command line which
cannot be interpreted as an option is considered to be an output url. cannot be interpreted as an option is considered to be an output filename.
Each input or output url can, in principle, contain any number of streams of Each input or output file can, in principle, contain any number of streams of
different types (video/audio/subtitle/attachment/data). The allowed number and/or different types (video/audio/subtitle/attachment/data). The allowed number and/or
types of streams may be limited by the container format. Selecting which types of streams may be limited by the container format. Selecting which
streams from which inputs will go into which output is either done automatically streams from which inputs will go into which output is either done automatically
@@ -223,7 +223,7 @@ with the highest resolution, for audio, it is the stream with the most channels,
subtitles, it is the first subtitle stream. In the case where several streams of subtitles, it is the first subtitle stream. In the case where several streams of
the same type rate equally, the stream with the lowest index is chosen. the same type rate equally, the stream with the lowest index is chosen.
You can disable some of those defaults by using the @code{-vn/-an/-sn/-dn} options. For You can disable some of those defaults by using the @code{-vn/-an/-sn} options. For
full manual control, use the @code{-map} option, which disables the defaults just full manual control, use the @code{-map} option, which disables the defaults just
described. described.
@@ -243,8 +243,8 @@ Force input or output file format. The format is normally auto detected for inpu
files and guessed from the file extension for output files, so this option is not files and guessed from the file extension for output files, so this option is not
needed in most cases. needed in most cases.
@item -i @var{url} (@emph{input}) @item -i @var{filename} (@emph{input})
input file url input file name
@item -y (@emph{global}) @item -y (@emph{global})
Overwrite output files without asking. Overwrite output files without asking.
@@ -281,7 +281,7 @@ libx264, and the 138th audio, which will be encoded with libvorbis.
When used as an input option (before @code{-i}), limit the @var{duration} of When used as an input option (before @code{-i}), limit the @var{duration} of
data read from the input file. data read from the input file.
When used as an output option (before an output url), stop writing the When used as an output option (before an output filename), stop writing the
output after its duration reaches @var{duration}. output after its duration reaches @var{duration}.
@var{duration} must be a time duration specification, @var{duration} must be a time duration specification,
@@ -289,8 +289,8 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1)
-to and -t are mutually exclusive and -t has priority. -to and -t are mutually exclusive and -t has priority.
@item -to @var{position} (@emph{input/output}) @item -to @var{position} (@emph{output})
Stop writing the output or reading the input at @var{position}. Stop writing the output at @var{position}.
@var{position} must be a time duration specification, @var{position} must be a time duration specification,
see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
@@ -310,7 +310,7 @@ extra segment between the seek point and @var{position} will be decoded and
discarded. When doing stream copy or when @option{-noaccurate_seek} is used, it discarded. When doing stream copy or when @option{-noaccurate_seek} is used, it
will be preserved. will be preserved.
When used as an output option (before an output url), decodes but discards When used as an output option (before an output filename), decodes but discards
input until the timestamps reach @var{position}. input until the timestamps reach @var{position}.
@var{position} must be a time duration specification, @var{position} must be a time duration specification,
@@ -357,40 +357,6 @@ To set the language of the first audio stream:
ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
@end example @end example
@item -disposition[:stream_specifier] @var{value} (@emph{output,per-stream})
Sets the disposition for a stream.
This option overrides the disposition copied from the input stream. It is also
possible to delete the disposition by setting it to 0.
The following dispositions are recognized:
@table @option
@item default
@item dub
@item original
@item comment
@item lyrics
@item karaoke
@item forced
@item hearing_impaired
@item visual_impaired
@item clean_effects
@item captions
@item descriptions
@item metadata
@end table
For example, to make the second audio stream the default stream:
@example
ffmpeg -i in.mkv -disposition:a:1 default out.mkv
@end example
To make the second subtitle stream the default stream and remove the default
disposition from the first subtitle stream:
@example
ffmpeg -i INPUT -disposition:s:0 0 -disposition:s:1 default OUTPUT
@end example
@item -program [title=@var{title}:][program_num=@var{program_num}:]st=@var{stream}[:st=@var{stream}...] (@emph{output}) @item -program [title=@var{title}:][program_num=@var{program_num}:]st=@var{stream}[:st=@var{stream}...] (@emph{output})
Creates a program with the specified @var{title}, @var{program_num} and adds the specified Creates a program with the specified @var{title}, @var{program_num} and adds the specified
@@ -413,13 +379,8 @@ they do not conflict with the standard, as in:
ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
@end example @end example
@item -dn (@emph{output})
Disable data recording. For full manual control see the @code{-map}
option.
@item -dframes @var{number} (@emph{output}) @item -dframes @var{number} (@emph{output})
Set the number of data frames to output. This is an obsolete alias for Set the number of data frames to output. This is an alias for @code{-frames:d}.
@code{-frames:d}, which you should use instead.
@item -frames[:@var{stream_specifier}] @var{framecount} (@emph{output,per-stream}) @item -frames[:@var{stream_specifier}] @var{framecount} (@emph{output,per-stream})
Stop writing to the stream after @var{framecount} frames. Stop writing to the stream after @var{framecount} frames.
@@ -454,11 +415,6 @@ This option is similar to @option{-filter}, the only difference is that its
argument is the name of the file from which a filtergraph description is to be argument is the name of the file from which a filtergraph description is to be
read. read.
@item -filter_threads @var{nb_threads} (@emph{global})
Defines how many threads are used to process a filter pipeline. Each pipeline
will produce a thread pool with this many threads available for parallel processing.
The default is the number of available CPUs.
@item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream}) @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
Specify the preset for matching stream(s). Specify the preset for matching stream(s).
@@ -474,7 +430,6 @@ the encoding process. It is made of "@var{key}=@var{value}" lines. @var{key}
consists of only alphanumeric characters. The last key of a sequence of consists of only alphanumeric characters. The last key of a sequence of
progress information is always "progress". progress information is always "progress".
@anchor{stdin option}
@item -stdin @item -stdin
Enable interaction on standard input. On by default unless standard input is Enable interaction on standard input. On by default unless standard input is
used as an input. To explicitly disable interaction you need to specify used as an input. To explicitly disable interaction you need to specify
@@ -535,8 +490,7 @@ Disable automatically rotating video based on file metadata.
@table @option @table @option
@item -vframes @var{number} (@emph{output}) @item -vframes @var{number} (@emph{output})
Set the number of video frames to output. This is an obsolete alias for Set the number of video frames to output. This is an alias for @code{-frames:v}.
@code{-frames:v}, which you should use instead.
@item -r[:@var{stream_specifier}] @var{fps} (@emph{input/output,per-stream}) @item -r[:@var{stream_specifier}] @var{fps} (@emph{input/output,per-stream})
Set frame rate (Hz value, fraction or abbreviation). Set frame rate (Hz value, fraction or abbreviation).
@@ -575,8 +529,7 @@ stored at container level, but not the aspect ratio stored in encoded
frames, if it exists. frames, if it exists.
@item -vn (@emph{output}) @item -vn (@emph{output})
Disable video recording. For full manual control see the @code{-map} Disable video recording.
option.
@item -vcodec @var{codec} (@emph{output}) @item -vcodec @var{codec} (@emph{output})
Set the video codec. This is an alias for @code{-codec:v}. Set the video codec. This is an alias for @code{-codec:v}.
@@ -644,16 +597,6 @@ Calculate PSNR of compressed frames.
Dump video coding statistics to @file{vstats_HHMMSS.log}. Dump video coding statistics to @file{vstats_HHMMSS.log}.
@item -vstats_file @var{file} @item -vstats_file @var{file}
Dump video coding statistics to @var{file}. Dump video coding statistics to @var{file}.
@item -vstats_version @var{file}
Specifies which version of the vstats format to use. Default is 2.
version = 1 :
@code{frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s}
version > 1:
@code{out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s}
@item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream}) @item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream})
top=1/bottom=0/auto=-1 field first top=1/bottom=0/auto=-1 field first
@item -dc @var{precision} @item -dc @var{precision}
@@ -721,104 +664,6 @@ would be more efficient.
When doing stream copy, copy also non-key frames found at the When doing stream copy, copy also non-key frames found at the
beginning. beginning.
@item -init_hw_device @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
Initialise a new hardware device of type @var{type} called @var{name}, using the
given device parameters.
If no name is specified it will receive a default name of the form "@var{type}%d".
The meaning of @var{device} and the following arguments depends on the
device type:
@table @option
@item cuda
@var{device} is the number of the CUDA device.
@item dxva2
@var{device} is the number of the Direct3D 9 display adapter.
@item vaapi
@var{device} is either an X11 display name or a DRM render node.
If not specified, it will attempt to open the default X11 display (@emph{$DISPLAY})
and then the first DRM render node (@emph{/dev/dri/renderD128}).
@item vdpau
@var{device} is an X11 display name.
If not specified, it will attempt to open the default X11 display (@emph{$DISPLAY}).
@item qsv
@var{device} selects a value in @samp{MFX_IMPL_*}. Allowed values are:
@table @option
@item auto
@item sw
@item hw
@item auto_any
@item hw_any
@item hw2
@item hw3
@item hw4
@end table
If not specified, @samp{auto_any} is used.
(Note that it may be easier to achieve the desired result for QSV by creating the
platform-appropriate subdevice (@samp{dxva2} or @samp{vaapi}) and then deriving a
QSV device from that.)
@item opencl
@var{device} selects the platform and device as @emph{platform_index.device_index}.
The set of devices can also be filtered using the key-value pairs to find only
devices matching particular platform or device strings.
The strings usable as filters are:
@table @option
@item platform_profile
@item platform_version
@item platform_name
@item platform_vendor
@item platform_extensions
@item device_name
@item device_vendor
@item driver_version
@item device_version
@item device_profile
@item device_extensions
@item device_type
@end table
The indices and filters must together uniquely select a device.
Examples:
@table @emph
@item -init_hw_device opencl:0.1
Choose the second device on the first platform.
@item -init_hw_device opencl:,device_name=Foo9000
Choose the device with a name containing the string @emph{Foo9000}.
@item -init_hw_device opencl:1,device_type=gpu,device_extensions=cl_khr_fp16
Choose the GPU device on the second platform supporting the @emph{cl_khr_fp16}
extension.
@end table
@end table
@item -init_hw_device @var{type}[=@var{name}]@@@var{source}
Initialise a new hardware device of type @var{type} called @var{name},
deriving it from the existing device with the name @var{source}.
@item -init_hw_device list
List all hardware device types supported in this build of ffmpeg.
@item -filter_hw_device @var{name}
Pass the hardware device called @var{name} to all filters in any filter graph.
This can be used to set the device to upload to with the @code{hwupload} filter,
or the device to map to with the @code{hwmap} filter. Other filters may also
make use of this parameter when they require a hardware device. Note that this
is typically only required when the input is not already in hardware frames -
when it is, filters will derive the device they require from the context of the
frames they receive as input.
This is a global setting, so all filters will receive the same device.
@item -hwaccel[:@var{stream_specifier}] @var{hwaccel} (@emph{input,per-stream}) @item -hwaccel[:@var{stream_specifier}] @var{hwaccel} (@emph{input,per-stream})
Use hardware acceleration to decode the matching stream(s). The allowed values Use hardware acceleration to decode the matching stream(s). The allowed values
of @var{hwaccel} are: of @var{hwaccel} are:
@@ -829,15 +674,15 @@ Do not use any hardware acceleration (the default).
@item auto @item auto
Automatically select the hardware acceleration method. Automatically select the hardware acceleration method.
@item vda
Use Apple VDA hardware acceleration.
@item vdpau @item vdpau
Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration. Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
@item dxva2 @item dxva2
Use DXVA2 (DirectX Video Acceleration) hardware acceleration. Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
@item vaapi
Use VAAPI (Video Acceleration API) hardware acceleration.
@item qsv @item qsv
Use the Intel QuickSync Video acceleration for video transcoding. Use the Intel QuickSync Video acceleration for video transcoding.
@@ -861,11 +706,33 @@ useful for testing.
@item -hwaccel_device[:@var{stream_specifier}] @var{hwaccel_device} (@emph{input,per-stream}) @item -hwaccel_device[:@var{stream_specifier}] @var{hwaccel_device} (@emph{input,per-stream})
Select a device to use for hardware acceleration. Select a device to use for hardware acceleration.
This option only makes sense when the @option{-hwaccel} option is also specified. This option only makes sense when the @option{-hwaccel} option is also
It can either refer to an existing device created with @option{-init_hw_device} specified. Its exact meaning depends on the specific hardware acceleration
by name, or it can create a new device as if method chosen.
@samp{-init_hw_device} @var{type}:@var{hwaccel_device}
were called immediately before. @table @option
@item vdpau
For VDPAU, this option specifies the X11 display/screen to use. If this option
is not specified, the value of the @var{DISPLAY} environment variable is used
@item dxva2
For DXVA2, this option should contain the number of the display adapter to use.
If this option is not specified, the default adapter is used.
@item qsv
For QSV, this option corresponds to the valus of MFX_IMPL_* . Allowed values
are:
@table @option
@item auto
@item sw
@item hw
@item auto_any
@item hw_any
@item hw2
@item hw3
@item hw4
@end table
@end table
@item -hwaccels @item -hwaccels
List all hardware acceleration methods supported in this build of ffmpeg. List all hardware acceleration methods supported in this build of ffmpeg.
@@ -876,8 +743,7 @@ List all hardware acceleration methods supported in this build of ffmpeg.
@table @option @table @option
@item -aframes @var{number} (@emph{output}) @item -aframes @var{number} (@emph{output})
Set the number of audio frames to output. This is an obsolete alias for Set the number of audio frames to output. This is an alias for @code{-frames:a}.
@code{-frames:a}, which you should use instead.
@item -ar[:@var{stream_specifier}] @var{freq} (@emph{input/output,per-stream}) @item -ar[:@var{stream_specifier}] @var{freq} (@emph{input/output,per-stream})
Set the audio sampling frequency. For output streams it is set by Set the audio sampling frequency. For output streams it is set by
default to the frequency of the corresponding input stream. For input default to the frequency of the corresponding input stream. For input
@@ -891,8 +757,7 @@ default to the number of input audio channels. For input streams
this option only makes sense for audio grabbing devices and raw demuxers this option only makes sense for audio grabbing devices and raw demuxers
and is mapped to the corresponding demuxer options. and is mapped to the corresponding demuxer options.
@item -an (@emph{output}) @item -an (@emph{output})
Disable audio recording. For full manual control see the @code{-map} Disable audio recording.
option.
@item -acodec @var{codec} (@emph{input/output}) @item -acodec @var{codec} (@emph{input/output})
Set the audio codec. This is an alias for @code{-codec:a}. Set the audio codec. This is an alias for @code{-codec:a}.
@item -sample_fmt[:@var{stream_specifier}] @var{sample_fmt} (@emph{output,per-stream}) @item -sample_fmt[:@var{stream_specifier}] @var{sample_fmt} (@emph{output,per-stream})
@@ -927,8 +792,7 @@ stereo but not 6 channels as 5.1. The default is to always try to guess. Use
@item -scodec @var{codec} (@emph{input/output}) @item -scodec @var{codec} (@emph{input/output})
Set the subtitle codec. This is an alias for @code{-codec:s}. Set the subtitle codec. This is an alias for @code{-codec:s}.
@item -sn (@emph{output}) @item -sn (@emph{output})
Disable subtitle recording. For full manual control see the @code{-map} Disable subtitle recording.
option.
@item -sbsf @var{bitstream_filter} @item -sbsf @var{bitstream_filter}
Deprecated, see -bsf Deprecated, see -bsf
@end table @end table
@@ -958,7 +822,7 @@ Set the size of the canvas used to render subtitles.
@section Advanced options @section Advanced options
@table @option @table @option
@item -map [-]@var{input_file_id}[:@var{stream_specifier}][?][,@var{sync_file_id}[:@var{stream_specifier}]] | @var{[linklabel]} (@emph{output}) @item -map [-]@var{input_file_id}[:@var{stream_specifier}][,@var{sync_file_id}[:@var{stream_specifier}]] | @var{[linklabel]} (@emph{output})
Designate one or more input streams as a source for the output file. Each input Designate one or more input streams as a source for the output file. Each input
stream is identified by the input file index @var{input_file_id} and stream is identified by the input file index @var{input_file_id} and
@@ -974,11 +838,6 @@ the source for output stream 1, etc.
A @code{-} character before the stream identifier creates a "negative" mapping. A @code{-} character before the stream identifier creates a "negative" mapping.
It disables matching streams from already created mappings. It disables matching streams from already created mappings.
A trailing @code{?} after the stream index will allow the map to be
optional: if the map matches no streams the map will be ignored instead
of failing. Note the map will still fail if an invalid input file index
is used; such as if the map refers to a non-existent input.
An alternative @var{[linklabel]} form will map outputs from complex filter An alternative @var{[linklabel]} form will map outputs from complex filter
graphs (see the @option{-filter_complex} option) to the output file. graphs (see the @option{-filter_complex} option) to the output file.
@var{linklabel} must correspond to a defined output link label in the graph. @var{linklabel} must correspond to a defined output link label in the graph.
@@ -1016,13 +875,6 @@ To map all the streams except the second audio, use negative mappings
ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
@end example @end example
To map the video and audio streams from the first input, and using the
trailing @code{?}, ignore the audio mapping if no audio streams exist in
the first input:
@example
ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
@end example
To pick the English audio stream: To pick the English audio stream:
@example @example
ffmpeg -i INPUT -map 0:m:language:eng OUTPUT ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
@@ -1038,7 +890,7 @@ such streams is attempted.
Allow input streams with unknown type to be copied instead of failing if copying Allow input streams with unknown type to be copied instead of failing if copying
such streams is attempted. such streams is attempted.
@item -map_channel [@var{input_file_id}.@var{stream_specifier}.@var{channel_id}|-1][?][:@var{output_file_id}.@var{stream_specifier}] @item -map_channel [@var{input_file_id}.@var{stream_specifier}.@var{channel_id}|-1][:@var{output_file_id}.@var{stream_specifier}]
Map an audio channel from a given input to an output. If Map an audio channel from a given input to an output. If
@var{output_file_id}.@var{stream_specifier} is not set, the audio channel will @var{output_file_id}.@var{stream_specifier} is not set, the audio channel will
be mapped on all the audio streams. be mapped on all the audio streams.
@@ -1047,10 +899,6 @@ Using "-1" instead of
@var{input_file_id}.@var{stream_specifier}.@var{channel_id} will map a muted @var{input_file_id}.@var{stream_specifier}.@var{channel_id} will map a muted
channel. channel.
A trailing @code{?} will allow the map_channel to be
optional: if the map_channel matches no channel the map_channel will be ignored instead
of failing.
For example, assuming @var{INPUT} is a stereo audio file, you can switch the For example, assuming @var{INPUT} is a stereo audio file, you can switch the
two audio channels with the following command: two audio channels with the following command:
@example @example
@@ -1098,13 +946,6 @@ video stream), you can use the following command:
ffmpeg -i input.mkv -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le -c:v copy output.mkv ffmpeg -i input.mkv -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le -c:v copy output.mkv
@end example @end example
To map the first two audio channels from the first input, and using the
trailing @code{?}, ignore the audio channel mapping if the first input is
mono instead of stereo:
@example
ffmpeg -i INPUT -map_channel 0.0.0 -map_channel 0.0.1? OUTPUT
@end example
@item -map_metadata[:@var{metadata_spec_out}] @var{infile}[:@var{metadata_spec_in}] (@emph{output,per-metadata}) @item -map_metadata[:@var{metadata_spec_out}] @var{infile}[:@var{metadata_spec_in}] (@emph{output,per-metadata})
Set metadata information of the next output file from @var{infile}. Note that Set metadata information of the next output file from @var{infile}. Note that
those are file indices (zero-based), not filenames. those are file indices (zero-based), not filenames.
@@ -1167,13 +1008,17 @@ Dump each input packet to stderr.
@item -hex (@emph{global}) @item -hex (@emph{global})
When dumping packets, also dump the payload. When dumping packets, also dump the payload.
@item -re (@emph{input}) @item -re (@emph{input})
Read input at native frame rate. Mainly used to simulate a grab device, Read input at native frame rate. Mainly used to simulate a grab device.
or live input stream (e.g. when reading from a file). Should not be used or live input stream (e.g. when reading from a file). Should not be used
with actual grab devices or live input streams (where it can cause packet with actual grab devices or live input streams (where it can cause packet
loss). loss).
By default @command{ffmpeg} attempts to read the input(s) as fast as possible. By default @command{ffmpeg} attempts to read the input(s) as fast as possible.
This option will slow down the reading of the input(s) to the native frame rate This option will slow down the reading of the input(s) to the native frame rate
of the input(s). It is useful for real-time output (e.g. live streaming). of the input(s). It is useful for real-time output (e.g. live streaming).
@item -loop_input
Loop over the input stream. Currently it works only for image
streams. This option is used for automatic FFserver testing.
This option is deprecated, use -loop 1.
@item -loop_output @var{number_of_times} @item -loop_output @var{number_of_times}
Repeatedly loop output for formats that support looping such as animated GIF Repeatedly loop output for formats that support looping such as animated GIF
(0 will loop the output infinitely). (0 will loop the output infinitely).
@@ -1267,32 +1112,6 @@ Try to make the choice automatically, in order to generate a sane output.
Default value is -1. Default value is -1.
@item -enc_time_base[:@var{stream_specifier}] @var{timebase} (@emph{output,per-stream})
Set the encoder timebase. @var{timebase} is a floating point number,
and can assume one of the following values:
@table @option
@item 0
Assign a default value according to the media type.
For video - use 1/framerate, for audio - use 1/samplerate.
@item -1
Use the input stream timebase when possible.
If an input stream is not available, the default timebase will be used.
@item >0
Use the provided number as the timebase.
This field can be provided as a ratio of two integers (e.g. 1:24, 1:48000)
or as a floating point number (e.g. 0.04166, 2.0833e-5)
@end table
Default value is 0.
@item -bitexact (@emph{input/output})
Enable bitexact mode for (de)muxer and (de/en)coder
@item -shortest (@emph{output}) @item -shortest (@emph{output})
Finish encoding when the shortest input stream ends. Finish encoding when the shortest input stream ends.
@item -dts_delta_threshold @item -dts_delta_threshold
@@ -1310,7 +1129,7 @@ may be reassigned to a different value.
For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
an output mpegts file: an output mpegts file:
@example @example
ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts
@end example @end example
@item -bsf[:@var{stream_specifier}] @var{bitstream_filters} (@emph{output,per-stream}) @item -bsf[:@var{stream_specifier}] @var{bitstream_filters} (@emph{output,per-stream})
@@ -1382,11 +1201,6 @@ To generate 5 seconds of pure red video using lavfi @code{color} source:
ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
@end example @end example
@item -filter_complex_threads @var{nb_threads} (@emph{global})
Defines how many threads are used to process a filter_complex graph.
Similar to filter_threads but used for @code{-filter_complex} graphs only.
The default is the number of available CPUs.
@item -lavfi @var{filtergraph} (@emph{global}) @item -lavfi @var{filtergraph} (@emph{global})
Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
outputs. Equivalent to @option{-filter_complex}. outputs. Equivalent to @option{-filter_complex}.
@@ -1415,6 +1229,16 @@ file or device. With low latency / high rate live streams, packets may be
discarded if they are not read in a timely manner; raising this value can discarded if they are not read in a timely manner; raising this value can
avoid it. avoid it.
@item -override_ffserver (@emph{global})
Overrides the input specifications from @command{ffserver}. Using this
option you can map any input stream to @command{ffserver} and control
many aspects of the encoding from @command{ffmpeg}. Without this
option @command{ffmpeg} will transmit to @command{ffserver} what is
requested by @command{ffserver}.
The option is intended for cases where features are needed that cannot be
specified to @command{ffserver} but can be to @command{ffmpeg}.
@item -sdp_file @var{file} (@emph{global}) @item -sdp_file @var{file} (@emph{global})
Print sdp information for an output stream to @var{file}. Print sdp information for an output stream to @var{file}.
This allows dumping sdp information when at least one output isn't an This allows dumping sdp information when at least one output isn't an
@@ -1455,15 +1279,6 @@ No packets were passed to the muxer, the output is empty.
@item -xerror (@emph{global}) @item -xerror (@emph{global})
Stop and exit on error Stop and exit on error
@item -max_muxing_queue_size @var{packets} (@emph{output,per-stream})
When transcoding audio and/or video streams, ffmpeg will not begin writing into
the output until it has one packet for each such stream. While waiting for that
to happen, packets for other streams are buffered. This option sets the size of
this buffer, in packets, for the matching output stream.
The default value of this option should be high enough for most uses, so only
touch this option if you are sure that you need it.
@end table @end table
As a special exception, you can use a bitmap subtitle stream as input: it As a special exception, you can use a bitmap subtitle stream as input: it
@@ -1669,7 +1484,7 @@ to enable LAME support by passing @code{--enable-libmp3lame} to configure.
The mapping is particularly useful for DVD transcoding The mapping is particularly useful for DVD transcoding
to get the desired audio language. to get the desired audio language.
NOTE: To see the supported input formats, use @code{ffmpeg -demuxers}. NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
@item @item
You can extract images from a video, or create a video from many images: You can extract images from a video, or create a video from many images:
@@ -1684,8 +1499,8 @@ output them in files named @file{foo-001.jpeg}, @file{foo-002.jpeg},
etc. Images will be rescaled to fit the new WxH values. etc. Images will be rescaled to fit the new WxH values.
If you want to extract just a limited number of frames, you can use the If you want to extract just a limited number of frames, you can use the
above command in combination with the @code{-frames:v} or @code{-t} option, above command in combination with the -vframes or -t option, or in
or in combination with -ss to start extracting from a certain point in time. combination with -ss to start extracting from a certain point in time.
For creating a video from many images: For creating a video from many images:
@example @example
@@ -1769,7 +1584,7 @@ ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
@ifset config-not-all @ifset config-not-all
@url{ffmpeg-all.html,ffmpeg-all}, @url{ffmpeg-all.html,ffmpeg-all},
@end ifset @end ifset
@url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe}, @url{ffserver.html,ffserver},
@url{ffmpeg-utils.html,ffmpeg-utils}, @url{ffmpeg-utils.html,ffmpeg-utils},
@url{ffmpeg-scaler.html,ffmpeg-scaler}, @url{ffmpeg-scaler.html,ffmpeg-scaler},
@url{ffmpeg-resampler.html,ffmpeg-resampler}, @url{ffmpeg-resampler.html,ffmpeg-resampler},
@@ -1788,7 +1603,7 @@ ffmpeg(1),
@ifset config-not-all @ifset config-not-all
ffmpeg-all(1), ffmpeg-all(1),
@end ifset @end ifset
ffplay(1), ffprobe(1), ffplay(1), ffprobe(1), ffserver(1),
ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1), ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1), ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1) ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)

View File

@@ -12,7 +12,7 @@
@chapter Synopsis @chapter Synopsis
ffplay [@var{options}] [@file{input_url}] ffplay [@var{options}] [@file{input_file}]
@chapter Description @chapter Description
@c man begin DESCRIPTION @c man begin DESCRIPTION
@@ -62,12 +62,6 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1)
Seek by bytes. Seek by bytes.
@item -nodisp @item -nodisp
Disable graphical display. Disable graphical display.
@item -noborder
Borderless window.
@item -volume
Set the startup volume. 0 means silence, 100 means no volume reduction or
amplification. Negative values are treated as 0, values above 100 are treated
as 100.
@item -f @var{fmt} @item -f @var{fmt}
Force format. Force format.
@item -window_title @var{title} @item -window_title @var{title}
@@ -112,8 +106,8 @@ the input audio.
Use the option "-filters" to show all the available filters (including Use the option "-filters" to show all the available filters (including
sources and sinks). sources and sinks).
@item -i @var{input_url} @item -i @var{input_file}
Read @var{input_url}. Read @var{input_file}.
@end table @end table
@section Advanced options @section Advanced options
@@ -291,7 +285,7 @@ Toggle full screen.
@ifset config-not-all @ifset config-not-all
@url{ffplay-all.html,ffmpeg-all}, @url{ffplay-all.html,ffmpeg-all},
@end ifset @end ifset
@url{ffmpeg.html,ffmpeg}, @url{ffprobe.html,ffprobe}, @url{ffmpeg.html,ffmpeg}, @url{ffprobe.html,ffprobe}, @url{ffserver.html,ffserver},
@url{ffmpeg-utils.html,ffmpeg-utils}, @url{ffmpeg-utils.html,ffmpeg-utils},
@url{ffmpeg-scaler.html,ffmpeg-scaler}, @url{ffmpeg-scaler.html,ffmpeg-scaler},
@url{ffmpeg-resampler.html,ffmpeg-resampler}, @url{ffmpeg-resampler.html,ffmpeg-resampler},
@@ -310,7 +304,7 @@ ffplay(1),
@ifset config-not-all @ifset config-not-all
ffplay-all(1), ffplay-all(1),
@end ifset @end ifset
ffmpeg(1), ffprobe(1), ffmpeg(1), ffprobe(1), ffserver(1),
ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1), ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1), ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1) ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)

View File

@@ -12,7 +12,7 @@
@chapter Synopsis @chapter Synopsis
ffprobe [@var{options}] [@file{input_url}] ffprobe [@var{options}] [@file{input_file}]
@chapter Description @chapter Description
@c man begin DESCRIPTION @c man begin DESCRIPTION
@@ -24,8 +24,8 @@ For example it can be used to check the format of the container used
by a multimedia stream and the format and type of each media stream by a multimedia stream and the format and type of each media stream
contained in it. contained in it.
If a url is specified in input, ffprobe will try to open and If a filename is specified in input, ffprobe will try to open and
probe the url content. If the url cannot be opened or recognized as probe the file content. If the file cannot be opened or recognized as
a multimedia file, a positive exit code is returned. a multimedia file, a positive exit code is returned.
ffprobe may be employed both as a standalone application or in ffprobe may be employed both as a standalone application or in
@@ -208,13 +208,6 @@ multimedia stream.
The information for each single frame is printed within a dedicated The information for each single frame is printed within a dedicated
section with name "FRAME" or "SUBTITLE". section with name "FRAME" or "SUBTITLE".
@item -show_log @var{loglevel}
Show logging information from the decoder about each frame according to
the value set in @var{loglevel}, (see @code{-loglevel}). This option requires @code{-show_frames}.
The information for each log message is printed within a dedicated
section with name "LOG".
@item -show_streams @item -show_streams
Show information about each media stream contained in the input Show information about each media stream contained in the input
multimedia stream. multimedia stream.
@@ -252,7 +245,7 @@ continue reading from that.
Each interval is specified by two optional parts, separated by "%". Each interval is specified by two optional parts, separated by "%".
The first part specifies the interval start position. It is The first part specifies the interval start position. It is
interpreted as an absolute position, or as a relative offset from the interpreted as an abolute position, or as a relative offset from the
current position if it is preceded by the "+" character. If this first current position if it is preceded by the "+" character. If this first
part is not specified, no seeking will be performed when reading this part is not specified, no seeking will be performed when reading this
interval. interval.
@@ -339,8 +332,8 @@ with name "PIXEL_FORMAT".
Force bitexact output, useful to produce output which is not dependent Force bitexact output, useful to produce output which is not dependent
on the specific build. on the specific build.
@item -i @var{input_url} @item -i @var{input_file}
Read @var{input_url}. Read @var{input_file}.
@end table @end table
@c man end @c man end
@@ -471,7 +464,7 @@ Perform no escaping.
@end table @end table
@item print_section, p @item print_section, p
Print the section name at the beginning of each line if the value is Print the section name at the begin of each line if the value is
@code{1}, disable it with value set to @code{0}. Default value is @code{1}, disable it with value set to @code{0}. Default value is
@code{1}. @code{1}.
@@ -653,7 +646,7 @@ DV, GXF and AVI timecodes are available in format metadata
@ifset config-not-all @ifset config-not-all
@url{ffprobe-all.html,ffprobe-all}, @url{ffprobe-all.html,ffprobe-all},
@end ifset @end ifset
@url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffserver.html,ffserver},
@url{ffmpeg-utils.html,ffmpeg-utils}, @url{ffmpeg-utils.html,ffmpeg-utils},
@url{ffmpeg-scaler.html,ffmpeg-scaler}, @url{ffmpeg-scaler.html,ffmpeg-scaler},
@url{ffmpeg-resampler.html,ffmpeg-resampler}, @url{ffmpeg-resampler.html,ffmpeg-resampler},
@@ -672,7 +665,7 @@ ffprobe(1),
@ifset config-not-all @ifset config-not-all
ffprobe-all(1), ffprobe-all(1),
@end ifset @end ifset
ffmpeg(1), ffplay(1), ffmpeg(1), ffplay(1), ffserver(1),
ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1), ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1), ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1) ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)

View File

@@ -83,7 +83,6 @@
<xsd:complexType name="frameType"> <xsd:complexType name="frameType">
<xsd:sequence> <xsd:sequence>
<xsd:element name="tag" type="ffprobe:tagType" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="tag" type="ffprobe:tagType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="logs" type="ffprobe:logsType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="side_data_list" type="ffprobe:frameSideDataListType" minOccurs="0" maxOccurs="1" /> <xsd:element name="side_data_list" type="ffprobe:frameSideDataListType" minOccurs="0" maxOccurs="1" />
</xsd:sequence> </xsd:sequence>
@@ -120,25 +119,6 @@
<xsd:attribute name="interlaced_frame" type="xsd:int" /> <xsd:attribute name="interlaced_frame" type="xsd:int" />
<xsd:attribute name="top_field_first" type="xsd:int" /> <xsd:attribute name="top_field_first" type="xsd:int" />
<xsd:attribute name="repeat_pict" type="xsd:int" /> <xsd:attribute name="repeat_pict" type="xsd:int" />
<xsd:attribute name="color_range" type="xsd:string"/>
<xsd:attribute name="color_space" type="xsd:string"/>
<xsd:attribute name="color_primaries" type="xsd:string"/>
<xsd:attribute name="color_transfer" type="xsd:string"/>
<xsd:attribute name="chroma_location" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="logsType">
<xsd:sequence>
<xsd:element name="log" type="ffprobe:logType" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="logType">
<xsd:attribute name="context" type="xsd:string"/>
<xsd:attribute name="level" type="xsd:int" />
<xsd:attribute name="category" type="xsd:int" />
<xsd:attribute name="parent_context" type="xsd:string"/>
<xsd:attribute name="parent_category" type="xsd:int" />
<xsd:attribute name="message" type="xsd:string"/>
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="frameSideDataListType"> <xsd:complexType name="frameSideDataListType">
@@ -149,7 +129,6 @@
<xsd:complexType name="frameSideDataType"> <xsd:complexType name="frameSideDataType">
<xsd:attribute name="side_data_type" type="xsd:string"/> <xsd:attribute name="side_data_type" type="xsd:string"/>
<xsd:attribute name="side_data_size" type="xsd:int" /> <xsd:attribute name="side_data_size" type="xsd:int" />
<xsd:attribute name="timecode" type="xsd:string"/>
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="subtitleType"> <xsd:complexType name="subtitleType">
@@ -186,7 +165,6 @@
<xsd:attribute name="visual_impaired" type="xsd:int" use="required" /> <xsd:attribute name="visual_impaired" type="xsd:int" use="required" />
<xsd:attribute name="clean_effects" type="xsd:int" use="required" /> <xsd:attribute name="clean_effects" type="xsd:int" use="required" />
<xsd:attribute name="attached_pic" type="xsd:int" use="required" /> <xsd:attribute name="attached_pic" type="xsd:int" use="required" />
<xsd:attribute name="timed_thumbnails" type="xsd:int" use="required" />
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="streamType"> <xsd:complexType name="streamType">
@@ -222,7 +200,6 @@
<xsd:attribute name="color_transfer" type="xsd:string"/> <xsd:attribute name="color_transfer" type="xsd:string"/>
<xsd:attribute name="color_primaries" type="xsd:string"/> <xsd:attribute name="color_primaries" type="xsd:string"/>
<xsd:attribute name="chroma_location" type="xsd:string"/> <xsd:attribute name="chroma_location" type="xsd:string"/>
<xsd:attribute name="field_order" type="xsd:string"/>
<xsd:attribute name="timecode" type="xsd:string"/> <xsd:attribute name="timecode" type="xsd:string"/>
<xsd:attribute name="refs" type="xsd:int"/> <xsd:attribute name="refs" type="xsd:int"/>

372
doc/ffserver.conf Normal file
View File

@@ -0,0 +1,372 @@
# Port on which the server is listening. You must select a different
# port from your standard HTTP web server if it is running on the same
# computer.
HTTPPort 8090
# Address on which the server is bound. Only useful if you have
# several network interfaces.
HTTPBindAddress 0.0.0.0
# Number of simultaneous HTTP connections that can be handled. It has
# to be defined *before* the MaxClients parameter, since it defines the
# MaxClients maximum limit.
MaxHTTPConnections 2000
# Number of simultaneous requests that can be handled. Since FFServer
# is very fast, it is more likely that you will want to leave this high
# and use MaxBandwidth, below.
MaxClients 1000
# This the maximum amount of kbit/sec that you are prepared to
# consume when streaming to clients.
MaxBandwidth 1000
# Access log file (uses standard Apache log file format)
# '-' is the standard output.
CustomLog -
##################################################################
# Definition of the live feeds. Each live feed contains one video
# and/or audio sequence coming from an ffmpeg encoder or another
# ffserver. This sequence may be encoded simultaneously with several
# codecs at several resolutions.
<Feed feed1.ffm>
# You must use 'ffmpeg' to send a live feed to ffserver. In this
# example, you can type:
#
# ffmpeg http://localhost:8090/feed1.ffm
# ffserver can also do time shifting. It means that it can stream any
# previously recorded live stream. The request should contain:
# "http://xxxx?date=[YYYY-MM-DDT][[HH:]MM:]SS[.m...]".You must specify
# a path where the feed is stored on disk. You also specify the
# maximum size of the feed, where zero means unlimited. Default:
# File=/tmp/feed_name.ffm FileMaxSize=5M
File /tmp/feed1.ffm
FileMaxSize 200K
# You could specify
# ReadOnlyFile /saved/specialvideo.ffm
# This marks the file as readonly and it will not be deleted or updated.
# Specify launch in order to start ffmpeg automatically.
# First ffmpeg must be defined with an appropriate path if needed,
# after that options can follow, but avoid adding the http:// field
#Launch ffmpeg
# Only allow connections from localhost to the feed.
ACL allow 127.0.0.1
</Feed>
##################################################################
# Now you can define each stream which will be generated from the
# original audio and video stream. Each format has a filename (here
# 'test1.mpg'). FFServer will send this stream when answering a
# request containing this filename.
<Stream test1.mpg>
# coming from live feed 'feed1'
Feed feed1.ffm
# Format of the stream : you can choose among:
# mpeg : MPEG-1 multiplexed video and audio
# mpegvideo : only MPEG-1 video
# mp2 : MPEG-2 audio (use AudioCodec to select layer 2 and 3 codec)
# ogg : Ogg format (Vorbis audio codec)
# rm : RealNetworks-compatible stream. Multiplexed audio and video.
# ra : RealNetworks-compatible stream. Audio only.
# mpjpeg : Multipart JPEG (works with Netscape without any plugin)
# jpeg : Generate a single JPEG image.
# mjpeg : Generate a M-JPEG stream.
# asf : ASF compatible streaming (Windows Media Player format).
# swf : Macromedia Flash compatible stream
# avi : AVI format (MPEG-4 video, MPEG audio sound)
Format mpeg
# Bitrate for the audio stream. Codecs usually support only a few
# different bitrates.
AudioBitRate 32
# Number of audio channels: 1 = mono, 2 = stereo
AudioChannels 1
# Sampling frequency for audio. When using low bitrates, you should
# lower this frequency to 22050 or 11025. The supported frequencies
# depend on the selected audio codec.
AudioSampleRate 44100
# Bitrate for the video stream
VideoBitRate 64
# Ratecontrol buffer size
VideoBufferSize 40
# Number of frames per second
VideoFrameRate 3
# Size of the video frame: WxH (default: 160x128)
# The following abbreviations are defined: sqcif, qcif, cif, 4cif, qqvga,
# qvga, vga, svga, xga, uxga, qxga, sxga, qsxga, hsxga, wvga, wxga, wsxga,
# wuxga, woxga, wqsxga, wquxga, whsxga, whuxga, cga, ega, hd480, hd720,
# hd1080
VideoSize 160x128
# Transmit only intra frames (useful for low bitrates, but kills frame rate).
#VideoIntraOnly
# If non-intra only, an intra frame is transmitted every VideoGopSize
# frames. Video synchronization can only begin at an intra frame.
VideoGopSize 12
# More MPEG-4 parameters
# VideoHighQuality
# Video4MotionVector
# Choose your codecs:
#AudioCodec mp2
#VideoCodec mpeg1video
# Suppress audio
#NoAudio
# Suppress video
#NoVideo
#VideoQMin 3
#VideoQMax 31
# Set this to the number of seconds backwards in time to start. Note that
# most players will buffer 5-10 seconds of video, and also you need to allow
# for a keyframe to appear in the data stream.
#Preroll 15
# ACL:
# You can allow ranges of addresses (or single addresses)
#ACL ALLOW <first address> <last address>
# You can deny ranges of addresses (or single addresses)
#ACL DENY <first address> <last address>
# You can repeat the ACL allow/deny as often as you like. It is on a per
# stream basis. The first match defines the action. If there are no matches,
# then the default is the inverse of the last ACL statement.
#
# Thus 'ACL allow localhost' only allows access from localhost.
# 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
# allow everybody else.
</Stream>
##################################################################
# Example streams
# Multipart JPEG
#<Stream test.mjpg>
#Feed feed1.ffm
#Format mpjpeg
#VideoFrameRate 2
#VideoIntraOnly
#NoAudio
#Strict -1
#</Stream>
# Single JPEG
#<Stream test.jpg>
#Feed feed1.ffm
#Format jpeg
#VideoFrameRate 2
#VideoIntraOnly
##VideoSize 352x240
#NoAudio
#Strict -1
#</Stream>
# Flash
#<Stream test.swf>
#Feed feed1.ffm
#Format swf
#VideoFrameRate 2
#VideoIntraOnly
#NoAudio
#</Stream>
# ASF compatible
<Stream test.asf>
Feed feed1.ffm
Format asf
VideoFrameRate 15
VideoSize 352x240
VideoBitRate 256
VideoBufferSize 40
VideoGopSize 30
AudioBitRate 64
StartSendOnKey
</Stream>
# MP3 audio
#<Stream test.mp3>
#Feed feed1.ffm
#Format mp2
#AudioCodec mp3
#AudioBitRate 64
#AudioChannels 1
#AudioSampleRate 44100
#NoVideo
#</Stream>
# Ogg Vorbis audio
#<Stream test.ogg>
#Feed feed1.ffm
#Metadata title "Stream title"
#AudioBitRate 64
#AudioChannels 2
#AudioSampleRate 44100
#NoVideo
#</Stream>
# Real with audio only at 32 kbits
#<Stream test.ra>
#Feed feed1.ffm
#Format rm
#AudioBitRate 32
#NoVideo
#NoAudio
#</Stream>
# Real with audio and video at 64 kbits
#<Stream test.rm>
#Feed feed1.ffm
#Format rm
#AudioBitRate 32
#VideoBitRate 128
#VideoFrameRate 25
#VideoGopSize 25
#NoAudio
#</Stream>
##################################################################
# A stream coming from a file: you only need to set the input
# filename and optionally a new format. Supported conversions:
# AVI -> ASF
#<Stream file.rm>
#File "/usr/local/httpd/htdocs/tlive.rm"
#NoAudio
#</Stream>
#<Stream file.asf>
#File "/usr/local/httpd/htdocs/test.asf"
#NoAudio
#Metadata author "Me"
#Metadata copyright "Super MegaCorp"
#Metadata title "Test stream from disk"
#Metadata comment "Test comment"
#</Stream>
##################################################################
# RTSP examples
#
# You can access this stream with the RTSP URL:
# rtsp://localhost:5454/test1-rtsp.mpg
#
# A non-standard RTSP redirector is also created. Its URL is:
# http://localhost:8090/test1-rtsp.rtsp
#<Stream test1-rtsp.mpg>
#Format rtp
#File "/usr/local/httpd/htdocs/test1.mpg"
#</Stream>
# Transcode an incoming live feed to another live feed,
# using libx264 and video presets
#<Stream live.h264>
#Format rtp
#Feed feed1.ffm
#VideoCodec libx264
#VideoFrameRate 24
#VideoBitRate 100
#VideoSize 480x272
#AVPresetVideo default
#AVPresetVideo baseline
#AVOptionVideo flags +global_header
#
#AudioCodec libfaac
#AudioBitRate 32
#AudioChannels 2
#AudioSampleRate 22050
#AVOptionAudio flags +global_header
#</Stream>
##################################################################
# SDP/multicast examples
#
# If you want to send your stream in multicast, you must set the
# multicast address with MulticastAddress. The port and the TTL can
# also be set.
#
# An SDP file is automatically generated by ffserver by adding the
# 'sdp' extension to the stream name (here
# http://localhost:8090/test1-sdp.sdp). You should usually give this
# file to your player to play the stream.
#
# The 'NoLoop' option can be used to avoid looping when the stream is
# terminated.
#<Stream test1-sdp.mpg>
#Format rtp
#File "/usr/local/httpd/htdocs/test1.mpg"
#MulticastAddress 224.124.0.1
#MulticastPort 5000
#MulticastTTL 16
#NoLoop
#</Stream>
##################################################################
# Special streams
# Server status
<Stream stat.html>
Format status
# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
#FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico
</Stream>
# Redirect index.html to the appropriate site
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>

923
doc/ffserver.texi Normal file
View File

@@ -0,0 +1,923 @@
\input texinfo @c -*- texinfo -*-
@documentencoding UTF-8
@settitle ffserver Documentation
@titlepage
@center @titlefont{ffserver Documentation}
@end titlepage
@top
@contents
@chapter Synopsis
ffserver [@var{options}]
@chapter Description
@c man begin DESCRIPTION
@command{ffserver} is a streaming server for both audio and video.
It supports several live feeds, streaming from files and time shifting
on live feeds. You can seek to positions in the past on each live
feed, provided you specify a big enough feed storage.
@command{ffserver} is configured through a configuration file, which
is read at startup. If not explicitly specified, it will read from
@file{/etc/ffserver.conf}.
@command{ffserver} receives prerecorded files or FFM streams from some
@command{ffmpeg} instance as input, then streams them over
RTP/RTSP/HTTP.
An @command{ffserver} instance will listen on some port as specified
in the configuration file. You can launch one or more instances of
@command{ffmpeg} and send one or more FFM streams to the port where
ffserver is expecting to receive them. Alternately, you can make
@command{ffserver} launch such @command{ffmpeg} instances at startup.
Input streams are called feeds, and each one is specified by a
@code{<Feed>} section in the configuration file.
For each feed you can have different output streams in various
formats, each one specified by a @code{<Stream>} section in the
configuration file.
@chapter Detailed description
@command{ffserver} works by forwarding streams encoded by
@command{ffmpeg}, or pre-recorded streams which are read from disk.
Precisely, @command{ffserver} acts as an HTTP server, accepting POST
requests from @command{ffmpeg} to acquire the stream to publish, and
serving RTSP clients or HTTP clients GET requests with the stream
media content.
A feed is an @ref{FFM} stream created by @command{ffmpeg}, and sent to
a port where @command{ffserver} is listening.
Each feed is identified by a unique name, corresponding to the name
of the resource published on @command{ffserver}, and is configured by
a dedicated @code{Feed} section in the configuration file.
The feed publish URL is given by:
@example
http://@var{ffserver_ip_address}:@var{http_port}/@var{feed_name}
@end example
where @var{ffserver_ip_address} is the IP address of the machine where
@command{ffserver} is installed, @var{http_port} is the port number of
the HTTP server (configured through the @option{HTTPPort} option), and
@var{feed_name} is the name of the corresponding feed defined in the
configuration file.
Each feed is associated to a file which is stored on disk. This stored
file is used to send pre-recorded data to a player as fast as
possible when new content is added in real-time to the stream.
A "live-stream" or "stream" is a resource published by
@command{ffserver}, and made accessible through the HTTP protocol to
clients.
A stream can be connected to a feed, or to a file. In the first case,
the published stream is forwarded from the corresponding feed
generated by a running instance of @command{ffmpeg}, in the second
case the stream is read from a pre-recorded file.
Each stream is identified by a unique name, corresponding to the name
of the resource served by @command{ffserver}, and is configured by
a dedicated @code{Stream} section in the configuration file.
The stream access HTTP URL is given by:
@example
http://@var{ffserver_ip_address}:@var{http_port}/@var{stream_name}[@var{options}]
@end example
The stream access RTSP URL is given by:
@example
http://@var{ffserver_ip_address}:@var{rtsp_port}/@var{stream_name}[@var{options}]
@end example
@var{stream_name} is the name of the corresponding stream defined in
the configuration file. @var{options} is a list of options specified
after the URL which affects how the stream is served by
@command{ffserver}. @var{http_port} and @var{rtsp_port} are the HTTP
and RTSP ports configured with the options @var{HTTPPort} and
@var{RTSPPort} respectively.
In case the stream is associated to a feed, the encoding parameters
must be configured in the stream configuration. They are sent to
@command{ffmpeg} when setting up the encoding. This allows
@command{ffserver} to define the encoding parameters used by
the @command{ffmpeg} encoders.
The @command{ffmpeg} @option{override_ffserver} commandline option
allows one to override the encoding parameters set by the server.
Multiple streams can be connected to the same feed.
For example, you can have a situation described by the following
graph:
@verbatim
_________ __________
| | | |
ffmpeg 1 -----| feed 1 |-----| stream 1 |
\ |_________|\ |__________|
\ \
\ \ __________
\ \ | |
\ \| stream 2 |
\ |__________|
\
\ _________ __________
\ | | | |
\| feed 2 |-----| stream 3 |
|_________| |__________|
_________ __________
| | | |
ffmpeg 2 -----| feed 3 |-----| stream 4 |
|_________| |__________|
_________ __________
| | | |
| file 1 |-----| stream 5 |
|_________| |__________|
@end verbatim
@anchor{FFM}
@section FFM, FFM2 formats
FFM and FFM2 are formats used by ffserver. They allow storing a wide variety of
video and audio streams and encoding options, and can store a moving time segment
of an infinite movie or a whole movie.
FFM is version specific, and there is limited compatibility of FFM files
generated by one version of ffmpeg/ffserver and another version of
ffmpeg/ffserver. It may work but it is not guaranteed to work.
FFM2 is extensible while maintaining compatibility and should work between
differing versions of tools. FFM2 is the default.
@section Status stream
@command{ffserver} supports an HTTP interface which exposes the
current status of the server.
Simply point your browser to the address of the special status stream
specified in the configuration file.
For example if you have:
@example
<Stream status.html>
Format status
# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>
@end example
then the server will post a page with the status information when
the special stream @file{status.html} is requested.
@section How do I make it work?
As a simple test, just run the following two command lines where INPUTFILE
is some file which you can decode with ffmpeg:
@example
ffserver -f doc/ffserver.conf &
ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
@end example
At this point you should be able to go to your Windows machine and fire up
Windows Media Player (WMP). Go to Open URL and enter
@example
http://<linuxbox>:8090/test.asf
@end example
You should (after a short delay) see video and hear audio.
WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to
transfer the entire file before starting to play.
The same is true of AVI files.
You should edit the @file{ffserver.conf} file to suit your needs (in
terms of frame rates etc). Then install @command{ffserver} and
@command{ffmpeg}, write a script to start them up, and off you go.
@section What else can it do?
You can replay video from .ffm files that was recorded earlier.
However, there are a number of caveats, including the fact that the
ffserver parameters must match the original parameters used to record the
file. If they do not, then ffserver deletes the file before recording into it.
(Now that I write this, it seems broken).
You can fiddle with many of the codec choices and encoding parameters, and
there are a bunch more parameters that you cannot control. Post a message
to the mailing list if there are some 'must have' parameters. Look in
ffserver.conf for a list of the currently available controls.
It will automatically generate the ASX or RAM files that are often used
in browsers. These files are actually redirections to the underlying ASF
or RM file. The reason for this is that the browser often fetches the
entire file before starting up the external viewer. The redirection files
are very small and can be transferred quickly. [The stream itself is
often 'infinite' and thus the browser tries to download it and never
finishes.]
@section Tips
* When you connect to a live stream, most players (WMP, RA, etc) want to
buffer a certain number of seconds of material so that they can display the
signal continuously. However, ffserver (by default) starts sending data
in realtime. This means that there is a pause of a few seconds while the
buffering is being done by the player. The good news is that this can be
cured by adding a '?buffer=5' to the end of the URL. This means that the
stream should start 5 seconds in the past -- and so the first 5 seconds
of the stream are sent as fast as the network will allow. It will then
slow down to real time. This noticeably improves the startup experience.
You can also add a 'Preroll 15' statement into the ffserver.conf that will
add the 15 second prebuffering on all requests that do not otherwise
specify a time. In addition, ffserver will skip frames until a key_frame
is found. This further reduces the startup delay by not transferring data
that will be discarded.
@section Why does the ?buffer / Preroll stop working after a time?
It turns out that (on my machine at least) the number of frames successfully
grabbed is marginally less than the number that ought to be grabbed. This
means that the timestamp in the encoded data stream gets behind realtime.
This means that if you say 'Preroll 10', then when the stream gets 10
or more seconds behind, there is no Preroll left.
Fixing this requires a change in the internals of how timestamps are
handled.
@section Does the @code{?date=} stuff work.
Yes (subject to the limitation outlined above). Also note that whenever you
start ffserver, it deletes the ffm file (if any parameters have changed),
thus wiping out what you had recorded before.
The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
of the following formats (the 'T' is literal):
@example
* YYYY-MM-DDTHH:MM:SS (localtime)
* YYYY-MM-DDTHH:MM:SSZ (UTC)
@end example
You can omit the YYYY-MM-DD, and then it refers to the current day. However
note that @samp{?date=16:00:00} refers to 16:00 on the current day -- this
may be in the future and so is unlikely to be useful.
You use this by adding the ?date= to the end of the URL for the stream.
For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}.
@c man end
@chapter Options
@c man begin OPTIONS
@include fftools-common-opts.texi
@section Main options
@table @option
@item -f @var{configfile}
Read configuration file @file{configfile}. If not specified it will
read by default from @file{/etc/ffserver.conf}.
@item -n
Enable no-launch mode. This option disables all the @code{Launch}
directives within the various @code{<Feed>} sections. Since
@command{ffserver} will not launch any @command{ffmpeg} instances, you
will have to launch them manually.
@item -d
Enable debug mode. This option increases log verbosity, and directs
log messages to stdout. When specified, the @option{CustomLog} option
is ignored.
@end table
@chapter Configuration file syntax
@command{ffserver} reads a configuration file containing global
options and settings for each stream and feed.
The configuration file consists of global options and dedicated
sections, which must be introduced by "<@var{SECTION_NAME}
@var{ARGS}>" on a separate line and must be terminated by a line in
the form "</@var{SECTION_NAME}>". @var{ARGS} is optional.
Currently the following sections are recognized: @samp{Feed},
@samp{Stream}, @samp{Redirect}.
A line starting with @code{#} is ignored and treated as a comment.
Name of options and sections are case-insensitive.
@section ACL syntax
An ACL (Access Control List) specifies the address which are allowed
to access a given stream, or to write a given feed.
It accepts the folling forms
@itemize
@item
Allow/deny access to @var{address}.
@example
ACL ALLOW <address>
ACL DENY <address>
@end example
@item
Allow/deny access to ranges of addresses from @var{first_address} to
@var{last_address}.
@example
ACL ALLOW <first_address> <last_address>
ACL DENY <first_address> <last_address>
@end example
@end itemize
You can repeat the ACL allow/deny as often as you like. It is on a per
stream basis. The first match defines the action. If there are no matches,
then the default is the inverse of the last ACL statement.
Thus 'ACL allow localhost' only allows access from localhost.
'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
allow everybody else.
@section Global options
@table @option
@item HTTPPort @var{port_number}
@item Port @var{port_number}
@item RTSPPort @var{port_number}
@var{HTTPPort} sets the HTTP server listening TCP port number,
@var{RTSPPort} sets the RTSP server listening TCP port number.
@var{Port} is the equivalent of @var{HTTPPort} and is deprecated.
You must select a different port from your standard HTTP web server if
it is running on the same computer.
If not specified, no corresponding server will be created.
@item HTTPBindAddress @var{ip_address}
@item BindAddress @var{ip_address}
@item RTSPBindAddress @var{ip_address}
Set address on which the HTTP/RTSP server is bound. Only useful if you
have several network interfaces.
@var{BindAddress} is the equivalent of @var{HTTPBindAddress} and is
deprecated.
@item MaxHTTPConnections @var{n}
Set number of simultaneous HTTP connections that can be handled. It
has to be defined @emph{before} the @option{MaxClients} parameter,
since it defines the @option{MaxClients} maximum limit.
Default value is 2000.
@item MaxClients @var{n}
Set number of simultaneous requests that can be handled. Since
@command{ffserver} is very fast, it is more likely that you will want
to leave this high and use @option{MaxBandwidth}.
Default value is 5.
@item MaxBandwidth @var{kbps}
Set the maximum amount of kbit/sec that you are prepared to consume
when streaming to clients.
Default value is 1000.
@item CustomLog @var{filename}
Set access log file (uses standard Apache log file format). '-' is the
standard output.
If not specified @command{ffserver} will produce no log.
In case the commandline option @option{-d} is specified this option is
ignored, and the log is written to standard output.
@item NoDaemon
Set no-daemon mode. This option is currently ignored since now
@command{ffserver} will always work in no-daemon mode, and is
deprecated.
@item UseDefaults
@item NoDefaults
Control whether default codec options are used for the all streams or not.
Each stream may overwrite this setting for its own. Default is @var{UseDefaults}.
The lastest occurrence overrides previous if multiple definitions.
@end table
@section Feed section
A Feed section defines a feed provided to @command{ffserver}.
Each live feed contains one video and/or audio sequence coming from an
@command{ffmpeg} encoder or another @command{ffserver}. This sequence
may be encoded simultaneously with several codecs at several
resolutions.
A feed instance specification is introduced by a line in the form:
@example
<Feed FEED_FILENAME>
@end example
where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
The following options are recognized within a Feed section.
@table @option
@item File @var{filename}
@item ReadOnlyFile @var{filename}
Set the path where the feed file is stored on disk.
If not specified, the @file{/tmp/FEED.ffm} is assumed, where
@var{FEED} is the feed name.
If @option{ReadOnlyFile} is used the file is marked as read-only and
it will not be deleted or updated.
@item Truncate
Truncate the feed file, rather than appending to it. By default
@command{ffserver} will append data to the file, until the maximum
file size value is reached (see @option{FileMaxSize} option).
@item FileMaxSize @var{size}
Set maximum size of the feed file in bytes. 0 means unlimited. The
postfixes @code{K} (2^10), @code{M} (2^20), and @code{G} (2^30) are
recognized.
Default value is 5M.
@item Launch @var{args}
Launch an @command{ffmpeg} command when creating @command{ffserver}.
@var{args} must be a sequence of arguments to be provided to an
@command{ffmpeg} instance. The first provided argument is ignored, and
it is replaced by a path with the same dirname of the @command{ffserver}
instance, followed by the remaining argument and terminated with a
path corresponding to the feed.
When the launched process exits, @command{ffserver} will launch
another program instance.
In case you need a more complex @command{ffmpeg} configuration,
e.g. if you need to generate multiple FFM feeds with a single
@command{ffmpeg} instance, you should launch @command{ffmpeg} by hand.
This option is ignored in case the commandline option @option{-n} is
specified.
@item ACL @var{spec}
Specify the list of IP address which are allowed or denied to write
the feed. Multiple ACL options can be specified.
@end table
@section Stream section
A Stream section defines a stream provided by @command{ffserver}, and
identified by a single name.
The stream is sent when answering a request containing the stream
name.
A stream section must be introduced by the line:
@example
<Stream STREAM_NAME>
@end example
where @var{STREAM_NAME} specifies the unique name of the stream.
The following options are recognized within a Stream section.
Encoding options are marked with the @emph{encoding} tag, and they are
used to set the encoding parameters, and are mapped to libavcodec
encoding options. Not all encoding options are supported, in
particular it is not possible to set encoder private options. In order
to override the encoding options specified by @command{ffserver}, you
can use the @command{ffmpeg} @option{override_ffserver} commandline
option.
Only one of the @option{Feed} and @option{File} options should be set.
@table @option
@item Feed @var{feed_name}
Set the input feed. @var{feed_name} must correspond to an existing
feed defined in a @code{Feed} section.
When this option is set, encoding options are used to setup the
encoding operated by the remote @command{ffmpeg} process.
@item File @var{filename}
Set the filename of the pre-recorded input file to stream.
When this option is set, encoding options are ignored and the input
file content is re-streamed as is.
@item Format @var{format_name}
Set the format of the output stream.
Must be the name of a format recognized by FFmpeg. If set to
@samp{status}, it is treated as a status stream.
@item InputFormat @var{format_name}
Set input format. If not specified, it is automatically guessed.
@item Preroll @var{n}
Set this to the number of seconds backwards in time to start. Note that
most players will buffer 5-10 seconds of video, and also you need to allow
for a keyframe to appear in the data stream.
Default value is 0.
@item StartSendOnKey
Do not send stream until it gets the first key frame. By default
@command{ffserver} will send data immediately.
@item MaxTime @var{n}
Set the number of seconds to run. This value set the maximum duration
of the stream a client will be able to receive.
A value of 0 means that no limit is set on the stream duration.
@item ACL @var{spec}
Set ACL for the stream.
@item DynamicACL @var{spec}
@item RTSPOption @var{option}
@item MulticastAddress @var{address}
@item MulticastPort @var{port}
@item MulticastTTL @var{integer}
@item NoLoop
@item FaviconURL @var{url}
Set favicon (favourite icon) for the server status page. It is ignored
for regular streams.
@item Author @var{value}
@item Comment @var{value}
@item Copyright @var{value}
@item Title @var{value}
Set metadata corresponding to the option. All these options are
deprecated in favor of @option{Metadata}.
@item Metadata @var{key} @var{value}
Set metadata value on the output stream.
@item UseDefaults
@item NoDefaults
Control whether default codec options are used for the stream or not.
Default is @var{UseDefaults} unless disabled globally.
@item NoAudio
@item NoVideo
Suppress audio/video.
@item AudioCodec @var{codec_name} (@emph{encoding,audio})
Set audio codec.
@item AudioBitRate @var{rate} (@emph{encoding,audio})
Set bitrate for the audio stream in kbits per second.
@item AudioChannels @var{n} (@emph{encoding,audio})
Set number of audio channels.
@item AudioSampleRate @var{n} (@emph{encoding,audio})
Set sampling frequency for audio. When using low bitrates, you should
lower this frequency to 22050 or 11025. The supported frequencies
depend on the selected audio codec.
@item AVOptionAudio [@var{codec}:]@var{option} @var{value} (@emph{encoding,audio})
Set generic or private option for audio stream.
Private option must be prefixed with codec name or codec must be defined before.
@item AVPresetAudio @var{preset} (@emph{encoding,audio})
Set preset for audio stream.
@item VideoCodec @var{codec_name} (@emph{encoding,video})
Set video codec.
@item VideoBitRate @var{n} (@emph{encoding,video})
Set bitrate for the video stream in kbits per second.
@item VideoBitRateRange @var{range} (@emph{encoding,video})
Set video bitrate range.
A range must be specified in the form @var{minrate}-@var{maxrate}, and
specifies the @option{minrate} and @option{maxrate} encoding options
expressed in kbits per second.
@item VideoBitRateRangeTolerance @var{n} (@emph{encoding,video})
Set video bitrate tolerance in kbits per second.
@item PixelFormat @var{pixel_format} (@emph{encoding,video})
Set video pixel format.
@item Debug @var{integer} (@emph{encoding,video})
Set video @option{debug} encoding option.
@item Strict @var{integer} (@emph{encoding,video})
Set video @option{strict} encoding option.
@item VideoBufferSize @var{n} (@emph{encoding,video})
Set ratecontrol buffer size, expressed in KB.
@item VideoFrameRate @var{n} (@emph{encoding,video})
Set number of video frames per second.
@item VideoSize (@emph{encoding,video})
Set size of the video frame, must be an abbreviation or in the form
@var{W}x@var{H}. See @ref{video size syntax,,the Video size section
in the ffmpeg-utils(1) manual,ffmpeg-utils}.
Default value is @code{160x128}.
@item VideoIntraOnly (@emph{encoding,video})
Transmit only intra frames (useful for low bitrates, but kills frame rate).
@item VideoGopSize @var{n} (@emph{encoding,video})
If non-intra only, an intra frame is transmitted every VideoGopSize
frames. Video synchronization can only begin at an intra frame.
@item VideoTag @var{tag} (@emph{encoding,video})
Set video tag.
@item VideoHighQuality (@emph{encoding,video})
@item Video4MotionVector (@emph{encoding,video})
@item BitExact (@emph{encoding,video})
Set bitexact encoding flag.
@item IdctSimple (@emph{encoding,video})
Set simple IDCT algorithm.
@item Qscale @var{n} (@emph{encoding,video})
Enable constant quality encoding, and set video qscale (quantization
scale) value, expressed in @var{n} QP units.
@item VideoQMin @var{n} (@emph{encoding,video})
@item VideoQMax @var{n} (@emph{encoding,video})
Set video qmin/qmax.
@item VideoQDiff @var{integer} (@emph{encoding,video})
Set video @option{qdiff} encoding option.
@item LumiMask @var{float} (@emph{encoding,video})
@item DarkMask @var{float} (@emph{encoding,video})
Set @option{lumi_mask}/@option{dark_mask} encoding options.
@item AVOptionVideo [@var{codec}:]@var{option} @var{value} (@emph{encoding,video})
Set generic or private option for video stream.
Private option must be prefixed with codec name or codec must be defined before.
@item AVPresetVideo @var{preset} (@emph{encoding,video})
Set preset for video stream.
@var{preset} must be the path of a preset file.
@end table
@subsection Server status stream
A server status stream is a special stream which is used to show
statistics about the @command{ffserver} operations.
It must be specified setting the option @option{Format} to
@samp{status}.
@section Redirect section
A redirect section specifies where to redirect the requested URL to
another page.
A redirect section must be introduced by the line:
@example
<Redirect NAME>
@end example
where @var{NAME} is the name of the page which should be redirected.
It only accepts the option @option{URL}, which specify the redirection
URL.
@chapter Stream examples
@itemize
@item
Multipart JPEG
@example
<Stream test.mjpg>
Feed feed1.ffm
Format mpjpeg
VideoFrameRate 2
VideoIntraOnly
NoAudio
Strict -1
</Stream>
@end example
@item
Single JPEG
@example
<Stream test.jpg>
Feed feed1.ffm
Format jpeg
VideoFrameRate 2
VideoIntraOnly
VideoSize 352x240
NoAudio
Strict -1
</Stream>
@end example
@item
Flash
@example
<Stream test.swf>
Feed feed1.ffm
Format swf
VideoFrameRate 2
VideoIntraOnly
NoAudio
</Stream>
@end example
@item
ASF compatible
@example
<Stream test.asf>
Feed feed1.ffm
Format asf
VideoFrameRate 15
VideoSize 352x240
VideoBitRate 256
VideoBufferSize 40
VideoGopSize 30
AudioBitRate 64
StartSendOnKey
</Stream>
@end example
@item
MP3 audio
@example
<Stream test.mp3>
Feed feed1.ffm
Format mp2
AudioCodec mp3
AudioBitRate 64
AudioChannels 1
AudioSampleRate 44100
NoVideo
</Stream>
@end example
@item
Ogg Vorbis audio
@example
<Stream test.ogg>
Feed feed1.ffm
Metadata title "Stream title"
AudioBitRate 64
AudioChannels 2
AudioSampleRate 44100
NoVideo
</Stream>
@end example
@item
Real with audio only at 32 kbits
@example
<Stream test.ra>
Feed feed1.ffm
Format rm
AudioBitRate 32
NoVideo
</Stream>
@end example
@item
Real with audio and video at 64 kbits
@example
<Stream test.rm>
Feed feed1.ffm
Format rm
AudioBitRate 32
VideoBitRate 128
VideoFrameRate 25
VideoGopSize 25
</Stream>
@end example
@item
For stream coming from a file: you only need to set the input filename
and optionally a new format.
@example
<Stream file.rm>
File "/usr/local/httpd/htdocs/tlive.rm"
NoAudio
</Stream>
@end example
@example
<Stream file.asf>
File "/usr/local/httpd/htdocs/test.asf"
NoAudio
Metadata author "Me"
Metadata copyright "Super MegaCorp"
Metadata title "Test stream from disk"
Metadata comment "Test comment"
</Stream>
@end example
@end itemize
@c man end
@include config.texi
@ifset config-all
@ifset config-avutil
@include utils.texi
@end ifset
@ifset config-avcodec
@include codecs.texi
@include bitstream_filters.texi
@end ifset
@ifset config-avformat
@include formats.texi
@include protocols.texi
@end ifset
@ifset config-avdevice
@include devices.texi
@end ifset
@ifset config-swresample
@include resampler.texi
@end ifset
@ifset config-swscale
@include scaler.texi
@end ifset
@ifset config-avfilter
@include filters.texi
@end ifset
@end ifset
@chapter See Also
@ifhtml
@ifset config-all
@url{ffserver.html,ffserver},
@end ifset
@ifset config-not-all
@url{ffserver-all.html,ffserver-all},
@end ifset
the @file{doc/ffserver.conf} example,
@url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
@url{ffmpeg-utils.html,ffmpeg-utils},
@url{ffmpeg-scaler.html,ffmpeg-scaler},
@url{ffmpeg-resampler.html,ffmpeg-resampler},
@url{ffmpeg-codecs.html,ffmpeg-codecs},
@url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
@url{ffmpeg-formats.html,ffmpeg-formats},
@url{ffmpeg-devices.html,ffmpeg-devices},
@url{ffmpeg-protocols.html,ffmpeg-protocols},
@url{ffmpeg-filters.html,ffmpeg-filters}
@end ifhtml
@ifnothtml
@ifset config-all
ffserver(1),
@end ifset
@ifset config-not-all
ffserver-all(1),
@end ifset
the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
@end ifnothtml
@include authors.texi
@ignore
@setfilename ffserver
@settitle ffserver video server
@end ignore
@bye

View File

@@ -42,20 +42,10 @@ streams, 'V' only matches video streams which are not attached pictures, video
thumbnails or cover arts. If @var{stream_index} is given, then it matches thumbnails or cover arts. If @var{stream_index} is given, then it matches
stream number @var{stream_index} of this type. Otherwise, it matches all stream number @var{stream_index} of this type. Otherwise, it matches all
streams of this type. streams of this type.
@item p:@var{program_id}[:@var{stream_index}] or p:@var{program_id}[:@var{stream_type}[:@var{stream_index}]] or @item p:@var{program_id}[:@var{stream_index}]
p:@var{program_id}:m:@var{key}[:@var{value}] If @var{stream_index} is given, then it matches the stream with number @var{stream_index}
In first version, if @var{stream_index} is given, then it matches the stream with number @var{stream_index}
in the program with the id @var{program_id}. Otherwise, it matches all streams in the in the program with the id @var{program_id}. Otherwise, it matches all streams in the
program. In the second version, @var{stream_type} is one of following: 'v' for video, 'a' for audio, 's' program.
for subtitle, 'd' for data. If @var{stream_index} is also given, then it matches
stream number @var{stream_index} of this type in the program with the id @var{program_id}.
Otherwise, if only @var{stream_type} is given, it matches all
streams of this type in the program with the id @var{program_id}.
In the third version matches streams in the program with the id @var{program_id} with the metadata
tag @var{key} having the specified value. If
@var{value} is not given, matches streams that contain the given tag with any
value.
@item #@var{stream_id} or i:@var{stream_id} @item #@var{stream_id} or i:@var{stream_id}
Match the stream by stream id (e.g. PID in MPEG-TS container). Match the stream by stream id (e.g. PID in MPEG-TS container).
@item m:@var{key}[:@var{value}] @item m:@var{key}[:@var{value}]
@@ -120,12 +110,6 @@ Show version.
@item -formats @item -formats
Show available formats (including devices). Show available formats (including devices).
@item -demuxers
Show available demuxers.
@item -muxers
Show available muxers.
@item -devices @item -devices
Show available devices. Show available devices.
@@ -163,7 +147,7 @@ Show channel names and standard channel layouts.
Show recognized color names. Show recognized color names.
@item -sources @var{device}[,@var{opt1}=@var{val1}[,@var{opt2}=@var{val2}]...] @item -sources @var{device}[,@var{opt1}=@var{val1}[,@var{opt2}=@var{val2}]...]
Show autodetected sources of the input device. Show autodetected sources of the intput device.
Some devices may provide system-dependent source names that cannot be autodetected. Some devices may provide system-dependent source names that cannot be autodetected.
The returned list cannot be assumed to be always complete. The returned list cannot be assumed to be always complete.
@example @example
@@ -178,34 +162,24 @@ The returned list cannot be assumed to be always complete.
ffmpeg -sinks pulse,server=192.168.0.4 ffmpeg -sinks pulse,server=192.168.0.4
@end example @end example
@item -loglevel [@var{flags}+]@var{loglevel} | -v [@var{flags}+]@var{loglevel} @item -loglevel [repeat+]@var{loglevel} | -v [repeat+]@var{loglevel}
Set logging level and flags used by the library. Set the logging level used by the library.
Adding "repeat+" indicates that repeated log output should not be compressed
The optional @var{flags} prefix can consist of the following values: to the first line and the "Last message repeated n times" line will be
@table @samp omitted. "repeat" can also be used alone.
@item repeat If "repeat" is used alone, and with no prior loglevel set, the default
Indicates that repeated log output should not be compressed to the first line loglevel will be used. If multiple loglevel parameters are given, using
and the "Last message repeated n times" line will be omitted. 'repeat' will not change the loglevel.
@item level
Indicates that log output should add a @code{[level]} prefix to each message
line. This can be used as an alternative to log coloring, e.g. when dumping the
log to file.
@end table
Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
flag without affecting other @var{flags} or changing @var{loglevel}. When
setting both @var{flags} and @var{loglevel}, a '+' separator is expected
between the last @var{flags} value and before @var{loglevel}.
@var{loglevel} is a string or a number containing one of the following values: @var{loglevel} is a string or a number containing one of the following values:
@table @samp @table @samp
@item quiet, -8 @item quiet, -8
Show nothing at all; be silent. Show nothing at all; be silent.
@item panic, 0 @item panic, 0
Only show fatal errors which could lead the process to crash, such as Only show fatal errors which could lead the process to crash, such as
an assertion failure. This is not currently used for anything. and assert failure. This is not currently used for anything.
@item fatal, 8 @item fatal, 8
Only show fatal errors. These are errors after which the process absolutely Only show fatal errors. These are errors after which the process absolutely
cannot continue. cannot continue after.
@item error, 16 @item error, 16
Show all errors, including ones which can be recovered from. Show all errors, including ones which can be recovered from.
@item warning, 24 @item warning, 24
@@ -221,24 +195,13 @@ Show everything, including debugging information.
@item trace, 56 @item trace, 56
@end table @end table
For example to enable repeated log output, add the @code{level} prefix, and set By default the program logs to stderr, if coloring is supported by the
@var{loglevel} to @code{verbose}:
@example
ffmpeg -loglevel repeat+level+verbose -i input output
@end example
Another example that enables repeated log output without affecting current
state of @code{level} prefix flag or @var{loglevel}:
@example
ffmpeg [...] -loglevel +repeat
@end example
By default the program logs to stderr. If coloring is supported by the
terminal, colors are used to mark errors and warnings. Log coloring terminal, colors are used to mark errors and warnings. Log coloring
can be disabled setting the environment variable can be disabled setting the environment variable
@env{AV_LOG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting @env{AV_LOG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting
the environment variable @env{AV_LOG_FORCE_COLOR}. the environment variable @env{AV_LOG_FORCE_COLOR}.
The use of the environment variable @env{NO_COLOR} is deprecated and The use of the environment variable @env{NO_COLOR} is deprecated and
will be dropped in a future FFmpeg version. will be dropped in a following FFmpeg version.
@item -report @item -report
Dump full command line and console output to a file named Dump full command line and console output to a file named
@@ -346,6 +309,51 @@ Possible flags for this option are:
@item k8 @item k8
@end table @end table
@end table @end table
@item -opencl_bench
This option is used to benchmark all available OpenCL devices and print the
results. This option is only available when FFmpeg has been compiled with
@code{--enable-opencl}.
When FFmpeg is configured with @code{--enable-opencl}, the options for the
global OpenCL context are set via @option{-opencl_options}. See the
"OpenCL Options" section in the ffmpeg-utils manual for the complete list of
supported options. Amongst others, these options include the ability to select
a specific platform and device to run the OpenCL code on. By default, FFmpeg
will run on the first device of the first platform. While the options for the
global OpenCL context provide flexibility to the user in selecting the OpenCL
device of their choice, most users would probably want to select the fastest
OpenCL device for their system.
This option assists the selection of the most efficient configuration by
identifying the appropriate device for the user's system. The built-in
benchmark is run on all the OpenCL devices and the performance is measured for
each device. The devices in the results list are sorted based on their
performance with the fastest device listed first. The user can subsequently
invoke @command{ffmpeg} using the device deemed most appropriate via
@option{-opencl_options} to obtain the best performance for the OpenCL
accelerated code.
Typical usage to use the fastest OpenCL device involve the following steps.
Run the command:
@example
ffmpeg -opencl_bench
@end example
Note down the platform ID (@var{pidx}) and device ID (@var{didx}) of the first
i.e. fastest device in the list.
Select the platform and device using the command:
@example
ffmpeg -opencl_options platform_idx=@var{pidx}:device_idx=@var{didx} ...
@end example
@item -opencl_options options (@emph{global})
Set OpenCL environment options. This option is only available when
FFmpeg has been compiled with @code{--enable-opencl}.
@var{options} must be a list of @var{key}=@var{value} option pairs
separated by ':'. See the ``OpenCL Options'' section in the
ffmpeg-utils manual for the list of supported options.
@end table @end table
@section AVOptions @section AVOptions

View File

@@ -5,7 +5,7 @@ This document explains guidelines that should be observed (or ignored with
good reason) when writing filters for libavfilter. good reason) when writing filters for libavfilter.
In this document, the word “frame” indicates either a video frame or a group In this document, the word “frame” indicates either a video frame or a group
of audio samples, as stored in an AVFrame structure. of audio samples, as stored in an AVFilterBuffer structure.
Format negotiation Format negotiation
@@ -35,31 +35,32 @@ Format negotiation
to set the formats supported on another. to set the formats supported on another.
Frame references ownership and permissions Buffer references ownership and permissions
========================================== ===========================================
Principle Principle
--------- ---------
Audio and video data are voluminous; the frame and frame reference Audio and video data are voluminous; the buffer and buffer reference
mechanism is intended to avoid, as much as possible, expensive copies of mechanism is intended to avoid, as much as possible, expensive copies of
that data while still allowing the filters to produce correct results. that data while still allowing the filters to produce correct results.
The data is stored in buffers represented by AVFrame structures. The data is stored in buffers represented by AVFilterBuffer structures.
Several references can point to the same frame buffer; the buffer is They must not be accessed directly, but through references stored in
automatically deallocated once all corresponding references have been AVFilterBufferRef structures. Several references can point to the
destroyed. same buffer; the buffer is automatically deallocated once all
corresponding references have been destroyed.
The characteristics of the data (resolution, sample rate, etc.) are The characteristics of the data (resolution, sample rate, etc.) are
stored in the reference; different references for the same buffer can stored in the reference; different references for the same buffer can
show different characteristics. In particular, a video reference can show different characteristics. In particular, a video reference can
point to only a part of a video buffer. point to only a part of a video buffer.
A reference is usually obtained as input to the filter_frame method or A reference is usually obtained as input to the start_frame or
requested using the ff_get_video_buffer or ff_get_audio_buffer filter_frame method or requested using the ff_get_video_buffer or
functions. A new reference on an existing buffer can be created with ff_get_audio_buffer functions. A new reference on an existing buffer can
av_frame_ref(). A reference is destroyed using be created with the avfilter_ref_buffer. A reference is destroyed using
the av_frame_free() function. the avfilter_unref_bufferp function.
Reference ownership Reference ownership
------------------- -------------------
@@ -72,13 +73,17 @@ Frame references ownership and permissions
Here are the (fairly obvious) rules for reference ownership: Here are the (fairly obvious) rules for reference ownership:
* A reference received by the filter_frame method belongs to the * A reference received by the filter_frame method (or its start_frame
corresponding filter. deprecated version) belongs to the corresponding filter.
* A reference passed to ff_filter_frame is given away and must no longer Special exception: for video references: the reference may be used
be used. internally for automatic copying and must not be destroyed before
end_frame; it can be given away to ff_start_frame.
* A reference created with av_frame_ref() belongs to the code that * A reference passed to ff_filter_frame (or the deprecated
ff_start_frame) is given away and must no longer be used.
* A reference created with avfilter_ref_buffer belongs to the code that
created it. created it.
* A reference obtained with ff_get_video_buffer or ff_get_audio_buffer * A reference obtained with ff_get_video_buffer or ff_get_audio_buffer
@@ -90,32 +95,89 @@ Frame references ownership and permissions
Link reference fields Link reference fields
--------------------- ---------------------
The AVFilterLink structure has a few AVFrame fields. The AVFilterLink structure has a few AVFilterBufferRef fields. The
cur_buf and out_buf were used with the deprecated
partial_buf is used by libavfilter internally and must not be accessed start_frame/draw_slice/end_frame API and should no longer be used.
by filters. src_buf and partial_buf are used by libavfilter internally
and must not be accessed by filters.
fifo contains frames queued in the filter's input. They belong to the
framework until they are taken by the filter.
Reference permissions Reference permissions
--------------------- ---------------------
Since the same frame data can be shared by several frames, modifying may The AVFilterBufferRef structure has a perms field that describes what
have unintended consequences. A frame is considered writable if only one the code that owns the reference is allowed to do to the buffer data.
reference to it exists. The code owning that reference it then allowed Different references for the same buffer can have different permissions.
to modify the data.
A filter can check if a frame is writable by using the For video filters that implement the deprecated
av_frame_is_writable() function. start_frame/draw_slice/end_frame API, the permissions only apply to the
parts of the buffer that have already been covered by the draw_slice
method.
A filter can ensure that a frame is writable at some point of the code The value is a binary OR of the following constants:
by using the ff_inlink_make_frame_writable() function. It will duplicate
the frame if needed.
A filter can ensure that the frame passed to the filter_frame() callback * AV_PERM_READ: the owner can read the buffer data; this is essentially
is writable by setting the needs_writable flag on the corresponding always true and is there for self-documentation.
input pad. It does not apply to the activate() callback.
* AV_PERM_WRITE: the owner can modify the buffer data.
* AV_PERM_PRESERVE: the owner can rely on the fact that the buffer data
will not be modified by previous filters.
* AV_PERM_REUSE: the owner can output the buffer several times, without
modifying the data in between.
* AV_PERM_REUSE2: the owner can output the buffer several times and
modify the data in between (useless without the WRITE permissions).
* AV_PERM_ALIGN: the owner can access the data using fast operations
that require data alignment.
The READ, WRITE and PRESERVE permissions are about sharing the same
buffer between several filters to avoid expensive copies without them
doing conflicting changes on the data.
The REUSE and REUSE2 permissions are about special memory for direct
rendering. For example a buffer directly allocated in video memory must
not modified once it is displayed on screen, or it will cause tearing;
it will therefore not have the REUSE2 permission.
The ALIGN permission is about extracting part of the buffer, for
copy-less padding or cropping for example.
References received on input pads are guaranteed to have all the
permissions stated in the min_perms field and none of the permissions
stated in the rej_perms.
References obtained by ff_get_video_buffer and ff_get_audio_buffer are
guaranteed to have at least all the permissions requested as argument.
References created by avfilter_ref_buffer have the same permissions as
the original reference minus the ones explicitly masked; the mask is
usually ~0 to keep the same permissions.
Filters should remove permissions on reference they give to output
whenever necessary. It can be automatically done by setting the
rej_perms field on the output pad.
Here are a few guidelines corresponding to common situations:
* Filters that modify and forward their frame (like drawtext) need the
WRITE permission.
* Filters that read their input to produce a new frame on output (like
scale) need the READ permission on input and must request a buffer
with the WRITE permission.
* Filters that intend to keep a reference after the filtering process
is finished (after filter_frame returns) must have the PRESERVE
permission on it and remove the WRITE permission if they create a new
reference to give it away.
* Filters that intend to modify a reference they have kept after the end
of the filtering process need the REUSE2 permission and must remove
the PRESERVE permission if they create a new reference to give it
away.
Frame scheduling Frame scheduling
@@ -127,100 +189,11 @@ Frame scheduling
Simple filters that output one frame for each input frame should not have Simple filters that output one frame for each input frame should not have
to worry about it. to worry about it.
There are two design for filters: one using the filter_frame() and
request_frame() callbacks and the other using the activate() callback.
The design using filter_frame() and request_frame() is legacy, but it is
suitable for filters that have a single input and process one frame at a
time. New filters with several inputs, that treat several frames at a time
or that require a special treatment at EOF should probably use the design
using activate().
activate
--------
This method is called when something must be done in a filter; the
definition of that "something" depends on the semantic of the filter.
The callback must examine the status of the filter's links and proceed
accordingly.
The status of output links is stored in the frame_wanted_out, status_in
and status_out fields and tested by the ff_outlink_frame_wanted()
function. If this function returns true, then the processing requires a
frame on this link and the filter is expected to make efforts in that
direction.
The status of input links is stored by the status_in, fifo and
status_out fields; they must not be accessed directly. The fifo field
contains the frames that are queued in the input for processing by the
filter. The status_in and status_out fields contains the queued status
(EOF or error) of the link; status_in is a status change that must be
taken into account after all frames in fifo have been processed;
status_out is the status that have been taken into account, it is final
when it is not 0.
The typical task of an activate callback is to first check the backward
status of output links, and if relevant forward it to the corresponding
input. Then, if relevant, for each input link: test the availability of
frames in fifo and process them; if no frame is available, test and
acknowledge a change of status using ff_inlink_acknowledge_status(); and
forward the result (frame or status change) to the corresponding input.
If nothing is possible, test the status of outputs and forward it to the
corresponding input(s). If still not possible, return FFERROR_NOT_READY.
If the filters stores internally one or a few frame for some input, it
can consider them to be part of the FIFO and delay acknowledging a
status change accordingly.
Example code:
ret = ff_outlink_get_status(outlink);
if (ret) {
ff_inlink_set_status(inlink, ret);
return 0;
}
if (priv->next_frame) {
/* use it */
return 0;
}
ret = ff_inlink_consume_frame(inlink, &frame);
if (ret < 0)
return ret;
if (ret) {
/* use it */
return 0;
}
ret = ff_inlink_acknowledge_status(inlink, &status, &pts);
if (ret) {
/* flush */
ff_outlink_set_status(outlink, status, pts);
return 0;
}
if (ff_outlink_frame_wanted(outlink)) {
ff_inlink_request_frame(inlink);
return 0;
}
return FFERROR_NOT_READY;
The exact code depends on how similar the /* use it */ blocks are and
how related they are to the /* flush */ block, and needs to apply these
operations to the correct inlink or outlink if there are several.
Macros are available to factor that when no extra processing is needed:
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
FF_FILTER_FORWARD_STATUS_ALL(outlink, filter);
FF_FILTER_FORWARD_STATUS(inlink, outlink);
FF_FILTER_FORWARD_STATUS_ALL(inlink, filter);
FF_FILTER_FORWARD_WANTED(outlink, inlink);
filter_frame filter_frame
------------ ------------
For filters that do not use the activate() callback, this method is This method is called when a frame is pushed to the filter's input. It
called when a frame is pushed to the filter's input. It can be called at can be called at any time except in a reentrant way.
any time except in a reentrant way.
If the input frame is enough to produce output, then the filter should If the input frame is enough to produce output, then the filter should
push the output frames on the output link immediately. push the output frames on the output link immediately.
@@ -249,10 +222,9 @@ Frame scheduling
request_frame request_frame
------------- -------------
For filters that do not use the activate() callback, this method is This method is called when a frame is wanted on an output.
called when a frame is wanted on an output.
For a source, it should directly call filter_frame on the corresponding For an input, it should directly call filter_frame on the corresponding
output. output.
For a filter, if there are queued frames already ready, one of these For a filter, if there are queued frames already ready, one of these
@@ -282,7 +254,16 @@ Frame scheduling
} }
return 0; return 0;
Note that, except for filters that can have queued frames and sources, Note that, except for filters that can have queued frames, request_frame
request_frame does not push frames: it requests them to its input, and does not push frames: it requests them to its input, and as a reaction,
as a reaction, the filter_frame method possibly will be called and do the filter_frame method possibly will be called and do the work.
the work.
Legacy API
==========
Until libavfilter 3.23, the filter_frame method was split:
- for video filters, it was made of start_frame, draw_slice (that could be
called several times on distinct parts of the frame) and end_frame;
- for audio filters, it was called filter_samples.

File diff suppressed because it is too large Load Diff

View File

@@ -61,10 +61,6 @@ Reduce the latency introduced by optional buffering
Only write platform-, build- and time-independent data. Only write platform-, build- and time-independent data.
This ensures that file and data checksums are reproducible and match between This ensures that file and data checksums are reproducible and match between
platforms. Its primary use is for regression testing. platforms. Its primary use is for regression testing.
@item shortest
Stop muxing at the end of the shortest stream.
It may be needed to increase max_interleave_delta to avoid flushing the longer
streams before EOF.
@end table @end table
@item seek2any @var{integer} (@emph{input}) @item seek2any @var{integer} (@emph{input})
@@ -151,7 +147,7 @@ a packet for each stream, regardless of the maximum timestamp
difference between the buffered packets. difference between the buffered packets.
@item use_wallclock_as_timestamps @var{integer} (@emph{input}) @item use_wallclock_as_timestamps @var{integer} (@emph{input})
Use wallclock as timestamps if set to 1. Default is 0. Use wallclock as timestamps.
@item avoid_negative_ts @var{integer} (@emph{output}) @item avoid_negative_ts @var{integer} (@emph{output})
@@ -182,10 +178,9 @@ Default is 0.
Correct single timestamp overflows if set to 1. Default is 1. Correct single timestamp overflows if set to 1. Default is 1.
@item flush_packets @var{integer} (@emph{output}) @item flush_packets @var{integer} (@emph{output})
Flush the underlying I/O stream after each packet. Default is -1 (auto), which Flush the underlying I/O stream after each packet. Default 1 enables it, and
means that the underlying protocol will decide, 1 enables it, and has the has the effect of reducing the latency; 0 disables it and may slightly
effect of reducing the latency, 0 disables it and may increase IO throughput in increase performance in some cases.
some cases.
@item output_ts_offset @var{offset} (@emph{output}) @item output_ts_offset @var{offset} (@emph{output})
Set the output time offset. Set the output time offset.
@@ -200,7 +195,7 @@ delayed bt the time duration specified in @var{offset}. Default value
is @code{0} (meaning that no offset is applied). is @code{0} (meaning that no offset is applied).
@item format_whitelist @var{list} (@emph{input}) @item format_whitelist @var{list} (@emph{input})
"," separated list of allowed demuxers. By default all are allowed. "," separated List of allowed demuxers. By default all are allowed.
@item dump_separator @var{string} (@emph{input}) @item dump_separator @var{string} (@emph{input})
Separator used to separate the fields printed on the command line about the Separator used to separate the fields printed on the command line about the
@@ -210,10 +205,6 @@ For example to separate the fields with newlines and indention:
ffprobe -dump_separator " ffprobe -dump_separator "
" -i ~/videos/matrixbench_mpeg2.mpg " -i ~/videos/matrixbench_mpeg2.mpg
@end example @end example
@item max_streams @var{integer} (@emph{input})
Specifies the maximum number of streams. This can be used to reject files that
would require too many resources due to a large number of streams.
@end table @end table
@c man end FORMAT OPTIONS @c man end FORMAT OPTIONS

View File

@@ -17,14 +17,6 @@ for more formats. None of them are used by default, their use has to be
explicitly requested by passing the appropriate flags to explicitly requested by passing the appropriate flags to
@command{./configure}. @command{./configure}.
@section Alliance for Open Media libaom
FFmpeg can make use of the libaom library for AV1 decoding.
Go to @url{http://aomedia.org/} and follow the instructions for
installing the library. Then pass @code{--enable-libaom} to configure to
enable it.
@section OpenJPEG @section OpenJPEG
FFmpeg can use the OpenJPEG libraries for encoding/decoding J2K videos. Go to FFmpeg can use the OpenJPEG libraries for encoding/decoding J2K videos. Go to
@@ -93,24 +85,6 @@ Go to @url{http://www.twolame.org/} and follow the
instructions for installing the library. instructions for installing the library.
Then pass @code{--enable-libtwolame} to configure to enable it. Then pass @code{--enable-libtwolame} to configure to enable it.
@section libcodec2 / codec2 general
FFmpeg can make use of libcodec2 for codec2 encoding and decoding.
There is currently no native decoder, so libcodec2 must be used for decoding.
Go to @url{http://freedv.org/}, download "Codec 2 source archive".
Build and install using CMake. Debian users can install the libcodec2-dev package instead.
Once libcodec2 is installed you can pass @code{--enable-libcodec2} to configure to enable it.
The easiest way to use codec2 is with .c2 files, since they contain the mode information required for decoding.
To encode such a file, use a .c2 file extension and give the libcodec2 encoder the -mode option:
@code{ffmpeg -i input.wav -mode 700C output.c2}.
Playback is as simple as @code{ffplay output.c2}.
For a list of supported modes, run @code{ffmpeg -h encoder=libcodec2}.
Raw codec2 files are also supported.
To make sense of them the mode in use needs to be specified as a format option:
@code{ffmpeg -f codec2raw -mode 1300 -i input.raw output.wav}.
@section libvpx @section libvpx
FFmpeg can make use of the libvpx library for VP8/VP9 encoding. FFmpeg can make use of the libvpx library for VP8/VP9 encoding.
@@ -127,29 +101,14 @@ Go to @url{http://www.wavpack.com/} and follow the instructions for
installing the library. Then pass @code{--enable-libwavpack} to configure to installing the library. Then pass @code{--enable-libwavpack} to configure to
enable it. enable it.
@section libxavs
FFmpeg can make use of the libxavs library for Xavs encoding.
Go to @url{http://xavs.sf.net/} and follow the instructions for
installing the library. Then pass @code{--enable-libxavs} to configure to
enable it.
@section OpenH264 @section OpenH264
FFmpeg can make use of the OpenH264 library for H.264 encoding and decoding. FFmpeg can make use of the OpenH264 library for H.264 encoding.
Go to @url{http://www.openh264.org/} and follow the instructions for Go to @url{http://www.openh264.org/} and follow the instructions for
installing the library. Then pass @code{--enable-libopenh264} to configure to installing the library. Then pass @code{--enable-libopenh264} to configure to
enable it. enable it.
For decoding, this library is much more limited than the built-in decoder
in libavcodec; currently, this library lacks support for decoding B-frames
and some other main/high profile features. (It currently only supports
constrained baseline profile and CABAC.) Using it is mostly useful for
testing and for taking advantage of Cisco's patent portfolio license
(@url{http://www.openh264.org/BINARY_LICENSE.txt}).
@section x264 @section x264
FFmpeg can make use of the x264 library for H.264 encoding. FFmpeg can make use of the x264 library for H.264 encoding.
@@ -220,19 +179,6 @@ For Windows, supported AviSynth variants are
For Linux and OS X, the supported AviSynth variant is For Linux and OS X, the supported AviSynth variant is
@url{https://github.com/avxsynth/avxsynth, AvxSynth}. @url{https://github.com/avxsynth/avxsynth, AvxSynth}.
@float NOTE
There is currently a regression in AviSynth+'s @code{capi.h} header as of
October 2016, which interferes with the ability for builds of FFmpeg to use
MSVC-built binaries of AviSynth. Until this is resolved, you can make sure
a known good version is installed by checking out a version from before
the regression occurred:
@code{git clone -b MT git://github.com/AviSynth/AviSynthPlus.git @*
cd AviSynthPlus @*
git checkout -b oldheader b4f292b4dbfad149697fb65c6a037bb3810813f9 @*
make install PREFIX=/install/prefix}
@end float
@float NOTE @float NOTE
AviSynth and AvxSynth are loaded dynamically. Distributors can build FFmpeg AviSynth and AvxSynth are loaded dynamically. Distributors can build FFmpeg
with @code{--enable-avisynth}, and the binaries will work regardless of the with @code{--enable-avisynth}, and the binaries will work regardless of the
@@ -251,18 +197,6 @@ The dispatcher is open source and can be downloaded from
with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able to with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able to
locate the dispatcher's @code{.pc} files. locate the dispatcher's @code{.pc} files.
@section AMD VCE
FFmpeg can use the AMD Advanced Media Framework library for accelerated H.264
and HEVC encoding on VCE enabled hardware under Windows.
To enable support you must obtain the AMF framework header files from
@url{https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}.
Create an @code{AMF/} directory in the system include path.
Copy the contents of @code{AMF/amf/public/include/} into that directory.
Then configure FFmpeg with @code{--enable-amf}.
@chapter Supported File Formats, Codecs or Features @chapter Supported File Formats, Codecs or Features
@@ -328,10 +262,6 @@ library:
@item BRSTM @tab @tab X @item BRSTM @tab @tab X
@tab Audio format used on the Nintendo Wii. @tab Audio format used on the Nintendo Wii.
@item BWF @tab X @tab X @item BWF @tab X @tab X
@item codec2 (raw) @tab X @tab X
@tab Must be given -mode format option to decode correctly.
@item codec2 (.c2 files) @tab X @tab X
@tab Contains header with version and mode info, simplifying playback.
@item CRI ADX @tab X @tab X @item CRI ADX @tab X @tab X
@tab Audio-only format used in console video games. @tab Audio-only format used in console video games.
@item Discworld II BMV @tab @tab X @item Discworld II BMV @tab @tab X
@@ -383,7 +313,6 @@ library:
@item FunCom ISS @tab @tab X @item FunCom ISS @tab @tab X
@tab Audio format used in various games from FunCom like The Longest Journey. @tab Audio format used in various games from FunCom like The Longest Journey.
@item G.723.1 @tab X @tab X @item G.723.1 @tab X @tab X
@item G.726 @tab @tab X @tab Both left- and right-justified.
@item G.729 BIT @tab X @tab X @item G.729 BIT @tab X @tab X
@item G.729 raw @tab @tab X @item G.729 raw @tab @tab X
@item GENH @tab @tab X @item GENH @tab @tab X
@@ -406,8 +335,6 @@ library:
@item iLBC @tab X @tab X @item iLBC @tab X @tab X
@item Interplay MVE @tab @tab X @item Interplay MVE @tab @tab X
@tab Format used in various Interplay computer games. @tab Format used in various Interplay computer games.
@item Iterated Systems ClearVideo @tab @tab X
@tab I-frames only
@item IV8 @tab @tab X @item IV8 @tab @tab X
@tab A format generated by IndigoVision 8000 video server. @tab A format generated by IndigoVision 8000 video server.
@item IVF (On2) @tab X @tab X @item IVF (On2) @tab X @tab X
@@ -453,7 +380,6 @@ library:
@tab Audio format used on the PS3. @tab Audio format used on the PS3.
@item Mirillis FIC video @tab @tab X @item Mirillis FIC video @tab @tab X
@tab No cursor rendering. @tab No cursor rendering.
@item MIDI Sample Dump Standard @tab @tab X
@item MIME multipart JPEG @tab X @tab @item MIME multipart JPEG @tab X @tab
@item MSN TCP webcam @tab @tab X @item MSN TCP webcam @tab @tab X
@tab Used by MSN Messenger webcam streams. @tab Used by MSN Messenger webcam streams.
@@ -467,7 +393,6 @@ library:
@item NC camera feed @tab @tab X @item NC camera feed @tab @tab X
@tab NC (AVIP NC4600) camera streams @tab NC (AVIP NC4600) camera streams
@item NIST SPeech HEader REsources @tab @tab X @item NIST SPeech HEader REsources @tab @tab X
@item Computerized Speech Lab NSP @tab @tab X
@item NTT TwinVQ (VQF) @tab @tab X @item NTT TwinVQ (VQF) @tab @tab X
@tab Nippon Telegraph and Telephone Corporation TwinVQ. @tab Nippon Telegraph and Telephone Corporation TwinVQ.
@item Nullsoft Streaming Video @tab @tab X @item Nullsoft Streaming Video @tab @tab X
@@ -482,10 +407,6 @@ library:
@item QCP @tab @tab X @item QCP @tab @tab X
@item raw ADTS (AAC) @tab X @tab X @item raw ADTS (AAC) @tab X @tab X
@item raw AC-3 @tab X @tab X @item raw AC-3 @tab X @tab X
@item raw AMR-NB @tab @tab X
@item raw AMR-WB @tab @tab X
@item raw aptX @tab X @tab X
@item raw aptX HD @tab X @tab X
@item raw Chinese AVS video @tab X @tab X @item raw Chinese AVS video @tab X @tab X
@item raw CRI ADX @tab X @tab X @item raw CRI ADX @tab X @tab X
@item raw Dirac @tab X @tab X @item raw Dirac @tab X @tab X
@@ -509,7 +430,6 @@ library:
@item raw NULL @tab X @tab @item raw NULL @tab X @tab
@item raw video @tab X @tab X @item raw video @tab X @tab X
@item raw id RoQ @tab X @tab @item raw id RoQ @tab X @tab
@item raw SBC @tab X @tab X
@item raw Shorten @tab @tab X @item raw Shorten @tab @tab X
@item raw TAK @tab @tab X @item raw TAK @tab @tab X
@item raw TrueHD @tab X @tab X @item raw TrueHD @tab X @tab X
@@ -523,8 +443,6 @@ library:
@item raw PCM signed 24 bit little-endian @tab X @tab X @item raw PCM signed 24 bit little-endian @tab X @tab X
@item raw PCM signed 32 bit big-endian @tab X @tab X @item raw PCM signed 32 bit big-endian @tab X @tab X
@item raw PCM signed 32 bit little-endian @tab X @tab X @item raw PCM signed 32 bit little-endian @tab X @tab X
@item raw PCM signed 64 bit big-endian @tab X @tab X
@item raw PCM signed 64 bit little-endian @tab X @tab X
@item raw PCM unsigned 8 bit @tab X @tab X @item raw PCM unsigned 8 bit @tab X @tab X
@item raw PCM unsigned 16 bit big-endian @tab X @tab X @item raw PCM unsigned 16 bit big-endian @tab X @tab X
@item raw PCM unsigned 16 bit little-endian @tab X @tab X @item raw PCM unsigned 16 bit little-endian @tab X @tab X
@@ -532,8 +450,6 @@ library:
@item raw PCM unsigned 24 bit little-endian @tab X @tab X @item raw PCM unsigned 24 bit little-endian @tab X @tab X
@item raw PCM unsigned 32 bit big-endian @tab X @tab X @item raw PCM unsigned 32 bit big-endian @tab X @tab X
@item raw PCM unsigned 32 bit little-endian @tab X @tab X @item raw PCM unsigned 32 bit little-endian @tab X @tab X
@item raw PCM 16.8 floating point little-endian @tab @tab X
@item raw PCM 24.0 floating point little-endian @tab @tab X
@item raw PCM floating-point 32 bit big-endian @tab X @tab X @item raw PCM floating-point 32 bit big-endian @tab X @tab X
@item raw PCM floating-point 32 bit little-endian @tab X @tab X @item raw PCM floating-point 32 bit little-endian @tab X @tab X
@item raw PCM floating-point 64 bit big-endian @tab X @tab X @item raw PCM floating-point 64 bit big-endian @tab X @tab X
@@ -555,11 +471,10 @@ library:
@tab Output is performed by publishing stream to RTMP server @tab Output is performed by publishing stream to RTMP server
@item RTP @tab X @tab X @item RTP @tab X @tab X
@item RTSP @tab X @tab X @item RTSP @tab X @tab X
@item Sample Dump eXchange @tab @tab X
@item SAP @tab X @tab X @item SAP @tab X @tab X
@item SBG @tab @tab X @item SBG @tab @tab X
@item SDP @tab @tab X @item SDP @tab @tab X
@item Sega FILM/CPK @tab X @tab X @item Sega FILM/CPK @tab @tab X
@tab Used in many Sega Saturn console games. @tab Used in many Sega Saturn console games.
@item Silicon Graphics Movie @tab @tab X @item Silicon Graphics Movie @tab @tab X
@item Sierra SOL @tab @tab X @item Sierra SOL @tab @tab X
@@ -570,7 +485,6 @@ library:
@tab Multimedia format used by many games. @tab Multimedia format used by many games.
@item SMJPEG @tab X @tab X @item SMJPEG @tab X @tab X
@tab Used in certain Loki game ports. @tab Used in certain Loki game ports.
@item SMPTE 337M encapsulation @tab @tab X
@item Smush @tab @tab X @item Smush @tab @tab X
@tab Multimedia format used in some LucasArts games. @tab Multimedia format used in some LucasArts games.
@item Sony OpenMG (OMA) @tab X @tab X @item Sony OpenMG (OMA) @tab X @tab X
@@ -579,7 +493,7 @@ library:
@item Sony Wave64 (W64) @tab X @tab X @item Sony Wave64 (W64) @tab X @tab X
@item SoX native format @tab X @tab X @item SoX native format @tab X @tab X
@item SUN AU format @tab X @tab X @item SUN AU format @tab X @tab X
@item SUP raw PGS subtitles @tab X @tab X @item SUP raw PGS subtitles @tab @tab X
@item SVAG @tab @tab X @item SVAG @tab @tab X
@tab Audio format used in Konami PS2 games. @tab Audio format used in Konami PS2 games.
@item TDSC @tab @tab X @item TDSC @tab @tab X
@@ -588,7 +502,7 @@ library:
@tab Used on the Nintendo GameCube. @tab Used on the Nintendo GameCube.
@item Tiertex Limited SEQ @tab @tab X @item Tiertex Limited SEQ @tab @tab X
@tab Tiertex .seq files used in the DOS CD-ROM version of the game Flashback. @tab Tiertex .seq files used in the DOS CD-ROM version of the game Flashback.
@item True Audio @tab X @tab X @item True Audio @tab @tab X
@item VAG @tab @tab X @item VAG @tab @tab X
@tab Audio format used in many Sony PS2 games. @tab Audio format used in many Sony PS2 games.
@item VC-1 test bitstream @tab X @tab X @item VC-1 test bitstream @tab X @tab X
@@ -606,7 +520,6 @@ library:
@tab Multimedia format used in Westwood Studios games. @tab Multimedia format used in Westwood Studios games.
@item Westwood Studios VQA @tab @tab X @item Westwood Studios VQA @tab @tab X
@tab Multimedia format used in Westwood Studios games. @tab Multimedia format used in Westwood Studios games.
@item Wideband Single-bit Data (WSD) @tab @tab X
@item WVE @tab @tab X @item WVE @tab @tab X
@item XMV @tab @tab X @item XMV @tab @tab X
@tab Microsoft video container used in Xbox games. @tab Microsoft video container used in Xbox games.
@@ -642,8 +555,6 @@ following image formats are supported:
@tab Digital Picture Exchange @tab Digital Picture Exchange
@item EXR @tab @tab X @item EXR @tab @tab X
@tab OpenEXR @tab OpenEXR
@item FITS @tab X @tab X
@tab Flexible Image Transport System
@item JPEG @tab X @tab X @item JPEG @tab X @tab X
@tab Progressive JPEG is not supported. @tab Progressive JPEG is not supported.
@item JPEG 2000 @tab X @tab X @item JPEG 2000 @tab X @tab X
@@ -665,8 +576,6 @@ following image formats are supported:
@item PNG @tab X @tab X @item PNG @tab X @tab X
@item PPM @tab X @tab X @item PPM @tab X @tab X
@tab Portable PixelMap image @tab Portable PixelMap image
@item PSD @tab @tab X
@tab Photoshop
@item PTX @tab @tab X @item PTX @tab @tab X
@tab V.Flash PTX format @tab V.Flash PTX format
@item SGI @tab X @tab X @item SGI @tab X @tab X
@@ -683,8 +592,6 @@ following image formats are supported:
@tab X BitMap image format @tab X BitMap image format
@item XFace @tab X @tab X @item XFace @tab X @tab X
@tab X-Face image format @tab X-Face image format
@item XPM @tab @tab X
@tab X PixMap image format
@item XWD @tab X @tab X @item XWD @tab X @tab X
@tab X Window Dump image format @tab X Window Dump image format
@end multitable @end multitable
@@ -710,7 +617,6 @@ following image formats are supported:
@item ANSI/ASCII art @tab @tab X @item ANSI/ASCII art @tab @tab X
@item Apple Intermediate Codec @tab @tab X @item Apple Intermediate Codec @tab @tab X
@item Apple MJPEG-B @tab @tab X @item Apple MJPEG-B @tab @tab X
@item Apple Pixlet @tab @tab X
@item Apple ProRes @tab X @tab X @item Apple ProRes @tab X @tab X
@item Apple QuickDraw @tab @tab X @item Apple QuickDraw @tab @tab X
@tab fourcc: qdrw @tab fourcc: qdrw
@@ -727,8 +633,6 @@ following image formats are supported:
@item Autodesk Animator Flic video @tab @tab X @item Autodesk Animator Flic video @tab @tab X
@item Autodesk RLE @tab @tab X @item Autodesk RLE @tab @tab X
@tab fourcc: AASC @tab fourcc: AASC
@item AV1 @tab @tab E
@tab Supported through external library libaom
@item Avid 1:1 10-bit RGB Packer @tab X @tab X @item Avid 1:1 10-bit RGB Packer @tab X @tab X
@tab fourcc: AVrp @tab fourcc: AVrp
@item AVS (Audio Video Standard) video @tab @tab X @item AVS (Audio Video Standard) video @tab @tab X
@@ -739,7 +643,6 @@ following image formats are supported:
@item Bethesda VID video @tab @tab X @item Bethesda VID video @tab @tab X
@tab Used in some games from Bethesda Softworks. @tab Used in some games from Bethesda Softworks.
@item Bink Video @tab @tab X @item Bink Video @tab @tab X
@item BitJazz SheerVideo @tab @tab X
@item Bitmap Brothers JV video @tab @tab X @item Bitmap Brothers JV video @tab @tab X
@item y41p Brooktree uncompressed 4:1:1 12-bit @tab X @tab X @item y41p Brooktree uncompressed 4:1:1 12-bit @tab X @tab X
@item Brute Force & Ignorance @tab @tab X @item Brute Force & Ignorance @tab @tab X
@@ -766,7 +669,7 @@ following image formats are supported:
@item DFA @tab @tab X @item DFA @tab @tab X
@tab Codec used in Chronomaster game. @tab Codec used in Chronomaster game.
@item Dirac @tab E @tab X @item Dirac @tab E @tab X
@tab supported though the native vc2 (Dirac Pro) encoder @tab supported through external library libschroedinger
@item Deluxe Paint Animation @tab @tab X @item Deluxe Paint Animation @tab @tab X
@item DNxHD @tab X @tab X @item DNxHD @tab X @tab X
@tab aka SMPTE VC3 @tab aka SMPTE VC3
@@ -774,8 +677,6 @@ following image formats are supported:
@tab fourcc: DUCK @tab fourcc: DUCK
@item Duck TrueMotion 2.0 @tab @tab X @item Duck TrueMotion 2.0 @tab @tab X
@tab fourcc: TM20 @tab fourcc: TM20
@item Duck TrueMotion 2.0 RT @tab @tab X
@tab fourcc: TR20
@item DV (Digital Video) @tab X @tab X @item DV (Digital Video) @tab X @tab X
@item Dxtory capture format @tab @tab X @item Dxtory capture format @tab @tab X
@item Feeble Files/ScummVM DXA @tab @tab X @item Feeble Files/ScummVM DXA @tab @tab X
@@ -795,7 +696,6 @@ following image formats are supported:
@item Flash Screen Video v2 @tab X @tab X @item Flash Screen Video v2 @tab X @tab X
@item Flash Video (FLV) @tab X @tab X @item Flash Video (FLV) @tab X @tab X
@tab Sorenson H.263 used in Flash @tab Sorenson H.263 used in Flash
@item FM Screen Capture Codec @tab @tab X
@item Forward Uncompressed @tab @tab X @item Forward Uncompressed @tab @tab X
@item Fraps @tab @tab X @item Fraps @tab @tab X
@item Go2Meeting @tab @tab X @item Go2Meeting @tab @tab X
@@ -843,8 +743,6 @@ following image formats are supported:
@item LucasArts SANM/Smush @tab @tab X @item LucasArts SANM/Smush @tab @tab X
@tab Used in LucasArts games / SMUSH animations. @tab Used in LucasArts games / SMUSH animations.
@item lossless MJPEG @tab X @tab X @item lossless MJPEG @tab X @tab X
@item MagicYUV Video @tab X @tab X
@item Mandsoft Screen Capture Codec @tab @tab X
@item Microsoft ATC Screen @tab @tab X @item Microsoft ATC Screen @tab @tab X
@tab Also known as Microsoft Screen 3. @tab Also known as Microsoft Screen 3.
@item Microsoft Expression Encoder Screen @tab @tab X @item Microsoft Expression Encoder Screen @tab @tab X
@@ -869,7 +767,6 @@ following image formats are supported:
@item MPEG-4 part 2 Microsoft variant version 1 @tab @tab X @item MPEG-4 part 2 Microsoft variant version 1 @tab @tab X
@item MPEG-4 part 2 Microsoft variant version 2 @tab X @tab X @item MPEG-4 part 2 Microsoft variant version 2 @tab X @tab X
@item MPEG-4 part 2 Microsoft variant version 3 @tab X @tab X @item MPEG-4 part 2 Microsoft variant version 3 @tab X @tab X
@item Newtek SpeedHQ @tab @tab X
@item Nintendo Gamecube THP video @tab @tab X @item Nintendo Gamecube THP video @tab @tab X
@item NuppelVideo/RTjpeg @tab @tab X @item NuppelVideo/RTjpeg @tab @tab X
@tab Video encoding used in NuppelVideo files. @tab Video encoding used in NuppelVideo files.
@@ -910,9 +807,7 @@ following image formats are supported:
@tab Texture dictionaries used by the Renderware Engine. @tab Texture dictionaries used by the Renderware Engine.
@item RL2 video @tab @tab X @item RL2 video @tab @tab X
@tab used in some games by Entertainment Software Partners @tab used in some games by Entertainment Software Partners
@item ScreenPressor @tab @tab X
@item Screenpresso @tab @tab X @item Screenpresso @tab @tab X
@item Screen Recorder Gold Codec @tab @tab X
@item Sierra VMD video @tab @tab X @item Sierra VMD video @tab @tab X
@tab Used in Sierra VMD files. @tab Used in Sierra VMD files.
@item Silicon Graphics Motion Video Compressor 1 (MVC1) @tab @tab X @item Silicon Graphics Motion Video Compressor 1 (MVC1) @tab @tab X
@@ -980,7 +875,7 @@ following image formats are supported:
@item 8SVX exponential @tab @tab X @item 8SVX exponential @tab @tab X
@item 8SVX fibonacci @tab @tab X @item 8SVX fibonacci @tab @tab X
@item AAC @tab EX @tab X @item AAC @tab EX @tab X
@tab encoding supported through internal encoder and external library libfdk-aac @tab encoding supported through internal encoder and external libraries libfaac and libfdk-aac
@item AAC+ @tab E @tab IX @item AAC+ @tab E @tab IX
@tab encoding supported through external library libfdk-aac @tab encoding supported through external library libfdk-aac
@item AC-3 @tab IX @tab IX @item AC-3 @tab IX @tab IX
@@ -1041,10 +936,6 @@ following image formats are supported:
@item Amazing Studio PAF Audio @tab @tab X @item Amazing Studio PAF Audio @tab @tab X
@item Apple lossless audio @tab X @tab X @item Apple lossless audio @tab X @tab X
@tab QuickTime fourcc 'alac' @tab QuickTime fourcc 'alac'
@item aptX @tab X @tab X
@tab Used in Bluetooth A2DP
@item aptX HD @tab X @tab X
@tab Used in Bluetooth A2DP
@item ATRAC1 @tab @tab X @item ATRAC1 @tab @tab X
@item ATRAC3 @tab @tab X @item ATRAC3 @tab @tab X
@item ATRAC3+ @tab @tab X @item ATRAC3+ @tab @tab X
@@ -1052,8 +943,6 @@ following image formats are supported:
@tab Used in Bink and Smacker files in many games. @tab Used in Bink and Smacker files in many games.
@item CELT @tab @tab E @item CELT @tab @tab E
@tab decoding supported through external library libcelt @tab decoding supported through external library libcelt
@item codec2 @tab E @tab E
@tab en/decoding supported through external library libcodec2
@item Delphine Software International CIN audio @tab @tab X @item Delphine Software International CIN audio @tab @tab X
@tab Codec used in Delphine Software International games. @tab Codec used in Delphine Software International games.
@item Digital Speech Standard - Standard Play mode (DSS SP) @tab @tab X @item Digital Speech Standard - Standard Play mode (DSS SP) @tab @tab X
@@ -1061,8 +950,7 @@ following image formats are supported:
@item COOK @tab @tab X @item COOK @tab @tab X
@tab All versions except 5.1 are supported. @tab All versions except 5.1 are supported.
@item DCA (DTS Coherent Acoustics) @tab X @tab X @item DCA (DTS Coherent Acoustics) @tab X @tab X
@tab supported extensions: XCh, XXCH, X96, XBR, XLL, LBR (partially) @tab supported extensions: XCh, XLL (partially)
@item Dolby E @tab @tab X
@item DPCM id RoQ @tab X @tab X @item DPCM id RoQ @tab X @tab X
@tab Used in Quake III, Jedi Knight 2 and other computer games. @tab Used in Quake III, Jedi Knight 2 and other computer games.
@item DPCM Interplay @tab @tab X @item DPCM Interplay @tab @tab X
@@ -1079,7 +967,6 @@ following image formats are supported:
@item DSD (Direct Stream Digitial), least significant bit first, planar @tab @tab X @item DSD (Direct Stream Digitial), least significant bit first, planar @tab @tab X
@item DSD (Direct Stream Digitial), most significant bit first, planar @tab @tab X @item DSD (Direct Stream Digitial), most significant bit first, planar @tab @tab X
@item DSP Group TrueSpeech @tab @tab X @item DSP Group TrueSpeech @tab @tab X
@item DST (Direct Stream Transfer) @tab @tab X
@item DV audio @tab @tab X @item DV audio @tab @tab X
@item Enhanced AC-3 @tab X @tab X @item Enhanced AC-3 @tab X @tab X
@item EVRC (Enhanced Variable Rate Codec) @tab @tab X @item EVRC (Enhanced Variable Rate Codec) @tab @tab X
@@ -1097,7 +984,7 @@ following image formats are supported:
@item Interplay ACM @tab @tab X @item Interplay ACM @tab @tab X
@item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X
@item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X
@item MLP (Meridian Lossless Packing) @tab X @tab X @item MLP (Meridian Lossless Packing) @tab @tab X
@tab Used in DVD-Audio discs. @tab Used in DVD-Audio discs.
@item Monkey's Audio @tab @tab X @item Monkey's Audio @tab @tab X
@item MP1 (MPEG audio layer 1) @tab @tab IX @item MP1 (MPEG audio layer 1) @tab @tab IX
@@ -1141,7 +1028,6 @@ following image formats are supported:
@item PCM unsigned 32-bit little-endian @tab X @tab X @item PCM unsigned 32-bit little-endian @tab X @tab X
@item PCM Zork @tab @tab X @item PCM Zork @tab @tab X
@item QCELP / PureVoice @tab @tab X @item QCELP / PureVoice @tab @tab X
@item QDesign Music Codec 1 @tab @tab X
@item QDesign Music Codec 2 @tab @tab X @item QDesign Music Codec 2 @tab @tab X
@tab There are still some distortions. @tab There are still some distortions.
@item RealAudio 1.0 (14.4K) @tab X @tab X @item RealAudio 1.0 (14.4K) @tab X @tab X
@@ -1152,8 +1038,6 @@ following image formats are supported:
@tab Real low bitrate AC-3 codec @tab Real low bitrate AC-3 codec
@item RealAudio Lossless @tab @tab X @item RealAudio Lossless @tab @tab X
@item RealAudio SIPR / ACELP.NET @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X
@item SBC (low-complexity subband codec) @tab X @tab X
@tab Used in Bluetooth A2DP
@item Shorten @tab @tab X @item Shorten @tab @tab X
@item Sierra VMD audio @tab @tab X @item Sierra VMD audio @tab @tab X
@tab Used in Sierra VMD files. @tab Used in Sierra VMD files.
@@ -1167,7 +1051,7 @@ following image formats are supported:
@tab supported through external library libspeex @tab supported through external library libspeex
@item TAK (Tom's lossless Audio Kompressor) @tab @tab X @item TAK (Tom's lossless Audio Kompressor) @tab @tab X
@item True Audio (TTA) @tab X @tab X @item True Audio (TTA) @tab X @tab X
@item TrueHD @tab X @tab X @item TrueHD @tab @tab X
@tab Used in HD-DVD and Blu-Ray discs. @tab Used in HD-DVD and Blu-Ray discs.
@item TwinVQ (VQF flavor) @tab @tab X @item TwinVQ (VQF flavor) @tab @tab X
@item VIMA @tab @tab X @item VIMA @tab @tab X
@@ -1240,7 +1124,6 @@ performance on systems without hardware floating point support).
@item MMSH @tab X @item MMSH @tab X
@item MMST @tab X @item MMST @tab X
@item pipe @tab X @item pipe @tab X
@item Pro-MPEG FEC @tab X
@item RTMP @tab X @item RTMP @tab X
@item RTMPE @tab X @item RTMPE @tab X
@item RTMPS @tab X @item RTMPS @tab X

View File

@@ -408,7 +408,7 @@ with @option{--dry-run} first. And then inspecting the commits listed with
@command{git log -p 1234567..987654}. The @command{git status} command @command{git log -p 1234567..987654}. The @command{git status} command
may help in finding local changes that have been forgotten to be added. may help in finding local changes that have been forgotten to be added.
Next let the code pass through a full run of our test suite. Next let the code pass through a full run of our testsuite.
@itemize @itemize
@item @command{make distclean} @item @command{make distclean}
@@ -418,7 +418,7 @@ Next let the code pass through a full run of our test suite.
@end itemize @end itemize
Make sure all your changes have been checked before pushing them, the Make sure all your changes have been checked before pushing them, the
test suite only checks against regressions and that only to some extend. It does testsuite only checks against regressions and that only to some extend. It does
obviously not check newly added features/code to be working unless you have obviously not check newly added features/code to be working unless you have
added a test for that (which is recommended). added a test for that (which is recommended).

View File

@@ -63,51 +63,12 @@ Set the number of channels. Default is 2.
@end table @end table
@section android_camera
Android camera input device.
This input devices uses the Android Camera2 NDK API which is
available on devices with API level 24+. The availability of
android_camera is autodetected during configuration.
This device allows capturing from all cameras on an Android device,
which are integrated into the Camera2 NDK API.
The available cameras are enumerated internally and can be selected
with the @var{camera_index} parameter. The input file string is
discarded.
Generally the back facing camera has index 0 while the front facing
camera has index 1.
@subsection Options
@table @option
@item video_size
Set the video size given as a string such as 640x480 or hd720.
Falls back to the first available configuration reported by
Android if requested video size is not available or by default.
@item framerate
Set the video framerate.
Falls back to the first available configuration reported by
Android if requested framerate is not available or by default (-1).
@item camera_index
Set the index of the camera to use. Default is 0.
@item input_queue_size
Set the maximum number of frames to buffer. Default is 5.
@end table
@section avfoundation @section avfoundation
AVFoundation input device. AVFoundation input device.
AVFoundation is the currently recommended framework by Apple for streamgrabbing on OSX >= 10.7 as well as on iOS. AVFoundation is the currently recommended framework by Apple for streamgrabbing on OSX >= 10.7 as well as on iOS.
The older QTKit framework has been marked deprecated since OSX version 10.7.
The input filename has to be given in the following syntax: The input filename has to be given in the following syntax:
@example @example
@@ -254,9 +215,8 @@ need to configure with the appropriate @code{--extra-cflags}
and @code{--extra-ldflags}. and @code{--extra-ldflags}.
On Windows, you need to run the IDL files through @command{widl}. On Windows, you need to run the IDL files through @command{widl}.
DeckLink is very picky about the formats it supports. Pixel format of the DeckLink is very picky about the formats it supports. Pixel format is
input can be set with @option{raw_format}. uyvy422 or v210, framerate and video size must be determined for your device with
Framerate and video size must be determined for your device with
@command{-list_formats 1}. Audio sample rate is always 48 kHz and the number @command{-list_formats 1}. Audio sample rate is always 48 kHz and the number
of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single
audio track. audio track.
@@ -273,97 +233,24 @@ Defaults to @option{false}.
If set to @option{true}, print a list of supported formats and exit. If set to @option{true}, print a list of supported formats and exit.
Defaults to @option{false}. Defaults to @option{false}.
@item format_code <FourCC>
This sets the input video format to the format given by the FourCC. To see
the supported values of your device(s) use @option{list_formats}.
Note that there is a FourCC @option{'pal '} that can also be used
as @option{pal} (3 letters).
Default behavior is autodetection of the input video format, if the hardware
supports it.
@item bm_v210 @item bm_v210
This is a deprecated option, you can use @option{raw_format} instead.
If set to @samp{1}, video is captured in 10 bit v210 instead If set to @samp{1}, video is captured in 10 bit v210 instead
of uyvy422. Not all Blackmagic devices support this option. of uyvy422. Not all Blackmagic devices support this option.
@item raw_format
Set the pixel format of the captured video.
Available values are:
@table @samp
@item uyvy422
@item yuv422p10
@item argb
@item bgra
@item rgb10
@end table
@item teletext_lines @item teletext_lines
If set to nonzero, an additional teletext stream will be captured from the If set to nonzero, an additional teletext stream will be captured from the
vertical ancillary data. Both SD PAL (576i) and HD (1080i or 1080p) vertical ancillary data. This option is a bitmask of the VBI lines checked,
sources are supported. In case of HD sources, OP47 packets are decoded. specifically lines 6 to 22, and lines 318 to 335. Line 6 is the LSB in the mask.
Selected lines which do not contain teletext information will be ignored. You
This option is a bitmask of the SD PAL VBI lines captured, specifically lines 6 can use the special @option{all} constant to select all possible lines, or
to 22, and lines 318 to 335. Line 6 is the LSB in the mask. Selected lines @option{standard} to skip lines 6, 318 and 319, which are not compatible with all
which do not contain teletext information will be ignored. You can use the receivers. Capturing teletext only works for SD PAL sources in 8 bit mode.
special @option{all} constant to select all possible lines, or To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}.
@option{standard} to skip lines 6, 318 and 319, which are not compatible with
all receivers.
For SD sources, ffmpeg needs to be compiled with @code{--enable-libzvbi}. For
HD sources, on older (pre-4K) DeckLink card models you have to capture in 10
bit mode.
@item channels @item channels
Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}. Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}.
Defaults to @samp{2}. Defaults to @samp{2}.
@item duplex_mode
Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or @samp{full}.
Defaults to @samp{unset}.
@item video_input
Sets the video input source. Must be @samp{unset}, @samp{sdi}, @samp{hdmi},
@samp{optical_sdi}, @samp{component}, @samp{composite} or @samp{s_video}.
Defaults to @samp{unset}.
@item audio_input
Sets the audio input source. Must be @samp{unset}, @samp{embedded},
@samp{aes_ebu}, @samp{analog}, @samp{analog_xlr}, @samp{analog_rca} or
@samp{microphone}. Defaults to @samp{unset}.
@item video_pts
Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},
@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
Defaults to @samp{video}.
@item audio_pts
Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
Defaults to @samp{audio}.
@item draw_bars
If set to @samp{true}, color bars are drawn in the event of a signal loss.
Defaults to @samp{true}.
@item queue_size
Sets maximum input buffer size in bytes. If the buffering reaches this value,
incoming frames will be dropped.
Defaults to @samp{1073741824}.
@item audio_depth
Sets the audio sample bit depth. Must be @samp{16} or @samp{32}.
Defaults to @samp{16}.
@item decklink_copyts
If set to @option{true}, timestamps are forwarded as they are without removing
the initial offset.
Defaults to @option{false}.
@end table @end table
@subsection Examples @subsection Examples
@@ -383,131 +270,21 @@ ffmpeg -f decklink -list_formats 1 -i 'Intensity Pro'
@end example @end example
@item @item
Capture video clip at 1080i50: Capture video clip at 1080i50 (format 11):
@example @example
ffmpeg -format_code Hi50 -f decklink -i 'Intensity Pro' -c:a copy -c:v copy output.avi ffmpeg -f decklink -i 'Intensity Pro@@11' -acodec copy -vcodec copy output.avi
@end example @end example
@item @item
Capture video clip at 1080i50 10 bit: Capture video clip at 1080i50 10 bit:
@example @example
ffmpeg -bm_v210 1 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -c:a copy -c:v copy output.avi ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
@end example @end example
@item @item
Capture video clip at 1080i50 with 16 audio channels: Capture video clip at 1080i50 with 16 audio channels:
@example @example
ffmpeg -channels 16 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -c:a copy -c:v copy output.avi ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
@end example
@end itemize
@section kmsgrab
KMS video input device.
Captures the KMS scanout framebuffer associated with a specified CRTC or plane as a
DRM object that can be passed to other hardware functions.
Requires either DRM master or CAP_SYS_ADMIN to run.
If you don't understand what all of that means, you probably don't want this. Look at
@option{x11grab} instead.
@subsection Options
@table @option
@item device
DRM device to capture on. Defaults to @option{/dev/dri/card0}.
@item format
Pixel format of the framebuffer. Defaults to @option{bgr0}.
@item format_modifier
Format modifier to signal on output frames. This is necessary to import correctly into
some APIs, but can't be autodetected. See the libdrm documentation for possible values.
@item crtc_id
KMS CRTC ID to define the capture source. The first active plane on the given CRTC
will be used.
@item plane_id
KMS plane ID to define the capture source. Defaults to the first active plane found if
neither @option{crtc_id} nor @option{plane_id} are specified.
@item framerate
Framerate to capture at. This is not synchronised to any page flipping or framebuffer
changes - it just defines the interval at which the framebuffer is sampled. Sampling
faster than the framebuffer update rate will generate independent frames with the same
content. Defaults to @code{30}.
@end table
@subsection Examples
@itemize
@item
Capture from the first active plane, download the result to normal frames and encode.
This will only work if the framebuffer is both linear and mappable - if not, the result
may be scrambled or fail to download.
@example
ffmpeg -f kmsgrab -i - -vf 'hwdownload,format=bgr0' output.mp4
@end example
@item
Capture from CRTC ID 42 at 60fps, map the result to VAAPI, convert to NV12 and encode as H.264.
@example
ffmpeg -crtc_id 42 -framerate 60 -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi output.mp4
@end example
@end itemize
@section libndi_newtek
The libndi_newtek input device provides capture capabilities for using NDI (Network
Device Interface, standard created by NewTek).
Input filename is a NDI source name that could be found by sending -find_sources 1
to command line - it has no specific syntax but human-readable formatted.
To enable this input device, you need the NDI SDK and you
need to configure with the appropriate @code{--extra-cflags}
and @code{--extra-ldflags}.
@subsection Options
@table @option
@item find_sources
If set to @option{true}, print a list of found/available NDI sources and exit.
Defaults to @option{false}.
@item wait_sources
Override time to wait until the number of online sources have changed.
Defaults to @option{0.5}.
@item allow_video_fields
When this flag is @option{false}, all video that you receive will be progressive.
Defaults to @option{true}.
@end table
@subsection Examples
@itemize
@item
List input devices:
@example
ffmpeg -f libndi_newtek -find_sources 1 -i dummy
@end example
@item
Restream to NDI:
@example
ffmpeg -f libndi_newtek -i "DEV-5.INTERNAL.M1STEREO.TV (NDI_SOURCE_NAME_1)" -f libndi_newtek -y NDI_SOURCE_NAME_2
@end example @end example
@end itemize @end itemize
@@ -712,6 +489,31 @@ $ ffmpeg -f dshow -show_video_device_dialog true -crossbar_video_input_pin_numbe
@end itemize @end itemize
@section dv1394
Linux DV 1394 input device.
@subsection Options
@table @option
@item framerate
Set the frame rate. Default is 25.
@item standard
Available values are:
@table @samp
@item pal
@item ntsc
@end table
Default value is @code{ntsc}.
@end table
@section fbdev @section fbdev
Linux framebuffer input device. Linux framebuffer input device.
@@ -854,7 +656,7 @@ is an exact value. For HDV, it is not frame exact, since HDV does
not have a fixed frame size. not have a fixed frame size.
@item dvguid @item dvguid
Select the capture device by specifying its GUID. Capturing will only Select the capture device by specifying it's GUID. Capturing will only
be performed from the specified device and fails if no device with the be performed from the specified device and fails if no device with the
given GUID is found. This is useful to select the input if multiple given GUID is found. This is useful to select the input if multiple
devices are connected at the same time. devices are connected at the same time.
@@ -1248,6 +1050,49 @@ Record a stream from default device:
ffmpeg -f pulse -i default /tmp/pulse.wav ffmpeg -f pulse -i default /tmp/pulse.wav
@end example @end example
@section qtkit
QTKit input device.
The filename passed as input is parsed to contain either a device name or index.
The device index can also be given by using -video_device_index.
A given device index will override any given device name.
If the desired device consists of numbers only, use -video_device_index to identify it.
The default device will be chosen if an empty string or the device name "default" is given.
The available devices can be enumerated by using -list_devices.
@example
ffmpeg -f qtkit -i "0" out.mpg
@end example
@example
ffmpeg -f qtkit -video_device_index 0 -i "" out.mpg
@end example
@example
ffmpeg -f qtkit -i "default" out.mpg
@end example
@example
ffmpeg -f qtkit -list_devices true -i ""
@end example
@subsection Options
@table @option
@item frame_rate
Set frame rate. Default is 30.
@item list_devices
If set to @code{true}, print a list of devices and exit. Default is
@code{false}.
@item video_device_index
Select the video device by index for devices with the same name (starts at 0).
@end table
@section sndio @section sndio
sndio input device. sndio input device.
@@ -1434,6 +1279,9 @@ To enable this input device during configuration you need libxcb
installed on your system. It will be automatically detected during installed on your system. It will be automatically detected during
configuration. configuration.
Alternatively, the configure option @option{--enable-x11grab} exists
for legacy Xlib users.
This device allows one to capture a region of an X11 display. This device allows one to capture a region of an X11 display.
The filename passed as input has the syntax: The filename passed as input has the syntax:
@@ -1471,7 +1319,7 @@ ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0+10,20 out.mpg
@table @option @table @option
@item draw_mouse @item draw_mouse
Specify whether to draw the mouse pointer. A value of @code{0} specifies Specify whether to draw the mouse pointer. A value of @code{0} specify
not to draw the pointer. Default value is @code{1}. not to draw the pointer. Default value is @code{1}.
@item follow_mouse @item follow_mouse
@@ -1521,6 +1369,11 @@ ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 25 -video_siz
@item video_size @item video_size
Set the video frame size. Default value is @code{vga}. Set the video frame size. Default value is @code{vga}.
@item use_shm
Use the MIT-SHM extension for shared memory. Default value is @code{1}.
It may be necessary to disable it for remote displays (legacy x11grab
only).
@item grab_x @item grab_x
@item grab_y @item grab_y
Set the grabbing region coordinates. They are expressed as offset from Set the grabbing region coordinates. They are expressed as offset from

View File

@@ -193,6 +193,9 @@ ffplay
ffprobe ffprobe
issues in or related to ffprobe.c issues in or related to ffprobe.c
ffserver
issues in or related to ffserver.c
postproc postproc
issues in libpostproc/* issues in libpostproc/*

Some files were not shown because too many files have changed in this diff Show More