add libdav1d codec, add remap_a/v_codec option keywords
authorGood Guy <[email protected]>
Tue, 27 Aug 2019 03:59:56 +0000 (21:59 -0600)
committerGood Guy <[email protected]>
Tue, 27 Aug 2019 03:59:56 +0000 (21:59 -0600)
cinelerra-5.1/blds/PKGBUILD
cinelerra-5.1/blds/bld_prepare.sh
cinelerra-5.1/blds/cinelerra.spec
cinelerra-5.1/blds/debian/control
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/cinelerra/ffmpeg.h
cinelerra-5.1/configure.ac
cinelerra-5.1/ffmpeg/decode.opts
cinelerra-5.1/thirdparty/Makefile
cinelerra-5.1/thirdparty/src/dav1d-0.4.0.tar.xz [new file with mode: 0644]

index 4a5ba37cbac30a581e6aa1de861e79ab1d713364..95350e87d4414ee14e8d0638e4a6e003064820e8 100644 (file)
@@ -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=()
index 9c6f2dcdbbeccf378d895da099c727cc96c4d27d..801a71b83b2112e9cb56fb0c94da6e8332f99d34 100755 (executable)
@@ -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"
index 4091a115904cb6efc7f38f6bf1f5bd01386b0177..fe23c3d62520c4290c46ccbdfc50aba6db39eed8 100644 (file)
@@ -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}
index 25bd1e661318198890d3609bd8e1e80bd102242e..27e9d3f0c9c7560536f180662d9dd289fb634ca8 100644 (file)
@@ -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}
index 47c603f2f72feedc8429243dd4c7dd06f9783ab0..6d1f535b28f108c03fe0f836bf3773d3d6eb16eb 100644 (file)
@@ -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") )
index b4867b8eb1943879499d7a6ed33515d9533ff44f..9e17d8b9024fda0a7b135175d78c6eb41f532c8c 100644 (file)
@@ -259,6 +259,22 @@ public:
        int top_field_first;
 };
 
+class FFCodecRemap
+{
+public:
+       FFCodecRemap();
+       ~FFCodecRemap();
+       const char *old_codec, *new_codec;
+};
+
+class FFCodecRemaps : public ArrayList<FFCodecRemap>
+{
+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;
 
index 5abf6a65cc1cec4eb531bd5fff94f71e8918e294..a8098cbe4bc6234cb248d0118c4ccaa3c6c777f5 100644 (file)
@@ -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])
index fc4e1a56282b92eacde11effbbae2740834d0560..42945d54298091b5fe7ddf2a96e4836b8ee221f9 100644 (file)
@@ -2,3 +2,4 @@
 loglevel=fatal
 formatprobesize=5000000
 scan_all_pmts=1
+remap_video_decoder libaom-av1=libdav1d
index 42211838aae214e58238dc22604c8f8cfe250a8b..426f3c9f49b76df91af77e19c73c4ec95f049741 100644 (file)
@@ -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 (file)
index 0000000..05fde9a
Binary files /dev/null and b/cinelerra-5.1/thirdparty/src/dav1d-0.4.0.tar.xz differ