From a518647af4a7056f4b7d111aef68a130cead64b3 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Sat, 29 Oct 2016 18:39:40 +0200 Subject: [PATCH] New upstream version 3.2 --- CONTRIBUTING.md | 4 + Changelog | 149 +- LICENSE.md | 2 - MAINTAINERS | 24 +- README.md | 3 +- RELEASE | 2 +- RELEASE_NOTES | 6 +- VERSION | 2 +- cmdutils.c | 13 +- common.mak | 9 +- compat/avisynth/avisynth_c.h | 246 +- compat/cuda/cuviddec.h | 827 +++++ compat/cuda/nvcuvid.h | 321 ++ compat/nvenc/nvEncodeAPI.h | 3219 +++++++++++++++++ configure | 241 +- doc/APIchanges | 57 + doc/Doxyfile | 2420 ++++++++----- doc/Makefile | 4 +- doc/bitstream_filters.texi | 2 +- doc/codecs.texi | 73 +- doc/decoders.texi | 2 +- doc/demuxers.texi | 53 +- doc/developer.texi | 130 +- doc/encoders.texi | 143 +- doc/examples/http_multiclient.c | 6 +- doc/faq.texi | 14 +- doc/ffmpeg.texi | 11 +- doc/ffprobe.texi | 2 +- doc/ffprobe.xsd | 3 + doc/ffserver.conf | 2 +- doc/filters.texi | 1447 ++++++-- doc/formats.texi | 4 + doc/general.texi | 21 +- doc/indevs.texi | 26 + doc/libav-merge.txt | 98 + doc/muxers.texi | 174 +- doc/patchwork | 10 + doc/platform.texi | 2 +- doc/protocols.texi | 17 +- doc/t2h.init | 2 +- doc/t2h.pm | 2 +- ffmpeg.c | 1103 +++--- ffmpeg.h | 30 +- ffmpeg_cuvid.c | 130 +- ffmpeg_filter.c | 34 +- ffmpeg_opt.c | 285 +- ffmpeg_qsv.c | 3 +- ffmpeg_vaapi.c | 2 +- ffplay.c | 604 ++-- ffprobe.c | 29 +- libavcodec/8bps.c | 13 +- libavcodec/Makefile | 44 +- libavcodec/aaccoder.c | 195 +- libavcodec/aaccoder_trellis.h | 2 +- libavcodec/aaccoder_twoloop.h | 4 +- libavcodec/aacenc.c | 12 +- libavcodec/aacenc.h | 8 +- libavcodec/aacenc_is.c | 6 +- libavcodec/aacenc_ltp.c | 4 +- libavcodec/aacenc_pred.c | 6 +- libavcodec/aacenc_quantization.h | 4 +- libavcodec/aacenc_utils.h | 15 +- libavcodec/aarch64/Makefile | 2 +- libavcodec/aarch64/h264cmc_neon.S | 2 +- libavcodec/aarch64/neontest.c | 20 + libavcodec/ac3.c | 3 +- libavcodec/ac3.h | 2 +- libavcodec/ac3dec.c | 9 +- libavcodec/ac3dec.h | 4 + libavcodec/adpcm.c | 4 +- libavcodec/alacenc.c | 4 +- libavcodec/allcodecs.c | 28 +- libavcodec/alsdec.c | 292 +- libavcodec/arm/h264cmc_neon.S | 2 +- libavcodec/arm/neontest.c | 20 + libavcodec/ass_split.c | 70 +- libavcodec/audiotoolboxdec.c | 5 + libavcodec/avcodec.h | 212 +- libavcodec/avpacket.c | 3 +- libavcodec/avrndec.c | 2 +- libavcodec/bink.c | 6 +- libavcodec/binkaudio.c | 15 +- libavcodec/bsf.c | 326 +- libavcodec/bsf.h | 11 + libavcodec/cabac.c | 2 +- libavcodec/cavsdec.c | 3 + libavcodec/ccaption_dec.c | 46 +- libavcodec/cfhd.c | 2 +- libavcodec/codec_desc.c | 91 +- libavcodec/crystalhd.c | 177 +- libavcodec/cuvid.c | 460 ++- libavcodec/dds.c | 38 +- libavcodec/dirac_vlc.c | 247 ++ libavcodec/dirac_vlc.h | 51 + libavcodec/diracdec.c | 244 +- libavcodec/diracdsp.c | 24 + libavcodec/diracdsp.h | 4 + libavcodec/diractab.h | 2 + libavcodec/dnxhddata.c | 48 +- libavcodec/dnxhddata.h | 33 +- libavcodec/dnxhddec.c | 26 +- libavcodec/dnxhdenc.c | 207 +- libavcodec/dnxhdenc.h | 10 +- libavcodec/dv.c | 1 - libavcodec/dv.h | 2 +- libavcodec/dvbsub_parser.c | 8 +- libavcodec/dvdsubdec.c | 7 +- libavcodec/dvenc.c | 2 + libavcodec/dxtory.c | 5 +- libavcodec/dxva2.c | 15 +- libavcodec/dxva2_h264.c | 3 +- libavcodec/dxva2_internal.h | 3 - libavcodec/eac3dec.c | 14 +- libavcodec/eatgq.c | 8 +- libavcodec/eatgv.c | 9 +- libavcodec/escape124.c | 5 +- libavcodec/escape130.c | 3 +- libavcodec/exr.c | 198 +- libavcodec/ffjni.c | 47 +- libavcodec/ffjni.h | 15 +- libavcodec/ffv1.c | 9 +- libavcodec/ffv1.h | 46 +- libavcodec/ffv1_template.c | 53 + libavcodec/ffv1dec.c | 156 +- libavcodec/ffv1dec_template.c | 164 + libavcodec/ffv1enc.c | 217 +- libavcodec/ffv1enc_template.c | 196 + libavcodec/flacenc.c | 4 +- libavcodec/g723_1dec.c | 9 +- libavcodec/gif.c | 2 +- libavcodec/gifdec.c | 4 + libavcodec/gsmdec_data.c | 7 + libavcodec/gsmdec_data.h | 1 + libavcodec/gsmdec_template.c | 9 +- libavcodec/h263.c | 1 - libavcodec/h264.h | 987 +---- libavcodec/h264_cabac.c | 9 +- libavcodec/h264_cavlc.c | 6 +- libavcodec/h264_direct.c | 3 +- libavcodec/h264_loopfilter.c | 33 +- libavcodec/h264_mb.c | 3 +- libavcodec/h264_mc_template.c | 2 +- libavcodec/h264_mvpred.h | 2 +- libavcodec/h264_parse.c | 16 +- libavcodec/h264_parse.h | 15 +- libavcodec/h264_parser.c | 78 +- libavcodec/h264_picture.c | 5 +- libavcodec/h264_ps.c | 45 +- libavcodec/h264_ps.h | 164 + libavcodec/h264_refs.c | 339 +- libavcodec/h264_sei.c | 6 +- libavcodec/h264_slice.c | 1196 +++--- libavcodec/h264data.c | 2 +- libavcodec/h264data.h | 2 +- libavcodec/{h264.c => h264dec.c} | 291 +- libavcodec/h264dec.h | 862 +++++ libavcodec/h264dsp.h | 5 +- libavcodec/h264dsp_template.c | 4 +- libavcodec/h264idct_template.c | 2 +- libavcodec/hapdec.c | 1 - libavcodec/hevc.c | 3 + libavcodec/hevc.h | 9 + libavcodec/hevc_filter.c | 1 - libavcodec/hevc_parse.c | 134 + libavcodec/hevc_parse.h | 33 + libavcodec/hevc_ps.c | 36 + libavcodec/hq_hqa.c | 1 + libavcodec/hq_hqa.h | 2 +- libavcodec/huffman.c | 2 +- libavcodec/iff.c | 34 +- libavcodec/imgconvert.c | 8 - libavcodec/indeo2.c | 3 +- libavcodec/indeo2data.h | 39 - libavcodec/indeo4.c | 4 +- libavcodec/internal.h | 1 + libavcodec/interplayacm.c | 3 +- libavcodec/interplayvideo.c | 12 +- libavcodec/intrax8.c | 2 +- libavcodec/ituh263enc.c | 1 - libavcodec/ivi.c | 3 +- libavcodec/ivi_dsp.c | 8 +- libavcodec/libavcodec.v | 14 +- libavcodec/libfaac.c | 248 -- libavcodec/libmp3lame.c | 27 +- libavcodec/libopenh264.c | 62 + libavcodec/libopenh264.h | 39 + libavcodec/libopenh264dec.c | 249 ++ libavcodec/libopenh264enc.c | 80 +- libavcodec/libopusenc.c | 204 +- libavcodec/libschroedingerdec.c | 7 +- libavcodec/libvpx.c | 3 + libavcodec/libvpxdec.c | 137 +- libavcodec/libvpxenc.c | 71 +- libavcodec/libx264.c | 2 +- libavcodec/libx265.c | 12 + libavcodec/lpc.c | 13 +- libavcodec/lpc.h | 2 +- libavcodec/magicyuv.c | 290 +- libavcodec/me_cmp.c | 76 + libavcodec/me_cmp.h | 1 + libavcodec/mediacodec.c | 125 + libavcodec/mediacodec.h | 88 + libavcodec/mediacodec_surface.c | 56 + libavcodec/mediacodec_surface.h | 31 + libavcodec/mediacodec_sw_buffer.c | 2 +- libavcodec/mediacodec_sw_buffer.h | 2 +- libavcodec/mediacodec_wrapper.c | 231 +- libavcodec/mediacodec_wrapper.h | 2 +- libavcodec/mediacodecdec.c | 1041 +++--- libavcodec/mediacodecdec_common.c | 789 ++++ ...mediacodecdec.h => mediacodecdec_common.h} | 28 +- libavcodec/mediacodecdec_h264.c | 336 -- libavcodec/metasound.c | 5 +- libavcodec/mips/blockdsp_mmi.c | 139 +- libavcodec/mips/h264chroma_mips.h | 2 +- libavcodec/mips/h264chroma_mmi.c | 193 +- libavcodec/mips/h264dsp_mips.h | 28 +- libavcodec/mips/h264dsp_mmi.c | 2130 ++++++----- libavcodec/mips/h264dsp_msa.c | 12 +- libavcodec/mips/h264pred_mmi.c | 259 +- libavcodec/mips/h264qpel_mmi.c | 777 ++-- libavcodec/mips/hpeldsp_mmi.c | 549 ++- libavcodec/mips/idctdsp_mmi.c | 130 +- libavcodec/mips/mpegvideo_mmi.c | 112 +- libavcodec/mips/pixblockdsp_mmi.c | 87 +- libavcodec/mjpeg_parser.c | 2 +- libavcodec/mjpegdec.c | 17 +- libavcodec/mlp.c | 21 + libavcodec/mlp.h | 40 + libavcodec/mlpenc.c | 2416 +++++++++++++ libavcodec/mlz.c | 192 + libavcodec/mlz.h | 70 + libavcodec/mmaldec.c | 27 +- libavcodec/motion_est.c | 1 + libavcodec/mpc.c | 1 - libavcodec/mpc.h | 3 +- libavcodec/mpeg12.c | 1 - libavcodec/mpeg12dec.c | 27 +- libavcodec/mpeg12vlc.h | 2 +- libavcodec/mpeg4_unpack_bframes_bsf.c | 12 +- libavcodec/mpegvideo.h | 3 +- libavcodec/mpegvideo_enc.c | 2 + libavcodec/msgsmdec.c | 3 +- libavcodec/msmpeg4data.h | 3 +- libavcodec/msmpeg4dec.c | 51 - libavcodec/mss2.c | 3 - libavcodec/nellymoser.c | 7 +- libavcodec/nellymoserdec.c | 6 +- libavcodec/nvenc.c | 285 +- libavcodec/nvenc.h | 21 +- libavcodec/nvenc_h264.c | 138 +- libavcodec/nvenc_hevc.c | 132 +- libavcodec/omx.c | 2 +- libavcodec/on2avc.c | 16 +- libavcodec/options_table.h | 5 + libavcodec/opus.c | 13 +- libavcodec/parser.c | 5 + libavcodec/pcm.c | 11 +- libavcodec/pnmdec.c | 6 +- libavcodec/ppc/asm.S | 8 +- libavcodec/ppc/fft_altivec.S | 26 +- libavcodec/ppc/h264dsp.c | 2 +- libavcodec/profiles.c | 12 + libavcodec/profiles.h | 1 + libavcodec/psymodel.h | 2 +- libavcodec/qdm2.c | 126 +- libavcodec/qsvdec.c | 82 +- libavcodec/qsvdec_h2645.c | 144 +- libavcodec/qsvenc_h264.c | 6 +- libavcodec/ra144enc.c | 2 +- libavcodec/ra288.c | 11 +- libavcodec/raw.c | 9 + libavcodec/rawdec.c | 11 + libavcodec/rawenc.c | 8 + libavcodec/remove_extradata_bsf.c | 2 +- libavcodec/rscc.c | 19 +- libavcodec/screenpresso.c | 4 +- libavcodec/sheervideo.c | 11 +- libavcodec/sipr.c | 4 +- libavcodec/smacker.c | 8 +- libavcodec/snowenc.c | 2 + libavcodec/svq1enc.c | 9 +- libavcodec/svq1enc.h | 3 +- libavcodec/svq3.c | 37 +- libavcodec/tak.c | 2 + libavcodec/tak.h | 3 +- libavcodec/tak_parser.c | 3 +- libavcodec/takdec.c | 6 +- libavcodec/tests/avfft.c | 40 +- libavcodec/tests/fft-fixed.c | 1 + libavcodec/tests/fft-fixed32.c | 1 + libavcodec/tests/fft.c | 205 +- libavcodec/tiertexseqv.c | 2 +- libavcodec/tiff.c | 1 + libavcodec/truemotion2rt.c | 153 +- libavcodec/tscc2.c | 2 +- libavcodec/tta.c | 14 +- libavcodec/ttadsp.c | 14 +- libavcodec/ttadsp.h | 7 +- libavcodec/ttaenc.c | 38 +- libavcodec/ttaencdsp.c | 59 + libavcodec/ttaencdsp.h | 33 + libavcodec/utils.c | 143 +- libavcodec/utvideo.h | 1 + libavcodec/utvideodec.c | 30 + libavcodec/utvideoenc.c | 22 +- libavcodec/vaapi_encode.c | 30 +- libavcodec/vaapi_encode.h | 4 + libavcodec/vaapi_encode_h264.c | 368 +- libavcodec/vaapi_encode_h265.c | 5 +- libavcodec/vaapi_h264.c | 3 +- libavcodec/vble.c | 3 +- libavcodec/vc1data.h | 4 +- libavcodec/vc2enc.c | 9 +- libavcodec/vda.c | 5 + libavcodec/vda_h264.c | 2 +- libavcodec/vda_h264_dec.c | 2 +- libavcodec/vdpau.c | 2 +- libavcodec/vdpau_compat.h | 2 +- libavcodec/vdpau_h264.c | 3 +- libavcodec/vdpau_internal.h | 10 +- libavcodec/version.h | 4 +- libavcodec/videotoolbox.c | 2 +- libavcodec/videotoolboxenc.c | 361 +- libavcodec/vorbis.c | 27 +- libavcodec/vorbisdec.c | 12 +- libavcodec/vp5.c | 1 - libavcodec/vp9.c | 10 +- libavcodec/wavpack.c | 6 +- libavcodec/webp.c | 5 +- libavcodec/x86/Makefile | 4 + libavcodec/x86/aacencdsp.asm | 86 + libavcodec/x86/aacencdsp_init.c | 43 + libavcodec/x86/cabac.h | 20 +- libavcodec/x86/dcadsp.asm | 43 +- libavcodec/x86/diracdsp.asm | 82 + libavcodec/x86/diracdsp_init.c | 8 + libavcodec/x86/h264_i386.h | 12 +- libavcodec/x86/h264_idct.asm | 21 + libavcodec/x86/h264_idct_10bit.asm | 8 + libavcodec/x86/h264_qpel.c | 2 +- libavcodec/x86/h264_weight.asm | 12 +- libavcodec/x86/h264dsp_init.c | 8 +- libavcodec/x86/hpeldsp_rnd_template.c | 56 +- libavcodec/x86/me_cmp_init.c | 44 +- libavcodec/x86/mpegvideo.c | 88 +- libavcodec/x86/mpegvideoenc_template.c | 36 +- libavcodec/x86/rnd_template.c | 44 +- libavcodec/x86/snowdsp.c | 180 +- libavcodec/x86/ttadsp.asm | 2 +- libavcodec/x86/ttadsp_init.c | 16 +- libavcodec/x86/ttaencdsp.asm | 119 + libavcodec/x86/ttaencdsp_init.c | 42 + libavcodec/x86/vc1dsp_mmx.c | 6 +- libavcodec/x86/vp9dsp_init.c | 10 + libavcodec/x86/vp9itxfm.asm | 434 ++- libavcodec/x86/vp9lpf.asm | 238 +- libavcodec/x86/vp9lpf_16bpp.asm | 2 +- libavcodec/x86/w64xmmtest.c | 20 + libavcodec/xan.c | 3 +- libavcodec/xxan.c | 5 +- libavdevice/Makefile | 2 +- libavdevice/alldevices.c | 2 +- libavdevice/avdevice.h | 12 +- libavdevice/decklink_common.cpp | 139 +- libavdevice/decklink_common.h | 29 + libavdevice/decklink_common_c.h | 13 + libavdevice/decklink_dec.cpp | 184 +- libavdevice/decklink_dec.h | 2 +- libavdevice/decklink_dec_c.c | 29 +- libavdevice/decklink_enc.cpp | 85 +- libavdevice/dshow_filter.c | 4 +- libavdevice/dv1394.c | 4 +- libavdevice/jack.c | 10 - libavdevice/libavdevice.v | 9 +- libavdevice/libdc1394.c | 11 +- libavdevice/openal-dec.c | 13 +- libavdevice/opengl_enc.c | 109 +- libavdevice/sdl.c | 377 -- libavdevice/sdl2.c | 365 ++ libavdevice/version.h | 4 +- libavfilter/Makefile | 60 +- libavfilter/af_acrusher.c | 362 ++ libavfilter/af_adelay.c | 10 +- libavfilter/af_amerge.c | 2 +- libavfilter/af_amix.c | 4 +- libavfilter/af_astats.c | 157 +- libavfilter/af_atempo.c | 3 +- libavfilter/af_crystalizer.c | 153 + libavfilter/af_dynaudnorm.c | 24 +- libavfilter/af_firequalizer.c | 235 +- libavfilter/af_hdcd.c | 890 ++++- libavfilter/af_pan.c | 2 +- libavfilter/af_stereowiden.c | 27 +- libavfilter/allfilters.c | 30 +- libavfilter/audio.c | 1 - libavfilter/avf_avectorscope.c | 126 +- libavfilter/avf_concat.c | 3 +- libavfilter/avf_showcqt.c | 182 +- libavfilter/avf_showcqt.h | 5 + libavfilter/avf_showfreqs.c | 10 +- libavfilter/avf_showspectrum.c | 313 +- libavfilter/avf_showvolume.c | 43 +- libavfilter/avf_showwaves.c | 44 + libavfilter/avfilter.c | 25 +- libavfilter/avfilter.h | 11 +- libavfilter/avfiltergraph.c | 8 + libavfilter/buffersrc.h | 1 - libavfilter/drawutils.c | 12 +- libavfilter/drawutils.h | 8 +- libavfilter/f_drawgraph.c | 172 +- libavfilter/f_ebur128.c | 2 +- libavfilter/f_metadata.c | 70 +- libavfilter/f_sidedata.c | 181 + libavfilter/fifo.c | 6 +- libavfilter/internal.h | 6 + libavfilter/libavfilter.v | 9 +- libavfilter/motion_estimation.c | 432 +++ libavfilter/motion_estimation.h | 87 + libavfilter/tests/integral.c | 90 + libavfilter/vaf_spectrumsynth.c | 2 + libavfilter/version.h | 2 +- libavfilter/vf_atadenoise.c | 24 +- libavfilter/vf_avgblur.c | 326 ++ libavfilter/vf_bitplanenoise.c | 227 ++ libavfilter/vf_blend.c | 2 +- libavfilter/vf_bwdif.c | 2 +- libavfilter/vf_chromakey.c | 2 +- libavfilter/vf_colorkey.c | 2 +- libavfilter/vf_colormatrix.c | 8 +- libavfilter/vf_colorspace.c | 74 +- libavfilter/vf_convolution.c | 645 +++- libavfilter/vf_crop.c | 21 +- libavfilter/vf_curves.c | 370 +- libavfilter/vf_datascope.c | 101 +- libavfilter/vf_dctdnoiz.c | 4 +- libavfilter/vf_deband.c | 2 +- libavfilter/vf_drawtext.c | 2 +- libavfilter/vf_fade.c | 8 +- libavfilter/vf_gblur.c | 367 ++ libavfilter/vf_hflip.c | 13 +- libavfilter/vf_histogram.c | 27 +- libavfilter/vf_hqx.c | 2 +- libavfilter/vf_hysteresis.c | 401 ++ libavfilter/vf_lenscorrection.c | 2 +- libavfilter/vf_lut.c | 17 +- libavfilter/vf_lut2.c | 379 ++ libavfilter/vf_lut3d.c | 2 +- libavfilter/vf_maskedclamp.c | 345 ++ libavfilter/vf_maskedmerge.c | 4 +- libavfilter/vf_mestimate.c | 377 ++ libavfilter/vf_minterpolate.c | 1243 +++++++ libavfilter/vf_nlmeans.c | 551 +++ libavfilter/vf_noise.c | 2 +- libavfilter/vf_overlay.c | 439 ++- libavfilter/vf_owdenoise.c | 46 +- libavfilter/vf_palettegen.c | 25 +- libavfilter/vf_paletteuse.c | 13 +- libavfilter/vf_perspective.c | 2 +- libavfilter/vf_psnr.c | 41 +- libavfilter/vf_remap.c | 84 +- libavfilter/vf_removegrain.c | 2 +- libavfilter/vf_rotate.c | 173 +- libavfilter/vf_scale_npp.c | 16 +- libavfilter/vf_selectivecolor.c | 270 +- libavfilter/vf_shuffleframes.c | 15 +- libavfilter/vf_signalstats.c | 467 ++- libavfilter/vf_stereo3d.c | 2 +- libavfilter/vf_swapuv.c | 14 + libavfilter/vf_transpose.c | 2 +- libavfilter/vf_unsharp.c | 6 +- libavfilter/vf_uspp.c | 8 +- libavfilter/vf_vaguedenoiser.c | 583 +++ libavfilter/vf_vflip.c | 10 + libavfilter/vf_w3fdif.c | 2 +- libavfilter/vf_waveform.c | 25 +- libavfilter/vf_weave.c | 151 + libavfilter/vf_xbr.c | 2 +- libavfilter/vf_yadif.c | 2 +- libavfilter/vf_zoompan.c | 15 +- libavfilter/vf_zscale.c | 43 +- libavfilter/vsrc_testsrc.c | 176 + libavfilter/window_func.c | 56 + libavfilter/window_func.h | 4 +- libavfilter/x86/avf_showcqt.asm | 17 +- libavfilter/x86/vf_noise.c | 40 +- libavformat/Makefile | 9 +- libavformat/aacdec.c | 2 +- libavformat/aiff.h | 1 + libavformat/aiffdec.c | 15 +- libavformat/aiffenc.c | 3 +- libavformat/allformats.c | 5 +- libavformat/asfdec_f.c | 2 +- libavformat/asfdec_o.c | 2 +- libavformat/asfenc.c | 2 +- libavformat/astdec.c | 2 +- libavformat/avformat.h | 99 +- libavformat/avidec.c | 12 +- libavformat/avienc.c | 2 +- libavformat/avio_internal.h | 2 + libavformat/aviobuf.c | 14 +- libavformat/avisynth.c | 208 +- libavformat/avlanguage.c | 11 +- libavformat/avlanguage.h | 7 + libavformat/bink.c | 2 +- libavformat/cinedec.c | 2 +- libavformat/concatdec.c | 24 +- libavformat/crypto.c | 119 +- libavformat/dashenc.c | 92 +- libavformat/dcstr.c | 8 +- libavformat/dnxhddec.c | 2 +- libavformat/dvenc.c | 1 + libavformat/fifo.c | 660 ++++ libavformat/flvdec.c | 1 + libavformat/flvenc.c | 77 +- libavformat/hls.c | 186 +- libavformat/hlsenc.c | 239 +- libavformat/http.c | 21 +- libavformat/httpauth.c | 4 +- libavformat/id3v2.c | 45 + libavformat/img2.c | 1 - libavformat/img2dec.c | 3 +- libavformat/img2enc.c | 4 +- libavformat/internal.h | 38 +- libavformat/isom.c | 12 +- libavformat/isom.h | 12 +- libavformat/ivfenc.c | 7 + libavformat/libavformat.v | 34 +- libavformat/libopenmpt.c | 206 ++ libavformat/matroska.h | 26 +- libavformat/matroskadec.c | 87 +- libavformat/matroskaenc.c | 623 ++-- libavformat/mmsh.c | 9 + libavformat/mov.c | 847 ++++- libavformat/movenc.c | 373 +- libavformat/movenc.h | 5 + libavformat/mp3enc.c | 34 +- libavformat/mpegts.c | 50 +- libavformat/mpegtsenc.c | 13 +- libavformat/msf.c | 12 + libavformat/mux.c | 231 +- libavformat/mxfdec.c | 274 +- libavformat/mxfenc.c | 10 +- libavformat/nut.c | 9 + libavformat/oggenc.c | 136 +- libavformat/oggparsevp8.c | 2 +- libavformat/options.c | 1 + libavformat/options_table.h | 4 +- libavformat/pcmdec.c | 34 +- libavformat/protocols.c | 1 + libavformat/psxstr.c | 2 +- libavformat/rawenc.c | 25 +- libavformat/riff.c | 5 + libavformat/riffenc.c | 5 +- libavformat/rmdec.c | 5 +- libavformat/rsd.c | 4 +- libavformat/rtmphttp.c | 9 + libavformat/rtmpproto.c | 47 +- libavformat/rtpdec.c | 7 +- libavformat/rtpdec_formats.h | 4 + libavformat/rtpdec_g726.c | 8 +- libavformat/rtsp.c | 11 +- libavformat/sdp.c | 2 +- libavformat/segment.c | 104 +- libavformat/swfdec.c | 12 +- libavformat/takdec.c | 5 +- libavformat/tee.c | 222 +- libavformat/tee_common.c | 68 + libavformat/tee_common.h | 30 + libavformat/teeproto.c | 147 + libavformat/tests/fifo_muxer.c | 443 +++ libavformat/tests/movenc.c | 39 +- libavformat/tls_openssl.c | 163 +- libavformat/tta.c | 10 +- libavformat/ttaenc.c | 149 + libavformat/udp.c | 6 +- libavformat/utils.c | 259 +- libavformat/version.h | 10 +- libavformat/webm_chunk.c | 20 +- libavformat/westwood_aud.c | 6 + libavresample/avresample.h | 2 +- libavresample/libavresample.v | 8 +- libavresample/version.h | 2 +- libavutil/Makefile | 3 + libavutil/adler32.h | 13 +- libavutil/audio_fifo.c | 3 +- libavutil/avassert.h | 9 + libavutil/avutil.h | 20 +- libavutil/crc.h | 16 +- libavutil/dict.c | 17 + libavutil/dynarray.h | 2 +- libavutil/frame.c | 19 +- libavutil/frame.h | 11 +- libavutil/hash.h | 191 +- libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_cuda.c | 37 +- libavutil/hwcontext_internal.h | 1 + libavutil/hwcontext_qsv.c | 791 ++++ libavutil/hwcontext_qsv.h | 53 + libavutil/hwcontext_vaapi.c | 190 +- libavutil/hwcontext_vdpau.c | 1 + libavutil/internal.h | 10 + libavutil/libavutil.v | 8 +- libavutil/log.h | 2 +- libavutil/mathematics.h | 143 +- libavutil/md5.h | 10 +- libavutil/mem.c | 8 +- libavutil/mem.h | 752 ++-- libavutil/mips/mmiutils.h | 241 ++ libavutil/murmur3.h | 82 + libavutil/parseutils.c | 1 + libavutil/pixdesc.c | 80 +- libavutil/pixdesc.h | 194 +- libavutil/pixfmt.h | 25 +- libavutil/rational.h | 119 +- libavutil/ripemd.h | 10 +- libavutil/samplefmt.c | 2 + libavutil/samplefmt.h | 2 + libavutil/sha.h | 18 +- libavutil/sha512.h | 21 +- libavutil/softfloat_ieee754.h | 115 + libavutil/tests/fifo.c | 39 +- libavutil/timestamp.h | 2 +- libavutil/tree.h | 2 +- libavutil/utils.c | 13 + libavutil/version.h | 37 +- libavutil/x86/asm.h | 66 +- libavutil/x86/cpu.c | 4 +- libavutil/x86/emms.h | 2 + libavutil/x86/x86util.asm | 69 +- libpostproc/libpostproc.v | 9 +- libpostproc/postprocess.h | 4 +- libpostproc/postprocess_template.c | 644 ++-- libpostproc/version.h | 2 +- library.mak | 3 + libswresample/audioconvert.c | 22 + libswresample/dither.c | 14 +- libswresample/libswresample.v | 9 +- libswresample/options.c | 2 +- libswresample/rematrix.c | 182 +- libswresample/resample.c | 4 +- libswresample/swresample.c | 18 +- libswresample/swresample.h | 36 +- libswresample/swresample_internal.h | 4 +- libswresample/version.h | 2 +- libswscale/libswscale.v | 9 +- libswscale/output.c | 100 +- libswscale/swscale.c | 63 +- libswscale/swscale.h | 4 +- libswscale/swscale_unscaled.c | 109 +- libswscale/tests/swscale.c | 9 + libswscale/utils.c | 4 +- libswscale/version.h | 2 +- libswscale/x86/hscale_fast_bilinear_simd.c | 124 +- libswscale/x86/rgb2rgb_template.c | 386 +- libswscale/x86/swscale.c | 34 +- libswscale/x86/swscale_template.c | 446 +-- tests/Makefile | 4 + tests/api/api-h264-test.c | 2 +- tests/api/api-seek-test.c | 10 +- tests/audiomatch.c | 2 +- tests/checkasm/Makefile | 27 +- tests/checkasm/checkasm.c | 5 +- tests/checkasm/checkasm.h | 3 + tests/checkasm/h264dsp.c | 232 ++ tests/checkasm/pixblockdsp.c | 6 +- tests/checkasm/vp9dsp.c | 2 +- tests/fate-run.sh | 21 +- tests/fate/aac.mak | 10 +- tests/fate/acodec.mak | 4 +- tests/fate/apng.mak | 10 + tests/fate/avformat.mak | 3 + tests/fate/canopus.mak | 34 + tests/fate/dnxhd.mak | 14 +- tests/fate/ffmpeg.mak | 58 +- tests/fate/fft.mak | 33 +- tests/fate/fifo-muxer.mak | 20 + tests/fate/filter-audio.mak | 90 + tests/fate/filter-video.mak | 21 + tests/fate/h264.mak | 10 +- tests/fate/hevc.mak | 11 + tests/fate/image.mak | 145 +- tests/fate/libswresample.mak | 8 + tests/fate/lossless-video.mak | 12 - tests/fate/matroska.mak | 2 +- tests/fate/mov.mak | 28 + tests/fate/mxf.mak | 32 +- tests/fate/qt.mak | 3 +- tests/fate/seek.mak | 5 + tests/fate/vcodec.mak | 67 +- tests/fate/video.mak | 57 +- tests/fate/vpx.mak | 58 +- tests/fate/wavpack.mak | 4 +- tests/filtergraphs/compand | 1 + tests/filtergraphs/firequalizer | 27 + tests/filtergraphs/hstack | 1 + tests/filtergraphs/vstack | 1 + tests/lavf-regression.sh | 12 + tests/ref/acodec/tta | 4 +- tests/ref/fate/adtstoasc_ticket3715 | 94 + tests/ref/fate/apng-clock | 45 + tests/ref/fate/apng-osample | 11 + tests/ref/fate/binsub-mksenc | 2 +- tests/ref/fate/cavs | 1 - .../ref/fate/concat-demuxer-extended-lavf-mxf | 2 +- .../fate/concat-demuxer-extended-lavf-mxf_d10 | 2 +- .../ref/fate/concat-demuxer-simple1-lavf-mxf | 206 +- .../fate/concat-demuxer-simple1-lavf-mxf_d10 | 144 +- tests/ref/fate/concat-demuxer-simple2-lavf-ts | 302 +- tests/ref/fate/copy-psp | 287 ++ tests/ref/fate/copy-trac2211-avi | 54 + tests/ref/fate/copy-trac236 | 24 + tests/ref/fate/copy-trac4914 | 48 + tests/ref/fate/copy-trac4914-avi | 72 + tests/ref/fate/dnxhd-mbaff | 2 +- tests/ref/fate/dnxhr-12bit | 6 + tests/ref/fate/dnxhr-prefix1 | 10 + tests/ref/fate/dnxhr-prefix2 | 10 + tests/ref/fate/dnxhr-prefix3 | 10 + tests/ref/fate/dnxhr-prefix4 | 10 + tests/ref/fate/dnxhr-prefix5 | 10 + .../exr-rgb-scanline-b44-half-float-12x8-l1 | 6 + .../exr-rgb-scanline-b44-half-float-12x8-l2 | 6 + .../fate/exr-rgb-scanline-pxr24-float-half-l1 | 6 + .../fate/exr-rgb-scanline-pxr24-float-half-l2 | 6 + .../fate/exr-rgb-scanline-pxr24-half-float-l1 | 6 + .../fate/exr-rgb-scanline-pxr24-half-float-l2 | 6 + .../fate/exr-rgb-scanline-raw-half-float-l1 | 6 + .../fate/exr-rgb-scanline-raw-half-float-l2 | 6 + .../fate/exr-rgb-scanline-rle-half-float-l1 | 6 + .../fate/exr-rgb-scanline-rle-half-float-l2 | 6 + .../fate/exr-rgb-scanline-zip-half-float-l1 | 6 + .../fate/exr-rgb-scanline-zip-half-float-l2 | 6 + .../fate/exr-rgb-scanline-zip1-half-float-l1 | 6 + .../fate/exr-rgb-scanline-zip1-half-float-l2 | 6 + .../fate/exr-rgb-tile-half-float-b44-12x8-l1 | 6 + .../fate/exr-rgb-tile-half-float-b44-12x8-l2 | 6 + .../ref/fate/exr-rgb-tile-pxr24-float-half-l1 | 6 + .../ref/fate/exr-rgb-tile-pxr24-float-half-l2 | 6 + .../ref/fate/exr-rgb-tile-pxr24-half-float-l1 | 6 + .../ref/fate/exr-rgb-tile-pxr24-half-float-l2 | 6 + tests/ref/fate/exr-rgb-tile-raw-half-float-l1 | 6 + tests/ref/fate/exr-rgb-tile-raw-half-float-l2 | 6 + tests/ref/fate/exr-rgb-tile-rle-half-float-l1 | 6 + tests/ref/fate/exr-rgb-tile-rle-half-float-l2 | 6 + tests/ref/fate/exr-rgb-tile-zip-half-float-l1 | 6 + tests/ref/fate/exr-rgb-tile-zip-half-float-l2 | 6 + .../ref/fate/exr-rgb-tile-zip1-half-float-l1 | 6 + .../ref/fate/exr-rgb-tile-zip1-half-float-l2 | 6 + .../exr-rgba-scanline-float-half-b44-12x8-l1 | 6 + .../exr-rgba-scanline-float-half-b44-12x8-l2 | 6 + .../exr-rgba-scanline-float-half-b44-13x9-l1 | 6 + .../exr-rgba-scanline-float-half-b44-13x9-l2 | 6 + .../exr-rgba-scanline-float-half-b44a-12x8-l1 | 6 + .../exr-rgba-scanline-float-half-b44a-12x8-l2 | 6 + .../exr-rgba-scanline-float-half-b44a-13x9-l1 | 6 + .../exr-rgba-scanline-float-half-b44a-13x9-l2 | 6 + tests/ref/fate/ffmpeg-bsf-remove-e | 32 + tests/ref/fate/ffmpeg-bsf-remove-k | 33 + tests/ref/fate/ffmpeg-bsf-remove-r | 32 + tests/ref/fate/ffprobe_compact | 34 +- tests/ref/fate/ffprobe_csv | 34 +- tests/ref/fate/ffprobe_default | 33 +- tests/ref/fate/ffprobe_flat | 33 +- tests/ref/fate/ffprobe_ini | 33 +- tests/ref/fate/ffprobe_json | 37 +- tests/ref/fate/ffprobe_xml | 34 +- tests/ref/fate/fifo | 43 + tests/ref/fate/fifo-muxer-tst | 11 + tests/ref/fate/filter-asetnsamples | 522 +++ tests/ref/fate/filter-asetrate | 25 + tests/ref/fate/filter-chorus | 15 + tests/ref/fate/filter-compand | 25 + tests/ref/fate/filter-dcshift | 25 + tests/ref/fate/filter-earwax | 25 + tests/ref/fate/filter-extrastereo | 25 + tests/ref/fate/filter-fps-cfr | 1 - tests/ref/fate/filter-hls-append | 1156 ++++++ tests/ref/fate/filter-hstack | 55 + tests/ref/fate/filter-pixdesc-gbrap | 2 +- tests/ref/fate/filter-pixdesc-gbrp10be | 2 +- tests/ref/fate/filter-pixdesc-gbrp10le | 2 +- tests/ref/fate/filter-pixdesc-gbrp12be | 2 +- tests/ref/fate/filter-pixdesc-gbrp12le | 2 +- tests/ref/fate/filter-pixdesc-gbrp14be | 2 +- tests/ref/fate/filter-pixdesc-gbrp14le | 2 +- tests/ref/fate/filter-pixdesc-gbrp9be | 2 +- tests/ref/fate/filter-pixdesc-gbrp9le | 2 +- tests/ref/fate/filter-pixdesc-p010be | 1 + tests/ref/fate/filter-pixdesc-p010le | 1 + tests/ref/fate/filter-pixfmts-copy | 20 +- tests/ref/fate/filter-pixfmts-crop | 20 +- tests/ref/fate/filter-pixfmts-field | 20 +- tests/ref/fate/filter-pixfmts-fieldorder | 18 +- tests/ref/fate/filter-pixfmts-hflip | 20 +- tests/ref/fate/filter-pixfmts-il | 20 +- tests/ref/fate/filter-pixfmts-lut | 6 + tests/ref/fate/filter-pixfmts-null | 20 +- tests/ref/fate/filter-pixfmts-pad | 10 +- tests/ref/fate/filter-pixfmts-rotate | 16 +- tests/ref/fate/filter-pixfmts-scale | 20 +- tests/ref/fate/filter-pixfmts-vflip | 20 +- tests/ref/fate/filter-shuffleframes | 53 + tests/ref/fate/filter-silenceremove | 35 + tests/ref/fate/filter-stereotools | 25 + tests/ref/fate/filter-swaprect | 55 + tests/ref/fate/filter-tremolo | 25 + tests/ref/fate/filter-vstack | 55 + tests/ref/fate/filter-weave | 30 + tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 6 +- tests/ref/fate/gaplessenc-pcm-to-mov-aac | 6 +- tests/ref/fate/gsm-toast | 1001 ++--- tests/ref/fate/h264-3386 | 52 + tests/ref/fate/h264-invalid-ref-mod | 20 +- tests/ref/fate/h264-skip-nointra | 54 + tests/ref/fate/h264-skip-nokey | 54 + tests/ref/fate/h264_mp4toannexb_ticket2991 | 127 + tests/ref/fate/jpg-12bpp | 6 + tests/ref/fate/jpg-jfif | 6 + tests/ref/fate/magicyuv-rgb | 6 + tests/ref/fate/magicyuv-rgba | 6 + tests/ref/fate/magicyuv-y400i | 6 + tests/ref/fate/magicyuv-y420 | 6 + tests/ref/fate/magicyuv-y422i | 6 + tests/ref/fate/magicyuv-y444 | 6 + tests/ref/fate/magicyuv-y4444i | 6 + tests/ref/fate/mov-1elist-1ctts | 57 + tests/ref/fate/mov-1elist-ends-last-bframe | 56 + tests/ref/fate/mov-1elist-noctts | 57 + tests/ref/fate/mov-2elist-elist1-ends-bframe | 51 + tests/ref/fate/mov-3elist | 57 + tests/ref/fate/mov-3elist-1ctts | 57 + .../ref/fate/mov-elist-starts-ctts-2ndsample | 57 + tests/ref/fate/movenc | 5 + tests/ref/fate/mpeg2-ticket186 | 356 ++ tests/ref/fate/mpeg4-bsf-unpack-bframes | 2 +- tests/ref/fate/mxf-metadata-source-ref1 | 13 + tests/ref/fate/mxf-metadata-source-ref2 | 13 + tests/ref/fate/mxf-multiple-components-demux | 11 + tests/ref/fate/mxf-probe-d10 | 108 + tests/ref/fate/mxf-probe-dnxhd | 182 + tests/ref/fate/mxf-probe-dv25 | 149 + tests/ref/fate/pcm_s16be-stereo | 2 +- tests/ref/fate/png-int-rgb24 | 6 + tests/ref/fate/png-rgba64 | 6 + tests/ref/fate/quickdraw | 12 +- tests/ref/fate/rgb24-mkv | 8 + tests/ref/fate/source | 3 + tests/ref/fate/sub-cc | 4 +- tests/ref/fate/sub-cc-realtime | 60 +- tests/ref/fate/svq3-watermark | 14 + tests/ref/fate/truemotion2rt-high | 6 + tests/ref/fate/truemotion2rt-low | 6 + tests/ref/fate/truemotion2rt-mid | 6 + tests/ref/fate/tscc2-mov | 20 +- tests/ref/fate/webp-rgb-lena-lossless | 6 + tests/ref/fate/webp-rgb-lena-lossless-rgb24 | 6 + tests/ref/fate/webp-rgb-lossless | 6 + tests/ref/fate/webp-rgb-lossy-q80 | 6 + tests/ref/fate/webp-rgba-lossless | 6 + tests/ref/fate/webp-rgba-lossy-q80 | 6 + tests/ref/lavf-fate/mov_qtrle_mace6 | 2 +- tests/ref/lavf-fate/ogg_vp8 | 3 + tests/ref/lavf/dpx | 8 +- tests/ref/lavf/mka | 3 + tests/ref/lavf/mkv | 8 +- tests/ref/lavf/tta | 3 + tests/ref/seek/acodec-adpcm-swf | 46 +- tests/ref/seek/acodec-adpcm-swf-trellis | 46 +- tests/ref/seek/lavf-flv_fmt | 36 +- tests/ref/seek/lavf-mkv | 44 +- tests/ref/seek/mkv-codec-delay | 48 + tests/ref/seek/vsynth_lena-dnxhd-4k-hr-lb | 40 + tests/ref/seek/vsynth_lena-flashsv | 40 +- tests/ref/seek/vsynth_lena-flv | 40 +- tests/ref/vsynth/vsynth1-dnxhd-2k-hr-hq | 4 + tests/ref/vsynth/vsynth1-dnxhd-4k-hr-lb | 4 + tests/ref/vsynth/vsynth1-dnxhd-720p-hr-lb | 4 + tests/ref/vsynth/vsynth1-dnxhd-edge1-hr | 4 + tests/ref/vsynth/vsynth1-dnxhd-edge2-hr | 4 + tests/ref/vsynth/vsynth1-dnxhd-edge3-hr | 4 + tests/ref/vsynth/vsynth1-dnxhd-hr-hq-mov | 4 + tests/ref/vsynth/vsynth1-dnxhd-hr-lb-mov | 4 + tests/ref/vsynth/vsynth1-dnxhd-hr-sq-mov | 4 + tests/ref/vsynth/vsynth1-dnxhd-uhd-hr-sq | 4 + tests/ref/vsynth/vsynth1-ffv1-v3-rgb48 | 4 + tests/ref/vsynth/vsynth2-dnxhd-2k-hr-hq | 4 + tests/ref/vsynth/vsynth2-dnxhd-4k-hr-lb | 4 + tests/ref/vsynth/vsynth2-dnxhd-720p-hr-lb | 4 + tests/ref/vsynth/vsynth2-dnxhd-edge1-hr | 4 + tests/ref/vsynth/vsynth2-dnxhd-edge2-hr | 4 + tests/ref/vsynth/vsynth2-dnxhd-edge3-hr | 4 + tests/ref/vsynth/vsynth2-dnxhd-hr-hq-mov | 4 + tests/ref/vsynth/vsynth2-dnxhd-hr-lb-mov | 4 + tests/ref/vsynth/vsynth2-dnxhd-hr-sq-mov | 4 + tests/ref/vsynth/vsynth2-dnxhd-uhd-hr-sq | 4 + tests/ref/vsynth/vsynth2-ffv1-v3-rgb48 | 4 + tests/ref/vsynth/vsynth3-dnxhd-2k-hr-hq | 4 + tests/ref/vsynth/vsynth3-dnxhd-4k-hr-lb | 4 + tests/ref/vsynth/vsynth3-dnxhd-720p-hr-lb | 4 + tests/ref/vsynth/vsynth3-dnxhd-edge1-hr | 4 + tests/ref/vsynth/vsynth3-dnxhd-edge2-hr | 4 + tests/ref/vsynth/vsynth3-dnxhd-edge3-hr | 4 + tests/ref/vsynth/vsynth3-dnxhd-hr-hq-mov | 4 + tests/ref/vsynth/vsynth3-dnxhd-hr-lb-mov | 4 + tests/ref/vsynth/vsynth3-dnxhd-hr-sq-mov | 4 + tests/ref/vsynth/vsynth3-dnxhd-uhd-hr-sq | 4 + tests/ref/vsynth/vsynth3-ffv1-v3-rgb48 | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-2k-hr-hq | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-4k-hr-lb | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-720p-hr-lb | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-edge1-hr | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-edge2-hr | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-edge3-hr | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-hr-hq-mov | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-hr-lb-mov | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-hr-sq-mov | 4 + tests/ref/vsynth/vsynth_lena-dnxhd-uhd-hr-sq | 4 + tests/ref/vsynth/vsynth_lena-ffv1-v3-rgb48 | 4 + tests/regression-funcs.sh | 2 +- tools/crypto_bench.c | 98 +- tools/libav-merge-next-commit | 22 + tools/murge | 11 + tools/patcheck | 2 +- 925 files changed, 54821 insertions(+), 16987 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 compat/cuda/cuviddec.h create mode 100644 compat/cuda/nvcuvid.h create mode 100644 compat/nvenc/nvEncodeAPI.h create mode 100644 doc/libav-merge.txt create mode 100644 doc/patchwork create mode 100644 libavcodec/dirac_vlc.c create mode 100644 libavcodec/dirac_vlc.h create mode 100644 libavcodec/ffv1_template.c create mode 100644 libavcodec/ffv1dec_template.c create mode 100644 libavcodec/ffv1enc_template.c create mode 100644 libavcodec/h264_ps.h rename libavcodec/{h264.c => h264dec.c} (80%) create mode 100644 libavcodec/h264dec.h create mode 100644 libavcodec/hevc_parse.c create mode 100644 libavcodec/hevc_parse.h delete mode 100644 libavcodec/libfaac.c create mode 100644 libavcodec/libopenh264.c create mode 100644 libavcodec/libopenh264.h create mode 100644 libavcodec/libopenh264dec.c create mode 100644 libavcodec/mediacodec.c create mode 100644 libavcodec/mediacodec.h create mode 100644 libavcodec/mediacodec_surface.c create mode 100644 libavcodec/mediacodec_surface.h create mode 100644 libavcodec/mediacodecdec_common.c rename libavcodec/{mediacodecdec.h => mediacodecdec_common.h} (80%) delete mode 100644 libavcodec/mediacodecdec_h264.c create mode 100644 libavcodec/mlpenc.c create mode 100644 libavcodec/mlz.c create mode 100644 libavcodec/mlz.h create mode 100644 libavcodec/ttaencdsp.c create mode 100644 libavcodec/ttaencdsp.h create mode 100644 libavcodec/x86/aacencdsp.asm create mode 100644 libavcodec/x86/aacencdsp_init.c create mode 100644 libavcodec/x86/ttaencdsp.asm create mode 100644 libavcodec/x86/ttaencdsp_init.c delete mode 100644 libavdevice/sdl.c create mode 100644 libavdevice/sdl2.c create mode 100644 libavfilter/af_acrusher.c create mode 100644 libavfilter/af_crystalizer.c create mode 100644 libavfilter/f_sidedata.c create mode 100644 libavfilter/motion_estimation.c create mode 100644 libavfilter/motion_estimation.h create mode 100644 libavfilter/tests/integral.c create mode 100644 libavfilter/vf_avgblur.c create mode 100644 libavfilter/vf_bitplanenoise.c create mode 100644 libavfilter/vf_gblur.c create mode 100644 libavfilter/vf_hysteresis.c create mode 100644 libavfilter/vf_lut2.c create mode 100644 libavfilter/vf_maskedclamp.c create mode 100644 libavfilter/vf_mestimate.c create mode 100644 libavfilter/vf_minterpolate.c create mode 100644 libavfilter/vf_nlmeans.c create mode 100644 libavfilter/vf_vaguedenoiser.c create mode 100644 libavfilter/vf_weave.c create mode 100644 libavformat/fifo.c create mode 100644 libavformat/libopenmpt.c create mode 100644 libavformat/tee_common.c create mode 100644 libavformat/tee_common.h create mode 100644 libavformat/teeproto.c create mode 100644 libavformat/tests/fifo_muxer.c create mode 100644 libavformat/ttaenc.c create mode 100644 libavutil/hwcontext_qsv.c create mode 100644 libavutil/hwcontext_qsv.h create mode 100644 libavutil/mips/mmiutils.h create mode 100644 libavutil/softfloat_ieee754.h create mode 100644 tests/checkasm/h264dsp.c create mode 100644 tests/fate/apng.mak create mode 100644 tests/fate/canopus.mak create mode 100644 tests/fate/fifo-muxer.mak create mode 100644 tests/fate/mov.mak create mode 100644 tests/filtergraphs/compand create mode 100644 tests/filtergraphs/firequalizer create mode 100644 tests/filtergraphs/hstack create mode 100644 tests/filtergraphs/vstack create mode 100644 tests/ref/fate/adtstoasc_ticket3715 create mode 100644 tests/ref/fate/apng-clock create mode 100644 tests/ref/fate/apng-osample create mode 100644 tests/ref/fate/copy-psp create mode 100644 tests/ref/fate/copy-trac2211-avi create mode 100644 tests/ref/fate/copy-trac236 create mode 100644 tests/ref/fate/copy-trac4914 create mode 100644 tests/ref/fate/copy-trac4914-avi create mode 100644 tests/ref/fate/dnxhr-12bit create mode 100644 tests/ref/fate/dnxhr-prefix1 create mode 100644 tests/ref/fate/dnxhr-prefix2 create mode 100644 tests/ref/fate/dnxhr-prefix3 create mode 100644 tests/ref/fate/dnxhr-prefix4 create mode 100644 tests/ref/fate/dnxhr-prefix5 create mode 100644 tests/ref/fate/exr-rgb-scanline-b44-half-float-12x8-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-b44-half-float-12x8-l2 create mode 100644 tests/ref/fate/exr-rgb-scanline-pxr24-float-half-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-pxr24-float-half-l2 create mode 100644 tests/ref/fate/exr-rgb-scanline-pxr24-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-pxr24-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-scanline-raw-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-raw-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-scanline-rle-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-rle-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-scanline-zip-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-zip-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-scanline-zip1-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-scanline-zip1-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-half-float-b44-12x8-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-half-float-b44-12x8-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-pxr24-float-half-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-pxr24-float-half-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-pxr24-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-pxr24-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-raw-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-raw-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-rle-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-rle-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-zip-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-zip-half-float-l2 create mode 100644 tests/ref/fate/exr-rgb-tile-zip1-half-float-l1 create mode 100644 tests/ref/fate/exr-rgb-tile-zip1-half-float-l2 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44-12x8-l1 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44-12x8-l2 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44-13x9-l1 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44-13x9-l2 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44a-12x8-l1 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44a-12x8-l2 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44a-13x9-l1 create mode 100644 tests/ref/fate/exr-rgba-scanline-float-half-b44a-13x9-l2 create mode 100644 tests/ref/fate/ffmpeg-bsf-remove-e create mode 100644 tests/ref/fate/ffmpeg-bsf-remove-k create mode 100644 tests/ref/fate/ffmpeg-bsf-remove-r create mode 100644 tests/ref/fate/fifo-muxer-tst create mode 100644 tests/ref/fate/filter-asetnsamples create mode 100644 tests/ref/fate/filter-asetrate create mode 100644 tests/ref/fate/filter-chorus create mode 100644 tests/ref/fate/filter-compand create mode 100644 tests/ref/fate/filter-dcshift create mode 100644 tests/ref/fate/filter-earwax create mode 100644 tests/ref/fate/filter-extrastereo create mode 100644 tests/ref/fate/filter-hls-append create mode 100644 tests/ref/fate/filter-hstack create mode 100644 tests/ref/fate/filter-pixdesc-p010be create mode 100644 tests/ref/fate/filter-pixdesc-p010le create mode 100644 tests/ref/fate/filter-shuffleframes create mode 100644 tests/ref/fate/filter-silenceremove create mode 100644 tests/ref/fate/filter-stereotools create mode 100644 tests/ref/fate/filter-swaprect create mode 100644 tests/ref/fate/filter-tremolo create mode 100644 tests/ref/fate/filter-vstack create mode 100644 tests/ref/fate/filter-weave create mode 100644 tests/ref/fate/h264-3386 create mode 100644 tests/ref/fate/h264-skip-nointra create mode 100644 tests/ref/fate/h264-skip-nokey create mode 100644 tests/ref/fate/h264_mp4toannexb_ticket2991 create mode 100644 tests/ref/fate/jpg-12bpp create mode 100644 tests/ref/fate/jpg-jfif create mode 100644 tests/ref/fate/magicyuv-rgb create mode 100644 tests/ref/fate/magicyuv-rgba create mode 100644 tests/ref/fate/magicyuv-y400i create mode 100644 tests/ref/fate/magicyuv-y420 create mode 100644 tests/ref/fate/magicyuv-y422i create mode 100644 tests/ref/fate/magicyuv-y444 create mode 100644 tests/ref/fate/magicyuv-y4444i create mode 100644 tests/ref/fate/mov-1elist-1ctts create mode 100644 tests/ref/fate/mov-1elist-ends-last-bframe create mode 100644 tests/ref/fate/mov-1elist-noctts create mode 100644 tests/ref/fate/mov-2elist-elist1-ends-bframe create mode 100644 tests/ref/fate/mov-3elist create mode 100644 tests/ref/fate/mov-3elist-1ctts create mode 100644 tests/ref/fate/mov-elist-starts-ctts-2ndsample create mode 100644 tests/ref/fate/mpeg2-ticket186 create mode 100644 tests/ref/fate/mxf-metadata-source-ref1 create mode 100644 tests/ref/fate/mxf-metadata-source-ref2 create mode 100644 tests/ref/fate/mxf-multiple-components-demux create mode 100644 tests/ref/fate/mxf-probe-d10 create mode 100644 tests/ref/fate/mxf-probe-dnxhd create mode 100644 tests/ref/fate/mxf-probe-dv25 create mode 100644 tests/ref/fate/png-int-rgb24 create mode 100644 tests/ref/fate/png-rgba64 create mode 100644 tests/ref/fate/rgb24-mkv create mode 100644 tests/ref/fate/svq3-watermark create mode 100644 tests/ref/fate/truemotion2rt-high create mode 100644 tests/ref/fate/truemotion2rt-low create mode 100644 tests/ref/fate/truemotion2rt-mid create mode 100644 tests/ref/fate/webp-rgb-lena-lossless create mode 100644 tests/ref/fate/webp-rgb-lena-lossless-rgb24 create mode 100644 tests/ref/fate/webp-rgb-lossless create mode 100644 tests/ref/fate/webp-rgb-lossy-q80 create mode 100644 tests/ref/fate/webp-rgba-lossless create mode 100644 tests/ref/fate/webp-rgba-lossy-q80 create mode 100644 tests/ref/lavf-fate/ogg_vp8 create mode 100644 tests/ref/lavf/mka create mode 100644 tests/ref/lavf/tta create mode 100644 tests/ref/seek/mkv-codec-delay create mode 100644 tests/ref/seek/vsynth_lena-dnxhd-4k-hr-lb create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-2k-hr-hq create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-4k-hr-lb create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-720p-hr-lb create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-edge1-hr create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-edge2-hr create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-edge3-hr create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-hr-hq-mov create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-hr-lb-mov create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-hr-sq-mov create mode 100644 tests/ref/vsynth/vsynth1-dnxhd-uhd-hr-sq create mode 100644 tests/ref/vsynth/vsynth1-ffv1-v3-rgb48 create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-2k-hr-hq create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-4k-hr-lb create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-720p-hr-lb create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-edge1-hr create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-edge2-hr create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-edge3-hr create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-hr-hq-mov create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-hr-lb-mov create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-hr-sq-mov create mode 100644 tests/ref/vsynth/vsynth2-dnxhd-uhd-hr-sq create mode 100644 tests/ref/vsynth/vsynth2-ffv1-v3-rgb48 create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-2k-hr-hq create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-4k-hr-lb create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-720p-hr-lb create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-edge1-hr create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-edge2-hr create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-edge3-hr create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-hr-hq-mov create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-hr-lb-mov create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-hr-sq-mov create mode 100644 tests/ref/vsynth/vsynth3-dnxhd-uhd-hr-sq create mode 100644 tests/ref/vsynth/vsynth3-ffv1-v3-rgb48 create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-2k-hr-hq create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-4k-hr-lb create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-720p-hr-lb create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-edge1-hr create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-edge2-hr create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-edge3-hr create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-hr-hq-mov create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-hr-lb-mov create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-hr-sq-mov create mode 100644 tests/ref/vsynth/vsynth_lena-dnxhd-uhd-hr-sq create mode 100644 tests/ref/vsynth/vsynth_lena-ffv1-v3-rgb48 create mode 100755 tools/libav-merge-next-commit create mode 100755 tools/murge diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..c2b79e452 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +# Note to Github users +Patches should be submitted to the [ffmpeg-devel mailing list](https://ffmpeg.org/mailman/listinfo/ffmpeg-devel) using `git format-patch` or `git send-email`. Github pull requests should be avoided because they are not part of our review process and **will be ignored**. + +See [https://ffmpeg.org/developer.html#Contributing](https://ffmpeg.org/developer.html#Contributing) for more information. diff --git a/Changelog b/Changelog index ccb0799df..fd71ad379 100644 --- a/Changelog +++ b/Changelog @@ -1,118 +1,43 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. -version 3.1.5: -- avformat/mxfdec: Check size to avoid integer overflow in mxf_read_utf16_string() -- avcodec/mpegvideo_enc: Clear mmx state in ff_mpv_reallocate_putbitbuffer() -- avcodec/utils: Clear MMX state before returning from avcodec_default_execute*() -- doc/examples/demuxing_decoding: Drop AVFrame->pts use -- libopenjpegenc: fix out-of-bounds reads when filling the edges -- libopenjpegenc: stop reusing image data buffer for openjpeg 2 -- configure: fix detection of libopenjpeg -- doc: fix various typos and grammar errors -- avformat/utils: Update codec_id before using it in the parser init -- cmdutils: fix typos -- lavfi: fix typos -- lavc: fix typos -- tools: fix grammar error -- ffmpeg: remove unused and errorneous AVFrame timestamp check -- Support for MIPS cpu P6600 -- avutil/mips/generic_macros_msa: rename macro variable which causes segfault for mips r6 - -version 3.1.4: -- avformat/avidec: Check nb_streams in read_gab2_sub() -- avformat/avidec: Remove ancient assert -- avfilter/vf_colorspace: fix range for output colorspace option -- lavc/mediacodecdec_h264: fix SODB escaping -- avcodec/nvenc: fix const options for hevc gpu setting -- avformat/avidec: Fix memleak with dv in avi -- lavc/movtextdec.c: Avoid infinite loop on invalid data. -- avcodec/ansi: Check dimensions -- avcodec/cavsdsp: use av_clip_uint8() for idct -- avformat/movenc: Check packet in mov_write_single_packet() too -- avformat/movenc: Factor check_pkt() out -- avformat/utils: fix timebase error in avformat_seek_file() -- avcodec/g726: Add missing ADDB output mask -- avcodec/avpacket: clear side_data_elems -- avformat/movenc: Check first DTS similar to dts difference -- avcodec/ccaption_dec: Use simple array instead of AVBuffer -- avcodec/svq3: Reintroduce slice_type -- avformat/mov: Fix potential integer overflow in mov_read_keys -- swscale/swscale_unscaled: Try to fix Rgb16ToPlanarRgb16Wrapper() with slices -- swscale/swscale_unscaled: Fix packed_16bpc_bswap() with slices -- avformat/avidec: Fix infinite loop in avi_read_nikon() -- lavf/utils: Avoid an overflow for huge negative durations. -- avformat/hls: Fix handling of EXT-X-BYTERANGE streams over 2GB -- lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy(). -- lavc/mjpegdec: Do not skip reading quantization tables. -- cmdutils: fix implicit declaration of SetDllDirectory function - -version 3.1.3: -- examples/demuxing_decoding: convert to codecpar -- avcodec/exr: Check tile positions -- avcodec/aacenc: Tighter input checks -- avformat/wtvdec: Check pointer before use -- libavcodec/wmalosslessdec: Check the remaining bits -- avcodec/adpcm: Fix adpcm_ima_wav padding -- avcodec/svq3: fix slice size check -- avcodec/diracdec: Check numx/y -- avcodec/h2645_parse: fix nal size -- avcodec/h2645_parse: Use get_nalsize() in ff_h2645_packet_split() -- h2645_parse: only read avc length code at the correct position -- h2645_parse: don't overread AnnexB NALs within an avc stream -- avcodec/h264_parser: Factor get_avc_nalsize() out -- avcodec/cfhd: Increase minimum band dimension to 3 -- avcodec/indeo2: check ctab -- avformat/swfdec: Fix inflate() error code check -- avcodec/rawdec: Fix bits_per_coded_sample checks -- vcodec/h2645_parse: Clear buffer padding -- avcodec/h2645: Fix NAL unit padding -- avfilter/drawutils: Fix single plane with alpha -- cmdutils: check for SetDllDirectory() availability - -version 3.1.2: -- cmdutils: remove the current working directory from the DLL search path on win32 -- avcodec/rawdec: Fix palette handling with changing palettes -- avcodec/raw: Fix decoding of ilacetest.mov -- avformat/mov: Enable mp3 parsing if a packet needs it -- avformat/hls: Use an array instead of stream offset for stream mapping -- avformat/hls: Sync starting segment across variants on live streams -- avformat/hls: Fix regression with ranged media segments -- avcodec/ffv1enc: Fix assertion failure with non zero bits per sample -- avfilter/af_hdcd: small fix in af_hdcd.c where gain was not being adjusted for "attenuate slowly" -- avformat/oggdec: Fix integer overflow with invalid pts -- ffplay: Fix invalid array index -- avcodec/alacenc: allocate bigger packets (cherry picked from commit 82b84c71b009884c8d041361027718b19922c76d) -- libavcodec/dnxhd: Enable 12-bit DNxHR support. -- lavc/vaapi_encode_h26x: Fix a crash if "." is not the decimal separator. -- jni: Return ENOSYS on unsupported platforms -- lavu/hwcontext_vaapi: Fix compilation if VA_FOURCC_ABGR is not defined. -- avcodec/vp9_parser: Check the input frame sizes for being consistent -- avformat/flvdec: parse keyframe before a\v stream was created add_keyframes_index() when stream created or keyframe parsed -- avformat/flvdec: splitting add_keyframes_index() out from parse_keyframes_index() -- libavformat/rtpdec_asf: zero initialize the AVIOContext struct -- libavutil/opt: Small bugfix in example. -- libx264: Increase x264 opts character limit to 4096 -- avcodec/h264_parser: Set sps/pps_ref -- librtmp: Avoid an infiniloop setting connection arguments -- avformat/oggparsevp8: fix pts calculation on pages ending with an invisible frame -- lavc/Makefile: Fix standalone compilation of the svq3 decoder. -- lavf/vplayerdec: Improve auto-detection. -- lavc/mediacodecdec_h264: properly convert extradata to annex-b -- Revert "configure: Enable GCC vectorization on ≥4.9 on x86" - -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.2: +- libopenmpt demuxer +- tee protocol +- Changed metadata print option to accept general urls +- Alias muxer for Ogg Video (.ogv) +- VP8 in Ogg muxing +- curves filter doesn't automatically insert points at x=0 and x=1 anymore +- 16-bit support in curves filter and selectivecolor filter +- OpenH264 decoder wrapper +- MediaCodec H.264/HEVC/MPEG-4/VP8/VP9 hwaccel +- True Audio (TTA) muxer +- crystalizer audio filter +- acrusher audio filter +- bitplanenoise video filter +- floating point support in als decoder +- fifo muxer +- maskedclamp filter +- hysteresis filter +- lut2 filter +- yuvtestsrc filter +- CUDA CUVID H.263/VP8/VP9/10 bit HEVC (Dithered) Decoding +- vaguedenoiser filter +- added threads option per filter instance +- weave filter +- gblur filter +- avgblur filter +- sobel and prewitt filter +- MediaCodec HEVC/MPEG-4/VP8/VP9 decoding +- Meridian Lossless Packing (MLP) / TrueHD encoder +- Non-Local Means (nlmeans) denoising filter +- sdl2 output device and ffplay support +- sdl1 output device and sdl1 support removed +- extended mov edit list support +- libfaac encoder removed +- Matroska muxer now writes CRC32 elements by default in all Level 1 elements +- sidedata video and asidedata audio filter +- Changed mapping of rtp MIME type G726 to codec g726le. version 3.1: diff --git a/LICENSE.md b/LICENSE.md index d08c747ae..a384fa0be 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -115,8 +115,6 @@ 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 diff --git a/MAINTAINERS b/MAINTAINERS index fd87db551..d0457a6bc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -43,7 +43,7 @@ Miscellaneous Areas =================== documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan -project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser +project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser, Nikolay Aleksandrov presets Robert Swain metadata subsystem Aurelien Jacobs release management Michael Niedermayer @@ -78,6 +78,7 @@ Other: eval.c, eval.h Michael Niedermayer float_dsp Loren Merritt hash Reimar Doeffinger + hwcontext_cuda* Timo Rothenpieler intfloat* Michael Niedermayer integer.c, integer.h Michael Niedermayer lzo Reimar Doeffinger @@ -136,10 +137,11 @@ Codecs: 8svx.c Jaikrishnan Menon aacenc*, aaccoder.c Rostislav Pehlivanov alacenc.c Jaikrishnan Menon - alsdec.c Thilo Borgmann + alsdec.c Thilo Borgmann, Umair Khan ass* Aurelien Jacobs asv* Michael Niedermayer atrac3plus* Maxim Poliakovski + audiotoolbox* Rodger Combs bgmc.c, bgmc.h Thilo Borgmann binkaudio.c Peter Ross cavs* Stefan Gehrer @@ -147,7 +149,7 @@ Codecs: celp_filters.* Vitor Sessak cinepak.c Roberto Togni cinepakenc.c Rl / Aetey G.T. AB - ccaption_dec.c Anshul Maheshwari + ccaption_dec.c Anshul Maheshwari, Aman Gupta cljr Alex Beregszaszi cpia.c Stephan Hilb crystalhd.c Philip Langdale @@ -164,6 +166,7 @@ Codecs: exif.c, exif.h Thilo Borgmann ffv1* Michael Niedermayer ffwavesynth.c Nicolas George + fifo.c Jan Sebechlebsky flicvideo.c Mike Melanson g722.c Martin Storsjo g726.c Roman Shaposhnik @@ -195,7 +198,7 @@ Codecs: mdec.c Michael Niedermayer mimic.c Ramiro Polla mjpeg*.c Michael Niedermayer - mlp* Ramiro Polla + mlp* Ramiro Polla, Jai Luthra mmvideo.c Peter Ross mpeg12.c, mpeg12data.h Michael Niedermayer mpegvideo.c, mpegvideo.h Michael Niedermayer @@ -284,6 +287,7 @@ libavdevice pulse_audio_enc.c Lukasz Marek qtkit.m Thilo Borgmann sdl Stefano Sabatini + sdl2.c Josh de Kock v4l2.c Giorgio Vazzana vfwcap.c Ramiro Polla xv.c Lukasz Marek @@ -294,6 +298,8 @@ libavfilter Generic parts: graphdump.c Nicolas George + motion_estimation.c Davinder Singh + Filters: f_drawgraph.c Paul B Mahol af_adelay.c Paul B Mahol @@ -308,6 +314,7 @@ Filters: af_chorus.c Paul B Mahol af_compand.c Paul B Mahol af_firequalizer.c Muhammad Faiz + af_hdcd.c Burt P. af_ladspa.c Paul B Mahol af_loudnorm.c Kyle Swanson af_pan.c Nicolas George @@ -334,6 +341,8 @@ Filters: vf_il.c Paul B Mahol vf_lenscorrection.c Daniel Oberhoff vf_mergeplanes.c Paul B Mahol + vf_mestimate.c Davinder Singh + vf_minterpolate.c Davinder Singh vf_neighbor.c Paul B Mahol vf_psnr.c Paul B Mahol vf_random.c Paul B Mahol @@ -372,7 +381,7 @@ Muxers/Demuxers: astdec.c Paul B Mahol astenc.c James Almer avi* Michael Niedermayer - avisynth.c AvxSynth Team (avxsynth.testing at gmail dot com) + avisynth.c Stephen Hutchinson avr.c Paul B Mahol bink.c Peter Ross brstm.c Paul B Mahol @@ -391,7 +400,7 @@ Muxers/Demuxers: gxf.c Reimar Doeffinger gxfenc.c Baptiste Coudurier hls.c Anssi Hannula - hls encryption (hlsenc.c) Christian Suloway + hls encryption (hlsenc.c) Christian Suloway, Steven Liu idcin.c Mike Melanson idroqdec.c Mike Melanson iff.c Jaikrishnan Menon @@ -402,6 +411,7 @@ Muxers/Demuxers: jvdec.c Peter Ross libmodplug.c Clément Bœsch libnut.c Oded Shimon + libopenmpt.c Josh de Kock lmlm4.c Ivo van Poorten lvfdec.c Paul B Mahol lxfdec.c Tomas Härdin @@ -520,7 +530,6 @@ Releases 2.7 Michael Niedermayer 2.6 Michael Niedermayer 2.5 Michael Niedermayer -2.4 Michael Niedermayer If you want to maintain an older release, please contact us @@ -546,6 +555,7 @@ Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE Lou Logan 7D68 DC73 CBEF EABB 671A B6CF 621C 2E28 82F8 DC3A Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 +Nikolay Aleksandrov 8978 1D8C FB71 588E 4B27 EAA8 C4F0 B5FC E011 13B1 Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E diff --git a/README.md b/README.md index 241919193..7d5a7efe9 100644 --- a/README.md +++ b/README.md @@ -45,5 +45,4 @@ GPL. Please refer to the LICENSE file for detailed information. Patches should be submitted to the ffmpeg-devel mailing list using `git format-patch` or `git send-email`. Github pull requests should be -avoided because they are not part of our review process. Few developers -follow pull requests so they will likely be ignored. +avoided because they are not part of our review process and will be ignored. diff --git a/RELEASE b/RELEASE index 3ad0595ad..a3ec5a4bd 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -3.1.5 +3.2 diff --git a/RELEASE_NOTES b/RELEASE_NOTES index afa25ae4e..c3ec01006 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,10 +1,10 @@ ┌────────────────────────────────────────┐ - │ RELEASE NOTES for FFmpeg 3.1 "Laplace" │ + │ RELEASE NOTES for FFmpeg 3.2 "Hypatia" │ └────────────────────────────────────────┘ - The FFmpeg Project proudly presents FFmpeg 3.1 "Laplace", about 4 - months after the release of FFmpeg 3.0. + The FFmpeg Project proudly presents FFmpeg 3.2 "Hypatia", about 4 + months after the release of FFmpeg 3.1. A complete Changelog is available at the root of the project, and the complete Git history on http://source.ffmpeg.org. diff --git a/VERSION b/VERSION index 3ad0595ad..a3ec5a4bd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.5 +3.2 diff --git a/cmdutils.c b/cmdutils.c index 476c85894..469c2d557 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -61,7 +61,7 @@ #include #include #endif -#if HAVE_SETDLLDIRECTORY +#ifdef _WIN32 #include #endif @@ -112,7 +112,7 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v void init_dynload(void) { -#if HAVE_SETDLLDIRECTORY +#ifdef _WIN32 /* Calling SetDllDirectory with the empty string (but not NULL) removes the * current working directory from the DLL search path as a security pre-caution. */ SetDllDirectory(""); @@ -1579,10 +1579,11 @@ int show_encoders(void *optctx, const char *opt, const char *arg) int show_bsfs(void *optctx, const char *opt, const char *arg) { - AVBitStreamFilter *bsf = NULL; + const AVBitStreamFilter *bsf = NULL; + void *opaque = NULL; printf("Bitstream filters:\n"); - while ((bsf = av_bitstream_filter_next(bsf))) + while ((bsf = av_bsf_next(&opaque))) printf("%s\n", bsf->name); printf("\n"); return 0; @@ -1993,7 +1994,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, codec = s->oformat ? avcodec_find_encoder(codec_id) : avcodec_find_decoder(codec_id); - switch (st->codec->codec_type) { + switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_VIDEO: prefix = 'v'; flags |= AV_OPT_FLAG_VIDEO_PARAM; @@ -2051,7 +2052,7 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, return NULL; } for (i = 0; i < s->nb_streams; i++) - opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id, + opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, s, s->streams[i], NULL); return opts; } diff --git a/common.mak b/common.mak index 3f2096d23..7815c3f35 100644 --- a/common.mak +++ b/common.mak @@ -83,12 +83,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC) %.h.c: $(Q)echo '#include "$*.h"' >$@ -%.ver: %.v - $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\ -/' -e 's/; /;\ -/g' > $@ - -%.c %.h: TAG = GEN +%.c %.h %.ver: TAG = GEN # Dummy rule to stop make trying to rebuild removed or renamed headers %.h: @@ -152,7 +147,7 @@ $(TOOLOBJS): | tools OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS)) -CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ver-sol2 *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm +CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).asm DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a diff --git a/compat/avisynth/avisynth_c.h b/compat/avisynth/avisynth_c.h index 0189dad72..605b92ae6 100644 --- a/compat/avisynth/avisynth_c.h +++ b/compat/avisynth/avisynth_c.h @@ -75,54 +75,149 @@ enum {AVS_PLANAR_Y=1<<0, AVS_PLANAR_B_ALIGNED=AVS_PLANAR_B|AVS_PLANAR_ALIGNED}; // Colorspace properties. -enum {AVS_CS_BGR = 1<<28, - AVS_CS_YUV = 1<<29, - AVS_CS_INTERLEAVED = 1<<30, - AVS_CS_PLANAR = 1<<31, +enum { + AVS_CS_YUVA = 1 << 27, + AVS_CS_BGR = 1 << 28, + AVS_CS_YUV = 1 << 29, + AVS_CS_INTERLEAVED = 1 << 30, + AVS_CS_PLANAR = 1 << 31, - AVS_CS_SHIFT_SUB_WIDTH = 0, - AVS_CS_SHIFT_SUB_HEIGHT = 8, - AVS_CS_SHIFT_SAMPLE_BITS = 16, + AVS_CS_SHIFT_SUB_WIDTH = 0, + AVS_CS_SHIFT_SUB_HEIGHT = 8, + AVS_CS_SHIFT_SAMPLE_BITS = 16, - AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, - AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24 - AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16 - AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411 + AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH, + AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24 + AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16 + AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411 - AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 - AVS_CS_UPLANEFIRST = 1 << 4, // I420 + AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 + AVS_CS_UPLANEFIRST = 1 << 4, // I420 - AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, - AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411 - AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420 - AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 + AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT, + AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411 + AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420 + AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9 - AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS, - AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS, + AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS, + + AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK, + AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST), + + AVS_CS_RGB_TYPE = 1 << 0, + AVS_CS_RGBA_TYPE = 1 << 1, + + AVS_CS_GENERIC_YUV420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0 planar + AVS_CS_GENERIC_YUV422 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2 planar + AVS_CS_GENERIC_YUV444 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // 4:4:4 planar + AVS_CS_GENERIC_Y = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV, // Y only (4:0:0) + AVS_CS_GENERIC_RGBP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE, // planar RGB + AVS_CS_GENERIC_RGBAP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE, // planar RGBA + AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // 4:2:0:A planar + AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // 4:2:2:A planar + AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1 }; // 4:4:4:A planar - AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_HEIGHT_MASK | AVS_CS_SUB_WIDTH_MASK, - AVS_CS_PLANAR_FILTER = ~( AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST )}; // Specific colorformats enum { AVS_CS_UNKNOWN = 0, - AVS_CS_BGR24 = 1<<0 | AVS_CS_BGR | AVS_CS_INTERLEAVED, - AVS_CS_BGR32 = 1<<1 | AVS_CS_BGR | AVS_CS_INTERLEAVED, + AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, + AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED, AVS_CS_YUY2 = 1<<2 | AVS_CS_YUV | AVS_CS_INTERLEAVED, // AVS_CS_YV12 = 1<<3 Reserved // AVS_CS_I420 = 1<<4 Reserved AVS_CS_RAW32 = 1<<5 | AVS_CS_INTERLEAVED, - AVS_CS_YV24 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_1, // YVU 4:4:4 planar - AVS_CS_YV16 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:2 planar - AVS_CS_YV12 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YVU 4:2:0 planar + AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YVU 4:4:4 planar + AVS_CS_YV16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YVU 4:2:2 planar + AVS_CS_YV12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YVU 4:2:0 planar AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_HEIGHT_2 | AVS_CS_SUB_WIDTH_2, // YUV 4:2:0 planar AVS_CS_IYUV = AVS_CS_I420, AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_1 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:1 planar AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_HEIGHT_4 | AVS_CS_SUB_WIDTH_4, // YVU 4:1:0 planar - AVS_CS_Y8 = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 // Y 4:0:0 planar + AVS_CS_Y8 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8, // Y 4:0:0 planar + + //------------------------- + // AVS16: new planar constants go live! Experimental PF 160613 + // 10-12-14 bit + planar RGB + BRG48/64 160725 + AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples + AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples + AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples + AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples + + AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples + AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples + AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples + AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples + + AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples + AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples + AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples + AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples + + AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples + AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples + AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples + AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples + + // 32 bit samples (float) + AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32, // YUV 4:4:4 32bit samples + AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:2 32bit samples + AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:0 32bit samples + AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples + + // RGB packed + AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 3x16 bit + AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 4x16 bit + // no packed 32 bit (float) support for these legacy types + + // RGB planar + AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples + AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples + AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples + AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples + AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples + AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples + + // RGBA planar + AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples + AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples + AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples + AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples + AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples + AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples + + // Planar YUVA + AVS_CS_YUVA444 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:4:4 8bit samples + AVS_CS_YUVA422 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:2 8bit samples + AVS_CS_YUVA420 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:0 8bit samples + + AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples + AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples + AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples + + AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples + AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples + AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples + + AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples + AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples + AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples + + AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples + AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples + AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples + + AVS_CS_YUVA444PS = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:4:4 32bit samples + AVS_CS_YUVA422PS = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:2 32bit samples + AVS_CS_YUVA420PS = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:0 32bit samples + }; enum { @@ -247,10 +342,10 @@ AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p) { return !!(p->pixel_type&AVS_CS_BGR); } AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p) - { return (p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24; } // Clear out additional properties + { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p) - { return (p->pixel_type & AVS_CS_BGR32) == AVS_CS_BGR32 ; } + { return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); } AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) { return !!(p->pixel_type&AVS_CS_YUV ); } @@ -258,6 +353,10 @@ AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p) AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p) { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; } +AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p); + AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); @@ -268,6 +367,38 @@ AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p); AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); +AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p); + + + AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property) { return ((p->image_type & property)==property ); } @@ -365,6 +496,12 @@ AVSC_INLINE int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y) } #endif +AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p); + +AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p); + ///////////////////////////////////////////////////////////////////// // // AVS_VideoFrame @@ -528,7 +665,7 @@ AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0) { AVS_Value v; avs_set_to_clip(&v, v0); return v; } #endif AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size) - { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = size; return v; } + { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; } ///////////////////////////////////////////////////////////////////// // @@ -761,11 +898,28 @@ struct AVS_Library { AVSC_DECLARE_FUNC(avs_vsprintf); AVSC_DECLARE_FUNC(avs_get_error); + AVSC_DECLARE_FUNC(avs_is_rgb48); + AVSC_DECLARE_FUNC(avs_is_rgb64); AVSC_DECLARE_FUNC(avs_is_yv24); AVSC_DECLARE_FUNC(avs_is_yv16); AVSC_DECLARE_FUNC(avs_is_yv12); AVSC_DECLARE_FUNC(avs_is_yv411); AVSC_DECLARE_FUNC(avs_is_y8); + AVSC_DECLARE_FUNC(avs_is_yuv444p16); + AVSC_DECLARE_FUNC(avs_is_yuv422p16); + AVSC_DECLARE_FUNC(avs_is_yuv420p16); + AVSC_DECLARE_FUNC(avs_is_y16); + AVSC_DECLARE_FUNC(avs_is_yuv444ps); + AVSC_DECLARE_FUNC(avs_is_yuv422ps); + AVSC_DECLARE_FUNC(avs_is_yuv420ps); + AVSC_DECLARE_FUNC(avs_is_y32); + AVSC_DECLARE_FUNC(avs_is_444); + AVSC_DECLARE_FUNC(avs_is_422); + AVSC_DECLARE_FUNC(avs_is_420); + AVSC_DECLARE_FUNC(avs_is_y); + AVSC_DECLARE_FUNC(avs_is_yuva); + AVSC_DECLARE_FUNC(avs_is_planar_rgb); + AVSC_DECLARE_FUNC(avs_is_planar_rgba); AVSC_DECLARE_FUNC(avs_is_color_space); AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling); @@ -780,6 +934,11 @@ struct AVS_Library { AVSC_DECLARE_FUNC(avs_get_read_ptr_p); AVSC_DECLARE_FUNC(avs_is_writable); AVSC_DECLARE_FUNC(avs_get_write_ptr_p); + + AVSC_DECLARE_FUNC(avs_num_components); + AVSC_DECLARE_FUNC(avs_component_size); + AVSC_DECLARE_FUNC(avs_bits_per_component); + }; #undef AVSC_DECLARE_FUNC @@ -840,11 +999,28 @@ AVSC_INLINE AVS_Library * avs_load_library() { AVSC_LOAD_FUNC(avs_vsprintf); AVSC_LOAD_FUNC(avs_get_error); + AVSC_LOAD_FUNC(avs_is_rgb48); + AVSC_LOAD_FUNC(avs_is_rgb64); AVSC_LOAD_FUNC(avs_is_yv24); AVSC_LOAD_FUNC(avs_is_yv16); AVSC_LOAD_FUNC(avs_is_yv12); AVSC_LOAD_FUNC(avs_is_yv411); AVSC_LOAD_FUNC(avs_is_y8); + AVSC_LOAD_FUNC(avs_is_yuv444p16); + AVSC_LOAD_FUNC(avs_is_yuv422p16); + AVSC_LOAD_FUNC(avs_is_yuv420p16); + AVSC_LOAD_FUNC(avs_is_y16); + AVSC_LOAD_FUNC(avs_is_yuv444ps); + AVSC_LOAD_FUNC(avs_is_yuv422ps); + AVSC_LOAD_FUNC(avs_is_yuv420ps); + AVSC_LOAD_FUNC(avs_is_y32); + AVSC_LOAD_FUNC(avs_is_444); + AVSC_LOAD_FUNC(avs_is_422); + AVSC_LOAD_FUNC(avs_is_420); + AVSC_LOAD_FUNC(avs_is_y); + AVSC_LOAD_FUNC(avs_is_yuva); + AVSC_LOAD_FUNC(avs_is_planar_rgb); + AVSC_LOAD_FUNC(avs_is_planar_rgba); AVSC_LOAD_FUNC(avs_is_color_space); AVSC_LOAD_FUNC(avs_get_plane_width_subsampling); @@ -860,6 +1036,12 @@ AVSC_INLINE AVS_Library * avs_load_library() { AVSC_LOAD_FUNC(avs_is_writable); AVSC_LOAD_FUNC(avs_get_write_ptr_p); + AVSC_LOAD_FUNC(avs_num_components); + AVSC_LOAD_FUNC(avs_component_size); + AVSC_LOAD_FUNC(avs_bits_per_component); + + + #undef __AVSC_STRINGIFY #undef AVSC_STRINGIFY #undef AVSC_LOAD_FUNC diff --git a/compat/cuda/cuviddec.h b/compat/cuda/cuviddec.h new file mode 100644 index 000000000..f9257ea53 --- /dev/null +++ b/compat/cuda/cuviddec.h @@ -0,0 +1,827 @@ +/* + * This copyright notice applies to this header file only: + * + * Copyright (c) 2010-2016 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the software, and to permit persons to whom the + * software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file cuviddec.h + * NvCuvid API provides Video Decoding interface to NVIDIA GPU devices. + * \date 2015-2016 + * This file contains constants, structure definitions and function prototypes used for decoding. + */ + +#if !defined(__CUDA_VIDEO_H__) +#define __CUDA_VIDEO_H__ + +#ifndef __cuda_cuda_h__ +#include +#endif // __cuda_cuda_h__ + +#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) +#if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020)) +#define __CUVID_DEVPTR64 +#endif +#endif + +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus */ + +typedef void *CUvideodecoder; +typedef struct _CUcontextlock_st *CUvideoctxlock; + +/** + * \addtogroup VIDEO_DECODER Video Decoder + * @{ + */ + +/*! + * \enum cudaVideoCodec + * Video Codec Enums + */ +typedef enum cudaVideoCodec_enum { + cudaVideoCodec_MPEG1=0, /**< MPEG1 */ + cudaVideoCodec_MPEG2, /**< MPEG2 */ + cudaVideoCodec_MPEG4, /**< MPEG4 */ + cudaVideoCodec_VC1, /**< VC1 */ + cudaVideoCodec_H264, /**< H264 */ + cudaVideoCodec_JPEG, /**< JPEG */ + cudaVideoCodec_H264_SVC, /**< H264-SVC */ + cudaVideoCodec_H264_MVC, /**< H264-MVC */ + cudaVideoCodec_HEVC, /**< HEVC */ + cudaVideoCodec_VP8, /**< VP8 */ + cudaVideoCodec_VP9, /**< VP9 */ + cudaVideoCodec_NumCodecs, /**< Max COdecs */ + // Uncompressed YUV + cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), /**< Y,U,V (4:2:0) */ + cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,V,U (4:2:0) */ + cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,UV (4:2:0) */ + cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), /**< YUYV/YUY2 (4:2:2) */ + cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) /**< UYVY (4:2:2) */ +} cudaVideoCodec; + +/*! + * \enum cudaVideoSurfaceFormat + * Video Surface Formats Enums + */ +typedef enum cudaVideoSurfaceFormat_enum { + cudaVideoSurfaceFormat_NV12=0 /**< NV12 (currently the only supported output format) */ +} cudaVideoSurfaceFormat; + +/*! + * \enum cudaVideoDeinterlaceMode + * Deinterlacing Modes Enums + */ +typedef enum cudaVideoDeinterlaceMode_enum { + cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */ + cudaVideoDeinterlaceMode_Bob, /**< Drop one field */ + cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */ +} cudaVideoDeinterlaceMode; + +/*! + * \enum cudaVideoChromaFormat + * Chroma Formats Enums + */ +typedef enum cudaVideoChromaFormat_enum { + cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */ + cudaVideoChromaFormat_420, /**< 4:2:0 */ + cudaVideoChromaFormat_422, /**< 4:2:2 */ + cudaVideoChromaFormat_444 /**< 4:4:4 */ +} cudaVideoChromaFormat; + +/*! + * \enum cudaVideoCreateFlags + * Decoder Flags Enums + */ +typedef enum cudaVideoCreateFlags_enum { + cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */ + cudaVideoCreate_PreferCUDA = 0x01, /**< Use a CUDA-based decoder if faster than dedicated engines (requires a valid vidLock object for multi-threading) */ + cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */ + cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */ +} cudaVideoCreateFlags; + +/*! + * \struct CUVIDDECODECREATEINFO + * Struct used in create decoder + */ +typedef struct _CUVIDDECODECREATEINFO +{ + unsigned long ulWidth; /**< Coded Sequence Width */ + unsigned long ulHeight; /**< Coded Sequence Height */ + unsigned long ulNumDecodeSurfaces; /**< Maximum number of internal decode surfaces */ + cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */ + cudaVideoChromaFormat ChromaFormat; /**< cudaVideoChromaFormat_XXX (only 4:2:0 is currently supported) */ + unsigned long ulCreationFlags; /**< Decoder creation flags (cudaVideoCreateFlags_XXX) */ + unsigned long bitDepthMinus8; + unsigned long Reserved1[4]; /**< Reserved for future use - set to zero */ + /** + * area of the frame that should be displayed + */ + struct { + short left; + short top; + short right; + short bottom; + } display_area; + + cudaVideoSurfaceFormat OutputFormat; /**< cudaVideoSurfaceFormat_XXX */ + cudaVideoDeinterlaceMode DeinterlaceMode; /**< cudaVideoDeinterlaceMode_XXX */ + unsigned long ulTargetWidth; /**< Post-processed Output Width (Should be aligned to 2) */ + unsigned long ulTargetHeight; /**< Post-processed Output Height (Should be aligbed to 2) */ + unsigned long ulNumOutputSurfaces; /**< Maximum number of output surfaces simultaneously mapped */ + CUvideoctxlock vidLock; /**< If non-NULL, context lock used for synchronizing ownership of the cuda context */ + /** + * target rectangle in the output frame (for aspect ratio conversion) + * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used + */ + struct { + short left; + short top; + short right; + short bottom; + } target_rect; + unsigned long Reserved2[5]; /**< Reserved for future use - set to zero */ +} CUVIDDECODECREATEINFO; + +/*! + * \struct CUVIDH264DPBENTRY + * H.264 DPB Entry + */ +typedef struct _CUVIDH264DPBENTRY +{ + int PicIdx; /**< picture index of reference frame */ + int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */ + int is_long_term; /**< 0=short term reference, 1=long term reference */ + int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */ + int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */ + int FieldOrderCnt[2]; /**< field order count of top and bottom fields */ +} CUVIDH264DPBENTRY; + +/*! + * \struct CUVIDH264MVCEXT + * H.264 MVC Picture Parameters Ext + */ +typedef struct _CUVIDH264MVCEXT +{ + int num_views_minus1; + int view_id; + unsigned char inter_view_flag; + unsigned char num_inter_view_refs_l0; + unsigned char num_inter_view_refs_l1; + unsigned char MVCReserved8Bits; + int InterViewRefsL0[16]; + int InterViewRefsL1[16]; +} CUVIDH264MVCEXT; + +/*! + * \struct CUVIDH264SVCEXT + * H.264 SVC Picture Parameters Ext + */ +typedef struct _CUVIDH264SVCEXT +{ + unsigned char profile_idc; + unsigned char level_idc; + unsigned char DQId; + unsigned char DQIdMax; + unsigned char disable_inter_layer_deblocking_filter_idc; + unsigned char ref_layer_chroma_phase_y_plus1; + signed char inter_layer_slice_alpha_c0_offset_div2; + signed char inter_layer_slice_beta_offset_div2; + + unsigned short DPBEntryValidFlag; + unsigned char inter_layer_deblocking_filter_control_present_flag; + unsigned char extended_spatial_scalability_idc; + unsigned char adaptive_tcoeff_level_prediction_flag; + unsigned char slice_header_restriction_flag; + unsigned char chroma_phase_x_plus1_flag; + unsigned char chroma_phase_y_plus1; + + unsigned char tcoeff_level_prediction_flag; + unsigned char constrained_intra_resampling_flag; + unsigned char ref_layer_chroma_phase_x_plus1_flag; + unsigned char store_ref_base_pic_flag; + unsigned char Reserved8BitsA; + unsigned char Reserved8BitsB; + // For the 4 scaled_ref_layer_XX fields below, + // if (extended_spatial_scalability_idc == 1), SPS field, G.7.3.2.1.4, add prefix "seq_" + // if (extended_spatial_scalability_idc == 2), SLH field, G.7.3.3.4, + short scaled_ref_layer_left_offset; + short scaled_ref_layer_top_offset; + short scaled_ref_layer_right_offset; + short scaled_ref_layer_bottom_offset; + unsigned short Reserved16Bits; + struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. Linked list ends at the target layer. */ + int bRefBaseLayer; /**< whether to store ref base pic */ +} CUVIDH264SVCEXT; + +/*! + * \struct CUVIDH264PICPARAMS + * H.264 Picture Parameters + */ +typedef struct _CUVIDH264PICPARAMS +{ + // SPS + int log2_max_frame_num_minus4; + int pic_order_cnt_type; + int log2_max_pic_order_cnt_lsb_minus4; + int delta_pic_order_always_zero_flag; + int frame_mbs_only_flag; + int direct_8x8_inference_flag; + int num_ref_frames; // NOTE: shall meet level 4.1 restrictions + unsigned char residual_colour_transform_flag; + unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported) + unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported) + unsigned char qpprime_y_zero_transform_bypass_flag; + // PPS + int entropy_coding_mode_flag; + int pic_order_present_flag; + int num_ref_idx_l0_active_minus1; + int num_ref_idx_l1_active_minus1; + int weighted_pred_flag; + int weighted_bipred_idc; + int pic_init_qp_minus26; + int deblocking_filter_control_present_flag; + int redundant_pic_cnt_present_flag; + int transform_8x8_mode_flag; + int MbaffFrameFlag; + int constrained_intra_pred_flag; + int chroma_qp_index_offset; + int second_chroma_qp_index_offset; + int ref_pic_flag; + int frame_num; + int CurrFieldOrderCnt[2]; + // DPB + CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB + // Quantization Matrices (raster-order) + unsigned char WeightScale4x4[6][16]; + unsigned char WeightScale8x8[2][64]; + // FMO/ASO + unsigned char fmo_aso_enable; + unsigned char num_slice_groups_minus1; + unsigned char slice_group_map_type; + signed char pic_init_qs_minus26; + unsigned int slice_group_change_rate_minus1; + union + { + unsigned long long slice_group_map_addr; + const unsigned char *pMb2SliceGroupMap; + } fmo; + unsigned int Reserved[12]; + // SVC/MVC + union + { + CUVIDH264MVCEXT mvcext; + CUVIDH264SVCEXT svcext; + }; +} CUVIDH264PICPARAMS; + + +/*! + * \struct CUVIDMPEG2PICPARAMS + * MPEG-2 Picture Parameters + */ +typedef struct _CUVIDMPEG2PICPARAMS +{ + int ForwardRefIdx; // Picture index of forward reference (P/B-frames) + int BackwardRefIdx; // Picture index of backward reference (B-frames) + int picture_coding_type; + int full_pel_forward_vector; + int full_pel_backward_vector; + int f_code[2][2]; + int intra_dc_precision; + int frame_pred_frame_dct; + int concealment_motion_vectors; + int q_scale_type; + int intra_vlc_format; + int alternate_scan; + int top_field_first; + // Quantization matrices (raster order) + unsigned char QuantMatrixIntra[64]; + unsigned char QuantMatrixInter[64]; +} CUVIDMPEG2PICPARAMS; + +//////////////////////////////////////////////////////////////////////////////////////////////// +// +// MPEG-4 Picture Parameters +// + +// MPEG-4 has VOP types instead of Picture types +#define I_VOP 0 +#define P_VOP 1 +#define B_VOP 2 +#define S_VOP 3 + +/*! + * \struct CUVIDMPEG4PICPARAMS + * MPEG-4 Picture Parameters + */ +typedef struct _CUVIDMPEG4PICPARAMS +{ + int ForwardRefIdx; // Picture index of forward reference (P/B-frames) + int BackwardRefIdx; // Picture index of backward reference (B-frames) + // VOL + int video_object_layer_width; + int video_object_layer_height; + int vop_time_increment_bitcount; + int top_field_first; + int resync_marker_disable; + int quant_type; + int quarter_sample; + int short_video_header; + int divx_flags; + // VOP + int vop_coding_type; + int vop_coded; + int vop_rounding_type; + int alternate_vertical_scan_flag; + int interlaced; + int vop_fcode_forward; + int vop_fcode_backward; + int trd[2]; + int trb[2]; + // Quantization matrices (raster order) + unsigned char QuantMatrixIntra[64]; + unsigned char QuantMatrixInter[64]; + int gmc_enabled; +} CUVIDMPEG4PICPARAMS; + +/*! + * \struct CUVIDVC1PICPARAMS + * VC1 Picture Parameters + */ +typedef struct _CUVIDVC1PICPARAMS +{ + int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */ + int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */ + int FrameWidth; /**< Actual frame width */ + int FrameHeight; /**< Actual frame height */ + // PICTURE + int intra_pic_flag; /**< Set to 1 for I,BI frames */ + int ref_pic_flag; /**< Set to 1 for I,P frames */ + int progressive_fcm; /**< Progressive frame */ + // SEQUENCE + int profile; + int postprocflag; + int pulldown; + int interlace; + int tfcntrflag; + int finterpflag; + int psf; + int multires; + int syncmarker; + int rangered; + int maxbframes; + // ENTRYPOINT + int panscan_flag; + int refdist_flag; + int extended_mv; + int dquant; + int vstransform; + int loopfilter; + int fastuvmc; + int overlap; + int quantizer; + int extended_dmv; + int range_mapy_flag; + int range_mapy; + int range_mapuv_flag; + int range_mapuv; + int rangeredfrm; // range reduction state +} CUVIDVC1PICPARAMS; + +/*! + * \struct CUVIDJPEGPICPARAMS + * JPEG Picture Parameters + */ +typedef struct _CUVIDJPEGPICPARAMS +{ + int Reserved; +} CUVIDJPEGPICPARAMS; + + + /*! + * \struct CUVIDHEVCPICPARAMS + * HEVC Picture Parameters + */ +typedef struct _CUVIDHEVCPICPARAMS +{ + // sps + int pic_width_in_luma_samples; + int pic_height_in_luma_samples; + unsigned char log2_min_luma_coding_block_size_minus3; + unsigned char log2_diff_max_min_luma_coding_block_size; + unsigned char log2_min_transform_block_size_minus2; + unsigned char log2_diff_max_min_transform_block_size; + unsigned char pcm_enabled_flag; + unsigned char log2_min_pcm_luma_coding_block_size_minus3; + unsigned char log2_diff_max_min_pcm_luma_coding_block_size; + unsigned char pcm_sample_bit_depth_luma_minus1; + + unsigned char pcm_sample_bit_depth_chroma_minus1; + unsigned char pcm_loop_filter_disabled_flag; + unsigned char strong_intra_smoothing_enabled_flag; + unsigned char max_transform_hierarchy_depth_intra; + unsigned char max_transform_hierarchy_depth_inter; + unsigned char amp_enabled_flag; + unsigned char separate_colour_plane_flag; + unsigned char log2_max_pic_order_cnt_lsb_minus4; + + unsigned char num_short_term_ref_pic_sets; + unsigned char long_term_ref_pics_present_flag; + unsigned char num_long_term_ref_pics_sps; + unsigned char sps_temporal_mvp_enabled_flag; + unsigned char sample_adaptive_offset_enabled_flag; + unsigned char scaling_list_enable_flag; + unsigned char IrapPicFlag; + unsigned char IdrPicFlag; + + unsigned char bit_depth_luma_minus8; + unsigned char bit_depth_chroma_minus8; + unsigned char reserved1[14]; + + // pps + unsigned char dependent_slice_segments_enabled_flag; + unsigned char slice_segment_header_extension_present_flag; + unsigned char sign_data_hiding_enabled_flag; + unsigned char cu_qp_delta_enabled_flag; + unsigned char diff_cu_qp_delta_depth; + signed char init_qp_minus26; + signed char pps_cb_qp_offset; + signed char pps_cr_qp_offset; + + unsigned char constrained_intra_pred_flag; + unsigned char weighted_pred_flag; + unsigned char weighted_bipred_flag; + unsigned char transform_skip_enabled_flag; + unsigned char transquant_bypass_enabled_flag; + unsigned char entropy_coding_sync_enabled_flag; + unsigned char log2_parallel_merge_level_minus2; + unsigned char num_extra_slice_header_bits; + + unsigned char loop_filter_across_tiles_enabled_flag; + unsigned char loop_filter_across_slices_enabled_flag; + unsigned char output_flag_present_flag; + unsigned char num_ref_idx_l0_default_active_minus1; + unsigned char num_ref_idx_l1_default_active_minus1; + unsigned char lists_modification_present_flag; + unsigned char cabac_init_present_flag; + unsigned char pps_slice_chroma_qp_offsets_present_flag; + + unsigned char deblocking_filter_override_enabled_flag; + unsigned char pps_deblocking_filter_disabled_flag; + signed char pps_beta_offset_div2; + signed char pps_tc_offset_div2; + unsigned char tiles_enabled_flag; + unsigned char uniform_spacing_flag; + unsigned char num_tile_columns_minus1; + unsigned char num_tile_rows_minus1; + + unsigned short column_width_minus1[21]; + unsigned short row_height_minus1[21]; + unsigned int reserved3[15]; + + // RefPicSets + int NumBitsForShortTermRPSInSlice; + int NumDeltaPocsOfRefRpsIdx; + int NumPocTotalCurr; + int NumPocStCurrBefore; + int NumPocStCurrAfter; + int NumPocLtCurr; + int CurrPicOrderCntVal; + int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference) + int PicOrderCntVal[16]; // [refpic] + unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference + unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15) + unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15) + unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15) + unsigned char RefPicSetInterLayer0[8]; + unsigned char RefPicSetInterLayer1[8]; + unsigned int reserved4[12]; + + // scaling lists (diag order) + unsigned char ScalingList4x4[6][16]; // [matrixId][i] + unsigned char ScalingList8x8[6][64]; // [matrixId][i] + unsigned char ScalingList16x16[6][64]; // [matrixId][i] + unsigned char ScalingList32x32[2][64]; // [matrixId][i] + unsigned char ScalingListDCCoeff16x16[6]; // [matrixId] + unsigned char ScalingListDCCoeff32x32[2]; // [matrixId] +} CUVIDHEVCPICPARAMS; + + +/*! + * \struct CUVIDVP8PICPARAMS + * VP8 Picture Parameters + */ +typedef struct _CUVIDVP8PICPARAMS +{ + int width; + int height; + unsigned int first_partition_size; + //Frame Indexes + unsigned char LastRefIdx; + unsigned char GoldenRefIdx; + unsigned char AltRefIdx; + union { + struct { + unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */ + unsigned char version : 3; + unsigned char show_frame : 1; + unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */ + unsigned char Reserved2Bits : 2; + }; + unsigned char wFrameTagFlags; + }; + unsigned char Reserved1[4]; + unsigned int Reserved2[3]; +} CUVIDVP8PICPARAMS; + +/*! + * \struct CUVIDVP9PICPARAMS + * VP9 Picture Parameters + */ +typedef struct _CUVIDVP9PICPARAMS +{ + unsigned int width; + unsigned int height; + + //Frame Indices + unsigned char LastRefIdx; + unsigned char GoldenRefIdx; + unsigned char AltRefIdx; + unsigned char colorSpace; + + unsigned short profile : 3; + unsigned short frameContextIdx : 2; + unsigned short frameType : 1; + unsigned short showFrame : 1; + unsigned short errorResilient : 1; + unsigned short frameParallelDecoding : 1; + unsigned short subSamplingX : 1; + unsigned short subSamplingY : 1; + unsigned short intraOnly : 1; + unsigned short allow_high_precision_mv : 1; + unsigned short refreshEntropyProbs : 1; + unsigned short reserved2Bits : 2; + + unsigned short reserved16Bits; + + unsigned char refFrameSignBias[4]; + + unsigned char bitDepthMinus8Luma; + unsigned char bitDepthMinus8Chroma; + unsigned char loopFilterLevel; + unsigned char loopFilterSharpness; + + unsigned char modeRefLfEnabled; + unsigned char log2_tile_columns; + unsigned char log2_tile_rows; + + unsigned char segmentEnabled : 1; + unsigned char segmentMapUpdate : 1; + unsigned char segmentMapTemporalUpdate : 1; + unsigned char segmentFeatureMode : 1; + unsigned char reserved4Bits : 4; + + + unsigned char segmentFeatureEnable[8][4]; + short segmentFeatureData[8][4]; + unsigned char mb_segment_tree_probs[7]; + unsigned char segment_pred_probs[3]; + unsigned char reservedSegment16Bits[2]; + + int qpYAc; + int qpYDc; + int qpChDc; + int qpChAc; + + unsigned int activeRefIdx[3]; + unsigned int resetFrameContext; + unsigned int mcomp_filter_type; + unsigned int mbRefLfDelta[4]; + unsigned int mbModeLfDelta[2]; + unsigned int frameTagSize; + unsigned int offsetToDctParts; + unsigned int reserved128Bits[4]; + +} CUVIDVP9PICPARAMS; + + +/*! + * \struct CUVIDPICPARAMS + * Picture Parameters for Decoding + */ +typedef struct _CUVIDPICPARAMS +{ + int PicWidthInMbs; /**< Coded Frame Size */ + int FrameHeightInMbs; /**< Coded Frame Height */ + int CurrPicIdx; /**< Output index of the current picture */ + int field_pic_flag; /**< 0=frame picture, 1=field picture */ + int bottom_field_flag; /**< 0=top field, 1=bottom field (ignored if field_pic_flag=0) */ + int second_field; /**< Second field of a complementary field pair */ + // Bitstream data + unsigned int nBitstreamDataLen; /**< Number of bytes in bitstream data buffer */ + const unsigned char *pBitstreamData; /**< Ptr to bitstream data for this picture (slice-layer) */ + unsigned int nNumSlices; /**< Number of slices in this picture */ + const unsigned int *pSliceDataOffsets; /**< nNumSlices entries, contains offset of each slice within the bitstream data buffer */ + int ref_pic_flag; /**< This picture is a reference picture */ + int intra_pic_flag; /**< This picture is entirely intra coded */ + unsigned int Reserved[30]; /**< Reserved for future use */ + // Codec-specific data + union { + CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */ + CUVIDH264PICPARAMS h264; + CUVIDVC1PICPARAMS vc1; + CUVIDMPEG4PICPARAMS mpeg4; + CUVIDJPEGPICPARAMS jpeg; + CUVIDHEVCPICPARAMS hevc; + CUVIDVP8PICPARAMS vp8; + CUVIDVP9PICPARAMS vp9; + unsigned int CodecReserved[1024]; + } CodecSpecific; +} CUVIDPICPARAMS; + + +/*! + * \struct CUVIDPROCPARAMS + * Picture Parameters for Postprocessing + */ +typedef struct _CUVIDPROCPARAMS +{ + int progressive_frame; /**< Input is progressive (deinterlace_mode will be ignored) */ + int second_field; /**< Output the second field (ignored if deinterlace mode is Weave) */ + int top_field_first; /**< Input frame is top field first (1st field is top, 2nd field is bottom) */ + int unpaired_field; /**< Input only contains one field (2nd field is invalid) */ + // The fields below are used for raw YUV input + unsigned int reserved_flags; /**< Reserved for future use (set to zero) */ + unsigned int reserved_zero; /**< Reserved (set to zero) */ + unsigned long long raw_input_dptr; /**< Input CUdeviceptr for raw YUV extensions */ + unsigned int raw_input_pitch; /**< pitch in bytes of raw YUV input (should be aligned appropriately) */ + unsigned int raw_input_format; /**< Reserved for future use (set to zero) */ + unsigned long long raw_output_dptr; /**< Reserved for future use (set to zero) */ + unsigned int raw_output_pitch; /**< Reserved for future use (set to zero) */ + unsigned int Reserved[48]; + void *Reserved3[3]; +} CUVIDPROCPARAMS; + + +/** + * + * In order to minimize decode latencies, there should be always at least 2 pictures in the decode + * queue at any time, in order to make sure that all decode engines are always busy. + * + * Overall data flow: + * - cuvidCreateDecoder(...) + * For each picture: + * - cuvidDecodePicture(N) + * - cuvidMapVideoFrame(N-4) + * - do some processing in cuda + * - cuvidUnmapVideoFrame(N-4) + * - cuvidDecodePicture(N+1) + * - cuvidMapVideoFrame(N-3) + * ... + * - cuvidDestroyDecoder(...) + * + * NOTE: + * - When the cuda context is created from a D3D device, the D3D device must also be created + * with the D3DCREATE_MULTITHREADED flag. + * - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces) + * - cuVidDecodePicture may block the calling thread if there are too many pictures pending + * in the decode queue + */ + +/** + * \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci) + * Create the decoder object + */ +CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci); + +/** + * \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder) + * Destroy the decoder object + */ +CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder); + +/** + * \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams) + * Decode a single picture (field or frame) + */ +CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams); + + +#if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL) +/** + * \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP); + * Post-process and map a video frame for use in cuda + */ +CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, + unsigned int *pDevPtr, unsigned int *pPitch, + CUVIDPROCPARAMS *pVPP); + +/** + * \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr) + * Unmap a previously mapped video frame + */ +CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr); +#endif + +#if defined(WIN64) || defined(_WIN64) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) +/** + * \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP); + * map a video frame + */ +CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, + unsigned int *pPitch, CUVIDPROCPARAMS *pVPP); + +/** + * \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr); + * Unmap a previously mapped video frame + */ +CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr); + +#if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL) +#define cuvidMapVideoFrame cuvidMapVideoFrame64 +#define cuvidUnmapVideoFrame cuvidUnmapVideoFrame64 +#endif +#endif + + + +/** + * + * Context-locking: to facilitate multi-threaded implementations, the following 4 functions + * provide a simple mutex-style host synchronization. If a non-NULL context is specified + * in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given + * context before making any cuda calls. + * A multi-threaded application could create a lock associated with a context handle so that + * multiple threads can safely share the same cuda context: + * - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context + * that can be passed to cuvidCtxLockCreate. + * - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section. + * + * NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video + * decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls). +*/ + +/** + * \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx) + */ +CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx); + +/** + * \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck) + */ +CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck); + +/** + * \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags) + */ +CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags); + +/** + * \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags) + */ +CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags); + +/** @} */ /* End VIDEO_DECODER */ +//////////////////////////////////////////////////////////////////////////////////////////////// + +#if defined(__cplusplus) + +// Auto-lock helper for C++ applications +class CCtxAutoLock +{ +private: + CUvideoctxlock m_ctx; +public: + CCtxAutoLock(CUvideoctxlock ctx); + ~CCtxAutoLock(); +}; + +} + +#endif /* __cplusplus */ + +#endif // __CUDA_VIDEO_H__ + diff --git a/compat/cuda/nvcuvid.h b/compat/cuda/nvcuvid.h new file mode 100644 index 000000000..738d8e38d --- /dev/null +++ b/compat/cuda/nvcuvid.h @@ -0,0 +1,321 @@ +/* + * This copyright notice applies to this header file only: + * + * Copyright (c) 2010-2016 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the software, and to permit persons to whom the + * software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file nvcuvid.h + * NvCuvid API provides Video Decoding interface to NVIDIA GPU devices. + * \date 2015-2015 + * This file contains the interface constants, structure definitions and function prototypes. + */ + +#if !defined(__NVCUVID_H__) +#define __NVCUVID_H__ + +#include "compat/cuda/cuviddec.h" + +#if defined(__cplusplus) +extern "C" { +#endif /* __cplusplus */ + +/********************************* +** Initialization +*********************************/ +CUresult CUDAAPI cuvidInit(unsigned int Flags); + +//////////////////////////////////////////////////////////////////////////////////////////////// +// +// High-level helper APIs for video sources +// + +typedef void *CUvideosource; +typedef void *CUvideoparser; +typedef long long CUvideotimestamp; + +/** + * \addtogroup VIDEO_PARSER Video Parser + * @{ + */ + +/*! + * \enum cudaVideoState + * Video Source State + */ +typedef enum { + cudaVideoState_Error = -1, /**< Error state (invalid source) */ + cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */ + cudaVideoState_Started = 1 /**< Source is running and delivering data */ +} cudaVideoState; + +/*! + * \enum cudaAudioCodec + * Audio compression + */ +typedef enum { + cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */ + cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */ + cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */ + cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */ + cudaAudioCodec_LPCM /**< PCM Audio */ +} cudaAudioCodec; + +/*! + * \struct CUVIDEOFORMAT + * Video format + */ +typedef struct +{ + cudaVideoCodec codec; /**< Compression format */ + /** + * frame rate = numerator / denominator (for example: 30000/1001) + */ + struct { + unsigned int numerator; /**< frame rate numerator (0 = unspecified or variable frame rate) */ + unsigned int denominator; /**< frame rate denominator (0 = unspecified or variable frame rate) */ + } frame_rate; + unsigned char progressive_sequence; /**< 0=interlaced, 1=progressive */ + unsigned char bit_depth_luma_minus8; /**< high bit depth Luma */ + unsigned char bit_depth_chroma_minus8; /**< high bit depth Chroma */ + unsigned char reserved1; /**< Reserved for future use */ + unsigned int coded_width; /**< coded frame width */ + unsigned int coded_height; /**< coded frame height */ + /** + * area of the frame that should be displayed + * typical example: + * coded_width = 1920, coded_height = 1088 + * display_area = { 0,0,1920,1080 } + */ + struct { + int left; /**< left position of display rect */ + int top; /**< top position of display rect */ + int right; /**< right position of display rect */ + int bottom; /**< bottom position of display rect */ + } display_area; + cudaVideoChromaFormat chroma_format; /**< Chroma format */ + unsigned int bitrate; /**< video bitrate (bps, 0=unknown) */ + /** + * Display Aspect Ratio = x:y (4:3, 16:9, etc) + */ + struct { + int x; + int y; + } display_aspect_ratio; + /** + * Video Signal Description + */ + struct { + unsigned char video_format : 3; + unsigned char video_full_range_flag : 1; + unsigned char reserved_zero_bits : 4; + unsigned char color_primaries; + unsigned char transfer_characteristics; + unsigned char matrix_coefficients; + } video_signal_description; + unsigned int seqhdr_data_length; /**< Additional bytes following (CUVIDEOFORMATEX) */ +} CUVIDEOFORMAT; + +/*! + * \struct CUVIDEOFORMATEX + * Video format including raw sequence header information + */ +typedef struct +{ + CUVIDEOFORMAT format; + unsigned char raw_seqhdr_data[1024]; +} CUVIDEOFORMATEX; + +/*! + * \struct CUAUDIOFORMAT + * Audio Formats + */ +typedef struct +{ + cudaAudioCodec codec; /**< Compression format */ + unsigned int channels; /**< number of audio channels */ + unsigned int samplespersec; /**< sampling frequency */ + unsigned int bitrate; /**< For uncompressed, can also be used to determine bits per sample */ + unsigned int reserved1; /**< Reserved for future use */ + unsigned int reserved2; /**< Reserved for future use */ +} CUAUDIOFORMAT; + + +/*! + * \enum CUvideopacketflags + * Data packet flags + */ +typedef enum { + CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */ + CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */ + CUVID_PKT_DISCONTINUITY = 0x04 /**< Set when a discontinuity has to be signalled */ +} CUvideopacketflags; + +/*! + * \struct CUVIDSOURCEDATAPACKET + * Data Packet + */ +typedef struct _CUVIDSOURCEDATAPACKET +{ + unsigned long flags; /**< Combination of CUVID_PKT_XXX flags */ + unsigned long payload_size; /**< number of bytes in the payload (may be zero if EOS flag is set) */ + const unsigned char *payload; /**< Pointer to packet payload data (may be NULL if EOS flag is set) */ + CUvideotimestamp timestamp; /**< Presentation timestamp (10MHz clock), only valid if CUVID_PKT_TIMESTAMP flag is set */ +} CUVIDSOURCEDATAPACKET; + +// Callback for packet delivery +typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *); + +/*! + * \struct CUVIDSOURCEPARAMS + * Source Params + */ +typedef struct _CUVIDSOURCEPARAMS +{ + unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */ + unsigned int uReserved1[7]; /**< Reserved for future use - set to zero */ + void *pUserData; /**< Parameter passed in to the data handlers */ + PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< Called to deliver audio packets */ + PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< Called to deliver video packets */ + void *pvReserved2[8]; /**< Reserved for future use - set to NULL */ +} CUVIDSOURCEPARAMS; + +/*! + * \enum CUvideosourceformat_flags + * CUvideosourceformat_flags + */ +typedef enum { + CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */ +} CUvideosourceformat_flags; + +#if !defined(__APPLE__) +/** + * \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams) + * Create Video Source + */ +CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams); + +/** + * \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams) + * Create Video Source + */ +CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams); + +/** + * \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj) + * Destroy Video Source + */ +CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj); + +/** + * \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state) + * Set Video Source state + */ +CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state); + +/** + * \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj) + * Get Video Source state + */ +cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj); + +/** + * \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags) + * Get Video Source Format + */ +CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags); + +/** + * \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags) + * Set Video Source state + */ +CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags); + +#endif + +/** + * \struct CUVIDPARSERDISPINFO + */ +typedef struct _CUVIDPARSERDISPINFO +{ + int picture_index; /**< */ + int progressive_frame; /**< */ + int top_field_first; /**< */ + int repeat_first_field; /**< Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) */ + CUvideotimestamp timestamp; /**< */ +} CUVIDPARSERDISPINFO; + +// +// Parser callbacks +// The parser will call these synchronously from within cuvidParseVideoData(), whenever a picture is ready to +// be decoded and/or displayed. +// +typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *); +typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *); +typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *); + +/** + * \struct CUVIDPARSERPARAMS + */ +typedef struct _CUVIDPARSERPARAMS +{ + cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */ + unsigned int ulMaxNumDecodeSurfaces; /**< Max # of decode surfaces (parser will cycle through these) */ + unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */ + unsigned int ulErrorThreshold; /**< % Error threshold (0-100) for calling pfnDecodePicture (100=always call pfnDecodePicture even if picture bitstream is fully corrupted) */ + unsigned int ulMaxDisplayDelay; /**< Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values: 2..4) */ + unsigned int uReserved1[5]; /**< Reserved for future use - set to 0 */ + void *pUserData; /**< User data for callbacks */ + PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< Called before decoding frames and/or whenever there is a format change */ + PFNVIDDECODECALLBACK pfnDecodePicture; /**< Called when a picture is ready to be decoded (decode order) */ + PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< Called whenever a picture is ready to be displayed (display order) */ + void *pvReserved2[7]; /**< Reserved for future use - set to NULL */ + CUVIDEOFORMATEX *pExtVideoInfo; /**< [Optional] sequence header data from system layer */ +} CUVIDPARSERPARAMS; + +/** + * \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams) + */ +CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams); + +/** + * \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket) + */ +CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket); + +/** + * \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj) + */ +CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj); + +/** @} */ /* END VIDEO_PARSER */ +//////////////////////////////////////////////////////////////////////////////////////////////// + +#if defined(__cplusplus) +} +#endif /* __cplusplus */ + +#endif // __NVCUVID_H__ + + diff --git a/compat/nvenc/nvEncodeAPI.h b/compat/nvenc/nvEncodeAPI.h new file mode 100644 index 000000000..18cf522d1 --- /dev/null +++ b/compat/nvenc/nvEncodeAPI.h @@ -0,0 +1,3219 @@ +/* + * This copyright notice applies to this header file only: + * + * Copyright (c) 2010-2015 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the software, and to permit persons to whom the + * software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file nvEncodeAPI.h + * NvEncodeAPI provides a NVENC Video Encoding interface to NVIDIA GPU devices based on the Kepler architecture. + * \date 2011-2016 + * This file contains the interface constants, structure definitions and function prototypes. + */ + +#ifndef _NV_ENCODEAPI_H_ +#define _NV_ENCODEAPI_H_ + +#include + +#ifdef _WIN32 +#include +#endif + +#ifdef _MSC_VER +#ifndef _STDINT +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +#endif +#else +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures + * @{ + */ + +#if defined(_WIN32) || defined(__CYGWIN__) +#define NVENCAPI __stdcall +#else +#define NVENCAPI +#endif + +#ifdef _WIN32 +typedef RECT NVENC_RECT; +#else +// ========================================================================================= +#ifndef GUID +/*! + * \struct GUID + * Abstracts the GUID structure for non-windows platforms. + */ +// ========================================================================================= +typedef struct +{ + uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */ + uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */ + uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */ + uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits. + The remaining 6 bytes contain the final 12 hexadecimal digits. */ +} GUID; +#endif // GUID + +/** + * \struct _NVENC_RECT + * Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME. + */ +typedef struct _NVENC_RECT +{ + uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */ + uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */ + uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */ + uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */ +} NVENC_RECT; + +#endif // _WIN32 + +/** @} */ /* End of GUID and NVENC_RECT structure grouping*/ + +typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */ +typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/ +typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/ + +#define NVENCAPI_MAJOR_VERSION 7 +#define NVENCAPI_MINOR_VERSION 0 + +#define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24)) + +/** + * Macro to generate per-structure version for use with API. + */ +#define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28)) + + +#define NVENC_INFINITE_GOPLENGTH 0xffffffff + +#define NV_MAX_SEQ_HDR_LEN (512) + +// ========================================================================================= +// Encode Codec GUIDS supported by the NvEncodeAPI interface. +// ========================================================================================= + +// {6BC82762-4E63-4ca4-AA85-1E50F321F6BF} +static const GUID NV_ENC_CODEC_H264_GUID = +{ 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } }; + +// {790CDC88-4522-4d7b-9425-BDA9975F7603} +static const GUID NV_ENC_CODEC_HEVC_GUID = +{ 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } }; + + + +// ========================================================================================= +// * Encode Profile GUIDS supported by the NvEncodeAPI interface. +// ========================================================================================= + +// {BFD6F8E7-233C-4341-8B3E-4818523803F4} +static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID = +{ 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } }; + +// {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A} +static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID = +{ 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } }; + +// {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D} +static const GUID NV_ENC_H264_PROFILE_MAIN_GUID = +{ 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } }; + +// {E7CBC309-4F7A-4b89-AF2A-D537C92BE310} +static const GUID NV_ENC_H264_PROFILE_HIGH_GUID = +{ 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } }; + +// {7AC663CB-A598-4960-B844-339B261A7D52} +static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID = +{ 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } }; + +// {40847BF5-33F7-4601-9084-E8FE3C1DB8B7} +static const GUID NV_ENC_H264_PROFILE_STEREO_GUID = +{ 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } }; + +// {CE788D20-AAA9-4318-92BB-AC7E858C8D36} +static const GUID NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY = +{ 0xce788d20, 0xaaa9, 0x4318, { 0x92, 0xbb, 0xac, 0x7e, 0x85, 0x8c, 0x8d, 0x36 } }; + +// {B405AFAC-F32B-417B-89C4-9ABEED3E5978} +static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID = +{ 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } }; + +// {AEC1BD87-E85B-48f2-84C3-98BCA6285072} +static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID = +{ 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } }; + +// {B514C39A-B55B-40fa-878F-F1253B4DFDEC} +static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID = +{ 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } }; + +// {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5} +static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID = +{ 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } }; + +// For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only +// {51ec32b5-1b4c-453c-9cbd-b616bd621341} +static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID = +{ 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } }; + +// ========================================================================================= +// * Preset GUIDS supported by the NvEncodeAPI interface. +// ========================================================================================= +// {B2DFB705-4EBD-4C49-9B5F-24A777D3E587} +static const GUID NV_ENC_PRESET_DEFAULT_GUID = +{ 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } }; + +// {60E4C59F-E846-4484-A56D-CD45BE9FDDF6} +static const GUID NV_ENC_PRESET_HP_GUID = +{ 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } }; + +// {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012} +static const GUID NV_ENC_PRESET_HQ_GUID = +{ 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } }; + +// {82E3E450-BDBB-4e40-989C-82A90DF9EF32} +static const GUID NV_ENC_PRESET_BD_GUID = +{ 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } }; + +// {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726} +static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID = +{ 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } }; + +// {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105} +static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID = +{ 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } }; + +// {67082A44-4BAD-48FA-98EA-93056D150A58} +static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID = +{ 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } }; + +// {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC} +static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID = +{ 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } }; + +// {149998E7-2364-411d-82EF-179888093409} +static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID = +{ 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } }; + +/** + * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures + * @{ + */ + +/** + * Input frame encode modes + */ +typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE +{ + NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */ + NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */ + NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */ +} NV_ENC_PARAMS_FRAME_FIELD_MODE; + +/** + * Rate Control Modes + */ +typedef enum _NV_ENC_PARAMS_RC_MODE +{ + NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */ + NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */ + NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */ + NV_ENC_PARAMS_RC_VBR_MINQP = 0x4, /**< Variable bitrate mode with MinQP */ + NV_ENC_PARAMS_RC_2_PASS_QUALITY = 0x8, /**< Multi pass encoding optimized for image quality and works only with low latency mode */ + NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP = 0x10, /**< Multi pass encoding optimized for maintaining frame size and works only with low latency mode */ + NV_ENC_PARAMS_RC_2_PASS_VBR = 0x20 /**< Multi pass VBR */ +} NV_ENC_PARAMS_RC_MODE; + +#define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */ + +/** + * Input picture structure + */ +typedef enum _NV_ENC_PIC_STRUCT +{ + NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */ + NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */ + NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */ +} NV_ENC_PIC_STRUCT; + +/** + * Input picture type + */ +typedef enum _NV_ENC_PIC_TYPE +{ + NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */ + NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */ + NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */ + NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */ + NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */ + NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */ + NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */ + NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */ +} NV_ENC_PIC_TYPE; + +/** + * Motion vector precisions + */ +typedef enum _NV_ENC_MV_PRECISION +{ + NV_ENC_MV_PRECISION_DEFAULT = 0x0, /** (if lookahead is enabled, input frames must remain available to the encoder until encode completion) */ + uint32_t disableIadapt :1; /**< [in]: Set this to 1 to disable adaptive I-frame insertion at scene cuts (only has an effect when lookahead is enabled) */ + uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */ + uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ for H.264 */ + uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */ + uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */ + uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */ + uint32_t aqStrength :4; /**< [in]: When AQ (Spatial) is enabled (i.e. NV_ENC_RC_PARAMS::enableAQ is set), this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive). If not set, strength is autoselected by driver. Currently supported only with h264 */ + uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */ + NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */ + NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */ + NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */ + uint32_t temporallayerIdxMask; /**< [in]: Specifies the temporal layers (as a bitmask) whose QPs have changed. Valid max bitmask is [2^NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS - 1] */ + uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as as the array index */ + uint16_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */ + uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-32 (only used if enableLookahead=1) */ + uint32_t reserved[9]; + } NV_ENC_RC_PARAMS; + +/** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */ +#define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1) + + + +/** + * \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS + * H264 Video Usability Info parameters + */ +typedef struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS +{ + uint32_t overscanInfoPresentFlag; /**< [in]: if set to 1 , it specifies that the overscanInfo is present */ + uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */ + uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */ + uint32_t videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/ + uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */ + uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */ + uint32_t colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */ + uint32_t transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */ + uint32_t colourMatrix; /**< [in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (as defined in Annex E of the ITU-T Specification). */ + uint32_t chromaSampleLocationFlag; /**< [in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/ + uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */ + uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */ + uint32_t bitstreamRestrictionFlag; /**< [in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/ + uint32_t reserved[15]; +}NV_ENC_CONFIG_H264_VUI_PARAMETERS; + +typedef NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS; + +/** + * \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE + * External motion vector hint counts per block type. + */ +typedef struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE +{ + uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Specifies the number of candidates per 16x16 block. */ + uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Specifies the number of candidates per 16x8 block. */ + uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Specifies the number of candidates per 8x16 block. */ + uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Specifies the number of candidates per 8x8 block. */ + uint32_t reserved : 16; /**< [in]: Reserved for padding. */ + uint32_t reserved1[3]; /**< [in]: Reserved for future use. */ +} NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE; + + +/** + * \struct _NVENC_EXTERNAL_ME_HINT + * External Motion Vector hint structure. + */ +typedef struct _NVENC_EXTERNAL_ME_HINT +{ + int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */ + int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/ + int32_t refidx : 5; /**< [in]: Specifies the reference index (31=invalid). Current we support only 1 reference frame per direction for external hints, so \p refidx must be 0. */ + int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/ + int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/ + int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */ + int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */ +} NVENC_EXTERNAL_ME_HINT; + + +/** + * \struct _NV_ENC_CONFIG_H264 + * H264 encoder configuration parameters + */ +typedef struct _NV_ENC_CONFIG_H264 +{ + uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/ + uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/ + uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical PFrames */ + uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical BFrames */ + uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */ + uint32_t outputPictureTimingSEI :1; /**< [in]: Set to 1 to write SEI picture timing syntax in the bitstream */ + uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */ + uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */ + uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */ + uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */ + uint32_t enableIntraRefresh :1; /**< [in]: Set to 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */ + uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constarined picture is independent of other slices + Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */ + uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */ + uint32_t enableVFR :1; /**< [in]: Set to 1 to enable variable frame rate. */ + uint32_t enableLTR :1; /**< [in]: Currently this feature is not available and must be set to 0. Set to 1 to enable LTR support and auto-mark the first */ + uint32_t qpPrimeYZeroTransformBypassFlag :1; /**< [in]: To enable lossless encode set this to 1, set QP to 0 and RC_mode to NV_ENC_PARAMS_RC_CONSTQP and profile to HIGH_444_PREDICTIVE_PROFILE. + Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */ + uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */ + uint32_t reservedBitFields :15; /**< [in]: Reserved bitfields and must be set to 0 */ + uint32_t level; /**< [in]: Specifies the encoding level. Client is recommended to set this to NV_ENC_LEVEL_AUTOSELECT in order to enable the NvEncodeAPI interface to select the correct level. */ + uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */ + uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */ + uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2] */ + uint32_t numTemporalLayers; /**< [in]: Specifies max temporal layers to be used for hierarchical coding. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */ + uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header. Currently reserved and must be set to 0. */ + uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header. Currently reserved and must be set to 0. */ + NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE adaptiveTransformMode; /**< [in]: Specifies the AdaptiveTransform Mode. Check support for AdaptiveTransform mode using ::NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM caps. */ + NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */ + NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/ + NV_ENC_H264_ENTROPY_CODING_MODE entropyCodingMode; /**< [in]: Specifies the entropy coding mode. Check support for CABAC mode using ::NV_ENC_CAPS_SUPPORT_CABAC caps. */ + NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signalled in frame packing arrangement SEI */ + uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set. + Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */ + uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */ + uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default dpb size. + The low latency application which wants to invalidate reference frame as an error resilience tool + is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent + frames are invalidated. */ + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices + sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: + sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice) + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) + sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice) + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ + NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info pamameters */ + uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames used. + If ltrTrustMode=1, encoder will mark first numLTRFrames base layer reference frames within each IDR interval as LTR. + If ltrMarkFrame=1, ltrNumFrames specifies maximum number of ltr frames in DPB. + If ltrNumFrames value is more that DPB size(maxNumRefFrames) encoder will take decision on its own. */ + uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. + Set to 0 to disallow encoding using LTR frames until later specified. + Set to 1 to allow encoding using LTR frames unless later invalidated.*/ + uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input. + Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/ + uint32_t maxTemporalLayers; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */ + uint32_t reserved1[270]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_CONFIG_H264; + + +/** + * \struct _NV_ENC_CONFIG_HEVC + * HEVC encoder configuration parameters to be set during initialization. + */ +typedef struct _NV_ENC_CONFIG_HEVC +{ + uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/ + uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/ + NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/ + NV_ENC_HEVC_CUSIZE maxCUSize; /**< [in]: Specifies the maximum size of luma coding unit. Currently NVENC SDK only supports maxCUSize equal to NV_ENC_HEVC_CUSIZE_32x32.*/ + uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */ + uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/ + uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */ + uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */ + uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */ + uint32_t enableLTR :1; /**< [in]: Set 1 to enable use of long term reference pictures for inter prediction. */ + uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS,SPS and PPS signalling in the bitstream. */ + uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/ + uint32_t enableIntraRefresh :1; /**< [in]: Set 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */ + uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/ + uint32_t pixelBitDepthMinus8 :3; /**< [in]: Specifies pixel bit depth minus 8. Should be set to 0 for 8 bit input, 2 for 10 bit input.*/ + uint32_t reserved :18; /**< [in]: Reserved bitfields.*/ + uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */ + uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set. + Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */ + uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */ + uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/ + uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames used. + If ltrTrustMode=1, encoder will mark first numLTRFrames base layer reference frames within each IDR interval as LTR. + If ltrMarkFrame=1, ltrNumFrames specifies maximum number of ltr frames in DPB. + If ltrNumFrames value is more that DPB size(maxNumRefFramesInDPB) encoder will take decision on its own. */ + uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set. Currently reserved and must be set to 0. */ + uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header. Currently reserved and must be set to 0. */ + uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header. Currently reserved and must be set to 0. */ + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices + sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: + sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice) + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) + sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice) + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ + uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */ + NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info pamameters */ + uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. + Set to 0 to disallow encoding using LTR frames until later specified. + Set to 1 to allow encoding using LTR frames unless later invalidated.*/ + uint32_t reserved1[217]; /**< [in]: Reserved and must be set to 0.*/ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_CONFIG_HEVC; + +/** + * \struct _NV_ENC_CODEC_CONFIG + * Codec-specific encoder configuration parameters to be set during initialization. + */ +typedef union _NV_ENC_CODEC_CONFIG +{ + NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */ + NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */ + uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0 */ +} NV_ENC_CODEC_CONFIG; + + +/** + * \struct _NV_ENC_CONFIG + * Encoder configuration parameters to be set during initialization. + */ +typedef struct _NV_ENC_CONFIG +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */ + GUID profileGUID; /**< [in]: Specifies the codec profile guid. If client specifies \p NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID the NvEncodeAPI interface will select the appropriate codec profile. */ + uint32_t gopLength; /**< [in]: Specifies the number of pictures in one GOP. Low latency application client can set goplength to NVENC_INFINITE_GOPLENGTH so that keyframes are not inserted automatically. */ + int32_t frameIntervalP; /**< [in]: Specifies the GOP pattern as follows: \p frameIntervalP = 0: I, 1: IPP, 2: IBP, 3: IBBP If goplength is set to NVENC_INFINITE_GOPLENGTH \p frameIntervalP should be set to 1. */ + uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */ + NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode. + Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps. + Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */ + NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */ + NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */ + NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */ + uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_CONFIG; + +/** macro for constructing the version field of ::_NV_ENC_CONFIG */ +#define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(6) | ( 1<<31 )) + + +/** + * \struct _NV_ENC_INITIALIZE_PARAMS + * Encode Session Initialization parameters. + */ +typedef struct _NV_ENC_INITIALIZE_PARAMS +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */ + GUID encodeGUID; /**< [in]: Specifies the Encode GUID for which the encoder is being created. ::NvEncInitializeEncoder() API will fail if this is not set, or set to unsupported value. */ + GUID presetGUID; /**< [in]: Specifies the preset for encoding. If the preset GUID is set then , the preset configuration will be applied before any other parameter. */ + uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */ + uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */ + uint32_t darWidth; /**< [in]: Specifies the display aspect ratio Width. */ + uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height. */ + uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */ + uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */ + uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */ + uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */ + uint32_t reportSliceOffsets :1; /**< [in]: Set this to 1 to enable reporting slice offsets in ::_NV_ENC_LOCK_BITSTREAM. NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync must be set to 0 to use this feature. Client must set this to 0 if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs */ + uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals */ + uint32_t enableExternalMEHints :1; /**< [in]: Set to 1 to enable external ME hints for the current frame. For NV_ENC_INITIALIZE_PARAMS::enablePTD=1 with B frames, programming L1 hints is optional for B frames since Client doesn't know internal GOP structure. + NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */ + uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/ + uint32_t reservedBitFields :28; /**< [in]: Reserved bitfields and must be set to 0 */ + uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */ + void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */ + NV_ENC_CONFIG* encodeConfig; /**< [in]: Specifies the advanced codec specific structure. If client has sent a valid codec config structure, it will override parameters set by the NV_ENC_INITIALIZE_PARAMS::presetGUID parameter. If set to NULL the NvEncodeAPI interface will use the NV_ENC_INITIALIZE_PARAMS::presetGUID to set the codec specific parameters. + Client can also optionally query the NvEncodeAPI interface to get codec specific parameters for a presetGUID using ::NvEncGetEncodePresetConfig() API. It can then modify (if required) some of the codec config parameters and send down a custom config structure as part of ::_NV_ENC_INITIALIZE_PARAMS. + Even in this case client is recommended to pass the same preset guid it has used in ::NvEncGetEncodePresetConfig() API to query the config structure; as NV_ENC_INITIALIZE_PARAMS::presetGUID. This will not override the custom config structure but will be used to determine other Encoder HW specific parameters not exposed in the API. */ + uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session. + Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */ + uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session. + Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */ + NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE maxMEHintCountsPerBlock[2]; /**< [in]: If Client wants to pass external motion vectors in NV_ENC_PIC_PARAMS::meExternalHints buffer it must specify the maximum number of hint candidates per block per direction for the encode session. + The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors. + This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */ + uint32_t reserved [289]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_INITIALIZE_PARAMS; + +/** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */ +#define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1<<31 )) + + +/** + * \struct _NV_ENC_RECONFIGURE_PARAMS + * Encode Session Reconfigured parameters. + */ +typedef struct _NV_ENC_RECONFIGURE_PARAMS +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */ + NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters. */ + uint32_t resetEncoder :1; /**< [in]: This resets the rate control states and other internal encoder states. This should be used only with an IDR frame. + If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */ + uint32_t forceIDR :1; /**< [in]: Encode the current picture as an IDR picture. This flag is only valid when Picture type decision is taken by the Encoder + [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */ + uint32_t reserved :30; + +}NV_ENC_RECONFIGURE_PARAMS; + +/** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */ +#define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1<<31 )) + +/** + * \struct _NV_ENC_PRESET_CONFIG + * Encoder preset config + */ +typedef struct _NV_ENC_PRESET_CONFIG +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */ + NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */ + uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +}NV_ENC_PRESET_CONFIG; + +/** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */ +#define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 )) + + +/** + * \struct _NV_ENC_SEI_PAYLOAD + * User SEI message + */ +typedef struct _NV_ENC_SEI_PAYLOAD +{ + uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */ + uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */ + uint8_t *payload; /**< [in] pointer to user data */ +} NV_ENC_SEI_PAYLOAD; + +#define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD + +/** + * \struct _NV_ENC_PIC_PARAMS_H264 + * H264 specific enc pic params. sent on a per frame basis. + */ +typedef struct _NV_ENC_PIC_PARAMS_H264 +{ + uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */ + uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */ + uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */ + uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */ + uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt. + When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message + forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */ + uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame. + NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */ + uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */ + uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */ + uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */ + uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */ + uint8_t* sliceTypeData; /**< [in]: Deprecated. */ + uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */ + uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */ + NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */ + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices + sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: + sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice) + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) + sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice) + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ + uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/ + uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the the associated bitmap of LTR frame indices when encoding this frame. */ + uint32_t ltrUsageMode; /**< [in]: Specifies additional usage constraints for encoding using LTR frames from this point further. 0: no constraints, 1: no short term refs older than current, no previous LTR frames.*/ + uint32_t reserved [243]; /**< [in]: Reserved and must be set to 0. */ + void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */ +} NV_ENC_PIC_PARAMS_H264; + +/** + * \struct _NV_ENC_PIC_PARAMS_HEVC + * HEVC specific enc pic params. sent on a per frame basis. + */ +typedef struct _NV_ENC_PIC_PARAMS_HEVC +{ + uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */ + uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */ + uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */ + uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt. + When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message + forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */ + uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame. + NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */ + uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */ + uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */ + uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */ + uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */ + uint8_t* sliceTypeData; /**< [in]: Array which specifies the slice type used to force intra slice for a particular slice. Currently supported only for NV_ENC_CONFIG_H264::sliceMode == 3. + Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264 + Array element with index n corresponds to nth slice. To force a particular slice to intra client should set corresponding array element to NV_ENC_SLICE_TYPE_I + all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */ + uint32_t sliceTypeArrayCnt; /**< [in]: Client should set this to the number of elements allocated in sliceTypeData array. If sliceTypeData is NULL then this should be set to 0 */ + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices + sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */ + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For: + sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice) + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice) + sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice) + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */ + uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/ + uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices when encoding this frame. */ + uint32_t ltrUsageMode; /**< [in]: Specifies additional usage constraints for encoding using LTR frames from this point further. 0: no constraints, 1: no short term refs older than current, no previous LTR frames.*/ + uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */ + uint32_t reserved; /**< [in]: Reserved and must be set to 0. */ + NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */ + uint32_t reserved2 [244]; /**< [in]: Reserved and must be set to 0. */ + void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */ +} NV_ENC_PIC_PARAMS_HEVC; + + +/** + * Codec specific per-picture encoding parameters. + */ +typedef union _NV_ENC_CODEC_PIC_PARAMS +{ + NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */ + NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. Currently unsupported and must not to be used. */ + uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */ +} NV_ENC_CODEC_PIC_PARAMS; + +/** + * \struct _NV_ENC_PIC_PARAMS + * Encoding parameters that need to be sent on a per frame basis. + */ +typedef struct _NV_ENC_PIC_PARAMS +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */ + uint32_t inputWidth; /**< [in]: Specifies the input buffer width */ + uint32_t inputHeight; /**< [in]: Specifies the input buffer height */ + uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */ + uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR`ed encode pic flags. See ::NV_ENC_PIC_FLAGS enum. */ + uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */ + uint64_t inputTimeStamp; /**< [in]: Specifies presentation timestamp associated with the input picture. */ + uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */ + NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/ + NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API. */ + void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */ + NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */ + NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */ + NV_ENC_PIC_TYPE pictureType; /**< [in]: Specifies input picture type. Client required to be set explicitly by the client if the client has not set NV_ENC_INITALIZE_PARAMS::enablePTD to 1 while calling NvInitializeEncoder. */ + NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */ + NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block per direction for the current frame. meHintCountsPerBlock[0] is for L0 predictors and meHintCountsPerBlock[1] is for L1 predictors. + The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization. */ + NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks multiplied by the total number of candidates per macroblock. + The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8 + + 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */ + uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */ + int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing QP delta value per MB in raster scan order in the current picture. This QP modifier is applied on top of the QP chosen by rate control. */ + uint32_t qpDeltaMapSize; /**< [in]: Specifies the size in bytes of qpDeltaMap surface allocated by client and pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap. Surface (array) should be picWidthInMbs * picHeightInMbs */ + uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */ + uint16_t meHintRefPicDist[2]; /**< [in]: Specifies temporal distance for reference picture (NVENC_EXTERNAL_ME_HINT::refidx = 0) used during external ME with NV_ENC_INITALIZE_PARAMS::enablePTD = 1 . meHintRefPicDist[0] is for L0 hints and meHintRefPicDist[1] is for L1 hints. + If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */ + uint32_t reserved3[286]; /**< [in]: Reserved and must be set to 0 */ + void* reserved4[60]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_PIC_PARAMS; + +/** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */ +#define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 )) + + +/** + * \struct _NV_ENC_MEONLY_PARAMS + * MEOnly parameters that need to be sent on a per motion estimation basis. + */ +typedef struct _NV_ENC_MEONLY_PARAMS +{ + uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/ + uint32_t inputWidth; /**< [in]: Specifies the input buffer width */ + uint32_t inputHeight; /**< [in]: Specifies the input buffer height */ + NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */ + NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */ + NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer. Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. */ + NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */ + void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of motion estimation + of this Frame [only if operating in Asynchronous mode]. + Each output buffer should be associated with a distinct event pointer. */ + uint32_t reserved1[252]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[60]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_MEONLY_PARAMS; + +/** NV_ENC_MEONLY_PARAMS struct version*/ +#define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(2) + + +/** + * \struct _NV_ENC_LOCK_BITSTREAM + * Bitstream buffer lock parameters. + */ +typedef struct _NV_ENC_LOCK_BITSTREAM +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */ + uint32_t doNotWait :1; /**< [in]: If this flag is set, the NvEncodeAPI interface will return buffer pointer even if operation is not completed. If not set, the call will block until operation completes. */ + uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */ + uint32_t reservedBitFields :30; /**< [in]: Reserved bit fields and must be set to 0 */ + void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */ + uint32_t* sliceOffsets; /**< [in,out]: Array which receives the slice offsets. This is not supported if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs. Array size must be equal to size of frame in MBs. */ + uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */ + uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */ + uint32_t numSlices; /**< [out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */ + uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr. */ + uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */ + uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */ + void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream. + For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to + NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */ + NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */ + NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */ + uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */ + uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */ + uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */ + uint32_t ltrFrameBitmap; /**< [out]: Bitmap of LTR frames indices which were used for encoding this frame. Value of 0 if no LTR frames were used. */ + uint32_t reserved [236]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_LOCK_BITSTREAM; + +/** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */ +#define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(1) + + +/** + * \struct _NV_ENC_LOCK_INPUT_BUFFER + * Uncompressed Input Buffer lock parameters. + */ +typedef struct _NV_ENC_LOCK_INPUT_BUFFER +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */ + uint32_t doNotWait :1; /**< [in]: Set to 1 to make ::NvEncLockInputBuffer() a unblocking call. If the encoding is not completed, driver will return ::NV_ENC_ERR_ENCODER_BUSY error code. */ + uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */ + NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Pointer to the input buffer to be locked, client should pass the pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource API. */ + void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */ + uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */ + uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_LOCK_INPUT_BUFFER; + +/** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */ +#define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1) + + +/** + * \struct _NV_ENC_MAP_INPUT_RESOURCE + * Map an input resource to a Nvidia Encoder Input Buffer + */ +typedef struct _NV_ENC_MAP_INPUT_RESOURCE +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */ + uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */ + void* inputResource; /**< [in]: Deprecated. Do not use. */ + NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */ + NV_ENC_INPUT_PTR mappedResource; /**< [out]: Mapped pointer corresponding to the registeredResource. This pointer must be used in NV_ENC_PIC_PARAMS::inputBuffer parameter in ::NvEncEncodePicture() API. */ + NV_ENC_BUFFER_FORMAT mappedBufferFmt; /**< [out]: Buffer format of the outputResource. This buffer format must be used in NV_ENC_PIC_PARAMS::bufferFmt if client using the above mapped resource pointer. */ + uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */ + void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_MAP_INPUT_RESOURCE; + +/** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */ +#define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4) + +/** + * \struct _NV_ENC_REGISTER_RESOURCE + * Register a resource for future use with the Nvidia Video Encoder Interface. + */ +typedef struct _NV_ENC_REGISTER_RESOURCE +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */ + NV_ENC_INPUT_RESOURCE_TYPE resourceType; /**< [in]: Specifies the type of resource to be registered. Supported values are ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX, ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR. */ + uint32_t width; /**< [in]: Input buffer Width. */ + uint32_t height; /**< [in]: Input buffer Height. */ + uint32_t pitch; /**< [in]: Input buffer Pitch. */ + uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */ + void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */ + NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */ + NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */ + uint32_t reserved1[248]; /**< [in]: Reserved and must be set to 0. */ + void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */ +} NV_ENC_REGISTER_RESOURCE; + +/** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */ +#define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(3) + +/** + * \struct _NV_ENC_STAT + * Encode Stats structure. + */ +typedef struct _NV_ENC_STAT +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */ + uint32_t reserved; /**< [in]: Reserved and must be set to 0 */ + NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */ + uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */ + uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */ + uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */ + uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */ + uint32_t picIdx; /**< [out]: Picture number */ + uint32_t reserved1[233]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_STAT; + +/** Macro for constructing the version field of ::_NV_ENC_STAT */ +#define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1) + + +/** + * \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD + * Sequence and picture paramaters payload. + */ +typedef struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */ + uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provied by the client */ + uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */ + uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */ + void* spsppsBuffer; /**< [in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize. It is the client's responsibility to manage this memory. */ + uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes written by the NvEncodeAPI interface to the SPSPPSBuffer. */ + uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_SEQUENCE_PARAM_PAYLOAD; + +/** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */ +#define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1) + + +/** + * Event registration/unregistration parameters. + */ +typedef struct _NV_ENC_EVENT_PARAMS +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */ + uint32_t reserved; /**< [in]: Reserved and must be set to 0 */ + void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */ + uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_EVENT_PARAMS; + +/** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */ +#define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1) + +/** + * Encoder Session Creation parameters + */ +typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS +{ + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */ + NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */ + void* device; /**< [in]: Pointer to client device. */ + void* reserved; /**< [in]: Reserved and must be set to 0. */ + uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */ + uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */ + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS; +/** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */ +#define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1) + +/** @} */ /* END ENCODER_STRUCTURE */ + + +/** + * \addtogroup ENCODE_FUNC NvEncodeAPI Functions + * @{ + */ + +// NvEncOpenEncodeSession +/** + * \brief Opens an encoding session. + * + * Deprecated. + * + * \return + * ::NV_ENC_ERR_INVALID_CALL\n + * + */ +NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder); + +// NvEncGetEncodeGuidCount +/** + * \brief Retrieves the number of supported encode GUIDs. + * + * The function returns the number of codec guids supported by the NvEncodeAPI + * interface. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [out] encodeGUIDCount + * Number of supported encode GUIDs. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount); + + +// NvEncGetEncodeGUIDs +/** + * \brief Retrieves an array of supported encoder codec GUIDs. + * + * The function returns an array of codec guids supported by the NvEncodeAPI interface. + * The client must allocate an array where the NvEncodeAPI interface can + * fill the supported guids and pass the pointer in \p *GUIDs parameter. + * The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API. + * The Nvidia Encoding interface returns the number of codec guids it has actually + * filled in the guid array in the \p GUIDCount parameter. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] guidArraySize + * Number of GUIDs to retrieved. Should be set to the number retrieved using + * ::NvEncGetEncodeGUIDCount. + * \param [out] GUIDs + * Array of supported Encode GUIDs. + * \param [out] GUIDCount + * Number of supported Encode GUIDs. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); + + +// NvEncGetEncodeProfileGuidCount +/** + * \brief Retrieves the number of supported profile GUIDs. + * + * The function returns the number of profile GUIDs supported for a given codec. + * The client must first enumerate the codec guids supported by the NvEncodeAPI + * interface. After determining the codec guid, it can query the NvEncodeAPI + * interface to determine the number of profile guids supported for a particular + * codec guid. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * The codec guid for which the profile guids are being enumerated. + * \param [out] encodeProfileGUIDCount + * Number of encode profiles supported for the given encodeGUID. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount); + + +// NvEncGetEncodeProfileGUIDs +/** + * \brief Retrieves an array of supported encode profile GUIDs. + * + * The function returns an array of supported profile guids for a particular + * codec guid. The client must allocate an array where the NvEncodeAPI interface + * can populate the profile guids. The client can determine the array size using + * ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the + * NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID + * parameter. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * The encode guid whose profile guids are being enumerated. + * \param [in] guidArraySize + * Number of GUIDs to be retrieved. Should be set to the number retrieved using + * ::NvEncGetEncodeProfileGUIDCount. + * \param [out] profileGUIDs + * Array of supported Encode Profile GUIDs + * \param [out] GUIDCount + * Number of valid encode profile GUIDs in \p profileGUIDs array. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); + +// NvEncGetInputFormatCount +/** + * \brief Retrieve the number of supported Input formats. + * + * The function returns the number of supported input formats. The client must + * query the NvEncodeAPI interface to determine the supported input formats + * before creating the input surfaces. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * Encode GUID, corresponding to which the number of supported input formats + * is to be retrieved. + * \param [out] inputFmtCount + * Number of input formats supported for specified Encode GUID. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + */ +NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount); + + +// NvEncGetInputFormats +/** + * \brief Retrieves an array of supported Input formats + * + * Returns an array of supported input formats The client must use the input + * format to create input surface using ::NvEncCreateInputBuffer() API. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * Encode GUID, corresponding to which the number of supported input formats + * is to be retrieved. + *\param [in] inputFmtArraySize + * Size input format count array passed in \p inputFmts. + *\param [out] inputFmts + * Array of input formats supported for this Encode GUID. + *\param [out] inputFmtCount + * The number of valid input format types returned by the NvEncodeAPI + * interface in \p inputFmts array. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount); + + +// NvEncGetEncodeCaps +/** + * \brief Retrieves the capability value for a specified encoder attribute. + * + * The function returns the capability value for a given encoder attribute. The + * client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before + * calling this function. The encoder attribute being queried are enumerated in + * ::NV_ENC_CAPS_PARAM enum. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * Encode GUID, corresponding to which the capability attribute is to be retrieved. + * \param [in] capsParam + * Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more + * details. + * \param [out] capsVal + * The value corresponding to the capability attribute being queried. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + */ +NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal); + + +// NvEncGetEncodePresetCount +/** + * \brief Retrieves the number of supported preset GUIDs. + * + * The function returns the number of preset GUIDs available for a given codec. + * The client must validate the codec guid using ::NvEncGetEncodeGUIDs() API + * before calling this function. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * Encode GUID, corresponding to which the number of supported presets is to + * be retrieved. + * \param [out] encodePresetGUIDCount + * Receives the number of supported preset GUIDs. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount); + + +// NvEncGetEncodePresetGUIDs +/** + * \brief Receives an array of supported encoder preset GUIDs. + * + * The function returns an array of encode preset guids available for a given codec. + * The client can directly use one of the preset guids based upon the use case + * or target device. The preset guid chosen can be directly used in + * NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API. + * Alternately client can also use the preset guid to retrieve the encoding config + * parameters being used by NvEncodeAPI interface for that given preset, using + * ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters + * as per its use case and send it to NvEncodeAPI interface as part of + * NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder() + * API. + * + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * Encode GUID, corresponding to which the list of supported presets is to be + * retrieved. + * \param [in] guidArraySize + * Size of array of preset guids passed in \p preset GUIDs + * \param [out] presetGUIDs + * Array of supported Encode preset GUIDs from the NvEncodeAPI interface + * to client. + * \param [out] encodePresetGUIDCount + * Receives the number of preset GUIDs returned by the NvEncodeAPI + * interface. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount); + + +// NvEncGetEncodePresetConfig +/** + * \brief Returns a preset config structure supported for given preset GUID. + * + * The function returns a preset config structure for a given preset guid. Before + * using this function the client must enumerate the preset guids available for + * a given codec. The preset config structure can be modified by the client depending + * upon its use case and can be then used to initialize the encoder using + * ::NvEncInitializeEncoder() API. The client can use this function only if it + * wants to modify the NvEncodeAPI preset configuration, otherwise it can + * directly use the preset guid. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] encodeGUID + * Encode GUID, corresponding to which the list of supported presets is to be + * retrieved. + * \param [in] presetGUID + * Preset GUID, corresponding to which the Encoding configurations is to be + * retrieved. + * \param [out] presetConfig + * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for +* more details. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig); + +// NvEncInitializeEncoder +/** + * \brief Initialize the encoder. + * + * This API must be used to initialize the encoder. The initialization parameter + * is passed using \p *createEncodeParams The client must send the following + * fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value. + * - NV_ENC_INITIALIZE_PARAMS::encodeGUID + * - NV_ENC_INITIALIZE_PARAMS::encodeWidth + * - NV_ENC_INITIALIZE_PARAMS::encodeHeight + * + * The client can pass a preset guid directly to the NvEncodeAPI interface using + * NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass + * NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters + * will be selected based on the preset guid. The preset guid must have been + * validated by the client using ::NvEncGetEncodePresetGUIDs() API. + * If the client passes a custom ::_NV_ENC_CONFIG structure through + * NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters + * based on the preset guid. It is recommended that even if the client passes a custom config, + * it should also send a preset guid. In this case, the preset guid passed by the client + * will not override any of the custom config parameters programmed by the client, + * it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters + * which are not exposed to the client. + * + * There are two modes of operation for the encoder namely: + * - Asynchronous mode + * - Synchronous mode + * + * The client can select asynchronous or synchronous mode by setting the \p + * enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively. + *\par Asynchronous mode of operation: + * The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1. + * The client operating in asynchronous mode must allocate completion event object + * for each output buffer and pass the completion event object in the + * ::NvEncEncodePicture() API. The client can create another thread and wait on + * the event object to be signalled by NvEncodeAPI interface on completion of the + * encoding process for the output frame. This should unblock the main thread from + * submitting work to the encoder. When the event is signalled the client can call + * NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream() + * API. This is the preferred mode of operation. + * + * NOTE: Asynchronous mode is not supported on Linux. + * + *\par Synchronous mode of operation: + * The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0. + * The client working in synchronous mode can work in a single threaded or multi + * threaded mode. The client need not allocate any event objects. The client can + * only lock the bitstream data after NvEncodeAPI interface has returned + * ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return + * ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The + * client must not lock the output buffer in such case but should send the next + * frame for encoding. The client must keep on calling ::NvEncEncodePicture() API + * until it returns ::NV_ENC_SUCCESS. \n + * The client must always lock the bitstream data in order in which it has submitted. + * This is true for both asynchronous and synchronous mode. + * + *\par Picture type decision: + * If the client is taking the picture type decision and it must disable the picture + * type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD + * to 0. In this case the client is required to send the picture in encoding + * order to NvEncodeAPI by doing the re-ordering for B frames. \n + * If the client doesn't want to take the picture type decision it can enable + * picture type decision module in the NvEncodeAPI interface by setting + * NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display + * order. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] createEncodeParams + * Refer ::_NV_ENC_INITIALIZE_PARAMS for details. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams); + + +// NvEncCreateInputBuffer +/** + * \brief Allocates Input buffer. + * + * This function is used to allocate an input buffer. The client must enumerate + * the input buffer format before allocating the input buffer resources. The + * NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the + * NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in + * ::NvEncEncodePicture() API. The number of input buffers to be allocated by the + * client must be at least 4 more than the number of B frames being used for encoding. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] createInputBufferParams + * Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams); + + +// NvEncDestroyInputBuffer +/** + * \brief Release an input buffers. + * + * This function is used to free an input buffer. If the client has allocated + * any input buffer using ::NvEncCreateInputBuffer() API, it must free those + * input buffers by calling this function. The client must release the input + * buffers before destroying the encoder using ::NvEncDestroyEncoder() API. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] inputBuffer + * Pointer to the input buffer to be released. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer); + + +// NvEncCreateBitstreamBuffer +/** + * \brief Allocates an output bitstream buffer + * + * This function is used to allocate an output bitstream buffer and returns a + * NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the + * NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field. + * The client can only call this function after the encoder session has been + * initialized using ::NvEncInitializeEncoder() API. The minimum number of output + * buffers allocated by the client must be at least 4 more than the number of B + * B frames being used for encoding. The client can only access the output + * bitsteam data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream() + * function. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] createBitstreamBufferParams + * Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams); + + +// NvEncDestroyBitstreamBuffer +/** + * \brief Release a bitstream buffer. + * + * This function is used to release the output bitstream buffer allocated using + * the ::NvEncCreateBitstreamBuffer() function. The client must release the output + * bitstreamBuffer using this function before destroying the encoder session. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] bitstreamBuffer + * Pointer to the bitstream buffer being released. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); + +// NvEncEncodePicture +/** + * \brief Submit an input picture for encoding. + * + * This function is used to submit an input picture buffer for encoding. The + * encoding parameters are passed using \p *encodePicParams which is a pointer + * to the ::_NV_ENC_PIC_PARAMS structure. + * + * If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must + * send a valid value for the following fields. + * - NV_ENC_PIC_PARAMS::pictureType + * - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only) + * - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only) + * - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only) + * + * + *\par Asynchronous Encoding + * If the client has enabled asynchronous mode of encoding by setting + * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder() + * API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent. + * Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture() + * API commands from the main thread and then queue output buffers to be processed + * to a secondary worker thread. Before the locking the output buffers in the + * secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent + * it has queued in ::NvEncEncodePicture() API call. The client must always process + * completion event and the output buffer in the same order in which they have been + * submitted for encoding. The NvEncodeAPI interface is responsible for any + * re-ordering required for B frames and will always ensure that encoded bitstream + * data is written in the same order in which output buffer is submitted. + *\code + The below example shows how asynchronous encoding in case of 1 B frames + ------------------------------------------------------------------------ + Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..) + and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to + keep a copy of the input buffers for re-ordering and it allocates following + internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI + and the client is not responsible for the allocating or freeing the memory of + the internal buffers. + + a) The client main thread will queue the following encode frame calls. + Note the picture type is unknown to the client, the decision is being taken by + NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter + consisting of allocated input buffer, output buffer and output events in successive + ::NvEncEncodePicture() API calls along with other required encode picture params. + For example: + 1st EncodePicture parameters - (I1, O1, E1) + 2nd EncodePicture parameters - (I2, O2, E2) + 3rd EncodePicture parameters - (I3, O3, E3) + + b) NvEncodeAPI SW will receive the following encode Commands from the client. + The left side shows input from client in the form (Input buffer, Output Buffer, + Output Event). The right hand side shows a possible picture type decision take by + the NvEncodeAPI interface. + (I1, O1, E1) ---P1 Frame + (I2, O2, E2) ---B2 Frame + (I3, O3, E3) ---P3 Frame + + c) NvEncodeAPI interface will make a copy of the input buffers to its internal + buffersfor re-ordering. These copies are done as part of nvEncEncodePicture + function call from the client and NvEncodeAPI interface is responsible for + synchronization of copy operation with the actual encoding operation. + I1 --> NvI1 + I2 --> NvI2 + I3 --> NvI3 + + d) After returning from ::NvEncEncodePicture() call , the client must queue the output + bitstream processing work to the secondary thread. The output bitstream processing + for asynchronous mode consist of first waiting on completion event(E1, E2..) + and then locking the output bitstream buffer(O1, O2..) for reading the encoded + data. The work queued to the secondary thread by the client is in the following order + (I1, O1, E1) + (I2, O2, E2) + (I3, O3, E3) + Note they are in the same order in which client calls ::NvEncEncodePicture() API + in \p step a). + + e) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive + the following encode commands: + (NvI1, O1, E1) ---P1 Frame + (NvI3, O2, E2) ---P3 Frame + (NvI2, O3, E3) ---B2 frame + + f) After the encoding operations are completed, the events will be signalled + by NvEncodeAPI interface in the following order : + (O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signalled. + (O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signalled. + (O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signalled. + + g) The client must lock the bitstream data using ::NvEncLockBitstream() API in + the order O1,O2,O3 to read the encoded data, after waiting for the events + to be signalled in the same order i.e E1, E2 and E3.The output processing is + done in the secondary thread in the following order: + Waits on E1, copies encoded bitstream from O1 + Waits on E2, copies encoded bitstream from O2 + Waits on E3, copies encoded bitstream from O3 + + -Note the client will receive the events signalling and output buffer in the + same order in which they have submitted for encoding. + -Note the LockBitstream will have picture type field which will notify the + output picture type to the clients. + -Note the input, output buffer and the output completion event are free to be + reused once NvEncodeAPI interfaced has signalled the event and the client has + copied the data from the output buffer. + + * \endcode + * + *\par Synchronous Encoding + * The client can enable synchronous mode of encoding by setting + * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API. + * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for + * some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD + * is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI + * interface might not be able to submit an input picture buffer for encoding + * immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot + * submit the input picture which is decided to be encoded as B frame as it waits + * for backward reference from temporally subsequent frames. This input picture + * is buffered internally and waits for more input picture to arrive. The client + * must not call ::NvEncLockBitstream() API on the output buffers whose + * ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must + * wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the + * output bitstreams to read the encoded bitstream data. The following example + * explains the scenario with synchronous encoding with 2 B frames. + *\code + The below example shows how synchronous encoding works in case of 1 B frames + ----------------------------------------------------------------------------- + Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..) + and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to + keep a copy of the input buffers for re-ordering and it allocates following + internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI + and the client is not responsible for the allocating or freeing the memory of + the internal buffers. + + The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1. + The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder + HW and returns ::NV_ENC_SUCCESS. + The client can now read the encoded data by locking the output O1 by calling + NvEncLockBitstream API. + + The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2. + The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it + to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT. + The error is not fatal and it notifies client that it cannot read the encoded + data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting + more work to the NvEncodeAPI interface. + + The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3. + The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for + encoding which will be used as backward reference frame for I2. + The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both + the submission are part of the same ::NvEncEncodePicture() function call. + The client can now read the encoded data for both the frames by locking the output + O2 followed by O3 ,by calling ::NvEncLockBitstream() API. + + The client must always lock the output in the same order in which it has submitted + to receive the encoded bitstream in correct encoding order. + + * \endcode + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] encodePicParams + * Pointer to the ::_NV_ENC_PIC_PARAMS structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_ENCODER_BUSY \n + * ::NV_ENC_ERR_NEED_MORE_INPUT \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams); + + +// NvEncLockBitstream +/** + * \brief Lock output bitstream buffer + * + * This function is used to lock the bitstream buffer to read the encoded data. + * The client can only access the encoded data by calling this function. + * The pointer to client accessible encoded data is returned in the + * NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data + * in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes + * The NvEncodeAPI interface also returns the output picture type and picture structure + * of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and + * NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has + * set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return + * ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not + * a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can + * retry the function after few milliseconds. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] lockBitstreamBufferParams + * Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_LOCK_BUSY \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams); + + +// NvEncUnlockBitstream +/** + * \brief Unlock the output bitstream buffer + * + * This function is used to unlock the output bitstream buffer after the client + * has read the encoded data from output buffer. The client must call this function + * to unlock the output buffer which it has previously locked using ::NvEncLockBitstream() + * function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause + * the function to fail. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] bitstreamBuffer + * bitstream buffer pointer being unlocked + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); + + +// NvLockInputBuffer +/** + * \brief Locks an input buffer + * + * This function is used to lock the input buffer to load the uncompressed YUV + * pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR + * it had previously allocated using ::NvEncCreateInputBuffer()in the + * NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field. + * The NvEncodeAPI interface returns pointer to client accessible input buffer + * memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] lockInputBufferParams + * Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure + * + * \return + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_LOCK_BUSY \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams); + + +// NvUnlockInputBuffer +/** + * \brief Unlocks the input buffer + * + * This function is used to unlock the input buffer memory previously locked for + * uploading YUV pixel data. The input buffer must be unlocked before being used + * again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture() + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] inputBuffer + * Pointer to the input buffer that is being unlocked. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + * + */ +NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer); + + +// NvEncGetEncodeStats +/** + * \brief Get encoding statistics. + * + * This function is used to retrieve the encoding statistics. + * This API is not supported when encode device type is CUDA. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] encodeStats + * Pointer to the ::_NV_ENC_STAT structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats); + + +// NvEncGetSequenceParams +/** + * \brief Get encoded sequence and picture header. + * + * This function can be used to retrieve the sequence and picture header out of + * band. The client must call this function only after the encoder has been + * initialized using ::NvEncInitializeEncoder() function. The client must + * allocate the memory where the NvEncodeAPI interface can copy the bitstream + * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer. + * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize. + * The NvEncodeAPI interface will copy the bitstream header payload and returns + * the actual size of the bitstream header in the field + * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize. + * The client must call ::NvEncGetSequenceParams() function from the same thread which is + * being used to call ::NvEncEncodePicture() function. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] sequenceParamPayload + * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload); + + +// NvEncRegisterAsyncEvent +/** + * \brief Register event for notification to encoding completion. + * + * This function is used to register the completion event with NvEncodeAPI + * interface. The event is required when the client has configured the encoder to + * work in asynchronous mode. In this mode the client needs to send a completion + * event with every output buffer. The NvEncodeAPI interface will signal the + * completion of the encoding process using this event. Only after the event is + * signalled the client can get the encoded data using ::NvEncLockBitstream() function. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] eventParams + * Pointer to the ::_NV_ENC_EVENT_PARAMS structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); + + +// NvEncUnregisterAsyncEvent +/** + * \brief Unregister completion event. + * + * This function is used to unregister completion event which has been previously + * registered using ::NvEncRegisterAsyncEvent() function. The client must unregister + * all events before destroying the encoder using ::NvEncDestroyEncoder() function. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] eventParams + * Pointer to the ::_NV_ENC_EVENT_PARAMS structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); + + +// NvEncMapInputResource +/** + * \brief Map an externally created input resource pointer for encoding. + * + * Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR + * which can be used for encoding in the ::NvEncEncodePicture() function. The + * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr. + * The NvEncodeAPI interface also returns the buffer format of the mapped resource + * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt. + * This function provides synchronization guarantee that any direct3d or cuda + * work submitted on the input buffer is completed before the buffer is used for encoding. + * The client should not access any input buffer while they are mapped by the encoder. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] mapInputResParams + * Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n + * ::NV_ENC_ERR_MAP_FAILED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams); + + +// NvEncUnmapInputResource +/** + * \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding + * + * + * UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource() + * API. The mapping created using ::NvEncMapInputResource() should be invalidated + * using this API before the external resource is destroyed by the client. The client + * must unmap the buffer after ::NvEncLockBitstream() API returns succuessfully for encode + * work submitted using the mapped input buffer. + * + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] mappedInputBuffer + * Pointer to the NV_ENC_INPUT_PTR + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n + * ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer); + +// NvEncDestroyEncoder +/** + * \brief Destroy Encoding Session + * + * Destroys the encoder session previously created using ::NvEncOpenEncodeSession() + * function. The client must flush the encoder before freeing any resources. In order + * to flush the encoder the client must pass a NULL encode picture packet and either + * wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait + * for the flush event to be signaled by the encoder in asynchronous mode. + * The client must free all the input and output resources created using the + * NvEncodeAPI interface before destroying the encoder. If the client is operating + * in asynchronous mode, it must also unregister the completion events previously + * registered. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder); + +// NvEncInvalidateRefFrames +/** + * \brief Invalidate reference frames + * + * Invalidates reference frame based on the time stamp provided by the client. + * The encoder marks any reference frames or any frames which have been reconstructed + * using the corrupt frame as invalid for motion estimation and uses older reference + * frames for motion estimation. The encoded forces the current frame to be encoded + * as an intra frame if no reference frames are left after invalidation process. + * This is useful for low latency application for error resiliency. The client + * is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so + * that encoder can keep a backup of older reference frames in the DPB and can use them + * for motion estimation when the newer reference frames have been invalidated. + * This API can be called multiple times. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] invalidRefFrameTimeStamp + * Timestamp of the invalid reference frames which needs to be invalidated. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp); + +// NvEncOpenEncodeSessionEx +/** + * \brief Opens an encoding session. + * + * Opens an encoding session and returns a pointer to the encoder interface in + * the \p **encoder parameter. The client should start encoding process by calling + * this API first. + * The client must pass a pointer to IDirect3DDevice9/CUDA interface in the \p *device parameter. + * If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API + * before exiting. + * + * \param [in] openSessionExParams + * Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure. + * \param [out] encoder + * Encode Session pointer to the NvEncodeAPI interface. + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n + * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n + * ::NV_ENC_ERR_INVALID_DEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder); + +// NvEncRegisterResource +/** + * \brief Registers a resource with the Nvidia Video Encoder Interface. + * + * Registers a resource with the Nvidia Video Encoder Interface for book keeping. + * The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API. + * This API is not implemented for the DirectX Interface. + * DirectX based clients need not change their implementation. + * + * \param [in] encoder + * Pointer to the NVEncodeAPI interface. + * + * \param [in] registerResParams + * Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n + * ::NV_ENC_ERR_GENERIC \n + * ::NV_ENC_ERR_UNIMPLEMENTED \n + * + */ +NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams); + +// NvEncUnregisterResource +/** + * \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface. + * + * Unregisters a resource previously registered with the Nvidia Video Encoder Interface. + * The client is expected to unregister any resource that it has registered with the + * Nvidia Video Encoder Interface before destroying the resource. + * This API is not implemented for the DirectX Interface. + * DirectX based clients need not change their implementation. + * + * \param [in] encoder + * Pointer to the NVEncodeAPI interface. + * + * \param [in] registeredResource + * The registered resource pointer that was returned in ::NvEncRegisterResource. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n + * ::NV_ENC_ERR_GENERIC \n + * ::NV_ENC_ERR_UNIMPLEMENTED \n + * + */ +NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource); + +// NvEncReconfigureEncoder +/** + * \brief Reconfigure an existing encoding session. + * + * Reconfigure an existing encoding session. + * The client should call this API to change/reconfigure the parameter passed during + * NvEncInitializeEncoder API call. + * Currently Reconfiguration of following are not supported. + * Change in GOP structure. + * Change in sync-Async mode. + * Change in MaxWidth & MaxHeight. + * Change in PTDmode. + * + * Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS + * is set while creating encoder session. + * + * \param [in] encoder + * Pointer to the NVEncodeAPI interface. + * + * \param [in] reInitEncodeParams + * Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure. + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n + * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n + * ::NV_ENC_ERR_INVALID_DEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_GENERIC \n + * + */ +NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams); + + + +// NvEncCreateMVBuffer +/** + * \brief Allocates output MV buffer for ME only mode. + * + * This function is used to allocate an output MV buffer. The size of the mvBuffer is + * dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call. + * The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the + * ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in + * ::NvEncRunMotionEstimationOnly() API. + * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in,out] createMVBufferParams + * Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_GENERIC \n + */ +NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams); + + +// NvEncDestroyMVBuffer +/** + * \brief Release an output MV buffer for ME only mode. + * + * This function is used to release the output MV buffer allocated using + * the ::NvEncCreateMVBuffer() function. The client must release the output + * mvBuffer using this function before destroying the encoder session. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] mvBuffer + * Pointer to the mvBuffer being released. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + */ +NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer); + + +// NvEncRunMotionEstimationOnly +/** + * \brief Submit an input picture and reference frame for motion estimation in ME only mode. + * + * This function is used to submit the input frame and reference frame for motion + * estimation. The ME parameters are passed using *meOnlyParams which is a pointer + * to ::_NV_ENC_MEONLY_PARAMS structure. + * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. + * to get motion vector data. + * + * \param [in] encoder + * Pointer to the NvEncodeAPI interface. + * \param [in] meOnlyParams + * Pointer to the ::_NV_ENC_MEONLY_PARAMS structure. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n + * ::NV_ENC_ERR_OUT_OF_MEMORY \n + * ::NV_ENC_ERR_INVALID_PARAM \n + * ::NV_ENC_ERR_INVALID_VERSION \n + * ::NV_ENC_ERR_NEED_MORE_INPUT \n + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n + * ::NV_ENC_ERR_GENERIC \n + */ +NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams); + +// NvEncodeAPIGetMaxSupportedVersion +/** + * \brief Get the largest NvEncodeAPI version supported by the driver. + * + * This function can be used by clients to determine if the driver supports + * the NvEncodeAPI header the application was compiled with. + * + * \param [out] version + * Pointer to the requested value. The 4 least significant bits in the returned + * indicate the minor version and the rest of the bits indicate the major + * version of the largest supported version. + * + * \return + * ::NV_ENC_SUCCESS \n + * ::NV_ENC_ERR_INVALID_PTR \n + */ +NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion (uint32_t* version); + + +/// \cond API PFN +/* + * Defines API function pointers + */ +typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig); +typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer); +typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); +typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer); +typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats); +typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload); +typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer); +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder); +typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp); +typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder); +typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes); +typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams); + +typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams); +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer); +typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams); + + +/// \endcond + + +/** @} */ /* END ENCODE_FUNC */ + +/** + * \ingroup ENCODER_STRUCTURE + * NV_ENCODE_API_FUNCTION_LIST + */ +typedef struct _NV_ENCODE_API_FUNCTION_LIST +{ + uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */ + uint32_t reserved; /**< [in]: Reserved and should be set to 0. */ + PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */ + PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */ + PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/ + PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */ + PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */ + PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */ + PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */ + PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */ + PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */ + PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */ + PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */ + PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */ + PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */ + PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */ + PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */ + PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */ + PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */ + PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */ + PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */ + PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */ + PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */ + PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */ + PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */ + PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */ + PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */ + PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */ + PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */ + PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */ + PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */ + PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */ + PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */ + PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */ + PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */ + void* reserved1; + PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */ + PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */ + PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */ + void* reserved2[281]; /**< [in]: Reserved and must be set to NULL */ +} NV_ENCODE_API_FUNCTION_LIST; + +/** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */ +#define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2) + +// NvEncodeAPICreateInstance +/** + * \ingroup ENCODE_FUNC + * Entry Point to the NvEncodeAPI interface. + * + * Creates an instance of the NvEncodeAPI interface, and populates the + * pFunctionList with function pointers to the API routines implemented by the + * NvEncodeAPI interface. + * + * \param [out] functionList + * + * \return + * ::NV_ENC_SUCCESS + * ::NV_ENC_ERR_INVALID_PTR + */ +NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList); + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/configure b/configure index 12158dd9c..7476ca885 100755 --- a/configure +++ b/configure @@ -108,7 +108,6 @@ Configuration options: --enable-gray enable full grayscale support (slower color) --disable-swscale-alpha disable alpha channel support in swscale --disable-all disable building components, libraries and programs - --enable-incompatible-libav-abi enable incompatible Libav fork ABI [no] --enable-raise-major increase major version numbers in sonames [no] Program options: @@ -225,7 +224,6 @@ External library support: and libraw1394 [no] --enable-libebur128 enable libebur128 for EBU R128 measurement, needed for loudnorm filter [no] - --enable-libfaac enable AAC encoding via libfaac [no] --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no] --enable-libflite enable flite (voice synthesis) support via libflite [no] --enable-libfontconfig enable libfontconfig, useful for drawtext filter [no] @@ -245,6 +243,7 @@ External library support: --enable-libopencv enable video filtering via libopencv [no] --enable-libopenh264 enable H.264 encoding via OpenH264 [no] --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no] + --enable-libopenmpt enable decoding tracked files via libopenmpt [no] --enable-libopus enable Opus de/encoding via libopus [no] --enable-libpulse enable Pulseaudio input via libpulse [no] --enable-librubberband enable rubberband needed for rubberband filter [no] @@ -290,7 +289,7 @@ External library support: if gnutls is not used [no] --disable-schannel disable SChannel SSP, needed for TLS support on Windows if openssl and gnutls are not used [autodetect] - --disable-sdl disable sdl [autodetect] + --disable-sdl2 disable sdl2 [autodetect] --disable-securetransport disable Secure Transport, needed for TLS support on OSX if openssl and gnutls are not used [autodetect] --enable-x11grab enable X11 grabbing (legacy) [no] @@ -306,7 +305,7 @@ External library support: --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] --enable-libnpp enable Nvidia Performance Primitives-based code [no] --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] - --enable-nvenc enable Nvidia video encoding code [no] + --disable-nvenc disable Nvidia video encoding code [autodetect] --enable-omx enable OpenMAX IL code [no] --enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no] --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] @@ -984,7 +983,7 @@ check_ld(){ check_$type $($cflags_filter $flags) || return flags=$($ldflags_filter $flags) libs=$($ldflags_filter $libs) - check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs + check_cmd $ld $LDFLAGS $LDEXEFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs } print_include(){ @@ -1447,14 +1446,15 @@ COMPONENT_LIST=" " EXAMPLE_LIST=" - avio_reading_example avio_dir_cmd_example + avio_reading_example decoding_encoding_example demuxing_decoding_example extract_mvs_example filter_audio_example filtering_audio_example filtering_video_example + http_multiclient_example metadata_example muxing_example qsvdec_example @@ -1486,7 +1486,6 @@ EXTERNAL_LIBRARY_LIST=" libcelt libdc1394 libebur128 - libfaac libfdk_aac libflite libfontconfig @@ -1505,6 +1504,7 @@ EXTERNAL_LIBRARY_LIST=" libopencv libopenh264 libopenjpeg + libopenmpt libopus libpulse librtmp @@ -1546,6 +1546,7 @@ EXTERNAL_LIBRARY_LIST=" openssl schannel sdl + sdl2 securetransport videotoolbox x11grab @@ -1644,7 +1645,6 @@ CONFIG_LIST=" $PROGRAM_LIST $SUBSYSTEM_LIST fontconfig - incompatible_libav_abi memalign_hack memory_poisoning neon_clobber_test @@ -1797,7 +1797,6 @@ HAVE_LIST_CMDLINE=" HAVE_LIST_PUB=" bigendian fast_unaligned - incompatible_libav_abi " HEADERS_LIST=" @@ -1919,6 +1918,7 @@ SYSTEM_FUNCS=" isatty jack_port_get_latency_range kbhit + LoadLibrary localtime_r lstat lzo1x_999_compress @@ -1935,7 +1935,6 @@ SYSTEM_FUNCS=" sched_getaffinity SetConsoleTextAttribute SetConsoleCtrlHandler - SetDllDirectory setmode setrlimit Sleep @@ -2019,7 +2018,7 @@ HAVE_LIST=" MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS perl pod2man - sdl + sdl2 section_data_rel_ro texi2html threads @@ -2212,6 +2211,8 @@ setend_deps="arm" map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM +loongson2_deps="mips" +loongson3_deps="mips" mipsfpu_deps="mips" mipsdsp_deps="mips" mipsdspr2_deps="mips" @@ -2545,17 +2546,19 @@ videotoolbox_hwaccel_deps="videotoolbox pthreads" videotoolbox_hwaccel_extralibs="-framework QuartzCore" xvmc_deps="X11_extensions_XvMClib_h" +h263_cuvid_hwaccel_deps="cuda cuvid" h263_vaapi_hwaccel_deps="vaapi" h263_vaapi_hwaccel_select="h263_decoder" h263_videotoolbox_hwaccel_deps="videotoolbox" h263_videotoolbox_hwaccel_select="h263_decoder" h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser" -h264_cuvid_hwaccel_deps="cuda cuvid CUVIDH264PICPARAMS" +h264_cuvid_hwaccel_deps="cuda cuvid" h264_d3d11va_hwaccel_deps="d3d11va" h264_d3d11va_hwaccel_select="h264_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" h264_mediacodec_decoder_deps="mediacodec" +h264_mediacodec_hwaccel_deps="mediacodec" h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser" h264_mmal_decoder_deps="mmal" h264_mmal_decoder_select="mmal" @@ -2576,9 +2579,12 @@ h264_vdpau_hwaccel_deps="vdpau" h264_vdpau_hwaccel_select="h264_decoder" h264_videotoolbox_hwaccel_deps="videotoolbox" h264_videotoolbox_hwaccel_select="h264_decoder" -hevc_cuvid_hwaccel_deps="cuda cuvid CUVIDHEVCPICPARAMS" +hevc_cuvid_hwaccel_deps="cuda cuvid" hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" +hevc_mediacodec_decoder_deps="mediacodec" +hevc_mediacodec_hwaccel_deps="mediacodec" +hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_qsv_hwaccel_deps="libmfx" @@ -2586,10 +2592,12 @@ hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" hevc_vaapi_hwaccel_select="hevc_decoder" hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" hevc_vdpau_hwaccel_select="hevc_decoder" +mjpeg_cuvid_hwaccel_deps="cuda cuvid" mpeg_vdpau_decoder_deps="vdpau" mpeg_vdpau_decoder_select="mpeg2video_decoder" mpeg_xvmc_hwaccel_deps="xvmc" mpeg_xvmc_hwaccel_select="mpeg2video_decoder" +mpeg1_cuvid_hwaccel_deps="cuda cuvid" mpeg1_vdpau_decoder_deps="vdpau" mpeg1_vdpau_decoder_select="mpeg1video_decoder" mpeg1_vdpau_hwaccel_deps="vdpau" @@ -2599,6 +2607,7 @@ mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder" mpeg1_xvmc_hwaccel_deps="xvmc" mpeg1_xvmc_hwaccel_select="mpeg1video_decoder" mpeg2_crystalhd_decoder_select="crystalhd" +mpeg2_cuvid_hwaccel_deps="cuda cuvid" mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" @@ -2617,6 +2626,9 @@ mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder" mpeg2_xvmc_hwaccel_deps="xvmc" mpeg2_xvmc_hwaccel_select="mpeg2video_decoder" mpeg4_crystalhd_decoder_select="crystalhd" +mpeg4_cuvid_hwaccel_deps="cuda cuvid" +mpeg4_mediacodec_decoder_deps="mediacodec" +mpeg4_mediacodec_hwaccel_deps="mediacodec" mpeg4_mmal_decoder_deps="mmal" mpeg4_mmal_decoder_select="mmal" mpeg4_mmal_hwaccel_deps="mmal" @@ -2631,7 +2643,7 @@ mpeg4_videotoolbox_hwaccel_deps="videotoolbox" mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" msmpeg4_crystalhd_decoder_select="crystalhd" vc1_crystalhd_decoder_select="crystalhd" -vc1_cuvid_hwaccel_deps="cuda cuvid CUVIDVC1PICPARAMS" +vc1_cuvid_hwaccel_deps="cuda cuvid" vc1_d3d11va_hwaccel_deps="d3d11va" vc1_d3d11va_hwaccel_select="vc1_decoder" vc1_dxva2_hwaccel_deps="dxva2" @@ -2647,12 +2659,16 @@ vc1_vdpau_decoder_deps="vdpau" vc1_vdpau_decoder_select="vc1_decoder" vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" -vp8_cuvid_hwaccel_deps="cuda cuvid CUVIDVP9PICPARAMS" -vp9_cuvid_hwaccel_deps="cuda cuvid CUVIDVP9PICPARAMS" +vp8_cuvid_hwaccel_deps="cuda cuvid" +vp9_cuvid_hwaccel_deps="cuda cuvid" +vp8_mediacodec_decoder_deps="mediacodec" +vp8_mediacodec_hwaccel_deps="mediacodec" vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" vp9_d3d11va_hwaccel_select="vp9_decoder" vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" vp9_dxva2_hwaccel_select="vp9_decoder" +vp9_mediacodec_decoder_deps="mediacodec" +vp9_mediacodec_hwaccel_deps="mediacodec" vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9" vp9_vaapi_hwaccel_select="vp9_decoder" wmv3_crystalhd_decoder_select="crystalhd" @@ -2672,8 +2688,11 @@ vaapi_encode_deps="vaapi" hwupload_cuda_filter_deps="cuda" scale_npp_filter_deps="cuda libnpp" +nvenc_deps_any="dlopen LoadLibrary" nvenc_encoder_deps="nvenc" -h264_cuvid_decoder_deps="cuda cuvid CUVIDH264PICPARAMS" +h263_cuvid_decoder_deps="cuda cuvid" +h263_cuvid_decoder_select="h263_cuvid_hwaccel" +h264_cuvid_decoder_deps="cuda cuvid" h264_cuvid_decoder_select="h264_mp4toannexb_bsf h264_cuvid_hwaccel" h264_nvenc_encoder_deps="nvenc" h264_qsv_decoder_deps="libmfx" @@ -2683,7 +2702,7 @@ h264_qsv_encoder_select="qsvenc" h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264" h264_vaapi_encoder_select="vaapi_encode golomb" -hevc_cuvid_decoder_deps="cuda cuvid CUVIDHEVCPICPARAMS" +hevc_cuvid_decoder_deps="cuda cuvid" hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf hevc_cuvid_hwaccel" hevc_nvenc_encoder_deps="nvenc" hevc_qsv_decoder_deps="libmfx" @@ -2692,18 +2711,26 @@ hevc_qsv_encoder_deps="libmfx" hevc_qsv_encoder_select="qsvenc" hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC" hevc_vaapi_encoder_select="vaapi_encode golomb" +mjpeg_cuvid_decoder_deps="cuda cuvid" +mjpeg_cuvid_decoder_select="mjpeg_cuvid_hwaccel" +mpeg1_cuvid_decoder_deps="cuda cuvid" +mpeg1_cuvid_decoder_select="mpeg1_cuvid_hwaccel" +mpeg2_cuvid_decoder_deps="cuda cuvid" +mpeg2_cuvid_decoder_select="mpeg2_cuvid_hwaccel" mpeg2_qsv_decoder_deps="libmfx" mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel" mpeg2_qsv_encoder_deps="libmfx" mpeg2_qsv_encoder_select="qsvenc" +mpeg4_cuvid_decoder_deps="cuda cuvid" +mpeg4_cuvid_decoder_select="mpeg4_cuvid_hwaccel" nvenc_h264_encoder_deps="nvenc" nvenc_hevc_encoder_deps="nvenc" -vc1_cuvid_decoder_deps="cuda cuvid CUVIDVC1PICPARAMS" +vc1_cuvid_decoder_deps="cuda cuvid" vc1_cuvid_decoder_select="vc1_cuvid_hwaccel" -vp8_cuvid_decoder_deps="cuda cuvid CUVIDVP9PICPARAMS" +vp8_cuvid_decoder_deps="cuda cuvid" vp8_cuvid_decoder_select="vp8_cuvid_hwaccel" -vp9_cuvid_decoder_deps="cuda cuvid CUVIDVP9PICPARAMS" +vp9_cuvid_decoder_deps="cuda cuvid" vp9_cuvid_decoder_select="vp9_cuvid_hwaccel" # parsers @@ -2747,8 +2774,6 @@ pcm_mulaw_at_encoder_select="audio_frame_queue" chromaprint_muxer_deps="chromaprint" h264_videotoolbox_encoder_deps="videotoolbox_encoder pthreads" libcelt_decoder_deps="libcelt" -libfaac_encoder_deps="libfaac" -libfaac_encoder_select="audio_frame_queue" libfdk_aac_decoder_deps="libfdk_aac" libfdk_aac_encoder_deps="libfdk_aac" libfdk_aac_encoder_select="audio_frame_queue" @@ -2767,9 +2792,12 @@ libopencore_amrnb_decoder_deps="libopencore_amrnb" libopencore_amrnb_encoder_deps="libopencore_amrnb" libopencore_amrnb_encoder_select="audio_frame_queue" libopencore_amrwb_decoder_deps="libopencore_amrwb" +libopenh264_decoder_deps="libopenh264" +libopenh264_decoder_select="h264_mp4toannexb_bsf" libopenh264_encoder_deps="libopenh264" libopenjpeg_decoder_deps="libopenjpeg" libopenjpeg_encoder_deps="libopenjpeg" +libopenmpt_demuxer_deps="libopenmpt" libopus_decoder_deps="libopus" libopus_encoder_deps="libopus" libopus_encoder_select="audio_frame_queue" @@ -2827,6 +2855,7 @@ dv_muxer_select="dvprofile" dxa_demuxer_select="riffdec" eac3_demuxer_select="ac3_parser" f4v_muxer_select="mov_muxer" +fifo_muxer_deps="threads" flac_demuxer_select="flac_parser" hds_muxer_select="flv_muxer" hls_muxer_select="mpegts_muxer" @@ -2855,6 +2884,7 @@ nut_muxer_select="riffenc" nuv_demuxer_select="riffdec" oga_muxer_select="ogg_muxer" ogg_demuxer_select="dirac_parse" +ogv_muxer_select="ogg_muxer" opus_muxer_select="ogg_muxer" psp_muxer_select="mov_muxer" rtp_demuxer_select="sdp_demuxer" @@ -2918,7 +2948,7 @@ pulse_indev_deps="libpulse" pulse_outdev_deps="libpulse" qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework QuartzCore" qtkit_indev_select="qtkit" -sdl_outdev_deps="sdl" +sdl2_outdev_deps="sdl2" sndio_indev_deps="sndio_h" sndio_outdev_deps="sndio_h" v4l_indev_deps="linux_videodev_h" @@ -3066,6 +3096,7 @@ tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" uspp_filter_deps="gpl avcodec" +vaguedenoiser_filter_deps="gpl" vidstabdetect_filter_deps="libvidstab" vidstabtransform_filter_deps="libvidstab" zmq_filter_deps="libzmq" @@ -3074,15 +3105,15 @@ zscale_filter_deps="libzimg" scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" # examples -avcodec_example_deps="avcodec avutil" -avio_dir_cmd="avformat avutil" -avio_reading="avformat avcodec avutil" +avio_dir_cmd_deps="avformat avutil" +avio_reading_deps="avformat avcodec avutil" decoding_encoding_example_deps="avcodec avformat avutil" demuxing_decoding_example_deps="avcodec avformat avutil" extract_mvs_example_deps="avcodec avformat avutil" filter_audio_example_deps="avfilter avutil" filtering_audio_example_deps="avfilter avcodec avformat avutil" filtering_video_example_deps="avfilter avcodec avformat avutil" +http_multiclient_example_deps="avformat avutil" metadata_example_deps="avformat avutil" muxing_example_deps="avcodec avformat avutil swscale" qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder vaapi_x11" @@ -3107,8 +3138,8 @@ ffmpeg_deps="avcodec avfilter avformat swresample" ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter null_filter setpts_filter trim_filter" -ffplay_deps="avcodec avformat swscale swresample sdl" -ffplay_libs='$sdl_libs' +ffplay_deps="avcodec avformat swscale swresample sdl2" +ffplay_libs='$sdl2_libs' ffplay_select="rdft crop_filter transpose_filter hflip_filter vflip_filter rotate_filter" ffprobe_deps="avcodec avformat" ffserver_deps="avformat fork sarestart" @@ -3149,6 +3180,7 @@ objformat="elf" pkg_config_default=pkg-config ranlib_default="ranlib" strip_default="strip" +version_script='--version-script' yasmexe_default="yasm" windres_default="windres" @@ -3194,7 +3226,7 @@ enable audiotoolbox enable d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc enable xlib -enable vda_framework videotoolbox videotoolbox_encoder +enable nvenc vda_framework videotoolbox videotoolbox_encoder # build settings SHFLAGS='-shared -Wl,-soname,$$(@F)' @@ -3210,6 +3242,7 @@ SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)' SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' +VERSION_SCRIPT_POSTPROCESS_CMD="cat" asflags_filter=echo cflags_filter=echo @@ -3545,6 +3578,8 @@ case "$toolchain" in add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 add_cflags -fno-strict-overflow -fstack-protector-all add_ldflags -Wl,-z,relro -Wl,-z,now + add_cflags -fPIE + add_ldexeflags -fPIE -pie ;; ?*) die "Unknown toolchain $toolchain" @@ -3794,11 +3829,11 @@ suncc_flags(){ westmere) echo -xtarget=westmere ;; silvermont) echo -xarch=sse4_2 ;; corei7-avx|sandybridge) echo -xtarget=sandybridge ;; - core-avx*|ivybridge|haswell|broadwell) + core-avx*|ivybridge|haswell|broadwell|skylake*|knl) echo -xarch=avx ;; amdfam10|barcelona) echo -xtarget=barcelona ;; btver1) echo -xarch=amdsse4a ;; - btver2|bdver*) echo -xarch=avx ;; + btver2|bdver*|znver*) echo -xarch=avx ;; athlon-4|athlon-[mx]p) echo -xarch=ssea ;; k8|opteron|athlon64|athlon-fx) echo -xarch=sse2a ;; @@ -4202,7 +4237,7 @@ case "$arch" in sh4|sh) arch="sh4" ;; - sun4u|sparc*) + sun4*|sparc*) arch="sparc" ;; tilegx|tile-gx) @@ -4350,6 +4385,9 @@ elif enabled mips; then enable fast_cmov enable fast_unaligned disable aligned_stack + disable mipsfpu + disable mipsdsp + disable mipsdspr2 case $cpu in loongson3*) cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations" @@ -4498,7 +4536,8 @@ elif enabled x86; then ;; # targets that do support nopl and conditional mov (cmov) i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\ - |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*) + |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|skylake*|knl\ + |amdfam10|barcelona|b[dt]ver*|znver*) cpuflags="-march=$cpu" enable i686 enable fast_cmov @@ -4632,7 +4671,8 @@ case $target_os in echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile nm_default='nm -P -g' - SLIB_CREATE_DEF_CMD='$(Q)perl $(SRC_PATH)/compat/solaris/make_sunver.pl $$(filter %.ver,$$^) $(OBJS) | grep -v @ > $(SUBDIR)lib$(NAME).ver-sol2' + version_script='-M' + VERSION_SCRIPT_POSTPROCESS_CMD='perl $(SRC_PATH)/compat/solaris/make_sunver.pl - $(OBJS)' ;; netbsd) disable symver @@ -4673,6 +4713,8 @@ case $target_os in { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; } check_header dispatch/dispatch.h && add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore' + version_script='-exported_symbols_list' + VERSION_SCRIPT_POSTPROCESS_CMD='tr " " "\n" | sed -n /global:/,/local:/p | grep ";" | tr ";" "\n" | sed -E "s/(.+)/_\1/g" | sed -E "s/(.+[^*])$$$$/\1*/"' ;; msys*) die "Native MSYS builds are discouraged, please use the MINGW environment." @@ -4770,6 +4812,7 @@ case $target_os in objformat="win32" enable dos_paths enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres + add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 ;; *-dos|freedos|opendos) network_extralibs="-lsocket" @@ -4907,6 +4950,8 @@ probe_libc(){ (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW32 runtime version must be >= 3.15." add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 + check_${pfx}cpp_condition _mingw.h "defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0502" || + add_${pfx}cppflags -D_WIN32_WINNT=0x0502 eval test \$${pfx_no_}cc_type = "gcc" && add_${pfx}cppflags -D__printf__=__gnu_printf__ elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then @@ -5034,7 +5079,6 @@ die_license_disabled gpl x11grab die_license_disabled nonfree cuda die_license_disabled nonfree cuvid -die_license_disabled nonfree libfaac die_license_disabled nonfree libnpp enabled gpl && die_license_disabled_gpl nonfree libfdk_aac enabled gpl && die_license_disabled_gpl nonfree openssl @@ -5361,9 +5405,9 @@ check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_ check_ldflags -Wl,--as-needed check_ldflags -Wl,-z,noexecstack -if check_func dlopen; then +if check_func dlopen && check_func dlsym; then ldl= -elif check_func dlopen -ldl; then +elif check_func dlopen -ldl && check_func dlsym -ldl; then ldl=-ldl fi @@ -5372,7 +5416,7 @@ decklink_indev_extralibs="$decklink_indev_extralibs $ldl" frei0r_filter_extralibs='$ldl' frei0r_src_filter_extralibs='$ldl' ladspa_filter_extralibs='$ldl' -nvenc_encoder_extralibs='$ldl' +nvenc_extralibs='$ldl' coreimage_filter_extralibs="-framework QuartzCore -framework AppKit -framework OpenGL" coreimagesrc_filter_extralibs="-framework QuartzCore -framework AppKit -framework OpenGL" @@ -5443,7 +5487,7 @@ check_func ${malloc_prefix}memalign && enable memalign check_func ${malloc_prefix}posix_memalign && enable posix_memalign check_func access -check_func arc4random +check_func_headers stdlib.h arc4random check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; } check_func fcntl check_func fork @@ -5476,11 +5520,11 @@ check_func_headers windows.h CoTaskMemFree -lole32 check_func_headers windows.h GetProcessAffinityMask check_func_headers windows.h GetProcessTimes check_func_headers windows.h GetSystemTimeAsFileTime +check_func_headers windows.h LoadLibrary check_func_headers windows.h MapViewOfFile check_func_headers windows.h PeekNamedPipe check_func_headers windows.h SetConsoleTextAttribute check_func_headers windows.h SetConsoleCtrlHandler -check_func_headers windows.h SetDllDirectory check_func_headers windows.h Sleep check_func_headers windows.h VirtualAlloc check_struct windows.h "CONDITION_VARIABLE" Ptr @@ -5542,11 +5586,6 @@ check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC" -check_type "cuviddec.h" "CUVIDH264PICPARAMS" -check_type "cuviddec.h" "CUVIDHEVCPICPARAMS" -check_type "cuviddec.h" "CUVIDVC1PICPARAMS" -check_type "cuviddec.h" "CUVIDVP9PICPARAMS" - check_cpp_condition windows.h "!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)" && enable winrt || disable winrt if ! disabled w32threads && ! enabled pthreads; then @@ -5624,14 +5663,16 @@ enabled avisynth && { { check_lib2 "windows.h" LoadLibrary; } || die "ERROR: LoadLibrary/dlopen not found for avisynth"; } enabled cuda && { check_lib cuda.h cuInit -lcuda || die "ERROR: CUDA not found"; } -enabled cuvid && { check_lib cuviddec.h cuvidCreateDecoder -lnvcuvid || +enabled cuvid && { add_cflags -I$source_path; + check_lib "compat/cuda/cuviddec.h" cuvidCreateDecoder -lnvcuvid || die "ERROR: CUVID not found"; } && { enabled cuda || die "ERROR: CUVID requires CUDA"; } enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint enabled coreimage_filter && { check_header_objcc QuartzCore/CoreImage.h || disable coreimage_filter; } enabled coreimagesrc_filter && { check_header_objcc QuartzCore/CoreImage.h || disable coreimagesrc_filter; } -enabled decklink && { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; } +enabled decklink && { { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; } && + { check_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR: Decklink API version must be >= 10.6.1."; } } enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } enabled gmp && require2 gmp gmp.h mpz_export -lgmp enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init @@ -5647,7 +5688,6 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } enabled libcaca && require_pkg_config caca caca.h caca_create_canvas enabled libebur128 && require ebur128 ebur128.h ebur128_relative_threshold -lebur128 -enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac enabled libfdk_aac && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && warn "using libfdk without pkg-config"; } } @@ -5681,6 +5721,7 @@ enabled libopenjpeg && { { check_lib2 openjpeg-2.1/openjpeg.h opj_version { check_lib2 openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || { check_lib2 openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || die "ERROR: libopenjpeg not found"; } +enabled libopenmpt && require_pkg_config "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket @@ -5761,10 +5802,6 @@ enabled mmal && { check_lib interface/mmal/mmal.h mmal_port_connect enabled mmal && check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS" enabled netcdf && require_pkg_config netcdf netcdf.h nc_inq_libvers -enabled nvenc && { check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."; } && - { check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 6" || - die "ERROR: NVENC API version 5 or older is not supported"; } && - { [ $target_os != cygwin ] || die "ERROR: NVENC is not supported on Cygwin currently."; } enabled openal && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } || die "ERROR: openal not found"; } && @@ -5788,7 +5825,8 @@ enabled omx && { check_header OMX_Core.h || add_cflags -isystem/opt/vc/include/IL ; } check_header OMX_Core.h ; } || die "ERROR: OpenMAX IL headers not found"; } -enabled openssl && { use_pkg_config openssl openssl/ssl.h SSL_library_init || +enabled openssl && { use_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl || + use_pkg_config openssl openssl/ssl.h SSL_library_init || check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || @@ -5817,31 +5855,27 @@ if enabled gcrypt; then fi fi -if ! disabled sdl; then - SDL_CONFIG="${cross_prefix}sdl-config" - if check_pkg_config sdl SDL_events.h SDL_PollEvent; then - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags && - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags && - enable sdl +disabled sdl && disable sdl2 +if ! disabled sdl2; then + SDL2_CONFIG="${cross_prefix}sdl2-config" + if check_pkg_config sdl2 SDL_events.h SDL_PollEvent; then + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags && + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags && + check_func SDL_Init $sdl2_libs $sdl2_cflags && enable sdl2 else - if "${SDL_CONFIG}" --version > /dev/null 2>&1; then - sdl_cflags=$("${SDL_CONFIG}" --cflags) - sdl_libs=$("${SDL_CONFIG}" --libs) - check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs && - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags && - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags && - enable sdl - elif enabled sdl ; then - die "ERROR: SDL not found" - else - disable sdl - fi + if "${SDL2_CONFIG}" --version > /dev/null 2>&1; then + sdl2_cflags=$("${SDL2_CONFIG}" --cflags) + sdl2_libs=$("${SDL2_CONFIG}" --libs) + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags && + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags && + check_func SDL_Init $sdl2_libs $sdl2_cflags && enable sdl2 + fi fi if test $target_os = "mingw32"; then - sdl_libs="$sdl_libs -mconsole" + sdl2_libs="$sdl2_libs -mconsole" fi fi -enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs +enabled sdl2 && add_cflags $sdl2_cflags && add_extralibs $sdl2_libs disabled securetransport || { check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" && check_lib2 "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" && @@ -5980,6 +6014,26 @@ enabled vdpau && enabled xlib && check_lib2 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau && enable vdpau_x11 +if enabled x86; then + case $target_os in + mingw32*|mingw64*|win32|win64|linux|cygwin*) + ;; + *) + disable nvenc + ;; + esac +else + disable nvenc +fi + +enabled nvenc && + check_cc -I$source_path < $TMPV -if test_ldflags -Wl,--version-script,$TMPV; then - append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' -elif test_ldflags -Wl,-M,$TMPV; then - append SHFLAGS '-Wl,-M,\$(SUBDIR)lib\$(NAME).ver-sol2' -fi +check_ld "cc" < $TMPV + if test_ldflags -Wl,${version_script},$TMPV; then + append SHFLAGS '-Wl,${version_script},\$(SUBDIR)lib\$(NAME).ver' + check_cc <