diff --git a/.gitattributes b/.gitattributes index 5a19b963b6..a900528e47 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ *.pnm -diff -text -tests/ref/fate/sub-scc eol=crlf diff --git a/.gitignore b/.gitignore index dabb51762d..1a08fd15c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.a *.o -*.o.* *.d *.def *.dll @@ -19,21 +18,14 @@ *.swp *.ver *.version -*.ptx -*.ptx.c -*_g -\#* -.\#* /.config /.version -/ffmpeg -/ffplay -/ffprobe -/ffserver +/avconv +/avplay +/avprobe +/avversion.h /config.asm /config.h /coverage.info -/avversion.h /lcov/ -/src /mapfile diff --git a/.travis.yml b/.travis.yml index 40f01f94c2..5aa2802636 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,16 +11,20 @@ addons: compiler: - clang - gcc +matrix: + exclude: + - os: osx + compiler: gcc cache: directories: - - ffmpeg-samples + - libav-samples before_install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install nasm; fi script: - - mkdir -p ffmpeg-samples - - ./configure --samples=ffmpeg-samples --cc=$CC + - mkdir -p libav-samples + - ./configure --samples=libav-samples --cc=$CC - make -j 8 - make fate-rsync - make check -j 8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c2b79e4526..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -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. diff --git a/CREDITS b/CREDITS index e29f0b853c..4a537786f0 100644 --- a/CREDITS +++ b/CREDITS @@ -1,6 +1,55 @@ -See the Git history of the project (git://source.ffmpeg.org/ffmpeg) to -get the names of people who have contributed to FFmpeg. +This file contains the names of some of the people who have contributed to +Libav/FFmpeg. The names are sorted alphabetically by last name. As this file is +currently quite outdated and git serves as a much better tool for determining +authorship, it remains here for historical reasons only. -To check the log, you can type the command "git log" in the FFmpeg -source directory, or browse the online repository at -http://source.ffmpeg.org. +Dénes Balatoni +Michel Bardiaux +Fabrice Bellard +Patrice Bensoussan +Alex Beregszaszi +BERO +Thilo Borgmann +Mario Brito +Ronald Bultje +Alex Converse +Maarten Daniels +Reimar Doeffinger +Tim Ferguson +Brian Foley +Arpad Gereoffy +Philip Gladstone +Vladimir Gneushev +Roine Gustafsson +David Hammerton +Wolfgang Hesseler +Marc Hoffman +Falk Hueffner +Aurélien Jacobs +Steven Johnson +Zdenek Kabelac +Robin Kay +Todd Kirby +Nick Kurshev +Benjamin Larsson +Loïc Le Loarer +Daniel Maas +Mike Melanson +Loren Merritt +Jeff Muizelaar +Michael Niedermayer +François Revol +Peter Ross +Måns Rullgård +Stefano Sabatini +Roman Shaposhnik +Oded Shimon +Dieter Shirley +Konstantin Shishkov +Juan J. Sierralta +Ewald Snel +Sascha Sommer +Leon van Stuivenberg +Roberto Togni +Lionel Ulmer +Reynaldo Verdejo diff --git a/Changelog b/Changelog index ca0758aca2..92a72490a9 100644 --- a/Changelog +++ b/Changelog @@ -2,666 +2,231 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version : -- deflicker video filter -- doubleweave video filter -- lumakey video filter -- pixscope video filter -- oscilloscope video filter -- config.log and other configuration files moved into ffbuild/ directory -- update cuvid/nvenc headers to Video Codec SDK 8.0.14 -- afir audio filter -- scale_cuda CUDA based video scale filter -- librsvg support for svg rasterization -- crossfeed audio filter -- spec compliant VP9 muxing support in MP4 -- remove the libnut muxer/demuxer wrappers -- remove the libschroedinger encoder/decoder wrappers -- surround audio filter -- sofalizer filter switched to libmysofa -- Gremlin Digital Video demuxer and decoder -- headphone audio filter -- superequalizer audio filter -- roberts video filter +- Support for spherical videos +- Intel QSV-accelerated VP8 and VC-1 decoding +- VAAPI-accelerated VP8 and HEVC decoding +- VAAPI-accelerated deinterlacing +- config.log and other configuration files moved into avbuild/ directory +- VAAPI-accelerated MPEG-2 and VP8 encoding +- Apple Pixlet decoder - The x86 assembler default switched from yasm to nasm, pass --x86asmexe=yasm to configure to restore the old behavior. -- additional frame format support for Interplay MVE movies -- support for decoding through D3D11VA in ffmpeg -- limiter video filter -- libvmaf video filter -- Dolby E decoder and SMPTE 337M demuxer -- unpremultiply video filter -- tlut2 video filter -- floodfill video filter -- pseudocolor video filter -- raw G.726 muxer and demuxer, left- and right-justified -- NewTek NDI input/output device -- Some video filters with several inputs now use a common set of options: - blend, libvmaf, lut3d, overlay, psnr, ssim. - They must always be used by name. -- FITS demuxer and decoder -- FITS muxer and encoder -- add --disable-autodetect build switch -- drop deprecated qtkit input device (use avfoundation instead) -- despill video filter -- haas audio filter -- SUP/PGS subtitle muxer -- convolve video filter -- VP9 tile threading support - -version 3.3: -- CrystalHD decoder moved to new decode API -- add internal ebur128 library, remove external libebur128 dependency -- Pro-MPEG CoP #3-R2 FEC protocol -- premultiply video filter -- Support for spherical videos -- configure now fails if autodetect-libraries are requested but not found -- PSD Decoder -- 16.8 floating point pcm decoder -- 24.0 floating point pcm decoder -- Apple Pixlet decoder -- QDMC audio decoder -- NewTek SpeedHQ decoder -- MIDI Sample Dump Standard demuxer -- readeia608 filter -- Sample Dump eXchange demuxer -- abitscope multimedia filter -- Scenarist Closed Captions demuxer and muxer -- threshold filter -- midequalizer filter -- Optimal Huffman tables for (M)JPEG encoding -- VAAPI-accelerated MPEG-2 and VP8 encoding -- FM Screen Capture Codec decoder -- native Opus encoder -- ScreenPressor decoder -- incomplete ClearVideo decoder -- Intel QSV video scaling and deinterlacing filters -- Support MOV with multiple sample description tables -- XPM decoder -- Removed the legacy X11 screen grabber, use XCB instead -- MPEG-7 Video Signature filter -- Removed asyncts filter (use af_aresample instead) -- Intel QSV-accelerated VP8 video decoding -- VAAPI-accelerated deinterlacing - - -version 3.2: -- libopenmpt demuxer -- tee protocol -- Changed metadata print option to accept general urls -- Alias muxer for Ogg Video (.ogv) -- VP8 in Ogg muxing -- curves filter doesn't automatically insert points at x=0 and x=1 anymore -- 16-bit support in curves filter and selectivecolor filter -- OpenH264 decoder wrapper -- MediaCodec H.264/HEVC/MPEG-4/VP8/VP9 hwaccel -- True Audio (TTA) muxer -- crystalizer audio filter -- acrusher audio filter -- bitplanenoise video filter -- floating point support in als decoder -- fifo muxer -- maskedclamp filter -- hysteresis filter -- lut2 filter -- yuvtestsrc filter -- CUDA CUVID H.263/VP8/VP9/10 bit HEVC (Dithered) Decoding -- vaguedenoiser filter -- added threads option per filter instance -- weave filter -- gblur filter -- avgblur filter -- sobel and prewitt filter -- MediaCodec HEVC/MPEG-4/VP8/VP9 decoding -- Meridian Lossless Packing (MLP) / TrueHD encoder -- Non-Local Means (nlmeans) denoising filter -- sdl2 output device and ffplay support -- sdl1 output device and sdl1 support removed -- extended mov edit list support -- libfaac encoder removed -- Matroska muxer now writes CRC32 elements by default in all Level 1 elements -- sidedata video and asidedata audio filter -- Changed mapping of rtp MIME type G726 to codec g726le. -- spec compliant VAAPI/DXVA2 VC-1 decoding of slices in frame-coded images - - -version 3.1: -- DXVA2-accelerated HEVC Main10 decoding -- fieldhint filter -- loop video filter and aloop audio filter -- Bob Weaver deinterlacing filter -- firequalizer filter -- datascope filter -- bench and abench filters -- ciescope filter -- protocol blacklisting API -- MediaCodec H264 decoding -- VC-2 HQ RTP payload format (draft v1) depacketizer and packetizer -- VP9 RTP payload format (draft v2) packetizer -- AudioToolbox audio decoders -- AudioToolbox audio encoders -- coreimage filter (GPU based image filtering on OSX) -- libdcadec removed -- bitstream filter for extracting DTS core -- ADPCM IMA DAT4 decoder -- musx demuxer -- aix demuxer -- remap filter -- hash and framehash muxers -- colorspace filter -- hdcd filter -- readvitc filter -- VAAPI-accelerated format conversion and scaling -- libnpp/CUDA-accelerated format conversion and scaling -- Duck TrueMotion 2.0 Real Time decoder -- Wideband Single-bit Data (WSD) demuxer -- VAAPI-accelerated H.264/HEVC/MJPEG encoding -- DTS Express (LBR) decoder -- Generic OpenMAX IL encoder with support for Raspberry Pi -- IFF ANIM demuxer & decoder -- Direct Stream Transfer (DST) decoder -- loudnorm filter -- MTAF demuxer and decoder -- MagicYUV decoder -- OpenExr improvements (tile data and B44/B44A support) -- BitJazz SheerVideo decoder -- CUDA CUVID H264/HEVC decoder -- 10-bit depth support in native utvideo decoder -- libutvideo wrapper removed -- YUY2 Lossless Codec decoder -- VideoToolbox H.264 encoder - - -version 3.0: -- Common Encryption (CENC) MP4 encoding and decoding support -- DXV decoding -- extrastereo filter -- ocr filter -- alimiter filter -- stereowiden filter -- stereotools filter -- rubberband filter -- tremolo filter -- agate filter -- chromakey filter -- maskedmerge filter -- Screenpresso SPV1 decoding -- chromaprint fingerprinting muxer -- ffplay dynamic volume control -- displace filter -- selectivecolor filter -- extensive native AAC encoder improvements and removal of experimental flag -- ADPCM PSX decoder -- 3dostr, dcstr, fsb, genh, vag, xvag, ads, msf, svag & vpk demuxer -- zscale filter -- wve demuxer -- zero-copy Intel QSV transcoding in ffmpeg -- shuffleframes filter -- SDX2 DPCM decoder -- vibrato filter -- innoHeim/Rsupport Screen Capture Codec decoder -- ADPCM AICA decoder -- Interplay ACM demuxer and audio decoder -- XMA1 & XMA2 decoder -- realtime filter -- anoisesrc audio filter source -- IVR demuxer -- compensationdelay filter -- acompressor filter -- support encoding 16-bit RLE SGI images -- apulsator filter -- sidechaingate audio filter -- mipsdspr1 option has been renamed to mipsdsp -- aemphasis filter -- mips32r5 option has been removed -- mips64r6 option has been removed -- DXVA2-accelerated VP9 decoding -- SOFAlizer: virtual binaural acoustics filter -- VAAPI VP9 hwaccel -- audio high-order multiband parametric equalizer -- automatic bitstream filtering -- showspectrumpic filter -- libstagefright support removed -- spectrumsynth filter -- ahistogram filter -- only seek with the right mouse button in ffplay -- toggle full screen when double-clicking with the left mouse button in ffplay -- afftfilt filter -- convolution filter -- libquvi support removed -- support for dvaudio in wav and avi -- libaacplus and libvo-aacenc support removed - Cineform HD decoder -- new DCA decoder with full support for DTS-HD extensions -- significant performance improvements in Windows Television (WTV) demuxer -- nnedi deinterlacer -- streamselect video and astreamselect audio filter -- swaprect filter -- metadata video and ametadata audio filter -- SMPTE VC-2 HQ profile support for the Dirac decoder -- SMPTE VC-2 native encoder supporting the HQ profile +- VP9 superframe split/merge bitstream filters +- FM Screen Capture Codec decoder +- ClearVideo decoder (I-frames only) +- support for decoding through D3D11VA in avconv +- Cinepak encoder +- Intel QSV-accelerated MJPEG encoding +- NVIDIA CUVID-accelerated H.264 and HEVC decoding -version 2.8: -- colorkey video filter -- BFSTM/BCSTM demuxer -- little-endian ADPCM_THP decoder -- Hap decoder and encoder -- DirectDraw Surface image/texture decoder -- ssim filter -- optional new ASF demuxer -- showvolume filter -- Many improvements to the JPEG 2000 decoder -- Go2Meeting decoding support -- adrawgraph audio and drawgraph video filter -- removegrain video filter -- Intel QSV-accelerated MPEG-2 video and HEVC encoding -- Intel QSV-accelerated MPEG-2 video and HEVC decoding -- Intel QSV-accelerated VC-1 video decoding -- libkvazaar HEVC encoder -- erosion, dilation, deflate and inflate video filters -- Dynamic Audio Normalizer as dynaudnorm filter -- Reverse video and areverse audio filter -- Random filter -- deband filter -- AAC fixed-point decoding -- sidechaincompress audio filter -- bitstream filter for converting HEVC from MP4 to Annex B -- acrossfade audio filter -- allyuv and allrgb video sources -- atadenoise video filter -- OS X VideoToolbox support -- aphasemeter filter -- showfreqs filter -- vectorscope filter -- waveform filter -- hstack and vstack filter -- Support DNx100 (1440x1080@8) -- VAAPI hevc hwaccel -- VDPAU hevc hwaccel -- framerate filter -- Switched default encoders for webm to VP9 and Opus -- Removed experimental flag from the JPEG 2000 encoder - - -version 2.7: -- FFT video filter -- TDSC decoder -- DTS lossless extension (XLL) decoding (not lossless, disabled by default) -- showwavespic filter -- DTS decoding through libdcadec -- Drop support for nvenc API before 5.0 -- nvenc HEVC encoder -- Detelecine filter -- Intel QSV-accelerated H.264 encoding -- MMAL-accelerated H.264 decoding -- basic APNG encoder and muxer with default extension "apng" -- unpack DivX-style packed B-frames in MPEG-4 bitstream filter -- WebM Live Chunk Muxer -- nvenc level and tier options -- chorus filter -- Canopus HQ/HQA decoder -- Automatically rotate videos based on metadata in ffmpeg -- improved Quickdraw compatibility -- VP9 high bit-depth and extended colorspaces decoding support -- WebPAnimEncoder API when available for encoding and muxing WebP -- Direct3D11-accelerated decoding -- Support Secure Transport -- Multipart JPEG demuxer - - -version 2.6: -- nvenc encoder -- 10bit spp filter -- colorlevels filter -- RIFX format for *.wav files +version 12: +- aliases and defaults for Ogg subtypes (opus, spx) +- HEVC/H.265 RTP payload format (draft v6) packetizer and depacketizer +- avplay now exits by default at the end of playback +- XCB-based screen-grabber +- creating DASH compatible fragmented MP4, MPEG-DASH segmenting muxer +- H.261 RTP payload format (RFC 4587) depacketizer and experimental packetizer - RTP/mpegts muxer -- non continuous cache protocol support -- tblend filter -- cropdetect support for non 8bpp, absolute (if limit >= 1) and relative (if limit < 1.0) threshold -- Camellia symmetric block cipher +- VP8 in Ogg demuxing - OpenH264 encoder wrapper -- VOC seeking support -- Closed caption Decoder -- fspp, uspp, pp7 MPlayer postprocessing filters ported to native filters -- showpalette filter -- Twofish symmetric block cipher - Support DNx100 (960x720@8) -- eq2 filter ported from libmpcodecs as eq filter -- removed libmpcodecs -- Changed default DNxHD colour range in QuickTime .mov derivatives to mpeg range -- ported softpulldown filter from libmpcodecs as repeatfields filter -- dcshift filter -- RTP depacketizer for loss tolerant payload format for MP3 audio (RFC 5219) -- RTP depacketizer for AC3 payload format (RFC 4184) -- palettegen and paletteuse filters -- VP9 RTP payload format (draft 0) experimental depacketizer -- RTP depacketizer for DV (RFC 6469) +- Direct3D11-accelerated decoding - DXVA2-accelerated HEVC decoding - AAC ELD 480 decoding - Intel QSV-accelerated H.264 decoding - DSS SP decoder and DSS demuxer -- Fix stsd atom corruption in DNxHD QuickTimes +- RTP depacketizer for AC3 payload format (RFC 4184) +- RTP depacketizer for loss tolerant payload format for MP3 audio (RFC 5219) +- RTP depacketizer for DV (RFC 6469) - Canopus HQX decoder - RTP depacketization of T.140 text (RFC 4103) -- Port MIPS optimizations to 64-bit +- VP9 RTP payload format (draft 0) experimental depacketizer +- TDSC decoder +- DTS lossless extension (XLL) decoding (not lossless, disabled by default) +- Intel QSV-accelerated H.264 encoding +- MMAL-accelerated H.264 decoding +- DTS decoding through libdcadec +- Canopus HQ/HQA decoder +- Automatically rotate videos based on metadata in avconv +- improved Quickdraw compatibility +- NVIDIA NVENC-accelerated H.264 and HEVC encoding support +- Multipart JPEG demuxer +- Support the extended vp9 profiles in the libvpx wrapper +- Hap decoder and encoder +- DirectDraw Surface image/texture decoder +- rewritten ASF demuxer +- Go2Meeting decoding support +- Intel QSV-accelerated MPEG-2 video and HEVC encoding +- bitstream filter for converting HEVC from MP4 to Annex B +- Intel QSV-accelerated MPEG-2 video and HEVC decoding +- Support DNx100 (1440x1080@8) +- DXV decoding +- Screenpresso SPV1 decoding +- zero-copy Intel QSV transcoding in avconv +- libkvazaar HEVC encoder +- innoHeim/Rsupport Screen Capture Codec decoder +- support encoding 16-bit RLE SGI images +- support Apple AVFoundation video capture +- G.723.1 muxer and encoder +- compressed SWF +- VAAPI-accelerated format conversion and scaling +- libnpp/CUDA-accelerated format conversion and scaling +- VAAPI-accelerate H.264/HEVC/MJPEG encoding +- Generic OpenMAX IL encoder with support for Raspberry Pi +- MMAL-accelerated MPEG-2 and VC-1 decoding +- G.729 raw demuxer +- MagicYUV decoder +- Duck TrueMotion 2.0 Real Time decoder +- Intel QSV video scaling and deinterlacing filter +- Support MOV with multiple sample description tables +- OpenH264 decoder wrapper +- Removed the legacy X11 screen grabber, use XCB instead +- HDCD decoding filter through libhdcd -version 2.5: -- HEVC/H.265 RTP payload format (draft v6) packetizer -- SUP/PGS subtitle demuxer -- ffprobe -show_pixel_formats option -- CAST128 symmetric block cipher, ECB mode -- STL subtitle demuxer and decoder -- libutvideo YUV 4:2:2 10bit support -- XCB-based screen-grabber -- UDP-Lite support (RFC 3828) -- xBR scaling filter -- AVFoundation screen capturing support -- ffserver supports codec private options -- creating DASH compatible fragmented MP4, MPEG-DASH segmenting muxer -- WebP muxer with animated WebP support -- zygoaudio decoding support -- APNG demuxer -- postproc visualization support - - -version 2.4: -- Icecast protocol -- ported lenscorrection filter from frei0r filter -- large optimizations in dctdnoiz to make it usable -- ICY metadata are now requested by default with the HTTP protocol -- support for using metadata in stream specifiers in fftools -- LZMA compression support in TIFF decoder -- H.261 RTP payload format (RFC 4587) depacketizer and experimental packetizer -- HEVC/H.265 RTP payload format (draft v6) depacketizer -- added codecview filter to visualize information exported by some codecs -- Matroska 3D support thorugh side data -- HTML generation using texi2html is deprecated in favor of makeinfo/texi2any -- silenceremove filter - - -version 2.3: -- AC3 fixed-point decoding +version 11: +- libx265 encoder - shuffleplanes filter -- subfile protocol -- Phantom Cine demuxer - replaygain data export -- VP7 video decoder - Alias PIX image encoder and decoder -- Improvements to the BRender PIX image decoder -- Improvements to the XBM decoder -- QTKit input device -- improvements to OpenEXR image decoder +- BRender PIX image decoder +- Amazing Studio PAF playback support +- XBM decoder +- BMP standalone parser +- OpenEXR image decoder +- support encoding and decoding 4-channel SGI images - support decoding 16-bit RLE SGI images -- GDI screen grabbing for Windows -- alternative rendition support for HTTP Live Streaming -- AVFoundation input device -- Direct Stream Digital (DSD) decoder -- Magic Lantern Video (MLV) demuxer +- VP7 video decoder +- LucasArts SMUSH SANM video decoder +- LucasArts SMUSH VIMA audio decoder (ADPCM) +- LucasArts SMUSH demuxer +- MP2 encoding via TwoLAME +- asettb filter +- Silicon Graphics RLE 8-bit video decoder +- Silicon Graphics Motion Video Compressor 1 & 2 decoder +- Silicon Graphics Movie demuxer - On2 AVC (Audio for Video) decoder -- support for decoding through DXVA2 in ffmpeg +- support for decoding through DXVA2 in avconv - libbs2b-based stereo-to-binaural audio filter -- libx264 reference frames count limiting depending on level - native Opus decoder - display matrix export and rotation API -- WebVTT encoder -- showcqt multimedia filter -- zoompan filter -- signalstats filter -- hqx filter (hq2x, hq3x, hq4x) -- flanger filter -- Image format auto-detection -- LRC demuxer and muxer -- Samba protocol (via libsmbclient) -- WebM DASH Manifest muxer -- libfribidi support in drawtext +- drop avserver, it was unmaintained for years and largely broken +- Icecast protocol +- request Icecast metadata by default +- support for using metadata in stream specifiers in avtools +- Matroska 3D support -version 2.2: - -- HNM version 4 demuxer and video decoder -- Live HDS muxer -- setsar/setdar filters now support variables in ratio expressions -- elbg filter -- string validation in ffprobe -- support for decoding through VDPAU in ffmpeg (the -hwaccel option) -- complete Voxware MetaSound decoder -- remove mp3_header_compress bitstream filter -- Windows resource files for shared libraries -- aeval filter -- stereoscopic 3d metadata handling -- WebP encoding via libwebp -- ATRAC3+ decoder -- VP8 in Ogg demuxing -- side & metadata support in NUT -- framepack filter -- XYZ12 rawvideo support in NUT -- Exif metadata support in WebP decoder -- OpenGL device -- Use metadata_header_padding to control padding in ID3 tags (currently used in - MP3, AIFF, and OMA files), FLAC header, and the AVI "junk" block. -- Mirillis FIC video decoder -- Support DNx444 -- libx265 encoder -- dejudder filter -- Autodetect VDA like all other hardware accelerations -- aliases and defaults for Ogg subtypes (opus, spx) - - -version 2.1: - -- aecho filter -- perspective filter ported from libmpcodecs -- ffprobe -show_programs option -- compand filter +version 10: +- av_strnstr +- support ID3v2 tags in ASF files +- reference-counting for AVFrame and AVPacket data +- avconv now fails when input options are used for output file + or vice versa +- avconv options -filter_script and -filter_complex_script, which allow a + filtergraph description to be read from a file +- uniform options syntax across all filters +- interlace filter +- JPEG 2000 decoder +- asetpts filter (same as setpts, but for audio) +- trim and atrim filters +- avconv -t and -ss (output-only) options are now sample-accurate when + transcoding audio +- Matroska muxer can now put the index at the beginning of the file. +- avconv -deinterlace option removed, the yadif filter should be used instead +- Apple Intermediate Codec decoder +- Escape 130 video decoder +- support for slice multithreading in libavfilter +- VC-1 interlaced B-frame support +- support for WavPack muxing (raw and in Matroska) +- Go2Webinar decoder +- WavPack encoding through libwavpack +- Added the -n parameter to avconv - RTMP seek support -- when transcoding with ffmpeg (i.e. not streamcopying), -ss is now accurate +- when transcoding with avconv (i.e. not streamcopying), -ss is now accurate even when used as an input option. Previous behavior can be restored with the -noaccurate_seek option. -- ffmpeg -t option can now be used for inputs, to limit the duration of +- avconv -t option can now be used for inputs, to limit the duration of data read from an input file -- incomplete Voxware MetaSound decoder -- read EXIF metadata from JPEG -- DVB teletext decoder -- phase filter ported from libmpcodecs -- w3fdif filter -- Opus support in Matroska -- FFV1 version 1.3 is stable and no longer experimental -- FFV1: YUVA(444,422,420) 9, 10 and 16 bit support -- changed DTS stream id in lavf mpeg ps muxer from 0x8a to 0x88, to be - more consistent with other muxers. -- adelay filter -- pullup filter ported from libmpcodecs -- ffprobe -read_intervals option -- Lossless and alpha support for WebP decoder +- Voxware MetaSound decoder +- WebP decoder - Error Resilient AAC syntax (ER AAC LC) decoding - Low Delay AAC (ER AAC LD) decoding - mux chapters in ASF files -- SFTP protocol (via libssh) -- libx264: add ability to encode in YUVJ422P and YUVJ444P -- Fraps: use BT.709 colorspace by default for yuv, as reference fraps decoder does -- make decoding alpha optional for prores, ffv1 and vp6 by setting - the skip_alpha flag. -- ladspa wrapper filter -- native VP9 decoder -- dpx parser -- max_error_rate parameter in ffmpeg -- PulseAudio output device -- ReplayGain scanner +- Opus in Ogg demuxing - Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support) -- Linux framebuffer output device +- F4V muxer +- HNM version 4 demuxer and video decoder - HEVC decoder - raw HEVC, HEVC in MOV/MP4, HEVC in Matroska, HEVC in MPEG-TS demuxing -- mergeplanes filter +- remove avplay -vismv option, which has not worked for a long time +- Live HDS muxer +- setsar/setdar filters now support variables in ratio expressions +- dar variable in the scale filter now returns the actual DAR (i.e. a * sar) +- VP9 decoder +- support for decoding through VDPAU in avconv (the -hwaccel option) +- remove mp3_header_(de)compress bitstream filters +- stereoscopic 3d metadata handling +- png standalone parser +- WebP encoding via libwebp +- ATRAC3+ decoder +- framepack filter +- Mirillis FIC video decoder +- Support DNx444 +- compand audio filter -version 2.0: - -- curves filter -- reference-counting for AVFrame and AVPacket data -- ffmpeg now fails when input options are used for output file - or vice versa -- support for Monkey's Audio versions from 3.93 -- perms and aperms filters -- audio filtering support in ffplay -- 10% faster aac encoding on x86 and MIPS -- sine audio filter source -- WebP demuxing and decoding support -- ffmpeg options -filter_script and -filter_complex_script, which allow a - filtergraph description to be read from a file -- OpenCL support -- audio phaser filter -- separatefields filter -- libquvi demuxer -- uniform options syntax across all filters -- telecine filter -- interlace filter -- smptehdbars source -- inverse telecine filters (fieldmatch and decimate) -- colorbalance filter -- colorchannelmixer filter -- The matroska demuxer can now output proper verbatim ASS packets. It will - become the default at the next libavformat major bump. -- decent native animated GIF encoding -- asetrate filter -- interleave filter -- timeline editing with filters -- vidstabdetect and vidstabtransform filters for video stabilization using - the vid.stab library -- astats filter -- trim and atrim filters -- ffmpeg -t and -ss (output-only) options are now sample-accurate when - transcoding audio -- Matroska muxer can now put the index at the beginning of the file. -- extractplanes filter -- avectorscope filter -- ADPCM DTK decoder -- ADP demuxer -- RSD demuxer -- RedSpark demuxer -- ADPCM IMA Radical decoder -- zmq filters -- DCT denoiser filter (dctdnoiz) -- Wavelet denoiser filter ported from libmpcodecs as owdenoise (formerly "ow") -- Apple Intermediate Codec decoder -- Escape 130 video decoder -- FTP protocol support -- V4L2 output device -- 3D LUT filter (lut3d) -- SMPTE 302M audio encoder -- support for slice multithreading in libavfilter -- Hald CLUT support (generation and filtering) -- VC-1 interlaced B-frame support -- support for WavPack muxing (raw and in Matroska) -- XVideo output device -- vignette filter -- True Audio (TTA) encoder -- Go2Webinar decoder -- mcdeint filter ported from libmpcodecs -- sab filter ported from libmpcodecs -- ffprobe -show_chapters option -- WavPack encoding through libwavpack -- rotate filter -- spp filter ported from libmpcodecs -- libgme support -- psnr filter - - -version 1.2: - +version 9: +- av_basename and av_dirname +- adobe and limelight publisher authentication in RTMP - VDPAU hardware acceleration through normal hwaccel - SRTP support -- Error diffusion dither in Swscale -- Chained Ogg support -- Theora Midstream reconfiguration support -- EVRC decoder -- audio fade filter -- filtering audio with unknown channel layout -- allpass, bass, bandpass, bandreject, biquad, equalizer, highpass, lowpass - and treble audio filter -- improved showspectrum filter, with multichannel support and sox-like colors -- histogram filter -- tee muxer -- il filter ported from libmpcodecs -- support ID3v2 tags in ASF files -- encrypted TTA stream decoding support -- RF64 support in WAV muxer -- noise filter ported from libmpcodecs -- Subtitles character encoding conversion -- blend filter -- stereo3d filter ported from libmpcodecs -version 1.1: - -- stream disposition information printing in ffprobe -- filter for loudness analysis following EBU R128 -- Opus encoder using libopus -- ffprobe -select_streams option -- Pinnacle TARGA CineWave YUV16 decoder -- TAK demuxer, decoder and parser -- DTS-HD demuxer -- remove -same_quant, it hasn't worked for years -- FFM2 support -- X-Face image encoder and decoder +version 9_beta3: +- ashowinfo audio filter - 24-bit FLAC encoding +- audio volume filter +- deprecated the avconv -vol option. the volume filter is to be used instead. - multi-channel ALAC encoding up to 7.1 +- TAK demuxer, parser, and decoder +- adaptive frame-level multithreading for H.264 + + +version 9_beta2: - metadata (INFO tag) support in WAV muxer -- subtitles raw text decoder - support for building DLLs using MSVC -- LVF demuxer -- ffescape tool -- metadata (info chunk) support in CAF muxer -- field filter ported from libmpcodecs -- AVR demuxer -- geq filter ported from libmpcodecs -- remove ffserver daemon mode -- AST muxer/demuxer -- new expansion syntax for drawtext -- BRender PIX image decoder -- ffprobe -show_entries option -- ffprobe -sections option -- ADPCM IMA Dialogic decoder -- BRSTM demuxer -- animated GIF decoder and demuxer -- PVF demuxer -- subtitles filter -- IRCAM muxer/demuxer -- Paris Audio File demuxer -- Virtual concatenation demuxer -- VobSub demuxer -- JSON captions for TED talks decoding support -- SOX Resampler support in libswresample -- aselect filter -- SGI RLE 8-bit / Silicon Graphics RLE 8-bit video decoder -- Silicon Graphics Motion Video Compressor 1 & 2 decoder -- Silicon Graphics Movie demuxer -- apad filter -- Resolution & pixel format change support with multithreading for H.264 -- documentation split into per-component manuals -- pp (postproc) filter ported from MPlayer -- NIST Sphere demuxer -- MPL2, VPlayer, MPlayer, AQTitle, PJS and SubViewer v1 subtitles demuxers and decoders -- Sony Wave64 muxer -- adobe and limelight publisher authentication in RTMP -- data: URI scheme +- remove avserver daemon mode - support building on the Plan 9 operating system -- kerndeint filter ported from MPlayer -- histeq filter ported from VirtualDub -- Megalux Frame demuxer -- 012v decoder -- Improved AVC Intra decoding support +- ffv1: support version 1.3 -version 1.0: +version 9_beta1: -- INI and flat output in ffprobe -- Scene detection in libavfilter +- XWD encoder and decoder +- Support for fragmentation in the mov/mp4 muxer +- ISMV (Smooth Streaming) muxer +- CDXL demuxer and decoder +- Apple ProRes encoder +- Sun Rasterfile Encoder +- remove libpostproc +- ID3v2 attached pictures reading and writing +- WMA Lossless decoder +- XBM encoder +- RealAudio Lossless decoder +- ZeroCodec decoder +- drop support for avconv without libavfilter +- add libavresample audio conversion library +- audio filters support in libavfilter and avconv +- add fps filter +- audio split filter +- audio mix filter +- avprobe output is now standard INI or JSON. The old format can still + be used with -of old. - Indeo Audio decoder - channelsplit audio filter -- setnsamples audio filter -- atempo filter -- ffprobe -show_data option - RTMPT protocol support - iLBC encoding/decoding via libilbc - Microsoft Screen 1 decoder @@ -674,146 +239,44 @@ version 1.0: - Microsoft Expression Encoder Screen decoder - RTMPS protocol support - RTMPTS protocol support +- JPEG 2000 encoding support through OpenJPEG +- G.723.1 demuxer and decoder - RTMPE protocol support - RTMPTE protocol support -- showwaves and showspectrum filter -- LucasArts SMUSH SANM playback support -- LucasArts SMUSH VIMA audio decoder (ADPCM) -- LucasArts SMUSH demuxer -- SAMI, RealText and SubViewer demuxers and decoders -- Heart Of Darkness PAF playback support -- iec61883 device -- asettb filter -- new option: -progress -- 3GPP Timed Text encoder/decoder -- GeoTIFF decoder support -- ffmpeg -(no)stdin option -- Opus decoder using libopus -- caca output device using libcaca -- alphaextract and alphamerge filters -- concat filter -- flite filter - Canopus Lossless Codec decoder -- bitmap subtitles in filters (experimental and temporary) -- MP2 encoding via TwoLAME -- bmp parser -- smptebars source -- asetpts filter -- hue filter -- ICO muxer -- SubRip encoder and decoder without embedded timing -- edge detection filter -- framestep filter -- ffmpeg -shortest option is now per-output file +- avconv -shortest option is now per-output file, -pass and -passlogfile are now per-output stream -- volume measurement filter - Ut Video encoder - Microsoft Screen 2 decoder -- smartblur filter ported from MPlayer -- CPiA decoder -- decimate filter ported from MPlayer - RTP depacketization of JPEG - Smooth Streaming live segmenter muxer -- F4V muxer -- sendcmd and asendcmd filters -- WebVTT demuxer and decoder (simple tags supported) - RTP packetization of JPEG -- faststart option in the MOV/MP4 muxer +- Opus decoder and encoder using libopus +- remove -same_quant, it hasn't worked for years - support for building with MSVC -version 0.11: +version 0.8: -- Fixes: CVE-2012-2772, CVE-2012-2774, CVE-2012-2775, CVE-2012-2776, CVE-2012-2777, - CVE-2012-2779, CVE-2012-2782, CVE-2012-2783, CVE-2012-2784, CVE-2012-2785, - CVE-2012-2786, CVE-2012-2787, CVE-2012-2788, CVE-2012-2789, CVE-2012-2790, - CVE-2012-2791, CVE-2012-2792, CVE-2012-2793, CVE-2012-2794, CVE-2012-2795, - CVE-2012-2796, CVE-2012-2797, CVE-2012-2798, CVE-2012-2799, CVE-2012-2800, - CVE-2012-2801, CVE-2012-2802, CVE-2012-2803, CVE-2012-2804, -- v408 Quicktime and Microsoft AYUV Uncompressed 4:4:4:4 encoder and decoder -- setfield filter -- CDXL demuxer and decoder -- Apple ProRes encoder -- ffprobe -count_packets and -count_frames options -- Sun Rasterfile Encoder -- ID3v2 attached pictures reading and writing -- WMA Lossless decoder -- bluray protocol -- blackdetect filter -- libutvideo encoder wrapper (--enable-libutvideo) -- swapuv filter -- bbox filter -- XBM encoder and decoder -- RealAudio Lossless decoder -- ZeroCodec decoder -- tile video filter -- Metal Gear Solid: The Twin Snakes demuxer -- OpenEXR image decoder -- removelogo filter -- drop support for ffmpeg without libavfilter -- drawtext video filter: fontconfig support -- ffmpeg -benchmark_all option -- super2xsai filter ported from libmpcodecs -- add libavresample audio conversion library for compatibility -- MicroDVD decoder -- Avid Meridien (AVUI) encoder and decoder -- accept + prefix to -pix_fmt option to disable automatic conversions. -- complete audio filtering in libavfilter and ffmpeg -- add fps filter -- vorbis parser -- png parser -- audio mix filter -- ffv1: support (draft) version 1.3 - - -version 0.10: - -- Fixes: CVE-2011-3929, CVE-2011-3934, CVE-2011-3935, CVE-2011-3936, - CVE-2011-3937, CVE-2011-3940, CVE-2011-3941, CVE-2011-3944, - CVE-2011-3945, CVE-2011-3946, CVE-2011-3947, CVE-2011-3949, - CVE-2011-3950, CVE-2011-3951, CVE-2011-3952 -- v410 Quicktime Uncompressed 4:4:4 10-bit encoder and decoder -- SBaGen (SBG) binaural beats script demuxer -- OpenMG Audio muxer -- Timecode extraction in DV and MOV -- thumbnail video filter -- XML output in ffprobe -- asplit audio filter -- tinterlace video filter -- astreamsync audio filter -- amerge audio filter -- ISMV (Smooth Streaming) muxer - GSM audio parser - SMJPEG muxer -- XWD encoder and decoder + + +version 0.8_beta2: + - Automatic thread count based on detection number of (available) CPU cores -- y41p Brooktree Uncompressed 4:1:1 12-bit encoder and decoder -- ffprobe -show_error option -- Avid 1:1 10-bit RGB Packer codec -- v308 Quicktime Uncompressed 4:4:4 encoder and decoder -- yuv4 libquicktime packed 4:2:0 encoder and decoder -- ffprobe -show_frames option -- silencedetect audio filter -- ffprobe -show_program_version, -show_library_versions, -show_versions options +- Deprecate libpostproc. If desired, the switch --enable-postproc will + enable it but it may be removed in a later Libav release. - rv34: frame-level multi-threading - optimized iMDCT transform on x86 using SSE for for mpegaudiodec -- Improved PGS subtitle decoder -- dumpgraph option to lavfi device -- r210 and r10k encoders -- ffwavesynth decoder -- aviocat tool -- ffeval tool -- support encoding and decoding 4-channel SGI images -version 0.9: +version 0.8_beta1: -- openal input device added -- boxblur filter added - BWF muxer - Flash Screen Video 2 decoder -- lavfi input device added -- added avconv, which is almost the same for now, except +- ffplay/ffprobe/ffserver renamed to avplay/avprobe/avserver +- ffmpeg deprecated, added avconv, which is almost the same for now, except for a few incompatible changes in the options, which will hopefully make them easier to use. The changes are: * The options placement is now strictly enforced! While in theory the @@ -852,7 +315,7 @@ easier to use. The changes are: all the stream in the first input file, except for the second audio stream'. * There is a new option -c (or -codec) for choosing the decoder/encoder to - use, which makes it possible to precisely specify target stream(s) consistently with + use, which allows to precisely specify target stream(s) consistently with other options. E.g. -c:v lib264 sets the codec for all video streams, -c:a:0 libvorbis sets the codec for the first audio stream and -c copy copies all the streams without reencoding. Old -vcodec/-acodec/-scodec options are now @@ -883,40 +346,23 @@ easier to use. The changes are: * -vframes/-aframes/-dframes options are now aliases to the new -frames option. * -vtag/-atag/-stag options are now aliases to the new -tag option. - XMV demuxer -- LOAS demuxer -- ashowinfo filter added - Windows Media Image decoder -- amovie source added - LATM muxer/demuxer -- Speex encoder via libspeex -- JSON output in ffprobe -- WTV muxer -- Optional C++ Support (needed for libstagefright) -- H.264 Decoding on Android via Stagefright -- Prores decoder -- BIN/XBIN/ADF/IDF text file decoder -- aconvert audio filter added -- audio support to lavfi input device added +- showinfo filter +- split filter - libcdio-paranoia input device for audio CD grabbing +- select filter - Apple ProRes decoder - CELT in Ogg demuxing -- G.723.1 demuxer and decoder -- libmodplug support (--enable-libmodplug) - VC-1 interlaced decoding -- libutvideo wrapper (--enable-libutvideo) -- aevalsrc audio source added +- lut, lutrgb, and lutyuv filters +- boxblur filter - Ut Video decoder - Speex encoding via libspeex - 4:2:2 H.264 decoding support - 4:2:2 and 4:4:4 H.264 encoding with libx264 - Pulseaudio input device -- Prores encoder -- Video Decoder Acceleration (VDA) HWAccel module. - replacement Indeo 3 decoder -- new ffmpeg option: -map_channel -- volume audio filter added -- earwax audio filter added -- libv4l2 support (--enable-libv4l2) - TLS/SSL and HTTPS protocol support - AVOptions API rewritten and documented - most of CODEC_FLAG2_*, some CODEC_FLAG_* and many codec-specific fields in @@ -926,27 +372,44 @@ easier to use. The changes are: - Discworld II BMV decoding support - VBLE Decoder - OS X Video Decoder Acceleration (VDA) support -- compact and csv output in ffprobe -- pan audio filter -- IFF Amiga Continuous Bitmap (ACBM) decoder -- ass filter - CRI ADX audio format muxer and demuxer - Playstation Portable PMP format demuxer -- Microsoft Windows ICO demuxer -- life source - PCM format support in OMA demuxer - CLJR encoder -- new option: -report - Dxtory capture format decoder -- cellauto source +- v410 QuickTime uncompressed 4:4:4 10-bit encoder and decoder +- OpenMG Audio muxer - Simple segmenting muxer - Indeo 4 decoder - SMJPEG demuxer -version 0.8: +version 0.7: + +- E-AC-3 audio encoder +- ac3enc: add channel coupling support +- floating-point sample format support for (E-)AC-3, DCA, AAC, Vorbis decoders +- H.264/MPEG frame-level multithreading +- av_metadata_* functions renamed to av_dict_* and moved to libavutil +- 4:4:4 H.264 decoding support +- 10-bit H.264 optimizations for x86 +- bump libswscale for recently reported ABI break + + +version 0.7_beta2: + +- VP8 frame-level multithreading +- NEON optimizations for VP8 +- removed a lot of deprecated API cruft +- FFT and IMDCT optimizations for AVX (Sandy Bridge) processors +- DPX image encoder +- SMPTE 302M AES3 audio decoder +- ffmpeg no longer quits after the 'q' key is pressed; use 'ctrl+c' instead +- 9 bits and 10 bits per sample support in the H.264 decoder + + +version 0.7_beta1: -- many many things we forgot because we rather write code than changelogs - WebM support in Matroska de/muxer - low overhead Ogg muxing - MMS-TCP support @@ -954,7 +417,6 @@ version 0.8: - Demuxer for On2's IVF format - Pictor/PC Paint decoder - HE-AAC v2 decoder -- HE-AAC v2 encoding with libaacplus - libfaad2 wrapper removed - DTS-ES extension (XCh) decoding support - native VP8 decoder @@ -966,7 +428,6 @@ version 0.8: - RTP depacketization of QDM2 - ANSI/ASCII art playback system - Lego Mindstorms RSO de/muxer -- libavcore added (and subsequently removed) - SubRip subtitle file muxer and demuxer - Chinese AVS encoding via libxavs - ffprobe -show_packets option added @@ -1013,7 +474,7 @@ version 0.8: - replace the ocv_smooth filter with a more generic ocv filter - Windows Televison (WTV) demuxer - FFmpeg metadata format muxer and demuxer -- SubRip (srt) subtitle encoder and decoder +- SubRip (srt) subtitle decoder - floating-point AC-3 encoder added - Lagarith decoder - ffmpeg -copytb option added @@ -1026,46 +487,11 @@ version 0.8: - sndio support for playback and record - Linux framebuffer input device added - Chronomaster DFA decoder -- DPX image encoder -- MicroDVD subtitle file muxer and demuxer -- Playstation Portable PMP format demuxer -- fieldorder video filter added +- Mobotix MxPEG decoder - AAC encoding via libvo-aacenc - AMR-WB encoding via libvo-amrwbenc - xWMA demuxer -- Mobotix MxPEG decoder -- VP8 frame-multithreading -- NEON optimizations for VP8 -- Lots of deprecated API cruft removed -- fft and imdct optimizations for AVX (Sandy Bridge) processors -- 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 -- split filter added -- select filter added -- sdl output device added -- libmpcodecs video filter support (3 times as many filters than before) -- mpeg2 aspect ratio dection fixed -- libxvid aspect pickiness fixed -- Frame multithreaded decoding -- E-AC-3 audio encoder -- ac3enc: add channel coupling support -- floating-point sample format support to the ac3, eac3, dca, aac, and vorbis decoders. -- H264/MPEG frame-level multi-threading -- All av_metadata_* functions renamed to av_dict_* and moved to libavutil -- 4:4:4 H.264 decoding support -- 10-bit H.264 optimizations for x86 -- lut, lutrgb, and lutyuv filters added -- buffersink libavfilter sink added -- Bump libswscale for recently reported ABI break -- New J2K encoder (via OpenJPEG) - - -version 0.7: - -- all the changes for 0.8, but keeping API/ABI compatibility with the 0.6 release +- fieldorder video filter added version 0.6: @@ -1306,7 +732,6 @@ version 0.5: - Gopher client support - MXF D-10 muxer - generic metadata API -- flash ScreenVideo2 encoder version 0.4.9-pre1: @@ -1509,7 +934,7 @@ version 0.4.5: - MPEG-4 vol header fixes (Jonathan Marsden ) - ARM optimizations (Lionel Ulmer ). - Windows porting of file converter -- added MJPEG raw format (input/output) +- added MJPEG raw format (input/ouput) - added JPEG image format support (input/output) diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000000..ac5dc5dbb6 --- /dev/null +++ b/INSTALL @@ -0,0 +1,18 @@ + +1) Type './configure' to create the configuration. A list of configure +options is printed by running 'configure --help'. + +'configure' can be launched from a directory different from the Libav +sources to build the objects out of tree. To do this, use an absolute +path when launching 'configure', e.g. '/libavdir/libav/configure'. + +2) Then type 'make' to build Libav. GNU Make 3.81 or later is required. + +3) Type 'make install' to install all binaries and libraries you built. + +NOTICE + + - Non system dependencies (e.g. libx264, libvpx) are disabled by default. + + - The default cflags include -g, if you want lean libraries you can either + pass --disable-debug or strip the debug symbols at a later time. diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index 5db912231c..0000000000 --- a/INSTALL.md +++ /dev/null @@ -1,17 +0,0 @@ -#Installing FFmpeg: - -1. Type `./configure` to create the configuration. A list of configure -options is printed by running `configure --help`. - - `configure` can be launched from a directory different from the FFmpeg -sources to build the objects out of tree. To do this, use an absolute -path when launching `configure`, e.g. `/ffmpegdir/ffmpeg/configure`. - -2. Then type `make` to build FFmpeg. GNU Make 3.81 or later is required. - -3. Type `make install` to install all binaries and libraries you built. - -NOTICE ------- - - - Non system dependencies (e.g. libx264, libvpx) are disabled by default. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..a2de35cf63 --- /dev/null +++ b/LICENSE @@ -0,0 +1,65 @@ +Libav: +====== + +Most files in Libav are under the GNU Lesser General Public License version 2.1 +or later (LGPL v2.1+). Read the file COPYING.LGPLv2.1 for details. Some other +files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to +Libav. + +Some optional parts of Libav are licensed under the GNU General Public License +version 2 or later (GPL v2+). See the file COPYING.GPLv2 for details. None of +these parts are used by default, you have to explicitly pass --enable-gpl to +configure to activate them. In this case, Libav's license changes to GPL v2+. + +Specifically, the GPL parts of Libav are + +- the texi2pod.pl tool +- the following filters in libavfilter: + - vf_blackframe.c + - vf_boxblur.c + - vf_cropdetect.c + - vf_delogo.c + - vf_hqdn3d.c + - vf_interlace.c + +Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then +the configure parameter --enable-version3 will activate this licensing option +for you. Read the file COPYING.LGPLv3 or, if you have enabled GPL parts, +COPYING.GPLv3 to learn the exact legal terms that apply in this case. + +There are a handful of files under other licensing terms, namely: + +* The files libavcodec/jfdctfst.c, libavcodec/jfdctint_template.c and + libavcodec/jrevdct.c are taken from libjpeg, see the top of the files for + licensing details. Specifically note that you must credit the IJG in the + documentation accompanying your program if you only distribute executables. + You must also indicate any changes including additions and deletions to + those three files in the documentation. + + +external libraries +================== + +Libav can be combined with a number of external libraries, which sometimes +affect the licensing of binaries resulting from the combination. + +compatible libraries +-------------------- + +The libcdio, libx264, libx265, libxavs and libxvid libraries are under GPL. When +combining them with Libav, Libav needs to be licensed as GPL as well by +passing --enable-gpl to configure. + +The OpenCORE and VisualOn libraries are under the Apache License 2.0. That +license is incompatible with the LGPL v2.1 and the GPL v2, but not with +version 3 of those licenses. So to combine these libraries with Libav, the +license version needs to be upgraded by passing --enable-version3 to configure. + +incompatible libraries +---------------------- + +The Fraunhofer AAC library, FAAC and OpenSSL are under licenses incompatible +with all (L)GPL versions. Thus, unfortunately, since both licenses cannot be +satisfied simultaneously, binaries resulting from the combination of Libav +with these libraries are nonfree and unredistributable. If you wish to enable +any of these libraries nonetheless, pass --enable-nonfree to configure. diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index ba65b059c5..0000000000 --- a/LICENSE.md +++ /dev/null @@ -1,120 +0,0 @@ -# License - -Most files in FFmpeg are under the GNU Lesser General Public License version 2.1 -or later (LGPL v2.1+). Read the file `COPYING.LGPLv2.1` for details. Some other -files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to -FFmpeg. - -Some optional parts of FFmpeg are licensed under the GNU General Public License -version 2 or later (GPL v2+). See the file `COPYING.GPLv2` for details. None of -these parts are used by default, you have to explicitly pass `--enable-gpl` to -configure to activate them. In this case, FFmpeg's license changes to GPL v2+. - -Specifically, the GPL parts of FFmpeg are: - -- libpostproc -- optional x86 optimization in the files - - `libavcodec/x86/flac_dsp_gpl.asm` - - `libavcodec/x86/idct_mmx.c` - - `libavfilter/x86/vf_removegrain.asm` -- the following building and testing tools - - `compat/solaris/make_sunver.pl` - - `doc/t2h.pm` - - `doc/texi2pod.pl` - - `libswresample/swresample-test.c` - - `tests/checkasm/*` - - `tests/tiny_ssim.c` -- the following filters in libavfilter: - - `vf_blackframe.c` - - `vf_boxblur.c` - - `vf_colormatrix.c` - - `vf_cover_rect.c` - - `vf_cropdetect.c` - - `vf_delogo.c` - - `vf_eq.c` - - `vf_find_rect.c` - - `vf_fspp.c` - - `vf_geq.c` - - `vf_histeq.c` - - `vf_hqdn3d.c` - - `vf_interlace.c` - - `vf_kerndeint.c` - - `vf_mcdeint.c` - - `vf_mpdecimate.c` - - `vf_owdenoise.c` - - `vf_perspective.c` - - `vf_phase.c` - - `vf_pp.c` - - `vf_pp7.c` - - `vf_pullup.c` - - `vf_repeatfields.c` - - `vf_sab.c` - - `vf_smartblur.c` - - `vf_spp.c` - - `vf_stereo3d.c` - - `vf_super2xsai.c` - - `vf_tinterlace.c` - - `vf_uspp.c` - - `vsrc_mptestsrc.c` - -Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then -the configure parameter `--enable-version3` will activate this licensing option -for you. Read the file `COPYING.LGPLv3` or, if you have enabled GPL parts, -`COPYING.GPLv3` to learn the exact legal terms that apply in this case. - -There are a handful of files under other licensing terms, namely: - -* The files `libavcodec/jfdctfst.c`, `libavcodec/jfdctint_template.c` and - `libavcodec/jrevdct.c` are taken from libjpeg, see the top of the files for - licensing details. Specifically note that you must credit the IJG in the - documentation accompanying your program if you only distribute executables. - You must also indicate any changes including additions and deletions to - those three files in the documentation. -* `tests/reference.pnm` is under the expat license. - - -## External libraries - -FFmpeg can be combined with a number of external libraries, which sometimes -affect the licensing of binaries resulting from the combination. - -### Compatible libraries - -The following libraries are under GPL: -- frei0r -- libcdio -- librubberband -- libvidstab -- libx264 -- libx265 -- libxavs -- libxvid - -When combining them with FFmpeg, FFmpeg needs to be licensed as GPL as well by -passing `--enable-gpl` to configure. - -The OpenCORE and VisualOn libraries are under the Apache License 2.0. That -license is incompatible with the LGPL v2.1 and the GPL v2, but not with -version 3 of those licenses. So to combine these libraries with FFmpeg, the -license version needs to be upgraded by passing `--enable-version3` to configure. - -### Incompatible libraries - -There are certain libraries you can combine with FFmpeg whose licenses are not -compatible with the GPL and/or the LGPL. If you wish to enable these -libraries, even in circumstances that their license may be incompatible, pass -`--enable-nonfree` to configure. But note that if you enable any of these -libraries the resulting binary will be under a complex license mix that is -more restrictive than the LGPL and that may result in additional obligations. -It is possible that these restrictions cause the resulting binary to be -unredistributable. - -The Fraunhofer FDK AAC and OpenSSL libraries are under licenses which are -incompatible with the GPLv2 and v3. To the best of our knowledge, they are -compatible with the LGPL. - -The NVENC library, while its header file is licensed under the compatible MIT -license, requires a proprietary binary blob at run time, and is deemed to be -incompatible with the GPL. We are not certain if it is compatible with the -LGPL, but we require `--enable-nonfree` even with LGPL configurations in case -it is not. diff --git a/MAINTAINERS b/MAINTAINERS deleted file mode 100644 index 0b0f7fa1e4..0000000000 --- a/MAINTAINERS +++ /dev/null @@ -1,607 +0,0 @@ -FFmpeg maintainers -================== - -Below is a list of the people maintaining different parts of the -FFmpeg code. - -Please try to keep entries where you are the maintainer up to date! - -Names in () mean that the maintainer currently has no time to maintain the code. -A (CC
) after the name means that the maintainer prefers to be CC-ed on -patches and related discussions. - - -Project Leader -============== - - final design decisions - - -Applications -============ - -ffmpeg: - ffmpeg.c Michael Niedermayer - -ffplay: - ffplay.c Marton Balint - -ffprobe: - ffprobe.c Stefano Sabatini - -ffserver: - ffserver.c Reynaldo H. Verdejo Pinochet - -Commandline utility code: - cmdutils.c, cmdutils.h Michael Niedermayer - -QuickTime faststart: - tools/qt-faststart.c Baptiste Coudurier - - -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 -presets Robert Swain -metadata subsystem Aurelien Jacobs -release management Michael Niedermayer -API tests Ludmila Glinskih - - -Communication -============= - -website Deby Barbara Lepage -fate.ffmpeg.org Timothy Gu -Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos, Lou Logan -mailing lists Baptiste Coudurier, Lou Logan -Google+ Paul B Mahol, Michael Niedermayer, Alexander Strasser -Twitter Lou Logan, Reynaldo H. Verdejo Pinochet -Launchpad Timothy Gu -ffmpeg-security Andreas Cadhalpun, Carl Eugen Hoyos, Clément Bœsch, Michael Niedermayer, Reimar Doeffinger, Rodger Combs, wm4 - - -libavutil -========= - -External Interfaces: - libavutil/avutil.h Michael Niedermayer -Internal Interfaces: - libavutil/common.h Michael Niedermayer - -Other: - aes_ctr.c, aes_ctr.h Eran Kornblau - bprint Nicolas George - bswap.h - des Reimar Doeffinger - dynarray.h Nicolas George - eval.c, eval.h Michael Niedermayer - float_dsp Loren Merritt - hash Reimar Doeffinger - hwcontext_cuda* Timo Rothenpieler - intfloat* Michael Niedermayer - integer.c, integer.h Michael Niedermayer - lzo Reimar Doeffinger - mathematics.c, mathematics.h Michael Niedermayer - mem.c, mem.h Michael Niedermayer - opencl.c, opencl.h Wei Gao - opt.c, opt.h Michael Niedermayer - rational.c, rational.h Michael Niedermayer - rc4 Reimar Doeffinger - ripemd.c, ripemd.h James Almer - - -libavcodec -========== - -Generic Parts: - External Interfaces: - avcodec.h Michael Niedermayer - utility code: - utils.c Michael Niedermayer - audio and video frame extraction: - parser.c Michael Niedermayer - bitstream reading: - bitstream.c, bitstream.h Michael Niedermayer - CABAC: - cabac.h, cabac.c Michael Niedermayer - codec names: - codec_names.sh Nicolas George - DSP utilities: - dsputils.c, dsputils.h Michael Niedermayer - entropy coding: - rangecoder.c, rangecoder.h Michael Niedermayer - 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 - motion estimation: - motion* Michael Niedermayer - rate control: - ratecontrol.c Michael Niedermayer - libxvid_rc.c Michael Niedermayer - simple IDCT: - simple_idct.c, simple_idct.h Michael Niedermayer - postprocessing: - libpostproc/* Michael Niedermayer - table generation: - tableprint.c, tableprint.h Reimar Doeffinger - fixed point FFT: - fft* Zeljko Lukac - Text Subtitles Clément Bœsch - -Codecs: - 4xm.c Michael Niedermayer - 8bps.c Roberto Togni - 8svx.c Jaikrishnan Menon - aacenc*, aaccoder.c Rostislav Pehlivanov - alacenc.c Jaikrishnan Menon - alsdec.c Thilo Borgmann, Umair Khan - ass* Aurelien Jacobs - asv* Michael Niedermayer - atrac3plus* Maxim Poliakovski - audiotoolbox* Rodger Combs - bgmc.c, bgmc.h Thilo Borgmann - binkaudio.c Peter Ross - 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 - cljr Alex Beregszaszi - cpia.c Stephan Hilb - crystalhd.c Philip Langdale - cscd.c Reimar Doeffinger - cuvid.c Timo Rothenpieler - dca* foo86 - dirac* Rostislav Pehlivanov - dnxhd* Baptiste Coudurier - dolby_e* foo86 - dpcm.c Mike Melanson - dss_sp.c Oleksij Rempel - dv.c Roman Shaposhnik - dvbsubdec.c Anshul Maheshwari - 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 - flicvideo.c Mike Melanson - g722.c Martin Storsjo - g726.c Roman Shaposhnik - gifdec.c Baptiste Coudurier - h261* Michael Niedermayer - h263* Michael Niedermayer - h264* Loren Merritt, Michael Niedermayer - hap* Tom Butterworth - huffyuv* Michael Niedermayer - idcinvideo.c Mike Melanson - interplayvideo.c Mike Melanson - jni*, ffjni* Matthieu Bouron - jpeg2000* Nicolas Bertrand - jvdec.c Peter Ross - lcl*.c Roberto Togni, Reimar Doeffinger - libcelt_dec.c Nicolas George - libdirac* David Conrad - libgsm.c Michel Bardiaux - libkvazaar.c Arttu Ylä-Outinen - libopenjpeg.c Jaikrishnan Menon - libopenjpegenc.c Michael Bradshaw - libtheoraenc.c David Conrad - libvorbis.c David Conrad - libvpx* James Zern - libxavs.c Stefan Gehrer - libzvbi-teletextdec.c Marton Balint - lzo.h, lzo.c Reimar Doeffinger - mdec.c Michael Niedermayer - mimic.c Ramiro Polla - mjpeg*.c Michael Niedermayer - mlp* Ramiro Polla, Jai Luthra - mmvideo.c Peter Ross - 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 - nuv.c Reimar Doeffinger - nvenc* Timo Rothenpieler - opus* Rostislav Pehlivanov - 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 - qtrle.c Mike Melanson - ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni - resample2.c Michael Niedermayer - rl2.c Sascha Sommer - rpza.c Roberto Togni - rtjpeg.c, rtjpeg.h Reimar Doeffinger - rv10.c Michael Niedermayer - s3tc* Ivo van Poorten - smc.c Mike Melanson - smvjpegdec.c Ash Hughes - snow* Michael Niedermayer, Loren Merritt - sonic.c Alex Beregszaszi - speedhq.c Steinar H. Gunderson - srt* Aurelien Jacobs - sunrast.c Ivo van Poorten - svq3.c Michael Niedermayer - tak* Paul B Mahol - truemotion1* Mike Melanson - tta.c Alex Beregszaszi, Jaikrishnan Menon - ttaenc.c Paul B Mahol - txd.c Ivo van Poorten - vc2* Rostislav Pehlivanov - vcr1.c Michael Niedermayer - vda_h264_dec.c Xidorn Quan - videotoolboxenc.c Rick Kern - vima.c Paul B Mahol - 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 - vqavideo.c Mike Melanson - wmaprodec.c Sascha Sommer - wmavoice.c Ronald S. Bultje - wmv2.c Michael Niedermayer - xan.c Mike Melanson - xbm* Paul B Mahol - xface Stefano Sabatini - xvmc.c Ivan Kalvachev - xwd* Paul B Mahol - -Hardware acceleration: - crystalhd.c Philip Langdale - dxva2* Hendrik Leppkes, Laurent Aimar, Steve Lhomme - d3d11va* Steve Lhomme - mediacodec* Matthieu Bouron - vaapi* Gwenole Beauchesne - vaapi_encode* Mark Thompson - vdpau* Philip Langdale, Carl Eugen Hoyos - videotoolbox* Rick Kern - - -libavdevice -=========== - External Interface: - libavdevice/avdevice.h - - - avfoundation.m Thilo Borgmann - decklink* Deti Fliegl - dshow.c Roger Pack (CC rogerdpack@gmail.com) - fbdev_enc.c Lukasz Marek - gdigrab.c Roger Pack (CC rogerdpack@gmail.com) - iec61883.c Georg Lippitsch - lavfi Stefano Sabatini - libdc1394.c Roman Shaposhnik - opengl_enc.c Lukasz Marek - pulse_audio_enc.c Lukasz Marek - sdl Stefano Sabatini - sdl2.c Josh de Kock - v4l2.c Giorgio Vazzana - vfwcap.c Ramiro Polla - xv.c Lukasz Marek - -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 - af_aecho.c Paul B Mahol - af_afade.c Paul B Mahol - af_amerge.c Nicolas George - af_aphaser.c Paul B Mahol - af_aresample.c Michael Niedermayer - af_astats.c Paul B Mahol - af_atempo.c Pavel Koshevoy - af_biquads.c Paul B Mahol - af_chorus.c Paul B Mahol - af_compand.c Paul B Mahol - af_firequalizer.c Muhammad Faiz - af_hdcd.c Burt P. - af_ladspa.c Paul B Mahol - af_loudnorm.c Kyle Swanson - af_pan.c Nicolas George - af_sidechaincompress.c Paul B Mahol - af_silenceremove.c Paul B Mahol - avf_aphasemeter.c Paul B Mahol - avf_avectorscope.c Paul B Mahol - avf_showcqt.c Muhammad Faiz - vf_blend.c Paul B Mahol - vf_chromakey.c Timo Rothenpieler - vf_colorchannelmixer.c Paul B Mahol - vf_colorbalance.c Paul B Mahol - vf_colorkey.c Timo Rothenpieler - vf_colorlevels.c Paul B Mahol - vf_coreimage.m Thilo Borgmann - vf_deband.c Paul B Mahol - vf_dejudder.c Nicholas Robbins - vf_delogo.c Jean Delvare (CC ) - vf_drawbox.c/drawgrid Andrey Utkin - vf_extractplanes.c Paul B Mahol - vf_histogram.c Paul B Mahol - vf_hqx.c Clément Bœsch - vf_idet.c Pascal Massimino - vf_il.c Paul B Mahol - vf_lenscorrection.c Daniel Oberhoff - vf_mergeplanes.c Paul B Mahol - vf_mestimate.c Davinder Singh - vf_minterpolate.c Davinder Singh - vf_neighbor.c Paul B Mahol - vf_psnr.c Paul B Mahol - vf_random.c Paul B Mahol - vf_readvitc.c Tobias Rapp (CC t.rapp at noa-archive dot com) - vf_scale.c Michael Niedermayer - vf_separatefields.c Paul B Mahol - vf_ssim.c Paul B Mahol - vf_stereo3d.c Paul B Mahol - vf_telecine.c Paul B Mahol - vf_yadif.c Michael Niedermayer - vf_zoompan.c Paul B Mahol - -Sources: - vsrc_mandelbrot.c Michael Niedermayer - -libavformat -=========== - -Generic parts: - External Interface: - libavformat/avformat.h Michael Niedermayer - Utility Code: - libavformat/utils.c Michael Niedermayer - Text Subtitles Clément Bœsch - - -Muxers/Demuxers: - 4xm.c Mike Melanson - aadec.c Vesselin Bontchev (vesselin.bontchev at yandex dot com) - adtsenc.c Robert Swain - afc.c Paul B Mahol - aiffdec.c Baptiste Coudurier, Matthieu Bouron - aiffenc.c Baptiste Coudurier, Matthieu Bouron - apngdec.c Benoit Fouet - ass* Aurelien Jacobs - astdec.c Paul B Mahol - astenc.c James Almer - avi* Michael Niedermayer - avisynth.c Stephen Hutchinson - 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 - crc.c Michael Niedermayer - dashdec.c Steven Liu - daud.c Reimar Doeffinger - dss.c Oleksij Rempel - dtsdec.c foo86 - dtshddec.c Paul B Mahol - dv.c Roman Shaposhnik - electronicarts.c Peter Ross - epafdec.c Paul B Mahol - ffm* Baptiste Coudurier - flic.c Mike Melanson - flvdec.c Michael Niedermayer - flvenc.c Michael Niedermayer, Steven Liu - gxf.c Reimar Doeffinger - gxfenc.c Baptiste Coudurier - hls.c Anssi Hannula - hls encryption (hlsenc.c) Christian Suloway, Steven Liu - idcin.c Mike Melanson - idroqdec.c Mike Melanson - iff.c Jaikrishnan Menon - img2*.c Michael Niedermayer - ipmovie.c Mike Melanson - ircam* Paul B Mahol - iss.c Stefan Gehrer - jvdec.c Peter Ross - libmodplug.c Clément Bœsch - libopenmpt.c Josh de Kock - lmlm4.c Ivo van Poorten - lvfdec.c Paul B Mahol - lxfdec.c Tomas Härdin - matroska.c Aurelien Jacobs - matroskadec.c Aurelien Jacobs - matroskaenc.c David Conrad - matroska subtitles (matroskaenc.c) John Peebles - metadata* Aurelien Jacobs - mgsts.c Paul B Mahol - microdvd* Aurelien Jacobs - mm.c Peter Ross - mov.c Baptiste Coudurier - movenc.c Baptiste Coudurier, Matthieu Bouron - movenccenc.c Eran Kornblau - mpeg.c Michael Niedermayer - mpegenc.c Michael Niedermayer - mpegts.c Marton Balint - mpegtsenc.c Baptiste Coudurier - msnwc_tcp.c Ramiro Polla - mtv.c Reynaldo H. Verdejo Pinochet - mxf* Baptiste Coudurier - nistspheredec.c Paul B Mahol - nsvdec.c Francois Revol - nut* Michael Niedermayer - nuv.c Reimar Doeffinger - oggdec.c, oggdec.h David Conrad - oggenc.c Baptiste Coudurier - oggparse*.c David Conrad - oggparsedaala* Rostislav Pehlivanov - oma.c Maxim Poliakovski - paf.c Paul B Mahol - psxstr.c Mike Melanson - pva.c Ivo van Poorten - pvfdec.c Paul B Mahol - r3d.c Baptiste Coudurier - raw.c Michael Niedermayer - rdt.c Ronald S. Bultje - rl2.c Sascha Sommer - rmdec.c, rmenc.c Ronald S. Bultje - rtp.c, rtpenc.c Martin Storsjo - rtpdec_ac3.* Gilles Chanteperdrix - rtpdec_dv.* Thomas Volkert - rtpdec_h261.*, rtpenc_h261.* Thomas Volkert - rtpdec_hevc.*, rtpenc_hevc.* Thomas Volkert - rtpdec_mpa_robust.* Gilles Chanteperdrix - rtpdec_asf.* Ronald S. Bultje - rtpdec_vc2hq.*, rtpenc_vc2hq.* Thomas Volkert - rtpdec_vp9.c Thomas Volkert - rtpenc_mpv.*, rtpenc_aac.* Martin Storsjo - s337m.c foo86 - sbgdec.c Nicolas George - sdp.c Martin Storsjo - segafilm.c Mike Melanson - segment.c Stefano Sabatini - smjpeg* Paul B Mahol - spdif* Anssi Hannula - srtdec.c Aurelien Jacobs - swf.c Baptiste Coudurier - takdec.c Paul B Mahol - tta.c Alex Beregszaszi - txd.c Ivo van Poorten - voc.c Aurelien Jacobs - wav.c Michael Niedermayer - wc3movie.c Mike Melanson - webm dash (matroskaenc.c) Vignesh Venkatasubramanian - webvtt* Matthew J Heaney - westwood.c Mike Melanson - wtv.c Peter Ross - wvenc.c Paul B Mahol - -Protocols: - async.c Zhang Rui - bluray.c Petri Hintukainen - ftp.c Lukasz Marek - http.c Ronald S. Bultje - libssh.c Lukasz Marek - mms*.c Ronald S. Bultje - udp.c Luca Abeni - icecast.c Marvin Scholz - - -libswresample -============= - -Generic parts: - audioconvert.c Michael Niedermayer - dither.c Michael Niedermayer - rematrix*.c Michael Niedermayer - swresample*.c Michael Niedermayer - -Resamplers: - resample*.c Michael Niedermayer - soxr_resample.c Rob Sykes - - -Operating systems / CPU architectures -===================================== - -Alpha Falk Hueffner -MIPS Manojkumar Bhosale -Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier -Amiga / PowerPC Colin Ward -Windows MinGW Alex Beregszaszi, Ramiro Polla -Windows Cygwin Victor Paesa -Windows MSVC Matthew Oliver, Hendrik Leppkes -Windows ICL Matthew Oliver -ADI/Blackfin DSP Marc Hoffman -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 -======== - -2.8 Michael Niedermayer -2.7 Michael Niedermayer -2.6 Michael Niedermayer -2.5 Michael Niedermayer - -If you want to maintain an older release, please contact us - - -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 -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 -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 -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 -Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE -Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A -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 -Reimar Doeffinger C61D 16E5 9E2C D10C 8958 38A4 0899 A2B9 06D4 D9C7 -Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4 -Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A -Robert Swain EE7A 56EA 4A81 A7B5 2001 A521 67FA 362D A2FC 3E71 -Sascha Sommer 38A0 F88B 868E 9D3A 97D4 D6A0 E823 706F 1E07 0D3C -Stefano Sabatini 0D0B AD6B 5330 BBAD D3D6 6A0C 719C 2839 FC43 2D5F -Steinar H. Gunderson C2E9 004F F028 C18E 4EAD DB83 7F61 7561 7797 8F76 -Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863 -Tiancheng "Timothy" Gu 9456 AFC0 814A 8139 E994 8351 7FE6 B095 B582 B0D4 -Tim Nicholson 38CF DB09 3ED0 F607 8B67 6CED 0C0B FC44 8B0B FC83 -Tomas Härdin A79D 4E3D F38F 763F 91F5 8B33 A01E 8AE0 41BB 2551 -Wei Gao 4269 7741 857A 0E60 9EC5 08D2 4744 4EFA 62C1 87B9 diff --git a/Makefile b/Makefile index 29870d7710..6ea8359318 100644 --- a/Makefile +++ b/Makefile @@ -1,46 +1,75 @@ -MAIN_MAKEFILE=1 -include ffbuild/config.mak +include avbuild/config.mak vpath %.c $(SRC_PATH) -vpath %.cpp $(SRC_PATH) -vpath %.h $(SRC_PATH) -vpath %.inc $(SRC_PATH) vpath %.m $(SRC_PATH) +vpath %.h $(SRC_PATH) vpath %.S $(SRC_PATH) vpath %.asm $(SRC_PATH) -vpath %.rc $(SRC_PATH) vpath %.v $(SRC_PATH) vpath %.texi $(SRC_PATH) -vpath %.cu $(SRC_PATH) -vpath %.ptx $(SRC_PATH) -vpath %/fate_config.sh.template $(SRC_PATH) -AVPROGS-$(CONFIG_FFMPEG) += ffmpeg -AVPROGS-$(CONFIG_FFPLAY) += ffplay -AVPROGS-$(CONFIG_FFPROBE) += ffprobe -AVPROGS-$(CONFIG_FFSERVER) += ffserver - -AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF)) -INSTPROGS = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF)) -PROGS += $(AVPROGS) - -AVBASENAMES = ffmpeg ffplay ffprobe ffserver -ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF)) -ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) - -$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o)) -$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o)) - -OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o ffmpeg_hw.o -OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o -OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o -ifndef CONFIG_VIDEOTOOLBOX -OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o +ifndef V +Q = @ +ECHO = printf "$(1)\t%s\n" $(2) +BRIEF = CC HOSTCC HOSTLD AS X86ASM AR LD +SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM STRIP +MSG = $@ +M = @$(call ECHO,$(TAG),$@); +$(foreach VAR,$(BRIEF), \ + $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) +$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) +$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL)) endif -OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o -OBJS-ffserver += ffserver_config.o -TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch +ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil swscale + +IFLAGS := -I. -I$(SRC_PATH) +CPPFLAGS := $(IFLAGS) $(CPPFLAGS) +CFLAGS += $(ECFLAGS) +CCFLAGS = $(CPPFLAGS) $(CFLAGS) +OBJCFLAGS += $(EOBJCFLAGS) +OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS) +ASFLAGS := $(CPPFLAGS) $(ASFLAGS) +X86ASMFLAGS += $(IFLAGS:%=%/) -I$($@ + +%.c %.h %.pc %.ver %.version: TAG = GEN + +TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options # $(FFLIBS-yes) needs to be in linking order @@ -49,14 +78,11 @@ FFLIBS-$(CONFIG_AVFILTER) += avfilter FFLIBS-$(CONFIG_AVFORMAT) += avformat FFLIBS-$(CONFIG_AVCODEC) += avcodec FFLIBS-$(CONFIG_AVRESAMPLE) += avresample -FFLIBS-$(CONFIG_POSTPROC) += postproc -FFLIBS-$(CONFIG_SWRESAMPLE) += swresample FFLIBS-$(CONFIG_SWSCALE) += swscale 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 +DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset) SKIPHEADERS = compat/w32pthreads.h @@ -64,43 +90,31 @@ SKIPHEADERS = compat/w32pthreads.h all: all-yes include $(SRC_PATH)/tools/Makefile -include $(SRC_PATH)/ffbuild/common.mak +include $(SRC_PATH)/avbuild/common.mak FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS) -all: $(AVPROGS) - $(TOOLS): %$(EXESUF): %.o - $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) - -target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS) - $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) - -tools/cws2fws$(EXESUF): ELIBS = $(ZLIB) -tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS) -tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS) -tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS) -tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS) CONFIGURABLE_COMPONENTS = \ $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \ $(SRC_PATH)/libavcodec/bitstream_filters.c \ $(SRC_PATH)/libavformat/protocols.c \ -config.h: ffbuild/.config -ffbuild/.config: $(CONFIGURABLE_COMPONENTS) +config.h: avbuild/.config +avbuild/.config: $(CONFIGURABLE_COMPONENTS) @-tput bold 2>/dev/null @-printf '\nWARNING: $(?) newer than config.h, rerun configure\n\n' @-tput sgr0 2>/dev/null -SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \ +SUBDIR_VARS := CLEANFILES 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 X86ASM-OBJS \ - MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \ - MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS + OBJS HOSTOBJS TESTOBJS define RESET $(1) := @@ -113,98 +127,60 @@ SUBDIR := $(1)/ include $(SRC_PATH)/$(1)/Makefile -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile -include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile -include $(SRC_PATH)/ffbuild/library.mak +include $(SRC_PATH)/avbuild/library.mak endef $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D)))) +include $(SRC_PATH)/avtools/Makefile include $(SRC_PATH)/doc/Makefile +include $(SRC_PATH)/doc/examples/Makefile -define DOPROG -OBJS-$(1) += $(1).o $(OBJS-$(1)-yes) -$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1)) -$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1)) -$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1)) -$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1)) --include $$(OBJS-$(1):.o=.d) -endef - -$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=)))) - -ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h - -$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF) - $(CP) $< $@ - $(STRIP) $@ - -%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS) +$(PROGS): %$(EXESUF): $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS) -VERSION_SH = $(SRC_PATH)/ffbuild/version.sh +VERSION_SH = $(SRC_PATH)/avbuild/version.sh GIT_LOG = $(SRC_PATH)/.git/logs/HEAD -.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) ffbuild/config.mak +.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) avbuild/config.mak .version: M=@ -libavutil/ffversion.h .version: - $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION) +libavutil/utils.o: avversion.h +avversion.h .version: + $(M)$(VERSION_SH) $(SRC_PATH) avversion.h $(EXTRA_VERSION) $(Q)touch .version # force version.sh to run whenever version might have changed -include .version -ifdef AVPROGS -install: install-progs install-data -endif - install: install-libs install-headers install-libs: install-libs-yes -install-progs-yes: -install-progs-$(CONFIG_SHARED): install-libs - -install-progs: install-progs-yes $(AVPROGS) - $(Q)mkdir -p "$(BINDIR)" - $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)" - -install-data: $(DATA_FILES) $(EXAMPLES_FILES) - $(Q)mkdir -p "$(DATADIR)/examples" +install-data: $(DATA_FILES) + $(Q)mkdir -p "$(DATADIR)" $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)" - $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples" -uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data - -uninstall-progs: - $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS)) +uninstall: uninstall-libs uninstall-headers uninstall-data uninstall-data: $(RM) -r "$(DATADIR)" clean:: - $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G) $(RM) $(CLEANSUFFIXES) - $(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%) - $(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%) - $(RM) $(CLEANSUFFIXES:%=compat/%) - $(RM) -r coverage-html - $(RM) -rf coverage.info coverage.info.in lcov + $(RM) -rf coverage.info lcov distclean:: $(RM) $(DISTCLEANSUFFIXES) - $(RM) .version avversion.h config.asm config.h mapfile \ - ffbuild/.config ffbuild/config.* libavutil/avconfig.h \ - version.h libavutil/ffversion.h libavcodec/codec_names.h \ - libavcodec/bsf_list.c libavformat/protocol_list.c -ifeq ($(SRC_LINK),src) - $(RM) src -endif - $(RM) -rf doc/examples/pc-uninstalled + $(RM) .version avversion.h config.asm config.h mapfile \ + avbuild/.config avbuild/config.* libavutil/avconfig.h \ + libavcodec/bsf_list.c libavformat/protocol_list.c config: - $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION) + $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION) -check: all alltools examples testprogs fate +build: all alltools checkheaders examples testprogs +check: all alltools checkheaders examples testprogs fate include $(SRC_PATH)/tests/Makefile @@ -219,5 +195,5 @@ $(sort $(OBJDIRS)): # so this saves some time on slow systems. .SUFFIXES: -.PHONY: all all-yes alltools check *clean config install* -.PHONY: testprogs uninstall* +.PHONY: all all-yes alltools build check config testprogs +.PHONY: *clean install* uninstall* diff --git a/README.md b/README.md index 7d5a7efe9e..169f878f88 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -FFmpeg README -============= +Libav +===== -FFmpeg is a collection of libraries and tools to process multimedia content +[![Build Status](https://travis-ci.org/libav/libav.svg)](https://travis-ci.org/libav/libav) + +Libav is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata. ## Libraries @@ -11,38 +13,30 @@ such as audio, video, subtitles and related metadata. * `libavutil` includes hashers, decompressors and miscellaneous utility functions. * `libavfilter` provides a mean to alter decoded Audio and Video through chain of filters. * `libavdevice` provides an abstraction to access capture and playback devices. -* `libswresample` implements audio mixing and resampling routines. +* `libavresample` implements audio mixing and resampling routines. * `libswscale` implements color conversion and scaling routines. ## Tools -* [ffmpeg](https://ffmpeg.org/ffmpeg.html) is a command line toolbox to +* [avconv](http://libav.org/avconv.html) is a command line toolbox to manipulate, convert and stream multimedia content. -* [ffplay](https://ffmpeg.org/ffplay.html) is a minimalistic multimedia player. -* [ffprobe](https://ffmpeg.org/ffprobe.html) is a simple analysis tool to inspect +* [avplay](http://libav.org/avplay.html) is a minimalistic multimedia player. +* [avprobe](http://libav.org/avprobe.html) is a simple analisys tool to inspect multimedia content. -* [ffserver](https://ffmpeg.org/ffserver.html) is a multimedia streaming server - for live broadcasts. * Additional small tools such as `aviocat`, `ismindex` and `qt-faststart`. ## Documentation The offline documentation is available in the **doc/** directory. -The online documentation is available in the main [website](https://ffmpeg.org) -and in the [wiki](https://trac.ffmpeg.org). +The online documentation is available in the main [website](http://libav.org) +and in the [wiki](http://wiki.libav.org). ### Examples -Coding examples are available in the **doc/examples** directory. +Conding examples are available in the **doc/example** directory. ## License -FFmpeg codebase is mainly LGPL-licensed with optional components licensed under +Libav codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information. - -## Contributing - -Patches should be submitted to the ffmpeg-devel mailing list using -`git format-patch` or `git send-email`. Github pull requests should be -avoided because they are not part of our review process and will be ignored. diff --git a/RELEASE b/RELEASE index 48ea63d180..238ce5fc45 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -3.3.git +13_dev0 diff --git a/ffbuild/.gitignore b/avbuild/.gitignore similarity index 100% rename from ffbuild/.gitignore rename to avbuild/.gitignore diff --git a/ffbuild/arch.mak b/avbuild/arch.mak similarity index 62% rename from ffbuild/arch.mak rename to avbuild/arch.mak index e09006efca..a84c1f518d 100644 --- a/ffbuild/arch.mak +++ b/avbuild/arch.mak @@ -4,12 +4,6 @@ OBJS-$(HAVE_ARMV8) += $(ARMV8-OBJS) $(ARMV8-OBJS-yes) OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes) OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes) -OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes) -OBJS-$(HAVE_MIPSDSP) += $(MIPSDSP-OBJS) $(MIPSDSP-OBJS-yes) -OBJS-$(HAVE_MIPSDSPR2) += $(MIPSDSPR2-OBJS) $(MIPSDSPR2-OBJS-yes) -OBJS-$(HAVE_MSA) += $(MSA-OBJS) $(MSA-OBJS-yes) -OBJS-$(HAVE_MMI) += $(MMI-OBJS) $(MMI-OBJS-yes) - OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes) OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes) diff --git a/avbuild/common.mak b/avbuild/common.mak new file mode 100644 index 0000000000..a627dc0ccf --- /dev/null +++ b/avbuild/common.mak @@ -0,0 +1,63 @@ +# +# common bits used by all libraries +# + +include $(SRC_PATH)/avbuild/arch.mak + +OBJS += $(OBJS-yes) +FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS) +TESTPROGS += $(TESTPROGS-yes) + +FFEXTRALIBS := $(FFLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) $(FFLIBS:%=EXTRALIBS-%),$($(lib))) $(EXTRALIBS) + +OBJS := $(sort $(OBJS:%=$(SUBDIR)%)) +TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o) +TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF)) +HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o) +HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF)) +TOOLS += $(TOOLS-yes) +TOOLOBJS := $(TOOLS:%=tools/%.o) +TOOLS := $(TOOLS:%=tools/%$(EXESUF)) +HEADERS += $(HEADERS-yes) + +PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME)) +DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S))) +STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib))) + +SRC_DIR := $(SRC_PATH)/lib$(NAME) +ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) +SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-) +SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%) +HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o)) +$(HOBJS): CCFLAGS += $(CFLAGS_HEADERS) +checkheaders: $(HOBJS) +.SECONDARY: $(HOBJS:.o=.c) + +alltools: $(TOOLS) + +$(HOSTOBJS): %.o: %.c + $(COMPILE_HOSTC) + +$(HOSTPROGS): %$(HOSTEXESUF): %.o + $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS) + +$(OBJS): | $(sort $(dir $(OBJS))) +$(HOBJS): | $(sort $(dir $(HOBJS))) +$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS))) +$(TESTOBJS): | $(sort $(dir $(TESTOBJS))) +$(TOOLOBJS): | tools + +OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS)) + +CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.version +DISTCLEANSUFFIXES = *.pc +LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a + +define RULES +clean:: + $(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS) +endef + +$(eval $(RULES)) + +-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d)) diff --git a/ffbuild/library.mak b/avbuild/library.mak similarity index 67% rename from ffbuild/library.mak rename to avbuild/library.mak index ee19c3c797..4e4b3f196d 100644 --- a/ffbuild/library.mak +++ b/avbuild/library.mak @@ -1,6 +1,6 @@ -include $(SRC_PATH)/ffbuild/common.mak +include $(SRC_PATH)/avbuild/common.mak -ifeq (,$(filter %clean,$(MAKECMDGOALS))) +ifeq (,$(filter %clean config,$(MAKECMDGOALS))) -include $(SUBDIR)lib$(NAME).version endif @@ -11,12 +11,11 @@ INCINSTDIR := $(INCDIR)/lib$(NAME) INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) -all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc -all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc +all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(NAME).pc +all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(NAME).pc LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) -$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H -$(TESTOBJS) $(TESTOBJS:.o=.i): CFLAGS += -Umain +$(LIBOBJS) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H $(SUBDIR)$(LIBNAME): $(OBJS) $(RM) $@ @@ -29,17 +28,19 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared define RULES -$(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB)) +$(TOOLS): THISLIB = $(NAME:%=$(LD_LIB)) $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME) +$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME) + $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o - $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS) + $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS) $(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR) - $$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$< > $$@ + $$(M) $$(SRC_PATH)/avbuild/libversion.sh $(NAME) $$< > $$@ -$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h | $(SUBDIR) - $$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" +$(SUBDIR)lib$(NAME).pc: $(SUBDIR)version.h | $(SUBDIR) + $$(M) $$(SRC_PATH)/avbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ @@ -47,15 +48,11 @@ $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR) $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME) -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver +$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS) $(SLIB_CREATE_DEF_CMD) - $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDLIBFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS) + $$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS) $(SLIB_EXTRA_CMD) -ifdef SUBDIR -$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS) -endif - clean:: $(RM) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \ $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(CLEANSUFFIXES:%=$(SUBDIR)tests/%) @@ -67,8 +64,7 @@ distclean:: clean install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME) $(Q)mkdir -p "$(SHLIBDIR)" $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" - $$(STRIP) "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)" - $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),(cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F));) + $(Q)$(foreach F,$(SLIB_INSTALL_LINKS),cd "$(SHLIBDIR)" && $(LN_S) $(SLIB_INSTALL_NAME) $(F);) $(if $(SLIB_INSTALL_EXTRA_SHLIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_SHLIB:%=$(SUBDIR)%) "$(SHLIBDIR)") $(if $(SLIB_INSTALL_EXTRA_LIB),$(Q)mkdir -p "$(LIBDIR)") $(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)") @@ -82,21 +78,21 @@ install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS)) $(Q)mkdir -p "$(INCINSTDIR)" $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)" -install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(FULLNAME).pc - $(Q)mkdir -p "$(PKGCONFIGDIR)" - $$(INSTALL) -m 644 $$^ "$(PKGCONFIGDIR)" +install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc + $(Q)mkdir -p "$(LIBDIR)/pkgconfig" + $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig" uninstall-libs:: -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \ "$(SHLIBDIR)/$(SLIBNAME)" \ "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)" - -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)/%") - -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)/%") + -$(RM) $(SLIB_INSTALL_EXTRA_SHLIB:%="$(SHLIBDIR)"%) + -$(RM) $(SLIB_INSTALL_EXTRA_LIB:%="$(LIBDIR)"%) -$(RM) "$(LIBDIR)/$(LIBNAME)" uninstall-headers:: $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS) $(BUILT_HEADERS)) - $(RM) "$(PKGCONFIGDIR)/lib$(FULLNAME).pc" + $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc" -rmdir "$(INCINSTDIR)" endef diff --git a/ffbuild/libversion.sh b/avbuild/libversion.sh similarity index 97% rename from ffbuild/libversion.sh rename to avbuild/libversion.sh index 990ce9f640..30046b1d25 100755 --- a/ffbuild/libversion.sh +++ b/avbuild/libversion.sh @@ -1,3 +1,5 @@ +#!/bin/sh + toupper(){ echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ } diff --git a/ffbuild/pkgconfig_generate.sh b/avbuild/pkgconfig_generate.sh similarity index 59% rename from ffbuild/pkgconfig_generate.sh rename to avbuild/pkgconfig_generate.sh index e5de6716d2..c7bc65254d 100755 --- a/ffbuild/pkgconfig_generate.sh +++ b/avbuild/pkgconfig_generate.sh @@ -1,6 +1,6 @@ #!/bin/sh -. ffbuild/config.sh +. avbuild/config.sh if test "$shared" = "yes"; then shared=true @@ -10,53 +10,49 @@ fi shortname=$1 name=lib${shortname} -fullname=${name}${build_suffix} comment=$2 libs=$(eval echo \$extralibs_${shortname}) deps=$(eval echo \$${shortname}_deps) for dep in $deps; do depname=lib${dep} - fulldepname=${depname}${build_suffix} . ${depname}/${depname}.version depversion=$(eval echo \$${depname}_VERSION) - requires="$requires ${fulldepname} >= ${depversion}, " + requires="$requires ${depname} >= ${depversion}, " done + requires=${requires%, } version=$(grep ${name}_VERSION= $name/${name}.version | cut -d= -f2) -cat < $name/$fullname.pc +cat < $name/$name.pc prefix=$prefix exec_prefix=\${prefix} libdir=$libdir includedir=$incdir -Name: $fullname +Name: $name Description: $comment Version: $version Requires: $($shared || echo $requires) Requires.private: $($shared && echo $requires) Conflicts: -Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs) +Libs: -L\${libdir} -l${shortname} $($shared || echo $libs) Libs.private: $($shared && echo $libs) Cflags: -I\${includedir} EOF -mkdir -p doc/examples/pc-uninstalled -includedir=${source_path} -[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.." - cat < doc/examples/pc-uninstalled/${name}-uninstalled.pc +cat < $name/$name-uninstalled.pc prefix= exec_prefix= -libdir=\${pcfiledir}/../../../$name +libdir=\${pcfiledir} includedir=${source_path} -Name: $fullname +Name: $name Description: $comment Version: $version Requires: $requires Conflicts: -Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${fullname#lib} $($shared || echo $libs) +Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs Cflags: -I\${includedir} EOF diff --git a/avbuild/version.sh b/avbuild/version.sh new file mode 100755 index 0000000000..4689627869 --- /dev/null +++ b/avbuild/version.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# check for git short hash +revision=$(cd "$1" && git describe --always 2> /dev/null) + +# no revision number found +test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null) + +# releases extract the version number from the VERSION file +version=$(cd "$1" && cat VERSION 2> /dev/null) +test "$version" || version=$revision + +test -n "$3" && version=$version-$3 + +if [ -z "$2" ]; then + echo "$version" + exit +fi + +NEW_REVISION="#define LIBAV_VERSION \"$version\"" +OLD_REVISION=$(cat "$2" 2> /dev/null) + +# Update version.h only on revision changes to avoid spurious rebuilds +if test "$NEW_REVISION" != "$OLD_REVISION"; then + echo "$NEW_REVISION" > "$2" +fi diff --git a/avtools/Makefile b/avtools/Makefile new file mode 100644 index 0000000000..d95e2d9fc2 --- /dev/null +++ b/avtools/Makefile @@ -0,0 +1,50 @@ +AVPROGS-$(CONFIG_AVCONV) += avconv +AVPROGS-$(CONFIG_AVPLAY) += avplay +AVPROGS-$(CONFIG_AVPROBE) += avprobe + +AVPROGS := $(AVPROGS-yes:%=%$(EXESUF)) +PROGS += $(AVPROGS) + +AVBASENAMES = avconv avplay avprobe +ALLAVPROGS = $(AVBASENAMES:%=%$(EXESUF)) + +OBJS-avconv += avtools/avconv_opt.o avtools/avconv_filter.o \ + avtools/avconv_hw.o +OBJS-avconv-$(CONFIG_LIBMFX) += avtools/avconv_qsv.o +OBJS-avconv-$(CONFIG_VDA) += avtools/avconv_vda.o + +define DOAVTOOL +OBJS-$(1) += avtools/cmdutils.o avtools/$(1).o $(OBJS-$(1)-yes) +$(1)$(EXESUF): $$(OBJS-$(1)) +$$(OBJS-$(1)): | avtools +$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1)) +$(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1)) +$(1)$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1)) +-include $$(OBJS-$(1):.o=.d) +endef + +$(foreach P,$(AVPROGS-yes),$(eval $(call DOAVTOOL,$(P)))) + +all: $(AVPROGS) + +avtools/cmdutils.o: avversion.h | avtools +OBJDIRS += avtools + +ifdef AVPROGS +install: install-progs install-data +endif + +install-progs-yes: +install-progs-$(CONFIG_SHARED): install-libs + +install-progs: install-progs-yes $(AVPROGS) + $(Q)mkdir -p "$(BINDIR)" + $(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)" + +uninstall: uninstall-progs + +uninstall-progs: + $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS)) + +clean:: + $(RM) $(ALLAVPROGS) $(CLEANSUFFIXES:%=avtools/%) diff --git a/avtools/avconv.c b/avtools/avconv.c new file mode 100644 index 0000000000..4e3ffecdef --- /dev/null +++ b/avtools/avconv.c @@ -0,0 +1,2950 @@ +/* + * avconv main + * Copyright (c) 2000-2011 The Libav developers + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libavformat/avformat.h" +#include "libavdevice/avdevice.h" +#include "libswscale/swscale.h" +#include "libavresample/avresample.h" +#include "libavutil/opt.h" +#include "libavutil/channel_layout.h" +#include "libavutil/parseutils.h" +#include "libavutil/samplefmt.h" +#include "libavutil/fifo.h" +#include "libavutil/hwcontext.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/dict.h" +#include "libavutil/mathematics.h" +#include "libavutil/pixdesc.h" +#include "libavutil/avstring.h" +#include "libavutil/libm.h" +#include "libavutil/imgutils.h" +#include "libavutil/time.h" +#include "libavformat/os_support.h" + +# include "libavfilter/avfilter.h" +# include "libavfilter/buffersrc.h" +# include "libavfilter/buffersink.h" + +#if HAVE_SYS_RESOURCE_H +#include +#include +#include +#elif HAVE_GETPROCESSTIMES +#include +#endif +#if HAVE_GETPROCESSMEMORYINFO +#include +#include +#endif + +#if HAVE_SYS_SELECT_H +#include +#endif + +#if HAVE_PTHREADS +#include +#endif + +#include + +#include "avconv.h" +#include "cmdutils.h" + +#include "libavutil/avassert.h" + +const char program_name[] = "avconv"; +const int program_birth_year = 2000; + +static FILE *vstats_file; + +static int nb_frames_drop = 0; + +static int want_sdp = 1; + +#if HAVE_PTHREADS +/* signal to input threads that they should exit; set by the main thread */ +static int transcoding_finished; +#endif + +InputStream **input_streams = NULL; +int nb_input_streams = 0; +InputFile **input_files = NULL; +int nb_input_files = 0; + +OutputStream **output_streams = NULL; +int nb_output_streams = 0; +OutputFile **output_files = NULL; +int nb_output_files = 0; + +FilterGraph **filtergraphs; +int nb_filtergraphs; + +static void term_exit(void) +{ + av_log(NULL, AV_LOG_QUIET, ""); +} + +static volatile int received_sigterm = 0; +static volatile int received_nb_signals = 0; + +static void +sigterm_handler(int sig) +{ + received_sigterm = sig; + received_nb_signals++; + term_exit(); +} + +static void term_init(void) +{ + signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */ + signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */ +#ifdef SIGXCPU + signal(SIGXCPU, sigterm_handler); +#endif +} + +static int decode_interrupt_cb(void *ctx) +{ + return received_nb_signals > 1; +} + +const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; + +static void avconv_cleanup(int ret) +{ + int i, j; + + for (i = 0; i < nb_filtergraphs; i++) { + FilterGraph *fg = filtergraphs[i]; + avfilter_graph_free(&fg->graph); + for (j = 0; j < fg->nb_inputs; j++) { + while (av_fifo_size(fg->inputs[j]->frame_queue)) { + AVFrame *frame; + av_fifo_generic_read(fg->inputs[j]->frame_queue, &frame, + sizeof(frame), NULL); + av_frame_free(&frame); + } + av_fifo_free(fg->inputs[j]->frame_queue); + av_buffer_unref(&fg->inputs[j]->hw_frames_ctx); + av_freep(&fg->inputs[j]->name); + av_freep(&fg->inputs[j]); + } + av_freep(&fg->inputs); + for (j = 0; j < fg->nb_outputs; j++) { + av_freep(&fg->outputs[j]->name); + av_freep(&fg->outputs[j]->formats); + av_freep(&fg->outputs[j]->channel_layouts); + av_freep(&fg->outputs[j]->sample_rates); + av_freep(&fg->outputs[j]); + } + av_freep(&fg->outputs); + av_freep(&fg->graph_desc); + + av_freep(&filtergraphs[i]); + } + av_freep(&filtergraphs); + + /* close files */ + for (i = 0; i < nb_output_files; i++) { + OutputFile *of = output_files[i]; + AVFormatContext *s = of->ctx; + if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb) + avio_close(s->pb); + avformat_free_context(s); + av_dict_free(&of->opts); + + av_freep(&output_files[i]); + } + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + + for (j = 0; j < ost->nb_bitstream_filters; j++) + av_bsf_free(&ost->bsf_ctx[j]); + av_freep(&ost->bsf_ctx); + + av_frame_free(&ost->filtered_frame); + + av_parser_close(ost->parser); + avcodec_free_context(&ost->parser_avctx); + + av_freep(&ost->forced_keyframes); + av_freep(&ost->avfilter); + av_freep(&ost->logfile_prefix); + + avcodec_free_context(&ost->enc_ctx); + + if (ost->muxing_queue) { + while (av_fifo_size(ost->muxing_queue)) { + AVPacket pkt; + av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL); + av_packet_unref(&pkt); + } + av_fifo_free(ost->muxing_queue); + } + av_freep(&output_streams[i]); + } + for (i = 0; i < nb_input_files; i++) { + avformat_close_input(&input_files[i]->ctx); + av_freep(&input_files[i]); + } + for (i = 0; i < nb_input_streams; i++) { + InputStream *ist = input_streams[i]; + + av_frame_free(&ist->decoded_frame); + av_frame_free(&ist->filter_frame); + av_dict_free(&ist->decoder_opts); + av_freep(&ist->filters); + av_freep(&ist->hwaccel_device); + + avcodec_free_context(&ist->dec_ctx); + + av_freep(&input_streams[i]); + } + + if (vstats_file) + fclose(vstats_file); + av_free(vstats_filename); + + av_freep(&input_streams); + av_freep(&input_files); + av_freep(&output_streams); + av_freep(&output_files); + + uninit_opts(); + + avformat_network_deinit(); + + if (received_sigterm) { + av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", + (int) received_sigterm); + exit (255); + } +} + +void assert_avoptions(AVDictionary *m) +{ + AVDictionaryEntry *t; + if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); + exit_program(1); + } +} + +static void abort_codec_experimental(AVCodec *c, int encoder) +{ + const char *codec_string = encoder ? "encoder" : "decoder"; + AVCodec *codec; + av_log(NULL, AV_LOG_FATAL, "%s '%s' is experimental and might produce bad " + "results.\nAdd '-strict experimental' if you want to use it.\n", + codec_string, c->name); + codec = encoder ? avcodec_find_encoder(c->id) : avcodec_find_decoder(c->id); + if (!(codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL)) + av_log(NULL, AV_LOG_FATAL, "Or use the non experimental %s '%s'.\n", + codec_string, codec->name); + exit_program(1); +} + +static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) +{ + AVFormatContext *s = of->ctx; + AVStream *st = ost->st; + int ret; + + if (!of->header_written) { + AVPacket tmp_pkt; + /* the muxer is not initialized yet, buffer the packet */ + if (!av_fifo_space(ost->muxing_queue)) { + int new_size = FFMIN(2 * av_fifo_size(ost->muxing_queue), + ost->max_muxing_queue_size); + if (new_size <= av_fifo_size(ost->muxing_queue)) { + av_log(NULL, AV_LOG_ERROR, + "Too many packets buffered for output stream %d:%d.\n", + ost->file_index, ost->st->index); + exit_program(1); + } + ret = av_fifo_realloc2(ost->muxing_queue, new_size); + if (ret < 0) + exit_program(1); + } + av_packet_move_ref(&tmp_pkt, pkt); + av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), NULL); + return; + } + + /* + * Audio encoders may split the packets -- #frames in != #packets out. + * But there is no reordering, so we can limit the number of output packets + * by simply dropping them here. + * Counting encoded video frames needs to be done separately because of + * reordering, see do_video_out() + */ + if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed)) { + if (ost->frame_number >= ost->max_frames) { + av_packet_unref(pkt); + return; + } + ost->frame_number++; + } + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, + NULL); + ost->quality = sd ? *(int *)sd : -1; + + if (ost->frame_rate.num) { + pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), + ost->mux_timebase); + } + } + + av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base); + + if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS) && + ost->last_mux_dts != AV_NOPTS_VALUE && + pkt->dts < ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT)) { + av_log(NULL, AV_LOG_WARNING, "Non-monotonous DTS in output stream " + "%d:%d; previous: %"PRId64", current: %"PRId64"; ", + ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); + if (exit_on_error) { + av_log(NULL, AV_LOG_FATAL, "aborting.\n"); + exit_program(1); + } + av_log(NULL, AV_LOG_WARNING, "changing to %"PRId64". This may result " + "in incorrect timestamps in the output file.\n", + ost->last_mux_dts + 1); + pkt->dts = ost->last_mux_dts + 1; + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts = FFMAX(pkt->pts, pkt->dts); + } + ost->last_mux_dts = pkt->dts; + + ost->data_size += pkt->size; + ost->packets_written++; + + pkt->stream_index = ost->index; + + ret = av_interleaved_write_frame(s, pkt); + if (ret < 0) { + print_error("av_interleaved_write_frame()", ret); + exit_program(1); + } +} + +static void output_packet(OutputFile *of, AVPacket *pkt, + OutputStream *ost, int eof) +{ + int ret = 0; + + /* apply the output bitstream filters, if any */ + if (ost->nb_bitstream_filters) { + int idx; + + ret = av_bsf_send_packet(ost->bsf_ctx[0], eof ? NULL : pkt); + if (ret < 0) + goto finish; + + eof = 0; + idx = 1; + while (idx) { + /* get a packet from the previous filter up the chain */ + ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt); + if (ret == AVERROR(EAGAIN)) { + ret = 0; + idx--; + continue; + } else if (ret == AVERROR_EOF) { + eof = 1; + } else if (ret < 0) + goto finish; + + /* send it to the next filter down the chain or to the muxer */ + if (idx < ost->nb_bitstream_filters) { + ret = av_bsf_send_packet(ost->bsf_ctx[idx], eof ? NULL : pkt); + if (ret < 0) + goto finish; + idx++; + eof = 0; + } else if (eof) + goto finish; + else + write_packet(of, pkt, ost); + } + } else if (!eof) + write_packet(of, pkt, ost); + +finish: + if (ret < 0 && ret != AVERROR_EOF) { + av_log(NULL, AV_LOG_FATAL, "Error applying bitstream filters to an output " + "packet for stream #%d:%d.\n", ost->file_index, ost->index); + exit_program(1); + } +} + +static int check_recording_time(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + + if (of->recording_time != INT64_MAX && + av_compare_ts(ost->sync_opts - ost->first_pts, ost->enc_ctx->time_base, of->recording_time, + AV_TIME_BASE_Q) >= 0) { + ost->finished = 1; + return 0; + } + return 1; +} + +static void do_audio_out(OutputFile *of, OutputStream *ost, + AVFrame *frame) +{ + AVCodecContext *enc = ost->enc_ctx; + AVPacket pkt; + int ret; + + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; + + if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0) + frame->pts = ost->sync_opts; + ost->sync_opts = frame->pts + frame->nb_samples; + + ost->samples_encoded += frame->nb_samples; + ost->frames_encoded++; + + ret = avcodec_send_frame(enc, frame); + if (ret < 0) + goto error; + + while (1) { + ret = avcodec_receive_packet(enc, &pkt); + if (ret == AVERROR(EAGAIN)) + break; + if (ret < 0) + goto error; + + output_packet(of, &pkt, ost, 0); + } + + return; +error: + av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n"); + exit_program(1); +} + +static void do_subtitle_out(OutputFile *of, + OutputStream *ost, + InputStream *ist, + AVSubtitle *sub, + int64_t pts) +{ + static uint8_t *subtitle_out = NULL; + int subtitle_out_max_size = 1024 * 1024; + int subtitle_out_size, nb, i; + AVCodecContext *enc; + AVPacket pkt; + + if (pts == AV_NOPTS_VALUE) { + av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n"); + if (exit_on_error) + exit_program(1); + return; + } + + enc = ost->enc_ctx; + + if (!subtitle_out) { + subtitle_out = av_malloc(subtitle_out_max_size); + } + + /* Note: DVB subtitle need one packet to draw them and one other + packet to clear them */ + /* XXX: signal it in the codec context ? */ + if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) + nb = 2; + else + nb = 1; + + for (i = 0; i < nb; i++) { + ost->sync_opts = av_rescale_q(pts, ist->st->time_base, enc->time_base); + if (!check_recording_time(ost)) + return; + + sub->pts = av_rescale_q(pts, ist->st->time_base, AV_TIME_BASE_Q); + // start_display_time is required to be 0 + sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q); + sub->end_display_time -= sub->start_display_time; + sub->start_display_time = 0; + + ost->frames_encoded++; + + subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out, + subtitle_out_max_size, sub); + if (subtitle_out_size < 0) { + av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n"); + exit_program(1); + } + + av_init_packet(&pkt); + pkt.data = subtitle_out; + pkt.size = subtitle_out_size; + pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->mux_timebase); + if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) { + /* XXX: the pts correction is handled here. Maybe handling + it in the codec would be better */ + if (i == 0) + pkt.pts += 90 * sub->start_display_time; + else + pkt.pts += 90 * sub->end_display_time; + } + output_packet(of, &pkt, ost, 0); + } +} + +static void do_video_out(OutputFile *of, + OutputStream *ost, + AVFrame *in_picture, + int *frame_size) +{ + int ret, format_video_sync; + AVPacket pkt; + AVCodecContext *enc = ost->enc_ctx; + + *frame_size = 0; + + format_video_sync = video_sync_method; + if (format_video_sync == VSYNC_AUTO) + format_video_sync = (of->ctx->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : + (of->ctx->oformat->flags & AVFMT_VARIABLE_FPS) ? VSYNC_VFR : VSYNC_CFR; + if (format_video_sync != VSYNC_PASSTHROUGH && + ost->frame_number && + in_picture->pts != AV_NOPTS_VALUE && + in_picture->pts < ost->sync_opts) { + nb_frames_drop++; + av_log(NULL, AV_LOG_WARNING, + "*** dropping frame %d from stream %d at ts %"PRId64"\n", + ost->frame_number, ost->st->index, in_picture->pts); + return; + } + + if (in_picture->pts == AV_NOPTS_VALUE) + in_picture->pts = ost->sync_opts; + ost->sync_opts = in_picture->pts; + + + if (!ost->frame_number) + ost->first_pts = in_picture->pts; + + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; + + if (ost->frame_number >= ost->max_frames) + return; + + if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && + ost->top_field_first >= 0) + in_picture->top_field_first = !!ost->top_field_first; + + in_picture->quality = enc->global_quality; + in_picture->pict_type = 0; + if (ost->forced_kf_index < ost->forced_kf_count && + in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { + in_picture->pict_type = AV_PICTURE_TYPE_I; + ost->forced_kf_index++; + } + + ost->frames_encoded++; + + ret = avcodec_send_frame(enc, in_picture); + if (ret < 0) + goto error; + + /* + * For video, there may be reordering, so we can't throw away frames on + * encoder flush, we need to limit them here, before they go into encoder. + */ + ost->frame_number++; + + while (1) { + ret = avcodec_receive_packet(enc, &pkt); + if (ret == AVERROR(EAGAIN)) + break; + if (ret < 0) + goto error; + + output_packet(of, &pkt, ost, 0); + *frame_size = pkt.size; + + /* if two pass, output log */ + if (ost->logfile && enc->stats_out) { + fprintf(ost->logfile, "%s", enc->stats_out); + } + + ost->sync_opts++; + } + + return; +error: + av_assert0(ret != AVERROR(EAGAIN) && ret != AVERROR_EOF); + av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n"); + exit_program(1); +} + +#if FF_API_CODED_FRAME && FF_API_ERROR_FRAME +static double psnr(double d) +{ + return -10.0 * log(d) / log(10.0); +} +#endif + +static void do_video_stats(OutputStream *ost, int frame_size) +{ + AVCodecContext *enc; + int frame_number; + double ti1, bitrate, avg_bitrate; + + /* this is executed just the first time do_video_stats is called */ + if (!vstats_file) { + vstats_file = fopen(vstats_filename, "w"); + if (!vstats_file) { + perror("fopen"); + exit_program(1); + } + } + + enc = ost->enc_ctx; + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { + frame_number = ost->frame_number; + fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, + ost->quality / (float)FF_QP2LAMBDA); + +#if FF_API_CODED_FRAME && FF_API_ERROR_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + if (enc->flags & AV_CODEC_FLAG_PSNR) + fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0))); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + fprintf(vstats_file,"f_size= %6d ", frame_size); + /* compute pts value */ + ti1 = ost->sync_opts * av_q2d(enc->time_base); + if (ti1 < 0.01) + ti1 = 0.01; + + bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0; + avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; + fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", + (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(enc->coded_frame->pict_type)); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + } +} + +static int init_output_stream(OutputStream *ost, char *error, int error_len); + +/* + * Read one frame for lavfi output for ost and encode it. + */ +static int poll_filter(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + AVFrame *filtered_frame = NULL; + int frame_size, ret; + + if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) { + return AVERROR(ENOMEM); + } + filtered_frame = ost->filtered_frame; + + if (!ost->initialized) { + char error[1024]; + ret = init_output_stream(ost, error, sizeof(error)); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n", + ost->file_index, ost->index, error); + exit_program(1); + } + } + + if (ost->enc->type == AVMEDIA_TYPE_AUDIO && + !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + ret = av_buffersink_get_samples(ost->filter->filter, filtered_frame, + ost->enc_ctx->frame_size); + else + ret = av_buffersink_get_frame(ost->filter->filter, filtered_frame); + + if (ret < 0) + return ret; + + if (filtered_frame->pts != AV_NOPTS_VALUE) { + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; + filtered_frame->pts = av_rescale_q(filtered_frame->pts, + ost->filter->filter->inputs[0]->time_base, + ost->enc_ctx->time_base) - + av_rescale_q(start_time, + AV_TIME_BASE_Q, + ost->enc_ctx->time_base); + } + + switch (ost->filter->filter->inputs[0]->type) { + case AVMEDIA_TYPE_VIDEO: + if (!ost->frame_aspect_ratio) + ost->enc_ctx->sample_aspect_ratio = filtered_frame->sample_aspect_ratio; + + do_video_out(of, ost, filtered_frame, &frame_size); + if (vstats_filename && frame_size) + do_video_stats(ost, frame_size); + break; + case AVMEDIA_TYPE_AUDIO: + do_audio_out(of, ost, filtered_frame); + break; + default: + // TODO support subtitle filters + av_assert0(0); + } + + av_frame_unref(filtered_frame); + + return 0; +} + +static void finish_output_stream(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + int i; + + ost->finished = 1; + + if (of->shortest) { + for (i = 0; i < of->ctx->nb_streams; i++) + output_streams[of->ost_index + i]->finished = 1; + } +} + +/* + * Read as many frames from possible from lavfi and encode them. + * + * Always read from the active stream with the lowest timestamp. If no frames + * are available for it then return EAGAIN and wait for more input. This way we + * can use lavfi sources that generate unlimited amount of frames without memory + * usage exploding. + */ +static int poll_filters(void) +{ + int i, ret = 0; + + while (ret >= 0 && !received_sigterm) { + OutputStream *ost = NULL; + int64_t min_pts = INT64_MAX; + + /* choose output stream with the lowest timestamp */ + for (i = 0; i < nb_output_streams; i++) { + int64_t pts = output_streams[i]->sync_opts; + + if (output_streams[i]->filter && !output_streams[i]->filter->graph->graph && + !output_streams[i]->filter->graph->nb_inputs) { + ret = configure_filtergraph(output_streams[i]->filter->graph); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n"); + return ret; + } + } + + if (!output_streams[i]->filter || output_streams[i]->finished || + !output_streams[i]->filter->graph->graph) + continue; + + pts = av_rescale_q(pts, output_streams[i]->enc_ctx->time_base, + AV_TIME_BASE_Q); + if (pts < min_pts) { + min_pts = pts; + ost = output_streams[i]; + } + } + + if (!ost) + break; + + ret = poll_filter(ost); + + if (ret == AVERROR_EOF) { + finish_output_stream(ost); + ret = 0; + } else if (ret == AVERROR(EAGAIN)) + return 0; + } + + return ret; +} + +static void print_final_stats(int64_t total_size) +{ + uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0; + uint64_t data_size = 0; + float percent = -1.0; + int i, j; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + switch (ost->enc_ctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break; + case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break; + default: other_size += ost->data_size; break; + } + extra_size += ost->enc_ctx->extradata_size; + data_size += ost->data_size; + } + + if (data_size && total_size >= data_size) + percent = 100.0 * (total_size - data_size) / data_size; + + av_log(NULL, AV_LOG_INFO, "\n"); + av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ", + video_size / 1024.0, + audio_size / 1024.0, + other_size / 1024.0, + extra_size / 1024.0); + if (percent >= 0.0) + av_log(NULL, AV_LOG_INFO, "%f%%", percent); + else + av_log(NULL, AV_LOG_INFO, "unknown"); + av_log(NULL, AV_LOG_INFO, "\n"); + + /* print verbose per-stream stats */ + for (i = 0; i < nb_input_files; i++) { + InputFile *f = input_files[i]; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", + i, f->ctx->filename); + + for (j = 0; j < f->nb_streams; j++) { + InputStream *ist = input_streams[f->ist_index + j]; + enum AVMediaType type = ist->dec_ctx->codec_type; + + total_size += ist->data_size; + total_packets += ist->nb_packets; + + av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", + i, j, media_type_string(type)); + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", + ist->nb_packets, ist->data_size); + + if (ist->decoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", + ist->frames_decoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", + total_packets, total_size); + } + + for (i = 0; i < nb_output_files; i++) { + OutputFile *of = output_files[i]; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", + i, of->ctx->filename); + + for (j = 0; j < of->ctx->nb_streams; j++) { + OutputStream *ost = output_streams[of->ost_index + j]; + enum AVMediaType type = ost->enc_ctx->codec_type; + + total_size += ost->data_size; + total_packets += ost->packets_written; + + av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", + i, j, media_type_string(type)); + if (ost->encoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", + ost->frames_encoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", + ost->packets_written, ost->data_size); + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", + total_packets, total_size); + } +} + +static void print_report(int is_last_report, int64_t timer_start) +{ + char buf[1024]; + OutputStream *ost; + AVFormatContext *oc; + int64_t total_size = 0; + AVCodecContext *enc; + int frame_number, vid, i; + double bitrate, ti1, pts; + static int64_t last_time = -1; + static int qp_histogram[52]; + + if (!print_stats && !is_last_report) + return; + + if (!is_last_report) { + int64_t cur_time; + /* display the report every 0.5 seconds */ + cur_time = av_gettime_relative(); + if (last_time == -1) { + last_time = cur_time; + return; + } + if ((cur_time - last_time) < 500000) + return; + last_time = cur_time; + } + + + oc = output_files[0]->ctx; + if (oc->pb) { + total_size = avio_size(oc->pb); + if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too + total_size = avio_tell(oc->pb); + if (total_size < 0) { + char errbuf[128]; + av_strerror(total_size, errbuf, sizeof(errbuf)); + av_log(NULL, AV_LOG_VERBOSE, "Bitrate not available, " + "avio_tell() failed: %s\n", errbuf); + total_size = 0; + } + } + + buf[0] = '\0'; + ti1 = 1e10; + vid = 0; + for (i = 0; i < nb_output_streams; i++) { + float q = -1; + ost = output_streams[i]; + enc = ost->enc_ctx; + if (!ost->stream_copy) + q = ost->quality / (float) FF_QP2LAMBDA; + + if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); + } + if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + float t = (av_gettime_relative() - timer_start) / 1000000.0; + + frame_number = ost->frame_number; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ", + frame_number, (t > 1) ? (int)(frame_number / t + 0.5) : 0, q); + if (is_last_report) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L"); + if (qp_hist) { + int j; + int qp = lrintf(q); + if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram)) + qp_histogram[qp]++; + for (j = 0; j < 32; j++) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1))); + } + +#if FF_API_CODED_FRAME && FF_API_ERROR_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + if (enc->flags & AV_CODEC_FLAG_PSNR) { + int j; + double error, error_sum = 0; + double scale, scale_sum = 0; + char type[3] = { 'Y','U','V' }; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR="); + for (j = 0; j < 3; j++) { + if (is_last_report) { + error = enc->error[j]; + scale = enc->width * enc->height * 255.0 * 255.0 * frame_number; + } else { + error = enc->coded_frame->error[j]; + scale = enc->width * enc->height * 255.0 * 255.0; + } + if (j) + scale /= 4; + error_sum += error; + scale_sum += scale; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error / scale)); + } + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum / scale_sum)); + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + vid = 1; + } + /* compute min output value */ + pts = (double)ost->last_mux_dts * av_q2d(ost->st->time_base); + if ((pts < ti1) && (pts > 0)) + ti1 = pts; + } + if (ti1 < 0.01) + ti1 = 0.01; + + bitrate = (double)(total_size * 8) / ti1 / 1000.0; + + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "size=%8.0fkB time=%0.2f bitrate=%6.1fkbits/s", + (double)total_size / 1024, ti1, bitrate); + + if (nb_frames_drop) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " drop=%d", + nb_frames_drop); + + av_log(NULL, AV_LOG_INFO, "%s \r", buf); + + fflush(stderr); + + if (is_last_report) + print_final_stats(total_size); + +} + +static void flush_encoders(void) +{ + int i, ret; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + AVCodecContext *enc = ost->enc_ctx; + OutputFile *of = output_files[ost->file_index]; + int stop_encoding = 0; + + if (!ost->encoding_needed) + continue; + + if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) + continue; + + if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO) + continue; + + avcodec_send_frame(enc, NULL); + + for (;;) { + const char *desc = NULL; + + switch (enc->codec_type) { + case AVMEDIA_TYPE_AUDIO: + desc = "Audio"; + break; + case AVMEDIA_TYPE_VIDEO: + desc = "Video"; + break; + default: + av_assert0(0); + } + + if (1) { + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; + + ret = avcodec_receive_packet(enc, &pkt); + if (ret < 0 && ret != AVERROR_EOF) { + av_log(NULL, AV_LOG_FATAL, "%s encoding failed\n", desc); + exit_program(1); + } + if (ost->logfile && enc->stats_out) { + fprintf(ost->logfile, "%s", enc->stats_out); + } + output_packet(of, &pkt, ost, ret == AVERROR_EOF); + if (ret == AVERROR_EOF) { + stop_encoding = 1; + break; + } + } + + if (stop_encoding) + break; + } + } +} + +/* + * Check whether a packet from ist should be written into ost at this time + */ +static int check_output_constraints(InputStream *ist, OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + int ist_index = input_files[ist->file_index]->ist_index + ist->st->index; + + if (ost->source_index != ist_index) + return 0; + + if (of->start_time != AV_NOPTS_VALUE && ist->last_dts < of->start_time) + return 0; + + return 1; +} + +static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) +{ + OutputFile *of = output_files[ost->file_index]; + InputFile *f = input_files [ist->file_index]; + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; + int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->mux_timebase); + AVPacket opkt = { 0 }; + + av_init_packet(&opkt); + + // EOF: flush output bitstream filters. + if (!pkt) { + output_packet(of, &opkt, ost, 1); + return; + } + + if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && + !ost->copy_initial_nonkeyframes) + return; + + if (of->recording_time != INT64_MAX && + ist->last_dts >= of->recording_time + start_time) { + ost->finished = 1; + return; + } + + if (f->recording_time != INT64_MAX) { + start_time = f->ctx->start_time; + if (f->start_time != AV_NOPTS_VALUE) + start_time += f->start_time; + if (ist->last_dts >= f->recording_time + start_time) { + ost->finished = 1; + return; + } + } + + /* force the input stream PTS */ + if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + ost->sync_opts++; + + if (pkt->pts != AV_NOPTS_VALUE) + opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->mux_timebase) - ost_tb_start_time; + else + opkt.pts = AV_NOPTS_VALUE; + + if (pkt->dts == AV_NOPTS_VALUE) + opkt.dts = av_rescale_q(ist->last_dts, AV_TIME_BASE_Q, ost->mux_timebase); + else + opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->mux_timebase); + opkt.dts -= ost_tb_start_time; + + opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase); + opkt.flags = pkt->flags; + + // FIXME remove the following 2 lines they shall be replaced by the bitstream filters + if ( ost->enc_ctx->codec_id != AV_CODEC_ID_H264 + && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG1VIDEO + && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG2VIDEO + && ost->enc_ctx->codec_id != AV_CODEC_ID_VC1 + ) { + if (av_parser_change(ost->parser, ost->parser_avctx, + &opkt.data, &opkt.size, + pkt->data, pkt->size, + pkt->flags & AV_PKT_FLAG_KEY)) { + opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0); + if (!opkt.buf) + exit_program(1); + } + } else { + opkt.data = pkt->data; + opkt.size = pkt->size; + } + + output_packet(of, &opkt, ost, 0); +} + +static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) +{ + FilterGraph *fg = ifilter->graph; + int need_reinit, ret, i; + + /* determine if the parameters for this input changed */ + need_reinit = ifilter->format != frame->format; + if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx || + (ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data)) + need_reinit = 1; + + switch (ifilter->ist->st->codecpar->codec_type) { + case AVMEDIA_TYPE_AUDIO: + need_reinit |= ifilter->sample_rate != frame->sample_rate || + ifilter->channel_layout != frame->channel_layout; + break; + case AVMEDIA_TYPE_VIDEO: + need_reinit |= ifilter->width != frame->width || + ifilter->height != frame->height; + break; + } + + if (need_reinit) { + ret = ifilter_parameters_from_frame(ifilter, frame); + if (ret < 0) + return ret; + } + + /* (re)init the graph if possible, otherwise buffer the frame and return */ + if (need_reinit || !fg->graph) { + for (i = 0; i < fg->nb_inputs; i++) { + if (fg->inputs[i]->format < 0) { + AVFrame *tmp = av_frame_clone(frame); + if (!tmp) + return AVERROR(ENOMEM); + av_frame_unref(frame); + + if (!av_fifo_space(ifilter->frame_queue)) { + ret = av_fifo_realloc2(ifilter->frame_queue, 2 * av_fifo_size(ifilter->frame_queue)); + if (ret < 0) + return ret; + } + av_fifo_generic_write(ifilter->frame_queue, &tmp, sizeof(tmp), NULL); + return 0; + } + } + + ret = poll_filters(); + if (ret < 0 && ret != AVERROR_EOF) { + char errbuf[128]; + av_strerror(ret, errbuf, sizeof(errbuf)); + + av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", errbuf); + return ret; + } + + ret = configure_filtergraph(fg); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n"); + return ret; + } + } + + ret = av_buffersrc_add_frame(ifilter->filter, frame); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error while filtering\n"); + return ret; + } + + return 0; +} + +static int ifilter_send_eof(InputFilter *ifilter) +{ + int i, j, ret; + + ifilter->eof = 1; + + if (ifilter->filter) { + ret = av_buffersrc_add_frame(ifilter->filter, NULL); + if (ret < 0) + return ret; + } else { + // the filtergraph was never configured + FilterGraph *fg = ifilter->graph; + for (i = 0; i < fg->nb_inputs; i++) + if (!fg->inputs[i]->eof) + break; + if (i == fg->nb_inputs) { + // All the input streams have finished without the filtergraph + // ever being configured. + // Mark the output streams as finished. + for (j = 0; j < fg->nb_outputs; j++) + finish_output_stream(fg->outputs[j]->ost); + } + } + + return 0; +} + +// This does not quite work like avcodec_decode_audio4/avcodec_decode_video2. +// There is the following difference: if you got a frame, you must call +// it again with pkt=NULL. pkt==NULL is treated differently from pkt.size==0 +// (pkt==NULL means get more output, pkt.size==0 is a flush/drain packet) +static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt) +{ + int ret; + + *got_frame = 0; + + if (pkt) { + ret = avcodec_send_packet(avctx, pkt); + // In particular, we don't expect AVERROR(EAGAIN), because we read all + // decoded frames with avcodec_receive_frame() until done. + if (ret < 0) + return ret == AVERROR_EOF ? 0 : ret; + } + + ret = avcodec_receive_frame(avctx, frame); + if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) + return ret; + if (ret >= 0) + *got_frame = 1; + + return 0; +} + +int guess_input_channel_layout(InputStream *ist) +{ + AVCodecContext *dec = ist->dec_ctx; + + if (!dec->channel_layout) { + char layout_name[256]; + + dec->channel_layout = av_get_default_channel_layout(dec->channels); + if (!dec->channel_layout) + return 0; + av_get_channel_layout_string(layout_name, sizeof(layout_name), + dec->channels, dec->channel_layout); + av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream " + "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name); + } + return 1; +} + +static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, + int *decode_failed) +{ + AVFrame *decoded_frame, *f; + AVCodecContext *avctx = ist->dec_ctx; + int i, ret, err = 0; + + if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + decoded_frame = ist->decoded_frame; + + ret = decode(avctx, decoded_frame, got_output, pkt); + if (ret < 0) + *decode_failed = 1; + if (!*got_output || ret < 0) + return ret; + + ist->samples_decoded += decoded_frame->nb_samples; + ist->frames_decoded++; + + /* if the decoder provides a pts, use it instead of the last packet pts. + the decoder could be delaying output by a packet or more. */ + if (decoded_frame->pts != AV_NOPTS_VALUE) + ist->next_dts = av_rescale_q(decoded_frame->pts, ist->st->time_base, AV_TIME_BASE_Q); + else if (pkt && pkt->pts != AV_NOPTS_VALUE) { + decoded_frame->pts = pkt->pts; + } + + if (decoded_frame->pts != AV_NOPTS_VALUE) + decoded_frame->pts = av_rescale_q(decoded_frame->pts, + ist->st->time_base, + (AVRational){1, avctx->sample_rate}); + ist->nb_samples = decoded_frame->nb_samples; + for (i = 0; i < ist->nb_filters; i++) { + if (i < ist->nb_filters - 1) { + f = ist->filter_frame; + err = av_frame_ref(f, decoded_frame); + if (err < 0) + break; + } else + f = decoded_frame; + + err = ifilter_send_frame(ist->filters[i], f); + if (err < 0) + break; + } + + av_frame_unref(ist->filter_frame); + av_frame_unref(decoded_frame); + return err < 0 ? err : ret; +} + +static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, + int *decode_failed) +{ + AVFrame *decoded_frame, *f; + int i, ret = 0, err = 0; + + if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + decoded_frame = ist->decoded_frame; + + ret = decode(ist->dec_ctx, decoded_frame, got_output, pkt); + if (ret < 0) + *decode_failed = 1; + if (!*got_output || ret < 0) + return ret; + + ist->frames_decoded++; + + if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) { + err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame); + if (err < 0) + goto fail; + } + ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; + + decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pts, + decoded_frame->pkt_dts); + if (ist->framerate.num) + decoded_frame->pts = ist->cfr_next_pts++; + + if (ist->st->sample_aspect_ratio.num) + decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio; + + for (i = 0; i < ist->nb_filters; i++) { + if (i < ist->nb_filters - 1) { + f = ist->filter_frame; + err = av_frame_ref(f, decoded_frame); + if (err < 0) + break; + } else + f = decoded_frame; + + err = ifilter_send_frame(ist->filters[i], f); + if (err < 0) + break; + } + +fail: + av_frame_unref(ist->filter_frame); + av_frame_unref(decoded_frame); + return err < 0 ? err : ret; +} + +static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, + int *decode_failed) +{ + AVSubtitle subtitle; + int i, ret = avcodec_decode_subtitle2(ist->dec_ctx, + &subtitle, got_output, pkt); + if (ret < 0) { + *decode_failed = 1; + return ret; + } + if (!*got_output) + return ret; + + ist->frames_decoded++; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + + if (!check_output_constraints(ist, ost) || !ost->encoding_needed) + continue; + + do_subtitle_out(output_files[ost->file_index], ost, ist, &subtitle, pkt->pts); + } + + avsubtitle_free(&subtitle); + return ret; +} + +static int send_filter_eof(InputStream *ist) +{ + int i, ret; + for (i = 0; i < ist->nb_filters; i++) { + ret = ifilter_send_eof(ist->filters[i]); + if (ret < 0) + return ret; + } + return 0; +} + +/* pkt = NULL means EOF (needed to flush decoder buffers) */ +static void process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof) +{ + int i; + int repeating = 0; + AVPacket avpkt; + + if (ist->next_dts == AV_NOPTS_VALUE) + ist->next_dts = ist->last_dts; + + if (!pkt) { + /* EOF handling */ + av_init_packet(&avpkt); + avpkt.data = NULL; + avpkt.size = 0; + } else { + avpkt = *pkt; + } + + if (pkt && pkt->dts != AV_NOPTS_VALUE) + ist->next_dts = ist->last_dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); + + // while we have more to decode or while the decoder did output something on EOF + while (ist->decoding_needed && (!pkt || avpkt.size > 0)) { + int ret = 0; + int got_output = 0; + int decode_failed = 0; + + if (!repeating) + ist->last_dts = ist->next_dts; + + switch (ist->dec_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + ret = decode_audio (ist, repeating ? NULL : &avpkt, &got_output, + &decode_failed); + break; + case AVMEDIA_TYPE_VIDEO: + ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, + &decode_failed); + if (repeating && !got_output) + ; + else if (pkt && pkt->duration) + ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + else if (ist->st->avg_frame_rate.num) + ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), + AV_TIME_BASE_Q); + else if (ist->dec_ctx->framerate.num != 0) { + int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : + ist->dec_ctx->ticks_per_frame; + ist->next_dts += av_rescale_q(ticks, ist->dec_ctx->framerate, AV_TIME_BASE_Q); + } + break; + case AVMEDIA_TYPE_SUBTITLE: + if (repeating) + break; + ret = transcode_subtitles(ist, &avpkt, &got_output, &decode_failed); + break; + default: + return; + } + + if (ret < 0) { + if (decode_failed) { + av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d\n", + ist->file_index, ist->st->index); + } else { + av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded " + "data for stream #%d:%d\n", ist->file_index, ist->st->index); + } + if (!decode_failed || exit_on_error) + exit_program(1); + break; + } + + if (!got_output) + break; + + repeating = 1; + } + + /* after flushing, send an EOF on all the filter inputs attached to the stream */ + /* except when looping we need to flush but not to send an EOF */ + if (!pkt && ist->decoding_needed && !no_eof) { + int ret = send_filter_eof(ist); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); + exit_program(1); + } + } + + /* handle stream copy */ + if (!ist->decoding_needed) { + ist->last_dts = ist->next_dts; + switch (ist->dec_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) / + ist->dec_ctx->sample_rate; + break; + case AVMEDIA_TYPE_VIDEO: + if (ist->dec_ctx->framerate.num != 0) { + int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame; + ist->next_dts += ((int64_t)AV_TIME_BASE * + ist->dec_ctx->framerate.den * ticks) / + ist->dec_ctx->framerate.num; + } + break; + } + } + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + + if (!check_output_constraints(ist, ost) || ost->encoding_needed) + continue; + + do_streamcopy(ist, ost, pkt); + } + + return; +} + +static void print_sdp(void) +{ + char sdp[16384]; + int i; + AVFormatContext **avc; + + for (i = 0; i < nb_output_files; i++) { + if (!output_files[i]->header_written) + return; + } + + avc = av_malloc(sizeof(*avc) * nb_output_files); + if (!avc) + exit_program(1); + for (i = 0; i < nb_output_files; i++) + avc[i] = output_files[i]->ctx; + + av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp)); + printf("SDP:\n%s\n", sdp); + fflush(stdout); + av_freep(&avc); +} + +static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt) +{ + int i; + for (i = 0; hwaccels[i].name; i++) + if (hwaccels[i].pix_fmt == pix_fmt) + return &hwaccels[i]; + return NULL; +} + +static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts) +{ + InputStream *ist = s->opaque; + const enum AVPixelFormat *p; + int ret; + + for (p = pix_fmts; *p != -1; p++) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p); + const HWAccel *hwaccel; + + if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) + break; + + hwaccel = get_hwaccel(*p); + if (!hwaccel || + (ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) || + (ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != hwaccel->id)) + continue; + + ret = hwaccel->init(s); + if (ret < 0) { + if (ist->hwaccel_id == hwaccel->id) { + av_log(NULL, AV_LOG_FATAL, + "%s hwaccel requested for input stream #%d:%d, " + "but cannot be initialized.\n", hwaccel->name, + ist->file_index, ist->st->index); + return AV_PIX_FMT_NONE; + } + continue; + } + + if (ist->hw_frames_ctx) { + s->hw_frames_ctx = av_buffer_ref(ist->hw_frames_ctx); + if (!s->hw_frames_ctx) + return AV_PIX_FMT_NONE; + } + + ist->active_hwaccel_id = hwaccel->id; + ist->hwaccel_pix_fmt = *p; + break; + } + + return *p; +} + +static int get_buffer(AVCodecContext *s, AVFrame *frame, int flags) +{ + InputStream *ist = s->opaque; + + if (ist->hwaccel_get_buffer && frame->format == ist->hwaccel_pix_fmt) + return ist->hwaccel_get_buffer(s, frame, flags); + + return avcodec_default_get_buffer2(s, frame, flags); +} + +static int init_input_stream(int ist_index, char *error, int error_len) +{ + int ret; + InputStream *ist = input_streams[ist_index]; + + if (ist->decoding_needed) { + AVCodec *codec = ist->dec; + if (!codec) { + snprintf(error, error_len, "Decoder (codec id %d) not found for input stream #%d:%d", + ist->dec_ctx->codec_id, ist->file_index, ist->st->index); + return AVERROR(EINVAL); + } + + ist->dec_ctx->opaque = ist; + ist->dec_ctx->get_format = get_format; + ist->dec_ctx->get_buffer2 = get_buffer; + ist->dec_ctx->thread_safe_callbacks = 1; + + av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0); + + if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) + av_dict_set(&ist->decoder_opts, "threads", "auto", 0); + + ret = hw_device_setup_for_decode(ist); + if (ret < 0) { + char errbuf[128]; + av_strerror(ret, errbuf, sizeof(errbuf)); + snprintf(error, error_len, "Device setup failed for " + "decoder on input stream #%d:%d : %s", + ist->file_index, ist->st->index, errbuf); + return ret; + } + + if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) { + char errbuf[128]; + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 0); + + av_strerror(ret, errbuf, sizeof(errbuf)); + + snprintf(error, error_len, + "Error while opening decoder for input stream " + "#%d:%d : %s", + ist->file_index, ist->st->index, errbuf); + return ret; + } + assert_avoptions(ist->decoder_opts); + } + + ist->last_dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; + ist->next_dts = AV_NOPTS_VALUE; + init_pts_correction(&ist->pts_ctx); + + return 0; +} + +static InputStream *get_input_stream(OutputStream *ost) +{ + if (ost->source_index >= 0) + return input_streams[ost->source_index]; + + if (ost->filter) { + FilterGraph *fg = ost->filter->graph; + int i; + + for (i = 0; i < fg->nb_inputs; i++) + if (fg->inputs[i]->ist->dec_ctx->codec_type == ost->enc_ctx->codec_type) + return fg->inputs[i]->ist; + } + + return NULL; +} + +/* open the muxer when all the streams are initialized */ +static int check_init_output_file(OutputFile *of, int file_index) +{ + int ret, i; + + for (i = 0; i < of->ctx->nb_streams; i++) { + OutputStream *ost = output_streams[of->ost_index + i]; + if (!ost->initialized) + return 0; + } + + of->ctx->interrupt_callback = int_cb; + + ret = avformat_write_header(of->ctx, &of->opts); + if (ret < 0) { + char errbuf[128]; + + av_strerror(ret, errbuf, sizeof(errbuf)); + + av_log(NULL, AV_LOG_ERROR, + "Could not write header for output file #%d " + "(incorrect codec parameters ?): %s", + file_index, errbuf); + return ret; + } + assert_avoptions(of->opts); + of->header_written = 1; + + av_dump_format(of->ctx, file_index, of->ctx->filename, 1); + + if (want_sdp) + print_sdp(); + + /* flush the muxing queues */ + for (i = 0; i < of->ctx->nb_streams; i++) { + OutputStream *ost = output_streams[of->ost_index + i]; + + while (av_fifo_size(ost->muxing_queue)) { + AVPacket pkt; + av_fifo_generic_read(ost->muxing_queue, &pkt, sizeof(pkt), NULL); + write_packet(of, &pkt, ost); + } + } + + return 0; +} + +static int init_output_bsfs(OutputStream *ost) +{ + AVBSFContext *ctx; + int i, ret; + + if (!ost->nb_bitstream_filters) + return 0; + + for (i = 0; i < ost->nb_bitstream_filters; i++) { + ctx = ost->bsf_ctx[i]; + + ret = avcodec_parameters_copy(ctx->par_in, + i ? ost->bsf_ctx[i - 1]->par_out : ost->st->codecpar); + if (ret < 0) + return ret; + + ctx->time_base_in = i ? ost->bsf_ctx[i - 1]->time_base_out : ost->st->time_base; + + ret = av_bsf_init(ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n", + ctx->filter->name); + return ret; + } + } + + ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out); + if (ret < 0) + return ret; + + ost->st->time_base = ctx->time_base_out; + + return 0; +} + +static int init_output_stream_streamcopy(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + InputStream *ist = get_input_stream(ost); + AVCodecParameters *par_dst = ost->st->codecpar; + AVCodecParameters *par_src = ist->st->codecpar; + AVRational sar; + uint32_t codec_tag = par_dst->codec_tag; + int i, ret; + + if (!codec_tag) { + if (!of->ctx->oformat->codec_tag || + av_codec_get_id (of->ctx->oformat->codec_tag, par_src->codec_tag) == par_src->codec_id || + av_codec_get_tag(of->ctx->oformat->codec_tag, par_src->codec_id) <= 0) + codec_tag = par_src->codec_tag; + } + + ret = avcodec_parameters_copy(par_dst, par_src); + if (ret < 0) + return ret; + + par_dst->codec_tag = codec_tag; + + ost->st->disposition = ist->st->disposition; + + ost->st->time_base = ist->st->time_base; + + if (ost->bitrate_override) + par_dst->bit_rate = ost->bitrate_override; + + if (ist->st->nb_side_data) { + ost->st->side_data = av_realloc_array(NULL, ist->st->nb_side_data, + sizeof(*ist->st->side_data)); + if (!ost->st->side_data) + return AVERROR(ENOMEM); + + for (i = 0; i < ist->st->nb_side_data; i++) { + const AVPacketSideData *sd_src = &ist->st->side_data[i]; + AVPacketSideData *sd_dst = &ost->st->side_data[i]; + + sd_dst->data = av_malloc(sd_src->size); + if (!sd_dst->data) + return AVERROR(ENOMEM); + memcpy(sd_dst->data, sd_src->data, sd_src->size); + sd_dst->size = sd_src->size; + sd_dst->type = sd_src->type; + ost->st->nb_side_data++; + } + } + + ost->parser = av_parser_init(par_dst->codec_id); + ost->parser_avctx = avcodec_alloc_context3(NULL); + if (!ost->parser_avctx) + return AVERROR(ENOMEM); + + if (par_dst->codec_type == AVMEDIA_TYPE_VIDEO) { + if (ost->frame_aspect_ratio) + sar = av_d2q(ost->frame_aspect_ratio * par_dst->height / par_dst->width, 255); + else if (ist->st->sample_aspect_ratio.num) + sar = ist->st->sample_aspect_ratio; + else + sar = par_src->sample_aspect_ratio; + ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar; + } + + return 0; +} + +static void set_encoder_id(OutputFile *of, OutputStream *ost) +{ + AVDictionaryEntry *e; + + uint8_t *encoder_string; + int encoder_string_len; + int format_flags = 0; + + e = av_dict_get(of->opts, "fflags", NULL, 0); + if (e) { + const AVOption *o = av_opt_find(of->ctx, "fflags", NULL, 0, 0); + if (!o) + return; + av_opt_eval_flags(of->ctx, o, e->value, &format_flags); + } + + encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(ost->enc->name) + 2; + encoder_string = av_mallocz(encoder_string_len); + if (!encoder_string) + exit_program(1); + + if (!(format_flags & AVFMT_FLAG_BITEXACT)) + av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); + av_strlcat(encoder_string, ost->enc->name, encoder_string_len); + av_dict_set(&ost->st->metadata, "encoder", encoder_string, + AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE); +} + +static void parse_forced_key_frames(char *kf, OutputStream *ost, + AVCodecContext *avctx) +{ + char *p; + int n = 1, i; + int64_t t; + + for (p = kf; *p; p++) + if (*p == ',') + n++; + ost->forced_kf_count = n; + ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n); + if (!ost->forced_kf_pts) { + av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n"); + exit_program(1); + } + + p = kf; + for (i = 0; i < n; i++) { + char *next = strchr(p, ','); + + if (next) + *next++ = 0; + + t = parse_time_or_die("force_key_frames", p, 1); + ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base); + + p = next; + } +} + +static int init_output_stream_encode(OutputStream *ost) +{ + InputStream *ist = get_input_stream(ost); + AVCodecContext *enc_ctx = ost->enc_ctx; + AVCodecContext *dec_ctx = NULL; + + set_encoder_id(output_files[ost->file_index], ost); + + if (ist) { + ost->st->disposition = ist->st->disposition; + + dec_ctx = ist->dec_ctx; + + enc_ctx->bits_per_raw_sample = dec_ctx->bits_per_raw_sample; + enc_ctx->chroma_sample_location = dec_ctx->chroma_sample_location; + } + + switch (enc_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + enc_ctx->sample_fmt = ost->filter->filter->inputs[0]->format; + enc_ctx->sample_rate = ost->filter->filter->inputs[0]->sample_rate; + enc_ctx->channel_layout = ost->filter->filter->inputs[0]->channel_layout; + enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout); + enc_ctx->time_base = (AVRational){ 1, enc_ctx->sample_rate }; + break; + case AVMEDIA_TYPE_VIDEO: + enc_ctx->time_base = ost->filter->filter->inputs[0]->time_base; + + enc_ctx->width = ost->filter->filter->inputs[0]->w; + enc_ctx->height = ost->filter->filter->inputs[0]->h; + enc_ctx->sample_aspect_ratio = ost->st->sample_aspect_ratio = + ost->frame_aspect_ratio ? // overridden by the -aspect cli option + av_d2q(ost->frame_aspect_ratio * enc_ctx->height/enc_ctx->width, 255) : + ost->filter->filter->inputs[0]->sample_aspect_ratio; + enc_ctx->pix_fmt = ost->filter->filter->inputs[0]->format; + + enc_ctx->framerate = ost->frame_rate; + + ost->st->avg_frame_rate = ost->frame_rate; + + if (dec_ctx && + (enc_ctx->width != dec_ctx->width || + enc_ctx->height != dec_ctx->height || + enc_ctx->pix_fmt != dec_ctx->pix_fmt)) { + enc_ctx->bits_per_raw_sample = 0; + } + + if (ost->forced_keyframes) + parse_forced_key_frames(ost->forced_keyframes, ost, + ost->enc_ctx); + break; + case AVMEDIA_TYPE_SUBTITLE: + enc_ctx->time_base = (AVRational){1, 1000}; + break; + default: + abort(); + break; + } + + return 0; +} + +static int init_output_stream(OutputStream *ost, char *error, int error_len) +{ + int ret = 0; + + if (ost->encoding_needed) { + AVCodec *codec = ost->enc; + AVCodecContext *dec = NULL; + InputStream *ist; + + ret = init_output_stream_encode(ost); + if (ret < 0) + return ret; + + if ((ist = get_input_stream(ost))) + dec = ist->dec_ctx; + if (dec && dec->subtitle_header) { + ost->enc_ctx->subtitle_header = av_malloc(dec->subtitle_header_size); + if (!ost->enc_ctx->subtitle_header) + return AVERROR(ENOMEM); + memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); + ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; + } + if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) + av_dict_set(&ost->encoder_opts, "threads", "auto", 0); + + if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx && + ((AVHWFramesContext*)ost->filter->filter->inputs[0]->hw_frames_ctx->data)->format == + ost->filter->filter->inputs[0]->format) { + ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ost->filter->filter->inputs[0]->hw_frames_ctx); + if (!ost->enc_ctx->hw_frames_ctx) + return AVERROR(ENOMEM); + } else { + ret = hw_device_setup_for_encode(ost); + if (ret < 0) { + char errbuf[128]; + av_strerror(ret, errbuf, sizeof(errbuf)); + snprintf(error, error_len, "Device setup failed for " + "encoder on output stream #%d:%d : %s", + ost->file_index, ost->index, errbuf); + return ret; + } + } + + if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 1); + snprintf(error, error_len, + "Error while opening encoder for output stream #%d:%d - " + "maybe incorrect parameters such as bit_rate, rate, width or height", + ost->file_index, ost->index); + return ret; + } + assert_avoptions(ost->encoder_opts); + if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) + av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." + "It takes bits/s as argument, not kbits/s\n"); + + ret = avcodec_parameters_from_context(ost->st->codecpar, ost->enc_ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error initializing the output stream codec context.\n"); + exit_program(1); + } + + if (ost->enc_ctx->nb_coded_side_data) { + int i; + + ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data, + sizeof(*ost->st->side_data)); + if (!ost->st->side_data) + return AVERROR(ENOMEM); + + for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { + const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; + AVPacketSideData *sd_dst = &ost->st->side_data[i]; + + sd_dst->data = av_malloc(sd_src->size); + if (!sd_dst->data) + return AVERROR(ENOMEM); + memcpy(sd_dst->data, sd_src->data, sd_src->size); + sd_dst->size = sd_src->size; + sd_dst->type = sd_src->type; + ost->st->nb_side_data++; + } + } + + ost->st->time_base = ost->enc_ctx->time_base; + } else if (ost->stream_copy) { + ret = init_output_stream_streamcopy(ost); + if (ret < 0) + return ret; + + /* + * FIXME: will the codec context used by the parser during streamcopy + * This should go away with the new parser API. + */ + ret = avcodec_parameters_to_context(ost->parser_avctx, ost->st->codecpar); + if (ret < 0) + return ret; + } + + /* initialize bitstream filters for the output stream + * needs to be done here, because the codec id for streamcopy is not + * known until now */ + ret = init_output_bsfs(ost); + if (ret < 0) + return ret; + + ost->mux_timebase = ost->st->time_base; + + ost->initialized = 1; + + ret = check_init_output_file(output_files[ost->file_index], ost->file_index); + if (ret < 0) + return ret; + + return ret; +} + +static int transcode_init(void) +{ + int ret = 0, i, j, k; + OutputStream *ost; + InputStream *ist; + char error[1024]; + + /* init framerate emulation */ + for (i = 0; i < nb_input_files; i++) { + InputFile *ifile = input_files[i]; + if (ifile->rate_emu) + for (j = 0; j < ifile->nb_streams; j++) + input_streams[j + ifile->ist_index]->start = av_gettime_relative(); + } + + /* init input streams */ + for (i = 0; i < nb_input_streams; i++) + if ((ret = init_input_stream(i, error, sizeof(error))) < 0) + goto dump_format; + + /* open each encoder */ + for (i = 0; i < nb_output_streams; i++) { + // skip streams fed from filtergraphs until we have a frame for them + if (output_streams[i]->filter) + continue; + + ret = init_output_stream(output_streams[i], error, sizeof(error)); + if (ret < 0) + goto dump_format; + } + + + /* discard unused programs */ + for (i = 0; i < nb_input_files; i++) { + InputFile *ifile = input_files[i]; + for (j = 0; j < ifile->ctx->nb_programs; j++) { + AVProgram *p = ifile->ctx->programs[j]; + int discard = AVDISCARD_ALL; + + for (k = 0; k < p->nb_stream_indexes; k++) + if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) { + discard = AVDISCARD_DEFAULT; + break; + } + p->discard = discard; + } + } + + dump_format: + /* dump the stream mapping */ + av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); + for (i = 0; i < nb_input_streams; i++) { + ist = input_streams[i]; + + for (j = 0; j < ist->nb_filters; j++) { + if (!filtergraph_is_simple(ist->filters[j]->graph)) { + av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s", + ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?", + ist->filters[j]->name); + if (nb_filtergraphs > 1) + av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index); + av_log(NULL, AV_LOG_INFO, "\n"); + } + } + } + + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + + if (ost->attachment_filename) { + /* an attached file */ + av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n", + ost->attachment_filename, ost->file_index, ost->index); + continue; + } + + if (ost->filter && !filtergraph_is_simple(ost->filter->graph)) { + /* output from a complex graph */ + av_log(NULL, AV_LOG_INFO, " %s", ost->filter->name); + if (nb_filtergraphs > 1) + av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index); + + av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index, + ost->index, ost->enc ? ost->enc->name : "?"); + continue; + } + + av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d", + input_streams[ost->source_index]->file_index, + input_streams[ost->source_index]->st->index, + ost->file_index, + ost->index); + if (ost->sync_ist != input_streams[ost->source_index]) + av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]", + ost->sync_ist->file_index, + ost->sync_ist->st->index); + if (ost->stream_copy) + av_log(NULL, AV_LOG_INFO, " (copy)"); + else { + const AVCodec *in_codec = input_streams[ost->source_index]->dec; + const AVCodec *out_codec = ost->enc; + const char *decoder_name = "?"; + const char *in_codec_name = "?"; + const char *encoder_name = "?"; + const char *out_codec_name = "?"; + const AVCodecDescriptor *desc; + + if (in_codec) { + decoder_name = in_codec->name; + desc = avcodec_descriptor_get(in_codec->id); + if (desc) + in_codec_name = desc->name; + if (!strcmp(decoder_name, in_codec_name)) + decoder_name = "native"; + } + + if (out_codec) { + encoder_name = out_codec->name; + desc = avcodec_descriptor_get(out_codec->id); + if (desc) + out_codec_name = desc->name; + if (!strcmp(encoder_name, out_codec_name)) + encoder_name = "native"; + } + + av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))", + in_codec_name, decoder_name, + out_codec_name, encoder_name); + } + av_log(NULL, AV_LOG_INFO, "\n"); + } + + if (ret) { + av_log(NULL, AV_LOG_ERROR, "%s\n", error); + return ret; + } + + return 0; +} + +/* Return 1 if there remain streams where more output is wanted, 0 otherwise. */ +static int need_output(void) +{ + int i; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + OutputFile *of = output_files[ost->file_index]; + AVFormatContext *os = output_files[ost->file_index]->ctx; + + if (ost->finished || + (os->pb && avio_tell(os->pb) >= of->limit_filesize)) + continue; + if (ost->frame_number >= ost->max_frames) { + int j; + for (j = 0; j < of->ctx->nb_streams; j++) + output_streams[of->ost_index + j]->finished = 1; + continue; + } + + return 1; + } + + return 0; +} + +static InputFile *select_input_file(void) +{ + InputFile *ifile = NULL; + int64_t ipts_min = INT64_MAX; + int i; + + for (i = 0; i < nb_input_streams; i++) { + InputStream *ist = input_streams[i]; + int64_t ipts = ist->last_dts; + + if (ist->discard || input_files[ist->file_index]->eagain) + continue; + if (!input_files[ist->file_index]->eof_reached) { + if (ipts < ipts_min) { + ipts_min = ipts; + ifile = input_files[ist->file_index]; + } + } + } + + return ifile; +} + +#if HAVE_PTHREADS +static void *input_thread(void *arg) +{ + InputFile *f = arg; + int ret = 0; + + while (!transcoding_finished && ret >= 0) { + AVPacket pkt; + ret = av_read_frame(f->ctx, &pkt); + + if (ret == AVERROR(EAGAIN)) { + av_usleep(10000); + ret = 0; + continue; + } else if (ret < 0) + break; + + pthread_mutex_lock(&f->fifo_lock); + while (!av_fifo_space(f->fifo)) + pthread_cond_wait(&f->fifo_cond, &f->fifo_lock); + + av_fifo_generic_write(f->fifo, &pkt, sizeof(pkt), NULL); + + pthread_mutex_unlock(&f->fifo_lock); + } + + f->finished = 1; + return NULL; +} + +static void free_input_threads(void) +{ + int i; + + if (nb_input_files == 1) + return; + + transcoding_finished = 1; + + for (i = 0; i < nb_input_files; i++) { + InputFile *f = input_files[i]; + AVPacket pkt; + + if (!f->fifo || f->joined) + continue; + + pthread_mutex_lock(&f->fifo_lock); + while (av_fifo_size(f->fifo)) { + av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL); + av_packet_unref(&pkt); + } + pthread_cond_signal(&f->fifo_cond); + pthread_mutex_unlock(&f->fifo_lock); + + pthread_join(f->thread, NULL); + f->joined = 1; + + while (av_fifo_size(f->fifo)) { + av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL); + av_packet_unref(&pkt); + } + av_fifo_free(f->fifo); + } +} + +static int init_input_threads(void) +{ + int i, ret; + + if (nb_input_files == 1) + return 0; + + for (i = 0; i < nb_input_files; i++) { + InputFile *f = input_files[i]; + + if (!(f->fifo = av_fifo_alloc(8*sizeof(AVPacket)))) + return AVERROR(ENOMEM); + + pthread_mutex_init(&f->fifo_lock, NULL); + pthread_cond_init (&f->fifo_cond, NULL); + + if ((ret = pthread_create(&f->thread, NULL, input_thread, f))) + return AVERROR(ret); + } + return 0; +} + +static int get_input_packet_mt(InputFile *f, AVPacket *pkt) +{ + int ret = 0; + + pthread_mutex_lock(&f->fifo_lock); + + if (av_fifo_size(f->fifo)) { + av_fifo_generic_read(f->fifo, pkt, sizeof(*pkt), NULL); + pthread_cond_signal(&f->fifo_cond); + } else { + if (f->finished) + ret = AVERROR_EOF; + else + ret = AVERROR(EAGAIN); + } + + pthread_mutex_unlock(&f->fifo_lock); + + return ret; +} +#endif + +static int get_input_packet(InputFile *f, AVPacket *pkt) +{ + if (f->rate_emu) { + int i; + for (i = 0; i < f->nb_streams; i++) { + InputStream *ist = input_streams[f->ist_index + i]; + int64_t pts = av_rescale(ist->last_dts, 1000000, AV_TIME_BASE); + int64_t now = av_gettime_relative() - ist->start; + if (pts > now) + return AVERROR(EAGAIN); + } + } + +#if HAVE_PTHREADS + if (nb_input_files > 1) + return get_input_packet_mt(f, pkt); +#endif + return av_read_frame(f->ctx, pkt); +} + +static int got_eagain(void) +{ + int i; + for (i = 0; i < nb_input_files; i++) + if (input_files[i]->eagain) + return 1; + return 0; +} + +static void reset_eagain(void) +{ + int i; + for (i = 0; i < nb_input_files; i++) + input_files[i]->eagain = 0; +} + +// set duration to max(tmp, duration) in a proper time base and return duration's time_base +static AVRational duration_max(int64_t tmp, int64_t *duration, AVRational tmp_time_base, + AVRational time_base) +{ + int ret; + + if (!*duration) { + *duration = tmp; + return tmp_time_base; + } + + ret = av_compare_ts(*duration, time_base, tmp, tmp_time_base); + if (ret < 0) { + *duration = tmp; + return tmp_time_base; + } + + return time_base; +} + +static int seek_to_start(InputFile *ifile, AVFormatContext *is) +{ + InputStream *ist; + AVCodecContext *avctx; + int i, ret, has_audio = 0; + int64_t duration = 0; + + ret = av_seek_frame(is, -1, is->start_time, 0); + if (ret < 0) + return ret; + + for (i = 0; i < ifile->nb_streams; i++) { + ist = input_streams[ifile->ist_index + i]; + avctx = ist->dec_ctx; + + // flush decoders + if (ist->decoding_needed) { + process_input_packet(ist, NULL, 1); + avcodec_flush_buffers(avctx); + } + + /* duration is the length of the last frame in a stream + * when audio stream is present we don't care about + * last video frame length because it's not defined exactly */ + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && ist->nb_samples) + has_audio = 1; + } + + for (i = 0; i < ifile->nb_streams; i++) { + ist = input_streams[ifile->ist_index + i]; + avctx = ist->dec_ctx; + + if (has_audio) { + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && ist->nb_samples) { + AVRational sample_rate = {1, avctx->sample_rate}; + + duration = av_rescale_q(ist->nb_samples, sample_rate, ist->st->time_base); + } else + continue; + } else { + if (ist->framerate.num) { + duration = av_rescale_q(1, ist->framerate, ist->st->time_base); + } else if (ist->st->avg_frame_rate.num) { + duration = av_rescale_q(1, ist->st->avg_frame_rate, ist->st->time_base); + } else duration = 1; + } + if (!ifile->duration) + ifile->time_base = ist->st->time_base; + /* the total duration of the stream, max_pts - min_pts is + * the duration of the stream without the last frame */ + duration += ist->max_pts - ist->min_pts; + ifile->time_base = duration_max(duration, &ifile->duration, ist->st->time_base, + ifile->time_base); + } + + if (ifile->loop > 0) + ifile->loop--; + + return ret; +} + +/* + * Read one packet from an input file and send it for + * - decoding -> lavfi (audio/video) + * - decoding -> encoding -> muxing (subtitles) + * - muxing (streamcopy) + * + * Return + * - 0 -- one packet was read and processed + * - AVERROR(EAGAIN) -- no packets were available for selected file, + * this function should be called again + * - AVERROR_EOF -- this function should not be called again + */ +static int process_input(void) +{ + InputFile *ifile; + AVFormatContext *is; + InputStream *ist; + AVPacket pkt; + int ret, i, j; + int64_t duration; + + /* select the stream that we must read now */ + ifile = select_input_file(); + /* if none, if is finished */ + if (!ifile) { + if (got_eagain()) { + reset_eagain(); + av_usleep(10000); + return AVERROR(EAGAIN); + } + av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from.\n"); + return AVERROR_EOF; + } + + is = ifile->ctx; + ret = get_input_packet(ifile, &pkt); + + if (ret == AVERROR(EAGAIN)) { + ifile->eagain = 1; + return ret; + } + if (ret < 0 && ifile->loop) { + ret = seek_to_start(ifile, is); + if(ret < 0) + av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n"); + else + ret = get_input_packet(ifile, &pkt); + } + if (ret < 0) { + if (ret != AVERROR_EOF) { + print_error(is->filename, ret); + if (exit_on_error) + exit_program(1); + } + ifile->eof_reached = 1; + + for (i = 0; i < ifile->nb_streams; i++) { + ist = input_streams[ifile->ist_index + i]; + if (ist->decoding_needed) + process_input_packet(ist, NULL, 0); + + /* mark all outputs that don't go through lavfi as finished */ + for (j = 0; j < nb_output_streams; j++) { + OutputStream *ost = output_streams[j]; + + if (ost->source_index == ifile->ist_index + i && + (ost->stream_copy || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) + finish_output_stream(ost); + } + } + + return AVERROR(EAGAIN); + } + + reset_eagain(); + + if (do_pkt_dump) { + av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump, + is->streams[pkt.stream_index]); + } + /* the following test is needed in case new streams appear + dynamically in stream : we ignore them */ + if (pkt.stream_index >= ifile->nb_streams) + goto discard_packet; + + ist = input_streams[ifile->ist_index + pkt.stream_index]; + + ist->data_size += pkt.size; + ist->nb_packets++; + + if (ist->discard) + goto discard_packet; + + /* add the stream-global side data to the first packet */ + if (ist->nb_packets == 1) + for (i = 0; i < ist->st->nb_side_data; i++) { + AVPacketSideData *src_sd = &ist->st->side_data[i]; + uint8_t *dst_data; + + if (av_packet_get_side_data(&pkt, src_sd->type, NULL)) + continue; + if (ist->autorotate && src_sd->type == AV_PKT_DATA_DISPLAYMATRIX) + continue; + + dst_data = av_packet_new_side_data(&pkt, src_sd->type, src_sd->size); + if (!dst_data) + exit_program(1); + + memcpy(dst_data, src_sd->data, src_sd->size); + } + + if (pkt.dts != AV_NOPTS_VALUE) + pkt.dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base); + + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts *= ist->ts_scale; + if (pkt.dts != AV_NOPTS_VALUE) + pkt.dts *= ist->ts_scale; + + if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || + ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) && + pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && + (is->iformat->flags & AVFMT_TS_DISCONT)) { + int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q); + int64_t delta = pkt_dts - ist->next_dts; + + if ((FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || pkt_dts + 1 < ist->last_dts) && !copy_ts) { + ifile->ts_offset -= delta; + av_log(NULL, AV_LOG_DEBUG, + "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", + delta, ifile->ts_offset); + pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); + } + } + duration = av_rescale_q(ifile->duration, ifile->time_base, ist->st->time_base); + if (pkt.pts != AV_NOPTS_VALUE) { + pkt.pts += duration; + ist->max_pts = FFMAX(pkt.pts, ist->max_pts); + ist->min_pts = FFMIN(pkt.pts, ist->min_pts); + } + + if (pkt.dts != AV_NOPTS_VALUE) + pkt.dts += duration; + + process_input_packet(ist, &pkt, 0); + +discard_packet: + av_packet_unref(&pkt); + + return 0; +} + +/* + * The following code is the main loop of the file converter + */ +static int transcode(void) +{ + int ret, i, need_input = 1; + AVFormatContext *os; + OutputStream *ost; + InputStream *ist; + int64_t timer_start; + + ret = transcode_init(); + if (ret < 0) + goto fail; + + av_log(NULL, AV_LOG_INFO, "Press ctrl-c to stop encoding\n"); + term_init(); + + timer_start = av_gettime_relative(); + +#if HAVE_PTHREADS + if ((ret = init_input_threads()) < 0) + goto fail; +#endif + + while (!received_sigterm) { + /* check if there's any stream where output is still needed */ + if (!need_output()) { + av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n"); + break; + } + + /* read and process one input packet if needed */ + if (need_input) { + ret = process_input(); + if (ret == AVERROR_EOF) + need_input = 0; + } + + ret = poll_filters(); + if (ret < 0 && ret != AVERROR_EOF) { + char errbuf[128]; + av_strerror(ret, errbuf, sizeof(errbuf)); + + av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", errbuf); + break; + } + + /* dump report by using the output first video and audio streams */ + print_report(0, timer_start); + } +#if HAVE_PTHREADS + free_input_threads(); +#endif + + /* at the end of stream, we must flush the decoder buffers */ + for (i = 0; i < nb_input_streams; i++) { + ist = input_streams[i]; + if (!input_files[ist->file_index]->eof_reached) { + process_input_packet(ist, NULL, 0); + } + } + poll_filters(); + flush_encoders(); + + term_exit(); + + /* write the trailer if needed and close file */ + for (i = 0; i < nb_output_files; i++) { + os = output_files[i]->ctx; + if (!output_files[i]->header_written) { + av_log(NULL, AV_LOG_ERROR, + "Nothing was written into output file %d (%s), because " + "at least one of its streams received no packets.\n", + i, os->filename); + continue; + } + av_write_trailer(os); + } + + /* dump report by using the first video and audio streams */ + print_report(1, timer_start); + + /* close each encoder */ + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + if (ost->encoding_needed) { + av_freep(&ost->enc_ctx->stats_in); + } + } + + /* close each decoder */ + for (i = 0; i < nb_input_streams; i++) { + ist = input_streams[i]; + if (ist->decoding_needed) { + avcodec_close(ist->dec_ctx); + if (ist->hwaccel_uninit) + ist->hwaccel_uninit(ist->dec_ctx); + } + } + + av_buffer_unref(&hw_device_ctx); + hw_device_free_all(); + + /* finished ! */ + ret = 0; + + fail: +#if HAVE_PTHREADS + free_input_threads(); +#endif + + if (output_streams) { + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + if (ost) { + if (ost->logfile) { + fclose(ost->logfile); + ost->logfile = NULL; + } + av_free(ost->forced_kf_pts); + av_dict_free(&ost->encoder_opts); + av_dict_free(&ost->resample_opts); + } + } + } + return ret; +} + +static int64_t getutime(void) +{ +#if HAVE_GETRUSAGE + struct rusage rusage; + + getrusage(RUSAGE_SELF, &rusage); + return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec; +#elif HAVE_GETPROCESSTIMES + HANDLE proc; + FILETIME c, e, k, u; + proc = GetCurrentProcess(); + GetProcessTimes(proc, &c, &e, &k, &u); + return ((int64_t) u.dwHighDateTime << 32 | u.dwLowDateTime) / 10; +#else + return av_gettime_relative(); +#endif +} + +static int64_t getmaxrss(void) +{ +#if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS + struct rusage rusage; + getrusage(RUSAGE_SELF, &rusage); + return (int64_t)rusage.ru_maxrss * 1024; +#elif HAVE_GETPROCESSMEMORYINFO + HANDLE proc; + PROCESS_MEMORY_COUNTERS memcounters; + proc = GetCurrentProcess(); + memcounters.cb = sizeof(memcounters); + GetProcessMemoryInfo(proc, &memcounters, sizeof(memcounters)); + return memcounters.PeakPagefileUsage; +#else + return 0; +#endif +} + +int main(int argc, char **argv) +{ + int i, ret; + int64_t ti; + + register_exit(avconv_cleanup); + + av_log_set_flags(AV_LOG_SKIP_REPEATED); + parse_loglevel(argc, argv, options); + + avcodec_register_all(); +#if CONFIG_AVDEVICE + avdevice_register_all(); +#endif + avfilter_register_all(); + av_register_all(); + avformat_network_init(); + + show_banner(); + + /* parse options and open all input/output files */ + ret = avconv_parse_options(argc, argv); + if (ret < 0) + exit_program(1); + + if (nb_output_files <= 0 && nb_input_files == 0) { + show_usage(); + av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name); + exit_program(1); + } + + /* file converter / grab */ + if (nb_output_files <= 0) { + fprintf(stderr, "At least one output file must be specified\n"); + exit_program(1); + } + + for (i = 0; i < nb_output_files; i++) { + if (strcmp(output_files[i]->ctx->oformat->name, "rtp")) + want_sdp = 0; + } + + ti = getutime(); + if (transcode() < 0) + exit_program(1); + ti = getutime() - ti; + if (do_benchmark) { + int maxrss = getmaxrss() / 1024; + printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss); + } + + exit_program(0); + return 0; +} diff --git a/ffmpeg.h b/avtools/avconv.h similarity index 67% rename from ffmpeg.h rename to avtools/avconv.h index d2deb432b7..b5843fbc03 100644 --- a/ffmpeg.h +++ b/avtools/avconv.h @@ -1,29 +1,28 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef FFMPEG_H -#define FFMPEG_H +#ifndef AVCONV_H +#define AVCONV_H #include "config.h" #include #include -#include #if HAVE_PTHREADS #include @@ -40,23 +39,15 @@ #include "libavutil/avutil.h" #include "libavutil/dict.h" -#include "libavutil/eval.h" #include "libavutil/fifo.h" #include "libavutil/hwcontext.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" -#include "libavutil/threadmessage.h" - -#include "libswresample/swresample.h" #define VSYNC_AUTO -1 #define VSYNC_PASSTHROUGH 0 #define VSYNC_CFR 1 #define VSYNC_VFR 2 -#define VSYNC_VSCFR 0xfe -#define VSYNC_DROP 0xff - -#define MAX_STREAMS 1024 /* arbitrary sanity check value */ enum HWAccelID { HWACCEL_NONE = 0, @@ -64,11 +55,10 @@ enum HWAccelID { HWACCEL_VDPAU, HWACCEL_DXVA2, HWACCEL_VDA, - HWACCEL_VIDEOTOOLBOX, HWACCEL_QSV, HWACCEL_VAAPI, - HWACCEL_CUVID, HWACCEL_D3D11VA, + HWACCEL_CUVID, }; typedef struct HWAccel { @@ -95,18 +85,18 @@ typedef struct StreamMap { char *linklabel; /* name of an output link, for mapping lavfi outputs */ } StreamMap; -typedef struct { - int file_idx, stream_idx, channel_idx; // input - int ofile_idx, ostream_idx; // output -} AudioChannelMap; +/* select an input file for an output file */ +typedef struct MetadataMap { + int file; // file index + char type; // type of metadata to copy -- (g)lobal, (s)tream, (c)hapter or (p)rogram + int index; // stream/chapter/program number +} MetadataMap; typedef struct OptionsContext { OptionGroup *g; /* input/output options */ int64_t start_time; - int64_t start_time_eof; - int seek_timestamp; const char *format; SpecifierOpt *codec_names; @@ -127,7 +117,6 @@ typedef struct OptionsContext { int loop; int rate_emu; int accurate_seek; - int thread_queue_size; SpecifierOpt *ts_scale; int nb_ts_scale; @@ -145,8 +134,9 @@ typedef struct OptionsContext { /* output options */ StreamMap *stream_maps; int nb_stream_maps; - AudioChannelMap *audio_channel_maps; /* one info entry per -map_channel */ - int nb_audio_channel_maps; /* number of (valid) -map_channel settings */ + /* first item specifies output metadata, second is input */ + MetadataMap (*meta_data_maps)[2]; + int nb_meta_data_maps; int metadata_global_manual; int metadata_streams_manual; int metadata_chapters_manual; @@ -156,7 +146,6 @@ typedef struct OptionsContext { int chapters_input_file; int64_t recording_time; - int64_t stop_time; uint64_t limit_filesize; float mux_preload; float mux_max_delay; @@ -183,6 +172,8 @@ typedef struct OptionsContext { int nb_sample_fmts; SpecifierOpt *qscale; int nb_qscale; + SpecifierOpt *bitrates; + int nb_bitrates; SpecifierOpt *forced_key_frames; int nb_forced_key_frames; SpecifierOpt *force_fps; @@ -195,8 +186,6 @@ typedef struct OptionsContext { int nb_intra_matrices; SpecifierOpt *inter_matrices; int nb_inter_matrices; - SpecifierOpt *chroma_intra_matrices; - int nb_chroma_intra_matrices; SpecifierOpt *top_field_first; int nb_top_field_first; SpecifierOpt *metadata_map; @@ -205,38 +194,16 @@ typedef struct OptionsContext { int nb_presets; SpecifierOpt *copy_initial_nonkeyframes; int nb_copy_initial_nonkeyframes; - SpecifierOpt *copy_prior_start; - int nb_copy_prior_start; SpecifierOpt *filters; int nb_filters; SpecifierOpt *filter_scripts; int nb_filter_scripts; - SpecifierOpt *reinit_filters; - int nb_reinit_filters; - SpecifierOpt *fix_sub_duration; - int nb_fix_sub_duration; - SpecifierOpt *canvas_sizes; - int nb_canvas_sizes; SpecifierOpt *pass; 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; - int nb_apad; - SpecifierOpt *discard; - int nb_discard; - SpecifierOpt *disposition; - int nb_disposition; - SpecifierOpt *program; - int nb_program; - SpecifierOpt *time_bases; - int nb_time_bases; - SpecifierOpt *enc_time_bases; - int nb_enc_time_bases; } OptionsContext; typedef struct InputFilter { @@ -244,7 +211,6 @@ typedef struct InputFilter { struct InputStream *ist; struct FilterGraph *graph; uint8_t *name; - enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video AVFifoBuffer *frame_queue; @@ -255,7 +221,6 @@ typedef struct InputFilter { AVRational sample_aspect_ratio; int sample_rate; - int channels; uint64_t channel_layout; AVBufferRef *hw_frames_ctx; @@ -291,7 +256,6 @@ typedef struct FilterGraph { const char *graph_desc; AVFilterGraph *graph; - int reconfiguration; InputFilter **inputs; int nb_inputs; @@ -303,11 +267,7 @@ typedef struct InputStream { int file_index; AVStream *st; int discard; /* true if stream data should be discarded */ - int user_set_discard; - int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ -#define DECODING_FOR_OST 1 -#define DECODING_FOR_FILTER 2 - + int decoding_needed; /* true if the packets must be decoded in 'raw_fifo' */ AVCodecContext *dec_ctx; AVCodec *dec; AVFrame *decoded_frame; @@ -315,16 +275,10 @@ typedef struct InputStream { int64_t start; /* time when read started */ /* predicted dts of the next packet read for this stream or (when there are - * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */ + * several frames in a packet) of the next frame in current packet */ int64_t next_dts; - int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units) - - int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units) - int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units) - int wrap_correction_done; - - int64_t filter_in_rescale_delta_last; - + /* dts of the last packet read for this stream */ + int64_t last_dts; 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 */ @@ -333,40 +287,18 @@ typedef struct InputStream { int64_t cfr_next_pts; int64_t nb_samples; /* number of samples in the last decoded audio frame before looping */ - + PtsCorrectionContext pts_ctx; double ts_scale; - int saw_first_ts; AVDictionary *decoder_opts; AVRational framerate; /* framerate forced with -r */ - int top_field_first; - int guess_layout_max; int autorotate; - int fix_sub_duration; - struct { /* previous decoded subtitle and related variables */ - int got_output; - int ret; - AVSubtitle subtitle; - } prev_sub; - - 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; - - int dr1; - /* decoded data from this stream goes into all those filters * currently video and audio only */ InputFilter **filters; int nb_filters; - int reinit_filters; - /* hwaccel options */ enum HWAccelID hwaccel_id; char *hwaccel_device; @@ -390,62 +322,35 @@ 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 { AVFormatContext *ctx; int eof_reached; /* true if eof reached */ int eagain; /* true if last read attempt returned EAGAIN */ - int ist_index; /* index of first stream in input_streams */ + int ist_index; /* index of first stream in ist_table */ int loop; /* set number of times input stream should be looped */ int64_t duration; /* actual duration of the longest stream in a file at the moment when looping happens */ AVRational time_base; /* time base of the duration */ - int64_t input_ts_offset; - int64_t ts_offset; - int64_t last_ts; int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */ - int seek_timestamp; int64_t recording_time; - int nb_streams; /* number of stream that ffmpeg is aware of; may be different + int nb_streams; /* number of stream that avconv is aware of; may be different from ctx.nb_streams if new streams appear during av_read_frame() */ - int nb_streams_warn; /* number of streams that the user was warned of */ int rate_emu; int accurate_seek; #if HAVE_PTHREADS - AVThreadMessageQueue *in_thread_queue; pthread_t thread; /* thread reading from this file */ - int non_blocking; /* reading packets from the thread should not block */ + int finished; /* the thread has exited */ int joined; /* the thread has been joined */ - int thread_queue_size; /* maximum number of queued packets */ + pthread_mutex_t fifo_lock; /* lock for access to fifo */ + pthread_cond_t fifo_cond; /* the main thread will signal on this cond after reading from fifo */ + AVFifoBuffer *fifo; /* demuxed packets are stored here; freed by the main thread */ #endif } InputFile; -enum forced_keyframes_const { - FKF_N, - FKF_N_FORCED, - FKF_PREV_FORCED_N, - FKF_PREV_FORCED_T, - FKF_T, - FKF_NB -}; - -#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0) - -extern const char *const forced_keyframes_const_names[]; - -typedef enum { - ENCODER_FINISHED = 1, - MUXER_FINISHED = 2, -} OSTFinished ; - typedef struct OutputStream { int file_index; /* file index */ int index; /* stream index in the output file */ @@ -455,6 +360,7 @@ typedef struct OutputStream { int frame_number; /* input pts and corresponding output pts for A/V sync */ + // double sync_ipts; /* dts from the AVPacket of the demuxer in second units */ struct InputStream *sync_ist; /* input stream to sync against */ int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number /* pts of the first frame encoded for this stream, used for limiting @@ -464,74 +370,54 @@ typedef struct OutputStream { int64_t last_mux_dts; // the timebase of the packets sent to the muxer AVRational mux_timebase; - AVRational enc_timebase; int nb_bitstream_filters; AVBSFContext **bsf_ctx; AVCodecContext *enc_ctx; - AVCodecParameters *ref_par; /* associated input codec parameters with encoders options applied */ AVCodec *enc; int64_t max_frames; AVFrame *filtered_frame; - AVFrame *last_frame; - int last_dropped; - int last_nb0_frames[3]; void *hwaccel_ctx; /* video only */ AVRational frame_rate; - int is_cfr; int force_fps; int top_field_first; - int rotate_overridden; - double rotate_override_value; - AVRational frame_aspect_ratio; + float frame_aspect_ratio; /* forced key frames */ int64_t *forced_kf_pts; int forced_kf_count; int forced_kf_index; char *forced_keyframes; - AVExpr *forced_keyframes_pexpr; - double forced_keyframes_expr_const_values[FKF_NB]; - /* audio only */ - int *audio_channels_map; /* list of the channels id to pick from the source stream */ - int audio_channels_mapped; /* number of channels in audio_channels_map */ + // the bitrate to send to the muxer for streamcopy + int bitrate_override; char *logfile_prefix; FILE *logfile; OutputFilter *filter; char *avfilter; - char *filters; ///< filtergraph associated to the -filter option - char *filters_script; ///< filtergraph script associated to the -filter_script option + int64_t sws_flags; AVDictionary *encoder_opts; - AVDictionary *sws_dict; - AVDictionary *swr_opts; AVDictionary *resample_opts; - char *apad; - OSTFinished finished; /* no more packets should be written for this stream */ - int unavailable; /* true if the steram is unavailable (possibly temporarily) */ + int finished; /* no more packets should be written for this stream */ int stream_copy; // init_output_stream() has been called for this stream - // The encoder and the bitstream filters have been initialized and the stream + // The encoder and the bistream 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; - char *disposition; - int keep_pix_fmt; + enum AVPixelFormat pix_fmts[2]; AVCodecParserContext *parser; AVCodecContext *parser_avctx; @@ -552,21 +438,15 @@ typedef struct OutputStream { /* the packets are buffered here until the muxer is ready to be initialized */ AVFifoBuffer *muxing_queue; - - /* packet picture type */ - int pict_type; - - /* frame encode sum of squared error values */ - int64_t error[4]; } OutputStream; typedef struct OutputFile { AVFormatContext *ctx; AVDictionary *opts; int ost_index; /* index of the first stream in output_streams */ - int64_t recording_time; ///< desired length of the resulting file in microseconds == AV_TIME_BASE units - int64_t start_time; ///< start time in microseconds == AV_TIME_BASE units - uint64_t limit_filesize; /* filesize limit expressed in bytes */ + int64_t recording_time; /* desired length of the resulting file in microseconds */ + int64_t start_time; /* start time in microseconds */ + uint64_t limit_filesize; int shortest; @@ -587,85 +467,56 @@ extern FilterGraph **filtergraphs; extern int nb_filtergraphs; extern char *vstats_filename; -extern char *sdp_filename; extern float audio_drift_threshold; extern float dts_delta_threshold; -extern float dts_error_threshold; extern int audio_volume; extern int audio_sync_method; extern int video_sync_method; -extern float frame_drop_threshold; extern int do_benchmark; -extern int do_benchmark_all; extern int do_deinterlace; extern int do_hex_dump; extern int do_pkt_dump; extern int copy_ts; -extern int start_at_zero; extern int copy_tb; -extern int debug_ts; extern int exit_on_error; -extern int abort_on_flags; extern int print_stats; extern int qp_hist; -extern int stdin_interaction; -extern int frame_bits_per_raw_sample; -extern AVIOContext *progress_avio; -extern float max_error_rate; -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 extern HWDevice *filter_hw_device; - -void term_init(void); -void term_exit(void); - -void reset_options(OptionsContext *o, int is_input); +void reset_options(OptionsContext *o); void show_usage(void); void opt_output_file(void *optctx, const char *filename); -void remove_avoptions(AVDictionary **a, AVDictionary *b); void assert_avoptions(AVDictionary *m); int guess_input_channel_layout(InputStream *ist); -enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, AVCodec *codec, enum AVPixelFormat target); -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); 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 avconv_parse_options(int argc, char **argv); +int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); -int videotoolbox_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); -int cuvid_init(AVCodecContext *s); +int qsv_transcode_init(OutputStream *ost); HWDevice *hw_device_get_by_name(const char *name); int hw_device_init_from_string(const char *arg, HWDevice **dev); @@ -676,4 +527,4 @@ int hw_device_setup_for_encode(OutputStream *ost); int hwaccel_decode_init(AVCodecContext *avctx); -#endif /* FFMPEG_H */ +#endif /* AVCONV_H */ diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c new file mode 100644 index 0000000000..884478da27 --- /dev/null +++ b/avtools/avconv_filter.c @@ -0,0 +1,824 @@ +/* + * avconv filter configuration + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avconv.h" + +#include "libavfilter/avfilter.h" +#include "libavfilter/buffersrc.h" + +#include "libavresample/avresample.h" + +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/channel_layout.h" +#include "libavutil/display.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" +#include "libavutil/samplefmt.h" + +/* 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) \ +{ \ + if (ofilter->var != none) { \ + get_name(ofilter->var); \ + return av_strdup(name); \ + } else if (ofilter->supported_list) { \ + const type *p; \ + AVIOContext *s = NULL; \ + uint8_t *ret; \ + int len; \ + \ + if (avio_open_dyn_buf(&s) < 0) \ + exit(1); \ + \ + for (p = ofilter->supported_list; *p != none; p++) { \ + get_name(*p); \ + avio_printf(s, "%s|", name); \ + } \ + len = avio_close_dyn_buf(s, &ret); \ + ret[len - 1] = 0; \ + return ret; \ + } else \ + return NULL; \ +} + +DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats, AV_PIX_FMT_NONE, + GET_PIX_FMT_NAME) + +DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats, + AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME) + +DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0, + GET_SAMPLE_RATE_NAME) + +DEF_CHOOSE_FORMAT(channel_layouts, uint64_t, channel_layout, channel_layouts, 0, + GET_CH_LAYOUT_NAME) + +int init_simple_filtergraph(InputStream *ist, OutputStream *ost) +{ + FilterGraph *fg = av_mallocz(sizeof(*fg)); + + if (!fg) + exit(1); + fg->index = nb_filtergraphs; + + GROW_ARRAY(fg->outputs, fg->nb_outputs); + if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0])))) + exit(1); + fg->outputs[0]->ost = ost; + fg->outputs[0]->graph = fg; + fg->outputs[0]->format = -1; + + ost->filter = fg->outputs[0]; + + GROW_ARRAY(fg->inputs, fg->nb_inputs); + if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0])))) + exit(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]) + exit_program(1); + + GROW_ARRAY(ist->filters, ist->nb_filters); + ist->filters[ist->nb_filters - 1] = fg->inputs[0]; + + GROW_ARRAY(filtergraphs, nb_filtergraphs); + filtergraphs[nb_filtergraphs - 1] = fg; + + return 0; +} + +static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) +{ + InputStream *ist = NULL; + enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx); + int i; + + // TODO: support other filter types + if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { + av_log(NULL, AV_LOG_FATAL, "Only video and audio filters supported " + "currently.\n"); + exit(1); + } + + if (in->name) { + AVFormatContext *s; + AVStream *st = NULL; + char *p; + int file_idx = strtol(in->name, &p, 0); + + if (file_idx < 0 || file_idx >= nb_input_files) { + av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtegraph description %s.\n", + file_idx, fg->graph_desc); + exit(1); + } + s = input_files[file_idx]->ctx; + + for (i = 0; i < s->nb_streams; i++) { + if (s->streams[i]->codecpar->codec_type != type) + continue; + if (check_stream_specifier(s, s->streams[i], *p == ':' ? p + 1 : p) == 1) { + st = s->streams[i]; + break; + } + } + if (!st) { + av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s " + "matches no streams.\n", p, fg->graph_desc); + exit(1); + } + ist = input_streams[input_files[file_idx]->ist_index + st->index]; + } else { + /* find the first unused stream of corresponding type */ + for (i = 0; i < nb_input_streams; i++) { + ist = input_streams[i]; + if (ist->dec_ctx->codec_type == type && ist->discard) + break; + } + if (i == nb_input_streams) { + av_log(NULL, AV_LOG_FATAL, "Cannot find a matching stream for " + "unlabeled input pad %d on filter %s\n", in->pad_idx, + in->filter_ctx->name); + exit(1); + } + } + av_assert0(ist); + + ist->discard = 0; + ist->decoding_needed = 1; + ist->st->discard = AVDISCARD_NONE; + + GROW_ARRAY(fg->inputs, fg->nb_inputs); + if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0])))) + exit(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]->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]; +} + +int init_complex_filtergraph(FilterGraph *fg) +{ + AVFilterInOut *inputs, *outputs, *cur; + AVFilterGraph *graph; + int ret = 0; + + /* this graph is only used for determining the kinds of inputs + * and outputs we have, and is discarded on exit from this function */ + graph = avfilter_graph_alloc(); + if (!graph) + return AVERROR(ENOMEM); + + ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs); + if (ret < 0) + goto fail; + + for (cur = inputs; cur; cur = cur->next) + init_input_filter(fg, cur); + + for (cur = outputs; cur;) { + GROW_ARRAY(fg->outputs, fg->nb_outputs); + fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0])); + if (!fg->outputs[fg->nb_outputs - 1]) + exit(1); + + fg->outputs[fg->nb_outputs - 1]->graph = 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); + cur = cur->next; + fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL; + } + +fail: + avfilter_inout_free(&inputs); + avfilter_graph_free(&graph); + return ret; +} + +static int insert_trim(int64_t start_time, int64_t duration, + AVFilterContext **last_filter, int *pad_idx, + const char *filter_name) +{ + AVFilterGraph *graph = (*last_filter)->graph; + AVFilterContext *ctx; + const AVFilter *trim; + enum AVMediaType type = avfilter_pad_get_type((*last_filter)->output_pads, *pad_idx); + const char *name = (type == AVMEDIA_TYPE_VIDEO) ? "trim" : "atrim"; + int ret = 0; + + if (duration == INT64_MAX && start_time == AV_NOPTS_VALUE) + return 0; + + trim = avfilter_get_by_name(name); + if (!trim) { + av_log(NULL, AV_LOG_ERROR, "%s filter not present, cannot limit " + "recording time.\n", name); + return AVERROR_FILTER_NOT_FOUND; + } + + ctx = avfilter_graph_alloc_filter(graph, trim, filter_name); + if (!ctx) + return AVERROR(ENOMEM); + + if (duration != INT64_MAX) { + ret = av_opt_set_double(ctx, "duration", (double)duration / 1e6, + AV_OPT_SEARCH_CHILDREN); + } + if (ret >= 0 && start_time != AV_NOPTS_VALUE) { + ret = av_opt_set_double(ctx, "start", (double)start_time / 1e6, + AV_OPT_SEARCH_CHILDREN); + } + if (ret < 0) { + av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", name); + return ret; + } + + ret = avfilter_init_str(ctx, NULL); + if (ret < 0) + return ret; + + ret = avfilter_link(*last_filter, *pad_idx, ctx, 0); + if (ret < 0) + return ret; + + *last_filter = ctx; + *pad_idx = 0; + return 0; +} + +static int insert_filter(AVFilterContext **last_filter, int *pad_idx, + const char *filter_name, const char *args) +{ + AVFilterGraph *graph = (*last_filter)->graph; + AVFilterContext *ctx; + int ret; + + ret = avfilter_graph_create_filter(&ctx, + avfilter_get_by_name(filter_name), + filter_name, args, NULL, graph); + if (ret < 0) + return ret; + + ret = avfilter_link(*last_filter, *pad_idx, ctx, 0); + if (ret < 0) + return ret; + + *last_filter = ctx; + *pad_idx = 0; + return 0; +} + +static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) +{ + char *pix_fmts; + OutputStream *ost = ofilter->ost; + OutputFile *of = output_files[ost->file_index]; + AVFilterContext *last_filter = out->filter_ctx; + int pad_idx = out->pad_idx; + int ret; + char name[255]; + + 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); + if (ret < 0) + return ret; + + if (ofilter->width || ofilter->height) { + char args[255]; + AVFilterContext *filter; + + snprintf(args, sizeof(args), "%d:%d:0x%X", + ofilter->width, ofilter->height, + (unsigned)ost->sws_flags); + 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) + return ret; + if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0) + return ret; + + last_filter = filter; + pad_idx = 0; + } + + if ((pix_fmts = choose_pix_fmts(ofilter))) { + AVFilterContext *filter; + 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"), + "format", pix_fmts, NULL, fg->graph); + av_freep(&pix_fmts); + if (ret < 0) + return ret; + if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0) + return ret; + + last_filter = filter; + pad_idx = 0; + } + + if (ost->frame_rate.num) { + AVFilterContext *fps; + char args[255]; + + snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num, + ost->frame_rate.den); + 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); + if (ret < 0) + return ret; + + ret = avfilter_link(last_filter, pad_idx, fps, 0); + if (ret < 0) + return ret; + last_filter = fps; + pad_idx = 0; + } + + 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); + if (ret < 0) + return ret; + + + if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0) + return ret; + + return 0; +} + +static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out) +{ + 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; + char *sample_fmts, *sample_rates, *channel_layouts; + char name[255]; + int ret; + + + 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); + if (ret < 0) + return ret; + + 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); + if (sample_fmts || sample_rates || channel_layouts) { + AVFilterContext *format; + char args[256]; + int len = 0; + + if (sample_fmts) + len += snprintf(args + len, sizeof(args) - len, "sample_fmts=%s:", + sample_fmts); + if (sample_rates) + len += snprintf(args + len, sizeof(args) - len, "sample_rates=%s:", + sample_rates); + if (channel_layouts) + len += snprintf(args + len, sizeof(args) - len, "channel_layouts=%s:", + channel_layouts); + args[len - 1] = 0; + + av_freep(&sample_fmts); + av_freep(&sample_rates); + av_freep(&channel_layouts); + + 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"), + name, args, NULL, fg->graph); + if (ret < 0) + return ret; + + ret = avfilter_link(last_filter, pad_idx, format, 0); + if (ret < 0) + return ret; + + last_filter = format; + pad_idx = 0; + } + + 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); + if (ret < 0) + return ret; + + if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0) + return ret; + + 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(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); + + switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) { + case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out); + case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out); + default: av_assert0(0); + } +} + +static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, + AVFilterInOut *in) +{ + AVFilterContext *last_filter; + const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); + InputStream *ist = ifilter->ist; + InputFile *f = input_files[ist->file_index]; + AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) : + ist->st->time_base; + AVBufferSrcParameters *par; + char name[255]; + int ret, pad_idx = 0; + + snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, + ist->file_index, ist->st->index); + + ifilter->filter = avfilter_graph_alloc_filter(fg->graph, buffer_filt, name); + if (!ifilter->filter) + return AVERROR(ENOMEM); + + par = av_buffersrc_parameters_alloc(); + if (!par) + return AVERROR(ENOMEM); + + par->sample_aspect_ratio = ifilter->sample_aspect_ratio; + par->width = ifilter->width; + par->height = ifilter->height; + par->format = ifilter->format; + par->time_base = tb; + if (ist->framerate.num) + par->frame_rate = ist->framerate; + par->hw_frames_ctx = ifilter->hw_frames_ctx; + + ret = av_buffersrc_parameters_set(ifilter->filter, par); + av_freep(&par); + if (ret < 0) + return ret; + + ret = avfilter_init_str(ifilter->filter, NULL); + if (ret < 0) + return ret; + + last_filter = ifilter->filter; + + if (ist->autorotate) { + uint8_t* displaymatrix = av_stream_get_side_data(ist->st, + AV_PKT_DATA_DISPLAYMATRIX, NULL); + if (displaymatrix) { + double rot = av_display_rotation_get((int32_t*) displaymatrix); + if (rot < -135 || rot > 135) { + ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); + if (ret < 0) + return ret; + ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); + } else if (rot < -45) { + ret = insert_filter(&last_filter, &pad_idx, "transpose", "dir=clock"); + } else if (rot > 45) { + ret = insert_filter(&last_filter, &pad_idx, "transpose", "dir=cclock"); + } + if (ret < 0) + return ret; + } + } + + snprintf(name, sizeof(name), "trim for input stream %d:%d", + ist->file_index, ist->st->index); + ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? + AV_NOPTS_VALUE : 0, f->recording_time, &last_filter, &pad_idx, name); + if (ret < 0) + return ret; + + if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0) + return ret; + return 0; +} + +static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, + AVFilterInOut *in) +{ + AVFilterContext *last_filter; + const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer"); + InputStream *ist = ifilter->ist; + InputFile *f = input_files[ist->file_index]; + AVBufferSrcParameters *par; + char args[255], name[255]; + int ret, pad_idx = 0; + + snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, + ist->file_index, ist->st->index); + + ifilter->filter = avfilter_graph_alloc_filter(fg->graph, abuffer_filt, name); + if (!ifilter->filter) + return AVERROR(ENOMEM); + + par = av_buffersrc_parameters_alloc(); + if (!par) + return AVERROR(ENOMEM); + + par->time_base = (AVRational){ 1, ifilter->sample_rate }; + par->sample_rate = ifilter->sample_rate; + par->format = ifilter->format; + par->channel_layout = ifilter->channel_layout; + + ret = av_buffersrc_parameters_set(ifilter->filter, par); + av_freep(&par); + if (ret < 0) + return ret; + + ret = avfilter_init_str(ifilter->filter, NULL); + if (ret < 0) + return ret; + last_filter = ifilter->filter; + + if (audio_sync_method > 0) { + AVFilterContext *async; + int len = 0; + + av_log(NULL, AV_LOG_WARNING, "-async has been deprecated. Used the " + "asyncts audio filter instead.\n"); + + if (audio_sync_method > 1) + len += snprintf(args + len, sizeof(args) - len, "compensate=1:" + "max_comp=%d:", audio_sync_method); + snprintf(args + len, sizeof(args) - len, "min_delta=%f", + audio_drift_threshold); + + snprintf(name, sizeof(name), "graph %d audio sync for input stream %d:%d", + fg->index, ist->file_index, ist->st->index); + ret = avfilter_graph_create_filter(&async, + avfilter_get_by_name("asyncts"), + name, args, NULL, fg->graph); + if (ret < 0) + return ret; + + ret = avfilter_link(last_filter, 0, async, 0); + if (ret < 0) + return ret; + + last_filter = async; + } + if (audio_volume != 256) { + AVFilterContext *volume; + + av_log(NULL, AV_LOG_WARNING, "-vol has been deprecated. Use the volume " + "audio filter instead.\n"); + + snprintf(args, sizeof(args), "volume=%f", audio_volume / 256.0); + + snprintf(name, sizeof(name), "graph %d volume for input stream %d:%d", + fg->index, ist->file_index, ist->st->index); + ret = avfilter_graph_create_filter(&volume, + avfilter_get_by_name("volume"), + name, args, NULL, fg->graph); + if (ret < 0) + return ret; + + ret = avfilter_link(last_filter, 0, volume, 0); + if (ret < 0) + return ret; + + last_filter = volume; + } + + snprintf(name, sizeof(name), "trim for input stream %d:%d", + ist->file_index, ist->st->index); + ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? + AV_NOPTS_VALUE : 0, f->recording_time, &last_filter, &pad_idx, name); + if (ret < 0) + return ret; + + if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0) + return ret; + + return 0; +} + +static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, + AVFilterInOut *in) +{ + av_freep(&ifilter->name); + DESCRIBE_FILTER_LINK(ifilter, in, 1); + + switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) { + case AVMEDIA_TYPE_VIDEO: return configure_input_video_filter(fg, ifilter, in); + case AVMEDIA_TYPE_AUDIO: return configure_input_audio_filter(fg, ifilter, in); + default: av_assert0(0); + } +} + +int configure_filtergraph(FilterGraph *fg) +{ + AVFilterInOut *inputs, *outputs, *cur; + int ret, i, simple = filtergraph_is_simple(fg); + const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter : + fg->graph_desc; + + avfilter_graph_free(&fg->graph); + if (!(fg->graph = avfilter_graph_alloc())) + return AVERROR(ENOMEM); + + if (simple) { + OutputStream *ost = fg->outputs[0]->ost; + char args[512]; + AVDictionaryEntry *e = NULL; + + snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags); + fg->graph->scale_sws_opts = av_strdup(args); + + args[0] = '\0'; + while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e, + AV_DICT_IGNORE_SUFFIX))) { + av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value); + } + if (strlen(args)) + args[strlen(args) - 1] = '\0'; + fg->graph->resample_lavr_opts = av_strdup(args); + } + + if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0) + goto fail; + + if (filter_hw_device || hw_device_ctx) { + AVBufferRef *device = filter_hw_device ? filter_hw_device->device_ref + : hw_device_ctx; + for (i = 0; i < fg->graph->nb_filters; i++) { + fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(device); + if (!fg->graph->filters[i]->hw_device_ctx) { + ret = AVERROR(ENOMEM); + goto fail; + } + } + } + + if (simple && (!inputs || inputs->next || !outputs || outputs->next)) { + av_log(NULL, AV_LOG_ERROR, "Simple filtergraph '%s' does not have " + "exactly one input and output.\n", graph_desc); + ret = AVERROR(EINVAL); + goto fail; + } + + for (cur = inputs, i = 0; cur; cur = cur->next, i++) + if ((ret = configure_input_filter(fg, fg->inputs[i], cur)) < 0) + goto fail; + avfilter_inout_free(&inputs); + + for (cur = outputs, i = 0; cur; cur = cur->next, i++) { + OutputFilter *ofilter = fg->outputs[i]; + if (ofilter->ost) + configure_output_filter(fg, ofilter, cur); + } + + 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]; + AVFilterLink *link = ofilter->filter->inputs[0]; + + ofilter->format = link->format; + + ofilter->width = link->w; + ofilter->height = link->h; + + ofilter->sample_rate = link->sample_rate; + ofilter->channel_layout = link->channel_layout; + } + + 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; + } + } + + return 0; +fail: + avfilter_graph_free(&fg->graph); + 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->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; +} + +int ist_in_filtergraph(FilterGraph *fg, InputStream *ist) +{ + int i; + for (i = 0; i < fg->nb_inputs; i++) + if (fg->inputs[i]->ist == ist) + return 1; + return 0; +} + +int filtergraph_is_simple(FilterGraph *fg) +{ + return !fg->graph_desc; +} diff --git a/ffmpeg_hw.c b/avtools/avconv_hw.c similarity index 94% rename from ffmpeg_hw.c rename to avtools/avconv_hw.c index a4d1cada59..36ef866927 100644 --- a/ffmpeg_hw.c +++ b/avtools/avconv_hw.c @@ -1,26 +1,24 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include "libavutil/avstring.h" - -#include "ffmpeg.h" +#include "avconv.h" static int nb_hw_devices; static HWDevice **hw_devices; @@ -256,12 +254,14 @@ int hw_device_setup_for_decode(InputStream *ist) { enum AVHWDeviceType type; HWDevice *dev; + const char *type_name; int err; if (ist->hwaccel_device) { dev = hw_device_get_by_name(ist->hwaccel_device); if (!dev) { char *tmp; + size_t len; type = hw_device_match_type_by_hwaccel(ist->hwaccel_id); if (type == AV_HWDEVICE_TYPE_NONE) { // No match - this isn't necessarily invalid, though, @@ -269,10 +269,13 @@ int hw_device_setup_for_decode(InputStream *ist) // the hwaccel setup could be handled elsewhere. return 0; } - tmp = av_asprintf("%s:%s", av_hwdevice_get_type_name(type), - ist->hwaccel_device); + type_name = av_hwdevice_get_type_name(type); + len = strlen(type_name) + 1 + + strlen(ist->hwaccel_device) + 1; + tmp = av_malloc(len); if (!tmp) return AVERROR(ENOMEM); + snprintf(tmp, len, "%s:%s", type_name, ist->hwaccel_device); err = hw_device_init_from_string(tmp, &dev); av_free(tmp); if (err < 0) diff --git a/ffmpeg_opt.c b/avtools/avconv_opt.c similarity index 61% rename from ffmpeg_opt.c rename to avtools/avconv_opt.c index 100fa76e46..df693360a7 100644 --- a/ffmpeg_opt.c +++ b/avtools/avconv_opt.c @@ -1,26 +1,26 @@ /* - * ffmpeg option parsing + * avconv option parsing * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include "ffmpeg.h" +#include "avconv.h" #include "cmdutils.h" #include "libavformat/avformat.h" @@ -41,7 +41,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/pixfmt.h" -#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" +#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass" #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ {\ @@ -55,16 +55,6 @@ }\ } -#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\ -{\ - int i;\ - for (i = 0; i < o->nb_ ## name; i++) {\ - char *spec = o->name[i].specifier;\ - if (!strcmp(spec, mediatype))\ - outvar = o->name[i].u.type;\ - }\ -} - const HWAccel hwaccels[] = { #if HAVE_VDPAU_X11 { "vdpau", hwaccel_decode_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU, @@ -79,11 +69,7 @@ const HWAccel hwaccels[] = { AV_HWDEVICE_TYPE_DXVA2 }, #endif #if CONFIG_VDA - { "vda", videotoolbox_init, HWACCEL_VDA, AV_PIX_FMT_VDA, - AV_HWDEVICE_TYPE_NONE }, -#endif -#if CONFIG_VIDEOTOOLBOX - { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX, + { "vda", vda_init, HWACCEL_VDA, AV_PIX_FMT_VDA, AV_HWDEVICE_TYPE_NONE }, #endif #if CONFIG_LIBMFX @@ -95,8 +81,8 @@ const HWAccel hwaccels[] = { AV_HWDEVICE_TYPE_VAAPI }, #endif #if CONFIG_CUVID - { "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA, - AV_HWDEVICE_TYPE_NONE }, + { "cuvid", hwaccel_decode_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA, + AV_HWDEVICE_TYPE_CUDA }, #endif { 0 }, }; @@ -105,47 +91,28 @@ AVBufferRef *hw_device_ctx; HWDevice *filter_hw_device; char *vstats_filename; -char *sdp_filename; float audio_drift_threshold = 0.1; float dts_delta_threshold = 10; -float dts_error_threshold = 3600*30; int audio_volume = 256; int audio_sync_method = 0; int video_sync_method = VSYNC_AUTO; -float frame_drop_threshold = 0; -int do_deinterlace = 0; int do_benchmark = 0; -int do_benchmark_all = 0; int do_hex_dump = 0; int do_pkt_dump = 0; int copy_ts = 0; -int start_at_zero = 0; -int copy_tb = -1; -int debug_ts = 0; +int copy_tb = 1; int exit_on_error = 0; -int abort_on_flags = 0; -int print_stats = -1; +int print_stats = 1; 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; static int file_overwrite = 0; -static int no_file_overwrite = 0; -static int do_psnr = 0; +static int file_skip = 0; +static int video_discard = 0; +static int intra_dc_precision = 8; +static int using_stdin = 0; static int input_sync; -static int override_ffserver = 0; -static int input_stream_potentially_available = 0; -static int ignore_unknown_streams = 0; -static int copy_unknown_streams = 0; -static int find_stream_info = 1; static void uninit_options(OptionsContext *o) { @@ -174,37 +141,22 @@ static void uninit_options(OptionsContext *o) for (i = 0; i < o->nb_stream_maps; i++) av_freep(&o->stream_maps[i].linklabel); av_freep(&o->stream_maps); - av_freep(&o->audio_channel_maps); + av_freep(&o->meta_data_maps); av_freep(&o->streamid_map); - av_freep(&o->attachments); } static void init_options(OptionsContext *o) { memset(o, 0, sizeof(*o)); - o->stop_time = INT64_MAX; o->mux_max_delay = 0.7; o->start_time = AV_NOPTS_VALUE; - o->start_time_eof = AV_NOPTS_VALUE; o->recording_time = INT64_MAX; o->limit_filesize = UINT64_MAX; o->chapters_input_file = INT_MAX; o->accurate_seek = 1; } -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++) { - printf("%s\n", hwaccels[i].name); - } - printf("\n"); - return 0; -} - /* return a copy of the input with the stream specifiers removed from the keys */ static AVDictionary *strip_specifiers(AVDictionary *dict) { @@ -223,43 +175,40 @@ static AVDictionary *strip_specifiers(AVDictionary *dict) return ret; } -static int opt_abort_on(void *optctx, const char *opt, const char *arg) +static double parse_frame_aspect_ratio(const char *arg) { - static const AVOption opts[] = { - { "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" }, - { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" }, - { NULL }, - }; - static const AVClass class = { - .class_name = "", - .item_name = av_default_item_name, - .option = opts, - .version = LIBAVUTIL_VERSION_INT, - }; - const AVClass *pclass = &class; + int x = 0, y = 0; + double ar = 0; + const char *p; + char *end; - return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags); + p = strchr(arg, ':'); + if (p) { + x = strtol(arg, &end, 10); + if (end == p) + y = strtol(end + 1, &end, 10); + if (x > 0 && y > 0) + ar = (double)x / (double)y; + } else + ar = strtod(arg, NULL); + + if (!ar) { + av_log(NULL, AV_LOG_FATAL, "Incorrect aspect ratio specification.\n"); + exit_program(1); + } + return ar; } -static int opt_sameq(void *optctx, const char *opt, const char *arg) +static int show_hwaccels(void *optctx, const char *opt, const char *arg) { - av_log(NULL, AV_LOG_ERROR, "Option '%s' was removed. " - "If you are looking for an option to preserve the quality (which is not " - "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n", - opt, opt); - return AVERROR(EINVAL); -} + int i; -static int opt_video_channel(void *optctx, const char *opt, const char *arg) -{ - av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -channel.\n"); - return opt_default(optctx, "channel", arg); -} - -static int opt_video_standard(void *optctx, const char *opt, const char *arg) -{ - av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -standard.\n"); - return opt_default(optctx, "standard", arg); + printf("Supported hardware acceleration:\n"); + for (i = 0; hwaccels[i].name; i++) { + printf("%s\n", hwaccels[i].name); + } + printf("\n"); + return 0; } static int opt_audio_codec(void *optctx, const char *opt, const char *arg) @@ -291,10 +240,9 @@ static int opt_map(void *optctx, const char *opt, const char *arg) OptionsContext *o = optctx; StreamMap *m = NULL; int i, negative = 0, file_idx; - int sync_file_idx = -1, sync_stream_idx = 0; + int sync_file_idx = -1, sync_stream_idx; char *p, *sync; char *map; - char *allow_unused; if (*arg == '-') { negative = 1; @@ -339,8 +287,6 @@ static int opt_map(void *optctx, const char *opt, const char *arg) exit_program(1); } } else { - if (allow_unused = strchr(map, '?')) - *allow_unused = 0; file_idx = strtol(map, &p, 0); if (file_idx >= nb_input_files || file_idx < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx); @@ -378,13 +324,8 @@ static int opt_map(void *optctx, const char *opt, const char *arg) } if (!m) { - if (allow_unused) { - av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg); - } else { - av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n" - "To ignore this, add a trailing '?' to the map.\n", arg); - exit_program(1); - } + av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n", arg); + exit_program(1); } av_freep(&map); @@ -399,89 +340,6 @@ static int opt_attach(void *optctx, const char *opt, const char *arg) return 0; } -static int opt_map_channel(void *optctx, const char *opt, const char *arg) -{ - OptionsContext *o = optctx; - int n; - AVStream *st; - AudioChannelMap *m; - char *allow_unused; - char *mapchan; - mapchan = av_strdup(arg); - if (!mapchan) - return AVERROR(ENOMEM); - - GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps); - m = &o->audio_channel_maps[o->nb_audio_channel_maps - 1]; - - /* muted channel syntax */ - n = sscanf(arg, "%d:%d.%d", &m->channel_idx, &m->ofile_idx, &m->ostream_idx); - if ((n == 1 || n == 3) && m->channel_idx == -1) { - m->file_idx = m->stream_idx = -1; - if (n == 1) - m->ofile_idx = m->ostream_idx = -1; - av_free(mapchan); - return 0; - } - - /* normal syntax */ - n = sscanf(arg, "%d.%d.%d:%d.%d", - &m->file_idx, &m->stream_idx, &m->channel_idx, - &m->ofile_idx, &m->ostream_idx); - - if (n != 3 && n != 5) { - av_log(NULL, AV_LOG_FATAL, "Syntax error, mapchan usage: " - "[file.stream.channel|-1][:syncfile:syncstream]\n"); - exit_program(1); - } - - if (n != 5) // only file.stream.channel specified - m->ofile_idx = m->ostream_idx = -1; - - /* check input */ - if (m->file_idx < 0 || m->file_idx >= nb_input_files) { - av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file index: %d\n", - m->file_idx); - exit_program(1); - } - if (m->stream_idx < 0 || - m->stream_idx >= input_files[m->file_idx]->nb_streams) { - av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file stream index #%d.%d\n", - m->file_idx, m->stream_idx); - exit_program(1); - } - st = input_files[m->file_idx]->ctx->streams[m->stream_idx]; - if (st->codecpar->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); - } - /* allow trailing ? to map_channel */ - if (allow_unused = strchr(mapchan, '?')) - *allow_unused = 0; - if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->channels) { - if (allow_unused) { - av_log(NULL, AV_LOG_VERBOSE, "mapchan: invalid audio channel #%d.%d.%d\n", - m->file_idx, m->stream_idx, m->channel_idx); - } else { - av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n" - "To ignore this, add a trailing '?' to the map_channel.\n", - m->file_idx, m->stream_idx, m->channel_idx); - exit_program(1); - } - - } - av_free(mapchan); - return 0; -} - -static int opt_sdp_file(void *optctx, const char *opt, const char *arg) -{ - av_free(sdp_filename); - sdp_filename = av_strdup(arg); - return 0; -} - #if CONFIG_VAAPI static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) { @@ -489,9 +347,11 @@ static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) const char *prefix = "vaapi:"; char *tmp; int err; - tmp = av_asprintf("%s%s", prefix, arg); + tmp = av_malloc(strlen(prefix) + strlen(arg) + 1); if (!tmp) return AVERROR(ENOMEM); + strcpy(tmp, prefix); + strcat(tmp, arg); err = hw_device_init_from_string(tmp, &dev); av_free(tmp); if (err < 0) @@ -569,7 +429,7 @@ static void parse_meta_type(char *arg, char *type, int *index, const char **stre static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o) { AVDictionary **meta_in = NULL; - AVDictionary **meta_out = NULL; + AVDictionary **meta_out; int i, ret = 0; char type_in, type_out; const char *istream_spec = NULL, *ostream_spec = NULL; @@ -578,16 +438,6 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor parse_meta_type(inspec, &type_in, &idx_in, &istream_spec); parse_meta_type(outspec, &type_out, &idx_out, &ostream_spec); - if (!ic) { - if (type_out == 'g' || !*outspec) - o->metadata_global_manual = 1; - if (type_out == 's' || !*outspec) - o->metadata_streams_manual = 1; - if (type_out == 'c' || !*outspec) - o->metadata_chapters_manual = 1; - return 0; - } - if (type_in == 'g' || type_out == 'g') o->metadata_global_manual = 1; if (type_in == 's' || type_out == 's') @@ -656,21 +506,6 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor return 0; } -static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg) -{ - OptionsContext *o = optctx; - char buf[128]; - int64_t recording_timestamp = parse_time_or_die(opt, arg, 0) / 1E6; - struct tm time = *gmtime((time_t*)&recording_timestamp); - if (!strftime(buf, sizeof(buf), "creation_time=%Y-%m-%dT%H:%M:%S%z", &time)) - return -1; - parse_option(o, "metadata", buf, options); - - av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata " - "tag instead.\n", opt); - return 0; -} - static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder) { const AVCodecDescriptor *desc; @@ -727,9 +562,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) 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); if (!ist) exit_program(1); @@ -760,20 +592,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) } 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->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) { - av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n", - discard_str); - exit_program(1); - } - - ist->filter_in_rescale_delta_last = AV_NOPTS_VALUE; + ist->decoder_opts = filter_codec_opts(o->g->codec_opts, par->codec_id, ic, st, ist->dec); ist->dec_ctx = avcodec_alloc_context3(ist->dec); if (!ist->dec_ctx) { @@ -789,24 +608,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: - if(!ist->dec) - ist->dec = avcodec_find_decoder(par->codec_id); -#if FF_API_LOWRES - 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; -#if FF_API_EMU_EDGE - ist->dec_ctx->flags |= CODEC_FLAG_EMU_EDGE; -#endif - } -#endif - - // avformat_find_stream_info() doesn't set this for us anymore. - ist->dec_ctx->framerate = st->avg_frame_rate; - MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st); if (framerate && av_parse_video_rate(&ist->framerate, framerate) < 0) { @@ -815,9 +616,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) exit_program(1); } - ist->top_field_first = -1; - MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st); - MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st); if (hwaccel) { if (!strcmp(hwaccel, "none")) @@ -868,62 +666,40 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) break; case AVMEDIA_TYPE_AUDIO: - 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); break; case AVMEDIA_TYPE_DATA: - case AVMEDIA_TYPE_SUBTITLE: { - char *canvas_size = NULL; - if(!ist->dec) - ist->dec = avcodec_find_decoder(par->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 && - av_parse_video_size(&ist->dec_ctx->width, &ist->dec_ctx->height, canvas_size) < 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size); - exit_program(1); - } - break; - } + case AVMEDIA_TYPE_SUBTITLE: case AVMEDIA_TYPE_ATTACHMENT: case AVMEDIA_TYPE_UNKNOWN: break; 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); - } } } static void assert_file_overwrite(const char *filename) { - if (file_overwrite && no_file_overwrite) { + if (file_overwrite && file_skip) { fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n"); exit_program(1); } - if (!file_overwrite) { - const char *proto_name = avio_find_protocol_name(filename); - if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) { - if (stdin_interaction && !no_file_overwrite) { + if (!file_overwrite && + (!strchr(filename, ':') || filename[1] == ':' || + av_strstart(filename, "file:", NULL))) { + if (avio_check(filename, 0) == 0) { + if (!using_stdin && !file_skip) { fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); fflush(stderr); - term_exit(); - signal(SIGINT, SIG_DFL); if (!read_yesno()) { - av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n"); + fprintf(stderr, "Not overwriting - exiting\n"); exit_program(1); } - term_init(); } else { - av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename); + fprintf(stderr,"File '%s' already exists. Exiting.\n", filename); exit_program(1); } } @@ -969,13 +745,11 @@ static int open_input_file(OptionsContext *o, const char *filename) AVInputFormat *file_iformat = NULL; int err, i, ret; int64_t timestamp; + uint8_t buf[128]; + AVDictionary **opts; AVDictionary *unused_opts = NULL; AVDictionaryEntry *e = NULL; - char * video_codec_name = NULL; - char * audio_codec_name = NULL; - char *subtitle_codec_name = NULL; - char * data_codec_name = NULL; - int scan_all_pmts_set = 0; + int orig_nb_streams; // number of streams before avformat_find_stream_info if (o->format) { if (!(file_iformat = av_find_input_format(o->format))) { @@ -987,8 +761,8 @@ static int open_input_file(OptionsContext *o, const char *filename) if (!strcmp(filename, "-")) filename = "pipe:"; - stdin_interaction &= strncmp(filename, "pipe:", 5) && - strcmp(filename, "/dev/stdin"); + using_stdin |= !strncmp(filename, "pipe:", 5) || + !strcmp(filename, "/dev/stdin"); /* get default parameters from command line */ ic = avformat_alloc_context(); @@ -996,9 +770,9 @@ 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); + snprintf(buf, sizeof(buf), "%d", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i); + av_dict_set(&o->g->format_opts, "sample_rate", buf, 0); } if (o->nb_audio_channels) { /* because we set audio_channels based on both the "ac" and @@ -1007,7 +781,9 @@ static int open_input_file(OptionsContext *o, const char *filename) if (file_iformat && file_iformat->priv_class && av_opt_find(&file_iformat->priv_class, "channels", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) { - av_dict_set_int(&o->g->format_opts, "channels", o->audio_channels[o->nb_audio_channels - 1].u.i, 0); + snprintf(buf, sizeof(buf), "%d", + o->audio_channels[o->nb_audio_channels - 1].u.i); + av_dict_set(&o->g->format_opts, "channels", buf, 0); } } if (o->nb_frame_rates) { @@ -1026,101 +802,42 @@ static int open_input_file(OptionsContext *o, const char *filename) if (o->nb_frame_pix_fmts) av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0); - MATCH_PER_TYPE_OPT(codec_names, str, video_codec_name, ic, "v"); - MATCH_PER_TYPE_OPT(codec_names, str, audio_codec_name, ic, "a"); - MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, ic, "s"); - MATCH_PER_TYPE_OPT(codec_names, str, data_codec_name, ic, "d"); - - ic->video_codec_id = video_codec_name ? - find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0)->id : AV_CODEC_ID_NONE; - ic->audio_codec_id = audio_codec_name ? - find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0)->id : AV_CODEC_ID_NONE; - ic->subtitle_codec_id= subtitle_codec_name ? - find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : AV_CODEC_ID_NONE; - ic->data_codec_id = data_codec_name ? - find_codec_or_die(data_codec_name, AVMEDIA_TYPE_DATA, 0)->id : AV_CODEC_ID_NONE; - - if (video_codec_name) - av_format_set_video_codec (ic, find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0)); - if (audio_codec_name) - av_format_set_audio_codec (ic, find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0)); - if (subtitle_codec_name) - av_format_set_subtitle_codec(ic, find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)); - if (data_codec_name) - av_format_set_data_codec(ic, find_codec_or_die(data_codec_name, AVMEDIA_TYPE_DATA, 0)); - ic->flags |= AVFMT_FLAG_NONBLOCK; ic->interrupt_callback = int_cb; - if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) { - av_dict_set(&o->g->format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE); - scan_all_pmts_set = 1; - } - /* open the input file with generic avformat function */ + /* open the input file with generic Libav function */ 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) - av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); - remove_avoptions(&o->g->format_opts, o->g->codec_opts); assert_avoptions(o->g->format_opts); /* apply forced codec ids */ for (i = 0; i < ic->nb_streams; i++) choose_decoder(o, ic, ic->streams[i]); - if (find_stream_info) { - AVDictionary **opts = setup_find_stream_info_opts(ic, o->g->codec_opts); - int orig_nb_streams = ic->nb_streams; + /* Set AVCodecContext options for avformat_find_stream_info */ + opts = setup_find_stream_info_opts(ic, o->g->codec_opts); + orig_nb_streams = ic->nb_streams; - /* If not enough info to get the stream parameters, we decode the - first frames to get it. (used in mpeg case for example) */ - ret = avformat_find_stream_info(ic, opts); - - for (i = 0; i < orig_nb_streams; i++) - av_dict_free(&opts[i]); - av_freep(&opts); - - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename); - if (ic->nb_streams == 0) { - avformat_close_input(&ic); - exit_program(1); - } - } + /* If not enough info to get the stream parameters, we decode the + first frames to get it. (used in mpeg case for example) */ + ret = avformat_find_stream_info(ic, opts); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename); + avformat_close_input(&ic); + exit_program(1); } - if (o->start_time_eof != AV_NOPTS_VALUE) { - if (ic->duration>0) { - o->start_time = o->start_time_eof + ic->duration; - } else - av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename); - } timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time; /* add the stream start time */ - if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE) + if (ic->start_time != AV_NOPTS_VALUE) timestamp += ic->start_time; /* if seeking requested, we execute it */ if (o->start_time != AV_NOPTS_VALUE) { - int64_t seek_timestamp = timestamp; - - if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) { - int dts_heuristic = 0; - for (i=0; inb_streams; i++) { - const AVCodecParameters *par = ic->streams[i]->codecpar; - if (par->video_delay) - dts_heuristic = 1; - } - if (dts_heuristic) { - seek_timestamp -= 3*AV_TIME_BASE / 23; - } - } - ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0); + ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD); if (ret < 0) { av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n", filename, (double)timestamp / AV_TIME_BASE); @@ -1143,17 +860,13 @@ static int open_input_file(OptionsContext *o, const char *filename) f->ist_index = nb_input_streams - ic->nb_streams; f->start_time = o->start_time; f->recording_time = o->recording_time; - f->input_ts_offset = o->input_ts_offset; - f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp); + f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp); f->nb_streams = ic->nb_streams; f->rate_emu = o->rate_emu; f->accurate_seek = o->accurate_seek; f->loop = o->loop; f->duration = 0; f->time_base = (AVRational){ 1, 1 }; -#if HAVE_PTHREADS - f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8; -#endif /* check if all codec options have been used */ unused_opts = strip_specifiers(o->g->codec_opts); @@ -1169,13 +882,8 @@ static int open_input_file(OptionsContext *o, const char *filename) const AVClass *class = avcodec_get_class(); const AVOption *option = av_opt_find(&class, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - const AVClass *fclass = avformat_get_class(); - const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - if (!option || foption) + if (!option) continue; - - if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) { av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for " "input file #%d (%s) is not a decoding option.\n", e->key, @@ -1204,7 +912,9 @@ static int open_input_file(OptionsContext *o, const char *filename) } } - input_stream_potentially_available = 1; + for (i = 0; i < orig_nb_streams; i++) + av_dict_free(&opts[i]); + av_freep(&opts); return 0; } @@ -1267,10 +977,9 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o 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 " + "output stream #%d:%d. Default encoder for format %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)); + ost->file_index, ost->index, s->oformat->name); return AVERROR_ENCODER_NOT_FOUND; } } else if (!strcmp(codec_name, "copy")) @@ -1279,6 +988,7 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o 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 */ @@ -1289,15 +999,15 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o return 0; } -static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) +static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) { OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; - const char *bsfs = NULL, *time_base = NULL; + const char *bsfs = NULL; char *next, *codec_tag = NULL; double qscale = -1; - int i; + int bitrate = 0; if (!st) { av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); @@ -1331,12 +1041,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; @@ -1359,7 +1063,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE); av_free(buf); } while (!s->eof_reached); - avio_closep(&s); + avio_close(s); } if (ret) { av_log(NULL, AV_LOG_FATAL, @@ -1371,50 +1075,19 @@ 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; - } - - MATCH_PER_STREAM_OPT(enc_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.den <= 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base); - exit_program(1); - } - ost->enc_timebase = q; - } - ost->max_frames = INT64_MAX; MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); - for (i = 0; inb_max_frames; i++) { - char *p = o->max_frames[i].specifier; - if (!*p && type != AVMEDIA_TYPE_VIDEO) { - av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n"); - break; - } - } - - 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; + const char *bsf, *bsf_options_str, *bsf_name; + AVDictionary *bsf_options = NULL; - bsf = av_get_token(&bsfs, ","); + bsf = bsf_options_str = av_get_token(&bsfs, ","); if (!bsf) exit_program(1); - bsf_name = av_strtok(bsf, "=", &bsf_options_str); + bsf_name = av_get_token(&bsf_options_str, "="); if (!bsf_name) exit_program(1); @@ -1423,6 +1096,14 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf_name); exit_program(1); } + if (*bsf_options_str++) { + ret = av_dict_parse_string(&bsf_options, bsf_options_str, "=", ":", 0); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error parsing options for bitstream filter %s\n", bsf_name); + exit_program(1); + } + } + av_freep(&bsf); ost->bsf_ctx = av_realloc_array(ost->bsf_ctx, ost->nb_bitstream_filters + 1, @@ -1432,26 +1113,21 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e 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"); + av_log(NULL, AV_LOG_ERROR, "Error allocating a bistream 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 (bsf_options) { + ret = av_opt_set_dict(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, &bsf_options); if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error parsing options for bitstream filter %s\n", bsf_name); + av_log(NULL, AV_LOG_ERROR, "Error setting options for bitstream filter %s\n", bsf_name); exit_program(1); } + assert_avoptions(bsf_options); + av_dict_free(&bsf_options); } - av_freep(&bsf); + av_freep(&bsf_name); if (*bsfs) bsfs++; @@ -1462,7 +1138,6 @@ 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->enc_ctx->codec_tag = tag; } @@ -1472,8 +1147,13 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; } - MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st); - ost->disposition = av_strdup(ost->disposition); + MATCH_PER_STREAM_OPT(bitrates, i, bitrate, oc, st); + if (bitrate > 0) { + if (ost->stream_copy) + ost->bitrate_override = bitrate; + else + ost->enc_ctx->bit_rate = bitrate; + } ost->max_muxing_queue_size = 128; MATCH_PER_STREAM_OPT(max_muxing_queue_size, i, ost->max_muxing_queue_size, oc, st); @@ -1482,20 +1162,11 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (oc->oformat->flags & AVFMT_GLOBALHEADER) ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; - av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); - - av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); - if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24) - av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); + av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags); av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0); - ost->source_index = source_index; - if (source_index >= 0) { - ost->sync_ist = input_streams[source_index]; - input_streams[source_index]->discard = 0; - input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard; - } + ost->pix_fmts[0] = ost->pix_fmts[1] = AV_PIX_FMT_NONE; ost->last_mux_dts = AV_NOPTS_VALUE; ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket)); @@ -1555,99 +1226,68 @@ static char *get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost) { AVStream *st = ost->st; + char *filter = NULL, *filter_script = NULL; - if (ost->filters_script && ost->filters) { + MATCH_PER_STREAM_OPT(filter_scripts, str, filter_script, oc, st); + MATCH_PER_STREAM_OPT(filters, str, filter, oc, st); + + if (filter_script && filter) { av_log(NULL, AV_LOG_ERROR, "Both -filter and -filter_script set for " "output stream #%d:%d.\n", nb_output_files, st->index); exit_program(1); } - if (ost->filters_script) - return read_file(ost->filters_script); - else if (ost->filters) - return av_strdup(ost->filters); + if (filter_script) + return read_file(filter_script); + else if (filter) + return av_strdup(filter); return av_strdup(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? "null" : "anull"); } -static void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc, - const OutputStream *ost, enum AVMediaType type) -{ - if (ost->filters_script || ost->filters) { - av_log(NULL, AV_LOG_ERROR, - "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n" - "Filtering and streamcopy cannot be used together.\n", - ost->filters ? "Filtergraph" : "Filtergraph script", - ost->filters ? ost->filters : ost->filters_script, - av_get_media_type_string(type), ost->file_index, ost->index); - exit_program(1); - } -} - -static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index) +static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc) { AVStream *st; OutputStream *ost; AVCodecContext *video_enc; - char *frame_rate = NULL, *frame_aspect_ratio = NULL; + char *frame_aspect_ratio = NULL; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO); st = ost->st; video_enc = ost->enc_ctx; - MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); - if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); - exit_program(1); - } - if (frame_rate && video_sync_method == VSYNC_PASSTHROUGH) - av_log(NULL, AV_LOG_ERROR, "Using -vsync 0 and -r can produce invalid output files\n"); - MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st); - if (frame_aspect_ratio) { - AVRational q; - if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 || - q.num <= 0 || q.den <= 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio); - exit_program(1); - } - ost->frame_aspect_ratio = q; - } - - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); + if (frame_aspect_ratio) + ost->frame_aspect_ratio = parse_frame_aspect_ratio(frame_aspect_ratio); if (!ost->stream_copy) { const char *p = NULL; - char *frame_size = NULL; + char *frame_rate = NULL, *frame_size = NULL; char *frame_pix_fmt = NULL; char *intra_matrix = NULL, *inter_matrix = NULL; - char *chroma_intra_matrix = NULL; int do_pass = 0; int i; + MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); + if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { + av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); + exit_program(1); + } + MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st); if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, frame_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size); exit_program(1); } - video_enc->bits_per_raw_sample = frame_bits_per_raw_sample; MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st); - if (frame_pix_fmt && *frame_pix_fmt == '+') { - ost->keep_pix_fmt = 1; - if (!*++frame_pix_fmt) - frame_pix_fmt = NULL; - } if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == AV_PIX_FMT_NONE) { av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt); exit_program(1); } st->sample_aspect_ratio = video_enc->sample_aspect_ratio; - if (intra_only) - video_enc->gop_size = 0; MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st); if (intra_matrix) { if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) { @@ -1656,16 +1296,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in } parse_matrix_coeffs(video_enc->intra_matrix, intra_matrix); } - MATCH_PER_STREAM_OPT(chroma_intra_matrices, str, chroma_intra_matrix, oc, st); - if (chroma_intra_matrix) { - uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64); - if (!p) { - av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n"); - exit_program(1); - } - av_codec_set_chroma_intra_matrix(video_enc, p); - parse_matrix_coeffs(p, chroma_intra_matrix); - } MATCH_PER_STREAM_OPT(inter_matrices, str, inter_matrix, oc, st); if (inter_matrix) { if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) { @@ -1684,8 +1314,8 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in exit_program(1); } video_enc->rc_override = - av_realloc_array(video_enc->rc_override, - i + 1, sizeof(RcOverride)); + av_realloc(video_enc->rc_override, + sizeof(RcOverride) * (i + 1)); if (!video_enc->rc_override) { av_log(NULL, AV_LOG_FATAL, "Could not (re)allocate memory for rc_override.\n"); exit_program(1); @@ -1704,20 +1334,15 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in if (p) p++; } video_enc->rc_override_count = i; - - if (do_psnr) - video_enc->flags|= AV_CODEC_FLAG_PSNR; + video_enc->intra_dc_precision = intra_dc_precision - 8; /* two pass mode */ MATCH_PER_STREAM_OPT(pass, i, do_pass, oc, st); if (do_pass) { - if (do_pass & 1) { + if (do_pass == 1) { video_enc->flags |= AV_CODEC_FLAG_PASS1; - av_dict_set(&ost->encoder_opts, "flags", "+pass1", AV_DICT_APPEND); - } - if (do_pass & 2) { + } else { video_enc->flags |= AV_CODEC_FLAG_PASS2; - av_dict_set(&ost->encoder_opts, "flags", "+pass2", AV_DICT_APPEND); } } @@ -1737,7 +1362,15 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in if (!strcmp(ost->enc->name, "libx264")) { av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); } else { - if (video_enc->flags & AV_CODEC_FLAG_PASS2) { + if (video_enc->flags & AV_CODEC_FLAG_PASS1) { + f = fopen(logfilename, "wb"); + if (!f) { + av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n", + logfilename, strerror(errno)); + exit_program(1); + } + ost->logfile = f; + } else { char *logbuffer = read_file(logfilename); if (!logbuffer) { @@ -1747,16 +1380,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in } video_enc->stats_in = logbuffer; } - if (video_enc->flags & AV_CODEC_FLAG_PASS1) { - f = av_fopen_utf8(logfilename, "wb"); - if (!f) { - av_log(NULL, AV_LOG_FATAL, - "Cannot write log file '%s' for pass-1 encoding: %s\n", - logfilename, strerror(errno)); - exit_program(1); - } - ost->logfile = f; - } } } @@ -1777,28 +1400,21 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc ,st); } - if (ost->stream_copy) - check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_VIDEO); - return ost; } -static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index) +static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc) { - int n; AVStream *st; OutputStream *ost; AVCodecContext *audio_enc; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO); st = ost->st; audio_enc = ost->enc_ctx; audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; - MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); - MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); - if (!ost->stream_copy) { char *sample_fmt = NULL; @@ -1813,54 +1429,19 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st); - MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st); - ost->apad = av_strdup(ost->apad); - ost->avfilter = get_ost_filters(o, oc, ost); if (!ost->avfilter) exit_program(1); - - /* check for channel mapping for this audio stream */ - for (n = 0; n < o->nb_audio_channel_maps; n++) { - AudioChannelMap *map = &o->audio_channel_maps[n]; - if ((map->ofile_idx == -1 || ost->file_index == map->ofile_idx) && - (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) { - InputStream *ist; - - if (map->channel_idx == -1) { - ist = NULL; - } else if (ost->source_index < 0) { - av_log(NULL, AV_LOG_FATAL, "Cannot determine input stream for channel mapping %d.%d\n", - ost->file_index, ost->st->index); - continue; - } else { - ist = input_streams[ost->source_index]; - } - - if (!ist || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) { - if (av_reallocp_array(&ost->audio_channels_map, - ost->audio_channels_mapped + 1, - sizeof(*ost->audio_channels_map) - ) < 0 ) - exit_program(1); - - ost->audio_channels_map[ost->audio_channels_mapped++] = map->channel_idx; - } - } - } } - if (ost->stream_copy) - check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_AUDIO); - return ost; } -static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int source_index) +static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc) { OutputStream *ost; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA); if (!ost->stream_copy) { av_log(NULL, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); exit_program(1); @@ -1869,51 +1450,24 @@ static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int return ost; } -static OutputStream *new_unknown_stream(OptionsContext *o, AVFormatContext *oc, int source_index) +static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc) { - OutputStream *ost; - - ost = new_output_stream(o, oc, AVMEDIA_TYPE_UNKNOWN, source_index); - if (!ost->stream_copy) { - av_log(NULL, AV_LOG_FATAL, "Unknown stream encoding not supported yet (only streamcopy)\n"); - exit_program(1); - } - - return ost; -} - -static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index) -{ - OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT, source_index); + OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT); ost->stream_copy = 1; ost->finished = 1; return ost; } -static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, int source_index) +static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc) { - AVStream *st; OutputStream *ost; AVCodecContext *subtitle_enc; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE, source_index); - st = ost->st; + ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE); subtitle_enc = ost->enc_ctx; subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; - MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc, st); - - if (!ost->stream_copy) { - char *frame_size = NULL; - - MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st); - if (frame_size && av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size) < 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size); - exit_program(1); - } - } - return ost; } @@ -1934,7 +1488,7 @@ static int opt_streamid(void *optctx, const char *opt, const char *arg) exit_program(1); } *p++ = '\0'; - idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1); + idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX); o->streamid_map = grow_array(o->streamid_map, sizeof(*o->streamid_map), &o->nb_streamid_map, idx+1); o->streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); return 0; @@ -1947,7 +1501,7 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) AVChapter **tmp; int i; - tmp = av_realloc_f(os->chapters, is->nb_chapters + os->nb_chapters, sizeof(*os->chapters)); + tmp = av_realloc(os->chapters, sizeof(*os->chapters) * (is->nb_chapters + os->nb_chapters)); if (!tmp) return AVERROR(ENOMEM); os->chapters = tmp; @@ -1983,65 +1537,14 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) return 0; } -static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename) -{ - 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) - return err; - /* copy stream format */ - for(i=0;inb_streams;i++) { - AVStream *st; - OutputStream *ost; - AVCodec *codec; - const char *enc_config; - - codec = avcodec_find_encoder(ic->streams[i]->codecpar->codec_id); - if (!codec) { - av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codecpar->codec_id); - return AVERROR(EINVAL); - } - if (codec->type == AVMEDIA_TYPE_AUDIO) - opt_audio_codec(o, "c:a", codec->name); - else if (codec->type == AVMEDIA_TYPE_VIDEO) - opt_video_codec(o, "c:v", codec->name); - ost = new_output_stream(o, s, codec->type, -1); - st = ost->st; - - avcodec_get_context_defaults3(st->codec, codec); - enc_config = av_stream_get_recommended_encoder_configuration(ic->streams[i]); - if (enc_config) { - AVDictionary *opts = NULL; - av_dict_parse_string(&opts, enc_config, "=", ",", 0); - av_opt_set_dict2(st->codec, &opts, AV_OPT_SEARCH_CHILDREN); - av_dict_free(&opts); - } - - if (st->codecpar->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); - avcodec_copy_context(ost->enc_ctx, st->codec); - if (enc_config) - av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0); - } - - avformat_close_input(&ic); - return err; -} - static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc) { OutputStream *ost; switch (ofilter->type) { - case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc, -1); break; - case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc, -1); break; + case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break; + case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break; default: av_log(NULL, AV_LOG_FATAL, "Only video and audio filters are supported " "currently.\n"); @@ -2061,18 +1564,6 @@ static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, exit_program(1); } - if (ost->avfilter && (ost->filters || ost->filters_script)) { - const char *opt = ost->filters ? "-vf/-af/-filter" : "-filter_script"; - av_log(NULL, AV_LOG_ERROR, - "%s '%s' was specified through the %s option " - "for output stream %d:%d, which is fed from a complex filtergraph.\n" - "%s and -filter_complex cannot be used together for the same stream.\n", - ost->filters ? "Filtergraph" : "Filtergraph script", - ost->filters ? ost->filters : ost->filters_script, - opt, ost->file_index, ost->index, opt); - exit_program(1); - } - avfilter_inout_free(&ofilter->out_tmp); } @@ -2098,22 +1589,6 @@ 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; - av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); - } - - if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) { - int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; - if (o->stop_time <= start_time) { - av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); - exit_program(1); - } else { - o->recording_time = o->stop_time - start_time; - } - } GROW_ARRAY(output_files, nb_output_files); of = av_mallocz(sizeof(*of)); @@ -2131,25 +1606,34 @@ static int open_output_file(OptionsContext *o, const char *filename) if (!strcmp(filename, "-")) filename = "pipe:"; - err = avformat_alloc_output_context2(&oc, NULL, o->format, filename); + oc = avformat_alloc_context(); if (!oc) { - print_error(filename, err); + print_error(filename, AVERROR(ENOMEM)); exit_program(1); } - of->ctx = oc; if (o->recording_time != INT64_MAX) oc->duration = o->recording_time; - 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); + if (o->format) { + file_oformat = av_guess_format(o->format, NULL, NULL); + if (!file_oformat) { + av_log(NULL, AV_LOG_FATAL, "Requested output format '%s' is not a suitable output format\n", o->format); + exit_program(1); + } + } else { + file_oformat = av_guess_format(NULL, filename, NULL); + if (!file_oformat) { + av_log(NULL, AV_LOG_FATAL, "Unable to find a suitable output format for '%s'\n", + filename); + exit_program(1); + } } + oc->oformat = file_oformat; + oc->interrupt_callback = int_cb; + av_strlcpy(oc->filename, filename, sizeof(oc->filename)); + /* create streams for all unlabeled output pads */ for (i = 0; i < nb_filtergraphs; i++) { FilterGraph *fg = filtergraphs[i]; @@ -2168,126 +1652,54 @@ 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) { - print_error(filename, err); - exit_program(1); - } - } - - if (!strcmp(file_oformat->name, "ffm") && !override_ffserver && - av_strstart(filename, "http:", NULL)) { - int j; - /* special case for files sent to ffserver: we get the stream - parameters from ffserver */ - int err = read_ffserver_streams(o, oc, filename); - if (err < 0) { - print_error(filename, err); - exit_program(1); - } - for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) { - 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){ - 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"); - 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)); - exit_program(1); - } - } - } else if (!o->nb_stream_maps) { - char *subtitle_codec_name = NULL; + if (!o->nb_stream_maps) { /* pick the "best" stream of each type */ +#define NEW_STREAM(type, index)\ + if (index >= 0) {\ + ost = new_ ## type ## _stream(o, oc);\ + ost->source_index = index;\ + ost->sync_ist = input_streams[index];\ + input_streams[index]->discard = 0;\ + input_streams[index]->st->discard = AVDISCARD_NONE;\ + } /* video: highest resolution */ - if (!o->video_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) { + if (!o->video_disable && oc->oformat->video_codec != AV_CODEC_ID_NONE) { int area = 0, idx = -1; - int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); 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; - 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 && - new_area > area) { - if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - continue; - area = new_area; + ist->st->codecpar->width * ist->st->codecpar->height > area) { + area = ist->st->codecpar->width * ist->st->codecpar->height; idx = i; } } - if (idx >= 0) - new_video_stream(o, oc, idx); + NEW_STREAM(video, idx); } /* audio: most channels */ - if (!o->audio_disable && av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; + if (!o->audio_disable && oc->oformat->audio_codec != AV_CODEC_ID_NONE) { + int channels = 0, idx = -1; 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 > best_score) { - best_score = score; + ist->st->codecpar->channels > channels) { + channels = ist->st->codecpar->channels; idx = i; } } - if (idx >= 0) - new_audio_stream(o, oc, idx); + NEW_STREAM(audio, idx); } /* subtitles: pick first */ - 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)) { + if (!o->subtitle_disable && oc->oformat->subtitle_codec != AV_CODEC_ID_NONE) { for (i = 0; i < nb_input_streams; i++) if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { - AVCodecDescriptor const *input_descriptor = - avcodec_descriptor_get(input_streams[i]->st->codecpar->codec_id); - AVCodecDescriptor const *output_descriptor = NULL; - AVCodec const *output_codec = - avcodec_find_encoder(oc->oformat->subtitle_codec); - int input_props = 0, output_props = 0; - if (output_codec) - output_descriptor = avcodec_descriptor_get(output_codec->id); - if (input_descriptor) - input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (output_descriptor) - output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (subtitle_codec_name || - input_props & output_props || - // Map dvb teletext which has neither property to any output subtitle encoder - input_descriptor && output_descriptor && - (!input_descriptor->props || - !output_descriptor->props)) { - new_subtitle_stream(o, oc, i); - break; - } + NEW_STREAM(subtitle, i); + break; } } - /* Data only if codec id match */ - 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 ) - new_data_stream(o, oc, i); - } - } + /* do something with data? */ } else { for (i = 0; i < o->nb_stream_maps; i++) { StreamMap *map = &o->stream_maps[i]; @@ -2313,50 +1725,29 @@ static int open_output_file(OptionsContext *o, const char *filename) loop_end: if (!ofilter) { av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist " - "in any defined filter graph, or was already used elsewhere.\n", map->linklabel); + "in any defined filter graph.\n", map->linklabel); exit_program(1); } init_output_filter(ofilter, o, oc); } else { - 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) - continue; - if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) - continue; - if(o-> video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) - continue; - if(o-> data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA) - continue; - - ost = NULL; switch (ist->st->codecpar->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; - case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break; - case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break; - case AVMEDIA_TYPE_UNKNOWN: - if (copy_unknown_streams) { - ost = new_unknown_stream (o, oc, src_idx); - break; - } + case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break; + case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break; + case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(o, oc); break; + case AVMEDIA_TYPE_DATA: ost = new_data_stream(o, oc); break; + case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc); break; default: - av_log(NULL, ignore_unknown_streams ? AV_LOG_WARNING : AV_LOG_FATAL, - "Cannot map stream #%d:%d - unsupported type.\n", + av_log(NULL, AV_LOG_FATAL, "Cannot map stream #%d:%d - unsupported type.\n", map->file_index, map->stream_index); - if (!ignore_unknown_streams) { - av_log(NULL, AV_LOG_FATAL, - "If you want unsupported types ignored instead " - "of failing, please use the -ignore_unknown option\n" - "If you want them copied, please use -copy_unknown\n"); - exit_program(1); - } + exit_program(1); } - if (ost) - ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index - + map->sync_stream_index]; + + ost->source_index = input_files[map->file_index]->ist_index + map->stream_index; + ost->sync_ist = input_streams[input_files[map->sync_file_index]->ist_index + + map->sync_stream_index]; + ist->discard = 0; + ist->st->discard = AVDISCARD_NONE; } } } @@ -2385,30 +1776,18 @@ loop_end: } avio_read(pb, attachment, len); - ost = new_attachment_stream(o, oc, -1); + ost = new_attachment_stream(o, oc); ost->stream_copy = 0; + ost->source_index = -1; ost->attachment_filename = o->attachments[i]; ost->st->codecpar->extradata = attachment; ost->st->codecpar->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); + avio_close(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]; - - if ((ost->stream_copy || ost->attachment_filename) - && (e = av_dict_get(o->g->codec_opts, "flags", NULL, AV_DICT_IGNORE_SUFFIX)) - && (!e->key[5] || check_stream_specifier(oc, ost->st, e->key+6))) - 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); av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1); @@ -2429,13 +1808,8 @@ loop_end: const AVClass *class = avcodec_get_class(); const AVOption *option = av_opt_find(&class, e->key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - const AVClass *fclass = avformat_get_class(); - const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); - if (!option || foption) + if (!option) continue; - - if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) { av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for " "output file #%d (%s) is not an encoding option.\n", e->key, @@ -2444,10 +1818,6 @@ loop_end: exit_program(1); } - // gop_timecode is injected by generic code but not always used - if (!strcmp(e->key, "gop_timecode")) - continue; - av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for " "output file #%d (%s) has not been used for any stream. The most " "likely reason is either wrong type (e.g. a video option with " @@ -2463,7 +1833,7 @@ loop_end: if (ost->encoding_needed && ost->source_index >= 0) { InputStream *ist = input_streams[ost->source_index]; - ist->decoding_needed |= DECODING_FOR_OST; + ist->decoding_needed = 1; if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { @@ -2478,6 +1848,47 @@ loop_end: } } + /* + * We want CFR output if and only if one of those is true: + * 1) user specified output framerate with -r + * 2) user specified -vsync cfr + * 3) output format is CFR and the user didn't force vsync to + * something else than CFR + * + * in such a case, set ost->frame_rate + */ + if (ost->encoding_needed && ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { + int format_cfr = !(oc->oformat->flags & (AVFMT_NOTIMESTAMPS | AVFMT_VARIABLE_FPS)); + int need_cfr = !!ost->frame_rate.num; + + if (video_sync_method == VSYNC_CFR || + (video_sync_method == VSYNC_AUTO && format_cfr)) + need_cfr = 1; + + if (need_cfr && !ost->frame_rate.num) { + InputStream *ist = ost->source_index >= 0 ? input_streams[ost->source_index] : NULL; + + if (ist && ist->framerate.num) + ost->frame_rate = ist->framerate; + else if (ist && ist->st->avg_frame_rate.num) + ost->frame_rate = ist->st->avg_frame_rate; + else { + av_log(NULL, AV_LOG_WARNING, "Constant framerate requested " + "for the output stream #%d:%d, but no information " + "about the input framerate is available. Falling " + "back to a default value of 25fps. Use the -r option " + "if you want a different framerate.\n", + ost->file_index, ost->index); + ost->frame_rate = (AVRational){ 25, 1 }; + } + } + + if (need_cfr && ost->enc->supported_framerates && !ost->force_fps) { + int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); + ost->frame_rate = ost->enc->supported_framerates[idx]; + } + } + /* set the filter output constraints */ if (ost->filter) { OutputFilter *f = ost->filter; @@ -2538,6 +1949,7 @@ loop_end: break; } } + } /* check filename in case of an image number is expected */ @@ -2548,12 +1960,6 @@ loop_end: } } - if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) { - av_log(NULL, AV_LOG_ERROR, - "No input streams but output needs an input stream\n"); - exit_program(1); - } - if (!(oc->oformat->flags & AVFMT_NOFILE)) { /* test if it already exists to avoid losing precious files */ assert_file_overwrite(filename); @@ -2565,13 +1971,15 @@ loop_end: print_error(filename, err); exit_program(1); } - } else if (strcmp(oc->oformat->name, "image2")==0 && !av_filename_number_test(filename)) - assert_file_overwrite(filename); + } if (o->mux_preload) { - av_dict_set_int(&of->opts, "preload", o->mux_preload*AV_TIME_BASE, 0); + uint8_t buf[64]; + snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE)); + av_dict_set(&of->opts, "preload", buf, 0); } oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE); + oc->flags |= AVFMT_FLAG_NONBLOCK; /* copy metadata */ for (i = 0; i < o->nb_metadata_map; i++) { @@ -2608,13 +2016,9 @@ loop_end: !o->metadata_chapters_manual); /* copy global metadata by default */ - if (!o->metadata_global_manual && nb_input_files){ + if (!o->metadata_global_manual && nb_input_files) av_dict_copy(&oc->metadata, input_files[0]->ctx->metadata, AV_DICT_DONT_OVERWRITE); - if(o->recording_time != INT64_MAX) - av_dict_set(&oc->metadata, "duration", NULL, 0); - av_dict_set(&oc->metadata, "creation_time", NULL, 0); - } if (!o->metadata_streams_manual) for (i = of->ost_index; i < nb_output_streams; i++) { InputStream *ist; @@ -2622,83 +2026,14 @@ loop_end: continue; ist = input_streams[output_streams[i]->source_index]; 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); - } } - /* process manually set programs */ - for (i = 0; i < o->nb_program; i++) { - const char *p = o->program[i].u.str; - int progid = i+1; - AVProgram *program; - - while(*p) { - const char *p2 = av_get_token(&p, ":"); - const char *to_dealloc = p2; - char *key; - if (!p2) - break; - - if(*p) p++; - - key = av_get_token(&p2, "="); - if (!key || !*p2) { - av_freep(&to_dealloc); - av_freep(&key); - break; - } - p2++; - - if (!strcmp(key, "program_num")) - progid = strtol(p2, NULL, 0); - av_freep(&to_dealloc); - av_freep(&key); - } - - program = av_new_program(oc, progid); - - p = o->program[i].u.str; - while(*p) { - const char *p2 = av_get_token(&p, ":"); - const char *to_dealloc = p2; - char *key; - if (!p2) - break; - if(*p) p++; - - key = av_get_token(&p2, "="); - if (!key) { - av_log(NULL, AV_LOG_FATAL, - "No '=' character in program string %s.\n", - p2); - exit_program(1); - } - if (!*p2) - exit_program(1); - p2++; - - if (!strcmp(key, "title")) { - av_dict_set(&program->metadata, "title", p2, 0); - } else if (!strcmp(key, "program_num")) { - } else if (!strcmp(key, "st")) { - int st_num = strtol(p2, NULL, 0); - av_program_add_stream_index(oc, progid, st_num); - } else { - av_log(NULL, AV_LOG_FATAL, "Unknown program key %s.\n", key); - exit_program(1); - } - av_freep(&to_dealloc); - av_freep(&key); - } - } - /* process manually set metadata */ for (i = 0; i < o->nb_metadata; i++) { AVDictionary **m; char type, *val; const char *stream_spec; - int index = 0, j, ret = 0; + int index = 0, j, ret; val = strchr(o->metadata[i].u.str, '='); if (!val) { @@ -2711,18 +2046,8 @@ loop_end: 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) { - 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); - } + av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0); } else if (ret < 0) exit_program(1); } @@ -2739,13 +2064,6 @@ loop_end: } m = &oc->chapters[index]->metadata; break; - case 'p': - if (index < 0 || index >= oc->nb_programs) { - av_log(NULL, AV_LOG_FATAL, "Invalid program index %d in metadata specifier.\n", index); - exit_program(1); - } - m = &oc->programs[index]->metadata; - break; default: av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier); exit_program(1); @@ -2814,17 +2132,17 @@ static int opt_target(void *optctx, const char *opt, const char *arg) parse_option(o, "r", frame_rates[norm], options); opt_default(NULL, "g", norm == PAL ? "15" : "18"); - opt_default(NULL, "b:v", "1150000"); - opt_default(NULL, "maxrate:v", "1150000"); - opt_default(NULL, "minrate:v", "1150000"); - opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8; + opt_default(NULL, "b", "1150000"); + opt_default(NULL, "maxrate", "1150000"); + opt_default(NULL, "minrate", "1150000"); + opt_default(NULL, "bufsize", "327680"); // 40*1024*8; opt_default(NULL, "b:a", "224000"); parse_option(o, "ar", "44100", options); parse_option(o, "ac", "2", options); opt_default(NULL, "packetsize", "2324"); - opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8; + opt_default(NULL, "muxrate", "3528"); // 2352 * 75 / 50; /* We have to offset the PTS, so that it is consistent with the SCR. SCR starts at 36000, but the first two packs contain only padding @@ -2840,15 +2158,15 @@ static int opt_target(void *optctx, const char *opt, const char *arg) parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options); parse_option(o, "r", frame_rates[norm], options); - parse_option(o, "pix_fmt", "yuv420p", options); opt_default(NULL, "g", norm == PAL ? "15" : "18"); - opt_default(NULL, "b:v", "2040000"); - opt_default(NULL, "maxrate:v", "2516000"); - opt_default(NULL, "minrate:v", "0"); // 1145000; - opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8; + opt_default(NULL, "b", "2040000"); + opt_default(NULL, "maxrate", "2516000"); + opt_default(NULL, "minrate", "0"); // 1145000; + opt_default(NULL, "bufsize", "1835008"); // 224*1024*8; opt_default(NULL, "scan_offset", "1"); + opt_default(NULL, "b:a", "224000"); parse_option(o, "ar", "44100", options); @@ -2862,16 +2180,15 @@ static int opt_target(void *optctx, const char *opt, const char *arg) parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options); parse_option(o, "r", frame_rates[norm], options); - parse_option(o, "pix_fmt", "yuv420p", options); opt_default(NULL, "g", norm == PAL ? "15" : "18"); - opt_default(NULL, "b:v", "6000000"); - opt_default(NULL, "maxrate:v", "9000000"); - opt_default(NULL, "minrate:v", "0"); // 1500000; - opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8; + opt_default(NULL, "b", "6000000"); + opt_default(NULL, "maxrate", "9000000"); + opt_default(NULL, "minrate", "0"); // 1500000; + opt_default(NULL, "bufsize", "1835008"); // 224*1024*8; opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack. - opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8 + opt_default(NULL, "muxrate", "25200"); // from mplex project: data_rate = 1260000. mux_rate = data_rate / 50 opt_default(NULL, "b:a", "448000"); parse_option(o, "ar", "48000", options); @@ -2893,8 +2210,8 @@ static int opt_target(void *optctx, const char *opt, const char *arg) return AVERROR(EINVAL); } - av_dict_copy(&o->g->codec_opts, codec_opts, AV_DICT_DONT_OVERWRITE); - av_dict_copy(&o->g->format_opts, format_opts, AV_DICT_DONT_OVERWRITE); + av_dict_copy(&o->g->codec_opts, codec_opts, 0); + av_dict_copy(&o->g->format_opts, format_opts, 0); return 0; } @@ -2913,7 +2230,7 @@ static int opt_vstats(void *optctx, const char *opt, const char *arg) struct tm *today = localtime(&today2); if (!today) { // maybe tomorrow - av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno)); + av_log(NULL, AV_LOG_FATAL, "Unable to get current time.\n"); exit_program(1); } @@ -2940,124 +2257,22 @@ static int opt_data_frames(void *optctx, const char *opt, const char *arg) return parse_option(o, "frames:d", arg, options); } -static int opt_default_new(OptionsContext *o, const char *opt, const char *arg) -{ - int ret; - AVDictionary *cbak = codec_opts; - AVDictionary *fbak = format_opts; - codec_opts = NULL; - format_opts = NULL; - - ret = opt_default(NULL, opt, arg); - - av_dict_copy(&o->g->codec_opts , codec_opts, 0); - av_dict_copy(&o->g->format_opts, format_opts, 0); - av_dict_free(&codec_opts); - av_dict_free(&format_opts); - codec_opts = cbak; - format_opts = fbak; - - return ret; -} - -static int opt_preset(void *optctx, const char *opt, const char *arg) +static int opt_video_tag(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; - FILE *f=NULL; - char filename[1000], line[1000], tmp_line[1000]; - const char *codec_name = NULL; - - tmp_line[0] = *opt; - tmp_line[1] = 0; - MATCH_PER_TYPE_OPT(codec_names, str, codec_name, NULL, tmp_line); - - if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) { - if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){ - av_log(NULL, AV_LOG_FATAL, "Please use -preset -qp 0\n"); - }else - av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg); - exit_program(1); - } - - while (fgets(line, sizeof(line), f)) { - char *key = tmp_line, *value, *endptr; - - if (strcspn(line, "#\n\r") == 0) - continue; - av_strlcpy(tmp_line, line, sizeof(tmp_line)); - if (!av_strtok(key, "=", &value) || - !av_strtok(value, "\r\n", &endptr)) { - av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line); - exit_program(1); - } - av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value); - - if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value); - else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value); - else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value); - else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value); - else if (opt_default_new(o, key, value) < 0) { - av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", - filename, line, key, value); - exit_program(1); - } - } - - fclose(f); - - return 0; + return parse_option(o, "tag:v", arg, options); } -static int opt_old2new(void *optctx, const char *opt, const char *arg) +static int opt_audio_tag(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; - char *s = av_asprintf("%s:%c", opt + 1, *opt); - int ret = parse_option(o, s, arg, options); - av_free(s); - return ret; + return parse_option(o, "tag:a", arg, options); } -static int opt_bitrate(void *optctx, const char *opt, const char *arg) +static int opt_subtitle_tag(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; - - if(!strcmp(opt, "ab")){ - av_dict_set(&o->g->codec_opts, "b:a", arg, 0); - return 0; - } else if(!strcmp(opt, "b")){ - av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n"); - av_dict_set(&o->g->codec_opts, "b:v", arg, 0); - return 0; - } - av_dict_set(&o->g->codec_opts, opt, arg, 0); - return 0; -} - -static int opt_qscale(void *optctx, const char *opt, const char *arg) -{ - OptionsContext *o = optctx; - char *s; - int ret; - if(!strcmp(opt, "qscale")){ - av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n"); - return parse_option(o, "q:v", arg, options); - } - s = av_asprintf("q%s", opt + 6); - ret = parse_option(o, s, arg, options); - av_free(s); - return ret; -} - -static int opt_profile(void *optctx, const char *opt, const char *arg) -{ - OptionsContext *o = optctx; - if(!strcmp(opt, "profile")){ - av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n"); - av_dict_set(&o->g->codec_opts, "profile:v", arg, 0); - return 0; - } - av_dict_set(&o->g->codec_opts, opt, arg, 0); - return 0; + return parse_option(o, "tag:s", arg, options); } static int opt_video_filters(void *optctx, const char *opt, const char *arg) @@ -3077,24 +2292,12 @@ static int opt_vsync(void *optctx, const char *opt, const char *arg) if (!av_strcasecmp(arg, "cfr")) video_sync_method = VSYNC_CFR; else if (!av_strcasecmp(arg, "vfr")) video_sync_method = VSYNC_VFR; else if (!av_strcasecmp(arg, "passthrough")) video_sync_method = VSYNC_PASSTHROUGH; - else if (!av_strcasecmp(arg, "drop")) video_sync_method = VSYNC_DROP; if (video_sync_method == VSYNC_AUTO) video_sync_method = parse_number_or_die("vsync", arg, OPT_INT, VSYNC_AUTO, VSYNC_VFR); return 0; } -static int opt_timecode(void *optctx, const char *opt, const char *arg) -{ - OptionsContext *o = optctx; - char *tcr = av_asprintf("timecode=%s", arg); - int ret = parse_option(o, "metadata:g", tcr, options); - if (ret >= 0) - ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0); - av_free(tcr); - return ret; -} - static int opt_channel_layout(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; @@ -3110,7 +2313,7 @@ static int opt_channel_layout(void *optctx, const char *opt, const char *arg) return AVERROR(EINVAL); } snprintf(layout_str, sizeof(layout_str), "%"PRIu64, layout); - ret = opt_default_new(o, opt, layout_str); + ret = opt_default(NULL, opt, layout_str); if (ret < 0) return ret; @@ -3146,9 +2349,6 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg) filtergraphs[nb_filtergraphs - 1]->graph_desc = av_strdup(arg); if (!filtergraphs[nb_filtergraphs - 1]->graph_desc) return AVERROR(ENOMEM); - - input_stream_potentially_available = 1; - return 0; } @@ -3163,9 +2363,6 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * return AVERROR(ENOMEM); filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1; filtergraphs[nb_filtergraphs - 1]->graph_desc = graph_desc; - - input_stream_potentially_available = 1; - return 0; } @@ -3230,19 +2427,16 @@ void show_help_default(const char *opt, const char *arg) int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM; show_help_children(avcodec_get_class(), flags); show_help_children(avformat_get_class(), flags); -#if CONFIG_SWSCALE show_help_children(sws_get_class(), flags); -#endif - show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM); - show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM); + show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM); } } void show_usage(void) { - av_log(NULL, AV_LOG_INFO, "Hyper fast Audio and Video encoder\n"); - av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name); - av_log(NULL, AV_LOG_INFO, "\n"); + printf("Hyper fast Audio and Video encoder\n"); + printf("usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name); + printf("\n"); } enum OptGroup { @@ -3251,8 +2445,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, @@ -3288,7 +2482,7 @@ static int open_files(OptionGroupList *l, const char *inout, return 0; } -int ffmpeg_parse_options(int argc, char **argv) +int avconv_parse_options(int argc, char **argv) { OptionParseContext octx; uint8_t error[128]; @@ -3311,9 +2505,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) { @@ -3335,8 +2526,6 @@ int ffmpeg_parse_options(int argc, char **argv) goto fail; } - check_filter_outputs(); - fail: uninit_parse_context(&octx); if (ret < 0) { @@ -3346,23 +2535,6 @@ fail: return ret; } -static int opt_progress(void *optctx, const char *opt, const char *arg) -{ - AVIOContext *avio = NULL; - int ret; - - if (!strcmp(arg, "-")) - arg = "pipe:"; - ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n", - arg, av_err2str(ret)); - return ret; - } - progress_avio = avio; - return 0; -} - #define OFFSET(x) offsetof(OptionsContext, x) const OptionDef options[] = { /* main options */ @@ -3372,12 +2544,8 @@ const OptionDef options[] = { "force format", "fmt" }, { "y", OPT_BOOL, { &file_overwrite }, "overwrite output files" }, - { "n", OPT_BOOL, { &no_file_overwrite }, + { "n", OPT_BOOL, { &file_skip }, "never overwrite output files" }, - { "ignore_unknown", OPT_BOOL, { &ignore_unknown_streams }, - "Ignore unknown stream types" }, - { "copy_unknown", OPT_BOOL | OPT_EXPERT, { ©_unknown_streams }, - "Copy unknown stream types" }, { "c", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) }, "codec name", "codec" }, @@ -3391,8 +2559,6 @@ const OptionDef options[] = { OPT_OUTPUT, { .func_arg = opt_map }, "set input stream mapping", "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" }, - { "map_channel", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_map_channel }, - "map an audio channel from one stream to another", "file.stream.channel[:syncfile.syncstream]" }, { "map_metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata_map) }, "set metadata information of outfile from infile", @@ -3404,19 +2570,11 @@ const OptionDef options[] = { OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(recording_time) }, "record or transcode \"duration\" seconds of audio/video", "duration" }, - { "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(stop_time) }, - "record or transcode stop time", "time_stop" }, { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(limit_filesize) }, "set the limit file size in bytes", "limit_size" }, { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time) }, "set the start time offset", "time_off" }, - { "sseof", HAS_ARG | OPT_TIME | OPT_OFFSET | - OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time_eof) }, - "set the start time offset relative to EOF", "time_off" }, - { "seek_timestamp", HAS_ARG | OPT_INT | OPT_OFFSET | - OPT_INPUT, { .off = OFFSET(seek_timestamp) }, - "enable/disable seeking by timestamp with -ss" }, { "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(accurate_seek) }, "enable/disable accurate seeking with -ss" }, @@ -3426,23 +2584,13 @@ const OptionDef options[] = { { "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(ts_scale) }, "set the input ts scale", "scale" }, - { "timestamp", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_recording_timestamp }, - "set the recording timestamp ('now' to set the current time)", "time" }, { "metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata) }, "add metadata", "string=string" }, - { "program", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(program) }, - "add program with specified streams", "title=string:st=number..." }, { "dframes", HAS_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_data_frames }, - "set the number of data frames to output", "number" }, + "set the number of data frames to record", "number" }, { "benchmark", OPT_BOOL | OPT_EXPERT, { &do_benchmark }, "add timings for benchmarking" }, - { "benchmark_all", OPT_BOOL | OPT_EXPERT, { &do_benchmark_all }, - "add timings for each task" }, - { "progress", HAS_ARG | OPT_EXPERT, { .func_arg = opt_progress }, - "write program-readable progress information", "url" }, - { "stdin", OPT_BOOL | OPT_EXPERT, { &stdin_interaction }, - "enable or disable interaction on standard input" }, { "timelimit", HAS_ARG | OPT_EXPERT, { .func_arg = opt_timelimit }, "set max runtime in seconds", "limit" }, { "dump", OPT_BOOL | OPT_EXPERT, { &do_pkt_dump }, @@ -3453,68 +2601,47 @@ const OptionDef options[] = { OPT_INPUT, { .off = OFFSET(rate_emu) }, "read input at native frame rate", "" }, { "target", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_target }, - "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" " - "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" }, + "specify target file type (\"vcd\", \"svcd\", \"dvd\"," + " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" }, { "vsync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vsync }, "video sync method", "" }, - { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold }, - "frame drop threshold", "" }, { "async", HAS_ARG | OPT_INT | OPT_EXPERT, { &audio_sync_method }, "audio sync method", "" }, { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &audio_drift_threshold }, "audio drift threshold", "threshold" }, { "copyts", OPT_BOOL | OPT_EXPERT, { ©_ts }, "copy timestamps" }, - { "start_at_zero", OPT_BOOL | OPT_EXPERT, { &start_at_zero }, - "shift input timestamps to start at 0 when using copyts" }, - { "copytb", HAS_ARG | OPT_INT | OPT_EXPERT, { ©_tb }, - "copy input stream time base when stream copying", "mode" }, + { "copytb", OPT_BOOL | OPT_EXPERT, { ©_tb }, + "copy input stream time base when stream copying" }, { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(shortest) }, "finish encoding within shortest input" }, - { "apad", OPT_STRING | HAS_ARG | OPT_SPEC | - OPT_OUTPUT, { .off = OFFSET(apad) }, - "audio pad", "" }, { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_delta_threshold }, "timestamp discontinuity delta threshold", "threshold" }, - { "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold }, - "timestamp error delta threshold", "threshold" }, { "xerror", OPT_BOOL | OPT_EXPERT, { &exit_on_error }, "exit on error", "error" }, - { "abort_on", HAS_ARG | OPT_EXPERT, { .func_arg = opt_abort_on }, - "abort on the specified condition flags", "flags" }, { "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(copy_initial_nonkeyframes) }, "copy initial non-keyframes" }, - { "copypriorss", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(copy_prior_start) }, - "copy or discard frames before start time" }, { "frames", OPT_INT64 | HAS_ARG | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(max_frames) }, - "set the number of frames to output", "number" }, + "set the number of frames to record", "number" }, { "tag", OPT_STRING | HAS_ARG | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT, { .off = OFFSET(codec_tags) }, "force codec tag/fourcc", "fourcc/tag" }, { "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(qscale) }, "use fixed quality scale (VBR)", "q" }, - { "qscale", HAS_ARG | OPT_EXPERT | OPT_PERFILE | - OPT_OUTPUT, { .func_arg = opt_qscale }, + { "qscale", HAS_ARG | OPT_EXPERT | OPT_DOUBLE | + OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(qscale) }, "use fixed quality scale (VBR)", "q" }, - { "profile", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_profile }, - "set profile", "profile" }, + { "b", HAS_ARG | OPT_INT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(bitrates) }, + "set stream bitrate in bits/second", "bitrate" }, { "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" }, + "set stream filterchain", "filter_list" }, { "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 }, "read complex filtergraph description from a file", "filename" }, { "stats", OPT_BOOL, { &print_stats }, @@ -3525,31 +2652,16 @@ const OptionDef options[] = { { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) }, "extract an attachment into a file", "filename" }, - { "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT | + { "loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT | OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" }, - { "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts }, - "print timestamp debugging info" }, - { "max_error_rate", HAS_ARG | OPT_FLOAT, { &max_error_rate }, - "maximum error rate", "ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." }, - { "discard", OPT_STRING | HAS_ARG | OPT_SPEC | - OPT_INPUT, { .off = OFFSET(discard) }, - "discard", "" }, - { "disposition", OPT_STRING | HAS_ARG | OPT_SPEC | - OPT_OUTPUT, { .off = OFFSET(disposition) }, - "disposition", "" }, - { "thread_queue_size", HAS_ARG | OPT_INT | OPT_OFFSET | OPT_EXPERT | OPT_INPUT, - { .off = OFFSET(thread_queue_size) }, - "set the maximum number of queued packets from the demuxer" }, - { "find_stream_info", OPT_BOOL | OPT_PERFILE | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, - "read and decode the streams to fill missing information with heuristics" }, /* video options */ { "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames }, - "set the number of video frames to output", "number" }, + "set the number of video frames to record", "number" }, { "r", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_rates) }, "set frame rate (Hz value, fraction or abbreviation)", "rate" }, - { "s", OPT_VIDEO | HAS_ARG | OPT_SUBTITLE | OPT_STRING | OPT_SPEC | + { "s", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_sizes) }, "set frame size (WxH or abbreviation)", "size" }, { "aspect", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC | @@ -3558,55 +2670,40 @@ const OptionDef options[] = { { "pix_fmt", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_pix_fmts) }, "set pixel format", "format" }, - { "bits_per_raw_sample", OPT_VIDEO | OPT_INT | HAS_ARG, { &frame_bits_per_raw_sample }, - "set the number of bits per raw sample", "number" }, - { "intra", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &intra_only }, - "deprecated use -g 1" }, - { "vn", OPT_VIDEO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(video_disable) }, + { "vn", OPT_VIDEO | OPT_BOOL | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(video_disable) }, "disable video" }, + { "vdt", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { &video_discard }, + "discard threshold", "n" }, { "rc_override", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(rc_overrides) }, "rate control override for specific intervals", "override" }, { "vcodec", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_video_codec }, "force video codec ('copy' to copy stream)", "codec" }, - { "sameq", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_sameq }, - "Removed" }, - { "same_quant", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_sameq }, - "Removed" }, - { "timecode", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_timecode }, - "set initial TimeCode value.", "hh:mm:ss[:;.]ff" }, { "pass", OPT_VIDEO | HAS_ARG | OPT_SPEC | OPT_INT | OPT_OUTPUT, { .off = OFFSET(pass) }, - "select the pass number (1 to 3)", "n" }, + "select the pass number (1 or 2)", "n" }, { "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(passlogfiles) }, "select two pass log file name prefix", "prefix" }, - { "deinterlace", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_deinterlace }, - "this option is deprecated, use the yadif filter instead" }, - { "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_psnr }, - "calculate PSNR of compressed frames" }, - { "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_vstats }, + { "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = &opt_vstats }, "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" }, + "video filters", "filter list" }, { "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(intra_matrices) }, "specify intra matrix coeffs", "matrix" }, { "inter_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(inter_matrices) }, "specify inter matrix coeffs", "matrix" }, - { "chroma_intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | - OPT_OUTPUT, { .off = OFFSET(chroma_intra_matrices) }, - "specify intra matrix coeffs", "matrix" }, { "top", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_INT| OPT_SPEC | - OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(top_field_first) }, + OPT_OUTPUT, { .off = OFFSET(top_field_first) }, "top=1/bottom=0/auto=-1 field first", "" }, + { "dc", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { &intra_dc_precision }, + "intra_dc_precision", "precision" }, { "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | - OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_old2new }, + OPT_OUTPUT, { .func_arg = opt_video_tag }, "force video tag/fourcc", "fourcc/tag" }, { "qphist", OPT_VIDEO | OPT_BOOL | OPT_EXPERT , { &qp_hist }, "show QP histogram" }, @@ -3619,10 +2716,6 @@ const OptionDef options[] = { { "force_key_frames", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(forced_key_frames) }, "force key frames at specified timestamps", "timestamps" }, - { "ab", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate }, - "audio bitrate (please use -b:a)", "bitrate" }, - { "b", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate }, - "video bitrate (please use -b:v)", "bitrate" }, { "hwaccel", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccels) }, "use HW accelerated decoding", "hwaccel name" }, @@ -3632,9 +2725,7 @@ const OptionDef options[] = { { "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 CONFIG_VDA || CONFIG_VIDEOTOOLBOX - { "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" }, -#endif + { "hwaccels", OPT_EXIT, { .func_arg = show_hwaccels }, "show available HW acceleration methods" }, { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC | @@ -3645,7 +2736,7 @@ const OptionDef options[] = { /* audio options */ { "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames }, - "set the number of audio frames to output", "number" }, + "set the number of audio frames to record", "number" }, { "aq", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_qscale }, "set audio quality (codec-specific)", "quality", }, { "ar", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC | @@ -3654,13 +2745,13 @@ const OptionDef options[] = { { "ac", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_channels) }, "set number of audio channels", "channels" }, - { "an", OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(audio_disable) }, + { "an", OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(audio_disable) }, "disable audio" }, { "acodec", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_audio_codec }, "force audio codec ('copy' to copy stream)", "codec" }, { "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE | - OPT_OUTPUT, { .func_arg = opt_old2new }, + OPT_OUTPUT, { .func_arg = opt_audio_tag }, "force audio tag/fourcc", "fourcc/tag" }, { "vol", OPT_AUDIO | HAS_ARG | OPT_INT, { &audio_volume }, "change audio volume (256=normal)" , "volume" }, @@ -3671,27 +2762,17 @@ const OptionDef options[] = { OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_channel_layout }, "set channel layout", "layout" }, { "af", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_filters }, - "set audio filters", "filter_graph" }, - { "guess_layout_max", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(guess_layout_max) }, - "set the maximum number of channels to try to guess the channel layout" }, + "audio filters", "filter list" }, /* subtitle options */ - { "sn", OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(subtitle_disable) }, + { "sn", OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(subtitle_disable) }, "disable subtitle" }, { "scodec", OPT_SUBTITLE | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_subtitle_codec }, "force subtitle codec ('copy' to copy stream)", "codec" }, - { "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new } + { "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_subtitle_tag } , "force subtitle tag/fourcc", "fourcc/tag" }, - { "fix_sub_duration", OPT_BOOL | OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT, { .off = OFFSET(fix_sub_duration) }, - "fix subtitles duration" }, - { "canvas_size", OPT_SUBTITLE | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT, { .off = OFFSET(canvas_sizes) }, - "set canvas size (WxH or abbreviation)", "size" }, /* grab options */ - { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_video_channel }, - "deprecated, use -channel", "channel" }, - { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_video_standard }, - "deprecated, use -standard", "standard" }, { "isync", OPT_BOOL | OPT_EXPERT, { &input_sync }, "this option is deprecated and does nothing", "" }, /* muxer options */ @@ -3699,34 +2780,9 @@ const OptionDef options[] = { "set the maximum demux-decode delay", "seconds" }, { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_preload) }, "set the initial demux-decode delay", "seconds" }, - { "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_ffserver }, - "override the options from ffserver", "" }, - { "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" }, - { "enc_time_base", HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(enc_time_bases) }, - "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). " - "two special values are defined - " - "0 = use frame rate (video) or sample rate (audio)," - "-1 = match source time base", "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 }, - "deprecated", "audio bitstream_filters" }, - { "vbsf", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new }, - "deprecated", "video bitstream_filters" }, - - { "apre", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset }, - "set the audio options to the indicated preset", "preset" }, - { "vpre", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset }, - "set the video options to the indicated preset", "preset" }, - { "spre", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset }, - "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" }, @@ -3734,19 +2790,12 @@ const OptionDef options[] = { /* 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 - { "init_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_init_hw_device }, "initialise hardware device", "args" }, { "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_hw_device }, diff --git a/ffmpeg_qsv.c b/avtools/avconv_qsv.c similarity index 79% rename from ffmpeg_qsv.c rename to avtools/avconv_qsv.c index 7442750029..723c6e0224 100644 --- a/ffmpeg_qsv.c +++ b/avtools/avconv_qsv.c @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -26,9 +26,7 @@ #include "libavutil/opt.h" #include "libavcodec/qsv.h" -#include "ffmpeg.h" - -char *qsv_device = NULL; +#include "avconv.h" static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags) { @@ -46,26 +44,15 @@ static void qsv_uninit(AVCodecContext *s) static int qsv_device_init(InputStream *ist) { int err; - AVDictionary *dict = NULL; - - if (qsv_device) { - err = av_dict_set(&dict, "child_device", qsv_device, 0); - if (err < 0) - return err; - } err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_QSV, - ist->hwaccel_device, dict, 0); + ist->hwaccel_device, NULL, 0); if (err < 0) { av_log(NULL, AV_LOG_ERROR, "Error creating a QSV device\n"); - goto err_out; + return err; } -err_out: - if (dict) - av_dict_free(&dict); - - return err; + return 0; } int qsv_init(AVCodecContext *s) @@ -93,7 +80,7 @@ int qsv_init(AVCodecContext *s) 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_ctx->initial_pool_size = 32; frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; ret = av_hwframe_ctx_init(ist->hw_frames_ctx); diff --git a/avtools/avconv_vda.c b/avtools/avconv_vda.c new file mode 100644 index 0000000000..d86076e79e --- /dev/null +++ b/avtools/avconv_vda.c @@ -0,0 +1,136 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/avcodec.h" +#include "libavcodec/vda.h" +#include "libavutil/imgutils.h" + +#include "avconv.h" + +typedef struct VDAContext { + AVFrame *tmp_frame; +} VDAContext; + +static int vda_retrieve_data(AVCodecContext *s, AVFrame *frame) +{ + InputStream *ist = s->opaque; + VDAContext *vda = ist->hwaccel_ctx; + CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3]; + OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf); + CVReturn err; + uint8_t *data[4] = { 0 }; + int linesize[4] = { 0 }; + int planes, ret, i; + + av_frame_unref(vda->tmp_frame); + + switch (pixel_format) { + case kCVPixelFormatType_420YpCbCr8Planar: vda->tmp_frame->format = AV_PIX_FMT_YUV420P; break; + case kCVPixelFormatType_422YpCbCr8: vda->tmp_frame->format = AV_PIX_FMT_UYVY422; break; + default: + av_log(NULL, AV_LOG_ERROR, + "Unsupported pixel format: %u\n", pixel_format); + return AVERROR(ENOSYS); + } + + vda->tmp_frame->width = frame->width; + vda->tmp_frame->height = frame->height; + ret = av_frame_get_buffer(vda->tmp_frame, 32); + if (ret < 0) + return ret; + + err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); + if (err != kCVReturnSuccess) { + av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n"); + return AVERROR_UNKNOWN; + } + + if (CVPixelBufferIsPlanar(pixbuf)) { + + planes = CVPixelBufferGetPlaneCount(pixbuf); + for (i = 0; i < planes; i++) { + data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i); + linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i); + } + } else { + data[0] = CVPixelBufferGetBaseAddress(pixbuf); + linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf); + } + + av_image_copy(vda->tmp_frame->data, vda->tmp_frame->linesize, + data, linesize, vda->tmp_frame->format, + frame->width, frame->height); + + CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); + + ret = av_frame_copy_props(vda->tmp_frame, frame); + if (ret < 0) + return ret; + + av_frame_unref(frame); + av_frame_move_ref(frame, vda->tmp_frame); + + return 0; +} + +static void vda_uninit(AVCodecContext *s) +{ + InputStream *ist = s->opaque; + VDAContext *vda = ist->hwaccel_ctx; + + ist->hwaccel_uninit = NULL; + ist->hwaccel_retrieve_data = NULL; + + av_frame_free(&vda->tmp_frame); + + av_vda_default_free(s); + av_freep(&ist->hwaccel_ctx); +} + +int vda_init(AVCodecContext *s) +{ + InputStream *ist = s->opaque; + int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; + VDAContext *vda; + int ret; + + vda = av_mallocz(sizeof(*vda)); + if (!vda) + return AVERROR(ENOMEM); + + ist->hwaccel_ctx = vda; + ist->hwaccel_uninit = vda_uninit; + ist->hwaccel_retrieve_data = vda_retrieve_data; + + vda->tmp_frame = av_frame_alloc(); + if (!vda->tmp_frame) { + ret = AVERROR(ENOMEM); + goto fail; + } + + ret = av_vda_default_init(s); + if (ret < 0) { + av_log(NULL, loglevel, "Error creating VDA decoder.\n"); + goto fail; + } + + return 0; +fail: + vda_uninit(s); + return ret; +} diff --git a/avtools/avplay.c b/avtools/avplay.c new file mode 100644 index 0000000000..b6dbc52cf7 --- /dev/null +++ b/avtools/avplay.c @@ -0,0 +1,3073 @@ +/* + * avplay : Simple Media Player based on the Libav libraries + * Copyright (c) 2003 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include +#include +#include +#include + +#include "libavutil/avstring.h" +#include "libavutil/colorspace.h" +#include "libavutil/display.h" +#include "libavutil/mathematics.h" +#include "libavutil/pixdesc.h" +#include "libavutil/imgutils.h" +#include "libavutil/dict.h" +#include "libavutil/parseutils.h" +#include "libavutil/samplefmt.h" +#include "libavutil/time.h" +#include "libavformat/avformat.h" +#include "libavdevice/avdevice.h" +#include "libavresample/avresample.h" +#include "libavutil/opt.h" +#include "libavcodec/avfft.h" + +#include "libavfilter/avfilter.h" +#include "libavfilter/buffersink.h" +#include "libavfilter/buffersrc.h" + +#include "cmdutils.h" + +#include +#include + +#ifdef __MINGW32__ +#undef main /* We don't want SDL to override our main() */ +#endif + +#include + +const char program_name[] = "avplay"; +const int program_birth_year = 2003; + +#define MAX_QUEUE_SIZE (15 * 1024 * 1024) +#define MIN_AUDIOQ_SIZE (20 * 16 * 1024) +#define MIN_FRAMES 5 + +/* SDL audio buffer size, in samples. Should be small to have precise + A/V sync as SDL does not have hardware buffer fullness info. */ +#define SDL_AUDIO_BUFFER_SIZE 1024 + +/* no AV sync correction is done if below the AV sync threshold */ +#define AV_SYNC_THRESHOLD 0.01 +/* no AV correction is done if too big error */ +#define AV_NOSYNC_THRESHOLD 10.0 + +#define FRAME_SKIP_FACTOR 0.05 + +/* maximum audio speed change to get correct sync */ +#define SAMPLE_CORRECTION_PERCENT_MAX 10 + +/* we use about AUDIO_DIFF_AVG_NB A-V differences to make the average */ +#define AUDIO_DIFF_AVG_NB 20 + +/* NOTE: the size must be big enough to compensate the hardware audio buffersize size */ +#define SAMPLE_ARRAY_SIZE (2 * 65536) + +static int64_t sws_flags = SWS_BICUBIC; + +typedef struct PacketQueue { + AVPacketList *first_pkt, *last_pkt; + int nb_packets; + int size; + int abort_request; + SDL_mutex *mutex; + SDL_cond *cond; +} PacketQueue; + +#define VIDEO_PICTURE_QUEUE_SIZE 2 +#define SUBPICTURE_QUEUE_SIZE 4 + +typedef struct VideoPicture { + double pts; // presentation timestamp for this picture + double target_clock; // av_gettime_relative() time at which this should be displayed ideally + int64_t pos; // byte position in file + SDL_Overlay *bmp; + int width, height; /* source height & width */ + int allocated; + int reallocate; + enum AVPixelFormat pix_fmt; + + AVRational sar; +} VideoPicture; + +typedef struct SubPicture { + double pts; /* presentation time stamp for this picture */ + AVSubtitle sub; +} SubPicture; + +enum { + AV_SYNC_AUDIO_MASTER, /* default choice */ + AV_SYNC_VIDEO_MASTER, + AV_SYNC_EXTERNAL_CLOCK, /* synchronize to an external clock */ +}; + +typedef struct PlayerState { + SDL_Thread *parse_tid; + SDL_Thread *video_tid; + SDL_Thread *refresh_tid; + AVInputFormat *iformat; + int no_background; + int abort_request; + int paused; + int last_paused; + int seek_req; + int seek_flags; + int64_t seek_pos; + int64_t seek_rel; + int read_pause_return; + AVFormatContext *ic; + + int audio_stream; + + int av_sync_type; + double external_clock; /* external clock base */ + int64_t external_clock_time; + + double audio_clock; + double audio_diff_cum; /* used for AV difference average computation */ + double audio_diff_avg_coef; + double audio_diff_threshold; + int audio_diff_avg_count; + AVStream *audio_st; + AVCodecContext *audio_dec; + PacketQueue audioq; + int audio_hw_buf_size; + uint8_t silence_buf[SDL_AUDIO_BUFFER_SIZE]; + uint8_t *audio_buf; + uint8_t *audio_buf1; + unsigned int audio_buf_size; /* in bytes */ + int audio_buf_index; /* in bytes */ + AVPacket audio_pkt_temp; + AVPacket audio_pkt; + enum AVSampleFormat sdl_sample_fmt; + uint64_t sdl_channel_layout; + int sdl_channels; + int sdl_sample_rate; + enum AVSampleFormat resample_sample_fmt; + uint64_t resample_channel_layout; + int resample_sample_rate; + AVAudioResampleContext *avr; + AVFrame *frame; + + int show_audio; /* if true, display audio samples */ + int16_t sample_array[SAMPLE_ARRAY_SIZE]; + int sample_array_index; + int last_i_start; + RDFTContext *rdft; + int rdft_bits; + FFTSample *rdft_data; + int xpos; + + SDL_Thread *subtitle_tid; + int subtitle_stream; + int subtitle_stream_changed; + AVStream *subtitle_st; + AVCodecContext *subtitle_dec; + PacketQueue subtitleq; + SubPicture subpq[SUBPICTURE_QUEUE_SIZE]; + int subpq_size, subpq_rindex, subpq_windex; + SDL_mutex *subpq_mutex; + SDL_cond *subpq_cond; + + double frame_timer; + double frame_last_pts; + double frame_last_delay; + double video_clock; // pts of last decoded frame / predicted pts of next decoded frame + int video_stream; + AVStream *video_st; + AVCodecContext *video_dec; + PacketQueue videoq; + double video_current_pts; // current displayed pts (different from video_clock if frame fifos are used) + double video_current_pts_drift; // video_current_pts - time (av_gettime_relative) at which we updated video_current_pts - used to have running video pts + int64_t video_current_pos; // current displayed file pos + VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE]; + int pictq_size, pictq_rindex, pictq_windex; + SDL_mutex *pictq_mutex; + SDL_cond *pictq_cond; + + // QETimer *video_timer; + char filename[1024]; + int width, height, xleft, ytop; + + PtsCorrectionContext pts_ctx; + + AVFilterContext *in_video_filter; // the first filter in the video chain + AVFilterContext *out_video_filter; // the last filter in the video chain + SDL_mutex *video_filter_mutex; + + float skip_frames; + float skip_frames_index; + int refresh; + + SpecifierOpt *codec_names; + int nb_codec_names; +} PlayerState; + +/* options specified by the user */ +static AVInputFormat *file_iformat; +static const char *input_filename; +static const char *window_title; +static int fs_screen_width; +static int fs_screen_height; +static int screen_width = 0; +static int screen_height = 0; +static int audio_disable; +static int video_disable; +static int wanted_stream[AVMEDIA_TYPE_NB] = { + [AVMEDIA_TYPE_AUDIO] = -1, + [AVMEDIA_TYPE_VIDEO] = -1, + [AVMEDIA_TYPE_SUBTITLE] = -1, +}; +static int seek_by_bytes = -1; +static int display_disable; +static int show_status = 1; +static int av_sync_type = AV_SYNC_AUDIO_MASTER; +static int64_t start_time = AV_NOPTS_VALUE; +static int64_t duration = AV_NOPTS_VALUE; +static int step = 0; +static int workaround_bugs = 1; +static int fast = 0; +static int genpts = 0; +static int idct = FF_IDCT_AUTO; +static enum AVDiscard skip_frame = AVDISCARD_DEFAULT; +static enum AVDiscard skip_idct = AVDISCARD_DEFAULT; +static enum AVDiscard skip_loop_filter = AVDISCARD_DEFAULT; +static int error_concealment = 3; +static int decoder_reorder_pts = -1; +static int noautoexit; +static int exit_on_keydown; +static int exit_on_mousedown; +static int loop = 1; +static int framedrop = 1; +static int infinite_buffer = 0; + +static int rdftspeed = 20; +static char *vfilters = NULL; +static int autorotate = 1; + +/* current context */ +static int is_full_screen; +static PlayerState player_state; +static PlayerState *player = &player_state; +static int64_t audio_callback_time; + +static AVPacket flush_pkt; + +#define FF_ALLOC_EVENT (SDL_USEREVENT) +#define FF_REFRESH_EVENT (SDL_USEREVENT + 1) +#define FF_QUIT_EVENT (SDL_USEREVENT + 2) + +static SDL_Surface *screen; + +static int packet_queue_put(PacketQueue *q, AVPacket *pkt); + +/* packet queue handling */ +static void packet_queue_init(PacketQueue *q) +{ + memset(q, 0, sizeof(PacketQueue)); + q->mutex = SDL_CreateMutex(); + q->cond = SDL_CreateCond(); + packet_queue_put(q, &flush_pkt); +} + +static void packet_queue_flush(PacketQueue *q) +{ + AVPacketList *pkt, *pkt1; + + SDL_LockMutex(q->mutex); + for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { + pkt1 = pkt->next; + av_packet_unref(&pkt->pkt); + av_freep(&pkt); + } + q->last_pkt = NULL; + q->first_pkt = NULL; + q->nb_packets = 0; + q->size = 0; + SDL_UnlockMutex(q->mutex); +} + +static void packet_queue_end(PacketQueue *q) +{ + packet_queue_flush(q); + SDL_DestroyMutex(q->mutex); + SDL_DestroyCond(q->cond); +} + +static int packet_queue_put(PacketQueue *q, AVPacket *pkt) +{ + AVPacketList *pkt1; + + pkt1 = av_malloc(sizeof(AVPacketList)); + if (!pkt1) + return -1; + pkt1->pkt = *pkt; + pkt1->next = NULL; + + + SDL_LockMutex(q->mutex); + + if (!q->last_pkt) + + q->first_pkt = pkt1; + else + q->last_pkt->next = pkt1; + q->last_pkt = pkt1; + q->nb_packets++; + q->size += pkt1->pkt.size + sizeof(*pkt1); + /* XXX: should duplicate packet data in DV case */ + SDL_CondSignal(q->cond); + + SDL_UnlockMutex(q->mutex); + return 0; +} + +static void packet_queue_abort(PacketQueue *q) +{ + SDL_LockMutex(q->mutex); + + q->abort_request = 1; + + SDL_CondSignal(q->cond); + + SDL_UnlockMutex(q->mutex); +} + +/* return < 0 if aborted, 0 if no packet and > 0 if packet. */ +static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block) +{ + AVPacketList *pkt1; + int ret; + + SDL_LockMutex(q->mutex); + + for (;;) { + if (q->abort_request) { + ret = -1; + break; + } + + pkt1 = q->first_pkt; + if (pkt1) { + q->first_pkt = pkt1->next; + if (!q->first_pkt) + q->last_pkt = NULL; + q->nb_packets--; + q->size -= pkt1->pkt.size + sizeof(*pkt1); + *pkt = pkt1->pkt; + av_free(pkt1); + ret = 1; + break; + } else if (!block) { + ret = 0; + break; + } else { + SDL_CondWait(q->cond, q->mutex); + } + } + SDL_UnlockMutex(q->mutex); + return ret; +} + +static inline void fill_rectangle(SDL_Surface *screen, + int x, int y, int w, int h, int color) +{ + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + SDL_FillRect(screen, &rect, color); +} + +#define ALPHA_BLEND(a, oldp, newp, s)\ +((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s)) + +#define RGBA_IN(r, g, b, a, s)\ +{\ + unsigned int v = ((const uint32_t *)(s))[0];\ + a = (v >> 24) & 0xff;\ + r = (v >> 16) & 0xff;\ + g = (v >> 8) & 0xff;\ + b = v & 0xff;\ +} + +#define YUVA_IN(y, u, v, a, s, pal)\ +{\ + unsigned int val = ((const uint32_t *)(pal))[*(const uint8_t*)(s)];\ + a = (val >> 24) & 0xff;\ + y = (val >> 16) & 0xff;\ + u = (val >> 8) & 0xff;\ + v = val & 0xff;\ +} + +#define YUVA_OUT(d, y, u, v, a)\ +{\ + ((uint32_t *)(d))[0] = (a << 24) | (y << 16) | (u << 8) | v;\ +} + + +#define BPP 1 + +static void blend_subrect(uint8_t *dst[4], uint16_t dst_linesize[4], + const AVSubtitleRect *rect, int imgw, int imgh) +{ + int wrap, wrap3, width2, skip2; + int y, u, v, a, u1, v1, a1, w, h; + uint8_t *lum, *cb, *cr; + const uint8_t *p; + const uint32_t *pal; + int dstx, dsty, dstw, dsth; + + dstw = av_clip(rect->w, 0, imgw); + dsth = av_clip(rect->h, 0, imgh); + dstx = av_clip(rect->x, 0, imgw - dstw); + dsty = av_clip(rect->y, 0, imgh - dsth); + /* sdl has U and V inverted */ + lum = dst[0] + dsty * dst_linesize[0]; + cb = dst[2] + (dsty >> 1) * dst_linesize[2]; + cr = dst[1] + (dsty >> 1) * dst_linesize[1]; + + width2 = ((dstw + 1) >> 1) + (dstx & ~dstw & 1); + skip2 = dstx >> 1; + wrap = dst_linesize[0]; + wrap3 = rect->linesize[0]; + p = rect->data[0]; + pal = (const uint32_t *)rect->data[1]; /* Now in YCrCb! */ + + if (dsty & 1) { + lum += dstx; + cb += skip2; + cr += skip2; + + if (dstx & 1) { + YUVA_IN(y, u, v, a, p, pal); + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); + cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); + cb++; + cr++; + lum++; + p += BPP; + } + for (w = dstw - (dstx & 1); w >= 2; w -= 2) { + YUVA_IN(y, u, v, a, p, pal); + u1 = u; + v1 = v; + a1 = a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + + YUVA_IN(y, u, v, a, p + BPP, pal); + u1 += u; + v1 += v; + a1 += a; + lum[1] = ALPHA_BLEND(a, lum[1], y, 0); + cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 1); + cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 1); + cb++; + cr++; + p += 2 * BPP; + lum += 2; + } + if (w) { + YUVA_IN(y, u, v, a, p, pal); + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); + cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); + p++; + lum++; + } + p += wrap3 - dstw * BPP; + lum += wrap - dstw - dstx; + cb += dst_linesize[2] - width2 - skip2; + cr += dst_linesize[1] - width2 - skip2; + } + for (h = dsth - (dsty & 1); h >= 2; h -= 2) { + lum += dstx; + cb += skip2; + cr += skip2; + + if (dstx & 1) { + YUVA_IN(y, u, v, a, p, pal); + u1 = u; + v1 = v; + a1 = a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + p += wrap3; + lum += wrap; + YUVA_IN(y, u, v, a, p, pal); + u1 += u; + v1 += v; + a1 += a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 1); + cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 1); + cb++; + cr++; + p += -wrap3 + BPP; + lum += -wrap + 1; + } + for (w = dstw - (dstx & 1); w >= 2; w -= 2) { + YUVA_IN(y, u, v, a, p, pal); + u1 = u; + v1 = v; + a1 = a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + + YUVA_IN(y, u, v, a, p + BPP, pal); + u1 += u; + v1 += v; + a1 += a; + lum[1] = ALPHA_BLEND(a, lum[1], y, 0); + p += wrap3; + lum += wrap; + + YUVA_IN(y, u, v, a, p, pal); + u1 += u; + v1 += v; + a1 += a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + + YUVA_IN(y, u, v, a, p + BPP, pal); + u1 += u; + v1 += v; + a1 += a; + lum[1] = ALPHA_BLEND(a, lum[1], y, 0); + + cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 2); + cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 2); + + cb++; + cr++; + p += -wrap3 + 2 * BPP; + lum += -wrap + 2; + } + if (w) { + YUVA_IN(y, u, v, a, p, pal); + u1 = u; + v1 = v; + a1 = a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + p += wrap3; + lum += wrap; + YUVA_IN(y, u, v, a, p, pal); + u1 += u; + v1 += v; + a1 += a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u1, 1); + cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v1, 1); + cb++; + cr++; + p += -wrap3 + BPP; + lum += -wrap + 1; + } + p += wrap3 + (wrap3 - dstw * BPP); + lum += wrap + (wrap - dstw - dstx); + cb += dst_linesize[2] - width2 - skip2; + cr += dst_linesize[1] - width2 - skip2; + } + /* handle odd height */ + if (h) { + lum += dstx; + cb += skip2; + cr += skip2; + + if (dstx & 1) { + YUVA_IN(y, u, v, a, p, pal); + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); + cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); + cb++; + cr++; + lum++; + p += BPP; + } + for (w = dstw - (dstx & 1); w >= 2; w -= 2) { + YUVA_IN(y, u, v, a, p, pal); + u1 = u; + v1 = v; + a1 = a; + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + + YUVA_IN(y, u, v, a, p + BPP, pal); + u1 += u; + v1 += v; + a1 += a; + lum[1] = ALPHA_BLEND(a, lum[1], y, 0); + cb[0] = ALPHA_BLEND(a1 >> 2, cb[0], u, 1); + cr[0] = ALPHA_BLEND(a1 >> 2, cr[0], v, 1); + cb++; + cr++; + p += 2 * BPP; + lum += 2; + } + if (w) { + YUVA_IN(y, u, v, a, p, pal); + lum[0] = ALPHA_BLEND(a, lum[0], y, 0); + cb[0] = ALPHA_BLEND(a >> 2, cb[0], u, 0); + cr[0] = ALPHA_BLEND(a >> 2, cr[0], v, 0); + } + } +} + +static void free_subpicture(SubPicture *sp) +{ + avsubtitle_free(&sp->sub); +} + +static void video_image_display(PlayerState *is) +{ + VideoPicture *vp; + SubPicture *sp; + float aspect_ratio; + int width, height, x, y; + SDL_Rect rect; + int i; + + vp = &is->pictq[is->pictq_rindex]; + if (vp->bmp) { + if (!vp->sar.num) + aspect_ratio = 0; + else + aspect_ratio = av_q2d(vp->sar); + if (aspect_ratio <= 0.0) + aspect_ratio = 1.0; + aspect_ratio *= (float)vp->width / (float)vp->height; + + if (is->subtitle_st) + { + if (is->subpq_size > 0) + { + sp = &is->subpq[is->subpq_rindex]; + + if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 1000)) + { + SDL_LockYUVOverlay (vp->bmp); + + for (i = 0; i < sp->sub.num_rects; i++) + blend_subrect(vp->bmp->pixels, vp->bmp->pitches, + sp->sub.rects[i], vp->bmp->w, vp->bmp->h); + + SDL_UnlockYUVOverlay (vp->bmp); + } + } + } + + + /* XXX: we suppose the screen has a 1.0 pixel ratio */ + height = is->height; + width = ((int)rint(height * aspect_ratio)) & ~1; + if (width > is->width) { + width = is->width; + height = ((int)rint(width / aspect_ratio)) & ~1; + } + x = (is->width - width) / 2; + y = (is->height - height) / 2; + is->no_background = 0; + rect.x = is->xleft + x; + rect.y = is->ytop + y; + rect.w = width; + rect.h = height; + SDL_DisplayYUVOverlay(vp->bmp, &rect); + } +} + +/* get the current audio output buffer size, in samples. With SDL, we + cannot have a precise information */ +static int audio_write_get_buf_size(PlayerState *is) +{ + return is->audio_buf_size - is->audio_buf_index; +} + +static inline int compute_mod(int a, int b) +{ + a = a % b; + if (a >= 0) + return a; + else + return a + b; +} + +static void video_audio_display(PlayerState *s) +{ + int i, i_start, x, y1, y, ys, delay, n, nb_display_channels; + int ch, channels, h, h2, bgcolor, fgcolor; + int16_t time_diff; + int rdft_bits, nb_freq; + + for (rdft_bits = 1; (1 << rdft_bits) < 2 * s->height; rdft_bits++) + ; + nb_freq = 1 << (rdft_bits - 1); + + /* compute display index : center on currently output samples */ + channels = s->sdl_channels; + nb_display_channels = channels; + if (!s->paused) { + int data_used = s->show_audio == 1 ? s->width : (2 * nb_freq); + n = 2 * channels; + delay = audio_write_get_buf_size(s); + delay /= n; + + /* to be more precise, we take into account the time spent since + the last buffer computation */ + if (audio_callback_time) { + time_diff = av_gettime_relative() - audio_callback_time; + delay -= (time_diff * s->sdl_sample_rate) / 1000000; + } + + delay += 2 * data_used; + if (delay < data_used) + delay = data_used; + + i_start= x = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE); + if (s->show_audio == 1) { + h = INT_MIN; + for (i = 0; i < 1000; i += channels) { + int idx = (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE; + int a = s->sample_array[idx]; + int b = s->sample_array[(idx + 4 * channels) % SAMPLE_ARRAY_SIZE]; + int c = s->sample_array[(idx + 5 * channels) % SAMPLE_ARRAY_SIZE]; + int d = s->sample_array[(idx + 9 * channels) % SAMPLE_ARRAY_SIZE]; + int score = a - d; + if (h < score && (b ^ c) < 0) { + h = score; + i_start = idx; + } + } + } + + s->last_i_start = i_start; + } else { + i_start = s->last_i_start; + } + + bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); + if (s->show_audio == 1) { + fill_rectangle(screen, + s->xleft, s->ytop, s->width, s->height, + bgcolor); + + fgcolor = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff); + + /* total height for one channel */ + h = s->height / nb_display_channels; + /* graph height / 2 */ + h2 = (h * 9) / 20; + for (ch = 0; ch < nb_display_channels; ch++) { + i = i_start + ch; + y1 = s->ytop + ch * h + (h / 2); /* position of center line */ + for (x = 0; x < s->width; x++) { + y = (s->sample_array[i] * h2) >> 15; + if (y < 0) { + y = -y; + ys = y1 - y; + } else { + ys = y1; + } + fill_rectangle(screen, + s->xleft + x, ys, 1, y, + fgcolor); + i += channels; + if (i >= SAMPLE_ARRAY_SIZE) + i -= SAMPLE_ARRAY_SIZE; + } + } + + fgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff); + + for (ch = 1; ch < nb_display_channels; ch++) { + y = s->ytop + ch * h; + fill_rectangle(screen, + s->xleft, y, s->width, 1, + fgcolor); + } + SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height); + } else { + nb_display_channels= FFMIN(nb_display_channels, 2); + if (rdft_bits != s->rdft_bits) { + av_rdft_end(s->rdft); + av_free(s->rdft_data); + s->rdft = av_rdft_init(rdft_bits, DFT_R2C); + s->rdft_bits = rdft_bits; + s->rdft_data = av_malloc(4 * nb_freq * sizeof(*s->rdft_data)); + } + { + FFTSample *data[2]; + for (ch = 0; ch < nb_display_channels; ch++) { + data[ch] = s->rdft_data + 2 * nb_freq * ch; + i = i_start + ch; + for (x = 0; x < 2 * nb_freq; x++) { + double w = (x-nb_freq) * (1.0 / nb_freq); + data[ch][x] = s->sample_array[i] * (1.0 - w * w); + i += channels; + if (i >= SAMPLE_ARRAY_SIZE) + i -= SAMPLE_ARRAY_SIZE; + } + av_rdft_calc(s->rdft, data[ch]); + } + /* Least efficient way to do this, we should of course + * directly access it but it is more than fast enough. */ + for (y = 0; y < s->height; y++) { + double w = 1 / sqrt(nb_freq); + int a = sqrt(w * sqrt(data[0][2 * y + 0] * data[0][2 * y + 0] + data[0][2 * y + 1] * data[0][2 * y + 1])); + int b = (nb_display_channels == 2 ) ? sqrt(w * sqrt(data[1][2 * y + 0] * data[1][2 * y + 0] + + data[1][2 * y + 1] * data[1][2 * y + 1])) : a; + a = FFMIN(a, 255); + b = FFMIN(b, 255); + fgcolor = SDL_MapRGB(screen->format, a, b, (a + b) / 2); + + fill_rectangle(screen, + s->xpos, s->height-y, 1, 1, + fgcolor); + } + } + SDL_UpdateRect(screen, s->xpos, s->ytop, 1, s->height); + s->xpos++; + if (s->xpos >= s->width) + s->xpos= s->xleft; + } +} + +static int video_open(PlayerState *is) +{ + int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; + int w,h; + + if (is_full_screen) flags |= SDL_FULLSCREEN; + else flags |= SDL_RESIZABLE; + + if (is_full_screen && fs_screen_width) { + w = fs_screen_width; + h = fs_screen_height; + } else if (!is_full_screen && screen_width) { + w = screen_width; + h = screen_height; + } else if (is->out_video_filter && is->out_video_filter->inputs[0]) { + w = is->out_video_filter->inputs[0]->w; + h = is->out_video_filter->inputs[0]->h; + } else { + w = 640; + h = 480; + } + if (screen && is->width == screen->w && screen->w == w + && is->height== screen->h && screen->h == h) + return 0; + +#if defined(__APPLE__) && !SDL_VERSION_ATLEAST(1, 2, 14) + /* setting bits_per_pixel = 0 or 32 causes blank video on OS X and older SDL */ + screen = SDL_SetVideoMode(w, h, 24, flags); +#else + screen = SDL_SetVideoMode(w, h, 0, flags); +#endif + if (!screen) { + fprintf(stderr, "SDL: could not set video mode - exiting\n"); + return -1; + } + if (!window_title) + window_title = input_filename; + SDL_WM_SetCaption(window_title, window_title); + + is->width = screen->w; + is->height = screen->h; + + return 0; +} + +/* display the current picture, if any */ +static void video_display(PlayerState *is) +{ + if (!screen) + video_open(player); + if (is->audio_st && is->show_audio) + video_audio_display(is); + else if (is->video_st) + video_image_display(is); +} + +static int refresh_thread(void *opaque) +{ + PlayerState *is= opaque; + while (!is->abort_request) { + SDL_Event event; + event.type = FF_REFRESH_EVENT; + event.user.data1 = opaque; + if (!is->refresh) { + is->refresh = 1; + SDL_PushEvent(&event); + } + av_usleep(is->audio_st && is->show_audio ? rdftspeed * 1000 : 5000); // FIXME ideally we should wait the correct time but SDLs event passing is so slow it would be silly + } + return 0; +} + +/* get the current audio clock value */ +static double get_audio_clock(PlayerState *is) +{ + double pts; + int hw_buf_size, bytes_per_sec; + pts = is->audio_clock; + hw_buf_size = audio_write_get_buf_size(is); + bytes_per_sec = 0; + if (is->audio_st) { + bytes_per_sec = is->sdl_sample_rate * is->sdl_channels * + av_get_bytes_per_sample(is->sdl_sample_fmt); + } + if (bytes_per_sec) + pts -= (double)hw_buf_size / bytes_per_sec; + return pts; +} + +/* get the current video clock value */ +static double get_video_clock(PlayerState *is) +{ + if (is->paused) { + return is->video_current_pts; + } else { + return is->video_current_pts_drift + av_gettime_relative() / 1000000.0; + } +} + +/* get the current external clock value */ +static double get_external_clock(PlayerState *is) +{ + int64_t ti; + ti = av_gettime_relative(); + return is->external_clock + ((ti - is->external_clock_time) * 1e-6); +} + +/* get the current master clock value */ +static double get_master_clock(PlayerState *is) +{ + double val; + + if (is->av_sync_type == AV_SYNC_VIDEO_MASTER) { + if (is->video_st) + val = get_video_clock(is); + else + val = get_audio_clock(is); + } else if (is->av_sync_type == AV_SYNC_AUDIO_MASTER) { + if (is->audio_st) + val = get_audio_clock(is); + else + val = get_video_clock(is); + } else { + val = get_external_clock(is); + } + return val; +} + +/* seek in the stream */ +static void stream_seek(PlayerState *is, int64_t pos, int64_t rel, int seek_by_bytes) +{ + if (!is->seek_req) { + is->seek_pos = pos; + is->seek_rel = rel; + is->seek_flags &= ~AVSEEK_FLAG_BYTE; + if (seek_by_bytes) + is->seek_flags |= AVSEEK_FLAG_BYTE; + is->seek_req = 1; + } +} + +/* pause or resume the video */ +static void stream_pause(PlayerState *is) +{ + if (is->paused) { + is->frame_timer += av_gettime_relative() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts; + if (is->read_pause_return != AVERROR(ENOSYS)) { + is->video_current_pts = is->video_current_pts_drift + av_gettime_relative() / 1000000.0; + } + is->video_current_pts_drift = is->video_current_pts - av_gettime_relative() / 1000000.0; + } + is->paused = !is->paused; +} + +static double compute_target_time(double frame_current_pts, PlayerState *is) +{ + double delay, sync_threshold, diff = 0; + + /* compute nominal delay */ + delay = frame_current_pts - is->frame_last_pts; + if (delay <= 0 || delay >= 10.0) { + /* if incorrect delay, use previous one */ + delay = is->frame_last_delay; + } else { + is->frame_last_delay = delay; + } + is->frame_last_pts = frame_current_pts; + + /* update delay to follow master synchronisation source */ + if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || + is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { + /* if video is slave, we try to correct big delays by + duplicating or deleting a frame */ + diff = get_video_clock(is) - get_master_clock(is); + + /* skip or repeat frame. We take into account the + delay to compute the threshold. I still don't know + if it is the best guess */ + sync_threshold = FFMAX(AV_SYNC_THRESHOLD, delay); + if (fabs(diff) < AV_NOSYNC_THRESHOLD) { + if (diff <= -sync_threshold) + delay = 0; + else if (diff >= sync_threshold) + delay = 2 * delay; + } + } + is->frame_timer += delay; + + av_log(NULL, AV_LOG_TRACE, "video: delay=%0.3f pts=%0.3f A-V=%f\n", + delay, frame_current_pts, -diff); + + return is->frame_timer; +} + +/* called to display each frame */ +static void video_refresh_timer(void *opaque) +{ + PlayerState *is = opaque; + VideoPicture *vp; + + SubPicture *sp, *sp2; + + if (is->video_st) { +retry: + if (is->pictq_size == 0) { + // nothing to do, no picture to display in the que + } else { + double time = av_gettime_relative() / 1000000.0; + double next_target; + /* dequeue the picture */ + vp = &is->pictq[is->pictq_rindex]; + + if (time < vp->target_clock) + return; + /* update current video pts */ + is->video_current_pts = vp->pts; + is->video_current_pts_drift = is->video_current_pts - time; + is->video_current_pos = vp->pos; + if (is->pictq_size > 1) { + VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE]; + assert(nextvp->target_clock >= vp->target_clock); + next_target= nextvp->target_clock; + } else { + next_target = vp->target_clock + is->video_clock - vp->pts; // FIXME pass durations cleanly + } + if (framedrop && time > next_target) { + is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR; + if (is->pictq_size > 1 || time > next_target + 0.5) { + /* update queue size and signal for next picture */ + if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) + is->pictq_rindex = 0; + + SDL_LockMutex(is->pictq_mutex); + is->pictq_size--; + SDL_CondSignal(is->pictq_cond); + SDL_UnlockMutex(is->pictq_mutex); + goto retry; + } + } + + if (is->subtitle_st) { + if (is->subtitle_stream_changed) { + SDL_LockMutex(is->subpq_mutex); + + while (is->subpq_size) { + free_subpicture(&is->subpq[is->subpq_rindex]); + + /* update queue size and signal for next picture */ + if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) + is->subpq_rindex = 0; + + is->subpq_size--; + } + is->subtitle_stream_changed = 0; + + SDL_CondSignal(is->subpq_cond); + SDL_UnlockMutex(is->subpq_mutex); + } else { + if (is->subpq_size > 0) { + sp = &is->subpq[is->subpq_rindex]; + + if (is->subpq_size > 1) + sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE]; + else + sp2 = NULL; + + if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) + || (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) + { + free_subpicture(sp); + + /* update queue size and signal for next picture */ + if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) + is->subpq_rindex = 0; + + SDL_LockMutex(is->subpq_mutex); + is->subpq_size--; + SDL_CondSignal(is->subpq_cond); + SDL_UnlockMutex(is->subpq_mutex); + } + } + } + } + + /* display picture */ + if (!display_disable) + video_display(is); + + /* update queue size and signal for next picture */ + if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) + is->pictq_rindex = 0; + + SDL_LockMutex(is->pictq_mutex); + is->pictq_size--; + SDL_CondSignal(is->pictq_cond); + SDL_UnlockMutex(is->pictq_mutex); + } + } else if (is->audio_st) { + /* draw the next audio frame */ + + /* if only audio stream, then display the audio bars (better + than nothing, just to test the implementation */ + + /* display picture */ + if (!display_disable) + video_display(is); + } + if (show_status) { + static int64_t last_time; + int64_t cur_time; + int aqsize, vqsize, sqsize; + double av_diff; + + cur_time = av_gettime_relative(); + if (!last_time || (cur_time - last_time) >= 30000) { + aqsize = 0; + vqsize = 0; + sqsize = 0; + if (is->audio_st) + aqsize = is->audioq.size; + if (is->video_st) + vqsize = is->videoq.size; + if (is->subtitle_st) + sqsize = is->subtitleq.size; + av_diff = 0; + if (is->audio_st && is->video_st) + av_diff = get_audio_clock(is) - get_video_clock(is); + printf("%7.2f A-V:%7.3f s:%3.1f aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", + get_master_clock(is), av_diff, FFMAX(is->skip_frames - 1, 0), aqsize / 1024, + vqsize / 1024, sqsize, is->pts_ctx.num_faulty_dts, is->pts_ctx.num_faulty_pts); + fflush(stdout); + last_time = cur_time; + } + } +} + +static void player_close(PlayerState *is) +{ + VideoPicture *vp; + int i; + /* XXX: use a special url_shutdown call to abort parse cleanly */ + is->abort_request = 1; + SDL_WaitThread(is->parse_tid, NULL); + SDL_WaitThread(is->refresh_tid, NULL); + + /* free all pictures */ + for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) { + vp = &is->pictq[i]; + if (vp->bmp) { + SDL_FreeYUVOverlay(vp->bmp); + vp->bmp = NULL; + } + } + SDL_DestroyMutex(is->video_filter_mutex); + SDL_DestroyMutex(is->pictq_mutex); + SDL_DestroyCond(is->pictq_cond); + SDL_DestroyMutex(is->subpq_mutex); + SDL_DestroyCond(is->subpq_cond); +} + +static void do_exit(void) +{ + if (player) { + player_close(player); + player = NULL; + } + uninit_opts(); + avformat_network_deinit(); + if (show_status) + printf("\n"); + SDL_Quit(); + av_log(NULL, AV_LOG_QUIET, ""); + exit(0); +} + +/* allocate a picture (needs to do that in main thread to avoid + potential locking problems */ +static void alloc_picture(void *opaque) +{ + PlayerState *is = opaque; + VideoPicture *vp; + + vp = &is->pictq[is->pictq_windex]; + + if (vp->bmp) + SDL_FreeYUVOverlay(vp->bmp); + + vp->width = is->out_video_filter->inputs[0]->w; + vp->height = is->out_video_filter->inputs[0]->h; + vp->pix_fmt = is->out_video_filter->inputs[0]->format; + + vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, + SDL_YV12_OVERLAY, + screen); + if (!vp->bmp || vp->bmp->pitches[0] < vp->width) { + /* SDL allocates a buffer smaller than requested if the video + * overlay hardware is unable to support the requested size. */ + fprintf(stderr, "Error: the video system does not support an image\n" + "size of %dx%d pixels. Try using -vf \"scale=w:h\"\n" + "to reduce the image size.\n", vp->width, vp->height ); + do_exit(); + } + + SDL_LockMutex(is->pictq_mutex); + vp->allocated = 1; + SDL_CondSignal(is->pictq_cond); + SDL_UnlockMutex(is->pictq_mutex); +} + +/* The 'pts' parameter is the dts of the packet / pts of the frame and + * guessed if not known. */ +static int queue_picture(PlayerState *is, AVFrame *src_frame, double pts, int64_t pos) +{ + VideoPicture *vp; + + /* wait until we have space to put a new picture */ + SDL_LockMutex(is->pictq_mutex); + + if (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->refresh) + is->skip_frames = FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0 - FRAME_SKIP_FACTOR)); + + while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && + !is->videoq.abort_request) { + SDL_CondWait(is->pictq_cond, is->pictq_mutex); + } + SDL_UnlockMutex(is->pictq_mutex); + + if (is->videoq.abort_request) + return -1; + + vp = &is->pictq[is->pictq_windex]; + + vp->sar = src_frame->sample_aspect_ratio; + + /* alloc or resize hardware picture buffer */ + if (!vp->bmp || vp->reallocate || + vp->width != is->out_video_filter->inputs[0]->w || + vp->height != is->out_video_filter->inputs[0]->h) { + SDL_Event event; + + vp->allocated = 0; + vp->reallocate = 0; + + /* the allocation must be done in the main thread to avoid + locking problems */ + event.type = FF_ALLOC_EVENT; + event.user.data1 = is; + SDL_PushEvent(&event); + + /* wait until the picture is allocated */ + SDL_LockMutex(is->pictq_mutex); + while (!vp->allocated && !is->videoq.abort_request) { + SDL_CondWait(is->pictq_cond, is->pictq_mutex); + } + SDL_UnlockMutex(is->pictq_mutex); + + if (is->videoq.abort_request) + return -1; + } + + /* if the frame is not skipped, then display it */ + if (vp->bmp) { + uint8_t *data[4]; + int linesize[4]; + + /* get a pointer on the bitmap */ + SDL_LockYUVOverlay (vp->bmp); + + data[0] = vp->bmp->pixels[0]; + data[1] = vp->bmp->pixels[2]; + data[2] = vp->bmp->pixels[1]; + + linesize[0] = vp->bmp->pitches[0]; + linesize[1] = vp->bmp->pitches[2]; + linesize[2] = vp->bmp->pitches[1]; + + // FIXME use direct rendering + av_image_copy(data, linesize, src_frame->data, src_frame->linesize, + vp->pix_fmt, vp->width, vp->height); + + /* update the bitmap content */ + SDL_UnlockYUVOverlay(vp->bmp); + + vp->pts = pts; + vp->pos = pos; + + /* now we can update the picture count */ + if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE) + is->pictq_windex = 0; + SDL_LockMutex(is->pictq_mutex); + vp->target_clock = compute_target_time(vp->pts, is); + + is->pictq_size++; + SDL_UnlockMutex(is->pictq_mutex); + } + return 0; +} + +/* Compute the exact PTS for the picture if it is omitted in the stream. + * The 'pts1' parameter is the dts of the packet / pts of the frame. */ +static int output_picture2(PlayerState *is, AVFrame *src_frame, double pts1, int64_t pos) +{ + double frame_delay, pts; + int ret; + + pts = pts1; + + if (pts != 0) { + /* update video clock with pts, if present */ + is->video_clock = pts; + } else { + pts = is->video_clock; + } + /* update video clock for next frame */ + frame_delay = av_q2d(is->video_dec->time_base); + /* For MPEG-2, the frame can be repeated, so we update the + clock accordingly */ + frame_delay += src_frame->repeat_pict * (frame_delay * 0.5); + is->video_clock += frame_delay; + + ret = queue_picture(is, src_frame, pts, pos); + av_frame_unref(src_frame); + return ret; +} + +static int get_video_frame(PlayerState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt) +{ + int got_picture, i; + + if (packet_queue_get(&is->videoq, pkt, 1) < 0) + return -1; + + if (pkt->data == flush_pkt.data) { + avcodec_flush_buffers(is->video_dec); + + SDL_LockMutex(is->pictq_mutex); + // Make sure there are no long delay timers (ideally we should just flush the que but thats harder) + for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) { + is->pictq[i].target_clock= 0; + } + while (is->pictq_size && !is->videoq.abort_request) { + SDL_CondWait(is->pictq_cond, is->pictq_mutex); + } + is->video_current_pos = -1; + SDL_UnlockMutex(is->pictq_mutex); + + init_pts_correction(&is->pts_ctx); + is->frame_last_pts = AV_NOPTS_VALUE; + is->frame_last_delay = 0; + is->frame_timer = (double)av_gettime_relative() / 1000000.0; + is->skip_frames = 1; + is->skip_frames_index = 0; + return 0; + } + + avcodec_decode_video2(is->video_dec, frame, &got_picture, pkt); + + if (got_picture) { + if (decoder_reorder_pts == -1) { + *pts = guess_correct_pts(&is->pts_ctx, frame->pts, frame->pkt_dts); + } else if (decoder_reorder_pts) { + *pts = frame->pts; + } else { + *pts = frame->pkt_dts; + } + + if (*pts == AV_NOPTS_VALUE) { + *pts = 0; + } + if (is->video_st->sample_aspect_ratio.num) { + frame->sample_aspect_ratio = is->video_st->sample_aspect_ratio; + } + + is->skip_frames_index += 1; + if (is->skip_frames_index >= is->skip_frames) { + is->skip_frames_index -= FFMAX(is->skip_frames, 1.0); + return 1; + } + av_frame_unref(frame); + } + return 0; +} + +static int configure_video_filters(AVFilterGraph *graph, PlayerState *is, const char *vfilters) +{ + char sws_flags_str[128]; + char buffersrc_args[256]; + int ret; + AVFilterContext *filt_src = NULL, *filt_out = NULL, *last_filter; + AVCodecContext *codec = is->video_dec; + + snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%"PRId64, sws_flags); + graph->scale_sws_opts = av_strdup(sws_flags_str); + + snprintf(buffersrc_args, sizeof(buffersrc_args), + "width=%d:height=%d:pix_fmt=%d:time_base=%d/%d:sar=%d/%d", + codec->width, codec->height, codec->pix_fmt, + is->video_st->time_base.num, is->video_st->time_base.den, + codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den); + + + if ((ret = avfilter_graph_create_filter(&filt_src, + avfilter_get_by_name("buffer"), + "src", buffersrc_args, NULL, + graph)) < 0) + return ret; + if ((ret = avfilter_graph_create_filter(&filt_out, + avfilter_get_by_name("buffersink"), + "out", NULL, NULL, graph)) < 0) + return ret; + + last_filter = filt_out; + +/* Note: this macro adds a filter before the lastly added filter, so the + * processing order of the filters is in reverse */ +#define INSERT_FILT(name, arg) do { \ + AVFilterContext *filt_ctx; \ + \ + ret = avfilter_graph_create_filter(&filt_ctx, \ + avfilter_get_by_name(name), \ + "avplay_" name, arg, NULL, graph); \ + if (ret < 0) \ + return ret; \ + \ + ret = avfilter_link(filt_ctx, 0, last_filter, 0); \ + if (ret < 0) \ + return ret; \ + \ + last_filter = filt_ctx; \ +} while (0) + + INSERT_FILT("format", "yuv420p"); + + if (autorotate) { + uint8_t* displaymatrix = av_stream_get_side_data(is->video_st, + AV_PKT_DATA_DISPLAYMATRIX, NULL); + if (displaymatrix) { + double rot = av_display_rotation_get((int32_t*) displaymatrix); + if (rot < -135 || rot > 135) { + INSERT_FILT("vflip", NULL); + INSERT_FILT("hflip", NULL); + } else if (rot < -45) { + INSERT_FILT("transpose", "dir=clock"); + } else if (rot > 45) { + INSERT_FILT("transpose", "dir=cclock"); + } + } + } + + if (vfilters) { + AVFilterInOut *outputs = avfilter_inout_alloc(); + AVFilterInOut *inputs = avfilter_inout_alloc(); + + outputs->name = av_strdup("in"); + outputs->filter_ctx = filt_src; + outputs->pad_idx = 0; + outputs->next = NULL; + + inputs->name = av_strdup("out"); + inputs->filter_ctx = last_filter; + inputs->pad_idx = 0; + inputs->next = NULL; + + if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0) + return ret; + } else { + if ((ret = avfilter_link(filt_src, 0, last_filter, 0)) < 0) + return ret; + } + + if ((ret = avfilter_graph_config(graph, NULL)) < 0) + return ret; + + is->in_video_filter = filt_src; + is->out_video_filter = filt_out; + + return ret; +} + +static int video_thread(void *arg) +{ + AVPacket pkt = { 0 }; + PlayerState *is = arg; + AVFrame *frame = av_frame_alloc(); + int64_t pts_int; + double pts; + int ret; + + AVFilterGraph *graph = avfilter_graph_alloc(); + AVFilterContext *filt_out = NULL, *filt_in = NULL; + int last_w = is->video_dec->width; + int last_h = is->video_dec->height; + if (!graph) { + av_frame_free(&frame); + return AVERROR(ENOMEM); + } + + if ((ret = configure_video_filters(graph, is, vfilters)) < 0) + goto the_end; + filt_in = is->in_video_filter; + filt_out = is->out_video_filter; + + if (!frame) { + avfilter_graph_free(&graph); + return AVERROR(ENOMEM); + } + + for (;;) { + AVRational tb; + while (is->paused && !is->videoq.abort_request) + SDL_Delay(10); + + av_packet_unref(&pkt); + + ret = get_video_frame(is, frame, &pts_int, &pkt); + if (ret < 0) + goto the_end; + + if (!ret) + continue; + + if ( last_w != is->video_dec->width + || last_h != is->video_dec->height) { + av_log(NULL, AV_LOG_TRACE, "Changing size %dx%d -> %dx%d\n", last_w, last_h, + is->video_dec->width, is->video_dec->height); + avfilter_graph_free(&graph); + graph = avfilter_graph_alloc(); + if ((ret = configure_video_filters(graph, is, vfilters)) < 0) + goto the_end; + filt_in = is->in_video_filter; + filt_out = is->out_video_filter; + last_w = is->video_dec->width; + last_h = is->video_dec->height; + } + + frame->pts = pts_int; + ret = av_buffersrc_add_frame(filt_in, frame); + if (ret < 0) + goto the_end; + + while (ret >= 0) { + ret = av_buffersink_get_frame(filt_out, frame); + if (ret < 0) { + ret = 0; + break; + } + + pts_int = frame->pts; + tb = filt_out->inputs[0]->time_base; + if (av_cmp_q(tb, is->video_st->time_base)) { + av_unused int64_t pts1 = pts_int; + pts_int = av_rescale_q(pts_int, tb, is->video_st->time_base); + av_log(NULL, AV_LOG_TRACE, "video_thread(): " + "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n", + tb.num, tb.den, pts1, + is->video_st->time_base.num, is->video_st->time_base.den, pts_int); + } + pts = pts_int * av_q2d(is->video_st->time_base); + ret = output_picture2(is, frame, pts, 0); + } + + if (ret < 0) + goto the_end; + + + if (step) + if (player) + stream_pause(player); + } + the_end: + SDL_LockMutex(is->video_filter_mutex); + is->out_video_filter = NULL; + SDL_UnlockMutex(is->video_filter_mutex); + av_freep(&vfilters); + avfilter_graph_free(&graph); + av_packet_unref(&pkt); + av_frame_free(&frame); + return 0; +} + +static int subtitle_thread(void *arg) +{ + PlayerState *is = arg; + SubPicture *sp; + AVPacket pkt1, *pkt = &pkt1; + int got_subtitle; + double pts; + int i, j; + int r, g, b, y, u, v, a; + + for (;;) { + while (is->paused && !is->subtitleq.abort_request) { + SDL_Delay(10); + } + if (packet_queue_get(&is->subtitleq, pkt, 1) < 0) + break; + + if (pkt->data == flush_pkt.data) { + avcodec_flush_buffers(is->subtitle_dec); + continue; + } + SDL_LockMutex(is->subpq_mutex); + while (is->subpq_size >= SUBPICTURE_QUEUE_SIZE && + !is->subtitleq.abort_request) { + SDL_CondWait(is->subpq_cond, is->subpq_mutex); + } + SDL_UnlockMutex(is->subpq_mutex); + + if (is->subtitleq.abort_request) + return 0; + + sp = &is->subpq[is->subpq_windex]; + + /* NOTE: ipts is the PTS of the _first_ picture beginning in + this packet, if any */ + pts = 0; + if (pkt->pts != AV_NOPTS_VALUE) + pts = av_q2d(is->subtitle_dec->time_base) * pkt->pts; + + avcodec_decode_subtitle2(is->subtitle_dec, &sp->sub, + &got_subtitle, pkt); + + if (got_subtitle && sp->sub.format == 0) { + sp->pts = pts; + + for (i = 0; i < sp->sub.num_rects; i++) + { + for (j = 0; j < sp->sub.rects[i]->nb_colors; j++) + { + RGBA_IN(r, g, b, a, (uint32_t *)sp->sub.rects[i]->data[1] + j); + y = RGB_TO_Y_CCIR(r, g, b); + u = RGB_TO_U_CCIR(r, g, b, 0); + v = RGB_TO_V_CCIR(r, g, b, 0); + YUVA_OUT((uint32_t *)sp->sub.rects[i]->data[1] + j, y, u, v, a); + } + } + + /* now we can update the picture count */ + if (++is->subpq_windex == SUBPICTURE_QUEUE_SIZE) + is->subpq_windex = 0; + SDL_LockMutex(is->subpq_mutex); + is->subpq_size++; + SDL_UnlockMutex(is->subpq_mutex); + } + av_packet_unref(pkt); + } + return 0; +} + +/* copy samples for viewing in editor window */ +static void update_sample_display(PlayerState *is, short *samples, int samples_size) +{ + int size, len; + + size = samples_size / sizeof(short); + while (size > 0) { + len = SAMPLE_ARRAY_SIZE - is->sample_array_index; + if (len > size) + len = size; + memcpy(is->sample_array + is->sample_array_index, samples, len * sizeof(short)); + samples += len; + is->sample_array_index += len; + if (is->sample_array_index >= SAMPLE_ARRAY_SIZE) + is->sample_array_index = 0; + size -= len; + } +} + +/* return the new audio buffer size (samples can be added or deleted + to get better sync if video or external master clock) */ +static int synchronize_audio(PlayerState *is, short *samples, + int samples_size1, double pts) +{ + int n, samples_size; + double ref_clock; + + n = is->sdl_channels * av_get_bytes_per_sample(is->sdl_sample_fmt); + samples_size = samples_size1; + + /* if not master, then we try to remove or add samples to correct the clock */ + if (((is->av_sync_type == AV_SYNC_VIDEO_MASTER && is->video_st) || + is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { + double diff, avg_diff; + int wanted_size, min_size, max_size, nb_samples; + + ref_clock = get_master_clock(is); + diff = get_audio_clock(is) - ref_clock; + + if (diff < AV_NOSYNC_THRESHOLD) { + is->audio_diff_cum = diff + is->audio_diff_avg_coef * is->audio_diff_cum; + if (is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB) { + /* not enough measures to have a correct estimate */ + is->audio_diff_avg_count++; + } else { + /* estimate the A-V difference */ + avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef); + + if (fabs(avg_diff) >= is->audio_diff_threshold) { + wanted_size = samples_size + ((int)(diff * is->sdl_sample_rate) * n); + nb_samples = samples_size / n; + + min_size = ((nb_samples * (100 - SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n; + max_size = ((nb_samples * (100 + SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n; + if (wanted_size < min_size) + wanted_size = min_size; + else if (wanted_size > max_size) + wanted_size = max_size; + + /* add or remove samples to correction the synchro */ + if (wanted_size < samples_size) { + /* remove samples */ + samples_size = wanted_size; + } else if (wanted_size > samples_size) { + uint8_t *samples_end, *q; + int nb; + + /* add samples */ + nb = (samples_size - wanted_size); + samples_end = (uint8_t *)samples + samples_size - n; + q = samples_end + n; + while (nb > 0) { + memcpy(q, samples_end, n); + q += n; + nb -= n; + } + samples_size = wanted_size; + } + } + av_log(NULL, AV_LOG_TRACE, "diff=%f adiff=%f sample_diff=%d apts=%0.3f vpts=%0.3f %f\n", + diff, avg_diff, samples_size - samples_size1, + is->audio_clock, is->video_clock, is->audio_diff_threshold); + } + } else { + /* too big difference : may be initial PTS errors, so + reset A-V filter */ + is->audio_diff_avg_count = 0; + is->audio_diff_cum = 0; + } + } + + return samples_size; +} + +/* decode one audio frame and returns its uncompressed size */ +static int audio_decode_frame(PlayerState *is, double *pts_ptr) +{ + AVPacket *pkt_temp = &is->audio_pkt_temp; + AVPacket *pkt = &is->audio_pkt; + AVCodecContext *dec = is->audio_dec; + int n, len1, data_size, got_frame; + double pts; + int new_packet = 0; + int flush_complete = 0; + + for (;;) { + /* NOTE: the audio packet can contain several frames */ + while (pkt_temp->size > 0 || (!pkt_temp->data && new_packet)) { + int resample_changed, audio_resample; + + if (!is->frame) { + if (!(is->frame = av_frame_alloc())) + return AVERROR(ENOMEM); + } + + if (flush_complete) + break; + new_packet = 0; + len1 = avcodec_decode_audio4(dec, is->frame, &got_frame, pkt_temp); + if (len1 < 0) { + /* if error, we skip the frame */ + pkt_temp->size = 0; + break; + } + + pkt_temp->data += len1; + pkt_temp->size -= len1; + + if (!got_frame) { + /* stop sending empty packets if the decoder is finished */ + if (!pkt_temp->data && (dec->codec->capabilities & AV_CODEC_CAP_DELAY)) + flush_complete = 1; + continue; + } + data_size = av_samples_get_buffer_size(NULL, dec->channels, + is->frame->nb_samples, + is->frame->format, 1); + + audio_resample = is->frame->format != is->sdl_sample_fmt || + is->frame->channel_layout != is->sdl_channel_layout || + is->frame->sample_rate != is->sdl_sample_rate; + + resample_changed = is->frame->format != is->resample_sample_fmt || + is->frame->channel_layout != is->resample_channel_layout || + is->frame->sample_rate != is->resample_sample_rate; + + if ((!is->avr && audio_resample) || resample_changed) { + int ret; + if (is->avr) + avresample_close(is->avr); + else if (audio_resample) { + is->avr = avresample_alloc_context(); + if (!is->avr) { + fprintf(stderr, "error allocating AVAudioResampleContext\n"); + break; + } + } + if (audio_resample) { + av_opt_set_int(is->avr, "in_channel_layout", is->frame->channel_layout, 0); + av_opt_set_int(is->avr, "in_sample_fmt", is->frame->format, 0); + av_opt_set_int(is->avr, "in_sample_rate", is->frame->sample_rate, 0); + av_opt_set_int(is->avr, "out_channel_layout", is->sdl_channel_layout, 0); + av_opt_set_int(is->avr, "out_sample_fmt", is->sdl_sample_fmt, 0); + av_opt_set_int(is->avr, "out_sample_rate", is->sdl_sample_rate, 0); + + if ((ret = avresample_open(is->avr)) < 0) { + fprintf(stderr, "error initializing libavresample\n"); + break; + } + } + is->resample_sample_fmt = is->frame->format; + is->resample_channel_layout = is->frame->channel_layout; + is->resample_sample_rate = is->frame->sample_rate; + } + + if (audio_resample) { + void *tmp_out; + int out_samples, out_size, out_linesize; + int osize = av_get_bytes_per_sample(is->sdl_sample_fmt); + int nb_samples = is->frame->nb_samples; + + out_size = av_samples_get_buffer_size(&out_linesize, + is->sdl_channels, + nb_samples, + is->sdl_sample_fmt, 0); + tmp_out = av_realloc(is->audio_buf1, out_size); + if (!tmp_out) + return AVERROR(ENOMEM); + is->audio_buf1 = tmp_out; + + out_samples = avresample_convert(is->avr, + &is->audio_buf1, + out_linesize, nb_samples, + is->frame->data, + is->frame->linesize[0], + is->frame->nb_samples); + if (out_samples < 0) { + fprintf(stderr, "avresample_convert() failed\n"); + break; + } + is->audio_buf = is->audio_buf1; + data_size = out_samples * osize * is->sdl_channels; + } else { + is->audio_buf = is->frame->data[0]; + } + + /* if no pts, then compute it */ + pts = is->audio_clock; + *pts_ptr = pts; + n = is->sdl_channels * av_get_bytes_per_sample(is->sdl_sample_fmt); + is->audio_clock += (double)data_size / + (double)(n * is->sdl_sample_rate); +#ifdef DEBUG + { + static double last_clock; + printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", + is->audio_clock - last_clock, + is->audio_clock, pts); + last_clock = is->audio_clock; + } +#endif + return data_size; + } + + /* free the current packet */ + if (pkt->data) + av_packet_unref(pkt); + memset(pkt_temp, 0, sizeof(*pkt_temp)); + + if (is->paused || is->audioq.abort_request) { + return -1; + } + + /* read next packet */ + if ((new_packet = packet_queue_get(&is->audioq, pkt, 1)) < 0) + return -1; + + if (pkt->data == flush_pkt.data) { + avcodec_flush_buffers(dec); + flush_complete = 0; + } + + *pkt_temp = *pkt; + + /* if update the audio clock with the pts */ + if (pkt->pts != AV_NOPTS_VALUE) { + is->audio_clock = av_q2d(is->audio_st->time_base)*pkt->pts; + } + } +} + +/* prepare a new audio buffer */ +static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) +{ + PlayerState *is = opaque; + int audio_size, len1; + double pts; + + audio_callback_time = av_gettime_relative(); + + while (len > 0) { + if (is->audio_buf_index >= is->audio_buf_size) { + audio_size = audio_decode_frame(is, &pts); + if (audio_size < 0) { + /* if error, just output silence */ + is->audio_buf = is->silence_buf; + is->audio_buf_size = sizeof(is->silence_buf); + } else { + if (is->show_audio) + update_sample_display(is, (int16_t *)is->audio_buf, audio_size); + audio_size = synchronize_audio(is, (int16_t *)is->audio_buf, audio_size, + pts); + is->audio_buf_size = audio_size; + } + is->audio_buf_index = 0; + } + len1 = is->audio_buf_size - is->audio_buf_index; + if (len1 > len) + len1 = len; + memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1); + len -= len1; + stream += len1; + is->audio_buf_index += len1; + } +} + +static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type) +{ + const AVCodecDescriptor *desc; + AVCodec *codec = avcodec_find_decoder_by_name(name); + + if (!codec && (desc = avcodec_descriptor_get_by_name(name))) { + codec = avcodec_find_decoder(desc->id); + if (codec) + av_log(NULL, AV_LOG_VERBOSE, "Matched decoder '%s' for codec '%s'.\n", + codec->name, desc->name); + } + + if (!codec) { + av_log(NULL, AV_LOG_FATAL, "Unknown decoder '%s'\n", name); + exit_program(1); + } + + if (codec->type != type) { + av_log(NULL, AV_LOG_FATAL, "Invalid decoder type '%s'\n", name); + exit_program(1); + } + + return codec; +} + +static AVCodec *choose_decoder(PlayerState *is, AVFormatContext *ic, AVStream *st) +{ + char *codec_name = NULL; + int i, ret; + + for (i = 0; i < is->nb_codec_names; i++) { + char *spec = is->codec_names[i].specifier; + if ((ret = check_stream_specifier(ic, st, spec)) > 0) + codec_name = is->codec_names[i].u.str; + else if (ret < 0) + exit_program(1); + } + + if (codec_name) { + AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type); + st->codecpar->codec_id = codec->id; + return codec; + } else + return avcodec_find_decoder(st->codecpar->codec_id); +} + +/* open a given stream. Return 0 if OK */ +static int stream_component_open(PlayerState *is, int stream_index) +{ + AVFormatContext *ic = is->ic; + AVCodecContext *avctx; + AVCodec *codec; + SDL_AudioSpec wanted_spec, spec; + AVDictionary *opts; + AVDictionaryEntry *t = NULL; + int ret = 0; + + if (stream_index < 0 || stream_index >= ic->nb_streams) + return -1; + + avctx = avcodec_alloc_context3(NULL); + if (!avctx) + return AVERROR(ENOMEM); + + ret = avcodec_parameters_to_context(avctx, ic->streams[stream_index]->codecpar); + if (ret < 0) { + avcodec_free_context(&avctx); + return ret; + } + + opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index], NULL); + + codec = choose_decoder(is, ic, ic->streams[stream_index]); + avctx->workaround_bugs = workaround_bugs; + avctx->idct_algo = idct; + avctx->skip_frame = skip_frame; + avctx->skip_idct = skip_idct; + avctx->skip_loop_filter = skip_loop_filter; + avctx->error_concealment = error_concealment; + + if (fast) + avctx->flags2 |= AV_CODEC_FLAG2_FAST; + + if (!av_dict_get(opts, "threads", NULL, 0)) + av_dict_set(&opts, "threads", "auto", 0); + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) + av_dict_set(&opts, "refcounted_frames", "1", 0); + if (!codec || + (ret = avcodec_open2(avctx, codec, &opts)) < 0) { + goto fail; + } + if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + ret = AVERROR_OPTION_NOT_FOUND; + goto fail; + } + + /* prepare audio output */ + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { + is->sdl_sample_rate = avctx->sample_rate; + + if (!avctx->channel_layout) + avctx->channel_layout = av_get_default_channel_layout(avctx->channels); + if (!avctx->channel_layout) { + fprintf(stderr, "unable to guess channel layout\n"); + ret = AVERROR_INVALIDDATA; + goto fail; + } + if (avctx->channels == 1) + is->sdl_channel_layout = AV_CH_LAYOUT_MONO; + else + is->sdl_channel_layout = AV_CH_LAYOUT_STEREO; + is->sdl_channels = av_get_channel_layout_nb_channels(is->sdl_channel_layout); + + wanted_spec.format = AUDIO_S16SYS; + wanted_spec.freq = is->sdl_sample_rate; + wanted_spec.channels = is->sdl_channels; + wanted_spec.silence = 0; + wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE; + wanted_spec.callback = sdl_audio_callback; + wanted_spec.userdata = is; + if (SDL_OpenAudio(&wanted_spec, &spec) < 0) { + fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError()); + ret = AVERROR_UNKNOWN; + goto fail; + } + is->audio_hw_buf_size = spec.size; + is->sdl_sample_fmt = AV_SAMPLE_FMT_S16; + is->resample_sample_fmt = is->sdl_sample_fmt; + is->resample_channel_layout = avctx->channel_layout; + is->resample_sample_rate = avctx->sample_rate; + } + + ic->streams[stream_index]->discard = AVDISCARD_DEFAULT; + switch (avctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + is->audio_stream = stream_index; + is->audio_st = ic->streams[stream_index]; + is->audio_dec = avctx; + is->audio_buf_size = 0; + is->audio_buf_index = 0; + + /* init averaging filter */ + is->audio_diff_avg_coef = exp(log(0.01) / AUDIO_DIFF_AVG_NB); + is->audio_diff_avg_count = 0; + /* since we do not have a precise enough audio FIFO fullness, + we correct audio sync only if larger than this threshold */ + is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / avctx->sample_rate; + + memset(&is->audio_pkt, 0, sizeof(is->audio_pkt)); + packet_queue_init(&is->audioq); + SDL_PauseAudio(0); + break; + case AVMEDIA_TYPE_VIDEO: + is->video_stream = stream_index; + is->video_st = ic->streams[stream_index]; + is->video_dec = avctx; + + packet_queue_init(&is->videoq); + is->video_tid = SDL_CreateThread(video_thread, is); + break; + case AVMEDIA_TYPE_SUBTITLE: + is->subtitle_stream = stream_index; + is->subtitle_st = ic->streams[stream_index]; + is->subtitle_dec = avctx; + packet_queue_init(&is->subtitleq); + + is->subtitle_tid = SDL_CreateThread(subtitle_thread, is); + break; + default: + break; + } + +fail: + av_dict_free(&opts); + + return ret; +} + +static void stream_component_close(PlayerState *is, int stream_index) +{ + AVFormatContext *ic = is->ic; + AVCodecParameters *par; + + if (stream_index < 0 || stream_index >= ic->nb_streams) + return; + par = ic->streams[stream_index]->codecpar; + + switch (par->codec_type) { + case AVMEDIA_TYPE_AUDIO: + packet_queue_abort(&is->audioq); + + SDL_CloseAudio(); + + packet_queue_end(&is->audioq); + av_packet_unref(&is->audio_pkt); + if (is->avr) + avresample_free(&is->avr); + av_freep(&is->audio_buf1); + is->audio_buf = NULL; + av_frame_free(&is->frame); + + if (is->rdft) { + av_rdft_end(is->rdft); + av_freep(&is->rdft_data); + is->rdft = NULL; + is->rdft_bits = 0; + } + break; + case AVMEDIA_TYPE_VIDEO: + packet_queue_abort(&is->videoq); + + /* note: we also signal this mutex to make sure we deblock the + video thread in all cases */ + SDL_LockMutex(is->pictq_mutex); + SDL_CondSignal(is->pictq_cond); + SDL_UnlockMutex(is->pictq_mutex); + + SDL_WaitThread(is->video_tid, NULL); + + packet_queue_end(&is->videoq); + break; + case AVMEDIA_TYPE_SUBTITLE: + packet_queue_abort(&is->subtitleq); + + /* note: we also signal this mutex to make sure we deblock the + video thread in all cases */ + SDL_LockMutex(is->subpq_mutex); + is->subtitle_stream_changed = 1; + + SDL_CondSignal(is->subpq_cond); + SDL_UnlockMutex(is->subpq_mutex); + + SDL_WaitThread(is->subtitle_tid, NULL); + + packet_queue_end(&is->subtitleq); + break; + default: + break; + } + + ic->streams[stream_index]->discard = AVDISCARD_ALL; + switch (par->codec_type) { + case AVMEDIA_TYPE_AUDIO: + avcodec_free_context(&is->audio_dec); + is->audio_st = NULL; + is->audio_stream = -1; + break; + case AVMEDIA_TYPE_VIDEO: + avcodec_free_context(&is->video_dec); + is->video_st = NULL; + is->video_stream = -1; + break; + case AVMEDIA_TYPE_SUBTITLE: + avcodec_free_context(&is->subtitle_dec); + is->subtitle_st = NULL; + is->subtitle_stream = -1; + break; + default: + break; + } +} + +/* since we have only one decoding thread, we can use a global + variable instead of a thread local variable */ +static PlayerState *global_video_state; + +static int decode_interrupt_cb(void *ctx) +{ + return global_video_state && global_video_state->abort_request; +} + +static void stream_close(PlayerState *is) +{ + /* disable interrupting */ + global_video_state = NULL; + + /* close each stream */ + if (is->audio_stream >= 0) + stream_component_close(is, is->audio_stream); + if (is->video_stream >= 0) + stream_component_close(is, is->video_stream); + if (is->subtitle_stream >= 0) + stream_component_close(is, is->subtitle_stream); + if (is->ic) { + avformat_close_input(&is->ic); + } +} + +static int stream_setup(PlayerState *is) +{ + AVFormatContext *ic = NULL; + int err, i, ret; + int st_index[AVMEDIA_TYPE_NB]; + AVDictionaryEntry *t; + AVDictionary **opts; + int orig_nb_streams; + + memset(st_index, -1, sizeof(st_index)); + is->video_stream = -1; + is->audio_stream = -1; + is->subtitle_stream = -1; + + global_video_state = is; + + ic = avformat_alloc_context(); + if (!ic) { + av_log(NULL, AV_LOG_FATAL, "Could not allocate context.\n"); + ret = AVERROR(ENOMEM); + goto fail; + } + ic->interrupt_callback.callback = decode_interrupt_cb; + err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts); + if (err < 0) { + print_error(is->filename, err); + ret = -1; + goto fail; + } + + if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + ret = AVERROR_OPTION_NOT_FOUND; + goto fail; + } + is->ic = ic; + + if (genpts) + ic->flags |= AVFMT_FLAG_GENPTS; + + opts = setup_find_stream_info_opts(ic, codec_opts); + orig_nb_streams = ic->nb_streams; + + for (i = 0; i < ic->nb_streams; i++) + choose_decoder(is, ic, ic->streams[i]); + + err = avformat_find_stream_info(ic, opts); + + for (i = 0; i < orig_nb_streams; i++) + av_dict_free(&opts[i]); + av_freep(&opts); + + if (err < 0) { + fprintf(stderr, "%s: could not find codec parameters\n", is->filename); + ret = -1; + goto fail; + } + + if (ic->pb) + ic->pb->eof_reached = 0; // FIXME hack, avplay maybe should not use url_feof() to test for the end + + if (seek_by_bytes < 0) + seek_by_bytes = !!(ic->iformat->flags & AVFMT_TS_DISCONT); + + /* if seeking requested, we execute it */ + if (start_time != AV_NOPTS_VALUE) { + int64_t timestamp; + + timestamp = start_time; + /* add the stream start time */ + if (ic->start_time != AV_NOPTS_VALUE) + timestamp += ic->start_time; + ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, INT64_MAX, 0); + if (ret < 0) { + fprintf(stderr, "%s: could not seek to position %0.3f\n", + is->filename, (double)timestamp / AV_TIME_BASE); + } + } + + for (i = 0; i < ic->nb_streams; i++) + ic->streams[i]->discard = AVDISCARD_ALL; + if (!video_disable) + st_index[AVMEDIA_TYPE_VIDEO] = + av_find_best_stream(ic, AVMEDIA_TYPE_VIDEO, + wanted_stream[AVMEDIA_TYPE_VIDEO], -1, NULL, 0); + if (!audio_disable) + st_index[AVMEDIA_TYPE_AUDIO] = + av_find_best_stream(ic, AVMEDIA_TYPE_AUDIO, + wanted_stream[AVMEDIA_TYPE_AUDIO], + st_index[AVMEDIA_TYPE_VIDEO], + NULL, 0); + if (!video_disable) + st_index[AVMEDIA_TYPE_SUBTITLE] = + av_find_best_stream(ic, AVMEDIA_TYPE_SUBTITLE, + wanted_stream[AVMEDIA_TYPE_SUBTITLE], + (st_index[AVMEDIA_TYPE_AUDIO] >= 0 ? + st_index[AVMEDIA_TYPE_AUDIO] : + st_index[AVMEDIA_TYPE_VIDEO]), + NULL, 0); + if (show_status) { + av_dump_format(ic, 0, is->filename, 0); + } + + /* open the streams */ + if (st_index[AVMEDIA_TYPE_AUDIO] >= 0) { + stream_component_open(is, st_index[AVMEDIA_TYPE_AUDIO]); + } + + ret = -1; + if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) { + ret = stream_component_open(is, st_index[AVMEDIA_TYPE_VIDEO]); + } + if (ret < 0) { + if (!display_disable) + is->show_audio = 2; + } + + if (st_index[AVMEDIA_TYPE_SUBTITLE] >= 0) { + stream_component_open(is, st_index[AVMEDIA_TYPE_SUBTITLE]); + } + + if (is->video_stream < 0 && is->audio_stream < 0) { + fprintf(stderr, "%s: could not open codecs\n", is->filename); + ret = -1; + goto fail; + } + + return 0; + +fail: + return ret; +} + +/* this thread gets the stream from the disk or the network */ +static int decode_thread(void *arg) +{ + PlayerState *is = arg; + AVPacket pkt1, *pkt = &pkt1; + AVFormatContext *ic = is->ic; + int pkt_in_play_range = 0; + int ret, eof = 0; + + for (;;) { + if (is->abort_request) + break; + if (is->paused != is->last_paused) { + is->last_paused = is->paused; + if (is->paused) + is->read_pause_return = av_read_pause(ic); + else + av_read_play(ic); + } +#if CONFIG_RTSP_DEMUXER + if (is->paused && !strcmp(ic->iformat->name, "rtsp")) { + /* wait 10 ms to avoid trying to get another packet */ + /* XXX: horrible */ + SDL_Delay(10); + continue; + } +#endif + if (is->seek_req) { + int64_t seek_target = is->seek_pos; + int64_t seek_min = is->seek_rel > 0 ? seek_target - is->seek_rel + 2: INT64_MIN; + int64_t seek_max = is->seek_rel < 0 ? seek_target - is->seek_rel - 2: INT64_MAX; +// FIXME the +-2 is due to rounding being not done in the correct direction in generation +// of the seek_pos/seek_rel variables + + ret = avformat_seek_file(is->ic, -1, seek_min, seek_target, seek_max, is->seek_flags); + if (ret < 0) { + fprintf(stderr, "%s: error while seeking\n", is->ic->filename); + } else { + if (is->audio_stream >= 0) { + packet_queue_flush(&is->audioq); + packet_queue_put(&is->audioq, &flush_pkt); + } + if (is->subtitle_stream >= 0) { + packet_queue_flush(&is->subtitleq); + packet_queue_put(&is->subtitleq, &flush_pkt); + } + if (is->video_stream >= 0) { + packet_queue_flush(&is->videoq); + packet_queue_put(&is->videoq, &flush_pkt); + } + } + is->seek_req = 0; + eof = 0; + } + + /* if the queue are full, no need to read more */ + if (!infinite_buffer && + (is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE + || ( (is->audioq .size > MIN_AUDIOQ_SIZE || is->audio_stream < 0) + && (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0) + && (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0)))) { + /* wait 10 ms */ + SDL_Delay(10); + continue; + } + if (eof) { + if (is->video_stream >= 0) { + av_init_packet(pkt); + pkt->data = NULL; + pkt->size = 0; + pkt->stream_index = is->video_stream; + packet_queue_put(&is->videoq, pkt); + } + if (is->audio_stream >= 0 && + (is->audio_dec->codec->capabilities & AV_CODEC_CAP_DELAY)) { + av_init_packet(pkt); + pkt->data = NULL; + pkt->size = 0; + pkt->stream_index = is->audio_stream; + packet_queue_put(&is->audioq, pkt); + } + SDL_Delay(10); + if (is->audioq.size + is->videoq.size + is->subtitleq.size == 0) { + if (loop != 1 && (!loop || --loop)) { + stream_seek(player, start_time != AV_NOPTS_VALUE ? start_time : 0, 0, 0); + } else if (!noautoexit) { + ret = AVERROR_EOF; + goto fail; + } + } + continue; + } + ret = av_read_frame(ic, pkt); + if (ret < 0) { + if (ret == AVERROR_EOF || (ic->pb && ic->pb->eof_reached)) + eof = 1; + if (ic->pb && ic->pb->error) + break; + SDL_Delay(100); /* wait for user event */ + continue; + } + /* check if packet is in play range specified by user, then queue, otherwise discard */ + pkt_in_play_range = duration == AV_NOPTS_VALUE || + (pkt->pts - ic->streams[pkt->stream_index]->start_time) * + av_q2d(ic->streams[pkt->stream_index]->time_base) - + (double)(start_time != AV_NOPTS_VALUE ? start_time : 0) / 1000000 + <= ((double)duration / 1000000); + if (pkt->stream_index == is->audio_stream && pkt_in_play_range) { + packet_queue_put(&is->audioq, pkt); + } else if (pkt->stream_index == is->video_stream && pkt_in_play_range) { + packet_queue_put(&is->videoq, pkt); + } else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) { + packet_queue_put(&is->subtitleq, pkt); + } else { + av_packet_unref(pkt); + } + } + /* wait until the end */ + while (!is->abort_request) { + SDL_Delay(100); + } + + ret = 0; + +fail: + stream_close(is); + + if (ret != 0) { + SDL_Event event; + + event.type = FF_QUIT_EVENT; + event.user.data1 = is; + SDL_PushEvent(&event); + } + return 0; +} + +static int stream_open(PlayerState *is, + const char *filename, AVInputFormat *iformat) +{ + int ret; + + av_strlcpy(is->filename, filename, sizeof(is->filename)); + is->iformat = iformat; + is->ytop = 0; + is->xleft = 0; + + if ((ret = stream_setup(is)) < 0) { + return ret; + } + + is->video_filter_mutex = SDL_CreateMutex(); + + /* start video display */ + is->pictq_mutex = SDL_CreateMutex(); + is->pictq_cond = SDL_CreateCond(); + + is->subpq_mutex = SDL_CreateMutex(); + is->subpq_cond = SDL_CreateCond(); + + is->av_sync_type = av_sync_type; + is->refresh_tid = SDL_CreateThread(refresh_thread, is); + if (!is->refresh_tid) + return -1; + is->parse_tid = SDL_CreateThread(decode_thread, is); + if (!is->parse_tid) + return -1; + return 0; +} + +static void stream_cycle_channel(PlayerState *is, int codec_type) +{ + AVFormatContext *ic = is->ic; + int start_index, stream_index; + AVStream *st; + + if (codec_type == AVMEDIA_TYPE_VIDEO) + start_index = is->video_stream; + else if (codec_type == AVMEDIA_TYPE_AUDIO) + start_index = is->audio_stream; + else + start_index = is->subtitle_stream; + if (start_index < (codec_type == AVMEDIA_TYPE_SUBTITLE ? -1 : 0)) + return; + stream_index = start_index; + for (;;) { + if (++stream_index >= is->ic->nb_streams) + { + if (codec_type == AVMEDIA_TYPE_SUBTITLE) + { + stream_index = -1; + goto the_end; + } else + stream_index = 0; + } + if (stream_index == start_index) + return; + st = ic->streams[stream_index]; + if (st->codecpar->codec_type == codec_type) { + /* check that parameters are OK */ + switch (codec_type) { + case AVMEDIA_TYPE_AUDIO: + if (st->codecpar->sample_rate != 0 && + st->codecpar->channels != 0) + goto the_end; + break; + case AVMEDIA_TYPE_VIDEO: + case AVMEDIA_TYPE_SUBTITLE: + goto the_end; + default: + break; + } + } + } + the_end: + stream_component_close(is, start_index); + stream_component_open(is, stream_index); +} + + +static void toggle_full_screen(void) +{ +#if defined(__APPLE__) && SDL_VERSION_ATLEAST(1, 2, 14) + /* OS X needs to empty the picture_queue */ + int i; + for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) + player->pictq[i].reallocate = 1; +#endif + is_full_screen = !is_full_screen; + video_open(player); +} + +static void toggle_pause(void) +{ + if (player) + stream_pause(player); + step = 0; +} + +static void step_to_next_frame(void) +{ + if (player) { + /* if the stream is paused unpause it, then step */ + if (player->paused) + stream_pause(player); + } + step = 1; +} + +static void toggle_audio_display(void) +{ + if (player) { + int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); + player->show_audio = (player->show_audio + 1) % 3; + fill_rectangle(screen, + player->xleft, player->ytop, player->width, player->height, + bgcolor); + SDL_UpdateRect(screen, player->xleft, player->ytop, player->width, player->height); + } +} + +static void seek_chapter(PlayerState *is, int incr) +{ + int64_t pos = get_master_clock(is) * AV_TIME_BASE; + int i; + + if (!is->ic->nb_chapters) + return; + + /* find the current chapter */ + for (i = 0; i < is->ic->nb_chapters; i++) { + AVChapter *ch = is->ic->chapters[i]; + if (av_compare_ts(pos, AV_TIME_BASE_Q, ch->start, ch->time_base) < 0) { + i--; + break; + } + } + + i += incr; + i = FFMAX(i, 0); + if (i >= is->ic->nb_chapters) + return; + + av_log(NULL, AV_LOG_VERBOSE, "Seeking to chapter %d.\n", i); + stream_seek(is, av_rescale_q(is->ic->chapters[i]->start, is->ic->chapters[i]->time_base, + AV_TIME_BASE_Q), 0, 0); +} + +/* handle an event sent by the GUI */ +static void event_loop(void) +{ + SDL_Event event; + double incr, pos, frac; + + for (;;) { + double x; + SDL_WaitEvent(&event); + switch (event.type) { + case SDL_KEYDOWN: + if (exit_on_keydown) { + do_exit(); + break; + } + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + case SDLK_q: + do_exit(); + break; + case SDLK_f: + toggle_full_screen(); + break; + case SDLK_p: + case SDLK_SPACE: + toggle_pause(); + break; + case SDLK_s: // S: Step to next frame + step_to_next_frame(); + break; + case SDLK_a: + if (player) + stream_cycle_channel(player, AVMEDIA_TYPE_AUDIO); + break; + case SDLK_v: + if (player) + stream_cycle_channel(player, AVMEDIA_TYPE_VIDEO); + break; + case SDLK_t: + if (player) + stream_cycle_channel(player, AVMEDIA_TYPE_SUBTITLE); + break; + case SDLK_w: + toggle_audio_display(); + break; + case SDLK_PAGEUP: + seek_chapter(player, 1); + break; + case SDLK_PAGEDOWN: + seek_chapter(player, -1); + break; + case SDLK_LEFT: + incr = -10.0; + goto do_seek; + case SDLK_RIGHT: + incr = 10.0; + goto do_seek; + case SDLK_UP: + incr = 60.0; + goto do_seek; + case SDLK_DOWN: + incr = -60.0; + do_seek: + if (player) { + if (seek_by_bytes) { + if (player->video_stream >= 0 && player->video_current_pos >= 0) { + pos = player->video_current_pos; + } else if (player->audio_stream >= 0 && player->audio_pkt.pos >= 0) { + pos = player->audio_pkt.pos; + } else + pos = avio_tell(player->ic->pb); + if (player->ic->bit_rate) + incr *= player->ic->bit_rate / 8.0; + else + incr *= 180000.0; + pos += incr; + stream_seek(player, pos, incr, 1); + } else { + pos = get_master_clock(player); + pos += incr; + stream_seek(player, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0); + } + } + break; + default: + break; + } + break; + case SDL_MOUSEBUTTONDOWN: + if (exit_on_mousedown) { + do_exit(); + break; + } + case SDL_MOUSEMOTION: + if (event.type == SDL_MOUSEBUTTONDOWN) { + x = event.button.x; + } else { + if (event.motion.state != SDL_PRESSED) + break; + x = event.motion.x; + } + if (player) { + if (seek_by_bytes || player->ic->duration <= 0) { + uint64_t size = avio_size(player->ic->pb); + stream_seek(player, size*x/player->width, 0, 1); + } else { + int64_t ts; + int ns, hh, mm, ss; + int tns, thh, tmm, tss; + tns = player->ic->duration / 1000000LL; + thh = tns / 3600; + tmm = (tns % 3600) / 60; + tss = (tns % 60); + frac = x / player->width; + ns = frac * tns; + hh = ns / 3600; + mm = (ns % 3600) / 60; + ss = (ns % 60); + fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of total duration (%2d:%02d:%02d) \n", frac*100, + hh, mm, ss, thh, tmm, tss); + ts = frac * player->ic->duration; + if (player->ic->start_time != AV_NOPTS_VALUE) + ts += player->ic->start_time; + stream_seek(player, ts, 0, 0); + } + } + break; + case SDL_VIDEORESIZE: + if (player) { + screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0, + SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); + screen_width = player->width = event.resize.w; + screen_height = player->height = event.resize.h; + } + break; + case SDL_QUIT: + case FF_QUIT_EVENT: + do_exit(); + break; + case FF_ALLOC_EVENT: + SDL_LockMutex(player->video_filter_mutex); + if (player->out_video_filter) { + video_open(event.user.data1); + alloc_picture(event.user.data1); + } + SDL_UnlockMutex(player->video_filter_mutex); + break; + case FF_REFRESH_EVENT: + video_refresh_timer(event.user.data1); + player->refresh = 0; + break; + default: + break; + } + } +} + +static int opt_frame_size(void *optctx, const char *opt, const char *arg) +{ + av_log(NULL, AV_LOG_ERROR, + "Option '%s' has been removed, use private format options instead\n", opt); + return AVERROR(EINVAL); +} + +static int opt_width(void *optctx, const char *opt, const char *arg) +{ + screen_width = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX); + return 0; +} + +static int opt_height(void *optctx, const char *opt, const char *arg) +{ + screen_height = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX); + return 0; +} + +static int opt_format(void *optctx, const char *opt, const char *arg) +{ + file_iformat = av_find_input_format(arg); + if (!file_iformat) { + fprintf(stderr, "Unknown input format: %s\n", arg); + return AVERROR(EINVAL); + } + return 0; +} + +static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg) +{ + av_log(NULL, AV_LOG_ERROR, + "Option '%s' has been removed, use private format options instead\n", opt); + return AVERROR(EINVAL); +} + +static int opt_sync(void *optctx, const char *opt, const char *arg) +{ + if (!strcmp(arg, "audio")) + av_sync_type = AV_SYNC_AUDIO_MASTER; + else if (!strcmp(arg, "video")) + av_sync_type = AV_SYNC_VIDEO_MASTER; + else if (!strcmp(arg, "ext")) + av_sync_type = AV_SYNC_EXTERNAL_CLOCK; + else { + fprintf(stderr, "Unknown value for %s: %s\n", opt, arg); + exit(1); + } + return 0; +} + +static int opt_seek(void *optctx, const char *opt, const char *arg) +{ + start_time = parse_time_or_die(opt, arg, 1); + return 0; +} + +static int opt_duration(void *optctx, const char *opt, const char *arg) +{ + duration = parse_time_or_die(opt, arg, 1); + return 0; +} + +#define OFF(x) offsetof(PlayerState, x) +static const OptionDef options[] = { + CMDUTILS_COMMON_OPTIONS + { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" }, + { "y", HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" }, + { "s", HAS_ARG | OPT_VIDEO, { .func_arg = opt_frame_size }, "set frame size (WxH or abbreviation)", "size" }, + { "fs", OPT_BOOL, { &is_full_screen }, "force full screen" }, + { "an", OPT_BOOL, { &audio_disable }, "disable audio" }, + { "vn", OPT_BOOL, { &video_disable }, "disable video" }, + { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, { &wanted_stream[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_number" }, + { "vst", OPT_INT | HAS_ARG | OPT_EXPERT, { &wanted_stream[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_number" }, + { "sst", OPT_INT | HAS_ARG | OPT_EXPERT, { &wanted_stream[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_number" }, + { "ss", HAS_ARG, { .func_arg = opt_seek }, "seek to a given position in seconds", "pos" }, + { "t", HAS_ARG, { .func_arg = opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, + { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, + { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" }, + { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" }, + { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, + { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" }, + { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, { &workaround_bugs }, "workaround bugs", "" }, + { "fast", OPT_BOOL | OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" }, + { "genpts", OPT_BOOL | OPT_EXPERT, { &genpts }, "generate pts", "" }, + { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, { &decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""}, + { "skiploop", OPT_INT | HAS_ARG | OPT_EXPERT, { &skip_loop_filter }, "", "" }, + { "skipframe", OPT_INT | HAS_ARG | OPT_EXPERT, { &skip_frame }, "", "" }, + { "skipidct", OPT_INT | HAS_ARG | OPT_EXPERT, { &skip_idct }, "", "" }, + { "idct", OPT_INT | HAS_ARG | OPT_EXPERT, { &idct }, "set idct algo", "algo" }, + { "ec", OPT_INT | HAS_ARG | OPT_EXPERT, { &error_concealment }, "set error concealment options", "bit_mask" }, + { "sync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_sync }, "set audio-video sync. type (type=audio/video/ext)", "type" }, + { "noautoexit", OPT_BOOL | OPT_EXPERT, { &noautoexit }, "Do not exit at the end of playback", "" }, + { "exitonkeydown", OPT_BOOL | OPT_EXPERT, { &exit_on_keydown }, "exit on key down", "" }, + { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { &exit_on_mousedown }, "exit on mouse down", "" }, + { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, { &loop }, "set number of times the playback shall be looped", "loop count" }, + { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" }, + { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, + { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" }, + { "vf", OPT_STRING | HAS_ARG, { &vfilters }, "video filters", "filter list" }, + { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" }, + { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { .func_arg = opt_default }, "generic catchall option", "" }, + { "i", 0, { NULL }, "avconv compatibility dummy option", ""}, + { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" }, + { "c", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT, { .off = OFF(codec_names) }, "codec name", "codec" }, + { "codec", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT, { .off = OFF(codec_names) }, "codec name", "codec" }, + + { NULL, }, +}; + +static void show_usage(void) +{ + printf("Simple media player\n"); + printf("usage: %s [options] input_file\n", program_name); + printf("\n"); +} + +void show_help_default(const char *opt, const char *arg) +{ + av_log_set_callback(log_callback_help); + show_usage(); + show_help_options(options, "Main options:", 0, OPT_EXPERT, 0); + show_help_options(options, "Advanced options:", OPT_EXPERT, 0, 0); + printf("\n"); + show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); + printf("\nWhile playing:\n" + "q, ESC quit\n" + "f toggle full screen\n" + "p, SPC pause\n" + "a cycle audio channel\n" + "v cycle video channel\n" + "t cycle subtitle channel\n" + "w show audio waves\n" + "s activate frame-step mode\n" + "left/right seek backward/forward 10 seconds\n" + "down/up seek backward/forward 1 minute\n" + "mouse click seek to percentage in file corresponding to fraction of width\n" + ); +} + +static void opt_input_file(void *optctx, const char *filename) +{ + if (input_filename) { + fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n", + filename, input_filename); + exit(1); + } + if (!strcmp(filename, "-")) + filename = "pipe:"; + input_filename = filename; +} + +/* Called from the main */ +int main(int argc, char **argv) +{ + int flags; + + av_log_set_flags(AV_LOG_SKIP_REPEATED); + parse_loglevel(argc, argv, options); + + /* register all codecs, demux and protocols */ + avcodec_register_all(); +#if CONFIG_AVDEVICE + avdevice_register_all(); +#endif + avfilter_register_all(); + av_register_all(); + avformat_network_init(); + + init_opts(); + + show_banner(); + + parse_options(player, argc, argv, options, opt_input_file); + + if (!input_filename) { + show_usage(); + fprintf(stderr, "An input file must be specified\n"); + fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'\n", program_name); + exit(1); + } + + if (display_disable) { + video_disable = 1; + } + flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; +#if !defined(__MINGW32__) && !defined(__APPLE__) + flags |= SDL_INIT_EVENTTHREAD; /* Not supported on Windows or Mac OS X */ +#endif + if (SDL_Init (flags)) { + fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError()); + exit(1); + } + + if (!display_disable) { + const SDL_VideoInfo *vi = SDL_GetVideoInfo(); + fs_screen_width = vi->current_w; + fs_screen_height = vi->current_h; + } + + SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); + SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); + SDL_EventState(SDL_USEREVENT, SDL_IGNORE); + + av_init_packet(&flush_pkt); + flush_pkt.data = (uint8_t *)&flush_pkt; + + if (stream_open(player, input_filename, file_iformat) < 0) { + fprintf(stderr, "Could not setup the player\n"); + stream_close(player); + exit(1); + } + + event_loop(); + + /* never returns */ + + return 0; +} diff --git a/avtools/avprobe.c b/avtools/avprobe.c new file mode 100644 index 0000000000..a9ca1934ca --- /dev/null +++ b/avtools/avprobe.c @@ -0,0 +1,1221 @@ +/* + * avprobe : Simple Media Prober based on the Libav libraries + * Copyright (c) 2007-2010 Stefano Sabatini + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/avstring.h" +#include "libavutil/display.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/spherical.h" +#include "libavutil/stereo3d.h" +#include "libavutil/dict.h" +#include "libavutil/libm.h" +#include "libavdevice/avdevice.h" +#include "cmdutils.h" + +typedef struct InputStream { + AVStream *st; + + AVCodecContext *dec_ctx; +} InputStream; + +typedef struct InputFile { + AVFormatContext *fmt_ctx; + + InputStream *streams; + int nb_streams; +} InputFile; + +const char program_name[] = "avprobe"; +const int program_birth_year = 2007; + +static int do_show_format = 0; +static AVDictionary *fmt_entries_to_show = NULL; +static int nb_fmt_entries_to_show; +static int do_show_packets = 0; +static int do_show_streams = 0; +static AVDictionary *stream_entries_to_show = NULL; +static int nb_stream_entries_to_show; + +/* key used to print when probe_{int,str}(NULL, ..) is invoked */ +static const char *header_key; + +static int show_value_unit = 0; +static int use_value_prefix = 0; +static int use_byte_value_binary_prefix = 0; +static int use_value_sexagesimal_format = 0; + +/* globals */ +static const OptionDef *options; + +/* avprobe context */ +static const char *input_filename; +static AVInputFormat *iformat = NULL; + +static const char *const binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" }; +static const char *const decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P" }; + +static const char unit_second_str[] = "s" ; +static const char unit_hertz_str[] = "Hz" ; +static const char unit_byte_str[] = "byte" ; +static const char unit_bit_per_second_str[] = "bit/s"; + +static void avprobe_cleanup(int ret) +{ + av_dict_free(&fmt_entries_to_show); + av_dict_free(&stream_entries_to_show); +} + +/* + * The output is structured in array and objects that might contain items + * Array could require the objects within to not be named. + * Object could require the items within to be named. + * + * For flat representation the name of each section is saved on prefix so it + * can be rendered in order to represent nested structures (e.g. array of + * objects for the packets list). + * + * Within an array each element can need an unique identifier or an index. + * + * Nesting level is accounted separately. + */ + +typedef enum { + ARRAY, + OBJECT +} PrintElementType; + +typedef struct PrintElement { + const char *name; + PrintElementType type; + int64_t index; + int64_t nb_elems; +} PrintElement; + +typedef struct PrintContext { + PrintElement *prefix; + int level; + void (*print_header)(void); + void (*print_footer)(void); + + void (*print_array_header) (const char *name, int plain_values); + void (*print_array_footer) (const char *name, int plain_values); + void (*print_object_header)(const char *name); + void (*print_object_footer)(const char *name); + + void (*print_integer) (const char *key, int64_t value); + void (*print_string) (const char *key, const char *value); +} PrintContext; + +static AVIOContext *probe_out = NULL; +static PrintContext octx; +#define AVP_INDENT() avio_printf(probe_out, "%*c", octx.level * 2, ' ') + +/* + * Default format, INI + * + * - all key and values are utf8 + * - '.' is the subgroup separator + * - newlines and the following characters are escaped + * - '\' is the escape character + * - '#' is the comment + * - '=' is the key/value separators + * - ':' is not used but usually parsed as key/value separator + */ + +static void ini_print_header(void) +{ + avio_printf(probe_out, "# avprobe output\n\n"); +} +static void ini_print_footer(void) +{ + avio_w8(probe_out, '\n'); +} + +static void ini_escape_print(const char *s) +{ + int i = 0; + char c = 0; + + while (c = s[i++]) { + switch (c) { + case '\r': avio_printf(probe_out, "%s", "\\r"); break; + case '\n': avio_printf(probe_out, "%s", "\\n"); break; + case '\f': avio_printf(probe_out, "%s", "\\f"); break; + case '\b': avio_printf(probe_out, "%s", "\\b"); break; + case '\t': avio_printf(probe_out, "%s", "\\t"); break; + case '\\': + case '#' : + case '=' : + case ':' : avio_w8(probe_out, '\\'); + default: + if ((unsigned char)c < 32) + avio_printf(probe_out, "\\x00%02x", c & 0xff); + else + avio_w8(probe_out, c); + break; + } + } +} + +static void ini_print_array_header(const char *name, int plain_values) +{ + if (!plain_values) { + /* Add a new line if we create a new full group */ + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, "\n"); + } else { + ini_escape_print(name); + avio_w8(probe_out, '='); + } +} + +static void ini_print_array_footer(const char *name, int plain_values) +{ + if (plain_values) + avio_printf(probe_out, "\n"); +} + +static void ini_print_object_header(const char *name) +{ + int i; + PrintElement *el = octx.prefix + octx.level -1; + + if (el->nb_elems) + avio_printf(probe_out, "\n"); + + avio_printf(probe_out, "["); + + for (i = 1; i < octx.level; i++) { + el = octx.prefix + i; + avio_printf(probe_out, "%s.", el->name); + if (el->index >= 0) + avio_printf(probe_out, "%"PRId64".", el->index); + } + + avio_printf(probe_out, "%s", name); + if (el->type == ARRAY) + avio_printf(probe_out, ".%"PRId64"", el->nb_elems); + avio_printf(probe_out, "]\n"); +} + +static void ini_print_integer(const char *key, int64_t value) +{ + if (key) { + ini_escape_print(key); + avio_printf(probe_out, "=%"PRId64"\n", value); + } else { + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ","); + avio_printf(probe_out, "%"PRId64, value); + } +} + + +static void ini_print_string(const char *key, const char *value) +{ + ini_escape_print(key); + avio_printf(probe_out, "="); + ini_escape_print(value); + avio_w8(probe_out, '\n'); +} + +/* + * Alternate format, JSON + */ + +static void json_print_header(void) +{ + avio_printf(probe_out, "{"); +} +static void json_print_footer(void) +{ + avio_printf(probe_out, "}\n"); +} + +static void json_print_array_header(const char *name, int plain_values) +{ + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ",\n"); + AVP_INDENT(); + avio_printf(probe_out, "\"%s\" : ", name); + avio_printf(probe_out, "[\n"); +} + +static void json_print_array_footer(const char *name, int plain_values) +{ + avio_printf(probe_out, "\n"); + AVP_INDENT(); + avio_printf(probe_out, "]"); +} + +static void json_print_object_header(const char *name) +{ + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ",\n"); + AVP_INDENT(); + if (octx.prefix[octx.level -1].type == OBJECT) + avio_printf(probe_out, "\"%s\" : ", name); + avio_printf(probe_out, "{\n"); +} + +static void json_print_object_footer(const char *name) +{ + avio_printf(probe_out, "\n"); + AVP_INDENT(); + avio_printf(probe_out, "}"); +} + +static void json_print_integer(const char *key, int64_t value) +{ + if (key) { + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ",\n"); + AVP_INDENT(); + avio_printf(probe_out, "\"%s\" : ", key); + } else { + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ", "); + else + AVP_INDENT(); + } + avio_printf(probe_out, "%"PRId64, value); +} + +static void json_escape_print(const char *s) +{ + int i = 0; + char c = 0; + + while (c = s[i++]) { + switch (c) { + case '\r': avio_printf(probe_out, "%s", "\\r"); break; + case '\n': avio_printf(probe_out, "%s", "\\n"); break; + case '\f': avio_printf(probe_out, "%s", "\\f"); break; + case '\b': avio_printf(probe_out, "%s", "\\b"); break; + case '\t': avio_printf(probe_out, "%s", "\\t"); break; + case '\\': + case '"' : avio_w8(probe_out, '\\'); + default: + if ((unsigned char)c < 32) + avio_printf(probe_out, "\\u00%02x", c & 0xff); + else + avio_w8(probe_out, c); + break; + } + } +} + +static void json_print_string(const char *key, const char *value) +{ + if (octx.prefix[octx.level -1].nb_elems) + avio_printf(probe_out, ",\n"); + AVP_INDENT(); + avio_w8(probe_out, '\"'); + json_escape_print(key); + avio_printf(probe_out, "\" : \""); + json_escape_print(value); + avio_w8(probe_out, '\"'); +} + +/* + * old-style pseudo-INI + */ +static void old_print_object_header(const char *name) +{ + char *str, *p; + + if (!strcmp(name, "tags")) + return; + + str = p = av_strdup(name); + if (!str) + return; + while (*p) { + *p = av_toupper(*p); + p++; + } + + avio_printf(probe_out, "[%s]\n", str); + av_freep(&str); +} + +static void old_print_object_footer(const char *name) +{ + char *str, *p; + + if (!strcmp(name, "tags")) + return; + + str = p = av_strdup(name); + if (!str) + return; + while (*p) { + *p = av_toupper(*p); + p++; + } + + avio_printf(probe_out, "[/%s]\n", str); + av_freep(&str); +} + +static void old_print_string(const char *key, const char *value) +{ + if (!strcmp(octx.prefix[octx.level - 1].name, "tags")) + avio_printf(probe_out, "TAG:"); + ini_print_string(key, value); +} + +/* + * Simple Formatter for single entries. + */ + +static void show_format_entry_integer(const char *key, int64_t value) +{ + if (key && av_dict_get(fmt_entries_to_show, key, NULL, 0)) { + if (nb_fmt_entries_to_show > 1) + avio_printf(probe_out, "%s=", key); + avio_printf(probe_out, "%"PRId64"\n", value); + } +} + +static void show_format_entry_string(const char *key, const char *value) +{ + if (key && av_dict_get(fmt_entries_to_show, key, NULL, 0)) { + if (nb_fmt_entries_to_show > 1) + avio_printf(probe_out, "%s=", key); + avio_printf(probe_out, "%s\n", value); + } +} + +static void show_stream_entry_header(const char *key, int value) +{ + header_key = key; +} + +static void show_stream_entry_footer(const char *key, int value) +{ + header_key = NULL; +} + +static void show_stream_entry_integer(const char *key, int64_t value) +{ + if (!key) + key = header_key; + + if (key && av_dict_get(stream_entries_to_show, key, NULL, 0)) { + if (nb_stream_entries_to_show > 1) + avio_printf(probe_out, "%s=", key); + avio_printf(probe_out, "%"PRId64"\n", value); + } +} + +static void show_stream_entry_string(const char *key, const char *value) +{ + if (key && av_dict_get(stream_entries_to_show, key, NULL, 0)) { + if (nb_stream_entries_to_show > 1) + avio_printf(probe_out, "%s=", key); + avio_printf(probe_out, "%s\n", value); + } +} + +static void probe_group_enter(const char *name, int type) +{ + int64_t count = -1; + + octx.prefix = + av_realloc(octx.prefix, sizeof(PrintElement) * (octx.level + 1)); + + if (!octx.prefix || !name) { + fprintf(stderr, "Out of memory\n"); + exit_program(1); + } + + if (octx.level) { + PrintElement *parent = octx.prefix + octx.level -1; + if (parent->type == ARRAY) + count = parent->nb_elems; + parent->nb_elems++; + } + + octx.prefix[octx.level++] = (PrintElement){name, type, count, 0}; +} + +static void probe_group_leave(void) +{ + --octx.level; +} + +static void probe_header(void) +{ + if (octx.print_header) + octx.print_header(); + probe_group_enter("root", OBJECT); +} + +static void probe_footer(void) +{ + if (octx.print_footer) + octx.print_footer(); + probe_group_leave(); +} + + +static void probe_array_header(const char *name, int plain_values) +{ + if (octx.print_array_header) + octx.print_array_header(name, plain_values); + + probe_group_enter(name, ARRAY); +} + +static void probe_array_footer(const char *name, int plain_values) +{ + probe_group_leave(); + if (octx.print_array_footer) + octx.print_array_footer(name, plain_values); +} + +static void probe_object_header(const char *name) +{ + if (octx.print_object_header) + octx.print_object_header(name); + + probe_group_enter(name, OBJECT); +} + +static void probe_object_footer(const char *name) +{ + probe_group_leave(); + if (octx.print_object_footer) + octx.print_object_footer(name); +} + +static void probe_int(const char *key, int64_t value) +{ + octx.print_integer(key, value); + octx.prefix[octx.level -1].nb_elems++; +} + +static void probe_str(const char *key, const char *value) +{ + octx.print_string(key, value); + octx.prefix[octx.level -1].nb_elems++; +} + +static void probe_dict(AVDictionary *dict, const char *name) +{ + AVDictionaryEntry *entry = NULL; + if (!dict) + return; + probe_object_header(name); + while ((entry = av_dict_get(dict, "", entry, AV_DICT_IGNORE_SUFFIX))) { + probe_str(entry->key, entry->value); + } + probe_object_footer(name); +} + +static char *value_string(char *buf, int buf_size, double val, const char *unit) +{ + if (unit == unit_second_str && use_value_sexagesimal_format) { + double secs; + int hours, mins; + secs = val; + mins = (int)secs / 60; + secs = secs - mins * 60; + hours = mins / 60; + mins %= 60; + snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs); + } else if (use_value_prefix) { + const char *prefix_string; + int index; + + if (unit == unit_byte_str && use_byte_value_binary_prefix) { + index = (int) log2(val) / 10; + index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) - 1); + val /= pow(2, index * 10); + prefix_string = binary_unit_prefixes[index]; + } else { + index = (int) (log10(val)) / 3; + index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) - 1); + val /= pow(10, index * 3); + prefix_string = decimal_unit_prefixes[index]; + } + snprintf(buf, buf_size, "%.*f%s%s", + index ? 3 : 0, val, + prefix_string, + show_value_unit ? unit : ""); + } else { + snprintf(buf, buf_size, "%f%s", val, show_value_unit ? unit : ""); + } + + return buf; +} + +static char *time_value_string(char *buf, int buf_size, int64_t val, + const AVRational *time_base) +{ + if (val == AV_NOPTS_VALUE) { + snprintf(buf, buf_size, "N/A"); + } else { + value_string(buf, buf_size, val * av_q2d(*time_base), unit_second_str); + } + + return buf; +} + +static char *ts_value_string(char *buf, int buf_size, int64_t ts) +{ + if (ts == AV_NOPTS_VALUE) { + snprintf(buf, buf_size, "N/A"); + } else { + snprintf(buf, buf_size, "%"PRId64, ts); + } + + return buf; +} + +static char *rational_string(char *buf, int buf_size, const char *sep, + const AVRational *rat) +{ + snprintf(buf, buf_size, "%d%s%d", rat->num, sep, rat->den); + return buf; +} + +static char *tag_string(char *buf, int buf_size, int tag) +{ + snprintf(buf, buf_size, "0x%04x", tag); + return buf; +} + +static char *unknown_string(char *buf, int buf_size, int val) +{ + snprintf(buf, buf_size, "Unknown (%d)", val); + return buf; +} + +static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt) +{ + char val_str[128]; + AVStream *st = fmt_ctx->streams[pkt->stream_index]; + + probe_object_header("packet"); + probe_str("codec_type", media_type_string(st->codecpar->codec_type)); + probe_int("stream_index", pkt->stream_index); + probe_str("pts", ts_value_string(val_str, sizeof(val_str), pkt->pts)); + probe_str("pts_time", time_value_string(val_str, sizeof(val_str), + pkt->pts, &st->time_base)); + probe_str("dts", ts_value_string(val_str, sizeof(val_str), pkt->dts)); + probe_str("dts_time", time_value_string(val_str, sizeof(val_str), + pkt->dts, &st->time_base)); + probe_str("duration", ts_value_string(val_str, sizeof(val_str), + pkt->duration)); + probe_str("duration_time", time_value_string(val_str, sizeof(val_str), + pkt->duration, + &st->time_base)); + probe_str("size", value_string(val_str, sizeof(val_str), + pkt->size, unit_byte_str)); + probe_int("pos", pkt->pos); + probe_str("flags", pkt->flags & AV_PKT_FLAG_KEY ? "K" : "_"); + probe_object_footer("packet"); +} + +static void show_packets(InputFile *ifile) +{ + AVFormatContext *fmt_ctx = ifile->fmt_ctx; + AVPacket pkt; + + av_init_packet(&pkt); + probe_array_header("packets", 0); + while (!av_read_frame(fmt_ctx, &pkt)) { + show_packet(fmt_ctx, &pkt); + av_packet_unref(&pkt); + } + probe_array_footer("packets", 0); +} + +static void show_stream(InputFile *ifile, InputStream *ist) +{ + AVFormatContext *fmt_ctx = ifile->fmt_ctx; + AVStream *stream = ist->st; + AVCodecParameters *par; + AVCodecContext *dec_ctx; + const AVCodecDescriptor *codec_desc; + const char *profile; + char val_str[128]; + AVRational display_aspect_ratio, *sar = NULL; + const AVPixFmtDescriptor *desc; + const char *val; + + probe_object_header("stream"); + + probe_int("index", stream->index); + + par = stream->codecpar; + dec_ctx = ist->dec_ctx; + codec_desc = avcodec_descriptor_get(par->codec_id); + if (codec_desc) { + probe_str("codec_name", codec_desc->name); + probe_str("codec_long_name", codec_desc->long_name); + } else { + probe_str("codec_name", "unknown"); + } + + probe_str("codec_type", media_type_string(par->codec_type)); + + /* print AVI/FourCC tag */ + av_get_codec_tag_string(val_str, sizeof(val_str), par->codec_tag); + probe_str("codec_tag_string", val_str); + probe_str("codec_tag", tag_string(val_str, sizeof(val_str), + par->codec_tag)); + + /* print profile, if there is one */ + profile = avcodec_profile_name(par->codec_id, par->profile); + if (profile) + probe_str("profile", profile); + + switch (par->codec_type) { + case AVMEDIA_TYPE_VIDEO: + probe_int("width", par->width); + probe_int("height", par->height); + if (dec_ctx) { + probe_int("coded_width", dec_ctx->coded_width); + probe_int("coded_height", dec_ctx->coded_height); + probe_int("has_b_frames", dec_ctx->has_b_frames); + } + if (dec_ctx && dec_ctx->sample_aspect_ratio.num) + sar = &dec_ctx->sample_aspect_ratio; + else if (par->sample_aspect_ratio.num) + sar = &par->sample_aspect_ratio; + else if (stream->sample_aspect_ratio.num) + sar = &stream->sample_aspect_ratio; + + if (sar) { + probe_str("sample_aspect_ratio", + rational_string(val_str, sizeof(val_str), ":", sar)); + av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, + par->width * sar->num, par->height * sar->den, + 1024*1024); + probe_str("display_aspect_ratio", + rational_string(val_str, sizeof(val_str), ":", + &display_aspect_ratio)); + } + desc = av_pix_fmt_desc_get(par->format); + probe_str("pix_fmt", desc ? desc->name : "unknown"); + probe_int("level", par->level); + + val = av_color_range_name(par->color_range); + if (!val) + val = unknown_string(val_str, sizeof(val_str), par->color_range); + probe_str("color_range", val); + + val = av_color_space_name(par->color_space); + if (!val) + val = unknown_string(val_str, sizeof(val_str), par->color_space); + probe_str("color_space", val); + + val = av_color_transfer_name(par->color_trc); + if (!val) + val = unknown_string(val_str, sizeof(val_str), par->color_trc); + probe_str("color_trc", val); + + val = av_color_primaries_name(par->color_primaries); + if (!val) + val = unknown_string(val_str, sizeof(val_str), par->color_primaries); + probe_str("color_pri", val); + + val = av_chroma_location_name(par->chroma_location); + if (!val) + val = unknown_string(val_str, sizeof(val_str), par->chroma_location); + probe_str("chroma_loc", val); + break; + + case AVMEDIA_TYPE_AUDIO: + probe_str("sample_rate", + value_string(val_str, sizeof(val_str), + par->sample_rate, + unit_hertz_str)); + probe_int("channels", par->channels); + probe_int("bits_per_sample", + av_get_bits_per_sample(par->codec_id)); + break; + } + + if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) + probe_int("id", stream->id); + probe_str("avg_frame_rate", + rational_string(val_str, sizeof(val_str), "/", + &stream->avg_frame_rate)); + + if (par->bit_rate) + probe_str("bit_rate", + value_string(val_str, sizeof(val_str), + par->bit_rate, unit_bit_per_second_str)); + probe_str("time_base", + rational_string(val_str, sizeof(val_str), "/", + &stream->time_base)); + probe_str("start_time", + time_value_string(val_str, sizeof(val_str), + stream->start_time, &stream->time_base)); + probe_str("duration", + time_value_string(val_str, sizeof(val_str), + stream->duration, &stream->time_base)); + if (stream->nb_frames) + probe_int("nb_frames", stream->nb_frames); + + probe_dict(stream->metadata, "tags"); + + if (stream->nb_side_data) { + int i, j; + + probe_object_header("sidedata"); + for (i = 0; i < stream->nb_side_data; i++) { + const AVPacketSideData* sd = &stream->side_data[i]; + AVStereo3D *stereo; + AVSphericalMapping *spherical; + + switch (sd->type) { + case AV_PKT_DATA_DISPLAYMATRIX: + probe_object_header("displaymatrix"); + probe_array_header("matrix", 1); + for (j = 0; j < 9; j++) + probe_int(NULL, ((int32_t *)sd->data)[j]); + probe_array_footer("matrix", 1); + probe_int("rotation", + av_display_rotation_get((int32_t *)sd->data)); + probe_object_footer("displaymatrix"); + break; + case AV_PKT_DATA_STEREO3D: + stereo = (AVStereo3D *)sd->data; + probe_object_header("stereo3d"); + probe_str("type", av_stereo3d_type_name(stereo->type)); + probe_int("inverted", + !!(stereo->flags & AV_STEREO3D_FLAG_INVERT)); + probe_object_footer("stereo3d"); + break; + case AV_PKT_DATA_SPHERICAL: + spherical = (AVSphericalMapping *)sd->data; + probe_object_header("spherical"); + probe_str("projection", av_spherical_projection_name(spherical->projection)); + + if (spherical->projection == AV_SPHERICAL_CUBEMAP) { + probe_int("padding", spherical->padding); + } else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { + size_t l, t, r, b; + av_spherical_tile_bounds(spherical, par->width, par->height, + &l, &t, &r, &b); + probe_object_header("bounding"); + probe_int("left", l); + probe_int("top", t); + probe_int("right", r); + probe_int("bottom", b); + probe_object_footer("bounding"); + } + + probe_object_header("orientation"); + probe_int("yaw", (double) spherical->yaw / (1 << 16)); + probe_int("pitch", (double) spherical->pitch / (1 << 16)); + probe_int("roll", (double) spherical->roll / (1 << 16)); + probe_object_footer("orientation"); + + probe_object_footer("spherical"); + break; + } + } + probe_object_footer("sidedata"); + } + + probe_object_footer("stream"); +} + +static void show_format(InputFile *ifile) +{ + AVFormatContext *fmt_ctx = ifile->fmt_ctx; + char val_str[128]; + int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1; + + probe_object_header("format"); + probe_str("filename", fmt_ctx->filename); + probe_int("nb_streams", fmt_ctx->nb_streams); + probe_str("format_name", fmt_ctx->iformat->name); + probe_str("format_long_name", fmt_ctx->iformat->long_name); + probe_str("start_time", + time_value_string(val_str, sizeof(val_str), + fmt_ctx->start_time, &AV_TIME_BASE_Q)); + probe_str("duration", + time_value_string(val_str, sizeof(val_str), + fmt_ctx->duration, &AV_TIME_BASE_Q)); + probe_str("size", + size >= 0 ? value_string(val_str, sizeof(val_str), + size, unit_byte_str) + : "unknown"); + probe_str("bit_rate", + value_string(val_str, sizeof(val_str), + fmt_ctx->bit_rate, unit_bit_per_second_str)); + + probe_dict(fmt_ctx->metadata, "tags"); + + probe_object_footer("format"); +} + +static int open_input_file(InputFile *ifile, const char *filename) +{ + int err, i; + AVFormatContext *fmt_ctx = NULL; + AVDictionaryEntry *t; + + if ((err = avformat_open_input(&fmt_ctx, filename, + iformat, &format_opts)) < 0) { + print_error(filename, err); + return err; + } + if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + return AVERROR_OPTION_NOT_FOUND; + } + + + /* fill the streams in the format context */ + if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) { + print_error(filename, err); + return err; + } + + av_dump_format(fmt_ctx, 0, filename, 0); + + ifile->streams = av_mallocz_array(fmt_ctx->nb_streams, + sizeof(*ifile->streams)); + if (!ifile->streams) + exit(1); + ifile->nb_streams = fmt_ctx->nb_streams; + + /* bind a decoder to each input stream */ + for (i = 0; i < fmt_ctx->nb_streams; i++) { + InputStream *ist = &ifile->streams[i]; + AVStream *stream = fmt_ctx->streams[i]; + AVCodec *codec; + + ist->st = stream; + + if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) { + fprintf(stderr, "Failed to probe codec for input stream %d\n", + stream->index); + continue; + } + + codec = avcodec_find_decoder(stream->codecpar->codec_id); + if (!codec) { + fprintf(stderr, + "Unsupported codec with id %d for input stream %d\n", + stream->codecpar->codec_id, stream->index); + continue; + } + + ist->dec_ctx = avcodec_alloc_context3(codec); + if (!ist->dec_ctx) + exit(1); + + err = avcodec_parameters_to_context(ist->dec_ctx, stream->codecpar); + if (err < 0) + exit(1); + + err = avcodec_open2(ist->dec_ctx, NULL, NULL); + if (err < 0) { + fprintf(stderr, "Error while opening codec for input stream %d\n", + stream->index); + exit(1); + + } + } + + ifile->fmt_ctx = fmt_ctx; + return 0; +} + +static void close_input_file(InputFile *ifile) +{ + int i; + + /* close decoder for each stream */ + for (i = 0; i < ifile->nb_streams; i++) { + InputStream *ist = &ifile->streams[i]; + + avcodec_free_context(&ist->dec_ctx); + } + + av_freep(&ifile->streams); + ifile->nb_streams = 0; + + avformat_close_input(&ifile->fmt_ctx); +} + +static int probe_file(const char *filename) +{ + InputFile ifile; + int ret, i; + + ret = open_input_file(&ifile, filename); + if (ret < 0) + return ret; + + if (do_show_format) + show_format(&ifile); + + if (do_show_streams) { + probe_array_header("streams", 0); + for (i = 0; i < ifile.nb_streams; i++) + show_stream(&ifile, &ifile.streams[i]); + probe_array_footer("streams", 0); + } + + if (do_show_packets) + show_packets(&ifile); + + close_input_file(&ifile); + return 0; +} + +static void show_usage(void) +{ + printf("Simple multimedia streams analyzer\n"); + printf("usage: %s [OPTIONS] [INPUT_FILE]\n", program_name); + printf("\n"); +} + +static int opt_format(void *optctx, const char *opt, const char *arg) +{ + iformat = av_find_input_format(arg); + if (!iformat) { + fprintf(stderr, "Unknown input format: %s\n", arg); + return AVERROR(EINVAL); + } + return 0; +} + +static int opt_output_format(void *optctx, const char *opt, const char *arg) +{ + + if (!strcmp(arg, "json")) { + octx.print_header = json_print_header; + octx.print_footer = json_print_footer; + octx.print_array_header = json_print_array_header; + octx.print_array_footer = json_print_array_footer; + octx.print_object_header = json_print_object_header; + octx.print_object_footer = json_print_object_footer; + + octx.print_integer = json_print_integer; + octx.print_string = json_print_string; + } else if (!strcmp(arg, "ini")) { + octx.print_header = ini_print_header; + octx.print_footer = ini_print_footer; + octx.print_array_header = ini_print_array_header; + octx.print_array_footer = ini_print_array_footer; + octx.print_object_header = ini_print_object_header; + + octx.print_integer = ini_print_integer; + octx.print_string = ini_print_string; + } else if (!strcmp(arg, "old")) { + octx.print_header = NULL; + octx.print_object_header = old_print_object_header; + octx.print_object_footer = old_print_object_footer; + + octx.print_string = old_print_string; + } else { + av_log(NULL, AV_LOG_ERROR, "Unsupported formatter %s\n", arg); + return AVERROR(EINVAL); + } + return 0; +} + +static int opt_show_format_entry(void *optctx, const char *opt, const char *arg) +{ + do_show_format = 1; + nb_fmt_entries_to_show++; + octx.print_header = NULL; + octx.print_footer = NULL; + octx.print_array_header = NULL; + octx.print_array_footer = NULL; + octx.print_object_header = NULL; + octx.print_object_footer = NULL; + + octx.print_integer = show_format_entry_integer; + octx.print_string = show_format_entry_string; + av_dict_set(&fmt_entries_to_show, arg, "", 0); + return 0; +} + +static int opt_show_stream_entry(void *optctx, const char *opt, const char *arg) +{ + const char *p = arg; + + do_show_streams = 1; + nb_stream_entries_to_show++; + octx.print_header = NULL; + octx.print_footer = NULL; + octx.print_array_header = show_stream_entry_header; + octx.print_array_footer = show_stream_entry_footer; + octx.print_object_header = NULL; + octx.print_object_footer = NULL; + + octx.print_integer = show_stream_entry_integer; + octx.print_string = show_stream_entry_string; + + while (*p) { + char *val = av_get_token(&p, ","); + if (!val) + return AVERROR(ENOMEM); + + av_dict_set(&stream_entries_to_show, val, "", 0); + + av_free(val); + if (*p) + p++; + } + + return 0; +} + +static void opt_input_file(void *optctx, const char *arg) +{ + if (input_filename) { + fprintf(stderr, + "Argument '%s' provided as input filename, but '%s' was already specified.\n", + arg, input_filename); + exit_program(1); + } + if (!strcmp(arg, "-")) + arg = "pipe:"; + input_filename = arg; +} + +void show_help_default(const char *opt, const char *arg) +{ + av_log_set_callback(log_callback_help); + show_usage(); + show_help_options(options, "Main options:", 0, 0, 0); + printf("\n"); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); +} + +static int opt_pretty(void *optctx, const char *opt, const char *arg) +{ + show_value_unit = 1; + use_value_prefix = 1; + use_byte_value_binary_prefix = 1; + use_value_sexagesimal_format = 1; + return 0; +} + +static const OptionDef real_options[] = { + CMDUTILS_COMMON_OPTIONS + { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" }, + { "of", HAS_ARG, {.func_arg = opt_output_format}, "output the document either as ini or json", "output_format" }, + { "unit", OPT_BOOL, {&show_value_unit}, + "show unit of the displayed values" }, + { "prefix", OPT_BOOL, {&use_value_prefix}, + "use SI prefixes for the displayed values" }, + { "byte_binary_prefix", OPT_BOOL, {&use_byte_value_binary_prefix}, + "use binary prefixes for byte units" }, + { "sexagesimal", OPT_BOOL, {&use_value_sexagesimal_format}, + "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" }, + { "pretty", 0, {.func_arg = opt_pretty}, + "prettify the format of displayed values, make it more human readable" }, + { "show_format", OPT_BOOL, {&do_show_format} , "show format/container info" }, + { "show_format_entry", HAS_ARG, {.func_arg = opt_show_format_entry}, + "show a particular entry from the format/container info", "entry" }, + { "show_packets", OPT_BOOL, {&do_show_packets}, "show packets info" }, + { "show_streams", OPT_BOOL, {&do_show_streams}, "show streams info" }, + { "show_stream_entry", HAS_ARG, {.func_arg = opt_show_stream_entry}, + "show a particular entry from all streams (comma separated)", "entry" }, + { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default}, + "generic catch all option", "" }, + { NULL, }, +}; + +static int probe_buf_write(void *opaque, uint8_t *buf, int buf_size) +{ + printf("%.*s", buf_size, buf); + return 0; +} + +#define AVP_BUFFSIZE 4096 + +int main(int argc, char **argv) +{ + int ret; + uint8_t *buffer = av_malloc(AVP_BUFFSIZE); + + if (!buffer) + exit(1); + + register_exit(avprobe_cleanup); + + options = real_options; + parse_loglevel(argc, argv, options); + av_register_all(); + avformat_network_init(); + init_opts(); +#if CONFIG_AVDEVICE + avdevice_register_all(); +#endif + + show_banner(); + + octx.print_header = ini_print_header; + octx.print_footer = ini_print_footer; + + octx.print_array_header = ini_print_array_header; + octx.print_array_footer = ini_print_array_footer; + octx.print_object_header = ini_print_object_header; + + octx.print_integer = ini_print_integer; + octx.print_string = ini_print_string; + + parse_options(NULL, argc, argv, options, opt_input_file); + + if (!input_filename) { + show_usage(); + fprintf(stderr, "You have to specify one input file.\n"); + fprintf(stderr, + "Use -h to get full help or, even better, run 'man %s'.\n", + program_name); + exit_program(1); + } + + probe_out = avio_alloc_context(buffer, AVP_BUFFSIZE, 1, NULL, NULL, + probe_buf_write, NULL); + if (!probe_out) + exit_program(1); + + probe_header(); + ret = probe_file(input_filename); + probe_footer(); + avio_flush(probe_out); + avio_context_free(&probe_out); + av_freep(&buffer); + uninit_opts(); + avformat_network_deinit(); + + return ret; +} diff --git a/cmdutils.c b/avtools/cmdutils.c similarity index 63% rename from cmdutils.c rename to avtools/cmdutils.c index 3d428f3eea..727e2835eb 100644 --- a/cmdutils.c +++ b/avtools/cmdutils.c @@ -2,20 +2,20 @@ * Various utilities for command line tools * Copyright (c) 2000-2003 Fabrice Bellard * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,29 +30,23 @@ references to libraries that are not being built. */ #include "config.h" -#include "compat/va_copy.h" #include "libavformat/avformat.h" #include "libavfilter/avfilter.h" #include "libavdevice/avdevice.h" #include "libavresample/avresample.h" #include "libswscale/swscale.h" -#include "libswresample/swresample.h" -#include "libpostproc/postprocess.h" +#include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" -#include "libavutil/bprint.h" -#include "libavutil/display.h" #include "libavutil/mathematics.h" #include "libavutil/imgutils.h" -#include "libavutil/libm.h" #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/eval.h" #include "libavutil/dict.h" #include "libavutil/opt.h" #include "libavutil/cpu.h" -#include "libavutil/ffversion.h" -#include "libavutil/version.h" +#include "avversion.h" #include "cmdutils.h" #if CONFIG_NETWORK #include "libavformat/network.h" @@ -61,35 +55,26 @@ #include #include #endif -#ifdef _WIN32 -#include -#endif -static int init_report(const char *env); - -AVDictionary *sws_dict; -AVDictionary *swr_opts; +struct SwsContext *sws_opts; AVDictionary *format_opts, *codec_opts, *resample_opts; -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, -}; +static const int this_year = 2017; void init_opts(void) { - av_dict_set(&sws_dict, "flags", "bicubic", 0); +#if CONFIG_SWSCALE + sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, + NULL, NULL, NULL); +#endif } void uninit_opts(void) { - av_dict_free(&swr_opts); - av_dict_free(&sws_dict); +#if CONFIG_SWSCALE + sws_freeContext(sws_opts); + sws_opts = NULL; +#endif av_dict_free(&format_opts); av_dict_free(&codec_opts); av_dict_free(&resample_opts); @@ -100,31 +85,6 @@ void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) vfprintf(stdout, fmt, vl); } -static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl) -{ - va_list vl2; - char line[1024]; - static int print_prefix = 1; - - va_copy(vl2, vl); - av_log_default_callback(ptr, level, fmt, vl); - av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix); - va_end(vl2); - if (report_file_level >= level) { - fputs(line, report_file); - fflush(report_file); - } -} - -void init_dynload(void) -{ -#ifdef _WIN32 - /* Calling SetDllDirectory with the empty string (but not NULL) removes the - * current working directory from the DLL search path as a security pre-caution. */ - SetDllDirectory(""); -#endif -} - static void (*program_exit)(int ret); void register_exit(void (*cb)(int ret)) @@ -180,7 +140,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, int first; first = 1; - for (po = options; po->name; po++) { + for (po = options; po->name != NULL; po++) { char buf[64]; if (((po->flags & req_flags) != req_flags) || @@ -205,10 +165,8 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, void show_help_children(const AVClass *class, int flags) { const AVClass *child = NULL; - if (class->option) { - av_opt_show2(&class, NULL, flags, 0); - printf("\n"); - } + av_opt_show2(&class, NULL, flags, 0); + printf("\n"); while (child = av_opt_child_class_next(class, child)) show_help_children(child, flags); @@ -231,6 +189,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 #include /* Will be leaked on exit */ static char** win32_argv_utf8 = NULL; @@ -335,8 +294,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, int ret = po->u.func_arg(optctx, opt, arg); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, - "Failed to set value '%s' for option '%s': %s\n", - arg, opt, av_err2str(ret)); + "Failed to set value '%s' for option '%s'\n", arg, opt); return ret; } } @@ -469,82 +427,19 @@ int locate_option(int argc, char **argv, const OptionDef *options, return 0; } -static void dump_argument(const char *a) -{ - const unsigned char *p; - - for (p = a; *p; p++) - if (!((*p >= '+' && *p <= ':') || (*p >= '@' && *p <= 'Z') || - *p == '_' || (*p >= 'a' && *p <= 'z'))) - break; - if (!*p) { - fputs(a, report_file); - return; - } - fputc('"', report_file); - for (p = a; *p; p++) { - if (*p == '\\' || *p == '"' || *p == '$' || *p == '`') - fprintf(report_file, "\\%c", *p); - else if (*p < ' ' || *p > '~') - fprintf(report_file, "\\x%02x", *p); - else - fputc(*p, report_file); - } - fputc('"', report_file); -} - -static void check_options(const OptionDef *po) -{ - while (po->name) { - if (po->flags & OPT_PERFILE) - av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT)); - po++; - } -} - void parse_loglevel(int argc, char **argv, const OptionDef *options) { int idx = locate_option(argc, argv, options, "loglevel"); - const char *env; - - check_options(options); - if (!idx) idx = locate_option(argc, argv, options, "v"); if (idx && argv[idx + 1]) opt_loglevel(NULL, "loglevel", argv[idx + 1]); - idx = locate_option(argc, argv, options, "report"); - if ((env = getenv("FFREPORT")) || idx) { - init_report(env); - if (report_file) { - int i; - fprintf(report_file, "Command line:\n"); - for (i = 0; i < argc; i++) { - dump_argument(argv[i]); - fputc(i < argc - 1 ? ' ' : '\n', report_file); - } - fflush(report_file); - } - } - idx = locate_option(argc, argv, options, "hide_banner"); - if (idx) - hide_banner = 1; } -static const AVOption *opt_find(void *obj, const char *name, const char *unit, - int opt_flags, int search_flags) -{ - const AVOption *o = av_opt_find(obj, name, unit, opt_flags, search_flags); - if(o && !o->flags) - return NULL; - return o; -} - -#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 +#define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 int opt_default(void *optctx, const char *opt, const char *arg) { const AVOption *o; - int consumed = 0; char opt_stripped[128]; const char *p; const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); @@ -554,81 +449,37 @@ int opt_default(void *optctx, const char *opt, const char *arg) #if CONFIG_SWSCALE const AVClass *sc = sws_get_class(); #endif -#if CONFIG_SWRESAMPLE - const AVClass *swr_class = swr_get_class(); -#endif - - if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) - av_log_set_level(AV_LOG_DEBUG); if (!(p = strchr(opt, ':'))) p = opt + strlen(opt); av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); - if ((o = opt_find(&cc, opt_stripped, NULL, 0, + if ((o = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && - (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { + (o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) av_dict_set(&codec_opts, opt, arg, FLAGS); - consumed = 1; - } - if ((o = opt_find(&fc, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + else if ((o = av_opt_find(&fc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) av_dict_set(&format_opts, opt, arg, FLAGS); - if (consumed) - av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt); - consumed = 1; - } -#if CONFIG_SWSCALE - if (!consumed && (o = opt_find(&sc, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - struct SwsContext *sws = sws_alloc_context(); - int ret = av_opt_set(sws, opt, arg, 0); - sws_freeContext(sws); - if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || - !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || - !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { - av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); - return AVERROR(EINVAL); - } - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); - return ret; - } - - av_dict_set(&sws_dict, opt, arg, FLAGS); - - consumed = 1; - } -#else - if (!consumed && !strcmp(opt, "sws_flags")) { - av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg); - consumed = 1; - } -#endif -#if CONFIG_SWRESAMPLE - if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - struct SwrContext *swr = swr_alloc(); - int ret = av_opt_set(swr, opt, arg, 0); - swr_free(&swr); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); - return ret; - } - av_dict_set(&swr_opts, opt, arg, FLAGS); - consumed = 1; - } -#endif #if CONFIG_AVRESAMPLE - if ((o=opt_find(&rc, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + else if ((o = av_opt_find(&rc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) av_dict_set(&resample_opts, opt, arg, FLAGS); - consumed = 1; +#endif +#if CONFIG_SWSCALE + else if ((o = av_opt_find(&sc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + // XXX we only support sws_flags, not arbitrary sws options + int ret = av_opt_set(sws_opts, opt, arg, 0); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); + return ret; + } } #endif - if (consumed) + if (o) return 0; return AVERROR_OPTION_NOT_FOUND; } @@ -670,8 +521,9 @@ static void finish_group(OptionParseContext *octx, int group_idx, *g = octx->cur_group; g->arg = arg; g->group_def = l->group_def; - g->sws_dict = sws_dict; - g->swr_opts = swr_opts; +#if CONFIG_SWSCALE + g->sws_opts = sws_opts; +#endif g->codec_opts = codec_opts; g->format_opts = format_opts; g->resample_opts = resample_opts; @@ -679,8 +531,9 @@ static void finish_group(OptionParseContext *octx, int group_idx, codec_opts = NULL; format_opts = NULL; resample_opts = NULL; - sws_dict = NULL; - swr_opts = NULL; +#if CONFIG_SWSCALE + sws_opts = NULL; +#endif init_opts(); memset(&octx->cur_group, 0, sizeof(octx->cur_group)); @@ -710,7 +563,7 @@ static void init_parse_context(OptionParseContext *octx, memset(octx, 0, sizeof(*octx)); octx->nb_groups = nb_groups; - octx->groups = av_mallocz_array(octx->nb_groups, sizeof(*octx->groups)); + octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups); if (!octx->groups) exit_program(1); @@ -735,9 +588,9 @@ void uninit_parse_context(OptionParseContext *octx) av_dict_free(&l->groups[j].codec_opts); av_dict_free(&l->groups[j].format_opts); av_dict_free(&l->groups[j].resample_opts); - - av_dict_free(&l->groups[j].sws_dict); - av_dict_free(&l->groups[j].swr_opts); +#if CONFIG_SWSCALE + sws_freeContext(l->groups[j].sws_opts); +#endif } av_freep(&l->groups); } @@ -754,7 +607,6 @@ int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionGroupDef *groups, int nb_groups) { int optindex = 1; - int dashdash = -2; /* perform system-dependent conversions for arguments list */ prepare_app_arguments(&argc, &argv); @@ -769,12 +621,8 @@ int split_commandline(OptionParseContext *octx, int argc, char *argv[], av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt); - if (opt[0] == '-' && opt[1] == '-' && !opt[2]) { - dashdash = optindex; - continue; - } /* unnamed group separators, e.g. output filename */ - if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) { + if (opt[0] != '-' || !opt[1]) { finish_group(octx, 0, opt); av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name); continue; @@ -857,13 +705,12 @@ do { \ int opt_cpuflags(void *optctx, const char *opt, const char *arg) { - int ret; - unsigned flags = av_get_cpu_flags(); + int flags = av_parse_cpu_flags(arg); - if ((ret = av_parse_cpu_caps(&flags, arg)) < 0) - return ret; + if (flags < 0) + return flags; - av_force_cpu_flags(flags); + av_set_cpu_flags_mask(flags); return 0; } @@ -882,22 +729,8 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) }; char *tail; int level; - int flags; int i; - flags = av_log_get_flags(); - tail = strstr(arg, "repeat"); - if (tail) - flags &= ~AV_LOG_SKIP_REPEATED; - else - flags |= AV_LOG_SKIP_REPEATED; - - av_log_set_flags(flags); - if (tail == arg) - arg += 6 + (arg[6]=='+'); - if(tail && !*arg) - return 0; - for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { if (!strcmp(log_levels[i].name, arg)) { av_log_set_level(log_levels[i].level); @@ -917,124 +750,6 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) return 0; } -static void expand_filename_template(AVBPrint *bp, const char *template, - struct tm *tm) -{ - int c; - - while ((c = *(template++))) { - if (c == '%') { - if (!(c = *(template++))) - break; - switch (c) { - case 'p': - av_bprintf(bp, "%s", program_name); - break; - case 't': - av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); - break; - case '%': - av_bprint_chars(bp, c, 1); - break; - } - } else { - av_bprint_chars(bp, c, 1); - } - } -} - -static int init_report(const char *env) -{ - char *filename_template = NULL; - char *key, *val; - int ret, count = 0; - time_t now; - struct tm *tm; - AVBPrint filename; - - if (report_file) /* already opened */ - return 0; - time(&now); - tm = localtime(&now); - - while (env && *env) { - if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) { - if (count) - av_log(NULL, AV_LOG_ERROR, - "Failed to parse FFREPORT environment variable: %s\n", - av_err2str(ret)); - break; - } - if (*env) - env++; - count++; - if (!strcmp(key, "file")) { - av_free(filename_template); - filename_template = val; - val = NULL; - } else if (!strcmp(key, "level")) { - char *tail; - report_file_level = strtol(val, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); - exit_program(1); - } - } else { - av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); - } - av_free(val); - av_free(key); - } - - av_bprint_init(&filename, 0, 1); - expand_filename_template(&filename, - av_x_if_null(filename_template, "%p-%t.log"), tm); - av_free(filename_template); - if (!av_bprint_is_complete(&filename)) { - av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n"); - return AVERROR(ENOMEM); - } - - report_file = fopen(filename.str, "w"); - if (!report_file) { - int ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n", - filename.str, strerror(errno)); - return ret; - } - av_log_set_callback(log_callback_report); - av_log(NULL, AV_LOG_INFO, - "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" - "Report written to \"%s\"\n", - program_name, - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, - filename.str); - av_bprint_finalize(&filename, NULL); - return 0; -} - -int opt_report(const char *opt) -{ - return init_report(NULL); -} - -int opt_max_alloc(void *optctx, const char *opt, const char *arg) -{ - char *tail; - size_t max; - - max = strtol(arg, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg); - exit_program(1); - } - av_max_alloc(max); - return 0; -} - int opt_timelimit(void *optctx, const char *opt, const char *arg) { #if HAVE_SETRLIMIT @@ -1063,7 +778,6 @@ static int warned_cfg = 0; #define INDENT 1 #define SHOW_VERSION 2 #define SHOW_CONFIG 4 -#define SHOW_COPYRIGHT 8 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ if (CONFIG_##LIBNAME) { \ @@ -1071,17 +785,16 @@ static int warned_cfg = 0; if (flags & SHOW_VERSION) { \ unsigned int version = libname##_version(); \ av_log(NULL, level, \ - "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \ + "%slib%-10s %2d.%3d.%2d / %2d.%3d.%2d\n", \ indent, #libname, \ LIB##LIBNAME##_VERSION_MAJOR, \ LIB##LIBNAME##_VERSION_MINOR, \ LIB##LIBNAME##_VERSION_MICRO, \ - AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ - AV_VERSION_MICRO(version)); \ + version >> 16, version >> 8 & 0xff, version & 0xff); \ } \ if (flags & SHOW_CONFIG) { \ const char *cfg = libname##_configuration(); \ - if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ + if (strcmp(LIBAV_CONFIGURATION, cfg)) { \ if (!warned_cfg) { \ av_log(NULL, level, \ "%sWARNING: library configuration mismatch\n", \ @@ -1096,94 +809,44 @@ static int warned_cfg = 0; static void print_all_libs_info(int flags, int level) { - PRINT_LIB_INFO(avutil, AVUTIL, flags, level); - PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); - PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); - PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); - PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); + PRINT_LIB_INFO(avutil, AVUTIL, flags, level); + PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); + PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); + PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); + PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level); - PRINT_LIB_INFO(swscale, SWSCALE, flags, level); - PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); - PRINT_LIB_INFO(postproc, POSTPROC, flags, level); + PRINT_LIB_INFO(swscale, SWSCALE, flags, level); } -static void print_program_info(int flags, int level) +void show_banner(void) { - const char *indent = flags & INDENT? " " : ""; - - av_log(NULL, level, "%s version " FFMPEG_VERSION, program_name); - if (flags & SHOW_COPYRIGHT) - av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers", - program_birth_year, CONFIG_THIS_YEAR); - av_log(NULL, level, "\n"); - av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT); - - av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent); -} - -static void print_buildconf(int flags, int level) -{ - const char *indent = flags & INDENT ? " " : ""; - char str[] = { FFMPEG_CONFIGURATION }; - char *conflist, *remove_tilde, *splitconf; - - // Change all the ' --' strings to '~--' so that - // they can be identified as tokens. - while ((conflist = strstr(str, " --")) != NULL) { - strncpy(conflist, "~--", 3); - } - - // Compensate for the weirdness this would cause - // when passing 'pkg-config --static'. - while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { - strncpy(remove_tilde, "pkg-config ", 11); - } - - splitconf = strtok(str, "~"); - av_log(NULL, level, "\n%sconfiguration:\n", indent); - while (splitconf != NULL) { - av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf); - splitconf = strtok(NULL, "~"); - } -} - -void show_banner(int argc, char **argv, const OptionDef *options) -{ - int idx = locate_option(argc, argv, options, "version"); - if (hide_banner || idx) - return; - - print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO); - print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_INFO); - print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_INFO); + av_log(NULL, AV_LOG_INFO, + "%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n", + program_name, program_birth_year, this_year); + av_log(NULL, AV_LOG_INFO, " built on %s %s with %s\n", + __DATE__, __TIME__, CC_IDENT); + av_log(NULL, AV_LOG_VERBOSE, " configuration: " LIBAV_CONFIGURATION "\n"); + print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_VERBOSE); + print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_VERBOSE); } int show_version(void *optctx, const char *opt, const char *arg) { av_log_set_callback(log_callback_help); - print_program_info (SHOW_COPYRIGHT, AV_LOG_INFO); + printf("%s " LIBAV_VERSION "\n", program_name); print_all_libs_info(SHOW_VERSION, AV_LOG_INFO); return 0; } -int show_buildconf(void *optctx, const char *opt, const char *arg) -{ - av_log_set_callback(log_callback_help); - print_buildconf (INDENT|0, AV_LOG_INFO); - - return 0; -} - int show_license(void *optctx, const char *opt, const char *arg) { -#if CONFIG_NONFREE printf( +#if CONFIG_NONFREE "This version of %s has nonfree parts compiled in.\n" "Therefore it is not legally redistributable.\n", - program_name ); + program_name #elif CONFIG_GPLV3 - printf( "%s is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation; either version 3 of the License, or\n" @@ -1196,9 +859,8 @@ int show_license(void *optctx, const char *opt, const char *arg) "\n" "You should have received a copy of the GNU General Public License\n" "along with %s. If not, see .\n", - program_name, program_name, program_name ); + program_name, program_name, program_name #elif CONFIG_GPL - printf( "%s is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation; either version 2 of the License, or\n" @@ -1212,9 +874,8 @@ int show_license(void *optctx, const char *opt, const char *arg) "You should have received a copy of the GNU General Public License\n" "along with %s; if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n", - program_name, program_name, program_name ); + program_name, program_name, program_name #elif CONFIG_LGPLV3 - printf( "%s is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU Lesser General Public License as published by\n" "the Free Software Foundation; either version 3 of the License, or\n" @@ -1227,9 +888,8 @@ int show_license(void *optctx, const char *opt, const char *arg) "\n" "You should have received a copy of the GNU Lesser General Public License\n" "along with %s. If not, see .\n", - program_name, program_name, program_name ); + program_name, program_name, program_name #else - printf( "%s is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" @@ -1243,30 +903,23 @@ int show_license(void *optctx, const char *opt, const char *arg) "You should have received a copy of the GNU Lesser General Public\n" "License along with %s; if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n", - program_name, program_name, program_name ); + program_name, program_name, program_name #endif + ); return 0; } -static int is_device(const AVClass *avclass) -{ - if (!avclass) - return 0; - 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) +int show_formats(void *optctx, const char *opt, const char *arg) { AVInputFormat *ifmt = NULL; AVOutputFormat *ofmt = NULL; const char *last_name; - int is_dev; - printf("%s\n" + printf("File formats:\n" " D. = Demuxing supported\n" " .E = Muxing supported\n" - " --\n", device_only ? "Devices:" : "File formats:"); + " --\n"); last_name = "000"; for (;;) { int decode = 0; @@ -1274,33 +927,23 @@ 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))) { + 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))) { + 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; @@ -1315,29 +958,9 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg, return 0; } -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); -} - -int show_devices(void *optctx, const char *opt, const char *arg) -{ - return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT); -} - #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ if (codec->field) { \ - const type *p = codec->field; \ + const type *p = c->field; \ \ printf(" Supported " list_name ":"); \ while (*p != term) { \ @@ -1384,8 +1007,7 @@ static void print_codec(const AVCodec *c) printf("none"); printf("\n"); - if (c->type == AVMEDIA_TYPE_VIDEO || - c->type == AVMEDIA_TYPE_AUDIO) { + if (c->type == AVMEDIA_TYPE_VIDEO) { printf(" Threading capabilities: "); switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS | @@ -1431,9 +1053,7 @@ static char get_media_type_char(enum AVMediaType type) switch (type) { case AVMEDIA_TYPE_VIDEO: return 'V'; case AVMEDIA_TYPE_AUDIO: return 'A'; - case AVMEDIA_TYPE_DATA: return 'D'; case AVMEDIA_TYPE_SUBTITLE: return 'S'; - case AVMEDIA_TYPE_ATTACHMENT:return 'T'; default: return '?'; } } @@ -1449,36 +1069,6 @@ static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, return NULL; } -static int compare_codec_desc(const void *a, const void *b) -{ - const AVCodecDescriptor * const *da = a; - const AVCodecDescriptor * const *db = b; - - return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) : - strcmp((*da)->name, (*db)->name); -} - -static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) -{ - const AVCodecDescriptor *desc = NULL; - const AVCodecDescriptor **codecs; - unsigned nb_codecs = 0, i = 0; - - while ((desc = avcodec_descriptor_next(desc))) - nb_codecs++; - if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) { - av_log(NULL, AV_LOG_ERROR, "Out of memory\n"); - exit_program(1); - } - desc = NULL; - while ((desc = avcodec_descriptor_next(desc))) - codecs[i++] = desc; - av_assert0(i == nb_codecs); - qsort(codecs, nb_codecs, sizeof(*codecs), compare_codec_desc); - *rcodecs = codecs; - return nb_codecs; -} - static void print_codecs_for_id(enum AVCodecID id, int encoder) { const AVCodec *codec = NULL; @@ -1493,8 +1083,7 @@ static void print_codecs_for_id(enum AVCodecID id, int encoder) int show_codecs(void *optctx, const char *opt, const char *arg) { - const AVCodecDescriptor **codecs; - unsigned i, nb_codecs = get_codecs_sorted(&codecs); + const AVCodecDescriptor *desc = NULL; printf("Codecs:\n" " D..... = Decoding supported\n" @@ -1506,14 +1095,9 @@ int show_codecs(void *optctx, const char *opt, const char *arg) " ....L. = Lossy compression\n" " .....S = Lossless compression\n" " -------\n"); - for (i = 0; i < nb_codecs; i++) { - const AVCodecDescriptor *desc = codecs[i]; + while ((desc = avcodec_descriptor_next(desc))) { const AVCodec *codec = NULL; - if (strstr(desc->name, "_deprecated")) - continue; - - printf(" "); printf(avcodec_find_decoder(desc->id) ? "D" : "."); printf(avcodec_find_encoder(desc->id) ? "E" : "."); @@ -1542,37 +1126,30 @@ int show_codecs(void *optctx, const char *opt, const char *arg) printf("\n"); } - av_free(codecs); return 0; } static void print_codecs(int encoder) { - const AVCodecDescriptor **codecs; - unsigned i, nb_codecs = get_codecs_sorted(&codecs); + const AVCodecDescriptor *desc = NULL; printf("%s:\n" - " V..... = Video\n" - " A..... = Audio\n" - " S..... = Subtitle\n" - " .F.... = Frame-level multithreading\n" - " ..S... = Slice-level multithreading\n" - " ...X.. = Codec is experimental\n" - " ....B. = Supports draw_horiz_band\n" - " .....D = Supports direct rendering method 1\n" - " ------\n", + " V... = Video\n" + " A... = Audio\n" + " S... = Subtitle\n" + " .F.. = Frame-level multithreading\n" + " ..S. = Slice-level multithreading\n" + " ...X = Codec is experimental\n" + " ---\n", encoder ? "Encoders" : "Decoders"); - for (i = 0; i < nb_codecs; i++) { - const AVCodecDescriptor *desc = codecs[i]; + while ((desc = avcodec_descriptor_next(desc))) { const AVCodec *codec = NULL; while ((codec = next_codec_for_id(desc->id, codec, encoder))) { - printf(" %c", get_media_type_char(desc->type)); + printf("%c", get_media_type_char(desc->type)); printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : "."); - printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); - printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : "."); printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : ""); if (strcmp(codec->name, desc->name)) @@ -1581,7 +1158,6 @@ static void print_codecs(int encoder) printf("\n"); } } - av_free(codecs); } int show_decoders(void *optctx, const char *opt, const char *arg) @@ -1616,10 +1192,10 @@ int show_protocols(void *optctx, const char *opt, const char *arg) printf("Supported file protocols:\n" "Input:\n"); while ((name = avio_enum_protocols(&opaque, 0))) - printf(" %s\n", name); + printf("%s\n", name); printf("Output:\n"); while ((name = avio_enum_protocols(&opaque, 1))) - printf(" %s\n", name); + printf("%s\n", name); return 0; } @@ -1627,62 +1203,16 @@ int show_filters(void *optctx, const char *opt, const char *arg) { #if CONFIG_AVFILTER const AVFilter *filter = NULL; - char descr[64], *descr_cur; - int i, j; - const AVFilterPad *pad; - printf("Filters:\n" - " T.. = Timeline support\n" - " .S. = Slice threading\n" - " ..C = Command support\n" - " A = Audio input/output\n" - " V = Video input/output\n" - " N = Dynamic number and/or type of input/output\n" - " | = Source or sink filter\n"); - while ((filter = avfilter_next(filter))) { - descr_cur = descr; - for (i = 0; i < 2; i++) { - if (i) { - *(descr_cur++) = '-'; - *(descr_cur++) = '>'; - } - pad = i ? filter->outputs : filter->inputs; - for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) { - if (descr_cur >= descr + sizeof(descr) - 4) - break; - *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j)); - } - if (!j) - *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) || - ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|'; - } - *descr_cur = 0; - printf(" %c%c%c %-17s %-10s %s\n", - filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.', - filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.', - filter->process_command ? 'C' : '.', - filter->name, descr, filter->description); - } + printf("Filters:\n"); + while ((filter = avfilter_next(filter))) + printf("%-16s %s\n", filter->name, filter->description); #else printf("No filters available: libavfilter disabled\n"); #endif return 0; } -int show_colors(void *optctx, const char *opt, const char *arg) -{ - const char *name; - const uint8_t *rgb; - int i; - - printf("%-32s #RRGGBB\n", "name"); - - for (i = 0; name = av_get_known_color_name(i, &rgb); i++) - printf("%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]); - - return 0; -} - int show_pix_fmts(void *optctx, const char *opt, const char *arg) { const AVPixFmtDescriptor *pix_desc = NULL; @@ -1702,7 +1232,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg) #endif while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) { - enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc); + enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc); printf("%c%c%c%c%c %-16s %d %2d\n", sws_isSupportedInput (pix_fmt) ? 'I' : '.', sws_isSupportedOutput(pix_fmt) ? 'O' : '.', @@ -1716,35 +1246,6 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg) return 0; } -int show_layouts(void *optctx, const char *opt, const char *arg) -{ - int i = 0; - uint64_t layout, j; - const char *name, *descr; - - printf("Individual channels:\n" - "NAME DESCRIPTION\n"); - for (i = 0; i < 63; i++) { - name = av_get_channel_name((uint64_t)1 << i); - if (!name) - continue; - descr = av_get_channel_description((uint64_t)1 << i); - printf("%-14s %s\n", name, descr); - } - printf("\nStandard channel layouts:\n" - "NAME DECOMPOSITION\n"); - for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) { - if (name) { - printf("%-14s ", name); - for (j = 1; j; j <<= 1) - if ((layout & j)) - printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j)); - printf("\n"); - } - } - return 0; -} - int show_sample_fmts(void *optctx, const char *opt, const char *arg) { int i; @@ -1778,13 +1279,13 @@ static void show_help_codec(const char *name, int encoder) } if (!printed) { - av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, " - "but no %s for it are available. FFmpeg might need to be " + av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to Libav, " + "but no %s for it are available. Libav might need to be " "recompiled with additional external libraries.\n", name, encoder ? "encoders" : "decoders"); } } else { - av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n", + av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by Libav.\n", name); } } @@ -1843,7 +1344,6 @@ static void show_help_muxer(const char *name) #if CONFIG_AVFILTER static void show_help_filter(const char *name) { -#if CONFIG_AVFILTER const AVFilter *f = avfilter_get_by_name(name); int i, count; @@ -1855,9 +1355,7 @@ static void show_help_filter(const char *name) return; } - printf("Filter %s\n", f->name); - if (f->description) - printf(" %s\n", f->description); + printf("Filter %s [%s]:\n", f->name, f->description); if (f->flags & AVFILTER_FLAG_SLICE_THREADS) printf(" slice threading supported\n"); @@ -1865,34 +1363,24 @@ static void show_help_filter(const char *name) printf(" Inputs:\n"); count = avfilter_pad_count(f->inputs); for (i = 0; i < count; i++) { - printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), + printf(" %d %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), media_type_string(avfilter_pad_get_type(f->inputs, i))); } if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) printf(" dynamic (depending on the options)\n"); - else if (!count) - printf(" none (source filter)\n"); printf(" Outputs:\n"); count = avfilter_pad_count(f->outputs); for (i = 0; i < count; i++) { - printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), + printf(" %d %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), media_type_string(avfilter_pad_get_type(f->outputs, i))); } if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) printf(" dynamic (depending on the options)\n"); - else if (!count) - printf(" none (sink filter)\n"); if (f->priv_class) - show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | + show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM); - if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) - printf("This filter has support for timeline through the 'enable' option.\n"); -#else - av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; " - "can not to satisfy request\n"); -#endif } #endif @@ -1941,47 +1429,58 @@ int read_yesno(void) return yesno; } +void init_pts_correction(PtsCorrectionContext *ctx) +{ + ctx->num_faulty_pts = ctx->num_faulty_dts = 0; + ctx->last_pts = ctx->last_dts = INT64_MIN; +} + +int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, + int64_t dts) +{ + int64_t pts = AV_NOPTS_VALUE; + + if (dts != AV_NOPTS_VALUE) { + ctx->num_faulty_dts += dts <= ctx->last_dts; + ctx->last_dts = dts; + } + if (reordered_pts != AV_NOPTS_VALUE) { + ctx->num_faulty_pts += reordered_pts <= ctx->last_pts; + ctx->last_pts = reordered_pts; + } + if ((ctx->num_faulty_pts<=ctx->num_faulty_dts || dts == AV_NOPTS_VALUE) + && reordered_pts != AV_NOPTS_VALUE) + pts = reordered_pts; + else + pts = dts; + + return pts; +} + FILE *get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name) { FILE *f = NULL; int i; - const char *base[3] = { getenv("FFMPEG_DATADIR"), + const char *base[3] = { getenv("AVCONV_DATADIR"), getenv("HOME"), - FFMPEG_DATADIR, }; + AVCONV_DATADIR, }; if (is_path) { av_strlcpy(filename, preset_name, filename_size); f = fopen(filename, "r"); } else { -#ifdef _WIN32 - char datadir[MAX_PATH], *ls; - base[2] = NULL; - - if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1)) - { - for (ls = datadir; ls < datadir + strlen(datadir); ls++) - if (*ls == '\\') *ls = '/'; - - if (ls = strrchr(datadir, '/')) - { - *ls = 0; - strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir)); - base[2] = datadir; - } - } -#endif for (i = 0; i < 3 && !f; i++) { if (!base[i]) continue; - snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], - i != 1 ? "" : "/.ffmpeg", preset_name); + snprintf(filename, filename_size, "%s%s/%s.avpreset", base[i], + i != 1 ? "" : "/.avconv", preset_name); f = fopen(filename, "r"); if (!f && codec_name) { snprintf(filename, filename_size, - "%s%s/%s-%s.ffpreset", - base[i], i != 1 ? "" : "/.ffmpeg", codec_name, + "%s%s/%s-%s.avpreset", + base[i], i != 1 ? "" : "/.avconv", codec_name, preset_name); f = fopen(filename, "r"); } @@ -1993,10 +1492,107 @@ FILE *get_preset_file(char *filename, size_t filename_size, int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) { - int ret = avformat_match_stream_specifier(s, st, spec); - if (ret < 0) - av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec); - return ret; + if (*spec <= '9' && *spec >= '0') /* opt:index */ + return strtol(spec, NULL, 0) == st->index; + else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' || + *spec == 't') { /* opt:[vasdt] */ + enum AVMediaType type; + + switch (*spec++) { + case 'v': type = AVMEDIA_TYPE_VIDEO; break; + case 'a': type = AVMEDIA_TYPE_AUDIO; break; + case 's': type = AVMEDIA_TYPE_SUBTITLE; break; + case 'd': type = AVMEDIA_TYPE_DATA; break; + case 't': type = AVMEDIA_TYPE_ATTACHMENT; break; + default: av_assert0(0); + } + if (type != st->codecpar->codec_type) + return 0; + if (*spec++ == ':') { /* possibly followed by :index */ + int i, index = strtol(spec, NULL, 0); + for (i = 0; i < s->nb_streams; i++) + if (s->streams[i]->codecpar->codec_type == type && index-- == 0) + return i == st->index; + return 0; + } + return 1; + } else if (*spec == 'p' && *(spec + 1) == ':') { + int prog_id, i, j; + char *endptr; + spec += 2; + prog_id = strtol(spec, &endptr, 0); + for (i = 0; i < s->nb_programs; i++) { + if (s->programs[i]->id != prog_id) + continue; + + if (*endptr++ == ':') { + int stream_idx = strtol(endptr, NULL, 0); + return stream_idx >= 0 && + stream_idx < s->programs[i]->nb_stream_indexes && + st->index == s->programs[i]->stream_index[stream_idx]; + } + + for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) + if (st->index == s->programs[i]->stream_index[j]) + return 1; + } + return 0; + } else if (*spec == 'i' && *(spec + 1) == ':') { + int stream_id; + char *endptr; + spec += 2; + stream_id = strtol(spec, &endptr, 0); + return stream_id == st->id; + } else if (*spec == 'm' && *(spec + 1) == ':') { + AVDictionaryEntry *tag; + char *key, *val; + int ret; + + spec += 2; + val = strchr(spec, ':'); + + key = val ? av_strndup(spec, val - spec) : av_strdup(spec); + if (!key) + return AVERROR(ENOMEM); + + tag = av_dict_get(st->metadata, key, NULL, 0); + if (tag) { + if (!val || !strcmp(tag->value, val + 1)) + ret = 1; + else + ret = 0; + } else + ret = 0; + + av_freep(&key); + return ret; + } else if (*spec == 'u') { + AVCodecParameters *par = st->codecpar; + int val; + switch (par->codec_type) { + case AVMEDIA_TYPE_AUDIO: + val = par->sample_rate && par->channels; + if (par->format == AV_SAMPLE_FMT_NONE) + return 0; + break; + case AVMEDIA_TYPE_VIDEO: + val = par->width && par->height; + if (par->format == AV_PIX_FMT_NONE) + return 0; + break; + case AVMEDIA_TYPE_UNKNOWN: + val = 0; + break; + default: + val = 1; + break; + } + return par->codec_id != AV_CODEC_ID_NONE && val != 0; + } else if (!*spec) /* empty specifier, matches everything */ + return 1; + + av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec); + return AVERROR(EINVAL); } AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, @@ -2036,12 +1632,11 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, switch (check_stream_specifier(s, st, p + 1)) { case 1: *p = 0; break; case 0: continue; - default: exit_program(1); + default: return NULL; } if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) || - !codec || - (codec->priv_class && + (codec && codec->priv_class && av_opt_find(&codec->priv_class, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ))) av_dict_set(&ret, t->key, t->value, 0); @@ -2064,7 +1659,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, if (!s->nb_streams) return NULL; - opts = av_mallocz_array(s->nb_streams, sizeof(*opts)); + opts = av_mallocz(s->nb_streams * sizeof(*opts)); if (!opts) { av_log(NULL, AV_LOG_ERROR, "Could not alloc memory for stream options.\n"); @@ -2083,7 +1678,7 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) exit_program(1); } if (*size < new_size) { - uint8_t *tmp = av_realloc_array(array, new_size, elem_size); + uint8_t *tmp = av_realloc(array, new_size*elem_size); if (!tmp) { av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n"); exit_program(1); @@ -2095,180 +1690,14 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) return array; } -double get_rotation(AVStream *st) +const char *media_type_string(enum AVMediaType media_type) { - uint8_t* displaymatrix = av_stream_get_side_data(st, - AV_PKT_DATA_DISPLAYMATRIX, NULL); - double theta = 0; - if (displaymatrix) - theta = -av_display_rotation_get((int32_t*) displaymatrix); - - theta -= 360*floor(theta/360 + 0.9/360); - - if (fabs(theta - 90*round(theta/90)) > 2) - av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n" - "If you want to help, upload a sample " - "of this file to ftp://upload.ffmpeg.org/incoming/ " - "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)"); - - return theta; -} - -#if CONFIG_AVDEVICE -static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) -{ - int ret, i; - AVDeviceInfoList *device_list = NULL; - - if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) - return AVERROR(EINVAL); - - printf("Auto-detected sources for %s:\n", fmt->name); - if (!fmt->get_device_list) { - ret = AVERROR(ENOSYS); - printf("Cannot list sources. Not implemented.\n"); - goto fail; + switch (media_type) { + case AVMEDIA_TYPE_VIDEO: return "video"; + case AVMEDIA_TYPE_AUDIO: return "audio"; + case AVMEDIA_TYPE_DATA: return "data"; + case AVMEDIA_TYPE_SUBTITLE: return "subtitle"; + case AVMEDIA_TYPE_ATTACHMENT: return "attachment"; + default: return "unknown"; } - - if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) { - printf("Cannot list sources.\n"); - goto fail; - } - - for (i = 0; i < device_list->nb_devices; i++) { - printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", - device_list->devices[i]->device_name, device_list->devices[i]->device_description); - } - - fail: - avdevice_free_list_devices(&device_list); - return ret; } - -static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts) -{ - int ret, i; - AVDeviceInfoList *device_list = NULL; - - if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) - return AVERROR(EINVAL); - - printf("Auto-detected sinks for %s:\n", fmt->name); - if (!fmt->get_device_list) { - ret = AVERROR(ENOSYS); - printf("Cannot list sinks. Not implemented.\n"); - goto fail; - } - - if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) { - printf("Cannot list sinks.\n"); - goto fail; - } - - for (i = 0; i < device_list->nb_devices; i++) { - printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", - device_list->devices[i]->device_name, device_list->devices[i]->device_description); - } - - fail: - avdevice_free_list_devices(&device_list); - return ret; -} - -static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionary **opts) -{ - int ret; - if (arg) { - char *opts_str = NULL; - av_assert0(dev && opts); - *dev = av_strdup(arg); - if (!*dev) - return AVERROR(ENOMEM); - if ((opts_str = strchr(*dev, ','))) { - *(opts_str++) = '\0'; - if (opts_str[0] && ((ret = av_dict_parse_string(opts, opts_str, "=", ":", 0)) < 0)) { - av_freep(dev); - return ret; - } - } - } else - printf("\nDevice name is not provided.\n" - "You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n"); - return 0; -} - -int show_sources(void *optctx, const char *opt, const char *arg) -{ - AVInputFormat *fmt = NULL; - char *dev = NULL; - AVDictionary *opts = NULL; - int ret = 0; - int error_level = av_log_get_level(); - - av_log_set_level(AV_LOG_ERROR); - - if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) - goto fail; - - do { - fmt = av_input_audio_device_next(fmt); - if (fmt) { - if (!strcmp(fmt->name, "lavfi")) - continue; //it's pointless to probe lavfi - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sources(fmt, opts); - } - } while (fmt); - do { - fmt = av_input_video_device_next(fmt); - if (fmt) { - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sources(fmt, opts); - } - } while (fmt); - fail: - av_dict_free(&opts); - av_free(dev); - av_log_set_level(error_level); - return ret; -} - -int show_sinks(void *optctx, const char *opt, const char *arg) -{ - AVOutputFormat *fmt = NULL; - char *dev = NULL; - AVDictionary *opts = NULL; - int ret = 0; - int error_level = av_log_get_level(); - - av_log_set_level(AV_LOG_ERROR); - - if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) - goto fail; - - do { - fmt = av_output_audio_device_next(fmt); - if (fmt) { - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sinks(fmt, opts); - } - } while (fmt); - do { - fmt = av_output_video_device_next(fmt); - if (fmt) { - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sinks(fmt, opts); - } - } while (fmt); - fail: - av_dict_free(&opts); - av_free(dev); - av_log_set_level(error_level); - return ret; -} - -#endif diff --git a/cmdutils.h b/avtools/cmdutils.h similarity index 71% rename from cmdutils.h rename to avtools/cmdutils.h index e1d64d8986..cc78ac5911 100644 --- a/cmdutils.h +++ b/avtools/cmdutils.h @@ -2,38 +2,33 @@ * Various utilities for command line tools * copyright (c) 2003 Fabrice Bellard * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef CMDUTILS_H -#define CMDUTILS_H +#ifndef LIBAV_CMDUTILS_H +#define LIBAV_CMDUTILS_H #include -#include "config.h" #include "libavcodec/avcodec.h" #include "libavfilter/avfilter.h" #include "libavformat/avformat.h" #include "libswscale/swscale.h" -#ifdef _WIN32 -#undef main /* We don't want SDL to override our main() */ -#endif - /** * program name, defined by the program for show_version(). */ @@ -46,10 +41,8 @@ extern const int program_birth_year; extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; extern AVFormatContext *avformat_opts; -extern AVDictionary *sws_dict; -extern AVDictionary *swr_opts; +extern struct SwsContext *sws_opts; extern AVDictionary *format_opts, *codec_opts, *resample_opts; -extern int hide_banner; /** * Register a program-specific cleanup routine. @@ -61,11 +54,6 @@ void register_exit(void (*cb)(int ret)); */ void exit_program(int ret) av_noreturn; -/** - * Initialize dynamic library loading - */ -void init_dynload(void); - /** * Initialize the cmdutils option system, in particular * allocate the *_opts contexts. @@ -79,12 +67,12 @@ void uninit_opts(void); /** * Trivial log callback. - * Only suitable for opt_help and similar since it lacks prefix handling. + * Only suitable for show_help and similar since it lacks prefix handling. */ void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); /** - * Override the cpuflags. + * Override the cpuflags mask. */ int opt_cpuflags(void *optctx, const char *opt, const char *arg); @@ -99,18 +87,6 @@ int opt_default(void *optctx, const char *opt, const char *arg); */ int opt_loglevel(void *optctx, const char *opt, const char *arg); -int opt_report(const char *opt); - -int opt_max_alloc(void *optctx, const char *opt, const char *arg); - -int opt_codec_debug(void *optctx, const char *opt, const char *arg); - -#if CONFIG_OPENCL -int opt_opencl(void *optctx, const char *opt, const char *arg); - -int opt_opencl_bench(void *optctx, const char *opt, const char *arg); -#endif - /** * Limit the execution time. */ @@ -144,7 +120,7 @@ double parse_number_or_die(const char *context, const char *numstr, int type, * not zero timestr is interpreted as a duration, otherwise as a * date * - * @see av_parse_time() + * @see parse_date() */ int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration); @@ -175,7 +151,7 @@ typedef struct OptionDef { #define OPT_INT64 0x0400 #define OPT_EXIT 0x0800 #define OPT_DATA 0x1000 -#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only). +#define OPT_PERFILE 0x2000 /* the option is per-file (currently avconv-only). implied by OPT_OFFSET or OPT_SPEC */ #define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */ #define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt. @@ -206,28 +182,6 @@ typedef struct OptionDef { void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags); -#if CONFIG_OPENCL -#define CMDUTILS_COMMON_OPTIONS_OPENCL \ - { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, \ - "run benchmark on all OpenCL devices and show results" }, \ - { "opencl_options", HAS_ARG, {.func_arg = opt_opencl}, \ - "set OpenCL environment options" }, \ - -#else -#define CMDUTILS_COMMON_OPTIONS_OPENCL -#endif - -#if CONFIG_AVDEVICE -#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \ - { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \ - "list sources of the input device", "device" }, \ - { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \ - "list sinks of the output device", "device" }, \ - -#else -#define CMDUTILS_COMMON_OPTIONS_AVDEVICE -#endif - #define CMDUTILS_COMMON_OPTIONS \ { "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \ { "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ @@ -235,11 +189,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, { "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ { "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ { "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \ - { "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \ { "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \ - { "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \ - { "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \ - { "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \ { "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \ { "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \ { "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \ @@ -247,17 +197,10 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, { "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \ { "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \ { "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \ - { "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \ { "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \ - { "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \ - { "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \ - { "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \ - { "report", 0, { (void*)opt_report }, "generate a report" }, \ - { "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \ - { "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \ - { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \ - CMDUTILS_COMMON_OPTIONS_OPENCL \ - CMDUTILS_COMMON_OPTIONS_AVDEVICE \ + { "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set libav* logging level", "loglevel" }, \ + { "v", HAS_ARG, { .func_arg = opt_loglevel }, "set libav* logging level", "loglevel" }, \ + { "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "set CPU flags mask", "mask" }, \ /** * Show help for all options with given flags in class and all its @@ -266,13 +209,13 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, void show_help_children(const AVClass *class, int flags); /** - * Per-fftool specific help handler. Implemented in each - * fftool, called by show_help(). + * Per-avtool specific help handler. Implemented in each + * avtool, called by show_help(). */ void show_help_default(const char *opt, const char *arg); /** - * Generic -h handler common to all fftools. + * Generic -h handler common to all avtools. */ int show_help(void *optctx, const char *opt, const char *arg); @@ -315,7 +258,7 @@ typedef struct OptionGroupDef { const char *name; /** * Option to be used as group separator. Can be NULL for groups which - * are terminated by a non-option argument (e.g. ffmpeg output files) + * are terminated by a non-option argument (e.g. avconv output files) */ const char *sep; /** @@ -335,8 +278,7 @@ typedef struct OptionGroup { AVDictionary *codec_opts; AVDictionary *format_opts; AVDictionary *resample_opts; - AVDictionary *sws_dict; - AVDictionary *swr_opts; + struct SwsContext *sws_opts; } OptionGroup; /** @@ -463,76 +405,30 @@ void print_error(const char *filename, int err); * current version of the repository and of the libav* libraries used by * the program. */ -void show_banner(int argc, char **argv, const OptionDef *options); +void show_banner(void); /** * Print the version of the program to stdout. The version message * depends on the current versions of the repository and of the libav* * libraries. - * This option processing function does not utilize the arguments. */ int show_version(void *optctx, const char *opt, const char *arg); -/** - * Print the build configuration of the program to stdout. The contents - * depend on the definition of FFMPEG_CONFIGURATION. - * This option processing function does not utilize the arguments. - */ -int show_buildconf(void *optctx, const char *opt, const char *arg); - /** * Print the license of the program to stdout. The license depends on * the license of the libraries compiled into the program. - * This option processing function does not utilize the arguments. */ int show_license(void *optctx, const char *opt, const char *arg); /** * Print a listing containing all the formats supported by the - * program (including devices). - * This option processing function does not utilize the arguments. + * program. */ 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. - * This option processing function does not utilize the arguments. - */ -int show_devices(void *optctx, const char *opt, const char *arg); - -#if CONFIG_AVDEVICE -/** - * Print a listing containing autodetected sinks of the output device. - * Device name with options may be passed as an argument to limit results. - */ -int show_sinks(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing autodetected sources of the input device. - * Device name with options may be passed as an argument to limit results. - */ -int show_sources(void *optctx, const char *opt, const char *arg); -#endif - /** * Print a listing containing all the codecs supported by the * program. - * This option processing function does not utilize the arguments. */ int show_codecs(void *optctx, const char *opt, const char *arg); @@ -551,64 +447,71 @@ int show_encoders(void *optctx, const char *opt, const char *arg); /** * Print a listing containing all the filters supported by the * program. - * This option processing function does not utilize the arguments. */ int show_filters(void *optctx, const char *opt, const char *arg); /** * Print a listing containing all the bit stream filters supported by the * program. - * This option processing function does not utilize the arguments. */ int show_bsfs(void *optctx, const char *opt, const char *arg); /** * Print a listing containing all the protocols supported by the * program. - * This option processing function does not utilize the arguments. */ int show_protocols(void *optctx, const char *opt, const char *arg); /** * Print a listing containing all the pixel formats supported by the * program. - * This option processing function does not utilize the arguments. */ int show_pix_fmts(void *optctx, const char *opt, const char *arg); -/** - * Print a listing containing all the standard channel layouts supported by - * the program. - * This option processing function does not utilize the arguments. - */ -int show_layouts(void *optctx, const char *opt, const char *arg); - /** * Print a listing containing all the sample formats supported by the * program. */ int show_sample_fmts(void *optctx, const char *opt, const char *arg); -/** - * Print a listing containing all the color names and values recognized - * by the program. - */ -int show_colors(void *optctx, const char *opt, const char *arg); - /** * Return a positive value if a line read from standard input * starts with [yY], otherwise return 0. */ int read_yesno(void); +typedef struct PtsCorrectionContext { + int64_t num_faulty_pts; /// Number of incorrect PTS values so far + int64_t num_faulty_dts; /// Number of incorrect DTS values so far + int64_t last_pts; /// PTS of the last frame + int64_t last_dts; /// DTS of the last frame +} PtsCorrectionContext; + +/** + * Reset the state of the PtsCorrectionContext. + */ +void init_pts_correction(PtsCorrectionContext *ctx); + +/** + * Attempt to guess proper monotonic timestamps for decoded video frames + * which might have incorrect times. Input timestamps may wrap around, in + * which case the output will as well. + * + * @param ctx the PtsCorrectionContext carrying stream pts information + * @param pts the pts field of the decoded AVPacket, as passed through + * AVCodecContext.reordered_opaque + * @param dts the dts field of the decoded AVPacket + * @return one of the input values, may be AV_NOPTS_VALUE + */ +int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts); + /** * Get a file corresponding to a preset file. * * If is_path is non-zero, look for the file in the path preset_name. - * Otherwise search for a file named arg.ffpreset in the directories - * $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined - * at configuration time or in a "ffpresets" folder along the executable - * on win32, in that order. If no such file is found and + * Otherwise search for a file named arg.avpreset in the directories + * $AVCONV_DATADIR (if set), $HOME/.avconv, and in the datadir defined + * at configuration time, in that order. If no such file is found and * codec_name is defined, then search for a file named * codec_name-preset_name.avpreset in the above-mentioned directories. * @@ -634,7 +537,10 @@ FILE *get_preset_file(char *filename, size_t filename_size, */ void *grow_array(void *array, int elem_size, int *size, int new_size); -#define media_type_string av_get_media_type_string +/** + * Get a string describing a media type. + */ +const char *media_type_string(enum AVMediaType media_type); #define GROW_ARRAY(array, nb_elems)\ array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1) @@ -657,6 +563,4 @@ void *grow_array(void *array, int elem_size, int *size, int new_size); char name[128];\ av_get_channel_layout_string(name, sizeof(name), 0, ch_layout); -double get_rotation(AVStream *st); - -#endif /* CMDUTILS_H */ +#endif /* LIBAV_CMDUTILS_H */ diff --git a/cmdutils_opencl.c b/cmdutils_opencl.c deleted file mode 100644 index 906aef4836..0000000000 --- a/cmdutils_opencl.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (C) 2013 Lenny Wang - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/opt.h" -#include "libavutil/time.h" -#include "libavutil/log.h" -#include "libavutil/opencl.h" -#include "libavutil/avstring.h" -#include "cmdutils.h" - -typedef struct { - int platform_idx; - int device_idx; - char device_name[64]; - int64_t runtime; -} OpenCLDeviceBenchmark; - -const char *ocl_bench_source = AV_OPENCL_KERNEL( -inline unsigned char clip_uint8(int a) -{ - if (a & (~0xFF)) - return (-a)>>31; - else - return a; -} - -kernel void unsharp_bench( - global unsigned char *src, - global unsigned char *dst, - global int *mask, - int width, - int height) -{ - int i, j, local_idx, lc_idx, sum = 0; - int2 thread_idx, block_idx, global_idx, lm_idx; - thread_idx.x = get_local_id(0); - thread_idx.y = get_local_id(1); - block_idx.x = get_group_id(0); - block_idx.y = get_group_id(1); - global_idx.x = get_global_id(0); - global_idx.y = get_global_id(1); - local uchar data[32][32]; - local int lc[128]; - - for (i = 0; i <= 1; i++) { - lm_idx.y = -8 + (block_idx.y + i) * 16 + thread_idx.y; - lm_idx.y = lm_idx.y < 0 ? 0 : lm_idx.y; - lm_idx.y = lm_idx.y >= height ? height - 1: lm_idx.y; - for (j = 0; j <= 1; j++) { - lm_idx.x = -8 + (block_idx.x + j) * 16 + thread_idx.x; - lm_idx.x = lm_idx.x < 0 ? 0 : lm_idx.x; - lm_idx.x = lm_idx.x >= width ? width - 1: lm_idx.x; - data[i*16 + thread_idx.y][j*16 + thread_idx.x] = src[lm_idx.y*width + lm_idx.x]; - } - } - local_idx = thread_idx.y*16 + thread_idx.x; - if (local_idx < 128) - lc[local_idx] = mask[local_idx]; - barrier(CLK_LOCAL_MEM_FENCE); - - \n#pragma unroll\n - for (i = -4; i <= 4; i++) { - lm_idx.y = 8 + i + thread_idx.y; - \n#pragma unroll\n - for (j = -4; j <= 4; j++) { - lm_idx.x = 8 + j + thread_idx.x; - lc_idx = (i + 4)*8 + j + 4; - sum += (int)data[lm_idx.y][lm_idx.x] * lc[lc_idx]; - } - } - int temp = (int)data[thread_idx.y + 8][thread_idx.x + 8]; - int res = temp + (((temp - (int)((sum + 1<<15) >> 16))) >> 16); - if (global_idx.x < width && global_idx.y < height) - dst[global_idx.x + global_idx.y*width] = clip_uint8(res); -} -); - -#define OCLCHECK(method, ... ) \ -do { \ - status = method(__VA_ARGS__); \ - if (status != CL_SUCCESS) { \ - av_log(NULL, AV_LOG_ERROR, # method " error '%s'\n", \ - av_opencl_errstr(status)); \ - ret = AVERROR_EXTERNAL; \ - goto end; \ - } \ -} while (0) - -#define CREATEBUF(out, flags, size) \ -do { \ - out = clCreateBuffer(ext_opencl_env->context, flags, size, NULL, &status); \ - if (status != CL_SUCCESS) { \ - av_log(NULL, AV_LOG_ERROR, "Could not create OpenCL buffer\n"); \ - ret = AVERROR_EXTERNAL; \ - goto end; \ - } \ -} while (0) - -static void fill_rand_int(int *data, int n) -{ - int i; - srand(av_gettime()); - for (i = 0; i < n; i++) - data[i] = rand(); -} - -#define OPENCL_NB_ITER 5 -static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env) -{ - int i, arg = 0, width = 1920, height = 1088; - int64_t start, ret = 0; - cl_int status; - size_t kernel_len; - char *inbuf; - int *mask = NULL; - int buf_size = width * height * sizeof(char); - int mask_size = sizeof(uint32_t) * 128; - - cl_mem cl_mask = NULL, cl_inbuf = NULL, cl_outbuf = NULL; - cl_kernel kernel = NULL; - cl_program program = NULL; - size_t local_work_size_2d[2] = {16, 16}; - size_t global_work_size_2d[2] = {(size_t)width, (size_t)height}; - - if (!(inbuf = av_malloc(buf_size)) || !(mask = av_malloc(mask_size))) { - av_log(NULL, AV_LOG_ERROR, "Out of memory\n"); - ret = AVERROR(ENOMEM); - goto end; - } - fill_rand_int((int*)inbuf, buf_size/4); - fill_rand_int(mask, mask_size/4); - - CREATEBUF(cl_mask, CL_MEM_READ_ONLY, mask_size); - CREATEBUF(cl_inbuf, CL_MEM_READ_ONLY, buf_size); - CREATEBUF(cl_outbuf, CL_MEM_READ_WRITE, buf_size); - - kernel_len = strlen(ocl_bench_source); - program = clCreateProgramWithSource(ext_opencl_env->context, 1, &ocl_bench_source, - &kernel_len, &status); - if (status != CL_SUCCESS || !program) { - av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark program\n"); - ret = AVERROR_EXTERNAL; - goto end; - } - status = clBuildProgram(program, 1, &(ext_opencl_env->device_id), NULL, NULL, NULL); - if (status != CL_SUCCESS) { - av_log(NULL, AV_LOG_ERROR, "OpenCL unable to build benchmark program\n"); - ret = AVERROR_EXTERNAL; - goto end; - } - kernel = clCreateKernel(program, "unsharp_bench", &status); - if (status != CL_SUCCESS) { - av_log(NULL, AV_LOG_ERROR, "OpenCL unable to create benchmark kernel\n"); - ret = AVERROR_EXTERNAL; - goto end; - } - - OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_inbuf, CL_TRUE, 0, - buf_size, inbuf, 0, NULL, NULL); - OCLCHECK(clEnqueueWriteBuffer, ext_opencl_env->command_queue, cl_mask, CL_TRUE, 0, - mask_size, mask, 0, NULL, NULL); - OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_inbuf); - OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_outbuf); - OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_mem), &cl_mask); - OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &width); - OCLCHECK(clSetKernelArg, kernel, arg++, sizeof(cl_int), &height); - - start = av_gettime_relative(); - for (i = 0; i < OPENCL_NB_ITER; i++) - OCLCHECK(clEnqueueNDRangeKernel, ext_opencl_env->command_queue, kernel, 2, NULL, - global_work_size_2d, local_work_size_2d, 0, NULL, NULL); - clFinish(ext_opencl_env->command_queue); - ret = (av_gettime_relative() - start)/OPENCL_NB_ITER; -end: - if (kernel) - clReleaseKernel(kernel); - if (program) - clReleaseProgram(program); - if (cl_inbuf) - clReleaseMemObject(cl_inbuf); - if (cl_outbuf) - clReleaseMemObject(cl_outbuf); - if (cl_mask) - clReleaseMemObject(cl_mask); - av_free(inbuf); - av_free(mask); - return ret; -} - -static int compare_ocl_device_desc(const void *a, const void *b) -{ - const OpenCLDeviceBenchmark* va = (const OpenCLDeviceBenchmark*)a; - const OpenCLDeviceBenchmark* vb = (const OpenCLDeviceBenchmark*)b; - return FFDIFFSIGN(va->runtime , vb->runtime); -} - -int opt_opencl_bench(void *optctx, const char *opt, const char *arg) -{ - int i, j, nb_devices = 0, count = 0, ret = 0; - int64_t score = 0; - AVOpenCLDeviceList *device_list; - AVOpenCLDeviceNode *device_node = NULL; - OpenCLDeviceBenchmark *devices = NULL; - cl_platform_id platform; - - ret = av_opencl_get_device_list(&device_list); - if (ret < 0) { - return ret; - } - for (i = 0; i < device_list->platform_num; i++) - nb_devices += device_list->platform_node[i]->device_num; - if (!nb_devices) { - av_log(NULL, AV_LOG_ERROR, "No OpenCL device detected!\n"); - av_opencl_free_device_list(&device_list); - return AVERROR(EINVAL); - } - if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) { - av_log(NULL, AV_LOG_ERROR, "Could not allocate buffer\n"); - av_opencl_free_device_list(&device_list); - return AVERROR(ENOMEM); - } - - for (i = 0; i < device_list->platform_num; i++) { - for (j = 0; j < device_list->platform_node[i]->device_num; j++) { - device_node = device_list->platform_node[i]->device_node[j]; - platform = device_list->platform_node[i]->platform_id; - score = av_opencl_benchmark(device_node, platform, run_opencl_bench); - if (score > 0) { - devices[count].platform_idx = i; - devices[count].device_idx = j; - devices[count].runtime = score; - av_strlcpy(devices[count].device_name, device_node->device_name, - sizeof(devices[count].device_name)); - count++; - } - } - } - qsort(devices, count, sizeof(OpenCLDeviceBenchmark), compare_ocl_device_desc); - fprintf(stderr, "platform_idx\tdevice_idx\tdevice_name\truntime\n"); - for (i = 0; i < count; i++) - fprintf(stdout, "%d\t%d\t%s\t%"PRId64"\n", - devices[i].platform_idx, devices[i].device_idx, - devices[i].device_name, devices[i].runtime); - - av_opencl_free_device_list(&device_list); - av_free(devices); - return 0; -} - -int opt_opencl(void *optctx, const char *opt, const char *arg) -{ - char *key, *value; - const char *opts = arg; - int ret = 0; - while (*opts) { - ret = av_opt_get_key_value(&opts, "=", ":", 0, &key, &value); - if (ret < 0) - return ret; - ret = av_opencl_set_option(key, value); - if (ret < 0) - return ret; - if (*opts) - opts++; - } - return ret; -} diff --git a/compat/aix/math.h b/compat/aix/math.h index dee13c8dd7..380f87804d 100644 --- a/compat/aix/math.h +++ b/compat/aix/math.h @@ -2,25 +2,25 @@ * Work around the class() function in AIX math.h clashing with * identifiers named "class". * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef COMPAT_AIX_MATH_H -#define COMPAT_AIX_MATH_H +#ifndef LIBAV_COMPAT_AIX_MATH_H +#define LIBAV_COMPAT_AIX_MATH_H #define class class_in_math_h_causes_problems @@ -28,4 +28,4 @@ #undef class -#endif /* COMPAT_AIX_MATH_H */ +#endif /* LIBAV_COMPAT_AIX_MATH_H */ diff --git a/compat/atomics/dummy/stdatomic.h b/compat/atomics/dummy/stdatomic.h index 59d85f915d..374e1e5e17 100644 --- a/compat/atomics/dummy/stdatomic.h +++ b/compat/atomics/dummy/stdatomic.h @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -21,8 +21,8 @@ * Copyright (C) 2010 Rémi Denis-Courmont */ -#ifndef COMPAT_ATOMICS_DUMMY_STDATOMIC_H -#define COMPAT_ATOMICS_DUMMY_STDATOMIC_H +#ifndef LIBAV_COMPAT_ATOMICS_DUMMY_STDATOMIC_H +#define LIBAV_COMPAT_ATOMICS_DUMMY_STDATOMIC_H #include @@ -156,7 +156,7 @@ FETCH_MODIFY(and, &) atomic_fetch_or(object, operand) #define atomic_fetch_xor_explicit(object, operand, order) \ - atomic_fetch_xor(object, operand) + atomic_fetch_sub(object, operand) #define atomic_fetch_and_explicit(object, operand, order) \ atomic_fetch_and(object, operand) @@ -173,4 +173,4 @@ FETCH_MODIFY(and, &) #define atomic_flag_clear_explicit(object, order) \ atomic_flag_clear(object) -#endif /* COMPAT_ATOMICS_DUMMY_STDATOMIC_H */ +#endif /* LIBAV_COMPAT_ATOMICS_DUMMY_STDATOMIC_H */ diff --git a/compat/atomics/gcc/stdatomic.h b/compat/atomics/gcc/stdatomic.h index e13ed0e068..67168abb5e 100644 --- a/compat/atomics/gcc/stdatomic.h +++ b/compat/atomics/gcc/stdatomic.h @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -21,8 +21,8 @@ * Copyright (C) 2010 Rémi Denis-Courmont */ -#ifndef COMPAT_ATOMICS_GCC_STDATOMIC_H -#define COMPAT_ATOMICS_GCC_STDATOMIC_H +#ifndef LIBAV_COMPAT_ATOMICS_GCC_STDATOMIC_H +#define LIBAV_COMPAT_ATOMICS_GCC_STDATOMIC_H #include #include @@ -100,8 +100,8 @@ do { \ #define atomic_exchange(object, desired) \ ({ \ - __typeof__(object) _obj = (object); \ - __typeof__(*object) _old; \ + typeof(object) _obj = (object); \ + typeof(*object) _old; \ do \ _old = atomic_load(_obj); \ while (!__sync_bool_compare_and_swap(_obj, _old, (desired))); \ @@ -113,8 +113,8 @@ do { \ #define atomic_compare_exchange_strong(object, expected, desired) \ ({ \ - __typeof__(object) _exp = (expected); \ - __typeof__(*object) _old = *_exp; \ + typeof(object) _exp = (expected); \ + typeof(*object) _old = *_exp; \ *_exp = __sync_val_compare_and_swap((object), _old, (desired)); \ *_exp == _old; \ }) @@ -147,10 +147,10 @@ do { \ atomic_fetch_or(object, operand) #define atomic_fetch_xor(object, operand) \ - __sync_fetch_and_xor(object, operand) + __sync_fetch_and_sub(object, operand) #define atomic_fetch_xor_explicit(object, operand, order) \ - atomic_fetch_xor(object, operand) + atomic_fetch_sub(object, operand) #define atomic_fetch_and(object, operand) \ __sync_fetch_and_and(object, operand) @@ -170,4 +170,4 @@ do { \ #define atomic_flag_clear_explicit(object, order) \ atomic_flag_clear(object) -#endif /* COMPAT_ATOMICS_GCC_STDATOMIC_H */ +#endif /* LIBAV_COMPAT_ATOMICS_GCC_STDATOMIC_H */ diff --git a/compat/atomics/pthread/stdatomic.c b/compat/atomics/pthread/stdatomic.c index 9fca98980b..0d1ecfec0d 100644 --- a/compat/atomics/pthread/stdatomic.c +++ b/compat/atomics/pthread/stdatomic.c @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/compat/atomics/pthread/stdatomic.h b/compat/atomics/pthread/stdatomic.h index 81a60f102b..a4aa9bbbed 100644 --- a/compat/atomics/pthread/stdatomic.h +++ b/compat/atomics/pthread/stdatomic.h @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -21,8 +21,8 @@ * Copyright (C) 2010 Rémi Denis-Courmont */ -#ifndef COMPAT_ATOMICS_PTHREAD_STDATOMIC_H -#define COMPAT_ATOMICS_PTHREAD_STDATOMIC_H +#ifndef LIBAV_COMPAT_ATOMICS_PTHREAD_STDATOMIC_H +#define LIBAV_COMPAT_ATOMICS_PTHREAD_STDATOMIC_H #include @@ -177,7 +177,7 @@ FETCH_MODIFY(and, &) atomic_fetch_or(object, operand) #define atomic_fetch_xor_explicit(object, operand, order) \ - atomic_fetch_xor(object, operand) + atomic_fetch_sub(object, operand) #define atomic_fetch_and_explicit(object, operand, order) \ atomic_fetch_and(object, operand) @@ -194,4 +194,4 @@ FETCH_MODIFY(and, &) #define atomic_flag_clear_explicit(object, order) \ atomic_flag_clear(object) -#endif /* COMPAT_ATOMICS_PTHREAD_STDATOMIC_H */ +#endif /* LIBAV_COMPAT_ATOMICS_PTHREAD_STDATOMIC_H */ diff --git a/compat/atomics/suncc/stdatomic.h b/compat/atomics/suncc/stdatomic.h index 0cf89e0f78..aef498d022 100644 --- a/compat/atomics/suncc/stdatomic.h +++ b/compat/atomics/suncc/stdatomic.h @@ -1,23 +1,23 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; 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 +#ifndef LIBAV_COMPAT_ATOMICS_SUNCC_STDATOMIC_H +#define LIBAV_COMPAT_ATOMICS_SUNCC_STDATOMIC_H #include #include @@ -166,7 +166,7 @@ static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand) atomic_fetch_or(object, operand) #define atomic_fetch_xor_explicit(object, operand, order) \ - atomic_fetch_xor(object, operand) + atomic_fetch_sub(object, operand) #define atomic_fetch_and_explicit(object, operand, order) \ atomic_fetch_and(object, operand) @@ -183,4 +183,4 @@ static inline intptr_t atomic_fetch_and(intptr_t *object, intptr_t operand) #define atomic_flag_clear_explicit(object, order) \ atomic_flag_clear(object) -#endif /* COMPAT_ATOMICS_SUNCC_STDATOMIC_H */ +#endif /* LIBAV_COMPAT_ATOMICS_SUNCC_STDATOMIC_H */ diff --git a/compat/atomics/win32/stdatomic.h b/compat/atomics/win32/stdatomic.h index bb8e6e7e15..9cfdaa523f 100644 --- a/compat/atomics/win32/stdatomic.h +++ b/compat/atomics/win32/stdatomic.h @@ -1,25 +1,24 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; 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 +#ifndef LIBAV_COMPAT_ATOMICS_WIN32_STDATOMIC_H +#define LIBAV_COMPAT_ATOMICS_WIN32_STDATOMIC_H -#define WIN32_LEAN_AND_MEAN #include #include #include @@ -161,7 +160,7 @@ static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp atomic_fetch_or(object, operand) #define atomic_fetch_xor_explicit(object, operand, order) \ - atomic_fetch_xor(object, operand) + atomic_fetch_sub(object, operand) #define atomic_fetch_and_explicit(object, operand, order) \ atomic_fetch_and(object, operand) @@ -178,4 +177,4 @@ static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp #define atomic_flag_clear_explicit(object, order) \ atomic_flag_clear(object) -#endif /* COMPAT_ATOMICS_WIN32_STDATOMIC_H */ +#endif /* LIBAV_COMPAT_ATOMICS_WIN32_STDATOMIC_H */ diff --git a/compat/avisynth/avisynth_c.h b/compat/avisynth/avisynth_c.h deleted file mode 100644 index 605b92ae62..0000000000 --- a/compat/avisynth/avisynth_c.h +++ /dev/null @@ -1,1064 +0,0 @@ -// Avisynth C Interface Version 0.20 -// Copyright 2003 Kevin Atkinson - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA, or visit -// http://www.gnu.org/copyleft/gpl.html . -// -// As a special exception, I give you permission to link to the -// Avisynth C interface with independent modules that communicate with -// the Avisynth C interface solely through the interfaces defined in -// avisynth_c.h, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting combined work -// under terms of your choice, provided that every copy of the -// combined work is accompanied by a complete copy of the source code -// of the Avisynth C interface and Avisynth itself (with the version -// used to produce the combined work), being distributed under the -// terms of the GNU General Public License plus this exception. An -// independent module is a module which is not derived from or based -// on Avisynth C Interface, such as 3rd-party filters, import and -// export plugins, or graphical user interfaces. - -// NOTE: this is a partial update of the Avisynth C interface to recognize -// new color spaces added in Avisynth 2.60. By no means is this document -// completely Avisynth 2.60 compliant. - -#ifndef __AVISYNTH_C__ -#define __AVISYNTH_C__ - -#include "avs/config.h" -#include "avs/capi.h" -#include "avs/types.h" - - -///////////////////////////////////////////////////////////////////// -// -// Constants -// - -#ifndef __AVISYNTH_6_H__ -enum { AVISYNTH_INTERFACE_VERSION = 6 }; -#endif - -enum {AVS_SAMPLE_INT8 = 1<<0, - AVS_SAMPLE_INT16 = 1<<1, - AVS_SAMPLE_INT24 = 1<<2, - AVS_SAMPLE_INT32 = 1<<3, - AVS_SAMPLE_FLOAT = 1<<4}; - -enum {AVS_PLANAR_Y=1<<0, - AVS_PLANAR_U=1<<1, - AVS_PLANAR_V=1<<2, - AVS_PLANAR_ALIGNED=1<<3, - AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED, - AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED, - AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED, - AVS_PLANAR_A=1<<4, - AVS_PLANAR_R=1<<5, - AVS_PLANAR_G=1<<6, - AVS_PLANAR_B=1<<7, - AVS_PLANAR_A_ALIGNED=AVS_PLANAR_A|AVS_PLANAR_ALIGNED, - AVS_PLANAR_R_ALIGNED=AVS_PLANAR_R|AVS_PLANAR_ALIGNED, - AVS_PLANAR_G_ALIGNED=AVS_PLANAR_G|AVS_PLANAR_ALIGNED, - AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED}; - - // Colorspace properties. -enum { - AVS_CS_YUVA = 1 << 27, - 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_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, - AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24 - AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16 - AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411 - - AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 - AVS_CS_UPLANEFIRST = 1 << 4, // I420 - - AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, - AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411 - AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420 - AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 - - AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_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 - - - // 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_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_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 - -}; - -enum { - AVS_IT_BFF = 1<<0, - AVS_IT_TFF = 1<<1, - AVS_IT_FIELDBASED = 1<<2}; - -enum { - AVS_FILTER_TYPE=1, - AVS_FILTER_INPUT_COLORSPACE=2, - AVS_FILTER_OUTPUT_TYPE=9, - AVS_FILTER_NAME=4, - AVS_FILTER_AUTHOR=5, - AVS_FILTER_VERSION=6, - AVS_FILTER_ARGS=7, - AVS_FILTER_ARGS_INFO=8, - AVS_FILTER_ARGS_DESCRIPTION=10, - AVS_FILTER_DESCRIPTION=11}; - -enum { //SUBTYPES - AVS_FILTER_TYPE_AUDIO=1, - AVS_FILTER_TYPE_VIDEO=2, - AVS_FILTER_OUTPUT_TYPE_SAME=3, - AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4}; - -enum { - // New 2.6 explicitly defined cache hints. - AVS_CACHE_NOTHING=10, // Do not cache video. - AVS_CACHE_WINDOW=11, // Hard protect upto X frames within a range of X from the current frame N. - AVS_CACHE_GENERIC=12, // LRU cache upto X frames. - AVS_CACHE_FORCE_GENERIC=13, // LRU cache upto X frames, override any previous CACHE_WINDOW. - - AVS_CACHE_GET_POLICY=30, // Get the current policy. - AVS_CACHE_GET_WINDOW=31, // Get the current window h_span. - AVS_CACHE_GET_RANGE=32, // Get the current generic frame range. - - AVS_CACHE_AUDIO=50, // Explicitly do cache audio, X byte cache. - AVS_CACHE_AUDIO_NOTHING=51, // Explicitly do not cache audio. - AVS_CACHE_AUDIO_NONE=52, // Audio cache off (auto mode), X byte intial cache. - AVS_CACHE_AUDIO_AUTO=53, // Audio cache on (auto mode), X byte intial cache. - - AVS_CACHE_GET_AUDIO_POLICY=70, // Get the current audio policy. - AVS_CACHE_GET_AUDIO_SIZE=71, // Get the current audio cache size. - - AVS_CACHE_PREFETCH_FRAME=100, // Queue request to prefetch frame N. - AVS_CACHE_PREFETCH_GO=101, // Action video prefetches. - - AVS_CACHE_PREFETCH_AUDIO_BEGIN=120, // Begin queue request transaction to prefetch audio (take critical section). - AVS_CACHE_PREFETCH_AUDIO_STARTLO=121, // Set low 32 bits of start. - AVS_CACHE_PREFETCH_AUDIO_STARTHI=122, // Set high 32 bits of start. - AVS_CACHE_PREFETCH_AUDIO_COUNT=123, // Set low 32 bits of length. - AVS_CACHE_PREFETCH_AUDIO_COMMIT=124, // Enqueue request transaction to prefetch audio (release critical section). - AVS_CACHE_PREFETCH_AUDIO_GO=125, // Action audio prefetches. - - AVS_CACHE_GETCHILD_CACHE_MODE=200, // Cache ask Child for desired video cache mode. - AVS_CACHE_GETCHILD_CACHE_SIZE=201, // Cache ask Child for desired video cache size. - AVS_CACHE_GETCHILD_AUDIO_MODE=202, // Cache ask Child for desired audio cache mode. - AVS_CACHE_GETCHILD_AUDIO_SIZE=203, // Cache ask Child for desired audio cache size. - - AVS_CACHE_GETCHILD_COST=220, // Cache ask Child for estimated processing cost. - AVS_CACHE_COST_ZERO=221, // Child response of zero cost (ptr arithmetic only). - AVS_CACHE_COST_UNIT=222, // Child response of unit cost (less than or equal 1 full frame blit). - AVS_CACHE_COST_LOW=223, // Child response of light cost. (Fast) - AVS_CACHE_COST_MED=224, // Child response of medium cost. (Real time) - AVS_CACHE_COST_HI=225, // Child response of heavy cost. (Slow) - - AVS_CACHE_GETCHILD_THREAD_MODE=240, // Cache ask Child for thread safetyness. - AVS_CACHE_THREAD_UNSAFE=241, // Only 1 thread allowed for all instances. 2.5 filters default! - AVS_CACHE_THREAD_CLASS=242, // Only 1 thread allowed for each instance. 2.6 filters default! - AVS_CACHE_THREAD_SAFE=243, // Allow all threads in any instance. - AVS_CACHE_THREAD_OWN=244, // Safe but limit to 1 thread, internally threaded. - - AVS_CACHE_GETCHILD_ACCESS_COST=260, // Cache ask Child for preferred access pattern. - AVS_CACHE_ACCESS_RAND=261, // Filter is access order agnostic. - AVS_CACHE_ACCESS_SEQ0=262, // Filter prefers sequential access (low cost) - AVS_CACHE_ACCESS_SEQ1=263, // Filter needs sequential access (high cost) - }; - -#ifdef BUILDING_AVSCORE -struct AVS_ScriptEnvironment { - IScriptEnvironment * env; - const char * error; - AVS_ScriptEnvironment(IScriptEnvironment * e = 0) - : env(e), error(0) {} -}; -#endif - -typedef struct AVS_Clip AVS_Clip; -typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment; - -///////////////////////////////////////////////////////////////////// -// -// AVS_VideoInfo -// - -// AVS_VideoInfo is layed out identicly to VideoInfo -typedef struct AVS_VideoInfo { - int width, height; // width=0 means no video - unsigned fps_numerator, fps_denominator; - int num_frames; - - int pixel_type; - - int audio_samples_per_second; // 0 means no audio - int sample_type; - INT64 num_audio_samples; - int nchannels; - - // Imagetype properties - - int image_type; -} AVS_VideoInfo; - -// useful functions of the above -AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p) - { return (p->width!=0); } - -AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p) - { return (p->audio_samples_per_second!=0); } - -AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p) - { return !!(p->pixel_type&AVS_CS_BGR); } - -AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p) - { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } - -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); } - -AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) - { return !!(p->pixel_type&AVS_CS_YUV ); } - -AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) - { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } - -AVSC_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); - -AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; - -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 ); } - -AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p) - { return !!(p->pixel_type & AVS_CS_PLANAR); } - -AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space); - -AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p) - { return !!(p->image_type & AVS_IT_FIELDBASED); } - -AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p) - { return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); } - -AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p) - { return !!(p->image_type & AVS_IT_BFF); } - -AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p) - { return !!(p->image_type & AVS_IT_TFF); } - -AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane); - -AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane); - - -AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p); - -AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels); - -AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane); - -AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi); - -AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p) - { return p->audio_samples_per_second; } - - -AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p) -{ - switch (p->sample_type) { - case AVS_SAMPLE_INT8: return sizeof(signed char); - case AVS_SAMPLE_INT16: return sizeof(signed short); - case AVS_SAMPLE_INT24: return 3; - case AVS_SAMPLE_INT32: return sizeof(signed int); - case AVS_SAMPLE_FLOAT: return sizeof(float); - default: return 0; - } -} -AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p) - { return p->nchannels*avs_bytes_per_channel_sample(p);} - -AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames) - { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); } - -AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) - { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); } - -AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes) - { return bytes / avs_bytes_per_audio_sample(p); } - -AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) - { return samples * avs_bytes_per_audio_sample(p); } - -AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p) - { return p->nchannels; } - -AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p) - { return p->sample_type;} - -// useful mutator -AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property) - { p->image_type|=property; } - -AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property) - { p->image_type&=~property; } - -AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased) - { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; } - -AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator) -{ - unsigned x=numerator, y=denominator; - while (y) { // find gcd - unsigned t = x%y; x = y; y = t; - } - p->fps_numerator = numerator/x; - p->fps_denominator = denominator/x; -} - -#ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR -AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y) -{ - return (x->pixel_type == y->pixel_type) - || (avs_is_yv12(x) && avs_is_yv12(y)); -} -#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 -// - -// VideoFrameBuffer holds information about a memory block which is used -// for video data. For efficiency, instances of this class are not deleted -// when the refcount reaches zero; instead they're stored in a linked list -// to be reused. The instances are deleted when the corresponding AVS -// file is closed. - -// AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer -// DO NOT USE THIS STRUCTURE DIRECTLY -typedef struct AVS_VideoFrameBuffer { - BYTE * data; - int data_size; - // sequence_number is incremented every time the buffer is changed, so - // that stale views can tell they're no longer valid. - volatile long sequence_number; - - volatile long refcount; -} AVS_VideoFrameBuffer; - -// VideoFrame holds a "window" into a VideoFrameBuffer. - -// AVS_VideoFrame is layed out identicly to IVideoFrame -// DO NOT USE THIS STRUCTURE DIRECTLY -typedef struct AVS_VideoFrame { - volatile long refcount; - AVS_VideoFrameBuffer * vfb; - int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture. - int row_sizeUV, heightUV; -} AVS_VideoFrame; - -// Access functions for AVS_VideoFrame -AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane); - -#ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR -AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) { - return avs_get_pitch_p(p, 0);} -#endif - -AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane); - -AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) { - return p->row_size; } - -AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane); - -AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) { - return p->height;} - -AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane); - -#ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR -AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) { - return avs_get_read_ptr_p(p, 0);} -#endif - -AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p); - -AVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane); - -#ifdef AVS_IMPLICIT_FUNCTION_DECLARATION_ERROR -AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) { - return avs_get_write_ptr_p(p, 0);} -#endif - -AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *); -// makes a shallow copy of a video frame -AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *); - -#ifndef AVSC_NO_DECLSPEC -AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f) - {avs_release_video_frame(f);} -AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f) - {return avs_copy_video_frame(f);} -#endif - -///////////////////////////////////////////////////////////////////// -// -// AVS_Value -// - -// Treat AVS_Value as a fat pointer. That is use avs_copy_value -// and avs_release_value appropiaty as you would if AVS_Value was -// a pointer. - -// To maintain source code compatibility with future versions of the -// avisynth_c API don't use the AVS_Value directly. Use the helper -// functions below. - -// AVS_Value is layed out identicly to AVSValue -typedef struct AVS_Value AVS_Value; -struct AVS_Value { - short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong - // for some function e'rror - short array_size; - union { - void * clip; // do not use directly, use avs_take_clip - char boolean; - int integer; - float floating_pt; - const char * string; - const AVS_Value * array; - } d; -}; - -// AVS_Value should be initilized with avs_void. -// Should also set to avs_void after the value is released -// with avs_copy_value. Consider it the equalvent of setting -// a pointer to NULL -static const AVS_Value avs_void = {'v'}; - -AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src); -AVSC_API(void, avs_release_value)(AVS_Value); - -AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; } -AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; } -AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; } -AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; } -AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; } -AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; } -AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; } -AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; } - -AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); -AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *); - -AVSC_INLINE int avs_as_bool(AVS_Value v) - { return v.d.boolean; } -AVSC_INLINE int avs_as_int(AVS_Value v) - { return v.d.integer; } -AVSC_INLINE const char * avs_as_string(AVS_Value v) - { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; } -AVSC_INLINE double avs_as_float(AVS_Value v) - { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; } -AVSC_INLINE const char * avs_as_error(AVS_Value v) - { return avs_is_error(v) ? v.d.string : 0; } -AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v) - { return v.d.array; } -AVSC_INLINE int avs_array_size(AVS_Value v) - { return avs_is_array(v) ? v.array_size : 1; } -AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index) - { return avs_is_array(v) ? v.d.array[index] : v; } - -// only use these functions on an AVS_Value that does not already have -// an active value. Remember, treat AVS_Value as a fat pointer. -AVSC_INLINE AVS_Value avs_new_value_bool(int v0) - { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; } -AVSC_INLINE AVS_Value avs_new_value_int(int v0) - { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; } -AVSC_INLINE AVS_Value avs_new_value_string(const char * v0) - { AVS_Value v; v.type = 's'; v.d.string = v0; return v; } -AVSC_INLINE AVS_Value avs_new_value_float(float v0) - { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;} -AVSC_INLINE AVS_Value avs_new_value_error(const char * v0) - { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; } -#ifndef AVSC_NO_DECLSPEC -AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0) - { AVS_Value v; avs_set_to_clip(&v, v0); return v; } -#endif -AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) - { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; } - -///////////////////////////////////////////////////////////////////// -// -// AVS_Clip -// - -AVSC_API(void, avs_release_clip)(AVS_Clip *); -AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *); - -AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error - -AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *); - -AVSC_API(int, avs_get_version)(AVS_Clip *); - -AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n); -// The returned video frame must be released with avs_release_video_frame - -AVSC_API(int, avs_get_parity)(AVS_Clip *, int n); -// return field parity if field_based, else parity of first field in frame - -AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf, - INT64 start, INT64 count); -// start and count are in samples - -AVSC_API(int, avs_set_cache_hints)(AVS_Clip *, - int cachehints, int frame_range); - -// This is the callback type used by avs_add_function -typedef AVS_Value (AVSC_CC * AVS_ApplyFunc) - (AVS_ScriptEnvironment *, AVS_Value args, void * user_data); - -typedef struct AVS_FilterInfo AVS_FilterInfo; -struct AVS_FilterInfo -{ - // these members should not be modified outside of the AVS_ApplyFunc callback - AVS_Clip * child; - AVS_VideoInfo vi; - AVS_ScriptEnvironment * env; - AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n); - int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n); - int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, - INT64 start, INT64 count); - int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, - int frame_range); - void (AVSC_CC * free_filter)(AVS_FilterInfo *); - - // Should be set when ever there is an error to report. - // It is cleared before any of the above methods are called - const char * error; - // this is to store whatever and may be modified at will - void * user_data; -}; - -// Create a new filter -// fi is set to point to the AVS_FilterInfo so that you can -// modify it once it is initilized. -// store_child should generally be set to true. If it is not -// set than ALL methods (the function pointers) must be defined -// If it is set than you do not need to worry about freeing the child -// clip. -AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e, - AVS_FilterInfo * * fi, - AVS_Value child, int store_child); - -///////////////////////////////////////////////////////////////////// -// -// AVS_ScriptEnvironment -// - -// For GetCPUFlags. These are backwards-compatible with those in VirtualDub. -enum { - /* slowest CPU to support extension */ - AVS_CPU_FORCE = 0x01, // N/A - AVS_CPU_FPU = 0x02, // 386/486DX - AVS_CPU_MMX = 0x04, // P55C, K6, PII - AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon - AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP - AVS_CPU_SSE2 = 0x20, // PIV, Hammer - AVS_CPU_3DNOW = 0x40, // K6-2 - AVS_CPU_3DNOW_EXT = 0x80, // Athlon - AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, - // which only Hammer will have anyway) - AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice - AVS_CPUF_SSSE3 = 0x200, // Core 2 - AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield - AVS_CPUF_SSE4_1 = 0x400, -//AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer - AVS_CPUF_SSE4_2 = 0x1000, // Nehalem -//AVS_CPUF_AVX2 = 0x2000, // Haswell -//AVS_CPUF_AVX512 = 0x4000, // Knights Landing -}; - - -AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error - -AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *); -AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version); - -AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length); -AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...); - -AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, void* val); - // note: val is really a va_list; I hope everyone typedefs va_list to a pointer - -AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *, - const char * name, const char * params, - AVS_ApplyFunc apply, void * user_data); - -AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name); - -AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name, - AVS_Value args, const char** arg_names); -// The returned value must be be released with avs_release_value - -AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name); -// The returned value must be be released with avs_release_value - -AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val); - -AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val); - -//void avs_push_context(AVS_ScriptEnvironment *, int level=0); -//void avs_pop_context(AVS_ScriptEnvironment *); - -AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *, - const AVS_VideoInfo * vi, int align); -// align should be at least 16 - -#ifndef AVSC_NO_DECLSPEC -AVSC_INLINE -AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env, - const AVS_VideoInfo * vi) - {return avs_new_video_frame_a(env,vi,FRAME_ALIGN);} - -AVSC_INLINE -AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env, - const AVS_VideoInfo * vi) - {return avs_new_video_frame_a(env,vi,FRAME_ALIGN);} -#endif - - -AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf); - -AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height); - -typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env); -AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data); - -AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height); -// The returned video frame must be be released - -AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem); - -AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir); - -// avisynth.dll exports this; it's a way to use it as a library, without -// writing an AVS script or without going through AVIFile. -AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version); - -// this symbol is the entry point for the plugin and must -// be defined -AVSC_EXPORT -const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env); - - -AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *); - - -AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV); -// The returned video frame must be be released - -#ifdef AVSC_NO_DECLSPEC -// use LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport) -/* - The following functions needs to have been declared, probably from windows.h - - void* malloc(size_t) - void free(void*); - - HMODULE LoadLibrary(const char*); - void* GetProcAddress(HMODULE, const char*); - FreeLibrary(HMODULE); -*/ - - -typedef struct AVS_Library AVS_Library; - -#define AVSC_DECLARE_FUNC(name) name##_func name - -struct AVS_Library { - HMODULE handle; - - AVSC_DECLARE_FUNC(avs_add_function); - AVSC_DECLARE_FUNC(avs_at_exit); - AVSC_DECLARE_FUNC(avs_bit_blt); - AVSC_DECLARE_FUNC(avs_check_version); - AVSC_DECLARE_FUNC(avs_clip_get_error); - AVSC_DECLARE_FUNC(avs_copy_clip); - AVSC_DECLARE_FUNC(avs_copy_value); - AVSC_DECLARE_FUNC(avs_copy_video_frame); - AVSC_DECLARE_FUNC(avs_create_script_environment); - AVSC_DECLARE_FUNC(avs_delete_script_environment); - AVSC_DECLARE_FUNC(avs_function_exists); - AVSC_DECLARE_FUNC(avs_get_audio); - AVSC_DECLARE_FUNC(avs_get_cpu_flags); - AVSC_DECLARE_FUNC(avs_get_frame); - AVSC_DECLARE_FUNC(avs_get_parity); - AVSC_DECLARE_FUNC(avs_get_var); - AVSC_DECLARE_FUNC(avs_get_version); - AVSC_DECLARE_FUNC(avs_get_video_info); - AVSC_DECLARE_FUNC(avs_invoke); - AVSC_DECLARE_FUNC(avs_make_writable); - AVSC_DECLARE_FUNC(avs_new_c_filter); - AVSC_DECLARE_FUNC(avs_new_video_frame_a); - AVSC_DECLARE_FUNC(avs_release_clip); - AVSC_DECLARE_FUNC(avs_release_value); - AVSC_DECLARE_FUNC(avs_release_video_frame); - AVSC_DECLARE_FUNC(avs_save_string); - AVSC_DECLARE_FUNC(avs_set_cache_hints); - AVSC_DECLARE_FUNC(avs_set_global_var); - AVSC_DECLARE_FUNC(avs_set_memory_max); - AVSC_DECLARE_FUNC(avs_set_to_clip); - AVSC_DECLARE_FUNC(avs_set_var); - AVSC_DECLARE_FUNC(avs_set_working_dir); - AVSC_DECLARE_FUNC(avs_sprintf); - AVSC_DECLARE_FUNC(avs_subframe); - AVSC_DECLARE_FUNC(avs_subframe_planar); - AVSC_DECLARE_FUNC(avs_take_clip); - AVSC_DECLARE_FUNC(avs_vsprintf); - - 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); - AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling); - AVSC_DECLARE_FUNC(avs_bits_per_pixel); - AVSC_DECLARE_FUNC(avs_bytes_from_pixels); - AVSC_DECLARE_FUNC(avs_row_size); - AVSC_DECLARE_FUNC(avs_bmp_size); - AVSC_DECLARE_FUNC(avs_get_pitch_p); - AVSC_DECLARE_FUNC(avs_get_row_size_p); - AVSC_DECLARE_FUNC(avs_get_height_p); - 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 - - -AVSC_INLINE AVS_Library * avs_load_library() { - AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library)); - if (library == NULL) - return NULL; - library->handle = LoadLibrary("avisynth"); - if (library->handle == NULL) - goto fail; - -#define __AVSC_STRINGIFY(x) #x -#define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x) -#define AVSC_LOAD_FUNC(name) {\ - library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\ - if (library->name == NULL)\ - goto fail;\ -} - - AVSC_LOAD_FUNC(avs_add_function); - AVSC_LOAD_FUNC(avs_at_exit); - AVSC_LOAD_FUNC(avs_bit_blt); - AVSC_LOAD_FUNC(avs_check_version); - AVSC_LOAD_FUNC(avs_clip_get_error); - AVSC_LOAD_FUNC(avs_copy_clip); - AVSC_LOAD_FUNC(avs_copy_value); - AVSC_LOAD_FUNC(avs_copy_video_frame); - AVSC_LOAD_FUNC(avs_create_script_environment); - AVSC_LOAD_FUNC(avs_delete_script_environment); - AVSC_LOAD_FUNC(avs_function_exists); - AVSC_LOAD_FUNC(avs_get_audio); - AVSC_LOAD_FUNC(avs_get_cpu_flags); - AVSC_LOAD_FUNC(avs_get_frame); - AVSC_LOAD_FUNC(avs_get_parity); - AVSC_LOAD_FUNC(avs_get_var); - AVSC_LOAD_FUNC(avs_get_version); - AVSC_LOAD_FUNC(avs_get_video_info); - AVSC_LOAD_FUNC(avs_invoke); - AVSC_LOAD_FUNC(avs_make_writable); - AVSC_LOAD_FUNC(avs_new_c_filter); - AVSC_LOAD_FUNC(avs_new_video_frame_a); - AVSC_LOAD_FUNC(avs_release_clip); - AVSC_LOAD_FUNC(avs_release_value); - AVSC_LOAD_FUNC(avs_release_video_frame); - AVSC_LOAD_FUNC(avs_save_string); - AVSC_LOAD_FUNC(avs_set_cache_hints); - AVSC_LOAD_FUNC(avs_set_global_var); - AVSC_LOAD_FUNC(avs_set_memory_max); - AVSC_LOAD_FUNC(avs_set_to_clip); - AVSC_LOAD_FUNC(avs_set_var); - AVSC_LOAD_FUNC(avs_set_working_dir); - AVSC_LOAD_FUNC(avs_sprintf); - AVSC_LOAD_FUNC(avs_subframe); - AVSC_LOAD_FUNC(avs_subframe_planar); - AVSC_LOAD_FUNC(avs_take_clip); - AVSC_LOAD_FUNC(avs_vsprintf); - - 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); - AVSC_LOAD_FUNC(avs_get_plane_height_subsampling); - AVSC_LOAD_FUNC(avs_bits_per_pixel); - AVSC_LOAD_FUNC(avs_bytes_from_pixels); - AVSC_LOAD_FUNC(avs_row_size); - AVSC_LOAD_FUNC(avs_bmp_size); - AVSC_LOAD_FUNC(avs_get_pitch_p); - AVSC_LOAD_FUNC(avs_get_row_size_p); - AVSC_LOAD_FUNC(avs_get_height_p); - AVSC_LOAD_FUNC(avs_get_read_ptr_p); - 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 - - return library; - -fail: - free(library); - return NULL; -} - -AVSC_INLINE void avs_free_library(AVS_Library *library) { - if (library == NULL) - return; - FreeLibrary(library->handle); - free(library); -} -#endif - -#endif diff --git a/compat/avisynth/avs/capi.h b/compat/avisynth/avs/capi.h deleted file mode 100644 index 6ed6770c66..0000000000 --- a/compat/avisynth/avs/capi.h +++ /dev/null @@ -1,62 +0,0 @@ -// Avisynth C Interface Version 0.20 -// Copyright 2003 Kevin Atkinson - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit -// http://www.gnu.org/copyleft/gpl.html . -// -// As a special exception, I give you permission to link to the -// Avisynth C interface with independent modules that communicate with -// the Avisynth C interface solely through the interfaces defined in -// avisynth_c.h, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting combined work -// under terms of your choice, provided that every copy of the -// combined work is accompanied by a complete copy of the source code -// of the Avisynth C interface and Avisynth itself (with the version -// used to produce the combined work), being distributed under the -// terms of the GNU General Public License plus this exception. An -// independent module is a module which is not derived from or based -// on Avisynth C Interface, such as 3rd-party filters, import and -// export plugins, or graphical user interfaces. - -#ifndef AVS_CAPI_H -#define AVS_CAPI_H - -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif - -#ifndef AVSC_USE_STDCALL -# define AVSC_CC __cdecl -#else -# define AVSC_CC __stdcall -#endif - -#define AVSC_INLINE static __inline - -#ifdef BUILDING_AVSCORE -# define AVSC_EXPORT EXTERN_C -# define AVSC_API(ret, name) EXTERN_C __declspec(dllexport) ret AVSC_CC name -#else -# define AVSC_EXPORT EXTERN_C __declspec(dllexport) -# ifndef AVSC_NO_DECLSPEC -# define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name -# else -# define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) -# endif -#endif - -#endif //AVS_CAPI_H diff --git a/compat/avisynth/avs/config.h b/compat/avisynth/avs/config.h deleted file mode 100644 index 7acd95b57e..0000000000 --- a/compat/avisynth/avs/config.h +++ /dev/null @@ -1,55 +0,0 @@ -// Avisynth C Interface Version 0.20 -// Copyright 2003 Kevin Atkinson - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit -// http://www.gnu.org/copyleft/gpl.html . -// -// As a special exception, I give you permission to link to the -// Avisynth C interface with independent modules that communicate with -// the Avisynth C interface solely through the interfaces defined in -// avisynth_c.h, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting combined work -// under terms of your choice, provided that every copy of the -// combined work is accompanied by a complete copy of the source code -// of the Avisynth C interface and Avisynth itself (with the version -// used to produce the combined work), being distributed under the -// terms of the GNU General Public License plus this exception. An -// independent module is a module which is not derived from or based -// on Avisynth C Interface, such as 3rd-party filters, import and -// export plugins, or graphical user interfaces. - -#ifndef AVS_CONFIG_H -#define AVS_CONFIG_H - -// Undefine this to get cdecl calling convention -#define AVSC_USE_STDCALL 1 - -// NOTE TO PLUGIN AUTHORS: -// Because FRAME_ALIGN can be substantially higher than the alignment -// a plugin actually needs, plugins should not use FRAME_ALIGN to check for -// alignment. They should always request the exact alignment value they need. -// This is to make sure that plugins work over the widest range of AviSynth -// builds possible. -#define FRAME_ALIGN 32 - -#if defined(_M_AMD64) || defined(__x86_64) -# define X86_64 -#elif defined(_M_IX86) || defined(__i386__) -# define X86_32 -#else -# error Unsupported CPU architecture. -#endif - -#endif //AVS_CONFIG_H diff --git a/compat/avisynth/avs/types.h b/compat/avisynth/avs/types.h deleted file mode 100644 index e5f084cd33..0000000000 --- a/compat/avisynth/avs/types.h +++ /dev/null @@ -1,51 +0,0 @@ -// Avisynth C Interface Version 0.20 -// Copyright 2003 Kevin Atkinson - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit -// http://www.gnu.org/copyleft/gpl.html . -// -// As a special exception, I give you permission to link to the -// Avisynth C interface with independent modules that communicate with -// the Avisynth C interface solely through the interfaces defined in -// avisynth_c.h, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting combined work -// under terms of your choice, provided that every copy of the -// combined work is accompanied by a complete copy of the source code -// of the Avisynth C interface and Avisynth itself (with the version -// used to produce the combined work), being distributed under the -// terms of the GNU General Public License plus this exception. An -// independent module is a module which is not derived from or based -// on Avisynth C Interface, such as 3rd-party filters, import and -// export plugins, or graphical user interfaces. - -#ifndef AVS_TYPES_H -#define AVS_TYPES_H - -// Define all types necessary for interfacing with avisynth.dll - -// Raster types used by VirtualDub & Avisynth -typedef unsigned int Pixel32; -typedef unsigned char BYTE; - -// Audio Sample information -typedef float SFLOAT; - -#ifdef __GNUC__ -typedef long long int INT64; -#else -typedef __int64 INT64; -#endif - -#endif //AVS_TYPES_H diff --git a/compat/avisynth/avxsynth_c.h b/compat/avisynth/avxsynth_c.h deleted file mode 100644 index 991f4be1ab..0000000000 --- a/compat/avisynth/avxsynth_c.h +++ /dev/null @@ -1,728 +0,0 @@ -// Avisynth C Interface Version 0.20 -// Copyright 2003 Kevin Atkinson - -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -// MA 02110-1301 USA, or visit -// http://www.gnu.org/copyleft/gpl.html . -// -// As a special exception, I give you permission to link to the -// Avisynth C interface with independent modules that communicate with -// the Avisynth C interface solely through the interfaces defined in -// avisynth_c.h, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting combined work -// under terms of your choice, provided that every copy of the -// combined work is accompanied by a complete copy of the source code -// of the Avisynth C interface and Avisynth itself (with the version -// used to produce the combined work), being distributed under the -// terms of the GNU General Public License plus this exception. An -// independent module is a module which is not derived from or based -// on Avisynth C Interface, such as 3rd-party filters, import and -// export plugins, or graphical user interfaces. - -#ifndef __AVXSYNTH_C__ -#define __AVXSYNTH_C__ - -#include "windowsPorts/windows2linux.h" -#include - -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif - -#define AVSC_USE_STDCALL 1 - -#ifndef AVSC_USE_STDCALL -# define AVSC_CC __cdecl -#else -# define AVSC_CC __stdcall -#endif - -#define AVSC_INLINE static __inline - -#ifdef AVISYNTH_C_EXPORTS -# define AVSC_EXPORT EXTERN_C -# define AVSC_API(ret, name) EXTERN_C __declspec(dllexport) ret AVSC_CC name -#else -# define AVSC_EXPORT EXTERN_C __declspec(dllexport) -# ifndef AVSC_NO_DECLSPEC -# define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name -# else -# define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) -# endif -#endif - -#ifdef __GNUC__ -typedef long long int INT64; -#else -typedef __int64 INT64; -#endif - - -///////////////////////////////////////////////////////////////////// -// -// Constants -// - -#ifndef __AVXSYNTH_H__ -enum { AVISYNTH_INTERFACE_VERSION = 3 }; -#endif - -enum {AVS_SAMPLE_INT8 = 1<<0, - AVS_SAMPLE_INT16 = 1<<1, - AVS_SAMPLE_INT24 = 1<<2, - AVS_SAMPLE_INT32 = 1<<3, - AVS_SAMPLE_FLOAT = 1<<4}; - -enum {AVS_PLANAR_Y=1<<0, - AVS_PLANAR_U=1<<1, - AVS_PLANAR_V=1<<2, - AVS_PLANAR_ALIGNED=1<<3, - AVS_PLANAR_Y_ALIGNED=AVS_PLANAR_Y|AVS_PLANAR_ALIGNED, - AVS_PLANAR_U_ALIGNED=AVS_PLANAR_U|AVS_PLANAR_ALIGNED, - AVS_PLANAR_V_ALIGNED=AVS_PLANAR_V|AVS_PLANAR_ALIGNED}; - - // Colorspace properties. -enum {AVS_CS_BGR = 1<<28, - AVS_CS_YUV = 1<<29, - AVS_CS_INTERLEAVED = 1<<30, - AVS_CS_PLANAR = 1<<31}; - - // Specific colorformats -enum { - AVS_CS_UNKNOWN = 0, - AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED, - AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED, - AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED, - AVS_CS_YV12 = 1<<3 | AVS_CS_YUV | AVS_CS_PLANAR, // y-v-u, planar - AVS_CS_I420 = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR, // y-u-v, planar - AVS_CS_IYUV = 1<<4 | AVS_CS_YUV | AVS_CS_PLANAR // same as above -}; - -enum { - AVS_IT_BFF = 1<<0, - AVS_IT_TFF = 1<<1, - AVS_IT_FIELDBASED = 1<<2}; - -enum { - AVS_FILTER_TYPE=1, - AVS_FILTER_INPUT_COLORSPACE=2, - AVS_FILTER_OUTPUT_TYPE=9, - AVS_FILTER_NAME=4, - AVS_FILTER_AUTHOR=5, - AVS_FILTER_VERSION=6, - AVS_FILTER_ARGS=7, - AVS_FILTER_ARGS_INFO=8, - AVS_FILTER_ARGS_DESCRIPTION=10, - AVS_FILTER_DESCRIPTION=11}; - -enum { //SUBTYPES - AVS_FILTER_TYPE_AUDIO=1, - AVS_FILTER_TYPE_VIDEO=2, - AVS_FILTER_OUTPUT_TYPE_SAME=3, - AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4}; - -enum { - AVS_CACHE_NOTHING=0, - AVS_CACHE_RANGE=1, - AVS_CACHE_ALL=2, - AVS_CACHE_AUDIO=3, - AVS_CACHE_AUDIO_NONE=4, - AVS_CACHE_AUDIO_AUTO=5 -}; - -#define AVS_FRAME_ALIGN 16 - -typedef struct AVS_Clip AVS_Clip; -typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment; - -///////////////////////////////////////////////////////////////////// -// -// AVS_VideoInfo -// - -// AVS_VideoInfo is layed out identicly to VideoInfo -typedef struct AVS_VideoInfo { - int width, height; // width=0 means no video - unsigned fps_numerator, fps_denominator; - int num_frames; - - int pixel_type; - - int audio_samples_per_second; // 0 means no audio - int sample_type; - INT64 num_audio_samples; - int nchannels; - - // Imagetype properties - - int image_type; -} AVS_VideoInfo; - -// useful functions of the above -AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p) - { return (p->width!=0); } - -AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p) - { return (p->audio_samples_per_second!=0); } - -AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p) - { return !!(p->pixel_type&AVS_CS_BGR); } - -AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p) - { return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties - -AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p) - { return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; } - -AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) - { return !!(p->pixel_type&AVS_CS_YUV ); } - -AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) - { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } - -AVSC_INLINE int avs_is_yv12(const AVS_VideoInfo * p) - { return ((p->pixel_type & AVS_CS_YV12) == AVS_CS_YV12)||((p->pixel_type & AVS_CS_I420) == AVS_CS_I420); } - -AVSC_INLINE int avs_is_color_space(const AVS_VideoInfo * p, int c_space) - { return ((p->pixel_type & c_space) == c_space); } - -AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property) - { return ((p->pixel_type & property)==property ); } - -AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p) - { return !!(p->pixel_type & AVS_CS_PLANAR); } - -AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p) - { return !!(p->image_type & AVS_IT_FIELDBASED); } - -AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p) - { return ((p->image_type & AVS_IT_FIELDBASED)&&(p->image_type & (AVS_IT_BFF | AVS_IT_TFF))); } - -AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p) - { return !!(p->image_type & AVS_IT_BFF); } - -AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p) - { return !!(p->image_type & AVS_IT_TFF); } - -AVSC_INLINE int avs_bits_per_pixel(const AVS_VideoInfo * p) -{ - switch (p->pixel_type) { - case AVS_CS_BGR24: return 24; - case AVS_CS_BGR32: return 32; - case AVS_CS_YUY2: return 16; - case AVS_CS_YV12: - case AVS_CS_I420: return 12; - default: return 0; - } -} -AVSC_INLINE int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels) - { return pixels * (avs_bits_per_pixel(p)>>3); } // Will work on planar images, but will return only luma planes - -AVSC_INLINE int avs_row_size(const AVS_VideoInfo * p) - { return avs_bytes_from_pixels(p,p->width); } // Also only returns first plane on planar images - -AVSC_INLINE int avs_bmp_size(const AVS_VideoInfo * vi) - { if (avs_is_planar(vi)) {int p = vi->height * ((avs_row_size(vi)+3) & ~3); p+=p>>1; return p; } return vi->height * ((avs_row_size(vi)+3) & ~3); } - -AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p) - { return p->audio_samples_per_second; } - - -AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p) -{ - switch (p->sample_type) { - case AVS_SAMPLE_INT8: return sizeof(signed char); - case AVS_SAMPLE_INT16: return sizeof(signed short); - case AVS_SAMPLE_INT24: return 3; - case AVS_SAMPLE_INT32: return sizeof(signed int); - case AVS_SAMPLE_FLOAT: return sizeof(float); - default: return 0; - } -} -AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p) - { return p->nchannels*avs_bytes_per_channel_sample(p);} - -AVSC_INLINE INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames) - { return ((INT64)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); } - -AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) - { return (int)(samples * (INT64)p->fps_numerator / (INT64)p->fps_denominator / (INT64)p->audio_samples_per_second); } - -AVSC_INLINE INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes) - { return bytes / avs_bytes_per_audio_sample(p); } - -AVSC_INLINE INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples) - { return samples * avs_bytes_per_audio_sample(p); } - -AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p) - { return p->nchannels; } - -AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p) - { return p->sample_type;} - -// useful mutator -AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property) - { p->image_type|=property; } - -AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property) - { p->image_type&=~property; } - -AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased) - { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; } - -AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator) -{ - unsigned x=numerator, y=denominator; - while (y) { // find gcd - unsigned t = x%y; x = y; y = t; - } - p->fps_numerator = numerator/x; - p->fps_denominator = denominator/x; -} - -AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y) -{ - return (x->pixel_type == y->pixel_type) - || (avs_is_yv12(x) && avs_is_yv12(y)); -} - -///////////////////////////////////////////////////////////////////// -// -// AVS_VideoFrame -// - -// VideoFrameBuffer holds information about a memory block which is used -// for video data. For efficiency, instances of this class are not deleted -// when the refcount reaches zero; instead they're stored in a linked list -// to be reused. The instances are deleted when the corresponding AVS -// file is closed. - -// AVS_VideoFrameBuffer is layed out identicly to VideoFrameBuffer -// DO NOT USE THIS STRUCTURE DIRECTLY -typedef struct AVS_VideoFrameBuffer { - unsigned char * data; - int data_size; - // sequence_number is incremented every time the buffer is changed, so - // that stale views can tell they're no longer valid. - long sequence_number; - - long refcount; -} AVS_VideoFrameBuffer; - -// VideoFrame holds a "window" into a VideoFrameBuffer. - -// AVS_VideoFrame is layed out identicly to IVideoFrame -// DO NOT USE THIS STRUCTURE DIRECTLY -typedef struct AVS_VideoFrame { - int refcount; - AVS_VideoFrameBuffer * vfb; - int offset, pitch, row_size, height, offsetU, offsetV, pitchUV; // U&V offsets are from top of picture. -} AVS_VideoFrame; - -// Access functions for AVS_VideoFrame -AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) { - return p->pitch;} - -AVSC_INLINE int avs_get_pitch_p(const AVS_VideoFrame * p, int plane) { - switch (plane) { - case AVS_PLANAR_U: case AVS_PLANAR_V: return p->pitchUV;} - return p->pitch;} - -AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) { - return p->row_size; } - -AVSC_INLINE int avs_get_row_size_p(const AVS_VideoFrame * p, int plane) { - int r; - switch (plane) { - case AVS_PLANAR_U: case AVS_PLANAR_V: - if (p->pitchUV) return p->row_size>>1; - else return 0; - case AVS_PLANAR_U_ALIGNED: case AVS_PLANAR_V_ALIGNED: - if (p->pitchUV) { - r = ((p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)) )>>1; // Aligned rowsize - if (r < p->pitchUV) - return r; - return p->row_size>>1; - } else return 0; - case AVS_PLANAR_Y_ALIGNED: - r = (p->row_size+AVS_FRAME_ALIGN-1)&(~(AVS_FRAME_ALIGN-1)); // Aligned rowsize - if (r <= p->pitch) - return r; - return p->row_size; - } - return p->row_size; -} - -AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) { - return p->height;} - -AVSC_INLINE int avs_get_height_p(const AVS_VideoFrame * p, int plane) { - switch (plane) { - case AVS_PLANAR_U: case AVS_PLANAR_V: - if (p->pitchUV) return p->height>>1; - return 0; - } - return p->height;} - -AVSC_INLINE const unsigned char* avs_get_read_ptr(const AVS_VideoFrame * p) { - return p->vfb->data + p->offset;} - -AVSC_INLINE const unsigned char* avs_get_read_ptr_p(const AVS_VideoFrame * p, int plane) -{ - switch (plane) { - case AVS_PLANAR_U: return p->vfb->data + p->offsetU; - case AVS_PLANAR_V: return p->vfb->data + p->offsetV; - default: return p->vfb->data + p->offset;} -} - -AVSC_INLINE int avs_is_writable(const AVS_VideoFrame * p) { - return (p->refcount == 1 && p->vfb->refcount == 1);} - -AVSC_INLINE unsigned char* avs_get_write_ptr(const AVS_VideoFrame * p) -{ - if (avs_is_writable(p)) { - ++p->vfb->sequence_number; - return p->vfb->data + p->offset; - } else - return 0; -} - -AVSC_INLINE unsigned char* avs_get_write_ptr_p(const AVS_VideoFrame * p, int plane) -{ - if (plane==AVS_PLANAR_Y && avs_is_writable(p)) { - ++p->vfb->sequence_number; - return p->vfb->data + p->offset; - } else if (plane==AVS_PLANAR_Y) { - return 0; - } else { - switch (plane) { - case AVS_PLANAR_U: return p->vfb->data + p->offsetU; - case AVS_PLANAR_V: return p->vfb->data + p->offsetV; - default: return p->vfb->data + p->offset; - } - } -} - -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *); -// makes a shallow copy of a video frame -AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *); -#if defined __cplusplus -} -#endif // __cplusplus - -#ifndef AVSC_NO_DECLSPEC -AVSC_INLINE void avs_release_frame(AVS_VideoFrame * f) - {avs_release_video_frame(f);} -AVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f) - {return avs_copy_video_frame(f);} -#endif - -///////////////////////////////////////////////////////////////////// -// -// AVS_Value -// - -// Treat AVS_Value as a fat pointer. That is use avs_copy_value -// and avs_release_value appropiaty as you would if AVS_Value was -// a pointer. - -// To maintain source code compatibility with future versions of the -// avisynth_c API don't use the AVS_Value directly. Use the helper -// functions below. - -// AVS_Value is layed out identicly to AVSValue -typedef struct AVS_Value AVS_Value; -struct AVS_Value { - short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong - // for some function e'rror - short array_size; - union { - void * clip; // do not use directly, use avs_take_clip - char boolean; - int integer; - INT64 integer64; // match addition of __int64 to avxplugin.h - float floating_pt; - const char * string; - const AVS_Value * array; - } d; -}; - -// AVS_Value should be initilized with avs_void. -// Should also set to avs_void after the value is released -// with avs_copy_value. Consider it the equalvent of setting -// a pointer to NULL -static const AVS_Value avs_void = {'v'}; - -AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src); -AVSC_API(void, avs_release_value)(AVS_Value); - -AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; } -AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; } -AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; } -AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; } -AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; } -AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; } -AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; } -AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; } - -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); -AVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *); -#if defined __cplusplus -} -#endif // __cplusplus - -AVSC_INLINE int avs_as_bool(AVS_Value v) - { return v.d.boolean; } -AVSC_INLINE int avs_as_int(AVS_Value v) - { return v.d.integer; } -AVSC_INLINE const char * avs_as_string(AVS_Value v) - { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; } -AVSC_INLINE double avs_as_float(AVS_Value v) - { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; } -AVSC_INLINE const char * avs_as_error(AVS_Value v) - { return avs_is_error(v) ? v.d.string : 0; } -AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v) - { return v.d.array; } -AVSC_INLINE int avs_array_size(AVS_Value v) - { return avs_is_array(v) ? v.array_size : 1; } -AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index) - { return avs_is_array(v) ? v.d.array[index] : v; } - -// only use these functions on am AVS_Value that does not already have -// an active value. Remember, treat AVS_Value as a fat pointer. -AVSC_INLINE AVS_Value avs_new_value_bool(int v0) - { AVS_Value v = {0}; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; } -AVSC_INLINE AVS_Value avs_new_value_int(int v0) - { AVS_Value v = {0}; v.type = 'i'; v.d.integer = v0; return v; } -AVSC_INLINE AVS_Value avs_new_value_string(const char * v0) - { AVS_Value v = {0}; v.type = 's'; v.d.string = v0; return v; } -AVSC_INLINE AVS_Value avs_new_value_float(float v0) - { AVS_Value v = {0}; v.type = 'f'; v.d.floating_pt = v0; return v;} -AVSC_INLINE AVS_Value avs_new_value_error(const char * v0) - { AVS_Value v = {0}; v.type = 'e'; v.d.string = v0; return v; } -#ifndef AVSC_NO_DECLSPEC -AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0) - { AVS_Value v = {0}; avs_set_to_clip(&v, v0); return v; } -#endif -AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) - { AVS_Value v = {0}; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; } - -///////////////////////////////////////////////////////////////////// -// -// AVS_Clip -// -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(void, avs_release_clip)(AVS_Clip *); -AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *); - -AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error - -AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *); - -AVSC_API(int, avs_get_version)(AVS_Clip *); - -AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n); -// The returned video frame must be released with avs_release_video_frame - -AVSC_API(int, avs_get_parity)(AVS_Clip *, int n); -// return field parity if field_based, else parity of first field in frame - -AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf, - INT64 start, INT64 count); -// start and count are in samples - -AVSC_API(int, avs_set_cache_hints)(AVS_Clip *, - int cachehints, size_t frame_range); -#if defined __cplusplus -} -#endif // __cplusplus - -// This is the callback type used by avs_add_function -typedef AVS_Value (AVSC_CC * AVS_ApplyFunc) - (AVS_ScriptEnvironment *, AVS_Value args, void * user_data); - -typedef struct AVS_FilterInfo AVS_FilterInfo; -struct AVS_FilterInfo -{ - // these members should not be modified outside of the AVS_ApplyFunc callback - AVS_Clip * child; - AVS_VideoInfo vi; - AVS_ScriptEnvironment * env; - AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n); - int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n); - int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf, - INT64 start, INT64 count); - int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints, - int frame_range); - void (AVSC_CC * free_filter)(AVS_FilterInfo *); - - // Should be set when ever there is an error to report. - // It is cleared before any of the above methods are called - const char * error; - // this is to store whatever and may be modified at will - void * user_data; -}; - -// Create a new filter -// fi is set to point to the AVS_FilterInfo so that you can -// modify it once it is initilized. -// store_child should generally be set to true. If it is not -// set than ALL methods (the function pointers) must be defined -// If it is set than you do not need to worry about freeing the child -// clip. -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e, - AVS_FilterInfo * * fi, - AVS_Value child, int store_child); -#if defined __cplusplus -} -#endif // __cplusplus - - -///////////////////////////////////////////////////////////////////// -// -// AVS_ScriptEnvironment -// - -// For GetCPUFlags. These are backwards-compatible with those in VirtualDub. -enum { - /* slowest CPU to support extension */ - AVS_CPU_FORCE = 0x01, // N/A - AVS_CPU_FPU = 0x02, // 386/486DX - AVS_CPU_MMX = 0x04, // P55C, K6, PII - AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon - AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP - AVS_CPU_SSE2 = 0x20, // PIV, Hammer - AVS_CPU_3DNOW = 0x40, // K6-2 - AVS_CPU_3DNOW_EXT = 0x80, // Athlon - AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, - // which only Hammer will have anyway) -}; - -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error - -AVSC_API(long, avs_get_cpu_flags)(AVS_ScriptEnvironment *); -AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version); - -AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length); -AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...); - -AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val); - // note: val is really a va_list; I hope everyone typedefs va_list to a pointer - -AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *, - const char * name, const char * params, - AVS_ApplyFunc apply, void * user_data); - -AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name); - -AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name, - AVS_Value args, const char** arg_names); -// The returned value must be be released with avs_release_value - -AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name); -// The returned value must be be released with avs_release_value - -AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val); - -AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val); - -//void avs_push_context(AVS_ScriptEnvironment *, int level=0); -//void avs_pop_context(AVS_ScriptEnvironment *); - -AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *, - const AVS_VideoInfo * vi, int align); -// align should be at least 16 -#if defined __cplusplus -} -#endif // __cplusplus - -#ifndef AVSC_NO_DECLSPEC -AVSC_INLINE -AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env, - const AVS_VideoInfo * vi) - {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} - -AVSC_INLINE -AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env, - const AVS_VideoInfo * vi) - {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);} -#endif - -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf); - -AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, unsigned char* dstp, int dst_pitch, const unsigned char* srcp, int src_pitch, int row_size, int height); - -typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env); -AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data); - -AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height); -// The returned video frame must be be released - -AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem); - -AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir); - -// avisynth.dll exports this; it's a way to use it as a library, without -// writing an AVS script or without going through AVIFile. -AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version); -#if defined __cplusplus -} -#endif // __cplusplus - -// this symbol is the entry point for the plugin and must -// be defined -AVSC_EXPORT -const char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env); - - -#if defined __cplusplus -extern "C" -{ -#endif // __cplusplus -AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *); - - -AVSC_API(AVS_VideoFrame *, avs_subframe_planar)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV); -// The returned video frame must be be released -#if defined __cplusplus -} -#endif // __cplusplus - -#endif //__AVXSYNTH_C__ diff --git a/compat/avisynth/windowsPorts/basicDataTypeConversions.h b/compat/avisynth/windowsPorts/basicDataTypeConversions.h deleted file mode 100644 index ff367d5a2a..0000000000 --- a/compat/avisynth/windowsPorts/basicDataTypeConversions.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef __DATA_TYPE_CONVERSIONS_H__ -#define __DATA_TYPE_CONVERSIONS_H__ - -#include -#include - -#ifdef __cplusplus -namespace avxsynth { -#endif // __cplusplus - -typedef int64_t __int64; -typedef int32_t __int32; -#ifdef __cplusplus -typedef bool BOOL; -#else -typedef uint32_t BOOL; -#endif // __cplusplus -typedef void* HMODULE; -typedef void* LPVOID; -typedef void* PVOID; -typedef PVOID HANDLE; -typedef HANDLE HWND; -typedef HANDLE HINSTANCE; -typedef void* HDC; -typedef void* HBITMAP; -typedef void* HICON; -typedef void* HFONT; -typedef void* HGDIOBJ; -typedef void* HBRUSH; -typedef void* HMMIO; -typedef void* HACMSTREAM; -typedef void* HACMDRIVER; -typedef void* HIC; -typedef void* HACMOBJ; -typedef HACMSTREAM* LPHACMSTREAM; -typedef void* HACMDRIVERID; -typedef void* LPHACMDRIVER; -typedef unsigned char BYTE; -typedef BYTE* LPBYTE; -typedef char TCHAR; -typedef TCHAR* LPTSTR; -typedef const TCHAR* LPCTSTR; -typedef char* LPSTR; -typedef LPSTR LPOLESTR; -typedef const char* LPCSTR; -typedef LPCSTR LPCOLESTR; -typedef wchar_t WCHAR; -typedef unsigned short WORD; -typedef unsigned int UINT; -typedef UINT MMRESULT; -typedef uint32_t DWORD; -typedef DWORD COLORREF; -typedef DWORD FOURCC; -typedef DWORD HRESULT; -typedef DWORD* LPDWORD; -typedef DWORD* DWORD_PTR; -typedef int32_t LONG; -typedef int32_t* LONG_PTR; -typedef LONG_PTR LRESULT; -typedef uint32_t ULONG; -typedef uint32_t* ULONG_PTR; -//typedef __int64_t intptr_t; -typedef uint64_t _fsize_t; - - -// -// Structures -// - -typedef struct _GUID { - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[8]; -} GUID; - -typedef GUID REFIID; -typedef GUID CLSID; -typedef CLSID* LPCLSID; -typedef GUID IID; - -#ifdef __cplusplus -}; // namespace avxsynth -#endif // __cplusplus -#endif // __DATA_TYPE_CONVERSIONS_H__ diff --git a/compat/avisynth/windowsPorts/windows2linux.h b/compat/avisynth/windowsPorts/windows2linux.h deleted file mode 100644 index 7cf4600266..0000000000 --- a/compat/avisynth/windowsPorts/windows2linux.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef __WINDOWS2LINUX_H__ -#define __WINDOWS2LINUX_H__ - -/* - * LINUX SPECIFIC DEFINITIONS -*/ -// -// Data types conversions -// -#include -#include -#include "basicDataTypeConversions.h" - -#ifdef __cplusplus -namespace avxsynth { -#endif // __cplusplus -// -// purposefully define the following MSFT definitions -// to mean nothing (as they do not mean anything on Linux) -// -#define __stdcall -#define __cdecl -#define noreturn -#define __declspec(x) -#define STDAPI extern "C" HRESULT -#define STDMETHODIMP HRESULT __stdcall -#define STDMETHODIMP_(x) x __stdcall - -#define STDMETHOD(x) virtual HRESULT x -#define STDMETHOD_(a, x) virtual a x - -#ifndef TRUE -#define TRUE true -#endif - -#ifndef FALSE -#define FALSE false -#endif - -#define S_OK (0x00000000) -#define S_FALSE (0x00000001) -#define E_NOINTERFACE (0X80004002) -#define E_POINTER (0x80004003) -#define E_FAIL (0x80004005) -#define E_OUTOFMEMORY (0x8007000E) - -#define INVALID_HANDLE_VALUE ((HANDLE)((LONG_PTR)-1)) -#define FAILED(hr) ((hr) & 0x80000000) -#define SUCCEEDED(hr) (!FAILED(hr)) - - -// -// Functions -// -#define MAKEDWORD(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) -#define MAKEWORD(a,b) (((a) << 8) | (b)) - -#define lstrlen strlen -#define lstrcpy strcpy -#define lstrcmpi strcasecmp -#define _stricmp strcasecmp -#define InterlockedIncrement(x) __sync_fetch_and_add((x), 1) -#define InterlockedDecrement(x) __sync_fetch_and_sub((x), 1) -// Windows uses (new, old) ordering but GCC has (old, new) -#define InterlockedCompareExchange(x,y,z) __sync_val_compare_and_swap(x,z,y) - -#define UInt32x32To64(a, b) ( (uint64_t) ( ((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)) ) ) -#define Int64ShrlMod32(a, b) ( (uint64_t) ( (uint64_t)(a) >> (b) ) ) -#define Int32x32To64(a, b) ((__int64)(((__int64)((long)(a))) * ((long)(b)))) - -#define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator)) - -#ifdef __cplusplus -}; // namespace avxsynth -#endif // __cplusplus - -#endif // __WINDOWS2LINUX_H__ diff --git a/compat/cuda/dynlink_cuda.h b/compat/cuda/dynlink_cuda.h deleted file mode 100644 index 3a13611ce6..0000000000 --- a/compat/cuda/dynlink_cuda.h +++ /dev/null @@ -1,98 +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 - -#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; -typedef void* CUstream; -#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 diff --git a/compat/cuda/dynlink_cuviddec.h b/compat/cuda/dynlink_cuviddec.h deleted file mode 100644 index 4af78a186b..0000000000 --- a/compat/cuda/dynlink_cuviddec.h +++ /dev/null @@ -1,886 +0,0 @@ -/* - * This copyright notice applies to this header file only: - * - * Copyright (c) 2010-2017 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 -//! NVDECODE API provides video decoding interface to NVIDIA GPU devices. -//! \date 2015-2017 -//! This file contains constants, structure definitions and function prototypes used for decoding. -/*****************************************************************************************************/ - -#if !defined(__CUDA_VIDEO_H__) -#define __CUDA_VIDEO_H__ - -#if defined(_WIN64) || defined(__LP64__) || 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; - -/*********************************************************************************/ -//! \enum cudaVideoCodec -//! Video codec enums -//! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures -/*********************************************************************************/ -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 format enums used for output format of decoded output -//! These enums are used in CUVIDDECODECREATEINFO structure -/*********************************************************************************/ -typedef enum cudaVideoSurfaceFormat_enum { - cudaVideoSurfaceFormat_NV12=0, /**< NV12 format */ - cudaVideoSurfaceFormat_P016=1 /**< 16 bit semiplaner format. Can be used for 10 bit(6LSB bits 0), - 12 bit (4LSB bits 0) */ -} cudaVideoSurfaceFormat; - -/******************************************************************************************************************/ -//! \enum cudaVideoDeinterlaceMode -//! Deinterlacing mode enums -//! These enums are used in CUVIDDECODECREATEINFO structure -//! Use cudaVideoDeinterlaceMode_Weave for progressive content and for content that doesn't need deinterlacing -//! cudaVideoDeinterlaceMode_Adaptive needs more video memory than other DImodes -/******************************************************************************************************************/ -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 format enums -//! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures -//! JPEG supports Monochrome, YUV 4:2:0, YUV 4:2:2 and YUV 4:4:4 chroma formats. -//! H264, HEVC, VP9, VP8, VC1, MPEG1, MPEG2 and MPEG4 support YUV 4:2:0 chroma format only. -/**************************************************************************************************************/ -typedef enum cudaVideoChromaFormat_enum { - cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */ - cudaVideoChromaFormat_420, /**< YUV 4:2:0 */ - cudaVideoChromaFormat_422, /**< YUV 4:2:2 */ - cudaVideoChromaFormat_444 /**< YUV 4:4:4 */ -} cudaVideoChromaFormat; - -/*************************************************************************************************************/ -//! \enum cudaVideoCreateFlags -//! Decoder flag enums to select preferred decode path -//! cudaVideoCreate_Default and cudaVideoCreate_PreferCUVID are most optimized, use these whenever possible -/*************************************************************************************************************/ -typedef enum cudaVideoCreateFlags_enum { - cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */ - cudaVideoCreate_PreferCUDA = 0x01, /**< Use CUDA-based decoder (requires 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 CUVIDDECODECAPS; -//! This structure is used in cuvidGetDecoderCaps API -/**************************************************************************************************************/ -typedef struct _CUVIDDECODECAPS -{ - cudaVideoCodec eCodecType; /**< IN: cudaVideoCodec_XXX */ - cudaVideoChromaFormat eChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */ - unsigned int nBitDepthMinus8; /**< IN: The Value "BitDepth minus 8" */ - unsigned int reserved1[3]; /**< Reserved for future use - set to zero */ - - unsigned char bIsSupported; /**< OUT: 1 if codec supported, 0 if not supported */ - unsigned char reserved2[3]; /**< Reserved for future use - set to zero */ - unsigned int nMaxWidth; /**< OUT: Max supported coded width in pixels */ - unsigned int nMaxHeight; /**< OUT: Max supported coded height in pixels */ - unsigned int nMaxMBCount; /**< OUT: Max supported macroblock count - CodedWidth*CodedHeight/256 must be <= nMaxMBCount */ - unsigned short nMinWidth; /**< OUT: Min supported coded width in pixels */ - unsigned short nMinHeight; /**< OUT: Min supported coded height in pixels */ - unsigned int reserved3[11]; /**< Reserved for future use - set to zero */ -} CUVIDDECODECAPS; - -/**************************************************************************************************************/ -//! \struct CUVIDDECODECREATEINFO -//! This structure is used in cuvidCreateDecoder API -/**************************************************************************************************************/ -typedef struct _CUVIDDECODECREATEINFO -{ - tcu_ulong ulWidth; /**< IN: Coded sequence width in pixels */ - tcu_ulong ulHeight; /**< IN: Coded sequence height in pixels */ - tcu_ulong ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ - cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */ - cudaVideoChromaFormat ChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */ - tcu_ulong ulCreationFlags; /**< IN: Decoder creation flags (cudaVideoCreateFlags_XXX) */ - tcu_ulong bitDepthMinus8; /**< IN: The value "BitDepth minus 8" */ - tcu_ulong ulIntraDecodeOnly; /**< IN: Set 1 only if video has all intra frames (default value is 0). This will - optimize video memory for Intra frames only decoding. The support is limited - to specific codecs(H264 rightnow), the flag will be ignored for codecs which - are not supported. However decoding might fail if the flag is enabled in case - of supported codecs for regular bit streams having P and/or B frames. */ - tcu_ulong Reserved1[3]; /**< Reserved for future use - set to zero */ - /** - * IN: area of the frame that should be displayed - */ - struct { - short left; - short top; - short right; - short bottom; - } display_area; - - cudaVideoSurfaceFormat OutputFormat; /**< IN: cudaVideoSurfaceFormat_XXX */ - cudaVideoDeinterlaceMode DeinterlaceMode; /**< IN: cudaVideoDeinterlaceMode_XXX */ - tcu_ulong ulTargetWidth; /**< IN: Post-processed output width (Should be aligned to 2) */ - tcu_ulong ulTargetHeight; /**< IN: Post-processed output height (Should be aligbed to 2) */ - tcu_ulong ulNumOutputSurfaces; /**< IN: Maximum number of output surfaces simultaneously mapped */ - CUvideoctxlock vidLock; /**< IN: If non-NULL, context lock used for synchronizing ownership of - the cuda context. Needed for cudaVideoCreate_PreferCUDA decode */ - /** - * IN: 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 -//! This structure is used in CUVIDH264PICPARAMS structure -/*********************************************************/ -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 -//! This structure is used in CUVIDH264PICPARAMS structure -/************************************************************/ -typedef struct _CUVIDH264MVCEXT -{ - int num_views_minus1; /**< Max number of coded views minus 1 in video : Range - 0 to 1023 */ - int view_id; /**< view identifier */ - unsigned char inter_view_flag; /**< 1 if used for inter-view prediction, 0 if not */ - unsigned char num_inter_view_refs_l0; /**< number of inter-view ref pics in RefPicList0 */ - unsigned char num_inter_view_refs_l1; /**< number of inter-view ref pics in RefPicList1 */ - unsigned char MVCReserved8Bits; /**< Reserved bits */ - int InterViewRefsL0[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList0 */ - int InterViewRefsL1[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList1 */ -} CUVIDH264MVCEXT; - -/*********************************************************/ -//! \struct CUVIDH264SVCEXT -//! H.264 SVC picture parameters ext -//! This structure is used in CUVIDH264PICPARAMS structure -/*********************************************************/ -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; - - 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 -//! This structure is used in CUVIDPICPARAMS structure -/******************************************************/ -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; - }; -} CUVIDH264PICPARAMS; - - -/********************************************************/ -//! \struct CUVIDMPEG2PICPARAMS -//! MPEG-2 picture parameters -//! This structure is used in CUVIDPICPARAMS structure -/********************************************************/ -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 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 -//! This structure is used in CUVIDPICPARAMS structure -/*******************************************************/ -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 -//! This structure is used in CUVIDPICPARAMS structure -/********************************************************/ -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 -//! This structure is used in CUVIDPICPARAMS structure -/***********************************************************/ -typedef struct _CUVIDJPEGPICPARAMS -{ - int Reserved; -} CUVIDJPEGPICPARAMS; - - -/*******************************************************/ -//! \struct CUVIDHEVCPICPARAMS -//! HEVC picture parameters -//! This structure is used in CUVIDPICPARAMS structure -/*******************************************************/ -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 -//! This structure is used in CUVIDPICPARAMS structure -/***********************************************************/ -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; - }; - unsigned char Reserved1[4]; - unsigned int Reserved2[3]; -} CUVIDVP8PICPARAMS; - -/***********************************************************/ -//! \struct CUVIDVP9PICPARAMS -//! VP9 picture parameters -//! This structure is used in CUVIDPICPARAMS structure -/***********************************************************/ -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 -//! This structure is used in cuvidDecodePicture API -//! IN for cuvidDecodePicture -/******************************************************************************************/ -typedef struct _CUVIDPICPARAMS -{ - int PicWidthInMbs; /**< IN: Coded frame size in macroblocks */ - int FrameHeightInMbs; /**< IN: Coded frame height in macroblocks */ - int CurrPicIdx; /**< IN: Output index of the current picture */ - int field_pic_flag; /**< IN: 0=frame picture, 1=field picture */ - int bottom_field_flag; /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */ - int second_field; /**< IN: Second field of a complementary field pair */ - // Bitstream data - unsigned int nBitstreamDataLen; /**< IN: Number of bytes in bitstream data buffer */ - const unsigned char *pBitstreamData; /**< IN: Ptr to bitstream data for this picture (slice-layer) */ - unsigned int nNumSlices; /**< IN: Number of slices in this picture */ - const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within - the bitstream data buffer */ - int ref_pic_flag; /**< IN: This picture is a reference picture */ - int intra_pic_flag; /**< IN: This picture is entirely intra coded */ - unsigned int Reserved[30]; /**< Reserved for future use */ - // IN: 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 -//! This structure is used in cuvidMapVideoFrame API -/******************************************************/ -typedef struct _CUVIDPROCPARAMS -{ - int progressive_frame; /**< IN: Input is progressive (deinterlace_mode will be ignored) */ - int second_field; /**< IN: Output the second field (ignored if deinterlace mode is Weave) */ - int top_field_first; /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */ - int unpaired_field; /**< IN: 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; /**< IN: Input CUdeviceptr for raw YUV extensions */ - unsigned int raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately) */ - unsigned int raw_input_format; /**< IN: Input YUV format (cudaVideoCodec_enum) */ - unsigned long long raw_output_dptr; /**< IN: Output CUdeviceptr for raw YUV extensions */ - unsigned int raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */ - unsigned int Reserved1; /**< Reserved for future use (set to zero) */ - CUstream output_stream; /**< IN: stream object used by cuvidMapVideoFrame */ - unsigned int Reserved[46]; /**< Reserved for future use (set to zero) */ - void *Reserved2[2]; /**< Reserved for future use (set to zero) */ -} CUVIDPROCPARAMS; - - -/***********************************************************************************************************/ -//! VIDEO_DECODER -//! -//! 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: -//! - cuvidGetDecoderCaps(...) -//! - 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 cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc) -//! Queries decode capabilities of NVDEC-HW based on CodecType, ChromaFormat and BitDepthMinus8 parameters. -//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of CUVIDDECODECAPS structure -//! 2. On calling cuvidGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported -//! If IN parameters passed to the driver are not supported by NVDEC-HW, then all OUT params are set to 0. -//! E.g. on Geforce GTX 960: -//! App fills - eCodecType = cudaVideoCodec_H264; eChromaFormat = cudaVideoChromaFormat_420; nBitDepthMinus8 = 0; -//! Given IN parameters are supported, hence driver fills: bIsSupported = 1; nMinWidth = 48; nMinHeight = 16; -//! nMaxWidth = 4096; nMaxHeight = 4096; nMaxMBCount = 65536; -//! CodedWidth*CodedHeight/256 must be less than or equal to nMaxMBCount -/**********************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidGetDecoderCaps(CUVIDDECODECAPS *pdc); - -/********************************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci) -//! Create the decoder object based on pdci. A handle to the created decoder is returned -/********************************************************************************************************************/ -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) -//! Kicks off HW decoding -/********************************************************************************************************************/ -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 video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated -//! pitch of the video frame -/************************************************************************************************************************/ -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(__LP64__) || 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); -//! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated -//! pitch of the 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) -//! This API is used to create CtxLock object -/********************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx); - -/********************************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck) -//! This API is used to free CtxLock object -/********************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck); - -/********************************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags) -//! This API is used to acquire ctxlock -/********************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags); - -/********************************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags) -//! This API is used to release ctxlock -/********************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags); - -/**********************************************************************************************/ - -#if defined(__cplusplus) -} -#endif /* __cplusplus */ - -#endif // __CUDA_VIDEO_H__ diff --git a/compat/cuda/dynlink_loader.h b/compat/cuda/dynlink_loader.h deleted file mode 100644 index 7d2c87449e..0000000000 --- a/compat/cuda/dynlink_loader.h +++ /dev/null @@ -1,268 +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, tp, symbol) \ - do { \ - if (!((f->fun) = (tp*)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 LOAD_SYMBOL_OPT(fun, tp, symbol) \ - do { \ - if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) { \ - av_log(NULL, AV_LOG_DEBUG, "Cannot load optional %s\n", symbol); \ - } else { \ - 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 { - tcuvidGetDecoderCaps *cuvidGetDecoderCaps; - 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 NVENCSTATUS NVENCAPI tNvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList); -typedef NVENCSTATUS NVENCAPI tNvEncodeAPIGetMaxSupportedVersion(uint32_t* version); - -typedef struct NvencFunctions { - tNvEncodeAPICreateInstance *NvEncodeAPICreateInstance; - tNvEncodeAPIGetMaxSupportedVersion *NvEncodeAPIGetMaxSupportedVersion; - - 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, tcuInit, "cuInit"); - LOAD_SYMBOL(cuDeviceGetCount, tcuDeviceGetCount, "cuDeviceGetCount"); - LOAD_SYMBOL(cuDeviceGet, tcuDeviceGet, "cuDeviceGet"); - LOAD_SYMBOL(cuDeviceGetName, tcuDeviceGetName, "cuDeviceGetName"); - LOAD_SYMBOL(cuDeviceComputeCapability, tcuDeviceComputeCapability, "cuDeviceComputeCapability"); - LOAD_SYMBOL(cuCtxCreate, tcuCtxCreate_v2, "cuCtxCreate_v2"); - LOAD_SYMBOL(cuCtxPushCurrent, tcuCtxPushCurrent_v2, "cuCtxPushCurrent_v2"); - LOAD_SYMBOL(cuCtxPopCurrent, tcuCtxPopCurrent_v2, "cuCtxPopCurrent_v2"); - LOAD_SYMBOL(cuCtxDestroy, tcuCtxDestroy_v2, "cuCtxDestroy_v2"); - LOAD_SYMBOL(cuMemAlloc, tcuMemAlloc_v2, "cuMemAlloc_v2"); - LOAD_SYMBOL(cuMemFree, tcuMemFree_v2, "cuMemFree_v2"); - LOAD_SYMBOL(cuMemcpy2D, tcuMemcpy2D_v2, "cuMemcpy2D_v2"); - LOAD_SYMBOL(cuGetErrorName, tcuGetErrorName, "cuGetErrorName"); - LOAD_SYMBOL(cuGetErrorString, tcuGetErrorString, "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_OPT(cuvidGetDecoderCaps, tcuvidGetDecoderCaps, "cuvidGetDecoderCaps"); - LOAD_SYMBOL(cuvidCreateDecoder, tcuvidCreateDecoder, "cuvidCreateDecoder"); - LOAD_SYMBOL(cuvidDestroyDecoder, tcuvidDestroyDecoder, "cuvidDestroyDecoder"); - LOAD_SYMBOL(cuvidDecodePicture, tcuvidDecodePicture, "cuvidDecodePicture"); -#ifdef __CUVID_DEVPTR64 - LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame64"); - LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64"); -#else - LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame"); - LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame"); -#endif - LOAD_SYMBOL(cuvidCtxLockCreate, tcuvidCtxLockCreate, "cuvidCtxLockCreate"); - LOAD_SYMBOL(cuvidCtxLockDestroy, tcuvidCtxLockDestroy, "cuvidCtxLockDestroy"); - LOAD_SYMBOL(cuvidCtxLock, tcuvidCtxLock, "cuvidCtxLock"); - LOAD_SYMBOL(cuvidCtxUnlock, tcuvidCtxUnlock, "cuvidCtxUnlock"); - - LOAD_SYMBOL(cuvidCreateVideoSource, tcuvidCreateVideoSource, "cuvidCreateVideoSource"); - LOAD_SYMBOL(cuvidCreateVideoSourceW, tcuvidCreateVideoSourceW, "cuvidCreateVideoSourceW"); - LOAD_SYMBOL(cuvidDestroyVideoSource, tcuvidDestroyVideoSource, "cuvidDestroyVideoSource"); - LOAD_SYMBOL(cuvidSetVideoSourceState, tcuvidSetVideoSourceState, "cuvidSetVideoSourceState"); - LOAD_SYMBOL(cuvidGetVideoSourceState, tcuvidGetVideoSourceState, "cuvidGetVideoSourceState"); - LOAD_SYMBOL(cuvidGetSourceVideoFormat, tcuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat"); - LOAD_SYMBOL(cuvidGetSourceAudioFormat, tcuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat"); - LOAD_SYMBOL(cuvidCreateVideoParser, tcuvidCreateVideoParser, "cuvidCreateVideoParser"); - LOAD_SYMBOL(cuvidParseVideoData, tcuvidParseVideoData, "cuvidParseVideoData"); - LOAD_SYMBOL(cuvidDestroyVideoParser, tcuvidDestroyVideoParser, "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, tNvEncodeAPICreateInstance, "NvEncodeAPICreateInstance"); - LOAD_SYMBOL(NvEncodeAPIGetMaxSupportedVersion, tNvEncodeAPIGetMaxSupportedVersion, "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 - diff --git a/compat/cuda/dynlink_nvcuvid.h b/compat/cuda/dynlink_nvcuvid.h deleted file mode 100644 index 87294248e5..0000000000 --- a/compat/cuda/dynlink_nvcuvid.h +++ /dev/null @@ -1,356 +0,0 @@ -/* - * This copyright notice applies to this header file only: - * - * Copyright (c) 2010-2017 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 -//! NVDECODE API provides video decoding interface to NVIDIA GPU devices. -//! \date 2015-2017 -//! 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 */ - -/********************************* -** Initialization -*********************************/ -CUresult CUDAAPI cuvidInit(unsigned int Flags); - -/***********************************************/ -//! -//! High-level helper APIs for video sources -//! -/***********************************************/ - -typedef void *CUvideosource; -typedef void *CUvideoparser; -typedef long long CUvideotimestamp; - - -/************************************************************************/ -//! \enum cudaVideoState -//! Video source state enums -//! Used in cuvidSetVideoSourceState and cuvidGetVideoSourceState APIs -/************************************************************************/ -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 enums -//! Used in CUAUDIOFORMAT structure -/************************************************************************/ -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_AAC, /**< AAC Audio */ -} cudaAudioCodec; - -/************************************************************************************************/ -//! \ingroup STRUCTS -//! \struct CUVIDEOFORMAT -//! Video format -//! Used in cuvidGetSourceVideoFormat API -/************************************************************************************************/ -typedef struct -{ - cudaVideoCodec codec; /**< OUT: Compression format */ - /** - * OUT: frame rate = numerator / denominator (for example: 30000/1001) - */ - struct { - /**< OUT: frame rate numerator (0 = unspecified or variable frame rate) */ - unsigned int numerator; - /**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */ - unsigned int denominator; - } frame_rate; - unsigned char progressive_sequence; /**< OUT: 0=interlaced, 1=progressive */ - unsigned char bit_depth_luma_minus8; /**< OUT: high bit depth luma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */ - unsigned char bit_depth_chroma_minus8; /**< OUT: high bit depth chroma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */ - unsigned char reserved1; /**< Reserved for future use */ - unsigned int coded_width; /**< OUT: coded frame width in pixels */ - unsigned int coded_height; /**< OUT: coded frame height in pixels */ - /** - * 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; /**< OUT: left position of display rect */ - int top; /**< OUT: top position of display rect */ - int right; /**< OUT: right position of display rect */ - int bottom; /**< OUT: bottom position of display rect */ - } display_area; - cudaVideoChromaFormat chroma_format; /**< OUT: Chroma format */ - unsigned int bitrate; /**< OUT: video bitrate (bps, 0=unknown) */ - /** - * OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc) - */ - struct { - int x; - int y; - } display_aspect_ratio; - /** - * Video Signal Description - * Refer section E.2.1 (VUI parameters semantics) of H264 spec file - */ - struct { - unsigned char video_format : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC, 3-SECAM, 4-MAC, 5-Unspecified */ - unsigned char video_full_range_flag : 1; /**< OUT: indicates the black level and luma and chroma range */ - unsigned char reserved_zero_bits : 4; /**< Reserved bits */ - unsigned char color_primaries; /**< OUT: chromaticity coordinates of source primaries */ - unsigned char transfer_characteristics; /**< OUT: opto-electronic transfer characteristic of the source picture */ - unsigned char matrix_coefficients; /**< OUT: used in deriving luma and chroma signals from RGB primaries */ - } video_signal_description; - unsigned int seqhdr_data_length; /**< OUT: Additional bytes following (CUVIDEOFORMATEX) */ -} CUVIDEOFORMAT; - -/****************************************************************/ -//! \ingroup STRUCTS -//! \struct CUVIDEOFORMATEX -//! Video format including raw sequence header information -//! Used in cuvidGetSourceVideoFormat API -/****************************************************************/ -typedef struct -{ - CUVIDEOFORMAT format; /**< OUT: CUVIDEOFORMAT structure */ - unsigned char raw_seqhdr_data[1024]; /**< OUT: Sequence header data */ -} CUVIDEOFORMATEX; - -/****************************************************************/ -//! \ingroup STRUCTS -//! \struct CUAUDIOFORMAT -//! Audio formats -//! Used in cuvidGetSourceAudioFormat API -/****************************************************************/ -typedef struct -{ - cudaAudioCodec codec; /**< OUT: Compression format */ - unsigned int channels; /**< OUT: number of audio channels */ - unsigned int samplespersec; /**< OUT: sampling frequency */ - unsigned int bitrate; /**< OUT: 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 -//! Used in CUVIDSOURCEDATAPACKET structure -/***************************************************************/ -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 */ - CUVID_PKT_ENDOFPICTURE = 0x08, /**< Set when the packet contains exactly one frame */ -} CUvideopacketflags; - -/*****************************************************************************/ -//! \ingroup STRUCTS -//! \struct CUVIDSOURCEDATAPACKET -//! Data Packet -//! Used in cuvidParseVideoData API -//! IN for cuvidParseVideoData -/*****************************************************************************/ -typedef struct _CUVIDSOURCEDATAPACKET -{ - tcu_ulong flags; /**< IN: Combination of CUVID_PKT_XXX flags */ - tcu_ulong payload_size; /**< IN: number of bytes in the payload (may be zero if EOS flag is set) */ - const unsigned char *payload; /**< IN: Pointer to packet payload data (may be NULL if EOS flag is set) */ - CUvideotimestamp timestamp; /**< IN: Presentation time stamp (10MHz clock), only valid if - CUVID_PKT_TIMESTAMP flag is set */ -} CUVIDSOURCEDATAPACKET; - -// Callback for packet delivery -typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *); - -/**************************************************************************************************************************/ -//! \ingroup STRUCTS -//! \struct CUVIDSOURCEPARAMS -//! Describes parameters needed in cuvidCreateVideoSource API -//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported -//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. -/**************************************************************************************************************************/ -typedef struct _CUVIDSOURCEPARAMS -{ - unsigned int ulClockRate; /**< IN: Time stamp units in Hz (0=default=10000000Hz) */ - unsigned int uReserved1[7]; /**< Reserved for future use - set to zero */ - void *pUserData; /**< IN: User private data passed in to the data handlers */ - PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< IN: Called to deliver video packets */ - PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< IN: Called to deliver audio packets. */ - void *pvReserved2[8]; /**< Reserved for future use - set to NULL */ -} CUVIDSOURCEPARAMS; - - -/**********************************************/ -//! \ingroup ENUMS -//! \enum CUvideosourceformat_flags -//! CUvideosourceformat_flags -//! Used in cuvidGetSourceVideoFormat API -/**********************************************/ -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 CUvideosource object. CUvideosource spawns demultiplexer thread that provides two callbacks: -//! pfnVideoDataHandler() and pfnAudioDataHandler() -//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported -//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. -/**************************************************************************************************************************/ -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 object and initialize -/****************************************************************************************************************************/ -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) -//! Gets details of video stream in pvidfmt -/****************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags); - -/****************************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags) -//! Get audio source format -//! NVDECODE API is intended for HW accelarated video decoding so CUvideosource doesn't have audio demuxer for all suppported -//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. -/****************************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags); - -#endif -/**********************************************************************************/ -//! \ingroup STRUCTS -//! \struct CUVIDPARSERDISPINFO -//! Used in cuvidParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture -/**********************************************************************************/ -typedef struct _CUVIDPARSERDISPINFO -{ - int picture_index; /**< OUT: Index of the current picture */ - int progressive_frame; /**< OUT: 1 if progressive frame; 0 otherwise */ - int top_field_first; /**< OUT: 1 if top field is displayed first; 0 otherwise */ - int repeat_first_field; /**< OUT: Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, - -1=unpaired field) */ - CUvideotimestamp timestamp; /**< OUT: Presentation time stamp */ -} CUVIDPARSERDISPINFO; - -/***********************************************************************************************************************/ -//! Parser callbacks -//! The parser will call these synchronously from within cuvidParseVideoData(), whenever a picture is ready to -//! be decoded and/or displayed. First argument in functions is "void *pUserData" member of structure CUVIDSOURCEPARAMS -/***********************************************************************************************************************/ -typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *); -typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *); -typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *); - -/**************************************/ -//! \ingroup STRUCTS -//! \struct CUVIDPARSERPARAMS -//! Used in cuvidCreateVideoParser API -/**************************************/ -typedef struct _CUVIDPARSERPARAMS -{ - cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */ - unsigned int ulMaxNumDecodeSurfaces; /**< IN: Max # of decode surfaces (parser will cycle through these) */ - unsigned int ulClockRate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */ - unsigned int ulErrorThreshold; /**< IN: % Error threshold (0-100) for calling pfnDecodePicture (100=always - IN: call pfnDecodePicture even if picture bitstream is fully corrupted) */ - unsigned int ulMaxDisplayDelay; /**< IN: Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values: 2..4) */ - unsigned int uReserved1[5]; /**< IN: Reserved for future use - set to 0 */ - void *pUserData; /**< IN: User data for callbacks */ - PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */ - PFNVIDDECODECALLBACK pfnDecodePicture; /**< IN: Called when a picture is ready to be decoded (decode order) */ - PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< IN: Called whenever a picture is ready to be displayed (display order) */ - void *pvReserved2[7]; /**< Reserved for future use - set to NULL */ - CUVIDEOFORMATEX *pExtVideoInfo; /**< IN: [Optional] sequence header data from system layer */ -} CUVIDPARSERPARAMS; - -/************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams) -//! Create video parser object and initialize -/************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams); - -/************************************************************************************************/ -//! \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket) -//! Parse the video data from source data packet in pPacket -//! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and -//! calls back pfnDecodePicture with CUVIDPICPARAMS data for kicking of HW decoding -/************************************************************************************************/ -typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket); - -/*******************************************************************/ -//! \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj) -/*******************************************************************/ -typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj); - -/**********************************************************************************************/ - -#if defined(__cplusplus) -} -#endif /* __cplusplus */ - -#endif // __NVCUVID_H__ - - diff --git a/compat/cuda/ptx2c.sh b/compat/cuda/ptx2c.sh deleted file mode 100755 index 5ccabbf56f..0000000000 --- a/compat/cuda/ptx2c.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -set -e - -OUT="$1" -IN="$2" -NAME="$(basename "$IN" | sed 's/\..*//')" - -printf "const char %s_ptx[] = \\" "$NAME" > "$OUT" -while read LINE -do - printf "\n\t\"%s\\\n\"" "$(printf "%s" "$LINE" | sed -e 's/\r//g' -e 's/["\\]/\\&/g')" >> "$OUT" -done < "$IN" -printf ";\n" >> "$OUT" - -exit 0 diff --git a/compat/dispatch_semaphore/semaphore.h b/compat/dispatch_semaphore/semaphore.h index 008c637c01..2461daf13d 100644 --- a/compat/dispatch_semaphore/semaphore.h +++ b/compat/dispatch_semaphore/semaphore.h @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/compat/float/float.h b/compat/float/float.h index 1f0d3ab4b5..c69f728e32 100644 --- a/compat/float/float.h +++ b/compat/float/float.h @@ -1,20 +1,20 @@ /* * Work around broken floating point limits on some systems. * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/compat/float/limits.h b/compat/float/limits.h index 7ea374a8bc..9150bc8134 100644 --- a/compat/float/limits.h +++ b/compat/float/limits.h @@ -1,20 +1,20 @@ /* * Work around broken floating point limits on some systems. * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/compat/getopt.c b/compat/getopt.c index 41a641f7c8..b7adf60e2f 100644 --- a/compat/getopt.c +++ b/compat/getopt.c @@ -1,18 +1,18 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -44,7 +44,7 @@ static int getopt(int argc, char *argv[], char *opts) int c; char *cp; - if (sp == 1) { + if (sp == 1) if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') return EOF; @@ -52,7 +52,6 @@ static int getopt(int argc, char *argv[], char *opts) optind++; return EOF; } - } optopt = c = argv[optind][sp]; if (c == ':' || !(cp = strchr(opts, c))) { fprintf(stderr, ": illegal option -- %c\n", c); diff --git a/compat/msvcrt/snprintf.c b/compat/msvcrt/snprintf.c index c64653fe82..0af7b54353 100644 --- a/compat/msvcrt/snprintf.c +++ b/compat/msvcrt/snprintf.c @@ -2,20 +2,20 @@ * C99-compatible snprintf() and vsnprintf() implementations * Copyright (c) 2012 Ronald S. Bultje * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -24,11 +24,10 @@ #include #include -#include "compat/va_copy.h" #include "libavutil/error.h" -#if defined(__MINGW32__) -#define EOVERFLOW EFBIG +#if !defined(va_copy) && defined(_MSC_VER) +#define va_copy(dst, src) ((dst) = (src)) #endif int avpriv_snprintf(char *s, size_t n, const char *fmt, ...) diff --git a/compat/msvcrt/snprintf.h b/compat/msvcrt/snprintf.h deleted file mode 100644 index cd47953e87..0000000000 --- a/compat/msvcrt/snprintf.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * C99-compatible snprintf() and vsnprintf() implementations - * Copyright (c) 2012 Ronald S. Bultje - * - * 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_MSVCRT_SNPRINTF_H -#define COMPAT_MSVCRT_SNPRINTF_H - -#include -#include - -int avpriv_snprintf(char *s, size_t n, const char *fmt, ...); -int avpriv_vsnprintf(char *s, size_t n, const char *fmt, va_list ap); - -#undef snprintf -#undef _snprintf -#undef vsnprintf -#define snprintf avpriv_snprintf -#define _snprintf avpriv_snprintf -#define vsnprintf avpriv_vsnprintf - -#endif /* COMPAT_MSVCRT_SNPRINTF_H */ diff --git a/compat/nvenc/nvEncodeAPI.h b/compat/nvenc/nvEncodeAPI.h deleted file mode 100644 index c3a8294212..0000000000 --- a/compat/nvenc/nvEncodeAPI.h +++ /dev/null @@ -1,3324 +0,0 @@ -/* - * This copyright notice applies to this header file only: - * - * Copyright (c) 2010-2017 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 nvEncodeAPI.h - * NVIDIA GPUs - beginning with the Kepler generation - contain a hardware-based encoder - * (referred to as NVENC) which provides fully-accelerated hardware-based video encoding. - * NvEncodeAPI provides the interface for NVIDIA video encoder (NVENC). - * \date 2011-2017 - * This file contains the interface constants, structure definitions and function prototypes. - */ - -#ifndef _NV_ENCODEAPI_H_ -#define _NV_ENCODEAPI_H_ - -#include - -#ifdef _WIN32 -#include -#endif - -#ifdef _MSC_VER -#ifndef _STDINT -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -#endif -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures - * @{ - */ - -#if defined(_WIN32) || defined(__CYGWIN__) -#define NVENCAPI __stdcall -#else -#define NVENCAPI -#endif - -#ifdef _WIN32 -typedef RECT NVENC_RECT; -#else -// ========================================================================================= -#ifndef GUID -/*! - * \struct GUID - * Abstracts the GUID structure for non-windows platforms. - */ -// ========================================================================================= -typedef struct -{ - uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */ - uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */ - uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */ - uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits. - The remaining 6 bytes contain the final 12 hexadecimal digits. */ -} GUID; -#endif // GUID - -/** - * \struct _NVENC_RECT - * Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME. - */ -typedef struct _NVENC_RECT -{ - uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */ - uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */ - uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */ - uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */ -} NVENC_RECT; - -#endif // _WIN32 - -/** @} */ /* End of GUID and NVENC_RECT structure grouping*/ - -typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */ -typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/ -typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/ - -#define NVENCAPI_MAJOR_VERSION 8 -#define NVENCAPI_MINOR_VERSION 0 - -#define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24)) - -/** - * Macro to generate per-structure version for use with API. - */ -#define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28)) - - -#define NVENC_INFINITE_GOPLENGTH 0xffffffff - -#define NV_MAX_SEQ_HDR_LEN (512) - -// ========================================================================================= -// Encode Codec GUIDS supported by the NvEncodeAPI interface. -// ========================================================================================= - -// {6BC82762-4E63-4ca4-AA85-1E50F321F6BF} -static const GUID NV_ENC_CODEC_H264_GUID = -{ 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } }; - -// {790CDC88-4522-4d7b-9425-BDA9975F7603} -static const GUID NV_ENC_CODEC_HEVC_GUID = -{ 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } }; - - - -// ========================================================================================= -// * Encode Profile GUIDS supported by the NvEncodeAPI interface. -// ========================================================================================= - -// {BFD6F8E7-233C-4341-8B3E-4818523803F4} -static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID = -{ 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } }; - -// {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A} -static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID = -{ 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } }; - -// {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D} -static const GUID NV_ENC_H264_PROFILE_MAIN_GUID = -{ 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } }; - -// {E7CBC309-4F7A-4b89-AF2A-D537C92BE310} -static const GUID NV_ENC_H264_PROFILE_HIGH_GUID = -{ 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } }; - -// {7AC663CB-A598-4960-B844-339B261A7D52} -static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID = -{ 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } }; - -// {40847BF5-33F7-4601-9084-E8FE3C1DB8B7} -static const GUID NV_ENC_H264_PROFILE_STEREO_GUID = -{ 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } }; - -// {CE788D20-AAA9-4318-92BB-AC7E858C8D36} -static const GUID NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY = -{ 0xce788d20, 0xaaa9, 0x4318, { 0x92, 0xbb, 0xac, 0x7e, 0x85, 0x8c, 0x8d, 0x36 } }; - -// {B405AFAC-F32B-417B-89C4-9ABEED3E5978} -static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID = -{ 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } }; - -// {AEC1BD87-E85B-48f2-84C3-98BCA6285072} -static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID = -{ 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } }; - -// {B514C39A-B55B-40fa-878F-F1253B4DFDEC} -static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID = -{ 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } }; - -// {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5} -static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID = -{ 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } }; - -// For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only -// {51ec32b5-1b4c-453c-9cbd-b616bd621341} -static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID = -{ 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } }; - -// ========================================================================================= -// * Preset GUIDS supported by the NvEncodeAPI interface. -// ========================================================================================= -// {B2DFB705-4EBD-4C49-9B5F-24A777D3E587} -static const GUID NV_ENC_PRESET_DEFAULT_GUID = -{ 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } }; - -// {60E4C59F-E846-4484-A56D-CD45BE9FDDF6} -static const GUID NV_ENC_PRESET_HP_GUID = -{ 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } }; - -// {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012} -static const GUID NV_ENC_PRESET_HQ_GUID = -{ 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } }; - -// {82E3E450-BDBB-4e40-989C-82A90DF9EF32} -static const GUID NV_ENC_PRESET_BD_GUID = -{ 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } }; - -// {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726} -static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID = -{ 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } }; - -// {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105} -static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID = -{ 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } }; - -// {67082A44-4BAD-48FA-98EA-93056D150A58} -static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID = -{ 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } }; - -// {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC} -static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID = -{ 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } }; - -// {149998E7-2364-411d-82EF-179888093409} -static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID = -{ 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } }; - -/** - * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures - * @{ - */ - -/** - * Input frame encode modes - */ -typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE -{ - NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */ - NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */ - NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */ -} NV_ENC_PARAMS_FRAME_FIELD_MODE; - -/** - * Rate Control Modes - */ -typedef enum _NV_ENC_PARAMS_RC_MODE -{ - NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */ - NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */ - NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */ - NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ = 0x8, /**< low-delay CBR, high quality */ - NV_ENC_PARAMS_RC_CBR_HQ = 0x10, /**< CBR, high quality (slower) */ - NV_ENC_PARAMS_RC_VBR_HQ = 0x20 /**< VBR, high quality (slower) */ -} NV_ENC_PARAMS_RC_MODE; - -#define NV_ENC_PARAMS_RC_VBR_MINQP (NV_ENC_PARAMS_RC_MODE)0x4 /**< Deprecated */ -#define NV_ENC_PARAMS_RC_2_PASS_QUALITY NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ /**< Deprecated */ -#define NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP NV_ENC_PARAMS_RC_CBR_HQ /**< Deprecated */ -#define NV_ENC_PARAMS_RC_2_PASS_VBR NV_ENC_PARAMS_RC_VBR_HQ /**< Deprecated */ -#define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */ - -/** - * Input picture structure - */ -typedef enum _NV_ENC_PIC_STRUCT -{ - NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */ - NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */ - NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */ -} NV_ENC_PIC_STRUCT; - -/** - * Input picture type - */ -typedef enum _NV_ENC_PIC_TYPE -{ - NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */ - NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */ - NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */ - NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */ - NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */ - NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */ - NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */ - NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */ -} NV_ENC_PIC_TYPE; - -/** - * Motion vector precisions - */ -typedef enum _NV_ENC_MV_PRECISION -{ - NV_ENC_MV_PRECISION_DEFAULT = 0x0, /** (if lookahead is enabled, input frames must remain available to the encoder until encode completion) */ - uint32_t disableIadapt :1; /**< [in]: Set this to 1 to disable adaptive I-frame insertion at scene cuts (only has an effect when lookahead is enabled) */ - uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */ - uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ for H.264 */ - uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */ - uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */ - uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */ - uint32_t aqStrength :4; /**< [in]: When AQ (Spatial) is enabled (i.e. NV_ENC_RC_PARAMS::enableAQ is set), this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive). If not set, strength is autoselected by driver. */ - uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */ - NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */ - NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */ - NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */ - uint32_t temporallayerIdxMask; /**< [in]: Specifies the temporal layers (as a bitmask) whose QPs have changed. Valid max bitmask is [2^NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS - 1] */ - uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as as the array index */ - uint8_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */ - uint8_t targetQualityLSB; /**< [in]: Fractional part of target quality (as 8.8 fixed point format) */ - uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-32 (only used if enableLookahead=1) */ - uint32_t reserved[9]; - } NV_ENC_RC_PARAMS; - -/** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */ -#define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1) - - - -/** - * \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS - * H264 Video Usability Info parameters - */ -typedef struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS -{ - uint32_t overscanInfoPresentFlag; /**< [in]: if set to 1 , it specifies that the overscanInfo is present */ - uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */ - uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */ - uint32_t videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/ - uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */ - uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */ - uint32_t colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */ - uint32_t transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */ - uint32_t colourMatrix; /**< [in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (as defined in Annex E of the ITU-T Specification). */ - uint32_t chromaSampleLocationFlag; /**< [in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/ - uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */ - uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */ - uint32_t bitstreamRestrictionFlag; /**< [in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/ - uint32_t reserved[15]; -}NV_ENC_CONFIG_H264_VUI_PARAMETERS; - -typedef NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS; - -/** - * \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE - * External motion vector hint counts per block type. - * H264 supports multiple hint while HEVC supports one hint for each valid candidate. - */ -typedef struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE -{ - uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Supported for H264,HEVC.It Specifies the number of candidates per 16x16 block. */ - uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Supported for H264 only.Specifies the number of candidates per 16x8 block. */ - uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Supported for H264 only.Specifies the number of candidates per 8x16 block. */ - uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Supported for H264,HEVC.Specifies the number of candidates per 8x8 block. */ - uint32_t reserved : 16; /**< [in]: Reserved for padding. */ - uint32_t reserved1[3]; /**< [in]: Reserved for future use. */ -} NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE; - - -/** - * \struct _NVENC_EXTERNAL_ME_HINT - * External Motion Vector hint structure. - */ -typedef struct _NVENC_EXTERNAL_ME_HINT -{ - int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */ - int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/ - int32_t refidx : 5; /**< [in]: Specifies the reference index (31=invalid). Current we support only 1 reference frame per direction for external hints, so \p refidx must be 0. */ - int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/ - int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/ - int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */ - int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */ -} NVENC_EXTERNAL_ME_HINT; - - -/** - * \struct _NV_ENC_CONFIG_H264 - * H264 encoder configuration parameters - */ -typedef struct _NV_ENC_CONFIG_H264 -{ - uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/ - uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/ - uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical PFrames */ - uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical BFrames */ - uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */ - uint32_t outputPictureTimingSEI :1; /**< [in]: Set to 1 to write SEI picture timing syntax in the bitstream. When set for following rateControlMode : NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ, - NV_ENC_PARAMS_RC_CBR_HQ, filler data is inserted if needed to achieve hrd bitrate */ - uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */ - uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */ - uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */ - uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */ - uint32_t enableIntraRefresh :1; /**< [in]: Set to 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */ - uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constarined picture is independent of other slices - Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */ - uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */ - uint32_t enableVFR :1; /**< [in]: Set to 1 to enable variable frame rate. */ - uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode. - LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1. - Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future. - LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting - ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode - for using LTR. - Note that LTRs are not supported if encoding session is configured with B-frames */ - uint32_t qpPrimeYZeroTransformBypassFlag :1; /**< [in]: To enable lossless encode set this to 1, set QP to 0 and RC_mode to NV_ENC_PARAMS_RC_CONSTQP and profile to HIGH_444_PREDICTIVE_PROFILE. - Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */ - uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */ - uint32_t reservedBitFields :15; /**< [in]: Reserved bitfields and must be set to 0 */ - uint32_t level; /**< [in]: Specifies the encoding level. Client is recommended to set this to NV_ENC_LEVEL_AUTOSELECT in order to enable the NvEncodeAPI interface to select the correct level. */ - uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */ - uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */ - uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2] */ - uint32_t numTemporalLayers; /**< [in]: Specifies max temporal layers to be used for hierarchical coding. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */ - uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */ - uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */ - NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE adaptiveTransformMode; /**< [in]: Specifies the AdaptiveTransform Mode. Check support for AdaptiveTransform mode using ::NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM caps. */ - NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */ - NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/ - NV_ENC_H264_ENTROPY_CODING_MODE entropyCodingMode; /**< [in]: Specifies the entropy coding mode. Check support for CABAC mode using ::NV_ENC_CAPS_SUPPORT_CABAC caps. */ - NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signalled in frame packing arrangement SEI */ - uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set. - Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */ - uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */ - uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default dpb size. - The low latency application which wants to invalidate reference frame as an error resilience tool - is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent - frames are invalidated. */ - uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices - sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture - When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting - When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ - uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: - sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice) - sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) - sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice) - sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ - NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info pamameters */ - uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames. This parameter has different meaning in two LTR modes. - In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR. - In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */ - uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_H264::enableLTR for description of the two modes. - Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may - be deprecated in future releases. - Set to 0 when using "LTR Per Picture" mode of LTR operation. */ - uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input. - Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/ - uint32_t maxTemporalLayers; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */ - uint32_t reserved1[270]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_CONFIG_H264; - - -/** - * \struct _NV_ENC_CONFIG_HEVC - * HEVC encoder configuration parameters to be set during initialization. - */ -typedef struct _NV_ENC_CONFIG_HEVC -{ - uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/ - uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/ - NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/ - NV_ENC_HEVC_CUSIZE maxCUSize; /**< [in]: Specifies the maximum size of luma coding unit. Currently NVENC SDK only supports maxCUSize equal to NV_ENC_HEVC_CUSIZE_32x32.*/ - uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */ - uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/ - uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */ - uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */ - uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */ - uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode. - LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1. - Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future releases. - LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting - ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode - for using LTR. - Note that LTRs are not supported if encoding session is configured with B-frames */ - uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS,SPS and PPS signalling in the bitstream. */ - uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/ - uint32_t enableIntraRefresh :1; /**< [in]: Set 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */ - uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/ - uint32_t pixelBitDepthMinus8 :3; /**< [in]: Specifies pixel bit depth minus 8. Should be set to 0 for 8 bit input, 2 for 10 bit input.*/ - uint32_t reserved :18; /**< [in]: Reserved bitfields.*/ - uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */ - uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set. - Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */ - uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */ - uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/ - uint32_t ltrNumFrames; /**< [in]: This parameter has different meaning in two LTR modes. - In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR. - In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */ - uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set */ - uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */ - uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */ - uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices - sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture - When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ - uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: - sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice) - sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) - sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice) - sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ - uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */ - NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info pamameters */ - uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_HEVC::enableLTR for description of the two modes. - Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may - be deprecated in future releases. - Set to 0 when using "LTR Per Picture" mode of LTR operation. */ - uint32_t reserved1[217]; /**< [in]: Reserved and must be set to 0.*/ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_CONFIG_HEVC; - -/** - * \struct _NV_ENC_CONFIG_H264_MEONLY - * H264 encoder configuration parameters for ME only Mode - * - */ -typedef struct _NV_ENC_CONFIG_H264_MEONLY -{ - uint32_t disablePartition16x16 :1; /**< [in]: Disable MotionEstimation on 16x16 blocks*/ - uint32_t disablePartition8x16 :1; /**< [in]: Disable MotionEstimation on 8x16 blocks*/ - uint32_t disablePartition16x8 :1; /**< [in]: Disable MotionEstimation on 16x8 blocks*/ - uint32_t disablePartition8x8 :1; /**< [in]: Disable MotionEstimation on 8x8 blocks*/ - uint32_t disableIntraSearch :1; /**< [in]: Disable Intra search during MotionEstimation*/ - uint32_t bStereoEnable :1; /**< [in]: Enable Stereo Mode for Motion Estimation where each view is independently executed*/ - uint32_t reserved :26; /**< [in]: Reserved and must be set to 0 */ - uint32_t reserved1 [255]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_CONFIG_H264_MEONLY; - - -/** - * \struct _NV_ENC_CONFIG_HEVC_MEONLY - * HEVC encoder configuration parameters for ME only Mode - * - */ -typedef struct _NV_ENC_CONFIG_HEVC_MEONLY -{ - uint32_t reserved [256]; /**< [in]: Reserved and must be set to 0 */ - void* reserved1[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_CONFIG_HEVC_MEONLY; - -/** - * \struct _NV_ENC_CODEC_CONFIG - * Codec-specific encoder configuration parameters to be set during initialization. - */ -typedef union _NV_ENC_CODEC_CONFIG -{ - NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */ - NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */ - NV_ENC_CONFIG_H264_MEONLY h264MeOnlyConfig; /**< [in]: Specifies the H.264-specific ME only encoder configuration. */ - NV_ENC_CONFIG_HEVC_MEONLY hevcMeOnlyConfig; /**< [in]: Specifies the HEVC-specific ME only encoder configuration. */ - uint32_t reserved[320]; /**< [in]: Reserved and must be set to 0 */ -} NV_ENC_CODEC_CONFIG; - - -/** - * \struct _NV_ENC_CONFIG - * Encoder configuration parameters to be set during initialization. - */ -typedef struct _NV_ENC_CONFIG -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */ - GUID profileGUID; /**< [in]: Specifies the codec profile guid. If client specifies \p NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID the NvEncodeAPI interface will select the appropriate codec profile. */ - uint32_t gopLength; /**< [in]: Specifies the number of pictures in one GOP. Low latency application client can set goplength to NVENC_INFINITE_GOPLENGTH so that keyframes are not inserted automatically. */ - int32_t frameIntervalP; /**< [in]: Specifies the GOP pattern as follows: \p frameIntervalP = 0: I, 1: IPP, 2: IBP, 3: IBBP If goplength is set to NVENC_INFINITE_GOPLENGTH \p frameIntervalP should be set to 1. */ - uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */ - NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode. - Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps. - Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */ - NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */ - NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */ - NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */ - uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_CONFIG; - -/** macro for constructing the version field of ::_NV_ENC_CONFIG */ -#define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(6) | ( 1<<31 )) - - -/** - * \struct _NV_ENC_INITIALIZE_PARAMS - * Encode Session Initialization parameters. - */ -typedef struct _NV_ENC_INITIALIZE_PARAMS -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */ - GUID encodeGUID; /**< [in]: Specifies the Encode GUID for which the encoder is being created. ::NvEncInitializeEncoder() API will fail if this is not set, or set to unsupported value. */ - GUID presetGUID; /**< [in]: Specifies the preset for encoding. If the preset GUID is set then , the preset configuration will be applied before any other parameter. */ - uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */ - uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */ - uint32_t darWidth; /**< [in]: Specifies the display aspect ratio Width. */ - uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height. */ - uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */ - uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */ - uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */ - uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */ - uint32_t reportSliceOffsets :1; /**< [in]: Set this to 1 to enable reporting slice offsets in ::_NV_ENC_LOCK_BITSTREAM. NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync must be set to 0 to use this feature. Client must set this to 0 if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs */ - uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals */ - uint32_t enableExternalMEHints :1; /**< [in]: Set to 1 to enable external ME hints for the current frame. For NV_ENC_INITIALIZE_PARAMS::enablePTD=1 with B frames, programming L1 hints is optional for B frames since Client doesn't know internal GOP structure. - NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */ - uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/ - uint32_t enableWeightedPrediction :1; /**< [in]: Set this to 1 to enable weighted prediction. Not supported if encode session is configured for B-Frames( 'frameIntervalP' in NV_ENC_CONFIG is greater than 1).*/ - uint32_t reservedBitFields :27; /**< [in]: Reserved bitfields and must be set to 0 */ - uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */ - void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */ - NV_ENC_CONFIG* encodeConfig; /**< [in]: Specifies the advanced codec specific structure. If client has sent a valid codec config structure, it will override parameters set by the NV_ENC_INITIALIZE_PARAMS::presetGUID parameter. If set to NULL the NvEncodeAPI interface will use the NV_ENC_INITIALIZE_PARAMS::presetGUID to set the codec specific parameters. - Client can also optionally query the NvEncodeAPI interface to get codec specific parameters for a presetGUID using ::NvEncGetEncodePresetConfig() API. It can then modify (if required) some of the codec config parameters and send down a custom config structure as part of ::_NV_ENC_INITIALIZE_PARAMS. - Even in this case client is recommended to pass the same preset guid it has used in ::NvEncGetEncodePresetConfig() API to query the config structure; as NV_ENC_INITIALIZE_PARAMS::presetGUID. This will not override the custom config structure but will be used to determine other Encoder HW specific parameters not exposed in the API. */ - uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session. - Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */ - uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session. - Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */ - NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE maxMEHintCountsPerBlock[2]; /**< [in]: If Client wants to pass external motion vectors in NV_ENC_PIC_PARAMS::meExternalHints buffer it must specify the maximum number of hint candidates per block per direction for the encode session. - The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors. - This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */ - uint32_t reserved [289]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_INITIALIZE_PARAMS; - -/** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */ -#define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1<<31 )) - - -/** - * \struct _NV_ENC_RECONFIGURE_PARAMS - * Encode Session Reconfigured parameters. - */ -typedef struct _NV_ENC_RECONFIGURE_PARAMS -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */ - NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters. */ - uint32_t resetEncoder :1; /**< [in]: This resets the rate control states and other internal encoder states. This should be used only with an IDR frame. - If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */ - uint32_t forceIDR :1; /**< [in]: Encode the current picture as an IDR picture. This flag is only valid when Picture type decision is taken by the Encoder - [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */ - uint32_t reserved :30; - -}NV_ENC_RECONFIGURE_PARAMS; - -/** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */ -#define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1<<31 )) - -/** - * \struct _NV_ENC_PRESET_CONFIG - * Encoder preset config - */ -typedef struct _NV_ENC_PRESET_CONFIG -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */ - NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */ - uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -}NV_ENC_PRESET_CONFIG; - -/** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */ -#define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 )) - - -/** - * \struct _NV_ENC_SEI_PAYLOAD - * User SEI message - */ -typedef struct _NV_ENC_SEI_PAYLOAD -{ - uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */ - uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */ - uint8_t *payload; /**< [in] pointer to user data */ -} NV_ENC_SEI_PAYLOAD; - -#define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD - -/** - * \struct _NV_ENC_PIC_PARAMS_H264 - * H264 specific enc pic params. sent on a per frame basis. - */ -typedef struct _NV_ENC_PIC_PARAMS_H264 -{ - uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */ - uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */ - uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */ - uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */ - uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt. - When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message - forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */ - uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame. - NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */ - uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter - When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */ - uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */ - uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */ - uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */ - uint8_t* sliceTypeData; /**< [in]: Deprecated. */ - uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */ - uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */ - NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */ - uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices - sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture - When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting - When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ - uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: - sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice) - sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) - sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice) - sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ - uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/ - uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the the associated bitmap of LTR frame indices to use when encoding this frame. */ - uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */ - uint32_t reserved [243]; /**< [in]: Reserved and must be set to 0. */ - void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */ -} NV_ENC_PIC_PARAMS_H264; - -/** - * \struct _NV_ENC_PIC_PARAMS_HEVC - * HEVC specific enc pic params. sent on a per frame basis. - */ -typedef struct _NV_ENC_PIC_PARAMS_HEVC -{ - uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */ - uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */ - uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */ - uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt. - When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message - forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */ - uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame. - NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */ - uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter - When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */ - uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */ - uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */ - uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */ - uint8_t* sliceTypeData; /**< [in]: Array which specifies the slice type used to force intra slice for a particular slice. Currently supported only for NV_ENC_CONFIG_H264::sliceMode == 3. - Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264 - Array element with index n corresponds to nth slice. To force a particular slice to intra client should set corresponding array element to NV_ENC_SLICE_TYPE_I - all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */ - uint32_t sliceTypeArrayCnt; /**< [in]: Client should set this to the number of elements allocated in sliceTypeData array. If sliceTypeData is NULL then this should be set to 0 */ - uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices - sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture - When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting - When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ - uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: - sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice) - sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) - sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice) - sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ - uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/ - uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */ - uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */ - uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */ - uint32_t reserved; /**< [in]: Reserved and must be set to 0. */ - NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */ - uint32_t reserved2 [244]; /**< [in]: Reserved and must be set to 0. */ - void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */ -} NV_ENC_PIC_PARAMS_HEVC; - - -/** - * Codec specific per-picture encoding parameters. - */ -typedef union _NV_ENC_CODEC_PIC_PARAMS -{ - NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */ - NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. */ - uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */ -} NV_ENC_CODEC_PIC_PARAMS; - -/** - * \struct _NV_ENC_PIC_PARAMS - * Encoding parameters that need to be sent on a per frame basis. - */ -typedef struct _NV_ENC_PIC_PARAMS -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */ - uint32_t inputWidth; /**< [in]: Specifies the input buffer width */ - uint32_t inputHeight; /**< [in]: Specifies the input buffer height */ - uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */ - uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR`ed encode pic flags. See ::NV_ENC_PIC_FLAGS enum. */ - uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */ - uint64_t inputTimeStamp; /**< [in]: Specifies presentation timestamp associated with the input picture. */ - uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */ - NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/ - NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API. */ - void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */ - NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */ - NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */ - NV_ENC_PIC_TYPE pictureType; /**< [in]: Specifies input picture type. Client required to be set explicitly by the client if the client has not set NV_ENC_INITALIZE_PARAMS::enablePTD to 1 while calling NvInitializeEncoder. */ - NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */ - NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block per direction for the current frame. meHintCountsPerBlock[0] is for L0 predictors and meHintCountsPerBlock[1] is for L1 predictors. - The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization. */ - NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock. - The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8 - + 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */ - uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */ - int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing QP delta value per MB in raster scan order in the current picture. This QP modifier is applied on top of the QP chosen by rate control. */ - uint32_t qpDeltaMapSize; /**< [in]: Specifies the size in bytes of qpDeltaMap surface allocated by client and pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap. Surface (array) should be picWidthInMbs * picHeightInMbs */ - uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */ - uint16_t meHintRefPicDist[2]; /**< [in]: Specifies temporal distance for reference picture (NVENC_EXTERNAL_ME_HINT::refidx = 0) used during external ME with NV_ENC_INITALIZE_PARAMS::enablePTD = 1 . meHintRefPicDist[0] is for L0 hints and meHintRefPicDist[1] is for L1 hints. - If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */ - uint32_t reserved3[286]; /**< [in]: Reserved and must be set to 0 */ - void* reserved4[60]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_PIC_PARAMS; - -/** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */ -#define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 )) - - -/** - * \struct _NV_ENC_MEONLY_PARAMS - * MEOnly parameters that need to be sent on a per motion estimation basis. - * NV_ENC_MEONLY_PARAMS::meExternalHints is supported for H264 only. - */ -typedef struct _NV_ENC_MEONLY_PARAMS -{ - uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/ - uint32_t inputWidth; /**< [in]: Specifies the input buffer width */ - uint32_t inputHeight; /**< [in]: Specifies the input buffer height */ - NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */ - NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */ - NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer. Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. */ - NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */ - void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of motion estimation - of this Frame [only if operating in Asynchronous mode]. - Each output buffer should be associated with a distinct event pointer. */ - uint32_t viewID; /**< [in]: Specifies left,right viewID if NV_ENC_CONFIG_H264_MEONLY::bStereoEnable is set. - viewID can be 0,1 if bStereoEnable is set, 0 otherwise. */ - NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE - meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block for the current frame. meHintCountsPerBlock[0] is for L0 predictors. - The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization. */ - NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock. - The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8 - + 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */ - uint32_t reserved1[243]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[59]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_MEONLY_PARAMS; - -/** NV_ENC_MEONLY_PARAMS struct version*/ -#define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(3) - - -/** - * \struct _NV_ENC_LOCK_BITSTREAM - * Bitstream buffer lock parameters. - */ -typedef struct _NV_ENC_LOCK_BITSTREAM -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */ - uint32_t doNotWait :1; /**< [in]: If this flag is set, the NvEncodeAPI interface will return buffer pointer even if operation is not completed. If not set, the call will block until operation completes. */ - uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */ - uint32_t reservedBitFields :30; /**< [in]: Reserved bit fields and must be set to 0 */ - void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */ - uint32_t* sliceOffsets; /**< [in,out]: Array which receives the slice offsets. This is not supported if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs. Array size must be equal to size of frame in MBs. */ - uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */ - uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */ - uint32_t numSlices; /**< [out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */ - uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr. */ - uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */ - uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */ - void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream. - For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to - NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */ - NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */ - NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */ - uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */ - uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */ - uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */ - uint32_t ltrFrameBitmap; /**< [out]: Bitmap of LTR frames indices which were used for encoding this frame. Value of 0 if no LTR frames were used. */ - uint32_t reserved [236]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_LOCK_BITSTREAM; - -/** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */ -#define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(1) - - -/** - * \struct _NV_ENC_LOCK_INPUT_BUFFER - * Uncompressed Input Buffer lock parameters. - */ -typedef struct _NV_ENC_LOCK_INPUT_BUFFER -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */ - uint32_t doNotWait :1; /**< [in]: Set to 1 to make ::NvEncLockInputBuffer() a unblocking call. If the encoding is not completed, driver will return ::NV_ENC_ERR_ENCODER_BUSY error code. */ - uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */ - NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Pointer to the input buffer to be locked, client should pass the pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource API. */ - void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */ - uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */ - uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_LOCK_INPUT_BUFFER; - -/** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */ -#define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1) - - -/** - * \struct _NV_ENC_MAP_INPUT_RESOURCE - * Map an input resource to a Nvidia Encoder Input Buffer - */ -typedef struct _NV_ENC_MAP_INPUT_RESOURCE -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */ - uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */ - void* inputResource; /**< [in]: Deprecated. Do not use. */ - NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */ - NV_ENC_INPUT_PTR mappedResource; /**< [out]: Mapped pointer corresponding to the registeredResource. This pointer must be used in NV_ENC_PIC_PARAMS::inputBuffer parameter in ::NvEncEncodePicture() API. */ - NV_ENC_BUFFER_FORMAT mappedBufferFmt; /**< [out]: Buffer format of the outputResource. This buffer format must be used in NV_ENC_PIC_PARAMS::bufferFmt if client using the above mapped resource pointer. */ - uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */ - void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_MAP_INPUT_RESOURCE; - -/** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */ -#define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4) - -/** - * \struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX - * NV_ENC_REGISTER_RESOURCE::resourceToRegister must be a pointer to a variable of this type, - * when NV_ENC_REGISTER_RESOURCE::resourceType is NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX - */ -typedef struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX -{ - uint32_t texture; /**< [in]: The name of the texture to be used. */ - uint32_t target; /**< [in]: Accepted values are GL_TEXTURE_RECTANGLE and GL_TEXTURE_2D. */ -} NV_ENC_INPUT_RESOURCE_OPENGL_TEX; - -/** - * \struct _NV_ENC_REGISTER_RESOURCE - * Register a resource for future use with the Nvidia Video Encoder Interface. - */ -typedef struct _NV_ENC_REGISTER_RESOURCE -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */ - NV_ENC_INPUT_RESOURCE_TYPE resourceType; /**< [in]: Specifies the type of resource to be registered. - Supported values are - ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX, - ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR, - ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX */ - uint32_t width; /**< [in]: Input buffer Width. */ - uint32_t height; /**< [in]: Input buffer Height. */ - uint32_t pitch; /**< [in]: Input buffer Pitch. */ - uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */ - void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */ - NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */ - NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */ - uint32_t reserved1[248]; /**< [in]: Reserved and must be set to 0. */ - void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */ -} NV_ENC_REGISTER_RESOURCE; - -/** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */ -#define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(3) - -/** - * \struct _NV_ENC_STAT - * Encode Stats structure. - */ -typedef struct _NV_ENC_STAT -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */ - uint32_t reserved; /**< [in]: Reserved and must be set to 0 */ - NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */ - uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */ - uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */ - uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */ - uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */ - uint32_t picIdx; /**< [out]: Picture number */ - uint32_t reserved1[233]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_STAT; - -/** Macro for constructing the version field of ::_NV_ENC_STAT */ -#define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1) - - -/** - * \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD - * Sequence and picture paramaters payload. - */ -typedef struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */ - uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provied by the client */ - uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */ - uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */ - void* spsppsBuffer; /**< [in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize. It is the client's responsibility to manage this memory. */ - uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes written by the NvEncodeAPI interface to the SPSPPSBuffer. */ - uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_SEQUENCE_PARAM_PAYLOAD; - -/** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */ -#define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1) - - -/** - * Event registration/unregistration parameters. - */ -typedef struct _NV_ENC_EVENT_PARAMS -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */ - uint32_t reserved; /**< [in]: Reserved and must be set to 0 */ - void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */ - uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_EVENT_PARAMS; - -/** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */ -#define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1) - -/** - * Encoder Session Creation parameters - */ -typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS -{ - uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */ - NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */ - void* device; /**< [in]: Pointer to client device. */ - void* reserved; /**< [in]: Reserved and must be set to 0. */ - uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */ - uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */ - void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS; -/** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */ -#define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1) - -/** @} */ /* END ENCODER_STRUCTURE */ - - -/** - * \addtogroup ENCODE_FUNC NvEncodeAPI Functions - * @{ - */ - -// NvEncOpenEncodeSession -/** - * \brief Opens an encoding session. - * - * Deprecated. - * - * \return - * ::NV_ENC_ERR_INVALID_CALL\n - * - */ -NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder); - -// NvEncGetEncodeGuidCount -/** - * \brief Retrieves the number of supported encode GUIDs. - * - * The function returns the number of codec guids supported by the NvEncodeAPI - * interface. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [out] encodeGUIDCount - * Number of supported encode GUIDs. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount); - - -// NvEncGetEncodeGUIDs -/** - * \brief Retrieves an array of supported encoder codec GUIDs. - * - * The function returns an array of codec guids supported by the NvEncodeAPI interface. - * The client must allocate an array where the NvEncodeAPI interface can - * fill the supported guids and pass the pointer in \p *GUIDs parameter. - * The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API. - * The Nvidia Encoding interface returns the number of codec guids it has actually - * filled in the guid array in the \p GUIDCount parameter. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] guidArraySize - * Number of GUIDs to retrieved. Should be set to the number retrieved using - * ::NvEncGetEncodeGUIDCount. - * \param [out] GUIDs - * Array of supported Encode GUIDs. - * \param [out] GUIDCount - * Number of supported Encode GUIDs. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); - - -// NvEncGetEncodeProfileGuidCount -/** - * \brief Retrieves the number of supported profile GUIDs. - * - * The function returns the number of profile GUIDs supported for a given codec. - * The client must first enumerate the codec guids supported by the NvEncodeAPI - * interface. After determining the codec guid, it can query the NvEncodeAPI - * interface to determine the number of profile guids supported for a particular - * codec guid. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * The codec guid for which the profile guids are being enumerated. - * \param [out] encodeProfileGUIDCount - * Number of encode profiles supported for the given encodeGUID. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount); - - -// NvEncGetEncodeProfileGUIDs -/** - * \brief Retrieves an array of supported encode profile GUIDs. - * - * The function returns an array of supported profile guids for a particular - * codec guid. The client must allocate an array where the NvEncodeAPI interface - * can populate the profile guids. The client can determine the array size using - * ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the - * NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID - * parameter. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * The encode guid whose profile guids are being enumerated. - * \param [in] guidArraySize - * Number of GUIDs to be retrieved. Should be set to the number retrieved using - * ::NvEncGetEncodeProfileGUIDCount. - * \param [out] profileGUIDs - * Array of supported Encode Profile GUIDs - * \param [out] GUIDCount - * Number of valid encode profile GUIDs in \p profileGUIDs array. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); - -// NvEncGetInputFormatCount -/** - * \brief Retrieve the number of supported Input formats. - * - * The function returns the number of supported input formats. The client must - * query the NvEncodeAPI interface to determine the supported input formats - * before creating the input surfaces. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * Encode GUID, corresponding to which the number of supported input formats - * is to be retrieved. - * \param [out] inputFmtCount - * Number of input formats supported for specified Encode GUID. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - */ -NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount); - - -// NvEncGetInputFormats -/** - * \brief Retrieves an array of supported Input formats - * - * Returns an array of supported input formats The client must use the input - * format to create input surface using ::NvEncCreateInputBuffer() API. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * Encode GUID, corresponding to which the number of supported input formats - * is to be retrieved. - *\param [in] inputFmtArraySize - * Size input format count array passed in \p inputFmts. - *\param [out] inputFmts - * Array of input formats supported for this Encode GUID. - *\param [out] inputFmtCount - * The number of valid input format types returned by the NvEncodeAPI - * interface in \p inputFmts array. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount); - - -// NvEncGetEncodeCaps -/** - * \brief Retrieves the capability value for a specified encoder attribute. - * - * The function returns the capability value for a given encoder attribute. The - * client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before - * calling this function. The encoder attribute being queried are enumerated in - * ::NV_ENC_CAPS_PARAM enum. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * Encode GUID, corresponding to which the capability attribute is to be retrieved. - * \param [in] capsParam - * Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more - * details. - * \param [out] capsVal - * The value corresponding to the capability attribute being queried. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - */ -NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal); - - -// NvEncGetEncodePresetCount -/** - * \brief Retrieves the number of supported preset GUIDs. - * - * The function returns the number of preset GUIDs available for a given codec. - * The client must validate the codec guid using ::NvEncGetEncodeGUIDs() API - * before calling this function. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * Encode GUID, corresponding to which the number of supported presets is to - * be retrieved. - * \param [out] encodePresetGUIDCount - * Receives the number of supported preset GUIDs. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount); - - -// NvEncGetEncodePresetGUIDs -/** - * \brief Receives an array of supported encoder preset GUIDs. - * - * The function returns an array of encode preset guids available for a given codec. - * The client can directly use one of the preset guids based upon the use case - * or target device. The preset guid chosen can be directly used in - * NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API. - * Alternately client can also use the preset guid to retrieve the encoding config - * parameters being used by NvEncodeAPI interface for that given preset, using - * ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters - * as per its use case and send it to NvEncodeAPI interface as part of - * NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder() - * API. - * - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * Encode GUID, corresponding to which the list of supported presets is to be - * retrieved. - * \param [in] guidArraySize - * Size of array of preset guids passed in \p preset GUIDs - * \param [out] presetGUIDs - * Array of supported Encode preset GUIDs from the NvEncodeAPI interface - * to client. - * \param [out] encodePresetGUIDCount - * Receives the number of preset GUIDs returned by the NvEncodeAPI - * interface. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount); - - -// NvEncGetEncodePresetConfig -/** - * \brief Returns a preset config structure supported for given preset GUID. - * - * The function returns a preset config structure for a given preset guid. Before - * using this function the client must enumerate the preset guids available for - * a given codec. The preset config structure can be modified by the client depending - * upon its use case and can be then used to initialize the encoder using - * ::NvEncInitializeEncoder() API. The client can use this function only if it - * wants to modify the NvEncodeAPI preset configuration, otherwise it can - * directly use the preset guid. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] encodeGUID - * Encode GUID, corresponding to which the list of supported presets is to be - * retrieved. - * \param [in] presetGUID - * Preset GUID, corresponding to which the Encoding configurations is to be - * retrieved. - * \param [out] presetConfig - * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for -* more details. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig); - -// NvEncInitializeEncoder -/** - * \brief Initialize the encoder. - * - * This API must be used to initialize the encoder. The initialization parameter - * is passed using \p *createEncodeParams The client must send the following - * fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value. - * - NV_ENC_INITIALIZE_PARAMS::encodeGUID - * - NV_ENC_INITIALIZE_PARAMS::encodeWidth - * - NV_ENC_INITIALIZE_PARAMS::encodeHeight - * - * The client can pass a preset guid directly to the NvEncodeAPI interface using - * NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass - * NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters - * will be selected based on the preset guid. The preset guid must have been - * validated by the client using ::NvEncGetEncodePresetGUIDs() API. - * If the client passes a custom ::_NV_ENC_CONFIG structure through - * NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters - * based on the preset guid. It is recommended that even if the client passes a custom config, - * it should also send a preset guid. In this case, the preset guid passed by the client - * will not override any of the custom config parameters programmed by the client, - * it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters - * which are not exposed to the client. - * - * There are two modes of operation for the encoder namely: - * - Asynchronous mode - * - Synchronous mode - * - * The client can select asynchronous or synchronous mode by setting the \p - * enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively. - *\par Asynchronous mode of operation: - * The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1. - * The client operating in asynchronous mode must allocate completion event object - * for each output buffer and pass the completion event object in the - * ::NvEncEncodePicture() API. The client can create another thread and wait on - * the event object to be signalled by NvEncodeAPI interface on completion of the - * encoding process for the output frame. This should unblock the main thread from - * submitting work to the encoder. When the event is signalled the client can call - * NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream() - * API. This is the preferred mode of operation. - * - * NOTE: Asynchronous mode is not supported on Linux. - * - *\par Synchronous mode of operation: - * The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0. - * The client working in synchronous mode can work in a single threaded or multi - * threaded mode. The client need not allocate any event objects. The client can - * only lock the bitstream data after NvEncodeAPI interface has returned - * ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return - * ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The - * client must not lock the output buffer in such case but should send the next - * frame for encoding. The client must keep on calling ::NvEncEncodePicture() API - * until it returns ::NV_ENC_SUCCESS. \n - * The client must always lock the bitstream data in order in which it has submitted. - * This is true for both asynchronous and synchronous mode. - * - *\par Picture type decision: - * If the client is taking the picture type decision and it must disable the picture - * type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD - * to 0. In this case the client is required to send the picture in encoding - * order to NvEncodeAPI by doing the re-ordering for B frames. \n - * If the client doesn't want to take the picture type decision it can enable - * picture type decision module in the NvEncodeAPI interface by setting - * NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display - * order. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] createEncodeParams - * Refer ::_NV_ENC_INITIALIZE_PARAMS for details. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams); - - -// NvEncCreateInputBuffer -/** - * \brief Allocates Input buffer. - * - * This function is used to allocate an input buffer. The client must enumerate - * the input buffer format before allocating the input buffer resources. The - * NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the - * NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in - * ::NvEncEncodePicture() API. The number of input buffers to be allocated by the - * client must be at least 4 more than the number of B frames being used for encoding. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] createInputBufferParams - * Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams); - - -// NvEncDestroyInputBuffer -/** - * \brief Release an input buffers. - * - * This function is used to free an input buffer. If the client has allocated - * any input buffer using ::NvEncCreateInputBuffer() API, it must free those - * input buffers by calling this function. The client must release the input - * buffers before destroying the encoder using ::NvEncDestroyEncoder() API. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] inputBuffer - * Pointer to the input buffer to be released. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer); - - -// NvEncCreateBitstreamBuffer -/** - * \brief Allocates an output bitstream buffer - * - * This function is used to allocate an output bitstream buffer and returns a - * NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the - * NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field. - * The client can only call this function after the encoder session has been - * initialized using ::NvEncInitializeEncoder() API. The minimum number of output - * buffers allocated by the client must be at least 4 more than the number of B - * B frames being used for encoding. The client can only access the output - * bitsteam data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream() - * function. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] createBitstreamBufferParams - * Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams); - - -// NvEncDestroyBitstreamBuffer -/** - * \brief Release a bitstream buffer. - * - * This function is used to release the output bitstream buffer allocated using - * the ::NvEncCreateBitstreamBuffer() function. The client must release the output - * bitstreamBuffer using this function before destroying the encoder session. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] bitstreamBuffer - * Pointer to the bitstream buffer being released. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); - -// NvEncEncodePicture -/** - * \brief Submit an input picture for encoding. - * - * This function is used to submit an input picture buffer for encoding. The - * encoding parameters are passed using \p *encodePicParams which is a pointer - * to the ::_NV_ENC_PIC_PARAMS structure. - * - * If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must - * send a valid value for the following fields. - * - NV_ENC_PIC_PARAMS::pictureType - * - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only) - * - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only) - * - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only) - * - * - *\par Asynchronous Encoding - * If the client has enabled asynchronous mode of encoding by setting - * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder() - * API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent. - * Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture() - * API commands from the main thread and then queue output buffers to be processed - * to a secondary worker thread. Before the locking the output buffers in the - * secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent - * it has queued in ::NvEncEncodePicture() API call. The client must always process - * completion event and the output buffer in the same order in which they have been - * submitted for encoding. The NvEncodeAPI interface is responsible for any - * re-ordering required for B frames and will always ensure that encoded bitstream - * data is written in the same order in which output buffer is submitted. - *\code - The below example shows how asynchronous encoding in case of 1 B frames - ------------------------------------------------------------------------ - Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..) - and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to - keep a copy of the input buffers for re-ordering and it allocates following - internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI - and the client is not responsible for the allocating or freeing the memory of - the internal buffers. - - a) The client main thread will queue the following encode frame calls. - Note the picture type is unknown to the client, the decision is being taken by - NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter - consisting of allocated input buffer, output buffer and output events in successive - ::NvEncEncodePicture() API calls along with other required encode picture params. - For example: - 1st EncodePicture parameters - (I1, O1, E1) - 2nd EncodePicture parameters - (I2, O2, E2) - 3rd EncodePicture parameters - (I3, O3, E3) - - b) NvEncodeAPI SW will receive the following encode Commands from the client. - The left side shows input from client in the form (Input buffer, Output Buffer, - Output Event). The right hand side shows a possible picture type decision take by - the NvEncodeAPI interface. - (I1, O1, E1) ---P1 Frame - (I2, O2, E2) ---B2 Frame - (I3, O3, E3) ---P3 Frame - - c) NvEncodeAPI interface will make a copy of the input buffers to its internal - buffersfor re-ordering. These copies are done as part of nvEncEncodePicture - function call from the client and NvEncodeAPI interface is responsible for - synchronization of copy operation with the actual encoding operation. - I1 --> NvI1 - I2 --> NvI2 - I3 --> NvI3 - - d) After returning from ::NvEncEncodePicture() call , the client must queue the output - bitstream processing work to the secondary thread. The output bitstream processing - for asynchronous mode consist of first waiting on completion event(E1, E2..) - and then locking the output bitstream buffer(O1, O2..) for reading the encoded - data. The work queued to the secondary thread by the client is in the following order - (I1, O1, E1) - (I2, O2, E2) - (I3, O3, E3) - Note they are in the same order in which client calls ::NvEncEncodePicture() API - in \p step a). - - e) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive - the following encode commands: - (NvI1, O1, E1) ---P1 Frame - (NvI3, O2, E2) ---P3 Frame - (NvI2, O3, E3) ---B2 frame - - f) After the encoding operations are completed, the events will be signalled - by NvEncodeAPI interface in the following order : - (O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signalled. - (O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signalled. - (O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signalled. - - g) The client must lock the bitstream data using ::NvEncLockBitstream() API in - the order O1,O2,O3 to read the encoded data, after waiting for the events - to be signalled in the same order i.e E1, E2 and E3.The output processing is - done in the secondary thread in the following order: - Waits on E1, copies encoded bitstream from O1 - Waits on E2, copies encoded bitstream from O2 - Waits on E3, copies encoded bitstream from O3 - - -Note the client will receive the events signalling and output buffer in the - same order in which they have submitted for encoding. - -Note the LockBitstream will have picture type field which will notify the - output picture type to the clients. - -Note the input, output buffer and the output completion event are free to be - reused once NvEncodeAPI interfaced has signalled the event and the client has - copied the data from the output buffer. - - * \endcode - * - *\par Synchronous Encoding - * The client can enable synchronous mode of encoding by setting - * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API. - * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for - * some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD - * is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI - * interface might not be able to submit an input picture buffer for encoding - * immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot - * submit the input picture which is decided to be encoded as B frame as it waits - * for backward reference from temporally subsequent frames. This input picture - * is buffered internally and waits for more input picture to arrive. The client - * must not call ::NvEncLockBitstream() API on the output buffers whose - * ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must - * wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the - * output bitstreams to read the encoded bitstream data. The following example - * explains the scenario with synchronous encoding with 2 B frames. - *\code - The below example shows how synchronous encoding works in case of 1 B frames - ----------------------------------------------------------------------------- - Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..) - and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to - keep a copy of the input buffers for re-ordering and it allocates following - internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI - and the client is not responsible for the allocating or freeing the memory of - the internal buffers. - - The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1. - The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder - HW and returns ::NV_ENC_SUCCESS. - The client can now read the encoded data by locking the output O1 by calling - NvEncLockBitstream API. - - The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2. - The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it - to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT. - The error is not fatal and it notifies client that it cannot read the encoded - data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting - more work to the NvEncodeAPI interface. - - The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3. - The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for - encoding which will be used as backward reference frame for I2. - The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both - the submission are part of the same ::NvEncEncodePicture() function call. - The client can now read the encoded data for both the frames by locking the output - O2 followed by O3 ,by calling ::NvEncLockBitstream() API. - - The client must always lock the output in the same order in which it has submitted - to receive the encoded bitstream in correct encoding order. - - * \endcode - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] encodePicParams - * Pointer to the ::_NV_ENC_PIC_PARAMS structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_ENCODER_BUSY \n - * ::NV_ENC_ERR_NEED_MORE_INPUT \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams); - - -// NvEncLockBitstream -/** - * \brief Lock output bitstream buffer - * - * This function is used to lock the bitstream buffer to read the encoded data. - * The client can only access the encoded data by calling this function. - * The pointer to client accessible encoded data is returned in the - * NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data - * in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes - * The NvEncodeAPI interface also returns the output picture type and picture structure - * of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and - * NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has - * set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return - * ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not - * a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can - * retry the function after few milliseconds. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] lockBitstreamBufferParams - * Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_LOCK_BUSY \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams); - - -// NvEncUnlockBitstream -/** - * \brief Unlock the output bitstream buffer - * - * This function is used to unlock the output bitstream buffer after the client - * has read the encoded data from output buffer. The client must call this function - * to unlock the output buffer which it has previously locked using ::NvEncLockBitstream() - * function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause - * the function to fail. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] bitstreamBuffer - * bitstream buffer pointer being unlocked - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); - - -// NvLockInputBuffer -/** - * \brief Locks an input buffer - * - * This function is used to lock the input buffer to load the uncompressed YUV - * pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR - * it had previously allocated using ::NvEncCreateInputBuffer()in the - * NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field. - * The NvEncodeAPI interface returns pointer to client accessible input buffer - * memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] lockInputBufferParams - * Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure - * - * \return - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_LOCK_BUSY \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams); - - -// NvUnlockInputBuffer -/** - * \brief Unlocks the input buffer - * - * This function is used to unlock the input buffer memory previously locked for - * uploading YUV pixel data. The input buffer must be unlocked before being used - * again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture() - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] inputBuffer - * Pointer to the input buffer that is being unlocked. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - * - */ -NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer); - - -// NvEncGetEncodeStats -/** - * \brief Get encoding statistics. - * - * This function is used to retrieve the encoding statistics. - * This API is not supported when encode device type is CUDA. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] encodeStats - * Pointer to the ::_NV_ENC_STAT structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats); - - -// NvEncGetSequenceParams -/** - * \brief Get encoded sequence and picture header. - * - * This function can be used to retrieve the sequence and picture header out of - * band. The client must call this function only after the encoder has been - * initialized using ::NvEncInitializeEncoder() function. The client must - * allocate the memory where the NvEncodeAPI interface can copy the bitstream - * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer. - * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize. - * The NvEncodeAPI interface will copy the bitstream header payload and returns - * the actual size of the bitstream header in the field - * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize. - * The client must call ::NvEncGetSequenceParams() function from the same thread which is - * being used to call ::NvEncEncodePicture() function. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] sequenceParamPayload - * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload); - - -// NvEncRegisterAsyncEvent -/** - * \brief Register event for notification to encoding completion. - * - * This function is used to register the completion event with NvEncodeAPI - * interface. The event is required when the client has configured the encoder to - * work in asynchronous mode. In this mode the client needs to send a completion - * event with every output buffer. The NvEncodeAPI interface will signal the - * completion of the encoding process using this event. Only after the event is - * signalled the client can get the encoded data using ::NvEncLockBitstream() function. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] eventParams - * Pointer to the ::_NV_ENC_EVENT_PARAMS structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); - - -// NvEncUnregisterAsyncEvent -/** - * \brief Unregister completion event. - * - * This function is used to unregister completion event which has been previously - * registered using ::NvEncRegisterAsyncEvent() function. The client must unregister - * all events before destroying the encoder using ::NvEncDestroyEncoder() function. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] eventParams - * Pointer to the ::_NV_ENC_EVENT_PARAMS structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); - - -// NvEncMapInputResource -/** - * \brief Map an externally created input resource pointer for encoding. - * - * Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR - * which can be used for encoding in the ::NvEncEncodePicture() function. The - * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr. - * The NvEncodeAPI interface also returns the buffer format of the mapped resource - * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt. - * This function provides synchronization guarantee that any graphics or compute - * work submitted on the input buffer is completed before the buffer is used for encoding. - * The client should not access any input buffer while they are mapped by the encoder. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] mapInputResParams - * Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n - * ::NV_ENC_ERR_MAP_FAILED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams); - - -// NvEncUnmapInputResource -/** - * \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding - * - * - * UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource() - * API. The mapping created using ::NvEncMapInputResource() should be invalidated - * using this API before the external resource is destroyed by the client. The client - * must unmap the buffer after ::NvEncLockBitstream() API returns succuessfully for encode - * work submitted using the mapped input buffer. - * - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] mappedInputBuffer - * Pointer to the NV_ENC_INPUT_PTR - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n - * ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer); - -// NvEncDestroyEncoder -/** - * \brief Destroy Encoding Session - * - * Destroys the encoder session previously created using ::NvEncOpenEncodeSession() - * function. The client must flush the encoder before freeing any resources. In order - * to flush the encoder the client must pass a NULL encode picture packet and either - * wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait - * for the flush event to be signaled by the encoder in asynchronous mode. - * The client must free all the input and output resources created using the - * NvEncodeAPI interface before destroying the encoder. If the client is operating - * in asynchronous mode, it must also unregister the completion events previously - * registered. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder); - -// NvEncInvalidateRefFrames -/** - * \brief Invalidate reference frames - * - * Invalidates reference frame based on the time stamp provided by the client. - * The encoder marks any reference frames or any frames which have been reconstructed - * using the corrupt frame as invalid for motion estimation and uses older reference - * frames for motion estimation. The encoded forces the current frame to be encoded - * as an intra frame if no reference frames are left after invalidation process. - * This is useful for low latency application for error resiliency. The client - * is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so - * that encoder can keep a backup of older reference frames in the DPB and can use them - * for motion estimation when the newer reference frames have been invalidated. - * This API can be called multiple times. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] invalidRefFrameTimeStamp - * Timestamp of the invalid reference frames which needs to be invalidated. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp); - -// NvEncOpenEncodeSessionEx -/** - * \brief Opens an encoding session. - * - * Opens an encoding session and returns a pointer to the encoder interface in - * the \p **encoder parameter. The client should start encoding process by calling - * this API first. - * The client must pass a pointer to IDirect3DDevice9 device or CUDA context in the \p *device parameter. - * For the OpenGL interface, \p device must be NULL. An OpenGL context must be current when - * calling all NvEncodeAPI functions. - * If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API - * before exiting. - * - * \param [in] openSessionExParams - * Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure. - * \param [out] encoder - * Encode Session pointer to the NvEncodeAPI interface. - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n - * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n - * ::NV_ENC_ERR_INVALID_DEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder); - -// NvEncRegisterResource -/** - * \brief Registers a resource with the Nvidia Video Encoder Interface. - * - * Registers a resource with the Nvidia Video Encoder Interface for book keeping. - * The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API. - * - * \param [in] encoder - * Pointer to the NVEncodeAPI interface. - * - * \param [in] registerResParams - * Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n - * ::NV_ENC_ERR_GENERIC \n - * ::NV_ENC_ERR_UNIMPLEMENTED \n - * - */ -NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams); - -// NvEncUnregisterResource -/** - * \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface. - * - * Unregisters a resource previously registered with the Nvidia Video Encoder Interface. - * The client is expected to unregister any resource that it has registered with the - * Nvidia Video Encoder Interface before destroying the resource. - * - * \param [in] encoder - * Pointer to the NVEncodeAPI interface. - * - * \param [in] registeredResource - * The registered resource pointer that was returned in ::NvEncRegisterResource. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n - * ::NV_ENC_ERR_GENERIC \n - * ::NV_ENC_ERR_UNIMPLEMENTED \n - * - */ -NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource); - -// NvEncReconfigureEncoder -/** - * \brief Reconfigure an existing encoding session. - * - * Reconfigure an existing encoding session. - * The client should call this API to change/reconfigure the parameter passed during - * NvEncInitializeEncoder API call. - * Currently Reconfiguration of following are not supported. - * Change in GOP structure. - * Change in sync-Async mode. - * Change in MaxWidth & MaxHeight. - * Change in PTDmode. - * - * Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS - * is set while creating encoder session. - * - * \param [in] encoder - * Pointer to the NVEncodeAPI interface. - * - * \param [in] reInitEncodeParams - * Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure. - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n - * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n - * ::NV_ENC_ERR_INVALID_DEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_GENERIC \n - * - */ -NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams); - - - -// NvEncCreateMVBuffer -/** - * \brief Allocates output MV buffer for ME only mode. - * - * This function is used to allocate an output MV buffer. The size of the mvBuffer is - * dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call. - * The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the - * ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in - * ::NvEncRunMotionEstimationOnly() API. - * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in,out] createMVBufferParams - * Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_GENERIC \n - */ -NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams); - - -// NvEncDestroyMVBuffer -/** - * \brief Release an output MV buffer for ME only mode. - * - * This function is used to release the output MV buffer allocated using - * the ::NvEncCreateMVBuffer() function. The client must release the output - * mvBuffer using this function before destroying the encoder session. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] mvBuffer - * Pointer to the mvBuffer being released. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - */ -NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer); - - -// NvEncRunMotionEstimationOnly -/** - * \brief Submit an input picture and reference frame for motion estimation in ME only mode. - * - * This function is used to submit the input frame and reference frame for motion - * estimation. The ME parameters are passed using *meOnlyParams which is a pointer - * to ::_NV_ENC_MEONLY_PARAMS structure. - * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. - * to get motion vector data. - * - * \param [in] encoder - * Pointer to the NvEncodeAPI interface. - * \param [in] meOnlyParams - * Pointer to the ::_NV_ENC_MEONLY_PARAMS structure. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n - * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n - * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n - * ::NV_ENC_ERR_OUT_OF_MEMORY \n - * ::NV_ENC_ERR_INVALID_PARAM \n - * ::NV_ENC_ERR_INVALID_VERSION \n - * ::NV_ENC_ERR_NEED_MORE_INPUT \n - * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n - * ::NV_ENC_ERR_GENERIC \n - */ -NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams); - -// NvEncodeAPIGetMaxSupportedVersion -/** - * \brief Get the largest NvEncodeAPI version supported by the driver. - * - * This function can be used by clients to determine if the driver supports - * the NvEncodeAPI header the application was compiled with. - * - * \param [out] version - * Pointer to the requested value. The 4 least significant bits in the returned - * indicate the minor version and the rest of the bits indicate the major - * version of the largest supported version. - * - * \return - * ::NV_ENC_SUCCESS \n - * ::NV_ENC_ERR_INVALID_PTR \n - */ -NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion (uint32_t* version); - - -/// \cond API PFN -/* - * Defines API function pointers - */ -typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig); -typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer); -typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); -typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); -typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats); -typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload); -typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer); -typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder); -typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp); -typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder); -typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes); -typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams); - -typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams); -typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer); -typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams); - - -/// \endcond - - -/** @} */ /* END ENCODE_FUNC */ - -/** - * \ingroup ENCODER_STRUCTURE - * NV_ENCODE_API_FUNCTION_LIST - */ -typedef struct _NV_ENCODE_API_FUNCTION_LIST -{ - uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */ - uint32_t reserved; /**< [in]: Reserved and should be set to 0. */ - PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */ - PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */ - PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/ - PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */ - PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */ - PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */ - PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */ - PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */ - PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */ - PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */ - PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */ - PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */ - PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */ - PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */ - PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */ - PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */ - PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */ - PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */ - PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */ - PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */ - PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */ - PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */ - PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */ - PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */ - PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */ - PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */ - PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */ - PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */ - PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */ - PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */ - PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */ - PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */ - PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */ - void* reserved1; - PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */ - PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */ - PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */ - void* reserved2[281]; /**< [in]: Reserved and must be set to NULL */ -} NV_ENCODE_API_FUNCTION_LIST; - -/** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */ -#define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2) - -// NvEncodeAPICreateInstance -/** - * \ingroup ENCODE_FUNC - * Entry Point to the NvEncodeAPI interface. - * - * Creates an instance of the NvEncodeAPI interface, and populates the - * pFunctionList with function pointers to the API routines implemented by the - * NvEncodeAPI interface. - * - * \param [out] functionList - * - * \return - * ::NV_ENC_SUCCESS - * ::NV_ENC_ERR_INVALID_PTR - */ -NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList); - -#ifdef __cplusplus -} -#endif - - -#endif - diff --git a/compat/os2threads.h b/compat/os2threads.h deleted file mode 100644 index 40a119ffe1..0000000000 --- a/compat/os2threads.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2011 KO Myung-Hun - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * os2threads to pthreads wrapper - */ - -#ifndef COMPAT_OS2THREADS_H -#define COMPAT_OS2THREADS_H - -#define INCL_DOS -#include - -#undef __STRICT_ANSI__ /* for _beginthread() */ -#include - -#include -#include - -#include "libavutil/attributes.h" - -typedef struct { - TID tid; - void *(*start_routine)(void *); - void *arg; - void *result; -} pthread_t; - -typedef void pthread_attr_t; - -typedef HMTX pthread_mutex_t; -typedef void pthread_mutexattr_t; - -typedef struct { - HEV event_sem; - HEV ack_sem; - volatile unsigned wait_count; -} pthread_cond_t; - -typedef void pthread_condattr_t; - -typedef struct { - volatile int done; - _fmutex mtx; -} pthread_once_t; - -#define PTHREAD_ONCE_INIT {0, _FMUTEX_INITIALIZER} - -static void thread_entry(void *arg) -{ - pthread_t *thread = arg; - - thread->result = thread->start_routine(thread->arg); -} - -static av_always_inline int pthread_create(pthread_t *thread, - const pthread_attr_t *attr, - void *(*start_routine)(void*), - void *arg) -{ - thread->start_routine = start_routine; - thread->arg = arg; - thread->result = NULL; - - thread->tid = _beginthread(thread_entry, NULL, 1024 * 1024, thread); - - return 0; -} - -static av_always_inline int pthread_join(pthread_t thread, void **value_ptr) -{ - DosWaitThread(&thread.tid, DCWW_WAIT); - - if (value_ptr) - *value_ptr = thread.result; - - return 0; -} - -static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr) -{ - DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE); - - return 0; -} - -static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex) -{ - DosCloseMutexSem(*(PHMTX)mutex); - - return 0; -} - -static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex) -{ - DosRequestMutexSem(*(PHMTX)mutex, SEM_INDEFINITE_WAIT); - - return 0; -} - -static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex) -{ - DosReleaseMutexSem(*(PHMTX)mutex); - - return 0; -} - -static av_always_inline int pthread_cond_init(pthread_cond_t *cond, - const pthread_condattr_t *attr) -{ - DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE); - DosCreateEventSem(NULL, &cond->ack_sem, DCE_POSTONE, FALSE); - - cond->wait_count = 0; - - return 0; -} - -static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond) -{ - DosCloseEventSem(cond->event_sem); - DosCloseEventSem(cond->ack_sem); - - return 0; -} - -static av_always_inline int pthread_cond_signal(pthread_cond_t *cond) -{ - if (!__atomic_cmpxchg32(&cond->wait_count, 0, 0)) { - DosPostEventSem(cond->event_sem); - DosWaitEventSem(cond->ack_sem, SEM_INDEFINITE_WAIT); - } - - return 0; -} - -static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond) -{ - while (!__atomic_cmpxchg32(&cond->wait_count, 0, 0)) - pthread_cond_signal(cond); - - return 0; -} - -static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, - pthread_mutex_t *mutex) -{ - __atomic_increment(&cond->wait_count); - - pthread_mutex_unlock(mutex); - - DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT); - - __atomic_decrement(&cond->wait_count); - - DosPostEventSem(cond->ack_sem); - - pthread_mutex_lock(mutex); - - return 0; -} - -static av_always_inline int pthread_once(pthread_once_t *once_control, - void (*init_routine)(void)) -{ - if (!once_control->done) - { - _fmutex_request(&once_control->mtx, 0); - - if (!once_control->done) - { - init_routine(); - - once_control->done = 1; - } - - _fmutex_release(&once_control->mtx); - } - - return 0; -} -#endif /* COMPAT_OS2THREADS_H */ diff --git a/compat/solaris/make_sunver.pl b/compat/solaris/make_sunver.pl index 0e9ed1d351..929bdda7b7 100755 --- a/compat/solaris/make_sunver.pl +++ b/compat/solaris/make_sunver.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/usr/bin/perl -w # make_sunver.pl # diff --git a/compat/strtod.c b/compat/strtod.c index 8b4243b313..258909f409 100644 --- a/compat/strtod.c +++ b/compat/strtod.c @@ -2,20 +2,20 @@ * C99-compatible strtod() implementation * Copyright (c) 2012 Ronald S. Bultje * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -25,9 +25,9 @@ #include "libavutil/avstring.h" #include "libavutil/mathematics.h" -static const char *check_nan_suffix(const char *s) +static char *check_nan_suffix(char *s) { - const char *start = s; + char *start = s; if (*s++ != '(') return start; @@ -44,7 +44,7 @@ double strtod(const char *, char **); double avpriv_strtod(const char *nptr, char **endptr) { - const char *end; + char *end; double res; /* Skip leading spaces */ @@ -81,13 +81,13 @@ double avpriv_strtod(const char *nptr, char **endptr) !av_strncasecmp(nptr, "+0x", 3)) { /* FIXME this doesn't handle exponents, non-integers (float/double) * and numbers too large for long long */ - res = strtoll(nptr, (char **)&end, 16); + res = strtoll(nptr, &end, 16); } else { - res = strtod(nptr, (char **)&end); + res = strtod(nptr, &end); } if (endptr) - *endptr = (char *)end; + *endptr = end; return res; } diff --git a/compat/tms470/math.h b/compat/tms470/math.h index 0a42743a0b..b686d4d8a9 100644 --- a/compat/tms470/math.h +++ b/compat/tms470/math.h @@ -1,23 +1,23 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef COMPAT_TMS470_MATH_H -#define COMPAT_TMS470_MATH_H +#ifndef LIBAV_COMPAT_TMS470_MATH_H +#define LIBAV_COMPAT_TMS470_MATH_H #include_next @@ -27,4 +27,4 @@ #define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 })) #define NAN (*(const float*)((const unsigned []){ 0x7fc00000 })) -#endif /* COMPAT_TMS470_MATH_H */ +#endif /* LIBAV_COMPAT_TMS470_MATH_H */ diff --git a/compat/va_copy.h b/compat/va_copy.h deleted file mode 100644 index a40bbe6637..0000000000 --- a/compat/va_copy.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MSVC Compatible va_copy macro - * Copyright (c) 2012 Derek Buitenhuis - * - * 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_VA_COPY_H -#define COMPAT_VA_COPY_H - -#include - -#if !defined(va_copy) && defined(_MSC_VER) -#define va_copy(dst, src) ((dst) = (src)) -#endif -#if !defined(va_copy) && defined(__GNUC__) && __GNUC__ < 3 -#define va_copy(dst, src) __va_copy(dst, src) -#endif - -#endif /* COMPAT_VA_COPY_H */ diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h deleted file mode 100644 index 78cc8f4c96..0000000000 --- a/compat/w32dlfcn.h +++ /dev/null @@ -1,93 +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 -#if (_WIN32_WINNT < 0x0602) || HAVE_WINRT -#include "libavutil/wchar_filename.h" -#endif -/** - * Safe function used to open dynamic libs. This attempts to improve program security - * by removing the current directory from the dll search path. Only dll's found in the - * executable or system directory are allowed to be loaded. - * @param name The dynamic lib name. - * @return A handle to the opened lib. - */ -static inline HMODULE win32_dlopen(const char *name) -{ -#if _WIN32_WINNT < 0x0602 - // Need to check if KB2533623 is available - if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDefaultDllDirectories")) { - HMODULE module = NULL; - wchar_t *path = NULL, *name_w = NULL; - DWORD pathlen; - if (utf8towchar(name, &name_w)) - goto exit; - path = (wchar_t *)av_mallocz_array(MAX_PATH, sizeof(wchar_t)); - // Try local directory first - pathlen = GetModuleFileNameW(NULL, path, MAX_PATH); - pathlen = wcsrchr(path, '\\') - path; - if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH) - goto exit; - path[pathlen] = '\\'; - wcscpy(path + pathlen + 1, name_w); - module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (module == NULL) { - // Next try System32 directory - pathlen = GetSystemDirectoryW(path, MAX_PATH); - if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH) - goto exit; - path[pathlen] = '\\'; - wcscpy(path + pathlen + 1, name_w); - module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - } -exit: - av_free(path); - av_free(name_w); - return module; - } -#endif -#ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR -# define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200 -#endif -#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32 -# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 -#endif -#if HAVE_WINRT - wchar_t *name_w = NULL; - int ret; - if (utf8towchar(name, &name_w)) - return NULL; - ret = LoadPackagedLibrary(name_w, 0); - av_free(name_w); - return ret; -#else - return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32); -#endif -} -#define dlopen(name, flags) win32_dlopen(name) -#define dlclose FreeLibrary -#define dlsym GetProcAddress -#else -#include -#endif - -#endif /* COMPAT_W32DLFCN_H */ diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h index eeead6051f..f38f767d8f 100644 --- a/compat/w32pthreads.h +++ b/compat/w32pthreads.h @@ -4,20 +4,20 @@ * Authors: Steven Walters * Pegasys Inc. * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav 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, + * Libav 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 + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -26,8 +26,8 @@ * w32threads to pthreads wrapper */ -#ifndef COMPAT_W32PTHREADS_H -#define COMPAT_W32PTHREADS_H +#ifndef LIBAV_COMPAT_W32PTHREADS_H +#define LIBAV_COMPAT_W32PTHREADS_H /* Build up a pthread-like API using underlying Windows API. Have only static * methods so as to not conflict with a potentially linked in pthread-win32 @@ -45,7 +45,6 @@ #endif #include "libavutil/attributes.h" -#include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/mem.h" @@ -77,7 +76,7 @@ typedef struct pthread_cond_t { static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg) { - pthread_t *h = (pthread_t*)arg; + pthread_t *h = arg; h->ret = h->func(h->arg); return 0; } @@ -87,29 +86,19 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr, { thread->func = start_routine; thread->arg = arg; -#if HAVE_WINRT - thread->handle = (void*)CreateThread(NULL, 0, win32thread_worker, thread, - 0, NULL); -#else thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread, 0, NULL); -#endif return !thread->handle; } -static av_unused int pthread_join(pthread_t thread, void **value_ptr) +static av_unused void pthread_join(pthread_t thread, void **value_ptr) { DWORD ret = WaitForSingleObject(thread.handle, INFINITE); - if (ret != WAIT_OBJECT_0) { - if (ret == WAIT_ABANDONED) - return EINVAL; - else - return EDEADLK; - } + if (ret != WAIT_OBJECT_0) + return; if (value_ptr) *value_ptr = thread.ret; CloseHandle(thread.handle); - return 0; } static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr) @@ -134,6 +123,7 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m) } #if _WIN32_WINNT >= 0x0600 + typedef INIT_ONCE pthread_once_t; #define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT @@ -147,22 +137,20 @@ static av_unused int pthread_once(pthread_once_t *once_control, void (*init_rout return 0; } -static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) +static inline void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) { InitializeConditionVariable(cond); - return 0; } /* native condition variables do not destroy */ -static inline int pthread_cond_destroy(pthread_cond_t *cond) +static inline void pthread_cond_destroy(pthread_cond_t *cond) { - return 0; + return; } -static inline int pthread_cond_broadcast(pthread_cond_t *cond) +static inline void pthread_cond_broadcast(pthread_cond_t *cond) { WakeAllConditionVariable(cond); - return 0; } static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) @@ -171,10 +159,9 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex return 0; } -static inline int pthread_cond_signal(pthread_cond_t *cond) +static inline void pthread_cond_signal(pthread_cond_t *cond) { WakeConditionVariable(cond); - return 0; } #else // _WIN32_WINNT < 0x0600 @@ -258,7 +245,7 @@ static void (WINAPI *cond_signal)(pthread_cond_t *cond); static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex, DWORD milliseconds); -static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) +static av_unused void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) { win32_cond_t *win32_cond = NULL; @@ -266,32 +253,31 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_ if (cond_init) { cond_init(cond); - return 0; + return; } /* non native condition variables */ - win32_cond = (win32_cond_t*)av_mallocz(sizeof(win32_cond_t)); + win32_cond = av_mallocz(sizeof(win32_cond_t)); if (!win32_cond) - return ENOMEM; + return; cond->Ptr = win32_cond; win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); if (!win32_cond->semaphore) - return ENOMEM; + return; win32_cond->waiters_done = CreateEvent(NULL, TRUE, FALSE, NULL); if (!win32_cond->waiters_done) - return ENOMEM; + return; pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL); pthread_mutex_init(&win32_cond->mtx_broadcast, NULL); - return 0; } -static av_unused int pthread_cond_destroy(pthread_cond_t *cond) +static av_unused void pthread_cond_destroy(pthread_cond_t *cond) { - win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr; + win32_cond_t *win32_cond = cond->Ptr; /* native condition variables do not destroy */ if (cond_init) - return 0; + return; /* non native condition variables */ CloseHandle(win32_cond->semaphore); @@ -300,17 +286,16 @@ static av_unused int pthread_cond_destroy(pthread_cond_t *cond) pthread_mutex_destroy(&win32_cond->mtx_broadcast); av_freep(&win32_cond); cond->Ptr = NULL; - return 0; } -static av_unused int pthread_cond_broadcast(pthread_cond_t *cond) +static av_unused void pthread_cond_broadcast(pthread_cond_t *cond) { - win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr; + win32_cond_t *win32_cond = cond->Ptr; int have_waiter; if (cond_broadcast) { cond_broadcast(cond); - return 0; + return; } /* non native condition variables */ @@ -332,12 +317,11 @@ static av_unused int pthread_cond_broadcast(pthread_cond_t *cond) } else pthread_mutex_unlock(&win32_cond->mtx_waiter_count); pthread_mutex_unlock(&win32_cond->mtx_broadcast); - return 0; } static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { - win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr; + win32_cond_t *win32_cond = cond->Ptr; int last_waiter; if (cond_wait) { cond_wait(cond, mutex, INFINITE); @@ -367,13 +351,13 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu return pthread_mutex_lock(mutex); } -static av_unused int pthread_cond_signal(pthread_cond_t *cond) +static av_unused void pthread_cond_signal(pthread_cond_t *cond) { - win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr; + win32_cond_t *win32_cond = cond->Ptr; int have_waiter; if (cond_signal) { cond_signal(cond); - return 0; + return; } pthread_mutex_lock(&win32_cond->mtx_broadcast); @@ -390,14 +374,13 @@ static av_unused int pthread_cond_signal(pthread_cond_t *cond) } pthread_mutex_unlock(&win32_cond->mtx_broadcast); - return 0; } #endif static av_unused void w32thread_init(void) { #if _WIN32_WINNT < 0x0600 - HMODULE kernel_dll = GetModuleHandle(TEXT("kernel32.dll")); + HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll")); /* if one is available, then they should all be available */ cond_init = (void (WINAPI*)(pthread_cond_t *)) GetProcAddress(kernel_dll, "InitializeConditionVariable"); @@ -415,4 +398,4 @@ static av_unused void w32thread_init(void) } -#endif /* COMPAT_W32PTHREADS_H */ +#endif /* LIBAV_COMPAT_W32PTHREADS_H */ diff --git a/compat/windows/makedef b/compat/windows/makedef index fcaf108332..fd7959a745 100755 --- a/compat/windows/makedef +++ b/compat/windows/makedef @@ -45,7 +45,11 @@ libname=$(mktemp -u "library").lib trap 'rm -f -- $libname' EXIT -lib -out:${libname} $@ >/dev/null +if [ -n "$AR" ]; then + $AR rcs ${libname} $@ >/dev/null +else + lib -out:${libname} $@ >/dev/null +fi if [ $? != 0 ]; then echo "Could not create temporary library." >&2 exit 1 @@ -57,18 +61,28 @@ IFS=' # Determine if we're building for x86 or x86_64 and # set the symbol prefix accordingly. prefix="" -arch=$(dumpbin -headers ${libname} | - tr '\t' ' ' | - grep '^ \+.\+machine \+(.\+)' | - head -1 | - sed -e 's/^ \{1,\}.\{1,\} \{1,\}machine \{1,\}(\(...\)).*/\1/') - -if [ "${arch}" = "x86" ]; then - prefix="_" +if [ -n "$NM" ]; then + case $ARCH in + *86) + prefix="_" + ;; + *) + ;; + esac else - if [ "${arch}" != "ARM" ] && [ "${arch}" != "x64" ]; then - echo "Unknown machine type." >&2 - exit 1 + arch=$(dumpbin -headers ${libname} | + tr '\t' ' ' | + grep '^ \+.\+machine \+(.\+)' | + head -1 | + sed -e 's/^ \{1,\}.\{1,\} \{1,\}machine \{1,\}(\(...\)).*/\1/') + + if [ "${arch}" = "x86" ]; then + prefix="_" + else + if [ "${arch}" != "ARM" ] && [ "${arch}" != "x64" ]; then + echo "Unknown machine type." >&2 + exit 1 + fi fi fi @@ -112,7 +126,19 @@ for line in $(cat ${vscript} | tr '\t' ' '); do ' done -dump=$(dumpbin -linkermember:1 ${libname}) +if [ -n "$NM" ]; then + # Use eval, since NM="nm -g" + dump=$(eval "$NM --defined-only -g ${libname}" | + grep -v : | + grep -v ^$ | + cut -d' ' -f3 | + sed -e "s/^${prefix}//") +else + dump=$(dumpbin -linkermember:1 ${libname} | + sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' | + tail -n +2 | + cut -d' ' -f3) +fi rm ${libname} @@ -121,9 +147,6 @@ list="" for exp in ${regex}; do list="${list}"' '$(echo "${dump}" | - sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' | - tail -n +2 | - cut -d' ' -f3 | grep "^${exp}" | sed -e 's/^/ /') done diff --git a/configure b/configure index 4dd11efe5e..c24cdd4f7e 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #!/bin/sh # -# FFmpeg configure script +# Libav configure script # # Copyright (c) 2000-2002 Fabrice Bellard # Copyright (c) 2005-2008 Diego Biurrun @@ -44,9 +44,9 @@ if test "$E1" != 0 || test "$E2" = 0; then echo "No compatible shell script interpreter found." echo "This configure script requires a POSIX-compatible shell" echo "such as bash or ksh." - echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH." + echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH." echo "Instead, install a working POSIX-compatible shell." - echo "Disabling this configure test will create a broken FFmpeg." + echo "Disabling this configure test will create a broken Libav." if test "$BASH_VERSION" = '2.04.0(1)-release'; then echo "This bash version ($BASH_VERSION) is broken on your platform." echo "Upgrade to a later version if available." @@ -77,22 +77,17 @@ Help options: --list-filters show all available filters Standard options: - --logfile=FILE log tests and output to FILE [ffbuild/config.log] + --logfile=FILE log tests and output to FILE [avbuild/config.log] --disable-logging do not log configure debug information - --fatal-warnings fail if any configure warning is generated --prefix=PREFIX install in PREFIX [$prefix_default] --bindir=DIR install binaries in DIR [PREFIX/bin] - --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg] - --docdir=DIR install documentation in DIR [PREFIX/share/doc/ffmpeg] + --datadir=DIR install data files in DIR [PREFIX/share/avconv] + --docdir=DIR install documentation in DIR [PREFIX/share/doc/libav] --libdir=DIR install libs in DIR [PREFIX/lib] - --shlibdir=DIR install shared libs in DIR [LIBDIR] + --shlibdir=DIR install shared libs in DIR [PREFIX/lib] --incdir=DIR install includes in DIR [PREFIX/include] --mandir=DIR install man page in DIR [PREFIX/share/man] - --pkgconfigdir=DIR install pkg-config files in DIR [LIBDIR/pkgconfig] - --enable-rpath use rpath to allow installing libraries in paths - not part of the dynamic linker search path - use rpath when linking programs (USE WITH CARE) - --install-name-dir=DIR Darwin directory name for installed targets + --enable-rpath use rpath when linking programs (USE WITH CARE) Licensing options: --enable-gpl allow use of GPL code, the resulting libs @@ -105,41 +100,33 @@ Configuration options: --disable-static do not build static libraries [no] --enable-shared build shared libraries [no] --enable-small optimize for size instead of speed - --disable-runtime-cpudetect disable detecting CPU capabilities at runtime (smaller binary) + --enable-runtime-cpudetect detect CPU capabilities at runtime (bigger binary) --enable-gray enable full grayscale support (slower color) --disable-swscale-alpha disable alpha channel support in swscale --disable-all disable building components, libraries and programs - --disable-autodetect disable automatically detected external libraries [no] Program options: --disable-programs do not build command line programs - --disable-ffmpeg disable ffmpeg build - --disable-ffplay disable ffplay build - --disable-ffprobe disable ffprobe build - --disable-ffserver disable ffserver build - -Documentation options: - --disable-doc do not build documentation - --disable-htmlpages do not build HTML documentation pages - --disable-manpages do not build man documentation pages - --disable-podpages do not build POD documentation pages - --disable-txtpages do not build text documentation pages + --disable-avconv disable avconv build + --disable-avplay disable avplay build + --disable-avprobe disable avprobe build + --disable-avserver deprecated, does nothing Component options: + --disable-doc do not build documentation + --disable-pod2man do not build manual pages + --disable-texi2html do not build HTML documentation --disable-avdevice disable libavdevice build --disable-avcodec disable libavcodec build --disable-avformat disable libavformat build - --disable-swresample disable libswresample build + --disable-avutil disable libavutil build --disable-swscale disable libswscale build - --disable-postproc disable libpostproc build - --disable-avfilter disable libavfilter build - --enable-avresample enable libavresample build [no] - --disable-pthreads disable pthreads [autodetect] - --disable-w32threads disable Win32 threads [autodetect] - --disable-os2threads disable OS/2 threads [autodetect] + --disable-avfilter disable video filter support [no] + --disable-avresample disable libavresample build [no] + --disable-pthreads disable pthreads [auto] + --disable-w32threads disable Win32 threads [auto] --disable-network disable network support [no] --disable-dct disable DCT code - --disable-dwt disable DWT code --disable-error-resilience disable error resilience code --disable-lsp disable LSP code --disable-lzo disable LZO decoder code @@ -147,7 +134,6 @@ Component options: --disable-rdft disable RDFT code --disable-fft disable FFT code --disable-faan disable floating point AAN (I)DCT code - --disable-pixelutils disable pixel utils in libavutil Individual component options: --disable-everything disable all components listed below @@ -188,7 +174,7 @@ Individual component options: External library support: - Using any of the following switches will allow FFmpeg to link to the + Using any of the following switches will allow Libav to link to the corresponding external library. All the components depending on that library will become enabled, if all their other dependencies are met and they are not explicitly disabled. E.g. --enable-libwavpack will enable linking to @@ -199,131 +185,76 @@ External library support: libraries must be explicitly enabled. Also note that the following help text describes the purpose of the libraries - themselves, not all their features will necessarily be usable by FFmpeg. + themselves, not all their features will necessarily be usable by Libav. - --disable-alsa disable ALSA support [autodetect] - --disable-avfoundation disable Apple AVFoundation framework [autodetect] - --enable-avisynth enable reading of AviSynth script files [no] - --disable-bzlib disable bzlib [autodetect] - --disable-coreimage disable Apple CoreImage framework [autodetect] - --enable-chromaprint enable audio fingerprinting with chromaprint [no] - --enable-frei0r enable frei0r video filtering [no] - --enable-gcrypt enable gcrypt, needed for rtmp(t)e support - if openssl, librtmp or gmp is not used [no] - --enable-gmp enable gmp, needed for rtmp(t)e support - if openssl or librtmp is not used [no] - --enable-gnutls enable gnutls, needed for https support - if openssl is not used [no] - --disable-iconv disable iconv [autodetect] - --disable-jack disable libjack support [autodetect] - --enable-jni enable JNI support [no] - --enable-ladspa enable LADSPA audio filtering [no] - --enable-libass enable libass subtitles rendering, - needed for subtitles and ass filter [no] - --enable-libbluray enable BluRay reading using libbluray [no] - --enable-libbs2b enable bs2b DSP library [no] - --enable-libcaca enable textual display using libcaca [no] - --enable-libcelt enable CELT decoding via libcelt [no] - --enable-libcdio enable audio CD grabbing with libcdio [no] - --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 - and libraw1394 [no] - --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no] - --enable-libflite enable flite (voice synthesis) support via libflite [no] - --enable-libfontconfig enable libfontconfig, useful for drawtext filter [no] - --enable-libfreetype enable libfreetype, needed for drawtext filter [no] - --enable-libfribidi enable libfribidi, improves drawtext filter [no] - --enable-libgme enable Game Music Emu via libgme [no] - --enable-libgsm enable GSM de/encoding via libgsm [no] - --enable-libiec61883 enable iec61883 via libiec61883 [no] - --enable-libilbc enable iLBC de/encoding via libilbc [no] - --enable-libkvazaar enable HEVC encoding via libkvazaar [no] - --enable-libmodplug enable ModPlug via libmodplug [no] - --enable-libmp3lame enable MP3 encoding via libmp3lame [no] - --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no] - --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no] - --enable-libopencv enable video filtering via libopencv [no] - --enable-libopenh264 enable H.264 encoding via OpenH264 [no] - --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no] - --enable-libopenmpt enable decoding tracked files via libopenmpt [no] - --enable-libopus enable Opus de/encoding via libopus [no] - --enable-libpulse enable Pulseaudio input via libpulse [no] - --enable-librsvg enable SVG rasterization via librsvg [no] - --enable-librubberband enable rubberband needed for rubberband filter [no] - --enable-librtmp enable RTMP[E] support via librtmp [no] - --enable-libshine enable fixed-point MP3 encoding via libshine [no] - --enable-libsmbclient enable Samba protocol via libsmbclient [no] - --enable-libsnappy enable Snappy compression, needed for hap encoding [no] - --enable-libsoxr enable Include libsoxr resampling [no] - --enable-libspeex enable Speex de/encoding via libspeex [no] - --enable-libssh enable SFTP protocol via libssh [no] - --enable-libtesseract enable Tesseract, needed for ocr filter [no] - --enable-libtheora enable Theora encoding via libtheora [no] - --enable-libtwolame enable MP2 encoding via libtwolame [no] - --enable-libv4l2 enable libv4l2/v4l-utils [no] - --enable-libvidstab enable video stabilization using vid.stab [no] - --enable-libvmaf enable vmaf filter via libvmaf [no] - --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] - --enable-libvorbis enable Vorbis en/decoding via libvorbis, - native implementation exists [no] - --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no] - --enable-libwavpack enable wavpack encoding via libwavpack [no] - --enable-libwebp enable WebP encoding via libwebp [no] - --enable-libx264 enable H.264 encoding via x264 [no] - --enable-libx265 enable HEVC encoding via x265 [no] - --enable-libxavs enable AVS encoding via xavs [no] - --enable-libxcb enable X11 grabbing using XCB [autodetect] - --enable-libxcb-shm enable X11 grabbing shm communication [autodetect] - --enable-libxcb-xfixes enable X11 grabbing mouse rendering [autodetect] - --enable-libxcb-shape enable X11 grabbing shape rendering [autodetect] - --enable-libxvid enable Xvid encoding via xvidcore, - native MPEG-4/Xvid encoder exists [no] - --enable-libxml2 enable XML parsing using the C library libxml2 [no] - --enable-libzimg enable z.lib, needed for zscale filter [no] - --enable-libzmq enable message passing via libzmq [no] - --enable-libzvbi enable teletext support via libzvbi [no] - --disable-lzma disable lzma [autodetect] - --enable-decklink enable Blackmagic DeckLink I/O support [no] - --enable-libndi_newtek enable Newteck NDI I/O support [no] - --enable-mediacodec enable Android MediaCodec support [no] - --enable-libmysofa enable libmysofa, needed for sofalizer filter [no] - --enable-openal enable OpenAL 1.1 capture support [no] - --enable-opencl enable OpenCL code - --enable-opengl enable OpenGL rendering [no] - --enable-openssl enable openssl, needed for https support - if gnutls is not used [no] - --disable-sndio disable sndio support [autodetect] - --disable-schannel disable SChannel SSP, needed for TLS support on - Windows if openssl and gnutls are not used [autodetect] - --disable-sdl2 disable sdl2 [autodetect] - --disable-securetransport disable Secure Transport, needed for TLS support - on OSX if openssl and gnutls are not used [autodetect] - --disable-xlib disable xlib [autodetect] - --disable-zlib disable zlib [autodetect] + --enable-avisynth video frameserver + --enable-avxsynth Linux version of AviSynth + --enable-bzlib bzip2 compression [autodetect] + --enable-frei0r video filtering plugins + --enable-gnutls crypto + --enable-libbs2b Bauer stereophonic-to-binaural DSP + --enable-libcdio audio CD input + --enable-libdc1394 IEEE 1394/Firewire camera input + --enable-libdcadec DCA audio decoding + --enable-libfaac AAC audio encoding + --enable-libfdk-aac AAC audio encoding/decoding + --enable-libfontconfig font configuration and management + --enable-libfreetype font rendering + --enable-libgsm GSM audio encoding/decoding + --enable-libhdcd HDCD decoding filter + --enable-libilbc ILBC audio encoding/decoding + --enable-libjack JACK audio sound server + --enable-libkvazaar HEVC video encoding + --enable-libmp3lame MP3 audio encoding + --enable-libopencore-amrnb AMR-NB audio encoding/decoding + --enable-libopencore-amrwb AMR-WB audio decoding + --enable-libopencv computer vision + --enable-libopenh264 H.264 video encoding/decoding + --enable-libopenjpeg JPEG 2000 image encoding/decoding + --enable-libopus Opus audio encoding/decoding + --enable-libpulse Pulseaudio sound server + --enable-librtmp RTMP streaming + --enable-libschroedinger Dirac video encoding/decoding + --enable-libsnappy snappy compression + --enable-libspeex Speex audio encoding/decoding + --enable-libtheora Theora video encoding/decoding + --enable-libtwolame MP2 audio encoding + --enable-libvo-aacenc AAC audio encoding + --enable-libvo-amrwbenc AMR-WB audio encoding + --enable-libvorbis Vorbis audio encoding/decoding + --enable-libvpx VP* video encoding/decoding + --enable-libwavpack Wavpack audio encoding/decoding + --enable-libwebp WebP image encoding/decoding + --enable-libx264 H.264 video encoding + --enable-libx265 HEVC video encoding + --enable-libxavs Chinese AVS video encoding + --enable-libxcb X window system protocol communication + --enable-libxcb-shm X11 shm communication [auto] + --enable-libxcb-xfixes X11 mouse rendering [auto] + --enable-libxvid MPEG-4 ASP video encoding + --enable-openssl crypto + --enable-zlib compression [autodetect] The following libraries provide various hardware acceleration features: - --disable-audiotoolbox disable Apple AudioToolbox code [autodetect] - --disable-cuda disable dynamically linked Nvidia CUDA code [autodetect] - --enable-cuda-sdk enable CUDA features that require the CUDA SDK [no] - --disable-cuvid disable Nvidia CUVID support [autodetect] - --disable-d3d11va disable Microsoft Direct3D 11 video acceleration code [autodetect] - --disable-dxva2 disable Microsoft DirectX 9 video acceleration code [autodetect] - --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] - --enable-libnpp enable Nvidia Performance Primitives-based code [no] - --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] - --disable-nvenc disable Nvidia video encoding code [autodetect] - --enable-omx enable OpenMAX IL code [no] - --enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no] - --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] - --disable-vda disable Apple Video Decode Acceleration code [autodetect] - --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] - --disable-videotoolbox disable VideoToolbox code [autodetect] + --enable-cuda Nvidia CUDA (dynamically linked) + --enable-cuvid Nvidia CUVID video decode acceleration + --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto] + --enable-dxva2 Microsoft DirectX 9 video acceleration [auto] + --enable-libmfx Intel MediaSDK (AKA Quick Sync Video) + --enable-libnpp Nvidia CUDA processing + --enable-mmal Broadcom Multi-Media Abstraction Layer (Raspberry Pi) + --enable-nvenc Nvidia video encoding + --enable-omx OpenMAX IL + --enable-omx-rpi OpenMAX IL for Raspberry Pi + --enable-vaapi Video Acceleration API (mainly Unix/Intel) + --enable-vda Apple Video Decode Acceleration [auto] + --enable-vdpau Nvidia Video Decode and Presentation API for Unix [auto] Toolchain options: --arch=ARCH select architecture [$arch] --cpu=CPU select the minimum required CPU (affects instruction selection, may crash on older CPUs) --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix] - --progs-suffix=SUFFIX program name suffix [] --enable-cross-compile assume a cross-compiler is used --sysroot=PATH root of cross-build tree --sysinclude=PATH location of cross-build system headers @@ -331,25 +262,17 @@ Toolchain options: --target-exec=CMD command to run executables on target --target-path=DIR path to view of build directory on target --target-samples=DIR path to samples directory on target - --tempprefix=PATH force fixed dir/prefix instead of mktemp for checks --toolchain=NAME set tool defaults according to NAME - --nm=NM use nm tool NM [$nm_default] + --nm=NM use nm tool --ar=AR use archive tool AR [$ar_default] --as=AS use assembler AS [$as_default] - --ln_s=LN_S use symbolic link tool LN_S [$ln_s_default] - --strip=STRIP use strip tool STRIP [$strip_default] - --windres=WINDRES use windows resource compiler WINDRES [$windres_default] - --x86asmexe=EXE use nasm-compatible assembler EXE [$x86asmexe_default] --cc=CC use C compiler CC [$cc_default] - --cxx=CXX use C compiler CXX [$cxx_default] --objcc=OCC use ObjC compiler OCC [$cc_default] --dep-cc=DEPCC use dependency generator DEPCC [$cc_default] - --nvcc=NVCC use Nvidia CUDA compiler NVCC [$nvcc_default] - --ld=LD use linker LD [$ld_default] + --ld=LD use linker LD + --x86asmexe=X86ASM use x86 assembler X86ASM --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default] --pkg-config-flags=FLAGS pass additional flags to pkgconf [] - --ranlib=RANLIB use ranlib RANLIB [$ranlib_default] - --doxygen=DOXYGEN use DOXYGEN to generate API doc [$doxygen_default] --host-cc=HOSTCC use host C compiler HOSTCC --host-cflags=HCFLAGS use HCFLAGS when compiling for host --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host @@ -358,16 +281,13 @@ Toolchain options: --host-libs=HLIBS use libs HLIBS when linking for host --host-os=OS compiler host OS [$target_os] --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS] - --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS] --extra-objcflags=FLAGS add FLAGS to OBJCFLAGS [$CFLAGS] --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] - --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS [$LDLIBFLAGS] + --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [$LDSOFLAGS] --extra-libs=ELIBS add ELIBS [$ELIBS] --extra-version=STRING version string suffix [] --optflags=OPTFLAGS override optimization-related compiler flags - --nvccflags=NVCCFLAGS override nvcc flags [$nvccflags_default] - --build-suffix=SUFFIX library name suffix [] --enable-pic build position-independent code --enable-thumb compile for Thumb instruction set --enable-lto use link-time optimization @@ -381,7 +301,7 @@ Advanced options (experts only): --disable-safe-bitstream-reader disable buffer boundary checking in bitreaders (faster, but may crash) - --sws-max-filter-size=N the max filter size swscale uses [$sws_max_filter_size_default] + --enable-sram allow use of on-chip SRAM Optimization options (experts only): --disable-asm disable all assembly optimizations @@ -403,7 +323,6 @@ Optimization options (experts only): --disable-fma3 disable FMA3 optimizations --disable-fma4 disable FMA4 optimizations --disable-avx2 disable AVX2 optimizations - --disable-aesni disable AESNI optimizations --disable-armv5te disable armv5te optimizations --disable-armv6 disable armv6 optimizations --disable-armv6t2 disable armv6t2 optimizations @@ -411,28 +330,14 @@ Optimization options (experts only): --disable-neon disable NEON optimizations --disable-inline-asm disable use of inline assembly --disable-x86asm disable use of standalone x86 assembly - --disable-mipsdsp disable MIPS DSP ASE R1 optimizations - --disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations - --disable-msa disable MSA optimizations - --disable-mipsfpu disable floating point MIPS optimizations - --disable-mmi disable Loongson SIMD optimizations - --disable-fast-unaligned consider unaligned accesses slow -Developer options (useful when working on FFmpeg itself): +Developer options (useful when working on Libav itself): --disable-debug disable debugging symbols --enable-debug=LEVEL set the debug level [$debuglevel] --disable-optimizations disable compiler optimizations --enable-extra-warnings enable more compiler warnings - --disable-stripping disable stripping of executables and shared libraries - --assert-level=level 0(default), 1 or 2, amount of assertion testing, - 2 causes a slowdown at runtime. - --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data - --valgrind=VALGRIND run "make fate" tests through valgrind to detect memory - leaks and errors, using the specified valgrind binary. - Cannot be combined with --target-exec - --enable-ftrapv Trap arithmetic overflows --samples=PATH location of test samples for FATE, if not set use - \$FATE_SAMPLES at make invocation time. + \$LIBAV_SAMPLES at make invocation time. --enable-neon-clobber-test check NEON registers for clobbering (should be used only for debugging purposes) --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only; @@ -447,11 +352,8 @@ Developer options (useful when working on FFmpeg itself): --random-seed=VALUE seed value for --enable/disable-random --disable-valgrind-backtrace do not print a backtrace under Valgrind (only applies to --disable-optimizations builds) - --enable-osfuzz Enable building fuzzer tool - --libfuzzer=PATH path to libfuzzer --ignore-tests=TESTS comma-separated list (without "fate-" prefix in the name) of tests whose result is ignored - --enable-linux-perf enable Linux Performance Monitor API NOTE: Object files are built at the place where configure is launched. EOF @@ -459,18 +361,6 @@ EOF } quotes='""' -if test -t 1 && which tput >/dev/null 2>&1; then - ncolors=$(tput colors) - if test -n "$ncolors" && test $ncolors -ge 8; then - bold_color=$(tput bold) - warn_color=$(tput setaf 3) - error_color=$(tput setaf 1) - reset_color=$(tput sgr0) - fi - # 72 used instead of 80 since that's the default of pr - ncols=$(tput cols) -fi -: ${ncols:=72} log(){ echo "$@" >> $logfile @@ -478,23 +368,31 @@ log(){ log_file(){ log BEGIN $1 - pr -n -t $1 >> $logfile + i=1 + while read line; do + printf '%5s %s\n' "${i}" "${line}" + i=$(($i+1)) + done < $1 >> $logfile log END $1 } +echolog(){ + log "$@" + echo "$@" +} + warn(){ log "WARNING: $*" WARNINGS="${WARNINGS}WARNING: $*\n" } die(){ - log "$@" - echo "$error_color$bold_color$@$reset_color" + echolog "$@" cat <>file; - } else if (file ~ /\\.texi\$/) { - pre = -v ? \"\" : \"@c \"; - yesno = \$2; - c2 = tolower(c); - gsub(/_/, \"-\", c2); - printf(\"%s@set %s %s\\n\", pre, c2, yesno) >>file; } } }" @@ -834,6 +705,15 @@ unique(){ eval "$var=\"${uniq_list}\"" } +resolve(){ + var=$1 + tmpvar= + for entry in $(eval echo \$$var); do + tmpvar="$tmpvar $(eval echo \$${entry})" + done + eval "$var=\"${tmpvar}\"" +} + add_cppflags(){ append CPPFLAGS "$@" } @@ -846,10 +726,6 @@ add_cflags_headers(){ append CFLAGS_HEADERS $($cflags_filter "$@") } -add_cxxflags(){ - append CXXFLAGS $($cflags_filter "$@") -} - add_asflags(){ append ASFLAGS $($asflags_filter "$@") } @@ -866,12 +742,12 @@ add_ldexeflags(){ append LDEXEFLAGS $($ldflags_filter "$@") } -add_ldlibflags(){ - append LDLIBFLAGS $($ldflags_filter "$@") +add_ldsoflags(){ + append LDSOFLAGS $($ldflags_filter "$@") } add_stripflags(){ - append ASMSTRIPFLAGS "$@" + append STRIPFLAGS "$@" } add_extralibs(){ @@ -901,11 +777,6 @@ check_cmd(){ "$@" >> $logfile 2>&1 } -check_stat(){ - log check_stat "$@" - stat "$1" >> $logfile 2>&1 -} - cc_o(){ eval printf '%s\\n' $CC_O } @@ -921,18 +792,11 @@ check_cc(){ check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC } -check_cxx(){ - log check_cxx "$@" - cat > $TMPCPP - log_file $TMPCPP - check_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP -} - check_objcc(){ log check_objcc "$@" - cat > $TMPM - log_file $TMPM - check_cmd $objcc -Werror=missing-prototypes $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPM + cat > $TMPC + log_file $TMPC + check_cmd $objcc $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPC } check_cpp(){ @@ -964,25 +828,6 @@ void foo(void){ __asm__ volatile($code); } EOF } -check_inline_asm_flags(){ - log check_inline_asm_flags "$@" - name="$1" - code="$2" - flags='' - shift 2 - while [ "$1" != "" ]; do - append flags $1 - shift - done; - disable $name - cat > $TMPC < $TMPS log_file $TMPS shift 1 - check_cmd $x86asmexe $X86ASMFLAGS -Werror "$@" -o $TMPO $TMPS + check_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS } ld_o(){ @@ -1003,14 +848,12 @@ ld_o(){ check_ld(){ log check_ld "$@" - type=$1 - shift 1 - flags=$(filter_out '-l*|*.so' $@) - libs=$(filter '-l*|*.so' $@) - check_$type $($cflags_filter $flags) || return + flags=$(filter_out '-l*' "$@") + libs=$(filter '-l*' "$@") + check_cc $($cflags_filter $flags) || return flags=$($ldflags_filter $flags) libs=$($ldflags_filter $libs) - check_cmd $ld $LDFLAGS $LDEXEFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs + check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs } print_include(){ @@ -1037,7 +880,7 @@ check_code(){ check_cppflags(){ log check_cppflags "$@" check_cpp "$@" <; EOF } @@ -1054,14 +897,6 @@ check_cflags(){ test_cflags "$@" && add_cflags "$@" } -check_cxxflags(){ - log check_cxxflags "$@" - set -- $($cflags_filter "$@") - check_cxx "$@" < int x; EOF } -check_header_objcc(){ - log check_header_objcc "$@" - rm -f -- "$TMPO" - header=$1 - shift - disable_safe $header - { - echo "#include <$header>" - echo "int main(void) { return 0; }" - } | check_objcc && check_stat "$TMPO" && enable_safe $header -} - -check_apple_framework(){ - log check_apple_framework "$@" - framework="$1" - name="$(tolower $framework)" - header="${framework}/${framework}.h" - disable $name - check_header_objcc $header && enable $name && add_extralibs "-framework $framework" -} - check_func(){ log check_func "$@" func=$1 shift disable $func - check_ld "cc" "$@" < -#include -float foo(complex float f, complex float g) { return $func($args); } -int main(void){ return (int) foo; } -EOF -} - check_mathfunc(){ log check_mathfunc "$@" func=$1 @@ -1166,10 +965,10 @@ check_mathfunc(){ shift 2 test $narg = 2 && args="f, g" || args="f" disable $func - check_ld "cc" "$@" < float foo(float f, float g) { return $func($args); } -int main(void){ return (int) foo; } +int main(void){ return 0; } EOF } @@ -1182,36 +981,11 @@ check_func_headers(){ for hdr in $headers; do print_include $hdr done - echo "#include " for func in $funcs; do echo "long check_$func(void) { return (long) $func; }" done - echo "int main(void) { int ret = 0;" - # LTO could optimize out the test functions without this - for func in $funcs; do - echo " ret |= ((intptr_t)check_$func) & 0xFFFF;" - done - echo "return ret; }" - } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers -} - -check_class_headers_cpp(){ - log check_class_headers_cpp "$@" - headers=$1 - classes=$2 - shift 2 - { - for hdr in $headers; do - echo "#include <$hdr>" - done - echo "int main(void) { " - i=1 - for class in $classes; do - echo "$class obj$i;" - i=$(expr $i + 1) - done - echo "return 0; }" - } | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers + echo "int main(void) { return 0; }" + } | check_ld "$@" && enable $funcs && enable_sanitized $headers } check_cpp_condition(){ @@ -1227,15 +1001,13 @@ check_cpp_condition(){ EOF } -test_cflags_cc(){ - log test_cflags_cc "$@" +test_cflags_cpp(){ + log test_cflags_cpp "$@" flags=$1 - header=$2 - condition=$3 - shift 3 + condition=$2 + shift 2 set -- $($cflags_filter "$flags") - check_cc "$@" < + check_cpp "$@" <> $logfile 2>&1; } + check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; } } check_exec_crash(){ @@ -1316,8 +1083,8 @@ check_type(){ headers=$1 type=$2 shift 2 - disable_safe "$type" - check_code cc "$headers" "$type v" "$@" && enable_safe "$type" + disable_sanitized "$type" + check_code cc "$headers" "$type v" "$@" && enable_sanitized "$type" } check_struct(){ @@ -1326,9 +1093,9 @@ check_struct(){ struct=$2 member=$3 shift 3 - disable_safe "${struct}_${member}" + disable_sanitized "${struct}_${member}" check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" && - enable_safe "${struct}_${member}" + enable_sanitized "${struct}_${member}" } check_builtin(){ @@ -1338,7 +1105,7 @@ check_builtin(){ builtin=$3 shift 3 disable "$name" - check_code ld "$headers" "$builtin" "cc" "$@" && enable "$name" + check_code ld "$headers" "$builtin" "$@" && enable "$name" } check_compile_assert(){ @@ -1361,24 +1128,25 @@ require(){ check_lib $name "$headers" $func "$@" || die "ERROR: $name_version not found" } -require_cpp(){ - name="$1" - headers="$2" - classes="$3" - shift 3 - check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found" +require_header(){ + log require "$@" + header="$1" + shift + check_header "$header" "$@" || die "ERROR: $header not found" } -use_pkg_config(){ - log use_pkg_config "$@" - pkg="$1" - check_pkg_config "$@" || return 1 - add_cflags $(get_safe "${pkg}_cflags") - add_extralibs $(get_safe "${pkg}_extralibs") +require_cpp_condition(){ + log require "$@" + header="$1" + condition="$2" + shift 2 + check_cpp_condition "$header" "$condition" "$@" || die "ERROR: $condition not satisfied" } require_pkg_config(){ - use_pkg_config "$@" || die "ERROR: $pkg not found using pkg-config$pkg_config_fail_message" + log require_pkg_config "$@" + pkg_version="$2" + check_pkg_config "$@" || die "ERROR: $pkg_version not found" } hostcc_e(){ @@ -1406,7 +1174,7 @@ check_host_cpp(){ check_host_cppflags(){ log check_host_cppflags "$@" check_host_cpp "$@" <; EOF } @@ -1431,6 +1199,12 @@ check_host_cpp_condition(){ EOF } +apply(){ + file=$1 + shift + "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp" +} + cp_if_changed(){ cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return mkdir -p "$(dirname $2)" @@ -1452,11 +1226,9 @@ AVDEVICE_COMPONENTS=" indevs outdevs " - AVFILTER_COMPONENTS=" filters " - AVFORMAT_COMPONENTS=" demuxers muxers @@ -1464,7 +1236,6 @@ AVFORMAT_COMPONENTS=" " AVRESAMPLE_COMPONENTS="" - AVUTIL_COMPONENTS="" COMPONENT_LIST=" @@ -1477,55 +1248,43 @@ COMPONENT_LIST=" " EXAMPLE_LIST=" - avio_dir_cmd_example - avio_reading_example decode_audio_example decode_video_example - demuxing_decoding_example encode_audio_example encode_video_example - extract_mvs_example filter_audio_example - filtering_audio_example - filtering_video_example - http_multiclient_example - hw_decode_example metadata_example - muxing_example + output_example qsvdec_example - remuxing_example - resampling_audio_example - scaling_video_example transcode_aac_example - transcoding_example " -EXTERNAL_AUTODETECT_LIBRARY_LIST=" - alsa - avfoundation - bzlib - coreimage - iconv - jack - libxcb - libxcb_shm - libxcb_shape - libxcb_xfixes - lzma - schannel - sdl2 - securetransport - sndio - xlib - zlib +# catchall list of things that require external libs to link +EXTRALIBS_LIST=" + cpu_init + cws2fws +" + +HWACCEL_LIBRARY_NONFREE_LIST=" + cuda + cuvid + libnpp +" +HWACCEL_LIBRARY_LIST=" + $HWACCEL_LIBRARY_NONFREE_LIST + d3d11va + dxva2 + libmfx + mmal + nvenc + omx + vaapi + vda + vdpau " EXTERNAL_LIBRARY_GPL_LIST=" - avisynth - frei0r libcdio - librubberband - libvidstab libx264 libx265 libxavs @@ -1533,123 +1292,63 @@ EXTERNAL_LIBRARY_GPL_LIST=" " EXTERNAL_LIBRARY_NONFREE_LIST=" - decklink - libndi_newtek + libfaac libfdk_aac openssl " EXTERNAL_LIBRARY_VERSION3_LIST=" - gmp libopencore_amrnb libopencore_amrwb + libvo_aacenc libvo_amrwbenc " -EXTERNAL_LIBRARY_GPLV3_LIST=" - libsmbclient -" - EXTERNAL_LIBRARY_LIST=" - $EXTERNAL_AUTODETECT_LIBRARY_LIST $EXTERNAL_LIBRARY_GPL_LIST $EXTERNAL_LIBRARY_NONFREE_LIST $EXTERNAL_LIBRARY_VERSION3_LIST - $EXTERNAL_LIBRARY_GPLV3_LIST - chromaprint - gcrypt + avisynth + avxsynth + frei0r gnutls - jni - ladspa - libass - libbluray libbs2b - libcaca - libcelt libdc1394 - libflite + libdcadec libfontconfig libfreetype - libfribidi - libgme libgsm - libiec61883 + libhdcd libilbc + libjack libkvazaar - libmodplug libmp3lame - libmysofa libopencv libopenh264 libopenjpeg - libopenmpt libopus libpulse - librsvg librtmp - libshine - libsmbclient + libschroedinger libsnappy - libsoxr libspeex - libssh - libtesseract libtheora libtwolame - libv4l2 - libvmaf libvorbis libvpx libwavpack libwebp - libxml2 - libzimg - libzmq - libzvbi - mediacodec - openal - opencl - opengl + libxcb + libxcb_shm + libxcb_xfixes " -HWACCEL_AUTODETECT_LIBRARY_LIST=" - audiotoolbox - crystalhd - cuda - cuvid - d3d11va - dxva2 - nvenc - vaapi - vda - vdpau - videotoolbox - xvmc -" - -HWACCEL_LIBRARY_NONFREE_LIST=" - cuda_sdk - libnpp -" - -HWACCEL_LIBRARY_LIST=" - $HWACCEL_AUTODETECT_LIBRARY_LIST - $HWACCEL_LIBRARY_NONFREE_LIST - libmfx - mmal - omx -" - -DOCUMENT_LIST=" - doc - htmlpages - manpages - podpages - txtpages +SYSTEM_LIBRARY_LIST=" + bzlib + zlib " FEATURE_LIST=" - ftrapv gray hardcoded_tables omx_rpi @@ -1657,6 +1356,7 @@ FEATURE_LIST=" safe_bitstream_reader shared small + sram static swscale_alpha " @@ -1668,8 +1368,6 @@ LIBRARY_LIST=" avformat avresample avutil - postproc - swresample swscale " @@ -1680,30 +1378,26 @@ LICENSE_LIST=" " PROGRAM_LIST=" - ffplay - ffprobe - ffserver - ffmpeg + avconv + avplay + avprobe " SUBSYSTEM_LIST=" dct - dwt + doc error_resilience faan - fast_unaligned fft lsp lzo mdct - pixelutils network rdft " # COMPONENT_LIST needs to come last to ensure correct dependency checking CONFIG_LIST=" - $DOCUMENT_LIST $EXAMPLE_LIST $EXTERNAL_LIBRARY_LIST $HWACCEL_LIBRARY_LIST @@ -1712,13 +1406,11 @@ CONFIG_LIST=" $LIBRARY_LIST $PROGRAM_LIST $SUBSYSTEM_LIST - autodetect - fontconfig - linux_perf - memory_poisoning + $SYSTEM_LIBRARY_LIST neon_clobber_test - ossfuzz pic + pod2man + texi2html thumb valgrind_backtrace xmm_clobber_test @@ -1727,7 +1419,6 @@ CONFIG_LIST=" THREADS_LIST=" pthreads - os2threads w32threads " @@ -1737,12 +1428,6 @@ ATOMICS_LIST=" atomics_win32 " -AUTODETECT_LIBS=" - $EXTERNAL_AUTODETECT_LIBRARY_LIST - $HWACCEL_AUTODETECT_LIBRARY_LIST - $THREADS_LIST -" - ARCH_LIST=" aarch64 alpha @@ -1778,29 +1463,9 @@ ARCH_EXT_LIST_ARM=" neon vfp vfpv3 - setend -" - -ARCH_EXT_LIST_MIPS=" - mipsfpu - mips32r2 - mips32r5 - mips64r2 - mips32r6 - mips64r6 - mipsdsp - mipsdspr2 - msa -" - -ARCH_EXT_LIST_LOONGSON=" - loongson2 - loongson3 - mmi " ARCH_EXT_LIST_X86_SIMD=" - aesni amd3dnow amd3dnowext avx @@ -1833,12 +1498,22 @@ ARCH_EXT_LIST_X86=" i686 " +ARCH_EXT_LIST_MIPS=" + loongson + mips32r1 + mips64r1 + mips32r2 + mips64r2 + mips32r6 + mips64r6 +" + ARCH_EXT_LIST=" $ARCH_EXT_LIST_ARM + $ARCH_EXT_LIST_MIPS $ARCH_EXT_LIST_PPC $ARCH_EXT_LIST_X86 - $ARCH_EXT_LIST_MIPS - $ARCH_EXT_LIST_LOONGSON + vis " ARCH_FEATURES=" @@ -1859,7 +1534,6 @@ BUILTIN_LIST=" MemoryBarrier mm_empty rdtsc - sarestart sem_timedwait sync_val_compare_and_swap " @@ -1875,12 +1549,11 @@ HAVE_LIST_PUB=" " HEADERS_LIST=" - altivec_h + AVFoundation_AVFoundation_h + alsa_asoundlib_h arpa_inet_h - asm_types_h cdio_paranoia_h cdio_paranoia_paranoia_h - cuda_h d3d11_h dispatch_dispatch_h dev_bktr_ioctl_bt848_h @@ -1889,24 +1562,17 @@ HEADERS_LIST=" dev_video_bktr_ioctl_bt848_h dev_video_meteor_ioctl_meteor_h direct_h - dirent_h dlfcn_h dxgidebug_h dxva_h - ES2_gl_h gsm_h io_h mach_mach_time_h machine_ioctl_bt848_h machine_ioctl_meteor_h malloc_h - opencv2_core_core_c_h - openjpeg_2_2_openjpeg_h - openjpeg_2_1_openjpeg_h - openjpeg_2_0_openjpeg_h - openjpeg_1_5_openjpeg_h - OpenGL_gl3_h poll_h + sndio_h soundcard_h stdatomic_h sys_mman_h @@ -1917,8 +1583,6 @@ HEADERS_LIST=" sys_time_h sys_un_h sys_videoio_h - termios_h - udplite_h unistd_h valgrind_valgrind_h windows_h @@ -1929,24 +1593,14 @@ INTRINSICS_LIST=" intrinsics_neon " -COMPLEX_FUNCS=" - cabs - cexp -" - MATH_FUNCS=" atanf atan2f - cbrt cbrtf - copysign cosf - erf exp2 exp2f expf - hypot - isfinite isinf isnan ldexpf @@ -1967,15 +1621,12 @@ MATH_FUNCS=" " SYSTEM_FUNCS=" - access aligned_malloc - arc4random clock_gettime closesocket CommandLineToArgvW CoTaskMemFree CryptGenRandom - dlopen fcntl flt_lim fork @@ -1988,17 +1639,11 @@ SYSTEM_FUNCS=" getrusage GetSystemTimeAsFileTime gettimeofday - glob - glXGetProcAddress gmtime_r inet_aton isatty - jack_port_get_latency_range - kbhit LoadLibrary localtime_r - lstat - lzo1x_999_compress mach_absolute_time MapViewOfFile memalign @@ -2006,12 +1651,9 @@ SYSTEM_FUNCS=" mmap mprotect nanosleep - PeekNamedPipe posix_memalign - pthread_cancel sched_getaffinity SetConsoleTextAttribute - SetConsoleCtrlHandler setmode setrlimit Sleep @@ -2019,13 +1661,11 @@ SYSTEM_FUNCS=" sysconf sysctl usleep - UTGetOSTypeFromString VirtualAlloc - wglGetProcAddress " TOOLCHAIN_FEATURES=" - as_dn_directive + as_arch_directive as_fpu_directive as_func as_object_arch @@ -2036,13 +1676,9 @@ TOOLCHAIN_FEATURES=" ebp_available ebx_available gnu_as - gnu_windres ibm_asm - inline_asm_direct_symbol_refs inline_asm_labels - inline_asm_nonlocal_labels pragma_deprecated - rsync_contimeout symver_asm_label symver_gnu_asm vfp_args @@ -2052,19 +1688,17 @@ TOOLCHAIN_FEATURES=" TYPES_LIST=" CONDITION_VARIABLE_Ptr + CUVIDDECODECREATEINFO_bitDepthMinus8 socklen_t struct_addrinfo struct_group_source_req struct_ip_mreq_source struct_ipv6_mreq - struct_msghdr_msg_flags struct_pollfd struct_rusage_ru_maxrss - struct_sctp_event_subscribe struct_sockaddr_in6 struct_sockaddr_sa_len struct_sockaddr_storage - struct_stat_st_mtim_tv_nsec struct_v4l2_frmivalenum_discrete " @@ -2073,9 +1707,7 @@ HAVE_LIST=" $(add_suffix _external $ARCH_EXT_LIST) $(add_suffix _inline $ARCH_EXT_LIST) $ARCH_FEATURES - $ATOMICS_LIST $BUILTIN_LIST - $COMPLEX_FUNCS $HAVE_LIST_CMDLINE $HAVE_LIST_PUB $HEADERS_LIST @@ -2085,43 +1717,41 @@ HAVE_LIST=" $THREADS_LIST $TOOLCHAIN_FEATURES $TYPES_LIST - atomics_native dos_paths libc_msvcrt - makeinfo - makeinfo_html MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS - perl - pod2man + sdl section_data_rel_ro - texi2html threads uwp vaapi_drm vaapi_x11 vdpau_x11 - winrt " # options emitted with CONFIG_ prefix but not available on the command line CONFIG_EXTRA=" aandcttables ac3dsp + adts_header audio_frame_queue audiodsp blockdsp bswapdsp cabac + cbs + cbs_h264 + cbs_h265 + cbs_mpeg2 dirac_parse dvprofile - exif faandct faanidct fdctdsp flacdsp fmtconvert - frame_thread_encoder g722dsp + gmp golomb gplv3 h263dsp @@ -2130,23 +1760,21 @@ CONFIG_EXTRA=" h264parse h264pred h264qpel - hevcparse + hevc_ps hpeldsp huffman huffyuvdsp huffyuvencdsp idctdsp iirfilter - mdct15 + imdct15 intrax8 iso_media ividsp jpegtables lgplv3 libx262 - llauddsp - llviddsp - llvidencdsp + libxcb_shape lpc lzf me_cmp @@ -2198,7 +1826,6 @@ CMDLINE_SELECT=" lto optimizations rpath - stripping " PATHS_LIST=" @@ -2208,10 +1835,8 @@ PATHS_LIST=" incdir libdir mandir - pkgconfigdir prefix shlibdir - install_name_dir " CMDLINE_SET=" @@ -2219,19 +1844,14 @@ CMDLINE_SET=" ar arch as - assert_level - build_suffix cc objcc cpu cross_prefix custom_allocator - cxx dep_cc - doxygen env extra_version - gas host_cc host_cflags host_extralibs @@ -2239,37 +1859,27 @@ CMDLINE_SET=" host_ldflags host_os ignore_tests - install ld - ln_s logfile malloc_prefix nm optflags - nvccflags pkg_config pkg_config_flags - progs_suffix random_seed - ranlib samples - strip - sws_max_filter_size sysinclude sysroot target_exec target_os target_path target_samples - tempprefix toolchain - valgrind x86asmexe " CMDLINE_APPEND=" extra_cflags - extra_cxxflags extra_objcflags host_cppflags " @@ -2286,23 +1896,9 @@ neon_deps_any="aarch64 arm" intrinsics_neon_deps="neon" vfp_deps_any="aarch64 arm" vfpv3_deps="vfp" -setend_deps="arm" map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM -loongson2_deps="mips" -loongson3_deps="mips" -mipsfpu_deps="mips" -mipsdsp_deps="mips" -mipsdspr2_deps="mips" -mips32r2_deps="mips" -mips32r5_deps="mips" -mips32r6_deps="mips" -mips64r2_deps="mips" -mips64r6_deps="mips" -msa_deps="mipsfpu" -mmi_deps="mips" - altivec_deps="ppc" dcbzl_deps="ppc" ldbrx_deps="ppc" @@ -2310,6 +1906,16 @@ ppc4xx_deps="ppc" vsx_deps="altivec" power8_deps="vsx" +loongson_deps="mips" +mips32r1_deps="mips32" +mips32r2_deps="mips32" +mips32r6_deps="mips32" +mips64r1_deps="mips64" +mips64r2_deps="mips64" +mips64r6_deps="mips64" + +vis_deps="sparc" + cpunop_deps="i686" x86_64_select="i686" x86_64_suggest="fast_cmov" @@ -2325,7 +1931,6 @@ sse3_deps="sse2" ssse3_deps="sse3" sse4_deps="ssse3" sse42_deps="sse4" -aesni_deps="sse42" avx_deps="sse42" xop_deps="avx" fma3_deps="avx" @@ -2333,7 +1938,7 @@ fma4_deps="avx" avx2_deps="avx" mmx_external_deps="x86asm" -mmx_inline_deps="inline_asm" +mmx_inline_deps="inline_asm x86" mmx_suggest="mmx_external mmx_inline" for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do @@ -2352,7 +1957,8 @@ simd_align_32_if_any="avx" # system capabilities symver_if_any="symver_asm_label symver_gnu_asm" -valgrind_backtrace_deps="!optimizations valgrind_valgrind_h" +valgrind_backtrace_conflict="optimizations" +valgrind_backtrace_deps="valgrind_valgrind_h" # threading support atomics_gcc_if="sync_val_compare_and_swap" @@ -2363,33 +1969,34 @@ w32threads_deps="atomics_native" threads_if_any="$THREADS_LIST" # subsystems +cbs_h264_select="cbs golomb" +cbs_h265_select="cbs golomb" +cbs_mpeg2_select="cbs" dct_select="rdft" dirac_parse_select="golomb" error_resilience_select="me_cmp" -faandct_deps="faan fdctdsp" -faanidct_deps="faan idctdsp" +faandct_deps="faan" +faandct_select="fdctdsp" +faanidct_deps="faan" +faanidct_select="idctdsp" h264dsp_select="startcode" -hevcparse_select="golomb" -frame_thread_encoder_deps="encoders threads" +hevc_ps_select="golomb" intrax8_select="blockdsp idctdsp" mdct_select="fft" -mdct15_select="fft" +rdft_select="fft" me_cmp_select="fdctdsp idctdsp pixblockdsp" mpeg_er_select="error_resilience" mpegaudio_select="mpegaudiodsp mpegaudioheader" mpegaudiodsp_select="dct" -mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp mpeg_er videodsp" +mpegvideo_select="blockdsp hpeldsp idctdsp me_cmp mpeg_er videodsp" mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp" vc1dsp_select="h264chroma qpeldsp startcode" -rdft_select="fft" # decoders / encoders -aac_decoder_select="mdct15 mdct sinewin" -aac_fixed_decoder_select="mdct sinewin" -aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin" +aac_decoder_select="adts_header imdct15 mdct sinewin" +aac_encoder_select="audio_frame_queue iirfilter mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct" -ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct" ac3_encoder_select="ac3dsp audiodsp mdct me_cmp" ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp" adpcm_g722_decoder_select="g722dsp" @@ -2399,11 +2006,8 @@ alac_encoder_select="lpc" als_decoder_select="bswapdsp" amrnb_decoder_select="lsp" amrwb_decoder_select="lsp" -amv_decoder_select="sp5x_decoder exif" -amv_encoder_select="aandcttables jpegtables mpegvideoenc" -ape_decoder_select="bswapdsp llauddsp" -apng_decoder_select="zlib" -apng_encoder_select="llvidencdsp zlib" +amv_decoder_select="sp5x_decoder" +ape_decoder_select="bswapdsp" asv1_decoder_select="blockdsp bswapdsp idctdsp" asv1_encoder_select="bswapdsp fdctdsp pixblockdsp" asv2_decoder_select="blockdsp bswapdsp idctdsp" @@ -2411,7 +2015,6 @@ asv2_encoder_select="bswapdsp fdctdsp pixblockdsp" atrac1_decoder_select="mdct sinewin" atrac3_decoder_select="mdct" atrac3p_decoder_select="mdct sinewin" -avrn_decoder_select="exif jpegtables" bink_decoder_select="blockdsp hpeldsp" binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs" @@ -2422,22 +2025,20 @@ comfortnoise_encoder_select="lpc" cook_decoder_select="audiodsp mdct sinewin" cscd_decoder_select="lzo" cscd_decoder_suggest="zlib" -dca_decoder_select="mdct" +dca_decoder_select="fmtconvert mdct" dds_decoder_select="texturedsp" -dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc" dnxhd_decoder_select="blockdsp idctdsp" dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp" -dolby_e_decoder_select="mdct" dvvideo_decoder_select="dvprofile idctdsp" dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp" -dxa_decoder_select="zlib" +dxa_decoder_deps="zlib" dxv_decoder_select="lzf texturedsp" eac3_decoder_select="ac3_decoder" eac3_encoder_select="ac3_encoder" eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo" -eatgq_decoder_select="aandcttables" +eatgq_decoder_select="aandcttables idctdsp" eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp" -exr_decoder_select="zlib" +exr_decoder_deps="zlib" ffv1_decoder_select="rangecoder" ffv1_encoder_select="rangecoder" ffvhuff_decoder_select="huffyuv_decoder" @@ -2445,31 +2046,29 @@ ffvhuff_encoder_select="huffyuv_encoder" fic_decoder_select="golomb" flac_decoder_select="flacdsp" flac_encoder_select="bswapdsp flacdsp lpc" -flashsv2_decoder_select="zlib" -flashsv2_encoder_select="zlib" -flashsv_decoder_select="zlib" -flashsv_encoder_select="zlib" +flashsv_decoder_deps="zlib" +flashsv_encoder_deps="zlib" +flashsv2_decoder_deps="zlib" flv_decoder_select="h263_decoder" flv_encoder_select="h263_encoder" fourxm_decoder_select="blockdsp bswapdsp" fraps_decoder_select="bswapdsp huffman" -g2m_decoder_select="blockdsp idctdsp jpegtables zlib" -g729_decoder_select="audiodsp" -h261_decoder_select="mpegvideo" +g2m_decoder_deps="zlib" +g2m_decoder_select="blockdsp idctdsp jpegtables" +h261_decoder_select="mpeg_er mpegvideo" h261_encoder_select="aandcttables mpegvideoenc" -h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp" +h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp" h263_encoder_select="aandcttables h263dsp mpegvideoenc" h263i_decoder_select="h263_decoder" -h263p_decoder_select="h263_decoder" h263p_encoder_select="h263_encoder" h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel videodsp" h264_decoder_suggest="error_resilience" hap_decoder_select="snappy texturedsp" hap_encoder_deps="libsnappy" hap_encoder_select="texturedspenc" -hevc_decoder_select="bswapdsp cabac golomb hevcparse videodsp" -huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp" -huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp" +hevc_decoder_select="bswapdsp cabac hevc_ps videodsp" +huffyuv_decoder_select="bswapdsp huffyuvdsp" +huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp" iac_decoder_select="imc_decoder" imc_decoder_select="bswapdsp fft mdct sinewin" indeo3_decoder_select="hpeldsp" @@ -2478,17 +2077,16 @@ indeo5_decoder_select="ividsp" interplay_video_decoder_select="hpeldsp" jpegls_decoder_select="mjpeg_decoder" jv_decoder_select="blockdsp" -lagarith_decoder_select="llviddsp" -ljpeg_encoder_select="aandcttables idctdsp jpegtables mpegvideoenc" -magicyuv_decoder_select="llviddsp" +lagarith_decoder_select="huffyuvdsp" +ljpeg_encoder_select="aandcttables idctdsp jpegtables" +magicyuv_decoder_select="huffyuvdsp" mdec_decoder_select="blockdsp idctdsp mpegvideo" metasound_decoder_select="lsp mdct sinewin" mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp" -mjpeg_decoder_select="blockdsp hpeldsp exif idctdsp jpegtables" +mjpeg_decoder_select="blockdsp hpeldsp idctdsp jpegtables" mjpeg_encoder_select="aandcttables jpegtables mpegvideoenc" mjpegb_decoder_select="mjpeg_decoder" mlp_decoder_select="mlp_parser" -mlp_encoder_select="lpc" motionpixels_decoder_select="bswapdsp" mp1_decoder_select="mpegaudio" mp1float_decoder_select="mpegaudio" @@ -2502,83 +2100,67 @@ mp3on4_decoder_select="mpegaudio" mp3on4float_decoder_select="mpegaudio" mpc7_decoder_select="bswapdsp mpegaudiodsp" mpc8_decoder_select="mpegaudiodsp" -mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h" -mpeg_xvmc_decoder_select="mpeg2video_decoder" -mpegvideo_decoder_select="mpegvideo" -mpeg1video_decoder_select="mpegvideo" -mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp" -mpeg2video_decoder_select="mpegvideo" -mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp" +mpeg1video_decoder_select="error_resilience mpeg_er mpegvideo" +mpeg1video_encoder_select="aandcttables mpegvideoenc" +mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo" +mpeg2video_encoder_select="aandcttables mpegvideoenc" mpeg4_decoder_select="h263_decoder mpeg4video_parser" mpeg4_encoder_select="h263_encoder" msa1_decoder_select="mss34dsp" -mscc_decoder_select="zlib" msmpeg4v1_decoder_select="h263_decoder" msmpeg4v2_decoder_select="h263_decoder" msmpeg4v2_encoder_select="h263_encoder" msmpeg4v3_decoder_select="h263_decoder" msmpeg4v3_encoder_select="h263_encoder" -mss2_decoder_select="mpegvideo qpeldsp vc1_decoder" +mss2_decoder_select="error_resilience mpeg_er mpegvideo qpeldsp vc1_decoder" mts2_decoder_select="mss34dsp" mxpeg_decoder_select="mjpeg_decoder" nellymoser_decoder_select="mdct sinewin" nellymoser_encoder_select="audio_frame_queue mdct sinewin" nuv_decoder_select="idctdsp lzo" on2avc_decoder_select="mdct" -opus_decoder_deps="swresample" -opus_decoder_select="mdct15" -opus_encoder_select="audio_frame_queue mdct15" -png_decoder_select="zlib" -png_encoder_select="llvidencdsp zlib" -prores_decoder_select="blockdsp idctdsp" +opus_decoder_deps="avresample" +opus_decoder_select="imdct15" +png_decoder_deps="zlib" +png_encoder_deps="zlib" +png_encoder_select="huffyuvencdsp" +prores_decoder_select="idctdsp" prores_encoder_select="fdctdsp" qcelp_decoder_select="lsp" qdm2_decoder_select="mdct rdft mpegaudiodsp" -ra_144_decoder_select="audiodsp" -ra_144_encoder_select="audio_frame_queue lpc audiodsp" +ra_144_encoder_select="audio_frame_queue lpc" ralf_decoder_select="golomb" -rawvideo_decoder_select="bswapdsp" -rscc_decoder_select="zlib" -rtjpeg_decoder_select="me_cmp" -rv10_decoder_select="h263_decoder" +rscc_decoder_deps="zlib" +rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" rv10_encoder_select="h263_encoder" -rv20_decoder_select="h263_decoder" +rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" rv20_encoder_select="h263_encoder" -rv30_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp" -rv40_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp" -screenpresso_decoder_select="zlib" -shorten_decoder_select="bswapdsp" +rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp" +rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp" +screenpresso_decoder_deps="zlib" sipr_decoder_select="lsp" -snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp" -snow_encoder_select="aandcttables dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder" -sonic_decoder_select="golomb rangecoder" -sonic_encoder_select="golomb rangecoder" -sonic_ls_encoder_select="golomb rangecoder" sp5x_decoder_select="mjpeg_decoder" -srgc_decoder_select="zlib" svq1_decoder_select="hpeldsp" svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc" svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp videodsp" svq3_decoder_suggest="zlib" tak_decoder_select="audiodsp" -tdsc_decoder_select="zlib mjpeg_decoder" +tdsc_decoder_deps="zlib" +tdsc_decoder_select="mjpeg_decoder" theora_decoder_select="vp3_decoder" thp_decoder_select="mjpeg_decoder" -tiff_decoder_suggest="zlib lzma" +tiff_decoder_suggest="zlib" tiff_encoder_suggest="zlib" -truehd_decoder_select="mlp_parser" -truehd_encoder_select="lpc" +truehd_decoder_select="mlp_decoder" truemotion2_decoder_select="bswapdsp" truespeech_decoder_select="bswapdsp" -tscc_decoder_select="zlib" -twinvq_decoder_select="mdct lsp sinewin" +tscc_decoder_deps="zlib" txd_decoder_select="texturedsp" -utvideo_decoder_select="bswapdsp llviddsp" -utvideo_encoder_select="bswapdsp huffman llvidencdsp" -vble_decoder_select="llviddsp" -vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideo vc1dsp" -vc1_qsv_decoder_deps="libmfx" -vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel vc1_parser" +twinvq_decoder_select="mdct lsp sinewin" +utvideo_decoder_select="bswapdsp huffyuvdsp" +utvideo_encoder_select="bswapdsp huffman huffyuvencdsp" +vble_decoder_select="huffyuvdsp" +vc1_decoder_select="blockdsp error_resilience h263_decoder h264qpel intrax8 mpeg_er mpegvideo vc1dsp" vc1image_decoder_select="vc1_decoder" vorbis_decoder_select="mdct" vorbis_encoder_select="mdct" @@ -2589,9 +2171,8 @@ vp6a_decoder_select="vp6_decoder" vp6f_decoder_select="vp6_decoder" vp7_decoder_select="h264pred videodsp vp8dsp" vp8_decoder_select="h264pred videodsp vp8dsp" -vp9_decoder_select="videodsp vp9_parser" -webp_decoder_select="vp8_decoder exif" -wmalossless_decoder_select="llauddsp" +vp9_decoder_select="videodsp vp9_superframe_split_bsf" +webp_decoder_select="vp8_decoder" wmapro_decoder_select="mdct sinewin wma_freqs" wmav1_decoder_select="mdct sinewin wma_freqs" wmav1_encoder_select="mdct sinewin wma_freqs" @@ -2604,42 +2185,28 @@ wmv2_decoder_select="blockdsp error_resilience h263_decoder idctdsp intrax8 vide wmv2_encoder_select="h263_encoder wmv2dsp" wmv3_decoder_select="vc1_decoder" wmv3image_decoder_select="wmv3_decoder" -xma1_decoder_select="wmapro_decoder" -xma2_decoder_select="wmapro_decoder" -zerocodec_decoder_select="zlib" -zlib_decoder_select="zlib" -zlib_encoder_select="zlib" -zmbv_decoder_select="zlib" -zmbv_encoder_select="zlib" +zerocodec_decoder_deps="zlib" +zlib_decoder_deps="zlib" +zlib_encoder_deps="zlib" +zmbv_decoder_deps="zlib" +zmbv_encoder_deps="zlib" # hardware accelerators -crystalhd_deps="libcrystalhd_libcrystalhd_if_h" -cuda_deps_any="dlopen LoadLibrary" -cuvid_deps="cuda" -d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder ID3D11VideoContext" +d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32" -dxva2_extralibs="-luser32" -vda_framework_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension" -vda_framework_extralibs="-framework VideoDecodeAcceleration" -vda_deps="vda_framework pthreads" -vda_extralibs="-framework CoreFoundation -framework QuartzCore" -videotoolbox_hwaccel_deps="videotoolbox pthreads" -videotoolbox_hwaccel_extralibs="-framework QuartzCore" -xvmc_deps="X11_extensions_XvMClib_h" +vda_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension pthreads" +vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" h263_vaapi_hwaccel_deps="vaapi" h263_vaapi_hwaccel_select="h263_decoder" -h263_videotoolbox_hwaccel_deps="videotoolbox" -h263_videotoolbox_hwaccel_select="h263_decoder" -h264_cuvid_hwaccel_deps="cuda cuvid" -h264_cuvid_hwaccel_select="h264_cuvid_decoder" +h264_cuvid_hwaccel_deps="cuvid CUVIDH264PICPARAMS" +h264_cuvid_hwaccel_select="h264_decoder" h264_d3d11va_hwaccel_deps="d3d11va" h264_d3d11va_hwaccel_select="h264_decoder" h264_d3d11va2_hwaccel_deps="d3d11va" h264_d3d11va2_hwaccel_select="h264_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" -h264_mediacodec_hwaccel_deps="mediacodec" h264_mmal_hwaccel_deps="mmal" h264_qsv_hwaccel_deps="libmfx" h264_vaapi_hwaccel_deps="vaapi" @@ -2650,13 +2217,10 @@ h264_vda_old_hwaccel_deps="vda" h264_vda_old_hwaccel_select="h264_decoder" h264_vdpau_hwaccel_deps="vdpau" h264_vdpau_hwaccel_select="h264_decoder" -h264_videotoolbox_hwaccel_deps="videotoolbox" -h264_videotoolbox_hwaccel_select="h264_decoder" -hevc_cuvid_hwaccel_deps="cuda cuvid" -hevc_cuvid_hwaccel_select="hevc_cuvid_decoder" +hevc_cuvid_hwaccel_deps="cuvid CUVIDHEVCPICPARAMS" +hevc_cuvid_hwaccel_select="hevc_decoder" hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" -hevc_mediacodec_hwaccel_deps="mediacodec" hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va2_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" @@ -2666,50 +2230,24 @@ hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" hevc_vaapi_hwaccel_select="hevc_decoder" hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" hevc_vdpau_hwaccel_select="hevc_decoder" -mjpeg_cuvid_hwaccel_deps="cuda cuvid" -mjpeg_cuvid_hwaccel_select="mjpeg_cuvid_decoder" -mpeg_xvmc_hwaccel_deps="xvmc" -mpeg_xvmc_hwaccel_select="mpeg2video_decoder" -mpeg1_cuvid_hwaccel_deps="cuda cuvid" -mpeg1_cuvid_hwaccel_select="mpeg1_cuvid_decoder" mpeg1_vdpau_hwaccel_deps="vdpau" mpeg1_vdpau_hwaccel_select="mpeg1video_decoder" -mpeg1_videotoolbox_hwaccel_deps="videotoolbox" -mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder" -mpeg1_xvmc_hwaccel_deps="xvmc" -mpeg1_xvmc_hwaccel_select="mpeg1video_decoder" -mpeg2_cuvid_hwaccel_deps="cuda cuvid" -mpeg2_cuvid_hwaccel_select="mpeg2_cuvid_decoder" mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_d3d11va2_hwaccel_deps="d3d11va" mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" -mpeg2_mediacodec_hwaccel_deps="mediacodec" mpeg2_mmal_hwaccel_deps="mmal" mpeg2_qsv_hwaccel_deps="libmfx" -mpeg2_qsv_hwaccel_select="qsvdec_mpeg2" mpeg2_vaapi_hwaccel_deps="vaapi" mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" mpeg2_vdpau_hwaccel_deps="vdpau" mpeg2_vdpau_hwaccel_select="mpeg2video_decoder" -mpeg2_videotoolbox_hwaccel_deps="videotoolbox" -mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder" -mpeg2_xvmc_hwaccel_deps="xvmc" -mpeg2_xvmc_hwaccel_select="mpeg2video_decoder" -mpeg4_cuvid_hwaccel_deps="cuda cuvid" -mpeg4_cuvid_hwaccel_select="mpeg4_cuvid_decoder" -mpeg4_mediacodec_hwaccel_deps="mediacodec" -mpeg4_mmal_hwaccel_deps="mmal" mpeg4_vaapi_hwaccel_deps="vaapi" mpeg4_vaapi_hwaccel_select="mpeg4_decoder" mpeg4_vdpau_hwaccel_deps="vdpau" mpeg4_vdpau_hwaccel_select="mpeg4_decoder" -mpeg4_videotoolbox_hwaccel_deps="videotoolbox" -mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" -vc1_cuvid_hwaccel_deps="cuda cuvid" -vc1_cuvid_hwaccel_select="vc1_cuvid_decoder" vc1_d3d11va_hwaccel_deps="d3d11va" vc1_d3d11va_hwaccel_select="vc1_decoder" vc1_d3d11va2_hwaccel_deps="d3d11va" @@ -2718,26 +2256,13 @@ vc1_dxva2_hwaccel_deps="dxva2" vc1_dxva2_hwaccel_select="vc1_decoder" vc1_mmal_hwaccel_deps="mmal" vc1_qsv_hwaccel_deps="libmfx" -vc1_qsv_hwaccel_select="qsvdec_vc1" vc1_vaapi_hwaccel_deps="vaapi" vc1_vaapi_hwaccel_select="vc1_decoder" vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" -vp8_cuvid_hwaccel_deps="cuda cuvid" -vp8_cuvid_hwaccel_select="vp8_cuvid_decoder" -vp9_cuvid_hwaccel_deps="cuda cuvid" -vp9_cuvid_hwaccel_select="vp9_cuvid_decoder" -vp8_mediacodec_hwaccel_deps="mediacodec" vp8_qsv_hwaccel_deps="libmfx" -vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" -vp9_d3d11va_hwaccel_select="vp9_decoder" -vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9" -vp9_d3d11va2_hwaccel_select="vp9_decoder" -vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" -vp9_dxva2_hwaccel_select="vp9_decoder" -vp9_mediacodec_hwaccel_deps="mediacodec" -vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" -vp9_vaapi_hwaccel_select="vp9_decoder" +vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8" +vp8_vaapi_hwaccel_select="vp8_decoder" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel" wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" @@ -2745,148 +2270,79 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # hardware-accelerated codecs -omx_deps="dlopen pthreads" -omx_extralibs='$ldl' +nvenc_deps_any="libdl LoadLibrary" +omx_deps="libdl pthreads" omx_rpi_select="omx" +qsv_deps="libmfx" qsvdec_select="qsv" qsvenc_select="qsv" vaapi_encode_deps="vaapi" hwupload_cuda_filter_deps="cuda" scale_npp_filter_deps="cuda libnpp" -scale_cuda_filter_deps="cuda_sdk" -nvenc_deps="cuda" -nvenc_deps_any="dlopen LoadLibrary" -nvenc_encoder_deps="nvenc" - -h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser" -h264_cuvid_decoder_deps="cuda cuvid" -h264_cuvid_decoder_select="h264_mp4toannexb_bsf" -h264_mediacodec_decoder_deps="mediacodec" -h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser" h264_mmal_decoder_deps="mmal" h264_nvenc_encoder_deps="nvenc" h264_omx_encoder_deps="omx" -h264_qsv_decoder_deps="libmfx" h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel" -h264_qsv_encoder_deps="libmfx" h264_qsv_encoder_select="qsvenc" h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264" -h264_vaapi_encoder_select="vaapi_encode golomb" -h264_vda_decoder_deps="vda" -h264_vda_decoder_select="h264_decoder" -h264_vdpau_decoder_deps="vdpau" -h264_vdpau_decoder_select="h264_decoder" -hevc_cuvid_decoder_deps="cuda cuvid" -hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf" -hevc_mediacodec_decoder_deps="mediacodec" -hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser" +h264_vaapi_encoder_select="cbs_h264 vaapi_encode" hevc_nvenc_encoder_deps="nvenc" -hevc_qsv_decoder_deps="libmfx" -hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec hevc_qsv_hwaccel" -hevc_qsv_encoder_deps="libmfx" -hevc_qsv_encoder_select="hevcparse qsvenc" +hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser hevc_qsv_hwaccel qsvdec" +hevc_qsv_encoder_select="hevc_ps qsvenc" hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC" -hevc_vaapi_encoder_select="vaapi_encode golomb" -mjpeg_cuvid_decoder_deps="cuda cuvid" +hevc_vaapi_encoder_select="cbs_h265 vaapi_encode" +mjpeg_qsv_encoder_deps="libmfx" +mjpeg_qsv_encoder_select="qsvenc" mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG" mjpeg_vaapi_encoder_select="vaapi_encode jpegtables" -mpeg1_cuvid_decoder_deps="cuda cuvid" -mpeg1_vdpau_decoder_deps="vdpau" -mpeg1_vdpau_decoder_select="mpeg1video_decoder" -mpeg2_crystalhd_decoder_select="crystalhd" -mpeg2_cuvid_decoder_deps="cuda cuvid" mpeg2_mmal_decoder_deps="mmal" -mpeg2_mediacodec_decoder_deps="mediacodec" -mpeg2_qsv_decoder_deps="libmfx" -mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel" -mpeg2_qsv_encoder_deps="libmfx" +mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel mpegvideo_parser" mpeg2_qsv_encoder_select="qsvenc" mpeg2_vaapi_encoder_deps="VAEncPictureParameterBufferMPEG2" mpeg2_vaapi_encoder_select="vaapi_encode" -mpeg4_crystalhd_decoder_select="crystalhd" -mpeg4_cuvid_decoder_deps="cuda cuvid" -mpeg4_mediacodec_decoder_deps="mediacodec" -mpeg4_mmal_decoder_deps="mmal" mpeg4_omx_encoder_deps="omx" -mpeg4_vdpau_decoder_deps="vdpau" -mpeg4_vdpau_decoder_select="mpeg4_decoder" -mpeg_vdpau_decoder_deps="vdpau" -mpeg_vdpau_decoder_select="mpeg2video_decoder" -msmpeg4_crystalhd_decoder_select="crystalhd" -nvenc_h264_encoder_select="h264_nvenc_encoder" -nvenc_hevc_encoder_select="hevc_nvenc_encoder" -vc1_crystalhd_decoder_select="crystalhd" -vc1_cuvid_decoder_deps="cuda cuvid" vc1_mmal_decoder_deps="mmal" -vc1_vdpau_decoder_deps="vdpau" -vc1_vdpau_decoder_select="vc1_decoder" -vp8_cuvid_decoder_deps="cuda cuvid" -vp8_mediacodec_decoder_deps="mediacodec" -vp8_qsv_decoder_deps="libmfx" +vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel vc1_parser" vp8_qsv_decoder_select="qsvdec vp8_qsv_hwaccel vp8_parser" vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8" vp8_vaapi_encoder_select="vaapi_encode" -vp9_cuvid_decoder_deps="cuda cuvid" -vp9_mediacodec_decoder_deps="mediacodec" vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9" vp9_vaapi_encoder_select="vaapi_encode" -wmv3_crystalhd_decoder_select="crystalhd" -wmv3_vdpau_decoder_select="vc1_vdpau_decoder" + +nvenc_h264_encoder_select="h264_nvenc_encoder" +nvenc_hevc_encoder_select="hevc_nvenc_encoder" # parsers +aac_parser_select="adts_header" h264_parser_select="golomb h264dsp h264parse" -hevc_parser_select="hevcparse" +hevc_parser_select="hevc_ps" mpegaudio_parser_select="mpegaudioheader" mpegvideo_parser_select="mpegvideo" -mpeg4video_parser_select="h263dsp mpegvideo qpeldsp" +mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp" vc1_parser_select="vc1dsp" # bitstream_filters +aac_adtstoasc_bsf_select="adts_header" +h264_metadata_bsf_select="cbs_h264" +h264_redundant_pps_bsf_select="cbs_h264" +hevc_metadata_bsf_select="cbs_h265" mjpeg2jpeg_bsf_select="jpegtables" +mpeg2_metadata_bsf_select="cbs_mpeg2" +trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2" # external libraries -aac_at_decoder_deps="audiotoolbox" -ac3_at_decoder_deps="audiotoolbox" -ac3_at_decoder_select="ac3_parser" -adpcm_ima_qt_at_decoder_deps="audiotoolbox" -alac_at_decoder_deps="audiotoolbox" -amr_nb_at_decoder_deps="audiotoolbox" -avisynth_deps_any="dlopen LoadLibrary" -avisynth_demuxer_deps="avisynth" +avisynth_deps="LoadLibrary" +avxsynth_deps="libdl" +avisynth_demuxer_deps_any="avisynth avxsynth" avisynth_demuxer_select="riffdec" -eac3_at_decoder_deps="audiotoolbox" -eac3_at_decoder_select="ac3_parser" -gsm_ms_at_decoder_deps="audiotoolbox" -ilbc_at_decoder_deps="audiotoolbox" -mp1_at_decoder_deps="audiotoolbox" -mp2_at_decoder_deps="audiotoolbox" -mp3_at_decoder_deps="audiotoolbox" -mp1_at_decoder_select="mpegaudioheader" -mp2_at_decoder_select="mpegaudioheader" -mp3_at_decoder_select="mpegaudioheader" -pcm_alaw_at_decoder_deps="audiotoolbox" -pcm_mulaw_at_decoder_deps="audiotoolbox" -qdmc_at_decoder_deps="audiotoolbox" -qdm2_at_decoder_deps="audiotoolbox" -aac_at_encoder_deps="audiotoolbox" -aac_at_encoder_select="audio_frame_queue" -alac_at_encoder_deps="audiotoolbox" -alac_at_encoder_select="audio_frame_queue" -ilbc_at_encoder_deps="audiotoolbox" -ilbc_at_encoder_select="audio_frame_queue" -pcm_alaw_at_encoder_deps="audiotoolbox" -pcm_alaw_at_encoder_select="audio_frame_queue" -pcm_mulaw_at_encoder_deps="audiotoolbox" -pcm_mulaw_at_encoder_select="audio_frame_queue" -chromaprint_muxer_deps="chromaprint" -h264_videotoolbox_encoder_deps="videotoolbox_encoder pthreads" -libcelt_decoder_deps="libcelt" +libdcadec_decoder_deps="libdcadec" +libfaac_encoder_deps="libfaac" +libfaac_encoder_select="audio_frame_queue" libfdk_aac_decoder_deps="libfdk_aac" libfdk_aac_encoder_deps="libfdk_aac" libfdk_aac_encoder_select="audio_frame_queue" -libgme_demuxer_deps="libgme" libgsm_decoder_deps="libgsm" libgsm_encoder_deps="libgsm" libgsm_ms_decoder_deps="libgsm" @@ -2894,7 +2350,6 @@ libgsm_ms_encoder_deps="libgsm" libilbc_decoder_deps="libilbc" libilbc_encoder_deps="libilbc" libkvazaar_encoder_deps="libkvazaar" -libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" libmp3lame_encoder_select="audio_frame_queue mpegaudioheader" libopencore_amrnb_decoder_deps="libopencore_amrnb" @@ -2906,20 +2361,19 @@ libopenh264_decoder_select="h264_mp4toannexb_bsf" libopenh264_encoder_deps="libopenh264" libopenjpeg_decoder_deps="libopenjpeg" libopenjpeg_encoder_deps="libopenjpeg" -libopenmpt_demuxer_deps="libopenmpt" libopus_decoder_deps="libopus" libopus_encoder_deps="libopus" libopus_encoder_select="audio_frame_queue" -librsvg_decoder_deps="librsvg" -libshine_encoder_deps="libshine" -libshine_encoder_select="audio_frame_queue" +libschroedinger_decoder_deps="libschroedinger" +libschroedinger_encoder_deps="libschroedinger" libspeex_decoder_deps="libspeex" libspeex_encoder_deps="libspeex" libspeex_encoder_select="audio_frame_queue" libtheora_encoder_deps="libtheora" libtwolame_encoder_deps="libtwolame" +libvo_aacenc_encoder_deps="libvo_aacenc" +libvo_aacenc_encoder_select="audio_frame_queue" libvo_amrwbenc_encoder_deps="libvo_amrwbenc" -libvorbis_decoder_deps="libvorbis" libvorbis_encoder_deps="libvorbis" libvorbis_encoder_select="audio_frame_queue" libvpx_vp8_decoder_deps="libvpx" @@ -2929,46 +2383,30 @@ libvpx_vp9_encoder_deps="libvpx" libwavpack_encoder_deps="libwavpack" libwavpack_encoder_select="audio_frame_queue" libwebp_encoder_deps="libwebp" -libwebp_anim_encoder_deps="libwebp" libx262_encoder_deps="libx262" libx264_encoder_deps="libx264" -libx264rgb_encoder_deps="libx264 x264_csp_bgr" -libx264rgb_encoder_select="libx264_encoder" libx265_encoder_deps="libx265" libxavs_encoder_deps="libxavs" -libxvid_encoder_deps="libxvid" -libzvbi_teletext_decoder_deps="libzvbi" -videotoolbox_extralibs="-framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework CoreVideo" -videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames" -videotoolbox_encoder_suggest="vda_framework" +libxvid_encoder_deps="libxvid mkstemp" # demuxers / muxers ac3_demuxer_select="ac3_parser" -aiff_muxer_select="iso_media" asf_demuxer_select="riffdec" -asf_o_demuxer_select="riffdec" asf_muxer_select="riffenc" asf_stream_muxer_select="asf_muxer" -avi_demuxer_select="iso_media riffdec exif" +avi_demuxer_select="iso_media riffdec" avi_muxer_select="riffenc" caf_demuxer_select="iso_media riffdec" -caf_muxer_select="iso_media" dash_muxer_select="mp4_muxer" -dash_demuxer_deps="libxml2" dirac_demuxer_select="dirac_parser" -dts_demuxer_select="dca_parser" -dtshd_demuxer_select="dca_parser" dv_demuxer_select="dvprofile" dv_muxer_select="dvprofile" dxa_demuxer_select="riffdec" eac3_demuxer_select="ac3_parser" f4v_muxer_select="mov_muxer" -fifo_muxer_deps="threads" flac_demuxer_select="flac_parser" hds_muxer_select="flv_muxer" hls_muxer_select="mpegts_muxer" -image2_alias_pix_demuxer_select="image2_demuxer" -image2_brender_pix_demuxer_select="image2_demuxer" ipod_muxer_select="mov_muxer" ismv_muxer_select="mov_muxer" matroska_audio_muxer_select="matroska_muxer" @@ -2986,16 +2424,13 @@ mpegts_demuxer_select="iso_media" mpegts_muxer_select="adts_muxer latm_muxer" mpegtsraw_demuxer_select="mpegts_demuxer" mxf_d10_muxer_select="mxf_muxer" -mxf_opatom_muxer_select="mxf_muxer" nut_muxer_select="riffenc" nuv_demuxer_select="riffdec" oga_muxer_select="ogg_muxer" ogg_demuxer_select="dirac_parse" -ogv_muxer_select="ogg_muxer" opus_muxer_select="ogg_muxer" psp_muxer_select="mov_muxer" rtp_demuxer_select="sdp_demuxer" -rtp_muxer_select="golomb" rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp" rtsp_demuxer_select="http_protocol rtpdec" rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain" @@ -3003,245 +2438,127 @@ sap_demuxer_select="sdp_demuxer" sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain" sdp_demuxer_select="rtpdec" smoothstreaming_muxer_select="ismv_muxer" -spdif_muxer_select="aac_parser" +spdif_demuxer_select="adts_header" +spdif_muxer_select="adts_header" spx_muxer_select="ogg_muxer" swf_demuxer_suggest="zlib" tak_demuxer_select="tak_parser" tg2_muxer_select="mov_muxer" tgp_muxer_select="mov_muxer" -vobsub_demuxer_select="mpegps_demuxer" w64_demuxer_select="wav_demuxer" -w64_muxer_select="wav_muxer" wav_demuxer_select="riffdec" wav_muxer_select="riffenc" webm_muxer_select="iso_media riffenc" -webm_dash_manifest_demuxer_select="matroska_demuxer" wtv_demuxer_select="mpegts_demuxer riffdec" -wtv_muxer_select="mpegts_muxer riffenc" xmv_demuxer_select="riffdec" xwma_demuxer_select="riffdec" # indevs / outdevs alsa_indev_deps="alsa" alsa_outdev_deps="alsa" -avfoundation_indev_deps="avfoundation pthreads" -avfoundation_indev_extralibs="-framework Foundation -framework CoreVideo -framework CoreMedia" +avfoundation_indev_deps="AVFoundation_AVFoundation_h objc_arc pthreads" +avfoundation_indev_extralibs="-framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia" bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h" -caca_outdev_deps="libcaca" -decklink_indev_deps="decklink threads" -decklink_indev_extralibs="-lstdc++" -decklink_outdev_deps="decklink threads" -decklink_outdev_extralibs="-lstdc++" -libndi_newtek_indev_deps="libndi_newtek" -libndi_newtek_indev_extralibs="-lndi" -libndi_newtek_outdev_deps="libndi_newtek" -libndi_newtek_outdev_extralibs="-lndi" -dshow_indev_deps="IBaseFilter" -dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi" dv1394_indev_deps="dv1394" dv1394_indev_select="dv_demuxer" fbdev_indev_deps="linux_fb_h" -fbdev_outdev_deps="linux_fb_h" -gdigrab_indev_deps="CreateDIBSection" -gdigrab_indev_extralibs="-lgdi32" -gdigrab_indev_select="bmp_decoder" -iec61883_indev_deps="libiec61883" -jack_indev_deps="jack" +jack_indev_deps="libjack" jack_indev_deps_any="sem_timedwait dispatch_dispatch_h" -lavfi_indev_deps="avfilter" libcdio_indev_deps="libcdio" libdc1394_indev_deps="libdc1394" -libv4l2_indev_deps="libv4l2" -openal_indev_deps="openal" -opengl_outdev_deps="opengl" oss_indev_deps_any="soundcard_h sys_soundcard_h" oss_outdev_deps_any="soundcard_h sys_soundcard_h" pulse_indev_deps="libpulse" -pulse_outdev_deps="libpulse" -sdl2_outdev_deps="sdl2" sndio_indev_deps="sndio" sndio_outdev_deps="sndio" v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" -v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h" vfwcap_indev_deps="vfw32 vfwcap_defines" -xcbgrab_indev_deps="libxcb" -xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute" -xv_outdev_extralibs="-lXv -lX11 -lXext" +xcbgrab_indev_deps="libxcb libxcb_shape" +xcbgrab_indev_suggest="libxcb_shm libxcb_xfixes" # protocols -async_protocol_deps="threads" -bluray_protocol_deps="libbluray" -ffrtmpcrypt_protocol_deps="!librtmp_protocol" -ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl" +ffrtmpcrypt_protocol_conflict="librtmp_protocol" +ffrtmpcrypt_protocol_deps_any="gmp openssl" ffrtmpcrypt_protocol_select="tcp_protocol" -ffrtmphttp_protocol_deps="!librtmp_protocol" +ffrtmphttp_protocol_conflict="librtmp_protocol" ffrtmphttp_protocol_select="http_protocol" -ftp_protocol_select="tcp_protocol" gopher_protocol_select="network" http_protocol_select="tcp_protocol" +http_protocol_suggest="zlib" httpproxy_protocol_select="tcp_protocol" +httpproxy_protocol_suggest="zlib" https_protocol_select="tls_protocol" +https_protocol_suggest="zlib" icecast_protocol_select="http_protocol" librtmp_protocol_deps="librtmp" librtmpe_protocol_deps="librtmp" librtmps_protocol_deps="librtmp" librtmpt_protocol_deps="librtmp" librtmpte_protocol_deps="librtmp" -libsmbclient_protocol_deps="libsmbclient gplv3" -libssh_protocol_deps="libssh" mmsh_protocol_select="http_protocol" mmst_protocol_select="network" -rtmp_protocol_deps="!librtmp_protocol" +rtmp_protocol_conflict="librtmp_protocol" rtmp_protocol_select="tcp_protocol" +rtmp_protocol_suggest="zlib" rtmpe_protocol_select="ffrtmpcrypt_protocol" -rtmps_protocol_deps="!librtmp_protocol" +rtmpe_protocol_suggest="zlib" +rtmps_protocol_conflict="librtmp_protocol" rtmps_protocol_select="tls_protocol" +rtmps_protocol_suggest="zlib" rtmpt_protocol_select="ffrtmphttp_protocol" +rtmpt_protocol_suggest="zlib" rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol" +rtmpte_protocol_suggest="zlib" rtmpts_protocol_select="ffrtmphttp_protocol https_protocol" +rtmpts_protocol_suggest="zlib" rtp_protocol_select="udp_protocol" -sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags" +sctp_protocol_deps="struct_sctp_event_subscribe" sctp_protocol_select="network" srtp_protocol_select="rtp_protocol srtp" tcp_protocol_select="network" -tls_gnutls_protocol_deps="gnutls !tls_schannel_protocol !tls_securetransport_protocol" -tls_gnutls_protocol_select="tcp_protocol" -tls_openssl_protocol_deps="openssl !tls_schannel_protocol !tls_securetransport_protocol !tls_gnutls_protocol" -tls_openssl_protocol_select="tcp_protocol" -tls_schannel_protocol_deps="schannel" -tls_schannel_protocol_select="tcp_protocol" -tls_securetransport_protocol_deps="securetransport" -tls_securetransport_protocol_select="tcp_protocol" -tls_protocol_deps_any="tls_schannel_protocol tls_securetransport_protocol tls_gnutls_protocol tls_openssl_protocol" +tls_protocol_deps_any="gnutls openssl" +tls_protocol_select="tcp_protocol" udp_protocol_select="network" -udplite_protocol_select="network" unix_protocol_deps="sys_un_h" unix_protocol_select="network" # filters -afftfilt_filter_deps="avcodec" -afftfilt_filter_select="fft" -afir_filter_deps="avcodec" -afir_filter_select="fft" -amovie_filter_deps="avcodec avformat" -aresample_filter_deps="swresample" -ass_filter_deps="libass" -atempo_filter_deps="avcodec" -atempo_filter_select="rdft" -azmq_filter_deps="libzmq" +asyncts_filter_deps="avresample" blackframe_filter_deps="gpl" boxblur_filter_deps="gpl" bs2b_filter_deps="libbs2b" -colormatrix_filter_deps="gpl" -coreimage_filter_deps="coreimage" -coreimage_filter_extralibs="-framework OpenGL -framework AppKit" -coreimagesrc_filter_deps="coreimage" -coreimagesrc_filter_extralibs="-framework OpenGL -framework AppKit" -cover_rect_filter_deps="avcodec avformat gpl" cropdetect_filter_deps="gpl" deinterlace_qsv_filter_deps="libmfx" deinterlace_vaapi_filter_deps="vaapi" delogo_filter_deps="gpl" -deshake_filter_select="pixelutils" drawtext_filter_deps="libfreetype" -elbg_filter_deps="avcodec" -eq_filter_deps="gpl" -fftfilt_filter_deps="avcodec" -fftfilt_filter_select="rdft" -find_rect_filter_deps="avcodec avformat gpl" -firequalizer_filter_deps="avcodec" -firequalizer_filter_select="rdft" -flite_filter_deps="libflite" -framerate_filter_select="pixelutils" -frei0r_filter_deps="frei0r dlopen" -frei0r_src_filter_deps="frei0r dlopen" -fspp_filter_deps="gpl" -geq_filter_deps="gpl" -histeq_filter_deps="gpl" +drawtext_filter_suggest="libfontconfig" +frei0r_filter_deps="frei0r libdl" +frei0r_src_filter_deps="frei0r libdl" +hdcd_filter_deps="libhdcd" hqdn3d_filter_deps="gpl" interlace_filter_deps="gpl" -kerndeint_filter_deps="gpl" -ladspa_filter_deps="ladspa dlopen" -mcdeint_filter_deps="avcodec gpl" movie_filter_deps="avcodec avformat" -mpdecimate_filter_deps="gpl" -mpdecimate_filter_select="pixelutils" -mptestsrc_filter_deps="gpl" -negate_filter_deps="lut_filter" -nnedi_filter_deps="gpl" -ocr_filter_deps="libtesseract" ocv_filter_deps="libopencv" -owdenoise_filter_deps="gpl" -pan_filter_deps="swresample" -perspective_filter_deps="gpl" -phase_filter_deps="gpl" -pp7_filter_deps="gpl" -pp_filter_deps="gpl postproc" -pullup_filter_deps="gpl" -removelogo_filter_deps="avcodec avformat swscale" -repeatfields_filter_deps="gpl" resample_filter_deps="avresample" -rubberband_filter_deps="librubberband" -sab_filter_deps="gpl swscale" -scale2ref_filter_deps="swscale" scale_filter_deps="swscale" scale_qsv_filter_deps="libmfx" -select_filter_select="pixelutils" -showcqt_filter_deps="avcodec avformat swscale" -showcqt_filter_select="fft" -showfreqs_filter_deps="avcodec" -showfreqs_filter_select="fft" -showspectrum_filter_deps="avcodec" -showspectrum_filter_select="fft" -showspectrumpic_filter_deps="avcodec" -showspectrumpic_filter_select="fft" -signature_filter_deps="gpl avcodec avformat" -smartblur_filter_deps="gpl swscale" -sofalizer_filter_deps="libmysofa avcodec" -sofalizer_filter_select="fft" -spectrumsynth_filter_deps="avcodec" -spectrumsynth_filter_select="fft" -spp_filter_deps="gpl avcodec" -spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp" -stereo3d_filter_deps="gpl" -subtitles_filter_deps="avformat avcodec libass" -super2xsai_filter_deps="gpl" -pixfmts_super2xsai_test_deps="super2xsai_filter" -tinterlace_filter_deps="gpl" -tinterlace_merge_test_deps="tinterlace_filter" -tinterlace_pad_test_deps="tinterlace_filter" -uspp_filter_deps="gpl avcodec" -vaguedenoiser_filter_deps="gpl" -vidstabdetect_filter_deps="libvidstab" -vidstabtransform_filter_deps="libvidstab" -libvmaf_filter_deps="libvmaf" -zmq_filter_deps="libzmq" -zoompan_filter_deps="swscale" -zscale_filter_deps="libzimg" scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" # examples -avio_dir_cmd_deps="avformat avutil" -avio_reading_deps="avformat avcodec avutil" decode_audio_example_deps="avcodec avutil" decode_video_example_deps="avcodec avutil" -demuxing_decoding_example_deps="avcodec avformat avutil" encode_audio_example_deps="avcodec avutil" encode_video_example_deps="avcodec avutil" -extract_mvs_example_deps="avcodec avformat avutil" filter_audio_example_deps="avfilter avutil" -filtering_audio_example_deps="avfilter avcodec avformat avutil" -filtering_video_example_deps="avfilter avcodec avformat avutil" -http_multiclient_example_deps="avformat avutil fork" -hw_decode_example_deps="avcodec avformat avutil" metadata_example_deps="avformat avutil" -muxing_example_deps="avcodec avformat avutil swscale" +output_example_deps="avcodec avformat avresample avutil swscale" qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder" -remuxing_example_deps="avcodec avformat avutil" -resampling_audio_example_deps="avutil swresample" -scaling_video_example_deps="avutil swscale" -transcode_aac_example_deps="avcodec avformat swresample" -transcoding_example_deps="avfilter avcodec avformat avutil" +transcode_aac_example_deps="avcodec avformat avresample" + +# EXTRALIBS_LIST +cpu_init_extralibs="pthreads_extralibs" +cws2fws_extralibs="zlib_extralibs" # libraries, in linking order avcodec_deps="avutil" @@ -3249,106 +2566,99 @@ avcodec_select="null_bsf" avdevice_deps="avformat avcodec avutil" avfilter_deps="avutil" avformat_deps="avcodec avutil" +avformat_suggest="network" avresample_deps="avutil" -postproc_deps="avutil gpl" -swresample_deps="avutil" swscale_deps="avutil" +avcodec_extralibs="pthreads_extralibs libm_extralibs" +avdevice_extralibs="libm_extralibs" +avformat_extralibs="libm_extralibs" +avfilter_extralibs="pthreads_extralibs libm_extralibs" +avresample_extralibs="libm_extralibs" +avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" +swscale_extralibs="libm_extralibs" + # programs -ffmpeg_deps="avcodec avfilter avformat swresample" -ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter - null_filter +avconv_deps="avcodec avfilter avformat avresample swscale" +avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter + fps_filter null_filter resample_filter scale_filter trim_filter" -ffplay_deps="avcodec avformat swscale swresample sdl2" -ffplay_extralibs='$sdl2_extralibs' -ffplay_select="rdft crop_filter transpose_filter hflip_filter vflip_filter rotate_filter" -ffprobe_deps="avcodec avformat" -ffserver_deps="avformat fork sarestart" -ffserver_select="ffm_muxer rtp_protocol rtsp_demuxer" +avconv_suggest="psapi shell32" +avplay_deps="avcodec avfilter avformat avresample sdl" +avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter" +avplay_suggest="shell32" +avprobe_deps="avcodec avformat" +avprobe_suggest="shell32" # documentation -podpages_deps="perl" -manpages_deps="perl pod2man" -htmlpages_deps="perl" -htmlpages_deps_any="makeinfo_html texi2html" -txtpages_deps="perl makeinfo" -doc_deps_any="manpages htmlpages podpages txtpages" +pod2man_deps="doc" +texi2html_deps="doc" # default parameters -logfile="ffbuild/config.log" +logfile="avbuild/config.log" # installation paths prefix_default="/usr/local" bindir_default='${prefix}/bin' -datadir_default='${prefix}/share/ffmpeg' -docdir_default='${prefix}/share/doc/ffmpeg' +datadir_default='${prefix}/share/avconv' +docdir_default='${prefix}/share/doc/libav' incdir_default='${prefix}/include' libdir_default='${prefix}/lib' mandir_default='${prefix}/share/man' +shlibdir_default="$libdir_default" # toolchain ar_default="ar" cc_default="gcc" -cxx_default="g++" host_cc_default="gcc" -doxygen_default="doxygen" -install="install" -ln_s_default="ln -s -f" +x86asmexe_default="nasm" +ln_s="ln -s -f" nm_default="nm -g" pkg_config_default=pkg-config -ranlib_default="ranlib" -strip_default="strip" +ranlib="ranlib" +strip="strip" version_script='--version-script' -x86asmexe_default="nasm" -windres_default="windres" -nvcc_default="nvcc" -nvccflags_default="-gencode arch=compute_30,code=sm_30 -O2" + +# machine +arch_default=$(uname -m) +cpu="generic" +intrinsics="none" # OS target_os_default=$(tolower $(uname -s)) host_os=$target_os_default -# machine -if test "$target_os_default" = aix; then - arch_default=$(uname -p) - strip_default="strip -X32_64" -else - arch_default=$(uname -m) -fi -cpu="generic" -intrinsics="none" - # configurable options -enable $PROGRAM_LIST -enable $DOCUMENT_LIST -enable $EXAMPLE_LIST -enable $(filter_out avresample $LIBRARY_LIST) -enable stripping +enable $EXAMPLE_LIST $LIBRARY_LIST $PROGRAM_LIST enable asm enable debug enable doc enable faan faandct faanidct enable optimizations -enable runtime_cpudetect enable safe_bitstream_reader enable static enable swscale_alpha enable valgrind_backtrace -sws_max_filter_size_default=256 -set_default sws_max_filter_size +# By default, enable only those hwaccels that have no external dependencies. +enable d3d11va dxva2 vda vdpau + +# internal components are enabled by default +enable $EXTRALIBS_LIST + +# Avoid external, non-system, libraries getting enabled by dependency resolution +disable $EXTERNAL_LIBRARY_LIST # build settings SHFLAGS='-shared -Wl,-soname,$$(@F)' LIBPREF="lib" LIBSUF=".a" -FULLNAME='$(NAME)$(BUILDSUF)' -LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)' +LIBNAME='$(LIBPREF)$(NAME)$(LIBSUF)' SLIBPREF="lib" SLIBSUF=".so" -SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)' +SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)' SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)' SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' @@ -3365,8 +2675,6 @@ AS_O='-o $@' CC_C='-c' CC_E='-E -o $@' CC_O='-o $@' -CXX_C='-c' -CXX_O='-o $@' OBJCC_C='-c' OBJCC_E='-E -o $@' OBJCC_O='-o $@' @@ -3378,8 +2686,6 @@ HOSTCC_C='-c' HOSTCC_E='-E -o $@' HOSTCC_O='-o $@' HOSTLD_O='-o $@' -NVCC_C='-c' -NVCC_O='-o $@' host_extralibs='-lm' host_cflags_filter=echo @@ -3389,19 +2695,18 @@ target_path='$(CURDIR)' # since the object filename is not given with the -MM flag, the compiler # is only able to print the basename, and we must add the path ourselves -DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>/dev/null | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(@F),$(@D)/$(@F)," > $(@:.o=.d)' +DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)' DEPFLAGS='-MM' -mkdir -p ffbuild +mkdir -p avbuild # find source path if test -f configure; then source_path=. else source_path=$(cd $(dirname "$0"); pwd) - case "$source_path" in - *[[:blank:]]*) die "Out of tree builds are impossible with whitespace in source path." ;; - esac + echo "$source_path" | grep -q '[[:blank:]]' && + die "Out of tree builds are impossible with whitespace in source path." test -e "$source_path/config.h" && die "Out of tree builds are impossible with config.h in source dir." fi @@ -3410,7 +2715,7 @@ for v in "$@"; do r=${v#*=} l=${v%"$r"} r=$(sh_quote "$r") - FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}" + LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}" done find_things(){ @@ -3440,20 +2745,36 @@ find_things_extern(){ BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c) PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c) -ALL_COMPONENTS=" +AVCODEC_COMPONENTS_LIST=" $BSF_LIST $DECODER_LIST - $DEMUXER_LIST $ENCODER_LIST - $FILTER_LIST $HWACCEL_LIST - $INDEV_LIST - $MUXER_LIST - $OUTDEV_LIST $PARSER_LIST +" + +AVDEVICE_COMPONENTS_LIST=" + $INDEV_LIST + $OUTDEV_LIST +" + +AVFILTER_COMPONENTS_LIST=" + $FILTER_LIST +" + +AVFORMAT_COMPONENTS_LIST=" + $DEMUXER_LIST + $MUXER_LIST $PROTOCOL_LIST " +ALL_COMPONENTS=" + $AVCODEC_COMPONENTS_LIST + $AVDEVICE_COMPONENTS_LIST + $AVFILTER_COMPONENTS_LIST + $AVFORMAT_COMPONENTS_LIST +" + for n in $COMPONENT_LIST; do v=$(toupper ${n%s})_LIST eval enable \$$v @@ -3468,15 +2789,14 @@ die_unknown(){ exit 1 } -print_in_columns() { - cols=$(expr $ncols / 24) - cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t +print_3_columns() { + printf "%-25s %-25s %-25s\n" $(cat | tr ' ' '\n' | sort) } show_list() { suffix=_$1 shift - echo $* | sed s/$suffix//g | print_in_columns + echo $* | sed s/$suffix//g | print_3_columns exit 0 } @@ -3510,8 +2830,8 @@ for opt do --extra-ldexeflags=*) add_ldexeflags $optval ;; - --extra-ldlibflags=*) - add_ldlibflags $optval + --extra-ldsoflags=*) + add_ldsoflags $optval ;; --extra-libs=*) add_extralibs $optval @@ -3531,7 +2851,6 @@ for opt do --disable-all) map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST disable $LIBRARY_LIST $PROGRAM_LIST doc - enable avutil ;; --enable-random|--disable-random) action=${opt%%-random} @@ -3541,28 +2860,22 @@ for opt do action=${opt%%-random=*} do_random ${action#--} $optval ;; - --enable-sdl) - enable sdl2 - ;; --enable-*=*|--disable-*=*) eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/') is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt" eval list=\$$(toupper $thing)_LIST name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing} - list=$(filter "$name" $list) - [ "$list" = "" ] && warn "Option $opt did not match anything" - $action $list + $action $(filter "$name" $list) + ;; + --enable-avserver|--disable-avserver*) + warn "avserver has been removed, the ${opt} option is only"\ + "provided for compatibility and will be removed in the future" ;; --enable-yasm|--disable-yasm) warn "The ${opt} option is only provided for compatibility and will be\n"\ "removed in the future. Use --enable-x86asm / --disable-x86asm instead." test $opt = --enable-yasm && x86asm=yes || x86asm=no ;; - --yasmexe=*) - warn "The --yasmexe option is only provided for compatibility and will be\n"\ - "removed in the future. Use --x86asmexe instead." - x86asmexe="$optval" - ;; --enable-?*|--disable-?*) eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g') if is_in $option $COMPONENT_LIST; then @@ -3584,11 +2897,6 @@ for opt do ;; --quiet|-q) quiet=yes ;; - --fatal-warnings) enable fatal_warnings - ;; - --libfuzzer=*) - libfuzzer_path="$optval" - ;; *) optname="${opt%%=*}" optname="${optname#--}" @@ -3608,41 +2916,22 @@ for e in $env; do eval "export $e" done -if disabled autodetect; then - - # Unless iconv is explicitely disabled by the user, we still want to probe - # for the iconv from the libc. - disabled iconv || enable libc_iconv - - disable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST - disable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST -fi -# Mark specifically enabled, but normally autodetected libraries as requested. -for lib in $AUTODETECT_LIBS; do - enabled $lib && request $lib -done -#TODO: switch to $AUTODETECT_LIBS when $THREADS_LIST is supported the same way -enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST -enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST - disabled logging && logfile=/dev/null +# Die early if licensing-related configure options are incompatible. die_license_disabled() { enabled $1 || { enabled $v && die "$v is $1 and --enable-$1 is not specified."; } } -die_license_disabled_gpl() { - enabled $1 || { enabled $v && die "$v is incompatible with the gpl and --enable-$1 is not specified."; } -} - -map "die_license_disabled gpl" $EXTERNAL_LIBRARY_GPL_LIST $EXTERNAL_LIBRARY_GPLV3_LIST -map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST $EXTERNAL_LIBRARY_GPLV3_LIST - -enabled gpl && map "die_license_disabled_gpl nonfree" $EXTERNAL_LIBRARY_NONFREE_LIST -map "die_license_disabled nonfree" $HWACCEL_LIBRARY_NONFREE_LIST +map "die_license_disabled gpl" $EXTERNAL_LIBRARY_GPL_LIST +map "die_license_disabled nonfree" $EXTERNAL_LIBRARY_NONFREE_LIST $HWACCEL_LIBRARY_NONFREE_LIST +map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; } +enabled_all gnutls openssl && + die "GnuTLS and OpenSSL must not be enabled at the same time." + # Disable all the library-specific components if the library itself # is disabled, see AVCODEC_LIST and following _LIST variables. @@ -3655,16 +2944,9 @@ disable_components(){ map 'disable_components $v' $LIBRARY_LIST -echo "# $0 $FFMPEG_CONFIGURATION" > $logfile +echo "# $0 $LIBAV_CONFIGURATION" > $logfile set >> $logfile -test -n "$valgrind" && toolchain="valgrind-memcheck" - -enabled ossfuzz && { - add_cflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp -fno-omit-frame-pointer - add_ldflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp -} - case "$toolchain" in *-asan) cc_default="${toolchain%-asan}" @@ -3691,32 +2973,35 @@ case "$toolchain" in cc_default="${toolchain%-usan}" add_cflags -fsanitize=undefined add_ldflags -fsanitize=undefined + case "$toolchain" in + clang-usan) + add_cflags -O1 + ;; + esac ;; valgrind-*) target_exec_default="valgrind" case "$toolchain" in valgrind-massif) - target_exec_args="--tool=massif --alloc-fn=av_malloc --alloc-fn=av_mallocz --alloc-fn=av_calloc --alloc-fn=av_fast_padded_malloc --alloc-fn=av_fast_malloc --alloc-fn=av_realloc_f --alloc-fn=av_fast_realloc --alloc-fn=av_realloc" + target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz" ;; valgrind-memcheck) - target_exec_args="--error-exitcode=1 --malloc-fill=0x2a --track-origins=yes --leak-check=full --gen-suppressions=all --suppressions=$source_path/tests/fate-valgrind.supp" + target_exec_args="--track-origins=yes --leak-check=full" ;; esac ;; msvc) # Check whether the current MSVC version needs the C99 converter. # From MSVC 2013 (compiler major version 18) onwards, it does actually - # support enough of C99 to build ffmpeg. Default to the new + # support enough of C99 to build libav. Default to the new # behaviour if the regexp was unable to match anything, since this # successfully parses the version number of existing supported # versions that require the converter (MSVC 2010 and 2012). cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p') if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then cc_default="cl" - cxx_default="cl" else cc_default="c99wrap cl" - cxx_default="c99wrap cl" fi ld_default="$source_path/compat/windows/mslink" nm_default="dumpbin -symbols" @@ -3753,8 +3038,6 @@ case "$toolchain" in add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 add_cflags -fno-strict-overflow -fstack-protector-all add_ldflags -Wl,-z,relro -Wl,-z,now - add_cflags -fPIE - add_ldexeflags -fPIE -pie ;; ?*) die "Unknown toolchain $toolchain" @@ -3770,36 +3053,22 @@ fi ar_default="${cross_prefix}${ar_default}" cc_default="${cross_prefix}${cc_default}" -cxx_default="${cross_prefix}${cxx_default}" +objcc_default="${cross_prefix}${objcc_default}" +x86asmexe_default="${cross_prefix}${x86asmexe_default}" nm_default="${cross_prefix}${nm_default}" pkg_config_default="${cross_prefix}${pkg_config_default}" -if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then - ranlib_default="${cross_prefix}${ranlib_default} -D" -else - ranlib_default="${cross_prefix}${ranlib_default}" -fi -strip_default="${cross_prefix}${strip_default}" -windres_default="${cross_prefix}${windres_default}" +ranlib="${cross_prefix}${ranlib}" +strip="${cross_prefix}${strip}" sysinclude_default="${sysroot}/usr/include" -set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \ - target_exec target_os x86asmexe nvcc +set_default arch cc pkg_config sysinclude target_exec target_os x86asmexe enabled cross_compile || host_cc_default=$cc set_default host_cc -pkg_config_fail_message="" if ! $pkg_config --version >/dev/null 2>&1; then warn "$pkg_config not found, library detection may fail." pkg_config=false -elif is_in -static $cc $LDFLAGS && ! is_in --static $pkg_config $pkg_config_flags; then - pkg_config_fail_message=" -Note: When building a static binary, add --pkg-config-flags=\"--static\"." -fi - -if test $doxygen != $doxygen_default && \ - ! $doxygen --version >/dev/null 2>&1; then - warn "Specified doxygen \"$doxygen\" not found, API documentation will fail to build." fi exesuf() { @@ -3816,13 +3085,7 @@ HOSTEXESUF=$(exesuf $host_os) : ${TMPDIR:=$TMP} : ${TMPDIR:=/tmp} -if [ -n "$tempprefix" ] ; then - mktemp(){ - tmpname="$tempprefix.${HOSTNAME}.${UID}" - echo "$tmpname" - mkdir "$tmpname" - } -elif ! check_cmd mktemp -u XXXXXX; then +if ! check_cmd mktemp -u XXXXXX; then # simple replacement for missing mktemp # NOT SAFE FOR GENERAL USE mktemp(){ @@ -3832,25 +3095,23 @@ elif ! check_cmd mktemp -u XXXXXX; then } fi -FFTMPDIR=$(mktemp -d "${TMPDIR}/ffconf.XXXXXXXX" 2> /dev/null) || +AVTMPDIR=$(mktemp -d "${TMPDIR}/avconf.XXXXXXXX" 2> /dev/null) || die "Unable to create temporary directory in $TMPDIR." tmpfile(){ - tmp="${FFTMPDIR}/test"$2 + tmp="${AVTMPDIR}/test"$2 (set -C; exec > $tmp) 2> /dev/null || - die "Unable to create temporary file in $FFTMPDIR." + die "Unable to create temporary file in $AVTMPDIR." eval $1=$tmp } -trap 'rm -rf -- "$FFTMPDIR"' EXIT +trap 'rm -rf -- "$AVTMPDIR"' EXIT trap 'exit 2' INT tmpfile TMPASM .asm tmpfile TMPC .c -tmpfile TMPCPP .cpp tmpfile TMPE $EXESUF tmpfile TMPH .h -tmpfile TMPM .m tmpfile TMPO .o tmpfile TMPS .S tmpfile TMPSH .sh @@ -3934,9 +3195,7 @@ msvc_common_flags(){ -march=*) ;; -lz) echo zlib.lib ;; -lx264) echo libx264.lib ;; - -lstdc++) ;; -l*) echo ${flag#-l}.lib ;; - -LARGEADDRESSAWARE) echo $flag ;; -L*) echo -libpath:${flag#-L} ;; *) echo $flag ;; esac @@ -3952,7 +3211,6 @@ msvc_flags(){ -Wextra) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \ -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \ -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \ - -wd4307 \ -wd4273 -wd4554 -wd4701 -wd4703 ;; esac done @@ -3966,16 +3224,6 @@ icl_flags(){ # on Windows, does enable remarks so disable them here. -Wall) echo $flag -Qdiag-disable:remark ;; -std=c99) echo -Qstd=c99 ;; - -flto) echo -ipo ;; - esac - done -} - -icc_flags(){ - for flag; do - case $flag in - -flto) echo -ipo ;; - *) echo $flag ;; esac done } @@ -4008,16 +3256,9 @@ suncc_flags(){ prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;; *-sse3) echo -xarch=sse3 ;; core2) echo -xarch=ssse3 -xchip=core2 ;; - bonnell) echo -xarch=ssse3 ;; - corei7|nehalem) echo -xtarget=nehalem ;; - westmere) echo -xtarget=westmere ;; - silvermont) echo -xarch=sse4_2 ;; - corei7-avx|sandybridge) echo -xtarget=sandybridge ;; - core-avx*|ivybridge|haswell|broadwell|skylake*|knl) - echo -xarch=avx ;; - amdfam10|barcelona) echo -xtarget=barcelona ;; - btver1) echo -xarch=amdsse4a ;; - btver2|bdver*|znver*) echo -xarch=avx ;; + corei7) echo -xarch=sse4_2 -xchip=nehalem ;; + corei7-avx) echo -xarch=avx -xchip=sandybridge ;; + amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;; athlon-4|athlon-[mx]p) echo -xarch=ssea ;; k8|opteron|athlon64|athlon-fx) echo -xarch=sse2a ;; @@ -4067,16 +3308,13 @@ tms470_flags(){ probe_cc(){ pfx=$1 _cc=$2 - first=$3 unset _type _ident _cc_c _cc_e _cc_o _flags _cflags unset _ld_o _ldflags _ld_lib _ld_path unset _depflags _DEPCMD _DEPFLAGS _flags_filter=echo - if $_cc --version 2>&1 | grep -q '^GNU assembler'; then - true # no-op to avoid reading stdin in following checks - elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then + if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then _type=llvm_gcc gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)') _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver" @@ -4090,16 +3328,8 @@ probe_cc(){ gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)') gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)") _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver") - case $gcc_basever in - 2) ;; - 2.*) ;; - *) _depflags='-MMD -MF $(@:.o=.d) -MT $@' ;; - esac - if [ "$first" = true ]; then - case $gcc_basever in - 4.2*) - warn "gcc 4.2 is outdated and may miscompile FFmpeg. Please use a newer compiler." ;; - esac + if ! $_cc -dumpversion | grep -q '^2\.'; then + _depflags='-MMD -MF $(@:.o=.d) -MT $@' fi _cflags_speed='-O3' _cflags_size='-Os' @@ -4110,7 +3340,6 @@ probe_cc(){ _cflags_speed='-O3' _cflags_size='-Os' _cflags_noopt='-O1' - _flags_filter=icc_flags elif $_cc -v 2>&1 | grep -q xlc; then _type=xlc _ident=$($_cc -qversion 2>/dev/null | head -n1) @@ -4154,7 +3383,7 @@ probe_cc(){ _ident=$($_cc --version 2>/dev/null | head -n1) _depflags='-MMD -MF $(@:.o=.d) -MT $@' _cflags_speed='-O3' - _cflags_size='-Oz' + _cflags_size='-Os' elif $_cc -V 2>&1 | grep -q Sun; then _type=suncc _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-) @@ -4184,7 +3413,7 @@ probe_cc(){ opt_common='-alias=ansi -Mdse -Mlre -Mpre' _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common" _cflags_size="-O2 -Munroll=c:1 $opt_common" - _cflags_noopt="-O" + _cflags_noopt="-O1" _flags_filter=pgi_flags elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then _type=armasm @@ -4192,6 +3421,25 @@ probe_cc(){ # 4509: "This form of conditional instruction is deprecated" _flags="-nologo -ignore 4509" _flags_filter=armasm_flags + elif $_cc -nologo- 2>&1 | grep -q Microsoft; then + _type=msvc + _ident=$($_cc 2>&1 | head -n1) + _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' + _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' + _cflags_speed="-O2" + _cflags_size="-O1" + _cflags_noopt="-O1" + if $_cc -nologo- 2>&1 | grep -q Linker; then + _ld_o='-out:$@' + else + _ld_o='-Fe$@' + fi + _cc_o='-Fo$@' + _cc_e='-P -Fi$@' + _flags_filter=msvc_flags + _ld_lib='lib%.a' + _ld_path='-libpath:' + _flags='-nologo' elif $_cc 2>&1 | grep -q Intel; then _type=icl _ident=$($_cc 2>&1 | head -n1) @@ -4212,10 +3460,9 @@ probe_cc(){ _ld_path='-libpath:' # -Qdiag-error to make icl error when seeing certain unknown arguments _flags='-nologo -Qdiag-error:4044,10157' - # -Qvec- -Qsimd- to prevent miscompilation, -GS, fp:precise for consistency + # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency # with MSVC which enables it by default. - _cflags='-Qms0 -Qvec- -Qsimd- -GS -fp:precise' - disable stripping + _cflags='-Qms0 -Qvec- -Qsimd- -GS' elif $_cc -? 2>/dev/null | grep -q 'LLVM.*Linker'; then # lld can emulate multiple different linkers; in ms link.exe mode, # the -? parameter gives the help output which contains an identifyable @@ -4228,26 +3475,6 @@ probe_cc(){ _flags_filter=msvc_flags _ld_lib='lib%.a' _ld_path='-libpath:' - elif $_cc -nologo- 2>&1 | grep -q Microsoft; then - _type=msvc - _ident=$($_cc 2>&1 | head -n1) - _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' - _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' - _cflags_speed="-O2" - _cflags_size="-O1" - _cflags_noopt="-O1" - if $_cc -nologo- 2>&1 | grep -q Linker; then - _ld_o='-out:$@' - else - _ld_o='-Fe$@' - fi - _cc_o='-Fo$@' - _cc_e='-P -Fi$@' - _flags_filter=msvc_flags - _ld_lib='lib%.a' - _ld_path='-libpath:' - _flags='-nologo' - disable stripping elif $_cc --version 2>/dev/null | grep -q ^cparser; then _type=cparser _ident=$($_cc --version | head -n1) @@ -4275,7 +3502,7 @@ set_ccvars(){ fi } -probe_cc cc "$cc" "true" +probe_cc cc "$cc" cflags_filter=$_flags_filter cflags_speed=$_cflags_speed cflags_size=$_cflags_size @@ -4283,7 +3510,6 @@ cflags_noopt=$_cflags_noopt add_cflags $_flags $_cflags cc_ldflags=$_ldflags set_ccvars CC -set_ccvars CXX probe_cc hostcc "$host_cc" host_cflags_filter=$_flags_filter @@ -4299,7 +3525,7 @@ test -n "$cc_type" && enable $cc_type || : ${dep_cc_default:=$cc} : ${ld_default:=$cc} : ${host_ld_default:=$host_cc} -set_default ar as objcc dep_cc ld ln_s host_ld windres +set_default ar as objcc dep_cc ld host_ld probe_cc as "$as" asflags_filter=$_flags_filter @@ -4340,16 +3566,12 @@ elif $ar 2>&1 | grep -q 'Texas Instruments'; then elif $ar 2>&1 | grep -q 'Usage: ar.*-X.*any'; then arflags='-Xany -r -c' ar_o='$@' -elif $ar 2>&1 | grep -q "\[D\] "; then - arflags="rcD" - ar_o='$@' else arflags="rc" ar_o='$@' fi add_cflags $extra_cflags -add_cxxflags $extra_cxxflags add_objcflags $extra_objcflags add_asflags $extra_cflags @@ -4358,9 +3580,6 @@ if test -n "$sysroot"; then gcc|llvm_gcc|clang) add_cppflags --sysroot="$sysroot" add_ldflags --sysroot="$sysroot" -# On Darwin --sysroot may be ignored, -isysroot always affects headers and linking - add_cppflags -isysroot "$sysroot" - add_ldflags -isysroot "$sysroot" ;; tms470) add_cppflags -I"$sysinclude" @@ -4385,17 +3604,6 @@ if test "$cpu" = host; then } cpu=$(check_native -march || check_native -mcpu) ;; - clang) - check_native(){ - $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return - sed -n "/cc1.*-target-cpu /{ - s/.*-target-cpu \\([^ ]*\\).*/\\1/ - p - q - }" $TMPE - } - cpu=$(check_native -march) - ;; esac test "${cpu:-host}" = host && @@ -4407,7 +3615,7 @@ case "$arch" in aarch64|arm64) arch="aarch64" ;; - arm*|iPad*|iPhone*) + arm*) arch="arm" ;; mips*|IP*) @@ -4435,13 +3643,13 @@ case "$arch" in sh4|sh) arch="sh4" ;; - sun4*|sparc*) + sun4u|sparc*) arch="sparc" ;; tilegx|tile-gx) arch="tilegx" ;; - i[3-6]86*|i86pc|BePC|x86pc|x86_64|x86_32|amd64) + i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64) arch="x86" ;; esac @@ -4520,10 +3728,7 @@ elif enabled arm; then case "$subarch" in armv5t*) enable fast_clz ;; - armv[6-8]*) - enable fast_clz - disabled fast_unaligned || enable fast_unaligned - ;; + armv[6-8]*) enable fast_clz fast_unaligned ;; esac elif enabled avr32; then @@ -4555,98 +3760,6 @@ elif enabled mips; then cpuflags="-march=$cpu" - if [ "$cpu" != "generic" ]; then - disable mips32r2 - disable mips32r5 - disable mips64r2 - disable mips32r6 - disable mips64r6 - disable loongson2 - disable loongson3 - - case $cpu in - 24kc|24kf*|24kec|34kc|1004kc|24kef*|34kf*|1004kf*|74kc|74kf) - enable mips32r2 - disable msa - ;; - p5600|i6400|p6600) - disable mipsdsp - disable mipsdspr2 - ;; - loongson*) - enable loongson2 - enable loongson3 - enable local_aligned_8 local_aligned_16 local_aligned_32 - enable simd_align_16 - enable fast_64bit - enable fast_clz - enable fast_cmov - enable fast_unaligned - disable aligned_stack - disable mipsfpu - disable mipsdsp - disable mipsdspr2 - case $cpu in - loongson3*) - cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations" - ;; - loongson2e) - cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations" - ;; - loongson2f) - cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations" - ;; - esac - ;; - *) - # Unknown CPU. Disable everything. - warn "unknown CPU. Disabling all MIPS optimizations." - disable mipsfpu - disable mipsdsp - disable mipsdspr2 - disable msa - disable mmi - ;; - esac - - case $cpu in - 24kc) - disable mipsfpu - disable mipsdsp - disable mipsdspr2 - ;; - 24kf*) - disable mipsdsp - disable mipsdspr2 - ;; - 24kec|34kc|1004kc) - disable mipsfpu - disable mipsdspr2 - ;; - 24kef*|34kf*|1004kf*) - disable mipsdspr2 - ;; - 74kc) - disable mipsfpu - ;; - p5600) - enable mips32r5 - check_cflags "-mtune=p5600" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" - ;; - i6400) - enable mips64r6 - check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" - ;; - p6600) - enable mips64r6 - check_cflags "-mtune=p6600 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" - ;; - esac - else - # We do not disable anything. Is up to the user to disable the unwanted features. - warn 'generic cpu selected' - fi - elif enabled ppc; then disable ldbrx @@ -4686,6 +3799,7 @@ elif enabled ppc; then ;; power[7-8]*) cpuflags="-mcpu=$cpu" + enable ldbrx ;; cell) cpuflags="-mcpu=cell" @@ -4733,9 +3847,7 @@ elif enabled x86; then disable i686 ;; # targets that do support nopl and conditional mov (cmov) - i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\ - |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|skylake*|knl\ - |amdfam10|barcelona|b[dt]ver*|znver*) + i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*) cpuflags="-march=$cpu" enable i686 enable fast_cmov @@ -4770,23 +3882,15 @@ if test "$?" != 0; then fi add_cppflags -D_ISOC99_SOURCE -add_cxxflags -D__STDC_CONSTANT_MACROS -check_cxxflags -std=c++11 || check_cxxflags -std=c++0x # some compilers silently accept -std=c11, so we also need to check that the # version macro is defined properly -if test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L"; then - add_cflags -std=c11 -else +check_cpp_condition stdlib.h "__STDC_VERSION__ >= 201112L" -std=c11 && + add_cflags -std=c11 || check_cflags -std=c99 -fi -check_cc -D_FILE_OFFSET_BITS=64 < -EOF -check_cc -D_LARGEFILE_SOURCE < -EOF +check_cppflags -D_FILE_OFFSET_BITS=64 +check_cppflags -D_LARGEFILE_SOURCE add_host_cppflags -D_ISOC99_SOURCE check_host_cflags -std=c99 @@ -4827,18 +3931,10 @@ case "$arch" in ;; x86) check_64bit x86_32 x86_64 'sizeof(void *) > 4' - # Treat x32 as x64 for now. Note it also needs spic=$shared - test "$subarch" = "x86_32" && check_cpp_condition stddef.h 'defined(__x86_64__)' && - subarch=x86_64 if test "$subarch" = "x86_64"; then spic=$shared fi ;; - ppc) - check_cc < $$(@:$(SLIBSUF)=.def); lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)' - if enabled x86_64; then - LIBTARGET=x64 - fi - elif check_cmd $dlltool --version; then - SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)' - fi + SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)' + SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)' + SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_LINKS= SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)' SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' - SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--disable-auto-image-base' + SLIB_CREATE_DEF_CMD='ARCH="$(ARCH)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' + SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-auto-image-base $$(@:$(SLIBSUF)=.def)' enabled x86_64 && objformat="win64" || objformat="win32" + dlltool="${cross_prefix}dlltool" ranlib=: enable dos_paths - check_ldflags -Wl,--nxcompat,--dynamicbase - # Lets work around some stupidity in binutils. - # ld will strip relocations from executables even though we need them - # for dynamicbase (ASLR). Using -pie does retain the reloc section - # however ld then forgets what the entry point should be (oops) so we - # have to manually (re)set it. - if enabled x86_32; then - disabled debug && add_ldexeflags -Wl,--pic-executable,-e,_mainCRTStartup - elif enabled x86_64; then - disabled debug && add_ldexeflags -Wl,--pic-executable,-e,mainCRTStartup - check_ldflags -Wl,--high-entropy-va # binutils 2.25 - # Set image base >4GB for extra entropy with HEASLR - add_ldexeflags -Wl,--image-base,0x140000000 - append SHFLAGS -Wl,--image-base,0x180000000 - fi ;; win32|win64) disable symver @@ -4988,12 +4058,11 @@ case $target_os in # Cannot build both shared and static libs with MSVC or icl. disable static fi - enabled x86_32 && check_ldflags -LARGEADDRESSAWARE shlibdir_default="$bindir_default" SLIBPREF="" SLIBSUF=".dll" - SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' - SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' + SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)' + SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)' SLIB_CREATE_DEF_CMD='$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)' SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_LINKS= @@ -5009,16 +4078,14 @@ case $target_os in shlibdir_default="$bindir_default" SLIBPREF="cyg" SLIBSUF=".dll" - SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' - SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' + SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)' + SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)' SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_LINKS= - SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a' - SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a' + SLIB_INSTALL_EXTRA_LIB='lib$(NAME).dll.a' + SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(NAME).dll.a' enabled x86_64 && objformat="win64" || objformat="win32" enable dos_paths - enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres - add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 ;; *-dos|freedos|opendos) network_extralibs="-lsocket" @@ -5029,14 +4096,13 @@ case $target_os in linux) enable dv1394 enable section_data_rel_ro - enabled_any arm aarch64 && enable_weak linux_perf ;; irix*) target_os=irix ranlib="echo ignoring ranlib" ;; os/2*) - strip="lxlite -CS" + ln_s="cp -f" objformat="aout" add_cppflags -D_GNU_SOURCE add_ldflags -Zomf -Zbin-files -Zargs-wild -Zhigh-mem -Zmap @@ -5044,20 +4110,17 @@ case $target_os in LIBSUF="_s.a" SLIBPREF="" SLIBSUF=".dll" - SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)' - SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(FULLNAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)' - SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(FULLNAME).def; \ - echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(FULLNAME).def; \ - echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(FULLNAME).def; \ - echo EXPORTS >> $(SUBDIR)$(FULLNAME).def; \ - emxexp $(OBJS) >> $(SUBDIR)$(FULLNAME).def' - SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(FULLNAME)_dll.a $(SUBDIR)$(FULLNAME).def; \ - emximp -o $(SUBDIR)$(LIBPREF)$(FULLNAME)_dll.lib $(SUBDIR)$(FULLNAME).def;' - SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' - SLIB_INSTALL_LINKS= - SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(FULLNAME)_dll.a $(LIBPREF)$(FULLNAME)_dll.lib' + SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)' + SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)' + SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \ + echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \ + echo EXPORTS >> $(SUBDIR)$(NAME).def; \ + emxexp $(OBJS) >> $(SUBDIR)$(NAME).def' + SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \ + emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;' + SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib' enable dos_paths - enable_weak os2threads ;; gnu/kfreebsd) add_cppflags -D_BSD_SOURCE @@ -5092,26 +4155,6 @@ case $target_os in ;; esac -# test if creating links works -link_dest=$(mktemp -u $TMPDIR/dest_XXXXXXXX) -link_name=$(mktemp -u $TMPDIR/name_XXXXXXXX) -mkdir "$link_dest" -$ln_s "$link_dest" "$link_name" -touch "$link_dest/test_file" -if [ "$source_path" != "." ] && ([ ! -d src ] || [ -L src ]) && [ -e "$link_name/test_file" ]; then - # create link to source path - [ -e src ] && rm src - $ln_s "$source_path" src - source_link=src -else - # creating directory links doesn't work - # fall back to using the full source path - source_link="$source_path" -fi -# cleanup -rm -r "$link_dest" -rm -r "$link_name" - # determine libc flavour probe_libc(){ @@ -5131,10 +4174,6 @@ probe_libc(){ # MinGW64 is backwards compatible with MinGW32, so check for it first. elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then eval ${pfx}libc_type=mingw64 - if check_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then - add_compat msvcrt/snprintf.o - add_cflags "-include $source_path/compat/msvcrt/snprintf.h" - fi add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 eval test \$${pfx_no_}cc_type = "gcc" && add_${pfx}cppflags -D__printf__=__gnu_printf__ @@ -5145,10 +4184,10 @@ probe_libc(){ (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW32 runtime version must be >= 3.15." add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 - check_${pfx}cpp_condition _mingw.h "defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0502" || - add_${pfx}cppflags -D_WIN32_WINNT=0x0502 check_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" && add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700 + check_${pfx}cpp_condition windows.h "defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0502" && + add_${pfx}cppflags -D_WIN32_WINNT=0x0502 eval test \$${pfx_no_}cc_type = "gcc" && add_${pfx}cppflags -D__printf__=__gnu_printf__ elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then @@ -5185,7 +4224,6 @@ probe_libc(){ EOF if [ "$pfx" = "" ]; then check_func strtoll || add_cflags -Dstrtoll=_strtoi64 - check_func strtoull || add_cflags -Dstrtoull=_strtoui64 fi elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then eval ${pfx}libc_type=klibc @@ -5194,16 +4232,10 @@ EOF elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then eval ${pfx}libc_type=solaris add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 + else + eval ${pfx}libc_type=default + add_${pfx}cppflags -D_DEFAULT_SOURCE fi - check_${pfx}cc < -void *v = localtime_r; -EOF -test "$?" != 0 && check_${pfx}cc -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 < -void *v = localtime_r; -EOF - } probe_libc @@ -5211,26 +4243,25 @@ test -n "$libc_type" && enable libc_$libc_type probe_libc host_ test -n "$host_libc_type" && enable host_libc_$host_libc_type +# hacks for compiler/libc/os combinations + case $libc_type in bionic) add_compat strtod.o strtod=avpriv_strtod ;; + glibc) + if enabled tms470; then + CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}" + add_cppflags -D__USER_LABEL_PREFIX__= + add_cppflags -D__builtin_memset=memset + add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED + add_cflags -pds=48 # incompatible redefinition of macro + elif enabled ccc; then + add_ldflags -Wl,-z,now # calls to libots crash without this + fi + ;; esac -# hacks for compiler/libc/os combinations - -if enabled_all tms470 libc_glibc; then - CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}" - add_cppflags -D__USER_LABEL_PREFIX__= - add_cppflags -D__builtin_memset=memset - add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED - add_cflags -pds=48 # incompatible redefinition of macro -fi - -if enabled_all ccc libc_glibc; then - add_ldflags -Wl,-z,now # calls to libots crash without this -fi - check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" || add_cppflags '-I\$(SRC_PATH)/compat/float' @@ -5238,14 +4269,10 @@ esc(){ echo "$*" | sed 's/%/%25/g;s/:/%3a/g' } -echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" > ffbuild/config.fate +echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" > avbuild/config.fate check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic -set_default libdir -: ${shlibdir_default:="$libdir"} -: ${pkgconfigdir_default:="$libdir/pkgconfig"} - set_default $PATHS_LIST set_default nm @@ -5260,7 +4287,7 @@ EOF exit 1 fi -disabled optimizations || enabled ossfuzz || check_cflags -fomit-frame-pointer +disabled optimizations || check_cflags -fomit-frame-pointer enable_weak_pic() { disabled pic && return @@ -5284,9 +4311,7 @@ EOF sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }') extern_prefix=${sym%%ff_extern*} -check_cc <= 0x0a060100" || die "ERROR: Decklink API version must be >= 10.6.1."; } } -enabled libndi_newtek && { check_header Processing.NDI.Lib.h || die "ERROR: Processing.NDI.Lib.h header not found"; } -enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } -enabled gmp && require gmp gmp.h mpz_export -lgmp -enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init -enabled jni && { [ $target_os = "android" ] && check_header jni.h && enabled pthreads || die "ERROR: jni not found"; } -enabled ladspa && { check_header ladspa.h || die "ERROR: ladspa.h header not found"; } -enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 -enabled libass && require_pkg_config libass ass/ass.h ass_library_init -enabled libbluray && require_pkg_config libbluray libbluray/bluray.h bd_open -enabled libbs2b && require_pkg_config libbs2b bs2b.h bs2b_open -enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && - { check_lib libcelt celt/celt.h celt_decoder_create_custom -lcelt0 || - die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } -enabled libcaca && require_pkg_config caca caca.h caca_create_canvas -enabled libdc1394 && require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new -enabled libfdk_aac && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || - { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && - warn "using libfdk without pkg-config"; } } -flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite" -enabled libflite && require libflite "flite/flite.h" flite_init $flite_extralibs -enabled fontconfig && enable libfontconfig -enabled libfontconfig && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit -enabled libfreetype && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType -enabled libfribidi && require_pkg_config fribidi fribidi.h fribidi_version_info -enabled libgme && { use_pkg_config libgme gme/gme.h gme_new_emu || - require libgme gme/gme.h gme_new_emu -lgme -lstdc++; } +enabled avisynth && require_header avisynth/avisynth_c.h +enabled avxsynth && require_header avxsynth/avxsynth_c.h +enabled cuda && require cuda cuda.h cuInit -lcuda +enabled cuvid && require cuvid cuviddec.h cuvidCreateDecoder -lnvcuvid +enabled frei0r && require_header frei0r.h +enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init +enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open +enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new +enabled libdcadec && require libdcadec libdcadec/dca_context.h dcadec_context_create -ldcadec +enabled libfaac && require libfaac "stdint.h faac.h" faacEncGetVersion -lfaac +enabled libfdk_aac && require_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen +enabled libfontconfig && require_pkg_config libfontconfig fontconfig "fontconfig/fontconfig.h" FcInit +enabled libfreetype && require_pkg_config libfreetype freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; done || die "ERROR: libgsm not found"; } +enabled libhdcd && require_pkg_config libhdcd libhdcd "hdcd/hdcd_simple.h" hdcd_new enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc -enabled libkvazaar && require_pkg_config "kvazaar >= 0.8.1" kvazaar.h kvz_api_get -# While it may appear that require is being used as a pkg-config -# fallback for libmfx, it is actually being used to detect a different -# installation route altogether. If libmfx is installed via the Intel -# Media SDK or Intel Media Server Studio, these don't come with -# pkg-config support. Instead, users should make sure that the build -# can find the libraries and headers through other means. -enabled libmfx && { use_pkg_config libmfx "mfx/mfxvideo.h" MFXInit || - { require libmfx "mfx/mfxvideo.h" MFXInit -llibmfx && warn "using libmfx without pkg-config"; } } -enabled libmodplug && require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load +enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get +enabled libmfx && require_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame -enabled libmysofa && require libmysofa "mysofa.h" mysofa_load -lmysofa -enabled libnpp && { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc || - check_lib libnpp npp.h nppGetLibVersion -lnppi -lnppc || - die "ERROR: libnpp not found"; } +enabled libnpp && require libnpp npp.h nppGetLibVersion -lnppi -lnppc enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -enabled libopencv && { check_header opencv2/core/core_c.h && - { use_pkg_config opencv opencv2/core/core_c.h cvCreateImageHeader || - require opencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } || - require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; } -enabled libopenh264 && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion -enabled libopenjpeg && { { check_lib libopenjpeg openjpeg-2.2/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || - check_lib libopenjpeg openjpeg-2.2/openjpeg.h opj_version -lopenjp2 || - { check_lib libopenjpeg openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || - check_lib libopenjpeg openjpeg-2.1/openjpeg.h opj_version -lopenjp2 || - { check_lib libopenjpeg openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || - { check_lib libopenjpeg openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || - { check_lib libopenjpeg openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || - die "ERROR: libopenjpeg not found"; } -enabled libopenmpt && require_pkg_config "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -enabled libopus && { - enabled libopus_decoder && { - require_pkg_config opus opus_multistream.h opus_multistream_decoder_create - } - enabled libopus_encoder && { - require_pkg_config opus opus_multistream.h opus_multistream_surround_encoder_create - } -} -enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new -enabled librsvg && require_pkg_config librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo -enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket -enabled librubberband && require_pkg_config "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new -enabled libshine && require_pkg_config shine shine/layer3.h shine_encode_buffer -enabled libsmbclient && { use_pkg_config smbclient libsmbclient.h smbc_init || - require smbclient libsmbclient.h smbc_init -lsmbclient; } +enabled libopencv && require_pkg_config libopencv opencv opencv/cv.h cvCreateImageHeader +enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion +enabled libopenjpeg && { check_lib libopenjpeg openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC || + require_pkg_config libopenjpeg libopenjpeg1 openjpeg.h opj_version -DOPJ_STATIC; } +enabled libopus && require_pkg_config libopus opus opus_multistream.h opus_multistream_decoder_create +enabled libpulse && require_pkg_config libpulse libpulse-simple pulse/simple.h pa_simple_new +enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket +enabled libschroedinger && require_pkg_config libschroedinger schroedinger-1.0 schroedinger/schro.h schro_init enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr && LIBSOXR="-lsoxr" -enabled libssh && require_pkg_config libssh libssh/sftp.h sftp_init -enabled libspeex && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex -enabled libtesseract && require_pkg_config tesseract tesseract/capi.h TessBaseAPICreate +enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init -lspeex enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg -enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame && - { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || - die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } -enabled libv4l2 && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl -enabled libvidstab && require_pkg_config "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit -enabled libvmaf && require_pkg_config libvmaf libvmaf.h compute_vmaf +enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame +enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc -enabled libvorbis && require_pkg_config vorbis vorbis/codec.h vorbis_info_init && - require_pkg_config vorbisenc vorbis/vorbisenc.h vorbis_encode_init - -enabled libvpx && { - enabled libvpx_vp8_decoder && { - use_pkg_config "vpx >= 0.9.1" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx || - check_lib libvpx_vp8_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx || - die "ERROR: libvpx decoder version must be >=0.9.1"; - } - enabled libvpx_vp8_encoder && { - use_pkg_config "vpx >= 0.9.7" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx || - check_lib libvpx_vp8_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx || - die "ERROR: libvpx encoder version must be >=0.9.7"; - } - enabled libvpx_vp9_decoder && { - use_pkg_config "vpx >= 1.3.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx || - check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx - } - enabled libvpx_vp9_encoder && { - use_pkg_config "vpx >= 1.3.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx || - check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx - } - if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then - die "libvpx enabled but no supported decoders found" - fi -} - +enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg +enabled libvpx && require_pkg_config libvpx "vpx >= 1.3.0" vpx/vpx_codec.h vpx_codec_version && + { enabled libvpx_vp8_decoder && + check_pkg_config libvpx_vp8_decoder vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx + enabled libvpx_vp8_encoder && + check_pkg_config libvpx_vp8_encoder vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx + enabled libvpx_vp9_decoder && + check_pkg_config libvpx_vp9_decoder vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx + enabled libvpx_vp9_encoder && + check_pkg_config libvpx_vp9_encoder vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx + disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder && + die "libvpx enabled but no supported decoders/encoders found" + } enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack -enabled libwebp && { - enabled libwebp_encoder && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion - enabled libwebp_anim_encoder && { use_pkg_config "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit || disable libwebp_anim_encoder; } } -enabled libx264 && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode || - { require libx264 "stdint.h x264.h" x264_encoder_encode -lx264 && - warn "using libx264 without pkg-config"; } } && - { check_cpp_condition x264.h "X264_BUILD >= 118" || - die "ERROR: libx264 must be installed and version must be >= 0.118."; } && +enabled libwebp && require_pkg_config libwebp libwebp webp/encode.h WebPGetEncoderVersion +enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode && + require_cpp_condition x264.h "X264_BUILD >= 118" && { check_cpp_condition x264.h "X264_MPEG2" && enable libx262; } -enabled libx265 && require_pkg_config x265 x265.h x265_api_get && - { check_cpp_condition x265.h "X265_BUILD >= 68" || - die "ERROR: libx265 version must be >= 68."; } +enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get && + require_cpp_condition x265.h "X265_BUILD >= 57" enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode -lxavs enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore -enabled libzimg && require_pkg_config "zimg >= 2.3.0" zimg.h zimg_get_api_version -enabled libzmq && require_pkg_config libzmq zmq.h zmq_ctx_new -enabled libzvbi && require libzvbi libzvbi.h vbi_decoder_new -lzvbi && - { check_cpp_condition libzvbi.h "VBI_VERSION_MAJOR > 0 || VBI_VERSION_MINOR > 2 || VBI_VERSION_MINOR == 2 && VBI_VERSION_MICRO >= 28" || - enabled gpl || die "ERROR: libzvbi requires version 0.2.28 or --enable-gpl."; } -enabled libxml2 && require_pkg_config libxml-2.0 libxml2/libxml/xmlversion.h xmlCheckVersion -enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; } enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host || { ! enabled cross_compile && add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline && @@ -6002,105 +4840,42 @@ enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_co check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } || die "ERROR: mmal not found" && check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } -enabled openal && { { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do - check_lib openal 'AL/al.h' alGetError "${al_extralibs}" && break; done } || - die "ERROR: openal not found"; } && - { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" || - die "ERROR: openal must be installed and version must be 1.1 or compatible"; } -enabled opencl && { check_lib opencl OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL || - check_lib opencl CL/cl.h clEnqueueNDRangeKernel -lOpenCL || - die "ERROR: opencl not found"; } && - { check_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" || - check_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" || - die "ERROR: opencl must be installed and version must be 1.2 or compatible"; } -enabled opengl && { check_lib opengl GL/glx.h glXGetProcAddress "-lGL" || - check_lib opengl windows.h wglGetProcAddress "-lopengl32 -lgdi32" || - check_lib opengl OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" || - check_lib opengl ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" || - die "ERROR: opengl not found." - } +enabled omx && require_header OMX_Core.h enabled omx_rpi && { check_header OMX_Core.h || { ! enabled cross_compile && add_cflags -isystem/opt/vc/include/IL && check_header OMX_Core.h ; } || - die "ERROR: OpenMAX IL headers not found"; } -enabled omx && { check_header OMX_Core.h || die "ERROR: OpenMAX IL headers not found"; } -enabled openssl && { use_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl || - use_pkg_config openssl openssl/ssl.h SSL_library_init || + die "ERROR: OpenMAX IL headers not found"; } && enable omx +enabled openssl && { { check_pkg_config openssl openssl openssl/ssl.h OPENSSL_init_ssl || + check_pkg_config openssl openssl openssl/ssl.h SSL_library_init; } || check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto || check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 || check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || die "ERROR: openssl not found"; } -if enabled gcrypt; then - GCRYPT_CONFIG="${cross_prefix}libgcrypt-config" - if "${GCRYPT_CONFIG}" --version > /dev/null 2>&1; then - gcrypt_cflags=$("${GCRYPT_CONFIG}" --cflags) - gcrypt_extralibs=$("${GCRYPT_CONFIG}" --libs) - check_func_headers gcrypt.h gcry_mpi_new $gcrypt_cflags $gcrypt_extralibs || - die "ERROR: gcrypt not found" - add_cflags $gcrypt_cflags && add_extralibs $gcrypt_extralibs - else - require gcrypt gcrypt.h gcry_mpi_new -lgcrypt - fi +enabled gnutls && check_lib gmp gmp.h mpz_export -lgmp + +if enabled nvenc; then + require_header nvEncodeAPI.h + require_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 6" fi -if enabled sdl2; then - SDL2_CONFIG="${cross_prefix}sdl2-config" - if check_pkg_config sdl2 SDL_events.h SDL_PollEvent; then - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags && - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags && - check_func SDL_Init $sdl2_extralibs $sdl2_cflags || - disable sdl2 - elif "${SDL2_CONFIG}" --version > /dev/null 2>&1; then - sdl2_cflags=$("${SDL2_CONFIG}" --cflags) - sdl2_extralibs=$("${SDL2_CONFIG}" --libs) - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags && - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags && - check_func SDL_Init $sdl2_extralibs $sdl2_cflags || - disable sdl2 - else - disable sdl2 - fi - if test $target_os = "mingw32"; then - sdl2_extralibs="$sdl2_extralibs -mconsole" - fi -fi -enabled sdl2 && add_cflags $sdl2_cflags && add_extralibs $sdl2_extralibs - -if enabled decklink; then - case $target_os in - mingw32*|mingw64*|win32|win64) - decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32" - decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32" - ;; - esac +# SDL is "special" and adds some CFLAGS that should not pollute anything else. +if enabled avplay; then + CFLAGS_SAVE=$CFLAGS + check_pkg_config sdl "sdl >= 1.2.1 sdl < 1.3.0" SDL_events.h SDL_PollEvent && + sdl_cflags=$pkg_cflags + CFLAGS=$CFLAGS_SAVE fi -enabled securetransport && - check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" && - check_lib securetransport "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" || - disable securetransport - -enabled schannel && - check_func_headers "windows.h security.h" InitializeSecurityContext -DSECURITY_WIN32 -lsecur32 && - check_cpp_condition winerror.h "defined(SEC_I_CONTEXT_EXPIRED)" && - add_extralibs -lsecur32 || - disable schannel - -makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo -enabled makeinfo \ - && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \ - && enable makeinfo_html || disable makeinfo_html -disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html -perl -v > /dev/null 2>&1 && enable perl || disable perl -pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man -rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout +! disabled pod2man && check_cmd pod2man --help && enable pod2man || disable pod2man +! disabled texi2html && check_cmd texi2html -version && enable texi2html || disable texi2html check_header linux/fb.h check_header linux/videodev2.h -check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete +check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete + +check_header AVFoundation/AVFoundation.h check_header sys/videoio.h -check_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete check_lib user32 "windows.h winuser.h" GetShellWindow -luser32 check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32 @@ -6108,8 +4883,6 @@ check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32 # w32api 3.12 had it defined wrong check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines -check_type "dshow.h" IBaseFilter - # check for ioctl_meteor.h, ioctl_bt848.h and alternatives { check_header dev/bktr/ioctl_meteor.h && check_header dev/bktr/ioctl_bt848.h; } || @@ -6119,22 +4892,16 @@ check_type "dshow.h" IBaseFilter check_header dev/video/bktr/ioctl_bt848.h; } || check_header dev/ic/bt8xx.h -if check_struct sys/soundcard.h audio_buf_info bytes; then - enable_safe sys/soundcard.h -else - check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE < - audio_buf_info abc; -EOF -fi +check_header sys/soundcard.h check_header soundcard.h -enabled alsa && check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound +enabled_any alsa_indev alsa_outdev && + check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound -enabled jack && check_lib jack jack/jack.h jack_client_open -ljack && - check_func jack_port_get_latency_range -ljack +enabled libjack && + require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range -enabled sndio && check_lib sndio sndio.h sio_open -lsndio +enabled_any sndio_indev sndio_outdev && check_lib sndio sndio.h sio_open -lsndio if enabled libcdio; then check_lib libcdio "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio || @@ -6142,20 +4909,15 @@ if enabled libcdio; then die "ERROR: No usable libcdio/cdparanoia found" fi -enabled libxcb && check_pkg_config "xcb >= 1.4" xcb/xcb.h xcb_connect || disable libxcb - if enabled libxcb; then - - enabled libxcb_shm && check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || disable libxcb_shm - enabled libxcb_shape && check_pkg_config xcb-shape xcb/shape.h xcb_shape_get_rectangles || disable libxcb_shape - enabled libxcb_xfixes && check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image || disable libxcb_xfixes - - add_cflags $xcb_cflags $xcb_shm_cflags $xcb_xfixes_cflags $xcb_shape_cflags - add_extralibs $xcb_extralibs $xcb_shm_extralibs $xcb_xfixes_extralibs $xcb_shape_extralibs + require_pkg_config libxcb xcb xcb/xcb.h xcb_connect + require_pkg_config libxcb_shape xcb-shape xcb/shape.h xcb_shape_rectangles + disabled libxcb_shm || + check_pkg_config libxcb_shm xcb-shm xcb/shm.h xcb_shm_attach + disabled libxcb_xfixes || + check_pkg_config libxcb_xfixes xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image fi -check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs" - # d3d11va requires linking directly to dxgi and d3d11 if not building for # the desktop api partition check_cpp <= 1400" && add_cflags -Qansi-alias - # Some inline asm is not compilable in debug - if enabled debug; then - disable ebp_available - disable ebx_available - fi + # icl will pass the inline asm tests but inline asm is currently + # not supported (build will fail) + disable inline_asm fi # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2. check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable log2 @@ -6471,13 +5175,6 @@ elif enabled_any msvc icl; then __declspec($_restrict) void* foo(int); EOF fi - # the new SSA optimzer in VS2015 U3 is mis-optimizing some parts of the code - # Issue has been fixed in MSVC v19.00.24218. - check_cpp_condition windows.h "_MSC_FULL_VER >= 190024218" || - check_cflags -d2SSAOptimizer- - # enable utf-8 source processing on VS2015 U2 and newer - check_cpp_condition windows.h "_MSC_FULL_VER >= 190023918" && - add_cflags -utf-8 fi for pfx in "" host_; do @@ -6508,8 +5205,6 @@ case $target_os in ;; esac -enable frame_thread_encoder - enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; } check_deps $CONFIG_LIST \ @@ -6517,40 +5212,42 @@ check_deps $CONFIG_LIST \ $HAVE_LIST \ $ALL_COMPONENTS \ -enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non pthread threading without atomics not supported, try adding --enable-pthreads or --cpu=i486 or higher if you are on x86" - - -if test $target_os = "haiku"; then - disable memalign - disable posix_memalign -fi - -# add_dep lib dep -# -> enable ${lib}_deps_${dep} -# -> add $dep to ${lib}_deps only once -add_dep() { - lib=$1 - dep=$2 - enabled "${lib}_deps_${dep}" && return 0 - enable "${lib}_deps_${dep}" - prepend "${lib}_deps" $dep -} - -# merge deps lib components -# merge all ${component}_deps into ${lib}_deps and ${lib}_deps_* -merge_deps() { - lib=$1 - shift - for comp in $*; do - enabled $comp || continue - eval "dep=\"\$${comp}_deps\"" - for d in $dep; do - add_dep $lib $d - done +flatten_extralibs(){ + unset nested_entries + list_name=$1 + eval list=\$${1} + for entry in $list; do + entry_copy=$entry + resolve entry_copy + append nested_entries $(filter '*_extralibs' $entry_copy) + flat_entries=$(filter_out '*_extralibs' $entry_copy) + eval $entry="\$flat_entries" done + append $list_name "$nested_entries" + + resolve nested_entries + if test -n "$(filter '*_extralibs' $nested_entries)"; then + flatten_extralibs $list_name + fi } -merge_deps libavfilter $FILTER_LIST +for linkunit in $LIBRARY_LIST; do + unset current_extralibs + eval components=\$$(toupper ${linkunit})_COMPONENTS_LIST + for comp in ${components}; do + enabled $comp || continue + comp_extralibs="${comp}_extralibs" + append current_extralibs $comp_extralibs + done + eval prepend ${linkunit}_extralibs $current_extralibs +done + +for linkunit in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do + flatten_extralibs ${linkunit}_extralibs + unique ${linkunit}_extralibs + resolve ${linkunit}_extralibs + eval ${linkunit}_extralibs=\$\(\$ldflags_filter \$${linkunit}_extralibs\) +done map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST @@ -6578,49 +5275,15 @@ if disabled stdatomic_h; then fi fi -# Check if requested libraries were found. -for lib in $AUTODETECT_LIBS; do - requested $lib && ! enabled $lib && die "ERROR: $lib requested but not found"; -done - enabled zlib && add_cppflags -DZLIB_CONST # conditional library dependencies, in linking order -enabled afftfilt_filter && prepend avfilter_deps "avcodec" -enabled afir_filter && prepend avfilter_deps "avcodec" -enabled amovie_filter && prepend avfilter_deps "avformat avcodec" -enabled aresample_filter && prepend avfilter_deps "swresample" -enabled atempo_filter && prepend avfilter_deps "avcodec" -enabled cover_rect_filter && prepend avfilter_deps "avformat avcodec" -enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" -enabled elbg_filter && prepend avfilter_deps "avcodec" -enabled fftfilt_filter && prepend avfilter_deps "avcodec" -enabled find_rect_filter && prepend avfilter_deps "avformat avcodec" -enabled firequalizer_filter && prepend avfilter_deps "avcodec" -enabled mcdeint_filter && prepend avfilter_deps "avcodec" enabled movie_filter && prepend avfilter_deps "avformat avcodec" -enabled pan_filter && prepend avfilter_deps "swresample" -enabled pp_filter && prepend avfilter_deps "postproc" -enabled removelogo_filter && prepend avfilter_deps "avformat avcodec swscale" -enabled resample_filter && prepend avfilter_deps "avresample" -enabled sab_filter && prepend avfilter_deps "swscale" +enabled_any asyncts_filter resample_filter && + prepend avfilter_deps "avresample" enabled scale_filter && prepend avfilter_deps "swscale" -enabled scale2ref_filter && prepend avfilter_deps "swscale" -enabled sofalizer_filter && prepend avfilter_deps "avcodec" -enabled showcqt_filter && prepend avfilter_deps "avformat avcodec swscale" -enabled showfreqs_filter && prepend avfilter_deps "avcodec" -enabled showspectrum_filter && prepend avfilter_deps "avcodec" -enabled signature_filter && prepend avfilter_deps "avcodec avformat" -enabled smartblur_filter && prepend avfilter_deps "swscale" -enabled spectrumsynth_filter && prepend avfilter_deps "avcodec" -enabled spp_filter && prepend avfilter_deps "avcodec" -enabled subtitles_filter && prepend avfilter_deps "avformat avcodec" -enabled uspp_filter && prepend avfilter_deps "avcodec" -enabled zoompan_filter && prepend avfilter_deps "swscale" -enabled lavfi_indev && prepend avdevice_deps "avfilter" - -enabled opus_decoder && prepend avcodec_deps "swresample" +enabled opus_decoder && prepend avcodec_deps "avresample" expand_deps(){ lib_deps=${1}_deps @@ -6629,22 +5292,8 @@ expand_deps(){ unique $lib_deps } -#we have to remove gpl from the deps here as some code assumes all lib deps are libs -postproc_deps="$(filter_out 'gpl' $postproc_deps)" - map 'expand_deps $v' $LIBRARY_LIST -license="LGPL version 2.1 or later" -if enabled nonfree; then - license="nonfree and unredistributable" -elif enabled gplv3; then - license="GPL version 3 or later" -elif enabled lgplv3; then - license="LGPL version 3 or later" -elif enabled gpl; then - license="GPL version 2 or later" -fi - if test "$quiet" != "yes"; then echo "install prefix $prefix" @@ -6656,12 +5305,6 @@ if test "$host_cc" != "$cc"; then echo "host C library $host_libc_type" fi echo "ARCH $arch ($cpu)" -if test "$build_suffix" != ""; then - echo "build suffix $build_suffix" -fi -if test "$progs_suffix" != ""; then - echo "progs suffix $progs_suffix" -fi if test "$extra_version" != ""; then echo "version string suffix $extra_version" fi @@ -6676,9 +5319,7 @@ if enabled x86; then echo "3DNow! extended enabled ${amd3dnowext-no}" echo "SSE enabled ${sse-no}" echo "SSSE3 enabled ${ssse3-no}" - echo "AESNI enabled ${aesni-no}" echo "AVX enabled ${avx-no}" - echo "AVX2 enabled ${avx2-no}" echo "XOP enabled ${xop-no}" echo "FMA3 enabled ${fma3-no}" echo "FMA4 enabled ${fma4-no}" @@ -6697,14 +5338,6 @@ if enabled arm; then echo "ARMv6T2 enabled ${armv6t2-no}" echo "VFP enabled ${vfp-no}" echo "NEON enabled ${neon-no}" - echo "THUMB enabled ${thumb-no}" -fi -if enabled mips; then - echo "MIPS FPU enabled ${mipsfpu-no}" - echo "MIPS DSP R1 enabled ${mipsdsp-no}" - echo "MIPS DSP R2 enabled ${mipsdspr2-no}" - echo "MIPS MSA enabled ${msa-no}" - echo "LOONGSON MMI enabled ${mmi-no}" fi if enabled ppc; then echo "AltiVec enabled ${altivec-no}" @@ -6714,54 +5347,57 @@ if enabled ppc; then echo "dcbzl available ${dcbzl-no}" fi echo "debug symbols ${debug-no}" -echo "strip symbols ${stripping-no}" echo "optimize for size ${small-no}" echo "optimizations ${optimizations-no}" echo "static ${static-no}" echo "shared ${shared-no}" -echo "postprocessing support ${postproc-no}" echo "network support ${network-no}" echo "threading support ${thread_type-no}" echo "safe bitstream reader ${safe_bitstream_reader-no}" -echo "texi2html enabled ${texi2html-no}" -echo "perl enabled ${perl-no}" -echo "pod2man enabled ${pod2man-no}" -echo "makeinfo enabled ${makeinfo-no}" -echo "makeinfo supports HTML ${makeinfo_html-no}" test -n "$random_seed" && echo "random seed ${random_seed}" echo echo "External libraries:" -print_enabled '' $EXTERNAL_LIBRARY_LIST | print_in_columns +print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns echo - echo "External libraries providing hardware acceleration:" -print_enabled '' $HWACCEL_LIBRARY_LIST | print_in_columns +print_enabled '' $HWACCEL_LIBRARY_LIST | print_3_columns echo echo "Libraries:" -print_enabled '' $LIBRARY_LIST | print_in_columns +print_enabled '' $LIBRARY_LIST | print_3_columns echo echo "Programs:" -print_enabled '' $PROGRAM_LIST | print_in_columns +print_enabled '' $PROGRAM_LIST | print_3_columns echo for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do echo "Enabled ${type}s:" eval list=\$$(toupper $type)_LIST - print_enabled '_*' $list | print_in_columns + print_enabled '_*' $list | print_3_columns echo done if test -n "$ignore_tests"; then ignore_tests=$(echo $ignore_tests | tr ',' ' ') echo "Ignored FATE tests:" - echo $ignore_tests | print_in_columns + echo $ignore_tests | print_3_columns echo fi +license="LGPL version 2.1 or later" +if enabled nonfree; then + license="nonfree and unredistributable" +elif enabled gplv3; then + license="GPL version 3 or later" +elif enabled lgplv3; then + license="LGPL version 3 or later" +elif enabled gpl; then + license="GPL version 2 or later" +fi + echo "License: $license" echo "Creating configuration files ..." @@ -6770,15 +5406,11 @@ fi # test "$quiet" != "yes" test -e Makefile || echo "include $source_path/Makefile" > Makefile -enabled stripping || strip="echo skipping strip" +config_files="$TMPH avbuild/config.mak" -config_files="$TMPH ffbuild/config.mak doc/config.texi" - -cat > ffbuild/config.mak < avbuild/config.mak <> ffbuild/config.mak' $LIBRARY_LIST +map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> avbuild/config.mak' $LIBRARY_LIST -print_program_extralibs(){ - eval "program_extralibs=\$${1}_extralibs" - eval echo "EXTRALIBS-${1}=${program_extralibs}" >> ffbuild/config.mak -} - -map 'print_program_extralibs $v' $PROGRAM_LIST +for entry in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do + eval echo "EXTRALIBS-${entry}=\$${entry}_extralibs" >> avbuild/config.mak +done cat > $TMPH <>$TMPH - test -n "$malloc_prefix" && echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH @@ -6952,24 +5550,17 @@ fi enabled getenv || echo "#define getenv(x) NULL" >> $TMPH - -mkdir -p doc -mkdir -p tests -mkdir -p tests/api -echo "@c auto-generated by configure - do not modify! " > doc/config.texi - print_config ARCH_ "$config_files" $ARCH_LIST print_config HAVE_ "$config_files" $HAVE_LIST print_config CONFIG_ "$config_files" $CONFIG_LIST \ $CONFIG_EXTRA \ $ALL_COMPONENTS \ -echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH -echo "endif # FFMPEG_CONFIG_MAK" >> ffbuild/config.mak +echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH # Do not overwrite an unchanged config.h to avoid superfluous rebuilds. cp_if_changed $TMPH config.h -touch ffbuild/.config +touch avbuild/.config enabled x86asm && cp_if_changed $TMPASM config.asm @@ -6991,7 +5582,7 @@ print_enabled_components(){ struct_name=$2 name=$3 shift 3 - echo "static const $struct_name *$name[] = {" > $TMPH + echo "static const $struct_name * const $name[] = {" > $TMPH for c in $*; do enabled $c && printf " &ff_%s,\n" $c >> $TMPH done @@ -7002,37 +5593,29 @@ print_enabled_components(){ print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST -if test -n "$WARNINGS"; then - printf "\n%s%s$WARNINGS%s" "$warn_color" "$bold_color" "$reset_color" - enabled fatal_warnings && exit 1 -fi +test -n "$WARNINGS" && printf "\n$WARNINGS" # Settings for pkg-config files -cat > ffbuild/config.sh < avbuild/config.sh <> ffbuild/config.sh + echo ${lib}_deps=\"$lib_deps\" >> avbuild/config.sh done diff --git a/doc/.gitignore b/doc/.gitignore index 7628cecb99..b05724125a 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -1,9 +1,6 @@ /*.1 -/*.3 /*.html /*.pod -/config.texi /avoptions_codec.texi /avoptions_format.texi -/fate.txt /print_options diff --git a/doc/APIchanges b/doc/APIchanges index cc67cbf6f8..ed90be890d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -1,715 +1,414 @@ Never assume the API of libav* to be stable unless at least 1 month has passed -since the last major version increase or the API was added. +since the last major version increase. The last version increases were: -libavcodec: 2015-08-28 -libavdevice: 2015-08-28 -libavfilter: 2015-08-28 -libavformat: 2015-08-28 -libavresample: 2015-08-28 -libpostproc: 2015-08-28 -libswresample: 2015-08-28 -libswscale: 2015-08-28 -libavutil: 2015-08-28 +libavcodec: 2017-03-23 +libavdevice: 2017-03-23 +libavfilter: 2017-03-23 +libavformat: 2017-03-23 +libavresample: 2017-03-23 +libswscale: 2017-03-23 +libavutil: 2017-03-23 API changes, most recent first: -2017-09-08 - xxxxxxx - lavfi 6.103.100 - buffersrc.h - Add av_buffersrc_close(). - -2017-09-04 - xxxxxxx - lavc 57.105.100 - avcodec.h - Add AV_HWACCEL_CODEC_CAP_EXPERIMENTAL, replacing the deprecated - HWACCEL_CODEC_CAP_EXPERIMENTAL flag. - -2017-09-01 - xxxxxxx - lavf 57.81.100 - avio.h +2016-xx-xx - xxxxxxx - lavf 58.1.0 - avio.h Add avio_read_partial(). -2017-09-01 - xxxxxxx - lavf 57.80.100 / 57.11.0 - avio.h - Add avio_context_free(). From now on it must be used for freeing AVIOContext. - -2017-08-08 - xxxxxxx - lavu 55.74.100 - pixdesc.h - Add AV_PIX_FMT_FLAG_FLOAT pixel format flag. - -2017-08-08 - xxxxxxx - lavu 55.72.100 - imgutils.h +2017-xx-xx - xxxxxxx - lavu 56.4.0 - imgutils.h Add av_image_fill_black(). -2017-08-08 - xxxxxxx - lavu 55.71.100 - frame.h +2017-xx-xx - xxxxxxx - lavu 56.3.0 - frame.h Add av_frame_apply_cropping(). -2017-07-25 - 24de4fddca - lavu 55.69.100 - frame.h - Add AV_FRAME_DATA_ICC_PROFILE side data type. - -2017-xx-xx - xxxxxxx - lavc 57.100.100 - avcodec.h +2017-xx-xx - xxxxxxx - lavc 58.4.0 - avcodec.h DXVA2 and D3D11 hardware accelerated decoding now supports the new hwaccel API, which can create the decoder context and allocate hardware frame automatically. See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx. For D3D11, the new AV_PIX_FMT_D3D11 pixfmt must be used with the new API. -2017-xx-xx - xxxxxxx - lavu 56.67.100 - hwcontext.h +2017-xx-xx - xxxxxxx - lavu 56.2.0 - hwcontext.h Add AV_HWDEVICE_TYPE_D3D11VA and AV_PIX_FMT_D3D11. -2017-06-24 - xxxxxxx - lavf 57.75.100 - avio.h - Add AVIO_DATA_MARKER_FLUSH_POINT to signal preferred flush points to aviobuf. - -2017-06-14 - xxxxxxx - lavu 55.66.100 - hwcontext.h +2017-04-30 - xxxxxxx - lavu 56.1.1 - hwcontext.h av_hwframe_ctx_create_derived() now takes some AV_HWFRAME_MAP_* combination as its flags argument (which was previously unused). -2017-06-14 - xxxxxxx - lavc 57.99.100 - avcodec.h +2017-04-xx - xxxxxxx - lavu 56.1.0 - spherical.h + Add av_spherical_projection_name() and av_spherical_from_name(). + +2017-04-26 - xxxxxxx - lavc 58.3.1 - avcodec.h Add AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH. -2017-06-14 - xxxxxxx - lavu 55.65.100 - hwcontext.h - Add AV_HWDEVICE_TYPE_NONE, av_hwdevice_find_type_by_name(), - av_hwdevice_get_type_name() and av_hwdevice_iterate_types(). - -2017-06-14 - xxxxxxx - lavu 55.64.100 - hwcontext.h - Add av_hwdevice_ctx_create_derived(). - -2017-05-15 - xxxxxxxxxx - lavc 57.96.100 - avcodec.h - VideoToolbox hardware-accelerated decoding now supports the new hwaccel API, - which can create the decoder context and allocate hardware frames automatically. - See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx. - -2017-05-15 - xxxxxxxxxx - lavu 57.63.100 - hwcontext.h - Add AV_HWDEVICE_TYPE_VIDEOTOOLBOX and implementation. - -2017-xx-xx - xxxxxxx - lavc 57.95.100 / 57.31.0 - avcodec.h - Add AVCodecContext.apply_cropping to control whether cropping - is handled by libavcodec or the caller. - -2017-xx-xx - xxxxxxx - lavu 55.62.100 / 55.30.0 - frame.h - Add AVFrame.crop_left/right/top/bottom fields for attaching cropping - information to video frames. - -2017-xx-xx - xxxxxxxxxx - Change av_sha_update(), av_sha512_update() and av_md5_sum()/av_md5_update() length - parameter type to size_t at next major bump. - -2017-05-05 - xxxxxxxxxx - lavc 57.94.100 - avcodec.h - The cuvid decoders now support AVCodecContext.hw_device_ctx, which removes - the requirement to set an incomplete AVCodecContext.hw_frames_ctx only to - set the Cuda device handle. - -2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h - Add av_strireplace(). - -2016-04-06 - 157e57a181 - lavc 57.92.100 - avcodec.h - Add AV_PKT_DATA_CONTENT_LIGHT_LEVEL packet side data. - -2016-04-06 - b378f5bd64 - lavu 55.60.100 - mastering_display_metadata.h - Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, av_content_light_metadata_alloc() - and av_content_light_metadata_create_side_data() API, and AVContentLightMetadata - type to export content light level video properties. - -2017-03-31 - 9033e8723c - lavu 55.57.100 - spherical.h - Add av_spherical_projection_name(). - Add av_spherical_from_name(). - -2017-03-30 - 4cda23f1f1 - lavu 55.53.100 / 55.27.0 - hwcontext.h - Add av_hwframe_map() and associated AV_HWFRAME_MAP_* flags. - Add av_hwframe_ctx_create_derived(). - -2017-03-29 - bfdcdd6d82 - lavu 55.52.100 - avutil.h - add av_fourcc_make_string() function and av_fourcc2str() macro to replace - av_get_codec_tag_string() from lavc. - -2017-03-27 - ddef3d902f - lavf 57.68.100 - avformat.h - Deprecate that demuxers export the stream rotation angle in AVStream.metadata - (via an entry named "rotate"). Use av_stream_get_side_data() with - AV_PKT_DATA_DISPLAYMATRIX instead, and read the rotation angle with - av_display_rotation_get(). The same is done for muxing. Instead of adding a - "rotate" entry to AVStream.metadata, AV_PKT_DATA_DISPLAYMATRIX side data has - to be added to the AVStream. - -2017-03-23 - 7e4ba776a2 - lavc 57.85.101 - avcodec.h - vdpau hardware accelerated decoding now supports the new hwaccel API, which - can create the decoder context and allocate hardware frame automatically. - See AVCodecContext.hw_device_ctx and AVCodecContext.hw_frames_ctx. - -2017-03-23 - 156bd8278f - lavc 57.85.100 - avcodec.h +2017-03-xx - xxxxxxx - lavc 57.37.0 - 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-xx - xxxxxxx - lavu 55.35.0 - hwcontext.h + Add AV_HWDEVICE_TYPE_NONE, av_hwdevice_find_type_by_name(), + av_hwdevice_get_type_name() and av_hwdevice_iterate_types(). -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(). +2017-03-xx - xxxxxxx - lavu 55.34.0 - hwcontext.h + Add av_hwdevice_ctx_create_derived(). -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 +2017-02-10 - xxxxxxx - lavu 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 +2017-xx-xx - xxxxxxx - lavc 57.34.0 - avcodec.h Add AVCodecContext.hw_device_ctx. -2017-02-11 - e3af49b14b - lavu 55.47.100 - frame.h +2017-02-11 - xxxxxxx - lavu 55.32.0 - 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-02-xx - xxxxxxx - lavu 55.31.1 - frame.h + Allow passing the value of 0 (meaning "automatic") as the required alignment + to av_frame_get_buffer(). -2017-01-24 - c4618f842a - lavu 55.45.100 - channel_layout.h - Add av_get_extended_channel_layout() +2017-02-xx - xxxxxxx - lavu 55.31.0 - cpu.h + Add av_cpu_max_align() for querying maximum required data alignment. -2017-01-22 - 76c5a69e26 - lavu 55.44.100 - lfg.h - Add av_lfg_init_from_data(). +2016-xx-xx - xxxxxxx - lavf 57.11.0 - avio.h + Add avio_context_free(). From now on it must be used for freeing AVIOContext. -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-02-01 - xxxxxxx - lavc - avcodec.h + Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated + API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs + (avcodec_send_packet/avcodec_receive_frame) always work with reference + counted frames. -2017-01-12 - dbe9dbed31 - lavfi 6.69.100 - buffersink.h - Add av_buffersink_get_*() functions. +2016-xx-xx - xxxxxxx - lavc 57.31.0 - avcodec.h + Add AVCodecContext.apply_cropping to control whether cropping + is handled by libavcodec or the caller. -2017-01-06 - 9488032e10 - lavf 57.62.100 - avio.h - Add avio_get_dyn_buf() +2016-xx-xx - xxxxxxx - lavu 55.30.0 - frame.h + Add AVFrame.crop_left/right/top/bottom fields for attaching cropping + information to video frames. -2016-12-10 - f542b152aa - lavu 55.43.100 - imgutils.h - Add av_image_check_size2() +2016-xx-xx - xxxxxxx + Change av_sha_update() and av_md5_sum()/av_md5_update() length + parameter type to size_t at next major bump. -2016-12-07 - e7a6f8c972 - lavc 57.67.100 / 57.29.0 - avcodec.h +2016-xx-xx - xxxxxxx - lavc 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 +2016-xx-xx - xxxxxxx - lavu 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 +2016-xx-xx - xxxxxxx - lavf 57.10.0 - avformat.h Add av_stream_add_side_data(). -2016-11-13 - 775a8477b7 - lavu 55.39.100 - hwcontext_vaapi.h +2016-xx-xx - xxxxxxx - lavu 55.28.0 - pixfmt.h + Add AV_PIX_FMT_GRAY12(LE/BE). + +2016-xx-xx - xxxxxxx - lavu 55.27.0 - hwcontext.h + Add av_hwframe_map() and associated AV_HWFRAME_MAP_* flags. + Add av_hwframe_ctx_create_derived(). + +2016-xx-xx - xxxxxxx - lavu 55.25.0 - pixfmt.h + Add AV_PIX_FMT_GBRAP12(LE/BE). + +2016-xx-xx - xxxxxxx - lavu 55.24.0 - pixfmt.h + Add AV_PIX_FMT_GBRP12(LE/BE). + +2016-xx-xx - xxxxxxx - lavu 55.23.0 - hwcontext_vaapi.h Add AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE. -2016-11-13 - a8d51bb424 - lavu 55.38.100 - hwcontext_vaapi.h +2016-xx-xx - xxxxxxx - lavf 57.08.0 - avio.h + Add AVIO_SEEKABLE_TIME flag. + +2016-xx-xx - xxxxxxx - lavu 55.22.0 - pixfmt.h + Add AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, and AV_PIX_FMT_YUV444P12. + +2016-xx-xx - xxxxxxx - lavc 57.27.0 - avcodec.h + Add FF_PROFILE_HEVC_REXT, the extended pixel format profile for HEVC. + +2016-08-24 - xxxxxxx - lavu 55.21.0 - imgutils.h + Add av_image_copy_uc_from(), a version of av_image_copy() for copying + from GPU mapped memory. + +2016-xx-xx - xxxxxxx - lavc 59.26.0 - vaapi.h + Deprecate struct vaapi_context and the vaapi.h installed header. + Callers should set AVCodecContext.hw_frames_ctx instead. + +------------------------------8<------------------------------------- + 12 branch was cut here +----------------------------->8-------------------------------------- + +2016-07-20 - xxxxxxx - lavu 55.20.0 - cpu.h + Add AV_CPU_FLAG_SSSE3SLOW. + +2016-07-02 - 4926fa9 - lavu 55.19.0 - 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). +2016-07-02 - b7c5f88 - lavu 55.18.0 - pixfmt.h + Add AV_PIX_FMT_P010(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 +2016-06-21 - 32c8359 - lavc 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 +2016-06-21 - 59e7361 - lavu 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 +2016-06-21 - e85f6f7 - lavc 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 +2016-06-12 - 90f469a - lavc 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 +2016-05-26 - 1c9e861 - lavu 55.13.0 - hwcontext.h Add av_hwdevice_ctx_create(). -2016-06-26 - b95534b / e47b8bb - lavc 57.48.101 / 57.19.1 - avcodec.h +2016-05-24 - ad61da05 - lavc 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 +2016-05-18 - db7968b - lavf 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 +2016-05-17 - 0c4468d - lavu 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 +2016-05-17 - c46db38 - lavu 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-03-24 - 564b459 - lavu 55.10.0 - opt.h + Add av_opt_copy(). -2016-04-21 - 7fc329e - lavc 57.37.100 - avcodec.h +2016-03-23 - 05f6670 - lavc 57.16.0 - 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 +2016-03-20 - 33d1898 - lavc 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 +2016-03-19 - 07a844f - lavfi 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 +2016-03-19 - 551c677 - lavu 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 +2016-03-19 - d264c72 - lavu 55.8.0 - pixfmt.h + Deprecate all AV_PIX_FMT_VAAPI_* formats. + Replaced by AV_PIX_FMT_VAAPI. + +2016-03-19 - b1f01e8 - lavu 55.7.0 - hwcontext.h Add AVHWFramesConstraints and associated API. -2016-04-11 - 6f69f7a / 9200514 - lavf 57.33.100 / 57.5.0 - avformat.h +2016-02-23 - 9200514 - lavf 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-02-23 - lavc 57.14.0 - avcodec.h + 998e1b8 - Add AVCodecParameters and its related API. + a806834 - Add av_get_audio_frame_duration2(). -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-02-22 - ec4c483 - lavf 57.4.0 - avformat.h + Add AVFormatContext.protocol_whitelist and protocol_blacklist. + Add 'protocol_whitelist' and 'protocol_blacklist' private options for + avio_open2(). -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 +2016-02-14 - 7b3214d0 - lavc 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-14 - lavfi 6.2.0 - avfilter.h + b3dd30d 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 +2016-02-14 - lavu 55.6.0 + 721a4ef buffer.h - Add av_buffer_pool_init2(). + 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 + 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 + 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. + 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 +2016-01-24 - 9f61abc - lavf 57.3.0 - avformat.h Add AVFormatContext.opaque, io_open and io_close, allowing custom IO + for muxers and demuxers that open additional files. -2016-02-01 - 1dba837 - lavf 57.24.100 - avformat.h, avio.h - Add protocol_whitelist to AVFormatContext, AVIOContext - -2016-01-31 - 66e9d2f - lavu 55.17.100 - frame.h - Add AV_FRAME_DATA_GOP_TIMECODE for exporting MPEG1/2 GOP timecodes. - -2016-01-01 - 5e8b053 / 2c68113 - lavc 57.21.100 / 57.12.0 - avcodec.h +2015-12-12 - 2c68113 - lavc 57.12.0 - avcodec.h Add AVCodecDescriptor.profiles and avcodec_profile_name(). -2015-12-28 - 1f9139b - lavf 57.21.100 - avformat.h - Add automatic bitstream filtering; add av_apply_bitstream_filters() - -2015-12-22 - 39a09e9 - lavfi 6.21.101 - avfilter.h - Deprecate avfilter_link_set_closed(). - Applications are not supposed to mess with links, - they should close the sinks. - -2015-12-17 - lavc 57.18.100 / 57.11.0 - avcodec.h dirac.h - xxxxxxx - Add av_packet_add_side_data(). - xxxxxxx - Add AVCodecContext.coded_side_data. - xxxxxxx - Add AVCPBProperties API. - xxxxxxx - Add a new public header dirac.h containing +2015-12-06 - lavc 57.11.0 - avcodec.h dirac.h + 31c51f7 - Add av_packet_add_side_data(). + 84adab3 - Add AVCodecContext.coded_side_data. + f0b769c - Add AVCPBProperties API. + e02de9d - Add a new public header dirac.h containing av_dirac_parse_sequence_header() -2015-12-11 - 676a93f - lavf 57.20.100 - avformat.h - Add av_program_add_stream_index() - -2015-11-29 - 93fb4a4 - lavc 57.16.101 - avcodec.h +2015-11-20 - 462a54e - lavc 57.9.1 - avcodec.h Deprecate rtp_callback without replacement, i.e. it won't be possible to get image slices before the full frame is encoded any more. The libavformat rtpenc muxer can still be used for RFC-2190 packetization. -2015-11-22 - fe20e34 - lavc 57.16.100 - avcodec.h +2015-11-18 - 79ae1e6 - lavc 57.9.0 - avcodec.h Add AV_PKT_DATA_FALLBACK_TRACK for making fallback associations between streams. -2015-11-22 - ad317c9 - lavf 57.19.100 - avformat.h +2015-11-18 - 7f4ec43 - lavf 57.1.0 - avformat.h Add av_stream_new_side_data(). -2015-11-22 - e12f403 - lavu 55.8.100 - xtea.h +2015-11-13 - 92d107a - lavu 55.3.0 - xtea.h Add av_xtea_le_init and av_xtea_le_crypt -2015-11-18 - lavu 55.7.100 - mem.h - Add av_fast_mallocz() +2015-11-09 - 48ff668 - lavfi 6.1.0 - avfilter.h + Add a frame_rate field to AVFilterLink -2015-10-29 - lavc 57.12.100 / 57.8.0 - avcodec.h - xxxxxx - Deprecate av_free_packet(). Use av_packet_unref() as replacement, - it resets the packet in a more consistent way. - xxxxxx - Deprecate av_dup_packet(), it is a no-op for most cases. - Use av_packet_ref() to make a non-refcounted AVPacket refcounted. - xxxxxx - Add av_packet_alloc(), av_packet_clone(), av_packet_free(). - They match the AVFrame functions with the same name. +2015-10-26 - lavc 57.7.0 - avcodec.h + ce70f28 - Deprecate av_free_packet(). Use av_packet_unref() as replacement, + it resets the packet in a more consistent way. + 9b56d5c - Deprecate av_dup_packet(), it is a no-op for most cases. + Use av_packet_ref() to make a non-refcounted AVPacket refcounted. + a9a6010 - Add av_packet_alloc(), av_packet_clone(), av_packet_free(). + They match the AVFrame functions with the same name. -2015-10-27 - 1e477a9 - lavu 55.5.100 - cpu.h - Add AV_CPU_FLAG_AESNI. - -2015-10-22 - ee573b4 / a17a766 - lavc 57.9.100 / 57.5.0 - avcodec.h +2015-10-21 - a17a766 - lavc 57.5.0 - avcodec.h Add data and linesize array to AVSubtitleRect, to be used instead of the ones from the embedded AVPicture. -2015-10-22 - 866a417 / dc923bc - lavc 57.8.100 / 57.0.0 - qsv.h +2015-10-16 - dc923bc - lavc 57.0.0 - qsv.h Add an API for allocating opaque surfaces. -2015-10-15 - 2c2d162 - lavf 57.4.100 - Remove the latm demuxer that was a duplicate of the loas demuxer. - -2015-10-14 - b994788 / 11c5f43 - lavu 55.4.100 / 55.2.0 - dict.h +2015-10-12 - 11c5f43 - lavu 55.2.0 - dict.h Change return type of av_dict_copy() from void to int, so that a proper error code can be reported. -2015-09-29 - b01891a / 948f3c1 - lavc 57.3.100 / 57.2.0 - avcodec.h +2015-09-29 - 948f3c1 - lavc 57.0.0 - avcodec.h Change type of AVPacket.duration from int to int64_t. -2015-09-17 - 7c46f24 / e3d4784 - lavc 57.3.100 / 57.2.0 - d3d11va.h +2015-09-18 - e3d4784 - lavc 57.2.0 - d3d11va.h Add av_d3d11va_alloc_context(). This function must from now on be used for allocating AVD3D11VAContext. -2015-09-15 - lavf 57.2.100 - avformat.h - probesize and max_analyze_duration switched to 64bit, both - are only accessible through AVOptions - -2015-09-15 - lavf 57.1.100 - avformat.h - bit_rate was changed to 64bit, make sure you update any - printf() or other type sensitive code - -2015-09-15 - lavc 57.2.100 - avcodec.h - bit_rate/rc_max_rate/rc_min_rate were changed to 64bit, make sure you update - any printf() or other type sensitive code - -2015-09-07 - lavu 55.0.100 / 55.0.0 - c734b34 / b8b5d82 - Change type of AVPixFmtDescriptor.flags from uint8_t to uint64_t. - f53569a / 6b3ef7f - Change type of AVComponentDescriptor fields from uint16_t to int +2015-09-07 - lavu 55.0.0 + b8b5d82 - Change type of AVPixFmtDescriptor.flags from uint8_t to uint64_t. + 6b3ef7f - Change type of AVComponentDescriptor fields from uint16_t to int and drop bit packing. - 151aa2e / 2268db2 - Add step, offset, and depth to AVComponentDescriptor to replace + 2268db2 - Add step, offset, and depth to AVComponentDescriptor to replace the deprecated step_minus1, offset_plus1, and depth_minus1. --------- 8< --------- FFmpeg 2.8 was cut here -------- 8< --------- +2015-07-31 - lavu 54.17.0 + 7a7df34 - Add av_blowfish_alloc(). + ae36545 - Add av_rc4_alloc(). + 5d8bea3 - Add av_xtea_alloc(). + d9e8b47 - Add av_des_alloc(). -2015-08-27 - 1dd854e1 - lavc 56.58.100 - vaapi.h - Deprecate old VA-API context (vaapi_context) fields that were only - set and used by libavcodec. They are all managed internally now. +2015-07-29 - 7e38340 - lavu 54.16.0 - hmac.h + Add AV_HMAC_SHA224 and AV_HMAC_SHA256. -2015-08-19 - 9f8e57ef - lavu 54.31.100 - pixfmt.h - Add a unique pixel format for VA-API (AV_PIX_FMT_VAAPI) that - indicates the nature of the underlying storage: a VA surface. This - yields the same value as AV_PIX_FMT_VAAPI_VLD. - Deprecate old VA-API related pixel formats: AV_PIX_FMT_VAAPI_MOCO, - AV_PIX_FMT_VAAPI_IDCT, AV_PIX_FMT_VAAPI_VLD. +2015-07-27 - lavc 56.35.0 - avcodec.h + 7c6eb0a - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*. + def9785 - Rename CODEC_CAP_* defines to AV_CODEC_CAP_*. + 059a934 - Rename FF_INPUT_BUFFER_PADDING_SIZE and FF_MIN_BUFFER_SIZE + to AV_INPUT_BUFFER_PADDING_SIZE and AV_INPUT_BUFFER_MIN_SIZE. -2015-08-02 - lavu 54.30.100 / 54.17.0 - 9ed59f1 / 7a7df34c - Add av_blowfish_alloc(). - a130ec9 / ae365453 - Add av_rc4_alloc(). - 9ca1997 / 5d8bea3b - Add av_xtea_alloc(). - 3cf08e9 / d9e8b47e - Add av_des_alloc(). +2015-07-20 - 5d3addb - lavc 56.33.0 - avcodec.h + Add AV_PKT_DATA_QUALITY_FACTOR to export the quality value of an AVPacket. -2015-07-27 - lavc 56.56.100 / 56.35.0 - avcodec.h - 94d68a4 / 7c6eb0a1 - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*. - 444e987 / def97856 - Rename CODEC_CAP_* defines to AV_CODEC_CAP_*. - 29d147c / 059a9348 - Rename FF_INPUT_BUFFER_PADDING_SIZE and FF_MIN_BUFFER_SIZE - to AV_INPUT_BUFFER_PADDING_SIZE and AV_INPUT_BUFFER_MIN_SIZE. - -2015-07-22 - c40ecff - lavc 56.51.100 - avcodec.h - Add AV_PKT_DATA_QUALITY_STATS to export the quality value, PSNR, and pict_type - of an AVPacket. - -2015-07-16 - 8dad213 - lavc 56.49.100 - Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS - and FF_CODEC_PROPERTY_CLOSED_CAPTIONS - -2015-07-03 - d563e13 / 83212943 - lavu 54.28.100 / 56.15.0 +2015-07-02 - 1316df7 - lavu 56.15.0 Add av_version_info(). --------- 8< --------- FFmpeg 2.7 was cut here -------- 8< --------- +2015-07-01 - 0d449c8 - lavfi 5.1.0 - version.h + 0f87f9b - lavd 55.2.0 - version.h + Add library identification symbols, LIBAVFILTER_IDENT and LIBAVDEVICE_IDENT. -2015-06-04 - cc17b43 - lswr 1.2.100 - Add swr_get_out_samples() +2015-06-07 - 252d620 - lavf 56.20.0 - avio.h + Add avio_put_str16be. -2015-05-27 - c312bfa - lavu 54.26.100 - cpu.h +2015-05-13 - f7cafb5 - lavu 54.14.0 - cpu.h Add AV_CPU_FLAG_AVXSLOW. -2015-05-26 - 1fb9b2a - lavu 54.25.100 - rational.h - Add av_q2intfloat(). - -2015-05-13 - cc48409 / e7c5e17 - lavc 56.39.100 / 56.23.0 +2015-05-13 - e7c5e17 - lavc 56.23.0 Add av_vda_default_init2. -2015-05-11 - 541d75f - lavf 56.33.100 - avformat.h - Add AVOpenCallback AVFormatContext.open_cb - -2015-05-07 - a7dd933 - 56.38.100 - avcodec.h - Add av_packet_side_data_name(). - -2015-05-07 - 01e59d4 - 56.37.102 - avcodec.h - Add FF_PROFILE_VP9_2 and FF_PROFILE_VP9_3. - -2015-05-04 - 079b7f6 - 56.37.100 - avcodec.h - Add FF_PROFILE_VP9_0 and FF_PROFILE_VP9_1. - -2015-04-22 - 748d481 - lavf 56.31.100 - avformat.h - Add AVFMT_FLAG_FAST_SEEK flag. Some formats (initially mp3) use it to enable - fast, but inaccurate seeking. - -2015-04-20 - 8e8219e / c253340 - lavu 54.23.100 / 54.12.0 - log.h +2015-04-19 - c253340 - lavu 54.12.0 Add AV_LOG_TRACE for extremely verbose debugging. -2015-04-02 - 26e0e393 - lavf 56.29.100 - avio.h - Add AVIODirEntryType.AVIO_ENTRY_SERVER. - Add AVIODirEntryType.AVIO_ENTRY_SHARE. - Add AVIODirEntryType.AVIO_ENTRY_WORKGROUP. +2015-04-07 - 27f2746 - lavu 54.11.0 + Add av_small_strptime(). -2015-03-31 - 3188696 - lavu 54.22.100 - avstring.h - Add av_append_path_component() - -2015-03-27 - 184084c - lavf 56.27.100 - avio.h url.h - New directory listing API. - - Add AVIODirEntryType enum. - Add AVIODirEntry, AVIODirContext structures. - Add avio_open_dir(), avio_read_dir(), avio_close_dir(), avio_free_directory_entry(). - Add ff_alloc_dir_entry(). - Extend URLProtocol with url_open_dir(), url_read_dir(), url_close_dir(). - -2015-03-29 - 268ff17 / c484561 - lavu 54.21.100 / 54.10.0 - pixfmt.h - Add AV_PIX_FMT_MMAL for MMAL hardware acceleration. - -2015-03-19 - 11fe56c - 56.29.100 / lavc 56.22.0 +2015-03-29 - 6fe2641 - lavc 56.22.0 Add FF_PROFILE_DTS_EXPRESS. --------- 8< --------- FFmpeg 2.6 was cut here -------- 8< --------- +2015-03-29 - c484561 - lavu 54.10.0 + Add AV_PIX_FMT_MMAL for MMAL hardware acceleration. -2015-03-04 - cca4476 - lavf 56.25.100 - Add avformat_flush() - -2015-03-03 - 81a9126 - lavf 56.24.100 - Add avio_put_str16be() - -2015-02-19 - 560eb71 / 31d2039 - lavc 56.23.100 / 56.13.0 +2015-02-19 - 31d2039 - lavc 56.13 Add width, height, coded_width, coded_height and format to AVCodecParserContext. -2015-02-19 - e375511 / 5b1d9ce - lavu 54.19.100 / 54.9.0 +2015-02-19 - 5b1d9ce - lavu 54.9.0 Add AV_PIX_FMT_QSV for QSV hardware acceleration. -2015-02-14 - ba22295 - lavc 56.21.102 - Deprecate VIMA decoder. - -2015-01-27 - 62a82c6 / 728685f - lavc 56.21.100 / 56.12.0, lavu 54.18.100 / 54.8.0 - avcodec.h, frame.h +2015-01-27 - 728685f - lavc 56.12.0, lavu 54.8.0 - avcodec.h, frame.h Add AV_PKT_DATA_AUDIO_SERVICE_TYPE and AV_FRAME_DATA_AUDIO_SERVICE_TYPE for storing the audio service type as side data. -2015-01-16 - a47c933 - lavf 56.19.100 - avformat.h - Add data_codec and data_codec_id for storing codec of data stream +2015-01-14 - e2ad0b6 - lavu 54.6.0 - imgutils.h + Add utility functions for image manipulation: av_image_get_buffer_size() + av_image_fill_arrays() and av_image_copy_to_buffer(). -2015-01-11 - 007c33d - lavd 56.4.100 - avdevice.h - Add avdevice_list_input_sources(). - Add avdevice_list_output_sinks(). - -2014-12-25 - d7aaeea / c220a60 - lavc 56.19.100 / 56.10.0 - vdpau.h +2014-12-25 - c220a60 - lavc 56.10.0 - vdpau.h Add av_vdpau_get_surface_parameters(). -2014-12-25 - ddb9a24 / 6c99c92 - lavc 56.18.100 / 56.9.0 - avcodec.h +2014-12-25 - 6c99c92 - lavc 56.9.0 - avcodec.h Add AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH flag to av_vdpau_bind_context(). -2014-12-25 - d16079a / 57b6704 - lavc 56.17.100 / 56.8.0 - avcodec.h +2014-12-25 - 57b6704 - lavc 56.8.0 - avcodec.h Add AVCodecContext.sw_pix_fmt. -2014-12-04 - 6e9ac02 - lavc 56.14.100 - dv_profile.h - Add av_dv_codec_profile2(). +2014-11-07 - 1384df6 - lavf 56.06.3 - avformat.h + Add AVFormatContext.avoid_negative_ts. --------- 8< --------- FFmpeg 2.5 was cut here -------- 8< --------- - -2014-11-21 - ab922f9 - lavu 54.15.100 - dict.h - Add av_dict_get_string(). - -2014-11-18 - a54a51c - lavu 54.14.100 - float_dsp.h - Add avpriv_float_dsp_alloc(). - -2014-11-16 - 6690d4c3 - lavf 56.13.100 - avformat.h - Add AVStream.recommended_encoder_configuration with accessors. - -2014-11-16 - bee5844d - lavu 54.13.100 - opt.h - Add av_opt_serialize(). - -2014-11-16 - eec69332 - lavu 54.12.100 - opt.h - Add av_opt_is_set_to_default(). - -2014-11-06 - 44fa267 / 5e80fb7 - lavc 56.11.100 / 56.6.0 - vorbis_parser.h +2014-11-06 - 5e80fb7 - lavc 56.6.0 - vorbis_parser.h Add a public API for parsing vorbis packets. -2014-10-15 - 17085a0 / 7ea1b34 - lavc 56.7.100 / 56.5.0 - avcodec.h +2014-10-24 - 1bd0bdc - lavu 54.5.0 - time.h + Add av_gettime_relative(). + +2014-10-15 - 7ea1b34 - lavc 56.5.0 - avcodec.h Replace AVCodecContext.time_base used for decoding with AVCodecContext.framerate. -2014-10-15 - 51c810e / d565fef1 - lavc 56.6.100 / 56.4.0 - avcodec.h +2014-10-15 - d565fef1- lavc 56.4.0 - avcodec.h Add AV_HWACCEL_FLAG_IGNORE_LEVEL flag to av_vdpau_bind_context(). -2014-10-13 - da21895 / 2df0c32e - lavc 56.5.100 / 56.3.0 - avcodec.h +2014-10-13 - 2df0c32 - lavc 56.03.0 - avcodec.h Add AVCodecContext.initial_padding. Deprecate the use of AVCodecContext.delay for audio encoding. -2014-10-08 - bb44f7d / 5a419b2 - lavu 54.10.100 / 54.4.0 - pixdesc.h +2014-10-08 - 5a419b2 - lavu 54.04.0 - pixdesc.h Add API to return the name of frame and context color properties. -2014-10-06 - a61899a / e3e158e - lavc 56.3.100 / 56.2.0 - vdpau.h +2014-10-06 - e3e158e - lavc 56.2.0 - vdpau.h Add av_vdpau_bind_context(). This function should now be used for creating (or resetting) a AVVDPAUContext instead of av_vdpau_alloc_context(). -2014-10-02 - cdd6f05 - lavc 56.2.100 - avcodec.h -2014-10-02 - cdd6f05 - lavu 54.9.100 - frame.h - Add AV_FRAME_DATA_SKIP_SAMPLES. Add lavc CODEC_FLAG2_SKIP_MANUAL and - AVOption "skip_manual", which makes lavc export skip information via - AV_FRAME_DATA_SKIP_SAMPLES AVFrame side data, instead of skipping and - discarding samples automatically. - -2014-10-02 - 0d92b0d - lavu 54.8.100 - avstring.h - Add av_match_list() - -2014-09-24 - ac68295 - libpostproc 53.1.100 - Add visualization support - -2014-09-19 - 6edd6a4 - lavc 56.1.101 - dv_profile.h - deprecate avpriv_dv_frame_profile2(), which was made public by accident. - - --------- 8< --------- FFmpeg 2.4 was cut here -------- 8< --------- - -2014-08-25 - 215db29 / b263f8f - lavf 56.3.100 / 56.3.0 - avformat.h +2014-08-25 - b263f8f - lavf 56.03.0 - avformat.h Add AVFormatContext.max_ts_probe. -2014-08-28 - f30a815 / 9301486 - lavc 56.1.100 / 56.1.0 - avcodec.h +------------------------------8<------------------------------------- + 11 branch was cut here +----------------------------->8-------------------------------------- + +2014-08-28 - 9301486 - lavc 56.1.0 - avcodec.h Add AV_PKT_DATA_STEREO3D to export container-level stereo3d information. -2014-08-23 - 8fc9bd0 - lavu 54.7.100 - dict.h - AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL arguments are now - freed even on error. This is consistent with the behaviour all users - of it we could find expect. - -2014-08-21 - 980a5b0 - lavu 54.6.100 - frame.h motion_vector.h - Add AV_FRAME_DATA_MOTION_VECTORS side data and AVMotionVector structure - -2014-08-16 - b7d5e01 - lswr 1.1.100 - swresample.h - Add AVFrame based API - -2014-08-16 - c2829dc - lavu 54.4.100 - dict.h - Add av_dict_set_int helper function. - -2014-08-13 - c8571c6 / 8ddc326 - lavu 54.3.100 / 54.3.0 - mem.h +2014-08-13 - 8ddc326 - lavu 54.03.0 - mem.h Add av_strndup(). -2014-08-13 - 2ba4577 / a8c104a - lavu 54.2.100 / 54.2.0 - opt.h +2014-08-13 - a8c104a - lavu 54.02.0 - opt.h Add av_opt_get_dict_val/set_dict_val with AV_OPT_TYPE_DICT to support dictionary types being set as options. @@ -717,740 +416,334 @@ API changes, most recent first: Add AVFormatContext.event_flags and AVStream.event_flags for signaling to the user when events happen in the file/stream. -2014-08-10 - 78eaaa8 / fb1ddcd - lavr 2.1.0 - avresample.h +2014-08-10 - fb1ddcd - lavr 2.1.0 - avresample.h Add avresample_convert_frame() and avresample_config(). -2014-08-10 - 78eaaa8 / fb1ddcd - lavu 54.1.100 / 54.1.0 - error.h +2014-08-10 - fb1ddcd - lavu 54.1.0 - error.h Add AVERROR_INPUT_CHANGED and AVERROR_OUTPUT_CHANGED. -2014-08-08 - 3841f2a / d35b94f - lavc 55.73.102 / 55.57.4 - avcodec.h +2014-08-08 - d35b94f - lavc 55.57.4 - avcodec.h Deprecate FF_IDCT_XVIDMMX define and xvidmmx idct option. Replaced by FF_IDCT_XVID and xvid respectively. -2014-08-08 - 5c3c671 - lavf 55.53.100 - avio.h - Add avio_feof() and deprecate url_feof(). - 2014-08-07 - bb78903 - lsws 2.1.3 - swscale.h - sws_getContext is not going to be removed in the future. + sws_getCachedContext is not going to be removed in the future. -2014-08-07 - a561662 / ad1ee5f - lavc 55.73.101 / 55.57.3 - avcodec.h +2014-08-07 - ad1ee5f - lavc 55.57.3 - avcodec.h reordered_opaque is not going to be removed in the future. -2014-08-02 - 28a2107 - lavu 52.98.100 - pixelutils.h - Add pixelutils API with SAD functions - -2014-08-04 - 6017c98 / e9abafc - lavu 52.97.100 / 53.22.0 - pixfmt.h +2014-08-04 - e9abafc - lavu 53.22.0 - pixfmt.h Add AV_PIX_FMT_YA16 pixel format for 16 bit packed gray with alpha. -2014-08-04 - 4c8bc6f / e96c3b8 - lavu 52.96.101 / 53.21.1 - avstring.h +2014-08-04 - e96c3b8 - lavu 53.21.1 - avstring.h Rename AV_PIX_FMT_Y400A to AV_PIX_FMT_YA8 to better identify the format. An alias pixel format and color space name are provided for compatibility. -2014-08-04 - 073c074 / d2962e9 - lavu 52.96.100 / 53.21.0 - pixdesc.h +2014-08-04 - d2962e9 - lavu 53.21.0 - pixdesc.h Support name aliases for pixel formats. -2014-08-03 - 71d008e / 1ef9e83 - lavc 55.72.101 / 55.57.2 - avcodec.h -2014-08-03 - 71d008e / 1ef9e83 - lavu 52.95.100 / 53.20.0 - frame.h +2014-08-03 - 1ef9e83 - lavc 55.57.2 - avcodec.h +2014-08-03 - 1ef9e83 - lavu 53.20.0 - frame.h Deprecate AVCodecContext.dtg_active_format and use side-data instead. -2014-08-03 - e680c73 - lavc 55.72.100 - avcodec.h - Add get_pixels() to AVDCT - -2014-08-03 - 9400603 / 9f17685 - lavc 55.71.101 / 55.57.1 - avcodec.h +2014-08-03 - 9f17685 - lavc 55.57.1 - avcodec.h Deprecate unused FF_IDCT_IPP define and ipp avcodec option. Deprecate unused FF_DEBUG_PTS define and pts avcodec option. Deprecate unused FF_CODER_TYPE_DEFLATE define and deflate avcodec option. Deprecate unused FF_DCT_INT define and int avcodec option. Deprecate unused avcodec option scenechange_factor. -2014-07-30 - ba3e331 - lavu 52.94.100 - frame.h - Add av_frame_side_data_name() - -2014-07-29 - 80a3a66 / 3a19405 - lavf 56.01.100 / 56.01.0 - avformat.h - Add mime_type field to AVProbeData, which now MUST be initialized in - order to avoid uninitialized reads of the mime_type pointer, likely - leading to crashes. - Typically, this means you will do 'AVProbeData pd = { 0 };' instead of - 'AVProbeData pd;'. - -2014-07-29 - 31e0b5d / 69e7336 - lavu 52.92.100 / 53.19.0 - avstring.h +2014-07-29 - 69e7336 - lavu 53.19.0 - avstring.h Make name matching function from lavf public as av_match_name(). -2014-07-28 - 2e5c8b0 / c5fca01 - lavc 55.71.100 / 55.57.0 - avcodec.h +2014-07-28 - c5fca01 - lavc 55.57.0 - avcodec.h Add AV_CODEC_PROP_REORDER to mark codecs supporting frame reordering. -2014-07-27 - ff9a154 - lavf 55.50.100 - avformat.h - New field int64_t probesize2 instead of deprecated - field int probesize. - -2014-07-27 - 932ff70 - lavc 55.70.100 - avdct.h - Add AVDCT / avcodec_dct_alloc() / avcodec_dct_init(). - -2014-07-23 - 8a4c086 - lavf 55.49.100 - avio.h - Add avio_read_to_bprint() - - --------- 8< --------- FFmpeg 2.3 was cut here -------- 8< --------- - -2014-07-14 - 62227a7 - lavf 55.47.100 - avformat.h - Add av_stream_get_parser() - -2014-07-09 - c67690f / a54f03b - lavu 52.92.100 / 53.18.0 - display.h +2014-07-09 - a54f03b - lavu 53.18.0 - display.h Add av_display_matrix_flip() to flip the transformation matrix. -2014-07-09 - 1b58f13 / f6ee61f - lavc 55.69.100 / 55.56.0 - dv_profile.h +2014-07-09 - f6ee61f - lavc 55.56.0 - dv_profile.h Add a public API for DV profile handling. -2014-06-20 - 0dceefc / 9e500ef - lavu 52.90.100 / 53.17.0 - imgutils.h +2014-06-20 - 9e500ef - lavu 53.17.0 - imgutils.h Add av_image_check_sar(). -2014-06-20 - 4a99333 / 874390e - lavc 55.68.100 / 55.55.0 - avcodec.h +2014-06-20 - 874390e - lavc 55.55.0 - avcodec.h Add av_packet_rescale_ts() to simplify timestamp conversion. -2014-06-18 - ac293b6 / 194be1f - lavf 55.44.100 / 55.20.0 - avformat.h +2014-06-18 - 194be1f - lavf 55.20.0 - avformat.h The proper way for providing a hint about the desired timebase to the muxers is now setting AVStream.time_base, instead of AVStream.codec.time_base as was done previously. The old method is now deprecated. -2014-06-11 - 67d29da - lavc 55.66.101 - avcodec.h - Increase FF_INPUT_BUFFER_PADDING_SIZE to 32 due to some corner cases needing - it - -2014-06-10 - 5482780 - lavf 55.43.100 - avformat.h - New field int64_t max_analyze_duration2 instead of deprecated - int max_analyze_duration. - -2014-05-30 - 00759d7 - lavu 52.89.100 - opt.h - Add av_opt_copy() - -2014-06-01 - 03bb99a / 0957b27 - lavc 55.66.100 / 55.54.0 - avcodec.h +2014-06-01 - 0957b27 - lavc 55.54.0 - avcodec.h Add AVCodecContext.side_data_only_packets to allow encoders to output packets with only side data. This option may become mandatory in the future, so all users are recommended to update their code and enable this option. -2014-06-01 - 6e8e9f1 / 8c02adc - lavu 52.88.100 / 53.16.0 - frame.h, pixfmt.h +2014-06-01 - 8c02adc - lavu 53.16.0 - frame.h, pixfmt.h Move all color-related enums (AVColorPrimaries, AVColorSpace, AVColorRange, AVColorTransferCharacteristic, and AVChromaLocation) inside lavu. - And add AVFrame fields for them. + Add AVFrame fields for them on the next lavu major bump. -2014-05-29 - bdb2e80 / b2d4565 - lavr 1.3.0 - avresample.h +2014-05-28 - b2d4565 - lavr 1.3.0 - avresample.h Add avresample_max_output_samples -2014-05-28 - d858ee7 / 6d21259 - lavf 55.42.100 / 55.19.0 - avformat.h +2014-05-28 - 6d21259 - lavf 55.19.0 - avformat.h Add strict_std_compliance and related AVOptions to support experimental muxing. -2014-05-26 - 55cc60c - lavu 52.87.100 - threadmessage.h - Add thread message queue API. - -2014-05-26 - c37d179 - lavf 55.41.100 - avformat.h - Add format_probesize to AVFormatContext. - -2014-05-20 - 7d25af1 / c23c96b - lavf 55.39.100 / 55.18.0 - avformat.h +2014-05-20 - c23c96b - lavf 55.18.0 - avformat.h Add av_stream_get_side_data() to access stream-level side data in the same way as av_packet_get_side_data(). -2014-05-20 - 7336e39 - lavu 52.86.100 - fifo.h - Add av_fifo_alloc_array() function. - -2014-05-19 - ef1d4ee / bddd8cb - lavu 52.85.100 / 53.15.0 - frame.h, display.h +2014-05-19 - bddd8cb - lavu 53.15.0 - frame.h, display.h Add AV_FRAME_DATA_DISPLAYMATRIX for exporting frame-level spatial rendering on video frames for proper display. -2014-05-19 - ef1d4ee / bddd8cb - lavc 55.64.100 / 55.53.0 - avcodec.h +2014-05-19 - bddd8cb - lavc 55.53.0 - avcodec.h Add AV_PKT_DATA_DISPLAYMATRIX for exporting packet-level spatial rendering on video frames for proper display. -2014-05-19 - 999a99c / a312f71 - lavf 55.38.101 / 55.17.1 - avformat.h +2014-05-19 - a312f71 - lavf 55.17.1 - avformat.h Deprecate AVStream.pts and the AVFrac struct, which was its only use case. - See use av_stream_get_end_pts() + Those fields were poorly defined and not meant to be public, so there is + no replacement for them. -2014-05-18 - 68c0518 / fd05602 - lavc 55.63.100 / 55.52.0 - avcodec.h +2014-05-18 - fd05602 - lavc 55.52.0 - avcodec.h Add avcodec_free_context(). From now on it should be used for freeing AVCodecContext. -2014-05-17 - 0eec06e / 1bd0bdc - lavu 52.84.100 / 54.5.0 - time.h - Add av_gettime_relative() av_gettime_relative_is_monotonic() - -2014-05-15 - eacf7d6 / 0c1959b - lavf 55.38.100 / 55.17.0 - avformat.h +2014-05-15 - 0c1959b - lavf 55.17.0 - avformat.h Add AVFMT_FLAG_BITEXACT flag. Muxers now use it instead of checking CODEC_FLAG_BITEXACT on the first stream. -2014-05-15 - 96cb4c8 - lswr 0.19.100 - swresample.h - Add swr_close() - -2014-05-11 - 14aef38 / 66e6c8a - lavu 52.83.100 / 53.14.0 - pixfmt.h +2014-05-11 - 66e6c8a - lavu 53.14.0 - pixfmt.h Add AV_PIX_FMT_VDA for new-style VDA acceleration. -2014-05-07 - 351f611 - lavu 52.82.100 - fifo.h - Add av_fifo_freep() function. - -2014-05-02 - ba52fb11 - lavu 52.81.100 - opt.h - Add av_opt_set_dict2() function. - -2014-05-01 - e77b985 / a2941c8 - lavc 55.60.103 / 55.50.3 - avcodec.h +2014-05-01 - a2941c8 - lavc 55.50.3 - avcodec.h Deprecate CODEC_FLAG_MV0. It is replaced by the flag "mv0" in the "mpv_flags" private option of the mpegvideo encoders. -2014-05-01 - e40ae8c / 6484149 - lavc 55.60.102 / 55.50.2 - avcodec.h +2014-05-01 - 6484149 - lavc 55.50.2 - avcodec.h Deprecate CODEC_FLAG_GMC. It is replaced by the "gmc" private option of the libxvid encoder. -2014-05-01 - 1851643 / b2c3171 - lavc 55.60.101 / 55.50.1 - avcodec.h +2014-05-01 - b2c3171 - lavc 55.50.1 - avcodec.h Deprecate CODEC_FLAG_NORMALIZE_AQP. It is replaced by the flag "naq" in the "mpv_flags" private option of the mpegvideo encoders. -2014-05-01 - cac07d0 / 5fcceda - avcodec.h +2014-05-01 - 5fcceda - avcodec.h Deprecate CODEC_FLAG_INPUT_PRESERVED. Its functionality is replaced by passing reference-counted frames to encoders. -2014-04-30 - 617e866 - lavu 52.81.100 - pixdesc.h - Add av_find_best_pix_fmt_of_2(), av_get_pix_fmt_loss() - Deprecate avcodec_get_pix_fmt_loss(), avcodec_find_best_pix_fmt_of_2() - -2014-04-29 - 1bf6396 - lavc 55.60.100 - avcodec.h - Add AVCodecDescriptor.mime_types field. - -2014-04-29 - b804eb4 - lavu 52.80.100 - hash.h - Add av_hash_final_bin(), av_hash_final_hex() and av_hash_final_b64(). - -2014-03-07 - 8b2a130 - lavc 55.50.0 / 55.53.100 - dxva2.h +2014-04-28 - ed4b757 - lavc 55.50.0 - dxva2.h Add FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO for old Intel GPUs. -2014-04-22 - 502512e /dac7e8a - lavu 53.13.0 / 52.78.100 - avutil.h +2014-04-22 - 502512e - lavu 53.13.0 - avutil.h Add av_get_time_base_q(). -2014-04-17 - a8d01a7 / 0983d48 - lavu 53.12.0 / 52.77.100 - crc.h +2014-04-17 - 0983d48 - lavu 53.12.0 - crc.h Add AV_CRC_16_ANSI_LE crc variant. -2014-04-15 - ef818d8 - lavf 55.37.101 - avformat.h - Add av_format_inject_global_side_data() - -2014-04-12 - 4f698be - lavu 52.76.100 - log.h - Add av_log_get_flags() - -2014-04-11 - 6db42a2b - lavd 55.12.100 - avdevice.h - Add avdevice_capabilities_create() function. - Add avdevice_capabilities_free() function. - -2014-04-07 - 0a1cc04 / 8b17243 - lavu 52.75.100 / 53.11.0 - pixfmt.h +2014-04-07 - 8b17243 - lavu 53.11.0 - pixfmt.h Add AV_PIX_FMT_YVYU422 pixel format. -2014-04-04 - c1d0536 / 8542f9c - lavu 52.74.100 / 53.10.0 - replaygain.h +2014-04-04 - 8542f9c - lavu 53.10.0 - replaygain.h Full scale for peak values is now 100000 (instead of UINT32_MAX) and values may overflow. -2014-04-03 - c16e006 / 7763118 - lavu 52.73.100 / 53.9.0 - log.h +2014-04-03 - 7763118 - lavu 53.09.0 - log.h Add AV_LOG(c) macro to have 256 color debug messages. -2014-04-03 - eaed4da9 - lavu 52.72.100 - opt.h - Add AV_OPT_MULTI_COMPONENT_RANGE define to allow return - multi-component option ranges. - -2014-03-29 - cd50a44b - lavu 52.70.100 - mem.h - Add av_dynarray_add_nofree() function. - -2014-02-24 - 3e1f241 / d161ae0 - lavu 52.69.100 / 53.8.0 - frame.h +2014-03-24 - d161ae0 - lavu 53.08.0 - frame.h Add av_frame_remove_side_data() for removing a single side data instance from a frame. -2014-03-24 - 83e8978 / 5a7e35d - lavu 52.68.100 / 53.7.0 - frame.h, replaygain.h +2014-03-24 - 5a7e35d - lavu 53.07.0 - frame.h, replaygain.h Add AV_FRAME_DATA_REPLAYGAIN for exporting replaygain tags. Add a new header replaygain.h with the AVReplayGain struct. -2014-03-24 - 83e8978 / 5a7e35d - lavc 55.54.100 / 55.36.0 - avcodec.h +2014-03-24 - 5a7e35d - lavc 55.36.0 - avcodec.h Add AV_PKT_DATA_REPLAYGAIN for exporting replaygain tags. -2014-03-24 - 595ba3b / 25b3258 - lavf 55.35.100 / 55.13.0 - avformat.h +2014-03-24 - 25b3258 - lavf 55.13.0 - avformat.h Add AVStream.side_data and AVStream.nb_side_data for exporting stream-global side data (e.g. replaygain tags, video rotation) -2014-03-24 - bd34e26 / 0e2c3ee - lavc 55.53.100 / 55.35.0 - avcodec.h +2014-03-24 - 0e2c3ee - lavc 55.35.0 - avcodec.h Give the name AVPacketSideData to the previously anonymous struct used for AVPacket.side_data. +2014-03-16 - 1481d24 - lavu 53.06.0 - pixfmt.h + Add RGBA64 pixel format and variants. --------- 8< --------- FFmpeg 2.2 was cut here -------- 8< --------- - -2014-03-18 - 37c07d4 - lsws 2.5.102 - Make gray16 full-scale. - -2014-03-16 - 6b1ca17 / 1481d24 - lavu 52.67.100 / 53.6.0 - pixfmt.h - Add RGBA64_LIBAV pixel format and variants for compatibility - -2014-03-11 - 3f3229c - lavf 55.34.101 - avformat.h - Set AVFormatContext.start_time_realtime when demuxing. - -2014-03-03 - 06fed440 - lavd 55.11.100 - avdevice.h - Add av_input_audio_device_next(). - Add av_input_video_device_next(). - Add av_output_audio_device_next(). - Add av_output_video_device_next(). - -2014-02-24 - fff5262 / 1155fd0 - lavu 52.66.100 / 53.5.0 - frame.h +2014-02-24 - 1155fd0 - lavu 53.05.0 - frame.h Add av_frame_copy() for copying the frame data. -2014-02-24 - a66be60 - lswr 0.18.100 - swresample.h - Add swr_is_initialized() for checking whether a resample context is initialized. - -2014-02-22 - 5367c0b / 7e86c27 - lavr 1.2.0 - avresample.h +2014-02-22 - 7e86c27 - lavr 1.2.0 - avresample.h Add avresample_is_open() for checking whether a resample context is open. -2014-02-19 - 6a24d77 / c3ecd96 - lavu 52.65.100 / 53.4.0 - opt.h +2014-02-19 - c3ecd96 - lavu 53.04.0 - opt.h Add AV_OPT_FLAG_EXPORT and AV_OPT_FLAG_READONLY to mark options meant (only) for reading. -2014-02-19 - f4c8d00 / 6bb8720 - lavu 52.64.101 / 53.3.1 - opt.h +2014-02-19 - 6bb8720 - lavu 53.03.01 - opt.h Deprecate unused AV_OPT_FLAG_METADATA. -2014-02-16 - 81c3f81 - lavd 55.10.100 - avdevice.h - Add avdevice_list_devices() and avdevice_free_list_devices() +------------------------------8<------------------------------------- + 10 branch was cut here +----------------------------->8-------------------------------------- -2014-02-16 - db3c970 - lavf 55.33.100 - avio.h - Add avio_find_protocol_name() to find out the name of the protocol that would - be selected for a given URL. - -2014-02-15 - a2bc6c1 / c98f316 - lavu 52.64.100 / 53.3.0 - frame.h +2014-02-15 - c98f316 - lavu 53.3.0 - frame.h Add AV_FRAME_DATA_DOWNMIX_INFO value to the AVFrameSideDataType enum and downmix_info.h API, which identify downmix-related metadata. -2014-02-11 - 1b05ac2 - lavf 55.32.100 - avformat.h - Add av_write_uncoded_frame() and av_interleaved_write_uncoded_frame(). - -2014-02-04 - 3adb5f8 / d9ae103 - lavf 55.30.100 / 55.11.0 - avformat.h +2014-02-04 - d9ae103 - lavf 55.11.0 - avformat.h Add AVFormatContext.max_interleave_delta for controlling amount of buffering when interleaving. -2014-02-02 - 5871ee5 - lavf 55.29.100 - avformat.h - Add output_ts_offset muxing option to AVFormatContext. - -2014-01-27 - 102bd64 - lavd 55.7.100 - avdevice.h - lavf 55.28.100 - avformat.h - Add avdevice_dev_to_app_control_message() function. - -2014-01-27 - 7151411 - lavd 55.6.100 - avdevice.h - lavf 55.27.100 - avformat.h - Add avdevice_app_to_dev_control_message() function. - -2014-01-24 - 86bee79 - lavf 55.26.100 - avformat.h - Add AVFormatContext option metadata_header_padding to allow control over the - amount of padding added. - -2014-01-20 - eef74b2 / 93c553c - lavc 55.48.102 / 55.32.1 - avcodec.h +2014-01-20 - 93c553c - lavc 55.32.1 - avcodec.h Edges are not required anymore on video buffers allocated by get_buffer2() (i.e. as if the CODEC_FLAG_EMU_EDGE flag was always on). Deprecate CODEC_FLAG_EMU_EDGE and avcodec_get_edge_width(). -2014-01-19 - 1a193c4 - lavf 55.25.100 - avformat.h - Add avformat_get_mov_video_tags() and avformat_get_mov_audio_tags(). - -2014-01-19 - 3532dd5 - lavu 52.63.100 - rational.h - Add av_make_q() function. - -2014-01-05 - 4cf4da9 / 5b4797a - lavu 52.62.100 / 53.2.0 - frame.h +2014-01-05 - 5b4797a - lavu 53.2.0 - frame.h Add AV_FRAME_DATA_MATRIXENCODING value to the AVFrameSideDataType enum, which identifies AVMatrixEncoding data. -2014-01-05 - 751385f / 5c437fb - lavu 52.61.100 / 53.1.0 - channel_layout.h +2014-01-05 - 5c437fb - lavu 53.1.0 - channel_layout.h Add values for various Dolby flags to the AVMatrixEncoding enum. -2014-01-04 - b317f94 - lavu 52.60.100 - mathematics.h - Add av_add_stable() function. +2013-12-20 - 2a41826 - lavc 55.30.0 - avcodec.h + Add HEVC profiles -2013-12-22 - 911676c - lavu 52.59.100 - avstring.h - Add av_strnlen() function. - -2013-12-09 - 64f73ac - lavu 52.57.100 - opencl.h - Add av_opencl_benchmark() function. - -2013-11-30 - 82b2e9c - lavu 52.56.100 - ffversion.h - Moves version.h to libavutil/ffversion.h. - Install ffversion.h and make it public. - -2013-12-11 - 29c83d2 / b9fb59d,409a143 / 9431356,44967ab / d7b3ee9 - lavc 55.45.101 / 55.28.1 - avcodec.h +2013-12-11 - b9fb59d,9431356,d7b3ee9 - lavc 55.28.1 - avcodec.h av_frame_alloc(), av_frame_unref() and av_frame_free() now can and should be used instead of avcodec_alloc_frame(), avcodec_get_frame_defaults() and avcodec_free_frame() respectively. The latter three functions are deprecated. -2013-12-09 - 7a60348 / 7e244c6- - lavu 52.58.100 / 52.20.0 - frame.h +2013-12-09 - 7e244c6- - lavu 52.20.0 - frame.h Add AV_FRAME_DATA_STEREO3D value to the AVFrameSideDataType enum and stereo3d.h API, that identify codec-independent stereo3d information. -2013-11-26 - 625b290 / 1eaac1d- - lavu 52.55.100 / 52.19.0 - frame.h +2013-11-26 - 1eaac1d- - lavu 52.19.0 - frame.h Add AV_FRAME_DATA_A53_CC value to the AVFrameSideDataType enum, which identifies ATSC A53 Part 4 Closed Captions data. -2013-11-22 - 6859065 - lavu 52.54.100 - avstring.h - Add av_utf8_decode() function. - -2013-11-22 - fb7d70c - lavc 55.44.100 - avcodec.h - Add HEVC profiles - -2013-11-20 - c28b61c - lavc 55.44.100 - avcodec.h - Add av_packet_{un,}pack_dictionary() - Add AV_PKT_METADATA_UPDATE side data type, used to transmit key/value - strings between a stream and the application. - -2013-11-14 - 7c888ae / cce3e0a - lavu 52.53.100 / 52.18.0 - mem.h +2013-11-14 - cce3e0a - lavu 52.18.0 - mem.h Move av_fast_malloc() and av_fast_realloc() for libavcodec to libavutil. -2013-11-14 - b71e4d8 / 8941971 - lavc 55.43.100 / 55.27.0 - avcodec.h +2013-11-14 - 8941971 - lavc 55.27.0 - avcodec.h Deprecate AVCodecContext.error_rate, it is replaced by the 'error_rate' private option of the mpegvideo encoder family. -2013-11-14 - 31c09b7 / 728c465 - lavc 55.42.100 / 55.26.0 - vdpau.h +2013-11-14 - 728c465 - lavc 55.26.0 - vdpau.h Add av_vdpau_get_profile(). Add av_vdpau_alloc_context(). This function must from now on be used for allocating AVVDPAUContext. -2013-11-04 - be41f21 / cd8f772 - lavc 55.41.100 / 55.25.0 - avcodec.h - lavu 52.51.100 - frame.h +2013-11-04 - cd8f772 - lavc 55.25.0 - avcodec.h Add ITU-R BT.2020 and other not yet included values to color primaries, transfer characteristics and colorspaces. -2013-11-04 - 85cabf1 - lavu 52.50.100 - avutil.h - Add av_fopen_utf8() - -2013-10-31 - 78265fc / 28096e0 - lavu 52.49.100 / 52.17.0 - frame.h +2013-10-31 - 28096e0 - lavu 52.17.0 - frame.h Add AVFrame.flags and AV_FRAME_FLAG_CORRUPT. - --------- 8< --------- FFmpeg 2.1 was cut here -------- 8< --------- - -2013-10-27 - dbe6f9f - lavc 55.39.100 - avcodec.h - Add CODEC_CAP_DELAY support to avcodec_decode_subtitle2. - -2013-10-27 - d61617a - lavu 52.48.100 - parseutils.h - Add av_get_known_color_name(). - -2013-10-17 - 8696e51 - lavu 52.47.100 - opt.h - Add AV_OPT_TYPE_CHANNEL_LAYOUT and channel layout option handlers - av_opt_get_channel_layout() and av_opt_set_channel_layout(). - -2013-10-06 - ccf96f8 -libswscale 2.5.101 - options.c - Change default scaler to bicubic - -2013-10-03 - e57dba0 - lavc 55.34.100 - avcodec.h - Add av_codec_get_max_lowres() - -2013-10-02 - 5082fcc - lavf 55.19.100 - avformat.h - Add audio/video/subtitle AVCodec fields to AVFormatContext to force specific - decoders - -2013-09-28 - 7381d31 / 0767bfd - lavfi 3.88.100 / 3.11.0 - avfilter.h +2013-09-28 - 0767bfd - lavfi 3.11.0 - avfilter.h Add AVFilterGraph.execute and AVFilterGraph.opaque for custom slice threading implementations. -2013-09-21 - 85f8a3c / e208e6d - lavu 52.46.100 / 52.16.0 - pixfmt.h +2013-09-21 - e208e6d - lavu 52.16.0 - pixfmt.h Add interleaved 4:2:2 8/10-bit formats AV_PIX_FMT_NV16 and AV_PIX_FMT_NV20. -2013-09-16 - c74c3fb / 3feb3d6 - lavu 52.44.100 / 52.15.0 - mem.h +2013-09-16 - 3feb3d6 - lavu 52.15.0 - mem.h Add av_reallocp. -2013-09-04 - 3e1f507 - lavc 55.31.101 - avcodec.h - avcodec_close() argument can be NULL. - -2013-09-04 - 36cd017a - lavf 55.16.101 - avformat.h - avformat_close_input() argument can be NULL and point on NULL. - -2013-08-29 - e31db62 - lavf 55.15.100 - avformat.h - Add av_format_get_probe_score(). - -2013-08-15 - 1e0e193 - lsws 2.5.100 - - Add a sws_dither AVOption, allowing to set the dither algorithm used - -2013-08-11 - d404fe35 - lavc 55.27.100 - vdpau.h - Add a render2 alternative to the render callback function. - -2013-08-11 - af05edc - lavc 55.26.100 - vdpau.h - Add allocation function for AVVDPAUContext, allowing - to extend it in the future without breaking ABI/API. - -2013-08-10 - 67a580f / 5a9a9d4 - lavc 55.25.100 / 55.16.0 - avcodec.h +2013-08-10 - 5a9a9d4 - lavc 55.16.0 - avcodec.h Extend AVPacket API with av_packet_unref, av_packet_ref, av_packet_move_ref, av_packet_copy_props, av_packet_free_side_data. -2013-08-05 - 9547e3e / f824535 - lavc 55.22.100 / 55.13.0 - avcodec.h +2013-08-05 - f824535 - lavc 55.13.0 - avcodec.h Deprecate the bitstream-related members from struct AVVDPAUContext. The bitstream buffers no longer need to be explicitly freed. -2013-08-05 - 3b805dc / 549294f - lavc 55.21.100 / 55.12.0 - avcodec.h +2013-08-05 - 549294f - lavc 55.12.0 - avcodec.h Deprecate the CODEC_CAP_HWACCEL_VDPAU codec capability. Use CODEC_CAP_HWACCEL and select the AV_PIX_FMT_VDPAU format with get_format() instead. -2013-08-05 - 4ee0984 / a0ad5d0 - lavu 52.41.100 / 52.14.0 - pixfmt.h +2013-08-05 - a0ad5d0 - lavu 52.14.0 - pixfmt.h Deprecate AV_PIX_FMT_VDPAU_*. Use AV_PIX_FMT_VDPAU instead. -2013-08-02 - 82fdfe8 / a8b1927 - lavc 55.20.100 / 55.11.0 - avcodec.h +2013-08-02 - a8b1927 - lavc 55.11.0 - avcodec.h Add output_picture_number to AVCodecParserContext. -2013-07-23 - abc8110 - lavc 55.19.100 - avcodec.h - Add avcodec_chroma_pos_to_enum() - Add avcodec_enum_to_chroma_pos() - - --------- 8< --------- FFmpeg 2.0 was cut here -------- 8< --------- - -2013-07-03 - 838bd73 - lavfi 3.78.100 - avfilter.h - Deprecate avfilter_graph_parse() in favor of the equivalent - avfilter_graph_parse_ptr(). - -2013-06-24 - af5f9c0 / 95d5246 - lavc 55.17.100 / 55.10.0 - avcodec.h +2013-06-24 - 95d5246 - lavc 55.10.0 - avcodec.h Add MPEG-2 AAC profiles -2013-06-25 - af5f9c0 / 95d5246 - lavf 55.10.100 - avformat.h - Add AV_DISPOSITION_* flags to indicate text track kind. - -2013-06-15 - 99b8cd0 - lavu 52.36.100 - Add AVRIPEMD: - av_ripemd_alloc() - av_ripemd_init() - av_ripemd_update() - av_ripemd_final() - -2013-06-10 - 82ef670 - lavu 52.35.101 - hmac.h - Add AV_HMAC_SHA224, AV_HMAC_SHA256, AV_HMAC_SHA384, AV_HMAC_SHA512 - -2013-06-04 - 30b491f / fc962d4 - lavu 52.35.100 / 52.13.0 - mem.h +2013-06-04 - fc962d4 - lavu 52.13.0 - mem.h Add av_realloc_array and av_reallocp_array -2013-05-30 - 682b227 - lavu 52.35.100 - Add AVSHA512: - av_sha512_alloc() - av_sha512_init() - av_sha512_update() - av_sha512_final() - -2013-05-24 - 8d4e969 / 129bb23 - lavfi 3.10.0 / 3.70.100 - avfilter.h +2013-05-24 - 129bb23 - lavfi 3.10.0 - avfilter.h Add support for slice multithreading to lavfi. Filters supporting threading are marked with AVFILTER_FLAG_SLICE_THREADS. New fields AVFilterContext.thread_type, AVFilterGraph.thread_type and AVFilterGraph.nb_threads (accessible directly or through AVOptions) may be used to configure multithreading. -2013-05-24 - fe40a9f / 2a6eaea - lavu 52.12.0 / 52.34.100 - cpu.h +2013-05-24 - 2a6eaea - lavu 52.12.0 - cpu.h Add av_cpu_count() function for getting the number of logical CPUs. -2013-05-24 - 0c25c39 / b493847 - lavc 55.7.0 / 55.12.100 - avcodec.h +2013-05-24 - b493847 - lavc 55.7.0 - avcodec.h Add picture_structure to AVCodecParserContext. -2013-05-17 - 3a751ea - lavu 52.33.100 - opt.h - Add AV_OPT_TYPE_COLOR value to AVOptionType enum. - -2013-05-13 - e398416 - lavu 52.31.100 - mem.h - Add av_dynarray2_add(). - -2013-05-12 - 1776177 - lavfi 3.65.100 - Add AVFILTER_FLAG_SUPPORT_TIMELINE* filter flags. - -2013-04-19 - 380cfce - lavc 55.4.100 - Add AV_CODEC_PROP_TEXT_SUB property for text based subtitles codec. - -2013-04-18 - 7c1a002 - lavf 55.3.100 - The matroska demuxer can now output proper verbatim ASS packets. It will - become the default starting lavf 56.0.100. - -2013-04-10 - af0d270 - lavu 25.26.100 - avutil.h,opt.h - Add av_int_list_length() - and av_opt_set_int_list(). - -2013-03-30 - 5c73645 - lavu 52.24.100 - samplefmt.h - Add av_samples_alloc_array_and_samples(). - -2013-03-29 - ef7b6b4 - lavf 55.1.100 - avformat.h - Add av_guess_frame_rate() - -2013-03-20 - 8d928a9 - lavu 52.22.100 - opt.h - Add AV_OPT_TYPE_DURATION value to AVOptionType enum. - -2013-03-17 - 7aa9af5 - lavu 52.20.100 - opt.h - Add AV_OPT_TYPE_VIDEO_RATE value to AVOptionType enum. - - --------- 8< --------- FFmpeg 1.2 was cut here -------- 8< --------- - -2013-03-07 - 9767ec6 - lavu 52.18.100 - avstring.h,bprint.h - Add av_escape() and av_bprint_escape() API. - -2013-02-24 - b59cd08 - lavfi 3.41.100 - buffersink.h - Add sample_rates field to AVABufferSinkParams. - -2013-01-17 - a1a707f - lavf 54.61.100 - Add av_codec_get_tag2(). - -2013-01-01 - 2eb2e17 - lavfi 3.34.100 - Add avfilter_get_audio_buffer_ref_from_arrays_channels. - - --------- 8< --------- FFmpeg 1.1 was cut here -------- 8< --------- - -2012-12-20 - 34de47aa - lavfi 3.29.100 - avfilter.h - Add AVFilterLink.channels, avfilter_link_get_channels() - and avfilter_ref_get_channels(). - -2012-12-15 - 96d815fc - lavc 54.80.100 - avcodec.h - Add pkt_size field to AVFrame. - -2012-11-25 - c70ec631 - lavu 52.9.100 - opt.h - Add the following convenience functions to opt.h: - av_opt_get_image_size - av_opt_get_pixel_fmt - av_opt_get_sample_fmt - av_opt_set_image_size - av_opt_set_pixel_fmt - av_opt_set_sample_fmt - -2012-11-17 - 4cd74c81 - lavu 52.8.100 - bprint.h - Add av_bprint_strftime(). - -2012-11-15 - 92648107 - lavu 52.7.100 - opt.h - Add av_opt_get_key_value(). - -2012-11-13 - 79456652 - lavfi 3.23.100 - avfilter.h - Add channels field to AVFilterBufferRefAudioProps. - -2012-11-03 - 481fdeee - lavu 52.3.100 - opt.h - Add AV_OPT_TYPE_SAMPLE_FMT value to AVOptionType enum. - -2012-10-21 - 6fb2fd8 - lavc 54.68.100 - avcodec.h - lavfi 3.20.100 - avfilter.h - Add AV_PKT_DATA_STRINGS_METADATA side data type, used to transmit key/value - strings between AVPacket and AVFrame, and add metadata field to - AVCodecContext (which shall not be accessed by users; see AVFrame metadata - instead). - -2012-09-27 - a70b493 - lavd 54.3.100 - version.h - Add LIBAVDEVICE_IDENT symbol. - -2012-09-27 - a70b493 - lavfi 3.18.100 - version.h - Add LIBAVFILTER_IDENT symbol. - -2012-09-27 - a70b493 - libswr 0.16.100 - version.h - Add LIBSWRESAMPLE_VERSION, LIBSWRESAMPLE_BUILD - and LIBSWRESAMPLE_IDENT symbols. - - --------- 8< --------- FFmpeg 1.0 was cut here -------- 8< --------- - -2012-09-06 - 29e972f - lavu 51.72.100 - parseutils.h - Add av_small_strptime() time parsing function. - - Can be used as a stripped-down replacement for strptime(), on - systems which do not support it. - -2012-08-25 - 2626cc4 - lavf 54.28.100 - Matroska demuxer now identifies SRT subtitles as AV_CODEC_ID_SUBRIP instead - of AV_CODEC_ID_TEXT. - -2012-08-13 - 5c0d8bc - lavfi 3.8.100 - avfilter.h - Add avfilter_get_class() function, and priv_class field to AVFilter - struct. - -2012-08-12 - a25346e - lavu 51.69.100 - opt.h - Add AV_OPT_FLAG_FILTERING_PARAM symbol in opt.h. - -2012-07-31 - 23fc4dd - lavc 54.46.100 - Add channels field to AVFrame. - -2012-07-30 - f893904 - lavu 51.66.100 - Add av_get_channel_description() - and av_get_standard_channel_layout() functions. - -2012-07-21 - 016a472 - lavc 54.43.100 - Add decode_error_flags field to AVFrame. - -2012-07-20 - b062936 - lavf 54.18.100 - Add avformat_match_stream_specifier() function. - -2012-07-14 - f49ec1b - lavc 54.38.100 - avcodec.h - Add metadata to AVFrame, and the accessor functions - av_frame_get_metadata() and av_frame_set_metadata(). - -2012-07-10 - 0e003d8 - lavc 54.33.100 - Add av_fast_padded_mallocz(). - -2012-07-10 - 21d5609 - lavfi 3.2.0 - avfilter.h - Add init_opaque() callback to AVFilter struct. - -2012-06-26 - e6674e4 - lavu 51.63.100 - imgutils.h - Add functions to libavutil/imgutils.h: - av_image_get_buffer_size() - av_image_fill_arrays() - av_image_copy_to_buffer() - -2012-06-24 - c41899a - lavu 51.62.100 - version.h - version moved from avutil.h to version.h - -2012-04-11 - 359abb1 - lavu 51.58.100 - error.h - Add av_make_error_string() and av_err2str() utilities to - libavutil/error.h. - -2012-06-05 - 62b39d4 - lavc 54.24.100 - Add pkt_duration field to AVFrame. - -2012-05-24 - f2ee065 - lavu 51.54.100 - Move AVPALETTE_SIZE and AVPALETTE_COUNT macros from - libavcodec/avcodec.h to libavutil/pixfmt.h. - -2012-05-14 - 94a9ac1 - lavf 54.5.100 - Add av_guess_sample_aspect_ratio() function. - -2012-04-20 - 65fa7bc - lavfi 2.70.100 - Add avfilter_unref_bufferp() to avfilter.h. - -2012-04-13 - 162e400 - lavfi 2.68.100 - Install libavfilter/asrc_abuffer.h public header. - -2012-03-26 - a67d9cf - lavfi 2.66.100 - Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. - -2013-05-15 - ff46809 / e6c4ac7 - lavu 52.32.100 / 52.11.0 - pixdesc.h +2013-05-15 - e6c4ac7 - lavu 52.11.0 - pixdesc.h Replace PIX_FMT_* flags with AV_PIX_FMT_FLAG_*. -2013-04-03 - 6fc58a8 / 507b1e4 - lavc 55.7.100 / 55.4.0 - avcodec.h +2013-04-03 - 507b1e4 - lavc 55.4.0 - avcodec.h Add field_order to AVCodecParserContext. -2013-04-19 - f4b05cd / 5e83d9a - lavc 55.5.100 / 55.2.0 - avcodec.h +2013-04-19 - 5e83d9a - lavc 55.2.0 - avcodec.h Add CODEC_FLAG_UNALIGNED to allow decoders to produce unaligned output. -2013-04-11 - lavfi 3.53.100 / 3.8.0 - 231fd44 / 38f0c07 - Move all content from avfiltergraph.h to avfilter.h. Deprecate +2013-04-11 - lavfi 3.8.0 + 38f0c07 - Move all content from avfiltergraph.h to avfilter.h. Deprecate avfilterhraph.h, user applications should include just avfilter.h - 86070b8 / bc1a985 - Add avfilter_graph_alloc_filter(), deprecate avfilter_open() and + bc1a985 - Add avfilter_graph_alloc_filter(), deprecate avfilter_open() and avfilter_graph_add_filter(). - 4fde705 / 1113672 - Add AVFilterContext.graph pointing to the AVFilterGraph that contains the + 1113672 - Add AVFilterContext.graph pointing to the AVFilterGraph that contains the filter. - 710b0aa / 48a5ada - Add avfilter_init_str(), deprecate avfilter_init_filter(). - 46de9ba / 1ba95a9 - Add avfilter_init_dict(). - 16fc24b / 7cdd737 - Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags. - f4db6bf / 7e8fe4b - Add avfilter_pad_count() for counting filter inputs/outputs. - 835cc0f / fa2a34c - Add avfilter_next(), deprecate av_filter_next(). + 48a5ada - Add avfilter_init_str(), deprecate avfilter_init_filter(). + 1ba95a9 - Add avfilter_init_dict(). + 7cdd737 - Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags. + 7e8fe4b - Add avfilter_pad_count() for counting filter inputs/outputs. + fa2a34c - Add avfilter_next(), deprecate av_filter_next(). Deprecate avfilter_uninit(). -2013-04-09 - lavfi 3.51.100 / 3.7.0 - avfilter.h - 0594ef0 / b439c99 - Add AVFilter.priv_class for exporting filter options through the +2013-04-09 - lavfi 3.7.0 - avfilter.h + b439c99 - Add AVFilter.priv_class for exporting filter options through the AVOptions API in the similar way private options work in lavc and lavf. - 44d4488 / 8114c10 - Add avfilter_get_class(). + 8114c10 - Add avfilter_get_class(). Switch all filters to use AVOptions. -2013-03-19 - 17ebef2 / 2c328a9 - lavu 52.20.100 / 52.9.0 - pixdesc.h +2013-03-19 - 2c328a9 - lavu 52.9.0 - pixdesc.h Add av_pix_fmt_count_planes() function for counting planes in a pixel format. -2013-03-16 - ecade98 / 42c7c61 - lavfi 3.47.100 / 3.6.0 +2013-03-16 - 42c7c61 - lavfi 3.6.0 Add AVFilterGraph.nb_filters, deprecate AVFilterGraph.filter_count. -2013-03-08 - Reference counted buffers - lavu 52.8.0, lavc 55.0.100 / 55.0.0, lavf 55.0.100 / 55.0.0, -lavd 54.4.100 / 54.0.0, lavfi 3.5.0 - 36099df / 8e401db, 532f31a / 1cec062 - add a new API for reference counted buffers and buffer +2013-03-08 - Reference counted buffers - lavu 52.8.0, lavc 55.0.0, lavf 55.0.0, +lavd 54.0.0, lavfi 3.5.0 + 8e401db, 1cec062 - add a new API for reference counted buffers and buffer pools (new header libavutil/buffer.h). - 2653e12 / 1afddbe - add AVPacket.buf to allow reference counting for the AVPacket data. + 1afddbe - add AVPacket.buf to allow reference counting for the AVPacket data. Add av_packet_from_data() function for constructing packets from av_malloc()ed data. - c4e8821 / 7ecc2d4 - move AVFrame from lavc to lavu (new header libavutil/frame.h), add + 7ecc2d4 - move AVFrame from lavc to lavu (new header libavutil/frame.h), add AVFrame.buf/extended_buf to allow reference counting for the AVFrame data. Add new API for working with reference-counted AVFrames. - 80e9e63 / 759001c - add the refcounted_frames field to AVCodecContext to make audio and + 759001c - add the refcounted_frames field to AVCodecContext to make audio and video decoders return reference-counted frames. Add get_buffer2() callback to AVCodecContext which allocates reference-counted frames. Add avcodec_default_get_buffer2() as the default get_buffer2() @@ -1468,62 +761,70 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 * qscale_table, qstride, qscale_type, mbskip_table, motion_val, mb_type, dct_coeff, ref_index -- mpegvideo-specific tables, which are not exported anymore. - a05a44e / 7e35037 - switch libavfilter to use AVFrame instead of AVFilterBufferRef. Add + 7e35037 - switch libavfilter to use AVFrame instead of AVFilterBufferRef. Add av_buffersrc_add_frame(), deprecate av_buffersrc_buffer(). Add av_buffersink_get_frame() and av_buffersink_get_samples(), deprecate av_buffersink_read() and av_buffersink_read_samples(). Deprecate AVFilterBufferRef and all functions for working with it. -2013-03-17 - 6c17ff8 / 12c5c1d - lavu 52.19.100 / 52.8.0 - avstring.h +2013-03-17 - 12c5c1d - lavu 52.8.0 - avstring.h Add av_isdigit, av_isgraph, av_isspace, av_isxdigit. -2013-02-23 - 71cf094 / 9f12235 - lavfi 3.40.100 / 3.4.0 - avfiltergraph.h +2013-02-23 - 9f12235 - lavfi 3.4.0 - avfiltergraph.h Add resample_lavr_opts to AVFilterGraph for setting libavresample options for auto-inserted resample filters. -2013-01-25 - e7e14bc / 38c1466 - lavu 52.17.100 / 52.7.0 - dict.h +2013-01-25 - 38c1466 - lavu 52.7.0 - dict.h Add av_dict_parse_string() to set multiple key/value pairs at once from a string. -2013-01-25 - 25be630 / b85a5e8 - lavu 52.16.100 / 52.6.0 - avstring.h +2013-01-25 - b85a5e8 - lavu 52.6.0 - avstring.h Add av_strnstr() -2013-01-15 - e7e0186 / 8ee288d - lavu 52.15.100 / 52.5.0 - hmac.h +2013-01-15 - 8ee288d - lavu 52.5.0 - hmac.h Add AVHMAC. -2013-01-13 - 8ee7b38 / 44e065d - lavc 54.87.100 / 54.36.0 - vdpau.h +2013-01-13 - 44e065d - lavc 54.36.0 - vdpau.h Add AVVDPAUContext struct for VDPAU hardware-accelerated decoding. -2013-01-12 - dae382b / 169fb94 - lavu 52.14.100 / 52.4.0 - pixdesc.h +2013-01-12 - 169fb94 - lavu 52.4.0 - pixdesc.h Add AV_PIX_FMT_VDPAU flag. -2013-01-07 - 249fca3 / 074a00d - lavr 1.1.0 +2013-01-07 - 074a00d - lavr 1.1.0 Add avresample_set_channel_mapping() for input channel reordering, duplication, and silencing. -2012-12-29 - lavu 52.13.100 / 52.3.0 - avstring.h - 2ce43b3 / d8fd06c - Add av_basename() and av_dirname(). - e13d5e9 / c1a02e8 - Add av_pix_fmt_get_chroma_sub_sample and deprecate - avcodec_get_chroma_sub_sample. +------------------------------8<------------------------------------- + 9 branch was cut here +----------------------------->8-------------------------------------- -2012-11-11 - 03b0787 / 5980f5d - lavu 52.6.100 / 52.2.0 - audioconvert.h +2012-12-29 - lavu 52.3.0 + d8fd06c - Add av_basename() and av_dirname(). + c1a02e8 - Add av_pix_fmt_get_chroma_sub_sample and deprecate + avcodec_get_chroma_sub_sample. + +2012-11-11 - 5980f5d - lavu 52.2.0 - audioconvert.h Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. -2012-10-21 - e3a91c5 / a893655 - lavu 51.77.100 / 51.45.0 - error.h +2012-11-05 - dfde8a3 - lavu 52.1.0 - intmath.h + Add av_ctz() for trailing zero bit count + +2012-10-21 - a893655 - lavu 51.45.0 - error.h Add AVERROR_EXPERIMENTAL -2012-10-12 - a33ed6b / d2fcb35 - lavu 51.76.100 / 51.44.0 - pixdesc.h +2012-10-12 - d2fcb35 - lavu 51.44.0 - pixdesc.h Add functions for accessing pixel format descriptors. Accessing the av_pix_fmt_descriptors array directly is now deprecated. -2012-10-11 - f391e40 / 9a92aea - lavu 51.75.100 / 51.43.0 - aes.h, md5.h, sha.h, tree.h +2012-10-11 - 9a92aea - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h Add functions for allocating the opaque contexts for the algorithms, + deprecate the context size variables. -2012-10-10 - de31814 / b522000 - lavf 54.32.100 / 54.18.0 - avio.h +2012-10-10 - b522000 - lavf 54.18.0 - avio.h Add avio_closep to complement avio_close. -2012-10-08 - ae77266 / 78071a1 - lavu 51.74.100 / 51.42.0 - pixfmt.h +2012-10-08 - 78071a1 - lavu 51.42.0 - pixfmt.h Rename PixelFormat to AVPixelFormat and all PIX_FMT_* to AV_PIX_FMT_*. To provide backwards compatibility, PixelFormat is now #defined as AVPixelFormat. @@ -1531,26 +832,23 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 'PixelFormat' identifier. Such code should either #undef PixelFormat or stop using the PixelFormat name. -2012-10-05 - 55c49af / e7ba5b1 - lavr 1.0.0 - avresample.h +2012-10-05 - e7ba5b1 - lavr 1.0.0 - avresample.h Data planes parameters to avresample_convert() and avresample_read() are now uint8_t** instead of void**. Libavresample is now stable. -2012-09-26 - 3ba0dab7 / 1384df64 - lavf 54.29.101 / 56.06.3 - avformat.h - Add AVFormatContext.avoid_negative_ts. - -2012-09-24 - 46a3595 / a42aada - lavc 54.59.100 / 54.28.0 - avcodec.h +2012-09-24 - a42aada - lavc 54.28.0 - avcodec.h Add avcodec_free_frame(). This function must now be used for freeing an AVFrame. -2012-09-12 - e3e09f2 / 8919fee - lavu 51.73.100 / 51.41.0 - audioconvert.h +2012-09-12 - 8919fee - lavu 51.41.0 - audioconvert.h Added AV_CH_LOW_FREQUENCY_2 channel mask value. -2012-09-04 - b21b5b0 / 686a329 - lavu 51.71.100 / 51.40.0 - opt.h +2012-09-04 - 686a329 - lavu 51.40.0 - opt.h Reordered the fields in default_val in AVOption, changed which default_val field is used for which AVOptionType. -2012-08-30 - 98298eb / a231832 - lavc 54.54.101 / 54.26.1 - avcodec.h +2012-08-30 - a231832 - lavc 54.26.1 - avcodec.h Add codec descriptor properties AV_CODEC_PROP_LOSSY and AV_CODEC_PROP_LOSSLESS. @@ -1558,90 +856,101 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 Add codec descriptors for accessing codec properties without having to refer to a specific decoder or encoder. - f5f3684 / c223d79 - Add an AVCodecDescriptor struct and functions + c223d79 - Add an AVCodecDescriptor struct and functions avcodec_descriptor_get() and avcodec_descriptor_next(). - f5f3684 / 51efed1 - Add AVCodecDescriptor.props and AV_CODEC_PROP_INTRA_ONLY. - 6c180b3 / 91e59fe - Add avcodec_descriptor_get_by_name(). + 51efed1 - Add AVCodecDescriptor.props and AV_CODEC_PROP_INTRA_ONLY. + 91e59fe - Add avcodec_descriptor_get_by_name(). -2012-08-08 - f5f3684 / 987170c - lavu 51.68.100 / 51.38.0 - dict.h + +2012-08-08 - 1d9c2dc - lavu 51.39 - avutil.h + Don't implicitly include libavutil/common.h in avutil.h + +2012-08-08 - 987170c - lavu 51.38 - dict.h Add av_dict_count(). -2012-08-07 - 7a72695 / 104e10f - lavc 54.51.100 / 54.25.0 - avcodec.h +2012-08-07 - 104e10f - lavc 54.25 - avcodec.h Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*. To provide backwards compatibility, CodecID is now #defined as AVCodecID. Note that this can break user code that includes avcodec.h and uses the 'CodecID' identifier. Such code should either #undef CodecID or stop using the CodecID name. -2012-08-03 - e776ee8 / 239fdf1 - lavu 51.66.101 / 51.37.1 - cpu.h +2012-08-03 - 239fdf1 - lavu 51.37.1 - cpu.h lsws 2.1.1 - swscale.h Rename AV_CPU_FLAG_MMX2 ---> AV_CPU_FLAG_MMXEXT. Rename SWS_CPU_CAPS_MMX2 ---> SWS_CPU_CAPS_MMXEXT. -2012-07-29 - 7c26761 / 681ed00 - lavf 54.22.100 / 54.13.0 - avformat.h +2012-07-29 - 681ed00 - lavf 54.13.0 - avformat.h Add AVFMT_FLAG_NOBUFFER for low latency use cases. -2012-07-10 - fbe0245 / f3e5e6f - lavu 51.65.100 / 51.37.0 +2012-07-20 - b70d89a - lavfi 3.0.0 - avfilter.h + Add avfilter_unref_bufferp(). + +2012-07-10 - 5fade8a - lavu 51.37.0 Add av_malloc_array() and av_mallocz_array() -2012-06-22 - e847f41 / d3d3a32 - lavu 51.61.100 / 51.34.0 +2012-06-22 - d3d3a32 - lavu 51.34.0 Add av_usleep() -2012-06-20 - 4da42eb / ae0a301 - lavu 51.60.100 / 51.33.0 +2012-06-20 - ae0a301 - lavu 51.33.0 Move av_gettime() to libavutil, add libavutil/time.h -2012-06-09 - 82edf67 / 3971be0 - lavr 0.0.3 +2012-06-09 - 3971be0 - lavr 0.0.3 Add a parameter to avresample_build_matrix() for Dolby/DPLII downmixing. -2012-06-12 - c7b9eab / 9baeff9 - lavfi 2.79.100 / 2.23.0 - avfilter.h +2012-06-12 - 9baeff9 - lavfi 2.23.0 - avfilter.h Add AVFilterContext.nb_inputs/outputs. Deprecate AVFilterContext.input/output_count. -2012-06-12 - c7b9eab / 84b9fbe - lavfi 2.79.100 / 2.22.0 - avfilter.h +2012-06-12 - 84b9fbe - lavfi 2.22.0 - avfilter.h Add avfilter_pad_get_type() and avfilter_pad_get_name(). Those should now be used instead of accessing AVFilterPad members directly. -2012-06-12 - 3630a07 / b0f0dfc - lavu 51.57.100 / 51.32.0 - audioconvert.h +2012-06-12 - b0f0dfc - lavu 51.32.0 - audioconvert.h Add av_get_channel_layout_channel_index(), av_get_channel_name() and av_channel_layout_extract_channel(). -2012-05-25 - 53ce990 / 154486f - lavu 51.55.100 / 51.31.0 - opt.h +2012-05-25 - 154486f - lavu 51.31.0 - opt.h Add av_opt_set_bin() -2012-05-15 - lavfi 2.74.100 / 2.17.0 +2012-05-26 - e9cef89 - lavf 54.3.0 + Add AVFMT_TS_NONSTRICT format flag to indicate that a muxer supports + non-increasing monotone timestamps. + +2012-05-15 - lavfi 2.17.0 Add support for audio filters - 61930bd / ac71230, 1cbf7fb / a2cd9be - add video/audio buffer sink in a new installed + ac71230/a2cd9be - add video/audio buffer sink in a new installed header buffersink.h - 1cbf7fb / 720c6b7 - add av_buffersrc_write_frame(), deprecate + 720c6b7 - add av_buffersrc_write_frame(), deprecate av_vsrc_buffer_add_frame() - 61930bd / ab16504 - add avfilter_copy_buf_props() - 61930bd / 9453c9e - add extended_data to AVFilterBuffer - 61930bd / 1b8c927 - add avfilter_get_audio_buffer_ref_from_arrays() + ab16504 - add avfilter_copy_buf_props() + 9453c9e - add extended_data to AVFilterBuffer + 1b8c927 - add avfilter_get_audio_buffer_ref_from_arrays() -2012-05-09 - lavu 51.53.100 / 51.30.0 - samplefmt.h - 61930bd / 142e740 - add av_samples_copy() - 61930bd / 6d7f617 - add av_samples_set_silence() +2012-05-09 - lavu 51.30.0 - samplefmt.h + 142e740 - add av_samples_copy() + 6d7f617 - add av_samples_set_silence() -2012-05-09 - 61930bd / a5117a2 - lavc 54.21.101 / 54.13.1 +2012-05-09 - a5117a2 - lavc 54.13.1 For audio formats with fixed frame size, the last frame no longer needs to be padded with silence, libavcodec will handle this internally (effectively all encoders behave as if they had CODEC_CAP_SMALL_LAST_FRAME set). -2012-05-07 - 653d117 / 828bd08 - lavc 54.20.100 / 54.13.0 - avcodec.h +2012-05-07 - 828bd08 - lavc 54.13.0 - avcodec.h Add sample_rate and channel_layout fields to AVFrame. -2012-05-01 - 2330eb1 / 4010d72 - lavr 0.0.1 +2012-05-01 - 4010d72 - lavr 0.0.1 Change AV_MIX_COEFF_TYPE_Q6 to AV_MIX_COEFF_TYPE_Q8. -2012-04-25 - e890b68 / 3527a73 - lavu 51.48.100 / 51.29.0 - cpu.h +2012-04-25 - 3527a73 - lavu 51.29.0 - cpu.h Add av_parse_cpu_flags() -2012-04-24 - 3ead79e / c8af852 - lavr 0.0.0 +2012-04-24 - c8af852 - lavr 0.0.0 Add libavresample audio conversion library -2012-04-20 - 3194ab7 / 0c0d1bc - lavu 51.47.100 / 51.28.0 - audio_fifo.h +2012-04-20 - 0c0d1bc - lavu 51.28.0 - audio_fifo.h Add audio FIFO functions: av_audio_fifo_free() av_audio_fifo_alloc() @@ -1653,165 +962,144 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 av_audio_fifo_size() av_audio_fifo_space() -2012-04-14 - lavfi 2.70.100 / 2.16.0 - avfiltergraph.h - 7432bcf / d7bcc71 Add avfilter_graph_parse2(). +2012-04-14 - lavfi 2.16.0 - avfiltergraph.h + d7bcc71 Add avfilter_graph_parse2(). + 91d3cbe Add avfilter_inout_alloc() and avfilter_inout_free(). -2012-04-08 - 6bfb304 / 4d693b0 - lavu 51.46.100 / 51.27.0 - samplefmt.h +2012-04-08 - 4d693b0 - lavu 51.27.0 - samplefmt.h Add av_get_packed_sample_fmt() and av_get_planar_sample_fmt() -2012-03-21 - b75c67d - lavu 51.43.100 - Add bprint.h for bprint API. +2012-04-05 - 5cc51a5 - lavu 51.26.0 - audioconvert.h + Add av_get_default_channel_layout() -2012-02-21 - 9cbf17e - lavc 54.4.100 - Add av_get_pcm_codec() function. - -2012-02-16 - 560b224 - libswr 0.7.100 - Add swr_set_matrix() function. - -2012-02-09 - c28e7af - lavu 51.39.100 - Add a new installed header libavutil/timestamp.h with timestamp - utilities. - -2012-02-06 - 70ffda3 - lavu 51.38.100 - Add av_parse_ratio() function to parseutils.h. - -2012-02-06 - 70ffda3 - lavu 51.38.100 - Add AV_LOG_MAX_OFFSET macro to log.h. - -2012-02-02 - 0eaa123 - lavu 51.37.100 - Add public timecode helpers. - -2012-01-24 - 0c3577b - lavfi 2.60.100 - Add avfilter_graph_dump. - -2012-03-20 - 0ebd836 / 3c90cc2 - lavfo 54.2.0 +2012-03-20 - 3c90cc2 - lavfo 54.2.0 Deprecate av_read_packet(), use av_read_frame() with AVFMT_FLAG_NOPARSE | AVFMT_FLAG_NOFILLIN in AVFormatContext.flags -2012-03-05 - lavc 54.10.100 / 54.8.0 - f095391 / 6699d07 Add av_get_exact_bits_per_sample() - f095391 / 9524cf7 Add av_get_audio_frame_duration() +2012-03-06 - 4d851f8 - lavu 51.25.0 - cpu.h + Add av_set_cpu_flags_mask(). -2012-03-04 - 2af8f2c / 44fe77b - lavc 54.8.100 / 54.7.0 - avcodec.h +2012-03-05 - lavc 54.8.0 + 6699d07 Add av_get_exact_bits_per_sample() + 9524cf7 Add av_get_audio_frame_duration() + +2012-03-04 - 44fe77b - lavc 54.7.0 - avcodec.h Add av_codec_is_encoder/decoder(). -2012-03-01 - 1eb7f39 / 442c132 - lavc 54.5.100 / 54.3.0 - avcodec.h +2012-03-01 - 442c132 - lavc 54.3.0 - avcodec.h Add av_packet_shrink_side_data. -2012-02-29 - 79ae084 / dd2a4bc - lavf 54.2.100 / 54.2.0 - avformat.h +2012-02-29 - dd2a4bc - lavf 54.2.0 - avformat.h Add AVStream.attached_pic and AV_DISPOSITION_ATTACHED_PIC, used for dealing with attached pictures/cover art. -2012-02-25 - 305e4b3 / c9bca80 - lavu 51.41.100 / 51.24.0 - error.h +2012-02-25 - c9bca80 - lavu 51.24.0 - error.h Add AVERROR_UNKNOWN NOTE: this was backported to 0.8 -2012-02-20 - eadd426 / e9cda85 - lavc 54.2.100 / 54.2.0 +2012-02-20 - e9cda85 - lavc 54.2.0 Add duration field to AVCodecParserContext -2012-02-20 - eadd426 / 0b42a93 - lavu 51.40.100 / 51.23.1 - mathematics.h +2012-02-20 - 0b42a93 - lavu 51.23.1 - mathematics.h Add av_rescale_q_rnd() -2012-02-08 - f2b20b7 / 38d5533 - lavu 51.38.101 / 51.22.1 - pixdesc.h +2012-02-08 - 38d5533 - lavu 51.22.1 - pixdesc.h Add PIX_FMT_PSEUDOPAL flag. -2012-02-08 - f2b20b7 / 52f82a1 - lavc 54.2.100 / 54.1.0 +2012-02-08 - 52f82a1 - lavc 54.01.0 Add avcodec_encode_video2() and deprecate avcodec_encode_video(). -2012-02-01 - 4c677df / 316fc74 - lavc 54.1.0 +2012-02-01 - 316fc74 - lavc 54.01.0 Add av_fast_padded_malloc() as alternative for av_realloc() when aligned memory is required. The buffer will always have FF_INPUT_BUFFER_PADDING_SIZE zero-padded bytes at the end. -2012-01-31 - a369a6b / dd6d3b0 - lavf 54.1.0 +2012-01-31 - dd6d3b0 - lavf 54.01.0 Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags(). NOTE: this was backported to 0.8 -2012-01-31 - a369a6b / af08d9a - lavc 54.1.0 +2012-01-31 - af08d9a - lavc 54.01.0 Add avcodec_is_open() function. NOTE: this was backported to 0.8 -2012-01-30 - 151ecc2 / 8b93312 - lavu 51.36.100 / 51.22.0 - intfloat.h +2012-01-30 - 8b93312 - lavu 51.22.0 - intfloat.h Add a new installed header libavutil/intfloat.h with int/float punning functions. NOTE: this was backported to 0.8 -2012-01-25 - lavf 53.31.100 / 53.22.0 - 3c5fe5b / f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible +2012-01-25 - lavf 53.22.0 + f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible buffered data within a muxer. Added AVFMT_ALLOW_FLUSH for muxers supporting it (av_write_frame makes sure it is called only for muxers with this flag). -2012-01-15 - lavc 53.56.105 / 53.34.0 +------------------------------8<------------------------------------- + 0.8 branch was cut here +----------------------------->8-------------------------------------- + +2012-01-15 - lavc 53.34.0 New audio encoding API: - 67f5650 / b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio + b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio encoders. - 67f5650 / 5ee5fa0 Add avcodec_fill_audio_frame() as a convenience function. - 67f5650 / b2c75b6 Add avcodec_encode_audio2() and deprecate avcodec_encode_audio(). + 5ee5fa0 Add avcodec_fill_audio_frame() as a convenience function. + b2c75b6 Add avcodec_encode_audio2() and deprecate avcodec_encode_audio(). Add AVCodec.encode2(). -2012-01-12 - b18e17e / 3167dc9 - lavfi 2.59.100 / 2.15.0 +2012-01-12 - 3167dc9 - lavfi 2.15.0 Add a new installed header -- libavfilter/version.h -- with version macros. - --------- 8< --------- FFmpeg 0.9 was cut here -------- 8< --------- - -2011-12-08 - a502939 - lavfi 2.52.0 - Add av_buffersink_poll_frame() to buffersink.h. - -2011-12-08 - 26c6fec - lavu 51.31.0 - Add av_log_format_line. - -2011-12-03 - 976b095 - lavu 51.30.0 - Add AVERROR_BUG. - -2011-11-24 - 573ffbb - lavu 51.28.1 - Add av_get_alt_sample_fmt() to samplefmt.h. - -2011-11-03 - 96949da - lavu 51.23.0 - Add av_strcasecmp() and av_strncasecmp() to avstring.h. - -2011-10-20 - b35e9e1 - lavu 51.22.0 - Add av_strtok() to avstring.h. - -2012-01-03 - ad1c8dd / b73ec05 - lavu 51.34.100 / 51.21.0 +2011-01-03 - b73ec05 - lavu 51.21.0 Add av_popcount64 -2011-12-18 - 7c29313 / 8400b12 - lavc 53.46.1 / 53.28.1 +2011-12-25 - lavfi 2.14.0 + e1d9dbf Add a new installed header - buffersrc.h + It contains a new function av_buffersrc_buffer() that allows passing + frames to the 'buffer' filter, but unlike av_vsrc_buffer_add_frame() + it allows for direct rendering. + 1c9e340 Add avfilter_copy_frame_props() for copying properties from + AVFrame to AVFilterBufferRef. + +2011-12-25 - lavc 53.31.0 + Add the following new fields to AVFrame: + b58dbb5 sample_aspect_ratio + 3a2ddf7 width, height + 8a4a5f6 format + +2011-12-18 - 8400b12 - lavc 53.28.1 Deprecate AVFrame.age. The field is unused. -2011-12-12 - 8bc7fe4 / 5266045 - lavf 53.25.0 / 53.17.0 +2011-12-12 - 5266045 - lavf 53.17.0 Add avformat_close_input(). Deprecate av_close_input_file() and av_close_input_stream(). -2011-12-09 - c59b80c / b2890f5 - lavu 51.32.0 / 51.20.0 - audioconvert.h +2011-12-09 - b2890f5 - lavu 51.20.0 - audioconvert.h Expand the channel layout list. -2011-12-02 - e4de716 / 0eea212 - lavc 53.40.0 / 53.25.0 +2011-12-02 - 0eea212 - lavc 53.25.0 Add nb_samples and extended_data fields to AVFrame. Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE. Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4(). avcodec_decode_audio4() writes output samples to an AVFrame, which allows audio decoders to use get_buffer(). -2011-12-04 - e4de716 / 560f773 - lavc 53.40.0 / 53.24.0 +2011-12-04 - 560f773 - lavc 53.24.0 Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump. Change AVPicture.data[4]/linesize[4] to [8] at next major bump. Change AVCodecContext.error[4] to [8] at next major bump. Add AV_NUM_DATA_POINTERS to simplify the bump transition. -2011-11-24 - lavu 51.29.0 / 51.19.0 - 92afb43 / bd97b2e - add planar RGB pixel formats - 92afb43 / 6b0768e - add PIX_FMT_PLANAR and PIX_FMT_RGB pixel descriptions +2011-11-24 - lavu 51.19.0 + bd97b2e - add planar RGB pixel formats + 6b0768e - add PIX_FMT_PLANAR and PIX_FMT_RGB pixel descriptions -2011-11-23 - 8e576d5 / bbb46f3 - lavu 51.27.0 / 51.18.0 +2011-11-23 - bbb46f3 - lavu 51.18.0 Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and av_samples_alloc(), to samplefmt.h. -2011-11-23 - 8e576d5 / 8889cc4 - lavu 51.27.0 / 51.17.0 +2011-11-23 - 8889cc4 - lavu 51.17.0 Add planar sample formats and av_sample_fmt_is_planar() to samplefmt.h. -2011-11-19 - dbb38bc / f3a29b7 - lavc 53.36.0 / 53.21.0 +2011-11-19 - f3a29b7 - lavc 53.21.0 Move some AVCodecContext fields to a new private struct, AVCodecInternal, which is accessed from a new field, AVCodecContext.internal. - fields moved: @@ -1819,371 +1107,220 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 AVCodecContext.internal_buffer_count --> AVCodecInternal.buffer_count AVCodecContext.is_copy --> AVCodecInternal.is_copy -2011-11-16 - 8709ba9 / 6270671 - lavu 51.26.0 / 51.16.0 +2011-11-16 - 6270671 - lavu 51.16.0 Add av_timegm() -2011-11-13 - lavf 53.21.0 / 53.15.0 +2011-11-13 - lavf 53.15.0 New interrupt callback API, allowing per-AVFormatContext/AVIOContext interrupt callbacks. - 5f268ca / 6aa0b98 Add AVIOInterruptCB struct and the interrupt_callback field to + 6aa0b98 Add AVIOInterruptCB struct and the interrupt_callback field to AVFormatContext. - 5f268ca / 1dee0ac Add avio_open2() with additional parameters. Those are + 1dee0ac Add avio_open2() with additional parameters. Those are an interrupt callback and an options AVDictionary. This will allow passing AVOptions to protocols after lavf 54.0. -2011-11-06 - 13b7781 / ba04ecf - lavu 51.24.0 / 51.14.0 +2011-11-06 - ba04ecf - lavu 51.14.0 Add av_strcasecmp() and av_strncasecmp() to avstring.h. -2011-11-06 - 13b7781 / 07b172f - lavu 51.24.0 / 51.13.0 +2011-11-06 - 07b172f - lavu 51.13.0 Add av_toupper()/av_tolower() -2011-11-05 - d8cab5c / b6d08f4 - lavf 53.19.0 / 53.13.0 +2011-11-05 - b6d08f4 - lavf 53.13.0 Add avformat_network_init()/avformat_network_deinit() -2011-10-27 - 6faf0a2 / 512557b - lavc 53.24.0 / 53.15.0 +2011-10-27 - 512557b - lavc 53.15.0 Remove avcodec_parse_frame. Deprecate AVCodecContext.parse_only and CODEC_CAP_PARSE_ONLY. -2011-10-19 - d049257 / 569129a - lavf 53.17.0 / 53.10.0 +2011-10-19 - 569129a - lavf 53.10.0 Add avformat_new_stream(). Deprecate av_new_stream(). -2011-10-13 - 91eb1b1 / b631fba - lavf 53.16.0 / 53.9.0 +2011-10-13 - b631fba - lavf 53.9.0 Add AVFMT_NO_BYTE_SEEK AVInputFormat flag. -2011-10-12 - lavu 51.21.0 / 51.12.0 +2011-10-12 - lavu 51.12.0 AVOptions API rewrite. - - f884ef0 / 145f741 FF_OPT_TYPE* renamed to AV_OPT_TYPE_* + - 145f741 FF_OPT_TYPE* renamed to AV_OPT_TYPE_* - new setting/getting functions with slightly different semantics: - f884ef0 / dac66da av_set_string3 -> av_opt_set + dac66da av_set_string3 -> av_opt_set av_set_double -> av_opt_set_double av_set_q -> av_opt_set_q av_set_int -> av_opt_set_int - f884ef0 / 41d9d51 av_get_string -> av_opt_get + 41d9d51 av_get_string -> av_opt_get av_get_double -> av_opt_get_double av_get_q -> av_opt_get_q av_get_int -> av_opt_get_int - - f884ef0 / 8c5dcaa trivial rename av_next_option -> av_opt_next - - f884ef0 / 641c7af new functions - av_opt_child_next, av_opt_child_class_next + - 8c5dcaa trivial rename av_next_option -> av_opt_next + - 641c7af new functions - av_opt_child_next, av_opt_child_class_next and av_opt_find2() -2011-09-22 - a70e787 - lavu 51.17.0 - Add av_x_if_null(). - -2011-09-18 - 645cebb - lavc 53.16.0 - Add showall flag2 - -2011-09-16 - ea8de10 - lavfi 2.42.0 - Add avfilter_all_channel_layouts. - -2011-09-16 - 9899037 - lavfi 2.41.0 - Rename avfilter_all_* function names to avfilter_make_all_*. - - In particular, apply the renames: - avfilter_all_formats -> avfilter_make_all_formats - avfilter_all_channel_layouts -> avfilter_make_all_channel_layouts - avfilter_all_packing_formats -> avfilter_make_all_packing_formats - -2011-09-12 - 4381bdd - lavfi 2.40.0 - Change AVFilterBufferRefAudioProps.sample_rate type from uint32_t to int. - -2011-09-12 - 2c03174 - lavfi 2.40.0 - Simplify signature for avfilter_get_audio_buffer(), make it - consistent with avfilter_get_video_buffer(). - -2011-09-06 - 4f7dfe1 - lavfi 2.39.0 - Rename libavfilter/vsink_buffer.h to libavfilter/buffersink.h. - -2011-09-06 - c4415f6 - lavfi 2.38.0 - Unify video and audio sink API. - - In particular, add av_buffersink_get_buffer_ref(), deprecate - av_vsink_buffer_get_video_buffer_ref() and change the value for the - opaque field passed to the abuffersink init function. - -2011-09-04 - 61e2e29 - lavu 51.16.0 - Add av_asprintf(). - -2011-08-22 - dacd827 - lavf 53.10.0 - Add av_find_program_from_stream(). - -2011-08-20 - 69e2c1a - lavu 51.13.0 - Add av_get_media_type_string(). - -2011-09-03 - 1889c67 / fb4ca26 - lavc 53.13.0 - lavf 53.11.0 +2011-09-03 - fb4ca26 - lavc 53.10.0 + lavf 53.6.0 lsws 2.1.0 Add {avcodec,avformat,sws}_get_class(). -2011-08-03 - 1889c67 / c11fb82 - lavu 51.15.0 +2011-09-03 - c11fb82 - lavu 51.10.0 Add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find() function. -2011-08-14 - 323b930 - lavu 51.12.0 - Add av_fifo_peek2(), deprecate av_fifo_peek(). - -2011-08-26 - lavu 51.14.0 / 51.9.0 - - 976a8b2 / add41de..976a8b2 / abc78a5 Do not include intfloat_readwrite.h, +2011-08-26 - lavu 51.9.0 + - f2011ed Add av_fifo_peek2(), deprecate av_fifo_peek(). + - add41de..abc78a5 Do not include intfloat_readwrite.h, mathematics.h, rational.h, pixfmt.h, or log.h from avutil.h. -2011-08-16 - 27fbe31 / 48f9e45 - lavf 53.11.0 / 53.8.0 +2011-08-16 - 48f9e45 - lavf 53.4.0 Add avformat_query_codec(). -2011-08-16 - 27fbe31 / bca06e7 - lavc 53.11.0 +2011-08-16 - bca06e7 - lavc 53.8.0 Add avcodec_get_type(). -2011-08-06 - 0cb233c / 2f63440 - lavf 53.7.0 +2011-08-06 - 2f63440 - lavf 53.4.0 Add error_recognition to AVFormatContext. -2011-08-02 - 1d186e9 / 9d39cbf - lavc 53.9.1 +2011-08-02 - 9d39cbf - lavc 53.7.1 Add AV_PKT_FLAG_CORRUPT AVPacket flag. -2011-07-16 - b57df29 - lavfi 2.27.0 - Add audio packing negotiation fields and helper functions. - - In particular, add AVFilterPacking enum, planar, in_packings and - out_packings fields to AVFilterLink, and the functions: - avfilter_set_common_packing_formats() - avfilter_all_packing_formats() - -2011-07-10 - 3602ad7 / a67c061 - lavf 53.6.0 +2011-07-10 - a67c061 - lavf 53.3.0 Add avformat_find_stream_info(), deprecate av_find_stream_info(). NOTE: this was backported to 0.7 -2011-07-10 - 3602ad7 / 0b950fe - lavc 53.8.0 +2011-07-10 - 0b950fe - lavc 53.6.0 Add avcodec_open2(), deprecate avcodec_open(). NOTE: this was backported to 0.7 Add avcodec_alloc_context3. Deprecate avcodec_alloc_context() and avcodec_alloc_context2(). -2011-07-01 - b442ca6 - lavf 53.5.0 - avformat.h - Add function av_get_output_timestamp(). - -2011-06-28 - 5129336 - lavu 51.11.0 - avutil.h - Define the AV_PICTURE_TYPE_NONE value in AVPictureType enum. - - --------- 8< --------- FFmpeg 0.7 was cut here -------- 8< --------- - - - --------- 8< --------- FFmpeg 0.8 was cut here -------- 8< --------- - -2011-06-19 - fd2c0a5 - lavfi 2.23.0 - avfilter.h - Add layout negotiation fields and helper functions. - - In particular, add in_chlayouts and out_chlayouts to AVFilterLink, - and the functions: - avfilter_set_common_sample_formats() - avfilter_set_common_channel_layouts() - avfilter_all_channel_layouts() - -2011-06-19 - 527ca39 - lavfi 2.22.0 - AVFilterFormats - Change type of AVFilterFormats.formats from int * to int64_t *, - and update formats handling API accordingly. - - avfilter_make_format_list() still takes a int32_t array and converts - it to int64_t. A new function, avfilter_make_format64_list(), that - takes int64_t arrays has been added. - -2011-06-19 - 44f669e - lavfi 2.21.0 - vsink_buffer.h - Add video sink buffer and vsink_buffer.h public header. - -2011-06-12 - 9fdf772 - lavfi 2.18.0 - avcodec.h - Add avfilter_get_video_buffer_ref_from_frame() function in - libavfilter/avcodec.h. - -2011-06-12 - c535494 - lavfi 2.17.0 - avfiltergraph.h - Add avfilter_inout_alloc() and avfilter_inout_free() functions. - -2011-06-12 - 6119b23 - lavfi 2.16.0 - avfilter_graph_parse() - Change avfilter_graph_parse() signature. - -2011-06-23 - 686959e / 67e9ae1 - lavu 51.10.0 / 51.8.0 - attributes.h +2011-06-23 - 67e9ae1 - lavu 51.8.0 - attributes.h Add av_printf_format(). -2011-06-16 - 2905e3f / 05e84c9, 2905e3f / 25de595 - lavf 53.4.0 / 53.2.0 - avformat.h +------------------------------8<------------------------------------- + 0.7 branch was cut here +----------------------------->8-------------------------------------- + +2011-06-16 - 05e84c9, 25de595 - lavf 53.2.0 - avformat.h Add avformat_open_input and avformat_write_header(). Deprecate av_open_input_stream, av_open_input_file, AVFormatParameters and av_write_header. -2011-06-16 - 2905e3f / 7e83e1c, 2905e3f / dc59ec5 - lavu 51.9.0 / 51.7.0 - opt.h +2011-06-16 - 7e83e1c, dc59ec5 - lavu 51.7.0 - opt.h Add av_opt_set_dict() and av_opt_find(). Deprecate av_find_opt(). Add AV_DICT_APPEND flag. -2011-06-10 - 45fb647 / cb7c11c - lavu 51.6.0 - opt.h +2011-06-10 - cb7c11c - lavu 51.6.0 - opt.h Add av_opt_flag_is_set(). -2011-06-10 - c381960 - lavfi 2.15.0 - avfilter_get_audio_buffer_ref_from_arrays - Add avfilter_get_audio_buffer_ref_from_arrays() to avfilter.h. - -2011-06-09 - f9ecb84 / d9f80ea - lavu 51.8.0 - AVMetadata +2011-06-08 - d9f80ea - lavu 51.5.0 - AVMetadata Move AVMetadata from lavf to lavu and rename it to AVDictionary -- new installed header dict.h. All av_metadata_* functions renamed to av_dict_*. -2011-06-07 - d552f61 / a6703fa - lavu 51.8.0 - av_get_bytes_per_sample() +2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample() Add av_get_bytes_per_sample() in libavutil/samplefmt.h. Deprecate av_get_bits_per_sample_fmt(). -2011-06-05 - f956924 / b39b062 - lavu 51.8.0 - opt.h +2011-06-05 - b39b062 - lavu 51.3.0 - opt.h Add av_opt_free convenience function. -2011-06-06 - 95a0242 - lavfi 2.14.0 - AVFilterBufferRefAudioProps - Remove AVFilterBufferRefAudioProps.size, and use nb_samples in - avfilter_get_audio_buffer() and avfilter_default_get_audio_buffer() in - place of size. - -2011-06-06 - 0bc2cca - lavu 51.6.0 - av_samples_alloc() - Switch nb_channels and nb_samples parameters order in - av_samples_alloc(). - -2011-06-06 - e1c7414 - lavu 51.5.0 - av_samples_* - Change the data layout created by av_samples_fill_arrays() and - av_samples_alloc(). - -2011-06-06 - 27bcf55 - lavfi 2.13.0 - vsrc_buffer.h - Make av_vsrc_buffer_add_video_buffer_ref() accepts an additional - flags parameter in input. - -2011-06-03 - e977ca2 - lavfi 2.12.0 - avfilter_link_free() - Add avfilter_link_free() function. - -2011-06-02 - 5ad38d9 - lavu 51.4.0 - av_force_cpu_flags() - Add av_cpu_flags() in libavutil/cpu.h. - -2011-05-28 - e71f260 - lavu 51.3.0 - pixdesc.h +2011-05-28 - 0420bd7 - lavu 51.2.0 - pixdesc.h Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor. -2011-05-25 - 39e4206 / 30315a8 - lavf 53.3.0 - avformat.h +2011-05-25 - 30315a8 - lavf 53.1.0 - avformat.h Add fps_probe_size to AVFormatContext. -2011-05-22 - 5ecdfd0 - lavf 53.2.0 - avformat.h - Introduce avformat_alloc_output_context2() and deprecate - avformat_alloc_output_context(). - -2011-05-22 - 83db719 - lavfi 2.10.0 - vsrc_buffer.h - Make libavfilter/vsrc_buffer.h public. - -2011-05-19 - c000a9f - lavfi 2.8.0 - avcodec.h - Add av_vsrc_buffer_add_frame() to libavfilter/avcodec.h. - -2011-05-14 - 9fdf772 - lavfi 2.6.0 - avcodec.h - Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h. - -2011-05-18 - 75a37b5 / 64150ff - lavc 53.7.0 - AVCodecContext.request_sample_fmt +2011-05-18 - 64150ff - lavc 53.4.0 - AVCodecContext.request_sample_fmt Add request_sample_fmt field to AVCodecContext. -2011-05-10 - 59eb12f / 188dea1 - lavc 53.6.0 - avcodec.h +2011-05-10 - 188dea1 - lavc 53.3.0 - avcodec.h Deprecate AVLPCType and the following fields in AVCodecContext: lpc_coeff_precision, prediction_order_method, min_partition_order, max_partition_order, lpc_type, lpc_passes. Corresponding FLAC encoder options should be used instead. -2011-05-07 - 9fdf772 - lavfi 2.5.0 - avcodec.h - Add libavfilter/avcodec.h header and avfilter_copy_frame_props() - function. - -2011-05-07 - 18ded93 - lavc 53.5.0 - AVFrame - Add format field to AVFrame. - -2011-05-07 - 22333a6 - lavc 53.4.0 - AVFrame - Add width and height fields to AVFrame. - -2011-05-01 - 35fe66a - lavfi 2.4.0 - avfilter.h - Rename AVFilterBufferRefVideoProps.pixel_aspect to - sample_aspect_ratio. - -2011-05-01 - 77e9dee - lavc 53.3.0 - AVFrame - Add a sample_aspect_ratio field to AVFrame. - -2011-05-01 - 1ba5727 - lavc 53.2.0 - AVFrame - Add a pkt_pos field to AVFrame. - -2011-04-29 - 35ceaa7 - lavu 51.2.0 - mem.h - Add av_dynarray_add function for adding - an element to a dynamic array. - -2011-04-26 - d7e5aeb / bebe72f - lavu 51.1.0 - avutil.h +2011-04-26 - bebe72f - lavu 51.1.0 - avutil.h Add AVPictureType enum and av_get_picture_type_char(), deprecate FF_*_TYPE defines and av_get_pict_type_char() defined in libavcodec/avcodec.h. -2011-04-26 - d7e5aeb / 10d3940 - lavfi 2.3.0 - avfilter.h +2011-04-26 - 10d3940 - lavfi 2.3.0 - avfilter.h Add pict_type and key_frame fields to AVFilterBufferRefVideo. -2011-04-26 - d7e5aeb / 7a11c82 - lavfi 2.2.0 - vsrc_buffer +2011-04-26 - 7a11c82 - lavfi 2.2.0 - vsrc_buffer Add sample_aspect_ratio fields to vsrc_buffer arguments -2011-04-21 - 8772156 / 94f7451 - lavc 53.1.0 - avcodec.h +2011-04-21 - 94f7451 - lavc 53.1.0 - avcodec.h Add CODEC_CAP_SLICE_THREADS for codecs supporting sliced threading. 2011-04-15 - lavc 52.120.0 - avcodec.h AVPacket structure got additional members for passing side information: - c407984 / 4de339e introduce side information for AVPacket - c407984 / 2d8591c make containers pass palette change in AVPacket + 4de339e introduce side information for AVPacket + 2d8591c make containers pass palette change in AVPacket 2011-04-12 - lavf 52.107.0 - avio.h Avio cleanup, part II - deprecate the entire URLContext API: - c55780d / 175389c add avio_check as a replacement for url_exist - 9891004 / ff1ec0c add avio_pause and avio_seek_time as replacements + 175389c add avio_check as a replacement for url_exist + ff1ec0c add avio_pause and avio_seek_time as replacements for _av_url_read_fseek/fpause - d4d0932 / cdc6a87 deprecate av_protocol_next(), avio_enum_protocols + cdc6a87 deprecate av_protocol_next(), avio_enum_protocols should be used instead. - c88caa5 / 80c6e23 rename url_set_interrupt_cb->avio_set_interrupt_cb. - c88caa5 / f87b1b3 rename open flags: URL_* -> AVIO_* - d4d0932 / f8270bb add avio_enum_protocols. - d4d0932 / 5593f03 deprecate URLProtocol. - d4d0932 / c486dad deprecate URLContext. - d4d0932 / 026e175 deprecate the typedef for URLInterruptCB - c88caa5 / 8e76a19 deprecate av_register_protocol2. - 11d7841 / b840484 deprecate URL_PROTOCOL_FLAG_NESTED_SCHEME - 11d7841 / 1305d93 deprecate av_url_read_seek - 11d7841 / fa104e1 deprecate av_url_read_pause - 434f248 / 727c7aa deprecate url_get_filename(). - 434f248 / 5958df3 deprecate url_max_packet_size(). - 434f248 / 1869ea0 deprecate url_get_file_handle(). - 434f248 / 32a97d4 deprecate url_filesize(). - 434f248 / e52a914 deprecate url_close(). - 434f248 / 58a48c6 deprecate url_seek(). - 434f248 / 925e908 deprecate url_write(). - 434f248 / dce3756 deprecate url_read_complete(). - 434f248 / bc371ac deprecate url_read(). - 434f248 / 0589da0 deprecate url_open(). - 434f248 / 62eaaea deprecate url_connect. - 434f248 / 5652bb9 deprecate url_alloc. - 434f248 / 333e894 deprecate url_open_protocol - 434f248 / e230705 deprecate url_poll and URLPollEntry + 80c6e23 rename url_set_interrupt_cb->avio_set_interrupt_cb. + f87b1b3 rename open flags: URL_* -> AVIO_* + f8270bb add avio_enum_protocols. + 5593f03 deprecate URLProtocol. + c486dad deprecate URLContext. + 026e175 deprecate the typedef for URLInterruptCB + 8e76a19 deprecate av_register_protocol2. + b840484 deprecate URL_PROTOCOL_FLAG_NESTED_SCHEME + 1305d93 deprecate av_url_read_seek + fa104e1 deprecate av_url_read_pause + 727c7aa deprecate url_get_filename(). + 5958df3 deprecate url_max_packet_size(). + 1869ea0 deprecate url_get_file_handle(). + 32a97d4 deprecate url_filesize(). + e52a914 deprecate url_close(). + 58a48c6 deprecate url_seek(). + 925e908 deprecate url_write(). + dce3756 deprecate url_read_complete(). + bc371ac deprecate url_read(). + 0589da0 deprecate url_open(). + 62eaaea deprecate url_connect. + 5652bb9 deprecate url_alloc. + 333e894 deprecate url_open_protocol + e230705 deprecate url_poll and URLPollEntry + +2011-04-10 - lavu 50.40.0 - pixfmt.h + Add PIX_FMT_BGR48LE and PIX_FMT_BGR48BE pixel formats 2011-04-08 - lavf 52.106.0 - avformat.h Minor avformat.h cleanup: - d4d0932 / a9bf9d8 deprecate av_guess_image2_codec - d4d0932 / c3675df rename avf_sdp_create->av_sdp_create + a9bf9d8 deprecate av_guess_image2_codec + c3675df rename avf_sdp_create->av_sdp_create 2011-04-03 - lavf 52.105.0 - avio.h Large-scale renaming/deprecating of AVIOContext-related functions: - 2cae980 / 724f6a0 deprecate url_fdopen - 2cae980 / 403ee83 deprecate url_open_dyn_packet_buf - 2cae980 / 6dc7d80 rename url_close_dyn_buf -> avio_close_dyn_buf - 2cae980 / b92c545 rename url_open_dyn_buf -> avio_open_dyn_buf - 2cae980 / 8978fed introduce an AVIOContext.seekable field as a replacement for + 724f6a0 deprecate url_fdopen + 403ee83 deprecate url_open_dyn_packet_buf + 6dc7d80 rename url_close_dyn_buf -> avio_close_dyn_buf + b92c545 rename url_open_dyn_buf -> avio_open_dyn_buf + 8978fed introduce an AVIOContext.seekable field as a replacement for AVIOContext.is_streamed and url_is_streamed() - 1caa412 / b64030f deprecate get_checksum() - 1caa412 / 4c4427a deprecate init_checksum() - 2fd41c9 / 4ec153b deprecate udp_set_remote_url/get_local_port - 4fa0e24 / 933e90a deprecate av_url_read_fseek/fpause - 4fa0e24 / 8d9769a deprecate url_fileno - 0fecf26 / b7f2fdd rename put_flush_packet -> avio_flush - 0fecf26 / 35f1023 deprecate url_close_buf - 0fecf26 / 83fddae deprecate url_open_buf - 0fecf26 / d9d86e0 rename url_fprintf -> avio_printf - 0fecf26 / 59f65d9 deprecate url_setbufsize - 6947b0c / 3e68b3b deprecate url_ferror + b64030f deprecate get_checksum() + 4c4427a deprecate init_checksum() + 4ec153b deprecate udp_set_remote_url/get_local_port + 933e90a deprecate av_url_read_fseek/fpause + 8d9769a deprecate url_fileno + b7f2fdd rename put_flush_packet -> avio_flush + 35f1023 deprecate url_close_buf + 83fddae deprecate url_open_buf + d9d86e0 rename url_fprintf -> avio_printf + 59f65d9 deprecate url_setbufsize + 3e68b3b deprecate url_ferror + 66e5b1d deprecate url_feof e8bb2e2 deprecate url_fget_max_packet_size 76aa876 rename url_fsize -> avio_size e519753 deprecate url_fgetc @@ -2204,12 +1341,9 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 b3db9ce deprecate get_partial_buffer 8d9ac96 rename av_alloc_put_byte -> avio_alloc_context -2011-03-25 - 27ef7b1 / 34b47d7 - lavc 52.115.0 - AVCodecContext.audio_service_type +2011-03-25 - 34b47d7 - lavc 52.115.0 - AVCodecContext.audio_service_type Add audio_service_type field to AVCodecContext. -2011-03-17 - e309fdc - lavu 50.40.0 - pixfmt.h - Add PIX_FMT_BGR48LE and PIX_FMT_BGR48BE pixel formats - 2011-03-02 - 863c471 - lavf 52.103.0 - av_pkt_dump2, av_pkt_dump_log2 Add new functions av_pkt_dump2, av_pkt_dump_log2 that uses the source stream timebase for outputting timestamps. Deprecate @@ -2242,11 +1376,11 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 2011-02-10 - 12c14cd - lavf 52.99.0 - AVStream.disposition Add AV_DISPOSITION_HEARING_IMPAIRED and AV_DISPOSITION_VISUAL_IMPAIRED. -2011-02-09 - c0b102c - lavc 52.112.0 - avcodec_thread_init() +2011-02-09 - 5592734 - lavc 52.112.0 - avcodec_thread_init() Deprecate avcodec_thread_init()/avcodec_thread_free() use; instead set thread_count before calling avcodec_open. -2011-02-09 - 37b00b4 - lavc 52.111.0 - threading API +2011-02-09 - 778b08a - lavc 52.111.0 - threading API Add CODEC_CAP_FRAME_THREADS with new restrictions on get_buffer()/ release_buffer()/draw_horiz_band() callbacks for appropriate codecs. Add thread_type and active_thread_type fields to AVCodecContext. @@ -2276,12 +1410,6 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 2011-02-02 - dfd2a00 - lavu 50.37.0 - log.h Make av_dlog public. -2011-01-31 - 7b3ea55 - lavfi 1.76.0 - vsrc_buffer - Add sample_aspect_ratio fields to vsrc_buffer arguments - -2011-01-31 - 910b5b8 - lavfi 1.75.0 - AVFilterLink sample_aspect_ratio - Add sample_aspect_ratio field to AVFilterLink. - 2011-01-15 - a242ac3 - lavfi 1.74.0 - AVFilterBufferRefAudioProps Rename AVFilterBufferRefAudioProps.samples_nb to nb_samples. @@ -2649,9 +1777,6 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 2010-06-02 - 7e566bb - lavc 52.73.0 - av_get_codec_tag_string() Add av_get_codec_tag_string(). - --------- 8< --------- FFmpeg 0.6 was cut here -------- 8< --------- - 2010-06-01 - 2b99142 - lsws 0.11.0 - convertPalette API Add sws_convertPalette8ToPacked32() and sws_convertPalette8ToPacked24(). @@ -2669,6 +1794,10 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 2010-05-09 - b6bc205 - lavfi 1.20.0 - AVFilterPicRef Add interlaced and top_field_first fields to AVFilterPicRef. +------------------------------8<------------------------------------- + 0.6 branch was cut here +----------------------------->8-------------------------------------- + 2010-05-01 - 8e2ee18 - lavf 52.62.0 - probe function Add av_probe_input_format2 to API, it allows ignoring probe results below given score and returns the actual probe score. diff --git a/doc/Doxyfile b/doc/Doxyfile index 0891899505..08c81f37ee 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1,129 +1,102 @@ -# Doxyfile 1.8.8 +# Doxyfile 1.7.1 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. +# doxygen (www.doxygen.org) for a project # -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. +# All text after a hash (#) is considered a comment and will be ignored # The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. -PROJECT_NAME = FFmpeg +PROJECT_NAME = Libav -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. PROJECT_NUMBER = -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. - +# With the PROJECT_LOGO tag one can specify an logo or icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will +# copy the logo to the output directory. PROJECT_LOGO = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc/doxy -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. -# The default value is: YES. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief +# Doxygen will generate a detailed section even if there is only a brief # description. -# The default value is: NO. ALWAYS_DETAILED_SEC = NO @@ -131,207 +104,153 @@ ALWAYS_DETAILED_SEC = NO # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. -# The default value is: NO. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. STRIP_FROM_PATH = . -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = . +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. -# The default value is: NO. +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. -TAB_SIZE = 4 +TAB_SIZE = 8 -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. +# sources. Doxygen will then generate output that is tailored for +# VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. -# The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. -# The default value is: NO. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES @@ -339,470 +258,371 @@ IDL_PROPERTY_SUPPORT = YES # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. -# The default value is: NO. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. SUBGROUPING = YES -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. TYPEDEF_HIDES_STRUCT = YES -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols -LOOKUP_CACHE_SIZE = 0 +SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will -# be included in the documentation. -# The default value is: NO. +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. EXTRACT_PRIVATE = YES -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be -# included in the documentation. -# The default value is: NO. +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. EXTRACT_STATIC = YES -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are -# included. -# The default value is: NO. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. -# The default value is: NO. +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. -# The default value is: NO. +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. -# The default value is: system dependent. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the -# scope will be hidden. -# The default value is: NO. +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. SHOW_INCLUDE_FILES = YES -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: YES. +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. SORT_MEMBER_DOCS = NO -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. +# Note: This option applies only to the class list, not to the +# alphabetical list. SORT_BY_SCOPE_NAME = NO -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. -# The default value is: YES. +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. -# The default value is: YES. +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. -# The default value is: YES. +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - #--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages +# configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. WARNINGS = YES -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. -# The default value is: NO. +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- -# Configuration options related to the input files +# configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. -# Note: If this tag is empty the current directory is searched. +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. INPUT = # This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should be +# The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. -# The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* EXCLUDE_PATTERNS = *.git \ *.d @@ -812,1108 +632,677 @@ EXCLUDE_PATTERNS = *.git \ # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). -EXAMPLE_PATH = doc/examples/ tools/ +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. -EXAMPLE_PATTERNS = *.c +EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - #--------------------------------------------------------------------------- -# Configuration options related to source browsing +# configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. -STRIP_CODE_COMMENTS = NO +STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - #--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index +# configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 5 +COLS_IN_ALPHA_INDEX = 2 -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the HTML output +# configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output -# The default value is: YES. +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a # standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra stylesheet files is of importance (e.g. the last -# stylesheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. -HTML_EXTRA_STYLESHEET = +HTML_COLORSTYLE_HUE = 120 -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OS X 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. GENERATE_HTMLHELP = NO -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. HHC_LOCATION = -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). GENERATE_CHI = NO -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. CHM_INDEX_ENCODING = -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. QHG_LOCATION = -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. GENERATE_ECLIPSEHELP = NO -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. ECLIPSE_DOC_ID = org.doxygen.Project -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. DISABLE_INDEX = NO -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. TREEVIEW_WIDTH = 250 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /