Imported Upstream version 3.1.1

This commit is contained in:
Sebastian Ramacher 2016-07-12 01:58:18 +02:00
parent 1db419b881
commit c1a7bf0ae2
2865 changed files with 114124 additions and 38237 deletions

125
Changelog
View File

@ -1,67 +1,68 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version 3.0.2:
- avcodec/ttaenc: Reallocate packet if its too small
- configure: build fix for P5600 with mips code restructuring
- mips: add support for R6
- pgssubdec: fix subpicture output colorspace and range
- avcodec/ac3dec: Reset SPX when switching from EAC3 to AC3
- avfilter/vf_drawtext: Check return code of load_glyph()
- avformat/mux: Check that deinit is set before calling it
- avcodec/takdec: add code that got somehow lost in process of REing
- avcodec/apedec: fix decoding of stereo files with one channel full of silence
- avcodec/avpacket: Fix off by 5 error
- avcodec/h264: Fix for H.264 configuration parsing
- avcodec/bmp_parser: Ensure remaining_size is not too small in startcode packet crossing corner case
- avcodec/pngdec: Fix alpha detection with skip_frame
- Changelog: Make formating consistent
- avfilter/src_movie: fix how we check for overflows with seek_point
- avcodec/j2kenc: Add attribution to OpenJPEG project:
version <next>:
version 3.0.1:
- avcodec/libutvideodec: copy frame so it has reference counters when refcounted_frames is set
- avformat/rtpdec_jpeg: fix low contrast image on low quality setting
- avformat/mpegtsenc: Fix used service
- avformat/mpegtsenc: Keep track of the program for each service
- avformat/file: Add crypto to default whitelist
- avcodec/mjpegenc_common: Store approximate aspect if exact cannot be stored
- lavc/hevc: Allow arbitrary garbage in bytestream as long as at least one NAL unit is found.
- avcodec/resample: Remove disabled and faulty code
- indeo2: Fix banding artefacts
- indeo2data: K&R formatting cosmetics
- avformat/hlsenc: Fix passing options, regression since bc9a5965c815cf7fd998d8ce14a18b8e861dd9ce
- avutil/random_seed: Add the runtime in cycles of the main loop to the entropy pool
- avutil/channel_layout: AV_CH_LAYOUT_6POINT1_BACK not reachable in parsing
- avformat/concatdec: set safe mode to enabled instead of auto
- avformat/utils: fix dts from pts code in compute_pkt_fields() during ascending delay
- avformat/rtpenc: Fix integer overflow in NTP_TO_RTP_FORMAT
- avcodec/dca: clear X96 channels if nothing was decoded
- fate/aac: Increase fuzz from of fate-aac-pns-encode from 72 to 74 for Loongson
- avformat/cache: Fix memleak of tree entries
- lavf/mov: downgrade sidx errors to non-fatal warnings; fixes trac #5216
- lavf/mov: fix sidx with edit lists
- avcodec/mjpegdec: Fix decoding slightly odd progressive jpeg
- swscale/utils: Fix chrSrcHSubSample for GBRAP16
- swscale/input: Fix GBRAP16 input
- avutil/pixdesc: Make get_color_type() aware of CIE XYZ formats
- avcodec/h264: Execute error concealment before marking the frame as done.
- swscale/x86/output: Fix yuv2planeX_16* with unaligned destination
- swscale/x86/output: Move code into yuv2planeX_mainloop
- MAINTAINERS: add myself as an OS/2 maintainer
- libwebpenc_animencoder: print library messages in verbose log levels
- libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct
- configure: check for SEC_I_CONTEXT_EXPIRED before enabling SChannel
- lavf/http: Add httpproxy to the default protocol whitelist.
- doc/utils: fix typo for min() description
- ffserver&ffm: Fixed issues preventing ffserver write_index and files_size from being set correctly which was breaking ffserver streaming.
- postproc: fix unaligned access
- vc2enc: fix use of uninitialized variables in the rate control system, correctly zero out coefficient array padding
- aacenc: optimize encoding speed
- avcodec/diracdec: check bitstream size related fields for overflows
- avcodec/h264_slice: Check PPS more extensively when its not copied
version 3.1.1:
- doc/APIchanges: document the lavu/lavf field moves
- avformat/avformat: Move new field to the end of AVStream
- avformat/utils: update deprecated AVStream->codec when the context is updated
- avutil/frame: Move new field to the end of AVFrame
- libavcodec/exr : fix decoding piz float file.
- avformat/mov: Check sample size
- lavfi: Move new field to the end of AVFilterContext
- lavfi: Move new field to the end of AVFilterLink
- ffplay: Fix usage of private lavfi API
- lavc/mediacodecdec_h264: add missing NAL headers to SPS/PPS buffers
- lavc/pnm_parser: disable parsing for text based PNMs
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:
@ -934,8 +935,8 @@ version 0.8:
- showinfo filter added
- SMPTE 302M AES3 audio decoder
- Apple Core Audio Format muxer
- 9bit and 10bit per sample support in the H.264 decoder
- 9bit and 10bit FFV1 encoding / decoding
- 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
@ -1228,7 +1229,7 @@ version 0.4.9-pre1:
- rate distorted optimal lambda->qp support
- AAC encoding with libfaac
- Sunplus JPEG codec (SP5X) support
- use Lagrange multipler instead of QP for ratecontrol
- use Lagrange multiplier instead of QP for ratecontrol
- Theora/VP3 decoding support
- XA and ADX ADPCM codecs
- export MPEG-2 active display area / pan scan

View File

@ -1,4 +1,4 @@
#FFmpeg:
# 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
@ -13,16 +13,18 @@ configure to activate them. In this case, FFmpeg's license changes to GPL v2+.
Specifically, the GPL parts of FFmpeg are:
- libpostproc
- optional x86 optimizations in the files
- `libavcodec/x86/flac_dsp_gpl.asm`
- `libavcodec/x86/idct_mmx.c`
- `libavfilter/x86/vf_removegrain.asm`
- libutvideo encoding/decoding wrappers in
`libavcodec/libutvideo*.cpp`
- optional x86 optimization in the files
- `libavcodec/x86/flac_dsp_gpl.asm`
- `libavcodec/x86/idct_mmx.c`
- `libavfilter/x86/vf_removegrain.asm`
- the X11 grabber in `libavdevice/x11grab.c`
- the swresample test app in
`libswresample/swresample-test.c`
- the `texi2pod.pl` tool
- 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:
- `f_ebur128.c`
- `vf_blackframe.c`
@ -47,9 +49,9 @@ Specifically, the GPL parts of FFmpeg are:
- `vf_pp.c`
- `vf_pp7.c`
- `vf_pullup.c`
- `vf_repeatfields.c`
- `vf_sab.c`
- `vf_smartblur.c`
- `vf_repeatfields.c`
- `vf_spp.c`
- `vf_stereo3d.c`
- `vf_super2xsai.c`
@ -73,20 +75,17 @@ There are a handful of files under other licensing terms, namely:
* `tests/reference.pnm` is under the expat license.
external libraries
==================
## External libraries
FFmpeg can be combined with a number of external libraries, which sometimes
affect the licensing of binaries resulting from the combination.
compatible libraries
--------------------
### Compatible libraries
The following libraries are under GPL:
- frei0r
- libcdio
- librubberband
- libutvideo
- libvidstab
- libx264
- libx265
@ -101,14 +100,25 @@ license is incompatible with the LGPL v2.1 and the GPL v2, but not with
version 3 of those licenses. So to combine these libraries with FFmpeg, the
license version needs to be upgraded by passing `--enable-version3` to configure.
incompatible libraries
----------------------
### Incompatible libraries
The Fraunhofer AAC library and FAAC are under licenses which
are incompatible with the GPLv2 and v3. We do not know for certain if their
licenses are compatible with the LGPL.
If you wish to enable these libraries, pass `--enable-nonfree` to configure.
But note that if you enable any of these libraries the resulting binary will
be under a complex license mix that is more restrictive than the LGPL and that
may result in additional obligations. It is possible that these
restrictions cause the resulting binary to be unredistributeable.
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 FAAC library is incompatible with all versions of GPL and LGPL.
The NVENC library, while its header file is licensed under the compatible MIT
license, requires a proprietary binary blob at run time, and is deemed to be
incompatible with the GPL. We are not certain if it is compatible with the
LGPL, but we require `--enable-nonfree` even with LGPL configurations in case
it is not.

View File

@ -43,8 +43,7 @@ Miscellaneous Areas
===================
documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan
build system (configure, makefiles) Diego Biurrun, Mans Rullgard
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser, Lou Logan
project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser
presets Robert Swain
metadata subsystem Aurelien Jacobs
release management Michael Niedermayer
@ -56,7 +55,7 @@ Communication
website Deby Barbara Lepage
fate.ffmpeg.org Timothy Gu
Trac bug tracker Alexander Strasser, Michael Niedermayer, Carl Eugen Hoyos, Lou Logan
mailing lists Michael Niedermayer, Baptiste Coudurier, 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
@ -89,7 +88,6 @@ Other:
rational.c, rational.h Michael Niedermayer
rc4 Reimar Doeffinger
ripemd.c, ripemd.h James Almer
timecode Clément Bœsch
libavcodec
@ -117,8 +115,6 @@ Generic Parts:
faandct.c, faandct.h Michael Niedermayer
Golomb coding:
golomb.c, golomb.h Michael Niedermayer
LPC:
lpc.c, lpc.h Justin Ruggles
motion estimation:
motion* Michael Niedermayer
rate control:
@ -139,19 +135,13 @@ Codecs:
8bps.c Roberto Togni
8svx.c Jaikrishnan Menon
aacenc*, aaccoder.c Rostislav Pehlivanov
aasc.c Kostya Shishkov
ac3* Justin Ruggles
alacenc.c Jaikrishnan Menon
alsdec.c Thilo Borgmann
apedec.c Kostya Shishkov
ass* Aurelien Jacobs
asv* Michael Niedermayer
atrac3* Benjamin Larsson
atrac3plus* Maxim Poliakovski
bgmc.c, bgmc.h Thilo Borgmann
bink.c Kostya Shishkov
binkaudio.c Peter Ross
bmp.c Mans Rullgard, Kostya Shishkov
cavs* Stefan Gehrer
cdxl.c Paul B Mahol
celp_filters.* Vitor Sessak
@ -159,27 +149,21 @@ Codecs:
cinepakenc.c Rl / Aetey G.T. AB
ccaption_dec.c Anshul Maheshwari
cljr Alex Beregszaszi
cllc.c Derek Buitenhuis
cook.c, cookdata.h Benjamin Larsson
cpia.c Stephan Hilb
crystalhd.c Philip Langdale
cscd.c Reimar Doeffinger
dca.c Kostya Shishkov, Benjamin Larsson
cuvid.c Timo Rothenpieler
dirac* Rostislav Pehlivanov
dnxhd* Baptiste Coudurier
dpcm.c Mike Melanson
dss_sp.c Oleksij Rempel, Michael Niedermayer
dss_sp.c Oleksij Rempel
dv.c Roman Shaposhnik
dvbsubdec.c Anshul Maheshwari
dxa.c Kostya Shishkov
eacmv*, eaidct*, eat* Peter Ross
evrc* Paul B Mahol
exif.c, exif.h Thilo Borgmann
ffv1* Michael Niedermayer
ffwavesynth.c Nicolas George
fic.c Derek Buitenhuis
flac* Justin Ruggles
flashsv* Benjamin Larsson
flicvideo.c Mike Melanson
g722.c Martin Storsjo
g726.c Roman Shaposhnik
@ -190,16 +174,10 @@ Codecs:
hap* Tom Butterworth
huffyuv* Michael Niedermayer, Christophe Gisquet
idcinvideo.c Mike Melanson
imc* Benjamin Larsson
indeo2* Kostya Shishkov
indeo5* Kostya Shishkov
interplayvideo.c Mike Melanson
ivi* Kostya Shishkov
jacosub* Clément Bœsch
jni*, ffjni* Matthieu Bouron
jpeg2000* Nicolas Bertrand
jpeg_ls.c Kostya Shishkov
jvdec.c Peter Ross
kmvc.c Kostya Shishkov
lcl*.c Roberto Togni, Reimar Doeffinger
libcelt_dec.c Nicolas George
libdirac* David Conrad
@ -208,40 +186,31 @@ Codecs:
libopenjpeg.c Jaikrishnan Menon
libopenjpegenc.c Michael Bradshaw
libschroedinger* David Conrad
libspeexdec.c Justin Ruggles
libtheoraenc.c David Conrad
libutvideo* Carl Eugen Hoyos
libvorbis.c David Conrad
libvpx* James Zern
libx264.c Mans Rullgard, Jason Garrett-Glaser
libx265.c Derek Buitenhuis
libxavs.c Stefan Gehrer
libzvbi-teletextdec.c Marton Balint
loco.c Kostya Shishkov
lzo.h, lzo.c Reimar Doeffinger
mdec.c Michael Niedermayer
mimic.c Ramiro Polla
mjpeg*.c Michael Niedermayer
mlp* Ramiro Polla
mmvideo.c Peter Ross
mpc* Kostya Shishkov
mpeg12.c, mpeg12data.h Michael Niedermayer
mpegvideo.c, mpegvideo.h Michael Niedermayer
mqc* Nicolas Bertrand
msmpeg4.c, msmpeg4data.h Michael Niedermayer
msrle.c Mike Melanson
msvideo1.c Mike Melanson
nellymoserdec.c Benjamin Larsson
nuv.c Reimar Doeffinger
nvenc.c Timo Rothenpieler
nvenc* Timo Rothenpieler
paf.* Paul B Mahol
pcx.c Ivo van Poorten
pgssubdec.c Reimar Doeffinger
ptx.c Ivo van Poorten
qcelp* Reynaldo H. Verdejo Pinochet
qdm2.c, qdm2data.h Roberto Togni, Benjamin Larsson
qdrw.c Kostya Shishkov
qpeg.c Kostya Shishkov
qdm2.c, qdm2data.h Roberto Togni
qsv* Ivan Uskov
qtrle.c Mike Melanson
ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni
@ -250,10 +219,8 @@ Codecs:
rpza.c Roberto Togni
rtjpeg.c, rtjpeg.h Reimar Doeffinger
rv10.c Michael Niedermayer
rv3* Kostya Shishkov
rv4* Kostya Shishkov, Christophe Gisquet
rv4* Christophe Gisquet
s3tc* Ivo van Poorten
smacker.c Kostya Shishkov
smc.c Mike Melanson
smvjpegdec.c Ash Hughes
snow* Michael Niedermayer, Loren Merritt
@ -262,54 +229,41 @@ Codecs:
sunrast.c Ivo van Poorten
svq3.c Michael Niedermayer
tak* Paul B Mahol
targa.c Kostya Shishkov
tiff.c Kostya Shishkov
truemotion1* Mike Melanson
truemotion2* Kostya Shishkov
truespeech.c Kostya Shishkov
tscc.c Kostya Shishkov
tta.c Alex Beregszaszi, Jaikrishnan Menon
ttaenc.c Paul B Mahol
txd.c Ivo van Poorten
ulti* Kostya Shishkov
v410*.c Derek Buitenhuis
vb.c Kostya Shishkov
vble.c Derek Buitenhuis
vc1* Kostya Shishkov, Christophe Gisquet
vc1* Christophe Gisquet
vc2* Rostislav Pehlivanov
vcr1.c Michael Niedermayer
vda_h264_dec.c Xidorn Quan
videotoolboxenc.c Rick Kern
vima.c Paul B Mahol
vmnc.c Kostya Shishkov
vorbisdec.c Denes Balatoni, David Conrad
vorbisenc.c Oded Shimon
vp3* Mike Melanson
vp5 Aurelien Jacobs
vp6 Aurelien Jacobs
vp8 David Conrad, Jason Garrett-Glaser, Ronald Bultje
vp9 Ronald Bultje, Clément Bœsch
vp8 David Conrad, Ronald Bultje
vp9 Ronald Bultje
vqavideo.c Mike Melanson
wavpack.c Kostya Shishkov
wmaprodec.c Sascha Sommer
wmavoice.c Ronald S. Bultje
wmv2.c Michael Niedermayer
wnv1.c Kostya Shishkov
xan.c Mike Melanson
xbm* Paul B Mahol
xface Stefano Sabatini
xl.c Kostya Shishkov
xvmc.c Ivan Kalvachev
xwd* Paul B Mahol
zerocodec.c Derek Buitenhuis
zmbv* Kostya Shishkov
Hardware acceleration:
crystalhd.c Philip Langdale
dxva2* Hendrik Leppkes, Laurent Aimar
mediacodec* Matthieu Bouron
vaapi* Gwenole Beauchesne
vda* Sebastien Zwickert
vaapi_encode* Mark Thompson
vdpau* Philip Langdale, Carl Eugen Hoyos
videotoolbox* Sebastien Zwickert
videotoolbox* Rick Kern
libavdevice
@ -353,7 +307,9 @@ Filters:
af_biquads.c Paul B Mahol
af_chorus.c Paul B Mahol
af_compand.c Paul B Mahol
af_firequalizer.c Muhammad Faiz
af_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
@ -366,6 +322,7 @@ Filters:
vf_colorbalance.c Paul B Mahol
vf_colorkey.c Timo Rothenpieler
vf_colorlevels.c Paul B Mahol
vf_coreimage.m Thilo Borgmann
vf_deband.c Paul B Mahol
vf_dejudder.c Nicholas Robbins
vf_delogo.c Jean Delvare (CC <jdelvare@suse.com>)
@ -380,6 +337,7 @@ Filters:
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
@ -399,6 +357,7 @@ Generic parts:
libavformat/avformat.h Michael Niedermayer
Utility Code:
libavformat/utils.c Michael Niedermayer
Text Subtitles Clément Bœsch
Muxers/Demuxers:
@ -408,7 +367,6 @@ Muxers/Demuxers:
afc.c Paul B Mahol
aiffdec.c Baptiste Coudurier, Matthieu Bouron
aiffenc.c Baptiste Coudurier, Matthieu Bouron
ape.c Kostya Shishkov
apngdec.c Benoit Fouet
ass* Aurelien Jacobs
astdec.c Paul B Mahol
@ -422,14 +380,12 @@ Muxers/Demuxers:
cdxl.c Paul B Mahol
crc.c Michael Niedermayer
daud.c Reimar Doeffinger
dss.c Oleksij Rempel, Michael Niedermayer
dss.c Oleksij Rempel
dtshddec.c Paul B Mahol
dv.c Roman Shaposhnik
dxa.c Kostya Shishkov
electronicarts.c Peter Ross
epafdec.c Paul B Mahol
ffm* Baptiste Coudurier
flac* Justin Ruggles
flic.c Mike Melanson
flvdec.c, flvenc.c Michael Niedermayer
gxf.c Reimar Doeffinger
@ -443,7 +399,6 @@ Muxers/Demuxers:
ipmovie.c Mike Melanson
ircam* Paul B Mahol
iss.c Stefan Gehrer
jacosub* Clément Bœsch
jvdec.c Peter Ross
libmodplug.c Clément Bœsch
libnut.c Oded Shimon
@ -458,10 +413,9 @@ Muxers/Demuxers:
mgsts.c Paul B Mahol
microdvd* Aurelien Jacobs
mm.c Peter Ross
mov.c Michael Niedermayer, Baptiste Coudurier
mov.c Baptiste Coudurier
movenc.c Baptiste Coudurier, Matthieu Bouron
movenccenc.c Eran Kornblau
mpc.c Kostya Shishkov
mpeg.c Michael Niedermayer
mpegenc.c Michael Niedermayer
mpegts.c Marton Balint
@ -487,8 +441,7 @@ Muxers/Demuxers:
raw.c Michael Niedermayer
rdt.c Ronald S. Bultje
rl2.c Sascha Sommer
rmdec.c, rmenc.c Ronald S. Bultje, Kostya Shishkov
rtmp* Kostya Shishkov
rmdec.c, rmenc.c Ronald S. Bultje
rtp.c, rtpenc.c Martin Storsjo
rtpdec_ac3.* Gilles Chanteperdrix
rtpdec_dv.* Thomas Volkert
@ -496,15 +449,13 @@ Muxers/Demuxers:
rtpdec_hevc.*, rtpenc_hevc.* Thomas Volkert
rtpdec_mpa_robust.* Gilles Chanteperdrix
rtpdec_asf.* Ronald S. Bultje
rtpdec_vc2hq.*, rtpenc_vc2hq.* Thomas Volkert
rtpdec_vp9.c Thomas Volkert
rtpenc_mpv.*, rtpenc_aac.* Martin Storsjo
rtsp.c Luca Barbato
sbgdec.c Nicolas George
sdp.c Martin Storsjo
segafilm.c Mike Melanson
segment.c Stefano Sabatini
siff.c Kostya Shishkov
smacker.c Kostya Shishkov
smjpeg* Paul B Mahol
spdif* Anssi Hannula
srtdec.c Aurelien Jacobs
@ -519,7 +470,6 @@ Muxers/Demuxers:
webvtt* Matthew J Heaney
westwood.c Mike Melanson
wtv.c Peter Ross
wv.c Kostya Shishkov
wvenc.c Paul B Mahol
Protocols:
@ -550,20 +500,16 @@ Resamplers:
Operating systems / CPU architectures
=====================================
Alpha Mans Rullgard, Falk Hueffner
ARM Mans Rullgard
AVR32 Mans Rullgard
MIPS Mans Rullgard, Nedeljko Babic
Alpha Falk Hueffner
MIPS Nedeljko Babic
Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier
Amiga / PowerPC Colin Ward
Linux / PowerPC Luca Barbato
Windows MinGW Alex Beregszaszi, Ramiro Polla
Windows Cygwin Victor Paesa
Windows MSVC Matthew Oliver, Hendrik Leppkes
Windows ICL Matthew Oliver
ADI/Blackfin DSP Marc Hoffman
Sparc Roman Shaposhnik
x86 Michael Niedermayer
OS/2 KO Myung-Hun
@ -584,7 +530,6 @@ GnuPG Fingerprints of maintainers and contributors
Alexander Strasser 1C96 78B7 83CB 8AA7 9AF5 D1EB A7D8 A57B A876 E58F
Anssi Hannula 1A92 FF42 2DD9 8D2E 8AF7 65A9 4278 C520 513D F3CB
Anton Khirnov 6D0C 6625 56F8 65D1 E5F5 814B B50A 1241 C067 07AB
Ash Hughes 694D 43D2 D180 C7C7 6421 ABD3 A641 D0B7 623D 6029
Attila Kinali 11F0 F9A6 A1D2 11F6 C745 D10C 6520 BCDD F2DF E765
Baptiste Coudurier 8D77 134D 20CC 9220 201F C5DB 0AC9 325C 5C1A BAAA
@ -592,16 +537,13 @@ Ben Littler 3EE3 3723 E560 3214 A8CD 4DEB 2CDB FCE7 768C 8D2C
Benoit Fouet B22A 4F4F 43EF 636B BB66 FCDC 0023 AE1E 2985 49C8
Clément Bœsch 52D0 3A82 D445 F194 DB8B 2B16 87EE 2CB8 F4B8 FCF9
Daniel Verkamp 78A6 07ED 782C 653E C628 B8B9 F0EB 8DD8 2F0E 21C7
Diego Biurrun 8227 1E31 B6D9 4994 7427 E220 9CAE D6CC 4757 FCC5
FFmpeg release signing key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8
Ganesh Ajjanagadde C96A 848E 97C3 CEA2 AB72 5CE4 45F9 6A2D 3C36 FB1B
Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4
Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368
Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A
Justin Ruggles 3136 ECC0 C10D 6C04 5F43 CA29 FCBE CD2A 3787 1EBF
Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A
Luca Barbato 6677 4209 213C 8843 5B67 29E7 E84C 78C2 84E9 0E34
Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93
Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029

View File

@ -30,16 +30,18 @@ $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o
OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
OBJS-ffmpeg-$(CONFIG_VAAPI) += ffmpeg_vaapi.o
ifndef CONFIG_VIDEOTOOLBOX
OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o
endif
OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o
OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
OBJS-ffserver += ffserver_config.o
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
TOOLS = qt-faststart trasher uncoded_frame
TOOLS-$(CONFIG_ZLIB) += cws2fws
@ -59,7 +61,8 @@ FFLIBS := avutil
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
SKIPHEADERS = cmdutils_common_opts.h \
compat/w32pthreads.h
include $(SRC_PATH)/common.mak
@ -181,7 +184,7 @@ clean::
distclean::
$(RM) $(DISTCLEANSUFFIXES)
$(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h
$(RM) config.* .config libavutil/avconfig.h .version mapfile avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c
ifeq ($(SRC_LINK),src)
$(RM) src
endif

View File

@ -1 +1 @@
3.0.2
3.1.1

View File

@ -1,10 +1,10 @@
┌────────────────────────────────────────
│ RELEASE NOTES for FFmpeg 3.0 "Einstein" │
└────────────────────────────────────────
┌────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 3.1 "Laplace" │
└────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 3.0 "Einstein", about 5
months after the release of FFmpeg 2.8.
The FFmpeg Project proudly presents FFmpeg 3.1 "Laplace", about 4
months after the release of FFmpeg 3.0.
A complete Changelog is available at the root of the project, and the
complete Git history on http://source.ffmpeg.org.

View File

@ -1 +1 @@
3.0.2
3.1.1

View File

@ -39,7 +39,7 @@ CCFLAGS = $(CPPFLAGS) $(CFLAGS)
OBJCFLAGS += $(EOBJCFLAGS)
OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
CXXFLAGS += $(CPPFLAGS) $(CFLAGS)
CXXFLAGS := $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS)
YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
@ -114,8 +114,8 @@ FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
TOOLS += $(TOOLS-yes)
@ -158,9 +158,7 @@ LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
define RULES
clean::
$(RM) $(OBJS) $(OBJS:.o=.d) $(OBJS:.o=$(DEFAULT_YASMD).d)
$(RM) $(HOSTPROGS)
$(RM) $(TOOLS)
$(RM) $(HOSTPROGS) $(TESTPROGS) $(TOOLS)
endef
$(eval $(RULES))

View File

@ -0,0 +1,42 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H
#define COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H
#include <dispatch/dispatch.h>
#include <errno.h>
#define sem_t dispatch_semaphore_t
#define sem_post(psem) dispatch_semaphore_signal(*psem)
#define sem_wait(psem) dispatch_semaphore_wait(*psem, DISPATCH_TIME_FOREVER)
#define sem_timedwait(psem, val) dispatch_semaphore_wait(*psem, dispatch_walltime(val, 0))
#define sem_destroy(psem) dispatch_release(*psem)
static inline int compat_sem_init(dispatch_semaphore_t *psem,
int unused, int val)
{
int ret = !!(*psem = dispatch_semaphore_create(val)) - 1;
if (ret < 0)
errno = ENOMEM;
return ret;
}
#define sem_init compat_sem_init
#endif /* COMPAT_DISPATCH_SEMAPHORE_SEMAPHORE_H */

555
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,131 @@ libavutil: 2015-08-28
API changes, most recent first:
2016-06-30 - c1c7e0ab - lavf 57.41.100 - avformat.h
Moved codecpar field from AVStream to the end of the struct, so that
the following private fields are in the same location as in FFmpeg 3.0 (lavf 57.25.100).
2016-06-30 - 042fb69d - lavu 55.28.100 - frame.h
Moved hw_frames_ctx field from AVFrame to the end of the struct, so that
the following private fields are in the same location as in FFmpeg 3.0 (lavu 55.17.103).
2016-06-29 - 1a751455 - lavfi 6.47.100 - avfilter.h
Fix accidental ABI breakage in AVFilterContext.
ABI was broken in 8688d3a, lavfi 6.42.100 and released as ffmpeg 3.1.
Because of this, ffmpeg and ffplay built against lavfi>=6.42.100 will not be
compatible with lavfi>=6.47.100. Potentially also affects other users of
libavfilter if they are using one of the affected fields.
-------- 8< --------- FFmpeg 3.1 was cut here -------- 8< ---------
2016-06-26 - 481f320 / 1c9e861 - lavu 55.27.100 / 55.13.0 - hwcontext.h
Add av_hwdevice_ctx_create().
2016-06-26 - b95534b / e47b8bb - lavc 57.48.101 / 57.19.1 - avcodec.h
Adjust values for JPEG 2000 profiles.
2016-06-23 - 5d75e46 / db7968b - lavf 57.40.100 / 57.7.0 - avio.h
Add AVIODataMarkerType, write_data_type, ignore_boundary_point and
avio_write_marker.
2016-06-23 - abb3cc4 / 0c4468d - lavu 55.26.100 / 55.12.0 - opt.h
Add av_stereo3d_type_name() and av_stereo3d_from_name().
2016-06-22 - 3689efe / c46db38 - lavu 55.25.100 / 55.11.0 - hwcontext_dxva2.h
Add new installed header with DXVA2-specific hwcontext definitions.
2016-04-27 - fb91871 - lavu 55.23.100 - log.h
Add a new function av_log_format_line2() which returns number of bytes
written to the target buffer.
2016-04-21 - 7fc329e - lavc 57.37.100 - avcodec.h
Add a new audio/video encoding and decoding API with decoupled input
and output -- avcodec_send_packet(), avcodec_receive_frame(),
avcodec_send_frame() and avcodec_receive_packet().
2016-04-17 - af9cac1 / 33d1898 - lavc 57.35.100 / 57.15.0 - avcodec.h
Add a new bitstream filtering API working with AVPackets.
Deprecate the old bitstream filtering API.
2016-04-14 - 8688d3a / 07a844f - lavfi 6.42.100 / 6.3.0 - avfilter.h
Add AVFilterContext.hw_device_ctx.
2016-04-14 - 28abb21 / 551c677 - lavu 55.22.100 / 55.9.0 - hwcontext_vaapi.h
Add new installed header with VAAPI-specific hwcontext definitions.
2016-04-14 - afccfaf / b1f01e8 - lavu 55.21.100 / 55.7.0 - hwcontext.h
Add AVHWFramesConstraints and associated API.
2016-04-11 - 6f69f7a / 9200514 - lavf 57.33.100 / 57.5.0 - avformat.h
Add AVStream.codecpar, deprecate AVStream.codec.
2016-04-02 - e8a9b64 - lavu 55.20.100 - base64.h
Add AV_BASE64_DECODE_SIZE(x) macro.
2016-xx-xx - lavc 57.33.100 / 57.14.0 - avcodec.h
f9b1cf1 / 998e1b8 - Add AVCodecParameters and its related API.
e6053b3 / a806834 - Add av_get_audio_frame_duration2().
2016-03-11 - 6d8ab35 - lavf/lavc 57.28.101
Add requirement to bitstream filtering API that returned packets with
size == 0 and side_data_elems == 0 are to be skipped by the caller.
2016-03-04 - 9362973 - lavf 57.28.100
Add protocol blacklisting API
2016-02-28 - 4dd4d53 - lavc 57.27.101
Validate AVFrame returned by get_buffer2 to have required
planes not NULL and unused planes set to NULL as crashes
and buffer overflow are possible with certain streams if
that is not the case.
2016-02-26 - 30e7685 - lavc 57.27.100 - avcodec.h
"flags2" decoding option now allows the flag "ass_ro_flush_noop" preventing
the reset of the ASS ReadOrder field on flush. This affects the content of
AVSubtitles.rects[N]->ass when "sub_text_format" is set to "ass" (see
previous entry).
2016-02-26 - 2941282 - lavc 57.26.100 - avcodec.h
Add a "sub_text_format" subtitles decoding option allowing the values "ass"
(recommended) and "ass_with_timings" (not recommended, deprecated, default).
The default value for this option will change to "ass" at the next major
libavcodec version bump.
The current default is "ass_with_timings" for compatibility. This means that
all subtitles text decoders currently still output ASS with timings printed
as strings in the AVSubtitles.rects[N]->ass fields.
Setting "sub_text_format" to "ass" allows a better timing accuracy (ASS
timing is limited to a 1/100 time base, so this is relevant for any subtitles
format needing a bigger one), ease timing adjustments, and prevents the need
of removing the timing from the decoded string yourself. This form is also
known as "the Matroska form". The timing information (start time, duration)
can be found in the AVSubtitles fields.
2016-02-24 - 7e49cdd / 7b3214d0 - lavc 57.25.100 / 57.13.0 - avcodec.h
Add AVCodecContext.hw_frames_ctx.
2016-02-24 - 1042402 / b3dd30d - lavfi 6.36.100 / 6.2.0 - avfilter.h
avfilter.h - Add AVFilterLink.hw_frames_ctx.
buffersrc.h - Add AVBufferSrcParameters and functions for handling it.
2016-02-23 - 14f7a3d - lavc 57.25.100
Add AV_PKT_DATA_MPEGTS_STREAM_ID for exporting the MPEGTS stream ID.
2016-02-18 - 08acab8 - lavu 55.18.100 - audio_fifo.h
Add av_audio_fifo_peek_at().
2016-xx-xx - lavu 55.18.100 / 55.6.0
26abd51 / 721a4ef buffer.h - Add av_buffer_pool_init2().
1a70878 / 89923e4 hwcontext.h - Add a new installed header hwcontext.h with a new API
for handling hwaccel frames.
6992276 / ad884d1 hwcontext_cuda.h - Add a new installed header hwcontext_cuda.h with
CUDA-specific hwcontext definitions.
d779d8d / a001ce3 hwcontext_vdpau.h - Add a new installed header hwcontext_vdpau.h with
VDPAU-specific hwcontext definitions.
63c3e35 / 7bc780c pixfmt.h - Add AV_PIX_FMT_CUDA.
-------- 8< --------- FFmpeg 3.0 was cut here -------- 8< ---------
2016-02-10 - bc9a596 / 9f61abc - lavf 57.25.100 / 57.3.0 - avformat.h
@ -1084,7 +1209,7 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0
* base -- is now stored in AVBufferRef
* reference, type, buffer_hints -- are unnecessary in the new API
* hwaccel_picture_private, owner, thread_opaque -- should not
have been acessed from outside of lavc
have been accessed from outside of lavc
* qscale_table, qstride, qscale_type, mbskip_table, motion_val,
mb_type, dct_coeff, ref_index -- mpegvideo-specific tables,
which are not exported anymore.

View File

@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 3.0.2
PROJECT_NUMBER = 3.1.1
# With the PROJECT_LOGO tag one can specify a logo or icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
@ -1429,7 +1429,7 @@ PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# generate an inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# or super classes. Setting the tag to NO turns the diagrams off. Note that
# this option is superseded by the HAVE_DOT option below. This is only a
# fallback. It is recommended to install and use dot, since it yields more

View File

@ -67,6 +67,10 @@ the header stored in extradata to the key packets:
ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
@end example
@section dca_core
Extract DCA core from DTS-HD streams.
@section h264_mp4toannexb
Convert an H.264 bitstream from length prefixed mode to start code

View File

@ -39,9 +39,6 @@ examples
libavformat/output-example
Build the libavformat basic example.
libavcodec/api-example
Build the libavcodec basic example.
libswscale/swscale-test
Build the swscale self-test (useful also as an example).

View File

@ -257,7 +257,7 @@ Specify how strictly to follow the standards.
Possible values:
@table @samp
@item very
strictly conform to a older more strict version of the spec or reference software
strictly conform to an older more strict version of the spec or reference software
@item strict
strictly conform to all the things in the spec no matter what consequences
@item normal
@ -456,6 +456,9 @@ Possible values:
@item aspect @var{rational number} (@emph{encoding,video})
Set sample aspect ratio.
@item sar @var{rational number} (@emph{encoding,video})
Set sample aspect ratio. Alias to @var{aspect}.
@item debug @var{flags} (@emph{decoding/encoding,audio,video,subtitles})
Print specific debug info.
@ -1047,7 +1050,38 @@ Possible values:
@item rc_min_vbv_use @var{float} (@emph{encoding,video})
@item ticks_per_frame @var{integer} (@emph{decoding/encoding,audio,video})
@item color_primaries @var{integer} (@emph{decoding/encoding,video})
@item color_trc @var{integer} (@emph{decoding/encoding,video})
Possible values:
@table @samp
@item bt709
BT.709
@item gamma22
BT.470 M
@item gamma28
BT.470 BG
@item linear
SMPTE 170 M
@item log
SMPTE 240 M
@item log_sqrt
Linear
@item iec61966_2_4
Log
@item bt1361
Log square root
@item iec61966_2_1
IEC 61966-2-4
@item bt2020_10bit
BT.1361
@item bt2020_12bit
IEC 61966-2-1
@item smpte2084
BT.2020 - 10 bit
@item smpte428_1
BT.2020 - 12 bit
@end table
@item colorspace @var{integer} (@emph{decoding/encoding,video})
@item color_range @var{integer} (@emph{decoding/encoding,video})

View File

@ -441,9 +441,9 @@ ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv
@end example
@end itemize
@section mov/mp4/3gp/Quicktme
@section mov/mp4/3gp/QuickTime
Quicktime / MP4 demuxer.
QuickTime / MP4 demuxer.
This demuxer accepts the following options:
@table @option

View File

@ -403,6 +403,35 @@ finding a new maintainer and also don't forget to update the @file{MAINTAINERS}
We think our rules are not too hard. If you have comments, contact us.
@section Code of conduct
Be friendly and respectful towards others and third parties.
Treat others the way you yourself want to be treated.
Be considerate. Not everyone shares the same viewpoint and priorities as you do.
Different opinions and interpretations help the project.
Looking at issues from a different perspective assists development.
Do not assume malice for things that can be attributed to incompetence. Even if
it is malice, it's rarely good to start with that as initial assumption.
Stay friendly even if someone acts contrarily. Everyone has a bad day
once in a while.
If you yourself have a bad day or are angry then try to take a break and reply
once you are calm and without anger if you have to.
Try to help other team members and cooperate if you can.
The goal of software development is to create technical excellence, not for any
individual to be better and "win" against the others. Large software projects
are only possible and successful through teamwork.
If someone struggles do not put them down. Give them a helping hand
instead and point them in the right direction.
Finally, keep in mind the immortal words of Bill and Ted,
"Be excellent to each other."
@anchor{Submitting patches}
@section Submitting patches

View File

@ -25,9 +25,9 @@
* libavcodec API use example.
*
* @example decoding_encoding.c
* Note that libavcodec only handles codecs (mpeg, mpeg4, etc...),
* not file formats (avi, vob, mp4, mov, mkv, mxf, flv, mpegts, mpegps, etc...). See library 'libavformat' for the
* format handling
* Note that libavcodec only handles codecs (MPEG, MPEG-4, etc...),
* not file formats (AVI, VOB, MP4, MOV, MKV, MXF, FLV, MPEG-TS, MPEG-PS, etc...).
* See library 'libavformat' for the format handling
*/
#include <math.h>
@ -253,7 +253,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
printf("Decode audio file %s to %s\n", filename, outfilename);
/* find the mpeg audio decoder */
/* find the MPEG audio decoder */
codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
if (!codec) {
fprintf(stderr, "Codec not found\n");
@ -356,7 +356,7 @@ static void video_encode_example(const char *filename, int codec_id)
printf("Encode video file %s\n", filename);
/* find the mpeg1 video encoder */
/* find the video encoder */
codec = avcodec_find_encoder(codec_id);
if (!codec) {
fprintf(stderr, "Codec not found\n");
@ -475,7 +475,7 @@ static void video_encode_example(const char *filename, int codec_id)
}
}
/* add sequence end code to have a real mpeg file */
/* add sequence end code to have a real MPEG file */
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
@ -543,12 +543,12 @@ static void video_decode_example(const char *outfilename, const char *filename)
av_init_packet(&avpkt);
/* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
/* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);
printf("Decode video file %s to %s\n", filename, outfilename);
/* find the mpeg1 video decoder */
/* find the MPEG-1 video decoder */
codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
if (!codec) {
fprintf(stderr, "Codec not found\n");
@ -613,9 +613,9 @@ static void video_decode_example(const char *outfilename, const char *filename)
exit(1);
}
/* some codecs, such as MPEG, transmit the I and P frame with a
/* Some codecs, such as MPEG, transmit the I- and P-frame with a
latency of one frame. You must do the following to have a
chance to get the last frame of the video */
chance to get the last frame of the video. */
avpkt.data = NULL;
avpkt.size = 0;
decode_write_frame(outfilename, c, frame, &frame_count, &avpkt, 1);

View File

@ -65,7 +65,7 @@ static int open_input_file(const char *filename)
/* select the audio stream */
ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot find a audio stream in the input file\n");
av_log(NULL, AV_LOG_ERROR, "Cannot find an audio stream in the input file\n");
return ret;
}
audio_stream_index = ret;

View File

@ -52,6 +52,7 @@
// a wrapper around a single output AVStream
typedef struct OutputStream {
AVStream *st;
AVCodecContext *enc;
/* pts of the next frame that will be generated */
int64_t next_pts;
@ -104,13 +105,18 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
exit(1);
}
ost->st = avformat_new_stream(oc, *codec);
ost->st = avformat_new_stream(oc, NULL);
if (!ost->st) {
fprintf(stderr, "Could not allocate stream\n");
exit(1);
}
ost->st->id = oc->nb_streams-1;
c = ost->st->codec;
c = avcodec_alloc_context3(*codec);
if (!c) {
fprintf(stderr, "Could not alloc an encoding context\n");
exit(1);
}
ost->enc = c;
switch ((*codec)->type) {
case AVMEDIA_TYPE_AUDIO:
@ -155,7 +161,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
c->gop_size = 12; /* emit one intra frame every twelve frames at most */
c->pix_fmt = STREAM_PIX_FMT;
if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
/* just for testing, we also add B frames */
/* just for testing, we also add B-frames */
c->max_b_frames = 2;
}
if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
@ -213,7 +219,7 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
int ret;
AVDictionary *opt = NULL;
c = ost->st->codec;
c = ost->enc;
/* open it */
av_dict_copy(&opt, opt_arg, 0);
@ -240,6 +246,13 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
c->sample_rate, nb_samples);
/* copy the stream parameters to the muxer */
ret = avcodec_parameters_from_context(ost->st->codecpar, c);
if (ret < 0) {
fprintf(stderr, "Could not copy the stream parameters\n");
exit(1);
}
/* create resampler context */
ost->swr_ctx = swr_alloc();
if (!ost->swr_ctx) {
@ -271,13 +284,13 @@ static AVFrame *get_audio_frame(OutputStream *ost)
int16_t *q = (int16_t*)frame->data[0];
/* check if we want to generate more frames */
if (av_compare_ts(ost->next_pts, ost->st->codec->time_base,
if (av_compare_ts(ost->next_pts, ost->enc->time_base,
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
return NULL;
for (j = 0; j <frame->nb_samples; j++) {
v = (int)(sin(ost->t) * 10000);
for (i = 0; i < ost->st->codec->channels; i++)
for (i = 0; i < ost->enc->channels; i++)
*q++ = v;
ost->t += ost->tincr;
ost->tincr += ost->tincr2;
@ -303,7 +316,7 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
int dst_nb_samples;
av_init_packet(&pkt);
c = ost->st->codec;
c = ost->enc;
frame = get_audio_frame(ost);
@ -383,7 +396,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
{
int ret;
AVCodecContext *c = ost->st->codec;
AVCodecContext *c = ost->enc;
AVDictionary *opt = NULL;
av_dict_copy(&opt, opt_arg, 0);
@ -414,6 +427,13 @@ static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
exit(1);
}
}
/* copy the stream parameters to the muxer */
ret = avcodec_parameters_from_context(ost->st->codecpar, c);
if (ret < 0) {
fprintf(stderr, "Could not copy the stream parameters\n");
exit(1);
}
}
/* Prepare a dummy image. */
@ -448,10 +468,10 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
static AVFrame *get_video_frame(OutputStream *ost)
{
AVCodecContext *c = ost->st->codec;
AVCodecContext *c = ost->enc;
/* check if we want to generate more frames */
if (av_compare_ts(ost->next_pts, ost->st->codec->time_base,
if (av_compare_ts(ost->next_pts, c->time_base,
STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
return NULL;
@ -495,7 +515,7 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
int got_packet = 0;
AVPacket pkt = { 0 };
c = ost->st->codec;
c = ost->enc;
frame = get_video_frame(ost);
@ -524,7 +544,7 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
static void close_stream(AVFormatContext *oc, OutputStream *ost)
{
avcodec_close(ost->st->codec);
avcodec_free_context(&ost->enc);
av_frame_free(&ost->frame);
av_frame_free(&ost->tmp_frame);
sws_freeContext(ost->sws_ctx);
@ -545,6 +565,7 @@ int main(int argc, char **argv)
int have_video = 0, have_audio = 0;
int encode_video = 0, encode_audio = 0;
AVDictionary *opt = NULL;
int i;
/* Initialize libavcodec, and register all codecs and formats. */
av_register_all();
@ -561,8 +582,9 @@ int main(int argc, char **argv)
}
filename = argv[1];
if (argc > 3 && !strcmp(argv[2], "-flags")) {
av_dict_set(&opt, argv[2]+1, argv[3], 0);
for (i = 2; i+1 < argc; i+=2) {
if (!strcmp(argv[i], "-flags") || !strcmp(argv[i], "-fflags"))
av_dict_set(&opt, argv[i]+1, argv[i+1], 0);
}
/* allocate the output media context */
@ -620,8 +642,8 @@ int main(int argc, char **argv)
while (encode_video || encode_audio) {
/* select the stream to encode */
if (encode_video &&
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.st->codec->time_base,
audio_st.next_pts, audio_st.st->codec->time_base) <= 0)) {
(!encode_audio || av_compare_ts(video_st.next_pts, video_st.enc->time_base,
audio_st.next_pts, audio_st.enc->time_base) <= 0)) {
encode_video = !write_video_frame(oc, &video_st);
} else {
encode_audio = !write_audio_frame(oc, &audio_st);

View File

@ -352,7 +352,7 @@ int main(int argc, char **argv)
for (i = 0; i < input_ctx->nb_streams; i++) {
AVStream *st = input_ctx->streams[i];
if (st->codec->codec_id == AV_CODEC_ID_H264 && !video_st)
if (st->codecpar->codec_id == AV_CODEC_ID_H264 && !video_st)
video_st = st;
else
st->discard = AVDISCARD_ALL;
@ -404,16 +404,16 @@ int main(int argc, char **argv)
goto finish;
}
decoder_ctx->codec_id = AV_CODEC_ID_H264;
if (video_st->codec->extradata_size) {
decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size +
if (video_st->codecpar->extradata_size) {
decoder_ctx->extradata = av_mallocz(video_st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!decoder_ctx->extradata) {
ret = AVERROR(ENOMEM);
goto finish;
}
memcpy(decoder_ctx->extradata, video_st->codec->extradata,
video_st->codec->extradata_size);
decoder_ctx->extradata_size = video_st->codec->extradata_size;
memcpy(decoder_ctx->extradata, video_st->codecpar->extradata,
video_st->codecpar->extradata_size);
decoder_ctx->extradata_size = video_st->codecpar->extradata_size;
}
decoder_ctx->refcounted_frames = 1;

View File

@ -62,6 +62,7 @@ static int open_input_file(const char *filename,
AVFormatContext **input_format_context,
AVCodecContext **input_codec_context)
{
AVCodecContext *avctx;
AVCodec *input_codec;
int error;
@ -91,23 +92,39 @@ static int open_input_file(const char *filename,
}
/** Find a decoder for the audio stream. */
if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codec->codec_id))) {
if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codecpar->codec_id))) {
fprintf(stderr, "Could not find input codec\n");
avformat_close_input(input_format_context);
return AVERROR_EXIT;
}
/** allocate a new decoding context */
avctx = avcodec_alloc_context3(input_codec);
if (!avctx) {
fprintf(stderr, "Could not allocate a decoding context\n");
avformat_close_input(input_format_context);
return AVERROR(ENOMEM);
}
/** initialize the stream parameters with demuxer information */
error = avcodec_parameters_to_context(avctx, (*input_format_context)->streams[0]->codecpar);
if (error < 0) {
avformat_close_input(input_format_context);
avcodec_free_context(&avctx);
return error;
}
/** Open the decoder for the audio stream to use it later. */
if ((error = avcodec_open2((*input_format_context)->streams[0]->codec,
input_codec, NULL)) < 0) {
if ((error = avcodec_open2(avctx, input_codec, NULL)) < 0) {
fprintf(stderr, "Could not open input codec (error '%s')\n",
get_error_text(error));
avcodec_free_context(&avctx);
avformat_close_input(input_format_context);
return error;
}
/** Save the decoder context for easier access later. */
*input_codec_context = (*input_format_context)->streams[0]->codec;
*input_codec_context = avctx;
return 0;
}
@ -122,6 +139,7 @@ static int open_output_file(const char *filename,
AVFormatContext **output_format_context,
AVCodecContext **output_codec_context)
{
AVCodecContext *avctx = NULL;
AVIOContext *output_io_context = NULL;
AVStream *stream = NULL;
AVCodec *output_codec = NULL;
@ -161,27 +179,31 @@ static int open_output_file(const char *filename,
}
/** Create a new audio stream in the output file container. */
if (!(stream = avformat_new_stream(*output_format_context, output_codec))) {
if (!(stream = avformat_new_stream(*output_format_context, NULL))) {
fprintf(stderr, "Could not create new stream\n");
error = AVERROR(ENOMEM);
goto cleanup;
}
/** Save the encoder context for easier access later. */
*output_codec_context = stream->codec;
avctx = avcodec_alloc_context3(output_codec);
if (!avctx) {
fprintf(stderr, "Could not allocate an encoding context\n");
error = AVERROR(ENOMEM);
goto cleanup;
}
/**
* Set the basic encoder parameters.
* The input file's sample rate is used to avoid a sample rate conversion.
*/
(*output_codec_context)->channels = OUTPUT_CHANNELS;
(*output_codec_context)->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
(*output_codec_context)->sample_rate = input_codec_context->sample_rate;
(*output_codec_context)->sample_fmt = output_codec->sample_fmts[0];
(*output_codec_context)->bit_rate = OUTPUT_BIT_RATE;
avctx->channels = OUTPUT_CHANNELS;
avctx->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
avctx->sample_rate = input_codec_context->sample_rate;
avctx->sample_fmt = output_codec->sample_fmts[0];
avctx->bit_rate = OUTPUT_BIT_RATE;
/** Allow the use of the experimental AAC encoder */
(*output_codec_context)->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
avctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
/** Set the sample rate for the container. */
stream->time_base.den = input_codec_context->sample_rate;
@ -192,18 +214,28 @@ static int open_output_file(const char *filename,
* Mark the encoder so that it behaves accordingly.
*/
if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER)
(*output_codec_context)->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
/** Open the encoder for the audio stream to use it later. */
if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) {
if ((error = avcodec_open2(avctx, output_codec, NULL)) < 0) {
fprintf(stderr, "Could not open output codec (error '%s')\n",
get_error_text(error));
goto cleanup;
}
error = avcodec_parameters_from_context(stream->codecpar, avctx);
if (error < 0) {
fprintf(stderr, "Could not initialize stream parameters\n");
goto cleanup;
}
/** Save the encoder context for easier access later. */
*output_codec_context = avctx;
return 0;
cleanup:
avcodec_free_context(&avctx);
avio_closep(&(*output_format_context)->pb);
avformat_free_context(*output_format_context);
*output_format_context = NULL;
@ -756,13 +788,13 @@ cleanup:
av_audio_fifo_free(fifo);
swr_free(&resample_context);
if (output_codec_context)
avcodec_close(output_codec_context);
avcodec_free_context(&output_codec_context);
if (output_format_context) {
avio_closep(&output_format_context->pb);
avformat_free_context(output_format_context);
}
if (input_codec_context)
avcodec_close(input_codec_context);
avcodec_free_context(&input_codec_context);
if (input_format_context)
avformat_close_input(&input_format_context);

View File

@ -128,7 +128,10 @@ static int open_output_file(const char *filename)
enc_ctx->width = dec_ctx->width;
enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
/* take first format from list of supported formats */
enc_ctx->pix_fmt = encoder->pix_fmts[0];
if (encoder->pix_fmts)
enc_ctx->pix_fmt = encoder->pix_fmts[0];
else
enc_ctx->pix_fmt = dec_ctx->pix_fmt;
/* video time_base can be set to whatever is handy and supported by encoder */
enc_ctx->time_base = dec_ctx->time_base;
} else {

View File

@ -720,7 +720,7 @@ For DXVA2, this option should contain the number of the display adapter to use.
If this option is not specified, the default adapter is used.
@item qsv
For QSV, this option corresponds to the valus of MFX_IMPL_* . Allowed values
For QSV, this option corresponds to the values of MFX_IMPL_* . Allowed values
are:
@table @option
@item auto

File diff suppressed because it is too large Load Diff

View File

@ -147,7 +147,7 @@ a packet for each stream, regardless of the maximum timestamp
difference between the buffered packets.
@item use_wallclock_as_timestamps @var{integer} (@emph{input})
Use wallclock as timestamps.
Use wallclock as timestamps if set to 1. Default is 0.
@item avoid_negative_ts @var{integer} (@emph{output})

View File

@ -520,6 +520,7 @@ library:
@tab Multimedia format used in Westwood Studios games.
@item Westwood Studios VQA @tab @tab X
@tab Multimedia format used in Westwood Studios games.
@item Wideband Single-bit Data (WSD) @tab @tab X
@item WVE @tab @tab X
@item XMV @tab @tab X
@tab Microsoft video container used in Xbox games.
@ -643,6 +644,7 @@ following image formats are supported:
@item Bethesda VID video @tab @tab X
@tab Used in some games from Bethesda Softworks.
@item Bink Video @tab @tab X
@item BitJazz SheerVideo @tab @tab X
@item Bitmap Brothers JV video @tab @tab X
@item y41p Brooktree uncompressed 4:1:1 12-bit @tab X @tab X
@item Brute Force & Ignorance @tab @tab X
@ -743,6 +745,7 @@ following image formats are supported:
@item LucasArts SANM/Smush @tab @tab X
@tab Used in LucasArts games / SMUSH animations.
@item lossless MJPEG @tab X @tab X
@item MagicYUV Lossless Video @tab @tab X
@item Microsoft ATC Screen @tab @tab X
@tab Also known as Microsoft Screen 3.
@item Microsoft Expression Encoder Screen @tab @tab X
@ -950,7 +953,7 @@ following image formats are supported:
@item COOK @tab @tab X
@tab All versions except 5.1 are supported.
@item DCA (DTS Coherent Acoustics) @tab X @tab X
@tab supported extensions: XCh, XLL (partially)
@tab supported extensions: XCh, XXCH, X96, XBR, XLL, LBR (partially)
@item DPCM id RoQ @tab X @tab X
@tab Used in Quake III, Jedi Knight 2 and other computer games.
@item DPCM Interplay @tab @tab X
@ -967,6 +970,7 @@ following image formats are supported:
@item DSD (Direct Stream Digitial), least significant bit first, planar @tab @tab X
@item DSD (Direct Stream Digitial), most significant bit first, planar @tab @tab X
@item DSP Group TrueSpeech @tab @tab X
@item DST (Direct Stream Transfer) @tab @tab X
@item DV audio @tab @tab X
@item Enhanced AC-3 @tab X @tab X
@item EVRC (Enhanced Variable Rate Codec) @tab @tab X

View File

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

View File

@ -174,30 +174,70 @@ ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
See also the @ref{crc} muxer.
@anchor{framehash}
@section framehash
Per-packet hash testing format.
This muxer computes and prints a cryptographic hash for each audio
and video packet. This can be used for packet-by-packet equality
checks without having to individually do a binary comparison on each.
By default audio frames are converted to signed 16-bit raw audio and
video frames to raw video before computing the hash, but the output
of explicit conversions to other codecs can also be used. It uses the
SHA-256 cryptographic hash function by default, but supports several
other algorithms.
The output of the muxer consists of a line for each audio and video
packet of the form:
@example
@var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, @var{hash}
@end example
@var{hash} is a hexadecimal number representing the computed hash
for the packet.
@table @option
@item hash @var{algorithm}
Use the cryptographic hash function specified by the string @var{algorithm}.
Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
@code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
@code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
@code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
@end table
@subsection Examples
To compute the SHA-256 hash of the audio and video frames in @file{INPUT},
converted to raw audio and video packets, and store it in the file
@file{out.sha256}:
@example
ffmpeg -i INPUT -f framehash out.sha256
@end example
To print the information to stdout, using the MD5 hash function, use
the command:
@example
ffmpeg -i INPUT -f framehash -hash md5 -
@end example
See also the @ref{hash} muxer.
@anchor{framemd5}
@section framemd5
Per-packet MD5 testing format.
This muxer computes and prints the MD5 hash for each audio
and video packet. By default audio frames are converted to signed
16-bit raw audio and video frames to raw video before computing the
hash.
The output of the muxer consists of a line for each audio and video
packet of the form:
@example
@var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, @var{MD5}
@end example
@var{MD5} is a hexadecimal number representing the computed MD5 hash
for the packet.
This is a variant of the @ref{framehash} muxer. Unlike that muxer,
it defaults to using the MD5 hash function.
@subsection Examples
For example to compute the MD5 of the audio and video frames in
@file{INPUT}, converted to raw audio and video packets, and store it
in the file @file{out.md5}:
To compute the MD5 hash of the audio and video frames in @file{INPUT},
converted to raw audio and video packets, and store it in the file
@file{out.md5}:
@example
ffmpeg -i INPUT -f framemd5 out.md5
@end example
@ -207,7 +247,7 @@ To print the information to stdout, use the command:
ffmpeg -i INPUT -f framemd5 -
@end example
See also the @ref{md5} muxer.
See also the @ref{framehash} and @ref{md5} muxers.
@anchor{gif}
@section gif
@ -243,6 +283,51 @@ ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif"
Note 2: the GIF format has a very small time base: the delay between two frames
can not be smaller than one centi second.
@anchor{hash}
@section hash
Hash testing format.
This muxer computes and prints a cryptographic hash of all the input
audio and video frames. This can be used for equality checks without
having to do a complete binary comparison.
By default audio frames are converted to signed 16-bit raw audio and
video frames to raw video before computing the hash, but the output
of explicit conversions to other codecs can also be used. Timestamps
are ignored. It uses the SHA-256 cryptographic hash function by default,
but supports several other algorithms.
The output of the muxer consists of a single line of the form:
@var{algo}=@var{hash}, where @var{algo} is a short string representing
the hash function used, and @var{hash} is a hexadecimal number
representing the computed hash.
@table @option
@item hash @var{algorithm}
Use the cryptographic hash function specified by the string @var{algorithm}.
Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
@code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
@code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
@code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
@end table
@subsection Examples
To compute the SHA-256 hash of the input converted to raw audio and
video, and store it in the file @file{out.sha256}:
@example
ffmpeg -i INPUT -f hash out.sha256
@end example
To print an MD5 hash to stdout use the command:
@example
ffmpeg -i INPUT -f hash -hash md5 -
@end example
See also the @ref{framehash} muxer.
@anchor{hls}
@section hls
@ -273,7 +358,8 @@ This muxer supports the following options:
@table @option
@item hls_time @var{seconds}
Set the segment length in seconds. Default value is 2.
Set the target segment length in seconds. Default value is 2.
Segment will be cut on the next key frame after this time has passed.
@item hls_list_size @var{size}
Set the maximum number of playlist entries. If set to 0 the list file
@ -318,6 +404,26 @@ ffmpeg in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
This example will produce the playlist, @file{out.m3u8}, and segment files:
@file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc.
@item use_localtime
Use strftime on @var{filename} to expand the segment filename with localtime.
The segment number (%d) is not available in this mode.
@example
ffmpeg in.nut -use_localtime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
@end example
This example will produce the playlist, @file{out.m3u8}, and segment files:
@file{file-20160215-1455569023.ts}, @file{file-20160215-1455569024.ts}, etc.
@item use_localtime_mkdir
Used together with -use_localtime, it will create up to one subdirectory which
is expanded in @var{filename}.
@example
ffmpeg in.nut -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
@end example
This example will create a directory 201560215 (if it does not exist), and then
produce the playlist, @file{out.m3u8}, and segment files:
@file{201560215/file-20160215-1455569023.ts}, @file{201560215/file-20160215-1455569024.ts}, etc.
@item hls_key_info_file @var{key_info_file}
Use the information in @var{key_info_file} for segment encryption. The first
line of @var{key_info_file} specifies the key URI written to the playlist. The
@ -388,6 +494,14 @@ Will produce the playlist, @file{out.m3u8}, and a single segment file,
@item hls_flags delete_segments
Segment files removed from the playlist are deleted after a period of time
equal to the duration of the segment plus the duration of the playlist.
@item hls_playlist_type event
Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces
@option{hls_list_size} to 0; the playlist can only be appended to.
@item hls_playlist_type vod
Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces
@option{hls_list_size} to 0; the playlist must not change.
@end table
@anchor{ico}
@ -601,16 +715,12 @@ have no effect if it is not.
MD5 testing format.
This muxer computes and prints the MD5 hash of all the input audio
and video frames. By default audio frames are converted to signed
16-bit raw audio and video frames to raw video before computing the
hash. Timestamps are ignored.
This is a variant of the @ref{hash} muxer. Unlike that muxer, it
defaults to using the MD5 hash function.
The output of the muxer consists of a single line of the form:
MD5=@var{MD5}, where @var{MD5} is a hexadecimal number representing
the computed MD5 hash.
@subsection Examples
For example to compute the MD5 hash of the input converted to raw
To compute the MD5 hash of the input converted to raw
audio and video, and store it in the file @file{out.md5}:
@example
ffmpeg -i INPUT -f md5 out.md5
@ -621,7 +731,7 @@ You can print the MD5 to stdout with the command:
ffmpeg -i INPUT -f md5 -
@end example
See also the @ref{framemd5} muxer.
See also the @ref{hash} and @ref{framemd5} muxers.
@section mov, mp4, ismv
@ -798,41 +908,41 @@ and @code{service_name}. If they are not set the default for
The muxer options are:
@table @option
@item -mpegts_original_network_id @var{number}
@item mpegts_original_network_id @var{number}
Set the original_network_id (default 0x0001). This is unique identifier
of a network in DVB. Its main use is in the unique identification of a
service through the path Original_Network_ID, Transport_Stream_ID.
@item -mpegts_transport_stream_id @var{number}
@item mpegts_transport_stream_id @var{number}
Set the transport_stream_id (default 0x0001). This identifies a
transponder in DVB.
@item -mpegts_service_id @var{number}
@item mpegts_service_id @var{number}
Set the service_id (default 0x0001) also known as program in DVB.
@item -mpegts_service_type @var{number}
@item mpegts_service_type @var{number}
Set the program service_type (default @var{digital_tv}), see below
a list of pre defined values.
@item -mpegts_pmt_start_pid @var{number}
@item mpegts_pmt_start_pid @var{number}
Set the first PID for PMT (default 0x1000, max 0x1f00).
@item -mpegts_start_pid @var{number}
@item mpegts_start_pid @var{number}
Set the first PID for data packets (default 0x0100, max 0x0f00).
@item -mpegts_m2ts_mode @var{number}
@item mpegts_m2ts_mode @var{number}
Enable m2ts mode if set to 1. Default value is -1 which disables m2ts mode.
@item -muxrate @var{number}
@item muxrate @var{number}
Set a constant muxrate (default VBR).
@item -pcr_period @var{numer}
@item pcr_period @var{numer}
Override the default PCR retransmission time (default 20ms), ignored
if variable muxrate is selected.
@item pat_period @var{number}
Maximal time in seconds between PAT/PMT tables.
@item sdt_period @var{number}
Maximal time in seconds between SDT tables.
@item -pes_payload_size @var{number}
@item pes_payload_size @var{number}
Set minimum PES packet payload in bytes.
@item -mpegts_flags @var{flags}
@item mpegts_flags @var{flags}
Set flags (see below).
@item -mpegts_copyts @var{number}
@item mpegts_copyts @var{number}
Preserve original timestamps, if value is set to 1. Default value is -1, which
results in shifting timestamps so that they start from 0.
@item -tables_version @var{number}
@item tables_version @var{number}
Set PAT, PMT and SDT version (default 0, valid values are from 0 to 31, inclusively).
This option allows updating stream structure so that standard consumer may
detect the change. To do so, reopen output AVFormatContext (in case of API
@ -848,7 +958,7 @@ ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
@end example
@end table
Option mpegts_service_type accepts the following values:
Option @option{mpegts_service_type} accepts the following values:
@table @option
@item hex_value
@ -869,7 +979,7 @@ Advanced Codec Digital SDTV service.
Advanced Codec Digital HDTV service.
@end table
Option mpegts_flags may take a set of such flags:
Option @option{mpegts_flags} may take a set of such flags:
@table @option
@item resend_headers
@ -1017,6 +1127,12 @@ implementation for HLS segmentation.
The segment muxer supports the following options:
@table @option
@item increment_tc @var{1|0}
if set to @code{1}, increment timecode between each segment
If this is selected, the input need to have
a timecode in the first video stream. Default value is
@code{0}.
@item reference_stream @var{specifier}
Set the reference stream, as specified by the string @var{specifier}.
If @var{specifier} is set to @code{auto}, the reference is chosen
@ -1204,6 +1320,11 @@ muxers/codecs. It is set to @code{0} by default.
@item initial_offset @var{offset}
Specify timestamp offset to apply to the output packet timestamps. The
argument must be a time duration specification, and defaults to 0.
@item write_empty_segments @var{1|0}
If enabled, write an empty segment if there are no packets during the period a
segment would usually span. Otherwise, the segment will be filled with the next
packet written. Defaults to @code{0}.
@end table
@subsection Examples
@ -1333,6 +1454,12 @@ Select the streams that should be mapped to the slave output,
specified by a stream specifier. If not specified, this defaults to
all the input streams. You may use multiple stream specifiers
separated by commas (@code{,}) e.g.: @code{a:0,v}
@item onfail
Specify behaviour on output failure. This can be set to either @code{abort} (which is
default) or @code{ignore}. @code{abort} will cause whole process to fail in case of failure
on this slave output. @code{ignore} will ignore failure on this output, so other outputs
will continue without being affected.
@end table
@subsection Examples
@ -1346,6 +1473,14 @@ ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
"archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
@end example
@item
As above, but continue streaming even if output to local file fails
(for example local drive fills up):
@example
ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
"[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
@end example
@item
Use @command{ffmpeg} to encode the input, and send the output
to three different destinations. The @code{dump_extra} bitstream

View File

@ -34,7 +34,7 @@ NUT has some variants signaled by using the flags field in its main header.
The BROADCAST variant provides a secondary time reference to facilitate
detecting endpoint latency and network delays.
It assumes all the endpoint clocks are syncronized.
It assumes all the endpoint clocks are synchronized.
To be used in real-time scenarios.
@section PIPE

View File

@ -7,7 +7,7 @@ If you plan to do non-x86 architecture specific optimizations (SIMD normally),
then take a look in the x86/ directory, as most important functions are
already optimized for MMX.
If you want to do x86 optimizations then you can either try to finetune the
If you want to do x86 optimizations then you can either try to fine-tune the
stuff in the x86 directory or find some other functions in the C source to
optimize, but there aren't many left.
@ -163,7 +163,7 @@ general x86 registers (e.g. eax) as well as XMM registers. This last one is
particularly important on Win64, where xmm6-15 are callee-save, and not
restoring their contents leads to undefined results. In external asm (e.g.
yasm), you do this by using:
cglobal functon_name, num_args, num_regs, num_xmm_regs
cglobal function_name, num_args, num_regs, num_xmm_regs
In inline asm, you specify clobbered registers at the end of your asm:
__asm__(".." ::: "%eax").
If gcc is not set to support sse (-msse) it will not accept xmm registers

View File

@ -63,7 +63,7 @@ bash ./configure
@section Darwin (Mac OS X, iPhone)
The toolchain provided with Xcode is sufficient to build the basic
unacelerated code.
unaccelerated code.
Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
@url{https://github.com/FFmpeg/gas-preprocessor} or
@ -144,7 +144,7 @@ pacman -S make pkgconf diffutils
pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL
@end example
To target 32bit replace the @code{x86_64} with @code{i686} in the command above.
To target 32 bits replace @code{x86_64} with @code{i686} in the command above.
@section Microsoft Visual C++ or Intel C++ Compiler for Windows

View File

@ -36,6 +36,14 @@ particular protocol using the option
The option "-protocols" of the ff* tools will display the list of
supported protocols.
All protocols accept the following options:
@table @option
@item rw_timeout
Maximum time to wait for (network) read/write operations to complete,
in microseconds.
@end table
A description of the currently available protocols follows.
@section async
@ -216,6 +224,17 @@ it, unless special care is taken (tests, customized server configuration
etc.). Different FTP servers behave in different way during seek
operation. ff* tools may produce incomplete content due to server limitations.
This protocol accepts the following options:
@table @option
@item follow
If set to 1, the protocol will retry reading at the end of the file, allowing
reading files that still are being written. In order for this to terminate,
you either need to use the rw_timeout option, or use the interrupt callback
(for API users).
@end table
@section gopher
Gopher protocol.
@ -1266,6 +1285,14 @@ Set the UDP maximum socket buffer size in bytes. This is used to set either
the receive or send buffer size, depending on what the socket is used for.
Default is 64KB. See also @var{fifo_size}.
@item bitrate=@var{bitrate}
If set to nonzero, the output will have the specified constant bitrate if the
input has enough packets to sustain it.
@item burst_bits=@var{bits}
When using @var{bitrate} this specifies the maximum number of bits in
packet bursts.
@item localport=@var{port}
Override the local UDP port to bind with.

View File

@ -120,8 +120,8 @@ select the native SW Resampler; filter options precision and cheby are not
applicable in this case.
@item soxr
select the SoX Resampler (where available); compensation, and filter options
filter_size, phase_shift, filter_type & kaiser_beta, are not applicable in this
case.
filter_size, phase_shift, exact_rational, filter_type & kaiser_beta, are not
applicable in this case.
@end table
@item filter_size
@ -134,6 +134,11 @@ the interval [0,30].
@item linear_interp
Use linear interpolation if set to 1, default value is 0.
@item exact_rational
For swr only, when enabled, try to use exact phase_count based on input and
output sample rate. However, if it is larger than @code{1 << phase_shift},
the phase_count will be @code{1 << phase_shift} as fallback. Default is disabled.
@item cutoff
Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float
value between 0 and 1. Default value is 0.97 with swr, and 0.91 with soxr

View File

@ -527,7 +527,7 @@ Wavelet Transform:
==================
Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integer
transform and a integer approximation of the symmetric biorthogonal 9/7
transform and an integer approximation of the symmetric biorthogonal 9/7
daubechies wavelet.
2D IDWT (inverse discrete wavelet transform)

View File

@ -10,12 +10,12 @@ Current (simplified) Architecture:
/ \
special converter [Input to YUV converter]
| |
| (8bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:0:0 )
| (8-bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:0:0 )
| |
| v
| Horizontal scaler
| |
| (15bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:1:1 / 4:0:0 )
| (15-bit YUV 4:4:4 / 4:2:2 / 4:2:0 / 4:1:1 / 4:0:0 )
| |
| v
| Vertical scaler and output converter

View File

@ -197,15 +197,15 @@ static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h,
}
dst += r->y * dst_linesize + r->x * 4;
src = r->pict.data[0];
pal = (uint32_t *)r->pict.data[1];
src = r->data[0];
pal = (uint32_t *)r->data[1];
for (y = 0; y < r->h; y++) {
dst2 = (uint32_t *)dst;
src2 = src;
for (x = 0; x < r->w; x++)
*(dst2++) = pal[*(src2++)];
dst += dst_linesize;
src += r->pict.linesize[0];
src += r->linesize[0];
}
}
@ -694,6 +694,17 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
if (exit_on_error)
exit_program(1);
}
if (pkt->size == 0 && pkt->side_data_elems == 0)
return;
if (!ost->st->codecpar->extradata && avctx->extradata) {
ost->st->codecpar->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!ost->st->codecpar->extradata) {
av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
exit_program(1);
}
ost->st->codecpar->extradata_size = avctx->extradata_size;
memcpy(ost->st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
}
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&
@ -710,6 +721,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
if(
(avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->dts != AV_NOPTS_VALUE &&
!(avctx->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) &&
ost->last_mux_dts != AV_NOPTS_VALUE) {
int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
if (pkt->dts < max) {
@ -1910,7 +1922,7 @@ int guess_input_channel_layout(InputStream *ist)
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 "
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;
@ -2123,8 +2135,12 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;
best_effort_timestamp= av_frame_get_best_effort_timestamp(decoded_frame);
if(best_effort_timestamp != AV_NOPTS_VALUE)
ist->next_pts = ist->pts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
if(best_effort_timestamp != AV_NOPTS_VALUE) {
int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
if (ts != AV_NOPTS_VALUE)
ist->next_pts = ist->pts = ts;
}
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "decoder -> ist_index:%d type:video "
@ -2543,6 +2559,8 @@ static int init_input_stream(int ist_index, char *error, int error_len)
av_log(NULL, AV_LOG_WARNING, "Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n");
}
av_dict_set(&ist->decoder_opts, "sub_text_format", "ass", AV_DICT_DONT_OVERWRITE);
if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) {
@ -2603,6 +2621,12 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
!av_dict_get(ost->encoder_opts, "ab", NULL, 0))
av_dict_set(&ost->encoder_opts, "b", "128000", 0);
if (ost->filter && ost->filter->filter->inputs[0]->hw_frames_ctx) {
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);
}
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
abort_codec_experimental(codec, 1);
@ -2654,7 +2678,7 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1});
ost->st->codec->codec= ost->enc_ctx->codec;
} else {
ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts);
ret = av_opt_set_dict(ost->st->codec, &ost->encoder_opts);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL,
"Error setting up codec context options.\n");
@ -2893,7 +2917,8 @@ static int transcode_init(void)
* overhead
*/
if(!strcmp(oc->oformat->name, "avi")) {
if ( copy_tb<0 && av_q2d(ist->st->r_frame_rate) >= av_q2d(ist->st->avg_frame_rate)
if ( copy_tb<0 && ist->st->r_frame_rate.num
&& av_q2d(ist->st->r_frame_rate) >= av_q2d(ist->st->avg_frame_rate)
&& 0.5/av_q2d(ist->st->r_frame_rate) > av_q2d(ist->st->time_base)
&& 0.5/av_q2d(ist->st->r_frame_rate) > av_q2d(dec_ctx->time_base)
&& av_q2d(ist->st->time_base) < 1.0/500 && av_q2d(dec_ctx->time_base) < 1.0/500
@ -2987,6 +3012,10 @@ static int transcode_init(void)
break;
case AVMEDIA_TYPE_VIDEO:
enc_ctx->pix_fmt = dec_ctx->pix_fmt;
enc_ctx->colorspace = dec_ctx->colorspace;
enc_ctx->color_range = dec_ctx->color_range;
enc_ctx->color_primaries = dec_ctx->color_primaries;
enc_ctx->color_trc = dec_ctx->color_trc;
enc_ctx->width = dec_ctx->width;
enc_ctx->height = dec_ctx->height;
enc_ctx->has_b_frames = dec_ctx->has_b_frames;
@ -3034,6 +3063,11 @@ static int transcode_init(void)
exit_program(1);
#endif
#if CONFIG_CUVID
if (cuvid_transcode_init(ost))
exit_program(1);
#endif
if (!ost->filter &&
(enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) {
@ -3194,13 +3228,6 @@ static int transcode_init(void)
}
}
/* open each encoder */
for (i = 0; i < nb_output_streams; i++) {
ret = init_output_stream(output_streams[i], error, sizeof(error));
if (ret < 0)
goto dump_format;
}
/* init input streams */
for (i = 0; i < nb_input_streams; i++)
if ((ret = init_input_stream(i, error, sizeof(error))) < 0) {
@ -3211,6 +3238,13 @@ static int transcode_init(void)
goto dump_format;
}
/* open each encoder */
for (i = 0; i < nb_output_streams; i++) {
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];
@ -4189,6 +4223,8 @@ static int transcode(void)
}
}
av_buffer_unref(&hw_device_ctx);
/* finished ! */
ret = 0;

View File

@ -65,6 +65,8 @@ enum HWAccelID {
HWACCEL_VDA,
HWACCEL_VIDEOTOOLBOX,
HWACCEL_QSV,
HWACCEL_VAAPI,
HWACCEL_CUVID,
};
typedef struct HWAccel {
@ -126,6 +128,8 @@ typedef struct OptionsContext {
int nb_hwaccels;
SpecifierOpt *hwaccel_devices;
int nb_hwaccel_devices;
SpecifierOpt *hwaccel_output_formats;
int nb_hwaccel_output_formats;
SpecifierOpt *autorotate;
int nb_autorotate;
@ -325,6 +329,7 @@ typedef struct InputStream {
/* hwaccel options */
enum HWAccelID hwaccel_id;
char *hwaccel_device;
enum AVPixelFormat hwaccel_output_format;
/* hwaccel context */
enum HWAccelID active_hwaccel_id;
@ -334,6 +339,7 @@ typedef struct InputStream {
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
enum AVPixelFormat hwaccel_pix_fmt;
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
AVBufferRef *hw_frames_ctx;
/* stats */
// combined size of all the packets read
@ -538,13 +544,14 @@ extern int stdin_interaction;
extern int frame_bits_per_raw_sample;
extern AVIOContext *progress_avio;
extern float max_error_rate;
extern int vdpau_api_ver;
extern char *videotoolbox_pixfmt;
extern const AVIOInterruptCB int_cb;
extern const OptionDef options[];
extern const HWAccel hwaccels[];
extern int hwaccel_lax_profile_check;
extern AVBufferRef *hw_device_ctx;
void term_init(void);
@ -577,5 +584,9 @@ int vda_init(AVCodecContext *s);
int videotoolbox_init(AVCodecContext *s);
int qsv_init(AVCodecContext *s);
int qsv_transcode_init(OutputStream *ost);
int vaapi_decode_init(AVCodecContext *avctx);
int vaapi_device_init(const char *device);
int cuvid_init(AVCodecContext *s);
int cuvid_transcode_init(OutputStream *ost);
#endif /* FFMPEG_H */

237
ffmpeg_cuvid.c Normal file
View File

@ -0,0 +1,237 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda.h"
#include "ffmpeg.h"
#include <cuda.h>
#include <nvcuvid.h>
typedef struct CUVIDContext {
AVBufferRef *hw_frames_ctx;
} CUVIDContext;
static void cuvid_uninit(AVCodecContext *avctx)
{
InputStream *ist = avctx->opaque;
CUVIDContext *ctx = ist->hwaccel_ctx;
if (ctx) {
av_buffer_unref(&ctx->hw_frames_ctx);
av_freep(&ctx);
}
av_buffer_unref(&ist->hw_frames_ctx);
ist->hwaccel_ctx = 0;
ist->hwaccel_uninit = 0;
}
int cuvid_init(AVCodecContext *avctx)
{
InputStream *ist = avctx->opaque;
CUVIDContext *ctx = ist->hwaccel_ctx;
av_log(NULL, AV_LOG_TRACE, "Initializing cuvid hwaccel\n");
if (!ctx) {
av_log(NULL, AV_LOG_ERROR, "CUVID transcoding is not initialized. "
"-hwaccel cuvid should only be used for one-to-one CUVID transcoding "
"with no (software) filters.\n");
return AVERROR(EINVAL);
}
return 0;
}
static void cuvid_ctx_free(AVHWDeviceContext *ctx)
{
AVCUDADeviceContext *hwctx = ctx->hwctx;
cuCtxDestroy(hwctx->cuda_ctx);
}
int cuvid_transcode_init(OutputStream *ost)
{
InputStream *ist;
const enum AVPixelFormat *pix_fmt;
AVCUDADeviceContext *device_hwctx;
AVHWDeviceContext *device_ctx;
AVHWFramesContext *hwframe_ctx;
CUVIDContext *ctx = NULL;
CUdevice device;
CUcontext cuda_ctx = NULL;
CUcontext dummy;
CUresult err;
int ret = 0;
av_log(NULL, AV_LOG_TRACE, "Initializing cuvid transcoding\n");
if (ost->source_index < 0)
return 0;
ist = input_streams[ost->source_index];
/* check if the encoder supports CUVID */
if (!ost->enc->pix_fmts)
goto cancel;
for (pix_fmt = ost->enc->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
if (*pix_fmt == AV_PIX_FMT_CUDA)
break;
if (*pix_fmt == AV_PIX_FMT_NONE)
goto cancel;
/* check if the decoder supports CUVID */
if (ist->hwaccel_id != HWACCEL_CUVID || !ist->dec || !ist->dec->pix_fmts)
goto cancel;
for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
if (*pix_fmt == AV_PIX_FMT_CUDA)
break;
if (*pix_fmt == AV_PIX_FMT_NONE)
goto cancel;
av_log(NULL, AV_LOG_VERBOSE, "Setting up CUVID transcoding\n");
if (ist->hwaccel_ctx) {
ctx = ist->hwaccel_ctx;
} else {
ctx = av_mallocz(sizeof(*ctx));
if (!ctx) {
ret = AVERROR(ENOMEM);
goto error;
}
}
if (!hw_device_ctx) {
hw_device_ctx = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_CUDA);
if (!hw_device_ctx) {
av_log(NULL, AV_LOG_ERROR, "av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_CUDA) failed\n");
ret = AVERROR(ENOMEM);
goto error;
}
err = cuInit(0);
if (err != CUDA_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "Could not initialize the CUDA driver API\n");
ret = AVERROR_UNKNOWN;
goto error;
}
err = cuDeviceGet(&device, 0); ///TODO: Make device index configurable
if (err != CUDA_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "Could not get the device number %d\n", 0);
ret = AVERROR_UNKNOWN;
goto error;
}
err = cuCtxCreate(&cuda_ctx, CU_CTX_SCHED_BLOCKING_SYNC, device);
if (err != CUDA_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "Error creating a CUDA context\n");
ret = AVERROR_UNKNOWN;
goto error;
}
device_ctx = (AVHWDeviceContext*)hw_device_ctx->data;
device_ctx->free = cuvid_ctx_free;
device_hwctx = device_ctx->hwctx;
device_hwctx->cuda_ctx = cuda_ctx;
err = cuCtxPopCurrent(&dummy);
if (err != CUDA_SUCCESS) {
av_log(NULL, AV_LOG_ERROR, "cuCtxPopCurrent failed\n");
ret = AVERROR_UNKNOWN;
goto error;
}
ret = av_hwdevice_ctx_init(hw_device_ctx);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "av_hwdevice_ctx_init failed\n");
goto error;
}
} else {
device_ctx = (AVHWDeviceContext*)hw_device_ctx->data;
device_hwctx = device_ctx->hwctx;
cuda_ctx = device_hwctx->cuda_ctx;
}
if (device_ctx->type != AV_HWDEVICE_TYPE_CUDA) {
av_log(NULL, AV_LOG_ERROR, "Hardware device context is already initialized for a diffrent hwaccel.\n");
ret = AVERROR(EINVAL);
goto error;
}
if (!ctx->hw_frames_ctx) {
ctx->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx);
if (!ctx->hw_frames_ctx) {
av_log(NULL, AV_LOG_ERROR, "av_hwframe_ctx_alloc failed\n");
ret = AVERROR(ENOMEM);
goto error;
}
}
/* This is a bit hacky, av_hwframe_ctx_init is called by the cuvid decoder
* once it has probed the neccesary format information. But as filters/nvenc
* need to know the format/sw_format, set them here so they are happy.
* This is fine as long as CUVID doesn't add another supported pix_fmt.
*/
hwframe_ctx = (AVHWFramesContext*)ctx->hw_frames_ctx->data;
hwframe_ctx->format = AV_PIX_FMT_CUDA;
hwframe_ctx->sw_format = AV_PIX_FMT_NV12;
ost->hwaccel_ctx = ctx;
ost->enc_ctx->hw_frames_ctx = av_buffer_ref(ctx->hw_frames_ctx);
ost->enc_ctx->pix_fmt = AV_PIX_FMT_CUDA;
if (!ost->enc_ctx->hw_frames_ctx) {
av_log(NULL, AV_LOG_ERROR, "av_buffer_ref failed\n");
ret = AVERROR(ENOMEM);
goto error;
}
if (!ist->hwaccel_ctx) {
ist->hwaccel_ctx = ctx;
ist->hw_frames_ctx = av_buffer_ref(ctx->hw_frames_ctx);
ist->dec_ctx->hw_frames_ctx = av_buffer_ref(ctx->hw_frames_ctx);
ist->dec_ctx->pix_fmt = AV_PIX_FMT_CUDA;
ist->resample_pix_fmt = AV_PIX_FMT_CUDA;
ist->hwaccel_uninit = cuvid_uninit;
if (!ist->hw_frames_ctx || !ist->dec_ctx->hw_frames_ctx) {
av_log(NULL, AV_LOG_ERROR, "av_buffer_ref failed\n");
ret = AVERROR(ENOMEM);
goto error;
}
}
return 0;
error:
av_freep(&ctx);
return ret;
cancel:
if (ist->hwaccel_id == HWACCEL_CUVID) {
av_log(NULL, AV_LOG_ERROR, "CUVID hwaccel requested, but impossible to achive.\n");
return AVERROR(EINVAL);
}
return 0;
}

View File

@ -40,6 +40,9 @@
#include "libavutil/imgutils.h"
#include "libavutil/pixfmt.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_dxva2.h"
/* define all the GUIDs used directly here,
to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and different MSVC version */
#include <initguid.h>
@ -53,13 +56,11 @@ DEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68, 0x4951,0x4C54,0x88,0xFE,0xAB,0
DEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0);
DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13);
DEFINE_GUID(DXVA2_ModeVP9_VLD_Profile0, 0x463707f8, 0xa1d0,0x4585,0x87,0x6d,0x83,0xaa,0x6d,0x60,0xb8,0x9e);
DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
DEFINE_GUID(GUID_NULL, 0x00000000, 0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT);
typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **);
typedef struct dxva2_mode {
const GUID *guid;
enum AVCodecID codec;
@ -84,6 +85,7 @@ static const dxva2_mode dxva2_modes[] = {
/* HEVC/H.265 */
{ &DXVA2_ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC },
{ &DXVA2_ModeHEVC_VLD_Main10,AV_CODEC_ID_HEVC },
/* VP8/9 */
{ &DXVA2_ModeVP9_VLD_Profile0, AV_CODEC_ID_VP9 },
@ -91,63 +93,19 @@ static const dxva2_mode dxva2_modes[] = {
{ NULL, 0 },
};
typedef struct surface_info {
int used;
uint64_t age;
} surface_info;
typedef struct DXVA2Context {
HMODULE d3dlib;
HMODULE dxva2lib;
HANDLE deviceHandle;
IDirect3D9 *d3d9;
IDirect3DDevice9 *d3d9device;
IDirect3DDeviceManager9 *d3d9devmgr;
IDirectXVideoDecoderService *decoder_service;
IDirectXVideoDecoder *decoder;
GUID decoder_guid;
DXVA2_ConfigPictureDecode decoder_config;
LPDIRECT3DSURFACE9 *surfaces;
surface_info *surface_infos;
uint32_t num_surfaces;
uint64_t surface_age;
IDirectXVideoDecoderService *decoder_service;
AVFrame *tmp_frame;
AVBufferRef *hw_device_ctx;
AVBufferRef *hw_frames_ctx;
} DXVA2Context;
typedef struct DXVA2SurfaceWrapper {
DXVA2Context *ctx;
LPDIRECT3DSURFACE9 surface;
IDirectXVideoDecoder *decoder;
} DXVA2SurfaceWrapper;
static void dxva2_destroy_decoder(AVCodecContext *s)
{
InputStream *ist = s->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
int i;
if (ctx->surfaces) {
for (i = 0; i < ctx->num_surfaces; i++) {
if (ctx->surfaces[i])
IDirect3DSurface9_Release(ctx->surfaces[i]);
}
}
av_freep(&ctx->surfaces);
av_freep(&ctx->surface_infos);
ctx->num_surfaces = 0;
ctx->surface_age = 0;
if (ctx->decoder) {
IDirectXVideoDecoder_Release(ctx->decoder);
ctx->decoder = NULL;
}
}
static void dxva2_uninit(AVCodecContext *s)
{
InputStream *ist = s->opaque;
@ -157,29 +115,11 @@ static void dxva2_uninit(AVCodecContext *s)
ist->hwaccel_get_buffer = NULL;
ist->hwaccel_retrieve_data = NULL;
if (ctx->decoder)
dxva2_destroy_decoder(s);
if (ctx->decoder_service)
IDirectXVideoDecoderService_Release(ctx->decoder_service);
if (ctx->d3d9devmgr && ctx->deviceHandle != INVALID_HANDLE_VALUE)
IDirect3DDeviceManager9_CloseDeviceHandle(ctx->d3d9devmgr, ctx->deviceHandle);
if (ctx->d3d9devmgr)
IDirect3DDeviceManager9_Release(ctx->d3d9devmgr);
if (ctx->d3d9device)
IDirect3DDevice9_Release(ctx->d3d9device);
if (ctx->d3d9)
IDirect3D9_Release(ctx->d3d9);
if (ctx->d3dlib)
FreeLibrary(ctx->d3dlib);
if (ctx->dxva2lib)
FreeLibrary(ctx->dxva2lib);
av_buffer_unref(&ctx->hw_frames_ctx);
av_buffer_unref(&ctx->hw_device_ctx);
av_frame_free(&ctx->tmp_frame);
@ -187,119 +127,34 @@ static void dxva2_uninit(AVCodecContext *s)
av_freep(&s->hwaccel_context);
}
static void dxva2_release_buffer(void *opaque, uint8_t *data)
{
DXVA2SurfaceWrapper *w = opaque;
DXVA2Context *ctx = w->ctx;
int i;
for (i = 0; i < ctx->num_surfaces; i++) {
if (ctx->surfaces[i] == w->surface) {
ctx->surface_infos[i].used = 0;
break;
}
}
IDirect3DSurface9_Release(w->surface);
IDirectXVideoDecoder_Release(w->decoder);
av_free(w);
}
static int dxva2_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
{
InputStream *ist = s->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
int i, old_unused = -1;
LPDIRECT3DSURFACE9 surface;
DXVA2SurfaceWrapper *w = NULL;
av_assert0(frame->format == AV_PIX_FMT_DXVA2_VLD);
for (i = 0; i < ctx->num_surfaces; i++) {
surface_info *info = &ctx->surface_infos[i];
if (!info->used && (old_unused == -1 || info->age < ctx->surface_infos[old_unused].age))
old_unused = i;
}
if (old_unused == -1) {
av_log(NULL, AV_LOG_ERROR, "No free DXVA2 surface!\n");
return AVERROR(ENOMEM);
}
i = old_unused;
surface = ctx->surfaces[i];
w = av_mallocz(sizeof(*w));
if (!w)
return AVERROR(ENOMEM);
frame->buf[0] = av_buffer_create((uint8_t*)surface, 0,
dxva2_release_buffer, w,
AV_BUFFER_FLAG_READONLY);
if (!frame->buf[0]) {
av_free(w);
return AVERROR(ENOMEM);
}
w->ctx = ctx;
w->surface = surface;
IDirect3DSurface9_AddRef(w->surface);
w->decoder = ctx->decoder;
IDirectXVideoDecoder_AddRef(w->decoder);
ctx->surface_infos[i].used = 1;
ctx->surface_infos[i].age = ctx->surface_age++;
frame->data[3] = (uint8_t *)surface;
return 0;
return av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0);
}
static int dxva2_retrieve_data(AVCodecContext *s, AVFrame *frame)
{
LPDIRECT3DSURFACE9 surface = (LPDIRECT3DSURFACE9)frame->data[3];
InputStream *ist = s->opaque;
DXVA2Context *ctx = ist->hwaccel_ctx;
D3DSURFACE_DESC surfaceDesc;
D3DLOCKED_RECT LockedRect;
HRESULT hr;
int ret;
IDirect3DSurface9_GetDesc(surface, &surfaceDesc);
ctx->tmp_frame->width = frame->width;
ctx->tmp_frame->height = frame->height;
ctx->tmp_frame->format = AV_PIX_FMT_NV12;
ret = av_frame_get_buffer(ctx->tmp_frame, 32);
ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0);
if (ret < 0)
return ret;
hr = IDirect3DSurface9_LockRect(surface, &LockedRect, NULL, D3DLOCK_READONLY);
if (FAILED(hr)) {
av_log(NULL, AV_LOG_ERROR, "Unable to lock DXVA2 surface\n");
return AVERROR_UNKNOWN;
}
av_image_copy_plane(ctx->tmp_frame->data[0], ctx->tmp_frame->linesize[0],
(uint8_t*)LockedRect.pBits,
LockedRect.Pitch, frame->width, frame->height);
av_image_copy_plane(ctx->tmp_frame->data[1], ctx->tmp_frame->linesize[1],
(uint8_t*)LockedRect.pBits + LockedRect.Pitch * surfaceDesc.Height,
LockedRect.Pitch, frame->width, frame->height / 2);
IDirect3DSurface9_UnlockRect(surface);
ret = av_frame_copy_props(ctx->tmp_frame, frame);
if (ret < 0)
goto fail;
if (ret < 0) {
av_frame_unref(ctx->tmp_frame);
return ret;
}
av_frame_unref(frame);
av_frame_move_ref(frame, ctx->tmp_frame);
return 0;
fail:
av_frame_unref(ctx->tmp_frame);
return ret;
}
static int dxva2_alloc(AVCodecContext *s)
@ -307,94 +162,40 @@ static int dxva2_alloc(AVCodecContext *s)
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
DXVA2Context *ctx;
pDirect3DCreate9 *createD3D = NULL;
pCreateDeviceManager9 *createDeviceManager = NULL;
HANDLE device_handle;
HRESULT hr;
D3DPRESENT_PARAMETERS d3dpp = {0};
D3DDISPLAYMODE d3ddm;
unsigned resetToken = 0;
UINT adapter = D3DADAPTER_DEFAULT;
AVHWDeviceContext *device_ctx;
AVDXVA2DeviceContext *device_hwctx;
int ret;
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
return AVERROR(ENOMEM);
ctx->deviceHandle = INVALID_HANDLE_VALUE;
ist->hwaccel_ctx = ctx;
ist->hwaccel_uninit = dxva2_uninit;
ist->hwaccel_get_buffer = dxva2_get_buffer;
ist->hwaccel_retrieve_data = dxva2_retrieve_data;
ctx->d3dlib = LoadLibrary("d3d9.dll");
if (!ctx->d3dlib) {
av_log(NULL, loglevel, "Failed to load D3D9 library\n");
ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2,
ist->hwaccel_device, NULL, 0);
if (ret < 0)
goto fail;
}
ctx->dxva2lib = LoadLibrary("dxva2.dll");
if (!ctx->dxva2lib) {
av_log(NULL, loglevel, "Failed to load DXVA2 library\n");
goto fail;
}
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data;
device_hwctx = device_ctx->hwctx;
createD3D = (pDirect3DCreate9 *)GetProcAddress(ctx->d3dlib, "Direct3DCreate9");
if (!createD3D) {
av_log(NULL, loglevel, "Failed to locate Direct3DCreate9\n");
goto fail;
}
createDeviceManager = (pCreateDeviceManager9 *)GetProcAddress(ctx->dxva2lib, "DXVA2CreateDirect3DDeviceManager9");
if (!createDeviceManager) {
av_log(NULL, loglevel, "Failed to locate DXVA2CreateDirect3DDeviceManager9\n");
goto fail;
}
ctx->d3d9 = createD3D(D3D_SDK_VERSION);
if (!ctx->d3d9) {
av_log(NULL, loglevel, "Failed to create IDirect3D object\n");
goto fail;
}
if (ist->hwaccel_device) {
adapter = atoi(ist->hwaccel_device);
av_log(NULL, AV_LOG_INFO, "Using HWAccel device %d\n", adapter);
}
IDirect3D9_GetAdapterDisplayMode(ctx->d3d9, adapter, &d3ddm);
d3dpp.Windowed = TRUE;
d3dpp.BackBufferWidth = 640;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferCount = 0;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
hr = IDirect3D9_CreateDevice(ctx->d3d9, adapter, D3DDEVTYPE_HAL, GetDesktopWindow(),
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
&d3dpp, &ctx->d3d9device);
hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
&device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create Direct3D device\n");
av_log(NULL, loglevel, "Failed to open a device handle\n");
goto fail;
}
hr = createDeviceManager(&resetToken, &ctx->d3d9devmgr);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create Direct3D device manager\n");
goto fail;
}
hr = IDirect3DDeviceManager9_ResetDevice(ctx->d3d9devmgr, ctx->d3d9device, resetToken);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to bind Direct3D device to device manager\n");
goto fail;
}
hr = IDirect3DDeviceManager9_OpenDeviceHandle(ctx->d3d9devmgr, &ctx->deviceHandle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to open device handle\n");
goto fail;
}
hr = IDirect3DDeviceManager9_GetVideoService(ctx->d3d9devmgr, ctx->deviceHandle, &IID_IDirectXVideoDecoderService, (void **)&ctx->decoder_service);
hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle,
&IID_IDirectXVideoDecoderService,
(void **)&ctx->decoder_service);
IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create IDirectXVideoDecoderService\n");
goto fail;
@ -470,13 +271,17 @@ static int dxva2_create_decoder(AVCodecContext *s)
GUID *guid_list = NULL;
unsigned guid_count = 0, i, j;
GUID device_guid = GUID_NULL;
const D3DFORMAT surface_format = (s->sw_pix_fmt == AV_PIX_FMT_YUV420P10) ? MKTAG('P','0','1','0') : MKTAG('N','V','1','2');
D3DFORMAT target_format = 0;
DXVA2_VideoDesc desc = { 0 };
DXVA2_ConfigPictureDecode config;
HRESULT hr;
int surface_alignment;
int surface_alignment, num_surfaces;
int ret;
AVDXVA2FramesContext *frames_hwctx;
AVHWFramesContext *frames_ctx;
hr = IDirectXVideoDecoderService_GetDecoderDeviceGuids(ctx->decoder_service, &guid_count, &guid_list);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to retrieve decoder device GUIDs\n");
@ -503,7 +308,7 @@ static int dxva2_create_decoder(AVCodecContext *s)
}
for (j = 0; j < target_count; j++) {
const D3DFORMAT format = target_list[j];
if (format == MKTAG('N','V','1','2')) {
if (format == surface_format) {
target_format = format;
break;
}
@ -542,43 +347,43 @@ static int dxva2_create_decoder(AVCodecContext *s)
surface_alignment = 16;
/* 4 base work surfaces */
ctx->num_surfaces = 4;
num_surfaces = 4;
/* add surfaces based on number of possible refs */
if (s->codec_id == AV_CODEC_ID_H264 || s->codec_id == AV_CODEC_ID_HEVC)
ctx->num_surfaces += 16;
num_surfaces += 16;
else if (s->codec_id == AV_CODEC_ID_VP9)
ctx->num_surfaces += 8;
num_surfaces += 8;
else
ctx->num_surfaces += 2;
num_surfaces += 2;
/* add extra surfaces for frame threading */
if (s->active_thread_type & FF_THREAD_FRAME)
ctx->num_surfaces += s->thread_count;
num_surfaces += s->thread_count;
ctx->surfaces = av_mallocz(ctx->num_surfaces * sizeof(*ctx->surfaces));
ctx->surface_infos = av_mallocz(ctx->num_surfaces * sizeof(*ctx->surface_infos));
if (!ctx->surfaces || !ctx->surface_infos) {
av_log(NULL, loglevel, "Unable to allocate surface arrays\n");
ctx->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->hw_device_ctx);
if (!ctx->hw_frames_ctx)
goto fail;
}
frames_ctx = (AVHWFramesContext*)ctx->hw_frames_ctx->data;
frames_hwctx = frames_ctx->hwctx;
hr = IDirectXVideoDecoderService_CreateSurface(ctx->decoder_service,
FFALIGN(s->coded_width, surface_alignment),
FFALIGN(s->coded_height, surface_alignment),
ctx->num_surfaces - 1,
target_format, D3DPOOL_DEFAULT, 0,
DXVA2_VideoDecoderRenderTarget,
ctx->surfaces, NULL);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create %d video surfaces\n", ctx->num_surfaces);
frames_ctx->format = AV_PIX_FMT_DXVA2_VLD;
frames_ctx->sw_format = (target_format == MKTAG('P','0','1','0') ? AV_PIX_FMT_P010 : AV_PIX_FMT_NV12);
frames_ctx->width = FFALIGN(s->coded_width, surface_alignment);
frames_ctx->height = FFALIGN(s->coded_height, surface_alignment);
frames_ctx->initial_pool_size = num_surfaces;
frames_hwctx->surface_type = DXVA2_VideoDecoderRenderTarget;
ret = av_hwframe_ctx_init(ctx->hw_frames_ctx);
if (ret < 0) {
av_log(NULL, loglevel, "Failed to initialize the HW frames context\n");
goto fail;
}
hr = IDirectXVideoDecoderService_CreateVideoDecoder(ctx->decoder_service, &device_guid,
&desc, &config, ctx->surfaces,
ctx->num_surfaces, &ctx->decoder);
&desc, &config, frames_hwctx->surfaces,
frames_hwctx->nb_surfaces, &frames_hwctx->decoder_to_release);
if (FAILED(hr)) {
av_log(NULL, loglevel, "Failed to create DXVA2 video decoder\n");
goto fail;
@ -588,16 +393,16 @@ static int dxva2_create_decoder(AVCodecContext *s)
ctx->decoder_config = config;
dxva_ctx->cfg = &ctx->decoder_config;
dxva_ctx->decoder = ctx->decoder;
dxva_ctx->surface = ctx->surfaces;
dxva_ctx->surface_count = ctx->num_surfaces;
dxva_ctx->decoder = frames_hwctx->decoder_to_release;
dxva_ctx->surface = frames_hwctx->surfaces;
dxva_ctx->surface_count = frames_hwctx->nb_surfaces;
if (IsEqualGUID(&ctx->decoder_guid, &DXVADDI_Intel_ModeH264_E))
dxva_ctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
return 0;
fail:
dxva2_destroy_decoder(s);
av_buffer_unref(&ctx->hw_frames_ctx);
return AVERROR(EINVAL);
}
@ -621,8 +426,13 @@ int dxva2_init(AVCodecContext *s)
return AVERROR(EINVAL);
}
if (ctx->decoder)
dxva2_destroy_decoder(s);
if (s->codec_id == AV_CODEC_ID_HEVC &&
s->profile != FF_PROFILE_HEVC_MAIN && s->profile != FF_PROFILE_HEVC_MAIN_10) {
av_log(NULL, loglevel, "Unsupported HEVC profile for DXVA2 HWAccel: %d\n", s->profile);
return AVERROR(EINVAL);
}
av_buffer_unref(&ctx->hw_frames_ctx);
ret = dxva2_create_decoder(s);
if (ret < 0) {

View File

@ -24,6 +24,7 @@
#include "libavfilter/avfilter.h"
#include "libavfilter/buffersink.h"
#include "libavfilter/buffersrc.h"
#include "libavresample/avresample.h"
@ -38,7 +39,6 @@
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum AVCodecID codec_id, const enum AVPixelFormat default_formats[])
{
static const enum AVPixelFormat mjpeg_formats[] =
@ -428,7 +428,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
if (ret < 0)
return ret;
if (codec->width || codec->height) {
if (!hw_device_ctx && (codec->width || codec->height)) {
char args[255];
AVFilterContext *filter;
AVDictionaryEntry *e = NULL;
@ -656,7 +656,7 @@ int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOu
DESCRIBE_FILTER_LINK(ofilter, out, 0);
if (!ofilter->ost) {
av_log(NULL, AV_LOG_FATAL, "Filter %s has a unconnected output\n", ofilter->name);
av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
exit_program(1);
}
@ -719,10 +719,17 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
char name[255];
int ret, pad_idx = 0;
int64_t tsoffset = 0;
AVBufferSrcParameters *par = av_buffersrc_parameters_alloc();
if (!par)
return AVERROR(ENOMEM);
memset(par, 0, sizeof(*par));
par->format = AV_PIX_FMT_NONE;
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
return AVERROR(EINVAL);
ret = AVERROR(EINVAL);
goto fail;
}
if (!fr.num)
@ -731,7 +738,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = sub2video_prepare(ist);
if (ret < 0)
return ret;
goto fail;
}
sar = ist->st->sample_aspect_ratio.num ?
@ -752,9 +759,15 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
ist->file_index, ist->st->index);
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
args.str, NULL, fg->graph)) < 0)
return ret;
goto fail;
par->hw_frames_ctx = ist->hw_frames_ctx;
ret = av_buffersrc_parameters_set(ifilter->filter, par);
if (ret < 0)
goto fail;
av_freep(&par);
last_filter = ifilter->filter;
if (ist->autorotate) {
@ -828,6 +841,10 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
return ret;
return 0;
fail:
av_freep(&par);
return ret;
}
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
@ -1010,6 +1027,12 @@ int configure_filtergraph(FilterGraph *fg)
if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
return ret;
if (hw_device_ctx) {
for (i = 0; i < fg->graph->nb_filters; i++) {
fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(hw_device_ctx);
}
}
if (simple && (!inputs || inputs->next || !outputs || outputs->next)) {
const char *num_inputs;
const char *num_outputs;

View File

@ -40,7 +40,6 @@
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "libavutil/time_internal.h"
#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
@ -81,9 +80,17 @@ const HWAccel hwaccels[] = {
#endif
#if CONFIG_LIBMFX
{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV },
#endif
#if CONFIG_VAAPI
{ "vaapi", vaapi_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI },
#endif
#if CONFIG_CUVID
{ "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA },
#endif
{ 0 },
};
int hwaccel_lax_profile_check = 0;
AVBufferRef *hw_device_ctx;
char *vstats_filename;
char *sdp_filename;
@ -442,6 +449,17 @@ static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
return 0;
}
#if CONFIG_VAAPI
static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
{
int err;
err = vaapi_device_init(arg);
if (err < 0)
exit_program(1);
return 0;
}
#endif
/**
* Parse a metadata specifier passed as 'arg' parameter.
* @param arg metadata string to parse
@ -634,6 +652,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
AVCodecContext *dec = st->codec;
InputStream *ist = av_mallocz(sizeof(*ist));
char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
char *hwaccel_output_format = NULL;
char *codec_tag = NULL;
char *next;
char *discard_str = NULL;
@ -753,6 +772,19 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
if (!ist->hwaccel_device)
exit_program(1);
}
MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
hwaccel_output_format, ic, st);
if (hwaccel_output_format) {
ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
"format: %s", hwaccel_output_format);
}
} else {
ist->hwaccel_output_format = AV_PIX_FMT_NONE;
}
ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
break;
@ -2430,7 +2462,6 @@ loop_end:
char type, *val;
const char *stream_spec;
int index = 0, j, ret = 0;
char now_time[256];
val = strchr(o->metadata[i].u.str, '=');
if (!val) {
@ -2440,17 +2471,6 @@ loop_end:
}
*val++ = 0;
if (!strcmp(o->metadata[i].u.str, "creation_time") &&
!strcmp(val, "now")) {
time_t now = time(0);
struct tm *ptm, tmbuf;
ptm = localtime_r(&now, &tmbuf);
if (ptm) {
if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm))
val = now_time;
}
}
parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec);
if (type == 's') {
for (j = 0; j < oc->nb_streams; j++) {
@ -3361,9 +3381,12 @@ const OptionDef options[] = {
{ "hwaccel_device", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_devices) },
"select a device for HW acceleration", "devicename" },
#if HAVE_VDPAU_X11
{ "vdpau_api_ver", HAS_ARG | OPT_INT | OPT_EXPERT, { &vdpau_api_ver }, "" },
#endif
{ "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" },
{ "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
@ -3372,6 +3395,8 @@ const OptionDef options[] = {
{ "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) },
"automatically insert correct rotate filters" },
{ "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT, { &hwaccel_lax_profile_check},
"attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream" },
/* audio options */
{ "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },
@ -3455,5 +3480,10 @@ const OptionDef options[] = {
{ "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
{ NULL, },
};

538
ffmpeg_vaapi.c Normal file
View File

@ -0,0 +1,538 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <fcntl.h>
#include <unistd.h>
#include <va/va.h>
#if HAVE_VAAPI_X11
# include <va/va_x11.h>
#endif
#if HAVE_VAAPI_DRM
# include <va/va_drm.h>
#endif
#include "libavutil/avassert.h"
#include "libavutil/avconfig.h"
#include "libavutil/buffer.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_vaapi.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "libavcodec/vaapi.h"
#include "ffmpeg.h"
static AVClass vaapi_class = {
.class_name = "vaapi",
.item_name = av_default_item_name,
.version = LIBAVUTIL_VERSION_INT,
};
#define DEFAULT_SURFACES 20
typedef struct VAAPIDecoderContext {
const AVClass *class;
AVBufferRef *device_ref;
AVHWDeviceContext *device;
AVBufferRef *frames_ref;
AVHWFramesContext *frames;
VAProfile va_profile;
VAEntrypoint va_entrypoint;
VAConfigID va_config;
VAContextID va_context;
enum AVPixelFormat decode_format;
int decode_width;
int decode_height;
int decode_surfaces;
// The output need not have the same format, width and height as the
// decoded frames - the copy for non-direct-mapped access is actually
// a whole vpp instance which can do arbitrary scaling and format
// conversion.
enum AVPixelFormat output_format;
struct vaapi_context decoder_vaapi_context;
} VAAPIDecoderContext;
static int vaapi_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
InputStream *ist = avctx->opaque;
VAAPIDecoderContext *ctx = ist->hwaccel_ctx;
int err;
err = av_hwframe_get_buffer(ctx->frames_ref, frame, 0);
if (err < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate decoder surface.\n");
} else {
av_log(ctx, AV_LOG_DEBUG, "Decoder given surface %#x.\n",
(unsigned int)(uintptr_t)frame->data[3]);
}
return err;
}
static int vaapi_retrieve_data(AVCodecContext *avctx, AVFrame *input)
{
InputStream *ist = avctx->opaque;
VAAPIDecoderContext *ctx = ist->hwaccel_ctx;
AVFrame *output = 0;
int err;
av_assert0(input->format == AV_PIX_FMT_VAAPI);
if (ctx->output_format == AV_PIX_FMT_VAAPI) {
// Nothing to do.
return 0;
}
av_log(ctx, AV_LOG_DEBUG, "Retrieve data from surface %#x.\n",
(unsigned int)(uintptr_t)input->data[3]);
output = av_frame_alloc();
if (!output)
return AVERROR(ENOMEM);
output->format = ctx->output_format;
err = av_hwframe_transfer_data(output, input, 0);
if (err < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to transfer data to "
"output frame: %d.\n", err);
goto fail;
}
err = av_frame_copy_props(output, input);
if (err < 0) {
av_frame_unref(output);
goto fail;
}
av_frame_unref(input);
av_frame_move_ref(input, output);
av_frame_free(&output);
return 0;
fail:
if (output)
av_frame_free(&output);
return err;
}
static const struct {
enum AVCodecID codec_id;
int codec_profile;
VAProfile va_profile;
} vaapi_profile_map[] = {
#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
MAP(MPEG2VIDEO, MPEG2_SIMPLE, MPEG2Simple ),
MAP(MPEG2VIDEO, MPEG2_MAIN, MPEG2Main ),
MAP(H263, UNKNOWN, H263Baseline),
MAP(MPEG4, MPEG4_SIMPLE, MPEG4Simple ),
MAP(MPEG4, MPEG4_ADVANCED_SIMPLE,
MPEG4AdvancedSimple),
MAP(MPEG4, MPEG4_MAIN, MPEG4Main ),
MAP(H264, H264_CONSTRAINED_BASELINE,
H264ConstrainedBaseline),
MAP(H264, H264_BASELINE, H264Baseline),
MAP(H264, H264_MAIN, H264Main ),
MAP(H264, H264_HIGH, H264High ),
#if VA_CHECK_VERSION(0, 37, 0)
MAP(HEVC, HEVC_MAIN, HEVCMain ),
#endif
MAP(WMV3, VC1_SIMPLE, VC1Simple ),
MAP(WMV3, VC1_MAIN, VC1Main ),
MAP(WMV3, VC1_COMPLEX, VC1Advanced ),
MAP(WMV3, VC1_ADVANCED, VC1Advanced ),
MAP(VC1, VC1_SIMPLE, VC1Simple ),
MAP(VC1, VC1_MAIN, VC1Main ),
MAP(VC1, VC1_COMPLEX, VC1Advanced ),
MAP(VC1, VC1_ADVANCED, VC1Advanced ),
#if VA_CHECK_VERSION(0, 35, 0)
MAP(VP8, UNKNOWN, VP8Version0_3 ),
#endif
#if VA_CHECK_VERSION(0, 37, 1)
MAP(VP9, VP9_0, VP9Profile0 ),
#endif
#undef MAP
};
static int vaapi_build_decoder_config(VAAPIDecoderContext *ctx,
AVCodecContext *avctx,
int fallback_allowed)
{
AVVAAPIDeviceContext *hwctx = ctx->device->hwctx;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
VAStatus vas;
int err, i, j;
int loglevel = fallback_allowed ? AV_LOG_VERBOSE : AV_LOG_ERROR;
const AVCodecDescriptor *codec_desc;
const AVPixFmtDescriptor *pix_desc;
enum AVPixelFormat pix_fmt;
VAProfile profile, *profile_list = NULL;
int profile_count, exact_match, alt_profile;
codec_desc = avcodec_descriptor_get(avctx->codec_id);
if (!codec_desc) {
err = AVERROR(EINVAL);
goto fail;
}
profile_count = vaMaxNumProfiles(hwctx->display);
profile_list = av_malloc(profile_count * sizeof(VAProfile));
if (!profile_list) {
err = AVERROR(ENOMEM);
goto fail;
}
vas = vaQueryConfigProfiles(hwctx->display,
profile_list, &profile_count);
if (vas != VA_STATUS_SUCCESS) {
av_log(ctx, loglevel, "Failed to query profiles: %d (%s).\n",
vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail;
}
profile = VAProfileNone;
exact_match = 0;
for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) {
int profile_match = 0;
if (avctx->codec_id != vaapi_profile_map[i].codec_id)
continue;
if (avctx->profile == vaapi_profile_map[i].codec_profile)
profile_match = 1;
profile = vaapi_profile_map[i].va_profile;
for (j = 0; j < profile_count; j++) {
if (profile == profile_list[j]) {
exact_match = profile_match;
break;
}
}
if (j < profile_count) {
if (exact_match)
break;
alt_profile = vaapi_profile_map[i].codec_profile;
}
}
av_freep(&profile_list);
if (profile == VAProfileNone) {
av_log(ctx, loglevel, "No VAAPI support for codec %s.\n",
codec_desc->name);
err = AVERROR(ENOSYS);
goto fail;
}
if (!exact_match) {
if (fallback_allowed || !hwaccel_lax_profile_check) {
av_log(ctx, loglevel, "No VAAPI support for codec %s "
"profile %d.\n", codec_desc->name, avctx->profile);
if (!fallback_allowed) {
av_log(ctx, AV_LOG_WARNING, "If you want attempt decoding "
"anyway with a possibly-incompatible profile, add "
"the option -hwaccel_lax_profile_check.\n");
}
err = AVERROR(EINVAL);
goto fail;
} else {
av_log(ctx, AV_LOG_WARNING, "No VAAPI support for codec %s "
"profile %d: trying instead with profile %d.\n",
codec_desc->name, avctx->profile, alt_profile);
av_log(ctx, AV_LOG_WARNING, "This may fail or give "
"incorrect results, depending on your hardware.\n");
}
}
ctx->va_profile = profile;
ctx->va_entrypoint = VAEntrypointVLD;
vas = vaCreateConfig(hwctx->display, ctx->va_profile,
ctx->va_entrypoint, 0, 0, &ctx->va_config);
if (vas != VA_STATUS_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed to create decode pipeline "
"configuration: %d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EIO);
goto fail;
}
hwconfig = av_hwdevice_hwconfig_alloc(ctx->device_ref);
if (!hwconfig) {
err = AVERROR(ENOMEM);
goto fail;
}
hwconfig->config_id = ctx->va_config;
constraints = av_hwdevice_get_hwframe_constraints(ctx->device_ref,
hwconfig);
if (!constraints)
goto fail;
// Decide on the decoder target format.
// If the user specified something with -hwaccel_output_format then
// try to use that to minimise conversions later.
ctx->decode_format = AV_PIX_FMT_NONE;
if (ctx->output_format != AV_PIX_FMT_NONE &&
ctx->output_format != AV_PIX_FMT_VAAPI) {
for (i = 0; constraints->valid_sw_formats[i] != AV_PIX_FMT_NONE; i++) {
if (constraints->valid_sw_formats[i] == ctx->decode_format) {
ctx->decode_format = ctx->output_format;
av_log(ctx, AV_LOG_DEBUG, "Using decode format %s (output "
"format).\n", av_get_pix_fmt_name(ctx->decode_format));
break;
}
}
}
// Otherwise, we would like to try to choose something which matches the
// decoder output, but there isn't enough information available here to
// do so. Assume for now that we are always dealing with YUV 4:2:0, so
// pick a format which does that.
if (ctx->decode_format == AV_PIX_FMT_NONE) {
for (i = 0; constraints->valid_sw_formats[i] != AV_PIX_FMT_NONE; i++) {
pix_fmt = constraints->valid_sw_formats[i];
pix_desc = av_pix_fmt_desc_get(pix_fmt);
if (pix_desc->nb_components == 3 &&
pix_desc->log2_chroma_w == 1 &&
pix_desc->log2_chroma_h == 1) {
ctx->decode_format = pix_fmt;
av_log(ctx, AV_LOG_DEBUG, "Using decode format %s (format "
"matched).\n", av_get_pix_fmt_name(ctx->decode_format));
break;
}
}
}
// Otherwise pick the first in the list and hope for the best.
if (ctx->decode_format == AV_PIX_FMT_NONE) {
ctx->decode_format = constraints->valid_sw_formats[0];
av_log(ctx, AV_LOG_DEBUG, "Using decode format %s (first in list).\n",
av_get_pix_fmt_name(ctx->decode_format));
if (i > 1) {
// There was a choice, and we picked randomly. Warn the user
// that they might want to choose intelligently instead.
av_log(ctx, AV_LOG_WARNING, "Using randomly chosen decode "
"format %s.\n", av_get_pix_fmt_name(ctx->decode_format));
}
}
// Ensure the picture size is supported by the hardware.
ctx->decode_width = avctx->coded_width;
ctx->decode_height = avctx->coded_height;
if (ctx->decode_width < constraints->min_width ||
ctx->decode_height < constraints->min_height ||
ctx->decode_width > constraints->max_width ||
ctx->decode_height >constraints->max_height) {
av_log(ctx, AV_LOG_ERROR, "VAAPI hardware does not support image "
"size %dx%d (constraints: width %d-%d height %d-%d).\n",
ctx->decode_width, ctx->decode_height,
constraints->min_width, constraints->max_width,
constraints->min_height, constraints->max_height);
err = AVERROR(EINVAL);
goto fail;
}
av_hwframe_constraints_free(&constraints);
av_freep(&hwconfig);
// Decide how many reference frames we need. This might be doable more
// nicely based on the codec and input stream?
ctx->decode_surfaces = DEFAULT_SURFACES;
// For frame-threaded decoding, one additional surfaces is needed for
// each thread.
if (avctx->active_thread_type & FF_THREAD_FRAME)
ctx->decode_surfaces += avctx->thread_count;
return 0;
fail:
av_hwframe_constraints_free(&constraints);
av_freep(&hwconfig);
vaDestroyConfig(hwctx->display, ctx->va_config);
av_freep(&profile_list);
return err;
}
static void vaapi_decode_uninit(AVCodecContext *avctx)
{
InputStream *ist = avctx->opaque;
VAAPIDecoderContext *ctx = ist->hwaccel_ctx;
if (ctx) {
AVVAAPIDeviceContext *hwctx = ctx->device->hwctx;
if (ctx->va_context != VA_INVALID_ID) {
vaDestroyContext(hwctx->display, ctx->va_context);
ctx->va_context = VA_INVALID_ID;
}
if (ctx->va_config != VA_INVALID_ID) {
vaDestroyConfig(hwctx->display, ctx->va_config);
ctx->va_config = VA_INVALID_ID;
}
av_buffer_unref(&ctx->frames_ref);
av_buffer_unref(&ctx->device_ref);
av_free(ctx);
}
av_buffer_unref(&ist->hw_frames_ctx);
ist->hwaccel_ctx = 0;
ist->hwaccel_uninit = 0;
ist->hwaccel_get_buffer = 0;
ist->hwaccel_retrieve_data = 0;
}
int vaapi_decode_init(AVCodecContext *avctx)
{
InputStream *ist = avctx->opaque;
AVVAAPIDeviceContext *hwctx;
AVVAAPIFramesContext *avfc;
VAAPIDecoderContext *ctx;
VAStatus vas;
int err;
int loglevel = (ist->hwaccel_id != HWACCEL_VAAPI ? AV_LOG_VERBOSE
: AV_LOG_ERROR);
if (ist->hwaccel_ctx)
vaapi_decode_uninit(avctx);
// We have -hwaccel without -vaapi_device, so just initialise here with
// the device passed as -hwaccel_device (if -vaapi_device was passed, it
// will always have been called before now).
if (!hw_device_ctx) {
err = vaapi_device_init(ist->hwaccel_device);
if (err < 0)
return err;
}
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
return AVERROR(ENOMEM);
ctx->class = &vaapi_class;
ctx->device_ref = av_buffer_ref(hw_device_ctx);
ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
ctx->va_config = VA_INVALID_ID;
ctx->va_context = VA_INVALID_ID;
hwctx = ctx->device->hwctx;
ctx->output_format = ist->hwaccel_output_format;
err = vaapi_build_decoder_config(ctx, avctx,
ist->hwaccel_id != HWACCEL_VAAPI);
if (err < 0) {
av_log(ctx, loglevel, "No supported configuration for this codec.");
goto fail;
}
avctx->pix_fmt = ctx->output_format;
ctx->frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
if (!ctx->frames_ref) {
av_log(ctx, loglevel, "Failed to create VAAPI frame context.\n");
err = AVERROR(ENOMEM);
goto fail;
}
ctx->frames = (AVHWFramesContext*)ctx->frames_ref->data;
ctx->frames->format = AV_PIX_FMT_VAAPI;
ctx->frames->sw_format = ctx->decode_format;
ctx->frames->width = ctx->decode_width;
ctx->frames->height = ctx->decode_height;
ctx->frames->initial_pool_size = ctx->decode_surfaces;
err = av_hwframe_ctx_init(ctx->frames_ref);
if (err < 0) {
av_log(ctx, loglevel, "Failed to initialise VAAPI frame "
"context: %d\n", err);
goto fail;
}
avfc = ctx->frames->hwctx;
vas = vaCreateContext(hwctx->display, ctx->va_config,
ctx->decode_width, ctx->decode_height,
VA_PROGRESSIVE,
avfc->surface_ids, avfc->nb_surfaces,
&ctx->va_context);
if (vas != VA_STATUS_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed to create decode pipeline "
"context: %d (%s).\n", vas, vaErrorStr(vas));
err = AVERROR(EINVAL);
goto fail;
}
av_log(ctx, AV_LOG_DEBUG, "VAAPI decoder (re)init complete.\n");
// We would like to set this on the AVCodecContext for use by whoever gets
// the frames from the decoder, but unfortunately the AVCodecContext we
// have here need not be the "real" one (H.264 makes many copies for
// threading purposes). To avoid the problem, we instead store it in the
// InputStream and propagate it from there.
ist->hw_frames_ctx = av_buffer_ref(ctx->frames_ref);
if (!ist->hw_frames_ctx) {
err = AVERROR(ENOMEM);
goto fail;
}
ist->hwaccel_ctx = ctx;
ist->hwaccel_uninit = vaapi_decode_uninit;
ist->hwaccel_get_buffer = vaapi_get_buffer;
ist->hwaccel_retrieve_data = vaapi_retrieve_data;
ctx->decoder_vaapi_context.display = hwctx->display;
ctx->decoder_vaapi_context.config_id = ctx->va_config;
ctx->decoder_vaapi_context.context_id = ctx->va_context;
avctx->hwaccel_context = &ctx->decoder_vaapi_context;
return 0;
fail:
vaapi_decode_uninit(avctx);
return err;
}
static AVClass *vaapi_log = &vaapi_class;
av_cold int vaapi_device_init(const char *device)
{
int err;
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
device, NULL, 0);
if (err < 0) {
av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n");
return err;
}
return 0;
}

View File

@ -18,49 +18,21 @@
#include <stdint.h>
#include <vdpau/vdpau.h>
#include <vdpau/vdpau_x11.h>
#include <X11/Xlib.h>
#include "ffmpeg.h"
#include "libavcodec/vdpau.h"
#include "libavutil/avassert.h"
#include "libavutil/buffer.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_vdpau.h"
#include "libavutil/pixfmt.h"
typedef struct VDPAUContext {
Display *dpy;
VdpDevice device;
VdpDecoder decoder;
VdpGetProcAddress *get_proc_address;
VdpGetErrorString *get_error_string;
VdpGetInformationString *get_information_string;
VdpDeviceDestroy *device_destroy;
#if 1 // for ffmpegs older vdpau API, not the oldest though
VdpDecoderCreate *decoder_create;
VdpDecoderDestroy *decoder_destroy;
VdpDecoderRender *decoder_render;
#endif
VdpVideoSurfaceCreate *video_surface_create;
VdpVideoSurfaceDestroy *video_surface_destroy;
VdpVideoSurfaceGetBitsYCbCr *video_surface_get_bits;
VdpVideoSurfaceGetParameters *video_surface_get_parameters;
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *video_surface_query;
AVBufferRef *hw_frames_ctx;
AVFrame *tmp_frame;
enum AVPixelFormat pix_fmt;
VdpYCbCrFormat vdpau_format;
} VDPAUContext;
int vdpau_api_ver = 2;
static void vdpau_uninit(AVCodecContext *s)
{
InputStream *ist = s->opaque;
@ -70,140 +42,54 @@ static void vdpau_uninit(AVCodecContext *s)
ist->hwaccel_get_buffer = NULL;
ist->hwaccel_retrieve_data = NULL;
if (ctx->decoder_destroy)
ctx->decoder_destroy(ctx->decoder);
if (ctx->device_destroy)
ctx->device_destroy(ctx->device);
if (ctx->dpy)
XCloseDisplay(ctx->dpy);
av_buffer_unref(&ctx->hw_frames_ctx);
av_frame_free(&ctx->tmp_frame);
av_freep(&ist->hwaccel_ctx);
av_freep(&s->hwaccel_context);
}
static void vdpau_release_buffer(void *opaque, uint8_t *data)
{
VdpVideoSurface surface = *(VdpVideoSurface*)data;
VDPAUContext *ctx = opaque;
ctx->video_surface_destroy(surface);
av_freep(&data);
}
static int vdpau_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
{
InputStream *ist = s->opaque;
VDPAUContext *ctx = ist->hwaccel_ctx;
VdpVideoSurface *surface;
VdpStatus err;
VdpChromaType chroma;
uint32_t width, height;
av_assert0(frame->format == AV_PIX_FMT_VDPAU);
if (av_vdpau_get_surface_parameters(s, &chroma, &width, &height))
return AVERROR(ENOSYS);
surface = av_malloc(sizeof(*surface));
if (!surface)
return AVERROR(ENOMEM);
frame->buf[0] = av_buffer_create((uint8_t*)surface, sizeof(*surface),
vdpau_release_buffer, ctx,
AV_BUFFER_FLAG_READONLY);
if (!frame->buf[0]) {
av_freep(&surface);
return AVERROR(ENOMEM);
}
// properly we should keep a pool of surfaces instead of creating
// them anew for each frame, but since we don't care about speed
// much in this code, we don't bother
err = ctx->video_surface_create(ctx->device, chroma, width, height,
surface);
if (err != VDP_STATUS_OK) {
av_log(NULL, AV_LOG_ERROR, "Error allocating a VDPAU video surface: %s\n",
ctx->get_error_string(err));
av_buffer_unref(&frame->buf[0]);
return AVERROR_UNKNOWN;
}
frame->data[3] = (uint8_t*)(uintptr_t)*surface;
return 0;
return av_hwframe_get_buffer(ctx->hw_frames_ctx, frame, 0);
}
static int vdpau_retrieve_data(AVCodecContext *s, AVFrame *frame)
{
VdpVideoSurface surface = (VdpVideoSurface)(uintptr_t)frame->data[3];
InputStream *ist = s->opaque;
VDPAUContext *ctx = ist->hwaccel_ctx;
VdpStatus err;
int ret, chroma_type;
int ret;
err = ctx->video_surface_get_parameters(surface, &chroma_type,
&ctx->tmp_frame->width,
&ctx->tmp_frame->height);
if (err != VDP_STATUS_OK) {
av_log(NULL, AV_LOG_ERROR, "Error getting surface parameters: %s\n",
ctx->get_error_string(err));
return AVERROR_UNKNOWN;
}
ctx->tmp_frame->format = ctx->pix_fmt;
ret = av_frame_get_buffer(ctx->tmp_frame, 32);
ret = av_hwframe_transfer_data(ctx->tmp_frame, frame, 0);
if (ret < 0)
return ret;
ctx->tmp_frame->width = frame->width;
ctx->tmp_frame->height = frame->height;
err = ctx->video_surface_get_bits(surface, ctx->vdpau_format,
(void * const *)ctx->tmp_frame->data,
ctx->tmp_frame->linesize);
if (err != VDP_STATUS_OK) {
av_log(NULL, AV_LOG_ERROR, "Error retrieving frame data from VDPAU: %s\n",
ctx->get_error_string(err));
ret = AVERROR_UNKNOWN;
goto fail;
}
if (ctx->vdpau_format == VDP_YCBCR_FORMAT_YV12)
FFSWAP(uint8_t*, ctx->tmp_frame->data[1], ctx->tmp_frame->data[2]);
ret = av_frame_copy_props(ctx->tmp_frame, frame);
if (ret < 0)
goto fail;
if (ret < 0) {
av_frame_unref(ctx->tmp_frame);
return ret;
}
av_frame_unref(frame);
av_frame_move_ref(frame, ctx->tmp_frame);
return 0;
fail:
av_frame_unref(ctx->tmp_frame);
return ret;
}
static const int vdpau_formats[][2] = {
{ VDP_YCBCR_FORMAT_YV12, AV_PIX_FMT_YUV420P },
{ VDP_YCBCR_FORMAT_NV12, AV_PIX_FMT_NV12 },
{ VDP_YCBCR_FORMAT_YUYV, AV_PIX_FMT_YUYV422 },
{ VDP_YCBCR_FORMAT_UYVY, AV_PIX_FMT_UYVY422 },
};
static int vdpau_alloc(AVCodecContext *s)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
AVVDPAUContext *vdpau_ctx;
VDPAUContext *ctx;
const char *display, *vendor;
VdpStatus err;
int i;
int ret;
AVBufferRef *device_ref = NULL;
AVHWDeviceContext *device_ctx;
AVVDPAUDeviceContext *device_hwctx;
AVHWFramesContext *frames_ctx;
ctx = av_mallocz(sizeof(*ctx));
if (!ctx)
@ -218,145 +104,48 @@ static int vdpau_alloc(AVCodecContext *s)
if (!ctx->tmp_frame)
goto fail;
ctx->dpy = XOpenDisplay(ist->hwaccel_device);
if (!ctx->dpy) {
av_log(NULL, loglevel, "Cannot open the X11 display %s.\n",
XDisplayName(ist->hwaccel_device));
ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VDPAU,
ist->hwaccel_device, NULL, 0);
if (ret < 0)
goto fail;
}
display = XDisplayString(ctx->dpy);
device_ctx = (AVHWDeviceContext*)device_ref->data;
device_hwctx = device_ctx->hwctx;
err = vdp_device_create_x11(ctx->dpy, XDefaultScreen(ctx->dpy), &ctx->device,
&ctx->get_proc_address);
if (err != VDP_STATUS_OK) {
av_log(NULL, loglevel, "VDPAU device creation on X11 display %s failed.\n",
display);
ctx->hw_frames_ctx = av_hwframe_ctx_alloc(device_ref);
if (!ctx->hw_frames_ctx)
goto fail;
}
av_buffer_unref(&device_ref);
#define GET_CALLBACK(id, result) \
do { \
void *tmp; \
err = ctx->get_proc_address(ctx->device, id, &tmp); \
if (err != VDP_STATUS_OK) { \
av_log(NULL, loglevel, "Error getting the " #id " callback.\n"); \
goto fail; \
} \
ctx->result = tmp; \
} while (0)
frames_ctx = (AVHWFramesContext*)ctx->hw_frames_ctx->data;
frames_ctx->format = AV_PIX_FMT_VDPAU;
frames_ctx->sw_format = s->sw_pix_fmt;
frames_ctx->width = s->coded_width;
frames_ctx->height = s->coded_height;
GET_CALLBACK(VDP_FUNC_ID_GET_ERROR_STRING, get_error_string);
GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, device_destroy);
if (vdpau_api_ver == 1) {
GET_CALLBACK(VDP_FUNC_ID_DECODER_CREATE, decoder_create);
GET_CALLBACK(VDP_FUNC_ID_DECODER_DESTROY, decoder_destroy);
GET_CALLBACK(VDP_FUNC_ID_DECODER_RENDER, decoder_render);
}
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_CREATE, video_surface_create);
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, video_surface_destroy);
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, video_surface_get_bits);
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, video_surface_get_parameters);
GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
video_surface_query);
for (i = 0; i < FF_ARRAY_ELEMS(vdpau_formats); i++) {
VdpBool supported;
err = ctx->video_surface_query(ctx->device, VDP_CHROMA_TYPE_420,
vdpau_formats[i][0], &supported);
if (err != VDP_STATUS_OK) {
av_log(NULL, loglevel,
"Error querying VDPAU surface capabilities: %s\n",
ctx->get_error_string(err));
goto fail;
}
if (supported)
break;
}
if (i == FF_ARRAY_ELEMS(vdpau_formats)) {
av_log(NULL, loglevel,
"No supported VDPAU format for retrieving the data.\n");
return AVERROR(EINVAL);
}
ctx->vdpau_format = vdpau_formats[i][0];
ctx->pix_fmt = vdpau_formats[i][1];
if (vdpau_api_ver == 1) {
vdpau_ctx = av_vdpau_alloc_context();
if (!vdpau_ctx)
goto fail;
vdpau_ctx->render = ctx->decoder_render;
s->hwaccel_context = vdpau_ctx;
} else
if (av_vdpau_bind_context(s, ctx->device, ctx->get_proc_address,
AV_HWACCEL_FLAG_IGNORE_LEVEL))
ret = av_hwframe_ctx_init(ctx->hw_frames_ctx);
if (ret < 0)
goto fail;
ctx->get_information_string(&vendor);
av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU -- %s -- on X11 display %s, "
"to decode input stream #%d:%d.\n", vendor,
display, ist->file_index, ist->st->index);
if (av_vdpau_bind_context(s, device_hwctx->device, device_hwctx->get_proc_address, 0))
goto fail;
av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU to decode input stream #%d:%d.\n",
ist->file_index, ist->st->index);
return 0;
fail:
av_log(NULL, loglevel, "VDPAU init failed for stream #%d:%d.\n",
ist->file_index, ist->st->index);
av_buffer_unref(&device_ref);
vdpau_uninit(s);
return AVERROR(EINVAL);
}
static int vdpau_old_init(AVCodecContext *s)
{
InputStream *ist = s->opaque;
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
AVVDPAUContext *vdpau_ctx;
VDPAUContext *ctx;
VdpStatus err;
int profile, ret;
if (!ist->hwaccel_ctx) {
ret = vdpau_alloc(s);
if (ret < 0)
return ret;
}
ctx = ist->hwaccel_ctx;
vdpau_ctx = s->hwaccel_context;
ret = av_vdpau_get_profile(s, &profile);
if (ret < 0) {
av_log(NULL, loglevel, "No known VDPAU decoder profile for this stream.\n");
return AVERROR(EINVAL);
}
if (ctx->decoder)
ctx->decoder_destroy(ctx->decoder);
err = ctx->decoder_create(ctx->device, profile,
s->coded_width, s->coded_height,
16, &ctx->decoder);
if (err != VDP_STATUS_OK) {
av_log(NULL, loglevel, "Error creating the VDPAU decoder: %s\n",
ctx->get_error_string(err));
return AVERROR_UNKNOWN;
}
vdpau_ctx->decoder = ctx->decoder;
ist->hwaccel_get_buffer = vdpau_get_buffer;
ist->hwaccel_retrieve_data = vdpau_retrieve_data;
return 0;
}
int vdpau_init(AVCodecContext *s)
{
InputStream *ist = s->opaque;
if (vdpau_api_ver == 1)
return vdpau_old_init(s);
if (!ist->hwaccel_ctx) {
int ret = vdpau_alloc(s);
if (ret < 0)

141
ffplay.c
View File

@ -117,6 +117,7 @@ typedef struct PacketQueue {
MyAVPacketList *first_pkt, *last_pkt;
int nb_packets;
int size;
int64_t duration;
int abort_request;
int serial;
SDL_mutex *mutex;
@ -243,7 +244,6 @@ typedef struct VideoState {
AVStream *audio_st;
PacketQueue audioq;
int audio_hw_buf_size;
uint8_t silence_buf[SDL_AUDIO_MIN_BUFFER_SIZE];
uint8_t *audio_buf;
uint8_t *audio_buf1;
unsigned int audio_buf_size; /* in bytes */
@ -418,6 +418,7 @@ static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
q->last_pkt = pkt1;
q->nb_packets++;
q->size += pkt1->pkt.size + sizeof(*pkt1);
q->duration += pkt1->pkt.duration;
/* XXX: should duplicate packet data in DV case */
SDL_CondSignal(q->cond);
return 0;
@ -479,6 +480,7 @@ static void packet_queue_flush(PacketQueue *q)
q->first_pkt = NULL;
q->nb_packets = 0;
q->size = 0;
q->duration = 0;
SDL_UnlockMutex(q->mutex);
}
@ -529,6 +531,7 @@ static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *seria
q->last_pkt = NULL;
q->nb_packets--;
q->size -= pkt1->pkt.size + sizeof(*pkt1);
q->duration -= pkt1->pkt.duration;
*pkt = pkt1->pkt;
if (serial)
*serial = pkt1->serial;
@ -642,6 +645,7 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
static void decoder_destroy(Decoder *d) {
av_packet_unref(&d->pkt);
avcodec_free_context(&d->avctx);
}
static void frame_queue_unref_item(Frame *vp)
@ -769,14 +773,6 @@ static void frame_queue_next(FrameQueue *f)
SDL_UnlockMutex(f->mutex);
}
/* jump back to the previous frame if available by resetting rindex_shown */
static int frame_queue_prev(FrameQueue *f)
{
int ret = f->rindex_shown;
f->rindex_shown = 0;
return ret;
}
/* return the number of undisplayed frames in the queue */
static int frame_queue_nb_remaining(FrameQueue *f)
{
@ -947,7 +943,7 @@ static void video_image_display(VideoState *is)
SDL_Rect rect;
int i;
vp = frame_queue_peek(&is->pictq);
vp = frame_queue_peek_last(&is->pictq);
if (vp->bmp) {
if (is->subtitle_st) {
if (frame_queue_nb_remaining(&is->subpq) > 0) {
@ -1140,13 +1136,13 @@ static void video_audio_display(VideoState *s)
static void stream_component_close(VideoState *is, int stream_index)
{
AVFormatContext *ic = is->ic;
AVCodecContext *avctx;
AVCodecParameters *codecpar;
if (stream_index < 0 || stream_index >= ic->nb_streams)
return;
avctx = ic->streams[stream_index]->codec;
codecpar = ic->streams[stream_index]->codecpar;
switch (avctx->codec_type) {
switch (codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
decoder_abort(&is->auddec, &is->sampq);
SDL_CloseAudio();
@ -1176,8 +1172,7 @@ static void stream_component_close(VideoState *is, int stream_index)
}
ic->streams[stream_index]->discard = AVDISCARD_ALL;
avcodec_close(avctx);
switch (avctx->codec_type) {
switch (codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
is->audio_st = NULL;
is->audio_stream = -1;
@ -1528,9 +1523,6 @@ static void video_refresh(void *opaque, double *remaining_time)
}
if (is->video_st) {
int redisplay = 0;
if (is->force_refresh)
redisplay = frame_queue_prev(&is->pictq);
retry:
if (frame_queue_nb_remaining(&is->pictq) == 0) {
// nothing to do, no picture to display in the queue
@ -1544,11 +1536,10 @@ retry:
if (vp->serial != is->videoq.serial) {
frame_queue_next(&is->pictq);
redisplay = 0;
goto retry;
}
if (lastvp->serial != vp->serial && !redisplay)
if (lastvp->serial != vp->serial)
is->frame_timer = av_gettime_relative() / 1000000.0;
if (is->paused)
@ -1556,15 +1547,12 @@ retry:
/* compute nominal last_duration */
last_duration = vp_duration(is, lastvp, vp);
if (redisplay)
delay = 0.0;
else
delay = compute_target_delay(last_duration, is);
delay = compute_target_delay(last_duration, is);
time= av_gettime_relative()/1000000.0;
if (time < is->frame_timer + delay && !redisplay) {
if (time < is->frame_timer + delay) {
*remaining_time = FFMIN(is->frame_timer + delay - time, *remaining_time);
return;
goto display;
}
is->frame_timer += delay;
@ -1572,18 +1560,16 @@ retry:
is->frame_timer = time;
SDL_LockMutex(is->pictq.mutex);
if (!redisplay && !isnan(vp->pts))
if (!isnan(vp->pts))
update_video_pts(is, vp->pts, vp->pos, vp->serial);
SDL_UnlockMutex(is->pictq.mutex);
if (frame_queue_nb_remaining(&is->pictq) > 1) {
Frame *nextvp = frame_queue_peek_next(&is->pictq);
duration = vp_duration(is, vp, nextvp);
if(!is->step && (redisplay || framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
if (!redisplay)
is->frame_drops_late++;
if(!is->step && (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){
is->frame_drops_late++;
frame_queue_next(&is->pictq);
redisplay = 0;
goto retry;
}
}
@ -1608,16 +1594,16 @@ retry:
}
}
display:
/* display picture */
if (!display_disable && is->show_mode == SHOW_MODE_VIDEO)
video_display(is);
frame_queue_next(&is->pictq);
is->force_refresh = 1;
if (is->step && !is->paused)
stream_toggle_pause(is);
}
display:
/* display picture */
if (!display_disable && is->force_refresh && is->show_mode == SHOW_MODE_VIDEO && is->pictq.rindex_shown)
video_display(is);
}
is->force_refresh = 0;
if (show_status) {
@ -1653,8 +1639,8 @@ display:
aqsize / 1024,
vqsize / 1024,
sqsize,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_dts : 0,
is->video_st ? is->video_st->codec->pts_correction_num_faulty_pts : 0);
is->video_st ? is->viddec.avctx->pts_correction_num_faulty_dts : 0,
is->video_st ? is->viddec.avctx->pts_correction_num_faulty_pts : 0);
fflush(stdout);
last_time = cur_time;
}
@ -1716,7 +1702,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double
{
Frame *vp;
#if defined(DEBUG_SYNC) && 0
#if defined(DEBUG_SYNC)
printf("frame_type=%c pts=%0.3f\n",
av_get_picture_type_char(src_frame->pict_type), pts);
#endif
@ -1906,7 +1892,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
char buffersrc_args[256];
int ret;
AVFilterContext *filt_src = NULL, *filt_out = NULL, *last_filter = NULL;
AVCodecContext *codec = is->video_st->codec;
AVCodecParameters *codecpar = is->video_st->codecpar;
AVRational fr = av_guess_frame_rate(is->ic, is->video_st, NULL);
AVDictionaryEntry *e = NULL;
@ -1925,7 +1911,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
frame->width, frame->height, frame->format,
is->video_st->time_base.num, is->video_st->time_base.den,
codec->sample_aspect_ratio.num, FFMAX(codec->sample_aspect_ratio.den, 1));
codecpar->sample_aspect_ratio.num, FFMAX(codecpar->sample_aspect_ratio.den, 1));
if (fr.num && fr.den)
av_strlcatf(buffersrc_args, sizeof(buffersrc_args), ":frame_rate=%d/%d", fr.num, fr.den);
@ -2541,8 +2527,8 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
audio_size = audio_decode_frame(is);
if (audio_size < 0) {
/* if error, just output silence */
is->audio_buf = is->silence_buf;
is->audio_buf_size = sizeof(is->silence_buf) / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
is->audio_buf = NULL;
is->audio_buf_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
@ -2553,11 +2539,11 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len)
len1 = len;
if (!is->muted && is->audio_volume == SDL_MIX_MAXVOLUME)
if (!is->muted && is->audio_buf && is->audio_volume == SDL_MIX_MAXVOLUME)
memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
else {
memset(stream, is->silence_buf[0], len1);
if (!is->muted)
memset(stream, 0, len1);
if (!is->muted && is->audio_buf)
SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);
}
len -= len1;
@ -2652,7 +2638,7 @@ static int stream_component_open(VideoState *is, int stream_index)
AVCodecContext *avctx;
AVCodec *codec;
const char *forced_codec_name = NULL;
AVDictionary *opts;
AVDictionary *opts = NULL;
AVDictionaryEntry *t = NULL;
int sample_rate, nb_channels;
int64_t channel_layout;
@ -2661,7 +2647,15 @@ static int stream_component_open(VideoState *is, int stream_index)
if (stream_index < 0 || stream_index >= ic->nb_streams)
return -1;
avctx = ic->streams[stream_index]->codec;
avctx = avcodec_alloc_context3(NULL);
if (!avctx)
return AVERROR(ENOMEM);
ret = avcodec_parameters_to_context(avctx, ic->streams[stream_index]->codecpar);
if (ret < 0)
goto fail;
av_codec_set_pkt_timebase(avctx, ic->streams[stream_index]->time_base);
codec = avcodec_find_decoder(avctx->codec_id);
@ -2677,7 +2671,8 @@ static int stream_component_open(VideoState *is, int stream_index)
"No codec could be found with name '%s'\n", forced_codec_name);
else av_log(NULL, AV_LOG_WARNING,
"No codec could be found with id %d\n", avctx->codec_id);
return -1;
ret = AVERROR(EINVAL);
goto fail;
}
avctx->codec_id = codec->id;
@ -2730,7 +2725,7 @@ static int stream_component_open(VideoState *is, int stream_index)
goto fail;
link = is->out_audio_filter->inputs[0];
sample_rate = link->sample_rate;
nb_channels = link->channels;
nb_channels = avfilter_link_get_channels(link);
channel_layout = link->channel_layout;
}
#else
@ -2750,7 +2745,7 @@ static int stream_component_open(VideoState *is, int stream_index)
/* 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 anough audio fifo fullness,
/* since we do not have a precise anough audio FIFO fullness,
we correct audio sync only if larger than this threshold */
is->audio_diff_threshold = (double)(is->audio_hw_buf_size) / is->audio_tgt.bytes_per_sec;
@ -2763,7 +2758,7 @@ static int stream_component_open(VideoState *is, int stream_index)
is->auddec.start_pts_tb = is->audio_st->time_base;
}
if ((ret = decoder_start(&is->auddec, audio_thread, is)) < 0)
goto fail;
goto out;
SDL_PauseAudio(0);
break;
case AVMEDIA_TYPE_VIDEO:
@ -2775,7 +2770,7 @@ static int stream_component_open(VideoState *is, int stream_index)
decoder_init(&is->viddec, avctx, &is->videoq, is->continue_read_thread);
if ((ret = decoder_start(&is->viddec, video_thread, is)) < 0)
goto fail;
goto out;
is->queue_attachments_req = 1;
break;
case AVMEDIA_TYPE_SUBTITLE:
@ -2784,13 +2779,16 @@ static int stream_component_open(VideoState *is, int stream_index)
decoder_init(&is->subdec, avctx, &is->subtitleq, is->continue_read_thread);
if ((ret = decoder_start(&is->subdec, subtitle_thread, is)) < 0)
goto fail;
goto out;
break;
default:
break;
}
goto out;
fail:
avcodec_free_context(&avctx);
out:
av_dict_free(&opts);
return ret;
@ -2802,6 +2800,13 @@ static int decode_interrupt_cb(void *ctx)
return is->abort_request;
}
static int stream_has_enough_packets(AVStream *st, int stream_id, PacketQueue *queue) {
return stream_id < 0 ||
queue->abort_request ||
(st->disposition & AV_DISPOSITION_ATTACHED_PIC) ||
queue->nb_packets > MIN_FRAMES && (!queue->duration || av_q2d(st->time_base) * queue->duration > 1.0);
}
static int is_realtime(AVFormatContext *s)
{
if( !strcmp(s->iformat->name, "rtp")
@ -2929,7 +2934,7 @@ static int read_thread(void *arg)
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
enum AVMediaType type = st->codec->codec_type;
enum AVMediaType type = st->codecpar->codec_type;
st->discard = AVDISCARD_ALL;
if (wanted_stream_spec[type] && st_index[type] == -1)
if (avformat_match_stream_specifier(ic, st, wanted_stream_spec[type]) > 0)
@ -2964,10 +2969,10 @@ static int read_thread(void *arg)
is->show_mode = show_mode;
if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) {
AVStream *st = ic->streams[st_index[AVMEDIA_TYPE_VIDEO]];
AVCodecContext *avctx = st->codec;
AVCodecParameters *codecpar = st->codecpar;
AVRational sar = av_guess_sample_aspect_ratio(ic, st, NULL);
if (avctx->width)
set_default_window_size(avctx->width, avctx->height, sar);
if (codecpar->width)
set_default_window_size(codecpar->width, codecpar->height, sar);
}
/* open the streams */
@ -3066,10 +3071,9 @@ static int read_thread(void *arg)
/* if the queue are full, no need to read more */
if (infinite_buffer<1 &&
(is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE
|| ( (is->audioq .nb_packets > MIN_FRAMES || is->audio_stream < 0 || is->audioq.abort_request)
&& (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0 || is->videoq.abort_request
|| (is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC))
&& (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0 || is->subtitleq.abort_request)))) {
|| (stream_has_enough_packets(is->audio_st, is->audio_stream, &is->audioq) &&
stream_has_enough_packets(is->video_st, is->video_stream, &is->videoq) &&
stream_has_enough_packets(is->subtitle_st, is->subtitle_stream, &is->subtitleq)))) {
/* wait 10 ms */
SDL_LockMutex(wait_mutex);
SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
@ -3241,12 +3245,12 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
if (stream_index == start_index)
return;
st = is->ic->streams[p ? p->stream_index[stream_index] : stream_index];
if (st->codec->codec_type == codec_type) {
if (st->codecpar->codec_type == codec_type) {
/* check that parameters are OK */
switch (codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (st->codec->sample_rate != 0 &&
st->codec->channels != 0)
if (st->codecpar->sample_rate != 0 &&
st->codecpar->channels != 0)
goto the_end;
break;
case AVMEDIA_TYPE_VIDEO:
@ -3770,6 +3774,7 @@ int main(int argc, char **argv)
int flags;
VideoState *is;
char dummy_videodriver[] = "SDL_VIDEODRIVER=dummy";
char alsa_bufsize[] = "SDL_AUDIO_ALSA_SET_BUFFER_SIZE=1";
av_log_set_flags(AV_LOG_SKIP_REPEATED);
parse_loglevel(argc, argv, options);
@ -3807,6 +3812,12 @@ int main(int argc, char **argv)
flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
if (audio_disable)
flags &= ~SDL_INIT_AUDIO;
else {
/* Try to work around an occasional ALSA buffer underflow issue when the
* period size is NPOT due to ALSA resampling by forcing the buffer size. */
if (!SDL_getenv("SDL_AUDIO_ALSA_SET_BUFFER_SIZE"))
SDL_putenv(alsa_bufsize);
}
if (display_disable)
SDL_putenv(dummy_videodriver); /* For the event queue, we always need a video driver. */
#if !defined(_WIN32) && !defined(__APPLE__)

535
ffprobe.c
View File

@ -37,6 +37,7 @@
#include "libavutil/hash.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/stereo3d.h"
#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/libm.h"
@ -49,6 +50,19 @@
#include "libpostproc/postprocess.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[] = "ffprobe";
const int program_birth_year = 2007;
@ -1746,10 +1760,39 @@ static inline int show_tags(WriterContext *w, AVDictionary *tags, int section_id
return ret;
}
static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx)
static void print_pkt_side_data(WriterContext *w,
const AVPacketSideData *side_data,
int nb_side_data,
SectionID id_data_list,
SectionID id_data)
{
int i;
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA_LIST);
for (i = 0; i < nb_side_data; i++) {
const AVPacketSideData *sd = &side_data[i];
const char *name = av_packet_side_data_name(sd->type);
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA);
print_str("side_data_type", name ? name : "unknown");
print_int("side_data_size", sd->size);
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
} else if (sd->type == AV_PKT_DATA_STEREO3D) {
const AVStereo3D *stereo = (AVStereo3D *)sd->data;
print_str("type", av_stereo3d_type_name(stereo->type));
print_int("inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
}
static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int packet_idx)
{
char val_str[128];
AVStream *st = fmt_ctx->streams[pkt->stream_index];
AVStream *st = ifile->streams[pkt->stream_index].st;
AVBPrint pbuf;
const char *s;
@ -1757,7 +1800,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
writer_print_section_header(w, SECTION_ID_PACKET);
s = av_get_media_type_string(st->codec->codec_type);
s = av_get_media_type_string(st->codecpar->codec_type);
if (s) print_str ("codec_type", s);
else print_str_opt("codec_type", "unknown");
print_int("stream_index", pkt->stream_index);
@ -1775,7 +1818,6 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
if (pkt->side_data_elems) {
int i;
int size;
const uint8_t *side_metadata;
@ -1786,20 +1828,10 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
show_tags(w, dict, SECTION_ID_PACKET_TAGS);
av_dict_free(&dict);
}
writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA_LIST);
for (i = 0; i < pkt->side_data_elems; i++) {
AVPacketSideData *sd = &pkt->side_data[i];
const char *name = av_packet_side_data_name(sd->type);
writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA);
print_str("side_data_type", name ? name : "unknown");
print_int("side_data_size", sd->size);
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
print_pkt_side_data(w, pkt->side_data, pkt->side_data_elems,
SECTION_ID_PACKET_SIDE_DATA_LIST,
SECTION_ID_PACKET_SIDE_DATA);
}
if (do_show_data)
@ -1846,7 +1878,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
writer_print_section_header(w, SECTION_ID_FRAME);
s = av_get_media_type_string(stream->codec->codec_type);
s = av_get_media_type_string(stream->codecpar->codec_type);
if (s) print_str ("media_type", s);
else print_str_opt("media_type", "unknown");
print_int("stream_index", stream->index);
@ -1864,7 +1896,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
if (av_frame_get_pkt_size(frame) != -1) print_val ("pkt_size", av_frame_get_pkt_size(frame), unit_byte_str);
else print_str_opt("pkt_size", "N/A");
switch (stream->codec->codec_type) {
switch (stream->codecpar->codec_type) {
AVRational sar;
case AVMEDIA_TYPE_VIDEO:
@ -1934,15 +1966,17 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
}
static av_always_inline int process_frame(WriterContext *w,
AVFormatContext *fmt_ctx,
InputFile *ifile,
AVFrame *frame, AVPacket *pkt)
{
AVCodecContext *dec_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
AVCodecContext *dec_ctx = ifile->streams[pkt->stream_index].dec_ctx;
AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar;
AVSubtitle sub;
int ret = 0, got_frame = 0;
if (dec_ctx->codec) {
switch (dec_ctx->codec_type) {
if (dec_ctx && dec_ctx->codec) {
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, pkt);
break;
@ -1963,13 +1997,13 @@ static av_always_inline int process_frame(WriterContext *w,
pkt->data += ret;
pkt->size -= ret;
if (got_frame) {
int is_sub = (dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE);
int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
nb_streams_frames[pkt->stream_index]++;
if (do_show_frames)
if (is_sub)
show_subtitle(w, &sub, fmt_ctx->streams[pkt->stream_index], fmt_ctx);
show_subtitle(w, &sub, ifile->streams[pkt->stream_index].st, fmt_ctx);
else
show_frame(w, frame, fmt_ctx->streams[pkt->stream_index], fmt_ctx);
show_frame(w, frame, ifile->streams[pkt->stream_index].st, fmt_ctx);
if (is_sub)
avsubtitle_free(&sub);
}
@ -2000,9 +2034,10 @@ static void log_read_interval(const ReadInterval *interval, void *log_ctx, int l
av_log(log_ctx, log_level, "\n");
}
static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
static int read_interval_packets(WriterContext *w, InputFile *ifile,
const ReadInterval *interval, int64_t *cur_ts)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
AVPacket pkt, pkt1;
AVFrame *frame = NULL;
int ret = 0, i = 0, frame_count = 0;
@ -2044,14 +2079,14 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
goto end;
}
while (!av_read_frame(fmt_ctx, &pkt)) {
if (fmt_ctx->nb_streams > nb_streams) {
if (ifile->nb_streams > nb_streams) {
REALLOCZ_ARRAY_STREAM(nb_streams_frames, nb_streams, fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(selected_streams, nb_streams, fmt_ctx->nb_streams);
nb_streams = fmt_ctx->nb_streams;
nb_streams = ifile->nb_streams;
}
if (selected_streams[pkt.stream_index]) {
AVRational tb = fmt_ctx->streams[pkt.stream_index]->time_base;
AVRational tb = ifile->streams[pkt.stream_index].st->time_base;
if (pkt.pts != AV_NOPTS_VALUE)
*cur_ts = av_rescale_q(pkt.pts, tb, AV_TIME_BASE_Q);
@ -2076,12 +2111,12 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
frame_count++;
if (do_read_packets) {
if (do_show_packets)
show_packet(w, fmt_ctx, &pkt, i++);
show_packet(w, ifile, &pkt, i++);
nb_streams_packets[pkt.stream_index]++;
}
if (do_read_frames) {
pkt1 = pkt;
while (pkt1.size && process_frame(w, fmt_ctx, frame, &pkt1) > 0);
while (pkt1.size && process_frame(w, ifile, frame, &pkt1) > 0);
}
}
av_packet_unref(&pkt);
@ -2093,7 +2128,7 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
for (i = 0; i < fmt_ctx->nb_streams; i++) {
pkt.stream_index = i;
if (do_read_frames)
while (process_frame(w, fmt_ctx, frame, &pkt) > 0);
while (process_frame(w, ifile, frame, &pkt) > 0);
}
end:
@ -2105,17 +2140,18 @@ end:
return ret;
}
static int read_packets(WriterContext *w, AVFormatContext *fmt_ctx)
static int read_packets(WriterContext *w, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
int64_t cur_ts = fmt_ctx->start_time;
if (read_intervals_nb == 0) {
ReadInterval interval = (ReadInterval) { .has_start = 0, .has_end = 0 };
ret = read_interval_packets(w, fmt_ctx, &interval, &cur_ts);
ret = read_interval_packets(w, ifile, &interval, &cur_ts);
} else {
for (i = 0; i < read_intervals_nb; i++) {
ret = read_interval_packets(w, fmt_ctx, &read_intervals[i], &cur_ts);
ret = read_interval_packets(w, ifile, &read_intervals[i], &cur_ts);
if (ret < 0)
break;
}
@ -2124,17 +2160,18 @@ static int read_packets(WriterContext *w, AVFormatContext *fmt_ctx)
return ret;
}
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, int in_program)
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
{
AVStream *stream = fmt_ctx->streams[stream_idx];
AVStream *stream = ist->st;
AVCodecParameters *par;
AVCodecContext *dec_ctx;
const AVCodec *dec;
char val_str[128];
const char *s;
AVRational sar, dar;
AVBPrint pbuf;
const AVCodecDescriptor *cd;
int ret = 0;
const char *profile = NULL;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
@ -2142,140 +2179,138 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
print_int("index", stream->index);
if ((dec_ctx = stream->codec)) {
const char *profile = NULL;
dec = dec_ctx->codec;
if (dec) {
print_str("codec_name", dec->name);
if (!do_bitexact) {
if (dec->long_name) print_str ("codec_long_name", dec->long_name);
else print_str_opt("codec_long_name", "unknown");
}
} else if ((cd = avcodec_descriptor_get(stream->codec->codec_id))) {
print_str_opt("codec_name", cd->name);
if (!do_bitexact) {
print_str_opt("codec_long_name",
cd->long_name ? cd->long_name : "unknown");
}
} else {
print_str_opt("codec_name", "unknown");
if (!do_bitexact) {
print_str_opt("codec_long_name", "unknown");
}
}
if (!do_bitexact && dec && (profile = av_get_profile_name(dec, dec_ctx->profile)))
print_str("profile", profile);
else {
if (dec_ctx->profile != FF_PROFILE_UNKNOWN) {
char profile_num[12];
snprintf(profile_num, sizeof(profile_num), "%d", dec_ctx->profile);
print_str("profile", profile_num);
} else
print_str_opt("profile", "unknown");
}
s = av_get_media_type_string(dec_ctx->codec_type);
if (s) print_str ("codec_type", s);
else print_str_opt("codec_type", "unknown");
print_q("codec_time_base", dec_ctx->time_base, '/');
/* print AVI/FourCC tag */
av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
print_str("codec_tag_string", val_str);
print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag);
switch (dec_ctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
print_int("width", dec_ctx->width);
print_int("height", dec_ctx->height);
print_int("coded_width", dec_ctx->coded_width);
print_int("coded_height", dec_ctx->coded_height);
print_int("has_b_frames", dec_ctx->has_b_frames);
sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
if (sar.den) {
print_q("sample_aspect_ratio", sar, ':');
av_reduce(&dar.num, &dar.den,
dec_ctx->width * sar.num,
dec_ctx->height * sar.den,
1024*1024);
print_q("display_aspect_ratio", dar, ':');
} else {
print_str_opt("sample_aspect_ratio", "N/A");
print_str_opt("display_aspect_ratio", "N/A");
}
s = av_get_pix_fmt_name(dec_ctx->pix_fmt);
if (s) print_str ("pix_fmt", s);
else print_str_opt("pix_fmt", "unknown");
print_int("level", dec_ctx->level);
if (dec_ctx->color_range != AVCOL_RANGE_UNSPECIFIED)
print_str ("color_range", av_color_range_name(dec_ctx->color_range));
else
print_str_opt("color_range", "N/A");
s = av_get_colorspace_name(dec_ctx->colorspace);
if (s) print_str ("color_space", s);
else print_str_opt("color_space", "unknown");
if (dec_ctx->color_trc != AVCOL_TRC_UNSPECIFIED)
print_str("color_transfer", av_color_transfer_name(dec_ctx->color_trc));
else
print_str_opt("color_transfer", av_color_transfer_name(dec_ctx->color_trc));
if (dec_ctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
print_str("color_primaries", av_color_primaries_name(dec_ctx->color_primaries));
else
print_str_opt("color_primaries", av_color_primaries_name(dec_ctx->color_primaries));
if (dec_ctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
print_str("chroma_location", av_chroma_location_name(dec_ctx->chroma_sample_location));
else
print_str_opt("chroma_location", av_chroma_location_name(dec_ctx->chroma_sample_location));
#if FF_API_PRIVATE_OPT
if (dec_ctx->timecode_frame_start >= 0) {
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);
print_str("timecode", tcbuf);
} else {
print_str_opt("timecode", "N/A");
}
#endif
print_int("refs", dec_ctx->refs);
break;
case AVMEDIA_TYPE_AUDIO:
s = av_get_sample_fmt_name(dec_ctx->sample_fmt);
if (s) print_str ("sample_fmt", s);
else print_str_opt("sample_fmt", "unknown");
print_val("sample_rate", dec_ctx->sample_rate, unit_hertz_str);
print_int("channels", dec_ctx->channels);
if (dec_ctx->channel_layout) {
av_bprint_clear(&pbuf);
av_bprint_channel_layout(&pbuf, dec_ctx->channels, dec_ctx->channel_layout);
print_str ("channel_layout", pbuf.str);
} else {
print_str_opt("channel_layout", "unknown");
}
print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id));
break;
case AVMEDIA_TYPE_SUBTITLE:
if (dec_ctx->width)
print_int("width", dec_ctx->width);
else
print_str_opt("width", "N/A");
if (dec_ctx->height)
print_int("height", dec_ctx->height);
else
print_str_opt("height", "N/A");
break;
par = stream->codecpar;
dec_ctx = ist->dec_ctx;
if (cd = avcodec_descriptor_get(par->codec_id)) {
print_str("codec_name", cd->name);
if (!do_bitexact) {
print_str("codec_long_name",
cd->long_name ? cd->long_name : "unknown");
}
} else {
print_str_opt("codec_type", "unknown");
print_str_opt("codec_name", "unknown");
if (!do_bitexact) {
print_str_opt("codec_long_name", "unknown");
}
}
if (dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) {
if (!do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
print_str("profile", profile);
else {
if (par->profile != FF_PROFILE_UNKNOWN) {
char profile_num[12];
snprintf(profile_num, sizeof(profile_num), "%d", par->profile);
print_str("profile", profile_num);
} else
print_str_opt("profile", "unknown");
}
s = av_get_media_type_string(par->codec_type);
if (s) print_str ("codec_type", s);
else print_str_opt("codec_type", "unknown");
#if FF_API_LAVF_AVCTX
if (dec_ctx)
print_q("codec_time_base", dec_ctx->time_base, '/');
#endif
/* print AVI/FourCC tag */
av_get_codec_tag_string(val_str, sizeof(val_str), par->codec_tag);
print_str("codec_tag_string", val_str);
print_fmt("codec_tag", "0x%04x", par->codec_tag);
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
print_int("width", par->width);
print_int("height", par->height);
if (dec_ctx) {
print_int("coded_width", dec_ctx->coded_width);
print_int("coded_height", dec_ctx->coded_height);
}
print_int("has_b_frames", par->video_delay);
sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
if (sar.den) {
print_q("sample_aspect_ratio", sar, ':');
av_reduce(&dar.num, &dar.den,
par->width * sar.num,
par->height * sar.den,
1024*1024);
print_q("display_aspect_ratio", dar, ':');
} else {
print_str_opt("sample_aspect_ratio", "N/A");
print_str_opt("display_aspect_ratio", "N/A");
}
s = av_get_pix_fmt_name(par->format);
if (s) print_str ("pix_fmt", s);
else print_str_opt("pix_fmt", "unknown");
print_int("level", par->level);
if (par->color_range != AVCOL_RANGE_UNSPECIFIED)
print_str ("color_range", av_color_range_name(par->color_range));
else
print_str_opt("color_range", "N/A");
s = av_get_colorspace_name(par->color_space);
if (s) print_str ("color_space", s);
else print_str_opt("color_space", "unknown");
if (par->color_trc != AVCOL_TRC_UNSPECIFIED)
print_str("color_transfer", av_color_transfer_name(par->color_trc));
else
print_str_opt("color_transfer", av_color_transfer_name(par->color_trc));
if (par->color_primaries != AVCOL_PRI_UNSPECIFIED)
print_str("color_primaries", av_color_primaries_name(par->color_primaries));
else
print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries));
if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
print_str("chroma_location", av_chroma_location_name(par->chroma_location));
else
print_str_opt("chroma_location", av_chroma_location_name(par->chroma_location));
#if FF_API_PRIVATE_OPT
if (dec_ctx && dec_ctx->timecode_frame_start >= 0) {
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);
print_str("timecode", tcbuf);
} else {
print_str_opt("timecode", "N/A");
}
#endif
if (dec_ctx)
print_int("refs", dec_ctx->refs);
break;
case AVMEDIA_TYPE_AUDIO:
s = av_get_sample_fmt_name(par->format);
if (s) print_str ("sample_fmt", s);
else print_str_opt("sample_fmt", "unknown");
print_val("sample_rate", par->sample_rate, unit_hertz_str);
print_int("channels", par->channels);
if (par->channel_layout) {
av_bprint_clear(&pbuf);
av_bprint_channel_layout(&pbuf, par->channels, par->channel_layout);
print_str ("channel_layout", pbuf.str);
} else {
print_str_opt("channel_layout", "unknown");
}
print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
break;
case AVMEDIA_TYPE_SUBTITLE:
if (par->width)
print_int("width", par->width);
else
print_str_opt("width", "N/A");
if (par->height)
print_int("height", par->height);
else
print_str_opt("height", "N/A");
break;
}
if (dec_ctx && dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) {
const AVOption *opt = NULL;
while (opt = av_opt_next(dec_ctx->priv_data,opt)) {
uint8_t *str;
@ -2296,12 +2331,14 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
print_time("start_time", stream->start_time, &stream->time_base);
print_ts ("duration_ts", stream->duration);
print_time("duration", stream->duration, &stream->time_base);
if (dec_ctx->bit_rate > 0) print_val ("bit_rate", dec_ctx->bit_rate, unit_bit_per_second_str);
if (par->bit_rate > 0) print_val ("bit_rate", par->bit_rate, unit_bit_per_second_str);
else print_str_opt("bit_rate", "N/A");
if (dec_ctx->rc_max_rate > 0) print_val ("max_bit_rate", dec_ctx->rc_max_rate, unit_bit_per_second_str);
else print_str_opt("max_bit_rate", "N/A");
if (dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
else print_str_opt("bits_per_raw_sample", "N/A");
#if FF_API_LAVF_AVCTX
if (stream->codec->rc_max_rate > 0) print_val ("max_bit_rate", stream->codec->rc_max_rate, unit_bit_per_second_str);
else print_str_opt("max_bit_rate", "N/A");
#endif
if (dec_ctx && dec_ctx->bits_per_raw_sample > 0) print_fmt("bits_per_raw_sample", "%d", dec_ctx->bits_per_raw_sample);
else print_str_opt("bits_per_raw_sample", "N/A");
if (stream->nb_frames) print_fmt ("nb_frames", "%"PRId64, stream->nb_frames);
else print_str_opt("nb_frames", "N/A");
if (nb_streams_frames[stream_idx]) print_fmt ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
@ -2309,10 +2346,10 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
if (nb_streams_packets[stream_idx]) print_fmt ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
else print_str_opt("nb_read_packets", "N/A");
if (do_show_data)
writer_print_data(w, "extradata", dec_ctx->extradata,
dec_ctx->extradata_size);
writer_print_data_hash(w, "extradata_hash", dec_ctx->extradata,
dec_ctx->extradata_size);
writer_print_data(w, "extradata", par->extradata,
par->extradata_size);
writer_print_data_hash(w, "extradata_hash", par->extradata,
par->extradata_size);
/* Print disposition information */
#define PRINT_DISPOSITION(flagname, name) do { \
@ -2339,22 +2376,9 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS);
if (stream->nb_side_data) {
int i;
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA_LIST);
for (i = 0; i < stream->nb_side_data; i++) {
AVPacketSideData *sd = &stream->side_data[i];
const char *name = av_packet_side_data_name(sd->type);
writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA);
print_str("side_data_type", name ? name : "unknown");
print_int("side_data_size", sd->size);
if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
}
writer_print_section_footer(w);
}
writer_print_section_footer(w);
print_pkt_side_data(w, stream->side_data, stream->nb_side_data,
SECTION_ID_STREAM_SIDE_DATA_LIST,
SECTION_ID_STREAM_SIDE_DATA);
}
writer_print_section_footer(w);
@ -2364,14 +2388,15 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
return ret;
}
static int show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
static int show_streams(WriterContext *w, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
writer_print_section_header(w, SECTION_ID_STREAMS);
for (i = 0; i < fmt_ctx->nb_streams; i++)
for (i = 0; i < ifile->nb_streams; i++)
if (selected_streams[i]) {
ret = show_stream(w, fmt_ctx, i, 0);
ret = show_stream(w, fmt_ctx, i, &ifile->streams[i], 0);
if (ret < 0)
break;
}
@ -2380,8 +2405,9 @@ static int show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
return ret;
}
static int show_program(WriterContext *w, AVFormatContext *fmt_ctx, AVProgram *program)
static int show_program(WriterContext *w, InputFile *ifile, AVProgram *program)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
writer_print_section_header(w, SECTION_ID_PROGRAM);
@ -2402,7 +2428,7 @@ static int show_program(WriterContext *w, AVFormatContext *fmt_ctx, AVProgram *p
writer_print_section_header(w, SECTION_ID_PROGRAM_STREAMS);
for (i = 0; i < program->nb_stream_indexes; i++) {
if (selected_streams[program->stream_index[i]]) {
ret = show_stream(w, fmt_ctx, program->stream_index[i], 1);
ret = show_stream(w, fmt_ctx, program->stream_index[i], &ifile->streams[program->stream_index[i]], 1);
if (ret < 0)
break;
}
@ -2414,8 +2440,9 @@ end:
return ret;
}
static int show_programs(WriterContext *w, AVFormatContext *fmt_ctx)
static int show_programs(WriterContext *w, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
writer_print_section_header(w, SECTION_ID_PROGRAMS);
@ -2423,7 +2450,7 @@ static int show_programs(WriterContext *w, AVFormatContext *fmt_ctx)
AVProgram *program = fmt_ctx->programs[i];
if (!program)
continue;
ret = show_program(w, fmt_ctx, program);
ret = show_program(w, ifile, program);
if (ret < 0)
break;
}
@ -2431,8 +2458,9 @@ static int show_programs(WriterContext *w, AVFormatContext *fmt_ctx)
return ret;
}
static int show_chapters(WriterContext *w, AVFormatContext *fmt_ctx)
static int show_chapters(WriterContext *w, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
int i, ret = 0;
writer_print_section_header(w, SECTION_ID_CHAPTERS);
@ -2455,8 +2483,9 @@ static int show_chapters(WriterContext *w, AVFormatContext *fmt_ctx)
return ret;
}
static int show_format(WriterContext *w, AVFormatContext *fmt_ctx)
static int show_format(WriterContext *w, InputFile *ifile)
{
AVFormatContext *fmt_ctx = ifile->fmt_ctx;
char val_str[128];
int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
int ret = 0;
@ -2499,7 +2528,7 @@ static void show_error(WriterContext *w, int err)
writer_print_section_footer(w);
}
static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
static int open_input_file(InputFile *ifile, const char *filename)
{
int err, i, orig_nb_streams;
AVFormatContext *fmt_ctx = NULL;
@ -2516,7 +2545,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
print_error(filename, err);
return err;
}
*fmt_ctx_ptr = fmt_ctx;
ifile->fmt_ctx = fmt_ctx;
if (scan_all_pmts_set)
av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
@ -2541,26 +2570,58 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
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;
if (stream->codec->codec_id == AV_CODEC_ID_PROBE) {
ist->st = stream;
if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
av_log(NULL, AV_LOG_WARNING,
"Failed to probe codec for input stream %d\n",
stream->index);
} else if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
continue;
}
codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_WARNING,
"Unsupported codec with id %d for input stream %d\n",
stream->codec->codec_id, stream->index);
} else {
AVDictionary *opts = filter_codec_opts(codec_opts, stream->codec->codec_id,
stream->codecpar->codec_id, stream->index);
continue;
}
{
AVDictionary *opts = filter_codec_opts(codec_opts, stream->codecpar->codec_id,
fmt_ctx, stream, codec);
if (avcodec_open2(stream->codec, codec, &opts) < 0) {
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);
ist->dec_ctx->pkt_timebase = stream->time_base;
#if FF_API_LAVF_AVCTX
ist->dec_ctx->time_base = stream->codec->time_base;
ist->dec_ctx->framerate = stream->codec->framerate;
#endif
if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
av_log(NULL, AV_LOG_WARNING, "Could not open codec for input stream %d\n",
stream->index);
exit(1);
}
if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
t->key, stream->index);
@ -2569,47 +2630,49 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
}
}
*fmt_ctx_ptr = fmt_ctx;
ifile->fmt_ctx = fmt_ctx;
return 0;
}
static void close_input_file(AVFormatContext **ctx_ptr)
static void close_input_file(InputFile *ifile)
{
int i;
AVFormatContext *fmt_ctx = *ctx_ptr;
/* close decoder for each stream */
for (i = 0; i < fmt_ctx->nb_streams; i++)
if (fmt_ctx->streams[i]->codec->codec_id != AV_CODEC_ID_NONE)
avcodec_close(fmt_ctx->streams[i]->codec);
for (i = 0; i < ifile->nb_streams; i++)
if (ifile->streams[i].st->codecpar->codec_id != AV_CODEC_ID_NONE)
avcodec_free_context(&ifile->streams[i].dec_ctx);
avformat_close_input(ctx_ptr);
av_freep(&ifile->streams);
ifile->nb_streams = 0;
avformat_close_input(&ifile->fmt_ctx);
}
static int probe_file(WriterContext *wctx, const char *filename)
{
AVFormatContext *fmt_ctx = NULL;
InputFile ifile = { 0 };
int ret, i;
int section_id;
do_read_frames = do_show_frames || do_count_frames;
do_read_packets = do_show_packets || do_count_packets;
ret = open_input_file(&fmt_ctx, filename);
ret = open_input_file(&ifile, filename);
if (ret < 0)
goto end;
#define CHECK_END if (ret < 0) goto end
nb_streams = fmt_ctx->nb_streams;
REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(selected_streams,0,fmt_ctx->nb_streams);
nb_streams = ifile.fmt_ctx->nb_streams;
REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,ifile.fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,ifile.fmt_ctx->nb_streams);
REALLOCZ_ARRAY_STREAM(selected_streams,0,ifile.fmt_ctx->nb_streams);
for (i = 0; i < fmt_ctx->nb_streams; i++) {
for (i = 0; i < ifile.fmt_ctx->nb_streams; i++) {
if (stream_specifier) {
ret = avformat_match_stream_specifier(fmt_ctx,
fmt_ctx->streams[i],
ret = avformat_match_stream_specifier(ifile.fmt_ctx,
ifile.fmt_ctx->streams[i],
stream_specifier);
CHECK_END;
else
@ -2630,33 +2693,33 @@ static int probe_file(WriterContext *wctx, const char *filename)
section_id = SECTION_ID_FRAMES;
if (do_show_frames || do_show_packets)
writer_print_section_header(wctx, section_id);
ret = read_packets(wctx, fmt_ctx);
ret = read_packets(wctx, &ifile);
if (do_show_frames || do_show_packets)
writer_print_section_footer(wctx);
CHECK_END;
}
if (do_show_programs) {
ret = show_programs(wctx, fmt_ctx);
ret = show_programs(wctx, &ifile);
CHECK_END;
}
if (do_show_streams) {
ret = show_streams(wctx, fmt_ctx);
ret = show_streams(wctx, &ifile);
CHECK_END;
}
if (do_show_chapters) {
ret = show_chapters(wctx, fmt_ctx);
ret = show_chapters(wctx, &ifile);
CHECK_END;
}
if (do_show_format) {
ret = show_format(wctx, fmt_ctx);
ret = show_format(wctx, &ifile);
CHECK_END;
}
end:
if (fmt_ctx)
close_input_file(&fmt_ctx);
if (ifile.fmt_ctx)
close_input_file(&ifile);
av_freep(&nb_streams_frames);
av_freep(&nb_streams_packets);
av_freep(&selected_streams);

View File

@ -2622,6 +2622,7 @@ static int http_start_receive_data(HTTPContext *c)
{
int fd;
int ret;
int64_t ret64;
if (c->stream->feed_opened) {
http_log("Stream feed '%s' was not opened\n",
@ -2657,13 +2658,13 @@ static int http_start_receive_data(HTTPContext *c)
return ret;
}
} else {
ret = ffm_read_write_index(fd);
if (ret < 0) {
ret64 = ffm_read_write_index(fd);
if (ret64 < 0) {
http_log("Error reading write index from feed file '%s': %s\n",
c->stream->feed_filename, strerror(errno));
return ret;
return ret64;
}
c->stream->feed_write_index = ret;
c->stream->feed_write_index = ret64;
}
c->stream->feed_write_index = FFMAX(ffm_read_write_index(fd),
@ -2995,6 +2996,8 @@ static int prepare_sdp_description(FFServerStream *stream, uint8_t **pbuffer,
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
avcodec_parameters_from_context(stream->streams[i]->codecpar, stream->streams[i]->codec);
avc->streams[i]->codecpar = stream->streams[i]->codecpar;
}
*pbuffer = av_mallocz(2048);
if (!*pbuffer)
@ -3535,6 +3538,8 @@ static AVStream *add_av_stream1(FFServerStream *stream,
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->internal = av_mallocz(sizeof(*fst->internal));
fst->internal->avctx = avcodec_alloc_context3(NULL);
fst->codecpar = avcodec_parameters_alloc();
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;
@ -3858,6 +3863,8 @@ drop:
if (avformat_write_header(s, NULL) < 0) {
http_log("Container doesn't support the required parameters\n");
avio_closep(&s->pb);
s->streams = NULL;
s->nb_streams = 0;
avformat_free_context(s);
goto bail;
}

View File

@ -1138,6 +1138,8 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
av_dict_free(&config->audio_opts);
avcodec_free_context(&config->dummy_vctx);
avcodec_free_context(&config->dummy_actx);
config->no_video = 0;
config->no_audio = 0;
*pstream = NULL;
} else if (!av_strcasecmp(cmd, "File") ||
!av_strcasecmp(cmd, "ReadOnlyFile")) {

View File

@ -28,7 +28,6 @@
* Supports: PAL8 (RGB 8bpp, paletted)
* : BGR24 (RGB 24bpp) (can also output it as RGB32)
* : RGB32 (RGB 32bpp, 4th plane is alpha)
*
*/
#include <stdio.h>

View File

@ -5,10 +5,11 @@ NAME = avcodec
HEADERS = avcodec.h \
avdct.h \
avfft.h \
dv_profile.h \
d3d11va.h \
dirac.h \
dv_profile.h \
dxva2.h \
jni.h \
qsv.h \
vaapi.h \
vda.h \
@ -25,11 +26,14 @@ OBJS = allcodecs.o \
avpicture.o \
bitstream.o \
bitstream_filter.o \
bitstream_filters.o \
bsf.o \
codec_desc.o \
d3d11va.o \
dirac.o \
dv_profile.o \
imgconvert.o \
jni.o \
mathtables.o \
options.o \
parser.o \
@ -78,6 +82,7 @@ OBJS-$(CONFIG_IIRFILTER) += iirfilter.o
OBJS-$(CONFIG_IMDCT15) += imdct15.o
OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o
OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o
OBJS-$(CONFIG_JNI) += ffjni.o jni.o
OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o
OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o
OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o
@ -87,6 +92,7 @@ OBJS-$(CONFIG_LSP) += lsp.o
OBJS-$(CONFIG_LZF) += lzf.o
OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o mdct_fixed_32.o
OBJS-$(CONFIG_ME_CMP) += me_cmp.o
OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec.o mediacodec_wrapper.o mediacodec_sw_buffer.o
OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o
OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o mpegaudiodata.o \
mpegaudiodecheader.o
@ -118,6 +124,8 @@ OBJS-$(CONFIG_STARTCODE) += startcode.o
OBJS-$(CONFIG_TEXTUREDSP) += texturedsp.o
OBJS-$(CONFIG_TEXTUREDSPENC) += texturedspenc.o
OBJS-$(CONFIG_TPELDSP) += tpeldsp.o
OBJS-$(CONFIG_VAAPI_ENCODE) += vaapi_encode.o
OBJS-$(CONFIG_VC1DSP) += vc1dsp.o
OBJS-$(CONFIG_VIDEODSP) += videodsp.o
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
OBJS-$(CONFIG_VP56DSP) += vp56dsp.o
@ -131,17 +139,17 @@ OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \
aacadtsdec.o mpeg4audio.o kbdwin.o \
sbrdsp.o aacpsdsp_float.o
sbrdsp.o aacpsdsp_float.o cbrt_data.o
OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \
aacadtsdec.o mpeg4audio.o kbdwin.o \
sbrdsp_fixed.o aacpsdsp_fixed.o
sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacpsy.o aactab.o \
aacenc_is.o \
aacenc_tns.o \
aacenc_ltp.o \
aacenc_pred.o \
psymodel.o mpeg4audio.o kbdwin.o
psymodel.o mpeg4audio.o kbdwin.o cbrt_data.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_FIXED_DECODER) += ac3dec_fixed.o ac3dec_data.o ac3.o kbdwin.o
@ -171,9 +179,9 @@ OBJS-$(CONFIG_ANSI_DECODER) += ansi.o cga_data.o
OBJS-$(CONFIG_APE_DECODER) += apedec.o
OBJS-$(CONFIG_APNG_DECODER) += png.o pngdec.o pngdsp.o
OBJS-$(CONFIG_APNG_ENCODER) += png.o pngenc.o
OBJS-$(CONFIG_SSA_DECODER) += assdec.o ass.o ass_split.o
OBJS-$(CONFIG_SSA_DECODER) += assdec.o ass.o
OBJS-$(CONFIG_SSA_ENCODER) += assenc.o ass.o
OBJS-$(CONFIG_ASS_DECODER) += assdec.o ass.o ass_split.o
OBJS-$(CONFIG_ASS_DECODER) += assdec.o ass.o
OBJS-$(CONFIG_ASS_ENCODER) += assenc.o ass.o
OBJS-$(CONFIG_ASV1_DECODER) += asvdec.o asv.o mpeg12data.o
OBJS-$(CONFIG_ASV1_ENCODER) += asvenc.o asv.o mpeg12data.o
@ -216,14 +224,14 @@ OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o
OBJS-$(CONFIG_CLJR_DECODER) += cljrdec.o
OBJS-$(CONFIG_CLJR_ENCODER) += cljrenc.o
OBJS-$(CONFIG_CLLC_DECODER) += cllc.o canopus.o
OBJS-$(CONFIG_COOK_DECODER) += cook.o
OBJS-$(CONFIG_COMFORTNOISE_DECODER) += cngdec.o celp_filters.o
OBJS-$(CONFIG_COMFORTNOISE_ENCODER) += cngenc.o
OBJS-$(CONFIG_COOK_DECODER) += cook.o
OBJS-$(CONFIG_CPIA_DECODER) += cpia.o
OBJS-$(CONFIG_CSCD_DECODER) += cscd.o
OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o \
dca_core.o dca_exss.o dca_xll.o \
OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \
dca_core.o dca_exss.o dca_xll.o dca_lbr.o \
dcadsp.o dcadct.o synth_filter.o
OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o
OBJS-$(CONFIG_DDS_DECODER) += dds.o
@ -234,13 +242,14 @@ OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o
OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o
OBJS-$(CONFIG_DPX_DECODER) += dpx.o
OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o
OBJS-$(CONFIG_DSD_LSBF_DECODER) += dsddec.o
OBJS-$(CONFIG_DSD_MSBF_DECODER) += dsddec.o
OBJS-$(CONFIG_DSD_LSBF_PLANAR_DECODER) += dsddec.o
OBJS-$(CONFIG_DSD_MSBF_PLANAR_DECODER) += dsddec.o
OBJS-$(CONFIG_DSD_LSBF_DECODER) += dsddec.o dsd.o
OBJS-$(CONFIG_DSD_MSBF_DECODER) += dsddec.o dsd.o
OBJS-$(CONFIG_DSD_LSBF_PLANAR_DECODER) += dsddec.o dsd.o
OBJS-$(CONFIG_DSD_MSBF_PLANAR_DECODER) += dsddec.o dsd.o
OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinaudio.o
OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinvideo.o
OBJS-$(CONFIG_DSS_SP_DECODER) += dss_sp.o
OBJS-$(CONFIG_DST_DECODER) += dstdec.o dsd.o
OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o
OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o
OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o
@ -258,7 +267,7 @@ OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \
mpeg12data.o
OBJS-$(CONFIG_EATGQ_DECODER) += eatgq.o eaidct.o
OBJS-$(CONFIG_EATGV_DECODER) += eatgv.o
OBJS-$(CONFIG_EATQI_DECODER) += eatqi.o eaidct.o
OBJS-$(CONFIG_EATQI_DECODER) += eatqi.o eaidct.o mpeg12.o mpeg12data.o mpegvideodata.o rl.o
OBJS-$(CONFIG_EIGHTBPS_DECODER) += 8bps.o
OBJS-$(CONFIG_EIGHTSVX_EXP_DECODER) += 8svx.o
OBJS-$(CONFIG_EIGHTSVX_FIB_DECODER) += 8svx.o
@ -296,22 +305,36 @@ OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
mpeg4video.o mpeg4videodec.o flvdec.o\
intelh263dec.o h263data.o
OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \
h263.o h263data.o ituh263enc.o flvenc.o
h263.o ituh263enc.o flvenc.o h263data.o
OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
h264_direct.o h264_loopfilter.o \
h264_mb.o h264_picture.o h264_ps.o \
h264_refs.o h264_sei.o h264_slice.o
h264_refs.o h264_sei.o \
h264_slice.o h264data.o h264_parse.o \
h2645_parse.o
OBJS-$(CONFIG_H264_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o
OBJS-$(CONFIG_NVENC_ENCODER) += nvenc_h264.o
OBJS-$(CONFIG_NVENC_H264_ENCODER) += nvenc_h264.o
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h2645.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o vaapi_encode_h26x.o
OBJS-$(CONFIG_H264_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_HAP_DECODER) += hapdec.o hap.o
OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o
OBJS-$(CONFIG_HEVC_DECODER) += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \
hevc_cabac.o hevc_refs.o hevcpred.o \
hevcdsp.o hevc_filter.o hevc_parse.o hevc_data.o
hevcdsp.o hevc_filter.o h2645_parse.o hevc_data.o
OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o
OBJS-$(CONFIG_NVENC_HEVC_ENCODER) += nvenc_hevc.o
OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec_h2645.o
OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o hevc_parse.o
OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o h2645_parse.o
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o vaapi_encode_h26x.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
canopus.o
@ -342,8 +365,10 @@ OBJS-$(CONFIG_KMVC_DECODER) += kmvc.o
OBJS-$(CONFIG_LAGARITH_DECODER) += lagarith.o lagarithrac.o
OBJS-$(CONFIG_LJPEG_ENCODER) += ljpegenc.o mjpegenc_common.o
OBJS-$(CONFIG_LOCO_DECODER) += loco.o
OBJS-$(CONFIG_M101_DECODER) += m101.o
OBJS-$(CONFIG_MACE3_DECODER) += mace.o
OBJS-$(CONFIG_MACE6_DECODER) += mace.o
OBJS-$(CONFIG_MAGICYUV_DECODER) += magicyuv.o
OBJS-$(CONFIG_MDEC_DECODER) += mdec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \
twinvq.o
@ -352,6 +377,7 @@ OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o
OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o
OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o
OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o
OBJS-$(CONFIG_MJPEG_VAAPI_ENCODER) += vaapi_encode_mjpeg.o
OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o
OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
OBJS-$(CONFIG_MOTIONPIXELS_DECODER) += motionpixels.o
@ -376,22 +402,23 @@ OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec_mpeg2.o
OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o
OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o
OBJS-$(CONFIG_MSA1_DECODER) += mss3.o
OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSMPEG4V2_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSMPEG4V2_ENCODER) += msmpeg4enc.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSMPEG4V3_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4enc.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o
OBJS-$(CONFIG_MSA1_DECODER) += mss3.o
OBJS-$(CONFIG_MSS1_DECODER) += mss1.o mss12.o
OBJS-$(CONFIG_MSS2_DECODER) += mss2.o mss12.o mss2dsp.o
OBJS-$(CONFIG_MSS2_DECODER) += mss2.o mss12.o mss2dsp.o wmv2data.o
OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o
OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o
@ -471,6 +498,7 @@ OBJS-$(CONFIG_SDX2_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_SGI_DECODER) += sgidec.o
OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o
OBJS-$(CONFIG_SGIRLE_DECODER) += sgirledec.o
OBJS-$(CONFIG_SHEERVIDEO_DECODER) += sheervideo.o
OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o
OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_delay.o \
celp_math.o acelp_vectors.o \
@ -497,10 +525,10 @@ OBJS-$(CONFIG_SUBVIEWER1_DECODER) += textdec.o ass.o
OBJS-$(CONFIG_SUBVIEWER_DECODER) += subviewerdec.o ass.o
OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o
OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o \
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263data.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o h263data.o \
h263.o ituh263enc.o
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o h264_parse.o h264data.o
OBJS-$(CONFIG_TEXT_DECODER) += textdec.o ass.o
OBJS-$(CONFIG_TEXT_ENCODER) += srtenc.o ass_split.o
OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o takdsp.o
@ -515,6 +543,7 @@ OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
OBJS-$(CONFIG_TRUEHD_DECODER) += mlpdec.o mlpdsp.o
OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o
OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o
OBJS-$(CONFIG_TRUEMOTION2RT_DECODER) += truemotion2rt.o
OBJS-$(CONFIG_TRUESPEECH_DECODER) += truespeech.o
OBJS-$(CONFIG_TSCC_DECODER) += tscc.o msrledec.o
OBJS-$(CONFIG_TSCC2_DECODER) += tscc2.o
@ -527,20 +556,20 @@ OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o utvideo.o
OBJS-$(CONFIG_UTVIDEO_ENCODER) += utvideoenc.o utvideo.o
OBJS-$(CONFIG_V210_DECODER) += v210dec.o
OBJS-$(CONFIG_V210_ENCODER) += v210enc.o
OBJS-$(CONFIG_V210X_DECODER) += v210x.o
OBJS-$(CONFIG_V308_DECODER) += v308dec.o
OBJS-$(CONFIG_V308_ENCODER) += v308enc.o
OBJS-$(CONFIG_V408_DECODER) += v408dec.o
OBJS-$(CONFIG_V408_ENCODER) += v408enc.o
OBJS-$(CONFIG_V410_DECODER) += v410dec.o
OBJS-$(CONFIG_V410_ENCODER) += v410enc.o
OBJS-$(CONFIG_V210X_DECODER) += v210x.o
OBJS-$(CONFIG_VB_DECODER) += vb.o
OBJS-$(CONFIG_VBLE_DECODER) += vble.o
OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o vc1_loopfilter.o \
vc1_mc.o vc1_pred.o vc1.o vc1data.o \
vc1dsp.o \
msmpeg4dec.o msmpeg4.o msmpeg4data.o \
wmv2dsp.o
wmv2dsp.o wmv2data.o
OBJS-$(CONFIG_VC1_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_VC1_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec_vc1.o
OBJS-$(CONFIG_VC2_ENCODER) += vc2enc.o vc2enc_dwt.o diractab.o
@ -558,8 +587,10 @@ OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \
vp6dsp.o vp56rac.o
OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp56rac.o
OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o
OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9dsp.o vp56rac.o vp9dsp_8bpp.o \
vp9dsp_10bpp.o vp9dsp_12bpp.o
OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuvid.o
OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
@ -578,13 +609,13 @@ OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \
acelp_vectors.o acelp_filters.o
OBJS-$(CONFIG_WMV1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_WMV1_ENCODER) += msmpeg4enc.o
OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o \
OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o wmv2data.o \
msmpeg4dec.o msmpeg4.o msmpeg4data.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o \
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o wmv2data.o \
msmpeg4.o msmpeg4enc.o msmpeg4data.o
OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o
OBJS-$(CONFIG_WRAPPED_AVFRAME_ENCODER) += wrapped_avframe.o
OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o
OBJS-$(CONFIG_XAN_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_XAN_WC3_DECODER) += xan.o
OBJS-$(CONFIG_XAN_WC4_DECODER) += xxan.o
@ -602,6 +633,7 @@ OBJS-$(CONFIG_XWD_DECODER) += xwddec.o
OBJS-$(CONFIG_XWD_ENCODER) += xwdenc.o
OBJS-$(CONFIG_Y41P_DECODER) += y41pdec.o
OBJS-$(CONFIG_Y41P_ENCODER) += y41penc.o
OBJS-$(CONFIG_YLC_DECODER) += ylc.o
OBJS-$(CONFIG_YOP_DECODER) += yop.o
OBJS-$(CONFIG_YUV4_DECODER) += yuv4dec.o
OBJS-$(CONFIG_YUV4_ENCODER) += yuv4enc.o
@ -689,6 +721,7 @@ OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
OBJS-$(CONFIG_ADPCM_G726LE_DECODER) += g726.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o adpcm_data.o
@ -704,6 +737,7 @@ OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_WS_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_MS_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_MS_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_MTAF_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_PSX_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SBPRO_2_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SBPRO_3_DECODER) += adpcm.o adpcm_data.o
@ -757,28 +791,24 @@ OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o
OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o
# libavformat dependencies
OBJS-$(CONFIG_ISO_MEDIA) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_AVI_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o \
ac3tab.o
OBJS-$(CONFIG_CAF_DEMUXER) += ac3tab.o
OBJS-$(CONFIG_DNXHD_DEMUXER) += dnxhddata.o
OBJS-$(CONFIG_FLAC_DEMUXER) += flac.o flacdata.o vorbis_data.o
OBJS-$(CONFIG_FLAC_MUXER) += flac.o flacdata.o vorbis_data.o
OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o
OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o
OBJS-$(CONFIG_IFF_DEMUXER) += iff.o
OBJS-$(CONFIG_ISMV_MUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += mpeg4audio.o vorbis_data.o \
flac.o flacdata.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o mpegaudiodata.o \
flac.o flacdata.o vorbis_data.o
OBJS-$(CONFIG_MATROSKA_MUXER) += flac.o flacdata.o vorbis_data.o
OBJS-$(CONFIG_MOV_DEMUXER) += ac3tab.o
OBJS-$(CONFIG_MP2_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP3_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o ac3tab.o
OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MPEGTS_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_NUT_DEMUXER) += mpegaudiodata.o mpeg4audio.o
@ -794,14 +824,32 @@ OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o mpegaudiodata.o \
flac.o flacdata.o \
vorbis_data.o
OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
# libavfilter dependencies
OBJS-$(CONFIG_ELBG_FILTER) += elbg.o
# external codec libraries
OBJS-$(CONFIG_AAC_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_AC3_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_ADPCM_IMA_QT_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_ALAC_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_AMR_NB_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_EAC3_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_GSM_MS_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_ILBC_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_MP1_AT_DECODER) += audiotoolboxdec.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP2_AT_DECODER) += audiotoolboxdec.o mpegaudiodecheader.o
OBJS-$(CONFIG_MP3_AT_DECODER) += audiotoolboxdec.o mpegaudiodecheader.o
OBJS-$(CONFIG_PCM_MULAW_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_PCM_ALAW_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_QDMC_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_QDM2_AT_DECODER) += audiotoolboxdec.o
OBJS-$(CONFIG_AAC_AT_ENCODER) += audiotoolboxenc.o
OBJS-$(CONFIG_ALAC_AT_ENCODER) += audiotoolboxenc.o
OBJS-$(CONFIG_ILBC_AT_ENCODER) += audiotoolboxenc.o
OBJS-$(CONFIG_PCM_ALAW_AT_ENCODER) += audiotoolboxenc.o
OBJS-$(CONFIG_PCM_MULAW_AT_ENCODER) += audiotoolboxenc.o
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
OBJS-$(CONFIG_LIBDCADEC_DECODER) += libdcadec.o dca.o
OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o
OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o
OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o
@ -832,8 +880,6 @@ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o
OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o
OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
OBJS-$(CONFIG_LIBUTVIDEO_DECODER) += libutvideodec.o
OBJS-$(CONFIG_LIBUTVIDEO_ENCODER) += libutvideoenc.o
OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
OBJS-$(CONFIG_LIBVORBIS_DECODER) += libvorbisdec.o
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbisenc.o \
@ -853,16 +899,16 @@ OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o
OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o
# parsers
OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \
aacadtsdec.o mpeg4audio.o
OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
OBJS-$(CONFIG_AC3_PARSER) += ac3_parser.o ac3tab.o \
aac_ac3_parser.o
OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o
OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o
OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs_parser.o
OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o dca.o
OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o dca_exss.o dca.o
OBJS-$(CONFIG_DIRAC_PARSER) += dirac_parser.o
OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o
OBJS-$(CONFIG_DPX_PARSER) += dpx_parser.o
@ -876,8 +922,9 @@ OBJS-$(CONFIG_G729_PARSER) += g729_parser.o
OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
OBJS-$(CONFIG_H264_PARSER) += h264_parser.o
OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_parse.o hevc_ps.o hevc_data.o
OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_parse.o h2645_parse.o \
h264_ps.o h264_sei.o h264data.o
OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o h2645_parse.o hevc_ps.o hevc_data.o
OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o
OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o
OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \
@ -894,7 +941,8 @@ OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o
OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o
OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o
OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o
OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \
simple_idct.o wmv2data.o
OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o
OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o
OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o
@ -904,6 +952,7 @@ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o aacadtsdec.o \
mpeg4audio.o
OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o
OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
OBJS-$(CONFIG_DCA_CORE_BSF) += dca_core_bsf.o
OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o
OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF) += hevc_mp4toannexb_bsf.o
OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o
@ -916,6 +965,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += mp3_header_decompress_bsf.o \
OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o
OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o
OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o
OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
# thread libraries
OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
@ -939,15 +989,17 @@ SKIPHEADERS += %_tablegen.h \
SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h
SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h
SKIPHEADERS-$(CONFIG_JNI) += ffjni.h
SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h
SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h
SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.h
SKIPHEADERS-$(CONFIG_MEDIACODEC) += mediacodecdec.h mediacodec_wrapper.h mediacodec_sw_buffer.h
SKIPHEADERS-$(CONFIG_NVENC) += nvenc.h
SKIPHEADERS-$(CONFIG_QSV) += qsv.h qsv_internal.h
SKIPHEADERS-$(CONFIG_QSVDEC) += qsvdec.h
SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h
SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_encode.h vaapi_internal.h
SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_vt_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h
@ -956,14 +1008,15 @@ TESTPROGS = imgconvert \
jpeg2000dwt \
mathops \
options \
avfft \
utils \
TESTPROGS-$(CONFIG_CABAC) += cabac
TESTPROGS-$(CONFIG_DCT) += avfft
TESTPROGS-$(CONFIG_FFT) += fft fft-fixed fft-fixed32
TESTPROGS-$(CONFIG_GOLOMB) += golomb
TESTPROGS-$(CONFIG_IDCTDSP) += dct
TESTPROGS-$(CONFIG_IIRFILTER) += iirfilter
TESTPROGS-$(HAVE_MMX) += motion
TESTPROGS-$(CONFIG_GOLOMB) += golomb
TESTPROGS-$(CONFIG_RANGECODER) += rangecoder
TESTPROGS-$(CONFIG_SNOW_ENCODER) += snowenc
@ -986,7 +1039,7 @@ HOSTPROGS = aacps_tablegen \
CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF)
$(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o
$(SUBDIR)tests/dct$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o
$(SUBDIR)dv_tablegen$(HOSTEXESUF): $(SUBDIR)dvdata_host.o
TRIG_TABLES = cos cos_fixed sin
@ -1011,17 +1064,17 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF)
$(M)./$< > $@
ifdef CONFIG_HARDCODED_TABLES
$(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h
$(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h
$(SUBDIR)cbrt_data.o: $(SUBDIR)cbrt_tables.h
$(SUBDIR)cbrt_data_fixed.o: $(SUBDIR)cbrt_fixed_tables.h
$(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h
$(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h
$(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h
$(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h
$(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h
$(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h
$(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
$(SUBDIR)mpegaudiodec_fixed.o: $(SUBDIR)mpegaudio_tables.h
$(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h
$(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
$(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h
$(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h
$(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h
$(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h
endif

View File

@ -34,6 +34,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
ParseContext *pc = &s->pc;
int len, i;
int new_frame_start;
int got_frame = 0;
get_next:
i=END_NOT_FOUND;
@ -51,6 +52,7 @@ get_next:
if(len<=0){
i=END_NOT_FOUND;
}else{
got_frame = 1;
s->state=0;
i-= s->header_size -1;
s->remaining_size = len;
@ -76,31 +78,34 @@ get_next:
if(s->codec_id)
avctx->codec_id = s->codec_id;
/* Due to backwards compatible HE-AAC the sample rate, channel count,
and total number of samples found in an AAC ADTS header are not
reliable. Bit rate is still accurate because the total frame duration in
seconds is still correct (as is the number of bits in the frame). */
if (avctx->codec_id != AV_CODEC_ID_AAC) {
avctx->sample_rate = s->sample_rate;
if (got_frame) {
/* Due to backwards compatible HE-AAC the sample rate, channel count,
and total number of samples found in an AAC ADTS header are not
reliable. Bit rate is still accurate because the total frame
duration in seconds is still correct (as is the number of bits in
the frame). */
if (avctx->codec_id != AV_CODEC_ID_AAC) {
avctx->sample_rate = s->sample_rate;
/* (E-)AC-3: allow downmixing to stereo or mono */
if (s->channels > 1 &&
avctx->request_channel_layout == AV_CH_LAYOUT_MONO) {
avctx->channels = 1;
avctx->channel_layout = AV_CH_LAYOUT_MONO;
} else if (s->channels > 2 &&
avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
avctx->channels = 2;
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
avctx->channels = s->channels;
avctx->channel_layout = s->channel_layout;
/* (E-)AC-3: allow downmixing to stereo or mono */
if (s->channels > 1 &&
avctx->request_channel_layout == AV_CH_LAYOUT_MONO) {
avctx->channels = 1;
avctx->channel_layout = AV_CH_LAYOUT_MONO;
} else if (s->channels > 2 &&
avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
avctx->channels = 2;
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
avctx->channels = s->channels;
avctx->channel_layout = s->channel_layout;
}
s1->duration = s->samples;
avctx->audio_service_type = s->service_type;
}
s1->duration = s->samples;
avctx->audio_service_type = s->service_type;
}
avctx->bit_rate = s->bit_rate;
avctx->bit_rate = s->bit_rate;
}
return i;
}

View File

@ -21,6 +21,7 @@
#include "avcodec.h"
#include "aacadtsdec.h"
#include "bsf.h"
#include "put_bits.h"
#include "get_bits.h"
#include "mpeg4audio.h"
@ -34,68 +35,75 @@ typedef struct AACBSFContext {
* This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
* ADTS header and removes the ADTS header.
*/
static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
AVCodecContext *avctx, const char *args,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int keyframe)
static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out)
{
AACBSFContext *ctx = bsfc->priv_data;
GetBitContext gb;
PutBitContext pb;
AACADTSHeaderInfo hdr;
AVPacket *in;
int ret;
AACBSFContext *ctx = bsfc->priv_data;
ret = ff_bsf_get_packet(bsfc, &in);
if (ret < 0)
return ret;
init_get_bits(&gb, buf, AAC_ADTS_HEADER_SIZE*8);
if (in->size < AAC_ADTS_HEADER_SIZE)
goto packet_too_small;
*poutbuf = (uint8_t*) buf;
*poutbuf_size = buf_size;
init_get_bits(&gb, in->data, AAC_ADTS_HEADER_SIZE * 8);
if (avctx->extradata)
if (show_bits(&gb, 12) != 0xfff)
return 0;
if (bsfc->par_in->extradata && show_bits(&gb, 12) != 0xfff)
goto finish;
if (avpriv_aac_parse_header(&gb, &hdr) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing ADTS frame header!\n");
return AVERROR_INVALIDDATA;
av_log(bsfc, AV_LOG_ERROR, "Error parsing ADTS frame header!\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!hdr.crc_absent && hdr.num_aac_frames > 1) {
avpriv_report_missing_feature(avctx,
avpriv_report_missing_feature(bsfc,
"Multiple RDBs per frame with CRC");
return AVERROR_PATCHWELCOME;
ret = AVERROR_PATCHWELCOME;
goto fail;
}
buf += AAC_ADTS_HEADER_SIZE + 2*!hdr.crc_absent;
buf_size -= AAC_ADTS_HEADER_SIZE + 2*!hdr.crc_absent;
in->size -= AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
if (in->size <= 0)
goto packet_too_small;
in->data += AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
if (!ctx->first_frame_done) {
int pce_size = 0;
uint8_t pce_data[MAX_PCE_SIZE];
uint8_t *extradata;
if (!hdr.chan_config) {
init_get_bits(&gb, buf, buf_size * 8);
init_get_bits(&gb, in->data, in->size * 8);
if (get_bits(&gb, 3) != 5) {
avpriv_report_missing_feature(avctx,
avpriv_report_missing_feature(bsfc,
"PCE-based channel configuration "
"without PCE as first syntax "
"element");
return AVERROR_PATCHWELCOME;
ret = AVERROR_PATCHWELCOME;
goto fail;
}
init_put_bits(&pb, pce_data, MAX_PCE_SIZE);
pce_size = avpriv_copy_pce_data(&pb, &gb)/8;
flush_put_bits(&pb);
buf_size -= get_bits_count(&gb)/8;
buf += get_bits_count(&gb)/8;
}
av_free(avctx->extradata);
avctx->extradata_size = 2 + pce_size;
avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
avctx->extradata_size = 0;
return AVERROR(ENOMEM);
in->size -= get_bits_count(&gb)/8;
in->data += get_bits_count(&gb)/8;
}
init_put_bits(&pb, avctx->extradata, avctx->extradata_size);
extradata = av_mallocz(2 + pce_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!extradata) {
ret = AVERROR(ENOMEM);
goto fail;
}
init_put_bits(&pb, extradata, 2 + pce_size);
put_bits(&pb, 5, hdr.object_type);
put_bits(&pb, 4, hdr.sampling_index);
put_bits(&pb, 4, hdr.chan_config);
@ -104,20 +112,44 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
put_bits(&pb, 1, 0); //is not extension
flush_put_bits(&pb);
if (pce_size) {
memcpy(avctx->extradata + 2, pce_data, pce_size);
memcpy(extradata + 2, pce_data, pce_size);
}
bsfc->par_out->extradata = extradata;
bsfc->par_out->extradata_size = 2 + pce_size;
ctx->first_frame_done = 1;
}
*poutbuf = (uint8_t*) buf;
*poutbuf_size = buf_size;
finish:
av_packet_move_ref(out, in);
av_packet_free(&in);
return 0;
packet_too_small:
av_log(bsfc, AV_LOG_ERROR, "Input packet too small\n");
ret = AVERROR_INVALIDDATA;
fail:
av_packet_free(&in);
return ret;
}
static int aac_adtstoasc_init(AVBSFContext *ctx)
{
av_freep(&ctx->par_out->extradata);
ctx->par_out->extradata_size = 0;
return 0;
}
AVBitStreamFilter ff_aac_adtstoasc_bsf = {
static const enum AVCodecID codec_ids[] = {
AV_CODEC_ID_AAC, AV_CODEC_ID_NONE,
};
const AVBitStreamFilter ff_aac_adtstoasc_bsf = {
.name = "aac_adtstoasc",
.priv_data_size = sizeof(AACBSFContext),
.init = aac_adtstoasc_init,
.filter = aac_adtstoasc_filter,
.codec_ids = codec_ids,
};

View File

@ -89,9 +89,9 @@ typedef float AAC_FLOAT;
typedef unsigned AAC_SIGNE;
#define FIXR(x) ((float)(x))
#define FIXR10(x) ((float)(x))
#define Q23(x) x
#define Q30(x) x
#define Q31(x) x
#define Q23(x) ((float)(x))
#define Q30(x) ((float)(x))
#define Q31(x) ((float)(x))
#define RANGE15(x) (32768.0 * (x))
#define GET_GAIN(x, y) powf((x), -(y))
#define AAC_MUL16(x, y) ((x) * (y))

View File

@ -77,7 +77,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
int toomanybits, toofewbits;
char nzs[128];
uint8_t nextband[128];
int maxsf[128];
int maxsf[128], minsf[128];
float dists[128] = { 0 }, qenergies[128] = { 0 }, uplims[128], euplims[128], energies[128];
float maxvals[128], spread_thr_r[128];
float min_spread_thr_r, max_spread_thr_r;
@ -294,11 +294,19 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
abs_pow34_v(s->scoefs, sce->coeffs, 1024);
ff_quantize_band_cost_cache_init(s);
for (i = 0; i < sizeof(minsf) / sizeof(minsf[0]); ++i)
minsf[i] = 0;
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
start = w*128;
for (g = 0; g < sce->ics.num_swb; g++) {
const float *scaled = s->scoefs + start;
int minsfidx;
maxvals[w*16+g] = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled);
if (maxvals[w*16+g] > 0) {
minsfidx = coef2minsf(maxvals[w*16+g]);
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++)
minsf[(w+w2)*16+g] = minsfidx;
}
start += sce->ics.swb_sizes[g];
}
}
@ -425,7 +433,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
recomprd = 1;
for (i = 0; i < 128; i++) {
if (sce->sf_idx[i] > SCALE_ONE_POS) {
int new_sf = FFMAX(SCALE_ONE_POS, sce->sf_idx[i] - qstep);
int new_sf = FFMAX3(minsf[i], SCALE_ONE_POS, sce->sf_idx[i] - qstep);
if (new_sf != sce->sf_idx[i]) {
sce->sf_idx[i] = new_sf;
changed = 1;
@ -595,7 +603,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
int cmb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
int mindeltasf = FFMAX(0, prev - SCALE_MAX_DIFF);
int maxdeltasf = FFMIN(SCALE_MAX_POS - SCALE_DIV_512, prev + SCALE_MAX_DIFF);
if ((!cmb || dists[w*16+g] > uplims[w*16+g]) && sce->sf_idx[w*16+g] > mindeltasf) {
if ((!cmb || dists[w*16+g] > uplims[w*16+g]) && sce->sf_idx[w*16+g] > FFMAX(mindeltasf, minsf[w*16+g])) {
/* Try to make sure there is some energy in every nonzero band
* NOTE: This algorithm must be forcibly imbalanced, pushing harder
* on holes or more distorted bands at first, otherwise there's

View File

@ -50,7 +50,7 @@
#include "aac.h"
#include "aactab.h"
#include "aacdectab.h"
#include "cbrt_tablegen.h"
#include "cbrt_data.h"
#include "sbr.h"
#include "aacsbr.h"
#include "mpeg4audio.h"

View File

@ -75,7 +75,7 @@
#include "aac.h"
#include "aactab.h"
#include "aacdectab.h"
#include "cbrt_tablegen.h"
#include "cbrt_data.h"
#include "sbr.h"
#include "aacsbr.h"
#include "mpeg4audio.h"
@ -155,9 +155,9 @@ static void vector_pow43(int *coefs, int len)
for (i=0; i<len; i++) {
coef = coefs[i];
if (coef < 0)
coef = -(int)cbrt_tab[-coef];
coef = -(int)ff_cbrt_tab_fixed[-coef];
else
coef = (int)cbrt_tab[coef];
coef = (int)ff_cbrt_tab_fixed[coef];
coefs[i] = coef;
}
}

View File

@ -1104,7 +1104,7 @@ static av_cold void aac_static_table_init(void)
AAC_RENAME(ff_init_ff_sine_windows)( 9);
AAC_RENAME(ff_init_ff_sine_windows)( 7);
AAC_RENAME(cbrt_tableinit)();
AAC_RENAME(ff_cbrt_tableinit)();
}
static AVOnce aac_table_init = AV_ONCE_INIT;
@ -1795,7 +1795,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024],
v = -v;
*icf++ = v;
#else
*icf++ = cbrt_tab[n] | (bits & 1U<<31);
*icf++ = ff_cbrt_tab[n] | (bits & 1U<<31);
#endif /* USE_FIXED */
bits <<= 1;
} else {

View File

@ -78,11 +78,10 @@ static void put_audio_specific_config(AVCodecContext *avctx)
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
{
int sf, g;
for (sf = 0; sf < 256; sf++) {
for (g = 0; g < 128; g++) {
s->quantize_band_cost_cache[sf][g].bits = -1;
}
++s->quantize_band_cost_cache_generation;
if (s->quantize_band_cost_cache_generation == 0) {
memset(s->quantize_band_cost_cache, 0, sizeof(s->quantize_band_cost_cache));
s->quantize_band_cost_cache_generation = 1;
}
}
@ -555,10 +554,11 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (!frame)
la = NULL;
if (tag == TYPE_LFE) {
wi[ch].window_type[0] = ONLY_LONG_SEQUENCE;
wi[ch].window_type[0] = wi[ch].window_type[1] = ONLY_LONG_SEQUENCE;
wi[ch].window_shape = 0;
wi[ch].num_windows = 1;
wi[ch].grouping[0] = 1;
wi[ch].clipping[0] = 0;
/* Only the lowest 12 coefficients are used in a LFE channel.
* The expression below results in only the bottom 8 coefficients
@ -583,9 +583,22 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ics->tns_max_bands = wi[ch].window_type[0] == EIGHT_SHORT_SEQUENCE ?
ff_tns_max_bands_128 [s->samplerate_index]:
ff_tns_max_bands_1024[s->samplerate_index];
clip_avoidance_factor = 0.0f;
for (w = 0; w < ics->num_windows; w++)
ics->group_len[w] = wi[ch].grouping[w];
/* Calculate input sample maximums and evaluate clipping risk */
clip_avoidance_factor = 0.0f;
for (w = 0; w < ics->num_windows; w++) {
const float *wbuf = overlap + w * 128;
const int wlen = 2048 / ics->num_windows;
float max = 0;
int j;
/* mdct input is 2 * output */
for (j = 0; j < wlen; j++)
max = FFMAX(max, fabsf(wbuf[j]));
wi[ch].clipping[w] = max;
}
for (w = 0; w < ics->num_windows; w++) {
if (wi[ch].clipping[w] > CLIP_AVOIDANCE_FACTOR) {
ics->window_clipping[w] = 1;

View File

@ -84,10 +84,10 @@ extern AACCoefficientsEncoder ff_aac_coders[];
typedef struct AACQuantizeBandCostCacheEntry {
float rd;
float energy;
int bits; ///< -1 means uninitialized entry
int bits;
char cb;
char rtz;
char padding[2]; ///< Keeps the entry size a multiple of 32 bits
uint16_t generation;
} AACQuantizeBandCostCacheEntry;
/**
@ -126,6 +126,7 @@ typedef struct AACEncContext {
DECLARE_ALIGNED(16, int, qcoefs)[96]; ///< quantized coefficients
DECLARE_ALIGNED(32, float, scoefs)[1024]; ///< scaled coefficients
uint16_t quantize_band_cost_cache_generation;
AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]; ///< memoization area for quantize_band_cost
struct {

View File

@ -36,11 +36,12 @@ static inline float quantize_band_cost_cached(struct AACEncContext *s, int w, in
AACQuantizeBandCostCacheEntry *entry;
av_assert1(scale_idx >= 0 && scale_idx < 256);
entry = &s->quantize_band_cost_cache[scale_idx][w*16+g];
if (entry->bits < 0 || entry->cb != cb || entry->rtz != rtz) {
if (entry->generation != s->quantize_band_cost_cache_generation || entry->cb != cb || entry->rtz != rtz) {
entry->rd = quantize_band_cost(s, in, scaled, size, scale_idx,
cb, lambda, uplim, &entry->bits, &entry->energy, rtz);
entry->cb = cb;
entry->rtz = rtz;
entry->generation = s->quantize_band_cost_cache_generation;
}
if (bits)
*bits = entry->bits;

View File

@ -28,7 +28,7 @@
#ifndef AVCODEC_AACENC_UTILS_H
#define AVCODEC_AACENC_UTILS_H
#include "libavutil/internal.h"
#include "libavutil/ffmath.h"
#include "aac.h"
#include "aacenctab.h"
#include "aactab.h"

View File

@ -25,8 +25,7 @@
*/
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/libm.h"
#include "libavutil/ffmath.h"
#include "avcodec.h"
#include "aactab.h"
@ -686,7 +685,7 @@ static void psy_3gpp_analyze_channel(FFPsyContext *ctx, int channel,
band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);
//5.4.2.5 "Pre-echo control"
if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))
if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (!w && wi->window_type[1] == LONG_START_SEQUENCE)))
band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr,
PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
@ -886,13 +885,12 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
int grouping = 0;
int uselongblock = 1;
int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
float clippings[AAC_NUM_BLOCKS_SHORT];
int i;
FFPsyWindowInfo wi = { { 0 } };
if (la) {
float hpfsmpl[AAC_BLOCK_SIZE_LONG];
float const *pf = hpfsmpl;
const float *pf = hpfsmpl;
float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
@ -911,7 +909,7 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
}
for (i = 0; i < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; i++) {
float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
const float *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
float p = 1.0f;
for (; pf < pfe; pf++)
p = FFMAX(p, fabsf(*pf));
@ -944,9 +942,9 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
/* GB: tuned (1) to avoid too many short blocks for test sample TRUMPET */
/* RH: tuned (2) to let enough short blocks through for test sample FSOL and SNAPS */
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) {
float const u = energy_short[i - 1];
float const v = energy_short[i];
float const m = FFMAX(u, v);
const float u = energy_short[i - 1];
const float v = energy_short[i];
const float m = FFMAX(u, v);
if (m < 40000) { /* (2) */
if (u < 1.7f * v && v < 1.7f * u) { /* (1) */
if (i == 1 && attacks[0] < attacks[i])
@ -976,24 +974,8 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
lame_apply_block_type(pch, &wi, uselongblock);
/* Calculate input sample maximums and evaluate clipping risk */
if (audio) {
for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) {
const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT;
float max = 0;
int j;
for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)
max = FFMAX(max, fabsf(wbuf[j]));
clippings[i] = max;
}
} else {
for (i = 0; i < 8; i++)
clippings[i] = 0;
}
wi.window_type[1] = prev_type;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
float clipping = 0.0f;
wi.num_windows = 1;
wi.grouping[0] = 1;
@ -1002,9 +984,6 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
else
wi.window_shape = 1;
for (i = 0; i < 8; i++)
clipping = FFMAX(clipping, clippings[i]);
wi.clipping[0] = clipping;
} else {
int lastgrp = 0;
@ -1015,14 +994,6 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
lastgrp = i;
wi.grouping[lastgrp]++;
}
for (i = 0; i < 8; i += wi.grouping[i]) {
int w;
float clipping = 0.0f;
for (w = 0; w < wi.grouping[i] && !clipping; w++)
clipping = FFMAX(clipping, clippings[i+w]);
wi.clipping[i] = clipping;
}
}
/* Determine grouping, based on the location of the first attack, and save for

View File

@ -1473,7 +1473,7 @@ void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int
int err;
if (id_aac != sbr->id_aac) {
av_log(ac->avctx, AV_LOG_ERROR,
av_log(ac->avctx, id_aac == TYPE_LFE ? AV_LOG_VERBOSE : AV_LOG_WARNING,
"element type mismatch %d != %d\n", id_aac, sbr->id_aac);
sbr_turnoff(sbr);
}

View File

@ -92,8 +92,8 @@ static inline void ff_aac_tableinit(void)
* Table of the LTP coefficients
*/
static const INTFLOAT ltp_coef[8] = {
Q30(0.570829f), Q30(0.696616f), Q30(0.813004f), Q30(0.911304f),
Q30(0.984900f), Q30(1.067894f), Q30(1.194601f), Q30(1.369533f),
Q30(0.570829), Q30(0.696616), Q30(0.813004), Q30(0.911304),
Q30(0.984900), Q30(1.067894), Q30(1.194601), Q30(1.369533),
};
/* @name tns_tmp2_map
@ -103,24 +103,24 @@ static const INTFLOAT ltp_coef[8] = {
* @{
*/
static const INTFLOAT tns_tmp2_map_1_3[4] = {
Q31(0.00000000f), Q31(-0.43388373f), Q31(0.64278758f), Q31(0.34202015f),
Q31(0.00000000), Q31(-0.43388373), Q31(0.64278758), Q31(0.34202015),
};
static const INTFLOAT tns_tmp2_map_0_3[8] = {
Q31(0.00000000f), Q31(-0.43388373f), Q31(-0.78183150f), Q31(-0.97492790f),
Q31(0.98480773f), Q31( 0.86602539f), Q31( 0.64278758f), Q31( 0.34202015f),
Q31(0.00000000), Q31(-0.43388373), Q31(-0.78183150), Q31(-0.97492790),
Q31(0.98480773), Q31( 0.86602539), Q31( 0.64278758), Q31( 0.34202015),
};
static const INTFLOAT tns_tmp2_map_1_4[8] = {
Q31(0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f),
Q31(0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f),
Q31(0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
Q31(0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
};
static const INTFLOAT tns_tmp2_map_0_4[16] = {
Q31( 0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f),
Q31(-0.74314481f), Q31(-0.86602539f), Q31(-0.95105654f), Q31(-0.99452192f),
Q31( 0.99573416f), Q31( 0.96182561f), Q31( 0.89516330f), Q31( 0.79801720f),
Q31( 0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f),
Q31( 0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
Q31(-0.74314481), Q31(-0.86602539), Q31(-0.95105654), Q31(-0.99452192),
Q31( 0.99573416), Q31( 0.96182561), Q31( 0.89516330), Q31( 0.79801720),
Q31( 0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
};
static const INTFLOAT * const tns_tmp2_map[4] = {

View File

@ -1,4 +1,4 @@
OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_init.o
# subsystems
OBJS-$(CONFIG_FFT) += aarch64/fft_init_aarch64.o
OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_init.o
OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o
@ -11,13 +11,20 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o
OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o
OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o
# decoders/encoders
OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_init.o
OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
OBJS-$(CONFIG_VC1_DECODER) += aarch64/vc1dsp_init_aarch64.o
OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_init.o
# ARMv8 optimizations
# subsystems
ARMV8-OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp.o
NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
# NEON optimizations
# subsystems
NEON-OBJS-$(CONFIG_FFT) += aarch64/fft_neon.o
NEON-OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_neon.o
NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o
@ -28,7 +35,9 @@ NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \
aarch64/hpeldsp_neon.o
NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
NEON-OBJS-$(CONFIG_IMDCT15) += aarch64/imdct15_neon.o
NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o
NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
# decoders/encoders
NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
NEON-OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_neon.o

View File

@ -20,7 +20,10 @@
#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/aarch64/cpu.h"
#include "libavcodec/fft.h"
void ff_fft_permute_neon(FFTContext *s, FFTComplex *z);

View File

@ -33,25 +33,25 @@ function ff_h264_idct_add_neon, export=1
sshr v17.4H, v3.4H, #1
st1 {v30.8H}, [x1], #16
sub v5.4H, v0.4H, v2.4H
add v6.4H, v1.4H, v17.4H
sub v7.4H, v16.4H, v3.4H
add v0.4H, v4.4H, v6.4H
add v1.4H, v5.4H, v7.4H
sub v3.4H, v4.4H, v6.4H
sub v2.4H, v5.4H, v7.4H
sub v6.4H, v16.4H, v3.4H
add v7.4H, v1.4H, v17.4H
add v0.4H, v4.4H, v7.4H
add v1.4H, v5.4H, v6.4H
sub v2.4H, v5.4H, v6.4H
sub v3.4H, v4.4H, v7.4H
transpose_4x4H v0, v1, v2, v3, v4, v5, v6, v7
add v4.4H, v0.4H, v3.4H
add v4.4H, v0.4H, v2.4H
ld1 {v18.S}[0], [x0], x2
sshr v16.4H, v2.4H, #1
sshr v16.4H, v3.4H, #1
sshr v17.4H, v1.4H, #1
ld1 {v19.S}[1], [x0], x2
sub v5.4H, v0.4H, v3.4H
ld1 {v18.S}[1], [x0], x2
sub v5.4H, v0.4H, v2.4H
ld1 {v19.S}[1], [x0], x2
add v6.4H, v16.4H, v1.4H
ins v4.D[1], v5.D[0]
sub v7.4H, v2.4H, v17.4H
sub v7.4H, v17.4H, v3.4H
ld1 {v19.S}[0], [x0], x2
ins v6.D[1], v7.D[0]
sub x0, x0, x2, lsl #2
@ -68,8 +68,8 @@ function ff_h264_idct_add_neon, export=1
sqxtun v1.8B, v1.8H
st1 {v0.S}[0], [x0], x2
st1 {v1.S}[1], [x0], x2
st1 {v0.S}[1], [x0], x2
st1 {v1.S}[1], [x0], x2
st1 {v1.S}[0], [x0], x2
sub x1, x1, #32

View File

@ -142,7 +142,7 @@ function ff_mpadsp_apply_window_\type\()_neon, export=1
sub x10, x10, #4<<2
b.gt 1b
// comuting samples[16]
// computing samples[16]
add x6, x1, #32<<2
ld1 {v0.2s}, [x6], x9
ld1 {v1.2s}, [x0], x9

View File

@ -107,12 +107,12 @@
.macro transpose_4x4H r0, r1, r2, r3, r4, r5, r6, r7
trn1 \r4\().4H, \r0\().4H, \r1\().4H
trn2 \r5\().4H, \r0\().4H, \r1\().4H
trn1 \r7\().4H, \r2\().4H, \r3\().4H
trn2 \r6\().4H, \r2\().4H, \r3\().4H
trn1 \r0\().2S, \r4\().2S, \r7\().2S
trn2 \r3\().2S, \r4\().2S, \r7\().2S
trn1 \r1\().2S, \r5\().2S, \r6\().2S
trn2 \r2\().2S, \r5\().2S, \r6\().2S
trn1 \r6\().4H, \r2\().4H, \r3\().4H
trn2 \r7\().4H, \r2\().4H, \r3\().4H
trn1 \r0\().2S, \r4\().2S, \r6\().2S
trn2 \r2\().2S, \r4\().2S, \r6\().2S
trn1 \r1\().2S, \r5\().2S, \r7\().2S
trn2 \r3\().2S, \r5\().2S, \r7\().2S
.endm
.macro transpose_8x8H r0, r1, r2, r3, r4, r5, r6, r7, r8, r9

View File

@ -23,7 +23,7 @@
#include "libavutil/aarch64/neontest.h"
wrap(avcodec_open2(AVCodecContext *avctx,
AVCodec *codec,
const AVCodec *codec,
AVDictionary **options))
{
testneonclobbers(avcodec_open2, avctx, codec, options);

View File

@ -1,6 +1,6 @@
/*
* Autodesk RLE Decoder
* Copyright (c) 2005 The FFmpeg Project
* Copyright (C) 2005 The FFmpeg project
*
* This file is part of FFmpeg.
*

View File

@ -1445,8 +1445,9 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
/* skip frame if CRC is ok. otherwise use error concealment. */
/* TODO: add support for substreams and dependent frames */
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
av_log(avctx, AV_LOG_WARNING, "unsupported frame type : "
"skipping frame\n");
av_log(avctx, AV_LOG_DEBUG,
"unsupported frame type %d: skipping frame\n",
s->frame_type);
*got_frame_ptr = 0;
return buf_size;
} else {

View File

@ -96,6 +96,8 @@ typedef struct AC3DecodeContext {
int lfe_mix_level_exists; ///< indicates if lfemixlevcod is specified (lfemixlevcode)
int lfe_mix_level; ///< LFE mix level index (lfemixlevcod)
int eac3; ///< indicates if current frame is E-AC-3
int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s)
int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s)
int dolby_surround_mode; ///< dolby surround mode (dsurmod)
int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod)
int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod)

View File

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "ac3.h"
#include "ac3dsp.h"

View File

@ -82,7 +82,6 @@ extern const int16_t ff_acelp_interp_filter[61];
* filter_coeffs contains coefficients of the right half of the symmetric
* interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient.
* See ff_acelp_interp_filter for an example.
*
*/
void ff_acelp_interpolate(int16_t* out, const int16_t* in,
const int16_t* filter_coeffs, int precision,

View File

@ -21,9 +21,8 @@
*/
#include "libavutil/common.h"
#include "libavutil/ffmath.h"
#include "libavutil/float_dsp.h"
#include "libavutil/internal.h"
#include "libavutil/libm.h"
#include "libavutil/mathematics.h"
#include "avcodec.h"
#include "acelp_pitch_delay.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2003 The FFmpeg Project
* Copyright (c) 2001-2003 The FFmpeg project
*
* first version by Francois Revol (revol@free.fr)
* fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
@ -107,9 +107,14 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
case AV_CODEC_ID_ADPCM_EA_XAS:
max_channels = 6;
break;
case AV_CODEC_ID_ADPCM_MTAF:
min_channels = 2;
max_channels = 8;
break;
case AV_CODEC_ID_ADPCM_PSX:
max_channels = 8;
break;
case AV_CODEC_ID_ADPCM_IMA_DAT4:
case AV_CODEC_ID_ADPCM_THP:
case AV_CODEC_ID_ADPCM_THP_LE:
max_channels = 14;
@ -144,6 +149,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
switch(avctx->codec->id) {
case AV_CODEC_ID_ADPCM_AICA:
case AV_CODEC_ID_ADPCM_IMA_DAT4:
case AV_CODEC_ID_ADPCM_IMA_QT:
case AV_CODEC_ID_ADPCM_IMA_WAV:
case AV_CODEC_ID_ADPCM_4XM:
@ -157,6 +163,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
case AV_CODEC_ID_ADPCM_AFC:
case AV_CODEC_ID_ADPCM_DTK:
case AV_CODEC_ID_ADPCM_PSX:
case AV_CODEC_ID_ADPCM_MTAF:
avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
break;
case AV_CODEC_ID_ADPCM_IMA_WS:
@ -170,7 +177,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
return 0;
}
static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
static inline int16_t adpcm_ima_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int shift)
{
int step_index;
int predictor;
@ -193,7 +200,7 @@ static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble,
c->predictor = av_clip_int16(predictor);
c->step_index = step_index;
return (short)c->predictor;
return (int16_t)c->predictor;
}
static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitContext *gb, int bps)
@ -245,7 +252,7 @@ static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble,
return c->predictor;
}
static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
static inline int16_t adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
{
int predictor;
@ -264,7 +271,7 @@ static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
return c->sample1;
}
static inline short adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
static inline int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
{
int step_index, predictor, sign, delta, diff, step;
@ -285,7 +292,7 @@ static inline short adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibbl
return c->predictor << 4;
}
static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
static inline int16_t adpcm_ct_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)
{
int sign, delta, diff;
int new_step;
@ -303,10 +310,10 @@ static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
new_step = (ff_adpcm_AdaptationTable[nibble & 7] * c->step) >> 8;
c->step = av_clip(new_step, 511, 32767);
return (short)c->predictor;
return (int16_t)c->predictor;
}
static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble, int size, int shift)
static inline int16_t adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, int8_t nibble, int size, int shift)
{
int sign, delta, diff;
@ -323,10 +330,10 @@ static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble
else if (delta == 0 && c->step > 0)
c->step--;
return (short) c->predictor;
return (int16_t) c->predictor;
}
static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
static inline int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
{
if(!c->step) {
c->predictor = 0;
@ -340,6 +347,15 @@ static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned c
return c->predictor;
}
static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
{
c->predictor += ff_adpcm_mtaf_stepsize[c->step][nibble];
c->predictor = av_clip_int16(c->predictor);
c->step += ff_adpcm_index_table[nibble];
c->step = av_clip_uintp2(c->step, 5);
return c->predictor;
}
static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1,
const uint8_t *in, ADPCMChannelStatus *left,
ADPCMChannelStatus *right, int channels, int sample_offset)
@ -450,7 +466,7 @@ static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_
// similar to IMA adpcm
int delta = get_bits(&gb, nb_bits);
int step = ff_adpcm_step_table[c->status[i].step_index];
long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
int vpdiff = 0; // vpdiff = (delta+0.5)*step/4
int k = k0;
do {
@ -533,6 +549,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
header_size = 0;
switch (avctx->codec->id) {
case AV_CODEC_ID_ADPCM_4XM:
case AV_CODEC_ID_ADPCM_IMA_DAT4:
case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break;
@ -614,6 +631,11 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = (buf_size - 6 * ch) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_MTAF:
if (avctx->block_align > 0)
buf_size = FFMIN(buf_size, avctx->block_align);
nb_samples = (buf_size - 16 * (ch / 2)) * 2 / ch;
break;
case AV_CODEC_ID_ADPCM_SBPRO_2:
case AV_CODEC_ID_ADPCM_SBPRO_3:
case AV_CODEC_ID_ADPCM_SBPRO_4:
@ -692,7 +714,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
ADPCMDecodeContext *c = avctx->priv_data;
ADPCMChannelStatus *cs;
int n, m, channel, i;
short *samples;
int16_t *samples;
int16_t **samples_p;
int st; /* stereo */
int count1, count2;
@ -710,7 +732,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
frame->nb_samples = nb_samples;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (short *)frame->data[0];
samples = (int16_t *)frame->data[0];
samples_p = (int16_t **)frame->extended_data;
/* use coded_samples when applicable */
@ -780,15 +802,23 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->bits_per_coded_sample != 4) {
int samples_per_block = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];
int block_size = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];
uint8_t temp[20] = { 0 };
GetBitContext g;
ret = init_get_bits8(&g, gb.buffer, bytestream2_get_bytes_left(&gb));
if (ret < 0)
return ret;
for (n = 0; n < (nb_samples - 1) / samples_per_block; n++) {
for (i = 0; i < avctx->channels; i++) {
int j;
cs = &c->status[i];
samples = &samples_p[i][1 + n * samples_per_block];
for (j = 0; j < block_size; j++) {
temp[j] = buf[4 * avctx->channels + block_size * n * avctx->channels +
(j % 4) + (j / 4) * (avctx->channels * 4) + i * 4];
}
ret = init_get_bits8(&g, (const uint8_t *)&temp, block_size);
if (ret < 0)
return ret;
for (m = 0; m < samples_per_block; m++) {
samples[m] = adpcm_ima_wav_expand_nibble(cs, &g,
avctx->bits_per_coded_sample);
@ -876,6 +906,27 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
break;
}
case AV_CODEC_ID_ADPCM_MTAF:
for (channel = 0; channel < avctx->channels; channel+=2) {
bytestream2_skipu(&gb, 4);
c->status[channel ].step = bytestream2_get_le16u(&gb);
c->status[channel + 1].step = bytestream2_get_le16u(&gb);
c->status[channel ].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
bytestream2_skipu(&gb, 2);
c->status[channel + 1].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
bytestream2_skipu(&gb, 2);
for (n = 0; n < nb_samples; n+=2) {
int v = bytestream2_get_byteu(&gb);
samples_p[channel][n ] = adpcm_mtaf_expand_nibble(&c->status[channel], v & 0x0F);
samples_p[channel][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel], v >> 4 );
}
for (n = 0; n < nb_samples; n+=2) {
int v = bytestream2_get_byteu(&gb);
samples_p[channel + 1][n ] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v & 0x0F);
samples_p[channel + 1][n + 1] = adpcm_mtaf_expand_nibble(&c->status[channel + 1], v >> 4 );
}
}
break;
case AV_CODEC_ID_ADPCM_IMA_DK4:
for (channel = 0; channel < avctx->channels; channel++) {
cs = &c->status[channel];
@ -984,6 +1035,18 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
*samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
}
break;
case AV_CODEC_ID_ADPCM_IMA_DAT4:
for (channel = 0; channel < avctx->channels; channel++) {
cs = &c->status[channel];
samples = samples_p[channel];
bytestream2_skip(&gb, 4);
for (n = 0; n < nb_samples; n += 2) {
int v = bytestream2_get_byteu(&gb);
*samples++ = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
*samples++ = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
}
}
break;
case AV_CODEC_ID_ADPCM_IMA_APC:
while (bytestream2_get_bytes_left(&gb) > 0) {
int v = bytestream2_get_byteu(&gb);
@ -1287,8 +1350,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
break;
case AV_CODEC_ID_ADPCM_IMA_AMV:
c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
c->status[0].step_index = bytestream2_get_le16u(&gb);
bytestream2_skipu(&gb, 4);
c->status[0].step_index = bytestream2_get_byteu(&gb);
bytestream2_skipu(&gb, 5);
if (c->status[0].step_index > 88u) {
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
c->status[0].step_index);
@ -1670,6 +1733,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3, sample_fmts_s16p, adpcm_ea_r3,
ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16p, adpcm_ea_xas, "ADPCM Electronic Arts XAS");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16, adpcm_ima_apc, "ADPCM IMA CRYO APC");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4, sample_fmts_s16, adpcm_ima_dat4, "ADPCM IMA Eurocom DAT4");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK3, sample_fmts_s16, adpcm_ima_dk3, "ADPCM IMA Duck DK3");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, "ADPCM IMA Duck DK4");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS");
@ -1682,6 +1746,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg,
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_s16, adpcm_ms, "ADPCM Microsoft");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_MTAF, sample_fmts_s16p, adpcm_mtaf, "ADPCM MTAF");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_PSX, sample_fmts_s16p, adpcm_psx, "ADPCM Playstation");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit");
ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, sample_fmts_s16, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2003 The FFmpeg Project
* Copyright (c) 2001-2003 The FFmpeg project
*
* This file is part of FFmpeg.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2003 The FFmpeg Project
* Copyright (c) 2001-2003 The FFmpeg project
*
* This file is part of FFmpeg.
*
@ -110,3 +110,70 @@ const int16_t ff_adpcm_afc_coeffs[2][16] = {
{ 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, 64512, 64512, 63488 },
{ 0, 0, 2048, 1024, 63488, 64000, 64512, 62976, 63288, 63236, 62464, 63488, 64512, 1024, 0, 0 }
};
const int16_t ff_adpcm_mtaf_stepsize[32][16] = {
{ 1, 5, 9, 13, 16, 20, 24, 28,
-1, -5, -9, -13, -16, -20, -24, -28, },
{ 2, 6, 11, 15, 20, 24, 29, 33,
-2, -6, -11, -15, -20, -24, -29, -33, },
{ 2, 7, 13, 18, 23, 28, 34, 39,
-2, -7, -13, -18, -23, -28, -34, -39, },
{ 3, 9, 15, 21, 28, 34, 40, 46,
-3, -9, -15, -21, -28, -34, -40, -46, },
{ 3, 11, 18, 26, 33, 41, 48, 56,
-3, -11, -18, -26, -33, -41, -48, -56, },
{ 4, 13, 22, 31, 40, 49, 58, 67,
-4, -13, -22, -31, -40, -49, -58, -67, },
{ 5, 16, 26, 37, 48, 59, 69, 80,
-5, -16, -26, -37, -48, -59, -69, -80, },
{ 6, 19, 31, 44, 57, 70, 82, 95,
-6, -19, -31, -44, -57, -70, -82, -95, },
{ 7, 22, 38, 53, 68, 83, 99, 114,
-7, -22, -38, -53, -68, -83, -99, -114, },
{ 9, 27, 45, 63, 81, 99, 117, 135,
-9, -27, -45, -63, -81, -99, -117, -135, },
{ 10, 32, 53, 75, 96, 118, 139, 161,
-10, -32, -53, -75, -96, -118, -139, -161, },
{ 12, 38, 64, 90, 115, 141, 167, 193,
-12, -38, -64, -90, -115, -141, -167, -193, },
{ 15, 45, 76, 106, 137, 167, 198, 228,
-15, -45, -76, -106, -137, -167, -198, -228, },
{ 18, 54, 91, 127, 164, 200, 237, 273,
-18, -54, -91, -127, -164, -200, -237, -273, },
{ 21, 65, 108, 152, 195, 239, 282, 326,
-21, -65, -108, -152, -195, -239, -282, -326, },
{ 25, 77, 129, 181, 232, 284, 336, 388,
-25, -77, -129, -181, -232, -284, -336, -388, },
{ 30, 92, 153, 215, 276, 338, 399, 461,
-30, -92, -153, -215, -276, -338, -399, -461, },
{ 36, 109, 183, 256, 329, 402, 476, 549,
-36, -109, -183, -256, -329, -402, -476, -549, },
{ 43, 130, 218, 305, 392, 479, 567, 654,
-43, -130, -218, -305, -392, -479, -567, -654, },
{ 52, 156, 260, 364, 468, 572, 676, 780,
-52, -156, -260, -364, -468, -572, -676, -780, },
{ 62, 186, 310, 434, 558, 682, 806, 930,
-62, -186, -310, -434, -558, -682, -806, -930, },
{ 73, 221, 368, 516, 663, 811, 958, 1106,
-73, -221, -368, -516, -663, -811, -958, -1106, },
{ 87, 263, 439, 615, 790, 966, 1142, 1318,
-87, -263, -439, -615, -790, -966, -1142, -1318, },
{ 104, 314, 523, 733, 942, 1152, 1361, 1571,
-104, -314, -523, -733, -942, -1152, -1361, -1571, },
{ 124, 374, 623, 873, 1122, 1372, 1621, 1871,
-124, -374, -623, -873, -1122, -1372, -1621, -1871, },
{ 148, 445, 743, 1040, 1337, 1634, 1932, 2229,
-148, -445, -743, -1040, -1337, -1634, -1932, -2229, },
{ 177, 531, 885, 1239, 1593, 1947, 2301, 2655,
-177, -531, -885, -1239, -1593, -1947, -2301, -2655, },
{ 210, 632, 1053, 1475, 1896, 2318, 2739, 3161,
-210, -632, -1053, -1475, -1896, -2318, -2739, -3161, },
{ 251, 753, 1255, 1757, 2260, 2762, 3264, 3766,
-251, -753, -1255, -1757, -2260, -2762, -3264, -3766, },
{ 299, 897, 1495, 2093, 2692, 3290, 3888, 4486,
-299, -897, -1495, -2093, -2692, -3290, -3888, -4486, },
{ 356, 1068, 1781, 2493, 3206, 3918, 4631, 5343,
-356, -1068, -1781, -2493, -3206, -3918, -4631, -5343, },
{ 424, 1273, 2121, 2970, 3819, 4668, 5516, 6365,
-424, -1273, -2121, -2970, -3819, -4668, -5516, -6365, },
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2003 The FFmpeg Project
* Copyright (c) 2001-2003 The FFmpeg project
*
* This file is part of FFmpeg.
*
@ -41,5 +41,6 @@ extern const int8_t ff_adpcm_AdaptCoeff2[];
extern const int16_t ff_adpcm_yamaha_indexscale[];
extern const int8_t ff_adpcm_yamaha_difflookup[];
extern const int16_t ff_adpcm_afc_coeffs[2][16];
extern const int16_t ff_adpcm_mtaf_stepsize[32][16];
#endif /* AVCODEC_ADPCM_DATA_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2003 The FFmpeg Project
* Copyright (c) 2001-2003 The FFmpeg project
*
* first version by Francois Revol (revol@free.fr)
* fringe ADPCM codecs (e.g., DK3, DK4, Westwood)

View File

@ -28,6 +28,7 @@
#include "get_bits.h"
#include "golomb.h"
#include "idctdsp.h"
#include "thread.h"
#include "unary.h"
#define AIC_HDR_SIZE 24
@ -375,6 +376,7 @@ static int aic_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
uint32_t off;
int x, y, ret;
int slice_size;
ThreadFrame frame = { .f = data };
ctx->frame = data;
ctx->frame->pict_type = AV_PICTURE_TYPE_I;
@ -393,7 +395,7 @@ static int aic_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return ret;
}
if ((ret = ff_get_buffer(avctx, ctx->frame, 0)) < 0)
if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
return ret;
bytestream2_init(&gb, buf + AIC_HDR_SIZE,
@ -488,5 +490,6 @@ AVCodec ff_aic_decoder = {
.init = aic_decode_init,
.close = aic_decode_close,
.decode = aic_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(aic_decode_init),
};

View File

@ -29,20 +29,20 @@
* passed through the extradata[_size] fields. This atom is tacked onto
* the end of an 'alac' stsd atom and has the following format:
*
* 32bit atom size
* 32bit tag ("alac")
* 32bit tag version (0)
* 32bit samples per frame (used when not set explicitly in the frames)
* 8bit compatible version (0)
* 8bit sample size
* 8bit history mult (40)
* 8bit initial history (10)
* 8bit rice param limit (14)
* 8bit channels
* 16bit maxRun (255)
* 32bit max coded frame size (0 means unknown)
* 32bit average bitrate (0 means unknown)
* 32bit samplerate
* 32 bits atom size
* 32 bits tag ("alac")
* 32 bits tag version (0)
* 32 bits samples per frame (used when not set explicitly in the frames)
* 8 bits compatible version (0)
* 8 bits sample size
* 8 bits history mult (40)
* 8 bits initial history (10)
* 8 bits rice param limit (14)
* 8 bits channels
* 16 bits maxRun (255)
* 32 bits max coded frame size (0 means unknown)
* 32 bits average bitrate (0 means unknown)
* 32 bits samplerate
*/
#include <inttypes.h>
@ -391,6 +391,12 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
*outbuffer++ = alac->output_samples_buffer[ch][i];
}}
break;
case 20: {
for (ch = 0; ch < channels; ch++) {
for (i = 0; i < alac->nb_samples; i++)
alac->output_samples_buffer[ch][i] <<= 12;
}}
break;
case 24: {
for (ch = 0; ch < channels; ch++) {
for (i = 0; i < alac->nb_samples; i++)
@ -556,6 +562,7 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
switch (alac->sample_size) {
case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
break;
case 20:
case 24:
case 32: avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
break;

View File

@ -81,7 +81,7 @@ typedef struct AlacEncodeContext {
static void init_sample_buffers(AlacEncodeContext *s, int channels,
uint8_t const *samples[2])
const uint8_t *samples[2])
{
int ch, i;
int shift = av_get_bytes_per_sample(s->avctx->sample_fmt) * 8 -
@ -364,7 +364,7 @@ static void write_element(AlacEncodeContext *s,
enum AlacRawDataBlockType element, int instance,
const uint8_t *samples0, const uint8_t *samples1)
{
uint8_t const *samples[2] = { samples0, samples1 };
const uint8_t *samples[2] = { samples0, samples1 };
int i, j, channels;
int prediction_type = 0;
PutBitContext *pb = &s->pbctx;
@ -376,14 +376,14 @@ static void write_element(AlacEncodeContext *s,
/* samples are channel-interleaved in verbatim mode */
if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S32P) {
int shift = 32 - s->avctx->bits_per_raw_sample;
int32_t const *samples_s32[2] = { (const int32_t *)samples0,
const int32_t *samples_s32[2] = { (const int32_t *)samples0,
(const int32_t *)samples1 };
for (i = 0; i < s->frame_size; i++)
for (j = 0; j < channels; j++)
put_sbits(pb, s->avctx->bits_per_raw_sample,
samples_s32[j][i] >> shift);
} else {
int16_t const *samples_s16[2] = { (const int16_t *)samples0,
const int16_t *samples_s16[2] = { (const int16_t *)samples0,
(const int16_t *)samples1 };
for (i = 0; i < s->frame_size; i++)
for (j = 0; j < channels; j++)

View File

@ -58,13 +58,6 @@
av_register_codec_parser(&ff_##x##_parser); \
}
#define REGISTER_BSF(X, x) \
{ \
extern AVBitStreamFilter ff_##x##_bsf; \
if (CONFIG_##X##_BSF) \
av_register_bitstream_filter(&ff_##x##_bsf); \
}
void avcodec_register_all(void)
{
static int initialized;
@ -76,6 +69,7 @@ void avcodec_register_all(void)
/* hardware accelerators */
REGISTER_HWACCEL(H263_VAAPI, h263_vaapi);
REGISTER_HWACCEL(H263_VIDEOTOOLBOX, h263_videotoolbox);
REGISTER_HWACCEL(H264_CUVID, h264_cuvid);
REGISTER_HWACCEL(H264_D3D11VA, h264_d3d11va);
REGISTER_HWACCEL(H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL(H264_MMAL, h264_mmal);
@ -85,6 +79,7 @@ void avcodec_register_all(void)
REGISTER_HWACCEL(H264_VDA_OLD, h264_vda_old);
REGISTER_HWACCEL(H264_VDPAU, h264_vdpau);
REGISTER_HWACCEL(H264_VIDEOTOOLBOX, h264_videotoolbox);
REGISTER_HWACCEL(HEVC_CUVID, hevc_cuvid);
REGISTER_HWACCEL(HEVC_D3D11VA, hevc_d3d11va);
REGISTER_HWACCEL(HEVC_DXVA2, hevc_dxva2);
REGISTER_HWACCEL(HEVC_QSV, hevc_qsv);
@ -105,12 +100,15 @@ void avcodec_register_all(void)
REGISTER_HWACCEL(MPEG4_VAAPI, mpeg4_vaapi);
REGISTER_HWACCEL(MPEG4_VDPAU, mpeg4_vdpau);
REGISTER_HWACCEL(MPEG4_VIDEOTOOLBOX, mpeg4_videotoolbox);
REGISTER_HWACCEL(VC1_CUVID, vc1_cuvid);
REGISTER_HWACCEL(VC1_D3D11VA, vc1_d3d11va);
REGISTER_HWACCEL(VC1_DXVA2, vc1_dxva2);
REGISTER_HWACCEL(VC1_VAAPI, vc1_vaapi);
REGISTER_HWACCEL(VC1_VDPAU, vc1_vdpau);
REGISTER_HWACCEL(VC1_MMAL, vc1_mmal);
REGISTER_HWACCEL(VC1_QSV, vc1_qsv);
REGISTER_HWACCEL(VP8_CUVID, vp8_cuvid);
REGISTER_HWACCEL(VP9_CUVID, vp9_cuvid);
REGISTER_HWACCEL(VP9_D3D11VA, vp9_d3d11va);
REGISTER_HWACCEL(VP9_DXVA2, vp9_dxva2);
REGISTER_HWACCEL(VP9_VAAPI, vp9_vaapi);
@ -196,6 +194,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (H263P, h263p);
REGISTER_DECODER(H264, h264);
REGISTER_DECODER(H264_CRYSTALHD, h264_crystalhd);
REGISTER_DECODER(H264_MEDIACODEC, h264_mediacodec);
REGISTER_DECODER(H264_MMAL, h264_mmal);
REGISTER_DECODER(H264_QSV, h264_qsv);
REGISTER_DECODER(H264_VDA, h264_vda);
@ -224,6 +223,8 @@ void avcodec_register_all(void)
REGISTER_DECODER(LAGARITH, lagarith);
REGISTER_ENCODER(LJPEG, ljpeg);
REGISTER_DECODER(LOCO, loco);
REGISTER_DECODER(M101, m101);
REGISTER_DECODER(MAGICYUV, magicyuv);
REGISTER_DECODER(MDEC, mdec);
REGISTER_DECODER(MIMIC, mimic);
REGISTER_ENCDEC (MJPEG, mjpeg);
@ -298,6 +299,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(SDX2_DPCM, sdx2_dpcm);
REGISTER_ENCDEC (SGI, sgi);
REGISTER_DECODER(SGIRLE, sgirle);
REGISTER_DECODER(SHEERVIDEO, sheervideo);
REGISTER_DECODER(SMACKER, smacker);
REGISTER_DECODER(SMC, smc);
REGISTER_DECODER(SMVJPEG, smvjpeg);
@ -316,6 +318,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(TMV, tmv);
REGISTER_DECODER(TRUEMOTION1, truemotion1);
REGISTER_DECODER(TRUEMOTION2, truemotion2);
REGISTER_DECODER(TRUEMOTION2RT, truemotion2rt);
REGISTER_DECODER(TSCC, tscc);
REGISTER_DECODER(TSCC2, tscc2);
REGISTER_DECODER(TXD, txd);
@ -367,6 +370,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(XL, xl);
REGISTER_ENCDEC (XWD, xwd);
REGISTER_ENCDEC (Y41P, y41p);
REGISTER_DECODER(YLC, ylc);
REGISTER_DECODER(YOP, yop);
REGISTER_ENCDEC (YUV4, yuv4);
REGISTER_DECODER(ZERO12V, zero12v);
@ -399,6 +403,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(DSD_MSBF_PLANAR, dsd_msbf_planar);
REGISTER_DECODER(DSICINAUDIO, dsicinaudio);
REGISTER_DECODER(DSS_SP, dss_sp);
REGISTER_DECODER(DST, dst);
REGISTER_ENCDEC (EAC3, eac3);
REGISTER_DECODER(EVRC, evrc);
REGISTER_DECODER(FFWAVESYNTH, ffwavesynth);
@ -514,6 +519,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(ADPCM_G726LE, adpcm_g726le);
REGISTER_DECODER(ADPCM_IMA_AMV, adpcm_ima_amv);
REGISTER_DECODER(ADPCM_IMA_APC, adpcm_ima_apc);
REGISTER_DECODER(ADPCM_IMA_DAT4, adpcm_ima_dat4);
REGISTER_DECODER(ADPCM_IMA_DK3, adpcm_ima_dk3);
REGISTER_DECODER(ADPCM_IMA_DK4, adpcm_ima_dk4);
REGISTER_DECODER(ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs);
@ -526,6 +532,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (ADPCM_IMA_WAV, adpcm_ima_wav);
REGISTER_DECODER(ADPCM_IMA_WS, adpcm_ima_ws);
REGISTER_ENCDEC (ADPCM_MS, adpcm_ms);
REGISTER_DECODER(ADPCM_MTAF, adpcm_mtaf);
REGISTER_DECODER(ADPCM_PSX, adpcm_psx);
REGISTER_DECODER(ADPCM_SBPRO_2, adpcm_sbpro_2);
REGISTER_DECODER(ADPCM_SBPRO_3, adpcm_sbpro_3);
@ -562,8 +569,22 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (XSUB, xsub);
/* external libraries */
REGISTER_ENCDEC (AAC_AT, aac_at);
REGISTER_DECODER(AC3_AT, ac3_at);
REGISTER_DECODER(ADPCM_IMA_QT_AT, adpcm_ima_qt_at);
REGISTER_ENCDEC (ALAC_AT, alac_at);
REGISTER_DECODER(AMR_NB_AT, amr_nb_at);
REGISTER_DECODER(EAC3_AT, eac3_at);
REGISTER_DECODER(GSM_MS_AT, gsm_ms_at);
REGISTER_ENCDEC (ILBC_AT, ilbc_at);
REGISTER_DECODER(MP1_AT, mp1_at);
REGISTER_DECODER(MP2_AT, mp2_at);
REGISTER_DECODER(MP3_AT, mp3_at);
REGISTER_ENCDEC (PCM_ALAW_AT, pcm_alaw_at);
REGISTER_ENCDEC (PCM_MULAW_AT, pcm_mulaw_at);
REGISTER_DECODER(QDMC_AT, qdmc_at);
REGISTER_DECODER(QDM2_AT, qdm2_at);
REGISTER_DECODER(LIBCELT, libcelt);
REGISTER_DECODER(LIBDCADEC, libdcadec)
REGISTER_ENCODER(LIBFAAC, libfaac);
REGISTER_ENCDEC (LIBFDK_AAC, libfdk_aac);
REGISTER_ENCDEC (LIBGSM, libgsm);
@ -579,7 +600,6 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (LIBSPEEX, libspeex);
REGISTER_ENCODER(LIBTHEORA, libtheora);
REGISTER_ENCODER(LIBTWOLAME, libtwolame);
REGISTER_ENCDEC (LIBUTVIDEO, libutvideo);
REGISTER_ENCODER(LIBVO_AMRWBENC, libvo_amrwbenc);
REGISTER_ENCDEC (LIBVORBIS, libvorbis);
REGISTER_ENCDEC (LIBVPX_VP8, libvpx_vp8);
@ -603,13 +623,27 @@ void avcodec_register_all(void)
/* external libraries, that shouldn't be used by default if one of the
* above is available */
REGISTER_ENCODER(LIBOPENH264, libopenh264);
REGISTER_DECODER(H264_CUVID, h264_cuvid);
REGISTER_ENCODER(H264_NVENC, h264_nvenc);
REGISTER_ENCODER(H264_OMX, h264_omx);
REGISTER_ENCODER(H264_QSV, h264_qsv);
REGISTER_ENCODER(H264_VAAPI, h264_vaapi);
REGISTER_ENCODER(H264_VIDEOTOOLBOX, h264_videotoolbox);
#if FF_API_NVENC_OLD_NAME
REGISTER_ENCODER(NVENC, nvenc);
REGISTER_ENCODER(NVENC_H264, nvenc_h264);
REGISTER_ENCODER(NVENC_HEVC, nvenc_hevc);
#endif
REGISTER_DECODER(HEVC_CUVID, hevc_cuvid);
REGISTER_ENCODER(HEVC_NVENC, hevc_nvenc);
REGISTER_ENCODER(HEVC_QSV, hevc_qsv);
REGISTER_ENCODER(HEVC_VAAPI, hevc_vaapi);
REGISTER_ENCODER(LIBKVAZAAR, libkvazaar);
REGISTER_ENCODER(MJPEG_VAAPI, mjpeg_vaapi);
REGISTER_ENCODER(MPEG2_QSV, mpeg2_qsv);
REGISTER_DECODER(VC1_CUVID, vc1_cuvid);
REGISTER_DECODER(VP8_CUVID, vp8_cuvid);
REGISTER_DECODER(VP9_CUVID, vp9_cuvid);
/* parsers */
REGISTER_PARSER(AAC, aac);
@ -650,20 +684,4 @@ void avcodec_register_all(void)
REGISTER_PARSER(VP3, vp3);
REGISTER_PARSER(VP8, vp8);
REGISTER_PARSER(VP9, vp9);
/* bitstream filters */
REGISTER_BSF(AAC_ADTSTOASC, aac_adtstoasc);
REGISTER_BSF(CHOMP, chomp);
REGISTER_BSF(DUMP_EXTRADATA, dump_extradata);
REGISTER_BSF(H264_MP4TOANNEXB, h264_mp4toannexb);
REGISTER_BSF(HEVC_MP4TOANNEXB, hevc_mp4toannexb);
REGISTER_BSF(IMX_DUMP_HEADER, imx_dump_header);
REGISTER_BSF(MJPEG2JPEG, mjpeg2jpeg);
REGISTER_BSF(MJPEGA_DUMP_HEADER, mjpega_dump_header);
REGISTER_BSF(MP3_HEADER_DECOMPRESS, mp3_header_decompress);
REGISTER_BSF(MPEG4_UNPACK_BFRAMES, mpeg4_unpack_bframes);
REGISTER_BSF(MOV2TEXTSUB, mov2textsub);
REGISTER_BSF(NOISE, noise);
REGISTER_BSF(REMOVE_EXTRADATA, remove_extradata);
REGISTER_BSF(TEXT2MOVSUB, text2movsub);
}

View File

@ -729,7 +729,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
quant_cof[k] = decode_rice(gb, rice_param) + offset;
if (quant_cof[k] < -64 || quant_cof[k] > 63) {
av_log(avctx, AV_LOG_ERROR,
"quant_cof %"PRIu32" is out of range.\n",
"quant_cof %"PRId32" is out of range.\n",
quant_cof[k]);
return AVERROR_INVALIDDATA;
}
@ -765,8 +765,13 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
bd->ltp_gain[0] = decode_rice(gb, 1) << 3;
bd->ltp_gain[1] = decode_rice(gb, 2) << 3;
r = get_unary(gb, 0, 3);
r = get_unary(gb, 0, 4);
c = get_bits(gb, 2);
if (r >= 4) {
av_log(avctx, AV_LOG_ERROR, "r overflow\n");
return AVERROR_INVALIDDATA;
}
bd->ltp_gain[2] = ltp_gain_values[r][c];
bd->ltp_gain[3] = decode_rice(gb, 2) << 3;
@ -867,9 +872,6 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
*current_res++ = decode_rice(gb, s[sb]);
}
if (!sconf->mc_coding || ctx->js_switch)
align_get_bits(gb);
return 0;
}
@ -989,6 +991,7 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
{
int ret;
GetBitContext *gb = &ctx->gb;
ALSSpecificConfig *sconf = &ctx->sconf;
*bd->shift_lsbs = 0;
// read block type flag and read the samples accordingly
@ -998,6 +1001,9 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
ret = read_const_block_data(ctx, bd);
}
if (!sconf->mc_coding || ctx->js_switch)
align_get_bits(gb);
return ret;
}
@ -1292,13 +1298,13 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
if (ch[dep].time_diff_sign) {
t = -t;
if (begin < t) {
av_log(ctx->avctx, AV_LOG_ERROR, "begin %td smaller than time diff index %d.\n", begin, t);
av_log(ctx->avctx, AV_LOG_ERROR, "begin %"PTRDIFF_SPECIFIER" smaller than time diff index %d.\n", begin, t);
return AVERROR_INVALIDDATA;
}
begin -= t;
} else {
if (end < t) {
av_log(ctx->avctx, AV_LOG_ERROR, "end %td smaller than time diff index %d.\n", end, t);
av_log(ctx->avctx, AV_LOG_ERROR, "end %"PTRDIFF_SPECIFIER" smaller than time diff index %d.\n", end, t);
return AVERROR_INVALIDDATA;
}
end -= t;

View File

@ -547,13 +547,13 @@ static void decode_fixed_sparse(AMRFixed *fixed_sparse, const uint16_t *pulses,
* @param p the context
* @param subframe unpacked amr subframe
* @param mode mode of the current frame
* @param fixed_sparse sparse respresentation of the fixed vector
* @param fixed_sparse sparse representation of the fixed vector
*/
static void pitch_sharpening(AMRContext *p, int subframe, enum Mode mode,
AMRFixed *fixed_sparse)
{
// The spec suggests the current pitch gain is always used, but in other
// modes the pitch and codebook gains are joinly quantized (sec 5.8.2)
// modes the pitch and codebook gains are jointly quantized (sec 5.8.2)
// so the codebook gain cannot depend on the quantized pitch gain.
if (mode == MODE_12k2)
p->beta = FFMIN(p->pitch_gain[4], 1.0);

View File

@ -38,7 +38,7 @@
#define MIN_ISF_SPACING (128.0 / 32768.0) ///< minimum isf gap
#define PRED_FACTOR (1.0 / 3.0)
#define MIN_ENERGY -14.0 ///< initial innnovation energy (dB)
#define MIN_ENERGY -14.0 ///< initial innovation energy (dB)
#define ENERGY_MEAN 30.0 ///< mean innovation energy (dB) in all modes
#define PREEMPH_FAC 0.68 ///< factor used to de-emphasize synthesis

View File

@ -151,7 +151,6 @@ static int decode_mime_header(AMRWBContext *ctx, const uint8_t *buf)
*
* @param[in] ind Array of 5 indexes
* @param[out] isf_q Buffer for isf_q[LP_ORDER]
*
*/
static void decode_isf_indices_36b(uint16_t *ind, float *isf_q)
{
@ -178,7 +177,6 @@ static void decode_isf_indices_36b(uint16_t *ind, float *isf_q)
*
* @param[in] ind Array of 7 indexes
* @param[out] isf_q Buffer for isf_q[LP_ORDER]
*
*/
static void decode_isf_indices_46b(uint16_t *ind, float *isf_q)
{
@ -212,7 +210,6 @@ static void decode_isf_indices_46b(uint16_t *ind, float *isf_q)
*
* @param[in,out] isf_q Current quantized ISF
* @param[in,out] isf_past Past quantized ISF
*
*/
static void isf_add_mean_and_past(float *isf_q, float *isf_past)
{

View File

@ -206,7 +206,7 @@ static int execute_code(AVCodecContext * avctx, int c)
s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
break;
case 'h': //set creen mode
case 'h': //set screen mode
case 'l': //reset screen mode
if (s->nb_args < 2)
s->args[0] = DEFAULT_SCREEN_MODE;

View File

@ -339,10 +339,10 @@ static inline void range_dec_normalize(APEContext *ctx)
}
/**
* Calculate culmulative frequency for next symbol. Does NO update!
* Calculate cumulative frequency for next symbol. Does NO update!
* @param ctx decoder context
* @param tot_f is the total frequency or (code_value)1<<shift
* @return the culmulative frequency
* @return the cumulative frequency
*/
static inline int range_decode_culfreq(APEContext *ctx, int tot_f)
{
@ -1284,8 +1284,16 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
/* Update the adaption coefficients */
absres = FFABS(res);
if (absres)
*f->adaptcoeffs = ((res & INT32_MIN) ^ (-(1<<30))) >>
(25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
*f->adaptcoeffs = APESIGN(res) *
(8 << ((absres > f->avg * 3) + (absres > f->avg * 4 / 3)));
/* equivalent to the following code
if (absres <= f->avg * 4 / 3)
*f->adaptcoeffs = APESIGN(res) * 8;
else if (absres <= f->avg * 3)
*f->adaptcoeffs = APESIGN(res) * 16;
else
*f->adaptcoeffs = APESIGN(res) * 32;
*/
else
*f->adaptcoeffs = 0;

View File

@ -7,7 +7,10 @@ OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_arm.o
OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_arm.o
OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o \
arm/fft_fixed_init_arm.o
OBJS-$(CONFIG_FLACDSP) += arm/flacdsp_init_arm.o \
arm/flacdsp_arm.o
OBJS-$(CONFIG_FMTCONVERT) += arm/fmtconvert_init_arm.o
OBJS-$(CONFIG_G722DSP) += arm/g722dsp_init_arm.o
OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o
OBJS-$(CONFIG_H264DSP) += arm/h264dsp_init_arm.o
OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o
@ -18,9 +21,6 @@ OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_arm.o \
arm/idctdsp_arm.o \
arm/jrevdct_arm.o \
arm/simple_idct_arm.o
OBJS-$(CONFIG_FLACDSP) += arm/flacdsp_init_arm.o \
arm/flacdsp_arm.o
OBJS-$(CONFIG_G722DSP) += arm/g722dsp_init_arm.o
OBJS-$(CONFIG_LLAUDDSP) += arm/lossless_audiodsp_init_arm.o
OBJS-$(CONFIG_ME_CMP) += arm/me_cmp_init_arm.o
OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o
@ -28,7 +28,9 @@ OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o
OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_init_arm.o
OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o
OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_init_arm.o
OBJS-$(CONFIG_RDFT) += arm/rdft_init_arm.o
OBJS-$(CONFIG_RV34DSP) += arm/rv34dsp_init_arm.o
OBJS-$(CONFIG_VC1DSP) += arm/vc1dsp_init_arm.o
OBJS-$(CONFIG_VIDEODSP) += arm/videodsp_init_arm.o
OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_init_arm.o
OBJS-$(CONFIG_VP8DSP) += arm/vp8dsp_init_arm.o
@ -40,7 +42,6 @@ OBJS-$(CONFIG_DCA_DECODER) += arm/synth_filter_init_arm.o
OBJS-$(CONFIG_HEVC_DECODER) += arm/hevcdsp_init_arm.o
OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o
OBJS-$(CONFIG_RV40_DECODER) += arm/rv40dsp_init_arm.o
OBJS-$(CONFIG_VC1_DECODER) += arm/vc1dsp_init_arm.o
OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_init_arm.o
OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_init_arm.o
@ -70,13 +71,13 @@ ARMV6-OBJS-$(CONFIG_ME_CMP) += arm/me_cmp_armv6.o
ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o
ARMV6-OBJS-$(CONFIG_MPEGVIDEOENC) += arm/mpegvideoencdsp_armv6.o
ARMV6-OBJS-$(CONFIG_PIXBLOCKDSP) += arm/pixblockdsp_armv6.o
ARMV6-OBJS-$(CONFIG_STARTCODE) += arm/startcode_armv6.o
ARMV6-OBJS-$(CONFIG_VP8DSP) += arm/vp8_armv6.o \
arm/vp8dsp_init_armv6.o \
arm/vp8dsp_armv6.o
# decoders/encoders
ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o
ARMV6-OBJS-$(CONFIG_STARTCODE) += arm/startcode_armv6.o
# VFP optimizations
@ -118,6 +119,8 @@ NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \
arm/mdct_fixed_neon.o
NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o
NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o
NEON-OBJS-$(CONFIG_VC1DSP) += arm/vc1dsp_init_neon.o \
arm/vc1dsp_neon.o
NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o
NEON-OBJS-$(CONFIG_VP8DSP) += arm/vp8dsp_init_neon.o \
arm/vp8dsp_neon.o
@ -134,7 +137,5 @@ NEON-OBJS-$(CONFIG_HEVC_DECODER) += arm/hevcdsp_init_neon.o \
NEON-OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_neon.o
NEON-OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_neon.o \
arm/rv40dsp_neon.o
NEON-OBJS-$(CONFIG_VC1_DECODER) += arm/vc1dsp_init_neon.o \
arm/vc1dsp_neon.o
NEON-OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_neon.o
NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_neon.o

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/arm/cpu.h"
#define FFT_FLOAT 0

View File

@ -18,10 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/arm/cpu.h"
#include "libavcodec/fft.h"
#include "libavcodec/rdft.h"
#include "libavcodec/synth_filter.h"
void ff_fft_calc_vfp(FFTContext *s, FFTComplex *z);
@ -34,8 +35,6 @@ void ff_imdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input
void ff_imdct_half_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
void ff_mdct_calc_neon(FFTContext *s, FFTSample *output, const FFTSample *input);
void ff_rdft_calc_neon(struct RDFTContext *s, FFTSample *z);
av_cold void ff_fft_init_arm(FFTContext *s)
{
int cpu_flags = av_get_cpu_flags();
@ -60,13 +59,3 @@ av_cold void ff_fft_init_arm(FFTContext *s)
#endif
}
}
#if CONFIG_RDFT
av_cold void ff_rdft_init_arm(RDFTContext *s)
{
int cpu_flags = av_get_cpu_flags();
if (have_neon(cpu_flags))
s->rdft_calc = ff_rdft_calc_neon;
}
#endif

View File

@ -240,7 +240,7 @@ DAT3 .req v4
DAT4 .req v5
DAT5 .req v6
DAT6 .req sl // use these rather than the otherwise unused
DAT7 .req fp // ip and lr so that we can load them usinf LDRD
DAT7 .req fp // ip and lr so that we can load them using LDRD
.macro output4words tail, head, r0, r1, r2, r3, r4, r5, r6, r7, pointer_dead=0
.if \head

View File

@ -29,7 +29,7 @@ void ff_dct_unquantize_h263_armv5te(int16_t *block, int qmul, int qadd, int coun
#ifdef ENABLE_ARM_TESTS
/**
* h263 dequantizer supplementary function, it is performance critical and needs to
* H.263 dequantizer supplementary function, it is performance critical and needs to
* have optimized implementations for each architecture. Is also used as a reference
* implementation in regression tests
*/

View File

@ -23,7 +23,7 @@
#include "libavutil/arm/neontest.h"
wrap(avcodec_open2(AVCodecContext *avctx,
AVCodec *codec,
const AVCodec *codec,
AVDictionary **options))
{
testneonclobbers(avcodec_open2, avctx, codec, options);

View File

@ -0,0 +1,33 @@
/*
* 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/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/arm/cpu.h"
#include "libavcodec/rdft.h"
void ff_rdft_calc_neon(struct RDFTContext *s, FFTSample *z);
av_cold void ff_rdft_init_arm(RDFTContext *s)
{
int cpu_flags = av_get_cpu_flags();
if (have_neon(cpu_flags))
s->rdft_calc = ff_rdft_calc_neon;
}

View File

@ -64,7 +64,7 @@ function ff_simple_idct_arm, export=1
__row_loop:
@@ read the row and check if it is null, almost null, or not, according to strongarm specs, it is not necessary to optimize ldr accesses (i.e. split 32bits in 2 16bits words), at least it gives more usable registers :)
@@ read the row and check if it is null, almost null, or not, according to strongarm specs, it is not necessary to optimize ldr accesses (i.e. split 32 bits in two 16-bit words), at least it gives more usable registers :)
ldr r1, [r14, #0] @ R1=(int32)(R12)[0]=ROWr32[0] (relative row cast to a 32b pointer)
ldr r2, [r14, #4] @ R2=(int32)(R12)[1]=ROWr32[1]
ldr r3, [r14, #8] @ R3=ROWr32[2]
@ -234,8 +234,8 @@ __end_a_evaluation:
@@ row[7] = (a0 - b0) >> ROW_SHIFT;
add r8, r6, r0 @ R8=a0+b0
add r9, r2, r1 @ R9=a1+b1
@@ put 2 16 bits half-words in a 32bits word
@@ ROWr32[0]=ROWr16[0] | (ROWr16[1]<<16) (only Little Endian compliant then!!!)
@@ put two 16-bit half-words in a 32-bit word
@@ ROWr32[0]=ROWr16[0] | (ROWr16[1]<<16) (only little-endian compliant then!!!)
ldr r10, =MASK_MSHW @ R10=0xFFFF0000
and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a1+b1)<<5)
mvn r11, r10 @ R11= NOT R10= 0x0000FFFF

View File

@ -322,7 +322,7 @@ endfunc
vmov.i16 q12, #3
vsubl.s8 q10, d8, d6 @ QS0 - PS0
vsubl.s8 q11, d9, d7 @ (widened to 16bit)
vsubl.s8 q11, d9, d7 @ (widened to 16 bits)
veor q2, q2, q13 @ PS1 = P1 ^ 0x80
veor q5, q5, q13 @ QS1 = Q1 ^ 0x80
vmul.i16 q10, q10, q12 @ w = 3 * (QS0 - PS0)

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