From: Good Guy Date: Tue, 27 Aug 2019 03:59:56 +0000 (-0600) Subject: add libdav1d codec, add remap_a/v_codec option keywords X-Git-Tag: 2019-08~4 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=b290324e67a45e465f2d0ad5d0ee662b64343339;p=goodguy%2Fcinelerra.git add libdav1d codec, add remap_a/v_codec option keywords --- diff --git a/cinelerra-5.1/blds/PKGBUILD b/cinelerra-5.1/blds/PKGBUILD index 4a5ba37c..95350e87 100644 --- a/cinelerra-5.1/blds/PKGBUILD +++ b/cinelerra-5.1/blds/PKGBUILD @@ -19,7 +19,7 @@ DEPENDS=( 'alsa-lib' 'atk' 'bzip2' 'cairo' 'expat' 'fftw' 'flac' 'xorg-fonts-misc' 'ttf-dejavu' 'inkscape' 'dvdauthor' 'udftools' ) makedepends=( 'autoconf' 'automake' 'yasm' 'nasm' 'cmake' 'libtool' - 'libxml2' 'perl-xml-libxml' 'perl-xml-parser' + 'libxml2' 'perl-xml-libxml' 'perl-xml-parser' 'meson' 'xorg-mkfontdir' 'xorg-mkfontscale' ) conflicts=() diff --git a/cinelerra-5.1/blds/bld_prepare.sh b/cinelerra-5.1/blds/bld_prepare.sh index 9c6f2dcd..801a71b8 100755 --- a/cinelerra-5.1/blds/bld_prepare.sh +++ b/cinelerra-5.1/blds/bld_prepare.sh @@ -27,7 +27,7 @@ case "$dir" in libsndfile-devel libtheora-devel linux-firmware ivtv-firmware \ libvorbis-devel texinfo xz-devel lzma-devel cmake udftools git \ autoconf automake rpm-build jbigkit-devel libvdpau-devel libva-devel \ - alsa-lib-devel gtk2-devel + alsa-lib-devel gtk2-devel meson yasm=yasm-1.3.0-3.fc24.x86_64.rpm release=http://archives.fedoraproject.org/pub/fedora/linux/releases/24 url=$release/Everything/x86_64/os/Packages/y/$yasm @@ -54,7 +54,8 @@ case "$dir" in ivtv-firmware libvorbis-devel texinfo xz-devel lzma-devel cmake git \ ctags patch gcc-c++ perl-XML-XPath libtiff-devel python dvdauthor \ gettext-devel inkscape udftools autoconf automake numactl-devel \ - jbigkit-devel libvdpau-devel libva-devel gtk2-devel mesa-vdpau-drivers + jbigkit-devel libvdpau-devel libva-devel gtk2-devel mesa-vdpau-drivers \ + meson ;; "suse" | "leap") zypper -n install nasm gcc gcc-c++ zlib-devel texinfo libpng16-devel \ @@ -66,7 +67,7 @@ case "$dir" in ilmbase-devel fftw3-devel libsndfile-devel libtheora-devel flac-devel \ libtiff-devel inkscape cmake patch libnuma-devel lzma-devel udftools git \ yasm autoconf automake rpm-build libjbig-devel libvdpau-devel libva-devel \ - gtk2-devel libusb-1_0-devel + gtk2-devel libusb-1_0-devel meson if [ ! -f /usr/lib64/libtermcap.so ]; then ln -s libtermcap.so.2 /usr/lib64/libtermcap.so fi @@ -80,7 +81,7 @@ case "$dir" in fonts-dejavu libopenexr-dev festival libfftw3-dev gdb libusb-1.0-0-dev \ libdc1394-22-dev libflac-dev libjbig-dev libvdpau-dev libva-dev \ inkscape libsndfile1-dev libtheora-dev cmake udftools libxml2-utils git \ - autoconf automake debhelper libgtk2.0-dev + autoconf automake debhelper libgtk2.0-dev meson ;; #"ub16-10") # apt-get -y install libx264-dev libx265-dev libvpx-dev libmjpegtools-dev @@ -92,7 +93,8 @@ case "$dir" in fonts-dejavu libopenexr-dev libavc1394-dev festival-dev fftw3-dev gdb \ libdc1394-22-dev libiec61883-dev libflac-dev libjbig-dev libusb-1.0-0-dev \ libvdpau-dev libva-dev libsndfile1-dev libtheora-dev cmake udftools \ - libxml2-utils git inkscape autoconf automake debhelper libgtk2.0-dev + libxml2-utils git inkscape autoconf automake debhelper libgtk2.0-dev \ + meson ;; *) echo "unknown os: $dir" diff --git a/cinelerra-5.1/blds/cinelerra.spec b/cinelerra-5.1/blds/cinelerra.spec index 4091a115..fe23c3d6 100644 --- a/cinelerra-5.1/blds/cinelerra.spec +++ b/cinelerra-5.1/blds/cinelerra.spec @@ -52,6 +52,7 @@ BuildRequires: udftools BuildRequires: gtk2-devel BuildRequires: libva-devel BuildRequires: libvdpau-devel +BuildRequires: meson %{?rhat:BuildRequires: alsa-lib-devel} %{?rhat:BuildRequires: bzip2-devel} %{?rhat:BuildRequires: xorg-x11-fonts-cyrillic} diff --git a/cinelerra-5.1/blds/debian/control b/cinelerra-5.1/blds/debian/control index 25bd1e66..27e9d3f0 100644 --- a/cinelerra-5.1/blds/debian/control +++ b/cinelerra-5.1/blds/debian/control @@ -12,7 +12,7 @@ Build-Depends: libpng-dev, libtool, libusb-1.0-0-dev, libva-dev, libvdpau-dev, libxft-dev, libxinerama-dev, libxml2-utils, libxv-dev, libz-dev, linux-firmware, nasm, texinfo, ttf-bitstream-vera, - udftools, xfonts-100dpi, xfonts-75dpi, yasm + udftools, xfonts-100dpi, xfonts-75dpi, yasm, meson Package: cin Depends: ${misc:Depends} diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index 47c603f2..6d1f535b 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -374,7 +374,21 @@ int FFStream::decode_activate() } while( ret >= 0 && st != 0 && !reading ) { AVCodecID codec_id = st->codecpar->codec_id; - AVCodec *decoder = avcodec_find_decoder(codec_id); + AVCodec *decoder = 0; + if( is_video() ) { + if( ffmpeg->opt_video_decoder ) + decoder = avcodec_find_decoder_by_name(ffmpeg->opt_video_decoder); + else + ffmpeg->video_codec_remaps.update(codec_id, decoder); + } + else if( is_audio() ) { + if( ffmpeg->opt_audio_decoder ) + decoder = avcodec_find_decoder_by_name(ffmpeg->opt_audio_decoder); + else + ffmpeg->audio_codec_remaps.update(codec_id, decoder); + } + if( !decoder ) + decoder = avcodec_find_decoder(codec_id); avctx = avcodec_alloc_context3(decoder); if( !avctx ) { eprintf(_("cant allocate codec context\n")); @@ -1547,6 +1561,8 @@ FFMPEG::FFMPEG(FileBase *file_base) opt_video_filter = 0; opt_audio_filter = 0; opt_hw_dev = 0; + opt_video_decoder = 0; + opt_audio_decoder = 0; fflags = 0; char option_path[BCTEXTLEN]; set_option_path(option_path, "%s", "ffmpeg.opts"); @@ -1992,6 +2008,45 @@ int FFMPEG::scan_options(const char *options, AVDictionary *&opts, AVStream *st) return ret; } +FFCodecRemap::FFCodecRemap() +{ + old_codec = 0; + new_codec = 0; +} +FFCodecRemap::~FFCodecRemap() +{ + delete [] old_codec; + delete [] new_codec; +} + +int FFCodecRemaps::add(const char *val) +{ + char old_codec[BCSTRLEN], new_codec[BCSTRLEN]; + if( sscanf(val, " %63[a-zA-z0-9_-] = %63[a-z0-9_-]", + &old_codec[0], &new_codec[0]) != 2 ) return 1; + FFCodecRemap &remap = append(); + remap.old_codec = cstrdup(old_codec); + remap.new_codec = cstrdup(new_codec); + return 0; +} + + +int FFCodecRemaps::update(AVCodecID &codec_id, AVCodec *&decoder) +{ + AVCodec *codec = avcodec_find_decoder(codec_id); + if( !codec ) return -1; + const char *name = codec->name; + FFCodecRemaps &map = *this; + int k = map.size(); + while( --k >= 0 && strcmp(map[k].old_codec, name) ); + if( k < 0 ) return 1; + const char *new_codec = map[k].new_codec; + codec = avcodec_find_decoder_by_name(new_codec); + if( !codec ) return -1; + decoder = codec; + return 0; +} + int FFMPEG::read_options(FILE *fp, const char *options, AVDictionary *&opts) { int ret = 0, no = 0; @@ -2008,6 +2063,14 @@ int FFMPEG::read_options(FILE *fp, const char *options, AVDictionary *&opts) if( !ret ) { if( !strcmp(key, "duration") ) opt_duration = strtod(val, 0); + else if( !strcmp(key, "video_decoder") ) + opt_video_decoder = cstrdup(val); + else if( !strcmp(key, "audio_decoder") ) + opt_audio_decoder = cstrdup(val); + else if( !strcmp(key, "remap_video_decoder") ) + video_codec_remaps.add(val); + else if( !strcmp(key, "remap_audio_decoder") ) + audio_codec_remaps.add(val); else if( !strcmp(key, "video_filter") ) opt_video_filter = cstrdup(val); else if( !strcmp(key, "audio_filter") ) diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h index b4867b8e..9e17d8b9 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.h +++ b/cinelerra-5.1/cinelerra/ffmpeg.h @@ -259,6 +259,22 @@ public: int top_field_first; }; +class FFCodecRemap +{ +public: + FFCodecRemap(); + ~FFCodecRemap(); + const char *old_codec, *new_codec; +}; + +class FFCodecRemaps : public ArrayList +{ +public: + FFCodecRemaps() {} + int add(const char *val); + int update(AVCodecID &codec_id, AVCodec *&decoder); +}; + class FFMPEG : public Thread { public: static Mutex fflock; @@ -329,6 +345,10 @@ public: char *opt_video_filter; char *opt_audio_filter; char *opt_hw_dev; + char *opt_video_decoder; + char *opt_audio_decoder; + FFCodecRemaps video_codec_remaps; + FFCodecRemaps audio_codec_remaps; char file_format[BCTEXTLEN]; int fflags; diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac index 5abf6a65..a8098cbe 100644 --- a/cinelerra-5.1/configure.ac +++ b/cinelerra-5.1/configure.ac @@ -411,6 +411,11 @@ PKG_3RD([libaom],[auto], [ usr/local/lib*/libaom*.a ], [ usr/local/include ]) +PKG_3RD([dav1d],[auto], + [dav1d-0.4.0], + [ usr/local/lib*/libdav1d*.a ], + [ usr/local/include ]) + PKG_3RD([libwebp],[auto], [libwebp-1.0.2], [ usr/local/lib*/libwebp*.a ], @@ -579,6 +584,8 @@ CHECK_LIB([opus], [opus], [opus_multistream_decoder_create]) CHECK_HEADERS([opus], [libopus headers], [opus/opus_multistream.h]) CHECK_LIB([libaom], [aom], [aom_codec_version]) CHECK_HEADERS([libaom], [libaom headers], [aom/aom.h]) +CHECK_LIB([dav1d], [dav1d], [dav1d_version]) +CHECK_HEADERS([dav1d], [libdav1d headers], [dav1d/dav1d.h]) CHECK_LIB([libwebp], [webp], [WebPGetEncoderVersion]) CHECK_HEADERS([libwebp], [libwebp headers], [webp/encode.h]) CHECK_LIB([a52dec], [a52], [a52_init]) @@ -827,6 +834,7 @@ PKG_PROVIDE([libuuid]) PKG_PROVIDE([libvorbis]) PKG_PROVIDE([mjpegtools]) PKG_PROVIDE([libaom]) +PKG_PROVIDE([dav1d]) PKG_PROVIDE([libwebp]) PKG_PROVIDE([openexr], [$WANT_OPENEXR]) PKG_PROVIDE([openjpeg]) diff --git a/cinelerra-5.1/ffmpeg/decode.opts b/cinelerra-5.1/ffmpeg/decode.opts index fc4e1a56..42945d54 100644 --- a/cinelerra-5.1/ffmpeg/decode.opts +++ b/cinelerra-5.1/ffmpeg/decode.opts @@ -2,3 +2,4 @@ loglevel=fatal formatprobesize=5000000 scan_all_pmts=1 +remap_video_decoder libaom-av1=libdav1d diff --git a/cinelerra-5.1/thirdparty/Makefile b/cinelerra-5.1/thirdparty/Makefile index 42211838..426f3c9f 100644 --- a/cinelerra-5.1/thirdparty/Makefile +++ b/cinelerra-5.1/thirdparty/Makefile @@ -118,6 +118,7 @@ ffmpeg.cfg_params= \ $(call if_pkg,openjpeg,--enable-libopenjpeg) \ $(call if_pkg,lame,--enable-libmp3lame) \ $(call if_pkg,libaom,--enable-libaom) \ + $(call if_pkg,dav1d,--enable-libdav1d) \ $(call if_pkg,libwebp,--enable-libwebp) \ $(call if_pkg,opus,--enable-libopus) \ $(call if_pkg,libvorbis,--enable-libvorbis) \ @@ -130,6 +131,7 @@ ffmpeg.cfg_params= \ $(call inc_path,twolame,libtwolame) \ $(call inc_path,lame,include) \ $(call inc_path,libaom,usr/local/include) \ + $(call inc_path,dav1d,usr/local/include) \ $(call inc_path,libwebp,usr/local/include) \ $(call inc_path,openjpeg,src/lib/openjp2) \ $(call inc_path,libogg,include) \ @@ -146,6 +148,7 @@ ffmpeg.cfg_params= \ $(call ld_path,twolame,libtwolame/.libs) \ $(call ld_path,lame,libmp3lame/.libs) \ $(call ld_path,libaom,usr/local/lib) \ + $(call ld_path,dav1d,usr/local/lib) \ $(call ld_path,libwebp,usr/local/lib) \ $(call ld_path,openjpeg,bin) \ $(call ld_path,opus,.libs) \ @@ -182,6 +185,9 @@ libaom.cfg_vars?=$(call cmake_config,aom-master) libaom.cfg_params?= -DENABLE_SHARED=no -DCMAKE_INSTALL_LIBDIR=lib \ -DCMAKE_INSTALL_PREFIX=$(call bld_path,libaom)/usr/local libaom.mak_params?= ; $(MAKE) -C libaom* install +dav1d.cfg_vars?=echo "meson build --buildtype release --default-library=both" > configure; chmod +x ./configure; +dav1d.mak_vars?=(echo "all:"; echo " ninja -C build") > $(call bld_path,dav1d)/Makefile; +dav1d.mak_params?=; cd "$(call bld_path,dav1d)"; DESTDIR="$(call bld_path,dav1d)" meson install -C build libwebp.cfg_vars?= mkdir build && cd build && $(call cmake_config,..) libwebp.mak_params?= -C build all install DESTDIR=$(call bld_path,libwebp) mjpegtools.cflags?="$(call inc_path,libjpeg) $(call ld_path,libjpeg,.libs)" @@ -292,7 +298,7 @@ $(call rules,$(call std-build,audiofile)) $(call rules,$(call std-build,encore)) $(call rules,$(call std-build,esound,audiofile)) $(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus \ - libtheora x264 x265 libvpx libaom libwebp \ + libtheora x264 x265 libvpx libaom dav1d libwebp \ $(if $(WANT_NV), ffnvcodec))) $(call rules,$(call std-build,fftw)) $(call rules,$(call std-build,flac,libogg)) @@ -301,6 +307,7 @@ $(call rules,$(call std-build,ilmbase)) $(call rules,$(call std-build,ladspa)) $(call rules,$(call std-build,lame)) $(call rules,$(call std-build,libaom)) +$(call rules,$(call std-build,dav1d)) $(call rules,$(call std-build,libwebp)) $(call rules,$(call std-build,libavc1394,libraw1394)) $(call rules,$(call std-build,libdv)) diff --git a/cinelerra-5.1/thirdparty/src/dav1d-0.4.0.tar.xz b/cinelerra-5.1/thirdparty/src/dav1d-0.4.0.tar.xz new file mode 100644 index 00000000..05fde9a1 Binary files /dev/null and b/cinelerra-5.1/thirdparty/src/dav1d-0.4.0.tar.xz differ