mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-05 22:40:09 +01:00
Compare commits
187 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5771a0c823 | ||
|
|
f309b698e6 | ||
|
|
0887f1835d | ||
|
|
de42af2bee | ||
|
|
ada229e66f | ||
|
|
047e0049d1 | ||
|
|
88f52f2f8f | ||
|
|
8baf2d8fad | ||
|
|
17b8e7799f | ||
|
|
6457346e6a | ||
|
|
27f1fb1251 | ||
|
|
c993a11e56 | ||
|
|
ef5b120e2d | ||
|
|
b9a1d389b2 | ||
|
|
8c43f32057 | ||
|
|
77d5a237ef | ||
|
|
fb7617df4e | ||
|
|
82b58841c9 | ||
|
|
e5bf7ab3e7 | ||
|
|
63f951601e | ||
|
|
7fefa4138d | ||
|
|
a1f77124c8 | ||
|
|
f2f7d49f41 | ||
|
|
9357aa6757 | ||
|
|
26a8fc1c00 | ||
|
|
b7b3b0086d | ||
|
|
d669b7f4f6 | ||
|
|
9259b7f38e | ||
|
|
cb8a29f872 | ||
|
|
6744d3f6b9 | ||
|
|
73b644cdee | ||
|
|
3512ed3622 | ||
|
|
1d90326f95 | ||
|
|
1b47c278a6 | ||
|
|
cd91aaa4cc | ||
|
|
2858f77fd4 | ||
|
|
fe7366ee93 | ||
|
|
4ab41164d2 | ||
|
|
d794d97d96 | ||
|
|
93534cd642 | ||
|
|
ca92adafb0 | ||
|
|
815a4439c3 | ||
|
|
17035c8d2e | ||
|
|
426b959e37 | ||
|
|
61fcba7546 | ||
|
|
66bd740e0b | ||
|
|
534dc63089 | ||
|
|
09d1854063 | ||
|
|
ab9616428a | ||
|
|
e7c00a2814 | ||
|
|
2a8441e949 | ||
|
|
7876fd679d | ||
|
|
8b3d9c33d6 | ||
|
|
c575726621 | ||
|
|
6e6609f5dd | ||
|
|
6e13acaadd | ||
|
|
a5680d83af | ||
|
|
811d560378 | ||
|
|
c34f0616d9 | ||
|
|
96ce6f64cc | ||
|
|
13b6852225 | ||
|
|
d13ba39606 | ||
|
|
19b86db2b3 | ||
|
|
694d37eb52 | ||
|
|
4e5d1c45f1 | ||
|
|
2577cfd207 | ||
|
|
280587b4ab | ||
|
|
5bf11223dd | ||
|
|
679e869496 | ||
|
|
7216068e42 | ||
|
|
e7a064efa6 | ||
|
|
a004e2e4f1 | ||
|
|
f50f7adf7a | ||
|
|
9cf85419a3 | ||
|
|
b3fe93e73b | ||
|
|
603fd4f771 | ||
|
|
76a239768f | ||
|
|
fca62cc6a7 | ||
|
|
9f1e8b4fb2 | ||
|
|
b2a2b1a88b | ||
|
|
f3c1a76ffd | ||
|
|
b62191f9c1 | ||
|
|
21c36d83f8 | ||
|
|
4774eb8128 | ||
|
|
96f5019bde | ||
|
|
bffe1c4222 | ||
|
|
fbdf5ca763 | ||
|
|
c6470d8193 | ||
|
|
e5942c1436 | ||
|
|
dab82a2a7c | ||
|
|
7f864badc0 | ||
|
|
cc1e01d8b6 | ||
|
|
69c3dfdd54 | ||
|
|
241f1e603f | ||
|
|
4d9fdca053 | ||
|
|
b11900251f | ||
|
|
145b18ce9a | ||
|
|
e5d167149d | ||
|
|
ed71759fd0 | ||
|
|
d7ae13d479 | ||
|
|
1cd872a7d5 | ||
|
|
f6586db165 | ||
|
|
7c43c48fda | ||
|
|
069eea16d9 | ||
|
|
79181b97d4 | ||
|
|
46360e36d9 | ||
|
|
ef2b8416d9 | ||
|
|
9491f47035 | ||
|
|
2fc7e5c1b5 | ||
|
|
68dcb46205 | ||
|
|
8dce66d33d | ||
|
|
08c21bcb5d | ||
|
|
e675926a4f | ||
|
|
c66f4d1ae6 | ||
|
|
ad559492dc | ||
|
|
8d0cfa68b9 | ||
|
|
83eaaae005 | ||
|
|
a5638dbfba | ||
|
|
666754c665 | ||
|
|
4c896d6bd4 | ||
|
|
f2e9e4757f | ||
|
|
512c064cd9 | ||
|
|
7626fb6cbf | ||
|
|
6fdd122b11 | ||
|
|
264c9fe6aa | ||
|
|
76573c5239 | ||
|
|
14fdebc4ff | ||
|
|
325d0b64d5 | ||
|
|
6103a8453f | ||
|
|
47f0d80ee0 | ||
|
|
5d79566ab3 | ||
|
|
fda00aa774 | ||
|
|
9b1b674ebe | ||
|
|
00b54d4625 | ||
|
|
26d29f0c3d | ||
|
|
7b1e020fc5 | ||
|
|
3d9ebfd272 | ||
|
|
f01919b57a | ||
|
|
6cb5bbc660 | ||
|
|
f281cb4ea9 | ||
|
|
b176ab0556 | ||
|
|
1cbe4ff2ac | ||
|
|
7c2576e15d | ||
|
|
526c7b2186 | ||
|
|
2d0e415482 | ||
|
|
daa6dc0a3b | ||
|
|
6e5648ad42 | ||
|
|
e15a48d35a | ||
|
|
0fae52d7e3 | ||
|
|
50a639a62a | ||
|
|
d6adcab842 | ||
|
|
bf80b1d88d | ||
|
|
53fffc9fc4 | ||
|
|
b0e836466f | ||
|
|
e158936712 | ||
|
|
c8977ec6e9 | ||
|
|
934bc32acc | ||
|
|
64f2b48be0 | ||
|
|
756f4b586a | ||
|
|
56c4dca5ae | ||
|
|
da6ccfe18e | ||
|
|
27a61302b7 | ||
|
|
b4be953c55 | ||
|
|
3b179b6302 | ||
|
|
bf8f2fae2a | ||
|
|
0d7343f8dd | ||
|
|
fb8676eb1c | ||
|
|
ca5c639446 | ||
|
|
bd79dbfa2b | ||
|
|
c4765a41b9 | ||
|
|
be5acd6cb1 | ||
|
|
c3e7a7ef3f | ||
|
|
9e4d297ba7 | ||
|
|
373bc77a35 | ||
|
|
20d89a3a32 | ||
|
|
ee7c347935 | ||
|
|
9da31a0373 | ||
|
|
eb46065f4a | ||
|
|
b80083a5c1 | ||
|
|
449ff0e3fd | ||
|
|
0aa2fbddb1 | ||
|
|
c40983a6f6 | ||
|
|
bd0497b28b | ||
|
|
4d95207938 | ||
|
|
1e8a75fae4 | ||
|
|
380980e0d2 | ||
|
|
1fd8eb4d4f |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,2 +1 @@
|
||||
*.pnm -diff -text
|
||||
tests/ref/fate/sub-scc eol=crlf
|
||||
|
||||
64
.gitignore
vendored
64
.gitignore
vendored
@@ -18,6 +18,8 @@
|
||||
*.so.*
|
||||
*.swp
|
||||
*.ver
|
||||
*-example
|
||||
*-test
|
||||
*_g
|
||||
\#*
|
||||
.\#*
|
||||
@@ -30,6 +32,66 @@
|
||||
/config.*
|
||||
/coverage.info
|
||||
/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/
|
||||
/libavcodec/*_tablegen
|
||||
/libavcodec/*_tables.c
|
||||
/libavcodec/*_tables.h
|
||||
/libavutil/avconfig.h
|
||||
/libavutil/ffversion.h
|
||||
/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
|
||||
|
||||
@@ -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.
|
||||
423
Changelog
423
Changelog
@@ -1,263 +1,176 @@
|
||||
Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
version 3.0.4:
|
||||
- libopenjpegenc: fix out-of-bounds reads when filling the edges
|
||||
- libopenjpegenc: stop reusing image data buffer for openjpeg 2
|
||||
- configure: fix detection of libopenjpeg
|
||||
- cmdutils: fix typos
|
||||
- lavfi: fix typos
|
||||
- lavc: fix typos
|
||||
- tools: fix grammar error
|
||||
- ffmpeg: remove unused and errorneous AVFrame timestamp check
|
||||
- Support for MIPS cpu P6600
|
||||
- avutil/mips/generic_macros_msa: rename macro variable which causes segfault for mips r
|
||||
- avformat/avidec: Check nb_streams in read_gab2_sub()
|
||||
- avformat/avidec: Remove ancient assert
|
||||
- avformat/avidec: Fix memleak with dv in avi
|
||||
- lavc/movtextdec.c: Avoid infinite loop on invalid data.
|
||||
- avcodec/ansi: Check dimensions
|
||||
- avcodec/cavsdsp: use av_clip_uint8() for idct
|
||||
- avformat/movenc: Check packet in mov_write_single_packet() too
|
||||
- avformat/movenc: Factor check_pkt() out
|
||||
- avformat/utils: fix timebase error in avformat_seek_file()
|
||||
- avcodec/g726: Add missing ADDB output mask
|
||||
- avcodec/avpacket: clear side_data_elems
|
||||
- avformat/movenc: Check first DTS similar to dts difference
|
||||
- avcodec/ccaption_dec: Use simple array instead of AVBuffer
|
||||
- avformat/mov: Fix potential integer overflow in mov_read_keys
|
||||
- swscale/swscale_unscaled: Try to fix Rgb16ToPlanarRgb16Wrapper() with slices
|
||||
- swscale/swscale_unscaled: Fix packed_16bpc_bswap() with slices
|
||||
- lavf/utils: Avoid an overflow for huge negative durations.
|
||||
|
||||
version 3.3.1:
|
||||
- libswscale/tests/swscale: Fix uninitialized variables
|
||||
- avcodec/ffv1dec: Fix runtime error: signed integer overflow: 1550964438 + 1550964438 cannot be represented in type 'int'
|
||||
- avcodec/webp: Fix signedness in prefix_code check
|
||||
- avcodec/svq3: Fix runtime error: signed integer overflow: 169 * 12717677 cannot be represented in type 'int'
|
||||
- avcodec/mlpdec: Check that there is enough data for headers
|
||||
- avcodec/ac3dec: Keep track of band structure
|
||||
- avcodec/webp: Add missing input padding
|
||||
- avcodec/aacdec_fixed: Fix runtime error: left shift of negative value -1
|
||||
- avcodec/aacsbr_template: Do not change bs_num_env before its checked
|
||||
- avcodec/scpr: Fix multiple runtime error: index 256 out of bounds for type 'unsigned int [256]'
|
||||
- avcodec/mlp: Fix multiple runtime error: left shift of negative value -1
|
||||
- avcodec/xpmdec: Fix multiple pointer/memory issues
|
||||
- avcodec/vp8dsp: vp7_luma_dc_wht_c: Fix multiple runtime error: signed integer overflow: -1366381240 + -1262413604 cannot be represented in type 'int'
|
||||
- avcodec/avcodec: Limit the number of side data elements per packet
|
||||
- avcodec/texturedsp: Fix runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
|
||||
- avcodec/g723_1dec: Fix runtime error: left shift of negative value -1
|
||||
- avcodec/wmv2dsp: Fix runtime error: signed integer overflow: 181 * -17047030 cannot be represented in type 'int'
|
||||
- avcodec/diracdec: Fix Assertion frame->buf[0] failed at libavcodec/decode.c:610
|
||||
- avcodec/msmpeg4dec: Check for cbpy VLC errors
|
||||
- avcodec/cllc: Check num_bits
|
||||
- avcodec/cllc: Factor VLC_BITS/DEPTH out, do not use repeated literal numbers
|
||||
- avcodec/scpr: Check y in first line loop in decompress_i()
|
||||
- avcodec/dvbsubdec: Check entry_id
|
||||
- avcodec/aacdec_fixed: Fix multiple shift exponent 33 is too large for 32-bit type 'int'
|
||||
- avcodec/mpeg12dec: Fixes runtime error: division by zero
|
||||
- avcodec/pixlet: Fix runtime error: signed integer overflow: 436207616 * -5160230545260541 cannot be represented in type 'long'
|
||||
- avcodec/webp: Always set pix_fmt
|
||||
- avfilter/vf_uspp: Fix currently unused input frame dimensions
|
||||
- avcodec/truemotion1: Fix multiple runtime error: left shift of negative value -1
|
||||
- avcodec/eatqi: Fix runtime error: signed integer overflow: 4466147 * 1075 cannot be represented in type 'int'
|
||||
- avcodec/dss_sp: Fix runtime error: signed integer overflow: 2147481189 + 4096 cannot be represented in type 'int'
|
||||
- avformat/wavdec: Check chunk_size
|
||||
- avcodec/cavs: Check updated MV
|
||||
- avcodec/y41pdec: Fix width in input buffer size check
|
||||
- avcodec/svq3: Fix multiple runtime error: signed integer overflow: -237341 * 24552 cannot be represented in type 'int'
|
||||
- avcodec/texturedsp: Fix runtime error: left shift of 218 by 24 places cannot be represented in type 'int'
|
||||
- avcodec/lagarith: Check scale_factor
|
||||
- avcodec/lagarith: Fix runtime error: left shift of negative value -1
|
||||
- avcodec/takdec: Fix multiple runtime error: left shift of negative value -1
|
||||
- avcodec/indeo2: Check for invalid VLCs
|
||||
- avcodec/g723_1dec: Fix several integer related cases of undefined behaviour
|
||||
- avcodec/htmlsubtitles: Check for string truncation and return error
|
||||
- avcodec/bmvvideo: Fix runtime error: left shift of 137 by 24 places cannot be represented in type 'int'
|
||||
- avcodec/dss_sp: Fix multiple runtime error: signed integer overflow: -15699 * -164039 cannot be represented in type 'int'
|
||||
- avcodec/dvbsubdec: check region dimensions
|
||||
- avcodec/vp8dsp: Fixes: runtime error: signed integer overflow: 1330143360 - -1023040530 cannot be represented in type 'int'
|
||||
- avcodec/hqxdsp: Fix multiple runtime error: signed integer overflow: 248220 * 21407 cannot be represented in type 'int' in idct_col()
|
||||
- avcodec/cavsdec: Check sym_factor
|
||||
- avcodec/cdxl: Check format for BGR24
|
||||
- avcodec/ffv1dec: Fix copying planes of paletted formats
|
||||
- avcodec/wmv2dsp: Fix runtime error: signed integer overflow: 181 * -12156865 cannot be represented in type 'int'
|
||||
- avcodec/xwddec: Check bpp more completely
|
||||
- avcodec/aacdec_template: Do not decode 2nd PCE if it will lead to failure
|
||||
- avcodec/s302m: Fix left shift of 8 by 28 places cannot be represented in type 'int'
|
||||
- avcodec/eamad: Fix runtime error: signed integer overflow: 49674 * 49858 cannot be represented in type 'int'
|
||||
- avcodec/g726: Fix runtime error: left shift of negative value -2
|
||||
- avcodec/magicyuv: Check len to be supported
|
||||
- avcodec/ra144: Fix runtime error: left shift of negative value -798
|
||||
- avcodec/mss34dsp: Fix multiple signed integer overflow
|
||||
- avcodec/targa_y216dec: Fix width type
|
||||
- avcodec/texturedsp: Fix multiple runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
|
||||
- avcodec/ivi_dsp: Fix multiple left shift of negative value -2
|
||||
- avcodec/svq3: Fix multiple runtime error: signed integer overflow: 44161 * 61694 cannot be represented in type 'int'
|
||||
- avcodec/msmpeg4dec: Correct table depth
|
||||
- avcodec/dds: Fix runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
|
||||
- avcodec/cdxl: Check format parameter
|
||||
- avutil/softfloat: Fix overflow in av_div_sf()
|
||||
- avcodec/hq_hqa: Fix runtime error: left shift of negative value -207
|
||||
- avcodec/mss3: Change types in rac_get_model_sym() to match the types they are initialized from
|
||||
- avcodec/shorten: Check k in get_uint()
|
||||
- avcodec/webp: Fix null pointer dereference
|
||||
- avcodec/dfa: Fix signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
|
||||
- avcodec/g723_1: Fix multiple runtime error: left shift of negative value
|
||||
- avcodec/mimic: Fix runtime error: left shift of negative value -1
|
||||
- avcodec/clearvideo: Fix multiple runtime error: left shift of negative value -1024
|
||||
- avcodec/fic: Fix multiple left shift of negative value -15
|
||||
- avcodec/mlpdec: Fix runtime error: left shift of negative value -22
|
||||
- avcodec/snowdec: Check qbias
|
||||
- avutil/softfloat: Fix multiple runtime error: left shift of negative value -8
|
||||
- avcodec/aacsbr_template: Do not leave bs_num_env invalid
|
||||
- avcodec/mdec: Fix signed integer overflow: 28835400 * 83 cannot be represented in type 'int'
|
||||
- avcodec/dfa: Fix off by 1 error
|
||||
- avcodec/nellymoser: Fix multiple left shift of negative value -8591
|
||||
- avcodec/cdxl: Fix signed integer overflow: 14243456 * 164 cannot be represented in type 'int'
|
||||
- avcodec/g722: Fix multiple runtime error: left shift of negative value -1
|
||||
- avcodec/dss_sp: Fix multiple left shift of negative value -466
|
||||
- avcodec/wnv1: Fix runtime error: left shift of negative value -1
|
||||
- avcodec/tiertexseqv: set the fixed dimenasions, do not depend on the demuxer doing so
|
||||
- avcodec/mjpegdec: Fix runtime error: signed integer overflow: -24543 * 2031616 cannot be represented in type 'int'
|
||||
- avcodec/cavsdec: Fix undefined behavior from integer overflow
|
||||
- avcodec/dvdsubdec: Fix runtime error: left shift of 242 by 24 places cannot be represented in type 'int'
|
||||
- libavcodec/mpeg4videodec: Convert sprite_offset to 64bit
|
||||
- avcodec/pngdec: Use ff_set_dimensions()
|
||||
- avcodec/msvideo1: Check buffer size before re-getting the frame
|
||||
- avcodec/h264_cavlc: Fix undefined behavior on qscale overflow
|
||||
- avcodec/dcadsp: Fix runtime error: signed integer overflow
|
||||
- avcodec/svq3: Reject dx/dy beyond 16bit
|
||||
- avcodec/svq3: Increase offsets to prevent integer overflows
|
||||
- avcodec/indeo2: Check remaining bits in ir2_decode_plane()
|
||||
- avcodec/vp3: Check remaining bits in unpack_dct_coeffs()
|
||||
- doc/developer: Add terse documentation of assumed C implementation defined behavior
|
||||
- avcodec/bmp: Use ff_set_dimensions()
|
||||
- avcodec/mdec: Fix runtime error: left shift of negative value -127
|
||||
- avcodec/x86/vc1dsp_init: Fix build failure with --disable-optimizations and clang
|
||||
- libavcodec/exr : fix float to uint16 conversion for negative float value
|
||||
- avformat/webmdashenc: Validate the 'streams' adaptation sets parameter
|
||||
- avformat/webmdashenc: Require the 'adaptation_sets' option to be set
|
||||
- lavfi/avfiltergraph: only return EOF in avfilter_graph_request_oldest if all sinks EOFed
|
||||
- ffmpeg: check for unconnected outputs
|
||||
- avformat/utils: free AVStream.codec properly in free_stream()
|
||||
- avcodec/options: do a more thorough clean up in avcodec_copy_context()
|
||||
- avcodec/options: factorize avcodec_copy_context() cleanup code
|
||||
- ffmpeg: count packets when queued
|
||||
- avformat/concatdec: fix the h264 annexb extradata check
|
||||
- avcodec/dnxhd_parser: fix parsing interlaced video, simplify code
|
||||
- ffmpeg; check return code of avcodec_send_frame when flushing encoders
|
||||
- avcodec/g723_1dec: Fix LCG type
|
||||
- avcodec/hqxdsp: Fix runtime error: signed integer overflow: -196264 * 11585 cannot be represented in type 'int'
|
||||
- avcodec/ac3dec: Fix: runtime error: index -1 out of bounds for type 'INTFLOAT [2]'
|
||||
- avcodec/mpeg4videodec: Clear sprite wraping on unsupported cases in VOP decode
|
||||
- avcodec/pixlet: Fixes: runtime error: signed integer overflow: 9203954323419769657 + 29897660706736950 cannot be represented in type 'long'
|
||||
- avcodec/dds: Fix runtime error: left shift of 210 by 24 places cannot be represented in type 'int'
|
||||
- avcodec/rscc: Check pixel_size for overflow
|
||||
- avcodec/fmvc: Check nb_blocks
|
||||
- avcodec/cllc: Check prefix
|
||||
- avcodec/webp: Factor update_canvas_size() out
|
||||
- avcodec/webp: Update canvas size in vp8_lossy_decode_frame() as in vp8_lossless_decode_frame()
|
||||
- avcodec/snowdec: Check width
|
||||
- avcodec/flacdec: Return error code instead of 0 for failures
|
||||
- avcodec/opus_silk: Fix integer overflow and out of array read
|
||||
- avcodec/aacps: Fix undefined behavior
|
||||
- avcodec/pixlet: Fix shift exponent 4294967268 is too large for 32-bit type 'int'
|
||||
- doc/general: fix project name after 2b1a6b1ae
|
||||
version 3.0.3:
|
||||
- avformat/avidec: Fix infinite loop in avi_read_nikon()
|
||||
- avcodec/aacenc: Tighter input checks
|
||||
- avformat/wtvdec: Check pointer before use
|
||||
- libavcodec/wmalosslessdec: Check the remaining bits
|
||||
- avcodec/diracdec: Check numx/y
|
||||
- avcodec/cfhd: Increase minimum band dimension to 3
|
||||
- avcodec/indeo2: check ctab
|
||||
- avformat/swfdec: Fix inflate() error code check
|
||||
- avcodec/rawdec: Fix bits_per_coded_sample checks
|
||||
- lavc/mjpegdec: Do not skip reading quantization tables.
|
||||
- cmdutils: fix implicit declaration of SetDllDirectory function
|
||||
- cmdutils: check for SetDllDirectory() availability
|
||||
- avcodec/h264: Put context_count check back
|
||||
- cmdutils: remove the current working directory from the DLL search path on win32
|
||||
- avcodec/raw: Fix decoding of ilacetest.mov
|
||||
- avcodec/ffv1enc: Fix assertion failure with non zero bits per sample
|
||||
- avformat/oggdec: Fix integer overflow with invalid pts
|
||||
- ffplay: Fix invalid array index
|
||||
- avcodec/vp9_parser: Check the input frame sizes for being consistent
|
||||
- libavformat/rtpdec_asf: zero initialize the AVIOContext struct
|
||||
- libavutil/opt: Small bugfix in example.
|
||||
- libx264: Increase x264 opts character limit to 4096
|
||||
- avformat/mov: Check sample size
|
||||
- avformat/format: Fix registering a format more than once and related races
|
||||
- avformat/flacdec: Fix seeking close to EOF
|
||||
- avcodec/flac_parser: Raise threshold for detecting invalid data
|
||||
- avformat/flvdec: Accept last size if its off by 1
|
||||
- tests/api/api-codec-param-test: Do not directly access caps_internal
|
||||
- avcodec: Add avpriv_codec_get_cap_skip_frame_fill_param()
|
||||
- avfilter/vf_telecine: Make frame writable before writing into it
|
||||
- avformat/mpegts: adjust probe score for low check_count
|
||||
- avcodec/mpc8: Correct end truncation
|
||||
- avformat/mp3dec: Increase probe score slightly when the whole data from begin to end is mp3
|
||||
- avcodec/cfhd: Set dimensions unconditionally
|
||||
- avcodec/mpegvideo: Do not clear the parse context during init
|
||||
- avcodec/h264: Fix off by 1 context count
|
||||
- avcodec/alsdec: Check r to prevent out of array read
|
||||
- avcodec/alsdec: fix max bits in ltp prefix code
|
||||
- avcodec/utils: check skip_samples signedness
|
||||
- avformat/mpegts: Do not trust BSSD descriptor, it is sometimes not an S302M stream
|
||||
- avcodec/bmp_parser: Check fsize
|
||||
- avcodec/bmp_parser: reset state
|
||||
- avcodec/bmp_parser: Fix remaining size
|
||||
- avcodec/bmp_parser: Fix frame_start_found in cross frame cases
|
||||
- avfilter/af_amix: do not fail if there are no samples in output_frame()
|
||||
- avformat/allformats: Making av_register_all() thread-safe.
|
||||
- librtmp: Avoid an infiniloop setting connection arguments
|
||||
- avformat/oggparsevp8: fix pts calculation on pages ending with an invisible frame
|
||||
- Revert "configure: Enable GCC vectorization on ≥4.9 on x86"
|
||||
- avcodec/libopenjpegenc: Set numresolutions by default to a value that is not too large
|
||||
- ffplay: Fix usage of private lavfi API
|
||||
- tests/checkasm/checkasm: Disable checkasm_check_pixblockdsp for ppc64be
|
||||
- avcodec/mpegvideo: Deallocate last/next picture earlier
|
||||
- avcodec/bmp_parser: Fix state
|
||||
- avformat/oggparseopus: Fix Undefined behavior in oggparseopus.c and libavformat/utils.c
|
||||
- avformat/utils: avoid overflow in compute_chapters_end() with huge durations
|
||||
- avformat/utils: avoid overflow in update_stream_timings() with huge durations
|
||||
- doc/developer.texi: Add a code of conduct
|
||||
- ffserver: fixed deallocation bug in build_feed_streams
|
||||
- avcodec/diracdec: Fix potential integer overflow
|
||||
- avformat/avidec: Detect index with too short entries
|
||||
- avformat/utils: Check negative bps before shifting in ff_get_pcm_codec_id()
|
||||
- avformat/utils: Do not compute the bitrate from duration == 0
|
||||
- ffmpeg: Check that r_frame_rate is set before attempting to use it
|
||||
- swresample/resample: Fix division by 0 with tap_count=1
|
||||
- swresample/rematrix: Use clipping s16 rematrixing if overflows are possible
|
||||
- swresample/rematrix: Use error diffusion to avoid error in the DC component of the matrix
|
||||
- hevc: Fix memory leak related to a53_caption data
|
||||
- libavformat/oggdec: Free stream private when header parsing fails.
|
||||
- avformat/utils: Check bps before using it in a shift in ff_get_pcm_codec_id()
|
||||
- avformat/oggparseopus: Check that granule pos is within the supported range
|
||||
- avcodec/mjpegdec: Do not try to detect last scan but apply idct after all scans for progressive jpeg
|
||||
- avformat/options_table: Add missing identifier for very strict compliance
|
||||
- avformat/ffmdec: Check pix_fmt
|
||||
- doc/general: update supported DCA extensions
|
||||
- avcodec/rscc: check input buffer size for deflate mode
|
||||
- avcodec/dca: fix sync word search error condition
|
||||
- lavf/mpegts: Return small probe score for very short transport streams.
|
||||
|
||||
|
||||
version 3.3:
|
||||
- CrystalHD decoder moved to new decode API
|
||||
- add internal ebur128 library, remove external libebur128 dependency
|
||||
- Pro-MPEG CoP #3-R2 FEC protocol
|
||||
- premultiply video filter
|
||||
- Support for spherical videos
|
||||
- configure now fails if autodetect-libraries are requested but not found
|
||||
- PSD Decoder
|
||||
- 16.8 floating point pcm decoder
|
||||
- 24.0 floating point pcm decoder
|
||||
- Apple Pixlet decoder
|
||||
- QDMC audio decoder
|
||||
- NewTek SpeedHQ decoder
|
||||
- MIDI Sample Dump Standard demuxer
|
||||
- readeia608 filter
|
||||
- Sample Dump eXchange demuxer
|
||||
- abitscope multimedia filter
|
||||
- Scenarist Closed Captions demuxer and muxer
|
||||
- threshold filter
|
||||
- midequalizer filter
|
||||
- Optimal Huffman tables for (M)JPEG encoding
|
||||
- VAAPI-accelerated MPEG-2 and VP8 encoding
|
||||
- FM Screen Capture Codec decoder
|
||||
- native Opus encoder
|
||||
- ScreenPressor decoder
|
||||
- incomplete ClearVideo decoder
|
||||
- Intel QSV video scaling and deinterlacing filters
|
||||
- Support MOV with multiple sample description tables
|
||||
- XPM decoder
|
||||
- Removed the legacy X11 screen grabber, use XCB instead
|
||||
- MPEG-7 Video Signature filter
|
||||
- Removed asyncts filter (use af_aresample instead)
|
||||
- Intel QSV-accelerated VP8 video decoding
|
||||
version 3.0.2:
|
||||
- avcodec/ttaenc: Reallocate packet if its too small
|
||||
- configure: build fix for P5600 with mips code restructuring
|
||||
- mips: add support for R6
|
||||
- pgssubdec: fix subpicture output colorspace and range
|
||||
- avcodec/ac3dec: Reset SPX when switching from EAC3 to AC3
|
||||
- avfilter/vf_drawtext: Check return code of load_glyph()
|
||||
- avformat/mux: Check that deinit is set before calling it
|
||||
- avcodec/takdec: add code that got somehow lost in process of REing
|
||||
- avcodec/apedec: fix decoding of stereo files with one channel full of silence
|
||||
- avcodec/avpacket: Fix off by 5 error
|
||||
- avcodec/h264: Fix for H.264 configuration parsing
|
||||
- avcodec/bmp_parser: Ensure remaining_size is not too small in startcode packet crossing corner case
|
||||
- avcodec/pngdec: Fix alpha detection with skip_frame
|
||||
- Changelog: Make formating consistent
|
||||
- avfilter/src_movie: fix how we check for overflows with seek_point
|
||||
- avcodec/j2kenc: Add attribution to OpenJPEG project:
|
||||
|
||||
|
||||
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.1:
|
||||
- avcodec/libutvideodec: copy frame so it has reference counters when refcounted_frames is set
|
||||
- avformat/rtpdec_jpeg: fix low contrast image on low quality setting
|
||||
- avformat/mpegtsenc: Fix used service
|
||||
- avformat/mpegtsenc: Keep track of the program for each service
|
||||
- avformat/file: Add crypto to default whitelist
|
||||
- avcodec/mjpegenc_common: Store approximate aspect if exact cannot be stored
|
||||
- lavc/hevc: Allow arbitrary garbage in bytestream as long as at least one NAL unit is found.
|
||||
- avcodec/resample: Remove disabled and faulty code
|
||||
- indeo2: Fix banding artefacts
|
||||
- indeo2data: K&R formatting cosmetics
|
||||
- avformat/hlsenc: Fix passing options, regression since bc9a5965c815cf7fd998d8ce14a18b8e861dd9ce
|
||||
- avutil/random_seed: Add the runtime in cycles of the main loop to the entropy pool
|
||||
- avutil/channel_layout: AV_CH_LAYOUT_6POINT1_BACK not reachable in parsing
|
||||
- avformat/concatdec: set safe mode to enabled instead of auto
|
||||
- avformat/utils: fix dts from pts code in compute_pkt_fields() during ascending delay
|
||||
- avformat/rtpenc: Fix integer overflow in NTP_TO_RTP_FORMAT
|
||||
- avcodec/dca: clear X96 channels if nothing was decoded
|
||||
- fate/aac: Increase fuzz from of fate-aac-pns-encode from 72 to 74 for Loongson
|
||||
- avformat/cache: Fix memleak of tree entries
|
||||
- lavf/mov: downgrade sidx errors to non-fatal warnings; fixes trac #5216
|
||||
- lavf/mov: fix sidx with edit lists
|
||||
- avcodec/mjpegdec: Fix decoding slightly odd progressive jpeg
|
||||
- swscale/utils: Fix chrSrcHSubSample for GBRAP16
|
||||
- swscale/input: Fix GBRAP16 input
|
||||
- avutil/pixdesc: Make get_color_type() aware of CIE XYZ formats
|
||||
- avcodec/h264: Execute error concealment before marking the frame as done.
|
||||
- swscale/x86/output: Fix yuv2planeX_16* with unaligned destination
|
||||
- swscale/x86/output: Move code into yuv2planeX_mainloop
|
||||
- MAINTAINERS: add myself as an OS/2 maintainer
|
||||
- libwebpenc_animencoder: print library messages in verbose log levels
|
||||
- libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct
|
||||
- configure: check for SEC_I_CONTEXT_EXPIRED before enabling SChannel
|
||||
- lavf/http: Add httpproxy to the default protocol whitelist.
|
||||
- doc/utils: fix typo for min() description
|
||||
- ffserver&ffm: Fixed issues preventing ffserver write_index and files_size from being set correctly which was breaking ffserver streaming.
|
||||
- postproc: fix unaligned access
|
||||
- vc2enc: fix use of uninitialized variables in the rate control system, correctly zero out coefficient array padding
|
||||
- aacenc: optimize encoding speed
|
||||
- avcodec/diracdec: check bitstream size related fields for overflows
|
||||
- avcodec/h264_slice: Check PPS more extensively when its not copied
|
||||
|
||||
|
||||
version 3.0:
|
||||
@@ -1130,8 +1043,8 @@ version 0.8:
|
||||
- showinfo filter added
|
||||
- SMPTE 302M AES3 audio decoder
|
||||
- Apple Core Audio Format muxer
|
||||
- 9 bits and 10 bits per sample support in the H.264 decoder
|
||||
- 9 bits and 10 bits FFV1 encoding / decoding
|
||||
- 9bit and 10bit per sample support in the H.264 decoder
|
||||
- 9bit and 10bit FFV1 encoding / decoding
|
||||
- split filter added
|
||||
- select filter added
|
||||
- sdl output device added
|
||||
@@ -1424,7 +1337,7 @@ version 0.4.9-pre1:
|
||||
- rate distorted optimal lambda->qp support
|
||||
- AAC encoding with libfaac
|
||||
- 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
|
||||
- XA and ADX ADPCM codecs
|
||||
- export MPEG-2 active display area / pan scan
|
||||
|
||||
62
LICENSE.md
62
LICENSE.md
@@ -1,4 +1,4 @@
|
||||
# License
|
||||
#FFmpeg:
|
||||
|
||||
Most files in FFmpeg are under the GNU Lesser General Public License version 2.1
|
||||
or later (LGPL v2.1+). Read the file `COPYING.LGPLv2.1` for details. Some other
|
||||
@@ -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:
|
||||
|
||||
- libpostproc
|
||||
- optional x86 optimization in the files
|
||||
- `libavcodec/x86/flac_dsp_gpl.asm`
|
||||
- `libavcodec/x86/idct_mmx.c`
|
||||
- `libavfilter/x86/vf_removegrain.asm`
|
||||
- the following building and testing tools
|
||||
- `compat/solaris/make_sunver.pl`
|
||||
- `doc/t2h.pm`
|
||||
- `doc/texi2pod.pl`
|
||||
- `libswresample/swresample-test.c`
|
||||
- `tests/checkasm/*`
|
||||
- `tests/tiny_ssim.c`
|
||||
- optional x86 optimizations in the files
|
||||
- `libavcodec/x86/flac_dsp_gpl.asm`
|
||||
- `libavcodec/x86/idct_mmx.c`
|
||||
- `libavfilter/x86/vf_removegrain.asm`
|
||||
- libutvideo encoding/decoding wrappers in
|
||||
`libavcodec/libutvideo*.cpp`
|
||||
- the X11 grabber in `libavdevice/x11grab.c`
|
||||
- the swresample test app in
|
||||
`libswresample/swresample-test.c`
|
||||
- the `texi2pod.pl` tool
|
||||
- the following filters in libavfilter:
|
||||
- `f_ebur128.c`
|
||||
- `vf_blackframe.c`
|
||||
- `vf_boxblur.c`
|
||||
- `vf_colormatrix.c`
|
||||
@@ -47,9 +47,9 @@ Specifically, the GPL parts of FFmpeg are:
|
||||
- `vf_pp.c`
|
||||
- `vf_pp7.c`
|
||||
- `vf_pullup.c`
|
||||
- `vf_repeatfields.c`
|
||||
- `vf_sab.c`
|
||||
- `vf_smartblur.c`
|
||||
- `vf_repeatfields.c`
|
||||
- `vf_spp.c`
|
||||
- `vf_stereo3d.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.
|
||||
|
||||
|
||||
## External libraries
|
||||
external libraries
|
||||
==================
|
||||
|
||||
FFmpeg can be combined with a number of external libraries, which sometimes
|
||||
affect the licensing of binaries resulting from the combination.
|
||||
|
||||
### Compatible libraries
|
||||
compatible libraries
|
||||
--------------------
|
||||
|
||||
The following libraries are under GPL:
|
||||
- frei0r
|
||||
- libcdio
|
||||
- librubberband
|
||||
- libutvideo
|
||||
- libvidstab
|
||||
- libx264
|
||||
- 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
|
||||
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
|
||||
compatible with the GPL and/or the LGPL. If you wish to enable these
|
||||
libraries, even in circumstances that their license may be incompatible, pass
|
||||
`--enable-nonfree` to configure. But note that if you enable any of these
|
||||
libraries the resulting binary will be under a complex license mix that is
|
||||
more restrictive than the LGPL and that may result in additional obligations.
|
||||
It is possible that these restrictions cause the resulting binary to be
|
||||
unredistributable.
|
||||
|
||||
The Fraunhofer FDK AAC and OpenSSL libraries are under licenses which are
|
||||
incompatible with the GPLv2 and v3. To the best of our knowledge, they are
|
||||
compatible with the LGPL.
|
||||
|
||||
The NVENC library, while its header file is licensed under the compatible MIT
|
||||
license, requires a proprietary binary blob at run time, and is deemed to be
|
||||
incompatible with the GPL. We are not certain if it is compatible with the
|
||||
LGPL, but we require `--enable-nonfree` even with LGPL configurations in case
|
||||
it is not.
|
||||
The Fraunhofer AAC library and FAAC are under licenses which
|
||||
are incompatible with the GPLv2 and v3. We do not know for certain if their
|
||||
licenses are compatible with the LGPL.
|
||||
If you wish to enable these libraries, pass `--enable-nonfree` to configure.
|
||||
But note that if you enable any of these libraries the resulting binary will
|
||||
be under a complex license mix that is more restrictive than the LGPL and that
|
||||
may result in additional obligations. It is possible that these
|
||||
restrictions cause the resulting binary to be unredistributeable.
|
||||
|
||||
163
MAINTAINERS
163
MAINTAINERS
@@ -43,11 +43,11 @@ Miscellaneous Areas
|
||||
===================
|
||||
|
||||
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
|
||||
metadata subsystem Aurelien Jacobs
|
||||
release management Michael Niedermayer
|
||||
API tests Ludmila Glinskih
|
||||
|
||||
|
||||
Communication
|
||||
@@ -60,7 +60,6 @@ mailing lists Baptiste Coudurier, Lou Logan
|
||||
Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser
|
||||
Twitter Lou Logan, Reynaldo H. Verdejo Pinochet
|
||||
Launchpad Timothy Gu
|
||||
ffmpeg-security Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, Rodger Combs, wm4
|
||||
|
||||
|
||||
libavutil
|
||||
@@ -80,7 +79,6 @@ Other:
|
||||
eval.c, eval.h Michael Niedermayer
|
||||
float_dsp Loren Merritt
|
||||
hash Reimar Doeffinger
|
||||
hwcontext_cuda* Timo Rothenpieler
|
||||
intfloat* Michael Niedermayer
|
||||
integer.c, integer.h Michael Niedermayer
|
||||
lzo Reimar Doeffinger
|
||||
@@ -91,6 +89,7 @@ Other:
|
||||
rational.c, rational.h Michael Niedermayer
|
||||
rc4 Reimar Doeffinger
|
||||
ripemd.c, ripemd.h James Almer
|
||||
timecode Clément Bœsch
|
||||
|
||||
|
||||
libavcodec
|
||||
@@ -116,10 +115,10 @@ Generic Parts:
|
||||
lzw.* Michael Niedermayer
|
||||
floating point AAN DCT:
|
||||
faandct.c, faandct.h Michael Niedermayer
|
||||
Non-power-of-two MDCT:
|
||||
mdct15.c, mdct15.h Rostislav Pehlivanov
|
||||
Golomb coding:
|
||||
golomb.c, golomb.h Michael Niedermayer
|
||||
LPC:
|
||||
lpc.c, lpc.h Justin Ruggles
|
||||
motion estimation:
|
||||
motion* Michael Niedermayer
|
||||
rate control:
|
||||
@@ -140,37 +139,47 @@ Codecs:
|
||||
8bps.c Roberto Togni
|
||||
8svx.c Jaikrishnan Menon
|
||||
aacenc*, aaccoder.c Rostislav Pehlivanov
|
||||
aasc.c Kostya Shishkov
|
||||
ac3* Justin Ruggles
|
||||
alacenc.c Jaikrishnan Menon
|
||||
alsdec.c Thilo Borgmann, Umair Khan
|
||||
alsdec.c Thilo Borgmann
|
||||
apedec.c Kostya Shishkov
|
||||
ass* Aurelien Jacobs
|
||||
asv* Michael Niedermayer
|
||||
atrac3* Benjamin Larsson
|
||||
atrac3plus* Maxim Poliakovski
|
||||
audiotoolbox* Rodger Combs
|
||||
bgmc.c, bgmc.h Thilo Borgmann
|
||||
bink.c Kostya Shishkov
|
||||
binkaudio.c Peter Ross
|
||||
bmp.c Mans Rullgard, Kostya Shishkov
|
||||
cavs* Stefan Gehrer
|
||||
cdxl.c Paul B Mahol
|
||||
celp_filters.* Vitor Sessak
|
||||
cinepak.c Roberto Togni
|
||||
cinepakenc.c Rl / Aetey G.T. AB
|
||||
ccaption_dec.c Anshul Maheshwari, Aman Gupta
|
||||
ccaption_dec.c Anshul Maheshwari
|
||||
cljr Alex Beregszaszi
|
||||
cllc.c Derek Buitenhuis
|
||||
cook.c, cookdata.h Benjamin Larsson
|
||||
cpia.c Stephan Hilb
|
||||
crystalhd.c Philip Langdale
|
||||
cscd.c Reimar Doeffinger
|
||||
cuvid.c Timo Rothenpieler
|
||||
dca.c Kostya Shishkov, Benjamin Larsson
|
||||
dirac* Rostislav Pehlivanov
|
||||
dnxhd* Baptiste Coudurier
|
||||
dpcm.c Mike Melanson
|
||||
dss_sp.c Oleksij Rempel
|
||||
dv.c Roman Shaposhnik
|
||||
dvbsubdec.c Anshul Maheshwari
|
||||
dxa.c Kostya Shishkov
|
||||
eacmv*, eaidct*, eat* Peter Ross
|
||||
evrc* Paul B Mahol
|
||||
exif.c, exif.h Thilo Borgmann
|
||||
ffv1* Michael Niedermayer
|
||||
ffwavesynth.c Nicolas George
|
||||
fifo.c Jan Sebechlebsky
|
||||
fic.c Derek Buitenhuis
|
||||
flac* Justin Ruggles
|
||||
flashsv* Benjamin Larsson
|
||||
flicvideo.c Mike Melanson
|
||||
g722.c Martin Storsjo
|
||||
g726.c Roman Shaposhnik
|
||||
@@ -179,12 +188,18 @@ Codecs:
|
||||
h263* Michael Niedermayer
|
||||
h264* Loren Merritt, Michael Niedermayer
|
||||
hap* Tom Butterworth
|
||||
huffyuv* Michael Niedermayer
|
||||
huffyuv* Michael Niedermayer, Christophe Gisquet
|
||||
idcinvideo.c Mike Melanson
|
||||
imc* Benjamin Larsson
|
||||
indeo2* Kostya Shishkov
|
||||
indeo5* Kostya Shishkov
|
||||
interplayvideo.c Mike Melanson
|
||||
jni*, ffjni* Matthieu Bouron
|
||||
ivi* Kostya Shishkov
|
||||
jacosub* Clément Bœsch
|
||||
jpeg2000* Nicolas Bertrand
|
||||
jpeg_ls.c Kostya Shishkov
|
||||
jvdec.c Peter Ross
|
||||
kmvc.c Kostya Shishkov
|
||||
lcl*.c Roberto Togni, Reimar Doeffinger
|
||||
libcelt_dec.c Nicolas George
|
||||
libdirac* David Conrad
|
||||
@@ -193,33 +208,41 @@ Codecs:
|
||||
libopenjpeg.c Jaikrishnan Menon
|
||||
libopenjpegenc.c Michael Bradshaw
|
||||
libschroedinger* David Conrad
|
||||
libspeexdec.c Justin Ruggles
|
||||
libtheoraenc.c David Conrad
|
||||
libutvideo* Carl Eugen Hoyos
|
||||
libvorbis.c David Conrad
|
||||
libvpx* James Zern
|
||||
libx264.c Mans Rullgard, Jason Garrett-Glaser
|
||||
libx265.c Derek Buitenhuis
|
||||
libxavs.c Stefan Gehrer
|
||||
libzvbi-teletextdec.c Marton Balint
|
||||
loco.c Kostya Shishkov
|
||||
lzo.h, lzo.c Reimar Doeffinger
|
||||
mdec.c Michael Niedermayer
|
||||
mimic.c Ramiro Polla
|
||||
mjpeg*.c Michael Niedermayer
|
||||
mlp* Ramiro Polla, Jai Luthra
|
||||
mlp* Ramiro Polla
|
||||
mmvideo.c Peter Ross
|
||||
mpc* Kostya Shishkov
|
||||
mpeg12.c, mpeg12data.h Michael Niedermayer
|
||||
mpegvideo.c, mpegvideo.h Michael Niedermayer
|
||||
mqc* Nicolas Bertrand
|
||||
msmpeg4.c, msmpeg4data.h Michael Niedermayer
|
||||
msrle.c Mike Melanson
|
||||
msvideo1.c Mike Melanson
|
||||
nellymoserdec.c Benjamin Larsson
|
||||
nuv.c Reimar Doeffinger
|
||||
nvenc* Timo Rothenpieler
|
||||
opus* Rostislav Pehlivanov
|
||||
nvenc.c Timo Rothenpieler
|
||||
paf.* Paul B Mahol
|
||||
pcx.c Ivo van Poorten
|
||||
pgssubdec.c Reimar Doeffinger
|
||||
ptx.c Ivo van Poorten
|
||||
qcelp* Reynaldo H. Verdejo Pinochet
|
||||
qdm2.c, qdm2data.h Roberto Togni
|
||||
qsv* Mark Thompson
|
||||
qdm2.c, qdm2data.h Roberto Togni, Benjamin Larsson
|
||||
qdrw.c Kostya Shishkov
|
||||
qpeg.c Kostya Shishkov
|
||||
qsv* Ivan Uskov
|
||||
qtrle.c Mike Melanson
|
||||
ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni
|
||||
resample2.c Michael Niedermayer
|
||||
@@ -227,7 +250,10 @@ Codecs:
|
||||
rpza.c Roberto Togni
|
||||
rtjpeg.c, rtjpeg.h Reimar Doeffinger
|
||||
rv10.c Michael Niedermayer
|
||||
rv3* Kostya Shishkov
|
||||
rv4* Kostya Shishkov, Christophe Gisquet
|
||||
s3tc* Ivo van Poorten
|
||||
smacker.c Kostya Shishkov
|
||||
smc.c Mike Melanson
|
||||
smvjpegdec.c Ash Hughes
|
||||
snow* Michael Niedermayer, Loren Merritt
|
||||
@@ -236,41 +262,54 @@ Codecs:
|
||||
sunrast.c Ivo van Poorten
|
||||
svq3.c Michael Niedermayer
|
||||
tak* Paul B Mahol
|
||||
targa.c Kostya Shishkov
|
||||
tiff.c Kostya Shishkov
|
||||
truemotion1* Mike Melanson
|
||||
truemotion2* Kostya Shishkov
|
||||
truespeech.c Kostya Shishkov
|
||||
tscc.c Kostya Shishkov
|
||||
tta.c Alex Beregszaszi, Jaikrishnan Menon
|
||||
ttaenc.c Paul B Mahol
|
||||
txd.c Ivo van Poorten
|
||||
ulti* Kostya Shishkov
|
||||
v410*.c Derek Buitenhuis
|
||||
vb.c Kostya Shishkov
|
||||
vble.c Derek Buitenhuis
|
||||
vc1* Kostya Shishkov, Christophe Gisquet
|
||||
vc2* Rostislav Pehlivanov
|
||||
vcr1.c Michael Niedermayer
|
||||
vda_h264_dec.c Xidorn Quan
|
||||
videotoolboxenc.c Rick Kern
|
||||
vima.c Paul B Mahol
|
||||
vmnc.c Kostya Shishkov
|
||||
vorbisdec.c Denes Balatoni, David Conrad
|
||||
vorbisenc.c Oded Shimon
|
||||
vp3* Mike Melanson
|
||||
vp5 Aurelien Jacobs
|
||||
vp6 Aurelien Jacobs
|
||||
vp8 David Conrad, Ronald Bultje
|
||||
vp9 Ronald Bultje
|
||||
vp8 David Conrad, Jason Garrett-Glaser, Ronald Bultje
|
||||
vp9 Ronald Bultje, Clément Bœsch
|
||||
vqavideo.c Mike Melanson
|
||||
wavpack.c Kostya Shishkov
|
||||
wmaprodec.c Sascha Sommer
|
||||
wmavoice.c Ronald S. Bultje
|
||||
wmv2.c Michael Niedermayer
|
||||
wnv1.c Kostya Shishkov
|
||||
xan.c Mike Melanson
|
||||
xbm* Paul B Mahol
|
||||
xface Stefano Sabatini
|
||||
xl.c Kostya Shishkov
|
||||
xvmc.c Ivan Kalvachev
|
||||
xwd* Paul B Mahol
|
||||
zerocodec.c Derek Buitenhuis
|
||||
zmbv* Kostya Shishkov
|
||||
|
||||
Hardware acceleration:
|
||||
crystalhd.c Philip Langdale
|
||||
dxva2* Hendrik Leppkes, Laurent Aimar, Steve Lhomme
|
||||
d3d11va* Steve Lhomme
|
||||
mediacodec* Matthieu Bouron
|
||||
dxva2* Hendrik Leppkes, Laurent Aimar
|
||||
vaapi* Gwenole Beauchesne
|
||||
vaapi_encode* Mark Thompson
|
||||
vda* Sebastien Zwickert
|
||||
vdpau* Philip Langdale, Carl Eugen Hoyos
|
||||
videotoolbox* Rick Kern
|
||||
videotoolbox* Sebastien Zwickert
|
||||
|
||||
|
||||
libavdevice
|
||||
@@ -291,7 +330,6 @@ libavdevice
|
||||
pulse_audio_enc.c Lukasz Marek
|
||||
qtkit.m Thilo Borgmann
|
||||
sdl Stefano Sabatini
|
||||
sdl2.c Josh de Kock
|
||||
v4l2.c Giorgio Vazzana
|
||||
vfwcap.c Ramiro Polla
|
||||
xv.c Lukasz Marek
|
||||
@@ -302,8 +340,6 @@ libavfilter
|
||||
Generic parts:
|
||||
graphdump.c Nicolas George
|
||||
|
||||
motion_estimation.c Davinder Singh
|
||||
|
||||
Filters:
|
||||
f_drawgraph.c Paul B Mahol
|
||||
af_adelay.c Paul B Mahol
|
||||
@@ -317,10 +353,7 @@ Filters:
|
||||
af_biquads.c Paul B Mahol
|
||||
af_chorus.c Paul B Mahol
|
||||
af_compand.c Paul B Mahol
|
||||
af_firequalizer.c Muhammad Faiz
|
||||
af_hdcd.c Burt P.
|
||||
af_ladspa.c Paul B Mahol
|
||||
af_loudnorm.c Kyle Swanson
|
||||
af_pan.c Nicolas George
|
||||
af_sidechaincompress.c Paul B Mahol
|
||||
af_silenceremove.c Paul B Mahol
|
||||
@@ -333,7 +366,6 @@ Filters:
|
||||
vf_colorbalance.c Paul B Mahol
|
||||
vf_colorkey.c Timo Rothenpieler
|
||||
vf_colorlevels.c Paul B Mahol
|
||||
vf_coreimage.m Thilo Borgmann
|
||||
vf_deband.c Paul B Mahol
|
||||
vf_dejudder.c Nicholas Robbins
|
||||
vf_delogo.c Jean Delvare (CC <jdelvare@suse.com>)
|
||||
@@ -345,12 +377,9 @@ Filters:
|
||||
vf_il.c Paul B Mahol
|
||||
vf_lenscorrection.c Daniel Oberhoff
|
||||
vf_mergeplanes.c Paul B Mahol
|
||||
vf_mestimate.c Davinder Singh
|
||||
vf_minterpolate.c Davinder Singh
|
||||
vf_neighbor.c Paul B Mahol
|
||||
vf_psnr.c Paul B Mahol
|
||||
vf_random.c Paul B Mahol
|
||||
vf_readvitc.c Tobias Rapp (CC t.rapp at noa-archive dot com)
|
||||
vf_scale.c Michael Niedermayer
|
||||
vf_separatefields.c Paul B Mahol
|
||||
vf_ssim.c Paul B Mahol
|
||||
@@ -370,7 +399,6 @@ Generic parts:
|
||||
libavformat/avformat.h Michael Niedermayer
|
||||
Utility Code:
|
||||
libavformat/utils.c Michael Niedermayer
|
||||
Text Subtitles Clément Bœsch
|
||||
|
||||
|
||||
Muxers/Demuxers:
|
||||
@@ -380,15 +408,15 @@ Muxers/Demuxers:
|
||||
afc.c Paul B Mahol
|
||||
aiffdec.c Baptiste Coudurier, Matthieu Bouron
|
||||
aiffenc.c Baptiste Coudurier, Matthieu Bouron
|
||||
ape.c Kostya Shishkov
|
||||
apngdec.c Benoit Fouet
|
||||
ass* Aurelien Jacobs
|
||||
astdec.c Paul B Mahol
|
||||
astenc.c James Almer
|
||||
avi* Michael Niedermayer
|
||||
avisynth.c Stephen Hutchinson
|
||||
avisynth.c AvxSynth Team (avxsynth.testing at gmail dot com)
|
||||
avr.c Paul B Mahol
|
||||
bink.c Peter Ross
|
||||
boadec.c Michael Niedermayer
|
||||
brstm.c Paul B Mahol
|
||||
caf* Peter Ross
|
||||
cdxl.c Paul B Mahol
|
||||
@@ -397,16 +425,17 @@ Muxers/Demuxers:
|
||||
dss.c Oleksij Rempel
|
||||
dtshddec.c Paul B Mahol
|
||||
dv.c Roman Shaposhnik
|
||||
dxa.c Kostya Shishkov
|
||||
electronicarts.c Peter Ross
|
||||
epafdec.c Paul B Mahol
|
||||
ffm* Baptiste Coudurier
|
||||
flac* Justin Ruggles
|
||||
flic.c Mike Melanson
|
||||
flvdec.c Michael Niedermayer
|
||||
flvenc.c Michael Niedermayer, Steven Liu
|
||||
flvdec.c, flvenc.c Michael Niedermayer
|
||||
gxf.c Reimar Doeffinger
|
||||
gxfenc.c Baptiste Coudurier
|
||||
hls.c Anssi Hannula
|
||||
hls encryption (hlsenc.c) Christian Suloway, Steven Liu
|
||||
hls encryption (hlsenc.c) Christian Suloway
|
||||
idcin.c Mike Melanson
|
||||
idroqdec.c Mike Melanson
|
||||
iff.c Jaikrishnan Menon
|
||||
@@ -414,10 +443,10 @@ Muxers/Demuxers:
|
||||
ipmovie.c Mike Melanson
|
||||
ircam* Paul B Mahol
|
||||
iss.c Stefan Gehrer
|
||||
jacosub* Clément Bœsch
|
||||
jvdec.c Peter Ross
|
||||
libmodplug.c Clément Bœsch
|
||||
libnut.c Oded Shimon
|
||||
libopenmpt.c Josh de Kock
|
||||
lmlm4.c Ivo van Poorten
|
||||
lvfdec.c Paul B Mahol
|
||||
lxfdec.c Tomas Härdin
|
||||
@@ -432,6 +461,7 @@ Muxers/Demuxers:
|
||||
mov.c Baptiste Coudurier
|
||||
movenc.c Baptiste Coudurier, Matthieu Bouron
|
||||
movenccenc.c Eran Kornblau
|
||||
mpc.c Kostya Shishkov
|
||||
mpeg.c Michael Niedermayer
|
||||
mpegenc.c Michael Niedermayer
|
||||
mpegts.c Marton Balint
|
||||
@@ -457,7 +487,8 @@ Muxers/Demuxers:
|
||||
raw.c Michael Niedermayer
|
||||
rdt.c Ronald S. Bultje
|
||||
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
|
||||
rtpdec_ac3.* Gilles Chanteperdrix
|
||||
rtpdec_dv.* Thomas Volkert
|
||||
@@ -465,13 +496,15 @@ Muxers/Demuxers:
|
||||
rtpdec_hevc.*, rtpenc_hevc.* Thomas Volkert
|
||||
rtpdec_mpa_robust.* Gilles Chanteperdrix
|
||||
rtpdec_asf.* Ronald S. Bultje
|
||||
rtpdec_vc2hq.*, rtpenc_vc2hq.* Thomas Volkert
|
||||
rtpdec_vp9.c Thomas Volkert
|
||||
rtpenc_mpv.*, rtpenc_aac.* Martin Storsjo
|
||||
rtsp.c Luca Barbato
|
||||
sbgdec.c Nicolas George
|
||||
sdp.c Martin Storsjo
|
||||
segafilm.c Mike Melanson
|
||||
segment.c Stefano Sabatini
|
||||
siff.c Kostya Shishkov
|
||||
smacker.c Kostya Shishkov
|
||||
smjpeg* Paul B Mahol
|
||||
spdif* Anssi Hannula
|
||||
srtdec.c Aurelien Jacobs
|
||||
@@ -486,6 +519,7 @@ Muxers/Demuxers:
|
||||
webvtt* Matthew J Heaney
|
||||
westwood.c Mike Melanson
|
||||
wtv.c Peter Ross
|
||||
wv.c Kostya Shishkov
|
||||
wvenc.c Paul B Mahol
|
||||
|
||||
Protocols:
|
||||
@@ -516,10 +550,13 @@ Resamplers:
|
||||
Operating systems / CPU architectures
|
||||
=====================================
|
||||
|
||||
Alpha Falk Hueffner
|
||||
MIPS Nedeljko Babic
|
||||
Alpha Mans Rullgard, Falk Hueffner
|
||||
ARM Mans Rullgard
|
||||
AVR32 Mans Rullgard
|
||||
MIPS Mans Rullgard, Nedeljko Babic
|
||||
Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier
|
||||
Amiga / PowerPC Colin Ward
|
||||
Linux / PowerPC Luca Barbato
|
||||
Windows MinGW Alex Beregszaszi, Ramiro Polla
|
||||
Windows Cygwin Victor Paesa
|
||||
Windows MSVC Matthew Oliver, Hendrik Leppkes
|
||||
@@ -529,32 +566,6 @@ Sparc Roman Shaposhnik
|
||||
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
|
||||
Joakim Plate
|
||||
Kieran Kunhya
|
||||
Kirill Gavrilov
|
||||
Martin Storsjö
|
||||
Panagiotis Issaris
|
||||
Pedro Arthur
|
||||
Sebastien Zwickert
|
||||
Vittorio Giovara
|
||||
wm4
|
||||
(this list is incomplete)
|
||||
|
||||
|
||||
Releases
|
||||
========
|
||||
|
||||
@@ -562,6 +573,7 @@ Releases
|
||||
2.7 Michael Niedermayer
|
||||
2.6 Michael Niedermayer
|
||||
2.5 Michael Niedermayer
|
||||
2.4 Michael Niedermayer
|
||||
|
||||
If you want to maintain an older release, please contact us
|
||||
|
||||
@@ -571,6 +583,7 @@ GnuPG Fingerprints of maintainers and contributors
|
||||
|
||||
Alexander Strasser 1C96 78B7 83CB 8AA7 9AF5 D1EB A7D8 A57B A876 E58F
|
||||
Anssi Hannula 1A92 FF42 2DD9 8D2E 8AF7 65A9 4278 C520 513D F3CB
|
||||
Anton Khirnov 6D0C 6625 56F8 65D1 E5F5 814B B50A 1241 C067 07AB
|
||||
Ash Hughes 694D 43D2 D180 C7C7 6421 ABD3 A641 D0B7 623D 6029
|
||||
Attila Kinali 11F0 F9A6 A1D2 11F6 C745 D10C 6520 BCDD F2DF E765
|
||||
Baptiste Coudurier 8D77 134D 20CC 9220 201F C5DB 0AC9 325C 5C1A BAAA
|
||||
@@ -578,16 +591,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
|
||||
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
|
||||
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
|
||||
Ganesh Ajjanagadde C96A 848E 97C3 CEA2 AB72 5CE4 45F9 6A2D 3C36 FB1B
|
||||
Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4
|
||||
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
|
||||
Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
|
||||
Justin Ruggles 3136 ECC0 C10D 6C04 5F43 CA29 FCBE CD2A 3787 1EBF
|
||||
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
|
||||
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
|
||||
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
|
||||
Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B
|
||||
Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E
|
||||
|
||||
29
Makefile
29
Makefile
@@ -30,18 +30,16 @@ $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
|
||||
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
|
||||
|
||||
OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o
|
||||
OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
|
||||
OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
|
||||
OBJS-ffmpeg-$(CONFIG_VAAPI) += ffmpeg_vaapi.o
|
||||
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_CUVID) += ffmpeg_cuvid.o
|
||||
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
|
||||
OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
|
||||
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 audiomatch
|
||||
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
|
||||
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
|
||||
TOOLS = qt-faststart trasher uncoded_frame
|
||||
TOOLS-$(CONFIG_ZLIB) += cws2fws
|
||||
@@ -61,8 +59,7 @@ FFLIBS := avutil
|
||||
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 = cmdutils_common_opts.h \
|
||||
compat/w32pthreads.h
|
||||
SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
|
||||
|
||||
include $(SRC_PATH)/common.mak
|
||||
|
||||
@@ -79,13 +76,8 @@ tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
|
||||
tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
|
||||
tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
|
||||
|
||||
CONFIGURABLE_COMPONENTS = \
|
||||
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
|
||||
$(SRC_PATH)/libavcodec/bitstream_filters.c \
|
||||
$(SRC_PATH)/libavformat/protocols.c \
|
||||
|
||||
config.h: .config
|
||||
.config: $(CONFIGURABLE_COMPONENTS)
|
||||
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
|
||||
@-tput bold 2>/dev/null
|
||||
@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
|
||||
@-tput sgr0 2>/dev/null
|
||||
@@ -93,7 +85,7 @@ config.h: .config
|
||||
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
|
||||
HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
|
||||
ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
|
||||
ALTIVEC-OBJS VSX-OBJS MMX-OBJS YASM-OBJS \
|
||||
ALTIVEC-OBJS MMX-OBJS YASM-OBJS \
|
||||
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
|
||||
MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
|
||||
|
||||
@@ -184,15 +176,12 @@ clean::
|
||||
$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
|
||||
$(RM) $(CLEANSUFFIXES)
|
||||
$(RM) $(CLEANSUFFIXES:%=tools/%)
|
||||
$(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
|
||||
$(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
|
||||
$(RM) $(CLEANSUFFIXES:%=compat/%)
|
||||
$(RM) -r coverage-html
|
||||
$(RM) -rf coverage.info coverage.info.in lcov
|
||||
|
||||
distclean::
|
||||
$(RM) $(DISTCLEANSUFFIXES)
|
||||
$(RM) config.* .config libavutil/avconfig.h .version mapfile avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c
|
||||
$(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h
|
||||
ifeq ($(SRC_LINK),src)
|
||||
$(RM) src
|
||||
endif
|
||||
|
||||
@@ -45,4 +45,5 @@ GPL. Please refer to the LICENSE file for detailed information.
|
||||
|
||||
Patches should be submitted to the ffmpeg-devel mailing list using
|
||||
`git format-patch` or `git send-email`. Github pull requests should be
|
||||
avoided because they are not part of our review process and will be ignored.
|
||||
avoided because they are not part of our review process. Few developers
|
||||
follow pull requests so they will likely be ignored.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
┌────────────────────────────────────────┐
|
||||
│ RELEASE NOTES for FFmpeg 3.3 "Hilbert" │
|
||||
└────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────┐
|
||||
│ RELEASE NOTES for FFmpeg 3.0 "Einstein" │
|
||||
└─────────────────────────────────────────┘
|
||||
|
||||
The FFmpeg Project proudly presents FFmpeg 3.3 "Hilbert", about 5
|
||||
months after the release of FFmpeg 3.2.
|
||||
The FFmpeg Project proudly presents FFmpeg 3.0 "Einstein", about 5
|
||||
months after the release of FFmpeg 2.8.
|
||||
|
||||
A complete Changelog is available at the root of the project, and the
|
||||
complete Git history on http://source.ffmpeg.org.
|
||||
|
||||
90
cmdutils.c
90
cmdutils.c
@@ -61,7 +61,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#if HAVE_SETDLLDIRECTORY
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -75,12 +75,6 @@ static FILE *report_file;
|
||||
static int report_file_level = AV_LOG_DEBUG;
|
||||
int hide_banner = 0;
|
||||
|
||||
enum show_muxdemuxers {
|
||||
SHOW_DEFAULT,
|
||||
SHOW_DEMUXERS,
|
||||
SHOW_MUXERS,
|
||||
};
|
||||
|
||||
void init_opts(void)
|
||||
{
|
||||
av_dict_set(&sws_dict, "flags", "bicubic", 0);
|
||||
@@ -118,7 +112,7 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v
|
||||
|
||||
void init_dynload(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if HAVE_SETDLLDIRECTORY
|
||||
/* 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("");
|
||||
@@ -231,6 +225,7 @@ static const OptionDef *find_option(const OptionDef *po, const char *name)
|
||||
* by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while
|
||||
* it doesn't provide the actual command line via GetCommandLineW(). */
|
||||
#if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
/* Will be leaked on exit */
|
||||
static char** win32_argv_utf8 = NULL;
|
||||
@@ -1256,7 +1251,7 @@ static int is_device(const AVClass *avclass)
|
||||
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)
|
||||
{
|
||||
AVInputFormat *ifmt = NULL;
|
||||
AVOutputFormat *ofmt = NULL;
|
||||
@@ -1274,33 +1269,29 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
|
||||
const char *name = NULL;
|
||||
const char *long_name = NULL;
|
||||
|
||||
if (muxdemuxers !=SHOW_DEMUXERS) {
|
||||
while ((ofmt = av_oformat_next(ofmt))) {
|
||||
is_dev = is_device(ofmt->priv_class);
|
||||
if (!is_dev && device_only)
|
||||
continue;
|
||||
if ((!name || strcmp(ofmt->name, name) < 0) &&
|
||||
strcmp(ofmt->name, last_name) > 0) {
|
||||
name = ofmt->name;
|
||||
long_name = ofmt->long_name;
|
||||
encode = 1;
|
||||
}
|
||||
while ((ofmt = av_oformat_next(ofmt))) {
|
||||
is_dev = is_device(ofmt->priv_class);
|
||||
if (!is_dev && device_only)
|
||||
continue;
|
||||
if ((!name || strcmp(ofmt->name, name) < 0) &&
|
||||
strcmp(ofmt->name, last_name) > 0) {
|
||||
name = ofmt->name;
|
||||
long_name = ofmt->long_name;
|
||||
encode = 1;
|
||||
}
|
||||
}
|
||||
if (muxdemuxers != SHOW_MUXERS) {
|
||||
while ((ifmt = av_iformat_next(ifmt))) {
|
||||
is_dev = is_device(ifmt->priv_class);
|
||||
if (!is_dev && device_only)
|
||||
continue;
|
||||
if ((!name || strcmp(ifmt->name, name) < 0) &&
|
||||
strcmp(ifmt->name, last_name) > 0) {
|
||||
name = ifmt->name;
|
||||
long_name = ifmt->long_name;
|
||||
encode = 0;
|
||||
}
|
||||
if (name && strcmp(ifmt->name, name) == 0)
|
||||
decode = 1;
|
||||
while ((ifmt = av_iformat_next(ifmt))) {
|
||||
is_dev = is_device(ifmt->priv_class);
|
||||
if (!is_dev && device_only)
|
||||
continue;
|
||||
if ((!name || strcmp(ifmt->name, name) < 0) &&
|
||||
strcmp(ifmt->name, last_name) > 0) {
|
||||
name = ifmt->name;
|
||||
long_name = ifmt->long_name;
|
||||
encode = 0;
|
||||
}
|
||||
if (name && strcmp(ifmt->name, name) == 0)
|
||||
decode = 1;
|
||||
}
|
||||
if (!name)
|
||||
break;
|
||||
@@ -1317,22 +1308,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)
|
||||
{
|
||||
return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT);
|
||||
}
|
||||
|
||||
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);
|
||||
return show_formats_devices(optctx, opt, arg, 0);
|
||||
}
|
||||
|
||||
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) \
|
||||
@@ -1598,11 +1579,10 @@ int show_encoders(void *optctx, const char *opt, const char *arg)
|
||||
|
||||
int show_bsfs(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
const AVBitStreamFilter *bsf = NULL;
|
||||
void *opaque = NULL;
|
||||
AVBitStreamFilter *bsf = NULL;
|
||||
|
||||
printf("Bitstream filters:\n");
|
||||
while ((bsf = av_bsf_next(&opaque)))
|
||||
while ((bsf = av_bitstream_filter_next(bsf)))
|
||||
printf("%s\n", bsf->name);
|
||||
printf("\n");
|
||||
return 0;
|
||||
@@ -2013,7 +1993,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
|
||||
codec = s->oformat ? avcodec_find_encoder(codec_id)
|
||||
: avcodec_find_decoder(codec_id);
|
||||
|
||||
switch (st->codecpar->codec_type) {
|
||||
switch (st->codec->codec_type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
prefix = 'v';
|
||||
flags |= AV_OPT_FLAG_VIDEO_PARAM;
|
||||
@@ -2071,7 +2051,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
||||
return NULL;
|
||||
}
|
||||
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);
|
||||
return opts;
|
||||
}
|
||||
@@ -2097,10 +2077,18 @@ void *grow_array(void *array, int elem_size, int *size, int new_size)
|
||||
|
||||
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,
|
||||
AV_PKT_DATA_DISPLAYMATRIX, NULL);
|
||||
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 -= 360*floor(theta/360 + 0.9/360);
|
||||
|
||||
14
cmdutils.h
14
cmdutils.h
@@ -441,20 +441,6 @@ int show_license(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
|
||||
* program.
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
{ "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" },
|
||||
|
||||
@@ -213,27 +213,22 @@ static int compare_ocl_device_desc(const void *a, const void *b)
|
||||
|
||||
int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
int i, j, nb_devices = 0, count = 0, ret = 0;
|
||||
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;
|
||||
|
||||
ret = av_opencl_get_device_list(&device_list);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
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");
|
||||
av_opencl_free_device_list(&device_list);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Could not allocate buffer\n");
|
||||
av_opencl_free_device_list(&device_list);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
|
||||
28
common.mak
28
common.mak
@@ -39,7 +39,7 @@ CCFLAGS = $(CPPFLAGS) $(CFLAGS)
|
||||
OBJCFLAGS += $(EOBJCFLAGS)
|
||||
OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
|
||||
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
|
||||
CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS)
|
||||
CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
|
||||
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
|
||||
|
||||
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
|
||||
@@ -74,15 +74,6 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
||||
%_host.o: %.c
|
||||
$(COMPILE_HOSTC)
|
||||
|
||||
%$(DEFAULT_YASMD).asm: %.asm
|
||||
$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.asm=.d)
|
||||
$(YASM) $(YASMFLAGS) -I $(<D)/ -e $< | sed '/^%/d;/^$$/d;' > $@
|
||||
|
||||
%.o: %.asm
|
||||
$(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
|
||||
$(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
|
||||
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)
|
||||
|
||||
%.o: %.rc
|
||||
$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
|
||||
|
||||
@@ -92,7 +83,12 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
|
||||
%.h.c:
|
||||
$(Q)echo '#include "$*.h"' >$@
|
||||
|
||||
%.c %.h %.ver: TAG = GEN
|
||||
%.ver: %.v
|
||||
$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\
|
||||
/' -e 's/; /;\
|
||||
/g' > $@
|
||||
|
||||
%.c %.h: TAG = GEN
|
||||
|
||||
# Dummy rule to stop make trying to rebuild removed or renamed headers
|
||||
%.h:
|
||||
@@ -118,8 +114,8 @@ FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
|
||||
|
||||
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
|
||||
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
|
||||
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
|
||||
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
|
||||
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
|
||||
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
|
||||
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
|
||||
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
|
||||
TOOLS += $(TOOLS-yes)
|
||||
@@ -156,13 +152,15 @@ $(TOOLOBJS): | tools
|
||||
|
||||
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
|
||||
|
||||
CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).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
|
||||
|
||||
define RULES
|
||||
clean::
|
||||
$(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
|
||||
$(RM) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=$(DEFAULT_YASMD).d)
|
||||
$(RM) $(HOSTPROGS)
|
||||
$(RM) $(TOOLS)
|
||||
endef
|
||||
|
||||
$(eval $(RULES))
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* based on vlc_atomic.h from VLC
|
||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_ATOMICS_DUMMY_STDATOMIC_H
|
||||
#define COMPAT_ATOMICS_DUMMY_STDATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define ATOMIC_FLAG_INIT 0
|
||||
|
||||
#define ATOMIC_VAR_INIT(value) (value)
|
||||
|
||||
#define atomic_init(obj, value) \
|
||||
do { \
|
||||
*(obj) = (value); \
|
||||
} while(0)
|
||||
|
||||
#define kill_dependency(y) ((void)0)
|
||||
|
||||
#define atomic_thread_fence(order) \
|
||||
((void)0)
|
||||
|
||||
#define atomic_signal_fence(order) \
|
||||
((void)0)
|
||||
|
||||
#define atomic_is_lock_free(obj) 0
|
||||
|
||||
typedef intptr_t atomic_flag;
|
||||
typedef intptr_t atomic_bool;
|
||||
typedef intptr_t atomic_char;
|
||||
typedef intptr_t atomic_schar;
|
||||
typedef intptr_t atomic_uchar;
|
||||
typedef intptr_t atomic_short;
|
||||
typedef intptr_t atomic_ushort;
|
||||
typedef intptr_t atomic_int;
|
||||
typedef intptr_t atomic_uint;
|
||||
typedef intptr_t atomic_long;
|
||||
typedef intptr_t atomic_ulong;
|
||||
typedef intptr_t atomic_llong;
|
||||
typedef intptr_t atomic_ullong;
|
||||
typedef intptr_t atomic_wchar_t;
|
||||
typedef intptr_t atomic_int_least8_t;
|
||||
typedef intptr_t atomic_uint_least8_t;
|
||||
typedef intptr_t atomic_int_least16_t;
|
||||
typedef intptr_t atomic_uint_least16_t;
|
||||
typedef intptr_t atomic_int_least32_t;
|
||||
typedef intptr_t atomic_uint_least32_t;
|
||||
typedef intptr_t atomic_int_least64_t;
|
||||
typedef intptr_t atomic_uint_least64_t;
|
||||
typedef intptr_t atomic_int_fast8_t;
|
||||
typedef intptr_t atomic_uint_fast8_t;
|
||||
typedef intptr_t atomic_int_fast16_t;
|
||||
typedef intptr_t atomic_uint_fast16_t;
|
||||
typedef intptr_t atomic_int_fast32_t;
|
||||
typedef intptr_t atomic_uint_fast32_t;
|
||||
typedef intptr_t atomic_int_fast64_t;
|
||||
typedef intptr_t atomic_uint_fast64_t;
|
||||
typedef intptr_t atomic_intptr_t;
|
||||
typedef intptr_t atomic_uintptr_t;
|
||||
typedef intptr_t atomic_size_t;
|
||||
typedef intptr_t atomic_ptrdiff_t;
|
||||
typedef intptr_t atomic_intmax_t;
|
||||
typedef intptr_t atomic_uintmax_t;
|
||||
|
||||
#define atomic_store(object, desired) \
|
||||
do { \
|
||||
*(object) = (desired); \
|
||||
} while (0)
|
||||
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
atomic_store(object, desired)
|
||||
|
||||
#define atomic_load(object) \
|
||||
(*(object))
|
||||
|
||||
#define atomic_load_explicit(object, order) \
|
||||
atomic_load(object)
|
||||
|
||||
static inline intptr_t atomic_exchange(intptr_t *object, intptr_t desired)
|
||||
{
|
||||
intptr_t ret = *object;
|
||||
*object = desired;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
atomic_exchange(object, desired)
|
||||
|
||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
||||
intptr_t desired)
|
||||
{
|
||||
int ret;
|
||||
if (*object == *expected) {
|
||||
*object = desired;
|
||||
ret = 1;
|
||||
} else {
|
||||
*expected = *object;
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_weak(object, expected, desired)
|
||||
|
||||
#define FETCH_MODIFY(opname, op) \
|
||||
static inline intptr_t atomic_fetch_ ## opname(intptr_t *object, intptr_t operand) \
|
||||
{ \
|
||||
intptr_t ret; \
|
||||
ret = *object; \
|
||||
*object = *object op operand; \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
FETCH_MODIFY(add, +)
|
||||
FETCH_MODIFY(sub, -)
|
||||
FETCH_MODIFY(or, |)
|
||||
FETCH_MODIFY(xor, ^)
|
||||
FETCH_MODIFY(and, &)
|
||||
|
||||
#undef FETCH_MODIFY
|
||||
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
atomic_fetch_add(object, operand)
|
||||
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
atomic_fetch_sub(object, operand)
|
||||
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
atomic_fetch_or(object, operand)
|
||||
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
atomic_fetch_xor(object, operand)
|
||||
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
atomic_fetch_and(object, operand)
|
||||
|
||||
#define atomic_flag_test_and_set(object) \
|
||||
atomic_exchange(object, 1)
|
||||
|
||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
||||
atomic_flag_test_and_set(object)
|
||||
|
||||
#define atomic_flag_clear(object) \
|
||||
atomic_store(object, 0)
|
||||
|
||||
#define atomic_flag_clear_explicit(object, order) \
|
||||
atomic_flag_clear(object)
|
||||
|
||||
#endif /* COMPAT_ATOMICS_DUMMY_STDATOMIC_H */
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* based on vlc_atomic.h from VLC
|
||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_ATOMICS_GCC_STDATOMIC_H
|
||||
#define COMPAT_ATOMICS_GCC_STDATOMIC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define ATOMIC_FLAG_INIT 0
|
||||
|
||||
#define ATOMIC_VAR_INIT(value) (value)
|
||||
|
||||
#define atomic_init(obj, value) \
|
||||
do { \
|
||||
*(obj) = (value); \
|
||||
} while(0)
|
||||
|
||||
#define kill_dependency(y) ((void)0)
|
||||
|
||||
#define atomic_thread_fence(order) \
|
||||
__sync_synchronize()
|
||||
|
||||
#define atomic_signal_fence(order) \
|
||||
((void)0)
|
||||
|
||||
#define atomic_is_lock_free(obj) 0
|
||||
|
||||
typedef _Bool atomic_flag;
|
||||
typedef _Bool atomic_bool;
|
||||
typedef char atomic_char;
|
||||
typedef signed char atomic_schar;
|
||||
typedef unsigned char atomic_uchar;
|
||||
typedef short atomic_short;
|
||||
typedef unsigned short atomic_ushort;
|
||||
typedef int atomic_int;
|
||||
typedef unsigned int atomic_uint;
|
||||
typedef long atomic_long;
|
||||
typedef unsigned long atomic_ulong;
|
||||
typedef long long atomic_llong;
|
||||
typedef unsigned long long atomic_ullong;
|
||||
typedef wchar_t atomic_wchar_t;
|
||||
typedef int_least8_t atomic_int_least8_t;
|
||||
typedef uint_least8_t atomic_uint_least8_t;
|
||||
typedef int_least16_t atomic_int_least16_t;
|
||||
typedef uint_least16_t atomic_uint_least16_t;
|
||||
typedef int_least32_t atomic_int_least32_t;
|
||||
typedef uint_least32_t atomic_uint_least32_t;
|
||||
typedef int_least64_t atomic_int_least64_t;
|
||||
typedef uint_least64_t atomic_uint_least64_t;
|
||||
typedef int_fast8_t atomic_int_fast8_t;
|
||||
typedef uint_fast8_t atomic_uint_fast8_t;
|
||||
typedef int_fast16_t atomic_int_fast16_t;
|
||||
typedef uint_fast16_t atomic_uint_fast16_t;
|
||||
typedef int_fast32_t atomic_int_fast32_t;
|
||||
typedef uint_fast32_t atomic_uint_fast32_t;
|
||||
typedef int_fast64_t atomic_int_fast64_t;
|
||||
typedef uint_fast64_t atomic_uint_fast64_t;
|
||||
typedef intptr_t atomic_intptr_t;
|
||||
typedef uintptr_t atomic_uintptr_t;
|
||||
typedef size_t atomic_size_t;
|
||||
typedef ptrdiff_t atomic_ptrdiff_t;
|
||||
typedef intmax_t atomic_intmax_t;
|
||||
typedef uintmax_t atomic_uintmax_t;
|
||||
|
||||
#define atomic_store(object, desired) \
|
||||
do { \
|
||||
*(object) = (desired); \
|
||||
__sync_synchronize(); \
|
||||
} while (0)
|
||||
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
atomic_store(object, desired)
|
||||
|
||||
#define atomic_load(object) \
|
||||
(__sync_synchronize(), *(object))
|
||||
|
||||
#define atomic_load_explicit(object, order) \
|
||||
atomic_load(object)
|
||||
|
||||
#define atomic_exchange(object, desired) \
|
||||
({ \
|
||||
__typeof__(object) _obj = (object); \
|
||||
__typeof__(*object) _old; \
|
||||
do \
|
||||
_old = atomic_load(_obj); \
|
||||
while (!__sync_bool_compare_and_swap(_obj, _old, (desired))); \
|
||||
_old; \
|
||||
})
|
||||
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
atomic_exchange(object, desired)
|
||||
|
||||
#define atomic_compare_exchange_strong(object, expected, desired) \
|
||||
({ \
|
||||
__typeof__(object) _exp = (expected); \
|
||||
__typeof__(*object) _old = *_exp; \
|
||||
*_exp = __sync_val_compare_and_swap((object), _old, (desired)); \
|
||||
*_exp == _old; \
|
||||
})
|
||||
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_weak(object, expected, desired)
|
||||
|
||||
#define atomic_fetch_add(object, operand) \
|
||||
__sync_fetch_and_add(object, operand)
|
||||
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
atomic_fetch_add(object, operand)
|
||||
|
||||
#define atomic_fetch_sub(object, operand) \
|
||||
__sync_fetch_and_sub(object, operand)
|
||||
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
atomic_fetch_sub(object, operand)
|
||||
|
||||
#define atomic_fetch_or(object, operand) \
|
||||
__sync_fetch_and_or(object, operand)
|
||||
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
atomic_fetch_or(object, operand)
|
||||
|
||||
#define atomic_fetch_xor(object, operand) \
|
||||
__sync_fetch_and_xor(object, operand)
|
||||
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
atomic_fetch_xor(object, operand)
|
||||
|
||||
#define atomic_fetch_and(object, operand) \
|
||||
__sync_fetch_and_and(object, operand)
|
||||
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
atomic_fetch_and(object, operand)
|
||||
|
||||
#define atomic_flag_test_and_set(object) \
|
||||
atomic_exchange(object, 1)
|
||||
|
||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
||||
atomic_flag_test_and_set(object)
|
||||
|
||||
#define atomic_flag_clear(object) \
|
||||
atomic_store(object, 0)
|
||||
|
||||
#define atomic_flag_clear_explicit(object, order) \
|
||||
atomic_flag_clear(object)
|
||||
|
||||
#endif /* COMPAT_ATOMICS_GCC_STDATOMIC_H */
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* based on vlc_atomic.h from VLC
|
||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "stdatomic.h"
|
||||
|
||||
static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
void avpriv_atomic_lock(void)
|
||||
{
|
||||
pthread_mutex_lock(&atomic_lock);
|
||||
}
|
||||
|
||||
void avpriv_atomic_unlock(void)
|
||||
{
|
||||
pthread_mutex_unlock(&atomic_lock);
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* based on vlc_atomic.h from VLC
|
||||
* Copyright (C) 2010 Rémi Denis-Courmont
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_ATOMICS_PTHREAD_STDATOMIC_H
|
||||
#define COMPAT_ATOMICS_PTHREAD_STDATOMIC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define ATOMIC_FLAG_INIT 0
|
||||
|
||||
#define ATOMIC_VAR_INIT(value) (value)
|
||||
|
||||
#define atomic_init(obj, value) \
|
||||
do { \
|
||||
*(obj) = (value); \
|
||||
} while(0)
|
||||
|
||||
#define kill_dependency(y) ((void)0)
|
||||
|
||||
#define atomic_signal_fence(order) \
|
||||
((void)0)
|
||||
|
||||
#define atomic_is_lock_free(obj) 0
|
||||
|
||||
typedef intptr_t atomic_flag;
|
||||
typedef intptr_t atomic_bool;
|
||||
typedef intptr_t atomic_char;
|
||||
typedef intptr_t atomic_schar;
|
||||
typedef intptr_t atomic_uchar;
|
||||
typedef intptr_t atomic_short;
|
||||
typedef intptr_t atomic_ushort;
|
||||
typedef intptr_t atomic_int;
|
||||
typedef intptr_t atomic_uint;
|
||||
typedef intptr_t atomic_long;
|
||||
typedef intptr_t atomic_ulong;
|
||||
typedef intptr_t atomic_llong;
|
||||
typedef intptr_t atomic_ullong;
|
||||
typedef intptr_t atomic_wchar_t;
|
||||
typedef intptr_t atomic_int_least8_t;
|
||||
typedef intptr_t atomic_uint_least8_t;
|
||||
typedef intptr_t atomic_int_least16_t;
|
||||
typedef intptr_t atomic_uint_least16_t;
|
||||
typedef intptr_t atomic_int_least32_t;
|
||||
typedef intptr_t atomic_uint_least32_t;
|
||||
typedef intptr_t atomic_int_least64_t;
|
||||
typedef intptr_t atomic_uint_least64_t;
|
||||
typedef intptr_t atomic_int_fast8_t;
|
||||
typedef intptr_t atomic_uint_fast8_t;
|
||||
typedef intptr_t atomic_int_fast16_t;
|
||||
typedef intptr_t atomic_uint_fast16_t;
|
||||
typedef intptr_t atomic_int_fast32_t;
|
||||
typedef intptr_t atomic_uint_fast32_t;
|
||||
typedef intptr_t atomic_int_fast64_t;
|
||||
typedef intptr_t atomic_uint_fast64_t;
|
||||
typedef intptr_t atomic_intptr_t;
|
||||
typedef intptr_t atomic_uintptr_t;
|
||||
typedef intptr_t atomic_size_t;
|
||||
typedef intptr_t atomic_ptrdiff_t;
|
||||
typedef intptr_t atomic_intmax_t;
|
||||
typedef intptr_t atomic_uintmax_t;
|
||||
|
||||
void avpriv_atomic_lock(void);
|
||||
void avpriv_atomic_unlock(void);
|
||||
|
||||
static inline void atomic_thread_fence(int order)
|
||||
{
|
||||
avpriv_atomic_lock();
|
||||
avpriv_atomic_unlock();
|
||||
}
|
||||
|
||||
static inline void atomic_store(intptr_t *object, intptr_t desired)
|
||||
{
|
||||
avpriv_atomic_lock();
|
||||
*object = desired;
|
||||
avpriv_atomic_unlock();
|
||||
}
|
||||
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
atomic_store(object, desired)
|
||||
|
||||
static inline intptr_t atomic_load(intptr_t *object)
|
||||
{
|
||||
intptr_t ret;
|
||||
avpriv_atomic_lock();
|
||||
ret = *object;
|
||||
avpriv_atomic_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define atomic_load_explicit(object, order) \
|
||||
atomic_load(object)
|
||||
|
||||
static inline intptr_t atomic_exchange(intptr_t *object, intptr_t desired)
|
||||
{
|
||||
intptr_t ret;
|
||||
avpriv_atomic_lock();
|
||||
ret = *object;
|
||||
*object = desired;
|
||||
avpriv_atomic_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
atomic_exchange(object, desired)
|
||||
|
||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
||||
intptr_t desired)
|
||||
{
|
||||
int ret;
|
||||
avpriv_atomic_lock();
|
||||
if (*object == *expected) {
|
||||
ret = 1;
|
||||
*object = desired;
|
||||
} else {
|
||||
ret = 0;
|
||||
*expected = *object;
|
||||
}
|
||||
avpriv_atomic_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_weak(object, expected, desired)
|
||||
|
||||
#define FETCH_MODIFY(opname, op) \
|
||||
static inline intptr_t atomic_fetch_ ## opname(intptr_t *object, intptr_t operand) \
|
||||
{ \
|
||||
intptr_t ret; \
|
||||
avpriv_atomic_lock(); \
|
||||
ret = *object; \
|
||||
*object = *object op operand; \
|
||||
avpriv_atomic_unlock(); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
FETCH_MODIFY(add, +)
|
||||
FETCH_MODIFY(sub, -)
|
||||
FETCH_MODIFY(or, |)
|
||||
FETCH_MODIFY(xor, ^)
|
||||
FETCH_MODIFY(and, &)
|
||||
|
||||
#undef FETCH_MODIFY
|
||||
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
atomic_fetch_add(object, operand)
|
||||
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
atomic_fetch_sub(object, operand)
|
||||
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
atomic_fetch_or(object, operand)
|
||||
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
atomic_fetch_xor(object, operand)
|
||||
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
atomic_fetch_and(object, operand)
|
||||
|
||||
#define atomic_flag_test_and_set(object) \
|
||||
atomic_exchange(object, 1)
|
||||
|
||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
||||
atomic_flag_test_and_set(object)
|
||||
|
||||
#define atomic_flag_clear(object) \
|
||||
atomic_store(object, 0)
|
||||
|
||||
#define atomic_flag_clear_explicit(object, order) \
|
||||
atomic_flag_clear(object)
|
||||
|
||||
#endif /* COMPAT_ATOMICS_PTHREAD_STDATOMIC_H */
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_ATOMICS_SUNCC_STDATOMIC_H
|
||||
#define COMPAT_ATOMICS_SUNCC_STDATOMIC_H
|
||||
|
||||
#include <atomic.h>
|
||||
#include <mbarrier.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define ATOMIC_FLAG_INIT 0
|
||||
|
||||
#define ATOMIC_VAR_INIT(value) (value)
|
||||
|
||||
#define atomic_init(obj, value) \
|
||||
do { \
|
||||
*(obj) = (value); \
|
||||
} while(0)
|
||||
|
||||
#define kill_dependency(y) ((void)0)
|
||||
|
||||
#define atomic_thread_fence(order) \
|
||||
__machine_rw_barrier();
|
||||
|
||||
#define atomic_signal_fence(order) \
|
||||
((void)0)
|
||||
|
||||
#define atomic_is_lock_free(obj) 0
|
||||
|
||||
typedef intptr_t atomic_flag;
|
||||
typedef intptr_t atomic_bool;
|
||||
typedef intptr_t atomic_char;
|
||||
typedef intptr_t atomic_schar;
|
||||
typedef intptr_t atomic_uchar;
|
||||
typedef intptr_t atomic_short;
|
||||
typedef intptr_t atomic_ushort;
|
||||
typedef intptr_t atomic_int;
|
||||
typedef intptr_t atomic_uint;
|
||||
typedef intptr_t atomic_long;
|
||||
typedef intptr_t atomic_ulong;
|
||||
typedef intptr_t atomic_llong;
|
||||
typedef intptr_t atomic_ullong;
|
||||
typedef intptr_t atomic_wchar_t;
|
||||
typedef intptr_t atomic_int_least8_t;
|
||||
typedef intptr_t atomic_uint_least8_t;
|
||||
typedef intptr_t atomic_int_least16_t;
|
||||
typedef intptr_t atomic_uint_least16_t;
|
||||
typedef intptr_t atomic_int_least32_t;
|
||||
typedef intptr_t atomic_uint_least32_t;
|
||||
typedef intptr_t atomic_int_least64_t;
|
||||
typedef intptr_t atomic_uint_least64_t;
|
||||
typedef intptr_t atomic_int_fast8_t;
|
||||
typedef intptr_t atomic_uint_fast8_t;
|
||||
typedef intptr_t atomic_int_fast16_t;
|
||||
typedef intptr_t atomic_uint_fast16_t;
|
||||
typedef intptr_t atomic_int_fast32_t;
|
||||
typedef intptr_t atomic_uint_fast32_t;
|
||||
typedef intptr_t atomic_int_fast64_t;
|
||||
typedef intptr_t atomic_uint_fast64_t;
|
||||
typedef intptr_t atomic_intptr_t;
|
||||
typedef intptr_t atomic_uintptr_t;
|
||||
typedef intptr_t atomic_size_t;
|
||||
typedef intptr_t atomic_ptrdiff_t;
|
||||
typedef intptr_t atomic_intmax_t;
|
||||
typedef intptr_t atomic_uintmax_t;
|
||||
|
||||
static inline void atomic_store(intptr_t *object, intptr_t desired)
|
||||
{
|
||||
*object = desired;
|
||||
__machine_rw_barrier();
|
||||
}
|
||||
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
atomic_store(object, desired)
|
||||
|
||||
static inline intptr_t atomic_load(intptr_t *object)
|
||||
{
|
||||
__machine_rw_barrier();
|
||||
return *object;
|
||||
}
|
||||
|
||||
#define atomic_load_explicit(object, order) \
|
||||
atomic_load(object)
|
||||
|
||||
#define atomic_exchange(object, desired) \
|
||||
atomic_swap_ptr(object, desired)
|
||||
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
atomic_exchange(object, desired)
|
||||
|
||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
||||
intptr_t desired)
|
||||
{
|
||||
intptr_t old = *expected;
|
||||
*expected = atomic_cas_ptr(object, old, desired);
|
||||
return *expected == old;
|
||||
}
|
||||
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_weak(object, expected, desired)
|
||||
|
||||
static inline intptr_t atomic_fetch_add(intptr_t *object, intptr_t operand)
|
||||
{
|
||||
return atomic_add_ptr_nv(object, operand) - operand;
|
||||
}
|
||||
|
||||
#define atomic_fetch_sub(object, operand) \
|
||||
atomic_fetch_add(object, -(operand))
|
||||
|
||||
static inline intptr_t atomic_fetch_or(intptr_t *object, intptr_t operand)
|
||||
{
|
||||
intptr_t old;
|
||||
do {
|
||||
old = atomic_load(object);
|
||||
} while (!atomic_compare_exchange_strong(object, old, old | operand));
|
||||
return old;
|
||||
}
|
||||
|
||||
static inline intptr_t atomic_fetch_xor(intptr_t *object, intptr_t operand)
|
||||
{
|
||||
intptr_t old;
|
||||
do {
|
||||
old = atomic_load(object);
|
||||
} while (!atomic_compare_exchange_strong(object, old, old ^ operand));
|
||||
return old;
|
||||
}
|
||||
|
||||
static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand)
|
||||
{
|
||||
intptr_t old;
|
||||
do {
|
||||
old = atomic_load(object);
|
||||
} while (!atomic_compare_exchange_strong(object, old, old & operand));
|
||||
return old;
|
||||
}
|
||||
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
atomic_fetch_add(object, operand)
|
||||
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
atomic_fetch_sub(object, operand)
|
||||
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
atomic_fetch_or(object, operand)
|
||||
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
atomic_fetch_xor(object, operand)
|
||||
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
atomic_fetch_and(object, operand)
|
||||
|
||||
#define atomic_flag_test_and_set(object) \
|
||||
atomic_exchange(object, 1)
|
||||
|
||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
||||
atomic_flag_test_and_set(object)
|
||||
|
||||
#define atomic_flag_clear(object) \
|
||||
atomic_store(object, 0)
|
||||
|
||||
#define atomic_flag_clear_explicit(object, order) \
|
||||
atomic_flag_clear(object)
|
||||
|
||||
#endif /* COMPAT_ATOMICS_SUNCC_STDATOMIC_H */
|
||||
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_ATOMICS_WIN32_STDATOMIC_H
|
||||
#define COMPAT_ATOMICS_WIN32_STDATOMIC_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define ATOMIC_FLAG_INIT 0
|
||||
|
||||
#define ATOMIC_VAR_INIT(value) (value)
|
||||
|
||||
#define atomic_init(obj, value) \
|
||||
do { \
|
||||
*(obj) = (value); \
|
||||
} while(0)
|
||||
|
||||
#define kill_dependency(y) ((void)0)
|
||||
|
||||
#define atomic_thread_fence(order) \
|
||||
MemoryBarrier();
|
||||
|
||||
#define atomic_signal_fence(order) \
|
||||
((void)0)
|
||||
|
||||
#define atomic_is_lock_free(obj) 0
|
||||
|
||||
typedef intptr_t atomic_flag;
|
||||
typedef intptr_t atomic_bool;
|
||||
typedef intptr_t atomic_char;
|
||||
typedef intptr_t atomic_schar;
|
||||
typedef intptr_t atomic_uchar;
|
||||
typedef intptr_t atomic_short;
|
||||
typedef intptr_t atomic_ushort;
|
||||
typedef intptr_t atomic_int;
|
||||
typedef intptr_t atomic_uint;
|
||||
typedef intptr_t atomic_long;
|
||||
typedef intptr_t atomic_ulong;
|
||||
typedef intptr_t atomic_llong;
|
||||
typedef intptr_t atomic_ullong;
|
||||
typedef intptr_t atomic_wchar_t;
|
||||
typedef intptr_t atomic_int_least8_t;
|
||||
typedef intptr_t atomic_uint_least8_t;
|
||||
typedef intptr_t atomic_int_least16_t;
|
||||
typedef intptr_t atomic_uint_least16_t;
|
||||
typedef intptr_t atomic_int_least32_t;
|
||||
typedef intptr_t atomic_uint_least32_t;
|
||||
typedef intptr_t atomic_int_least64_t;
|
||||
typedef intptr_t atomic_uint_least64_t;
|
||||
typedef intptr_t atomic_int_fast8_t;
|
||||
typedef intptr_t atomic_uint_fast8_t;
|
||||
typedef intptr_t atomic_int_fast16_t;
|
||||
typedef intptr_t atomic_uint_fast16_t;
|
||||
typedef intptr_t atomic_int_fast32_t;
|
||||
typedef intptr_t atomic_uint_fast32_t;
|
||||
typedef intptr_t atomic_int_fast64_t;
|
||||
typedef intptr_t atomic_uint_fast64_t;
|
||||
typedef intptr_t atomic_intptr_t;
|
||||
typedef intptr_t atomic_uintptr_t;
|
||||
typedef intptr_t atomic_size_t;
|
||||
typedef intptr_t atomic_ptrdiff_t;
|
||||
typedef intptr_t atomic_intmax_t;
|
||||
typedef intptr_t atomic_uintmax_t;
|
||||
|
||||
#define atomic_store(object, desired) \
|
||||
do { \
|
||||
*(object) = (desired); \
|
||||
MemoryBarrier(); \
|
||||
} while (0)
|
||||
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
atomic_store(object, desired)
|
||||
|
||||
#define atomic_load(object) \
|
||||
(MemoryBarrier(), *(object))
|
||||
|
||||
#define atomic_load_explicit(object, order) \
|
||||
atomic_load(object)
|
||||
|
||||
#define atomic_exchange(object, desired) \
|
||||
InterlockedExchangePointer(object, desired);
|
||||
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
atomic_exchange(object, desired)
|
||||
|
||||
static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
|
||||
intptr_t desired)
|
||||
{
|
||||
intptr_t old = *expected;
|
||||
*expected = InterlockedCompareExchangePointer(object, desired, old);
|
||||
return *expected == old;
|
||||
}
|
||||
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
||||
atomic_compare_exchange_strong(object, expected, desired)
|
||||
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
|
||||
atomic_compare_exchange_weak(object, expected, desired)
|
||||
|
||||
#ifdef _WIN64
|
||||
#define atomic_fetch_add(object, operand) \
|
||||
InterlockedExchangeAdd64(object, operand)
|
||||
|
||||
#define atomic_fetch_sub(object, operand) \
|
||||
InterlockedExchangeAdd64(object, -(operand))
|
||||
|
||||
#define atomic_fetch_or(object, operand) \
|
||||
InterlockedOr64(object, operand)
|
||||
|
||||
#define atomic_fetch_xor(object, operand) \
|
||||
InterlockedXor64(object, operand)
|
||||
|
||||
#define atomic_fetch_and(object, operand) \
|
||||
InterlockedAnd64(object, operand)
|
||||
#else
|
||||
#define atomic_fetch_add(object, operand) \
|
||||
InterlockedExchangeAdd(object, operand)
|
||||
|
||||
#define atomic_fetch_sub(object, operand) \
|
||||
InterlockedExchangeAdd(object, -(operand))
|
||||
|
||||
#define atomic_fetch_or(object, operand) \
|
||||
InterlockedOr(object, operand)
|
||||
|
||||
#define atomic_fetch_xor(object, operand) \
|
||||
InterlockedXor(object, operand)
|
||||
|
||||
#define atomic_fetch_and(object, operand) \
|
||||
InterlockedAnd(object, operand)
|
||||
#endif /* _WIN64 */
|
||||
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
atomic_fetch_add(object, operand)
|
||||
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
atomic_fetch_sub(object, operand)
|
||||
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
atomic_fetch_or(object, operand)
|
||||
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
atomic_fetch_xor(object, operand)
|
||||
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
atomic_fetch_and(object, operand)
|
||||
|
||||
#define atomic_flag_test_and_set(object) \
|
||||
atomic_exchange(object, 1)
|
||||
|
||||
#define atomic_flag_test_and_set_explicit(object, order) \
|
||||
atomic_flag_test_and_set(object)
|
||||
|
||||
#define atomic_flag_clear(object) \
|
||||
atomic_store(object, 0)
|
||||
|
||||
#define atomic_flag_clear_explicit(object, order) \
|
||||
atomic_flag_clear(object)
|
||||
|
||||
#endif /* COMPAT_ATOMICS_WIN32_STDATOMIC_H */
|
||||
@@ -75,149 +75,54 @@ enum {AVS_PLANAR_Y=1<<0,
|
||||
AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED};
|
||||
|
||||
// Colorspace properties.
|
||||
enum {
|
||||
AVS_CS_YUVA = 1 << 27,
|
||||
AVS_CS_BGR = 1 << 28,
|
||||
AVS_CS_YUV = 1 << 29,
|
||||
AVS_CS_INTERLEAVED = 1 << 30,
|
||||
AVS_CS_PLANAR = 1 << 31,
|
||||
enum {AVS_CS_BGR = 1<<28,
|
||||
AVS_CS_YUV = 1<<29,
|
||||
AVS_CS_INTERLEAVED = 1<<30,
|
||||
AVS_CS_PLANAR = 1<<31,
|
||||
|
||||
AVS_CS_SHIFT_SUB_WIDTH = 0,
|
||||
AVS_CS_SHIFT_SUB_HEIGHT = 8,
|
||||
AVS_CS_SHIFT_SAMPLE_BITS = 16,
|
||||
AVS_CS_SHIFT_SUB_WIDTH = 0,
|
||||
AVS_CS_SHIFT_SUB_HEIGHT = 8,
|
||||
AVS_CS_SHIFT_SAMPLE_BITS = 16,
|
||||
|
||||
AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,
|
||||
AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24
|
||||
AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
|
||||
AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
|
||||
AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,
|
||||
AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24
|
||||
AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
|
||||
AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
|
||||
|
||||
AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
|
||||
AVS_CS_UPLANEFIRST = 1 << 4, // I420
|
||||
AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
|
||||
AVS_CS_UPLANEFIRST = 1 << 4, // I420
|
||||
|
||||
AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,
|
||||
AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
|
||||
AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
|
||||
AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9
|
||||
AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,
|
||||
AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
|
||||
AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
|
||||
AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9
|
||||
|
||||
AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
AVS_CS_SAMPLE_BITS_12 = 6 << 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_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,
|
||||
|
||||
AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK,
|
||||
AVS_CS_PLANAR_FILTER = ~( AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST )};
|
||||
|
||||
// Specific colorformats
|
||||
enum {
|
||||
AVS_CS_UNKNOWN = 0,
|
||||
AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,
|
||||
AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,
|
||||
AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
|
||||
AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED,
|
||||
AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
|
||||
// AVS_CS_YV12 = 1<<3 Reserved
|
||||
// AVS_CS_I420 = 1<<4 Reserved
|
||||
AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED,
|
||||
|
||||
AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YVU 4:4:4 planar
|
||||
AVS_CS_YV16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YVU 4:2:2 planar
|
||||
AVS_CS_YV12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YVU 4:2:0 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_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:2 planar
|
||||
AVS_CS_YV12 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:0 planar
|
||||
AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YUV 4:2:0 planar
|
||||
AVS_CS_IYUV = AVS_CS_I420,
|
||||
AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:1 planar
|
||||
AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:0 planar
|
||||
AVS_CS_Y8 = AVS_CS_GENERIC_Y | 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
|
||||
|
||||
AVS_CS_Y8 = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 // Y 4:0:0 planar
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -342,10 +247,10 @@ AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)
|
||||
{ return !!(p->pixel_type&AVS_CS_BGR); }
|
||||
|
||||
AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)
|
||||
{ return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((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)
|
||||
{ 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)
|
||||
{ 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)
|
||||
{ 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_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_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)
|
||||
{ return ((p->image_type & property)==property ); }
|
||||
|
||||
@@ -496,12 +365,6 @@ AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)
|
||||
}
|
||||
#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
|
||||
@@ -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; }
|
||||
#endif
|
||||
AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)
|
||||
{ AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (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_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_yv16);
|
||||
AVSC_DECLARE_FUNC(avs_is_yv12);
|
||||
AVSC_DECLARE_FUNC(avs_is_yv411);
|
||||
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_get_plane_width_subsampling);
|
||||
@@ -934,11 +780,6 @@ struct AVS_Library {
|
||||
AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
|
||||
AVSC_DECLARE_FUNC(avs_is_writable);
|
||||
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
|
||||
@@ -999,28 +840,11 @@ AVSC_INLINE AVS_Library * avs_load_library() {
|
||||
AVSC_LOAD_FUNC(avs_vsprintf);
|
||||
|
||||
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_yv16);
|
||||
AVSC_LOAD_FUNC(avs_is_yv12);
|
||||
AVSC_LOAD_FUNC(avs_is_yv411);
|
||||
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_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_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_LOAD_FUNC
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* This copyright notice applies to this header file only:
|
||||
*
|
||||
* Copyright (c) 2016
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the software, and to permit persons to whom the
|
||||
* software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if !defined(AV_COMPAT_DYNLINK_CUDA_H) && !defined(CUDA_VERSION)
|
||||
#define AV_COMPAT_DYNLINK_CUDA_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define CUDA_VERSION 7050
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define CUDAAPI __stdcall
|
||||
#else
|
||||
#define CUDAAPI
|
||||
#endif
|
||||
|
||||
#define CU_CTX_SCHED_BLOCKING_SYNC 4
|
||||
|
||||
typedef int CUdevice;
|
||||
typedef void* CUarray;
|
||||
typedef void* CUcontext;
|
||||
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
|
||||
typedef unsigned long long CUdeviceptr;
|
||||
#else
|
||||
typedef unsigned int CUdeviceptr;
|
||||
#endif
|
||||
|
||||
typedef enum cudaError_enum {
|
||||
CUDA_SUCCESS = 0
|
||||
} CUresult;
|
||||
|
||||
typedef enum CUmemorytype_enum {
|
||||
CU_MEMORYTYPE_HOST = 1,
|
||||
CU_MEMORYTYPE_DEVICE = 2
|
||||
} CUmemorytype;
|
||||
|
||||
typedef struct CUDA_MEMCPY2D_st {
|
||||
size_t srcXInBytes;
|
||||
size_t srcY;
|
||||
CUmemorytype srcMemoryType;
|
||||
const void *srcHost;
|
||||
CUdeviceptr srcDevice;
|
||||
CUarray srcArray;
|
||||
size_t srcPitch;
|
||||
|
||||
size_t dstXInBytes;
|
||||
size_t dstY;
|
||||
CUmemorytype dstMemoryType;
|
||||
void *dstHost;
|
||||
CUdeviceptr dstDevice;
|
||||
CUarray dstArray;
|
||||
size_t dstPitch;
|
||||
|
||||
size_t WidthInBytes;
|
||||
size_t Height;
|
||||
} CUDA_MEMCPY2D;
|
||||
|
||||
typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
|
||||
typedef CUresult CUDAAPI tcuDeviceGetCount(int *count);
|
||||
typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
|
||||
typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);
|
||||
typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
|
||||
typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev);
|
||||
typedef CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext *pctx);
|
||||
typedef CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx);
|
||||
typedef CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx);
|
||||
typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize);
|
||||
typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
|
||||
typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
|
||||
typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
|
||||
typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr);
|
||||
|
||||
#endif
|
||||
@@ -1,815 +0,0 @@
|
||||
/*
|
||||
* This copyright notice applies to this header file only:
|
||||
*
|
||||
* Copyright (c) 2010-2016 NVIDIA Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the software, and to permit persons to whom the
|
||||
* software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file cuviddec.h
|
||||
* NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
|
||||
* \date 2015-2016
|
||||
* This file contains constants, structure definitions and function prototypes used for decoding.
|
||||
*/
|
||||
|
||||
#if !defined(__CUDA_VIDEO_H__)
|
||||
#define __CUDA_VIDEO_H__
|
||||
|
||||
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
|
||||
#if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))
|
||||
#define __CUVID_DEVPTR64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
typedef unsigned int tcu_ulong;
|
||||
#else
|
||||
typedef unsigned long tcu_ulong;
|
||||
#endif
|
||||
|
||||
typedef void *CUvideodecoder;
|
||||
typedef struct _CUcontextlock_st *CUvideoctxlock;
|
||||
|
||||
/**
|
||||
* \addtogroup VIDEO_DECODER Video Decoder
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \enum cudaVideoCodec
|
||||
* Video Codec Enums
|
||||
*/
|
||||
typedef enum cudaVideoCodec_enum {
|
||||
cudaVideoCodec_MPEG1=0, /**< MPEG1 */
|
||||
cudaVideoCodec_MPEG2, /**< MPEG2 */
|
||||
cudaVideoCodec_MPEG4, /**< MPEG4 */
|
||||
cudaVideoCodec_VC1, /**< VC1 */
|
||||
cudaVideoCodec_H264, /**< H264 */
|
||||
cudaVideoCodec_JPEG, /**< JPEG */
|
||||
cudaVideoCodec_H264_SVC, /**< H264-SVC */
|
||||
cudaVideoCodec_H264_MVC, /**< H264-MVC */
|
||||
cudaVideoCodec_HEVC, /**< HEVC */
|
||||
cudaVideoCodec_VP8, /**< VP8 */
|
||||
cudaVideoCodec_VP9, /**< VP9 */
|
||||
cudaVideoCodec_NumCodecs, /**< Max COdecs */
|
||||
// Uncompressed YUV
|
||||
cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), /**< Y,U,V (4:2:0) */
|
||||
cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,V,U (4:2:0) */
|
||||
cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,UV (4:2:0) */
|
||||
cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), /**< YUYV/YUY2 (4:2:2) */
|
||||
cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) /**< UYVY (4:2:2) */
|
||||
} cudaVideoCodec;
|
||||
|
||||
/*!
|
||||
* \enum cudaVideoSurfaceFormat
|
||||
* Video Surface Formats Enums
|
||||
*/
|
||||
typedef enum cudaVideoSurfaceFormat_enum {
|
||||
cudaVideoSurfaceFormat_NV12=0, /**< NV12 */
|
||||
cudaVideoSurfaceFormat_P016=1 /**< P016 */
|
||||
} cudaVideoSurfaceFormat;
|
||||
|
||||
/*!
|
||||
* \enum cudaVideoDeinterlaceMode
|
||||
* Deinterlacing Modes Enums
|
||||
*/
|
||||
typedef enum cudaVideoDeinterlaceMode_enum {
|
||||
cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */
|
||||
cudaVideoDeinterlaceMode_Bob, /**< Drop one field */
|
||||
cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */
|
||||
} cudaVideoDeinterlaceMode;
|
||||
|
||||
/*!
|
||||
* \enum cudaVideoChromaFormat
|
||||
* Chroma Formats Enums
|
||||
*/
|
||||
typedef enum cudaVideoChromaFormat_enum {
|
||||
cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */
|
||||
cudaVideoChromaFormat_420, /**< 4:2:0 */
|
||||
cudaVideoChromaFormat_422, /**< 4:2:2 */
|
||||
cudaVideoChromaFormat_444 /**< 4:4:4 */
|
||||
} cudaVideoChromaFormat;
|
||||
|
||||
/*!
|
||||
* \enum cudaVideoCreateFlags
|
||||
* Decoder Flags Enums
|
||||
*/
|
||||
typedef enum cudaVideoCreateFlags_enum {
|
||||
cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */
|
||||
cudaVideoCreate_PreferCUDA = 0x01, /**< Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading) */
|
||||
cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */
|
||||
cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */
|
||||
} cudaVideoCreateFlags;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDDECODECREATEINFO
|
||||
* Struct used in create decoder
|
||||
*/
|
||||
typedef struct _CUVIDDECODECREATEINFO
|
||||
{
|
||||
tcu_ulong ulWidth; /**< Coded Sequence Width */
|
||||
tcu_ulong ulHeight; /**< Coded Sequence Height */
|
||||
tcu_ulong ulNumDecodeSurfaces; /**< Maximum number of internal decode surfaces */
|
||||
cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
|
||||
cudaVideoChromaFormat ChromaFormat; /**< cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported) */
|
||||
tcu_ulong ulCreationFlags; /**< Decoder creation flags (cudaVideoCreateFlags_XXX) */
|
||||
tcu_ulong bitDepthMinus8;
|
||||
tcu_ulong Reserved1[4]; /**< Reserved for future use - set to zero */
|
||||
/**
|
||||
* area of the frame that should be displayed
|
||||
*/
|
||||
struct {
|
||||
short left;
|
||||
short top;
|
||||
short right;
|
||||
short bottom;
|
||||
} display_area;
|
||||
|
||||
cudaVideoSurfaceFormat OutputFormat; /**< cudaVideoSurfaceFormat_XXX */
|
||||
cudaVideoDeinterlaceMode DeinterlaceMode; /**< cudaVideoDeinterlaceMode_XXX */
|
||||
tcu_ulong ulTargetWidth; /**< Post-processed Output Width (Should be aligned to 2) */
|
||||
tcu_ulong ulTargetHeight; /**< Post-processed Output Height (Should be aligbed to 2) */
|
||||
tcu_ulong ulNumOutputSurfaces; /**< Maximum number of output surfaces simultaneously mapped */
|
||||
CUvideoctxlock vidLock; /**< If non-NULL, context lock used for synchronizing ownership of the cuda context */
|
||||
/**
|
||||
* target rectangle in the output frame (for aspect ratio conversion)
|
||||
* if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
|
||||
*/
|
||||
struct {
|
||||
short left;
|
||||
short top;
|
||||
short right;
|
||||
short bottom;
|
||||
} target_rect;
|
||||
tcu_ulong Reserved2[5]; /**< Reserved for future use - set to zero */
|
||||
} CUVIDDECODECREATEINFO;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDH264DPBENTRY
|
||||
* H.264 DPB Entry
|
||||
*/
|
||||
typedef struct _CUVIDH264DPBENTRY
|
||||
{
|
||||
int PicIdx; /**< picture index of reference frame */
|
||||
int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */
|
||||
int is_long_term; /**< 0=short term reference, 1=long term reference */
|
||||
int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
|
||||
int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */
|
||||
int FieldOrderCnt[2]; /**< field order count of top and bottom fields */
|
||||
} CUVIDH264DPBENTRY;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDH264MVCEXT
|
||||
* H.264 MVC Picture Parameters Ext
|
||||
*/
|
||||
typedef struct _CUVIDH264MVCEXT
|
||||
{
|
||||
int num_views_minus1;
|
||||
int view_id;
|
||||
unsigned char inter_view_flag;
|
||||
unsigned char num_inter_view_refs_l0;
|
||||
unsigned char num_inter_view_refs_l1;
|
||||
unsigned char MVCReserved8Bits;
|
||||
int InterViewRefsL0[16];
|
||||
int InterViewRefsL1[16];
|
||||
} CUVIDH264MVCEXT;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDH264SVCEXT
|
||||
* H.264 SVC Picture Parameters Ext
|
||||
*/
|
||||
typedef struct _CUVIDH264SVCEXT
|
||||
{
|
||||
unsigned char profile_idc;
|
||||
unsigned char level_idc;
|
||||
unsigned char DQId;
|
||||
unsigned char DQIdMax;
|
||||
unsigned char disable_inter_layer_deblocking_filter_idc;
|
||||
unsigned char ref_layer_chroma_phase_y_plus1;
|
||||
signed char inter_layer_slice_alpha_c0_offset_div2;
|
||||
signed char inter_layer_slice_beta_offset_div2;
|
||||
|
||||
unsigned short DPBEntryValidFlag;
|
||||
unsigned char inter_layer_deblocking_filter_control_present_flag;
|
||||
unsigned char extended_spatial_scalability_idc;
|
||||
unsigned char adaptive_tcoeff_level_prediction_flag;
|
||||
unsigned char slice_header_restriction_flag;
|
||||
unsigned char chroma_phase_x_plus1_flag;
|
||||
unsigned char chroma_phase_y_plus1;
|
||||
|
||||
unsigned char tcoeff_level_prediction_flag;
|
||||
unsigned char constrained_intra_resampling_flag;
|
||||
unsigned char ref_layer_chroma_phase_x_plus1_flag;
|
||||
unsigned char store_ref_base_pic_flag;
|
||||
unsigned char Reserved8BitsA;
|
||||
unsigned char Reserved8BitsB;
|
||||
// For the 4 scaled_ref_layer_XX fields below,
|
||||
// if (extended_spatial_scalability_idc == 1), SPS field, G.7.3.2.1.4, add prefix "seq_"
|
||||
// if (extended_spatial_scalability_idc == 2), SLH field, G.7.3.3.4,
|
||||
short scaled_ref_layer_left_offset;
|
||||
short scaled_ref_layer_top_offset;
|
||||
short scaled_ref_layer_right_offset;
|
||||
short scaled_ref_layer_bottom_offset;
|
||||
unsigned short Reserved16Bits;
|
||||
struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. Linked list ends at the target layer. */
|
||||
int bRefBaseLayer; /**< whether to store ref base pic */
|
||||
} CUVIDH264SVCEXT;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDH264PICPARAMS
|
||||
* H.264 Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDH264PICPARAMS
|
||||
{
|
||||
// SPS
|
||||
int log2_max_frame_num_minus4;
|
||||
int pic_order_cnt_type;
|
||||
int log2_max_pic_order_cnt_lsb_minus4;
|
||||
int delta_pic_order_always_zero_flag;
|
||||
int frame_mbs_only_flag;
|
||||
int direct_8x8_inference_flag;
|
||||
int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
|
||||
unsigned char residual_colour_transform_flag;
|
||||
unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
|
||||
unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
|
||||
unsigned char qpprime_y_zero_transform_bypass_flag;
|
||||
// PPS
|
||||
int entropy_coding_mode_flag;
|
||||
int pic_order_present_flag;
|
||||
int num_ref_idx_l0_active_minus1;
|
||||
int num_ref_idx_l1_active_minus1;
|
||||
int weighted_pred_flag;
|
||||
int weighted_bipred_idc;
|
||||
int pic_init_qp_minus26;
|
||||
int deblocking_filter_control_present_flag;
|
||||
int redundant_pic_cnt_present_flag;
|
||||
int transform_8x8_mode_flag;
|
||||
int MbaffFrameFlag;
|
||||
int constrained_intra_pred_flag;
|
||||
int chroma_qp_index_offset;
|
||||
int second_chroma_qp_index_offset;
|
||||
int ref_pic_flag;
|
||||
int frame_num;
|
||||
int CurrFieldOrderCnt[2];
|
||||
// DPB
|
||||
CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
|
||||
// Quantization Matrices (raster-order)
|
||||
unsigned char WeightScale4x4[6][16];
|
||||
unsigned char WeightScale8x8[2][64];
|
||||
// FMO/ASO
|
||||
unsigned char fmo_aso_enable;
|
||||
unsigned char num_slice_groups_minus1;
|
||||
unsigned char slice_group_map_type;
|
||||
signed char pic_init_qs_minus26;
|
||||
unsigned int slice_group_change_rate_minus1;
|
||||
union
|
||||
{
|
||||
unsigned long long slice_group_map_addr;
|
||||
const unsigned char *pMb2SliceGroupMap;
|
||||
} fmo;
|
||||
unsigned int Reserved[12];
|
||||
// SVC/MVC
|
||||
union
|
||||
{
|
||||
CUVIDH264MVCEXT mvcext;
|
||||
CUVIDH264SVCEXT svcext;
|
||||
} svcmvc;
|
||||
} CUVIDH264PICPARAMS;
|
||||
|
||||
|
||||
/*!
|
||||
* \struct CUVIDMPEG2PICPARAMS
|
||||
* MPEG-2 Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDMPEG2PICPARAMS
|
||||
{
|
||||
int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
|
||||
int BackwardRefIdx; // Picture index of backward reference (B-frames)
|
||||
int picture_coding_type;
|
||||
int full_pel_forward_vector;
|
||||
int full_pel_backward_vector;
|
||||
int f_code[2][2];
|
||||
int intra_dc_precision;
|
||||
int frame_pred_frame_dct;
|
||||
int concealment_motion_vectors;
|
||||
int q_scale_type;
|
||||
int intra_vlc_format;
|
||||
int alternate_scan;
|
||||
int top_field_first;
|
||||
// Quantization matrices (raster order)
|
||||
unsigned char QuantMatrixIntra[64];
|
||||
unsigned char QuantMatrixInter[64];
|
||||
} CUVIDMPEG2PICPARAMS;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MPEG-4 Picture Parameters
|
||||
//
|
||||
|
||||
// MPEG-4 has VOP types instead of Picture types
|
||||
#define I_VOP 0
|
||||
#define P_VOP 1
|
||||
#define B_VOP 2
|
||||
#define S_VOP 3
|
||||
|
||||
/*!
|
||||
* \struct CUVIDMPEG4PICPARAMS
|
||||
* MPEG-4 Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDMPEG4PICPARAMS
|
||||
{
|
||||
int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
|
||||
int BackwardRefIdx; // Picture index of backward reference (B-frames)
|
||||
// VOL
|
||||
int video_object_layer_width;
|
||||
int video_object_layer_height;
|
||||
int vop_time_increment_bitcount;
|
||||
int top_field_first;
|
||||
int resync_marker_disable;
|
||||
int quant_type;
|
||||
int quarter_sample;
|
||||
int short_video_header;
|
||||
int divx_flags;
|
||||
// VOP
|
||||
int vop_coding_type;
|
||||
int vop_coded;
|
||||
int vop_rounding_type;
|
||||
int alternate_vertical_scan_flag;
|
||||
int interlaced;
|
||||
int vop_fcode_forward;
|
||||
int vop_fcode_backward;
|
||||
int trd[2];
|
||||
int trb[2];
|
||||
// Quantization matrices (raster order)
|
||||
unsigned char QuantMatrixIntra[64];
|
||||
unsigned char QuantMatrixInter[64];
|
||||
int gmc_enabled;
|
||||
} CUVIDMPEG4PICPARAMS;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDVC1PICPARAMS
|
||||
* VC1 Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDVC1PICPARAMS
|
||||
{
|
||||
int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */
|
||||
int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */
|
||||
int FrameWidth; /**< Actual frame width */
|
||||
int FrameHeight; /**< Actual frame height */
|
||||
// PICTURE
|
||||
int intra_pic_flag; /**< Set to 1 for I,BI frames */
|
||||
int ref_pic_flag; /**< Set to 1 for I,P frames */
|
||||
int progressive_fcm; /**< Progressive frame */
|
||||
// SEQUENCE
|
||||
int profile;
|
||||
int postprocflag;
|
||||
int pulldown;
|
||||
int interlace;
|
||||
int tfcntrflag;
|
||||
int finterpflag;
|
||||
int psf;
|
||||
int multires;
|
||||
int syncmarker;
|
||||
int rangered;
|
||||
int maxbframes;
|
||||
// ENTRYPOINT
|
||||
int panscan_flag;
|
||||
int refdist_flag;
|
||||
int extended_mv;
|
||||
int dquant;
|
||||
int vstransform;
|
||||
int loopfilter;
|
||||
int fastuvmc;
|
||||
int overlap;
|
||||
int quantizer;
|
||||
int extended_dmv;
|
||||
int range_mapy_flag;
|
||||
int range_mapy;
|
||||
int range_mapuv_flag;
|
||||
int range_mapuv;
|
||||
int rangeredfrm; // range reduction state
|
||||
} CUVIDVC1PICPARAMS;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDJPEGPICPARAMS
|
||||
* JPEG Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDJPEGPICPARAMS
|
||||
{
|
||||
int Reserved;
|
||||
} CUVIDJPEGPICPARAMS;
|
||||
|
||||
|
||||
/*!
|
||||
* \struct CUVIDHEVCPICPARAMS
|
||||
* HEVC Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDHEVCPICPARAMS
|
||||
{
|
||||
// sps
|
||||
int pic_width_in_luma_samples;
|
||||
int pic_height_in_luma_samples;
|
||||
unsigned char log2_min_luma_coding_block_size_minus3;
|
||||
unsigned char log2_diff_max_min_luma_coding_block_size;
|
||||
unsigned char log2_min_transform_block_size_minus2;
|
||||
unsigned char log2_diff_max_min_transform_block_size;
|
||||
unsigned char pcm_enabled_flag;
|
||||
unsigned char log2_min_pcm_luma_coding_block_size_minus3;
|
||||
unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
|
||||
unsigned char pcm_sample_bit_depth_luma_minus1;
|
||||
|
||||
unsigned char pcm_sample_bit_depth_chroma_minus1;
|
||||
unsigned char pcm_loop_filter_disabled_flag;
|
||||
unsigned char strong_intra_smoothing_enabled_flag;
|
||||
unsigned char max_transform_hierarchy_depth_intra;
|
||||
unsigned char max_transform_hierarchy_depth_inter;
|
||||
unsigned char amp_enabled_flag;
|
||||
unsigned char separate_colour_plane_flag;
|
||||
unsigned char log2_max_pic_order_cnt_lsb_minus4;
|
||||
|
||||
unsigned char num_short_term_ref_pic_sets;
|
||||
unsigned char long_term_ref_pics_present_flag;
|
||||
unsigned char num_long_term_ref_pics_sps;
|
||||
unsigned char sps_temporal_mvp_enabled_flag;
|
||||
unsigned char sample_adaptive_offset_enabled_flag;
|
||||
unsigned char scaling_list_enable_flag;
|
||||
unsigned char IrapPicFlag;
|
||||
unsigned char IdrPicFlag;
|
||||
|
||||
unsigned char bit_depth_luma_minus8;
|
||||
unsigned char bit_depth_chroma_minus8;
|
||||
unsigned char reserved1[14];
|
||||
|
||||
// pps
|
||||
unsigned char dependent_slice_segments_enabled_flag;
|
||||
unsigned char slice_segment_header_extension_present_flag;
|
||||
unsigned char sign_data_hiding_enabled_flag;
|
||||
unsigned char cu_qp_delta_enabled_flag;
|
||||
unsigned char diff_cu_qp_delta_depth;
|
||||
signed char init_qp_minus26;
|
||||
signed char pps_cb_qp_offset;
|
||||
signed char pps_cr_qp_offset;
|
||||
|
||||
unsigned char constrained_intra_pred_flag;
|
||||
unsigned char weighted_pred_flag;
|
||||
unsigned char weighted_bipred_flag;
|
||||
unsigned char transform_skip_enabled_flag;
|
||||
unsigned char transquant_bypass_enabled_flag;
|
||||
unsigned char entropy_coding_sync_enabled_flag;
|
||||
unsigned char log2_parallel_merge_level_minus2;
|
||||
unsigned char num_extra_slice_header_bits;
|
||||
|
||||
unsigned char loop_filter_across_tiles_enabled_flag;
|
||||
unsigned char loop_filter_across_slices_enabled_flag;
|
||||
unsigned char output_flag_present_flag;
|
||||
unsigned char num_ref_idx_l0_default_active_minus1;
|
||||
unsigned char num_ref_idx_l1_default_active_minus1;
|
||||
unsigned char lists_modification_present_flag;
|
||||
unsigned char cabac_init_present_flag;
|
||||
unsigned char pps_slice_chroma_qp_offsets_present_flag;
|
||||
|
||||
unsigned char deblocking_filter_override_enabled_flag;
|
||||
unsigned char pps_deblocking_filter_disabled_flag;
|
||||
signed char pps_beta_offset_div2;
|
||||
signed char pps_tc_offset_div2;
|
||||
unsigned char tiles_enabled_flag;
|
||||
unsigned char uniform_spacing_flag;
|
||||
unsigned char num_tile_columns_minus1;
|
||||
unsigned char num_tile_rows_minus1;
|
||||
|
||||
unsigned short column_width_minus1[21];
|
||||
unsigned short row_height_minus1[21];
|
||||
unsigned int reserved3[15];
|
||||
|
||||
// RefPicSets
|
||||
int NumBitsForShortTermRPSInSlice;
|
||||
int NumDeltaPocsOfRefRpsIdx;
|
||||
int NumPocTotalCurr;
|
||||
int NumPocStCurrBefore;
|
||||
int NumPocStCurrAfter;
|
||||
int NumPocLtCurr;
|
||||
int CurrPicOrderCntVal;
|
||||
int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference)
|
||||
int PicOrderCntVal[16]; // [refpic]
|
||||
unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference
|
||||
unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
|
||||
unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15)
|
||||
unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15)
|
||||
unsigned char RefPicSetInterLayer0[8];
|
||||
unsigned char RefPicSetInterLayer1[8];
|
||||
unsigned int reserved4[12];
|
||||
|
||||
// scaling lists (diag order)
|
||||
unsigned char ScalingList4x4[6][16]; // [matrixId][i]
|
||||
unsigned char ScalingList8x8[6][64]; // [matrixId][i]
|
||||
unsigned char ScalingList16x16[6][64]; // [matrixId][i]
|
||||
unsigned char ScalingList32x32[2][64]; // [matrixId][i]
|
||||
unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]
|
||||
unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]
|
||||
} CUVIDHEVCPICPARAMS;
|
||||
|
||||
|
||||
/*!
|
||||
* \struct CUVIDVP8PICPARAMS
|
||||
* VP8 Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDVP8PICPARAMS
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
unsigned int first_partition_size;
|
||||
//Frame Indexes
|
||||
unsigned char LastRefIdx;
|
||||
unsigned char GoldenRefIdx;
|
||||
unsigned char AltRefIdx;
|
||||
union {
|
||||
struct {
|
||||
unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */
|
||||
unsigned char version : 3;
|
||||
unsigned char show_frame : 1;
|
||||
unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */
|
||||
unsigned char Reserved2Bits : 2;
|
||||
};
|
||||
unsigned char wFrameTagFlags;
|
||||
} tagflags;
|
||||
unsigned char Reserved1[4];
|
||||
unsigned int Reserved2[3];
|
||||
} CUVIDVP8PICPARAMS;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDVP9PICPARAMS
|
||||
* VP9 Picture Parameters
|
||||
*/
|
||||
typedef struct _CUVIDVP9PICPARAMS
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
//Frame Indices
|
||||
unsigned char LastRefIdx;
|
||||
unsigned char GoldenRefIdx;
|
||||
unsigned char AltRefIdx;
|
||||
unsigned char colorSpace;
|
||||
|
||||
unsigned short profile : 3;
|
||||
unsigned short frameContextIdx : 2;
|
||||
unsigned short frameType : 1;
|
||||
unsigned short showFrame : 1;
|
||||
unsigned short errorResilient : 1;
|
||||
unsigned short frameParallelDecoding : 1;
|
||||
unsigned short subSamplingX : 1;
|
||||
unsigned short subSamplingY : 1;
|
||||
unsigned short intraOnly : 1;
|
||||
unsigned short allow_high_precision_mv : 1;
|
||||
unsigned short refreshEntropyProbs : 1;
|
||||
unsigned short reserved2Bits : 2;
|
||||
|
||||
unsigned short reserved16Bits;
|
||||
|
||||
unsigned char refFrameSignBias[4];
|
||||
|
||||
unsigned char bitDepthMinus8Luma;
|
||||
unsigned char bitDepthMinus8Chroma;
|
||||
unsigned char loopFilterLevel;
|
||||
unsigned char loopFilterSharpness;
|
||||
|
||||
unsigned char modeRefLfEnabled;
|
||||
unsigned char log2_tile_columns;
|
||||
unsigned char log2_tile_rows;
|
||||
|
||||
unsigned char segmentEnabled : 1;
|
||||
unsigned char segmentMapUpdate : 1;
|
||||
unsigned char segmentMapTemporalUpdate : 1;
|
||||
unsigned char segmentFeatureMode : 1;
|
||||
unsigned char reserved4Bits : 4;
|
||||
|
||||
|
||||
unsigned char segmentFeatureEnable[8][4];
|
||||
short segmentFeatureData[8][4];
|
||||
unsigned char mb_segment_tree_probs[7];
|
||||
unsigned char segment_pred_probs[3];
|
||||
unsigned char reservedSegment16Bits[2];
|
||||
|
||||
int qpYAc;
|
||||
int qpYDc;
|
||||
int qpChDc;
|
||||
int qpChAc;
|
||||
|
||||
unsigned int activeRefIdx[3];
|
||||
unsigned int resetFrameContext;
|
||||
unsigned int mcomp_filter_type;
|
||||
unsigned int mbRefLfDelta[4];
|
||||
unsigned int mbModeLfDelta[2];
|
||||
unsigned int frameTagSize;
|
||||
unsigned int offsetToDctParts;
|
||||
unsigned int reserved128Bits[4];
|
||||
|
||||
} CUVIDVP9PICPARAMS;
|
||||
|
||||
|
||||
/*!
|
||||
* \struct CUVIDPICPARAMS
|
||||
* Picture Parameters for Decoding
|
||||
*/
|
||||
typedef struct _CUVIDPICPARAMS
|
||||
{
|
||||
int PicWidthInMbs; /**< Coded Frame Size */
|
||||
int FrameHeightInMbs; /**< Coded Frame Height */
|
||||
int CurrPicIdx; /**< Output index of the current picture */
|
||||
int field_pic_flag; /**< 0=frame picture, 1=field picture */
|
||||
int bottom_field_flag; /**< 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
|
||||
int second_field; /**< Second field of a complementary field pair */
|
||||
// Bitstream data
|
||||
unsigned int nBitstreamDataLen; /**< Number of bytes in bitstream data buffer */
|
||||
const unsigned char *pBitstreamData; /**< Ptr to bitstream data for this picture (slice-layer) */
|
||||
unsigned int nNumSlices; /**< Number of slices in this picture */
|
||||
const unsigned int *pSliceDataOffsets; /**< nNumSlices entries, contains offset of each slice within the bitstream data buffer */
|
||||
int ref_pic_flag; /**< This picture is a reference picture */
|
||||
int intra_pic_flag; /**< This picture is entirely intra coded */
|
||||
unsigned int Reserved[30]; /**< Reserved for future use */
|
||||
// Codec-specific data
|
||||
union {
|
||||
CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */
|
||||
CUVIDH264PICPARAMS h264;
|
||||
CUVIDVC1PICPARAMS vc1;
|
||||
CUVIDMPEG4PICPARAMS mpeg4;
|
||||
CUVIDJPEGPICPARAMS jpeg;
|
||||
CUVIDHEVCPICPARAMS hevc;
|
||||
CUVIDVP8PICPARAMS vp8;
|
||||
CUVIDVP9PICPARAMS vp9;
|
||||
unsigned int CodecReserved[1024];
|
||||
} CodecSpecific;
|
||||
} CUVIDPICPARAMS;
|
||||
|
||||
|
||||
/*!
|
||||
* \struct CUVIDPROCPARAMS
|
||||
* Picture Parameters for Postprocessing
|
||||
*/
|
||||
typedef struct _CUVIDPROCPARAMS
|
||||
{
|
||||
int progressive_frame; /**< Input is progressive (deinterlace_mode will be ignored) */
|
||||
int second_field; /**< Output the second field (ignored if deinterlace mode is Weave) */
|
||||
int top_field_first; /**< Input frame is top field first (1st field is top, 2nd field is bottom) */
|
||||
int unpaired_field; /**< Input only contains one field (2nd field is invalid) */
|
||||
// The fields below are used for raw YUV input
|
||||
unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
|
||||
unsigned int reserved_zero; /**< Reserved (set to zero) */
|
||||
unsigned long long raw_input_dptr; /**< Input CUdeviceptr for raw YUV extensions */
|
||||
unsigned int raw_input_pitch; /**< pitch in bytes of raw YUV input (should be aligned appropriately) */
|
||||
unsigned int raw_input_format; /**< Reserved for future use (set to zero) */
|
||||
unsigned long long raw_output_dptr; /**< Reserved for future use (set to zero) */
|
||||
unsigned int raw_output_pitch; /**< Reserved for future use (set to zero) */
|
||||
unsigned int Reserved[48];
|
||||
void *Reserved3[3];
|
||||
} CUVIDPROCPARAMS;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* In order to minimize decode latencies, there should be always at least 2 pictures in the decode
|
||||
* queue at any time, in order to make sure that all decode engines are always busy.
|
||||
*
|
||||
* Overall data flow:
|
||||
* - cuvidCreateDecoder(...)
|
||||
* For each picture:
|
||||
* - cuvidDecodePicture(N)
|
||||
* - cuvidMapVideoFrame(N-4)
|
||||
* - do some processing in cuda
|
||||
* - cuvidUnmapVideoFrame(N-4)
|
||||
* - cuvidDecodePicture(N+1)
|
||||
* - cuvidMapVideoFrame(N-3)
|
||||
* ...
|
||||
* - cuvidDestroyDecoder(...)
|
||||
*
|
||||
* NOTE:
|
||||
* - When the cuda context is created from a D3D device, the D3D device must also be created
|
||||
* with the D3DCREATE_MULTITHREADED flag.
|
||||
* - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
|
||||
* - cuVidDecodePicture may block the calling thread if there are too many pictures pending
|
||||
* in the decode queue
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
|
||||
* Create the decoder object
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
|
||||
* Destroy the decoder object
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
|
||||
* Decode a single picture (field or frame)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
|
||||
|
||||
|
||||
#if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
|
||||
* Post-process and map a video frame for use in cuda
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
|
||||
unsigned int *pDevPtr, unsigned int *pPitch,
|
||||
CUVIDPROCPARAMS *pVPP);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
|
||||
* Unmap a previously mapped video frame
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
|
||||
#endif
|
||||
|
||||
#if defined(WIN64) || defined(_WIN64) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
|
||||
* map a video frame
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
|
||||
unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
|
||||
* Unmap a previously mapped video frame
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
|
||||
|
||||
#if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
|
||||
#define tcuvidMapVideoFrame tcuvidMapVideoFrame64
|
||||
#define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Context-locking: to facilitate multi-threaded implementations, the following 4 functions
|
||||
* provide a simple mutex-style host synchronization. If a non-NULL context is specified
|
||||
* in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
|
||||
* context before making any cuda calls.
|
||||
* A multi-threaded application could create a lock associated with a context handle so that
|
||||
* multiple threads can safely share the same cuda context:
|
||||
* - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
|
||||
* that can be passed to cuvidCtxLockCreate.
|
||||
* - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
|
||||
*
|
||||
* NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
|
||||
* decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
|
||||
|
||||
/** @} */ /* End VIDEO_DECODER */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // __CUDA_VIDEO_H__
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* This copyright notice applies to this header file only:
|
||||
*
|
||||
* Copyright (c) 2016
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the software, and to permit persons to whom the
|
||||
* software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef AV_COMPAT_CUDA_DYNLINK_LOADER_H
|
||||
#define AV_COMPAT_CUDA_DYNLINK_LOADER_H
|
||||
|
||||
#include "compat/cuda/dynlink_cuda.h"
|
||||
#include "compat/cuda/dynlink_nvcuvid.h"
|
||||
#include "compat/nvenc/nvEncodeAPI.h"
|
||||
#include "compat/w32dlfcn.h"
|
||||
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/error.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define LIB_HANDLE HMODULE
|
||||
#else
|
||||
# define LIB_HANDLE void*
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# define CUDA_LIBNAME "nvcuda.dll"
|
||||
# define NVCUVID_LIBNAME "nvcuvid.dll"
|
||||
# if ARCH_X86_64
|
||||
# define NVENC_LIBNAME "nvEncodeAPI64.dll"
|
||||
# else
|
||||
# define NVENC_LIBNAME "nvEncodeAPI.dll"
|
||||
# endif
|
||||
#else
|
||||
# define CUDA_LIBNAME "libcuda.so.1"
|
||||
# define NVCUVID_LIBNAME "libnvcuvid.so.1"
|
||||
# define NVENC_LIBNAME "libnvidia-encode.so.1"
|
||||
#endif
|
||||
|
||||
#define LOAD_LIBRARY(l, path) \
|
||||
do { \
|
||||
if (!((l) = dlopen(path, RTLD_LAZY))) { \
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", path); \
|
||||
ret = AVERROR_UNKNOWN; \
|
||||
goto error; \
|
||||
} \
|
||||
av_log(NULL, AV_LOG_TRACE, "Loaded lib: %s\n", path); \
|
||||
} while (0)
|
||||
|
||||
#define LOAD_SYMBOL(fun, symbol) \
|
||||
do { \
|
||||
if (!((f->fun) = dlsym(f->lib, symbol))) { \
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
|
||||
ret = AVERROR_UNKNOWN; \
|
||||
goto error; \
|
||||
} \
|
||||
av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
|
||||
} while (0)
|
||||
|
||||
#define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N) \
|
||||
T *f; \
|
||||
int ret; \
|
||||
\
|
||||
n##_free_functions(functions); \
|
||||
\
|
||||
f = *functions = av_mallocz(sizeof(*f)); \
|
||||
if (!f) \
|
||||
return AVERROR(ENOMEM); \
|
||||
\
|
||||
LOAD_LIBRARY(f->lib, N);
|
||||
|
||||
#define GENERIC_LOAD_FUNC_FINALE(n) \
|
||||
return 0; \
|
||||
error: \
|
||||
n##_free_functions(functions); \
|
||||
return ret;
|
||||
|
||||
#define GENERIC_FREE_FUNC() \
|
||||
if (!functions) \
|
||||
return; \
|
||||
if (*functions && (*functions)->lib) \
|
||||
dlclose((*functions)->lib); \
|
||||
av_freep(functions);
|
||||
|
||||
#ifdef AV_COMPAT_DYNLINK_CUDA_H
|
||||
typedef struct CudaFunctions {
|
||||
tcuInit *cuInit;
|
||||
tcuDeviceGetCount *cuDeviceGetCount;
|
||||
tcuDeviceGet *cuDeviceGet;
|
||||
tcuDeviceGetName *cuDeviceGetName;
|
||||
tcuDeviceComputeCapability *cuDeviceComputeCapability;
|
||||
tcuCtxCreate_v2 *cuCtxCreate;
|
||||
tcuCtxPushCurrent_v2 *cuCtxPushCurrent;
|
||||
tcuCtxPopCurrent_v2 *cuCtxPopCurrent;
|
||||
tcuCtxDestroy_v2 *cuCtxDestroy;
|
||||
tcuMemAlloc_v2 *cuMemAlloc;
|
||||
tcuMemFree_v2 *cuMemFree;
|
||||
tcuMemcpy2D_v2 *cuMemcpy2D;
|
||||
tcuGetErrorName *cuGetErrorName;
|
||||
tcuGetErrorString *cuGetErrorString;
|
||||
|
||||
LIB_HANDLE lib;
|
||||
} CudaFunctions;
|
||||
#else
|
||||
typedef struct CudaFunctions CudaFunctions;
|
||||
#endif
|
||||
|
||||
typedef struct CuvidFunctions {
|
||||
tcuvidCreateDecoder *cuvidCreateDecoder;
|
||||
tcuvidDestroyDecoder *cuvidDestroyDecoder;
|
||||
tcuvidDecodePicture *cuvidDecodePicture;
|
||||
tcuvidMapVideoFrame *cuvidMapVideoFrame;
|
||||
tcuvidUnmapVideoFrame *cuvidUnmapVideoFrame;
|
||||
tcuvidCtxLockCreate *cuvidCtxLockCreate;
|
||||
tcuvidCtxLockDestroy *cuvidCtxLockDestroy;
|
||||
tcuvidCtxLock *cuvidCtxLock;
|
||||
tcuvidCtxUnlock *cuvidCtxUnlock;
|
||||
|
||||
tcuvidCreateVideoSource *cuvidCreateVideoSource;
|
||||
tcuvidCreateVideoSourceW *cuvidCreateVideoSourceW;
|
||||
tcuvidDestroyVideoSource *cuvidDestroyVideoSource;
|
||||
tcuvidSetVideoSourceState *cuvidSetVideoSourceState;
|
||||
tcuvidGetVideoSourceState *cuvidGetVideoSourceState;
|
||||
tcuvidGetSourceVideoFormat *cuvidGetSourceVideoFormat;
|
||||
tcuvidGetSourceAudioFormat *cuvidGetSourceAudioFormat;
|
||||
tcuvidCreateVideoParser *cuvidCreateVideoParser;
|
||||
tcuvidParseVideoData *cuvidParseVideoData;
|
||||
tcuvidDestroyVideoParser *cuvidDestroyVideoParser;
|
||||
|
||||
LIB_HANDLE lib;
|
||||
} CuvidFunctions;
|
||||
|
||||
typedef struct NvencFunctions {
|
||||
NVENCSTATUS (NVENCAPI *NvEncodeAPICreateInstance)(NV_ENCODE_API_FUNCTION_LIST *functionList);
|
||||
NVENCSTATUS (NVENCAPI *NvEncodeAPIGetMaxSupportedVersion)(uint32_t* version);
|
||||
|
||||
LIB_HANDLE lib;
|
||||
} NvencFunctions;
|
||||
|
||||
#ifdef AV_COMPAT_DYNLINK_CUDA_H
|
||||
static inline void cuda_free_functions(CudaFunctions **functions)
|
||||
{
|
||||
GENERIC_FREE_FUNC();
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void cuvid_free_functions(CuvidFunctions **functions)
|
||||
{
|
||||
GENERIC_FREE_FUNC();
|
||||
}
|
||||
|
||||
static inline void nvenc_free_functions(NvencFunctions **functions)
|
||||
{
|
||||
GENERIC_FREE_FUNC();
|
||||
}
|
||||
|
||||
#ifdef AV_COMPAT_DYNLINK_CUDA_H
|
||||
static inline int cuda_load_functions(CudaFunctions **functions)
|
||||
{
|
||||
GENERIC_LOAD_FUNC_PREAMBLE(CudaFunctions, cuda, CUDA_LIBNAME);
|
||||
|
||||
LOAD_SYMBOL(cuInit, "cuInit");
|
||||
LOAD_SYMBOL(cuDeviceGetCount, "cuDeviceGetCount");
|
||||
LOAD_SYMBOL(cuDeviceGet, "cuDeviceGet");
|
||||
LOAD_SYMBOL(cuDeviceGetName, "cuDeviceGetName");
|
||||
LOAD_SYMBOL(cuDeviceComputeCapability, "cuDeviceComputeCapability");
|
||||
LOAD_SYMBOL(cuCtxCreate, "cuCtxCreate_v2");
|
||||
LOAD_SYMBOL(cuCtxPushCurrent, "cuCtxPushCurrent_v2");
|
||||
LOAD_SYMBOL(cuCtxPopCurrent, "cuCtxPopCurrent_v2");
|
||||
LOAD_SYMBOL(cuCtxDestroy, "cuCtxDestroy_v2");
|
||||
LOAD_SYMBOL(cuMemAlloc, "cuMemAlloc_v2");
|
||||
LOAD_SYMBOL(cuMemFree, "cuMemFree_v2");
|
||||
LOAD_SYMBOL(cuMemcpy2D, "cuMemcpy2D_v2");
|
||||
LOAD_SYMBOL(cuGetErrorName, "cuGetErrorName");
|
||||
LOAD_SYMBOL(cuGetErrorString, "cuGetErrorString");
|
||||
|
||||
GENERIC_LOAD_FUNC_FINALE(cuda);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int cuvid_load_functions(CuvidFunctions **functions)
|
||||
{
|
||||
GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
|
||||
|
||||
LOAD_SYMBOL(cuvidCreateDecoder, "cuvidCreateDecoder");
|
||||
LOAD_SYMBOL(cuvidDestroyDecoder, "cuvidDestroyDecoder");
|
||||
LOAD_SYMBOL(cuvidDecodePicture, "cuvidDecodePicture");
|
||||
#ifdef __CUVID_DEVPTR64
|
||||
LOAD_SYMBOL(cuvidMapVideoFrame, "cuvidMapVideoFrame64");
|
||||
LOAD_SYMBOL(cuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64");
|
||||
#else
|
||||
LOAD_SYMBOL(cuvidMapVideoFrame, "cuvidMapVideoFrame");
|
||||
LOAD_SYMBOL(cuvidUnmapVideoFrame, "cuvidUnmapVideoFrame");
|
||||
#endif
|
||||
LOAD_SYMBOL(cuvidCtxLockCreate, "cuvidCtxLockCreate");
|
||||
LOAD_SYMBOL(cuvidCtxLockDestroy, "cuvidCtxLockDestroy");
|
||||
LOAD_SYMBOL(cuvidCtxLock, "cuvidCtxLock");
|
||||
LOAD_SYMBOL(cuvidCtxUnlock, "cuvidCtxUnlock");
|
||||
|
||||
LOAD_SYMBOL(cuvidCreateVideoSource, "cuvidCreateVideoSource");
|
||||
LOAD_SYMBOL(cuvidCreateVideoSourceW, "cuvidCreateVideoSourceW");
|
||||
LOAD_SYMBOL(cuvidDestroyVideoSource, "cuvidDestroyVideoSource");
|
||||
LOAD_SYMBOL(cuvidSetVideoSourceState, "cuvidSetVideoSourceState");
|
||||
LOAD_SYMBOL(cuvidGetVideoSourceState, "cuvidGetVideoSourceState");
|
||||
LOAD_SYMBOL(cuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat");
|
||||
LOAD_SYMBOL(cuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat");
|
||||
LOAD_SYMBOL(cuvidCreateVideoParser, "cuvidCreateVideoParser");
|
||||
LOAD_SYMBOL(cuvidParseVideoData, "cuvidParseVideoData");
|
||||
LOAD_SYMBOL(cuvidDestroyVideoParser, "cuvidDestroyVideoParser");
|
||||
|
||||
GENERIC_LOAD_FUNC_FINALE(cuvid);
|
||||
}
|
||||
|
||||
static inline int nvenc_load_functions(NvencFunctions **functions)
|
||||
{
|
||||
GENERIC_LOAD_FUNC_PREAMBLE(NvencFunctions, nvenc, NVENC_LIBNAME);
|
||||
|
||||
LOAD_SYMBOL(NvEncodeAPICreateInstance, "NvEncodeAPICreateInstance");
|
||||
LOAD_SYMBOL(NvEncodeAPIGetMaxSupportedVersion, "NvEncodeAPIGetMaxSupportedVersion");
|
||||
|
||||
GENERIC_LOAD_FUNC_FINALE(nvenc);
|
||||
}
|
||||
|
||||
#undef GENERIC_LOAD_FUNC_PREAMBLE
|
||||
#undef LOAD_LIBRARY
|
||||
#undef LOAD_SYMBOL
|
||||
#undef GENERIC_LOAD_FUNC_FINALE
|
||||
#undef GENERIC_FREE_FUNC
|
||||
#undef CUDA_LIBNAME
|
||||
#undef NVCUVID_LIBNAME
|
||||
#undef NVENC_LIBNAME
|
||||
#undef LIB_HANDLE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,316 +0,0 @@
|
||||
/*
|
||||
* This copyright notice applies to this header file only:
|
||||
*
|
||||
* Copyright (c) 2010-2016 NVIDIA Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the software, and to permit persons to whom the
|
||||
* software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file nvcuvid.h
|
||||
* NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
|
||||
* \date 2015-2015
|
||||
* This file contains the interface constants, structure definitions and function prototypes.
|
||||
*/
|
||||
|
||||
#if !defined(__NVCUVID_H__)
|
||||
#define __NVCUVID_H__
|
||||
|
||||
#include "compat/cuda/dynlink_cuviddec.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// High-level helper APIs for video sources
|
||||
//
|
||||
|
||||
typedef void *CUvideosource;
|
||||
typedef void *CUvideoparser;
|
||||
typedef long long CUvideotimestamp;
|
||||
|
||||
/**
|
||||
* \addtogroup VIDEO_PARSER Video Parser
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \enum cudaVideoState
|
||||
* Video Source State
|
||||
*/
|
||||
typedef enum {
|
||||
cudaVideoState_Error = -1, /**< Error state (invalid source) */
|
||||
cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */
|
||||
cudaVideoState_Started = 1 /**< Source is running and delivering data */
|
||||
} cudaVideoState;
|
||||
|
||||
/*!
|
||||
* \enum cudaAudioCodec
|
||||
* Audio compression
|
||||
*/
|
||||
typedef enum {
|
||||
cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */
|
||||
cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */
|
||||
cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */
|
||||
cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */
|
||||
cudaAudioCodec_LPCM /**< PCM Audio */
|
||||
} cudaAudioCodec;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDEOFORMAT
|
||||
* Video format
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
cudaVideoCodec codec; /**< Compression format */
|
||||
/**
|
||||
* frame rate = numerator / denominator (for example: 30000/1001)
|
||||
*/
|
||||
struct {
|
||||
unsigned int numerator; /**< frame rate numerator (0 = unspecified or variable frame rate) */
|
||||
unsigned int denominator; /**< frame rate denominator (0 = unspecified or variable frame rate) */
|
||||
} frame_rate;
|
||||
unsigned char progressive_sequence; /**< 0=interlaced, 1=progressive */
|
||||
unsigned char bit_depth_luma_minus8; /**< high bit depth Luma */
|
||||
unsigned char bit_depth_chroma_minus8; /**< high bit depth Chroma */
|
||||
unsigned char reserved1; /**< Reserved for future use */
|
||||
unsigned int coded_width; /**< coded frame width */
|
||||
unsigned int coded_height; /**< coded frame height */
|
||||
/**
|
||||
* area of the frame that should be displayed
|
||||
* typical example:
|
||||
* coded_width = 1920, coded_height = 1088
|
||||
* display_area = { 0,0,1920,1080 }
|
||||
*/
|
||||
struct {
|
||||
int left; /**< left position of display rect */
|
||||
int top; /**< top position of display rect */
|
||||
int right; /**< right position of display rect */
|
||||
int bottom; /**< bottom position of display rect */
|
||||
} display_area;
|
||||
cudaVideoChromaFormat chroma_format; /**< Chroma format */
|
||||
unsigned int bitrate; /**< video bitrate (bps, 0=unknown) */
|
||||
/**
|
||||
* Display Aspect Ratio = x:y (4:3, 16:9, etc)
|
||||
*/
|
||||
struct {
|
||||
int x;
|
||||
int y;
|
||||
} display_aspect_ratio;
|
||||
/**
|
||||
* Video Signal Description
|
||||
*/
|
||||
struct {
|
||||
unsigned char video_format : 3;
|
||||
unsigned char video_full_range_flag : 1;
|
||||
unsigned char reserved_zero_bits : 4;
|
||||
unsigned char color_primaries;
|
||||
unsigned char transfer_characteristics;
|
||||
unsigned char matrix_coefficients;
|
||||
} video_signal_description;
|
||||
unsigned int seqhdr_data_length; /**< Additional bytes following (CUVIDEOFORMATEX) */
|
||||
} CUVIDEOFORMAT;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDEOFORMATEX
|
||||
* Video format including raw sequence header information
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
CUVIDEOFORMAT format;
|
||||
unsigned char raw_seqhdr_data[1024];
|
||||
} CUVIDEOFORMATEX;
|
||||
|
||||
/*!
|
||||
* \struct CUAUDIOFORMAT
|
||||
* Audio Formats
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
cudaAudioCodec codec; /**< Compression format */
|
||||
unsigned int channels; /**< number of audio channels */
|
||||
unsigned int samplespersec; /**< sampling frequency */
|
||||
unsigned int bitrate; /**< For uncompressed, can also be used to determine bits per sample */
|
||||
unsigned int reserved1; /**< Reserved for future use */
|
||||
unsigned int reserved2; /**< Reserved for future use */
|
||||
} CUAUDIOFORMAT;
|
||||
|
||||
|
||||
/*!
|
||||
* \enum CUvideopacketflags
|
||||
* Data packet flags
|
||||
*/
|
||||
typedef enum {
|
||||
CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */
|
||||
CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
|
||||
CUVID_PKT_DISCONTINUITY = 0x04 /**< Set when a discontinuity has to be signalled */
|
||||
} CUvideopacketflags;
|
||||
|
||||
/*!
|
||||
* \struct CUVIDSOURCEDATAPACKET
|
||||
* Data Packet
|
||||
*/
|
||||
typedef struct _CUVIDSOURCEDATAPACKET
|
||||
{
|
||||
tcu_ulong flags; /**< Combination of CUVID_PKT_XXX flags */
|
||||
tcu_ulong payload_size; /**< number of bytes in the payload (may be zero if EOS flag is set) */
|
||||
const unsigned char *payload; /**< Pointer to packet payload data (may be NULL if EOS flag is set) */
|
||||
CUvideotimestamp timestamp; /**< Presentation timestamp (10MHz clock), only valid if CUVID_PKT_TIMESTAMP flag is set */
|
||||
} CUVIDSOURCEDATAPACKET;
|
||||
|
||||
// Callback for packet delivery
|
||||
typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *);
|
||||
|
||||
/*!
|
||||
* \struct CUVIDSOURCEPARAMS
|
||||
* Source Params
|
||||
*/
|
||||
typedef struct _CUVIDSOURCEPARAMS
|
||||
{
|
||||
unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
|
||||
unsigned int uReserved1[7]; /**< Reserved for future use - set to zero */
|
||||
void *pUserData; /**< Parameter passed in to the data handlers */
|
||||
PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< Called to deliver audio packets */
|
||||
PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< Called to deliver video packets */
|
||||
void *pvReserved2[8]; /**< Reserved for future use - set to NULL */
|
||||
} CUVIDSOURCEPARAMS;
|
||||
|
||||
/*!
|
||||
* \enum CUvideosourceformat_flags
|
||||
* CUvideosourceformat_flags
|
||||
*/
|
||||
typedef enum {
|
||||
CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */
|
||||
} CUvideosourceformat_flags;
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
|
||||
* Create Video Source
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
|
||||
* Create Video Source
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)
|
||||
* Destroy Video Source
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
|
||||
* Set Video Source state
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state);
|
||||
|
||||
/**
|
||||
* \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)
|
||||
* Get Video Source state
|
||||
*/
|
||||
typedef cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
|
||||
* Get Video Source Format
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
|
||||
* Set Video Source state
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \struct CUVIDPARSERDISPINFO
|
||||
*/
|
||||
typedef struct _CUVIDPARSERDISPINFO
|
||||
{
|
||||
int picture_index; /**< */
|
||||
int progressive_frame; /**< */
|
||||
int top_field_first; /**< */
|
||||
int repeat_first_field; /**< Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) */
|
||||
CUvideotimestamp timestamp; /**< */
|
||||
} CUVIDPARSERDISPINFO;
|
||||
|
||||
//
|
||||
// Parser callbacks
|
||||
// The parser will call these synchronously from within cuvidParseVideoData(), whenever a picture is ready to
|
||||
// be decoded and/or displayed.
|
||||
//
|
||||
typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *);
|
||||
typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *);
|
||||
typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *);
|
||||
|
||||
/**
|
||||
* \struct CUVIDPARSERPARAMS
|
||||
*/
|
||||
typedef struct _CUVIDPARSERPARAMS
|
||||
{
|
||||
cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
|
||||
unsigned int ulMaxNumDecodeSurfaces; /**< Max # of decode surfaces (parser will cycle through these) */
|
||||
unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
|
||||
unsigned int ulErrorThreshold; /**< % Error threshold (0-100) for calling pfnDecodePicture (100=always call pfnDecodePicture even if picture bitstream is fully corrupted) */
|
||||
unsigned int ulMaxDisplayDelay; /**< Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values: 2..4) */
|
||||
unsigned int uReserved1[5]; /**< Reserved for future use - set to 0 */
|
||||
void *pUserData; /**< User data for callbacks */
|
||||
PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< Called before decoding frames and/or whenever there is a format change */
|
||||
PFNVIDDECODECALLBACK pfnDecodePicture; /**< Called when a picture is ready to be decoded (decode order) */
|
||||
PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< Called whenever a picture is ready to be displayed (display order) */
|
||||
void *pvReserved2[7]; /**< Reserved for future use - set to NULL */
|
||||
CUVIDEOFORMATEX *pExtVideoInfo; /**< [Optional] sequence header data from system layer */
|
||||
} CUVIDPARSERPARAMS;
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket);
|
||||
|
||||
/**
|
||||
* \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)
|
||||
*/
|
||||
typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj);
|
||||
|
||||
/** @} */ /* END VIDEO_PARSER */
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // __NVCUVID_H__
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H
|
||||
#define COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H
|
||||
|
||||
#include <dispatch/dispatch.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define sem_t dispatch_semaphore_t
|
||||
#define sem_post(psem) dispatch_semaphore_signal(*psem)
|
||||
#define sem_wait(psem) dispatch_semaphore_wait(*psem, DISPATCH_TIME_FOREVER)
|
||||
#define sem_timedwait(psem, val) dispatch_semaphore_wait(*psem, dispatch_walltime(val, 0))
|
||||
#define sem_destroy(psem) dispatch_release(*psem)
|
||||
|
||||
static inline int compat_sem_init(dispatch_semaphore_t *psem,
|
||||
int unused, int val)
|
||||
{
|
||||
int ret = !!(*psem = dispatch_semaphore_create(val)) - 1;
|
||||
if (ret < 0)
|
||||
errno = ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define sem_init compat_sem_init
|
||||
|
||||
#endif /* COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMPAT_W32DLFCN_H
|
||||
#define COMPAT_W32DLFCN_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#if _WIN32_WINNT < 0x0602
|
||||
#include "libavutil/wchar_filename.h"
|
||||
#endif
|
||||
/**
|
||||
* Safe function used to open dynamic libs. This attempts to improve program security
|
||||
* by removing the current directory from the dll search path. Only dll's found in the
|
||||
* executable or system directory are allowed to be loaded.
|
||||
* @param name The dynamic lib name.
|
||||
* @return A handle to the opened lib.
|
||||
*/
|
||||
static inline HMODULE win32_dlopen(const char *name)
|
||||
{
|
||||
#if _WIN32_WINNT < 0x0602
|
||||
// Need to check if KB2533623 is available
|
||||
if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) {
|
||||
HMODULE module = NULL;
|
||||
wchar_t *path = NULL, *name_w = NULL;
|
||||
DWORD pathlen;
|
||||
if (utf8towchar(name, &name_w))
|
||||
goto exit;
|
||||
path = (wchar_t *)av_mallocz_array(MAX_PATH, sizeof(wchar_t));
|
||||
// Try local directory first
|
||||
pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
|
||||
pathlen = wcsrchr(path, '\\') - path;
|
||||
if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
|
||||
goto exit;
|
||||
path[pathlen] = '\\';
|
||||
wcscpy(path + pathlen + 1, name_w);
|
||||
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (module == NULL) {
|
||||
// Next try System32 directory
|
||||
pathlen = GetSystemDirectoryW(path, MAX_PATH);
|
||||
if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
|
||||
goto exit;
|
||||
path[pathlen] = '\\';
|
||||
wcscpy(path + pathlen + 1, name_w);
|
||||
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
}
|
||||
exit:
|
||||
av_free(path);
|
||||
av_free(name_w);
|
||||
return module;
|
||||
}
|
||||
#endif
|
||||
#ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR
|
||||
# define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200
|
||||
#endif
|
||||
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
|
||||
# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
|
||||
#endif
|
||||
return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
}
|
||||
#define dlopen(name, flags) win32_dlopen(name)
|
||||
#define dlclose FreeLibrary
|
||||
#define dlsym GetProcAddress
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#endif /* COMPAT_W32DLFCN_H */
|
||||
9
doc/.gitignore
vendored
9
doc/.gitignore
vendored
@@ -1,9 +0,0 @@
|
||||
/*.1
|
||||
/*.3
|
||||
/*.html
|
||||
/*.pod
|
||||
/config.texi
|
||||
/avoptions_codec.texi
|
||||
/avoptions_format.texi
|
||||
/fate.txt
|
||||
/print_options
|
||||
295
doc/APIchanges
295
doc/APIchanges
@@ -15,299 +15,6 @@ libavutil: 2015-08-28
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
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< ---------
|
||||
|
||||
2016-02-10 - bc9a596 / 9f61abc - lavf 57.25.100 / 57.3.0 - avformat.h
|
||||
@@ -1377,7 +1084,7 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0
|
||||
* base -- is now stored in AVBufferRef
|
||||
* reference, type, buffer_hints -- are unnecessary in the new API
|
||||
* 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,
|
||||
mb_type, dct_coeff, ref_index -- mpegvideo-specific tables,
|
||||
which are not exported anymore.
|
||||
|
||||
2422
doc/Doxyfile
2422
doc/Doxyfile
File diff suppressed because it is too large
Load Diff
@@ -38,16 +38,13 @@ DOCS = $(DOCS-yes)
|
||||
|
||||
DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd
|
||||
DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
|
||||
DOC_EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
|
||||
DOC_EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video
|
||||
DOC_EXAMPLES-$(CONFIG_AVCODEC_EXAMPLE) += avcodec
|
||||
DOC_EXAMPLES-$(CONFIG_DECODING_ENCODING_EXAMPLE) += decoding_encoding
|
||||
DOC_EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding
|
||||
DOC_EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio
|
||||
DOC_EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video
|
||||
DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs
|
||||
DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
|
||||
DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio
|
||||
DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video
|
||||
DOC_EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient
|
||||
DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata
|
||||
DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE) += muxing
|
||||
DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE) += qsvdec
|
||||
@@ -128,7 +125,7 @@ $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
|
||||
OBJDIRS += doc/examples
|
||||
|
||||
DOXY_INPUT = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c)
|
||||
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) config.mak
|
||||
DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT))
|
||||
|
||||
doc/doxy/html: TAG = DOXY
|
||||
doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT_DEPS)
|
||||
|
||||
@@ -18,7 +18,7 @@ comma-separated list of filters, whose parameters follow the filter
|
||||
name after a '='.
|
||||
|
||||
@example
|
||||
ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
|
||||
ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1/opt2=str2][,filter2] OUTPUT
|
||||
@end example
|
||||
|
||||
Below is a description of the currently available bitstream filters,
|
||||
@@ -26,26 +26,19 @@ with their parameters, if any.
|
||||
|
||||
@section aac_adtstoasc
|
||||
|
||||
Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration
|
||||
bitstream.
|
||||
Convert MPEG-2/4 AAC ADTS to MPEG-4 Audio Specific Configuration
|
||||
bitstream filter.
|
||||
|
||||
This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
|
||||
ADTS header and removes the ADTS header.
|
||||
|
||||
This filter is required for example when copying an AAC stream from a
|
||||
raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or
|
||||
to MOV/MP4 files and related formats such as 3GP or M4A. Please note
|
||||
that it is auto-inserted for MP4A-LATM and MOV/MP4 and related formats.
|
||||
This is required for example when copying an AAC stream from a raw
|
||||
ADTS AAC container to a FLV or a MOV/MP4 file.
|
||||
|
||||
@section chomp
|
||||
|
||||
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
|
||||
|
||||
Add extradata to the beginning of the filtered packets.
|
||||
@@ -74,24 +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
|
||||
@end example
|
||||
|
||||
@section extract_extradata
|
||||
|
||||
Extract the in-band extradata.
|
||||
|
||||
Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
|
||||
or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
|
||||
of the bitstream containing the coded frames) or "out of band" (e.g. on the
|
||||
container level). This latter form is called "extradata" in FFmpeg terminology.
|
||||
|
||||
This bitstream filter detects the in-band headers and makes them available as
|
||||
extradata.
|
||||
|
||||
@table @option
|
||||
@item remove
|
||||
When this option is enabled, the long-term headers are removed from the
|
||||
bitstream after extraction.
|
||||
@end table
|
||||
|
||||
@section h264_mp4toannexb
|
||||
|
||||
Convert an H.264 bitstream from length prefixed mode to start code
|
||||
@@ -99,7 +74,7 @@ prefixed mode (as defined in the Annex B of the ITU-T H.264
|
||||
specification).
|
||||
|
||||
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
|
||||
format with @command{ffmpeg}, you can use the command:
|
||||
@@ -108,29 +83,6 @@ format with @command{ffmpeg}, you can use the command:
|
||||
ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
|
||||
@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 hevc_mp4toannexb
|
||||
|
||||
Convert an HEVC/H.265 bitstream from length prefixed mode to start code
|
||||
prefixed mode (as defined in the Annex B of the ITU-T H.265
|
||||
specification).
|
||||
|
||||
This is required by some streaming formats, typically the MPEG-2
|
||||
transport stream format (muxer @code{mpegts}).
|
||||
|
||||
For example to remux an MP4 file containing an HEVC stream to mpegts
|
||||
format with @command{ffmpeg}, you can use the command:
|
||||
|
||||
@example
|
||||
ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
|
||||
@end example
|
||||
|
||||
Please note that this filter is auto-inserted for MPEG-TS (muxer
|
||||
@code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
|
||||
@code{hevc}) output formats.
|
||||
|
||||
@section imxdump
|
||||
|
||||
Modifies the bitstream to fit in MOV and to be usable by the Final Cut
|
||||
@@ -181,22 +133,11 @@ exiftran -i -9 frame*.jpg
|
||||
ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
|
||||
@end example
|
||||
|
||||
@section mjpegadump
|
||||
@section mjpega_dump_header
|
||||
|
||||
Add an MJPEG A header to the bitstream, to enable decoding by
|
||||
Quicktime.
|
||||
@section movsub
|
||||
|
||||
@anchor{mov2textsub}
|
||||
@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 mp3_header_decompress
|
||||
|
||||
@section mpeg4_unpack_bframes
|
||||
|
||||
@@ -236,38 +177,4 @@ applies the modification to every byte.
|
||||
|
||||
@section remove_extra
|
||||
|
||||
Remove extradata from packets.
|
||||
|
||||
It accepts the following parameter:
|
||||
@table @option
|
||||
@item freq
|
||||
Set which frame types to remove extradata from.
|
||||
|
||||
@table @samp
|
||||
@item k
|
||||
Remove extradata from non-keyframes only.
|
||||
|
||||
@item keyframe
|
||||
Remove extradata from keyframes only.
|
||||
|
||||
@item e, all
|
||||
Remove extradata from all frames.
|
||||
|
||||
@end table
|
||||
@end table
|
||||
|
||||
@anchor{text2movsub}
|
||||
@section text2movsub
|
||||
|
||||
Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
|
||||
codec) with metadata headers.
|
||||
|
||||
See also the @ref{mov2textsub} filter.
|
||||
|
||||
@section vp9_superframe
|
||||
|
||||
Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
|
||||
fixes merging of split/segmented VP9 streams where the alt-ref frame
|
||||
was split from its visible counterpart.
|
||||
|
||||
@c man end BITSTREAM FILTERS
|
||||
|
||||
@@ -39,6 +39,9 @@ examples
|
||||
libavformat/output-example
|
||||
Build the libavformat basic example.
|
||||
|
||||
libavcodec/api-example
|
||||
Build the libavcodec basic example.
|
||||
|
||||
libswscale/swscale-test
|
||||
Build the swscale self-test (useful also as an example).
|
||||
|
||||
|
||||
135
doc/codecs.texi
135
doc/codecs.texi
@@ -138,8 +138,7 @@ Set audio sampling rate (in Hz).
|
||||
Set number of audio channels.
|
||||
|
||||
@item cutoff @var{integer} (@emph{encoding,audio})
|
||||
Set cutoff bandwidth. (Supported only by selected encoders, see
|
||||
their respective documentation sections.)
|
||||
Set cutoff bandwidth.
|
||||
|
||||
@item frame_size @var{integer} (@emph{encoding,audio})
|
||||
Set audio frame size.
|
||||
@@ -258,7 +257,7 @@ Specify how strictly to follow the standards.
|
||||
Possible values:
|
||||
@table @samp
|
||||
@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
|
||||
strictly conform to all the things in the spec no matter what consequences
|
||||
@item normal
|
||||
@@ -457,9 +456,6 @@ Possible values:
|
||||
@item aspect @var{rational number} (@emph{encoding,video})
|
||||
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})
|
||||
Print specific debug info.
|
||||
|
||||
@@ -1050,136 +1046,15 @@ Possible values:
|
||||
@item rc_max_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 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})
|
||||
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})
|
||||
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})
|
||||
If used as input parameter, it serves as a hint to the decoder, which
|
||||
color_range the input has.
|
||||
Possible values:
|
||||
@table @samp
|
||||
@item tv
|
||||
@item mpeg
|
||||
MPEG (219*2^(n-8))
|
||||
@item pc
|
||||
@item jpeg
|
||||
JPEG (2^n-1)
|
||||
@end table
|
||||
|
||||
@item chroma_sample_location @var{integer} (@emph{decoding/encoding,video})
|
||||
Possible values:
|
||||
@table @samp
|
||||
@item left
|
||||
|
||||
@item center
|
||||
|
||||
@item topleft
|
||||
|
||||
@item top
|
||||
|
||||
@item bottomleft
|
||||
|
||||
@item bottom
|
||||
|
||||
@end table
|
||||
|
||||
@item log_level_offset @var{integer}
|
||||
Set the log level offset.
|
||||
@@ -1264,7 +1139,7 @@ Set to 1 to disable processing alpha (transparency). This works like the
|
||||
instead of alpha. Default is 0.
|
||||
|
||||
@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})
|
||||
Separator used to separate the fields printed on the command line about the
|
||||
@@ -1275,10 +1150,6 @@ ffprobe -dump_separator "
|
||||
" -i ~/videos/matrixbench_mpeg2.mpg
|
||||
@end example
|
||||
|
||||
@item max_pixels @var{integer} (@emph{decoding/encoding,video})
|
||||
Maximum number of pixels per image. This value can be used to avoid out of
|
||||
memory failures due to large images.
|
||||
|
||||
@end table
|
||||
|
||||
@c man end CODEC OPTIONS
|
||||
|
||||
@@ -279,7 +279,7 @@ present between the subtitle lines because of double-sized teletext charactes.
|
||||
Default value is 1.
|
||||
@item txt_duration
|
||||
Sets the display duration of the decoded teletext pages or subtitles in
|
||||
milliseconds. Default value is 30000 which is 30 seconds.
|
||||
miliseconds. Default value is 30000 which is 30 seconds.
|
||||
@item txt_transparent
|
||||
Force transparent background of the generated teletext bitmaps. Default value
|
||||
is 0 which means an opaque background.
|
||||
|
||||
@@ -13,9 +13,8 @@ You can disable all the demuxers using the configure option
|
||||
the option @code{--enable-demuxer=@var{DEMUXER}}, or disable it
|
||||
with the option @code{--disable-demuxer=@var{DEMUXER}}.
|
||||
|
||||
The option @code{-demuxers} of the ff* tools will display the list of
|
||||
enabled demuxers. Use @code{-formats} to view a combined list of
|
||||
enabled demuxers and muxers.
|
||||
The option @code{-formats} of the ff* tools will display the list of
|
||||
enabled demuxers.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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 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.
|
||||
|
||||
@item @code{duration @var{dur}}
|
||||
@@ -244,23 +243,30 @@ file subdir/file-2.wav
|
||||
@end example
|
||||
@end itemize
|
||||
|
||||
@section flv, live_flv
|
||||
@section flv
|
||||
|
||||
Adobe Flash Video Format demuxer.
|
||||
|
||||
This demuxer is used to demux FLV files and RTMP network streams. In case of live network streams, if you force format, you may use live_flv option instead of flv to survive timestamp discontinuities.
|
||||
|
||||
@example
|
||||
ffmpeg -f flv -i myfile.flv ...
|
||||
ffmpeg -f live_flv -i rtmp://<any.server>/anything/key ....
|
||||
@end example
|
||||
|
||||
This demuxer is used to demux FLV files and RTMP network streams.
|
||||
|
||||
@table @option
|
||||
@item -flv_metadata @var{bool}
|
||||
Allocate the streams according to the onMetaData array content.
|
||||
@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
|
||||
|
||||
Animated GIF demuxer.
|
||||
@@ -435,49 +441,9 @@ ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv
|
||||
@end example
|
||||
@end itemize
|
||||
|
||||
@section libgme
|
||||
@section mov/mp4/3gp/Quicktme
|
||||
|
||||
The Game Music Emu library is a collection of video game music file emulators.
|
||||
|
||||
See @url{http://code.google.com/p/game-music-emu/} for more information.
|
||||
|
||||
Some files have multiple tracks. The demuxer will pick the first track by
|
||||
default. The @option{track_index} option can be used to select a different
|
||||
track. Track indexes start at 0. The demuxer exports the number of tracks as
|
||||
@var{tracks} meta data entry.
|
||||
|
||||
For very large files, the @option{max_size} option may have to be adjusted.
|
||||
|
||||
@section libopenmpt
|
||||
|
||||
libopenmpt based module demuxer
|
||||
|
||||
See @url{https://lib.openmpt.org/libopenmpt/} for more information.
|
||||
|
||||
Some files have multiple subsongs (tracks) this can be set with the @option{subsong}
|
||||
option.
|
||||
|
||||
It accepts the following options:
|
||||
|
||||
@table @option
|
||||
@item subsong
|
||||
Set the subsong index. This can be either 'all', 'auto', or the index of the
|
||||
subsong. Subsong indexes start at 0. The default is 'auto'.
|
||||
|
||||
The default value is to let libopenmpt choose.
|
||||
|
||||
@item layout
|
||||
Set the channel layout. Valid values are 1, 2, and 4 channel layouts.
|
||||
The default value is STEREO.
|
||||
|
||||
@item sample_rate
|
||||
Set the sample rate for libopenmpt to output.
|
||||
Range is from 1000 to INT_MAX. The value default is 48000.
|
||||
@end table
|
||||
|
||||
@section mov/mp4/3gp/QuickTime
|
||||
|
||||
QuickTime / MP4 demuxer.
|
||||
Quicktime / MP4 demuxer.
|
||||
|
||||
This demuxer accepts the following options:
|
||||
@table @option
|
||||
|
||||
@@ -131,11 +131,6 @@ designated struct initializers (@samp{struct s x = @{ .i = 17 @};});
|
||||
|
||||
@item
|
||||
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
|
||||
|
||||
These features are supported by all compilers we care about, so we will not
|
||||
@@ -251,8 +246,8 @@ For Emacs, add these roughly equivalent lines to your @file{.emacs.d/init.el}:
|
||||
|
||||
@section Development Policy
|
||||
|
||||
@subsection Patches/Committing
|
||||
@subheading Licenses for patches must be compatible with FFmpeg.
|
||||
@enumerate
|
||||
@item
|
||||
Contributions should be licensed under the
|
||||
@uref{http://www.gnu.org/licenses/lgpl-2.1.html, LGPL 2.1},
|
||||
including an "or any later version" clause, or, if you prefer
|
||||
@@ -265,15 +260,15 @@ preferred.
|
||||
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.
|
||||
|
||||
@subheading You must not commit code which breaks FFmpeg!
|
||||
This means unfinished code which is enabled and breaks compilation,
|
||||
or compiles but does not work/breaks the regression tests. Code which
|
||||
is unfinished but disabled may be permitted under-circumstances, like
|
||||
missing samples or an implementation with a small subset of features.
|
||||
Always check the mailing list for any reviewers with issues and test
|
||||
FATE before you push.
|
||||
@item
|
||||
You must not commit code which breaks FFmpeg! (Meaning unfinished but
|
||||
enabled code which breaks compilation or compiles but does not work or
|
||||
breaks the regression tests)
|
||||
You can commit unfinished stuff (for testing etc), but it must be disabled
|
||||
(#ifdef etc) by default so it does not interfere with other developers'
|
||||
work.
|
||||
|
||||
@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
|
||||
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.
|
||||
@@ -281,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
|
||||
not exempt you from writing an excerpt of the bug in the commit message.
|
||||
|
||||
@subheading Testing must be adequate but not excessive.
|
||||
If it works for you, others, and passes FATE then it should be OK to commit
|
||||
it, provided it fits the other committing criteria. You should not worry about
|
||||
over-testing things. If your code has problems (portability, triggers
|
||||
compiler bugs, unusual environment etc) they will be reported and eventually
|
||||
fixed.
|
||||
@item
|
||||
You do not have to over-test things. If it works for you, and you think it
|
||||
should work for others, then commit. If your code has problems
|
||||
(portability, triggers compiler bugs, unusual environment etc) they will be
|
||||
reported and eventually fixed.
|
||||
|
||||
@subheading Do not commit unrelated changes together.
|
||||
They should be split them into self-contained pieces. Also do not forget
|
||||
that if part B depends on part A, but A does not depend on B, then A can
|
||||
and should be committed first and separate from B. Keeping changes well
|
||||
split into self-contained parts makes reviewing and understanding them on
|
||||
the commit log mailing list easier. This also helps in case of debugging
|
||||
later on.
|
||||
@item
|
||||
Do not commit unrelated changes together, split them into self-contained
|
||||
pieces. Also do not forget that if part B depends on part A, but A does not
|
||||
depend on B, then A can and should be committed first and separate from B.
|
||||
Keeping changes well split into self-contained parts makes reviewing and
|
||||
understanding them on the commit log mailing list easier. This also helps
|
||||
in case of debugging later on.
|
||||
Also if you have doubts about splitting or not splitting, do not hesitate to
|
||||
ask/discuss it on the developer mailing list.
|
||||
|
||||
@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)
|
||||
which change behavior, defaults etc, without asking first. The same
|
||||
applies to compiler warning fixes, trivial looking fixes and to code
|
||||
@@ -307,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
|
||||
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
|
||||
with functional changes, such commits will be rejected and removed. Every
|
||||
developer has his own indentation style, you should not change it. Of course
|
||||
@@ -321,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
|
||||
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
|
||||
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.
|
||||
@@ -333,31 +334,47 @@ area changed: Short 1 line description
|
||||
details describing what and why and giving references.
|
||||
@end example
|
||||
|
||||
@subheading Credit the author of the patch.
|
||||
@item
|
||||
Make sure the author of the commit is set correctly. (see git commit --author)
|
||||
If you apply a patch, send an
|
||||
answer to ffmpeg-devel (or wherever you got the patch from) saying that
|
||||
you applied the patch.
|
||||
|
||||
@subheading Complex patches should refer to discussion surrounding them.
|
||||
@item
|
||||
When applying patches that have been discussed (at length) on the mailing
|
||||
list, reference the thread in the log message.
|
||||
|
||||
@subheading Always wait long enough before pushing changes
|
||||
@item
|
||||
Do NOT commit to code actively maintained by others without permission.
|
||||
Send a patch to ffmpeg-devel. If no one answers within a reasonable
|
||||
time-frame (12h for build failures and security fixes, 3 days small changes,
|
||||
Send a patch to ffmpeg-devel instead. If no one answers within a reasonable
|
||||
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.
|
||||
Also note, the maintainer can simply ask for more time to review!
|
||||
|
||||
@subsection Code
|
||||
@subheading API/ABI changes should be discussed before they are made.
|
||||
Do not change behavior of the programs (renaming options etc) or public
|
||||
API or ABI without first discussing it on the ffmpeg-devel mailing list.
|
||||
Do not remove widely used functionality or features (redundant code can be removed).
|
||||
@item
|
||||
Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
|
||||
are sent there and reviewed by all the other developers. Bugs and possible
|
||||
improvements or general questions regarding commits are discussed there. We
|
||||
expect you to react if problems with your code are uncovered.
|
||||
|
||||
@subheading Remember to check if you need to bump versions for libav*.
|
||||
Depending on the change, you may need to change the version integer.
|
||||
@item
|
||||
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
|
||||
previous versions (e.g. removal of a function from the public API).
|
||||
Incrementing the second component means backward compatible change
|
||||
@@ -367,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
|
||||
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
|
||||
warning always points to correct and clean code, that warning should
|
||||
be disabled, not the code changed.
|
||||
@@ -376,33 +393,13 @@ If it is a bug, the bug has to be fixed. If it is not, the code should
|
||||
be changed to not generate a warning unless that causes a slowdown
|
||||
or obfuscates the code.
|
||||
|
||||
@subheading Check untrusted input properly.
|
||||
Never write to unallocated memory, never write over the end of arrays,
|
||||
always check values read from some untrusted source before using them
|
||||
as array index or other risky things.
|
||||
|
||||
@subsection Documentation/Other
|
||||
@subheading Subscribe to the ffmpeg-cvslog mailing list.
|
||||
It is important to do this as the diffs of all commits are sent there and
|
||||
reviewed by all the other developers. Bugs and possible improvements or
|
||||
general questions regarding commits are discussed there. We expect you to
|
||||
react if problems with your code are uncovered.
|
||||
|
||||
@subheading Keep the documentation up to date.
|
||||
Update the documentation if you change behavior or add features. If you are
|
||||
unsure how best to do this, send a patch to ffmpeg-devel, the documentation
|
||||
maintainer(s) will review and commit your stuff.
|
||||
|
||||
@subheading Important discussions should be accessible to all.
|
||||
Try to keep important discussions and requests (also) on the public
|
||||
developer mailing list, so that all developers can benefit from them.
|
||||
|
||||
@subheading Check your entries in MAINTAINERS.
|
||||
@item
|
||||
Make sure that no parts of the codebase that you maintain are missing from the
|
||||
@file{MAINTAINERS} file. If something that you want to maintain is missing add it with
|
||||
your name after it.
|
||||
If at some point you no longer want to maintain some code, then please help in
|
||||
finding a new maintainer and also don't forget to update the @file{MAINTAINERS} file.
|
||||
@end enumerate
|
||||
|
||||
We think our rules are not too hard. If you have comments, contact us.
|
||||
|
||||
@@ -469,11 +466,7 @@ Patches should be posted to the
|
||||
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
|
||||
as base64-encoded attachments, so your patch is not trashed during
|
||||
transmission. Also ensure the correct mime type is used
|
||||
(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.
|
||||
transmission.
|
||||
|
||||
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
|
||||
|
||||
1
doc/doxy/.gitignore
vendored
1
doc/doxy/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/html/
|
||||
@@ -61,9 +61,8 @@ Two loop searching (TLS) method.
|
||||
|
||||
This method first sets quantizers depending on band thresholds and then tries
|
||||
to find an optimal combination by adding or subtracting a specific value from
|
||||
all quantizers and adjusting some individual quantizer a little. Will tune
|
||||
itself based on whether @option{aac_is}, @option{aac_ms} and @option{aac_pns}
|
||||
are enabled.
|
||||
all quantizers and adjusting some individual quantizer a little.
|
||||
Will tune itself based on whether aac_is/aac_ms/aac_pns are enabled.
|
||||
This is the default choice for a coder.
|
||||
|
||||
@item anmr
|
||||
@@ -85,7 +84,7 @@ Not recommended.
|
||||
@end table
|
||||
|
||||
@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
|
||||
using the value "enable", which is mainly useful for debugging or disabled using
|
||||
"disable".
|
||||
@@ -131,20 +130,20 @@ The default, AAC "Low-complexity" profile. Is the most compatible and produces
|
||||
decent quality.
|
||||
|
||||
@item mpeg2_aac_low
|
||||
Equivalent to @code{-profile:a aac_low -aac_pns 0}. PNS was introduced with the
|
||||
MPEG4 specifications.
|
||||
Equivalent to -profile:a aac_low -aac_pns 0. PNS was introduced with the MPEG4
|
||||
specifications.
|
||||
|
||||
@item aac_ltp
|
||||
Long term prediction profile, is enabled by and will enable the @option{aac_ltp}
|
||||
option. Introduced in MPEG4.
|
||||
Long term prediction profile, is enabled by and will enable the aac_ltp option.
|
||||
Introduced in MPEG4.
|
||||
|
||||
@item aac_main
|
||||
Main-type prediction profile, is enabled by and will enable the @option{aac_pred}
|
||||
option. Introduced in MPEG2.
|
||||
Main-type prediction profile, is enabled by and will enable the aac_pred option.
|
||||
Introduced in MPEG2.
|
||||
|
||||
@end table
|
||||
If this option is unspecified it is set to @samp{aac_low}.
|
||||
@end table
|
||||
@end table
|
||||
|
||||
@section ac3 and ac3_fixed
|
||||
|
||||
@@ -488,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
|
||||
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
|
||||
|
||||
@subsection Floating-Point-Only AC-3 Encoding Options
|
||||
@@ -549,8 +544,7 @@ The following options are supported by FFmpeg's flac encoder.
|
||||
@table @option
|
||||
@item compression_level
|
||||
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
|
||||
default.
|
||||
if they are not set explicitly.
|
||||
|
||||
@item frame_size
|
||||
Sets the size of the frames in samples per channel.
|
||||
@@ -617,27 +611,111 @@ and slightly improves compression.
|
||||
|
||||
@end table
|
||||
|
||||
@anchor{opusenc}
|
||||
@section opus
|
||||
@anchor{libfaac}
|
||||
@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
|
||||
only implements the CELT part of the codec. Its quality is usually worse and at best
|
||||
is equal to the libopus encoder.
|
||||
This encoder is of much lower quality and is more unstable than any other AAC
|
||||
encoders, so it's highly recommended to instead use other encoders, like
|
||||
@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
|
||||
|
||||
@table @option
|
||||
@item b
|
||||
Set bit rate in bits/s. If unspecified it uses the number of channels and the layout
|
||||
to make a good guess.
|
||||
The following shared FFmpeg codec options are recognized.
|
||||
|
||||
@item opus_delay
|
||||
Sets the maximum delay in milliseconds. Lower delays than 20ms will very quickly
|
||||
decrease quality.
|
||||
The following options are supported by the libfaac wrapper. The
|
||||
@command{faac}-equivalent of the options are listed in parentheses.
|
||||
|
||||
@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
|
||||
|
||||
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}
|
||||
@section libfdk_aac
|
||||
|
||||
@@ -843,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
|
||||
while producing the worst quality.
|
||||
|
||||
@item cutoff (@emph{--lowpass})
|
||||
Set lowpass cutoff frequency. If unspecified, the encoder dynamically
|
||||
adjusts the cutoff.
|
||||
|
||||
@item reservoir
|
||||
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
|
||||
@@ -900,90 +974,6 @@ default value is 0 (disabled).
|
||||
|
||||
@end table
|
||||
|
||||
@section libopus
|
||||
|
||||
libopus Opus Interactive Audio Codec encoder wrapper.
|
||||
|
||||
Requires the presence of the libopus headers and library during
|
||||
configuration. You need to explicitly configure the build with
|
||||
@code{--enable-libopus}.
|
||||
|
||||
@subsection Option Mapping
|
||||
|
||||
Most libopus options are 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.
|
||||
|
||||
@end table
|
||||
|
||||
@anchor{libshine}
|
||||
@section libshine
|
||||
|
||||
@@ -1123,6 +1113,79 @@ default value is 0 (disabled).
|
||||
|
||||
@end table
|
||||
|
||||
@section libopus
|
||||
|
||||
libopus Opus Interactive Audio Codec encoder wrapper.
|
||||
|
||||
Requires the presence of the libopus headers and library during
|
||||
configuration. You need to explicitly configure the build with
|
||||
@code{--enable-libopus}.
|
||||
|
||||
@subsection Option Mapping
|
||||
|
||||
Most libopus options are 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
|
||||
|
||||
libvorbis encoder wrapper.
|
||||
@@ -1222,27 +1285,6 @@ Same as @samp{3}, but with extra processing enabled.
|
||||
@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}
|
||||
@section wavpack
|
||||
|
||||
@@ -1312,81 +1354,6 @@ disabled
|
||||
A description of some of the currently available video encoders
|
||||
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
|
||||
|
||||
Cisco libopenh264 H.264/MPEG-4 AVC encoder wrapper.
|
||||
@@ -1423,7 +1390,7 @@ is 0. This is only used when @option{slice_mode} is set to
|
||||
@samp{fixed}.
|
||||
|
||||
@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
|
||||
@item fixed
|
||||
@@ -1453,6 +1420,30 @@ Set maximum NAL size in bytes.
|
||||
Allow skipping frames to hit the target bitrate if set to 1.
|
||||
@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
|
||||
|
||||
libtheora Theora encoder wrapper.
|
||||
@@ -1686,6 +1677,7 @@ colorspaces:
|
||||
For more information about libvpx see:
|
||||
@url{http://www.webmproject.org/}
|
||||
|
||||
|
||||
@section libwebp
|
||||
|
||||
libwebp WebP Image encoder wrapper
|
||||
@@ -1852,10 +1844,6 @@ Exhaustive search.
|
||||
Hadamard exhaustive search (slowest).
|
||||
@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})
|
||||
Sub-pixel motion estimation method.
|
||||
|
||||
@@ -1878,7 +1866,7 @@ Enable CAVLC and disable CABAC. It generates the same effect as
|
||||
@end table
|
||||
|
||||
@item cmp
|
||||
Set full pixel motion estimation comparison algorithm. Possible values:
|
||||
Set full pixel motion estimation comparation algorithm. Possible values:
|
||||
|
||||
@table @samp
|
||||
@item chroma
|
||||
@@ -2109,7 +2097,7 @@ ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
|
||||
|
||||
@item a53cc @var{boolean}
|
||||
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.)
|
||||
Override the x264 configuration using a :-separated list of key=value
|
||||
@@ -2146,10 +2134,6 @@ Set the x265 preset.
|
||||
@item tune
|
||||
Set the x265 tune parameter.
|
||||
|
||||
@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
|
||||
Set x265 options using a list of @var{key}=@var{value} couples separated
|
||||
by ":". See @command{x265 --help} for a list of options.
|
||||
@@ -2428,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
|
||||
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
|
||||
|
||||
The family of Intel QuickSync Video encoders (MPEG-2, H.264 and HEVC)
|
||||
@@ -2516,15 +2521,6 @@ encoder use CAVLC instead of CABAC.
|
||||
|
||||
@end itemize
|
||||
|
||||
@section snow
|
||||
|
||||
@subsection Options
|
||||
|
||||
@table @option
|
||||
@item iterative_dia_size
|
||||
dia size for the iterative motion estimation
|
||||
@end table
|
||||
|
||||
@section vc2
|
||||
|
||||
SMPTE VC-2 (previously BBC Dirac Pro). This codec was primarily aimed at
|
||||
|
||||
21
doc/examples/.gitignore
vendored
21
doc/examples/.gitignore
vendored
@@ -1,21 +0,0 @@
|
||||
/avio_dir_cmd
|
||||
/avio_reading
|
||||
/decode_audio
|
||||
/decode_video
|
||||
/demuxing_decoding
|
||||
/encode_audio
|
||||
/encode_video
|
||||
/extract_mvs
|
||||
/filter_audio
|
||||
/filtering_audio
|
||||
/filtering_video
|
||||
/http_multiclient
|
||||
/metadata
|
||||
/muxing
|
||||
/pc-uninstalled
|
||||
/qsvdec
|
||||
/remuxing
|
||||
/resampling_audio
|
||||
/scaling_video
|
||||
/transcode_aac
|
||||
/transcoding
|
||||
@@ -13,11 +13,8 @@ LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
|
||||
|
||||
EXAMPLES= avio_dir_cmd \
|
||||
avio_reading \
|
||||
decode_audio \
|
||||
decode_video \
|
||||
decoding_encoding \
|
||||
demuxing_decoding \
|
||||
encode_audio \
|
||||
encode_video \
|
||||
extract_mvs \
|
||||
filtering_video \
|
||||
filtering_audio \
|
||||
@@ -34,7 +31,7 @@ OBJS=$(addsuffix .o,$(EXAMPLES))
|
||||
|
||||
# the following examples make explicit use of the math library
|
||||
avcodec: LDLIBS += -lm
|
||||
encode_audio: LDLIBS += -lm
|
||||
decoding_encoding: LDLIBS += -lm
|
||||
muxing: LDLIBS += -lm
|
||||
resampling_audio: LDLIBS += -lm
|
||||
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio decoding with libavcodec API example
|
||||
*
|
||||
* @example decode_audio.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libavutil/frame.h>
|
||||
#include <libavutil/mem.h>
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#define AUDIO_INBUF_SIZE 20480
|
||||
#define AUDIO_REFILL_THRESH 4096
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *outfilename, *filename;
|
||||
const AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
int len;
|
||||
FILE *f, *outfile;
|
||||
uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
||||
AVPacket avpkt;
|
||||
AVFrame *decoded_frame = NULL;
|
||||
|
||||
if (argc <= 2) {
|
||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
filename = argv[1];
|
||||
outfilename = argv[2];
|
||||
|
||||
/* register all the codecs */
|
||||
avcodec_register_all();
|
||||
|
||||
av_init_packet(&avpkt);
|
||||
|
||||
/* find the MPEG audio decoder */
|
||||
codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate audio codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
outfile = fopen(outfilename, "wb");
|
||||
if (!outfile) {
|
||||
av_free(c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* decode until eof */
|
||||
avpkt.data = inbuf;
|
||||
avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
|
||||
|
||||
while (avpkt.size > 0) {
|
||||
int i, ch;
|
||||
int got_frame = 0;
|
||||
|
||||
if (!decoded_frame) {
|
||||
if (!(decoded_frame = av_frame_alloc())) {
|
||||
fprintf(stderr, "Could not allocate audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "Error while decoding\n");
|
||||
exit(1);
|
||||
}
|
||||
if (got_frame) {
|
||||
/* if a frame has been decoded, output it */
|
||||
int data_size = av_get_bytes_per_sample(c->sample_fmt);
|
||||
if (data_size < 0) {
|
||||
/* This should not occur, checking just for paranoia */
|
||||
fprintf(stderr, "Failed to calculate data size\n");
|
||||
exit(1);
|
||||
}
|
||||
for (i=0; i<decoded_frame->nb_samples; i++)
|
||||
for (ch=0; ch<c->channels; ch++)
|
||||
fwrite(decoded_frame->data[ch] + data_size*i, 1, data_size, outfile);
|
||||
}
|
||||
avpkt.size -= len;
|
||||
avpkt.data += len;
|
||||
avpkt.dts =
|
||||
avpkt.pts = AV_NOPTS_VALUE;
|
||||
if (avpkt.size < AUDIO_REFILL_THRESH) {
|
||||
/* Refill the input buffer, to avoid trying to decode
|
||||
* incomplete frames. Instead of this, one could also use
|
||||
* a parser, or use a proper container format through
|
||||
* libavformat. */
|
||||
memmove(inbuf, avpkt.data, avpkt.size);
|
||||
avpkt.data = inbuf;
|
||||
len = fread(avpkt.data + avpkt.size, 1,
|
||||
AUDIO_INBUF_SIZE - avpkt.size, f);
|
||||
if (len > 0)
|
||||
avpkt.size += len;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(outfile);
|
||||
fclose(f);
|
||||
|
||||
avcodec_free_context(&c);
|
||||
av_frame_free(&decoded_frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* video decoding with libavcodec API example
|
||||
*
|
||||
* @example decode_video.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#define INBUF_SIZE 4096
|
||||
|
||||
static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
|
||||
char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
f = fopen(filename,"w");
|
||||
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
|
||||
for (i = 0; i < ysize; i++)
|
||||
fwrite(buf + i * wrap, 1, xsize, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,
|
||||
AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
|
||||
{
|
||||
int len, got_frame;
|
||||
char buf[1024];
|
||||
|
||||
len = avcodec_decode_video2(avctx, frame, &got_frame, pkt);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
|
||||
return len;
|
||||
}
|
||||
if (got_frame) {
|
||||
printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);
|
||||
fflush(stdout);
|
||||
|
||||
/* the picture is allocated by the decoder, no need to free it */
|
||||
snprintf(buf, sizeof(buf), "%s-%d", outfilename, *frame_count);
|
||||
pgm_save(frame->data[0], frame->linesize[0],
|
||||
frame->width, frame->height, buf);
|
||||
(*frame_count)++;
|
||||
}
|
||||
if (pkt->data) {
|
||||
pkt->size -= len;
|
||||
pkt->data += len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *filename, *outfilename;
|
||||
const AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
int frame_count;
|
||||
FILE *f;
|
||||
AVFrame *frame;
|
||||
uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
|
||||
AVPacket avpkt;
|
||||
|
||||
if (argc <= 2) {
|
||||
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
filename = argv[1];
|
||||
outfilename = argv[2];
|
||||
|
||||
avcodec_register_all();
|
||||
|
||||
av_init_packet(&avpkt);
|
||||
|
||||
/* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
|
||||
memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
/* find the MPEG-1 video decoder */
|
||||
codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate video codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
|
||||
c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames
|
||||
|
||||
/* For some codecs, such as msmpeg4 and mpeg4, width and height
|
||||
MUST be initialized there because this information is not
|
||||
available in the bitstream. */
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate video frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame_count = 0;
|
||||
for (;;) {
|
||||
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
|
||||
if (avpkt.size == 0)
|
||||
break;
|
||||
|
||||
/* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
|
||||
and this is the only method to use them because you cannot
|
||||
know the compressed data size before analysing it.
|
||||
|
||||
BUT some other codecs (msmpeg4, mpeg4) are inherently frame
|
||||
based, so you must call them with all the data for one
|
||||
frame exactly. You must also initialize 'width' and
|
||||
'height' before initializing them. */
|
||||
|
||||
/* NOTE2: some codecs allow the raw parameters (frame size,
|
||||
sample rate) to be changed at any frame. We handle this, so
|
||||
you should also take care of it */
|
||||
|
||||
/* here, we use a stream based decoder (mpeg1video), so we
|
||||
feed decoder and see if it could decode a frame */
|
||||
avpkt.data = inbuf;
|
||||
while (avpkt.size > 0)
|
||||
if (decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 0) < 0)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Some codecs, such as MPEG, transmit the I- and P-frame with a
|
||||
latency of one frame. You must do the following to have a
|
||||
chance to get the last frame of the video. */
|
||||
avpkt.data = NULL;
|
||||
avpkt.size = 0;
|
||||
decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);
|
||||
|
||||
fclose(f);
|
||||
|
||||
avcodec_free_context(&c);
|
||||
av_frame_free(&frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
665
doc/examples/decoding_encoding.c
Normal file
665
doc/examples/decoding_encoding.c
Normal 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;
|
||||
}
|
||||
@@ -147,10 +147,11 @@ static int decode_packet(int *got_frame, int cached)
|
||||
}
|
||||
|
||||
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;
|
||||
AVStream *st;
|
||||
AVCodecContext *dec_ctx = NULL;
|
||||
AVCodec *dec = NULL;
|
||||
AVDictionary *opts = NULL;
|
||||
|
||||
@@ -164,31 +165,17 @@ static int open_codec_context(int *stream_idx,
|
||||
st = fmt_ctx->streams[stream_index];
|
||||
|
||||
/* 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) {
|
||||
fprintf(stderr, "Failed to find %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
/* Allocate a codec context for the decoder */
|
||||
*dec_ctx = avcodec_alloc_context3(dec);
|
||||
if (!*dec_ctx) {
|
||||
fprintf(stderr, "Failed to allocate the %s codec context\n",
|
||||
av_get_media_type_string(type));
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* Copy codec parameters from input stream to output codec context */
|
||||
if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) < 0) {
|
||||
fprintf(stderr, "Failed to copy %s codec parameters to decoder context\n",
|
||||
av_get_media_type_string(type));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Init the decoders, with or without reference counting */
|
||||
av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0);
|
||||
if ((ret = avcodec_open2(*dec_ctx, dec, &opts)) < 0) {
|
||||
if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) {
|
||||
fprintf(stderr, "Failed to open %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return ret;
|
||||
@@ -267,8 +254,9 @@ int main (int argc, char **argv)
|
||||
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_dec_ctx = video_stream->codec;
|
||||
|
||||
video_dst_file = fopen(video_dst_filename, "wb");
|
||||
if (!video_dst_file) {
|
||||
@@ -290,8 +278,9 @@ int main (int argc, char **argv)
|
||||
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_dec_ctx = audio_stream->codec;
|
||||
audio_dst_file = fopen(audio_dst_filename, "wb");
|
||||
if (!audio_dst_file) {
|
||||
fprintf(stderr, "Could not open destination file %s\n", audio_dst_filename);
|
||||
@@ -379,8 +368,8 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
end:
|
||||
avcodec_free_context(&video_dec_ctx);
|
||||
avcodec_free_context(&audio_dec_ctx);
|
||||
avcodec_close(video_dec_ctx);
|
||||
avcodec_close(audio_dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
if (video_dst_file)
|
||||
fclose(video_dst_file);
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio encoding with libavcodec API example.
|
||||
*
|
||||
* @example encode_audio.c
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#include <libavutil/channel_layout.h>
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/frame.h>
|
||||
#include <libavutil/samplefmt.h>
|
||||
|
||||
/* check that a given sample format is supported by the encoder */
|
||||
static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt)
|
||||
{
|
||||
const enum AVSampleFormat *p = codec->sample_fmts;
|
||||
|
||||
while (*p != AV_SAMPLE_FMT_NONE) {
|
||||
if (*p == sample_fmt)
|
||||
return 1;
|
||||
p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* just pick the highest supported samplerate */
|
||||
static int select_sample_rate(const AVCodec *codec)
|
||||
{
|
||||
const int *p;
|
||||
int best_samplerate = 0;
|
||||
|
||||
if (!codec->supported_samplerates)
|
||||
return 44100;
|
||||
|
||||
p = codec->supported_samplerates;
|
||||
while (*p) {
|
||||
if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
|
||||
best_samplerate = *p;
|
||||
p++;
|
||||
}
|
||||
return best_samplerate;
|
||||
}
|
||||
|
||||
/* select layout with the highest channel count */
|
||||
static int select_channel_layout(const AVCodec *codec)
|
||||
{
|
||||
const uint64_t *p;
|
||||
uint64_t best_ch_layout = 0;
|
||||
int best_nb_channels = 0;
|
||||
|
||||
if (!codec->channel_layouts)
|
||||
return AV_CH_LAYOUT_STEREO;
|
||||
|
||||
p = codec->channel_layouts;
|
||||
while (*p) {
|
||||
int nb_channels = av_get_channel_layout_nb_channels(*p);
|
||||
|
||||
if (nb_channels > best_nb_channels) {
|
||||
best_ch_layout = *p;
|
||||
best_nb_channels = nb_channels;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return best_ch_layout;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *filename;
|
||||
const AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
AVFrame *frame;
|
||||
AVPacket pkt;
|
||||
int i, j, k, ret, got_output;
|
||||
FILE *f;
|
||||
uint16_t *samples;
|
||||
float t, tincr;
|
||||
|
||||
if (argc <= 1) {
|
||||
fprintf(stderr, "Usage: %s <output file>\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
filename = argv[1];
|
||||
|
||||
/* register all the codecs */
|
||||
avcodec_register_all();
|
||||
|
||||
/* find the MP2 encoder */
|
||||
codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate audio codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* put sample parameters */
|
||||
c->bit_rate = 64000;
|
||||
|
||||
/* check that the encoder supports s16 pcm input */
|
||||
c->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
if (!check_sample_fmt(codec, c->sample_fmt)) {
|
||||
fprintf(stderr, "Encoder does not support sample format %s",
|
||||
av_get_sample_fmt_name(c->sample_fmt));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* select other audio parameters supported by the encoder */
|
||||
c->sample_rate = select_sample_rate(codec);
|
||||
c->channel_layout = select_channel_layout(codec);
|
||||
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* frame containing input raw audio */
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame->nb_samples = c->frame_size;
|
||||
frame->format = c->sample_fmt;
|
||||
frame->channel_layout = c->channel_layout;
|
||||
|
||||
/* allocate the data buffers */
|
||||
ret = av_frame_get_buffer(frame, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate audio data buffers\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* encode a single tone sound */
|
||||
t = 0;
|
||||
tincr = 2 * M_PI * 440.0 / c->sample_rate;
|
||||
for (i = 0; i < 200; i++) {
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||
pkt.size = 0;
|
||||
|
||||
/* make sure the frame is writable -- makes a copy if the encoder
|
||||
* kept a reference internally */
|
||||
ret = av_frame_make_writable(frame);
|
||||
if (ret < 0)
|
||||
exit(1);
|
||||
samples = (uint16_t*)frame->data[0];
|
||||
|
||||
for (j = 0; j < c->frame_size; j++) {
|
||||
samples[2*j] = (int)(sin(t) * 10000);
|
||||
|
||||
for (k = 1; k < c->channels; k++)
|
||||
samples[2*j + k] = samples[2*j];
|
||||
t += tincr;
|
||||
}
|
||||
/* encode the samples */
|
||||
ret = avcodec_encode_audio2(c, &pkt, frame, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding audio frame\n");
|
||||
exit(1);
|
||||
}
|
||||
if (got_output) {
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* get the delayed frames */
|
||||
for (got_output = 1; got_output; i++) {
|
||||
ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_output) {
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
av_frame_free(&frame);
|
||||
avcodec_free_context(&c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* video encoding with libavcodec API example
|
||||
*
|
||||
* @example encode_video.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
#include <libavutil/opt.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *filename, *codec_name;
|
||||
const AVCodec *codec;
|
||||
AVCodecContext *c= NULL;
|
||||
int i, ret, x, y, got_output;
|
||||
FILE *f;
|
||||
AVFrame *frame;
|
||||
AVPacket pkt;
|
||||
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
|
||||
|
||||
if (argc <= 2) {
|
||||
fprintf(stderr, "Usage: %s <output file> <codec name>\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
filename = argv[1];
|
||||
codec_name = argv[2];
|
||||
|
||||
avcodec_register_all();
|
||||
|
||||
/* find the mpeg1video encoder */
|
||||
codec = avcodec_find_encoder_by_name(codec_name);
|
||||
if (!codec) {
|
||||
fprintf(stderr, "Codec not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
c = avcodec_alloc_context3(codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not allocate video codec context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* put sample parameters */
|
||||
c->bit_rate = 400000;
|
||||
/* resolution must be a multiple of two */
|
||||
c->width = 352;
|
||||
c->height = 288;
|
||||
/* frames per second */
|
||||
c->time_base = (AVRational){1, 25};
|
||||
c->framerate = (AVRational){25, 1};
|
||||
|
||||
/* emit one intra frame every ten frames
|
||||
* check frame pict_type before passing frame
|
||||
* to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
|
||||
* then gop_size is ignored and the output of encoder
|
||||
* will always be I frame irrespective to gop_size
|
||||
*/
|
||||
c->gop_size = 10;
|
||||
c->max_b_frames = 1;
|
||||
c->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
|
||||
if (codec->id == AV_CODEC_ID_H264)
|
||||
av_opt_set(c->priv_data, "preset", "slow", 0);
|
||||
|
||||
/* open it */
|
||||
if (avcodec_open2(c, codec, NULL) < 0) {
|
||||
fprintf(stderr, "Could not open codec\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Could not open %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
fprintf(stderr, "Could not allocate video frame\n");
|
||||
exit(1);
|
||||
}
|
||||
frame->format = c->pix_fmt;
|
||||
frame->width = c->width;
|
||||
frame->height = c->height;
|
||||
|
||||
ret = av_frame_get_buffer(frame, 32);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Could not allocate the video frame data\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* encode 1 second of video */
|
||||
for (i = 0; i < 25; i++) {
|
||||
av_init_packet(&pkt);
|
||||
pkt.data = NULL; // packet data will be allocated by the encoder
|
||||
pkt.size = 0;
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
/* make sure the frame data is writable */
|
||||
ret = av_frame_make_writable(frame);
|
||||
if (ret < 0)
|
||||
exit(1);
|
||||
|
||||
/* prepare a dummy image */
|
||||
/* Y */
|
||||
for (y = 0; y < c->height; y++) {
|
||||
for (x = 0; x < c->width; x++) {
|
||||
frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Cb and Cr */
|
||||
for (y = 0; y < c->height/2; y++) {
|
||||
for (x = 0; x < c->width/2; x++) {
|
||||
frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
|
||||
frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
|
||||
}
|
||||
}
|
||||
|
||||
frame->pts = i;
|
||||
|
||||
/* encode the image */
|
||||
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_output) {
|
||||
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* get the delayed frames */
|
||||
for (got_output = 1; got_output; i++) {
|
||||
fflush(stdout);
|
||||
|
||||
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error encoding frame\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (got_output) {
|
||||
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
|
||||
fwrite(pkt.data, 1, pkt.size, f);
|
||||
av_packet_unref(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/* add sequence end code to have a real MPEG file */
|
||||
fwrite(endcode, 1, sizeof(endcode), f);
|
||||
fclose(f);
|
||||
|
||||
avcodec_free_context(&c);
|
||||
av_frame_free(&frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -69,7 +69,8 @@ static int decode_packet(int *got_frame, int cached)
|
||||
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;
|
||||
AVStream *st;
|
||||
@@ -77,27 +78,24 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
|
||||
AVCodec *dec = 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) {
|
||||
fprintf(stderr, "Could not find %s stream in input file '%s'\n",
|
||||
av_get_media_type_string(type), src_filename);
|
||||
return ret;
|
||||
} else {
|
||||
int stream_idx = ret;
|
||||
st = fmt_ctx->streams[stream_idx];
|
||||
*stream_idx = ret;
|
||||
st = fmt_ctx->streams[*stream_idx];
|
||||
|
||||
dec_ctx = avcodec_alloc_context3(dec);
|
||||
if (!dec_ctx) {
|
||||
fprintf(stderr, "Failed to allocate codec\n");
|
||||
/* find decoder for the stream */
|
||||
dec_ctx = st->codec;
|
||||
dec = avcodec_find_decoder(dec_ctx->codec_id);
|
||||
if (!dec) {
|
||||
fprintf(stderr, "Failed to find %s codec\n",
|
||||
av_get_media_type_string(type));
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Failed to copy codec parameters to codec context\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Init the video decoder */
|
||||
av_dict_set(&opts, "flags2", "+export_mvs", 0);
|
||||
if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) {
|
||||
@@ -105,10 +103,6 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
|
||||
av_get_media_type_string(type));
|
||||
return ret;
|
||||
}
|
||||
|
||||
video_stream_idx = stream_idx;
|
||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||
video_dec_ctx = dec_ctx;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -136,7 +130,10 @@ int main(int argc, char **argv)
|
||||
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);
|
||||
|
||||
@@ -181,7 +178,7 @@ int main(int argc, char **argv)
|
||||
} while (got_frame);
|
||||
|
||||
end:
|
||||
avcodec_free_context(&video_dec_ctx);
|
||||
avcodec_close(video_dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
av_frame_free(&frame);
|
||||
return ret < 0;
|
||||
|
||||
@@ -65,16 +65,11 @@ static int open_input_file(const char *filename)
|
||||
/* select the audio stream */
|
||||
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 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;
|
||||
}
|
||||
audio_stream_index = ret;
|
||||
|
||||
/* 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);
|
||||
dec_ctx = fmt_ctx->streams[audio_stream_index]->codec;
|
||||
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
||||
|
||||
/* init the audio decoder */
|
||||
@@ -216,9 +211,10 @@ static void print_frame(const AVFrame *frame)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
AVPacket packet;
|
||||
AVPacket packet0, packet;
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
AVFrame *filt_frame = av_frame_alloc();
|
||||
int got_frame;
|
||||
|
||||
if (!frame || !filt_frame) {
|
||||
perror("Could not allocate frame");
|
||||
@@ -238,52 +234,54 @@ int main(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
/* read all packets */
|
||||
packet0.data = NULL;
|
||||
packet.data = NULL;
|
||||
while (1) {
|
||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||
break;
|
||||
if (!packet0.data) {
|
||||
if ((ret = av_read_frame(fmt_ctx, &packet)) < 0)
|
||||
break;
|
||||
packet0 = packet;
|
||||
}
|
||||
|
||||
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) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
|
||||
break;
|
||||
av_log(NULL, AV_LOG_ERROR, "Error decoding audio\n");
|
||||
continue;
|
||||
}
|
||||
packet.size -= ret;
|
||||
packet.data += ret;
|
||||
|
||||
while (ret >= 0) {
|
||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||
if (got_frame) {
|
||||
/* push the audio data from decoded frame into the filtergraph */
|
||||
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;
|
||||
} else if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (ret >= 0) {
|
||||
/* push the audio data from decoded frame into the filtergraph */
|
||||
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while feeding the audio filtergraph\n");
|
||||
/* pull filtered audio from the filtergraph */
|
||||
while (1) {
|
||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
break;
|
||||
}
|
||||
|
||||
/* pull filtered audio from the filtergraph */
|
||||
while (1) {
|
||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
break;
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
print_frame(filt_frame);
|
||||
av_frame_unref(filt_frame);
|
||||
}
|
||||
av_frame_unref(frame);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
print_frame(filt_frame);
|
||||
av_frame_unref(filt_frame);
|
||||
}
|
||||
}
|
||||
|
||||
if (packet.size <= 0)
|
||||
av_packet_unref(&packet0);
|
||||
} else {
|
||||
/* discard non-wanted packets */
|
||||
av_packet_unref(&packet0);
|
||||
}
|
||||
av_packet_unref(&packet);
|
||||
}
|
||||
end:
|
||||
avfilter_graph_free(&filter_graph);
|
||||
avcodec_free_context(&dec_ctx);
|
||||
avcodec_close(dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
av_frame_free(&frame);
|
||||
av_frame_free(&filt_frame);
|
||||
|
||||
@@ -72,12 +72,7 @@ static int open_input_file(const char *filename)
|
||||
return ret;
|
||||
}
|
||||
video_stream_index = ret;
|
||||
|
||||
/* 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);
|
||||
dec_ctx = fmt_ctx->streams[video_stream_index]->codec;
|
||||
av_opt_set_int(dec_ctx, "refcounted_frames", 1, 0);
|
||||
|
||||
/* init the video decoder */
|
||||
@@ -213,6 +208,7 @@ int main(int argc, char **argv)
|
||||
AVPacket packet;
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
AVFrame *filt_frame = av_frame_alloc();
|
||||
int got_frame;
|
||||
|
||||
if (!frame || !filt_frame) {
|
||||
perror("Could not allocate frame");
|
||||
@@ -237,49 +233,40 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
while (ret >= 0) {
|
||||
ret = avcodec_receive_frame(dec_ctx, frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||
if (got_frame) {
|
||||
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
||||
|
||||
/* 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;
|
||||
} else if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (ret >= 0) {
|
||||
frame->pts = av_frame_get_best_effort_timestamp(frame);
|
||||
|
||||
/* 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");
|
||||
/* pull filtered frames from the filtergraph */
|
||||
while (1) {
|
||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
break;
|
||||
}
|
||||
|
||||
/* pull filtered frames from the filtergraph */
|
||||
while (1) {
|
||||
ret = av_buffersink_get_frame(buffersink_ctx, filt_frame);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
|
||||
break;
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
|
||||
av_frame_unref(filt_frame);
|
||||
}
|
||||
av_frame_unref(frame);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
display_frame(filt_frame, buffersink_ctx->inputs[0]->time_base);
|
||||
av_frame_unref(filt_frame);
|
||||
}
|
||||
av_frame_unref(frame);
|
||||
}
|
||||
}
|
||||
av_packet_unref(&packet);
|
||||
}
|
||||
end:
|
||||
avfilter_graph_free(&filter_graph);
|
||||
avcodec_free_context(&dec_ctx);
|
||||
avcodec_close(dec_ctx);
|
||||
avformat_close_input(&fmt_ctx);
|
||||
av_frame_free(&frame);
|
||||
av_frame_free(&filt_frame);
|
||||
|
||||
@@ -33,19 +33,18 @@
|
||||
#include <libavutil/opt.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;
|
||||
uint8_t buf[1024];
|
||||
int ret, n, reply_code;
|
||||
uint8_t *resource = NULL;
|
||||
char *resource = NULL;
|
||||
while ((ret = avio_handshake(client)) > 0) {
|
||||
av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource);
|
||||
// check for strlen(resource) is necessary, because av_opt_get()
|
||||
// may return empty string.
|
||||
if (resource && strlen(resource))
|
||||
break;
|
||||
av_freep(&resource);
|
||||
}
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
@@ -94,16 +93,15 @@ end:
|
||||
avio_close(client);
|
||||
fprintf(stderr, "Closing input\n");
|
||||
avio_close(input);
|
||||
av_freep(&resource);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
av_log_set_level(AV_LOG_TRACE);
|
||||
AVDictionary *options = NULL;
|
||||
AVIOContext *client = NULL, *server = NULL;
|
||||
const char *in_uri, *out_uri;
|
||||
int ret, pid;
|
||||
av_log_set_level(AV_LOG_TRACE);
|
||||
if (argc < 3) {
|
||||
printf("usage: %s input http://hostname[:port]\n"
|
||||
"API example program to serve http to multiple clients.\n"
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
// a wrapper around a single output AVStream
|
||||
typedef struct OutputStream {
|
||||
AVStream *st;
|
||||
AVCodecContext *enc;
|
||||
|
||||
/* pts of the next frame that will be generated */
|
||||
int64_t next_pts;
|
||||
@@ -105,18 +104,13 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ost->st = avformat_new_stream(oc, NULL);
|
||||
ost->st = avformat_new_stream(oc, *codec);
|
||||
if (!ost->st) {
|
||||
fprintf(stderr, "Could not allocate stream\n");
|
||||
exit(1);
|
||||
}
|
||||
ost->st->id = oc->nb_streams-1;
|
||||
c = avcodec_alloc_context3(*codec);
|
||||
if (!c) {
|
||||
fprintf(stderr, "Could not alloc an encoding context\n");
|
||||
exit(1);
|
||||
}
|
||||
ost->enc = c;
|
||||
c = ost->st->codec;
|
||||
|
||||
switch ((*codec)->type) {
|
||||
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->pix_fmt = STREAM_PIX_FMT;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
AVDictionary *opt = NULL;
|
||||
|
||||
c = ost->enc;
|
||||
c = ost->st->codec;
|
||||
|
||||
/* open it */
|
||||
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,
|
||||
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 */
|
||||
ost->swr_ctx = swr_alloc();
|
||||
if (!ost->swr_ctx) {
|
||||
@@ -284,13 +271,13 @@ static AVFrame *get_audio_frame(OutputStream *ost)
|
||||
int16_t *q = (int16_t*)frame->data[0];
|
||||
|
||||
/* 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)
|
||||
return NULL;
|
||||
|
||||
for (j = 0; j <frame->nb_samples; j++) {
|
||||
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;
|
||||
ost->t += ost->tincr;
|
||||
ost->tincr += ost->tincr2;
|
||||
@@ -316,7 +303,7 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
||||
int dst_nb_samples;
|
||||
|
||||
av_init_packet(&pkt);
|
||||
c = ost->enc;
|
||||
c = ost->st->codec;
|
||||
|
||||
frame = get_audio_frame(ost);
|
||||
|
||||
@@ -335,15 +322,15 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
|
||||
if (ret < 0)
|
||||
exit(1);
|
||||
|
||||
/* convert to destination format */
|
||||
ret = swr_convert(ost->swr_ctx,
|
||||
ost->frame->data, dst_nb_samples,
|
||||
(const uint8_t **)frame->data, frame->nb_samples);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error while converting\n");
|
||||
exit(1);
|
||||
}
|
||||
frame = ost->frame;
|
||||
/* convert to destination format */
|
||||
ret = swr_convert(ost->swr_ctx,
|
||||
ost->frame->data, dst_nb_samples,
|
||||
(const uint8_t **)frame->data, frame->nb_samples);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error while converting\n");
|
||||
exit(1);
|
||||
}
|
||||
frame = ost->frame;
|
||||
|
||||
frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
|
||||
ost->samples_count += dst_nb_samples;
|
||||
@@ -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)
|
||||
{
|
||||
int ret;
|
||||
AVCodecContext *c = ost->enc;
|
||||
AVCodecContext *c = ost->st->codec;
|
||||
AVDictionary *opt = NULL;
|
||||
|
||||
av_dict_copy(&opt, opt_arg, 0);
|
||||
@@ -427,20 +414,21 @@ static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
|
||||
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. */
|
||||
static void fill_yuv_image(AVFrame *pict, int frame_index,
|
||||
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;
|
||||
|
||||
@@ -460,18 +448,13 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
|
||||
|
||||
static AVFrame *get_video_frame(OutputStream *ost)
|
||||
{
|
||||
AVCodecContext *c = ost->enc;
|
||||
AVCodecContext *c = ost->st->codec;
|
||||
|
||||
/* 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)
|
||||
return NULL;
|
||||
|
||||
/* when we pass a frame to the encoder, it may keep a reference to it
|
||||
* internally; make sure we do not overwrite it here */
|
||||
if (av_frame_make_writable(ost->frame) < 0)
|
||||
exit(1);
|
||||
|
||||
if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
|
||||
/* as we only generate a YUV420P picture, we must convert it
|
||||
* to the codec pixel format if needed */
|
||||
@@ -512,7 +495,7 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
|
||||
int got_packet = 0;
|
||||
AVPacket pkt = { 0 };
|
||||
|
||||
c = ost->enc;
|
||||
c = ost->st->codec;
|
||||
|
||||
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)
|
||||
{
|
||||
avcodec_free_context(&ost->enc);
|
||||
avcodec_close(ost->st->codec);
|
||||
av_frame_free(&ost->frame);
|
||||
av_frame_free(&ost->tmp_frame);
|
||||
sws_freeContext(ost->sws_ctx);
|
||||
@@ -562,7 +545,6 @@ int main(int argc, char **argv)
|
||||
int have_video = 0, have_audio = 0;
|
||||
int encode_video = 0, encode_audio = 0;
|
||||
AVDictionary *opt = NULL;
|
||||
int i;
|
||||
|
||||
/* Initialize libavcodec, and register all codecs and formats. */
|
||||
av_register_all();
|
||||
@@ -579,9 +561,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
for (i = 2; i+1 < argc; i+=2) {
|
||||
if (!strcmp(argv[i], "-flags") || !strcmp(argv[i], "-fflags"))
|
||||
av_dict_set(&opt, argv[i]+1, argv[i+1], 0);
|
||||
if (argc > 3 && !strcmp(argv[2], "-flags")) {
|
||||
av_dict_set(&opt, argv[2]+1, argv[3], 0);
|
||||
}
|
||||
|
||||
/* allocate the output media context */
|
||||
@@ -639,8 +620,8 @@ int main(int argc, char **argv)
|
||||
while (encode_video || encode_audio) {
|
||||
/* select the stream to encode */
|
||||
if (encode_video &&
|
||||
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.enc->time_base,
|
||||
audio_st.next_pts, audio_st.enc->time_base) <= 0)) {
|
||||
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.st->codec->time_base,
|
||||
audio_st.next_pts, audio_st.st->codec->time_base) <= 0)) {
|
||||
encode_video = !write_video_frame(oc, &video_st);
|
||||
} else {
|
||||
encode_audio = !write_audio_frame(oc, &audio_st);
|
||||
|
||||
@@ -352,7 +352,7 @@ int main(int argc, char **argv)
|
||||
for (i = 0; i < input_ctx->nb_streams; i++) {
|
||||
AVStream *st = input_ctx->streams[i];
|
||||
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !video_st)
|
||||
if (st->codec->codec_id == AV_CODEC_ID_H264 && !video_st)
|
||||
video_st = st;
|
||||
else
|
||||
st->discard = AVDISCARD_ALL;
|
||||
@@ -404,16 +404,16 @@ int main(int argc, char **argv)
|
||||
goto finish;
|
||||
}
|
||||
decoder_ctx->codec_id = AV_CODEC_ID_H264;
|
||||
if (video_st->codecpar->extradata_size) {
|
||||
decoder_ctx->extradata = av_mallocz(video_st->codecpar->extradata_size +
|
||||
if (video_st->codec->extradata_size) {
|
||||
decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size +
|
||||
AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!decoder_ctx->extradata) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto finish;
|
||||
}
|
||||
memcpy(decoder_ctx->extradata, video_st->codecpar->extradata,
|
||||
video_st->codecpar->extradata_size);
|
||||
decoder_ctx->extradata_size = video_st->codecpar->extradata_size;
|
||||
memcpy(decoder_ctx->extradata, video_st->codec->extradata,
|
||||
video_st->codec->extradata_size);
|
||||
decoder_ctx->extradata_size = video_st->codec->extradata_size;
|
||||
}
|
||||
decoder_ctx->refcounted_frames = 1;
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ int main(int argc, char **argv)
|
||||
AVPacket pkt;
|
||||
const char *in_filename, *out_filename;
|
||||
int ret, i;
|
||||
int stream_index = 0;
|
||||
int *stream_mapping = NULL;
|
||||
int stream_mapping_size = 0;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s input output\n"
|
||||
@@ -86,42 +83,25 @@ int main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
stream_mapping_size = ifmt_ctx->nb_streams;
|
||||
stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
|
||||
if (!stream_mapping) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ofmt = ofmt_ctx->oformat;
|
||||
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
AVStream *out_stream;
|
||||
AVStream *in_stream = ifmt_ctx->streams[i];
|
||||
AVCodecParameters *in_codecpar = in_stream->codecpar;
|
||||
|
||||
if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO &&
|
||||
in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO &&
|
||||
in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
|
||||
stream_mapping[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
stream_mapping[i] = stream_index++;
|
||||
|
||||
out_stream = avformat_new_stream(ofmt_ctx, NULL);
|
||||
AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);
|
||||
if (!out_stream) {
|
||||
fprintf(stderr, "Failed allocating output stream\n");
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
|
||||
ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -147,14 +127,8 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
in_stream = ifmt_ctx->streams[pkt.stream_index];
|
||||
if (pkt.stream_index >= stream_mapping_size ||
|
||||
stream_mapping[pkt.stream_index] < 0) {
|
||||
av_packet_unref(&pkt);
|
||||
continue;
|
||||
}
|
||||
|
||||
pkt.stream_index = stream_mapping[pkt.stream_index];
|
||||
out_stream = ofmt_ctx->streams[pkt.stream_index];
|
||||
|
||||
log_packet(ifmt_ctx, &pkt, "in");
|
||||
|
||||
/* copy packet */
|
||||
@@ -182,8 +156,6 @@ end:
|
||||
avio_closep(&ofmt_ctx->pb);
|
||||
avformat_free_context(ofmt_ctx);
|
||||
|
||||
av_freep(&stream_mapping);
|
||||
|
||||
if (ret < 0 && ret != AVERROR_EOF) {
|
||||
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
|
||||
return 1;
|
||||
|
||||
@@ -45,12 +45,23 @@
|
||||
/** The number of output channels */
|
||||
#define OUTPUT_CHANNELS 2
|
||||
|
||||
/**
|
||||
* Convert an error code into a text message.
|
||||
* @param error Error code to be converted
|
||||
* @return Corresponding error text (not thread-safe)
|
||||
*/
|
||||
static const char *get_error_text(const int error)
|
||||
{
|
||||
static char error_buffer[255];
|
||||
av_strerror(error, error_buffer, sizeof(error_buffer));
|
||||
return error_buffer;
|
||||
}
|
||||
|
||||
/** Open an input file and the required decoder. */
|
||||
static int open_input_file(const char *filename,
|
||||
AVFormatContext **input_format_context,
|
||||
AVCodecContext **input_codec_context)
|
||||
{
|
||||
AVCodecContext *avctx;
|
||||
AVCodec *input_codec;
|
||||
int error;
|
||||
|
||||
@@ -58,7 +69,7 @@ static int open_input_file(const char *filename,
|
||||
if ((error = avformat_open_input(input_format_context, filename, NULL,
|
||||
NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open input file '%s' (error '%s')\n",
|
||||
filename, av_err2str(error));
|
||||
filename, get_error_text(error));
|
||||
*input_format_context = NULL;
|
||||
return error;
|
||||
}
|
||||
@@ -66,7 +77,7 @@ static int open_input_file(const char *filename,
|
||||
/** Get information on the input file (number of streams etc.). */
|
||||
if ((error = avformat_find_stream_info(*input_format_context, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open find stream info (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
avformat_close_input(input_format_context);
|
||||
return error;
|
||||
}
|
||||
@@ -80,39 +91,23 @@ static int open_input_file(const char *filename,
|
||||
}
|
||||
|
||||
/** Find a decoder for the audio stream. */
|
||||
if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codecpar->codec_id))) {
|
||||
if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codec->codec_id))) {
|
||||
fprintf(stderr, "Could not find input codec\n");
|
||||
avformat_close_input(input_format_context);
|
||||
return AVERROR_EXIT;
|
||||
}
|
||||
|
||||
/** allocate a new decoding context */
|
||||
avctx = avcodec_alloc_context3(input_codec);
|
||||
if (!avctx) {
|
||||
fprintf(stderr, "Could not allocate a decoding context\n");
|
||||
avformat_close_input(input_format_context);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/** initialize the stream parameters with demuxer information */
|
||||
error = avcodec_parameters_to_context(avctx, (*input_format_context)->streams[0]->codecpar);
|
||||
if (error < 0) {
|
||||
avformat_close_input(input_format_context);
|
||||
avcodec_free_context(&avctx);
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Open the decoder for the audio stream to use it later. */
|
||||
if ((error = avcodec_open2(avctx, input_codec, NULL)) < 0) {
|
||||
if ((error = avcodec_open2((*input_format_context)->streams[0]->codec,
|
||||
input_codec, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open input codec (error '%s')\n",
|
||||
av_err2str(error));
|
||||
avcodec_free_context(&avctx);
|
||||
get_error_text(error));
|
||||
avformat_close_input(input_format_context);
|
||||
return error;
|
||||
}
|
||||
|
||||
/** Save the decoder context for easier access later. */
|
||||
*input_codec_context = avctx;
|
||||
*input_codec_context = (*input_format_context)->streams[0]->codec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -127,7 +122,6 @@ static int open_output_file(const char *filename,
|
||||
AVFormatContext **output_format_context,
|
||||
AVCodecContext **output_codec_context)
|
||||
{
|
||||
AVCodecContext *avctx = NULL;
|
||||
AVIOContext *output_io_context = NULL;
|
||||
AVStream *stream = NULL;
|
||||
AVCodec *output_codec = NULL;
|
||||
@@ -137,7 +131,7 @@ static int open_output_file(const char *filename,
|
||||
if ((error = avio_open(&output_io_context, filename,
|
||||
AVIO_FLAG_WRITE)) < 0) {
|
||||
fprintf(stderr, "Could not open output file '%s' (error '%s')\n",
|
||||
filename, av_err2str(error));
|
||||
filename, get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -167,31 +161,27 @@ static int open_output_file(const char *filename,
|
||||
}
|
||||
|
||||
/** Create a new audio stream in the output file container. */
|
||||
if (!(stream = avformat_new_stream(*output_format_context, NULL))) {
|
||||
if (!(stream = avformat_new_stream(*output_format_context, output_codec))) {
|
||||
fprintf(stderr, "Could not create new stream\n");
|
||||
error = AVERROR(ENOMEM);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
avctx = avcodec_alloc_context3(output_codec);
|
||||
if (!avctx) {
|
||||
fprintf(stderr, "Could not allocate an encoding context\n");
|
||||
error = AVERROR(ENOMEM);
|
||||
goto cleanup;
|
||||
}
|
||||
/** Save the encoder context for easier access later. */
|
||||
*output_codec_context = stream->codec;
|
||||
|
||||
/**
|
||||
* Set the basic encoder parameters.
|
||||
* The input file's sample rate is used to avoid a sample rate conversion.
|
||||
*/
|
||||
avctx->channels = OUTPUT_CHANNELS;
|
||||
avctx->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
|
||||
avctx->sample_rate = input_codec_context->sample_rate;
|
||||
avctx->sample_fmt = output_codec->sample_fmts[0];
|
||||
avctx->bit_rate = OUTPUT_BIT_RATE;
|
||||
(*output_codec_context)->channels = OUTPUT_CHANNELS;
|
||||
(*output_codec_context)->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
|
||||
(*output_codec_context)->sample_rate = input_codec_context->sample_rate;
|
||||
(*output_codec_context)->sample_fmt = output_codec->sample_fmts[0];
|
||||
(*output_codec_context)->bit_rate = OUTPUT_BIT_RATE;
|
||||
|
||||
/** Allow the use of the experimental AAC encoder */
|
||||
avctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
|
||||
(*output_codec_context)->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
|
||||
|
||||
/** Set the sample rate for the container. */
|
||||
stream->time_base.den = input_codec_context->sample_rate;
|
||||
@@ -202,28 +192,18 @@ static int open_output_file(const char *filename,
|
||||
* Mark the encoder so that it behaves accordingly.
|
||||
*/
|
||||
if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
(*output_codec_context)->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
/** Open the encoder for the audio stream to use it later. */
|
||||
if ((error = avcodec_open2(avctx, output_codec, NULL)) < 0) {
|
||||
if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not open output codec (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
error = avcodec_parameters_from_context(stream->codecpar, avctx);
|
||||
if (error < 0) {
|
||||
fprintf(stderr, "Could not initialize stream parameters\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/** Save the encoder context for easier access later. */
|
||||
*output_codec_context = avctx;
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
avcodec_free_context(&avctx);
|
||||
avio_closep(&(*output_format_context)->pb);
|
||||
avformat_free_context(*output_format_context);
|
||||
*output_format_context = NULL;
|
||||
@@ -313,7 +293,7 @@ static int write_output_file_header(AVFormatContext *output_format_context)
|
||||
int error;
|
||||
if ((error = avformat_write_header(output_format_context, NULL)) < 0) {
|
||||
fprintf(stderr, "Could not write output file header (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
@@ -337,7 +317,7 @@ static int decode_audio_frame(AVFrame *frame,
|
||||
*finished = 1;
|
||||
else {
|
||||
fprintf(stderr, "Could not read frame (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -351,7 +331,7 @@ static int decode_audio_frame(AVFrame *frame,
|
||||
if ((error = avcodec_decode_audio4(input_codec_context, frame,
|
||||
data_present, &input_packet)) < 0) {
|
||||
fprintf(stderr, "Could not decode frame (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
av_packet_unref(&input_packet);
|
||||
return error;
|
||||
}
|
||||
@@ -398,7 +378,7 @@ static int init_converted_samples(uint8_t ***converted_input_samples,
|
||||
output_codec_context->sample_fmt, 0)) < 0) {
|
||||
fprintf(stderr,
|
||||
"Could not allocate converted input samples (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
av_freep(&(*converted_input_samples)[0]);
|
||||
free(*converted_input_samples);
|
||||
return error;
|
||||
@@ -422,7 +402,7 @@ static int convert_samples(const uint8_t **input_data,
|
||||
converted_data, frame_size,
|
||||
input_data , frame_size)) < 0) {
|
||||
fprintf(stderr, "Could not convert input samples (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -554,8 +534,8 @@ static int init_output_frame(AVFrame **frame,
|
||||
* sure that the audio frame can hold as many samples as specified.
|
||||
*/
|
||||
if ((error = av_frame_get_buffer(*frame, 0)) < 0) {
|
||||
fprintf(stderr, "Could not allocate output frame samples (error '%s')\n",
|
||||
av_err2str(error));
|
||||
fprintf(stderr, "Could allocate output frame samples (error '%s')\n",
|
||||
get_error_text(error));
|
||||
av_frame_free(frame);
|
||||
return error;
|
||||
}
|
||||
@@ -590,7 +570,7 @@ static int encode_audio_frame(AVFrame *frame,
|
||||
if ((error = avcodec_encode_audio2(output_codec_context, &output_packet,
|
||||
frame, data_present)) < 0) {
|
||||
fprintf(stderr, "Could not encode frame (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
av_packet_unref(&output_packet);
|
||||
return error;
|
||||
}
|
||||
@@ -599,7 +579,7 @@ static int encode_audio_frame(AVFrame *frame,
|
||||
if (*data_present) {
|
||||
if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
|
||||
fprintf(stderr, "Could not write frame (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
av_packet_unref(&output_packet);
|
||||
return error;
|
||||
}
|
||||
@@ -659,7 +639,7 @@ static int write_output_file_trailer(AVFormatContext *output_format_context)
|
||||
int error;
|
||||
if ((error = av_write_trailer(output_format_context)) < 0) {
|
||||
fprintf(stderr, "Could not write output file trailer (error '%s')\n",
|
||||
av_err2str(error));
|
||||
get_error_text(error));
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
@@ -776,13 +756,13 @@ cleanup:
|
||||
av_audio_fifo_free(fifo);
|
||||
swr_free(&resample_context);
|
||||
if (output_codec_context)
|
||||
avcodec_free_context(&output_codec_context);
|
||||
avcodec_close(output_codec_context);
|
||||
if (output_format_context) {
|
||||
avio_closep(&output_format_context->pb);
|
||||
avformat_free_context(output_format_context);
|
||||
}
|
||||
if (input_codec_context)
|
||||
avcodec_free_context(&input_codec_context);
|
||||
avcodec_close(input_codec_context);
|
||||
if (input_format_context)
|
||||
avformat_close_input(&input_format_context);
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@ typedef struct FilteringContext {
|
||||
} FilteringContext;
|
||||
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)
|
||||
{
|
||||
int ret;
|
||||
@@ -67,42 +61,22 @@ static int open_input_file(const char *filename)
|
||||
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++) {
|
||||
AVStream *stream = ifmt_ctx->streams[i];
|
||||
AVCodec *dec = avcodec_find_decoder(stream->codecpar->codec_id);
|
||||
AVStream *stream;
|
||||
AVCodecContext *codec_ctx;
|
||||
if (!dec) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to find decoder for stream #%u\n", i);
|
||||
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;
|
||||
}
|
||||
stream = ifmt_ctx->streams[i];
|
||||
codec_ctx = stream->codec;
|
||||
/* Reencode video & audio and remux subtitles etc. */
|
||||
if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
|
||||
|| 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 */
|
||||
ret = avcodec_open2(codec_ctx, dec, NULL);
|
||||
ret = avcodec_open2(codec_ctx,
|
||||
avcodec_find_decoder(codec_ctx->codec_id), NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
stream_ctx[i].dec_ctx = codec_ctx;
|
||||
}
|
||||
|
||||
av_dump_format(ifmt_ctx, 0, filename, 0);
|
||||
@@ -134,7 +108,8 @@ static int open_output_file(const char *filename)
|
||||
}
|
||||
|
||||
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
|
||||
|| dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
@@ -144,11 +119,6 @@ static int open_output_file(const char *filename)
|
||||
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
enc_ctx = avcodec_alloc_context3(encoder);
|
||||
if (!enc_ctx) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Failed to allocate the encoder context\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
/* In this example, we transcode to same properties (picture size,
|
||||
* sample rate etc.). These properties can be changed for output
|
||||
@@ -158,12 +128,9 @@ static int open_output_file(const char *filename)
|
||||
enc_ctx->width = dec_ctx->width;
|
||||
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
|
||||
/* take first format from list of supported formats */
|
||||
if (encoder->pix_fmts)
|
||||
enc_ctx->pix_fmt = encoder->pix_fmts[0];
|
||||
else
|
||||
enc_ctx->pix_fmt = dec_ctx->pix_fmt;
|
||||
enc_ctx->pix_fmt = encoder->pix_fmts[0];
|
||||
/* 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 {
|
||||
enc_ctx->sample_rate = dec_ctx->sample_rate;
|
||||
enc_ctx->channel_layout = dec_ctx->channel_layout;
|
||||
@@ -179,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);
|
||||
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) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Elementary stream #%d is of unknown type, cannot proceed\n", i);
|
||||
return AVERROR_INVALIDDATA;
|
||||
} else {
|
||||
/* 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) {
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -385,17 +345,17 @@ static int init_filters(void)
|
||||
filter_ctx[i].buffersrc_ctx = NULL;
|
||||
filter_ctx[i].buffersink_ctx = NULL;
|
||||
filter_ctx[i].filter_graph = NULL;
|
||||
if (!(ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
|
||||
|| ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO))
|
||||
if (!(ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO
|
||||
|| ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO))
|
||||
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 */
|
||||
else
|
||||
filter_spec = "anull"; /* passthrough (dummy) filter for audio */
|
||||
ret = init_filter(&filter_ctx[i], stream_ctx[i].dec_ctx,
|
||||
stream_ctx[i].enc_ctx, filter_spec);
|
||||
ret = init_filter(&filter_ctx[i], ifmt_ctx->streams[i]->codec,
|
||||
ofmt_ctx->streams[i]->codec, filter_spec);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
@@ -407,7 +367,7 @@ static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, in
|
||||
int got_frame_local;
|
||||
AVPacket enc_pkt;
|
||||
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;
|
||||
|
||||
if (!got_frame)
|
||||
@@ -418,7 +378,7 @@ static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, in
|
||||
enc_pkt.data = NULL;
|
||||
enc_pkt.size = 0;
|
||||
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);
|
||||
av_frame_free(&filt_frame);
|
||||
if (ret < 0)
|
||||
@@ -429,7 +389,7 @@ static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, in
|
||||
/* prepare packet for muxing */
|
||||
enc_pkt.stream_index = stream_index;
|
||||
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);
|
||||
|
||||
av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
|
||||
@@ -487,7 +447,7 @@ static int flush_encoder(unsigned int stream_index)
|
||||
int ret;
|
||||
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))
|
||||
return 0;
|
||||
|
||||
@@ -533,7 +493,7 @@ int main(int argc, char **argv)
|
||||
if ((ret = av_read_frame(ifmt_ctx, &packet)) < 0)
|
||||
break;
|
||||
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",
|
||||
stream_index);
|
||||
|
||||
@@ -546,10 +506,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
av_packet_rescale_ts(&packet,
|
||||
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 :
|
||||
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);
|
||||
if (ret < 0) {
|
||||
av_frame_free(&frame);
|
||||
@@ -603,14 +563,13 @@ end:
|
||||
av_packet_unref(&packet);
|
||||
av_frame_free(&frame);
|
||||
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
|
||||
avcodec_free_context(&stream_ctx[i].dec_ctx);
|
||||
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && stream_ctx[i].enc_ctx)
|
||||
avcodec_free_context(&stream_ctx[i].enc_ctx);
|
||||
avcodec_close(ifmt_ctx->streams[i]->codec);
|
||||
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && ofmt_ctx->streams[i]->codec)
|
||||
avcodec_close(ofmt_ctx->streams[i]->codec);
|
||||
if (filter_ctx && filter_ctx[i].filter_graph)
|
||||
avfilter_graph_free(&filter_ctx[i].filter_graph);
|
||||
}
|
||||
av_free(filter_ctx);
|
||||
av_free(stream_ctx);
|
||||
avformat_close_input(&ifmt_ctx);
|
||||
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
|
||||
avio_closep(&ofmt_ctx->pb);
|
||||
|
||||
14
doc/faq.texi
14
doc/faq.texi
@@ -311,18 +311,18 @@ invoking ffmpeg with several @option{-i} options.
|
||||
For audio, to put all channels together in a single stream (example: two
|
||||
mono streams into one stereo stream): this is sometimes called to
|
||||
@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
|
||||
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
|
||||
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.
|
||||
|
||||
@item
|
||||
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
|
||||
@url{ffmpeg-filters.html#overlay, @code{overlay}} video filter.
|
||||
@url{https://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video filter.
|
||||
|
||||
@end itemize
|
||||
|
||||
@@ -333,19 +333,19 @@ There are several solutions, depending on the exact circumstances.
|
||||
|
||||
@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
|
||||
documentation. This operation is recommended if you need to re-encode.
|
||||
|
||||
@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
|
||||
your format doesn't support file level concatenation.
|
||||
|
||||
@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
|
||||
documentation.
|
||||
|
||||
@@ -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
|
||||
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
|
||||
stretching comes from the image or from the aspect ratio information.
|
||||
|
||||
@@ -197,11 +197,6 @@ through @command{ssh}.
|
||||
|
||||
@item GEN
|
||||
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
|
||||
|
||||
@section Examples
|
||||
|
||||
116
doc/ffmpeg.texi
116
doc/ffmpeg.texi
@@ -12,7 +12,7 @@
|
||||
|
||||
@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
|
||||
@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
|
||||
files, pipes, network streams, grabbing devices, etc.), specified by the
|
||||
@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
|
||||
cannot be interpreted as an option is considered to be an output url.
|
||||
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 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
|
||||
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
|
||||
@@ -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
|
||||
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
|
||||
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
|
||||
needed in most cases.
|
||||
|
||||
@item -i @var{url} (@emph{input})
|
||||
input file url
|
||||
@item -i @var{filename} (@emph{input})
|
||||
input file name
|
||||
|
||||
@item -y (@emph{global})
|
||||
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
|
||||
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}.
|
||||
|
||||
@var{duration} must be a time duration specification,
|
||||
@@ -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
|
||||
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}.
|
||||
|
||||
@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
|
||||
@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})
|
||||
|
||||
Creates a program with the specified @var{title}, @var{program_num} and adds the specified
|
||||
@@ -414,8 +380,7 @@ ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
|
||||
@end example
|
||||
|
||||
@item -dframes @var{number} (@emph{output})
|
||||
Set the number of data frames to output. This is an obsolete alias for
|
||||
@code{-frames:d}, which you should use instead.
|
||||
Set the number of data frames to output. This is an alias for @code{-frames:d}.
|
||||
|
||||
@item -frames[:@var{stream_specifier}] @var{framecount} (@emph{output,per-stream})
|
||||
Stop writing to the stream after @var{framecount} frames.
|
||||
@@ -450,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
|
||||
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})
|
||||
Specify the preset for matching stream(s).
|
||||
|
||||
@@ -530,8 +490,7 @@ Disable automatically rotating video based on file metadata.
|
||||
|
||||
@table @option
|
||||
@item -vframes @var{number} (@emph{output})
|
||||
Set the number of video frames to output. This is an obsolete alias for
|
||||
@code{-frames:v}, which you should use instead.
|
||||
Set the number of video frames to output. This is an alias for @code{-frames:v}.
|
||||
@item -r[:@var{stream_specifier}] @var{fps} (@emph{input/output,per-stream})
|
||||
Set frame rate (Hz value, fraction or abbreviation).
|
||||
|
||||
@@ -638,16 +597,6 @@ Calculate PSNR of compressed frames.
|
||||
Dump video coding statistics to @file{vstats_HHMMSS.log}.
|
||||
@item -vstats_file @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})
|
||||
top=1/bottom=0/auto=-1 field first
|
||||
@item -dc @var{precision}
|
||||
@@ -771,7 +720,7 @@ 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 values of MFX_IMPL_* . Allowed values
|
||||
For QSV, this option corresponds to the valus of MFX_IMPL_* . Allowed values
|
||||
are:
|
||||
@table @option
|
||||
@item auto
|
||||
@@ -794,8 +743,7 @@ List all hardware acceleration methods supported in this build of ffmpeg.
|
||||
|
||||
@table @option
|
||||
@item -aframes @var{number} (@emph{output})
|
||||
Set the number of audio frames to output. This is an obsolete alias for
|
||||
@code{-frames:a}, which you should use instead.
|
||||
Set the number of audio frames to output. This is an alias for @code{-frames:a}.
|
||||
@item -ar[:@var{stream_specifier}] @var{freq} (@emph{input/output,per-stream})
|
||||
Set the audio sampling frequency. For output streams it is set by
|
||||
default to the frequency of the corresponding input stream. For input
|
||||
@@ -874,7 +822,7 @@ Set the size of the canvas used to render subtitles.
|
||||
@section Advanced options
|
||||
|
||||
@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
|
||||
stream is identified by the input file index @var{input_file_id} and
|
||||
@@ -890,11 +838,6 @@ the source for output stream 1, etc.
|
||||
A @code{-} character before the stream identifier creates a "negative" mapping.
|
||||
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-existant input.
|
||||
|
||||
An alternative @var{[linklabel]} form will map outputs from complex filter
|
||||
graphs (see the @option{-filter_complex} option) to the output file.
|
||||
@var{linklabel} must correspond to a defined output link label in the graph.
|
||||
@@ -932,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
|
||||
@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:
|
||||
@example
|
||||
ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
|
||||
@@ -1072,7 +1008,7 @@ Dump each input packet to stderr.
|
||||
@item -hex (@emph{global})
|
||||
When dumping packets, also dump the payload.
|
||||
@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
|
||||
with actual grab devices or live input streams (where it can cause packet
|
||||
loss).
|
||||
@@ -1193,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
|
||||
an output mpegts file:
|
||||
@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
|
||||
|
||||
@item -bsf[:@var{stream_specifier}] @var{bitstream_filters} (@emph{output,per-stream})
|
||||
@@ -1265,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
|
||||
@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})
|
||||
Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
|
||||
outputs. Equivalent to @option{-filter_complex}.
|
||||
@@ -1348,15 +1279,6 @@ No packets were passed to the muxer, the output is empty.
|
||||
@item -xerror (@emph{global})
|
||||
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
|
||||
|
||||
As a special exception, you can use a bitmap subtitle stream as input: it
|
||||
@@ -1562,7 +1484,7 @@ to enable LAME support by passing @code{--enable-libmp3lame} to configure.
|
||||
The mapping is particularly useful for DVD transcoding
|
||||
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
|
||||
You can extract images from a video, or create a video from many images:
|
||||
@@ -1577,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.
|
||||
|
||||
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,
|
||||
or in combination with -ss to start extracting from a certain point in time.
|
||||
above command in combination with the -vframes or -t option, or in
|
||||
combination with -ss to start extracting from a certain point in time.
|
||||
|
||||
For creating a video from many images:
|
||||
@example
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@chapter Synopsis
|
||||
|
||||
ffplay [@var{options}] [@file{input_url}]
|
||||
ffplay [@var{options}] [@file{input_file}]
|
||||
|
||||
@chapter 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.
|
||||
@item -nodisp
|
||||
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}
|
||||
Force format.
|
||||
@item -window_title @var{title}
|
||||
@@ -112,8 +106,8 @@ the input audio.
|
||||
Use the option "-filters" to show all the available filters (including
|
||||
sources and sinks).
|
||||
|
||||
@item -i @var{input_url}
|
||||
Read @var{input_url}.
|
||||
@item -i @var{input_file}
|
||||
Read @var{input_file}.
|
||||
@end table
|
||||
|
||||
@section Advanced options
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@chapter Synopsis
|
||||
|
||||
ffprobe [@var{options}] [@file{input_url}]
|
||||
ffprobe [@var{options}] [@file{input_file}]
|
||||
|
||||
@chapter 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
|
||||
contained in it.
|
||||
|
||||
If a url is specified in input, ffprobe will try to open and
|
||||
probe the url content. If the url cannot be opened or recognized as
|
||||
If a filename is specified in input, ffprobe will try to open and
|
||||
probe the file content. If the file cannot be opened or recognized as
|
||||
a multimedia file, a positive exit code is returned.
|
||||
|
||||
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
|
||||
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
|
||||
Show information about each media stream contained in the input
|
||||
multimedia stream.
|
||||
@@ -252,7 +245,7 @@ continue reading from that.
|
||||
Each interval is specified by two optional parts, separated by "%".
|
||||
|
||||
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
|
||||
part is not specified, no seeking will be performed when reading this
|
||||
interval.
|
||||
@@ -339,8 +332,8 @@ with name "PIXEL_FORMAT".
|
||||
Force bitexact output, useful to produce output which is not dependent
|
||||
on the specific build.
|
||||
|
||||
@item -i @var{input_url}
|
||||
Read @var{input_url}.
|
||||
@item -i @var{input_file}
|
||||
Read @var{input_file}.
|
||||
|
||||
@end table
|
||||
@c man end
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
<xsd:complexType name="frameType">
|
||||
<xsd:sequence>
|
||||
<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:sequence>
|
||||
|
||||
@@ -122,20 +121,6 @@
|
||||
<xsd:attribute name="repeat_pict" type="xsd:int" />
|
||||
</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 name="frameSideDataListType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="side_data" type="ffprobe:frameSideDataType" minOccurs="1" maxOccurs="unbounded"/>
|
||||
@@ -144,7 +129,6 @@
|
||||
<xsd:complexType name="frameSideDataType">
|
||||
<xsd:attribute name="side_data_type" type="xsd:string"/>
|
||||
<xsd:attribute name="side_data_size" type="xsd:int" />
|
||||
<xsd:attribute name="timecode" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="subtitleType">
|
||||
@@ -181,7 +165,6 @@
|
||||
<xsd:attribute name="visual_impaired" 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="timed_thumbnails" type="xsd:int" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="streamType">
|
||||
@@ -217,7 +200,6 @@
|
||||
<xsd:attribute name="color_transfer" type="xsd:string"/>
|
||||
<xsd:attribute name="color_primaries" 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="refs" type="xsd:int"/>
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ StartSendOnKey
|
||||
#AVPresetVideo baseline
|
||||
#AVOptionVideo flags +global_header
|
||||
#
|
||||
#AudioCodec aac
|
||||
#AudioCodec libfaac
|
||||
#AudioBitRate 32
|
||||
#AudioChannels 2
|
||||
#AudioSampleRate 22050
|
||||
|
||||
@@ -110,12 +110,6 @@ Show version.
|
||||
@item -formats
|
||||
Show available formats (including devices).
|
||||
|
||||
@item -demuxers
|
||||
Show available demuxers.
|
||||
|
||||
@item -muxers
|
||||
Show available muxers.
|
||||
|
||||
@item -devices
|
||||
Show available devices.
|
||||
|
||||
@@ -182,10 +176,10 @@ loglevel will be used. If multiple loglevel parameters are given, using
|
||||
Show nothing at all; be silent.
|
||||
@item panic, 0
|
||||
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
|
||||
Only show fatal errors. These are errors after which the process absolutely
|
||||
cannot continue.
|
||||
cannot continue after.
|
||||
@item error, 16
|
||||
Show all errors, including ones which can be recovered from.
|
||||
@item warning, 24
|
||||
@@ -201,13 +195,13 @@ Show everything, including debugging information.
|
||||
@item trace, 56
|
||||
@end table
|
||||
|
||||
By default the program logs to stderr. If coloring is supported by the
|
||||
By default the program logs to stderr, if coloring is supported by the
|
||||
terminal, colors are used to mark errors and warnings. Log coloring
|
||||
can be disabled setting the environment variable
|
||||
@env{AV_LOG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting
|
||||
the environment variable @env{AV_LOG_FORCE_COLOR}.
|
||||
The use of the environment variable @env{NO_COLOR} is deprecated and
|
||||
will be dropped in a future FFmpeg version.
|
||||
will be dropped in a following FFmpeg version.
|
||||
|
||||
@item -report
|
||||
Dump full command line and console output to a file named
|
||||
|
||||
3120
doc/filters.texi
3120
doc/filters.texi
File diff suppressed because it is too large
Load Diff
@@ -61,10 +61,6 @@ Reduce the latency introduced by optional buffering
|
||||
Only write platform-, build- and time-independent data.
|
||||
This ensures that file and data checksums are reproducible and match between
|
||||
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
|
||||
|
||||
@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.
|
||||
|
||||
@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})
|
||||
|
||||
@@ -199,7 +195,7 @@ delayed bt the time duration specified in @var{offset}. Default value
|
||||
is @code{0} (meaning that no offset is applied).
|
||||
|
||||
@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})
|
||||
Separator used to separate the fields printed on the command line about the
|
||||
@@ -209,10 +205,6 @@ For example to separate the fields with newlines and indention:
|
||||
ffprobe -dump_separator "
|
||||
" -i ~/videos/matrixbench_mpeg2.mpg
|
||||
@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
|
||||
|
||||
@c man end FORMAT OPTIONS
|
||||
|
||||
@@ -103,19 +103,12 @@ enable it.
|
||||
|
||||
@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
|
||||
installing the library. Then pass @code{--enable-libopenh264} to configure to
|
||||
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
|
||||
|
||||
FFmpeg can make use of the x264 library for H.264 encoding.
|
||||
@@ -186,19 +179,6 @@ For Windows, supported AviSynth variants are
|
||||
For Linux and OS X, the supported AviSynth variant is
|
||||
@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
|
||||
AviSynth and AvxSynth are loaded dynamically. Distributors can build FFmpeg
|
||||
with @code{--enable-avisynth}, and the binaries will work regardless of the
|
||||
@@ -355,7 +335,6 @@ library:
|
||||
@item iLBC @tab X @tab X
|
||||
@item Interplay MVE @tab @tab X
|
||||
@tab Format used in various Interplay computer games.
|
||||
@item Iterated Systems ClearVideo @tab @tab X
|
||||
@item IV8 @tab @tab X
|
||||
@tab A format generated by IndigoVision 8000 video server.
|
||||
@item IVF (On2) @tab X @tab X
|
||||
@@ -401,7 +380,6 @@ library:
|
||||
@tab Audio format used on the PS3.
|
||||
@item Mirillis FIC video @tab @tab X
|
||||
@tab No cursor rendering.
|
||||
@item MIDI Sample Dump Standard @tab @tab X
|
||||
@item MIME multipart JPEG @tab X @tab
|
||||
@item MSN TCP webcam @tab @tab X
|
||||
@tab Used by MSN Messenger webcam streams.
|
||||
@@ -465,8 +443,6 @@ library:
|
||||
@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 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 16 bit big-endian @tab X @tab X
|
||||
@item raw PCM unsigned 16 bit little-endian @tab X @tab X
|
||||
@@ -474,8 +450,6 @@ library:
|
||||
@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 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 little-endian @tab X @tab X
|
||||
@item raw PCM floating-point 64 bit big-endian @tab X @tab X
|
||||
@@ -497,7 +471,6 @@ library:
|
||||
@tab Output is performed by publishing stream to RTMP server
|
||||
@item RTP @tab X @tab X
|
||||
@item RTSP @tab X @tab X
|
||||
@item Sample Dump eXchange @tab @tab X
|
||||
@item SAP @tab X @tab X
|
||||
@item SBG @tab @tab X
|
||||
@item SDP @tab @tab X
|
||||
@@ -529,7 +502,7 @@ library:
|
||||
@tab Used on the Nintendo GameCube.
|
||||
@item Tiertex Limited SEQ @tab @tab X
|
||||
@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
|
||||
@tab Audio format used in many Sony PS2 games.
|
||||
@item VC-1 test bitstream @tab X @tab X
|
||||
@@ -547,7 +520,6 @@ library:
|
||||
@tab Multimedia format used in Westwood Studios games.
|
||||
@item Westwood Studios VQA @tab @tab X
|
||||
@tab Multimedia format used in Westwood Studios games.
|
||||
@item Wideband Single-bit Data (WSD) @tab @tab X
|
||||
@item WVE @tab @tab X
|
||||
@item XMV @tab @tab X
|
||||
@tab Microsoft video container used in Xbox games.
|
||||
@@ -604,8 +576,6 @@ following image formats are supported:
|
||||
@item PNG @tab X @tab X
|
||||
@item PPM @tab X @tab X
|
||||
@tab Portable PixelMap image
|
||||
@item PSD @tab @tab X
|
||||
@tab Photoshop
|
||||
@item PTX @tab @tab X
|
||||
@tab V.Flash PTX format
|
||||
@item SGI @tab X @tab X
|
||||
@@ -622,8 +592,6 @@ following image formats are supported:
|
||||
@tab X BitMap image format
|
||||
@item XFace @tab X @tab X
|
||||
@tab X-Face image format
|
||||
@item XPM @tab @tab X
|
||||
@tab X PixMap image format
|
||||
@item XWD @tab X @tab X
|
||||
@tab X Window Dump image format
|
||||
@end multitable
|
||||
@@ -649,7 +617,6 @@ following image formats are supported:
|
||||
@item ANSI/ASCII art @tab @tab X
|
||||
@item Apple Intermediate Codec @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 QuickDraw @tab @tab X
|
||||
@tab fourcc: qdrw
|
||||
@@ -676,7 +643,6 @@ following image formats are supported:
|
||||
@item Bethesda VID video @tab @tab X
|
||||
@tab Used in some games from Bethesda Softworks.
|
||||
@item Bink Video @tab @tab X
|
||||
@item BitJazz SheerVideo @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 Brute Force & Ignorance @tab @tab X
|
||||
@@ -711,8 +677,6 @@ following image formats are supported:
|
||||
@tab fourcc: DUCK
|
||||
@item Duck TrueMotion 2.0 @tab @tab X
|
||||
@tab fourcc: TM20
|
||||
@item Duck TrueMotion 2.0 RT @tab @tab X
|
||||
@tab fourcc: TR20
|
||||
@item DV (Digital Video) @tab X @tab X
|
||||
@item Dxtory capture format @tab @tab X
|
||||
@item Feeble Files/ScummVM DXA @tab @tab X
|
||||
@@ -732,7 +696,6 @@ following image formats are supported:
|
||||
@item Flash Screen Video v2 @tab X @tab X
|
||||
@item Flash Video (FLV) @tab X @tab X
|
||||
@tab Sorenson H.263 used in Flash
|
||||
@item FM Screen Capture Codec @tab @tab X
|
||||
@item Forward Uncompressed @tab @tab X
|
||||
@item Fraps @tab @tab X
|
||||
@item Go2Meeting @tab @tab X
|
||||
@@ -780,7 +743,6 @@ following image formats are supported:
|
||||
@item LucasArts SANM/Smush @tab @tab X
|
||||
@tab Used in LucasArts games / SMUSH animations.
|
||||
@item lossless MJPEG @tab X @tab X
|
||||
@item MagicYUV Video @tab @tab X
|
||||
@item Microsoft ATC Screen @tab @tab X
|
||||
@tab Also known as Microsoft Screen 3.
|
||||
@item Microsoft Expression Encoder Screen @tab @tab X
|
||||
@@ -805,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 2 @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 NuppelVideo/RTjpeg @tab @tab X
|
||||
@tab Video encoding used in NuppelVideo files.
|
||||
@@ -846,7 +807,6 @@ following image formats are supported:
|
||||
@tab Texture dictionaries used by the Renderware Engine.
|
||||
@item RL2 video @tab @tab X
|
||||
@tab used in some games by Entertainment Software Partners
|
||||
@item ScreenPressor @tab @tab X
|
||||
@item Screenpresso @tab @tab X
|
||||
@item Sierra VMD video @tab @tab X
|
||||
@tab Used in Sierra VMD files.
|
||||
@@ -915,7 +875,7 @@ following image formats are supported:
|
||||
@item 8SVX exponential @tab @tab X
|
||||
@item 8SVX fibonacci @tab @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
|
||||
@tab encoding supported through external library libfdk-aac
|
||||
@item AC-3 @tab IX @tab IX
|
||||
@@ -990,7 +950,7 @@ following image formats are supported:
|
||||
@item COOK @tab @tab X
|
||||
@tab All versions except 5.1 are supported.
|
||||
@item DCA (DTS Coherent Acoustics) @tab X @tab X
|
||||
@tab supported extensions: XCh, XXCH, X96, XBR, XLL, LBR (partially)
|
||||
@tab supported extensions: XCh, XXCH, X96, XBR, XLL
|
||||
@item DPCM id RoQ @tab X @tab X
|
||||
@tab Used in Quake III, Jedi Knight 2 and other computer games.
|
||||
@item DPCM Interplay @tab @tab X
|
||||
@@ -1007,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), most significant bit first, planar @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 Enhanced AC-3 @tab X @tab X
|
||||
@item EVRC (Enhanced Variable Rate Codec) @tab @tab X
|
||||
@@ -1025,7 +984,7 @@ following image formats are supported:
|
||||
@item Interplay ACM @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 MLP (Meridian Lossless Packing) @tab X @tab X
|
||||
@item MLP (Meridian Lossless Packing) @tab @tab X
|
||||
@tab Used in DVD-Audio discs.
|
||||
@item Monkey's Audio @tab @tab X
|
||||
@item MP1 (MPEG audio layer 1) @tab @tab IX
|
||||
@@ -1069,7 +1028,6 @@ following image formats are supported:
|
||||
@item PCM unsigned 32-bit little-endian @tab X @tab X
|
||||
@item PCM Zork @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
|
||||
@tab There are still some distortions.
|
||||
@item RealAudio 1.0 (14.4K) @tab X @tab X
|
||||
@@ -1093,7 +1051,7 @@ following image formats are supported:
|
||||
@tab supported through external library libspeex
|
||||
@item TAK (Tom's lossless Audio Kompressor) @tab @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.
|
||||
@item TwinVQ (VQF flavor) @tab @tab X
|
||||
@item VIMA @tab @tab X
|
||||
@@ -1166,7 +1124,6 @@ performance on systems without hardware floating point support).
|
||||
@item MMSH @tab X
|
||||
@item MMST @tab X
|
||||
@item pipe @tab X
|
||||
@item Pro-MPEG FEC @tab X
|
||||
@item RTMP @tab X
|
||||
@item RTMPE @tab X
|
||||
@item RTMPS @tab X
|
||||
|
||||
@@ -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
|
||||
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
|
||||
@item @command{make distclean}
|
||||
@@ -418,7 +418,7 @@ Next let the code pass through a full run of our test suite.
|
||||
@end itemize
|
||||
|
||||
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
|
||||
added a test for that (which is recommended).
|
||||
|
||||
|
||||
@@ -233,12 +233,6 @@ Defaults to @option{false}.
|
||||
If set to @option{true}, print a list of supported formats and exit.
|
||||
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).
|
||||
|
||||
@item bm_v210
|
||||
If set to @samp{1}, video is captured in 10 bit v210 instead
|
||||
of uyvy422. Not all Blackmagic devices support this option.
|
||||
@@ -257,32 +251,6 @@ To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}.
|
||||
Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}.
|
||||
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} or @samp{wallclock}. Defaults to @samp{video}.
|
||||
|
||||
@item audio_pts
|
||||
Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
|
||||
@samp{reference} or @samp{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}.
|
||||
|
||||
@end table
|
||||
|
||||
@subsection Examples
|
||||
@@ -302,21 +270,21 @@ ffmpeg -f decklink -list_formats 1 -i 'Intensity Pro'
|
||||
@end example
|
||||
|
||||
@item
|
||||
Capture video clip at 1080i50:
|
||||
Capture video clip at 1080i50 (format 11):
|
||||
@example
|
||||
ffmpeg -format_code Hi50 -f decklink -i 'Intensity Pro' -acodec copy -vcodec copy output.avi
|
||||
ffmpeg -f decklink -i 'Intensity Pro@@11' -acodec copy -vcodec copy output.avi
|
||||
@end example
|
||||
|
||||
@item
|
||||
Capture video clip at 1080i50 10 bit:
|
||||
@example
|
||||
ffmpeg -bm_v210 1 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi
|
||||
ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
|
||||
@end example
|
||||
|
||||
@item
|
||||
Capture video clip at 1080i50 with 16 audio channels:
|
||||
@example
|
||||
ffmpeg -channels 16 -format_code Hi50 -f decklink -i 'UltraStudio Mini Recorder' -acodec copy -vcodec copy output.avi
|
||||
ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi
|
||||
@end example
|
||||
|
||||
@end itemize
|
||||
@@ -688,7 +656,7 @@ is an exact value. For HDV, it is not frame exact, since HDV does
|
||||
not have a fixed frame size.
|
||||
|
||||
@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
|
||||
given GUID is found. This is useful to select the input if multiple
|
||||
devices are connected at the same time.
|
||||
@@ -1311,6 +1279,9 @@ To enable this input device during configuration you need libxcb
|
||||
installed on your system. It will be automatically detected during
|
||||
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.
|
||||
|
||||
The filename passed as input has the syntax:
|
||||
@@ -1348,7 +1319,7 @@ ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0+10,20 out.mpg
|
||||
|
||||
@table @option
|
||||
@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}.
|
||||
|
||||
@item follow_mouse
|
||||
@@ -1398,6 +1369,11 @@ ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 25 -video_siz
|
||||
@item video_size
|
||||
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_y
|
||||
Set the grabbing region coordinates. They are expressed as offset from
|
||||
|
||||
27
doc/lexicon
27
doc/lexicon
@@ -1,27 +0,0 @@
|
||||
Common abbreviations/shorthands we use that don't need a comment
|
||||
================================================================
|
||||
|
||||
dsp: digital signal processing
|
||||
dst/adst: (asymmetric) discrete sine transform
|
||||
ec: entropy coding or error concealment
|
||||
er: error resilience
|
||||
fdct/idct: forward/inverse discrete cosine transform
|
||||
fft: fast Fourier transform
|
||||
gop: group of pictures
|
||||
hw/sw: hardware/software
|
||||
lp: lowpass
|
||||
lpf: loop filter
|
||||
lut: lookup table
|
||||
mb: macroblock
|
||||
mc: motion compensation
|
||||
me: motion estimation
|
||||
mv: motion vector
|
||||
nal: network abstraction layer
|
||||
pel/qpel/epel/hpel/fpel: pixel / quarter-pixel / eighth-pixel / half-pixel / full-pixel
|
||||
pp: post process
|
||||
qp: quantization parameter
|
||||
rc: rate control
|
||||
sei: supplemental enhancement information
|
||||
sl: slice
|
||||
vlc: variable length coding
|
||||
vq: vector quantization
|
||||
@@ -1,115 +0,0 @@
|
||||
CONTEXT
|
||||
=======
|
||||
|
||||
The FFmpeg project merges all the changes from the Libav project
|
||||
(https://libav.org) since the origin of the fork (around 2011).
|
||||
|
||||
With the exceptions of some commits due to technical/political disagreements or
|
||||
issues, the changes are merged on a more or less regular schedule (daily for
|
||||
years thanks to Michael, but more sparse nowadays).
|
||||
|
||||
WHY
|
||||
===
|
||||
|
||||
The majority of the active developers believe the project needs to keep this
|
||||
policy for various reasons.
|
||||
|
||||
The most important one is that we don't want our users to have to choose
|
||||
between two distributors of libraries of the exact same name in order to have a
|
||||
different set of features and bugfixes. By taking the responsibility of
|
||||
unifying the two codebases, we allow users to benefit from the changes from the
|
||||
two teams.
|
||||
|
||||
Today, FFmpeg has a much larger user database (we are distributed by every
|
||||
major distribution), so we consider this mission a priority.
|
||||
|
||||
A different approach to the merge could have been to pick the changes we are
|
||||
interested in and drop most of the cosmetics and other less important changes.
|
||||
Unfortunately, this makes the following picks much harder, especially since the
|
||||
Libav project is involved in various deep API changes. As a result, we decide
|
||||
to virtually take everything done there.
|
||||
|
||||
Any Libav developer is of course welcome anytime to contribute directly to the
|
||||
FFmpeg tree. Of course, we fully understand and are forced to accept that very
|
||||
few Libav developers are interested in doing so, but we still want to recognize
|
||||
their work. This leads us to create merge commits for every single one from
|
||||
Libav. The original commit appears totally unchanged with full authorship in
|
||||
our history (and the conflict are solved in the merge one). That way, not a
|
||||
single thing from Libav will be lost in the future in case some reunification
|
||||
happens, or that project disappears one way or another.
|
||||
|
||||
DOWNSIDES
|
||||
=========
|
||||
|
||||
Of course, there are many downsides to this approach.
|
||||
|
||||
- It causes a non negligible merge commits pollution. We make sure there are
|
||||
not several level of merges entangled (we do a 1:1 merge/commit), but it's
|
||||
still a non-linear history.
|
||||
|
||||
- Many duplicated work. For instance, we added libavresample in our tree to
|
||||
keep compatibility with Libav when our libswresample was already covering the
|
||||
exact same purpose. The same thing happened for various elements such as the
|
||||
ProRes support (but differences in features, bugs, licenses, ...). There are
|
||||
many work to do to unify them, and any help is very much welcome.
|
||||
|
||||
- So much manpower from both FFmpeg and Libav is lost because of this mess. We
|
||||
know it, and we don't know how to fix it. It takes incredible time to do
|
||||
these merges, so we have even less time to work on things we personally care
|
||||
about. The bad vibes also do not help with keeping our developers motivated.
|
||||
|
||||
- There is a growing technical risk factor with the merges due to the codebase
|
||||
differing more and more.
|
||||
|
||||
MERGE GUIDELINES
|
||||
================
|
||||
|
||||
The following gives developer guidelines on how to proceed when merging Libav commits.
|
||||
|
||||
Before starting, you can reduce the risk of errors on merge conflicts by using
|
||||
a different merge conflict style:
|
||||
|
||||
$ git config --global merge.conflictstyle diff3
|
||||
|
||||
tools/libav-merge-next-commit is a script to help merging the next commit in
|
||||
the queue. It assumes a remote named libav. It has two modes: merge, and noop.
|
||||
The noop mode creates a merge with no change to the HEAD. You can pass a hash
|
||||
as extra argument to reference a justification (it is common that we already
|
||||
have the change done in FFmpeg).
|
||||
|
||||
Also see tools/murge, you can copy and paste a 3 way conflict into its stdin
|
||||
and it will display colored diffs. Any arguments to murge (like ones to suppress
|
||||
whitespace differences) are passed into colordiff.
|
||||
|
||||
TODO/FIXME/UNMERGED
|
||||
===================
|
||||
|
||||
Stuff that didn't reach the codebase:
|
||||
-------------------------------------
|
||||
|
||||
- HEVC DSP and x86 MC SIMD improvements from Libav (see https://ffmpeg.org/pipermail/ffmpeg-devel/2015-December/184777.html)
|
||||
- 1f821750f hevcdsp: split the qpel functions by width instead of by the subpixel fraction
|
||||
- 818bfe7f0 hevcdsp: split the epel functions by width
|
||||
- 688417399 hevcdsp: split the pred functions by width
|
||||
- a853388d2 hevc: change the stride of the MC buffer to be in bytes instead of elements
|
||||
- 0cef06df0 checkasm: add HEVC MC tests
|
||||
- e7078e842 hevcdsp: add x86 SIMD for MC
|
||||
- VAAPI VP8 decode hwaccel (currently under review: http://ffmpeg.org/pipermail/ffmpeg-devel/2017-February/thread.html#207348)
|
||||
- Removal of the custom atomic API (5cc0057f49, see http://ffmpeg.org/pipermail/ffmpeg-devel/2017-March/209003.html)
|
||||
- Use the new bitstream filter for extracting extradata (8e2ea69135 and 096a8effa3, see https://ffmpeg.org/pipermail/ffmpeg-devel/2017-March/209068.html)
|
||||
- Read aac_adtstoasc extradata updates from packet side data on Matroska once mov and the bsf in question are fixed (See 13a211e632 and 5ef1959080)
|
||||
|
||||
Collateral damage that needs work locally:
|
||||
------------------------------------------
|
||||
|
||||
- Merge proresdec2.c and proresdec_lgpl.c
|
||||
- Merge proresenc_anatoliy.c and proresenc_kostya.c
|
||||
- Remove ADVANCED_PARSER in libavcodec/hevc_parser.c
|
||||
- Fix MIPS AC3 downmix
|
||||
- hlsenc encryption support may need some adjustment (see edc43c571d)
|
||||
|
||||
Extra changes needed to be aligned with Libav:
|
||||
----------------------------------------------
|
||||
|
||||
- Switching our examples to the new encode/decode API (see 67d28f4a0f)
|
||||
- HEVC IDCT bit depth 12-bit support (Libav added 8 and 10 but doesn't have 12)
|
||||
680
doc/muxers.texi
680
doc/muxers.texi
@@ -13,9 +13,8 @@ You can disable all the muxers with the configure option
|
||||
with the options @code{--enable-muxer=@var{MUXER}} /
|
||||
@code{--disable-muxer=@var{MUXER}}.
|
||||
|
||||
The option @code{-muxers} of the ff* tools will display the list of
|
||||
enabled muxers. Use @code{-formats} to view a combined list of
|
||||
enabled demuxers and muxers.
|
||||
The option @code{-formats} of the ff* tools will display the list of
|
||||
enabled muxers.
|
||||
|
||||
A description of some of the currently available muxers follows.
|
||||
|
||||
@@ -58,39 +57,6 @@ fragmentation or muxer overhead depending on your source. Default value is
|
||||
|
||||
@end table
|
||||
|
||||
@anchor{avi}
|
||||
@section avi
|
||||
|
||||
Audio Video Interleaved muxer.
|
||||
|
||||
@subsection Options
|
||||
|
||||
It accepts the following options:
|
||||
|
||||
@table @option
|
||||
@item reserve_index_space
|
||||
Reserve the specified amount of bytes for the OpenDML master index of each
|
||||
stream within the file header. By default additional master indexes are
|
||||
embedded within the data packets if there is no space left in the first master
|
||||
index and are linked together as a chain of indexes. This index structure can
|
||||
cause problems for some use cases, e.g. third-party software strictly relying
|
||||
on the OpenDML index specification or when file seeking is slow. Reserving
|
||||
enough index space in the file header avoids these problems.
|
||||
|
||||
The required index space depends on the output file size and should be about 16
|
||||
bytes per gigabyte. When this option is omitted or set to zero the necessary
|
||||
index space is guessed.
|
||||
|
||||
@item write_channel_mask
|
||||
Write the channel layout mask into the audio stream header.
|
||||
|
||||
This option is enabled by default. Disabling the channel mask can be useful in
|
||||
specific scenarios, e.g. when merging multiple audio streams into one for
|
||||
compatibility with software that only supports a single audio stream in AVI
|
||||
(see @ref{amerge,,the "amerge" section in the ffmpeg-filters manual,ffmpeg-filters}).
|
||||
|
||||
@end table
|
||||
|
||||
@anchor{chromaprint}
|
||||
@section chromaprint
|
||||
|
||||
@@ -163,37 +129,6 @@ and the input video converted to MPEG-2 video, use the command:
|
||||
ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -
|
||||
@end example
|
||||
|
||||
@section flv
|
||||
|
||||
Adobe Flash Video Format muxer.
|
||||
|
||||
This muxer accepts the following options:
|
||||
|
||||
@table @option
|
||||
|
||||
@item flvflags @var{flags}
|
||||
Possible values:
|
||||
|
||||
@table @samp
|
||||
|
||||
@item aac_seq_header_detect
|
||||
Place AAC sequence header based on audio stream data.
|
||||
|
||||
@item no_sequence_end
|
||||
Disable sequence end tag.
|
||||
|
||||
@item no_metadata
|
||||
Disable metadata tag.
|
||||
|
||||
@item no_duration_filesize
|
||||
Disable duration and filesize in metadata when they are equal to zero
|
||||
at the end of stream. (Be used to non-seekable living stream).
|
||||
|
||||
@item add_keyframe_index
|
||||
Used to facilitate seeking; particularly for HTTP pseudo streaming.
|
||||
@end table
|
||||
@end table
|
||||
|
||||
@anchor{framecrc}
|
||||
@section framecrc
|
||||
|
||||
@@ -239,70 +174,30 @@ ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
|
||||
|
||||
See also the @ref{crc} muxer.
|
||||
|
||||
@anchor{framehash}
|
||||
@section framehash
|
||||
|
||||
Per-packet hash testing format.
|
||||
|
||||
This muxer computes and prints a cryptographic hash for each audio
|
||||
and video packet. This can be used for packet-by-packet equality
|
||||
checks without having to individually do a binary comparison on each.
|
||||
|
||||
By default audio frames are converted to signed 16-bit raw audio and
|
||||
video frames to raw video before computing the hash, but the output
|
||||
of explicit conversions to other codecs can also be used. It uses the
|
||||
SHA-256 cryptographic hash function by default, but supports several
|
||||
other algorithms.
|
||||
|
||||
The output of the muxer consists of a line for each audio and video
|
||||
packet of the form:
|
||||
@example
|
||||
@var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, @var{hash}
|
||||
@end example
|
||||
|
||||
@var{hash} is a hexadecimal number representing the computed hash
|
||||
for the packet.
|
||||
|
||||
@table @option
|
||||
@item hash @var{algorithm}
|
||||
Use the cryptographic hash function specified by the string @var{algorithm}.
|
||||
Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
|
||||
@code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
|
||||
@code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
|
||||
@code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
|
||||
|
||||
@end table
|
||||
|
||||
@subsection Examples
|
||||
|
||||
To compute the SHA-256 hash of the audio and video frames in @file{INPUT},
|
||||
converted to raw audio and video packets, and store it in the file
|
||||
@file{out.sha256}:
|
||||
@example
|
||||
ffmpeg -i INPUT -f framehash out.sha256
|
||||
@end example
|
||||
|
||||
To print the information to stdout, using the MD5 hash function, use
|
||||
the command:
|
||||
@example
|
||||
ffmpeg -i INPUT -f framehash -hash md5 -
|
||||
@end example
|
||||
|
||||
See also the @ref{hash} muxer.
|
||||
|
||||
@anchor{framemd5}
|
||||
@section framemd5
|
||||
|
||||
Per-packet MD5 testing format.
|
||||
|
||||
This is a variant of the @ref{framehash} muxer. Unlike that muxer,
|
||||
it defaults to using the MD5 hash function.
|
||||
This muxer computes and prints the MD5 hash for each audio
|
||||
and video packet. By default audio frames are converted to signed
|
||||
16-bit raw audio and video frames to raw video before computing the
|
||||
hash.
|
||||
|
||||
The output of the muxer consists of a line for each audio and video
|
||||
packet of the form:
|
||||
@example
|
||||
@var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, @var{MD5}
|
||||
@end example
|
||||
|
||||
@var{MD5} is a hexadecimal number representing the computed MD5 hash
|
||||
for the packet.
|
||||
|
||||
@subsection Examples
|
||||
|
||||
To compute the MD5 hash of the audio and video frames in @file{INPUT},
|
||||
converted to raw audio and video packets, and store it in the file
|
||||
@file{out.md5}:
|
||||
For example to compute the MD5 of the audio and video frames in
|
||||
@file{INPUT}, converted to raw audio and video packets, and store it
|
||||
in the file @file{out.md5}:
|
||||
@example
|
||||
ffmpeg -i INPUT -f framemd5 out.md5
|
||||
@end example
|
||||
@@ -312,7 +207,7 @@ To print the information to stdout, use the command:
|
||||
ffmpeg -i INPUT -f framemd5 -
|
||||
@end example
|
||||
|
||||
See also the @ref{framehash} and @ref{md5} muxers.
|
||||
See also the @ref{md5} muxer.
|
||||
|
||||
@anchor{gif}
|
||||
@section gif
|
||||
@@ -339,59 +234,14 @@ the loops:
|
||||
ffmpeg -i INPUT -loop 10 -final_delay 500 out.gif
|
||||
@end example
|
||||
|
||||
Note 1: if you wish to extract the frames into separate GIF files, you need to
|
||||
Note 1: if you wish to extract the frames in separate GIF files, you need to
|
||||
force the @ref{image2} muxer:
|
||||
@example
|
||||
ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif"
|
||||
@end example
|
||||
|
||||
Note 2: the GIF format has a very large time base: the delay between two frames
|
||||
can therefore not be smaller than one centi second.
|
||||
|
||||
@anchor{hash}
|
||||
@section hash
|
||||
|
||||
Hash testing format.
|
||||
|
||||
This muxer computes and prints a cryptographic hash of all the input
|
||||
audio and video frames. This can be used for equality checks without
|
||||
having to do a complete binary comparison.
|
||||
|
||||
By default audio frames are converted to signed 16-bit raw audio and
|
||||
video frames to raw video before computing the hash, but the output
|
||||
of explicit conversions to other codecs can also be used. Timestamps
|
||||
are ignored. It uses the SHA-256 cryptographic hash function by default,
|
||||
but supports several other algorithms.
|
||||
|
||||
The output of the muxer consists of a single line of the form:
|
||||
@var{algo}=@var{hash}, where @var{algo} is a short string representing
|
||||
the hash function used, and @var{hash} is a hexadecimal number
|
||||
representing the computed hash.
|
||||
|
||||
@table @option
|
||||
@item hash @var{algorithm}
|
||||
Use the cryptographic hash function specified by the string @var{algorithm}.
|
||||
Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
|
||||
@code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
|
||||
@code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
|
||||
@code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
|
||||
|
||||
@end table
|
||||
|
||||
@subsection Examples
|
||||
|
||||
To compute the SHA-256 hash of the input converted to raw audio and
|
||||
video, and store it in the file @file{out.sha256}:
|
||||
@example
|
||||
ffmpeg -i INPUT -f hash out.sha256
|
||||
@end example
|
||||
|
||||
To print an MD5 hash to stdout use the command:
|
||||
@example
|
||||
ffmpeg -i INPUT -f hash -hash md5 -
|
||||
@end example
|
||||
|
||||
See also the @ref{framehash} muxer.
|
||||
Note 2: the GIF format has a very small time base: the delay between two frames
|
||||
can not be smaller than one centi second.
|
||||
|
||||
@anchor{hls}
|
||||
@section hls
|
||||
@@ -422,15 +272,8 @@ segmentation.
|
||||
This muxer supports the following options:
|
||||
|
||||
@table @option
|
||||
@item hls_init_time @var{seconds}
|
||||
Set the initial target segment length in seconds. Default value is @var{0}.
|
||||
Segment will be cut on the next key frame after this time has passed on the first m3u8 list.
|
||||
After the initial playlist is filled @command{ffmpeg} will cut segments
|
||||
at duration equal to @code{hls_time}
|
||||
|
||||
@item hls_time @var{seconds}
|
||||
Set the target segment length in seconds. Default value is 2.
|
||||
Segment will be cut on the next key frame after this time has passed.
|
||||
Set the segment length in seconds. Default value is 2.
|
||||
|
||||
@item hls_list_size @var{size}
|
||||
Set the maximum number of playlist entries. If set to 0 the list file
|
||||
@@ -442,41 +285,17 @@ parameters. Values containing @code{:} special characters must be
|
||||
escaped.
|
||||
|
||||
@item hls_wrap @var{wrap}
|
||||
This is a deprecated option, you can use @code{hls_list_size}
|
||||
and @code{hls_flags delete_segments} instead it
|
||||
Set the number after which the segment filename number (the number
|
||||
specified in each segment file) wraps. If set to 0 the number will be
|
||||
never wrapped. Default value is 0.
|
||||
|
||||
This option is useful to avoid to fill the disk with many segment
|
||||
files, and limits the maximum number of segment files written to disk
|
||||
to @var{wrap}.
|
||||
|
||||
|
||||
@item hls_start_number_source
|
||||
Start the playlist sequence number (@code{#EXT-X-MEDIA-SEQUENCE}) according to the specified source.
|
||||
Unless @code{hls_flags single_file} is set, it also specifies source of starting sequence numbers of
|
||||
segment and subtitle filenames. In any case, if @code{hls_flags append_list}
|
||||
is set and read playlist sequence number is greater than the specified start sequence number,
|
||||
then that value will be used as start value.
|
||||
|
||||
It accepts the following values:
|
||||
|
||||
@table @option
|
||||
|
||||
@item generic (default)
|
||||
Set the starting sequence numbers according to @var{start_number} option value.
|
||||
|
||||
@item epoch
|
||||
The start number will be the seconds since epoch (1970-01-01 00:00:00)
|
||||
|
||||
@item datetime
|
||||
The start number will be based on the current date/time as YYYYmmddHHMMSS. e.g. 20161231235759.
|
||||
|
||||
@end table
|
||||
|
||||
@item start_number @var{number}
|
||||
Start the playlist sequence number (@code{#EXT-X-MEDIA-SEQUENCE}) from the specified @var{number}
|
||||
when @var{hls_start_number_source} value is @var{generic}. (This is the default case.)
|
||||
Unless @code{hls_flags single_file} is set, it also specifies starting sequence numbers of segment and subtitle filenames.
|
||||
Default value is 0.
|
||||
Start the playlist sequence number from @var{number}. Default value is
|
||||
0.
|
||||
|
||||
@item hls_allow_cache @var{allowcache}
|
||||
Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.
|
||||
@@ -491,56 +310,14 @@ which can be cyclic, for example if the @option{wrap} option is
|
||||
specified.
|
||||
|
||||
@item hls_segment_filename @var{filename}
|
||||
Set the segment filename. Unless @code{hls_flags single_file} is set,
|
||||
@var{filename} is used as a string format with the segment number:
|
||||
Set the segment filename. Unless hls_flags single_file is set @var{filename}
|
||||
is used as a string format with the segment number:
|
||||
@example
|
||||
ffmpeg -i in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
|
||||
ffmpeg in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
|
||||
@end example
|
||||
This example will produce the playlist, @file{out.m3u8}, and segment files:
|
||||
@file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc.
|
||||
|
||||
@var{filename} may contain full path or relative path specification,
|
||||
but only the file name part without any path info will be contained in the m3u8 segment list.
|
||||
Should a relative path be specified, the path of the created segment
|
||||
files will be relative to the current working directory.
|
||||
When use_localtime_mkdir is set, the whole expanded value of @var{filename} will be written into the m3u8 segment list.
|
||||
|
||||
|
||||
@item use_localtime
|
||||
Use strftime() on @var{filename} to expand the segment filename with localtime.
|
||||
The segment number is also available in this mode, but to use it, you need to specify second_level_segment_index
|
||||
hls_flag and %%d will be the specifier.
|
||||
@example
|
||||
ffmpeg -i in.nut -use_localtime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
|
||||
@end example
|
||||
This example will produce the playlist, @file{out.m3u8}, and segment files:
|
||||
@file{file-20160215-1455569023.ts}, @file{file-20160215-1455569024.ts}, etc.
|
||||
Note: On some systems/environments, the @code{%s} specifier is not available. See
|
||||
@code{strftime()} documentation.
|
||||
@example
|
||||
ffmpeg -i in.nut -use_localtime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8
|
||||
@end example
|
||||
This example will produce the playlist, @file{out.m3u8}, and segment files:
|
||||
@file{file-20160215-0001.ts}, @file{file-20160215-0002.ts}, etc.
|
||||
|
||||
@item use_localtime_mkdir
|
||||
Used together with -use_localtime, it will create all subdirectories which
|
||||
is expanded in @var{filename}.
|
||||
@example
|
||||
ffmpeg -i in.nut -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
|
||||
@end example
|
||||
This example will create a directory 201560215 (if it does not exist), and then
|
||||
produce the playlist, @file{out.m3u8}, and segment files:
|
||||
@file{20160215/file-20160215-1455569023.ts}, @file{20160215/file-20160215-1455569024.ts}, etc.
|
||||
|
||||
@example
|
||||
ffmpeg -i in.nut -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8
|
||||
@end example
|
||||
This example will create a directory hierarchy 2016/02/15 (if any of them do not exist), and then
|
||||
produce the playlist, @file{out.m3u8}, and segment files:
|
||||
@file{2016/02/15/file-20160215-1455569023.ts}, @file{2016/02/15/file-20160215-1455569024.ts}, etc.
|
||||
|
||||
|
||||
@item hls_key_info_file @var{key_info_file}
|
||||
Use the information in @var{key_info_file} for segment encryption. The first
|
||||
line of @var{key_info_file} specifies the key URI written to the playlist. The
|
||||
@@ -597,12 +374,7 @@ ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
|
||||
-hls_key_info_file file.keyinfo out.m3u8
|
||||
@end example
|
||||
|
||||
|
||||
@item hls_flags @var{flags}
|
||||
Possible values:
|
||||
|
||||
@table @samp
|
||||
@item single_file
|
||||
@item hls_flags single_file
|
||||
If this flag is set, the muxer will store all segments in a single MPEG-TS
|
||||
file, and will use byte ranges in the playlist. HLS playlists generated with
|
||||
this way will have the version number 4.
|
||||
@@ -613,83 +385,9 @@ ffmpeg -i in.nut -hls_flags single_file out.m3u8
|
||||
Will produce the playlist, @file{out.m3u8}, and a single segment file,
|
||||
@file{out.ts}.
|
||||
|
||||
@item delete_segments
|
||||
@item hls_flags delete_segments
|
||||
Segment files removed from the playlist are deleted after a period of time
|
||||
equal to the duration of the segment plus the duration of the playlist.
|
||||
|
||||
@item append_list
|
||||
Append new segments into the end of old segment list,
|
||||
and remove the @code{#EXT-X-ENDLIST} from the old segment list.
|
||||
|
||||
@item round_durations
|
||||
Round the duration info in the playlist file segment info to integer
|
||||
values, instead of using floating point.
|
||||
|
||||
@item discont_start
|
||||
Add the @code{#EXT-X-DISCONTINUITY} tag to the playlist, before the
|
||||
first segment's information.
|
||||
|
||||
@item omit_endlist
|
||||
Do not append the @code{EXT-X-ENDLIST} tag at the end of the playlist.
|
||||
|
||||
@item split_by_time
|
||||
Allow segments to start on frames other than keyframes. This improves
|
||||
behavior on some players when the time between keyframes is inconsistent,
|
||||
but may make things worse on others, and can cause some oddities during
|
||||
seeking. This flag should be used with the @code{hls_time} option.
|
||||
|
||||
@item program_date_time
|
||||
Generate @code{EXT-X-PROGRAM-DATE-TIME} tags.
|
||||
|
||||
@item second_level_segment_index
|
||||
Makes it possible to use segment indexes as %%d in hls_segment_filename expression
|
||||
besides date/time values when use_localtime is on.
|
||||
To get fixed width numbers with trailing zeroes, %%0xd format is available where x is the required width.
|
||||
|
||||
@item second_level_segment_size
|
||||
Makes it possible to use segment sizes (counted in bytes) as %%s in hls_segment_filename
|
||||
expression besides date/time values when use_localtime is on.
|
||||
To get fixed width numbers with trailing zeroes, %%0xs format is available where x is the required width.
|
||||
|
||||
@item second_level_segment_duration
|
||||
Makes it possible to use segment duration (calculated in microseconds) as %%t in hls_segment_filename
|
||||
expression besides date/time values when use_localtime is on.
|
||||
To get fixed width numbers with trailing zeroes, %%0xt format is available where x is the required width.
|
||||
|
||||
@example
|
||||
ffmpeg -i sample.mpeg \
|
||||
-f hls -hls_time 3 -hls_list_size 5 \
|
||||
-hls_flags second_level_segment_index+second_level_segment_size+second_level_segment_duration \
|
||||
-use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
|
||||
@end example
|
||||
This will produce segments like this:
|
||||
@file{segment_20170102194334_0003_00122200_0000003000000.ts}, @file{segment_20170102194334_0004_00120072_0000003000000.ts} etc.
|
||||
|
||||
@item temp_file
|
||||
Write segment data to filename.tmp and rename to filename only once the segment is complete. A webserver
|
||||
serving up segments can be configured to reject requests to *.tmp to prevent access to in-progress segments
|
||||
before they have been added to the m3u8 playlist.
|
||||
|
||||
@end table
|
||||
|
||||
@item hls_playlist_type event
|
||||
Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces
|
||||
@option{hls_list_size} to 0; the playlist can only be appended to.
|
||||
|
||||
@item hls_playlist_type vod
|
||||
Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces
|
||||
@option{hls_list_size} to 0; the playlist must not change.
|
||||
|
||||
@item method
|
||||
Use the given HTTP method to create the hls files.
|
||||
@example
|
||||
ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8
|
||||
@end example
|
||||
This example will upload all the mpegts segment files to the HTTP
|
||||
server using the HTTP PUT method, and update the m3u8 files every
|
||||
@code{refresh} times using the same method.
|
||||
Note that the HTTP server must support the given method for uploading
|
||||
files.
|
||||
@end table
|
||||
|
||||
@anchor{ico}
|
||||
@@ -761,7 +459,7 @@ The following example shows how to use @command{ffmpeg} for creating a
|
||||
sequence of files @file{img-001.jpeg}, @file{img-002.jpeg}, ...,
|
||||
taking one image every second from the input video:
|
||||
@example
|
||||
ffmpeg -i in.avi -vsync cfr -r 1 -f image2 'img-%03d.jpeg'
|
||||
ffmpeg -i in.avi -vsync 1 -r 1 -f image2 'img-%03d.jpeg'
|
||||
@end example
|
||||
|
||||
Note that with @command{ffmpeg}, if the format is not specified with the
|
||||
@@ -769,12 +467,12 @@ Note that with @command{ffmpeg}, if the format is not specified with the
|
||||
format, the image2 muxer is automatically selected, so the previous
|
||||
command can be written as:
|
||||
@example
|
||||
ffmpeg -i in.avi -vsync cfr -r 1 'img-%03d.jpeg'
|
||||
ffmpeg -i in.avi -vsync 1 -r 1 'img-%03d.jpeg'
|
||||
@end example
|
||||
|
||||
Note also that the pattern must not necessarily contain "%d" or
|
||||
"%0@var{N}d", for example to create a single image file
|
||||
@file{img.jpeg} from the start of the input video you can employ the command:
|
||||
@file{img.jpeg} from the input video you can employ the command:
|
||||
@example
|
||||
ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
|
||||
@end example
|
||||
@@ -903,12 +601,16 @@ have no effect if it is not.
|
||||
|
||||
MD5 testing format.
|
||||
|
||||
This is a variant of the @ref{hash} muxer. Unlike that muxer, it
|
||||
defaults to using the MD5 hash function.
|
||||
This muxer computes and prints the MD5 hash of all the input audio
|
||||
and video frames. By default audio frames are converted to signed
|
||||
16-bit raw audio and video frames to raw video before computing the
|
||||
hash. Timestamps are ignored.
|
||||
|
||||
@subsection Examples
|
||||
The output of the muxer consists of a single line of the form:
|
||||
MD5=@var{MD5}, where @var{MD5} is a hexadecimal number representing
|
||||
the computed MD5 hash.
|
||||
|
||||
To compute the MD5 hash of the input converted to raw
|
||||
For example to compute the MD5 hash of the input converted to raw
|
||||
audio and video, and store it in the file @file{out.md5}:
|
||||
@example
|
||||
ffmpeg -i INPUT -f md5 out.md5
|
||||
@@ -919,7 +621,7 @@ You can print the MD5 to stdout with the command:
|
||||
ffmpeg -i INPUT -f md5 -
|
||||
@end example
|
||||
|
||||
See also the @ref{hash} and @ref{framemd5} muxers.
|
||||
See also the @ref{framemd5} muxer.
|
||||
|
||||
@section mov, mp4, ismv
|
||||
|
||||
@@ -1010,9 +712,6 @@ the new default-base-is-moof flag instead. This flag is new from
|
||||
14496-12:2012. This may make the fragments easier to parse in certain
|
||||
circumstances (avoiding basing track fragment location calculations
|
||||
on the implicit end of the previous track fragment).
|
||||
@item -write_tmcd
|
||||
Specify @code{on} to force writing a timecode track, @code{off} to disable it
|
||||
and @code{auto} to write a timecode track only for mov and mp4 output (default).
|
||||
@end table
|
||||
|
||||
@subsection Example
|
||||
@@ -1091,35 +790,69 @@ This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
|
||||
|
||||
The recognized metadata settings in mpegts muxer are @code{service_provider}
|
||||
and @code{service_name}. If they are not set the default for
|
||||
@code{service_provider} is @samp{FFmpeg} and the default for
|
||||
@code{service_name} is @samp{Service01}.
|
||||
@code{service_provider} is "FFmpeg" and the default for
|
||||
@code{service_name} is "Service01".
|
||||
|
||||
@subsection Options
|
||||
|
||||
The muxer options are:
|
||||
|
||||
@table @option
|
||||
@item mpegts_transport_stream_id @var{integer}
|
||||
Set the @samp{transport_stream_id}. This identifies a transponder in DVB.
|
||||
Default is @code{0x0001}.
|
||||
@item -mpegts_original_network_id @var{number}
|
||||
Set the original_network_id (default 0x0001). This is unique identifier
|
||||
of a network in DVB. Its main use is in the unique identification of a
|
||||
service through the path Original_Network_ID, Transport_Stream_ID.
|
||||
@item -mpegts_transport_stream_id @var{number}
|
||||
Set the transport_stream_id (default 0x0001). This identifies a
|
||||
transponder in DVB.
|
||||
@item -mpegts_service_id @var{number}
|
||||
Set the service_id (default 0x0001) also known as program in DVB.
|
||||
@item -mpegts_service_type @var{number}
|
||||
Set the program service_type (default @var{digital_tv}), see below
|
||||
a list of pre defined values.
|
||||
@item -mpegts_pmt_start_pid @var{number}
|
||||
Set the first PID for PMT (default 0x1000, max 0x1f00).
|
||||
@item -mpegts_start_pid @var{number}
|
||||
Set the first PID for data packets (default 0x0100, max 0x0f00).
|
||||
@item -mpegts_m2ts_mode @var{number}
|
||||
Enable m2ts mode if set to 1. Default value is -1 which disables m2ts mode.
|
||||
@item -muxrate @var{number}
|
||||
Set a constant muxrate (default VBR).
|
||||
@item -pcr_period @var{numer}
|
||||
Override the default PCR retransmission time (default 20ms), ignored
|
||||
if variable muxrate is selected.
|
||||
@item pat_period @var{number}
|
||||
Maximal time in seconds between PAT/PMT tables.
|
||||
@item sdt_period @var{number}
|
||||
Maximal time in seconds between SDT tables.
|
||||
@item -pes_payload_size @var{number}
|
||||
Set minimum PES packet payload in bytes.
|
||||
@item -mpegts_flags @var{flags}
|
||||
Set flags (see below).
|
||||
@item -mpegts_copyts @var{number}
|
||||
Preserve original timestamps, if value is set to 1. Default value is -1, which
|
||||
results in shifting timestamps so that they start from 0.
|
||||
@item -tables_version @var{number}
|
||||
Set PAT, PMT and SDT version (default 0, valid values are from 0 to 31, inclusively).
|
||||
This option allows updating stream structure so that standard consumer may
|
||||
detect the change. To do so, reopen output AVFormatContext (in case of API
|
||||
usage) or restart ffmpeg instance, cyclically changing tables_version value:
|
||||
@example
|
||||
ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
|
||||
ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
|
||||
...
|
||||
ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
|
||||
ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
|
||||
ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
|
||||
...
|
||||
@end example
|
||||
@end table
|
||||
|
||||
@item mpegts_original_network_id @var{integer}
|
||||
Set the @samp{original_network_id}. This is unique identifier of a
|
||||
network in DVB. Its main use is in the unique identification of a service
|
||||
through the path @samp{Original_Network_ID, Transport_Stream_ID}. Default
|
||||
is @code{0x0001}.
|
||||
Option mpegts_service_type accepts the following values:
|
||||
|
||||
@item mpegts_service_id @var{integer}
|
||||
Set the @samp{service_id}, also known as program in DVB. Default is
|
||||
@code{0x0001}.
|
||||
|
||||
@item mpegts_service_type @var{integer}
|
||||
Set the program @samp{service_type}. Default is @code{digital_tv}.
|
||||
Accepts the following options:
|
||||
@table @samp
|
||||
@table @option
|
||||
@item hex_value
|
||||
Any hexdecimal value between @code{0x01} to @code{0xff} as defined in
|
||||
ETSI 300 468.
|
||||
Any hexdecimal value between 0x01 to 0xff as defined in ETSI 300 468.
|
||||
@item digital_tv
|
||||
Digital TV service.
|
||||
@item digital_radio
|
||||
@@ -1136,26 +869,9 @@ Advanced Codec Digital SDTV service.
|
||||
Advanced Codec Digital HDTV service.
|
||||
@end table
|
||||
|
||||
@item mpegts_pmt_start_pid @var{integer}
|
||||
Set the first PID for PMT. Default is @code{0x1000}. Max is @code{0x1f00}.
|
||||
Option mpegts_flags may take a set of such flags:
|
||||
|
||||
@item mpegts_start_pid @var{integer}
|
||||
Set the first PID for data packets. Default is @code{0x0100}. Max is
|
||||
@code{0x0f00}.
|
||||
|
||||
@item mpegts_m2ts_mode @var{boolean}
|
||||
Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
|
||||
disables m2ts mode.
|
||||
|
||||
@item muxrate @var{integer}
|
||||
Set a constant muxrate. Default is VBR.
|
||||
|
||||
@item pes_payload_size @var{integer}
|
||||
Set minimum PES packet payload in bytes. Default is @code{2930}.
|
||||
|
||||
@item mpegts_flags @var{flags}
|
||||
Set mpegts flags. Accepts the following options:
|
||||
@table @samp
|
||||
@table @option
|
||||
@item resend_headers
|
||||
Reemit PAT/PMT before writing the next packet.
|
||||
@item latm
|
||||
@@ -1164,47 +880,6 @@ Use LATM packetization for AAC.
|
||||
Reemit PAT and PMT at each video frame.
|
||||
@item system_b
|
||||
Conform to System B (DVB) instead of System A (ATSC).
|
||||
@item initial_discontinuity
|
||||
Mark the initial packet of each stream as discontinuity.
|
||||
@end table
|
||||
|
||||
@item resend_headers @var{integer}
|
||||
Reemit PAT/PMT before writing the next packet. This option is deprecated:
|
||||
use @option{mpegts_flags} instead.
|
||||
|
||||
@item mpegts_copyts @var{boolean}
|
||||
Preserve original timestamps, if value is set to @code{1}. Default value
|
||||
is @code{-1}, which results in shifting timestamps so that they start from 0.
|
||||
|
||||
@item omit_video_pes_length @var{boolean}
|
||||
Omit the PES packet length for video packets. Default is @code{1} (true).
|
||||
|
||||
@item pcr_period @var{integer}
|
||||
Override the default PCR retransmission time in milliseconds. Ignored if
|
||||
variable muxrate is selected. Default is @code{20}.
|
||||
|
||||
@item pat_period @var{double}
|
||||
Maximum time in seconds between PAT/PMT tables.
|
||||
|
||||
@item sdt_period @var{double}
|
||||
Maximum time in seconds between SDT tables.
|
||||
|
||||
@item tables_version @var{integer}
|
||||
Set PAT, PMT and SDT version (default @code{0}, valid values are from 0 to 31, inclusively).
|
||||
This option allows updating stream structure so that standard consumer may
|
||||
detect the change. To do so, reopen output @code{AVFormatContext} (in case of API
|
||||
usage) or restart @command{ffmpeg} instance, cyclically changing
|
||||
@option{tables_version} value:
|
||||
|
||||
@example
|
||||
ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
|
||||
ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
|
||||
...
|
||||
ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
|
||||
ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
|
||||
ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
|
||||
...
|
||||
@end example
|
||||
@end table
|
||||
|
||||
@subsection Example
|
||||
@@ -1218,7 +893,7 @@ ffmpeg -i file.mpg -c copy \
|
||||
-mpegts_start_pid 0x150 \
|
||||
-metadata service_provider="Some provider" \
|
||||
-metadata service_name="Some Channel" \
|
||||
out.ts
|
||||
-y out.ts
|
||||
@end example
|
||||
|
||||
@section mxf, mxf_d10
|
||||
@@ -1342,12 +1017,6 @@ implementation for HLS segmentation.
|
||||
The segment muxer supports the following options:
|
||||
|
||||
@table @option
|
||||
@item increment_tc @var{1|0}
|
||||
if set to @code{1}, increment timecode between each segment
|
||||
If this is selected, the input need to have
|
||||
a timecode in the first video stream. Default value is
|
||||
@code{0}.
|
||||
|
||||
@item reference_stream @var{specifier}
|
||||
Set the reference stream, as specified by the string @var{specifier}.
|
||||
If @var{specifier} is set to @code{auto}, the reference is chosen
|
||||
@@ -1467,6 +1136,9 @@ within the specified duration after the segmenting clock time. This way you
|
||||
can make the segmenter more resilient to backward local time jumps, such as
|
||||
leap seconds or transition to standard time from daylight savings time.
|
||||
|
||||
Assuming that the delay between the packets of your source is less than 0.5
|
||||
second you can detect a leap second by specifying 0.5 as the duration.
|
||||
|
||||
Default is the maximum possible duration which means starting a new segment
|
||||
regardless of the elapsed time since the last clock time.
|
||||
|
||||
@@ -1532,11 +1204,6 @@ muxers/codecs. It is set to @code{0} by default.
|
||||
@item initial_offset @var{offset}
|
||||
Specify timestamp offset to apply to the output packet timestamps. The
|
||||
argument must be a time duration specification, and defaults to 0.
|
||||
|
||||
@item write_empty_segments @var{1|0}
|
||||
If enabled, write an empty segment if there are no packets during the period a
|
||||
segment would usually span. Otherwise, the segment will be filled with the next
|
||||
packet written. Defaults to @code{0}.
|
||||
@end table
|
||||
|
||||
@subsection Examples
|
||||
@@ -1584,9 +1251,9 @@ ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_fr
|
||||
|
||||
@item
|
||||
Convert the @file{in.mkv} to TS segments using the @code{libx264}
|
||||
and @code{aac} encoders:
|
||||
and @code{libfaac} encoders:
|
||||
@example
|
||||
ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
|
||||
ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a libfaac -f ssegment -segment_list out.list out%03d.ts
|
||||
@end example
|
||||
|
||||
@item
|
||||
@@ -1620,102 +1287,6 @@ Specify whether to remove all fragments when finished. Default 0 (do not remove)
|
||||
|
||||
@end table
|
||||
|
||||
@anchor{fifo}
|
||||
@section fifo
|
||||
|
||||
The fifo pseudo-muxer allows the separation of encoding and muxing by using
|
||||
first-in-first-out queue and running the actual muxer in a separate thread. This
|
||||
is especially useful in combination with the @ref{tee} muxer and can be used to
|
||||
send data to several destinations with different reliability/writing speed/latency.
|
||||
|
||||
API users should be aware that callback functions (interrupt_callback,
|
||||
io_open and io_close) used within its AVFormatContext must be thread-safe.
|
||||
|
||||
The behavior of the fifo muxer if the queue fills up or if the output fails is
|
||||
selectable,
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
output can be transparently restarted with configurable delay between retries
|
||||
based on real time or time of the processed stream.
|
||||
|
||||
@item
|
||||
encoding can be blocked during temporary failure, or continue transparently
|
||||
dropping packets in case fifo queue fills up.
|
||||
|
||||
@end itemize
|
||||
|
||||
@table @option
|
||||
|
||||
@item fifo_format
|
||||
Specify the format name. Useful if it cannot be guessed from the
|
||||
output name suffix.
|
||||
|
||||
@item queue_size
|
||||
Specify size of the queue (number of packets). Default value is 60.
|
||||
|
||||
@item format_opts
|
||||
Specify format options for the underlying muxer. Muxer options can be specified
|
||||
as a list of @var{key}=@var{value} pairs separated by ':'.
|
||||
|
||||
@item drop_pkts_on_overflow @var{bool}
|
||||
If set to 1 (true), in case the fifo queue fills up, packets will be dropped
|
||||
rather than blocking the encoder. This makes it possible to continue streaming without
|
||||
delaying the input, at the cost of omitting part of the stream. By default
|
||||
this option is set to 0 (false), so in such cases the encoder will be blocked
|
||||
until the muxer processes some of the packets and none of them is lost.
|
||||
|
||||
@item attempt_recovery @var{bool}
|
||||
If failure occurs, attempt to recover the output. This is especially useful
|
||||
when used with network output, since it makes it possible to restart streaming transparently.
|
||||
By default this option is set to 0 (false).
|
||||
|
||||
@item max_recovery_attempts
|
||||
Sets maximum number of successive unsuccessful recovery attempts after which
|
||||
the output fails permanently. By default this option is set to 0 (unlimited).
|
||||
|
||||
@item recovery_wait_time @var{duration}
|
||||
Waiting time before the next recovery attempt after previous unsuccessful
|
||||
recovery attempt. Default value is 5 seconds.
|
||||
|
||||
@item recovery_wait_streamtime @var{bool}
|
||||
If set to 0 (false), the real time is used when waiting for the recovery
|
||||
attempt (i.e. the recovery will be attempted after at least
|
||||
recovery_wait_time seconds).
|
||||
If set to 1 (true), the time of the processed stream is taken into account
|
||||
instead (i.e. the recovery will be attempted after at least @var{recovery_wait_time}
|
||||
seconds of the stream is omitted).
|
||||
By default, this option is set to 0 (false).
|
||||
|
||||
@item recover_any_error @var{bool}
|
||||
If set to 1 (true), recovery will be attempted regardless of type of the error
|
||||
causing the failure. By default this option is set to 0 (false) and in case of
|
||||
certain (usually permanent) errors the recovery is not attempted even when
|
||||
@var{attempt_recovery} is set to 1.
|
||||
|
||||
@item restart_with_keyframe @var{bool}
|
||||
Specify whether to wait for the keyframe after recovering from
|
||||
queue overflow or failure. This option is set to 0 (false) by default.
|
||||
|
||||
@end table
|
||||
|
||||
@subsection Examples
|
||||
|
||||
@itemize
|
||||
|
||||
@item
|
||||
Stream something to rtmp server, continue processing the stream at real-time
|
||||
rate even in case of temporary failure (network outage) and attempt to recover
|
||||
streaming every second indefinitely.
|
||||
@example
|
||||
ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv -map 0:v -map 0:a
|
||||
-drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 rtmp://example.com/live/stream_name
|
||||
@end example
|
||||
|
||||
@end itemize
|
||||
|
||||
@anchor{tee}
|
||||
@section tee
|
||||
|
||||
The tee muxer can be used to write the same data to several files or any
|
||||
@@ -1728,18 +1299,6 @@ with the tee muxer; encoding can be a very expensive process. It is not
|
||||
useful when using the libavformat API directly because it is then possible
|
||||
to feed the same packets to several muxers directly.
|
||||
|
||||
@table @option
|
||||
|
||||
@item use_fifo @var{bool}
|
||||
If set to 1, slave outputs will be processed in separate thread using @ref{fifo}
|
||||
muxer. This allows to compensate for different speed/latency/reliability of
|
||||
outputs and setup transparent recovery. By default this feature is turned off.
|
||||
|
||||
@item fifo_options
|
||||
Options to pass to fifo pseudo-muxer instances. See @ref{fifo}.
|
||||
|
||||
@end table
|
||||
|
||||
The slave outputs are specified in the file name given to the muxer,
|
||||
separated by '|'. If any of the slave name contains the '|' separator,
|
||||
leading or trailing spaces or any special character, it must be
|
||||
@@ -1761,13 +1320,6 @@ output name suffix.
|
||||
Specify a list of bitstream filters to apply to the specified
|
||||
output.
|
||||
|
||||
@item use_fifo @var{bool}
|
||||
This allows to override tee muxer use_fifo option for individual slave muxer.
|
||||
|
||||
@item fifo_options
|
||||
This allows to override tee muxer fifo_options for individual slave muxer.
|
||||
See @ref{fifo}.
|
||||
|
||||
It is possible to specify to which streams a given bitstream filter
|
||||
applies, by appending a stream specifier to the option separated by
|
||||
@code{/}. @var{spec} must be a stream specifier (see @ref{Format
|
||||
@@ -1781,12 +1333,6 @@ Select the streams that should be mapped to the slave output,
|
||||
specified by a stream specifier. If not specified, this defaults to
|
||||
all the input streams. You may use multiple stream specifiers
|
||||
separated by commas (@code{,}) e.g.: @code{a:0,v}
|
||||
|
||||
@item onfail
|
||||
Specify behaviour on output failure. This can be set to either @code{abort} (which is
|
||||
default) or @code{ignore}. @code{abort} will cause whole process to fail in case of failure
|
||||
on this slave output. @code{ignore} will ignore failure on this output, so other outputs
|
||||
will continue without being affected.
|
||||
@end table
|
||||
|
||||
@subsection Examples
|
||||
@@ -1800,14 +1346,6 @@ ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
|
||||
"archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
|
||||
@end example
|
||||
|
||||
@item
|
||||
As above, but continue streaming even if output to local file fails
|
||||
(for example local drive fills up):
|
||||
@example
|
||||
ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
|
||||
"[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
|
||||
@end example
|
||||
|
||||
@item
|
||||
Use @command{ffmpeg} to encode the input, and send the output
|
||||
to three different destinations. The @code{dump_extra} bitstream
|
||||
@@ -1816,7 +1354,7 @@ keyframes packets, as requested by the MPEG-TS format. The select
|
||||
option is applied to @file{out.aac} in order to make it contain only
|
||||
audio packets.
|
||||
@example
|
||||
ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
|
||||
ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac -strict experimental
|
||||
-f tee "[bsfs/v=dump_extra]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac"
|
||||
@end example
|
||||
|
||||
@@ -1825,7 +1363,7 @@ As below, but select only stream @code{a:1} for the audio output. Note
|
||||
that a second level escaping must be performed, as ":" is a special
|
||||
character used to separate options.
|
||||
@example
|
||||
ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
|
||||
ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac -strict experimental
|
||||
-f tee "[bsfs/v=dump_extra]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac"
|
||||
@end example
|
||||
@end itemize
|
||||
|
||||
@@ -34,7 +34,7 @@ NUT has some variants signaled by using the flags field in its main header.
|
||||
|
||||
The BROADCAST variant provides a secondary time reference to facilitate
|
||||
detecting endpoint latency and network delays.
|
||||
It assumes all the endpoint clocks are synchronized.
|
||||
It assumes all the endpoint clocks are syncronized.
|
||||
To be used in real-time scenarios.
|
||||
|
||||
@section PIPE
|
||||
|
||||
@@ -7,7 +7,7 @@ If you plan to do non-x86 architecture specific optimizations (SIMD normally),
|
||||
then take a look in the x86/ directory, as most important functions are
|
||||
already optimized for MMX.
|
||||
|
||||
If you want to do x86 optimizations then you can either try to fine-tune the
|
||||
If you want to do x86 optimizations then you can either try to finetune the
|
||||
stuff in the x86 directory or find some other functions in the C source to
|
||||
optimize, but there aren't many left.
|
||||
|
||||
@@ -142,7 +142,7 @@ Alignment:
|
||||
Some instructions on some architectures have strict alignment restrictions,
|
||||
for example most SSE/SSE2 instructions on x86.
|
||||
The minimum guaranteed alignment is written in the .h files, for example:
|
||||
void (*put_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, ptrdiff_t stride);
|
||||
void (*put_pixels_clamped)(const int16_t *block/*align 16*/, UINT8 *pixels/*align 8*/, int line_size);
|
||||
|
||||
|
||||
General Tips:
|
||||
@@ -163,7 +163,7 @@ general x86 registers (e.g. eax) as well as XMM registers. This last one is
|
||||
particularly important on Win64, where xmm6-15 are callee-save, and not
|
||||
restoring their contents leads to undefined results. In external asm (e.g.
|
||||
yasm), you do this by using:
|
||||
cglobal function_name, num_args, num_regs, num_xmm_regs
|
||||
cglobal functon_name, num_args, num_regs, num_xmm_regs
|
||||
In inline asm, you specify clobbered registers at the end of your asm:
|
||||
__asm__(".." ::: "%eax").
|
||||
If gcc is not set to support sse (-msse) it will not accept xmm registers
|
||||
|
||||
@@ -131,8 +131,8 @@ and @code{--extra-ldflags}.
|
||||
On Windows, you need to run the IDL files through @command{widl}.
|
||||
|
||||
DeckLink is very picky about the formats it supports. Pixel format is always
|
||||
uyvy422, framerate, field order and video size must be determined for your
|
||||
device with @command{-list_formats 1}. Audio sample rate is always 48 kHz.
|
||||
uyvy422, framerate and video size must be determined for your device with
|
||||
@command{-list_formats 1}. Audio sample rate is always 48 kHz.
|
||||
|
||||
@subsection Options
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
Patchwork states
|
||||
|
||||
NEW: Initial state of new patches
|
||||
Accepted: The patch was pushed to the main master repository
|
||||
Rejected: The patch has been rejected
|
||||
Withdrawn: The patch was withdrawn by the author
|
||||
Not Applicable: The patch does not apply to the main master repository
|
||||
Superseded: A newer version of the patch has been posted
|
||||
Changes Requested: The patch has been or is under review and changes have been requested
|
||||
RFC: The patch is not intended to be applied but only for comments
|
||||
@@ -63,7 +63,7 @@ bash ./configure
|
||||
@section Darwin (Mac OS X, iPhone)
|
||||
|
||||
The toolchain provided with Xcode is sufficient to build the basic
|
||||
unaccelerated code.
|
||||
unacelerated code.
|
||||
|
||||
Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
|
||||
@url{https://github.com/FFmpeg/gas-preprocessor} or
|
||||
@@ -144,7 +144,7 @@ pacman -S make pkgconf diffutils
|
||||
pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL
|
||||
@end example
|
||||
|
||||
To target 32 bits replace @code{x86_64} with @code{i686} in the command above.
|
||||
To target 32bit replace the @code{x86_64} with @code{i686} in the command above.
|
||||
|
||||
@section Microsoft Visual C++ or Intel C++ Compiler for Windows
|
||||
|
||||
@@ -173,7 +173,7 @@ earlier, place @code{c99wrap.exe} and @code{c99conv.exe} somewhere in your
|
||||
Next, make sure any other headers and libs you want to use, such as zlib, are
|
||||
located in a spot that the compiler can see. Do so by modifying the @code{LIB}
|
||||
and @code{INCLUDE} environment variables to include the @strong{Windows-style}
|
||||
paths to these directories. Alternatively, you can try to use the
|
||||
paths to these directories. Alternatively, you can try and use the
|
||||
@code{--extra-cflags}/@code{--extra-ldflags} configure options. If using MSVC
|
||||
2012 or earlier, place @code{inttypes.h} somewhere the compiler can see too.
|
||||
|
||||
@@ -314,7 +314,7 @@ These library packages are only available from
|
||||
@uref{http://sourceware.org/cygwinports/, Cygwin Ports}:
|
||||
|
||||
@example
|
||||
yasm, libSDL-devel, libgsm-devel, libmp3lame-devel,
|
||||
yasm, libSDL-devel, libfaac-devel, libgsm-devel, libmp3lame-devel,
|
||||
libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel
|
||||
@end example
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
@@ -31,16 +30,11 @@
|
||||
// for the target. without this build breaks on mingw
|
||||
#define AVFORMAT_OS_SUPPORT_H
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
/* Forcibly turn off deprecation warnings, which just add noise here. */
|
||||
#undef attribute_deprecated
|
||||
#define attribute_deprecated
|
||||
|
||||
#include "libavcodec/options_table.h"
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/options_table.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavcodec/options_table.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
static void print_usage(void)
|
||||
{
|
||||
|
||||
@@ -5,11 +5,6 @@ The libavformat library provides some generic global options, which
|
||||
can be set on all the protocols. In addition each protocol may support
|
||||
so-called private options, which are specific for that component.
|
||||
|
||||
Options may be set by specifying -@var{option} @var{value} in the
|
||||
FFmpeg tools, or by setting the value explicitly in the
|
||||
@code{AVFormatContext} options or using the @file{libavutil/opt.h} API
|
||||
for programmatic use.
|
||||
|
||||
The list of supported options follows:
|
||||
|
||||
@table @option
|
||||
@@ -41,14 +36,6 @@ particular protocol using the option
|
||||
The option "-protocols" of the ff* tools will display the list of
|
||||
supported protocols.
|
||||
|
||||
All protocols accept the following options:
|
||||
|
||||
@table @option
|
||||
@item rw_timeout
|
||||
Maximum time to wait for (network) read/write operations to complete,
|
||||
in microseconds.
|
||||
@end table
|
||||
|
||||
A description of the currently available protocols follows.
|
||||
|
||||
@section async
|
||||
@@ -229,17 +216,6 @@ it, unless special care is taken (tests, customized server configuration
|
||||
etc.). Different FTP servers behave in different way during seek
|
||||
operation. ff* tools may produce incomplete content due to server limitations.
|
||||
|
||||
This protocol accepts the following options:
|
||||
|
||||
@table @option
|
||||
@item follow
|
||||
If set to 1, the protocol will retry reading at the end of the file, allowing
|
||||
reading files that still are being written. In order for this to terminate,
|
||||
you either need to use the rw_timeout option, or use the interrupt callback
|
||||
(for API users).
|
||||
|
||||
@end table
|
||||
|
||||
@section gopher
|
||||
|
||||
Gopher protocol.
|
||||
@@ -281,7 +257,7 @@ value is -1.
|
||||
If set to 1 use chunked Transfer-Encoding for posts, default is 1.
|
||||
|
||||
@item content_type
|
||||
Set a specific content type for the POST messages or for listen mode.
|
||||
Set a specific content type for the POST messages.
|
||||
|
||||
@item http_proxy
|
||||
set HTTP proxy to tunnel through e.g. http://example.com:1234
|
||||
@@ -296,13 +272,11 @@ Use persistent connections if set to 1, default is 0.
|
||||
@item post_data
|
||||
Set custom HTTP post data.
|
||||
|
||||
@item user-agent
|
||||
@item user_agent
|
||||
Override the User-Agent header. If not specified the protocol will use a
|
||||
string describing the libavformat build. ("Lavf/<version>")
|
||||
|
||||
@item user-agent
|
||||
This is a deprecated option, you can use user_agent instead it.
|
||||
|
||||
@item timeout
|
||||
Set timeout in microseconds of socket I/O operations used by the underlying low level
|
||||
operation. By default it is set to -1, which means that the timeout is
|
||||
@@ -362,7 +336,7 @@ autodetection in the future.
|
||||
If set to 1 enables experimental HTTP server. This can be used to send data when
|
||||
used as an output option, or read data from a client with HTTP POST when used as
|
||||
an input option.
|
||||
If set to 2 enables experimental multi-client HTTP server. This is not yet implemented
|
||||
If set to 2 enables experimental mutli-client HTTP server. This is not yet implemented
|
||||
in ffmpeg.c or ffserver.c and thus must not be used as a command line option.
|
||||
@example
|
||||
# Server side (sending):
|
||||
@@ -520,41 +494,6 @@ time, which is valuable if data transmission is slow.
|
||||
Note that some formats (typically MOV), require the output protocol to
|
||||
be seekable, so they will fail with the pipe output protocol.
|
||||
|
||||
@section prompeg
|
||||
|
||||
Pro-MPEG Code of Practice #3 Release 2 FEC protocol.
|
||||
|
||||
The Pro-MPEG CoP#3 FEC is a 2D parity-check forward error correction mechanism
|
||||
for MPEG-2 Transport Streams sent over RTP.
|
||||
|
||||
This protocol must be used in conjunction with the @code{rtp_mpegts} muxer and
|
||||
the @code{rtp} protocol.
|
||||
|
||||
The required syntax is:
|
||||
@example
|
||||
-f rtp_mpegts -fec prompeg=@var{option}=@var{val}... rtp://@var{hostname}:@var{port}
|
||||
@end example
|
||||
|
||||
The destination UDP ports are @code{port + 2} for the column FEC stream
|
||||
and @code{port + 4} for the row FEC stream.
|
||||
|
||||
This protocol accepts the following options:
|
||||
@table @option
|
||||
|
||||
@item l=@var{n}
|
||||
The number of columns (4-20, LxD <= 100)
|
||||
|
||||
@item d=@var{n}
|
||||
The number of rows (4-20, LxD <= 100)
|
||||
|
||||
@end table
|
||||
|
||||
Example usage:
|
||||
|
||||
@example
|
||||
-f rtp_mpegts -fec prompeg=l=8:d=4 rtp://@var{hostname}:@var{port}
|
||||
@end example
|
||||
|
||||
@section rtmp
|
||||
|
||||
Real-Time Messaging Protocol.
|
||||
@@ -737,7 +676,7 @@ This protocol accepts the following options.
|
||||
|
||||
@table @option
|
||||
@item timeout
|
||||
Set timeout in milliseconds of socket I/O operations used by the underlying
|
||||
Set timeout in miliseconds of socket I/O operations used by the underlying
|
||||
low level operation. By default it is set to -1, which means that the timeout
|
||||
is not specified.
|
||||
|
||||
@@ -1201,15 +1140,6 @@ Play an AVI file directly from a TAR archive:
|
||||
subfile,,start,183241728,end,366490624,,:archive.tar
|
||||
@end example
|
||||
|
||||
@section tee
|
||||
|
||||
Writes the output to multiple protocols. The individual outputs are separated
|
||||
by |
|
||||
|
||||
@example
|
||||
tee:file://path/to/local/this.avi|file://path/to/local/that.avi
|
||||
@end example
|
||||
|
||||
@section tcp
|
||||
|
||||
Transmission Control Protocol.
|
||||
@@ -1336,14 +1266,6 @@ Set the UDP maximum socket buffer size in bytes. This is used to set either
|
||||
the receive or send buffer size, depending on what the socket is used for.
|
||||
Default is 64KB. See also @var{fifo_size}.
|
||||
|
||||
@item bitrate=@var{bitrate}
|
||||
If set to nonzero, the output will have the specified constant bitrate if the
|
||||
input has enough packets to sustain it.
|
||||
|
||||
@item burst_bits=@var{bits}
|
||||
When using @var{bitrate} this specifies the maximum number of bits in
|
||||
packet bursts.
|
||||
|
||||
@item localport=@var{port}
|
||||
Override the local UDP port to bind with.
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ select the native SW Resampler; filter options precision and cheby are not
|
||||
applicable in this case.
|
||||
@item soxr
|
||||
select the SoX Resampler (where available); compensation, and filter options
|
||||
filter_size, phase_shift, exact_rational, filter_type & kaiser_beta, are not
|
||||
applicable in this case.
|
||||
filter_size, phase_shift, filter_type & kaiser_beta, are not applicable in this
|
||||
case.
|
||||
@end table
|
||||
|
||||
@item filter_size
|
||||
@@ -132,13 +132,7 @@ For swr only, set resampling phase shift, default value is 10, and must be in
|
||||
the interval [0,30].
|
||||
|
||||
@item linear_interp
|
||||
Use linear interpolation when enabled (the default). Disable it if you want
|
||||
to preserve speed instead of quality when exact_rational fails.
|
||||
|
||||
@item exact_rational
|
||||
For swr only, when enabled, try to use exact phase_count based on input and
|
||||
output sample rate. However, if it is larger than @code{1 << phase_shift},
|
||||
the phase_count will be @code{1 << phase_shift} as fallback. Default is enabled.
|
||||
Use linear interpolation if set to 1, default value is 0.
|
||||
|
||||
@item cutoff
|
||||
Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float
|
||||
|
||||
@@ -13,8 +13,7 @@ FFmpeg tools. For programmatic use, they can be set explicitly in the
|
||||
@anchor{sws_flags}
|
||||
@item sws_flags
|
||||
Set the scaler flags. This is also used to set the scaling
|
||||
algorithm. Only a single algorithm should be selected. Default
|
||||
value is @samp{bicubic}.
|
||||
algorithm. Only a single algorithm should be selected.
|
||||
|
||||
It accepts the following values:
|
||||
@table @samp
|
||||
|
||||
@@ -527,7 +527,7 @@ Wavelet Transform:
|
||||
==================
|
||||
|
||||
Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integer
|
||||
transform and an integer approximation of the symmetric biorthogonal 9/7
|
||||
transform and a integer approximation of the symmetric biorthogonal 9/7
|
||||
daubechies wavelet.
|
||||
|
||||
2D IDWT (inverse discrete wavelet transform)
|
||||
|
||||
@@ -10,12 +10,12 @@ Current (simplified) Architecture:
|
||||
/ \
|
||||
special converter [Input to YUV converter]
|
||||
| |
|
||||
| (8-bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:0:0 )
|
||||
| (8bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:0:0 )
|
||||
| |
|
||||
| v
|
||||
| Horizontal scaler
|
||||
| |
|
||||
| (15-bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:1:1 / 4:0:0 )
|
||||
| (15bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:1:1 / 4:0:0 )
|
||||
| |
|
||||
| v
|
||||
| Vertical scaler and output converter
|
||||
|
||||
@@ -22,7 +22,7 @@ EOT
|
||||
my $TEMPLATE_HEADER2 = $ENV{"FFMPEG_HEADER2"} || <<EOT;
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div style="width: 95%; margin: auto">
|
||||
EOT
|
||||
|
||||
my $TEMPLATE_FOOTER = $ENV{"FFMPEG_FOOTER"} || <<EOT;
|
||||
|
||||
@@ -174,7 +174,7 @@ EOT
|
||||
<link rel="stylesheet" type="text/css" href="style.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div style="width: 95%; margin: auto">
|
||||
<h1>
|
||||
EOT
|
||||
|
||||
|
||||
@@ -719,24 +719,19 @@ the name of a standard channel layout (e.g. @samp{mono},
|
||||
the name of a single channel (e.g. @samp{FL}, @samp{FR}, @samp{FC}, @samp{LFE}, etc.)
|
||||
|
||||
@item
|
||||
a number of channels, in decimal, followed by 'c', yielding the default channel
|
||||
layout for that number of channels (see the function
|
||||
@code{av_get_default_channel_layout}). Note that not all channel counts have a
|
||||
default layout.
|
||||
|
||||
@item
|
||||
a number of channels, in decimal, followed by 'C', yielding an unknown channel
|
||||
layout with the specified number of channels. Note that not all channel layout
|
||||
specification strings support unknown channel layouts.
|
||||
a number of channels, in decimal, optionally followed by 'c', yielding
|
||||
the default channel layout for that number of channels (see the
|
||||
function @code{av_get_default_channel_layout})
|
||||
|
||||
@item
|
||||
a channel layout mask, in hexadecimal starting with "0x" (see the
|
||||
@code{AV_CH_*} macros in @file{libavutil/channel_layout.h}.
|
||||
@end itemize
|
||||
|
||||
Before libavutil version 53 the trailing character "c" to specify a number of
|
||||
channels was optional, but now it is required, while a channel layout mask can
|
||||
also be specified as a decimal number (if and only if not followed by "c" or "C").
|
||||
Starting from libavutil version 53 the trailing character "c" to
|
||||
specify a number of channels will be required, while a channel layout
|
||||
mask could also be specified as a decimal number (if and only if not
|
||||
followed by "c").
|
||||
|
||||
See also the function @code{av_get_channel_layout} defined in
|
||||
@file{libavutil/channel_layout.h}.
|
||||
@@ -776,9 +771,6 @@ Compute arcsine of @var{x}.
|
||||
@item atan(x)
|
||||
Compute arctangent of @var{x}.
|
||||
|
||||
@item atan2(x, y)
|
||||
Compute principal value of the arc tangent of @var{y}/@var{x}.
|
||||
|
||||
@item between(x, min, max)
|
||||
Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or
|
||||
equal to @var{max}, 0 otherwise.
|
||||
|
||||
107
ffmpeg.h
107
ffmpeg.h
@@ -65,8 +65,6 @@ enum HWAccelID {
|
||||
HWACCEL_VDA,
|
||||
HWACCEL_VIDEOTOOLBOX,
|
||||
HWACCEL_QSV,
|
||||
HWACCEL_VAAPI,
|
||||
HWACCEL_CUVID,
|
||||
};
|
||||
|
||||
typedef struct HWAccel {
|
||||
@@ -128,8 +126,6 @@ typedef struct OptionsContext {
|
||||
int nb_hwaccels;
|
||||
SpecifierOpt *hwaccel_devices;
|
||||
int nb_hwaccel_devices;
|
||||
SpecifierOpt *hwaccel_output_formats;
|
||||
int nb_hwaccel_output_formats;
|
||||
SpecifierOpt *autorotate;
|
||||
int nb_autorotate;
|
||||
|
||||
@@ -212,8 +208,6 @@ typedef struct OptionsContext {
|
||||
int nb_pass;
|
||||
SpecifierOpt *passlogfiles;
|
||||
int nb_passlogfiles;
|
||||
SpecifierOpt *max_muxing_queue_size;
|
||||
int nb_max_muxing_queue_size;
|
||||
SpecifierOpt *guess_layout_max;
|
||||
int nb_guess_layout_max;
|
||||
SpecifierOpt *apad;
|
||||
@@ -224,8 +218,6 @@ typedef struct OptionsContext {
|
||||
int nb_disposition;
|
||||
SpecifierOpt *program;
|
||||
int nb_program;
|
||||
SpecifierOpt *time_bases;
|
||||
int nb_time_bases;
|
||||
} OptionsContext;
|
||||
|
||||
typedef struct InputFilter {
|
||||
@@ -233,23 +225,6 @@ typedef struct InputFilter {
|
||||
struct InputStream *ist;
|
||||
struct FilterGraph *graph;
|
||||
uint8_t *name;
|
||||
enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video
|
||||
|
||||
AVFifoBuffer *frame_queue;
|
||||
|
||||
// parameters configured for this input
|
||||
int format;
|
||||
|
||||
int width, height;
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
int sample_rate;
|
||||
int channels;
|
||||
uint64_t channel_layout;
|
||||
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
int eof;
|
||||
} InputFilter;
|
||||
|
||||
typedef struct OutputFilter {
|
||||
@@ -261,18 +236,6 @@ typedef struct OutputFilter {
|
||||
/* temporary storage until stream maps are processed */
|
||||
AVFilterInOut *out_tmp;
|
||||
enum AVMediaType type;
|
||||
|
||||
/* desired output stream properties */
|
||||
int width, height;
|
||||
AVRational frame_rate;
|
||||
int format;
|
||||
int sample_rate;
|
||||
uint64_t channel_layout;
|
||||
|
||||
// those are only set if no format is specified and the encoder gives us multiple options
|
||||
int *formats;
|
||||
uint64_t *channel_layouts;
|
||||
int *sample_rates;
|
||||
} OutputFilter;
|
||||
|
||||
typedef struct FilterGraph {
|
||||
@@ -316,21 +279,25 @@ typedef struct InputStream {
|
||||
|
||||
int64_t min_pts; /* pts with the smallest value in a current stream */
|
||||
int64_t max_pts; /* pts with the higher value in a current stream */
|
||||
|
||||
// when forcing constant input framerate through -r,
|
||||
// this contains the pts that will be given to the next decoded frame
|
||||
int64_t cfr_next_pts;
|
||||
|
||||
int64_t nb_samples; /* number of samples in the last decoded audio frame before looping */
|
||||
|
||||
double ts_scale;
|
||||
int saw_first_ts;
|
||||
int showed_multi_packet_warning;
|
||||
AVDictionary *decoder_opts;
|
||||
AVRational framerate; /* framerate forced with -r */
|
||||
int top_field_first;
|
||||
int guess_layout_max;
|
||||
|
||||
int autorotate;
|
||||
int resample_height;
|
||||
int resample_width;
|
||||
int resample_pix_fmt;
|
||||
|
||||
int resample_sample_fmt;
|
||||
int resample_sample_rate;
|
||||
int resample_channels;
|
||||
uint64_t resample_channel_layout;
|
||||
|
||||
int fix_sub_duration;
|
||||
struct { /* previous decoded subtitle and related variables */
|
||||
@@ -342,7 +309,6 @@ typedef struct InputStream {
|
||||
struct sub2video {
|
||||
int64_t last_pts;
|
||||
int64_t end_pts;
|
||||
AVFifoBuffer *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFrame *frame;
|
||||
int w, h;
|
||||
} sub2video;
|
||||
@@ -359,7 +325,6 @@ typedef struct InputStream {
|
||||
/* hwaccel options */
|
||||
enum HWAccelID hwaccel_id;
|
||||
char *hwaccel_device;
|
||||
enum AVPixelFormat hwaccel_output_format;
|
||||
|
||||
/* hwaccel context */
|
||||
enum HWAccelID active_hwaccel_id;
|
||||
@@ -369,7 +334,6 @@ typedef struct InputStream {
|
||||
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
|
||||
enum AVPixelFormat hwaccel_pix_fmt;
|
||||
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
/* stats */
|
||||
// combined size of all the packets read
|
||||
@@ -379,11 +343,6 @@ typedef struct InputStream {
|
||||
// number of frames/samples retrieved from the decoder
|
||||
uint64_t frames_decoded;
|
||||
uint64_t samples_decoded;
|
||||
|
||||
int64_t *dts_buffer;
|
||||
int nb_dts_buffer;
|
||||
|
||||
int got_output;
|
||||
} InputStream;
|
||||
|
||||
typedef struct InputFile {
|
||||
@@ -451,15 +410,8 @@ typedef struct OutputStream {
|
||||
int64_t first_pts;
|
||||
/* dts of the last packet sent to the muxer */
|
||||
int64_t last_mux_dts;
|
||||
// the timebase of the packets sent to the muxer
|
||||
AVRational mux_timebase;
|
||||
|
||||
int nb_bitstream_filters;
|
||||
uint8_t *bsf_extradata_updated;
|
||||
AVBSFContext **bsf_ctx;
|
||||
|
||||
AVBitStreamFilterContext *bitstream_filters;
|
||||
AVCodecContext *enc_ctx;
|
||||
AVCodecParameters *ref_par; /* associated input codec parameters with encoders options applied */
|
||||
AVCodec *enc;
|
||||
int64_t max_frames;
|
||||
AVFrame *filtered_frame;
|
||||
@@ -475,7 +427,6 @@ typedef struct OutputStream {
|
||||
int force_fps;
|
||||
int top_field_first;
|
||||
int rotate_overridden;
|
||||
double rotate_override_value;
|
||||
|
||||
AVRational frame_aspect_ratio;
|
||||
|
||||
@@ -507,14 +458,6 @@ typedef struct OutputStream {
|
||||
OSTFinished finished; /* no more packets should be written for this stream */
|
||||
int unavailable; /* true if the steram is unavailable (possibly temporarily) */
|
||||
int stream_copy;
|
||||
|
||||
// init_output_stream() has been called for this stream
|
||||
// The encoder and the bitstream filters have been initialized and the stream
|
||||
// parameters are set in the AVStream.
|
||||
int initialized;
|
||||
|
||||
int inputs_done;
|
||||
|
||||
const char *attachment_filename;
|
||||
int copy_initial_nonkeyframes;
|
||||
int copy_prior_start;
|
||||
@@ -523,7 +466,6 @@ typedef struct OutputStream {
|
||||
int keep_pix_fmt;
|
||||
|
||||
AVCodecParserContext *parser;
|
||||
AVCodecContext *parser_avctx;
|
||||
|
||||
/* stats */
|
||||
// combined size of all the packets written
|
||||
@@ -537,11 +479,6 @@ typedef struct OutputStream {
|
||||
/* packet quality factor */
|
||||
int quality;
|
||||
|
||||
int max_muxing_queue_size;
|
||||
|
||||
/* the packets are buffered here until the muxer is ready to be initialized */
|
||||
AVFifoBuffer *muxing_queue;
|
||||
|
||||
/* packet picture type */
|
||||
int pict_type;
|
||||
|
||||
@@ -558,8 +495,6 @@ typedef struct OutputFile {
|
||||
uint64_t limit_filesize; /* filesize limit expressed in bytes */
|
||||
|
||||
int shortest;
|
||||
|
||||
int header_written;
|
||||
} OutputFile;
|
||||
|
||||
extern InputStream **input_streams;
|
||||
@@ -603,21 +538,13 @@ extern int stdin_interaction;
|
||||
extern int frame_bits_per_raw_sample;
|
||||
extern AVIOContext *progress_avio;
|
||||
extern float max_error_rate;
|
||||
extern int vdpau_api_ver;
|
||||
extern char *videotoolbox_pixfmt;
|
||||
|
||||
extern int filter_nbthreads;
|
||||
extern int filter_complex_nbthreads;
|
||||
extern int vstats_version;
|
||||
|
||||
extern const AVIOInterruptCB int_cb;
|
||||
|
||||
extern const OptionDef options[];
|
||||
extern const HWAccel hwaccels[];
|
||||
extern int hwaccel_lax_profile_check;
|
||||
extern AVBufferRef *hw_device_ctx;
|
||||
#if CONFIG_QSV
|
||||
extern char *qsv_device;
|
||||
#endif
|
||||
|
||||
|
||||
void term_init(void);
|
||||
@@ -638,16 +565,10 @@ void choose_sample_fmt(AVStream *st, AVCodec *codec);
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg);
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
|
||||
void check_filter_outputs(void);
|
||||
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
|
||||
int filtergraph_is_simple(FilterGraph *fg);
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
|
||||
FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost);
|
||||
int init_complex_filtergraph(FilterGraph *fg);
|
||||
|
||||
void sub2video_update(InputStream *ist, AVSubtitle *sub);
|
||||
|
||||
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame);
|
||||
|
||||
int ffmpeg_parse_options(int argc, char **argv);
|
||||
|
||||
int vdpau_init(AVCodecContext *s);
|
||||
@@ -655,8 +576,6 @@ int dxva2_init(AVCodecContext *s);
|
||||
int vda_init(AVCodecContext *s);
|
||||
int videotoolbox_init(AVCodecContext *s);
|
||||
int qsv_init(AVCodecContext *s);
|
||||
int vaapi_decode_init(AVCodecContext *avctx);
|
||||
int vaapi_device_init(const char *device);
|
||||
int cuvid_init(AVCodecContext *s);
|
||||
int qsv_transcode_init(OutputStream *ost);
|
||||
|
||||
#endif /* FFMPEG_H */
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
|
||||
#include "ffmpeg.h"
|
||||
|
||||
static void cuvid_uninit(AVCodecContext *avctx)
|
||||
{
|
||||
InputStream *ist = avctx->opaque;
|
||||
av_buffer_unref(&ist->hw_frames_ctx);
|
||||
}
|
||||
|
||||
int cuvid_init(AVCodecContext *avctx)
|
||||
{
|
||||
InputStream *ist = avctx->opaque;
|
||||
AVHWFramesContext *frames_ctx;
|
||||
int ret;
|
||||
|
||||
av_log(avctx, AV_LOG_VERBOSE, "Initializing cuvid hwaccel\n");
|
||||
|
||||
if (!hw_device_ctx) {
|
||||
ret = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_CUDA,
|
||||
ist->hwaccel_device, NULL, 0);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error creating a CUDA device\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
av_buffer_unref(&ist->hw_frames_ctx);
|
||||
ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx);
|
||||
if (!ist->hw_frames_ctx) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error creating a CUDA frames context\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data;
|
||||
|
||||
frames_ctx->format = AV_PIX_FMT_CUDA;
|
||||
frames_ctx->sw_format = avctx->sw_pix_fmt;
|
||||
frames_ctx->width = avctx->width;
|
||||
frames_ctx->height = avctx->height;
|
||||
|
||||
av_log(avctx, AV_LOG_DEBUG, "Initializing CUDA frames context: sw_format = %s, width = %d, height = %d\n",
|
||||
av_get_pix_fmt_name(frames_ctx->sw_format), frames_ctx->width, frames_ctx->height);
|
||||
|
||||
ret = av_hwframe_ctx_init(ist->hw_frames_ctx);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error initializing a CUDA frame pool\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ist->hwaccel_uninit = cuvid_uninit;
|
||||
|
||||
return 0;
|
||||
}
|
||||
340
ffmpeg_dxva2.c
340
ffmpeg_dxva2.c
@@ -40,9 +40,6 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/hwcontext_dxva2.h"
|
||||
|
||||
/* define all the GUIDs used directly here,
|
||||
to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and different MSVC version */
|
||||
#include <initguid.h>
|
||||
@@ -56,11 +53,13 @@ DEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68, 0x4951,0x4C54,0x88,0xFE,0xAB,0
|
||||
DEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
|
||||
DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
|
||||
DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0);
|
||||
DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13);
|
||||
DEFINE_GUID(DXVA2_ModeVP9_VLD_Profile0, 0x463707f8, 0xa1d0,0x4585,0x87,0x6d,0x83,0xaa,0x6d,0x60,0xb8,0x9e);
|
||||
DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
|
||||
DEFINE_GUID(GUID_NULL, 0x00000000, 0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
|
||||
|
||||
typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT);
|
||||
typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **);
|
||||
|
||||
typedef struct dxva2_mode {
|
||||
const GUID *guid;
|
||||
enum AVCodecID codec;
|
||||
@@ -85,7 +84,6 @@ static const dxva2_mode dxva2_modes[] = {
|
||||
|
||||
/* HEVC/H.265 */
|
||||
{ &DXVA2_ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC },
|
||||
{ &DXVA2_ModeHEVC_VLD_Main10,AV_CODEC_ID_HEVC },
|
||||
|
||||
/* VP8/9 */
|
||||
{ &DXVA2_ModeVP9_VLD_Profile0, AV_CODEC_ID_VP9 },
|
||||
@@ -93,19 +91,63 @@ static const dxva2_mode dxva2_modes[] = {
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
typedef struct surface_info {
|
||||
int used;
|
||||
uint64_t age;
|
||||
} surface_info;
|
||||
|
||||
typedef struct DXVA2Context {
|
||||
HMODULE d3dlib;
|
||||
HMODULE dxva2lib;
|
||||
|
||||
HANDLE deviceHandle;
|
||||
|
||||
IDirect3D9 *d3d9;
|
||||
IDirect3DDevice9 *d3d9device;
|
||||
IDirect3DDeviceManager9 *d3d9devmgr;
|
||||
IDirectXVideoDecoderService *decoder_service;
|
||||
IDirectXVideoDecoder *decoder;
|
||||
|
||||
GUID decoder_guid;
|
||||
DXVA2_ConfigPictureDecode decoder_config;
|
||||
IDirectXVideoDecoderService *decoder_service;
|
||||
|
||||
LPDIRECT3DSURFACE9 *surfaces;
|
||||
surface_info *surface_infos;
|
||||
uint32_t num_surfaces;
|
||||
uint64_t surface_age;
|
||||
|
||||
AVFrame *tmp_frame;
|
||||
|
||||
AVBufferRef *hw_device_ctx;
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
} DXVA2Context;
|
||||
|
||||
typedef struct DXVA2SurfaceWrapper {
|
||||
DXVA2Context *ctx;
|
||||
LPDIRECT3DSURFACE9 surface;
|
||||
IDirectXVideoDecoder *decoder;
|
||||
} DXVA2SurfaceWrapper;
|
||||
|
||||
static void dxva2_destroy_decoder(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
DXVA2Context *ctx = ist->hwaccel_ctx;
|
||||
int i;
|
||||
|
||||
if (ctx->surfaces) {
|
||||
for (i = 0; i < ctx->num_surfaces; i++) {
|
||||
if (ctx->surfaces[i])
|
||||
IDirect3DSurface9_Release(ctx->surfaces[i]);
|
||||
}
|
||||
}
|
||||
av_freep(&ctx->surfaces);
|
||||
av_freep(&ctx->surface_infos);
|
||||
ctx->num_surfaces = 0;
|
||||
ctx->surface_age = 0;
|
||||
|
||||
if (ctx->decoder) {
|
||||
IDirectXVideoDecoder_Release(ctx->decoder);
|
||||
ctx->decoder = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void dxva2_uninit(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
@@ -115,11 +157,29 @@ static void dxva2_uninit(AVCodecContext *s)
|
||||
ist->hwaccel_get_buffer = NULL;
|
||||
ist->hwaccel_retrieve_data = NULL;
|
||||
|
||||
if (ctx->decoder)
|
||||
dxva2_destroy_decoder(s);
|
||||
|
||||
if (ctx->decoder_service)
|
||||
IDirectXVideoDecoderService_Release(ctx->decoder_service);
|
||||
|
||||
av_buffer_unref(&ctx->hw_frames_ctx);
|
||||
av_buffer_unref(&ctx->hw_device_ctx);
|
||||
if (ctx->d3d9devmgr && ctx->deviceHandle != INVALID_HANDLE_VALUE)
|
||||
IDirect3DDeviceManager9_CloseDeviceHandle(ctx->d3d9devmgr, ctx->deviceHandle);
|
||||
|
||||
if (ctx->d3d9devmgr)
|
||||
IDirect3DDeviceManager9_Release(ctx->d3d9devmgr);
|
||||
|
||||
if (ctx->d3d9device)
|
||||
IDirect3DDevice9_Release(ctx->d3d9device);
|
||||
|
||||
if (ctx->d3d9)
|
||||
IDirect3D9_Release(ctx->d3d9);
|
||||
|
||||
if (ctx->d3dlib)
|
||||
FreeLibrary(ctx->d3dlib);
|
||||
|
||||
if (ctx->dxva2lib)
|
||||
FreeLibrary(ctx->dxva2lib);
|
||||
|
||||
av_frame_free(&ctx->tmp_frame);
|
||||
|
||||
@@ -127,34 +187,119 @@ static void dxva2_uninit(AVCodecContext *s)
|
||||
av_freep(&s->hwaccel_context);
|
||||
}
|
||||
|
||||
static void dxva2_release_buffer(void *opaque, uint8_t *data)
|
||||
{
|
||||
DXVA2SurfaceWrapper *w = opaque;
|
||||
DXVA2Context *ctx = w->ctx;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ctx->num_surfaces; i++) {
|
||||
if (ctx->surfaces[i] == w->surface) {
|
||||
ctx->surface_infos[i].used = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
IDirect3DSurface9_Release(w->surface);
|
||||
IDirectXVideoDecoder_Release(w->decoder);
|
||||
av_free(w);
|
||||
}
|
||||
|
||||
static int dxva2_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
DXVA2Context *ctx = ist->hwaccel_ctx;
|
||||
int i, old_unused = -1;
|
||||
LPDIRECT3DSURFACE9 surface;
|
||||
DXVA2SurfaceWrapper *w = NULL;
|
||||
|
||||
return av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0);
|
||||
av_assert0(frame->format == AV_PIX_FMT_DXVA2_VLD);
|
||||
|
||||
for (i = 0; i < ctx->num_surfaces; i++) {
|
||||
surface_info *info = &ctx->surface_infos[i];
|
||||
if (!info->used && (old_unused == -1 || info->age < ctx->surface_infos[old_unused].age))
|
||||
old_unused = i;
|
||||
}
|
||||
if (old_unused == -1) {
|
||||
av_log(NULL, AV_LOG_ERROR, "No free DXVA2 surface!\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
i = old_unused;
|
||||
|
||||
surface = ctx->surfaces[i];
|
||||
|
||||
w = av_mallocz(sizeof(*w));
|
||||
if (!w)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
frame->buf[0] = av_buffer_create((uint8_t*)surface, 0,
|
||||
dxva2_release_buffer, w,
|
||||
AV_BUFFER_FLAG_READONLY);
|
||||
if (!frame->buf[0]) {
|
||||
av_free(w);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
w->ctx = ctx;
|
||||
w->surface = surface;
|
||||
IDirect3DSurface9_AddRef(w->surface);
|
||||
w->decoder = ctx->decoder;
|
||||
IDirectXVideoDecoder_AddRef(w->decoder);
|
||||
|
||||
ctx->surface_infos[i].used = 1;
|
||||
ctx->surface_infos[i].age = ctx->surface_age++;
|
||||
|
||||
frame->data[3] = (uint8_t *)surface;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dxva2_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
{
|
||||
LPDIRECT3DSURFACE9 surface = (LPDIRECT3DSURFACE9)frame->data[3];
|
||||
InputStream *ist = s->opaque;
|
||||
DXVA2Context *ctx = ist->hwaccel_ctx;
|
||||
D3DSURFACE_DESC surfaceDesc;
|
||||
D3DLOCKED_RECT LockedRect;
|
||||
HRESULT hr;
|
||||
int ret;
|
||||
|
||||
ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0);
|
||||
IDirect3DSurface9_GetDesc(surface, &surfaceDesc);
|
||||
|
||||
ctx->tmp_frame->width = frame->width;
|
||||
ctx->tmp_frame->height = frame->height;
|
||||
ctx->tmp_frame->format = AV_PIX_FMT_NV12;
|
||||
|
||||
ret = av_frame_get_buffer(ctx->tmp_frame, 32);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = av_frame_copy_props(ctx->tmp_frame, frame);
|
||||
if (ret < 0) {
|
||||
av_frame_unref(ctx->tmp_frame);
|
||||
return ret;
|
||||
hr = IDirect3DSurface9_LockRect(surface, &LockedRect, NULL, D3DLOCK_READONLY);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Unable to lock DXVA2 surface\n");
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
av_image_copy_plane(ctx->tmp_frame->data[0], ctx->tmp_frame->linesize[0],
|
||||
(uint8_t*)LockedRect.pBits,
|
||||
LockedRect.Pitch, frame->width, frame->height);
|
||||
|
||||
av_image_copy_plane(ctx->tmp_frame->data[1], ctx->tmp_frame->linesize[1],
|
||||
(uint8_t*)LockedRect.pBits + LockedRect.Pitch * surfaceDesc.Height,
|
||||
LockedRect.Pitch, frame->width, frame->height / 2);
|
||||
|
||||
IDirect3DSurface9_UnlockRect(surface);
|
||||
|
||||
ret = av_frame_copy_props(ctx->tmp_frame, frame);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
av_frame_unref(frame);
|
||||
av_frame_move_ref(frame, ctx->tmp_frame);
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
av_frame_unref(ctx->tmp_frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dxva2_alloc(AVCodecContext *s)
|
||||
@@ -162,40 +307,94 @@ static int dxva2_alloc(AVCodecContext *s)
|
||||
InputStream *ist = s->opaque;
|
||||
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
|
||||
DXVA2Context *ctx;
|
||||
HANDLE device_handle;
|
||||
pDirect3DCreate9 *createD3D = NULL;
|
||||
pCreateDeviceManager9 *createDeviceManager = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
AVHWDeviceContext *device_ctx;
|
||||
AVDXVA2DeviceContext *device_hwctx;
|
||||
int ret;
|
||||
D3DPRESENT_PARAMETERS d3dpp = {0};
|
||||
D3DDISPLAYMODE d3ddm;
|
||||
unsigned resetToken = 0;
|
||||
UINT adapter = D3DADAPTER_DEFAULT;
|
||||
|
||||
ctx = av_mallocz(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ctx->deviceHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
ist->hwaccel_ctx = ctx;
|
||||
ist->hwaccel_uninit = dxva2_uninit;
|
||||
ist->hwaccel_get_buffer = dxva2_get_buffer;
|
||||
ist->hwaccel_retrieve_data = dxva2_retrieve_data;
|
||||
|
||||
ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,
|
||||
ist->hwaccel_device, NULL, 0);
|
||||
if (ret < 0)
|
||||
ctx->d3dlib = LoadLibrary("d3d9.dll");
|
||||
if (!ctx->d3dlib) {
|
||||
av_log(NULL, loglevel, "Failed to load D3D9 library\n");
|
||||
goto fail;
|
||||
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
|
||||
device_hwctx = device_ctx->hwctx;
|
||||
|
||||
hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
|
||||
&device_handle);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to open a device handle\n");
|
||||
}
|
||||
ctx->dxva2lib = LoadLibrary("dxva2.dll");
|
||||
if (!ctx->dxva2lib) {
|
||||
av_log(NULL, loglevel, "Failed to load DXVA2 library\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,
|
||||
&IID_IDirectXVideoDecoderService,
|
||||
(void **)&ctx->decoder_service);
|
||||
IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);
|
||||
createD3D = (pDirect3DCreate9 *)GetProcAddress(ctx->d3dlib, "Direct3DCreate9");
|
||||
if (!createD3D) {
|
||||
av_log(NULL, loglevel, "Failed to locate Direct3DCreate9\n");
|
||||
goto fail;
|
||||
}
|
||||
createDeviceManager = (pCreateDeviceManager9 *)GetProcAddress(ctx->dxva2lib, "DXVA2CreateDirect3DDeviceManager9");
|
||||
if (!createDeviceManager) {
|
||||
av_log(NULL, loglevel, "Failed to locate DXVA2CreateDirect3DDeviceManager9\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx->d3d9 = createD3D(D3D_SDK_VERSION);
|
||||
if (!ctx->d3d9) {
|
||||
av_log(NULL, loglevel, "Failed to create IDirect3D object\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ist->hwaccel_device) {
|
||||
adapter = atoi(ist->hwaccel_device);
|
||||
av_log(NULL, AV_LOG_INFO, "Using HWAccel device %d\n", adapter);
|
||||
}
|
||||
|
||||
IDirect3D9_GetAdapterDisplayMode(ctx->d3d9, adapter, &d3ddm);
|
||||
d3dpp.Windowed = TRUE;
|
||||
d3dpp.BackBufferWidth = 640;
|
||||
d3dpp.BackBufferHeight = 480;
|
||||
d3dpp.BackBufferCount = 0;
|
||||
d3dpp.BackBufferFormat = d3ddm.Format;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
|
||||
|
||||
hr = IDirect3D9_CreateDevice(ctx->d3d9, adapter, D3DDEVTYPE_HAL, GetDesktopWindow(),
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
|
||||
&d3dpp, &ctx->d3d9device);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to create Direct3D device\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = createDeviceManager(&resetToken, &ctx->d3d9devmgr);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to create Direct3D device manager\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = IDirect3DDeviceManager9_ResetDevice(ctx->d3d9devmgr, ctx->d3d9device, resetToken);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to bind Direct3D device to device manager\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = IDirect3DDeviceManager9_OpenDeviceHandle(ctx->d3d9devmgr, &ctx->deviceHandle);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to open device handle\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = IDirect3DDeviceManager9_GetVideoService(ctx->d3d9devmgr, ctx->deviceHandle, &IID_IDirectXVideoDecoderService, (void **)&ctx->decoder_service);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to create IDirectXVideoDecoderService\n");
|
||||
goto fail;
|
||||
@@ -271,17 +470,13 @@ static int dxva2_create_decoder(AVCodecContext *s)
|
||||
GUID *guid_list = NULL;
|
||||
unsigned guid_count = 0, i, j;
|
||||
GUID device_guid = GUID_NULL;
|
||||
const D3DFORMAT surface_format = (s->sw_pix_fmt == AV_PIX_FMT_YUV420P10) ? MKTAG('P','0','1','0') : MKTAG('N','V','1','2');
|
||||
D3DFORMAT target_format = 0;
|
||||
DXVA2_VideoDesc desc = { 0 };
|
||||
DXVA2_ConfigPictureDecode config;
|
||||
HRESULT hr;
|
||||
int surface_alignment, num_surfaces;
|
||||
int surface_alignment;
|
||||
int ret;
|
||||
|
||||
AVDXVA2FramesContext *frames_hwctx;
|
||||
AVHWFramesContext *frames_ctx;
|
||||
|
||||
hr = IDirectXVideoDecoderService_GetDecoderDeviceGuids(ctx->decoder_service, &guid_count, &guid_list);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to retrieve decoder device GUIDs\n");
|
||||
@@ -308,7 +503,7 @@ static int dxva2_create_decoder(AVCodecContext *s)
|
||||
}
|
||||
for (j = 0; j < target_count; j++) {
|
||||
const D3DFORMAT format = target_list[j];
|
||||
if (format == surface_format) {
|
||||
if (format == MKTAG('N','V','1','2')) {
|
||||
target_format = format;
|
||||
break;
|
||||
}
|
||||
@@ -347,43 +542,43 @@ static int dxva2_create_decoder(AVCodecContext *s)
|
||||
surface_alignment = 16;
|
||||
|
||||
/* 4 base work surfaces */
|
||||
num_surfaces = 4;
|
||||
ctx->num_surfaces = 4;
|
||||
|
||||
/* add surfaces based on number of possible refs */
|
||||
if (s->codec_id == AV_CODEC_ID_H264 || s->codec_id == AV_CODEC_ID_HEVC)
|
||||
num_surfaces += 16;
|
||||
ctx->num_surfaces += 16;
|
||||
else if (s->codec_id == AV_CODEC_ID_VP9)
|
||||
num_surfaces += 8;
|
||||
ctx->num_surfaces += 8;
|
||||
else
|
||||
num_surfaces += 2;
|
||||
ctx->num_surfaces += 2;
|
||||
|
||||
/* add extra surfaces for frame threading */
|
||||
if (s->active_thread_type & FF_THREAD_FRAME)
|
||||
num_surfaces += s->thread_count;
|
||||
ctx->num_surfaces += s->thread_count;
|
||||
|
||||
ctx->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->hw_device_ctx);
|
||||
if (!ctx->hw_frames_ctx)
|
||||
ctx->surfaces = av_mallocz(ctx->num_surfaces * sizeof(*ctx->surfaces));
|
||||
ctx->surface_infos = av_mallocz(ctx->num_surfaces * sizeof(*ctx->surface_infos));
|
||||
|
||||
if (!ctx->surfaces || !ctx->surface_infos) {
|
||||
av_log(NULL, loglevel, "Unable to allocate surface arrays\n");
|
||||
goto fail;
|
||||
frames_ctx = (AVHWFramesContext*)ctx->hw_frames_ctx->data;
|
||||
frames_hwctx = frames_ctx->hwctx;
|
||||
}
|
||||
|
||||
frames_ctx->format = AV_PIX_FMT_DXVA2_VLD;
|
||||
frames_ctx->sw_format = (target_format == MKTAG('P','0','1','0') ? AV_PIX_FMT_P010 : AV_PIX_FMT_NV12);
|
||||
frames_ctx->width = FFALIGN(s->coded_width, surface_alignment);
|
||||
frames_ctx->height = FFALIGN(s->coded_height, surface_alignment);
|
||||
frames_ctx->initial_pool_size = num_surfaces;
|
||||
|
||||
frames_hwctx->surface_type = DXVA2_VideoDecoderRenderTarget;
|
||||
|
||||
ret = av_hwframe_ctx_init(ctx->hw_frames_ctx);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, loglevel, "Failed to initialize the HW frames context\n");
|
||||
hr = IDirectXVideoDecoderService_CreateSurface(ctx->decoder_service,
|
||||
FFALIGN(s->coded_width, surface_alignment),
|
||||
FFALIGN(s->coded_height, surface_alignment),
|
||||
ctx->num_surfaces - 1,
|
||||
target_format, D3DPOOL_DEFAULT, 0,
|
||||
DXVA2_VideoDecoderRenderTarget,
|
||||
ctx->surfaces, NULL);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to create %d video surfaces\n", ctx->num_surfaces);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = IDirectXVideoDecoderService_CreateVideoDecoder(ctx->decoder_service, &device_guid,
|
||||
&desc, &config, frames_hwctx->surfaces,
|
||||
frames_hwctx->nb_surfaces, &frames_hwctx->decoder_to_release);
|
||||
&desc, &config, ctx->surfaces,
|
||||
ctx->num_surfaces, &ctx->decoder);
|
||||
if (FAILED(hr)) {
|
||||
av_log(NULL, loglevel, "Failed to create DXVA2 video decoder\n");
|
||||
goto fail;
|
||||
@@ -393,16 +588,16 @@ static int dxva2_create_decoder(AVCodecContext *s)
|
||||
ctx->decoder_config = config;
|
||||
|
||||
dxva_ctx->cfg = &ctx->decoder_config;
|
||||
dxva_ctx->decoder = frames_hwctx->decoder_to_release;
|
||||
dxva_ctx->surface = frames_hwctx->surfaces;
|
||||
dxva_ctx->surface_count = frames_hwctx->nb_surfaces;
|
||||
dxva_ctx->decoder = ctx->decoder;
|
||||
dxva_ctx->surface = ctx->surfaces;
|
||||
dxva_ctx->surface_count = ctx->num_surfaces;
|
||||
|
||||
if (IsEqualGUID(&ctx->decoder_guid, &DXVADDI_Intel_ModeH264_E))
|
||||
dxva_ctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
av_buffer_unref(&ctx->hw_frames_ctx);
|
||||
dxva2_destroy_decoder(s);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@@ -426,13 +621,8 @@ int dxva2_init(AVCodecContext *s)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if (s->codec_id == AV_CODEC_ID_HEVC &&
|
||||
s->profile != FF_PROFILE_HEVC_MAIN && s->profile != FF_PROFILE_HEVC_MAIN_10) {
|
||||
av_log(NULL, loglevel, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", s->profile);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
av_buffer_unref(&ctx->hw_frames_ctx);
|
||||
if (ctx->decoder)
|
||||
dxva2_destroy_decoder(s);
|
||||
|
||||
ret = dxva2_create_decoder(s);
|
||||
if (ret < 0) {
|
||||
|
||||
361
ffmpeg_filter.c
361
ffmpeg_filter.c
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "libavfilter/avfilter.h"
|
||||
#include "libavfilter/buffersink.h"
|
||||
#include "libavfilter/buffersrc.h"
|
||||
|
||||
#include "libavresample/avresample.h"
|
||||
|
||||
@@ -39,6 +38,7 @@
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/samplefmt.h"
|
||||
|
||||
|
||||
static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum AVCodecID codec_id, const enum AVPixelFormat default_formats[])
|
||||
{
|
||||
static const enum AVPixelFormat mjpeg_formats[] =
|
||||
@@ -94,33 +94,33 @@ void choose_sample_fmt(AVStream *st, AVCodec *codec)
|
||||
if (codec && codec->sample_fmts) {
|
||||
const enum AVSampleFormat *p = codec->sample_fmts;
|
||||
for (; *p != -1; p++) {
|
||||
if (*p == st->codecpar->format)
|
||||
if (*p == st->codec->sample_fmt)
|
||||
break;
|
||||
}
|
||||
if (*p == -1) {
|
||||
if((codec->capabilities & AV_CODEC_CAP_LOSSLESS) && av_get_sample_fmt_name(st->codecpar->format) > av_get_sample_fmt_name(codec->sample_fmts[0]))
|
||||
if((codec->capabilities & AV_CODEC_CAP_LOSSLESS) && av_get_sample_fmt_name(st->codec->sample_fmt) > av_get_sample_fmt_name(codec->sample_fmts[0]))
|
||||
av_log(NULL, AV_LOG_ERROR, "Conversion will not be lossless.\n");
|
||||
if(av_get_sample_fmt_name(st->codecpar->format))
|
||||
if(av_get_sample_fmt_name(st->codec->sample_fmt))
|
||||
av_log(NULL, AV_LOG_WARNING,
|
||||
"Incompatible sample format '%s' for codec '%s', auto-selecting format '%s'\n",
|
||||
av_get_sample_fmt_name(st->codecpar->format),
|
||||
av_get_sample_fmt_name(st->codec->sample_fmt),
|
||||
codec->name,
|
||||
av_get_sample_fmt_name(codec->sample_fmts[0]));
|
||||
st->codecpar->format = codec->sample_fmts[0];
|
||||
st->codec->sample_fmt = codec->sample_fmts[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
static char *choose_pix_fmts(OutputStream *ost)
|
||||
{
|
||||
OutputStream *ost = ofilter->ost;
|
||||
AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
if (strict_dict)
|
||||
// used by choose_pixel_fmt() and below
|
||||
av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
|
||||
|
||||
if (ost->keep_pix_fmt) {
|
||||
avfilter_graph_set_auto_convert(ofilter->graph->graph,
|
||||
if (ost->filter)
|
||||
avfilter_graph_set_auto_convert(ost->filter->graph->graph,
|
||||
AVFILTER_AUTO_CONVERT_NONE);
|
||||
if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
|
||||
return NULL;
|
||||
@@ -155,13 +155,13 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
|
||||
/* Define a function for building a string containing a list of
|
||||
* allowed formats. */
|
||||
#define DEF_CHOOSE_FORMAT(suffix, type, var, supported_list, none, get_name) \
|
||||
static char *choose_ ## suffix (OutputFilter *ofilter) \
|
||||
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name) \
|
||||
static char *choose_ ## var ## s(OutputStream *ost) \
|
||||
{ \
|
||||
if (ofilter->var != none) { \
|
||||
get_name(ofilter->var); \
|
||||
if (ost->enc_ctx->var != none) { \
|
||||
get_name(ost->enc_ctx->var); \
|
||||
return av_strdup(name); \
|
||||
} else if (ofilter->supported_list) { \
|
||||
} else if (ost->enc && ost->enc->supported_list) { \
|
||||
const type *p; \
|
||||
AVIOContext *s = NULL; \
|
||||
uint8_t *ret; \
|
||||
@@ -170,7 +170,7 @@ static char *choose_ ## suffix (OutputFilter *ofilter) \
|
||||
if (avio_open_dyn_buf(&s) < 0) \
|
||||
exit_program(1); \
|
||||
\
|
||||
for (p = ofilter->supported_list; *p != none; p++) { \
|
||||
for (p = ost->enc->supported_list; *p != none; p++) { \
|
||||
get_name(*p); \
|
||||
avio_printf(s, "%s|", name); \
|
||||
} \
|
||||
@@ -181,19 +181,19 @@ static char *choose_ ## suffix (OutputFilter *ofilter) \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
//DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, AV_PIX_FMT_NONE,
|
||||
// GET_PIX_FMT_NAME)
|
||||
// DEF_CHOOSE_FORMAT(enum AVPixelFormat, pix_fmt, pix_fmts, AV_PIX_FMT_NONE,
|
||||
// GET_PIX_FMT_NAME)
|
||||
|
||||
DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
|
||||
DEF_CHOOSE_FORMAT(enum AVSampleFormat, sample_fmt, sample_fmts,
|
||||
AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME)
|
||||
|
||||
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
|
||||
DEF_CHOOSE_FORMAT(int, sample_rate, supported_samplerates, 0,
|
||||
GET_SAMPLE_RATE_NAME)
|
||||
|
||||
DEF_CHOOSE_FORMAT(channel_layouts, uint64_t, channel_layout, channel_layouts, 0,
|
||||
DEF_CHOOSE_FORMAT(uint64_t, channel_layout, channel_layouts, 0,
|
||||
GET_CH_LAYOUT_NAME)
|
||||
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
FilterGraph *fg = av_mallocz(sizeof(*fg));
|
||||
|
||||
@@ -206,7 +206,6 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
exit_program(1);
|
||||
fg->outputs[0]->ost = ost;
|
||||
fg->outputs[0]->graph = fg;
|
||||
fg->outputs[0]->format = -1;
|
||||
|
||||
ost->filter = fg->outputs[0];
|
||||
|
||||
@@ -215,11 +214,6 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
exit_program(1);
|
||||
fg->inputs[0]->ist = ist;
|
||||
fg->inputs[0]->graph = fg;
|
||||
fg->inputs[0]->format = -1;
|
||||
|
||||
fg->inputs[0]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[0]->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[0];
|
||||
@@ -227,26 +221,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1] = fg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
|
||||
{
|
||||
AVFilterContext *ctx = inout->filter_ctx;
|
||||
AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
|
||||
int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
|
||||
AVIOContext *pb;
|
||||
uint8_t *res = NULL;
|
||||
|
||||
if (avio_open_dyn_buf(&pb) < 0)
|
||||
exit_program(1);
|
||||
|
||||
avio_printf(pb, "%s", ctx->filter->name);
|
||||
if (nb_pads > 1)
|
||||
avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
avio_w8(pb, 0);
|
||||
avio_close_dyn_buf(pb, &res);
|
||||
return res;
|
||||
return fg;
|
||||
}
|
||||
|
||||
static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
@@ -276,7 +251,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
s = input_files[file_idx]->ctx;
|
||||
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
enum AVMediaType stream_type = s->streams[i]->codecpar->codec_type;
|
||||
enum AVMediaType stream_type = s->streams[i]->codec->codec_type;
|
||||
if (stream_type != type &&
|
||||
!(stream_type == AVMEDIA_TYPE_SUBTITLE &&
|
||||
type == AVMEDIA_TYPE_VIDEO /* sub2video hack */))
|
||||
@@ -317,13 +292,6 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
exit_program(1);
|
||||
fg->inputs[fg->nb_inputs - 1]->ist = ist;
|
||||
fg->inputs[fg->nb_inputs - 1]->graph = fg;
|
||||
fg->inputs[fg->nb_inputs - 1]->format = -1;
|
||||
fg->inputs[fg->nb_inputs - 1]->type = ist->st->codecpar->codec_type;
|
||||
fg->inputs[fg->nb_inputs - 1]->name = describe_filter_link(fg, in, 1);
|
||||
|
||||
fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[fg->nb_inputs - 1]->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
|
||||
@@ -358,7 +326,6 @@ int init_complex_filtergraph(FilterGraph *fg)
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
|
||||
fg->outputs[fg->nb_outputs - 1]->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
cur->pad_idx);
|
||||
fg->outputs[fg->nb_outputs - 1]->name = describe_filter_link(fg, cur, 0);
|
||||
cur = cur->next;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
|
||||
}
|
||||
@@ -447,12 +414,13 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
char *pix_fmts;
|
||||
OutputStream *ost = ofilter->ost;
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
AVCodecContext *codec = ost->enc_ctx;
|
||||
AVFilterContext *last_filter = out->filter_ctx;
|
||||
int pad_idx = out->pad_idx;
|
||||
int ret;
|
||||
char name[255];
|
||||
|
||||
snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
|
||||
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
|
||||
ret = avfilter_graph_create_filter(&ofilter->filter,
|
||||
avfilter_get_by_name("buffersink"),
|
||||
name, NULL, NULL, fg->graph);
|
||||
@@ -460,20 +428,21 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (ofilter->width || ofilter->height) {
|
||||
if (codec->width || codec->height) {
|
||||
char args[255];
|
||||
AVFilterContext *filter;
|
||||
AVDictionaryEntry *e = NULL;
|
||||
|
||||
snprintf(args, sizeof(args), "%d:%d",
|
||||
ofilter->width, ofilter->height);
|
||||
codec->width,
|
||||
codec->height);
|
||||
|
||||
while ((e = av_dict_get(ost->sws_dict, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value);
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "scaler_out_%d_%d",
|
||||
snprintf(name, sizeof(name), "scaler for output stream %d:%d",
|
||||
ost->file_index, ost->index);
|
||||
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
|
||||
name, args, NULL, fg->graph)) < 0)
|
||||
@@ -485,9 +454,9 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
pad_idx = 0;
|
||||
}
|
||||
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter))) {
|
||||
if ((pix_fmts = choose_pix_fmts(ost))) {
|
||||
AVFilterContext *filter;
|
||||
snprintf(name, sizeof(name), "format_out_%d_%d",
|
||||
snprintf(name, sizeof(name), "pixel format for output stream %d:%d",
|
||||
ost->file_index, ost->index);
|
||||
ret = avfilter_graph_create_filter(&filter,
|
||||
avfilter_get_by_name("format"),
|
||||
@@ -508,7 +477,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
|
||||
snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
|
||||
ost->frame_rate.den);
|
||||
snprintf(name, sizeof(name), "fps_out_%d_%d",
|
||||
snprintf(name, sizeof(name), "fps for output stream %d:%d",
|
||||
ost->file_index, ost->index);
|
||||
ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"),
|
||||
name, args, NULL, fg->graph);
|
||||
@@ -522,7 +491,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
pad_idx = 0;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "trim_out_%d_%d",
|
||||
snprintf(name, sizeof(name), "trim for output stream %d:%d",
|
||||
ost->file_index, ost->index);
|
||||
ret = insert_trim(of->start_time, of->recording_time,
|
||||
&last_filter, &pad_idx, name);
|
||||
@@ -547,7 +516,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
char name[255];
|
||||
int ret;
|
||||
|
||||
snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
|
||||
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
|
||||
ret = avfilter_graph_create_filter(&ofilter->filter,
|
||||
avfilter_get_by_name("abuffersink"),
|
||||
name, NULL, NULL, fg->graph);
|
||||
@@ -592,9 +561,9 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
if (codec->channels && !codec->channel_layout)
|
||||
codec->channel_layout = av_get_default_channel_layout(codec->channels);
|
||||
|
||||
sample_fmts = choose_sample_fmts(ofilter);
|
||||
sample_rates = choose_sample_rates(ofilter);
|
||||
channel_layouts = choose_channel_layouts(ofilter);
|
||||
sample_fmts = choose_sample_fmts(ost);
|
||||
sample_rates = choose_sample_rates(ost);
|
||||
channel_layouts = choose_channel_layouts(ost);
|
||||
if (sample_fmts || sample_rates || channel_layouts) {
|
||||
AVFilterContext *format;
|
||||
char args[256];
|
||||
@@ -614,7 +583,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
av_freep(&sample_rates);
|
||||
av_freep(&channel_layouts);
|
||||
|
||||
snprintf(name, sizeof(name), "format_out_%d_%d",
|
||||
snprintf(name, sizeof(name), "audio format for output stream %d:%d",
|
||||
ost->file_index, ost->index);
|
||||
ret = avfilter_graph_create_filter(&format,
|
||||
avfilter_get_by_name("aformat"),
|
||||
@@ -642,7 +611,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
int i;
|
||||
|
||||
for (i=0; i<of->ctx->nb_streams; i++)
|
||||
if (of->ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
if (of->ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
break;
|
||||
|
||||
if (i<of->ctx->nb_streams) {
|
||||
@@ -664,10 +633,30 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define DESCRIBE_FILTER_LINK(f, inout, in) \
|
||||
{ \
|
||||
AVFilterContext *ctx = inout->filter_ctx; \
|
||||
AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; \
|
||||
int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; \
|
||||
AVIOContext *pb; \
|
||||
\
|
||||
if (avio_open_dyn_buf(&pb) < 0) \
|
||||
exit_program(1); \
|
||||
\
|
||||
avio_printf(pb, "%s", ctx->filter->name); \
|
||||
if (nb_pads > 1) \
|
||||
avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\
|
||||
avio_w8(pb, 0); \
|
||||
avio_close_dyn_buf(pb, &f->name); \
|
||||
}
|
||||
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
|
||||
{
|
||||
av_freep(&ofilter->name);
|
||||
DESCRIBE_FILTER_LINK(ofilter, out, 0);
|
||||
|
||||
if (!ofilter->ost) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
|
||||
av_log(NULL, AV_LOG_FATAL, "Filter %s has a unconnected output\n", ofilter->name);
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
@@ -678,36 +667,21 @@ int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOu
|
||||
}
|
||||
}
|
||||
|
||||
void check_filter_outputs(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nb_filtergraphs; i++) {
|
||||
int n;
|
||||
for (n = 0; n < filtergraphs[i]->nb_outputs; n++) {
|
||||
OutputFilter *output = filtergraphs[i]->outputs[n];
|
||||
if (!output->ost) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", output->name);
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
|
||||
static int sub2video_prepare(InputStream *ist)
|
||||
{
|
||||
AVFormatContext *avf = input_files[ist->file_index]->ctx;
|
||||
int i, w, h;
|
||||
|
||||
/* Compute the size of the canvas for the subtitles stream.
|
||||
If the subtitles codecpar has set a size, use it. Otherwise use the
|
||||
If the subtitles codec has set a size, use it. Otherwise use the
|
||||
maximum dimensions of the video streams in the same file. */
|
||||
w = ifilter->width;
|
||||
h = ifilter->height;
|
||||
w = ist->dec_ctx->width;
|
||||
h = ist->dec_ctx->height;
|
||||
if (!(w && h)) {
|
||||
for (i = 0; i < avf->nb_streams; i++) {
|
||||
if (avf->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
w = FFMAX(w, avf->streams[i]->codecpar->width);
|
||||
h = FFMAX(h, avf->streams[i]->codecpar->height);
|
||||
if (avf->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
w = FFMAX(w, avf->streams[i]->codec->width);
|
||||
h = FFMAX(h, avf->streams[i]->codec->height);
|
||||
}
|
||||
}
|
||||
if (!(w && h)) {
|
||||
@@ -716,15 +690,12 @@ static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
|
||||
}
|
||||
av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
|
||||
}
|
||||
ist->sub2video.w = ifilter->width = w;
|
||||
ist->sub2video.h = ifilter->height = h;
|
||||
|
||||
ifilter->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w;
|
||||
ifilter->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h;
|
||||
ist->sub2video.w = ist->resample_width = w;
|
||||
ist->sub2video.h = ist->resample_height = h;
|
||||
|
||||
/* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
|
||||
palettes for all rectangles are identical or compatible */
|
||||
ifilter->format = AV_PIX_FMT_RGB32;
|
||||
ist->resample_pix_fmt = ist->dec_ctx->pix_fmt = AV_PIX_FMT_RGB32;
|
||||
|
||||
ist->sub2video.frame = av_frame_alloc();
|
||||
if (!ist->sub2video.frame)
|
||||
@@ -748,36 +719,32 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
char name[255];
|
||||
int ret, pad_idx = 0;
|
||||
int64_t tsoffset = 0;
|
||||
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
|
||||
|
||||
if (!par)
|
||||
return AVERROR(ENOMEM);
|
||||
memset(par, 0, sizeof(*par));
|
||||
par->format = AV_PIX_FMT_NONE;
|
||||
|
||||
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if (!fr.num)
|
||||
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
|
||||
|
||||
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
ret = sub2video_prepare(ist, ifilter);
|
||||
ret = sub2video_prepare(ist);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
return ret;
|
||||
}
|
||||
|
||||
sar = ifilter->sample_aspect_ratio;
|
||||
sar = ist->st->sample_aspect_ratio.num ?
|
||||
ist->st->sample_aspect_ratio :
|
||||
ist->dec_ctx->sample_aspect_ratio;
|
||||
if(!sar.den)
|
||||
sar = (AVRational){0,1};
|
||||
av_bprint_init(&args, 0, 1);
|
||||
av_bprintf(&args,
|
||||
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
|
||||
"pixel_aspect=%d/%d:sws_param=flags=%d",
|
||||
ifilter->width, ifilter->height, ifilter->format,
|
||||
"pixel_aspect=%d/%d:sws_param=flags=%d", ist->resample_width,
|
||||
ist->resample_height,
|
||||
ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->resample_pix_fmt,
|
||||
tb.num, tb.den, sar.num, sar.den,
|
||||
SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0));
|
||||
if (fr.num && fr.den)
|
||||
@@ -785,15 +752,9 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
|
||||
ist->file_index, ist->st->index);
|
||||
|
||||
|
||||
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
|
||||
args.str, NULL, fg->graph)) < 0)
|
||||
goto fail;
|
||||
par->hw_frames_ctx = ifilter->hw_frames_ctx;
|
||||
ret = av_buffersrc_parameters_set(ifilter->filter, par);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
av_freep(&par);
|
||||
return ret;
|
||||
last_filter = ifilter->filter;
|
||||
|
||||
if (ist->autorotate) {
|
||||
@@ -817,10 +778,27 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ist->framerate.num) {
|
||||
AVFilterContext *setpts;
|
||||
|
||||
snprintf(name, sizeof(name), "force CFR for input from stream %d:%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if ((ret = avfilter_graph_create_filter(&setpts,
|
||||
avfilter_get_by_name("setpts"),
|
||||
name, "N", NULL,
|
||||
fg->graph)) < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
last_filter = setpts;
|
||||
}
|
||||
|
||||
if (do_deinterlace) {
|
||||
AVFilterContext *yadif;
|
||||
|
||||
snprintf(name, sizeof(name), "deinterlace_in_%d_%d",
|
||||
snprintf(name, sizeof(name), "deinterlace input from stream %d:%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if ((ret = avfilter_graph_create_filter(&yadif,
|
||||
avfilter_get_by_name("yadif"),
|
||||
@@ -834,7 +812,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
last_filter = yadif;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "trim_in_%d_%d",
|
||||
snprintf(name, sizeof(name), "trim for input stream %d:%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if (copy_ts) {
|
||||
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
|
||||
@@ -850,10 +828,6 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
|
||||
return ret;
|
||||
return 0;
|
||||
fail:
|
||||
av_freep(&par);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
@@ -875,15 +849,15 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
|
||||
av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);
|
||||
av_bprintf(&args, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
|
||||
1, ifilter->sample_rate,
|
||||
ifilter->sample_rate,
|
||||
av_get_sample_fmt_name(ifilter->format));
|
||||
if (ifilter->channel_layout)
|
||||
1, ist->dec_ctx->sample_rate,
|
||||
ist->dec_ctx->sample_rate,
|
||||
av_get_sample_fmt_name(ist->dec_ctx->sample_fmt));
|
||||
if (ist->dec_ctx->channel_layout)
|
||||
av_bprintf(&args, ":channel_layout=0x%"PRIx64,
|
||||
ifilter->channel_layout);
|
||||
ist->dec_ctx->channel_layout);
|
||||
else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->channels);
|
||||
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
|
||||
av_bprintf(&args, ":channels=%d", ist->dec_ctx->channels);
|
||||
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
|
||||
ist->file_index, ist->st->index);
|
||||
|
||||
if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
|
||||
@@ -898,7 +872,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
|
||||
"similarly to -af " filter_name "=%s.\n", arg); \
|
||||
\
|
||||
snprintf(name, sizeof(name), "graph_%d_%s_in_%d_%d", \
|
||||
snprintf(name, sizeof(name), "graph %d %s for input stream %d:%d", \
|
||||
fg->index, filter_name, ist->file_index, ist->st->index); \
|
||||
ret = avfilter_graph_create_filter(&filt_ctx, \
|
||||
avfilter_get_by_name(filter_name), \
|
||||
@@ -969,6 +943,9 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
AVFilterInOut *in)
|
||||
{
|
||||
av_freep(&ifilter->name);
|
||||
DESCRIBE_FILTER_LINK(ifilter, in, 1);
|
||||
|
||||
if (!ifilter->ist->dec) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"No decoder for stream #%d:%d, filtering impossible\n",
|
||||
@@ -982,24 +959,14 @@ static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
}
|
||||
}
|
||||
|
||||
static void cleanup_filtergraph(FilterGraph *fg)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < fg->nb_outputs; i++)
|
||||
fg->outputs[i]->filter = (AVFilterContext *)NULL;
|
||||
for (i = 0; i < fg->nb_inputs; i++)
|
||||
fg->inputs[i]->filter = (AVFilterContext *)NULL;
|
||||
avfilter_graph_free(&fg->graph);
|
||||
}
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg)
|
||||
{
|
||||
AVFilterInOut *inputs, *outputs, *cur;
|
||||
int ret, i, simple = filtergraph_is_simple(fg);
|
||||
int ret, i, simple = !fg->graph_desc;
|
||||
const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter :
|
||||
fg->graph_desc;
|
||||
|
||||
cleanup_filtergraph(fg);
|
||||
avfilter_graph_free(&fg->graph);
|
||||
if (!(fg->graph = avfilter_graph_alloc()))
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
@@ -1008,8 +975,6 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
char args[512];
|
||||
AVDictionaryEntry *e = NULL;
|
||||
|
||||
fg->graph->nb_threads = filter_nbthreads;
|
||||
|
||||
args[0] = 0;
|
||||
while ((e = av_dict_get(ost->sws_dict, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
@@ -1035,22 +1000,15 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
}
|
||||
if (strlen(args))
|
||||
args[strlen(args) - 1] = '\0';
|
||||
fg->graph->resample_lavr_opts = av_strdup(args);
|
||||
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
} else {
|
||||
fg->graph->nb_threads = filter_complex_nbthreads;
|
||||
}
|
||||
|
||||
if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
|
||||
goto fail;
|
||||
|
||||
if (hw_device_ctx) {
|
||||
for (i = 0; i < fg->graph->nb_filters; i++) {
|
||||
fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(hw_device_ctx);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
|
||||
const char *num_inputs;
|
||||
@@ -1074,15 +1032,14 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
" However, it had %s input(s) and %s output(s)."
|
||||
" Please adjust, or use a complex filtergraph (-filter_complex) instead.\n",
|
||||
graph_desc, num_inputs, num_outputs);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
for (cur = inputs, i = 0; cur; cur = cur->next, i++)
|
||||
if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0) {
|
||||
avfilter_inout_free(&inputs);
|
||||
avfilter_inout_free(&outputs);
|
||||
goto fail;
|
||||
return ret;
|
||||
}
|
||||
avfilter_inout_free(&inputs);
|
||||
|
||||
@@ -1091,22 +1048,7 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
avfilter_inout_free(&outputs);
|
||||
|
||||
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
|
||||
goto fail;
|
||||
|
||||
/* limit the lists of allowed formats to the ones selected, to
|
||||
* make sure they stay the same if the filtergraph is reconfigured later */
|
||||
for (i = 0; i < fg->nb_outputs; i++) {
|
||||
OutputFilter *ofilter = fg->outputs[i];
|
||||
AVFilterContext *sink = ofilter->filter;
|
||||
|
||||
ofilter->format = av_buffersink_get_format(sink);
|
||||
|
||||
ofilter->width = av_buffersink_get_w(sink);
|
||||
ofilter->height = av_buffersink_get_h(sink);
|
||||
|
||||
ofilter->sample_rate = av_buffersink_get_sample_rate(sink);
|
||||
ofilter->channel_layout = av_buffersink_get_channel_layout(sink);
|
||||
}
|
||||
return ret;
|
||||
|
||||
fg->reconfiguration = 1;
|
||||
|
||||
@@ -1116,9 +1058,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
/* identical to the same check in ffmpeg.c, needed because
|
||||
complex filter graphs are initialized earlier */
|
||||
av_log(NULL, AV_LOG_ERROR, "Encoder (codec %s) not found for output stream #%d:%d\n",
|
||||
avcodec_get_name(ost->st->codecpar->codec_id), ost->file_index, ost->index);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&
|
||||
!(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
|
||||
@@ -1126,66 +1067,6 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
ost->enc_ctx->frame_size);
|
||||
}
|
||||
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
while (av_fifo_size(fg->inputs[i]->frame_queue)) {
|
||||
AVFrame *tmp;
|
||||
av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL);
|
||||
ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp);
|
||||
av_frame_free(&tmp);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* send the EOFs for the finished inputs */
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
if (fg->inputs[i]->eof) {
|
||||
ret = av_buffersrc_add_frame(fg->inputs[i]->filter, NULL);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* process queued up subtitle packets */
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
InputStream *ist = fg->inputs[i]->ist;
|
||||
if (ist->sub2video.sub_queue && ist->sub2video.frame) {
|
||||
while (av_fifo_size(ist->sub2video.sub_queue)) {
|
||||
AVSubtitle tmp;
|
||||
av_fifo_generic_read(ist->sub2video.sub_queue, &tmp, sizeof(tmp), NULL);
|
||||
sub2video_update(ist, &tmp);
|
||||
avsubtitle_free(&tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
cleanup_filtergraph(fg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
{
|
||||
av_buffer_unref(&ifilter->hw_frames_ctx);
|
||||
|
||||
ifilter->format = frame->format;
|
||||
|
||||
ifilter->width = frame->width;
|
||||
ifilter->height = frame->height;
|
||||
ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
|
||||
|
||||
ifilter->sample_rate = frame->sample_rate;
|
||||
ifilter->channels = av_frame_get_channels(frame);
|
||||
ifilter->channel_layout = frame->channel_layout;
|
||||
|
||||
if (frame->hw_frames_ctx) {
|
||||
ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
|
||||
if (!ifilter->hw_frames_ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1198,7 +1079,3 @@ int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int filtergraph_is_simple(FilterGraph *fg)
|
||||
{
|
||||
return !fg->graph_desc;
|
||||
}
|
||||
|
||||
484
ffmpeg_opt.c
484
ffmpeg_opt.c
@@ -40,6 +40,7 @@
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/time_internal.h"
|
||||
|
||||
#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
|
||||
|
||||
@@ -80,17 +81,9 @@ const HWAccel hwaccels[] = {
|
||||
#endif
|
||||
#if CONFIG_LIBMFX
|
||||
{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV },
|
||||
#endif
|
||||
#if CONFIG_VAAPI
|
||||
{ "vaapi", vaapi_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI },
|
||||
#endif
|
||||
#if CONFIG_CUVID
|
||||
{ "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA },
|
||||
#endif
|
||||
{ 0 },
|
||||
};
|
||||
int hwaccel_lax_profile_check = 0;
|
||||
AVBufferRef *hw_device_ctx;
|
||||
|
||||
char *vstats_filename;
|
||||
char *sdp_filename;
|
||||
@@ -119,9 +112,6 @@ int qp_hist = 0;
|
||||
int stdin_interaction = 1;
|
||||
int frame_bits_per_raw_sample = 0;
|
||||
float max_error_rate = 2.0/3;
|
||||
int filter_nbthreads = 0;
|
||||
int filter_complex_nbthreads = 0;
|
||||
int vstats_version = 2;
|
||||
|
||||
|
||||
static int intra_only = 0;
|
||||
@@ -185,7 +175,7 @@ static int show_hwaccels(void *optctx, const char *opt, const char *arg)
|
||||
int i;
|
||||
|
||||
printf("Hardware acceleration methods:\n");
|
||||
for (i = 0; hwaccels[i].name; i++) {
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(hwaccels) - 1; i++) {
|
||||
printf("%s\n", hwaccels[i].name);
|
||||
}
|
||||
printf("\n");
|
||||
@@ -432,12 +422,12 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg)
|
||||
exit_program(1);
|
||||
}
|
||||
st = input_files[m->file_idx]->ctx->streams[m->stream_idx];
|
||||
if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
|
||||
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
|
||||
av_log(NULL, AV_LOG_FATAL, "mapchan: stream #%d.%d is not an audio stream.\n",
|
||||
m->file_idx, m->stream_idx);
|
||||
exit_program(1);
|
||||
}
|
||||
if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->channels) {
|
||||
if (m->channel_idx < 0 || m->channel_idx >= st->codec->channels) {
|
||||
av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n",
|
||||
m->file_idx, m->stream_idx, m->channel_idx);
|
||||
exit_program(1);
|
||||
@@ -452,17 +442,6 @@ static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_VAAPI
|
||||
static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
int err;
|
||||
err = vaapi_device_init(arg);
|
||||
if (err < 0)
|
||||
exit_program(1);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Parse a metadata specifier passed as 'arg' parameter.
|
||||
* @param arg metadata string to parse
|
||||
@@ -637,11 +616,11 @@ static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *
|
||||
|
||||
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
|
||||
if (codec_name) {
|
||||
AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
|
||||
st->codecpar->codec_id = codec->id;
|
||||
AVCodec *codec = find_codec_or_die(codec_name, st->codec->codec_type, 0);
|
||||
st->codec->codec_id = codec->id;
|
||||
return codec;
|
||||
} else
|
||||
return avcodec_find_decoder(st->codecpar->codec_id);
|
||||
return avcodec_find_decoder(st->codec->codec_id);
|
||||
}
|
||||
|
||||
/* Add all the streams from the given input file to the global
|
||||
@@ -652,15 +631,13 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||
|
||||
for (i = 0; i < ic->nb_streams; i++) {
|
||||
AVStream *st = ic->streams[i];
|
||||
AVCodecParameters *par = st->codecpar;
|
||||
AVCodecContext *dec = st->codec;
|
||||
InputStream *ist = av_mallocz(sizeof(*ist));
|
||||
char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
|
||||
char *hwaccel_output_format = NULL;
|
||||
char *codec_tag = NULL;
|
||||
char *next;
|
||||
char *discard_str = NULL;
|
||||
const AVClass *cc = avcodec_get_class();
|
||||
const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL, 0, 0);
|
||||
const AVOption *discard_opt = av_opt_find(dec, "skip_frame", NULL, 0, 0);
|
||||
|
||||
if (!ist)
|
||||
exit_program(1);
|
||||
@@ -687,18 +664,18 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||
uint32_t tag = strtol(codec_tag, &next, 0);
|
||||
if (*next)
|
||||
tag = AV_RL32(codec_tag);
|
||||
st->codecpar->codec_tag = tag;
|
||||
st->codec->codec_tag = tag;
|
||||
}
|
||||
|
||||
ist->dec = choose_decoder(o, ic, st);
|
||||
ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, ic, st, ist->dec);
|
||||
ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
|
||||
|
||||
ist->reinit_filters = -1;
|
||||
MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
|
||||
|
||||
MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
|
||||
ist->user_set_discard = AVDISCARD_NONE;
|
||||
if (discard_str && av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard) < 0) {
|
||||
if (discard_str && av_opt_eval_int(dec, discard_opt, discard_str, &ist->user_set_discard) < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
|
||||
discard_str);
|
||||
exit_program(1);
|
||||
@@ -712,29 +689,25 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
ret = avcodec_parameters_to_context(ist->dec_ctx, par);
|
||||
ret = avcodec_copy_context(ist->dec_ctx, dec);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
switch (par->codec_type) {
|
||||
switch (dec->codec_type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
if(!ist->dec)
|
||||
ist->dec = avcodec_find_decoder(par->codec_id);
|
||||
ist->dec = avcodec_find_decoder(dec->codec_id);
|
||||
#if FF_API_EMU_EDGE
|
||||
if (av_codec_get_lowres(st->codec)) {
|
||||
av_codec_set_lowres(ist->dec_ctx, av_codec_get_lowres(st->codec));
|
||||
ist->dec_ctx->width = st->codec->width;
|
||||
ist->dec_ctx->height = st->codec->height;
|
||||
ist->dec_ctx->coded_width = st->codec->coded_width;
|
||||
ist->dec_ctx->coded_height = st->codec->coded_height;
|
||||
ist->dec_ctx->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
if (av_codec_get_lowres(dec)) {
|
||||
dec->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// avformat_find_stream_info() doesn't set this for us anymore.
|
||||
ist->dec_ctx->framerate = st->avg_frame_rate;
|
||||
ist->resample_height = ist->dec_ctx->height;
|
||||
ist->resample_width = ist->dec_ctx->width;
|
||||
ist->resample_pix_fmt = ist->dec_ctx->pix_fmt;
|
||||
|
||||
MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
|
||||
if (framerate && av_parse_video_rate(&ist->framerate,
|
||||
@@ -780,19 +753,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||
if (!ist->hwaccel_device)
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
|
||||
hwaccel_output_format, ic, st);
|
||||
if (hwaccel_output_format) {
|
||||
ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
|
||||
if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
|
||||
"format: %s", hwaccel_output_format);
|
||||
}
|
||||
} else {
|
||||
ist->hwaccel_output_format = AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
|
||||
|
||||
break;
|
||||
@@ -800,12 +760,18 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||
ist->guess_layout_max = INT_MAX;
|
||||
MATCH_PER_STREAM_OPT(guess_layout_max, i, ist->guess_layout_max, ic, st);
|
||||
guess_input_channel_layout(ist);
|
||||
|
||||
ist->resample_sample_fmt = ist->dec_ctx->sample_fmt;
|
||||
ist->resample_sample_rate = ist->dec_ctx->sample_rate;
|
||||
ist->resample_channels = ist->dec_ctx->channels;
|
||||
ist->resample_channel_layout = ist->dec_ctx->channel_layout;
|
||||
|
||||
break;
|
||||
case AVMEDIA_TYPE_DATA:
|
||||
case AVMEDIA_TYPE_SUBTITLE: {
|
||||
char *canvas_size = NULL;
|
||||
if(!ist->dec)
|
||||
ist->dec = avcodec_find_decoder(par->codec_id);
|
||||
ist->dec = avcodec_find_decoder(dec->codec_id);
|
||||
MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st);
|
||||
MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st);
|
||||
if (canvas_size &&
|
||||
@@ -821,12 +787,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
ret = avcodec_parameters_from_context(par, ist->dec_ctx);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +825,7 @@ static void dump_attachment(AVStream *st, const char *filename)
|
||||
AVIOContext *out = NULL;
|
||||
AVDictionaryEntry *e;
|
||||
|
||||
if (!st->codecpar->extradata_size) {
|
||||
if (!st->codec->extradata_size) {
|
||||
av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream #%d:%d.\n",
|
||||
nb_input_files - 1, st->index);
|
||||
return;
|
||||
@@ -886,7 +846,7 @@ static void dump_attachment(AVStream *st, const char *filename)
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size);
|
||||
avio_write(out, st->codec->extradata, st->codec->extradata_size);
|
||||
avio_flush(out);
|
||||
avio_close(out);
|
||||
}
|
||||
@@ -927,7 +887,6 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
||||
print_error(filename, AVERROR(ENOMEM));
|
||||
exit_program(1);
|
||||
}
|
||||
ic->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
|
||||
if (o->nb_audio_sample_rate) {
|
||||
av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0);
|
||||
}
|
||||
@@ -991,8 +950,6 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
||||
err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);
|
||||
if (err < 0) {
|
||||
print_error(filename, err);
|
||||
if (err == AVERROR_PROTOCOL_NOT_FOUND)
|
||||
av_log(NULL, AV_LOG_ERROR, "Did you mean file:%s?\n", filename);
|
||||
exit_program(1);
|
||||
}
|
||||
if (scan_all_pmts_set)
|
||||
@@ -1037,8 +994,8 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
||||
if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) {
|
||||
int dts_heuristic = 0;
|
||||
for (i=0; i<ic->nb_streams; i++) {
|
||||
const AVCodecParameters *par = ic->streams[i]->codecpar;
|
||||
if (par->video_delay)
|
||||
AVCodecContext *avctx = ic->streams[i]->codec;
|
||||
if (avctx->has_b_frames)
|
||||
dts_heuristic = 1;
|
||||
}
|
||||
if (dts_heuristic) {
|
||||
@@ -1183,39 +1140,21 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
|
||||
static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
|
||||
{
|
||||
enum AVMediaType type = ost->st->codecpar->codec_type;
|
||||
char *codec_name = NULL;
|
||||
|
||||
if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
|
||||
if (!codec_name) {
|
||||
ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->filename,
|
||||
NULL, ost->st->codecpar->codec_type);
|
||||
ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id);
|
||||
if (!ost->enc) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for "
|
||||
"output stream #%d:%d. Default encoder for format %s (codec %s) is "
|
||||
"probably disabled. Please choose an encoder manually.\n",
|
||||
ost->file_index, ost->index, s->oformat->name,
|
||||
avcodec_get_name(ost->st->codecpar->codec_id));
|
||||
return AVERROR_ENCODER_NOT_FOUND;
|
||||
}
|
||||
} else if (!strcmp(codec_name, "copy"))
|
||||
ost->stream_copy = 1;
|
||||
else {
|
||||
ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1);
|
||||
ost->st->codecpar->codec_id = ost->enc->id;
|
||||
}
|
||||
ost->encoding_needed = !ost->stream_copy;
|
||||
} else {
|
||||
/* no encoding supported for other media types */
|
||||
ost->stream_copy = 1;
|
||||
ost->encoding_needed = 0;
|
||||
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
|
||||
if (!codec_name) {
|
||||
ost->st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename,
|
||||
NULL, ost->st->codec->codec_type);
|
||||
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
|
||||
} else if (!strcmp(codec_name, "copy"))
|
||||
ost->stream_copy = 1;
|
||||
else {
|
||||
ost->enc = find_codec_or_die(codec_name, ost->st->codec->codec_type, 1);
|
||||
ost->st->codec->codec_id = ost->enc->id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)
|
||||
@@ -1223,8 +1162,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
OutputStream *ost;
|
||||
AVStream *st = avformat_new_stream(oc, NULL);
|
||||
int idx = oc->nb_streams - 1, ret = 0;
|
||||
const char *bsfs = NULL, *time_base = NULL;
|
||||
char *next, *codec_tag = NULL;
|
||||
char *bsf = NULL, *next, *codec_tag = NULL;
|
||||
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
|
||||
double qscale = -1;
|
||||
int i;
|
||||
|
||||
@@ -1244,14 +1183,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
ost->file_index = nb_output_files - 1;
|
||||
ost->index = idx;
|
||||
ost->st = st;
|
||||
st->codecpar->codec_type = type;
|
||||
|
||||
ret = choose_encoder(o, oc, ost);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream "
|
||||
"%d:%d\n", ost->file_index, ost->index);
|
||||
exit_program(1);
|
||||
}
|
||||
st->codec->codec_type = type;
|
||||
choose_encoder(o, oc, ost);
|
||||
|
||||
ost->enc_ctx = avcodec_alloc_context3(ost->enc);
|
||||
if (!ost->enc_ctx) {
|
||||
@@ -1260,12 +1193,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
}
|
||||
ost->enc_ctx->codec_type = type;
|
||||
|
||||
ost->ref_par = avcodec_parameters_alloc();
|
||||
if (!ost->ref_par) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n");
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
if (ost->enc) {
|
||||
AVIOContext *s = NULL;
|
||||
char *buf = NULL, *arg = NULL, *preset = NULL;
|
||||
@@ -1300,17 +1227,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
|
||||
}
|
||||
|
||||
MATCH_PER_STREAM_OPT(time_bases, str, time_base, oc, st);
|
||||
if (time_base) {
|
||||
AVRational q;
|
||||
if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 ||
|
||||
q.num <= 0 || q.den <= 0) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base);
|
||||
exit_program(1);
|
||||
}
|
||||
st->time_base = q;
|
||||
}
|
||||
|
||||
ost->max_frames = INT64_MAX;
|
||||
MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
|
||||
for (i = 0; i<o->nb_max_frames; i++) {
|
||||
@@ -1324,62 +1240,29 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
ost->copy_prior_start = -1;
|
||||
MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st);
|
||||
|
||||
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st);
|
||||
while (bsfs && *bsfs) {
|
||||
const AVBitStreamFilter *filter;
|
||||
char *bsf, *bsf_options_str, *bsf_name;
|
||||
|
||||
bsf = av_get_token(&bsfs, ",");
|
||||
if (!bsf)
|
||||
exit_program(1);
|
||||
bsf_name = av_strtok(bsf, "=", &bsf_options_str);
|
||||
if (!bsf_name)
|
||||
exit_program(1);
|
||||
|
||||
filter = av_bsf_get_by_name(bsf_name);
|
||||
if (!filter) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf_name);
|
||||
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
|
||||
while (bsf) {
|
||||
char *arg = NULL;
|
||||
if (next = strchr(bsf, ','))
|
||||
*next++ = 0;
|
||||
if (arg = strchr(bsf, '='))
|
||||
*arg++ = 0;
|
||||
if (!(bsfc = av_bitstream_filter_init(bsf))) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
ost->bsf_ctx = av_realloc_array(ost->bsf_ctx,
|
||||
ost->nb_bitstream_filters + 1,
|
||||
sizeof(*ost->bsf_ctx));
|
||||
if (!ost->bsf_ctx)
|
||||
exit_program(1);
|
||||
|
||||
ret = av_bsf_alloc(filter, &ost->bsf_ctx[ost->nb_bitstream_filters]);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error allocating a bitstream filter context\n");
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
ost->nb_bitstream_filters++;
|
||||
|
||||
if (bsf_options_str && filter->priv_class) {
|
||||
const AVOption *opt = av_opt_next(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, NULL);
|
||||
const char * shorthand[2] = {NULL};
|
||||
|
||||
if (opt)
|
||||
shorthand[0] = opt->name;
|
||||
|
||||
ret = av_opt_set_from_string(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, bsf_options_str, shorthand, "=", ":");
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error parsing options for bitstream filter %s\n", bsf_name);
|
||||
if (bsfc_prev)
|
||||
bsfc_prev->next = bsfc;
|
||||
else
|
||||
ost->bitstream_filters = bsfc;
|
||||
if (arg)
|
||||
if (!(bsfc->args = av_strdup(arg))) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
av_freep(&bsf);
|
||||
|
||||
if (*bsfs)
|
||||
bsfs++;
|
||||
}
|
||||
if (ost->nb_bitstream_filters) {
|
||||
ost->bsf_extradata_updated = av_mallocz_array(ost->nb_bitstream_filters, sizeof(*ost->bsf_extradata_updated));
|
||||
if (!ost->bsf_extradata_updated) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n");
|
||||
exit_program(1);
|
||||
}
|
||||
bsfc_prev = bsfc;
|
||||
bsf = next;
|
||||
}
|
||||
|
||||
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
|
||||
@@ -1387,7 +1270,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
uint32_t tag = strtol(codec_tag, &next, 0);
|
||||
if (*next)
|
||||
tag = AV_RL32(codec_tag);
|
||||
ost->st->codecpar->codec_tag =
|
||||
ost->st->codec->codec_tag =
|
||||
ost->enc_ctx->codec_tag = tag;
|
||||
}
|
||||
|
||||
@@ -1400,10 +1283,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
|
||||
ost->disposition = av_strdup(ost->disposition);
|
||||
|
||||
ost->max_muxing_queue_size = 128;
|
||||
MATCH_PER_STREAM_OPT(max_muxing_queue_size, i, ost->max_muxing_queue_size, oc, st);
|
||||
ost->max_muxing_queue_size *= sizeof(AVPacket);
|
||||
|
||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
@@ -1423,10 +1302,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
||||
}
|
||||
ost->last_mux_dts = AV_NOPTS_VALUE;
|
||||
|
||||
ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket));
|
||||
if (!ost->muxing_queue)
|
||||
exit_program(1);
|
||||
|
||||
return ost;
|
||||
}
|
||||
|
||||
@@ -1492,7 +1367,7 @@ static char *get_ost_filters(OptionsContext *o, AVFormatContext *oc,
|
||||
else if (ost->filters)
|
||||
return av_strdup(ost->filters);
|
||||
|
||||
return av_strdup(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ?
|
||||
return av_strdup(st->codec->codec_type == AVMEDIA_TYPE_VIDEO ?
|
||||
"null" : "anull");
|
||||
}
|
||||
|
||||
@@ -1913,7 +1788,6 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
|
||||
int i, err;
|
||||
AVFormatContext *ic = avformat_alloc_context();
|
||||
|
||||
ic->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
|
||||
ic->interrupt_callback = int_cb;
|
||||
err = avformat_open_input(&ic, filename, NULL, NULL);
|
||||
if (err < 0)
|
||||
@@ -1925,9 +1799,9 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
|
||||
AVCodec *codec;
|
||||
const char *enc_config;
|
||||
|
||||
codec = avcodec_find_encoder(ic->streams[i]->codecpar->codec_id);
|
||||
codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
|
||||
if (!codec) {
|
||||
av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codecpar->codec_id);
|
||||
av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codec->codec_id);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (codec->type == AVMEDIA_TYPE_AUDIO)
|
||||
@@ -1946,10 +1820,10 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
|
||||
av_dict_free(&opts);
|
||||
}
|
||||
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
|
||||
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
|
||||
choose_sample_fmt(st, codec);
|
||||
else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
|
||||
choose_pixel_fmt(st, st->codec, codec, st->codecpar->format);
|
||||
else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
|
||||
choose_pixel_fmt(st, st->codec, codec, st->codec->pix_fmt);
|
||||
avcodec_copy_context(ost->enc_ctx, st->codec);
|
||||
if (enc_config)
|
||||
av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0);
|
||||
@@ -1977,7 +1851,6 @@ static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
|
||||
ost->filter = ofilter;
|
||||
|
||||
ofilter->ost = ost;
|
||||
ofilter->format = -1;
|
||||
|
||||
if (ost->stream_copy) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Streamcopy requested for output stream %d:%d, "
|
||||
@@ -2013,6 +1886,17 @@ static int init_complex_filters(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int configure_complex_filters(void)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
for (i = 0; i < nb_filtergraphs; i++)
|
||||
if (!filtergraphs[i]->graph &&
|
||||
(ret = configure_filtergraph(filtergraphs[i])) < 0)
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open_output_file(OptionsContext *o, const char *filename)
|
||||
{
|
||||
AVFormatContext *oc;
|
||||
@@ -2023,7 +1907,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
InputStream *ist;
|
||||
AVDictionary *unused_opts = NULL;
|
||||
AVDictionaryEntry *e = NULL;
|
||||
int format_flags = 0;
|
||||
|
||||
|
||||
if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {
|
||||
o->stop_time = INT64_MAX;
|
||||
@@ -2069,12 +1953,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
file_oformat= oc->oformat;
|
||||
oc->interrupt_callback = int_cb;
|
||||
|
||||
e = av_dict_get(o->g->format_opts, "fflags", NULL, 0);
|
||||
if (e) {
|
||||
const AVOption *o = av_opt_find(oc, "fflags", NULL, 0, 0);
|
||||
av_opt_eval_flags(oc, o, e->value, &format_flags);
|
||||
}
|
||||
|
||||
/* create streams for all unlabeled output pads */
|
||||
for (i = 0; i < nb_filtergraphs; i++) {
|
||||
FilterGraph *fg = filtergraphs[i];
|
||||
@@ -2095,7 +1973,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
|
||||
/* ffserver seeking with date=... needs a date reference */
|
||||
if (!strcmp(file_oformat->name, "ffm") &&
|
||||
!(format_flags & AVFMT_FLAG_BITEXACT) &&
|
||||
av_strstart(filename, "http:", NULL)) {
|
||||
int err = parse_option(o, "metadata", "creation_time=now", options);
|
||||
if (err < 0) {
|
||||
@@ -2118,18 +1995,18 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
ost = output_streams[j];
|
||||
for (i = 0; i < nb_input_streams; i++) {
|
||||
ist = input_streams[i];
|
||||
if(ist->st->codecpar->codec_type == ost->st->codecpar->codec_type){
|
||||
if(ist->st->codec->codec_type == ost->st->codec->codec_type){
|
||||
ost->sync_ist= ist;
|
||||
ost->source_index= i;
|
||||
if(ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
|
||||
if(ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
|
||||
if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
|
||||
if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
|
||||
ist->discard = 0;
|
||||
ist->st->discard = ist->user_set_discard;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!ost->sync_ist){
|
||||
av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codecpar->codec_type));
|
||||
av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type));
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
@@ -2144,10 +2021,10 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
for (i = 0; i < nb_input_streams; i++) {
|
||||
int new_area;
|
||||
ist = input_streams[i];
|
||||
new_area = ist->st->codecpar->width * ist->st->codecpar->height + 100000000*!!ist->st->codec_info_nb_frames;
|
||||
new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames;
|
||||
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
|
||||
new_area = 1;
|
||||
if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||
new_area > area) {
|
||||
if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
|
||||
continue;
|
||||
@@ -2165,8 +2042,8 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
for (i = 0; i < nb_input_streams; i++) {
|
||||
int score;
|
||||
ist = input_streams[i];
|
||||
score = ist->st->codecpar->channels + 100000000*!!ist->st->codec_info_nb_frames;
|
||||
if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
score = ist->st->codec->channels + 100000000*!!ist->st->codec_info_nb_frames;
|
||||
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
score > best_score) {
|
||||
best_score = score;
|
||||
idx = i;
|
||||
@@ -2180,9 +2057,9 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
|
||||
if (!o->subtitle_disable && (avcodec_find_encoder(oc->oformat->subtitle_codec) || subtitle_codec_name)) {
|
||||
for (i = 0; i < nb_input_streams; i++)
|
||||
if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
|
||||
AVCodecDescriptor const *input_descriptor =
|
||||
avcodec_descriptor_get(input_streams[i]->st->codecpar->codec_id);
|
||||
avcodec_descriptor_get(input_streams[i]->st->codec->codec_id);
|
||||
AVCodecDescriptor const *output_descriptor = NULL;
|
||||
AVCodec const *output_codec =
|
||||
avcodec_find_encoder(oc->oformat->subtitle_codec);
|
||||
@@ -2208,8 +2085,8 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
||||
if (!o->data_disable ) {
|
||||
enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA);
|
||||
for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
|
||||
if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA
|
||||
&& input_streams[i]->st->codecpar->codec_id == codec_id )
|
||||
if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_DATA
|
||||
&& input_streams[i]->st->codec->codec_id == codec_id )
|
||||
new_data_stream(o, oc, i);
|
||||
}
|
||||
}
|
||||
@@ -2246,17 +2123,17 @@ loop_end:
|
||||
int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
|
||||
|
||||
ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
|
||||
if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
|
||||
if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
|
||||
continue;
|
||||
if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
continue;
|
||||
if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
if(o-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
continue;
|
||||
if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
|
||||
if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA)
|
||||
continue;
|
||||
|
||||
ost = NULL;
|
||||
switch (ist->st->codecpar->codec_type) {
|
||||
switch (ist->st->codec->codec_type) {
|
||||
case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break;
|
||||
case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break;
|
||||
case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break;
|
||||
@@ -2311,17 +2188,17 @@ loop_end:
|
||||
avio_read(pb, attachment, len);
|
||||
|
||||
ost = new_attachment_stream(o, oc, -1);
|
||||
ost->stream_copy = 0;
|
||||
ost->stream_copy = 1;
|
||||
ost->attachment_filename = o->attachments[i];
|
||||
ost->st->codecpar->extradata = attachment;
|
||||
ost->st->codecpar->extradata_size = len;
|
||||
ost->finished = 1;
|
||||
ost->st->codec->extradata = attachment;
|
||||
ost->st->codec->extradata_size = len;
|
||||
|
||||
p = strrchr(o->attachments[i], '/');
|
||||
av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
|
||||
avio_closep(&pb);
|
||||
}
|
||||
|
||||
#if FF_API_LAVF_AVCTX
|
||||
for (i = nb_output_streams - oc->nb_streams; i < nb_output_streams; i++) { //for all streams of this output file
|
||||
AVDictionaryEntry *e;
|
||||
ost = output_streams[i];
|
||||
@@ -2332,7 +2209,6 @@ loop_end:
|
||||
if (av_opt_set(ost->st->codec, "flags", e->value, 0) < 0)
|
||||
exit_program(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
|
||||
av_dump_format(oc, nb_output_files - 1, oc->filename, 1);
|
||||
@@ -2382,86 +2258,14 @@ loop_end:
|
||||
}
|
||||
av_dict_free(&unused_opts);
|
||||
|
||||
/* set the decoding_needed flags and create simple filtergraphs */
|
||||
/* set the encoding/decoding_needed flags */
|
||||
for (i = of->ost_index; i < nb_output_streams; i++) {
|
||||
OutputStream *ost = output_streams[i];
|
||||
|
||||
ost->encoding_needed = !ost->stream_copy;
|
||||
if (ost->encoding_needed && ost->source_index >= 0) {
|
||||
InputStream *ist = input_streams[ost->source_index];
|
||||
ist->decoding_needed |= DECODING_FOR_OST;
|
||||
|
||||
if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
|
||||
ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
err = init_simple_filtergraph(ist, ost);
|
||||
if (err < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Error initializing a simple filtergraph between streams "
|
||||
"%d:%d->%d:%d\n", ist->file_index, ost->source_index,
|
||||
nb_output_files - 1, ost->st->index);
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* set the filter output constraints */
|
||||
if (ost->filter) {
|
||||
OutputFilter *f = ost->filter;
|
||||
int count;
|
||||
switch (ost->enc_ctx->codec_type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
f->frame_rate = ost->frame_rate;
|
||||
f->width = ost->enc_ctx->width;
|
||||
f->height = ost->enc_ctx->height;
|
||||
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
|
||||
f->format = ost->enc_ctx->pix_fmt;
|
||||
} else if (ost->enc->pix_fmts) {
|
||||
count = 0;
|
||||
while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE)
|
||||
count++;
|
||||
f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
|
||||
if (!f->formats)
|
||||
exit_program(1);
|
||||
memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats));
|
||||
}
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
|
||||
f->format = ost->enc_ctx->sample_fmt;
|
||||
} else if (ost->enc->sample_fmts) {
|
||||
count = 0;
|
||||
while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE)
|
||||
count++;
|
||||
f->formats = av_mallocz_array(count + 1, sizeof(*f->formats));
|
||||
if (!f->formats)
|
||||
exit_program(1);
|
||||
memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats));
|
||||
}
|
||||
if (ost->enc_ctx->sample_rate) {
|
||||
f->sample_rate = ost->enc_ctx->sample_rate;
|
||||
} else if (ost->enc->supported_samplerates) {
|
||||
count = 0;
|
||||
while (ost->enc->supported_samplerates[count])
|
||||
count++;
|
||||
f->sample_rates = av_mallocz_array(count + 1, sizeof(*f->sample_rates));
|
||||
if (!f->sample_rates)
|
||||
exit_program(1);
|
||||
memcpy(f->sample_rates, ost->enc->supported_samplerates,
|
||||
(count + 1) * sizeof(*f->sample_rates));
|
||||
}
|
||||
if (ost->enc_ctx->channels) {
|
||||
f->channel_layout = av_get_default_channel_layout(ost->enc_ctx->channels);
|
||||
} else if (ost->enc->channel_layouts) {
|
||||
count = 0;
|
||||
while (ost->enc->channel_layouts[count])
|
||||
count++;
|
||||
f->channel_layouts = av_mallocz_array(count + 1, sizeof(*f->channel_layouts));
|
||||
if (!f->channel_layouts)
|
||||
exit_program(1);
|
||||
memcpy(f->channel_layouts, ost->enc->channel_layouts,
|
||||
(count + 1) * sizeof(*f->channel_layouts));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2549,6 +2353,8 @@ loop_end:
|
||||
av_dict_copy(&output_streams[i]->st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);
|
||||
if (!output_streams[i]->stream_copy) {
|
||||
av_dict_set(&output_streams[i]->st->metadata, "encoder", NULL, 0);
|
||||
if (ist->autorotate)
|
||||
av_dict_set(&output_streams[i]->st->metadata, "rotate", NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2624,6 +2430,7 @@ loop_end:
|
||||
char type, *val;
|
||||
const char *stream_spec;
|
||||
int index = 0, j, ret = 0;
|
||||
char now_time[256];
|
||||
|
||||
val = strchr(o->metadata[i].u.str, '=');
|
||||
if (!val) {
|
||||
@@ -2633,20 +2440,25 @@ loop_end:
|
||||
}
|
||||
*val++ = 0;
|
||||
|
||||
if (!strcmp(o->metadata[i].u.str, "creation_time") &&
|
||||
!strcmp(val, "now")) {
|
||||
time_t now = time(0);
|
||||
struct tm *ptm, tmbuf;
|
||||
ptm = localtime_r(&now, &tmbuf);
|
||||
if (ptm) {
|
||||
if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm))
|
||||
val = now_time;
|
||||
}
|
||||
}
|
||||
|
||||
parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec);
|
||||
if (type == 's') {
|
||||
for (j = 0; j < oc->nb_streams; j++) {
|
||||
ost = output_streams[nb_output_streams - oc->nb_streams + j];
|
||||
if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) {
|
||||
av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0);
|
||||
if (!strcmp(o->metadata[i].u.str, "rotate")) {
|
||||
char *tail;
|
||||
double theta = av_strtod(val, &tail);
|
||||
if (!*tail) {
|
||||
ost->rotate_overridden = 1;
|
||||
ost->rotate_override_value = theta;
|
||||
}
|
||||
} else {
|
||||
av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0);
|
||||
ost->rotate_overridden = 1;
|
||||
}
|
||||
} else if (ret < 0)
|
||||
exit_program(1);
|
||||
@@ -2703,10 +2515,11 @@ static int opt_target(void *optctx, const char *opt, const char *arg)
|
||||
int i, j, fr;
|
||||
for (j = 0; j < nb_input_files; j++) {
|
||||
for (i = 0; i < input_files[j]->nb_streams; i++) {
|
||||
AVStream *st = input_files[j]->ctx->streams[i];
|
||||
if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
|
||||
AVCodecContext *c = input_files[j]->ctx->streams[i]->codec;
|
||||
if (c->codec_type != AVMEDIA_TYPE_VIDEO ||
|
||||
!c->time_base.num)
|
||||
continue;
|
||||
fr = st->time_base.den * 1000 / st->time_base.num;
|
||||
fr = c->time_base.den * 1000 / c->time_base.num;
|
||||
if (fr == 25000) {
|
||||
norm = PAL;
|
||||
break;
|
||||
@@ -3176,8 +2989,8 @@ enum OptGroup {
|
||||
};
|
||||
|
||||
static const OptionGroupDef groups[] = {
|
||||
[GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
|
||||
[GROUP_INFILE] = { "input url", "i", OPT_INPUT },
|
||||
[GROUP_OUTFILE] = { "output file", NULL, OPT_OUTPUT },
|
||||
[GROUP_INFILE] = { "input file", "i", OPT_INPUT },
|
||||
};
|
||||
|
||||
static int open_files(OptionGroupList *l, const char *inout,
|
||||
@@ -3236,9 +3049,6 @@ int ffmpeg_parse_options(int argc, char **argv)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* configure terminal and setup signal handlers */
|
||||
term_init();
|
||||
|
||||
/* open input files */
|
||||
ret = open_files(&octx.groups[GROUP_INFILE], "input", open_input_file);
|
||||
if (ret < 0) {
|
||||
@@ -3260,7 +3070,12 @@ int ffmpeg_parse_options(int argc, char **argv)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
check_filter_outputs();
|
||||
/* configure the complex filtergraphs */
|
||||
ret = configure_complex_filters();
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Error configuring complex filters.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
uninit_parse_context(&octx);
|
||||
@@ -3428,16 +3243,12 @@ const OptionDef options[] = {
|
||||
"set profile", "profile" },
|
||||
{ "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) },
|
||||
"set stream filtergraph", "filter_graph" },
|
||||
{ "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads },
|
||||
"number of non-complex filter threads" },
|
||||
{ "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) },
|
||||
"read stream filtergraph description from a file", "filename" },
|
||||
{ "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(reinit_filters) },
|
||||
"reinit filtergraph on input parameter changes", "" },
|
||||
{ "filter_complex", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
|
||||
"create a complex filtergraph", "graph_description" },
|
||||
{ "filter_complex_threads", HAS_ARG | OPT_INT, { &filter_complex_nbthreads },
|
||||
"number of threads for -filter_complex" },
|
||||
{ "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
|
||||
"create a complex filtergraph", "graph_description" },
|
||||
{ "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script },
|
||||
@@ -3512,8 +3323,6 @@ const OptionDef options[] = {
|
||||
"dump video coding statistics to file" },
|
||||
{ "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file },
|
||||
"dump video coding statistics to file", "file" },
|
||||
{ "vstats_version", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { &vstats_version },
|
||||
"Version of the vstats format to use."},
|
||||
{ "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_filters },
|
||||
"set video filters", "filter_graph" },
|
||||
{ "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
|
||||
@@ -3552,9 +3361,9 @@ const OptionDef options[] = {
|
||||
{ "hwaccel_device", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
|
||||
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_devices) },
|
||||
"select a device for HW acceleration", "devicename" },
|
||||
{ "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
|
||||
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
|
||||
"select output format used with HW accelerated decoding", "format" },
|
||||
#if HAVE_VDPAU_X11
|
||||
{ "vdpau_api_ver", HAS_ARG | OPT_INT | OPT_EXPERT, { &vdpau_api_ver }, "" },
|
||||
#endif
|
||||
#if CONFIG_VDA || CONFIG_VIDEOTOOLBOX
|
||||
{ "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" },
|
||||
#endif
|
||||
@@ -3563,8 +3372,6 @@ const OptionDef options[] = {
|
||||
{ "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC |
|
||||
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) },
|
||||
"automatically insert correct rotate filters" },
|
||||
{ "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT, { &hwaccel_lax_profile_check},
|
||||
"attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream" },
|
||||
|
||||
/* audio options */
|
||||
{ "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },
|
||||
@@ -3627,9 +3434,6 @@ const OptionDef options[] = {
|
||||
{ "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_sdp_file },
|
||||
"specify a file in which to print sdp information", "file" },
|
||||
|
||||
{ "time_base", HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(time_bases) },
|
||||
"set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
|
||||
|
||||
{ "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
|
||||
"A comma-separated list of bitstream filters", "bitstream_filters" },
|
||||
{ "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
|
||||
@@ -3645,25 +3449,11 @@ const OptionDef options[] = {
|
||||
"set the subtitle options to the indicated preset", "preset" },
|
||||
{ "fpre", HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
|
||||
"set options from indicated preset file", "filename" },
|
||||
|
||||
{ "max_muxing_queue_size", HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(max_muxing_queue_size) },
|
||||
"maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
|
||||
|
||||
/* data codec support */
|
||||
{ "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_data_codec },
|
||||
"force data codec ('copy' to copy stream)", "codec" },
|
||||
{ "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(data_disable) },
|
||||
"disable data" },
|
||||
|
||||
#if CONFIG_VAAPI
|
||||
{ "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device },
|
||||
"set VAAPI hardware device (DRM path or X11 display name)", "device" },
|
||||
#endif
|
||||
|
||||
#if CONFIG_QSV
|
||||
{ "qsv_device", HAS_ARG | OPT_STRING | OPT_EXPERT, { &qsv_device },
|
||||
"set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
|
||||
#endif
|
||||
|
||||
{ NULL, },
|
||||
};
|
||||
|
||||
259
ffmpeg_qsv.c
259
ffmpeg_qsv.c
@@ -20,90 +20,249 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/hwcontext_qsv.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavcodec/qsv.h"
|
||||
|
||||
#include "ffmpeg.h"
|
||||
|
||||
char *qsv_device = NULL;
|
||||
typedef struct QSVContext {
|
||||
OutputStream *ost;
|
||||
|
||||
mfxSession session;
|
||||
|
||||
mfxExtOpaqueSurfaceAlloc opaque_alloc;
|
||||
AVBufferRef *opaque_surfaces_buf;
|
||||
|
||||
uint8_t *surface_used;
|
||||
mfxFrameSurface1 **surface_ptrs;
|
||||
int nb_surfaces;
|
||||
|
||||
mfxExtBuffer *ext_buffers[1];
|
||||
} QSVContext;
|
||||
|
||||
static void buffer_release(void *opaque, uint8_t *data)
|
||||
{
|
||||
*(uint8_t*)opaque = 0;
|
||||
}
|
||||
|
||||
static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
QSVContext *qsv = ist->hwaccel_ctx;
|
||||
int i;
|
||||
|
||||
return av_hwframe_get_buffer(ist->hw_frames_ctx, frame, 0);
|
||||
for (i = 0; i < qsv->nb_surfaces; i++) {
|
||||
if (qsv->surface_used[i])
|
||||
continue;
|
||||
|
||||
frame->buf[0] = av_buffer_create((uint8_t*)qsv->surface_ptrs[i], sizeof(*qsv->surface_ptrs[i]),
|
||||
buffer_release, &qsv->surface_used[i], 0);
|
||||
if (!frame->buf[0])
|
||||
return AVERROR(ENOMEM);
|
||||
frame->data[3] = (uint8_t*)qsv->surface_ptrs[i];
|
||||
qsv->surface_used[i] = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static int init_opaque_surf(QSVContext *qsv)
|
||||
{
|
||||
AVQSVContext *hwctx_enc = qsv->ost->enc_ctx->hwaccel_context;
|
||||
mfxFrameSurface1 *surfaces;
|
||||
int i;
|
||||
|
||||
qsv->nb_surfaces = hwctx_enc->nb_opaque_surfaces;
|
||||
|
||||
qsv->opaque_surfaces_buf = av_buffer_ref(hwctx_enc->opaque_surfaces);
|
||||
qsv->surface_ptrs = av_mallocz_array(qsv->nb_surfaces, sizeof(*qsv->surface_ptrs));
|
||||
qsv->surface_used = av_mallocz_array(qsv->nb_surfaces, sizeof(*qsv->surface_used));
|
||||
if (!qsv->opaque_surfaces_buf || !qsv->surface_ptrs || !qsv->surface_used)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
surfaces = (mfxFrameSurface1*)qsv->opaque_surfaces_buf->data;
|
||||
for (i = 0; i < qsv->nb_surfaces; i++)
|
||||
qsv->surface_ptrs[i] = surfaces + i;
|
||||
|
||||
qsv->opaque_alloc.Out.Surfaces = qsv->surface_ptrs;
|
||||
qsv->opaque_alloc.Out.NumSurface = qsv->nb_surfaces;
|
||||
qsv->opaque_alloc.Out.Type = hwctx_enc->opaque_alloc_type;
|
||||
|
||||
qsv->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
|
||||
qsv->opaque_alloc.Header.BufferSz = sizeof(qsv->opaque_alloc);
|
||||
qsv->ext_buffers[0] = (mfxExtBuffer*)&qsv->opaque_alloc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void qsv_uninit(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
av_buffer_unref(&ist->hw_frames_ctx);
|
||||
}
|
||||
QSVContext *qsv = ist->hwaccel_ctx;
|
||||
|
||||
static int qsv_device_init(InputStream *ist)
|
||||
{
|
||||
int err;
|
||||
AVDictionary *dict = NULL;
|
||||
av_freep(&qsv->ost->enc_ctx->hwaccel_context);
|
||||
av_freep(&s->hwaccel_context);
|
||||
|
||||
if (qsv_device) {
|
||||
err = av_dict_set(&dict, "child_device", qsv_device, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
av_buffer_unref(&qsv->opaque_surfaces_buf);
|
||||
av_freep(&qsv->surface_used);
|
||||
av_freep(&qsv->surface_ptrs);
|
||||
|
||||
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_QSV,
|
||||
ist->hwaccel_device, dict, 0);
|
||||
if (err < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error creating a QSV device\n");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
err_out:
|
||||
if (dict)
|
||||
av_dict_free(&dict);
|
||||
|
||||
return err;
|
||||
av_freep(&qsv);
|
||||
}
|
||||
|
||||
int qsv_init(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
AVHWFramesContext *frames_ctx;
|
||||
AVQSVFramesContext *frames_hwctx;
|
||||
QSVContext *qsv = ist->hwaccel_ctx;
|
||||
AVQSVContext *hwctx_dec;
|
||||
int ret;
|
||||
|
||||
if (!hw_device_ctx) {
|
||||
ret = qsv_device_init(ist);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!qsv) {
|
||||
av_log(NULL, AV_LOG_ERROR, "QSV transcoding is not initialized. "
|
||||
"-hwaccel qsv should only be used for one-to-one QSV transcoding "
|
||||
"with no filters.\n");
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
|
||||
av_buffer_unref(&ist->hw_frames_ctx);
|
||||
ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx);
|
||||
if (!ist->hw_frames_ctx)
|
||||
ret = init_opaque_surf(qsv);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
hwctx_dec = av_qsv_alloc_context();
|
||||
if (!hwctx_dec)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data;
|
||||
frames_hwctx = frames_ctx->hwctx;
|
||||
hwctx_dec->session = qsv->session;
|
||||
hwctx_dec->iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
|
||||
hwctx_dec->ext_buffers = qsv->ext_buffers;
|
||||
hwctx_dec->nb_ext_buffers = FF_ARRAY_ELEMS(qsv->ext_buffers);
|
||||
|
||||
frames_ctx->width = FFALIGN(s->coded_width, 32);
|
||||
frames_ctx->height = FFALIGN(s->coded_height, 32);
|
||||
frames_ctx->format = AV_PIX_FMT_QSV;
|
||||
frames_ctx->sw_format = s->sw_pix_fmt;
|
||||
frames_ctx->initial_pool_size = 64;
|
||||
frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
|
||||
|
||||
ret = av_hwframe_ctx_init(ist->hw_frames_ctx);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error initializing a QSV frame pool\n");
|
||||
return ret;
|
||||
}
|
||||
av_freep(&s->hwaccel_context);
|
||||
s->hwaccel_context = hwctx_dec;
|
||||
|
||||
ist->hwaccel_get_buffer = qsv_get_buffer;
|
||||
ist->hwaccel_uninit = qsv_uninit;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static mfxIMPL choose_implementation(const InputStream *ist)
|
||||
{
|
||||
static const struct {
|
||||
const char *name;
|
||||
mfxIMPL impl;
|
||||
} impl_map[] = {
|
||||
{ "auto", MFX_IMPL_AUTO },
|
||||
{ "sw", MFX_IMPL_SOFTWARE },
|
||||
{ "hw", MFX_IMPL_HARDWARE },
|
||||
{ "auto_any", MFX_IMPL_AUTO_ANY },
|
||||
{ "hw_any", MFX_IMPL_HARDWARE_ANY },
|
||||
{ "hw2", MFX_IMPL_HARDWARE2 },
|
||||
{ "hw3", MFX_IMPL_HARDWARE3 },
|
||||
{ "hw4", MFX_IMPL_HARDWARE4 },
|
||||
};
|
||||
|
||||
mfxIMPL impl = MFX_IMPL_AUTO_ANY;
|
||||
int i;
|
||||
|
||||
if (ist->hwaccel_device) {
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(impl_map); i++)
|
||||
if (!strcmp(ist->hwaccel_device, impl_map[i].name)) {
|
||||
impl = impl_map[i].impl;
|
||||
break;
|
||||
}
|
||||
if (i == FF_ARRAY_ELEMS(impl_map))
|
||||
impl = strtol(ist->hwaccel_device, NULL, 0);
|
||||
}
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
int qsv_transcode_init(OutputStream *ost)
|
||||
{
|
||||
InputStream *ist;
|
||||
const enum AVPixelFormat *pix_fmt;
|
||||
|
||||
AVDictionaryEntry *e;
|
||||
const AVOption *opt;
|
||||
int flags = 0;
|
||||
|
||||
int err, i;
|
||||
|
||||
QSVContext *qsv = NULL;
|
||||
AVQSVContext *hwctx = NULL;
|
||||
mfxIMPL impl;
|
||||
mfxVersion ver = { { 3, 1 } };
|
||||
|
||||
/* check if the encoder supports QSV */
|
||||
if (!ost->enc->pix_fmts)
|
||||
return 0;
|
||||
for (pix_fmt = ost->enc->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
|
||||
if (*pix_fmt == AV_PIX_FMT_QSV)
|
||||
break;
|
||||
if (*pix_fmt == AV_PIX_FMT_NONE)
|
||||
return 0;
|
||||
|
||||
if (strcmp(ost->avfilter, "null") || ost->source_index < 0)
|
||||
return 0;
|
||||
|
||||
/* check if the decoder supports QSV and the output only goes to this stream */
|
||||
ist = input_streams[ost->source_index];
|
||||
if (ist->nb_filters || ist->hwaccel_id != HWACCEL_QSV ||
|
||||
!ist->dec || !ist->dec->pix_fmts)
|
||||
return 0;
|
||||
for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
|
||||
if (*pix_fmt == AV_PIX_FMT_QSV)
|
||||
break;
|
||||
if (*pix_fmt == AV_PIX_FMT_NONE)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < nb_output_streams; i++)
|
||||
if (output_streams[i] != ost &&
|
||||
output_streams[i]->source_index == ost->source_index)
|
||||
return 0;
|
||||
|
||||
av_log(NULL, AV_LOG_VERBOSE, "Setting up QSV transcoding\n");
|
||||
|
||||
qsv = av_mallocz(sizeof(*qsv));
|
||||
hwctx = av_qsv_alloc_context();
|
||||
if (!qsv || !hwctx)
|
||||
goto fail;
|
||||
|
||||
impl = choose_implementation(ist);
|
||||
|
||||
err = MFXInit(impl, &ver, &qsv->session);
|
||||
if (err != MFX_ERR_NONE) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error initializing an MFX session: %d\n", err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
e = av_dict_get(ost->encoder_opts, "flags", NULL, 0);
|
||||
opt = av_opt_find(ost->enc_ctx, "flags", NULL, 0, 0);
|
||||
if (e && opt)
|
||||
av_opt_eval_flags(ost->enc_ctx, opt, e->value, &flags);
|
||||
|
||||
qsv->ost = ost;
|
||||
|
||||
hwctx->session = qsv->session;
|
||||
hwctx->iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
|
||||
hwctx->opaque_alloc = 1;
|
||||
hwctx->nb_opaque_surfaces = 16;
|
||||
|
||||
ost->hwaccel_ctx = qsv;
|
||||
ost->enc_ctx->hwaccel_context = hwctx;
|
||||
ost->enc_ctx->pix_fmt = AV_PIX_FMT_QSV;
|
||||
|
||||
ist->hwaccel_ctx = qsv;
|
||||
ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV;
|
||||
ist->resample_pix_fmt = AV_PIX_FMT_QSV;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_freep(&hwctx);
|
||||
av_freep(&qsv);
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
233
ffmpeg_vaapi.c
233
ffmpeg_vaapi.c
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "ffmpeg.h"
|
||||
|
||||
|
||||
static AVClass vaapi_class = {
|
||||
.class_name = "vaapi",
|
||||
.item_name = av_default_item_name,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
#define DEFAULT_SURFACES 20
|
||||
|
||||
typedef struct VAAPIDecoderContext {
|
||||
const AVClass *class;
|
||||
|
||||
AVBufferRef *device_ref;
|
||||
AVHWDeviceContext *device;
|
||||
AVBufferRef *frames_ref;
|
||||
AVHWFramesContext *frames;
|
||||
|
||||
// The output need not have the same format, width and height as the
|
||||
// decoded frames - the copy for non-direct-mapped access is actually
|
||||
// a whole vpp instance which can do arbitrary scaling and format
|
||||
// conversion.
|
||||
enum AVPixelFormat output_format;
|
||||
} VAAPIDecoderContext;
|
||||
|
||||
|
||||
static int vaapi_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
{
|
||||
InputStream *ist = avctx->opaque;
|
||||
VAAPIDecoderContext *ctx = ist->hwaccel_ctx;
|
||||
int err;
|
||||
|
||||
err = av_hwframe_get_buffer(ctx->frames_ref, frame, 0);
|
||||
if (err < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to allocate decoder surface.\n");
|
||||
} else {
|
||||
av_log(ctx, AV_LOG_DEBUG, "Decoder given surface %#x.\n",
|
||||
(unsigned int)(uintptr_t)frame->data[3]);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static int vaapi_retrieve_data(AVCodecContext *avctx, AVFrame *input)
|
||||
{
|
||||
InputStream *ist = avctx->opaque;
|
||||
VAAPIDecoderContext *ctx = ist->hwaccel_ctx;
|
||||
AVFrame *output = 0;
|
||||
int err;
|
||||
|
||||
av_assert0(input->format == AV_PIX_FMT_VAAPI);
|
||||
|
||||
if (ctx->output_format == AV_PIX_FMT_VAAPI) {
|
||||
// Nothing to do.
|
||||
return 0;
|
||||
}
|
||||
|
||||
av_log(ctx, AV_LOG_DEBUG, "Retrieve data from surface %#x.\n",
|
||||
(unsigned int)(uintptr_t)input->data[3]);
|
||||
|
||||
output = av_frame_alloc();
|
||||
if (!output)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
output->format = ctx->output_format;
|
||||
|
||||
err = av_hwframe_transfer_data(output, input, 0);
|
||||
if (err < 0) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Failed to transfer data to "
|
||||
"output frame: %d.\n", err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
err = av_frame_copy_props(output, input);
|
||||
if (err < 0) {
|
||||
av_frame_unref(output);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
av_frame_unref(input);
|
||||
av_frame_move_ref(input, output);
|
||||
av_frame_free(&output);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (output)
|
||||
av_frame_free(&output);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void vaapi_decode_uninit(AVCodecContext *avctx)
|
||||
{
|
||||
InputStream *ist = avctx->opaque;
|
||||
VAAPIDecoderContext *ctx = ist->hwaccel_ctx;
|
||||
|
||||
if (ctx) {
|
||||
av_buffer_unref(&ctx->frames_ref);
|
||||
av_buffer_unref(&ctx->device_ref);
|
||||
av_free(ctx);
|
||||
}
|
||||
|
||||
av_buffer_unref(&ist->hw_frames_ctx);
|
||||
|
||||
ist->hwaccel_ctx = NULL;
|
||||
ist->hwaccel_uninit = NULL;
|
||||
ist->hwaccel_get_buffer = NULL;
|
||||
ist->hwaccel_retrieve_data = NULL;
|
||||
}
|
||||
|
||||
int vaapi_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
InputStream *ist = avctx->opaque;
|
||||
VAAPIDecoderContext *ctx;
|
||||
int err;
|
||||
int loglevel = (ist->hwaccel_id != HWACCEL_VAAPI ? AV_LOG_VERBOSE
|
||||
: AV_LOG_ERROR);
|
||||
|
||||
if (ist->hwaccel_ctx)
|
||||
vaapi_decode_uninit(avctx);
|
||||
|
||||
// We have -hwaccel without -vaapi_device, so just initialise here with
|
||||
// the device passed as -hwaccel_device (if -vaapi_device was passed, it
|
||||
// will always have been called before now).
|
||||
if (!hw_device_ctx) {
|
||||
err = vaapi_device_init(ist->hwaccel_device);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
ctx = av_mallocz(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
return AVERROR(ENOMEM);
|
||||
ctx->class = &vaapi_class;
|
||||
ist->hwaccel_ctx = ctx;
|
||||
|
||||
ctx->device_ref = av_buffer_ref(hw_device_ctx);
|
||||
ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
|
||||
|
||||
ctx->output_format = ist->hwaccel_output_format;
|
||||
avctx->pix_fmt = ctx->output_format;
|
||||
|
||||
ctx->frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
|
||||
if (!ctx->frames_ref) {
|
||||
av_log(ctx, loglevel, "Failed to create VAAPI frame context.\n");
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx->frames = (AVHWFramesContext*)ctx->frames_ref->data;
|
||||
|
||||
ctx->frames->format = AV_PIX_FMT_VAAPI;
|
||||
ctx->frames->width = avctx->coded_width;
|
||||
ctx->frames->height = avctx->coded_height;
|
||||
|
||||
// It would be nice if we could query the available formats here,
|
||||
// but unfortunately we don't have a VAConfigID to do it with.
|
||||
// For now, just assume an NV12 format (or P010 if 10-bit).
|
||||
ctx->frames->sw_format = (avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
|
||||
AV_PIX_FMT_P010 : AV_PIX_FMT_NV12);
|
||||
|
||||
// For frame-threaded decoding, at least one additional surface
|
||||
// is needed for each thread.
|
||||
ctx->frames->initial_pool_size = DEFAULT_SURFACES;
|
||||
if (avctx->active_thread_type & FF_THREAD_FRAME)
|
||||
ctx->frames->initial_pool_size += avctx->thread_count;
|
||||
|
||||
err = av_hwframe_ctx_init(ctx->frames_ref);
|
||||
if (err < 0) {
|
||||
av_log(ctx, loglevel, "Failed to initialise VAAPI frame "
|
||||
"context: %d\n", err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ist->hw_frames_ctx = av_buffer_ref(ctx->frames_ref);
|
||||
if (!ist->hw_frames_ctx) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ist->hwaccel_uninit = &vaapi_decode_uninit;
|
||||
ist->hwaccel_get_buffer = &vaapi_get_buffer;
|
||||
ist->hwaccel_retrieve_data = &vaapi_retrieve_data;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
vaapi_decode_uninit(avctx);
|
||||
return err;
|
||||
}
|
||||
|
||||
static AVClass *vaapi_log = &vaapi_class;
|
||||
|
||||
av_cold int vaapi_device_init(const char *device)
|
||||
{
|
||||
int err;
|
||||
|
||||
av_buffer_unref(&hw_device_ctx);
|
||||
|
||||
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
|
||||
device, NULL, 0);
|
||||
if (err < 0) {
|
||||
av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
289
ffmpeg_vdpau.c
289
ffmpeg_vdpau.c
@@ -18,21 +18,49 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <vdpau/vdpau.h>
|
||||
#include <vdpau/vdpau_x11.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "ffmpeg.h"
|
||||
|
||||
#include "libavcodec/vdpau.h"
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/hwcontext_vdpau.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
|
||||
typedef struct VDPAUContext {
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
Display *dpy;
|
||||
|
||||
VdpDevice device;
|
||||
VdpDecoder decoder;
|
||||
VdpGetProcAddress *get_proc_address;
|
||||
|
||||
VdpGetErrorString *get_error_string;
|
||||
VdpGetInformationString *get_information_string;
|
||||
VdpDeviceDestroy *device_destroy;
|
||||
#if 1 // for ffmpegs older vdpau API, not the oldest though
|
||||
VdpDecoderCreate *decoder_create;
|
||||
VdpDecoderDestroy *decoder_destroy;
|
||||
VdpDecoderRender *decoder_render;
|
||||
#endif
|
||||
VdpVideoSurfaceCreate *video_surface_create;
|
||||
VdpVideoSurfaceDestroy *video_surface_destroy;
|
||||
VdpVideoSurfaceGetBitsYCbCr *video_surface_get_bits;
|
||||
VdpVideoSurfaceGetParameters *video_surface_get_parameters;
|
||||
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *video_surface_query;
|
||||
|
||||
AVFrame *tmp_frame;
|
||||
|
||||
enum AVPixelFormat pix_fmt;
|
||||
VdpYCbCrFormat vdpau_format;
|
||||
} VDPAUContext;
|
||||
|
||||
int vdpau_api_ver = 2;
|
||||
|
||||
static void vdpau_uninit(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
@@ -42,54 +70,140 @@ static void vdpau_uninit(AVCodecContext *s)
|
||||
ist->hwaccel_get_buffer = NULL;
|
||||
ist->hwaccel_retrieve_data = NULL;
|
||||
|
||||
av_buffer_unref(&ctx->hw_frames_ctx);
|
||||
if (ctx->decoder_destroy)
|
||||
ctx->decoder_destroy(ctx->decoder);
|
||||
|
||||
if (ctx->device_destroy)
|
||||
ctx->device_destroy(ctx->device);
|
||||
|
||||
if (ctx->dpy)
|
||||
XCloseDisplay(ctx->dpy);
|
||||
|
||||
av_frame_free(&ctx->tmp_frame);
|
||||
|
||||
av_freep(&ist->hwaccel_ctx);
|
||||
av_freep(&s->hwaccel_context);
|
||||
}
|
||||
|
||||
static void vdpau_release_buffer(void *opaque, uint8_t *data)
|
||||
{
|
||||
VdpVideoSurface surface = *(VdpVideoSurface*)data;
|
||||
VDPAUContext *ctx = opaque;
|
||||
|
||||
ctx->video_surface_destroy(surface);
|
||||
av_freep(&data);
|
||||
}
|
||||
|
||||
static int vdpau_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
VDPAUContext *ctx = ist->hwaccel_ctx;
|
||||
VdpVideoSurface *surface;
|
||||
VdpStatus err;
|
||||
VdpChromaType chroma;
|
||||
uint32_t width, height;
|
||||
|
||||
return av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0);
|
||||
av_assert0(frame->format == AV_PIX_FMT_VDPAU);
|
||||
|
||||
if (av_vdpau_get_surface_parameters(s, &chroma, &width, &height))
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
surface = av_malloc(sizeof(*surface));
|
||||
if (!surface)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
frame->buf[0] = av_buffer_create((uint8_t*)surface, sizeof(*surface),
|
||||
vdpau_release_buffer, ctx,
|
||||
AV_BUFFER_FLAG_READONLY);
|
||||
if (!frame->buf[0]) {
|
||||
av_freep(&surface);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
// properly we should keep a pool of surfaces instead of creating
|
||||
// them anew for each frame, but since we don't care about speed
|
||||
// much in this code, we don't bother
|
||||
err = ctx->video_surface_create(ctx->device, chroma, width, height,
|
||||
surface);
|
||||
if (err != VDP_STATUS_OK) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error allocating a VDPAU video surface: %s\n",
|
||||
ctx->get_error_string(err));
|
||||
av_buffer_unref(&frame->buf[0]);
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
frame->data[3] = (uint8_t*)(uintptr_t)*surface;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vdpau_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
{
|
||||
VdpVideoSurface surface = (VdpVideoSurface)(uintptr_t)frame->data[3];
|
||||
InputStream *ist = s->opaque;
|
||||
VDPAUContext *ctx = ist->hwaccel_ctx;
|
||||
int ret;
|
||||
VdpStatus err;
|
||||
int ret, chroma_type;
|
||||
|
||||
ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0);
|
||||
err = ctx->video_surface_get_parameters(surface, &chroma_type,
|
||||
&ctx->tmp_frame->width,
|
||||
&ctx->tmp_frame->height);
|
||||
if (err != VDP_STATUS_OK) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error getting surface parameters: %s\n",
|
||||
ctx->get_error_string(err));
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
ctx->tmp_frame->format = ctx->pix_fmt;
|
||||
|
||||
ret = av_frame_get_buffer(ctx->tmp_frame, 32);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = av_frame_copy_props(ctx->tmp_frame, frame);
|
||||
if (ret < 0) {
|
||||
av_frame_unref(ctx->tmp_frame);
|
||||
return ret;
|
||||
ctx->tmp_frame->width = frame->width;
|
||||
ctx->tmp_frame->height = frame->height;
|
||||
|
||||
err = ctx->video_surface_get_bits(surface, ctx->vdpau_format,
|
||||
(void * const *)ctx->tmp_frame->data,
|
||||
ctx->tmp_frame->linesize);
|
||||
if (err != VDP_STATUS_OK) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error retrieving frame data from VDPAU: %s\n",
|
||||
ctx->get_error_string(err));
|
||||
ret = AVERROR_UNKNOWN;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ctx->vdpau_format == VDP_YCBCR_FORMAT_YV12)
|
||||
FFSWAP(uint8_t*, ctx->tmp_frame->data[1], ctx->tmp_frame->data[2]);
|
||||
|
||||
ret = av_frame_copy_props(ctx->tmp_frame, frame);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
av_frame_unref(frame);
|
||||
av_frame_move_ref(frame, ctx->tmp_frame);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_frame_unref(ctx->tmp_frame);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const int vdpau_formats[][2] = {
|
||||
{ VDP_YCBCR_FORMAT_YV12, AV_PIX_FMT_YUV420P },
|
||||
{ VDP_YCBCR_FORMAT_NV12, AV_PIX_FMT_NV12 },
|
||||
{ VDP_YCBCR_FORMAT_YUYV, AV_PIX_FMT_YUYV422 },
|
||||
{ VDP_YCBCR_FORMAT_UYVY, AV_PIX_FMT_UYVY422 },
|
||||
};
|
||||
|
||||
static int vdpau_alloc(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
|
||||
AVVDPAUContext *vdpau_ctx;
|
||||
VDPAUContext *ctx;
|
||||
int ret;
|
||||
|
||||
AVBufferRef *device_ref = NULL;
|
||||
AVHWDeviceContext *device_ctx;
|
||||
AVVDPAUDeviceContext *device_hwctx;
|
||||
AVHWFramesContext *frames_ctx;
|
||||
const char *display, *vendor;
|
||||
VdpStatus err;
|
||||
int i;
|
||||
|
||||
ctx = av_mallocz(sizeof(*ctx));
|
||||
if (!ctx)
|
||||
@@ -104,48 +218,145 @@ static int vdpau_alloc(AVCodecContext *s)
|
||||
if (!ctx->tmp_frame)
|
||||
goto fail;
|
||||
|
||||
ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VDPAU,
|
||||
ist->hwaccel_device, NULL, 0);
|
||||
if (ret < 0)
|
||||
ctx->dpy = XOpenDisplay(ist->hwaccel_device);
|
||||
if (!ctx->dpy) {
|
||||
av_log(NULL, loglevel, "Cannot open the X11 display %s.\n",
|
||||
XDisplayName(ist->hwaccel_device));
|
||||
goto fail;
|
||||
device_ctx = (AVHWDeviceContext*)device_ref->data;
|
||||
device_hwctx = device_ctx->hwctx;
|
||||
}
|
||||
display = XDisplayString(ctx->dpy);
|
||||
|
||||
ctx->hw_frames_ctx = av_hwframe_ctx_alloc(device_ref);
|
||||
if (!ctx->hw_frames_ctx)
|
||||
err = vdp_device_create_x11(ctx->dpy, XDefaultScreen(ctx->dpy), &ctx->device,
|
||||
&ctx->get_proc_address);
|
||||
if (err != VDP_STATUS_OK) {
|
||||
av_log(NULL, loglevel, "VDPAU device creation on X11 display %s failed.\n",
|
||||
display);
|
||||
goto fail;
|
||||
av_buffer_unref(&device_ref);
|
||||
}
|
||||
|
||||
frames_ctx = (AVHWFramesContext*)ctx->hw_frames_ctx->data;
|
||||
frames_ctx->format = AV_PIX_FMT_VDPAU;
|
||||
frames_ctx->sw_format = s->sw_pix_fmt;
|
||||
frames_ctx->width = s->coded_width;
|
||||
frames_ctx->height = s->coded_height;
|
||||
#define GET_CALLBACK(id, result) \
|
||||
do { \
|
||||
void *tmp; \
|
||||
err = ctx->get_proc_address(ctx->device, id, &tmp); \
|
||||
if (err != VDP_STATUS_OK) { \
|
||||
av_log(NULL, loglevel, "Error getting the " #id " callback.\n"); \
|
||||
goto fail; \
|
||||
} \
|
||||
ctx->result = tmp; \
|
||||
} while (0)
|
||||
|
||||
ret = av_hwframe_ctx_init(ctx->hw_frames_ctx);
|
||||
if (ret < 0)
|
||||
GET_CALLBACK(VDP_FUNC_ID_GET_ERROR_STRING, get_error_string);
|
||||
GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
|
||||
GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, device_destroy);
|
||||
if (vdpau_api_ver == 1) {
|
||||
GET_CALLBACK(VDP_FUNC_ID_DECODER_CREATE, decoder_create);
|
||||
GET_CALLBACK(VDP_FUNC_ID_DECODER_DESTROY, decoder_destroy);
|
||||
GET_CALLBACK(VDP_FUNC_ID_DECODER_RENDER, decoder_render);
|
||||
}
|
||||
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_CREATE, video_surface_create);
|
||||
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, video_surface_destroy);
|
||||
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, video_surface_get_bits);
|
||||
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, video_surface_get_parameters);
|
||||
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
|
||||
video_surface_query);
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(vdpau_formats); i++) {
|
||||
VdpBool supported;
|
||||
err = ctx->video_surface_query(ctx->device, VDP_CHROMA_TYPE_420,
|
||||
vdpau_formats[i][0], &supported);
|
||||
if (err != VDP_STATUS_OK) {
|
||||
av_log(NULL, loglevel,
|
||||
"Error querying VDPAU surface capabilities: %s\n",
|
||||
ctx->get_error_string(err));
|
||||
goto fail;
|
||||
}
|
||||
if (supported)
|
||||
break;
|
||||
}
|
||||
if (i == FF_ARRAY_ELEMS(vdpau_formats)) {
|
||||
av_log(NULL, loglevel,
|
||||
"No supported VDPAU format for retrieving the data.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
ctx->vdpau_format = vdpau_formats[i][0];
|
||||
ctx->pix_fmt = vdpau_formats[i][1];
|
||||
|
||||
if (vdpau_api_ver == 1) {
|
||||
vdpau_ctx = av_vdpau_alloc_context();
|
||||
if (!vdpau_ctx)
|
||||
goto fail;
|
||||
vdpau_ctx->render = ctx->decoder_render;
|
||||
|
||||
s->hwaccel_context = vdpau_ctx;
|
||||
} else
|
||||
if (av_vdpau_bind_context(s, ctx->device, ctx->get_proc_address,
|
||||
AV_HWACCEL_FLAG_IGNORE_LEVEL))
|
||||
goto fail;
|
||||
|
||||
if (av_vdpau_bind_context(s, device_hwctx->device, device_hwctx->get_proc_address, 0))
|
||||
goto fail;
|
||||
|
||||
av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU to decode input stream #%d:%d.\n",
|
||||
ist->file_index, ist->st->index);
|
||||
ctx->get_information_string(&vendor);
|
||||
av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU -- %s -- on X11 display %s, "
|
||||
"to decode input stream #%d:%d.\n", vendor,
|
||||
display, ist->file_index, ist->st->index);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_log(NULL, loglevel, "VDPAU init failed for stream #%d:%d.\n",
|
||||
ist->file_index, ist->st->index);
|
||||
av_buffer_unref(&device_ref);
|
||||
vdpau_uninit(s);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
static int vdpau_old_init(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
|
||||
AVVDPAUContext *vdpau_ctx;
|
||||
VDPAUContext *ctx;
|
||||
VdpStatus err;
|
||||
int profile, ret;
|
||||
|
||||
if (!ist->hwaccel_ctx) {
|
||||
ret = vdpau_alloc(s);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
ctx = ist->hwaccel_ctx;
|
||||
vdpau_ctx = s->hwaccel_context;
|
||||
|
||||
ret = av_vdpau_get_profile(s, &profile);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, loglevel, "No known VDPAU decoder profile for this stream.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if (ctx->decoder)
|
||||
ctx->decoder_destroy(ctx->decoder);
|
||||
|
||||
err = ctx->decoder_create(ctx->device, profile,
|
||||
s->coded_width, s->coded_height,
|
||||
16, &ctx->decoder);
|
||||
if (err != VDP_STATUS_OK) {
|
||||
av_log(NULL, loglevel, "Error creating the VDPAU decoder: %s\n",
|
||||
ctx->get_error_string(err));
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
vdpau_ctx->decoder = ctx->decoder;
|
||||
|
||||
ist->hwaccel_get_buffer = vdpau_get_buffer;
|
||||
ist->hwaccel_retrieve_data = vdpau_retrieve_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vdpau_init(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
|
||||
if (vdpau_api_ver == 1)
|
||||
return vdpau_old_init(s);
|
||||
|
||||
if (!ist->hwaccel_ctx) {
|
||||
int ret = vdpau_alloc(s);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -48,6 +48,7 @@ static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
uint8_t *data[4] = { 0 };
|
||||
int linesize[4] = { 0 };
|
||||
int planes, ret, i;
|
||||
char codec_str[32];
|
||||
|
||||
av_frame_unref(vt->tmp_frame);
|
||||
|
||||
@@ -59,9 +60,9 @@ static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: vt->tmp_frame->format = AV_PIX_FMT_NV12; break;
|
||||
#endif
|
||||
default:
|
||||
av_get_codec_tag_string(codec_str, sizeof(codec_str), s->codec_tag);
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"%s: Unsupported pixel format: %s\n",
|
||||
av_fourcc2str(s->codec_tag), videotoolbox_pixfmt);
|
||||
"%s: Unsupported pixel format: %s\n", codec_str, videotoolbox_pixfmt);
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user